本文整理汇总了Java中com.google.common.io.ByteStreams.newDataInput方法的典型用法代码示例。如果您正苦于以下问题:Java ByteStreams.newDataInput方法的具体用法?Java ByteStreams.newDataInput怎么用?Java ByteStreams.newDataInput使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.common.io.ByteStreams
的用法示例。
在下文中一共展示了ByteStreams.newDataInput方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: handleChannel
import com.google.common.io.ByteStreams; //导入方法依赖的package包/类
@EventHandler
public void handleChannel(PluginMessageEvent pluginMessageEvent)
{
if(!(pluginMessageEvent.getReceiver() instanceof ProxiedPlayer)) return;
if(pluginMessageEvent.getTag().equalsIgnoreCase("CloudNet"))
{
ByteArrayDataInput byteArrayDataInput = ByteStreams.newDataInput(pluginMessageEvent.getData());
switch (byteArrayDataInput.readUTF().toLowerCase())
{
case "connect":
List<String> servers = CloudProxy.getInstance().getServers(byteArrayDataInput.readUTF()); if(servers.size() == 0) return;
((ProxiedPlayer)pluginMessageEvent.getReceiver()).connect(ProxyServer.getInstance().getServerInfo(servers.get(NetworkUtils.RANDOM.nextInt(servers.size()))));
break;
case "fallback":
((ProxiedPlayer)pluginMessageEvent.getReceiver()).connect(ProxyServer.getInstance()
.getServerInfo(CloudProxy.getInstance()
.fallback(((ProxiedPlayer)pluginMessageEvent.getReceiver()))));
break;
case "command":
ProxyServer.getInstance().getPluginManager().dispatchCommand(((ProxiedPlayer)pluginMessageEvent.getReceiver()), byteArrayDataInput.readUTF());
break;
}
}
}
示例2: onPluginMessageReceived
import com.google.common.io.ByteStreams; //导入方法依赖的package包/类
public void onPluginMessageReceived(String channel, Player player, byte[] message) {
if (!channel.equals("BungeeCord")) {
return;
}
ByteArrayDataInput in = ByteStreams.newDataInput(message);
String subchannel = in.readUTF();
if (subchannel.equals("SkyWarsReloadedRequest")) {
short len = in.readShort();
byte[] msgbytes = new byte[len];
in.readFully(msgbytes);
Game game = gc.getGame(1);
if (game != null) {
BungeeUtil.sendSignUpdateRequest(game);
} else {
System.out.println("Game " + game + " couldn't be found, please fix your setup.");
}
}
}
示例3: onPluginMessageReceived
import com.google.common.io.ByteStreams; //导入方法依赖的package包/类
@Override
public void onPluginMessageReceived(String channel, Player player, byte[] message) {
if (!channel.equals("BungeeCord")) {
return;
}
final ByteArrayDataInput in = ByteStreams.newDataInput(message);
final String type = in.readUTF();
if (type.equals("ServerIP")) {
final String serverName = in.readUTF();
final String ip = in.readUTF();
final short port = in.readShort();
this.plugin.getServer().getScheduler().runTaskAsynchronously(this.plugin, () -> {
final String data = BungeeCordProvider.this.receiveResultFromServer(serverName, ip, port);
BungeeCordProvider.this.parseData(serverName, data);
});
}
}
示例4: onPluginMessageReceived
import com.google.common.io.ByteStreams; //导入方法依赖的package包/类
@Override
public void onPluginMessageReceived(String channel, Player player, byte[] message) {
if (!channel.equals(CHANNEL_BUNGEE)) return;
ByteArrayDataInput in = ByteStreams.newDataInput(message);
String subchannel = in.readUTF();
if (!subchannel.equals(GET_SERVERS)) return;
this.plugin.setServers(in.readUTF().split(", "));
}
示例5: deserializeInputSplit
import com.google.common.io.ByteStreams; //导入方法依赖的package包/类
public static InputSplit deserializeInputSplit(String base64, String className) throws IOException, ReflectiveOperationException{
Constructor<?> constructor = Class.forName(className).getDeclaredConstructor();
if (constructor == null) {
throw new ReflectiveOperationException("Class " + className + " does not implement a default constructor.");
}
constructor.setAccessible(true);
InputSplit split = (InputSplit) constructor.newInstance();
ByteArrayDataInput byteArrayDataInput = ByteStreams.newDataInput(Base64.decodeBase64(base64));
split.readFields(byteArrayDataInput);
return split;
}
示例6: onPluginMessageReceived
import com.google.common.io.ByteStreams; //导入方法依赖的package包/类
@SuppressWarnings("deprecation")
@Override
public void onPluginMessageReceived(String channel, Player player, byte[] message) {
if (!channel.equals(BungeeSayNoToMcLeaks.CHANNEL)) return;
ByteArrayDataInput in = ByteStreams.newDataInput(message);
String subchannel = in.readUTF();
if (subchannel.equals(BungeeSayNoToMcLeaks.SUBCHANNEL)) {
final String name = in.readUTF();
final boolean result = in.readBoolean();
// S'il est déjà connu
if (this.caches.getIfPresent(name) != null) return;
this.caches.put(name, result);
// Si les 2 IP correspondent
if (result) {
this.plugin.debug("The player " + name + " doesn't use alt account.");
// Les 2 IP ne correspondent pas
} else {
// Si le joueur est déjà connecté
if (this.plugin.getServer().getPlayer(name) != null) {
this.executeCommands(name, 100);
}
}
}
}
示例7: readPatch
import com.google.common.io.ByteStreams; //导入方法依赖的package包/类
private ClassPatch readPatch(JarEntry patchEntry, JarInputStream jis)
{
if (DEBUG)
FMLRelaunchLog.finer("Reading patch data from %s", patchEntry.getName());
ByteArrayDataInput input;
try
{
input = ByteStreams.newDataInput(ByteStreams.toByteArray(jis));
}
catch (IOException e)
{
FMLRelaunchLog.log(Level.WARN, e, "Unable to read binpatch file %s - ignoring", patchEntry.getName());
return null;
}
String name = input.readUTF();
String sourceClassName = input.readUTF();
String targetClassName = input.readUTF();
boolean exists = input.readBoolean();
int inputChecksum = 0;
if (exists)
{
inputChecksum = input.readInt();
}
int patchLength = input.readInt();
byte[] patchBytes = new byte[patchLength];
input.readFully(patchBytes);
return new ClassPatch(name, sourceClassName, targetClassName, exists, inputChecksum, patchBytes);
}
示例8: getClusterIds
import com.google.common.io.ByteStreams; //导入方法依赖的package包/类
/**
* @return the set of clusterIds that have consumed the mutation
*/
public List<UUID> getClusterIds() {
List<UUID> clusterIds = new ArrayList<UUID>();
byte[] bytes = getAttribute(CONSUMED_CLUSTER_IDS);
if(bytes != null) {
ByteArrayDataInput in = ByteStreams.newDataInput(bytes);
int numClusters = in.readInt();
for(int i=0; i<numClusters; i++){
clusterIds.add(new UUID(in.readLong(), in.readLong()));
}
}
return clusterIds;
}
示例9: onPluginMessageReceived
import com.google.common.io.ByteStreams; //导入方法依赖的package包/类
@Override
public void onPluginMessageReceived(String channel, Player player, byte[] data) {
if (!channel.equals(CHANNEL)) {
return;
}
ByteArrayInputStream inputStream = new ByteArrayInputStream(data);
ByteArrayDataInput in = ByteStreams.newDataInput(inputStream);
String subChannel = in.readUTF();
// exclude the first value from the input stream
inputStream.mark(/* ignored */ 0);
lock.lock();
try {
Iterator<MessageCallback> it = listeners.iterator();
while (it.hasNext()) {
MessageCallback e = it.next();
if (!e.getSubChannel().equals(subChannel)) {
continue;
}
inputStream.reset();
boolean accepted = e.test(player, in);
if (!accepted) {
continue;
}
inputStream.reset();
boolean shouldRemove = e.accept(player, in);
if (shouldRemove) {
it.remove();
}
}
} finally {
lock.unlock();
}
}
示例10: getCandidate
import com.google.common.io.ByteStreams; //导入方法依赖的package包/类
public Entry<TransactionIdentifier, DataTreeCandidate> getCandidate() throws IOException {
final DataInput in = ByteStreams.newDataInput(serialized);
return new SimpleImmutableEntry<>(TransactionIdentifier.readFrom(in),
DataTreeCandidateInputOutput.readDataTreeCandidate(in));
}