Java Code Examples for com.google.common.io.ByteArrayDataInput#readLong()

The following examples show how to use com.google.common.io.ByteArrayDataInput#readLong() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ConstantPoolReader.java    From turbine with Apache License 2.0 6 votes vote down vote up
/**
 * 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()));
    case CONSTANT_UTF8:
      return new Const.StringValue(reader.readUTF());
    default:
      throw new AssertionError(String.format("bad tag: %x", tag));
  }
}
 
Example 2
Source File: PluginMessenger.java    From TAB with Apache License 2.0 5 votes vote down vote up
@EventHandler
public void on(PluginMessageEvent event){
	if (!event.getTag().equalsIgnoreCase(Shared.CHANNEL_NAME)) return;
	ByteArrayDataInput in = ByteStreams.newDataInput(event.getData());
	String subChannel = in.readUTF();
	if (event.getReceiver() instanceof ProxiedPlayer && subChannel.equalsIgnoreCase("Placeholder")){
		event.setCancelled(true);
		ITabPlayer receiver = Shared.getPlayer(((ProxiedPlayer) event.getReceiver()).getUniqueId());
		if (receiver == null) return;
		String placeholder = in.readUTF();
		String output = in.readUTF();
		long cpu = in.readLong();
		PlayerPlaceholder pl = (PlayerPlaceholder) Placeholders.getPlaceholder(placeholder); //all bridge placeholders are marked as player
		if (pl != null) {
			pl.lastValue.put(receiver.getName(), output);
			pl.lastValue.put("null", output);
			Set<Refreshable> update = PlaceholderManager.getPlaceholderUsage(pl.getIdentifier());
			Shared.featureCpu.runTask("refreshing", new Runnable() {

				@Override
				public void run() {
					for (Refreshable r : update) {
						long startTime = System.nanoTime();
						r.refresh(receiver, false);
						Shared.featureCpu.addTime(r.getRefreshCPU(), System.nanoTime()-startTime);
					}
				}
			});
			Shared.bukkitBridgePlaceholderCpu.addTime(pl.getIdentifier(), cpu);
		} else {
			Shared.debug("Received output for unknown placeholder " + placeholder);
		}
	}
}
 
Example 3
Source File: PluginMessenger.java    From TAB with Apache License 2.0 5 votes vote down vote up
@Subscribe
public void on(PluginMessageEvent event){
	if (!event.getIdentifier().getId().equalsIgnoreCase(Shared.CHANNEL_NAME)) return;
	ByteArrayDataInput in = ByteStreams.newDataInput(event.getData());
	String subChannel = in.readUTF();
	if (event.getTarget() instanceof Player && subChannel.equalsIgnoreCase("Placeholder")){
		event.setResult(ForwardResult.handled());
		ITabPlayer receiver = Shared.getPlayer(((Player) event.getTarget()).getUniqueId());
		if (receiver == null) return;
		String placeholder = in.readUTF();
		String output = in.readUTF();
		long cpu = in.readLong();
		PlayerPlaceholder pl = (PlayerPlaceholder) Placeholders.getPlaceholder(placeholder); //all bridge placeholders are marked as player
		if (pl != null) {
			pl.lastValue.put(receiver.getName(), output);
			pl.lastValue.put("null", output);
			Set<Refreshable> update = PlaceholderManager.getPlaceholderUsage(pl.getIdentifier());
			Shared.featureCpu.runTask("refreshing", new Runnable() {

				@Override
				public void run() {
					for (Refreshable r : update) {
						long startTime = System.nanoTime();
						r.refresh(receiver, false);
						Shared.featureCpu.addTime(r.getRefreshCPU(), System.nanoTime()-startTime);
					}
				}
			});
			Shared.bukkitBridgePlaceholderCpu.addTime(pl.getIdentifier(), cpu);
		} else {
			Shared.debug("Received output for unknown placeholder " + placeholder);
		}
	}
}
 
Example 4
Source File: LoginActionMessage.java    From FastLogin with MIT License 5 votes vote down vote up
@Override
public void readFrom(ByteArrayDataInput input) {
    this.type = Type.values()[input.readInt()];

    this.playerName = input.readUTF();

    //bungeecord UUID
    long mostSignificantBits = input.readLong();
    long leastSignificantBits = input.readLong();
    this.proxyId = new UUID(mostSignificantBits, leastSignificantBits);
}
 
Example 5
Source File: PacketLevelEmitterFluid.java    From ExtraCells1 with MIT License 5 votes vote down vote up
@Override
public void read(ByteArrayDataInput in) throws ProtocolException
{
	world = DimensionManager.getWorld(in.readInt());
	x = in.readInt();
	y = in.readInt();
	z = in.readInt();
	filterAmount = in.readLong();
	type = in.readInt();
}