List of usage examples for io.netty.buffer ByteBuf readChar
public abstract char readChar();
From source file:com.theoriginalbit.moarperipherals.common.network.message.MessageGeneric.java
License:Apache License
@Override public void fromBytes(ByteBuf buf) { int nStr = buf.readInt(); stringData = new String[nStr]; if (nStr > 0) { for (int i = 0; i < nStr; ++i) { stringData[i] = ByteBufUtils.readUTF8String(buf); }/*from ww w . j a va2 s.co m*/ } int nInt = buf.readInt(); intData = new int[nInt]; if (nInt > 0) { for (int i = 0; i < nInt; ++i) { intData[i] = buf.readInt(); } } int nByte = buf.readInt(); byteData = new byte[nByte]; if (nByte > 0) { buf.readBytes(byteData); } int nChar = buf.readInt(); charData = new char[nChar]; if (nChar > 0) { for (int i = 0; i < nChar; ++i) { charData[i] = buf.readChar(); } } int nFloat = buf.readInt(); floatData = new float[nFloat]; if (nFloat > 0) { for (int i = 0; i < nFloat; ++i) { floatData[i] = buf.readFloat(); } } int nDouble = buf.readInt(); doubleData = new double[nDouble]; if (nDouble > 0) { for (int i = 0; i < nDouble; ++i) { doubleData[i] = buf.readDouble(); } } boolean wasNBT = buf.readBoolean(); if (wasNBT) { nbtData = ByteBufUtils.readTag(buf); } }
From source file:com.vethrfolnir.network.ReadPacket.java
License:Open Source License
/** * This is only for LS <-> GS Communication, do not use it for clients! Unless overriden and managed * @param buff/*from w w w .j ava 2 s .co m*/ * @return */ protected String readS(ByteBuf buff) { try { ArrayList<Character> ins = new ArrayList<>(); char in; while (buff.isReadable() && (in = buff.readChar()) != '\000') { ins.add(in); } char[] arr = new char[ins.size()]; for (int i = 0; i < arr.length; i++) { arr[i] = ins.get(i); } String str = new String(arr); return str; } catch (Exception e) { log.warn("Failed reading string!", e); } return null; }
From source file:de.ellpeck.actuallyadditions.mod.network.gui.PacketGuiString.java
@Override public void fromBytes(ByteBuf buf) { this.tileX = buf.readInt(); this.tileY = buf.readInt(); this.tileZ = buf.readInt(); this.worldID = buf.readInt(); this.text = ""; int textLength = buf.readInt(); for (int i = 0; i < textLength; i++) { this.text += buf.readChar(); }/* ww w . ja va 2 s .c o m*/ this.textID = buf.readInt(); this.playerID = buf.readInt(); }
From source file:gps.GpsPacket.java
License:Open Source License
private PlayerData readPlayerData(ByteBuf buf) { char[] chars = new char[buf.readUnsignedByte()]; for (int i = 0; i < chars.length; i++) { chars[i] = buf.readChar(); }/*from ww w . ja v a2s. c o m*/ String username = new String(chars); BlockPos pos = new BlockPos(buf.readInt(), buf.readInt(), buf.readInt()); int dimension = buf.readInt(); return new PlayerData(username, dimension, pos); }
From source file:matteroverdrive.network.packet.client.PacketUpdateMatterRegistry.java
License:Open Source License
@Override public void fromBytes(ByteBuf buf) { String key;/*from ww w . j a v a 2 s. co m*/ int keySize; char[] keyChars; int size = buf.readInt(); entries = new HashMap<>(); for (int i = 0; i < size; i++) { keySize = buf.readInt(); keyChars = new char[keySize]; for (int c = 0; c < keySize; c++) { keyChars[c] = buf.readChar(); } key = String.copyValueOf(keyChars); entries.put(key, new MatterEntry(key, buf.readInt(), buf.readByte())); } }
From source file:net.jamcraft.chowtime.core.network.NetworkUtils.java
License:Open Source License
public static String readString(ByteBuf buff) { int size = buff.readInt(); String s = ""; for (int i = 0; i < size; i++) { s += buff.readChar(); }/*from www . j a v a 2s . c o m*/ return s; }
From source file:nova.core.wrapper.mc.forge.v17.wrapper.entity.forward.FWEntity.java
License:Open Source License
@Override public void readSpawnData(ByteBuf buffer) { //Load the client ID String id = ""; int length = buffer.readInt(); for (int i = 0; i < length; i++) id += buffer.readChar(); setWrapped(Game.entities().get(id).get().build()); }
From source file:org.clitherproject.clither.server.net.packet.Packet.java
License:Open Source License
@SuppressWarnings("deprecation") public static String readUTF16(ByteBuf in) { in = in.order(ByteOrder.BIG_ENDIAN); ByteBuf buffer = in.alloc().buffer(); char chr;/* w ww . ja v a2 s. co m*/ while (in.readableBytes() > 1 && (chr = in.readChar()) != 0) { buffer.writeChar(chr); } return buffer.toString(Charsets.UTF_16LE); }
From source file:org.spout.vanilla.protocol.VanillaByteBufUtils.java
License:Open Source License
/** * Reads a string from the buffer.//ww w .j a v a2 s .c o m * * @param buf The buffer. * @return The string. */ public static String readString(ByteBuf buf) { int len = buf.readUnsignedShort(); char[] characters = new char[len]; for (int i = 0; i < len; i++) { characters[i] = buf.readChar(); } return new String(characters); }