當前位置: 首頁>>代碼示例>>Java>>正文


Java ByteArrayDataInput類代碼示例

本文整理匯總了Java中com.google.common.io.ByteArrayDataInput的典型用法代碼示例。如果您正苦於以下問題:Java ByteArrayDataInput類的具體用法?Java ByteArrayDataInput怎麽用?Java ByteArrayDataInput使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


ByteArrayDataInput類屬於com.google.common.io包,在下文中一共展示了ByteArrayDataInput類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: handleChannel

import com.google.common.io.ByteArrayDataInput; //導入依賴的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.ByteArrayDataInput; //導入依賴的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.ByteArrayDataInput; //導入依賴的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: onPluginMessage

import com.google.common.io.ByteArrayDataInput; //導入依賴的package包/類
@EventHandler
public void onPluginMessage(PluginMessageEvent e) {
    if (!e.getTag().equals(CHANNEL)) {
        return;
    }

    e.setCancelled(true);

    if (e.getSender() instanceof ProxiedPlayer) {
        return;
    }

    ByteArrayDataInput in = ByteStreams.newDataInput(e.getData());
    String msg = in.readUTF();

    onMessage(msg, u -> {
        // Forward to other servers
        this.plugin.getScheduler().doAsync(() -> sendMessage(u));
    });
}
 
開發者ID:lucko,項目名稱:LuckPerms,代碼行數:21,代碼來源:BungeeMessagingService.java

示例5: constant

import com.google.common.io.ByteArrayDataInput; //導入依賴的package包/類
/**
 * Reads a constant value at the given index, which must be one of CONSTANT_String_info,
 * CONSTANT_Integer_info, CONSTANT_Float_info, CONSTANT_Long_info, or CONSTANT_Double_info.
 */
Const.Value constant(int index) {
  ByteArrayDataInput reader = byteReader.seek(constantPool[index - 1]);
  byte tag = reader.readByte();
  switch (tag) {
    case CONSTANT_LONG:
      return new Const.LongValue(reader.readLong());
    case CONSTANT_FLOAT:
      return new Const.FloatValue(reader.readFloat());
    case CONSTANT_DOUBLE:
      return new Const.DoubleValue(reader.readDouble());
    case CONSTANT_INTEGER:
      return new Const.IntValue(reader.readInt());
    case CONSTANT_STRING:
      return new Const.StringValue(utf8(reader.readUnsignedShort()));
    default:
      throw new AssertionError(String.format("bad tag: %x", tag));
  }
}
 
開發者ID:google,項目名稱:turbine,代碼行數:23,代碼來源:ConstantPoolReader.java

示例6: onPluginMessageReceived

import com.google.common.io.ByteArrayDataInput; //導入依賴的package包/類
@Override
public void onPluginMessageReceived(String channel, Player p, byte[] message) {
	if (channel.equals(incomingChannel)) {
		ByteArrayDataInput in = ByteStreams.newDataInput(message);
		String subchannel = in.readUTF();

		if (subchannel.equals("AutoLogin")) {
			Player player = Bukkit.getPlayer(in.readUTF());

			if (player != null) {
				if (!xauth.getPlayerManager().getPlayer(player.getName()).isAuthenticated()) {
					xauth.getPlayerManager().doLogin(xauth.getPlayerManager().getPlayer(player));
					if (!autoLoginMessage.isEmpty())
						player.sendMessage(autoLoginMessage);
				}
			}
		}
	}
}
 
開發者ID:CryLegend,項目名稱:AuthMeBridge,代碼行數:20,代碼來源:xAuthBridge.java

示例7: onPluginMessageReceived

import com.google.common.io.ByteArrayDataInput; //導入依賴的package包/類
@Override
public void onPluginMessageReceived(String channel, Player p, byte[] message) {
	if (channel.equals(incomingChannel)) {
		ByteArrayDataInput in = ByteStreams.newDataInput(message);
		String subchannel = in.readUTF();

		if (subchannel.equals("AutoLogin")) {
			Player player = Bukkit.getPlayer(in.readUTF());

			if (player != null) {
				if (!fr.xephi.authme.api.NewAPI.getInstance().isAuthenticated(player)) {
					fr.xephi.authme.api.NewAPI.getInstance().forceLogin(player);
					if (!autoLoginMessage.isEmpty())
						player.sendMessage(autoLoginMessage);
				}
			}
		}
	}
}
 
