/me is an idiot and forgot that WECUI packets don't have the string length in them (string length == packet length)

Dieser Commit ist enthalten in:
zml2008 2012-08-07 14:14:40 -07:00
Ursprung fe445a7ec9
Commit 853bc53e21

Datei anzeigen

@ -39,15 +39,14 @@ public class WorldEditCUICodec extends MessageCodec<WorldEditCUIMessage> impleme
public ChannelBuffer encode(WorldEditCUIMessage message) { public ChannelBuffer encode(WorldEditCUIMessage message) {
byte[] data = message.getMessage().getBytes(UTF_8_CHARSET); byte[] data = message.getMessage().getBytes(UTF_8_CHARSET);
ChannelBuffer buffer = ChannelBuffers.buffer(data.length + 2); ChannelBuffer buffer = ChannelBuffers.buffer(data.length);
buffer.writeShort(data.length);
buffer.writeBytes(data); buffer.writeBytes(data);
return buffer; return buffer;
} }
@Override @Override
public WorldEditCUIMessage decode(ChannelBuffer buffer) { public WorldEditCUIMessage decode(ChannelBuffer buffer) {
byte[] data = new byte[buffer.readShort()]; byte[] data = new byte[buffer.readableBytes()];
buffer.readBytes(data); buffer.readBytes(data);
String message = new String(data, UTF_8_CHARSET); String message = new String(data, UTF_8_CHARSET);
return new WorldEditCUIMessage(message); return new WorldEditCUIMessage(message);