当前位置: 首页>>代码示例>>Java>>正文


Java ByteStreams.newDataInput方法代码示例

本文整理汇总了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;
        }
    }
}
 
开发者ID:Dytanic,项目名称:CloudNet,代码行数:25,代码来源:ProxiedListener.java

示例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.");
		}
	}
}
 
开发者ID:smessie,项目名称:SkyWarsReloaded,代码行数:21,代码来源:SkyWarsReloaded.java

示例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);
        });
    }
}
 
开发者ID:Shynixn,项目名称:BlockBall,代码行数:18,代码来源:BungeeCordProvider.java

示例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(", "));
}
 
开发者ID:EverCraft,项目名称:ServerConnect,代码行数:12,代码来源:MessageBungee.java

示例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;
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:12,代码来源:HiveSubScan.java

示例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);
			}
		}
    }
	
}
 
开发者ID:EverCraft,项目名称:SayNoToMcLeaks,代码行数:30,代码来源:ManagerBungee.java

示例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);
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:30,代码来源:ClassPatchManager.java

示例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;
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:16,代码来源:Mutation.java

示例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();
    }
}
 
开发者ID:lucko,项目名称:helper,代码行数:43,代码来源:BungeeMessaging.java

示例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));
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:6,代码来源:CommitTransactionPayload.java


注:本文中的com.google.common.io.ByteStreams.newDataInput方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。