開發者ID:CryLegend,項目名稱:AuthMeBridge,代碼行數:20,代碼來源:AuthMeBridge.java

示例8: getNext

import com.google.common.io.ByteArrayDataInput; //導入依賴的package包/類
@Override
public Tuple getNext() throws IOException {
    try {
        if (reader.nextKeyValue()) {
            Key key = (Key) reader.getCurrentKey();
            org.apache.accumulo.core.data.Value value = (org.apache.accumulo.core.data.Value) reader.getCurrentValue();
            ByteArrayDataInput input = ByteStreams.newDataInput(key.getRow().getBytes());
            RyaStatement ryaStatement = ryaContext.deserializeTriple(layout, new TripleRow(key.getRow().getBytes(),
                    key.getColumnFamily().getBytes(), key.getColumnQualifier().getBytes()));

            Tuple tuple = TupleFactory.getInstance().newTuple(7);
            tuple.set(0, ryaStatement.getSubject().getData());
            tuple.set(1, ryaStatement.getPredicate().getData());
            tuple.set(2, ryaStatement.getObject().getData());
            tuple.set(3, (ryaStatement.getContext() != null) ? (ryaStatement.getContext().getData()) : (null));
            tuple.set(4, ryaStatement.getSubject().getDataType());
            tuple.set(5, ryaStatement.getPredicate().getDataType());
            tuple.set(6, ryaStatement.getObject().getDataType());
            return tuple;
        }
    } catch (Exception e) {
        throw new IOException(e);
    }
    return null;
}
 
開發者ID:apache,項目名稱:incubator-rya,代碼行數:26,代碼來源:StatementPatternStorage.java

示例9: testSerialization

import com.google.common.io.ByteArrayDataInput; //導入依賴的package包/類
@Test
public void testSerialization() throws Exception
{
    Range<Token> full = new Range<>(tok(-1), tok(-1));

    // populate and validate the tree
    mt.maxsize(256);
    mt.init();
    for (TreeRange range : mt.invalids())
        range.addAll(new HIterator(range.right));

    byte[] initialhash = mt.hash(full);

    DataOutputBuffer out = new DataOutputBuffer();
    MerkleTree.serializer.serialize(mt, out, MessagingService.current_version);
    byte[] serialized = out.toByteArray();

    ByteArrayDataInput in = ByteStreams.newDataInput(serialized);
    MerkleTree restored = MerkleTree.serializer.deserialize(in, MessagingService.current_version);

    assertHashEquals(initialhash, restored.hash(full));
}
 
開發者ID:vcostet,項目名稱:cassandra-kmean,代碼行數:23,代碼來源:MerkleTreeTest.java

示例10: testSerialization

import com.google.common.io.ByteArrayDataInput; //導入依賴的package包/類
@Test
public void testSerialization() throws Exception
{
    Range<Token> full = new Range<>(tok(-1), tok(-1));

    // populate and validate the tree
    mt.maxsize(256);
    mt.init();
    for (TreeRange range : mt.invalids())
        range.addAll(new HIterator(range.right));

    byte[] initialhash = mt.hash(full);

    ByteArrayDataOutput out = ByteStreams.newDataOutput();
    MerkleTree.serializer.serialize(mt, out, MessagingService.current_version);
    byte[] serialized = out.toByteArray();

    ByteArrayDataInput in = ByteStreams.newDataInput(serialized);
    MerkleTree restored = MerkleTree.serializer.deserialize(in, MessagingService.current_version);

    assertHashEquals(initialhash, restored.hash(full));
}
 
開發者ID:pgaref,項目名稱:ACaZoo,代碼行數:23,代碼來源:MerkleTreeTest.java

示例11: readPermissionRequest

import com.google.common.io.ByteArrayDataInput; //導入依賴的package包/類
/**
 * Reads a permission request.
 */
public static PermissionRequest readPermissionRequest(
		Player player, byte[] data) {
	ByteArrayDataInput input = ByteStreams.newDataInput(data);
	
	String requestReason = input.readUTF();
	
	Map<String, String> requestedPerms = new HashMap<>();
	int numRequests = input.readInt();
	for (int i = 0; i < numRequests; i++) {
		String key = input.readUTF();
		String value = input.readUTF();
		
		requestedPerms.put(key, value);
	}
	
	List<ProtectionRange> rangeRequests = new ArrayList<>();
	int numRangeRequests = input.readInt();
	for (int i = 0; i < numRangeRequests; i++) {
		rangeRequests.add(readProtectionRange(input));
	}
	
	return new PermissionRequest(player, requestReason, requestedPerms,
			rangeRequests);
}
 
