Java Code Examples for io.netty.buffer.ByteBuf#readChar()

The following examples show how to use io.netty.buffer.ByteBuf#readChar() . 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: ReadPacket.java    From vethrfolnir-mu with GNU General Public License v3.0 6 votes vote down vote up
/**
 * This is only for LS <-> GS Communication, do not use it for clients! Unless overriden and managed
 * @param buff
 * @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;
}
 
Example 2
Source File: Packet.java    From Clither-Server with GNU General Public License v3.0 5 votes vote down vote up
@SuppressWarnings("deprecation")
public static String readUTF16(ByteBuf in) {
       in = in.order(ByteOrder.BIG_ENDIAN);
       ByteBuf buffer = in.alloc().buffer();
       char chr;
       while (in.readableBytes() > 1 && (chr = in.readChar()) != 0) {
           buffer.writeChar(chr);
       }

       return buffer.toString(Charsets.UTF_16LE);
   }
 
Example 3
Source File: FWEntity.java    From NOVA-Core with GNU Lesser General Public License v3.0 5 votes vote down vote up
@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());
}
 
Example 4
Source File: FWEntity.java    From NOVA-Core with GNU Lesser General Public License v3.0 5 votes vote down vote up
@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());
}
 
Example 5
Source File: FWEntity.java    From NOVA-Core with GNU Lesser General Public License v3.0 5 votes vote down vote up
@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());
}
 
Example 6
Source File: Packet.java    From Ogar2-Server with GNU General Public License v3.0 5 votes vote down vote up
public static String readUTF16(ByteBuf in) {
    in = in.order(ByteOrder.BIG_ENDIAN);
    ByteBuf buffer = in.alloc().buffer();
    char chr;
    while (in.readableBytes() > 1 && (chr = in.readChar()) != 0) {
        buffer.writeChar(chr);
    }

    return buffer.toString(Charsets.UTF_16LE);
}