開發者ID:Pokechu22,項目名稱:WorldDownloader-Serverside-Companion,代碼行數:28,代碼來源:WDLPackets.java

示例12: onPluginMessageReceived

import com.google.common.io.ByteArrayDataInput; //導入依賴的package包/類
/**
 * Calls when the plugin received a message from a bungee-server
 */
@Override
public void onPluginMessageReceived(String channel, Player player, byte[] message) {
	if(!channel.equals(Main.BUNGEE_CHANNEL_NAME)) {
		return;
	}
	
	ByteArrayDataInput in = ByteStreams.newDataInput(message);
    String subchannel = in.readUTF();
    if (subchannel.equals(Subchannel.UPDATE_RECEIVE)) {
    	String game = in.readUTF();
    	String serverName = in.readUTF();
    	
    	String firstLine = in.readUTF();
    	String secondLine = in.readUTF();
    	String thirdLine = in.readUTF();
    	String fourthLine = in.readUTF();
    	
    	SignUpdateInformation info = new SignUpdateInformation(firstLine, secondLine, thirdLine, fourthLine);
    	
    	this.signManager.updateJoinSign(game, serverName, info);
    }
}
 
開發者ID:Yannici,項目名稱:bedwars-reloaded-bungee,代碼行數:26,代碼來源:Main.java

示例13: recievePacket

import com.google.common.io.ByteArrayDataInput; //導入依賴的package包/類
@Override
public void recievePacket(ByteArrayDataInput data) 
{
	posX = data.readDouble();
	posY = data.readDouble();
	posZ = data.readDouble();
	
	motionX = data.readDouble();
	motionY = data.readDouble();
	motionZ = data.readDouble();
	
	rotationPitch = (float)data.readDouble();
	rotationYaw = (float)data.readDouble();
	prevRotationPitch = (float)data.readDouble();
	prevRotationYaw = (float)data.readDouble();
}
 
開發者ID:TheAwesomeGem,項目名稱:MineFantasy,代碼行數:17,代碼來源:EntityBoltMF.java

示例14: consumePacket

import com.google.common.io.ByteArrayDataInput; //導入依賴的package包/類
@Override
public FMLPacket consumePacket(byte[] data)
{
    ByteArrayDataInput dat = ByteStreams.newDataInput(data);
    int versionListSize = dat.readInt();
    modVersions = Maps.newHashMapWithExpectedSize(versionListSize);
    for (int i = 0; i < versionListSize; i++)
    {
        String modName = dat.readUTF();
        String modVersion = dat.readUTF();
        modVersions.put(modName, modVersion);
    }

    int missingModSize = dat.readInt();
    missingMods = Lists.newArrayListWithExpectedSize(missingModSize);

    for (int i = 0; i < missingModSize; i++)
    {
        missingMods.add(dat.readUTF());
    }
    return this;
}
 
開發者ID:HATB0T,項目名稱:RuneCraftery,代碼行數:23,代碼來源:ModListResponsePacket.java

示例15: handleNetworkMessage

import com.google.common.io.ByteArrayDataInput; //導入依賴的package包/類
@Override
public void handleNetworkMessage(NetHandler source, boolean isClient, ByteArrayDataInput data) {
	if (isClient) return;
	
	int x = data.readInt();
	int y = data.readInt();
	int z = data.readInt();
	String sound = data.readUTF();
	
	World world = MiscPeripherals.proxy.getClientWorld();
	
	for (int i = 0; i < 50; i++) {
		MiscPeripherals.proxy.spawnSmoke(x + 0.5D + world.rand.nextFloat() - world.rand.nextFloat(), y + world.rand.nextFloat() - world.rand.nextFloat(), z + 0.5D + world.rand.nextFloat() - world.rand.nextFloat(), 0.0D, 0.0D, 0.0D);
	}
	
	world.playSoundEffect(x + 0.5D, y + 0.5D, z + 0.5D, sound, 0.8F, world.rand.nextFloat() * 0.2F + 0.9F);
}
 
開發者ID:austinv11,項目名稱:PeripheralsPlusPlus,代碼行數:18,代碼來源:ModuleMystcraft.java


注:本文中的com.google.common.io.ByteArrayDataInput類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。