Program: 151777
Project: 151777
Buggy source:
private void handlePacket() throws IOException {
  Byte packetId=in.readByte();
  int x;
  byte y;
  int z;
  byte dimension;
  Coordinate coordinate;
switch (packetId) {
case 0x00:
    write(packetId);
  write(in.readInt());
break;
case 0x01:
write(packetId);
if (!isServerTunnel) {
write(in.readInt());
write(readUTF16());
copyNBytes(5);
break;
}
player.setEntityId(write(in.readInt()));
write(readUTF16());
write(in.readByte());
dimension=in.readByte();
if (isServerTunnel) {
player.setDimension(Dimension.get(dimension));
}
write(dimension);
write(in.readByte());
write(in.readByte());
if (isServerTunnel) {
in.readByte();
write((byte)server.config.properties.getInt("String_Node_Str"));
}
 else {
write(in.readByte());
}
break;
case 0x02:
byte version=in.readByte();
String name=readUTF16();
boolean nameSet=false;
if (name.contains("String_Node_Str")) {
name=name.substring(0,name.indexOf("String_Node_Str"));
}
if (name.equals("String_Node_Str") || !server.authenticator.isMinecraftUp) {
AuthRequest req=server.authenticator.getAuthRequest(player.getIPAddress());
if (req != null) {
name=req.playerName;
nameSet=server.authenticator.completeLogin(req,player);
}
if (req == null || !nameSet) {
if (!name.equals("String_Node_Str")) {
player.addTMessage(Color.RED,"String_Node_Str");
player.addTMessage(Color.RED,"String_Node_Str");
}
name=server.authenticator.getFreeGuestName();
player.setGuest(true);
nameSet=player.setName(name);
}
}
 else {
nameSet=player.setName(name);
if (nameSet) {
player.updateRealName(name);
}
}
if (player.isGuest() && !server.authenticator.allowGuestJoin()) {
player.kick(t("String_Node_Str"));
nameSet=false;
}
tunneler.setName(streamType + "String_Node_Str" + player.getName());
write(packetId);
write(version);
write(player.getName());
write(readUTF16());
write(in.readInt());
break;
case 0x03:
String message=readUTF16();
Matcher joinMatcher=JOIN_PATTERN.matcher(message);
if (isServerTunnel && joinMatcher.find()) {
if (server.bots.ninja(joinMatcher.group(1))) {
break;
}
if (message.contains("String_Node_Str")) {
player.addTMessage(Color.YELLOW,"String_Node_Str",joinMatcher.group(1));
}
 else {
player.addTMessage(Color.YELLOW,"String_Node_Str",joinMatcher.group(1));
}
break;
}
if (isServerTunnel && server.config.properties.getBoolean("String_Node_Str")) {
if (server.config.properties.getBoolean("String_Node_Str") && server.getMessager().wasForwarded(message)) {
break;
}
Matcher colorMatcher=COLOR_PATTERN.matcher(message);
String cleanMessage=colorMatcher.replaceAll("String_Node_Str");
Matcher messageMatcher=MESSAGE_PATTERN.matcher(cleanMessage);
if (messageMatcher.find()) {
}
 else if (cleanMessage.matches(CONSOLE_CHAT_PATTERN) && !server.config.properties.getBoolean("String_Node_Str")) {
break;
}
if (server.config.properties.getBoolean("String_Node_Str")) {
sendMessage(message);
}
 else {
if (message.length() > MAXIMUM_MESSAGE_SIZE) {
message=message.substring(0,MAXIMUM_MESSAGE_SIZE);
}
write(packetId);
write(message);
}
}
 else if (!isServerTunnel) {
if (player.isMuted() && !message.startsWith("String_Node_Str") && !message.startsWith("String_Node_Str")) {
player.addTMessage(Color.RED,"String_Node_Str");
break;
}
if (message.charAt(0) == commandPrefix) {
message=player.parseCommand(message,false);
if (message == null) {
break;
}
write(packetId);
write(message);
return;
}
player.sendMessage(message);
}
break;
case 0x04:
write(packetId);
write(in.readLong());
long time=in.readLong();
server.setTime(time);
write(time);
break;
case 0x05:
write(packetId);
write(in.readInt());
write(in.readShort());
copyItem();
break;
case 0x06:
write(packetId);
copyNBytes(12);
if (server.options.getBoolean("String_Node_Str")) {
server.eventhost.execute(server.eventhost.findEvent("String_Node_Str"),player,true,null);
}
break;
case 0x07:
int user=in.readInt();
int target=in.readInt();
Player targetPlayer=server.playerList.findPlayer(target);
if (targetPlayer != null) {
if (targetPlayer.godModeEnabled()) {
in.readBoolean();
break;
}
}
write(packetId);
write(user);
write(target);
copyNBytes(1);
break;
case 0x08:
write(packetId);
player.updateHealth(write(in.readShort()));
player.getHealth();
write(in.readShort());
write(in.readFloat());
break;
case 0x09:
write(packetId);
if (!isServerTunnel) {
break;
}
player.setDimension(Dimension.get(write(in.readInt())));
write(in.readByte());
write(in.readByte());
write(in.readShort());
write(readUTF16());
if (server.options.getBoolean("String_Node_Str") && isServerTunnel) {
server.eventhost.execute(server.eventhost.findEvent("String_Node_Str"),player,true,null);
}
break;
case 0x0a:
write(packetId);
copyNBytes(1);
if (!inGame && !isServerTunnel) {
player.sendMOTD();
if (server.config.properties.getBoolean("String_Node_Str")) {
player.execute(PlayerListCommand.class);
}
inGame=true;
}
break;
case 0x0b:
write(packetId);
copyPlayerLocation();
copyNBytes(1);
break;
case 0x0c:
write(packetId);
copyPlayerLook();
copyNBytes(1);
break;
case 0x0d:
write(packetId);
copyPlayerLocation();
copyPlayerLook();
copyNBytes(1);
break;
case 0x0e:
if (!isServerTunnel) {
byte status=in.readByte();
x=in.readInt();
y=in.readByte();
z=in.readInt();
byte face=in.readByte();
coordinate=new Coordinate(x,y,z,player);
if (!player.getGroup().ignoreAreas) {
BlockPermission perm=server.config.blockPermission(player,coordinate);
if (!perm.use && status == 0) {
player.addTMessage(Color.RED,"String_Node_Str");
break;
}
if (!perm.destroy && status == BLOCK_DESTROYED_STATUS) {
player.addTMessage(Color.RED,"String_Node_Str");
break;
}
}
boolean locked=server.data.chests.isLocked(coordinate);
if (!locked || player.ignoresChestLocks() || server.data.chests.canOpen(player,coordinate)) {
if (locked && status == BLOCK_DESTROYED_STATUS) {
server.data.chests.releaseLock(coordinate);
server.data.save();
}
write(packetId);
write(status);
write(x);
write(y);
write(z);
write(face);
if (player.instantDestroyEnabled()) {
packetFinished();
write(packetId);
write(BLOCK_DESTROYED_STATUS);
write(x);
write(y);
write(z);
write(face);
}
if (status == BLOCK_DESTROYED_STATUS) {
player.destroyedBlock();
}
}
}
 else {
write(packetId);
copyNBytes(11);
}
break;
case 0x0f:
x=in.readInt();
y=in.readByte();
z=in.readInt();
coordinate=new Coordinate(x,y,z,player);
final byte direction=in.readByte();
final short dropItem=in.readShort();
byte itemCount=0;
short uses=0;
byte[] data=null;
if (dropItem != -1) {
itemCount=in.readByte();
uses=in.readShort();
short dataLength=in.readShort();
if (dataLength != -1) {
data=new byte[dataLength];
in.readFully(data);
}
}
byte blockX=in.readByte();
byte blockY=in.readByte();
byte blockZ=in.readByte();
boolean writePacket=true;
boolean drop=false;
BlockPermission perm=server.config.blockPermission(player,coordinate,dropItem);
if (server.options.getBoolean("String_Node_Str")) {
player.checkButtonEvents(new Coordinate(x + (x < 0 ? 1 : 0),y + 1,z + (z < 0 ? 1 : 0)));
}
if (isServerTunnel || server.data.chests.isChest(coordinate)) {
}
 else if (!player.getGroup().ignoreAreas && ((dropItem != -1 && !perm.place) || !perm.use)) {
if (!perm.use) {
player.addTMessage(Color.RED,"String_Node_Str");
}
 else {
player.addTMessage(Color.RED,"String_Node_Str");
}
writePacket=false;
drop=true;
}
 else if (dropItem == 54) {
int xPosition=x;
byte yPosition=y;
int zPosition=z;
switch (direction) {
case 0:
--yPosition;
break;
case 1:
++yPosition;
break;
case 2:
--zPosition;
break;
case 3:
++zPosition;
break;
case 4:
--xPosition;
break;
case 5:
++xPosition;
break;
}
Coordinate targetBlock=new Coordinate(xPosition,yPosition,zPosition,player);
Chest adjacentChest=server.data.chests.adjacentChest(targetBlock);
if (adjacentChest != null && !adjacentChest.isOpen() && !adjacentChest.ownedBy(player)) {
player.addTMessage(Color.RED,"String_Node_Str");
writePacket=false;
drop=true;
}
 else {
player.placingChest(targetBlock);
}
}
if (writePacket) {
write(packetId);
write(x);
write(y);
write(z);
write(direction);
write(dropItem);
if (dropItem != -1) {
write(itemCount);
write(uses);
if (data != null) {
write((short)data.length);
out.write(data);
}
 else {
write((short)-1);
}
if (dropItem <= 94 && direction >= 0) {
player.placedBlock();
}
}
write(blockX);
write(blockY);
write(blockZ);
player.openingChest(coordinate);
}
 else if (drop) {
write((byte)0x0e);
write((byte)0x04);
write(x);
write(y);
write(z);
write(direction);
}
break;
case 0x10:
write(packetId);
copyNBytes(2);
break;
case 0x11:
write(packetId);
copyNBytes(14);
break;
case 0x12:
write(packetId);
copyNBytes(5);
break;
case 0x13:
write(packetId);
write(in.readInt());
write(in.readByte());
break;
case 0x14:
int eid=in.readInt();
name=readUTF16();
if (!server.bots.ninja(name)) {
write(packetId);
write(eid);
write(name);
copyNBytes(16);
copyUnknownBlob();
}
 else {
skipNBytes(16);
skipUnknownBlob();
}
break;
case 0x15:
write(packetId);
copyNBytes(4);
copyItem();
copyNBytes(15);
break;
case 0x16:
write(packetId);
copyNBytes(8);
break;
case 0x17:
write(packetId);
write(in.readInt());
write(in.readByte());
write(in.readInt());
write(in.readInt());
write(in.readInt());
int flag=in.readInt();
write(flag);
if (flag > 0) {
write(in.readShort());
write(in.readShort());
write(in.readShort());
}
break;
case 0x18:
write(packetId);
write(in.readInt());
write(in.readByte());
write(in.readInt());
write(in.readInt());
write(in.readInt());
write(in.readByte());
write(in.readByte());
write(in.readByte());
write(in.readShort());
write(in.readShort());
write(in.readShort());
copyUnknownBlob();
break;
case 0x19:
write(packetId);
write(in.readInt());
write(readUTF16());
write(in.readInt());
write(in.readInt());
write(in.readInt());
write(in.readInt());
break;
case 0x1a:
write(packetId);
write(in.readInt());
write(in.readInt());
write(in.readInt());
write(in.readInt());
write(in.readShort());
break;
case 0x1c:
write(packetId);
copyNBytes(10);
break;
case 0x1d:
write(packetId);
byte destoryCount=write(in.readByte());
if (destoryCount > 0) {
copyNBytes(destoryCount * 4);
}
break;
case 0x1e:
write(packetId);
copyNBytes(4);
break;
case 0x1f:
write(packetId);
copyNBytes(7);
break;
case 0x20:
write(packetId);
copyNBytes(6);
break;
case 0x21:
write(packetId);
copyNBytes(9);
break;
case 0x22:
write(packetId);
copyNBytes(18);
break;
case 0x23:
write(packetId);
write(in.readInt());
write(in.readByte());
break;
case 0x26:
write(packetId);
copyNBytes(5);
break;
case 0x27:
write(packetId);
copyNBytes(8);
break;
case 0x28:
write(packetId);
write(in.readInt());
copyUnknownBlob();
break;
case 0x29:
write(packetId);
write(in.readInt());
write(in.readByte());
write(in.readByte());
write(in.readShort());
break;
case 0x2a:
write(packetId);
write(in.readInt());
write(in.readByte());
break;
case 0x2b:
write(packetId);
player.updateExperience(write(in.readFloat()),write(in.readShort()),write(in.readShort()));
break;
case 0x33:
write(packetId);
write(in.readInt());
write(in.readInt());
write(in.readBoolean());
write(in.readShort());
write(in.readShort());
copyNBytes(write(in.readInt()));
break;
case 0x34:
write(packetId);
write(in.readInt());
write(in.readInt());
write(in.readShort());
copyNBytes(write(in.readInt()));
break;
case 0x35:
write(packetId);
x=in.readInt();
y=in.readByte();
z=in.readInt();
short blockType=in.readShort();
byte metadata=in.readByte();
coordinate=new Coordinate(x,y,z,player);
if (blockType == 54 && player.placedChest(coordinate)) {
lockChest(coordinate);
player.placingChest(null);
}
write(x);
write(y);
write(z);
write(blockType);
write(metadata);
break;
case 0x36:
write(packetId);
copyNBytes(14);
break;
case 0x37:
write(packetId);
write(in.readInt());
write(in.readInt());
write(in.readInt());
write(in.readInt());
write(in.readByte());
break;
case 0x38:
write(packetId);
copyNBytes(write(in.readShort()) * 12 + write(in.readInt()));
break;
case 0x3c:
write(packetId);
copyNBytes(28);
int recordCount=in.readInt();
write(recordCount);
copyNBytes(recordCount * 3);
write(in.readFloat());
write(in.readFloat());
write(in.readFloat());
break;
case 0x3d:
write(packetId);
write(in.readInt());
write(in.readInt());
write(in.readByte());
write(in.readInt());
write(in.readInt());
write(in.readByte());
break;
case 0x3e:
write(packetId);
write(readUTF16());
write(in.readInt());
write(in.readInt());
write(in.readInt());
write(in.readFloat());
write(in.readByte());
break;
case 0x46:
write(packetId);
write(in.readByte());
write(in.readByte());
break;
case 0x47:
write(packetId);
copyNBytes(17);
break;
case 0x64:
boolean allow=true;
byte id=in.readByte();
byte invtype=in.readByte();
String typeString=readUTF16();
byte unknownByte=in.readByte();
if (invtype == 0) {
Chest adjacent=server.data.chests.adjacentChest(player.openedChest());
if (!server.data.chests.isChest(player.openedChest())) {
if (adjacent == null) {
server.data.chests.addOpenChest(player.openedChest());
}
 else {
server.data.chests.giveLock(adjacent.owner,player.openedChest(),adjacent.name);
}
server.data.save();
}
if (!player.getGroup().ignoreAreas && (!server.config.blockPermission(player,player.openedChest()).chest || (adjacent != null && !server.config.blockPermission(player,adjacent.coordinate).chest))) {
player.addTMessage(Color.RED,"String_Node_Str");
allow=false;
}
 else if (server.data.chests.canOpen(player,player.openedChest()) || player.ignoresChestLocks()) {
if (server.data.chests.isLocked(player.openedChest())) {
if (player.isAttemptingUnlock()) {
server.data.chests.unlock(player.openedChest());
server.data.save();
player.setAttemptedAction(null);
player.addTMessage(Color.RED,"String_Node_Str");
typeString=t("String_Node_Str");
}
 else {
typeString=server.data.chests.chestName(player.openedChest());
}
}
 else {
typeString=t("String_Node_Str");
if (player.isAttemptLock()) {
lockChest(player.openedChest());
typeString=(player.nextChestName() == null) ? t("String_Node_Str") : player.nextChestName();
}
}
}
 else {
player.addTMessage(Color.RED,"String_Node_Str");
allow=false;
}
}
if (!allow) {
write((byte)0x65);
write(id);
}
 else {
write(packetId);
write(id);
write(invtype);
write(typeString);
write(unknownByte);
}
break;
case 0x65:
write(packetId);
write(in.readByte());
break;
case 0x66:
write(packetId);
write(in.readByte());
write(in.readShort());
write(in.readByte());
write(in.readShort());
write(in.readByte());
copyItem();
break;
case 0x67:
write(packetId);
write(in.readByte());
write(in.readShort());
copyItem();
break;
case 0x68:
write(packetId);
write(in.readByte());
short count=write(in.readShort());
for (int c=0; c < count; ++c) {
copyItem();
}
break;
case 0x69:
write(packetId);
write(in.readByte());
write(in.readShort());
write(in.readShort());
break;
case 0x6a:
write(packetId);
write(in.readByte());
write(in.readShort());
write(in.readByte());
break;
case 0x6b:
write(packetId);
write(in.readShort());
copyItem();
break;
case 0x6c:
write(packetId);
write(in.readByte());
write(in.readByte());
break;
case (byte)0x82:
write(packetId);
write(in.readInt());
write(in.readShort());
write(in.readInt());
write(readUTF16());
write(readUTF16());
write(readUTF16());
write(readUTF16());
break;
case (byte)0x83:
write(packetId);
write(in.readShort());
write(in.readShort());
short length=in.readShort();
write(length);
copyNBytes(0xff & length);
break;
case (byte)0x84:
write(packetId);
write(in.readInt());
write(in.readShort());
write(in.readInt());
write(in.readByte());
short nbtLength=write(in.readShort());
if (nbtLength > 0) {
copyNBytes(nbtLength);
}
break;
case (byte)0xc3:
write(packetId);
write(in.readInt());
copyNBytes(write(in.readInt()));
break;
case (byte)0xc8:
write(packetId);
copyNBytes(5);
break;
case (byte)0xc9:
write(packetId);
write(readUTF16());
write(in.readByte());
write(in.readShort());
break;
case (byte)0xca:
write(packetId);
write(in.readByte());
write(in.readByte());
write(in.readByte());
break;
case (byte)0xcb:
write(packetId);
write(readUTF16());
break;
case (byte)0xcc:
write(packetId);
write(readUTF16());
write(in.readByte());
write(in.readByte());
write(in.readByte());
write(in.readBoolean());
break;
case (byte)0xcd:
write(packetId);
write(in.readByte());
break;
case (byte)0xd3:
write(packetId);
copyNBytes(1);
copyVLC();
copyVLC();
copyVLC();
copyNBytes((int)copyVLC());
break;
case (byte)0xe6:
write(packetId);
write(in.readInt());
write(in.readInt());
copyNBytes(write(in.readInt()) * 4);
copyNBytes(write(in.readInt()) * 4);
copyNBytes(write(in.readInt()) * 8);
int sizeString=write(in.readInt());
for (int i=0; i < sizeString; i++) {
copyNBytes(write(in.readInt()));
}
break;
case (byte)0xfa:
write(packetId);
write(readUTF16());
copyNBytes(write(in.readShort()));
break;
case (byte)0xfc:
byte[] sharedKey=new byte[in.readShort()];
in.readFully(sharedKey);
byte[] challengeTokenResponse=new byte[in.readShort()];
in.readFully(challengeTokenResponse);
if (!isServerTunnel) {
if (!player.clientEncryption.checkChallengeToken(challengeTokenResponse)) {
player.kick("String_Node_Str");
break;
}
player.clientEncryption.setEncryptedSharedKey(sharedKey);
sharedKey=player.serverEncryption.getEncryptedSharedKey();
}
if (!isServerTunnel && server.authenticator.useCustAuth(player) && !server.authenticator.onlineAuthenticate(player)) {
player.kick(t("String_Node_Str","String_Node_Str"));
break;
}
write(packetId);
write((short)sharedKey.length);
write(sharedKey);
challengeTokenResponse=player.serverEncryption.encryptChallengeToken();
write((short)challengeTokenResponse.length);
write(challengeTokenResponse);
if (isServerTunnel) {
in=new DataInputStream(new BufferedInputStream(player.serverEncryption.encryptedInputStream(inputStream)));
out=new DataOutputStream(new BufferedOutputStream(player.clientEncryption.encryptedOutputStream(outputStream)));
}
 else {
in=new DataInputStream(new BufferedInputStream(player.clientEncryption.encryptedInputStream(inputStream)));
out=new DataOutputStream(new BufferedOutputStream(player.serverEncryption.encryptedOutputStream(outputStream)));
}
break;
case (byte)0xfd:
tunneler.setName(streamType + "String_Node_Str" + player.getName());
write(packetId);
String serverId=readUTF16();
if (!server.authenticator.useCustAuth(player)) {
serverId="String_Node_Str";
}
 else {
serverId=player.getConnectionHash();
}
write(serverId);
byte[] keyBytes=new byte[in.readShort()];
in.readFully(keyBytes);
byte[] challengeToken=new byte[in.readShort()];
in.readFully(challengeToken);
player.serverEncryption.setPublicKey(keyBytes);
byte[] key=player.clientEncryption.getPublicKey();
write((short)key.length);
write(key);
write((short)challengeToken.length);
write(challengeToken);
player.serverEncryption.setChallengeToken(challengeToken);
player.clientEncryption.setChallengeToken(challengeToken);
break;
case (byte)0xfe:
write(packetId);
write(in.readByte());
break;
case (byte)0xff:
write(packetId);
String reason=readUTF16();
if (reason.startsWith("String_Node_Str")) {
reason=String.format("String_Node_Str",Main.protocolVersion,Main.minecraftVersion,server.config.properties.get("String_Node_Str"),server.playerList.size(),server.config.properties.getInt("String_Node_Str"));
}
write(reason);
if (reason.startsWith("String_Node_Str")) {
server.addRobot(player);
}
player.close();
break;
default :
if (EXPENSIVE_DEBUG_LOGGING) {
while (true) {
skipNBytes(1);
flushAll();
}
}
 else {
if (lastPacket != null) {
throw new IOException("String_Node_Str" + streamType + "String_Node_Str"+ Integer.toHexString(packetId)+ "String_Node_Str"+ player.getName()+ "String_Node_Str"+ Integer.toHexString(lastPacket));
}
 else {
throw new IOException("String_Node_Str" + streamType + "String_Node_Str"+ Integer.toHexString(packetId)+ "String_Node_Str"+ player.getName());
}
}
}
packetFinished();
lastPacket=(packetId == 0x00) ? lastPacket : packetId;
}

Fixed version (ground truth):
private void handlePacket() throws IOException {
  Byte packetId=in.readByte();
  int x;
  byte y;
  int z;
  byte dimension;
  Coordinate coordinate;
switch (packetId) {
case 0x00:
    write(packetId);
  write(in.readInt());
break;
case 0x01:
write(packetId);
if (!isServerTunnel) {
write(in.readInt());
write(readUTF16());
copyNBytes(5);
break;
}
player.setEntityId(write(in.readInt()));
write(readUTF16());
write(in.readByte());
dimension=in.readByte();
if (isServerTunnel) {
player.setDimension(Dimension.get(dimension));
}
write(dimension);
write(in.readByte());
write(in.readByte());
if (isServerTunnel) {
in.readByte();
write((byte)server.config.properties.getInt("String_Node_Str"));
}
 else {
write(in.readByte());
}
break;
case 0x02:
byte version=in.readByte();
String name=readUTF16();
boolean nameSet=false;
if (name.contains("String_Node_Str")) {
name=name.substring(0,name.indexOf("String_Node_Str"));
}
if (name.equals("String_Node_Str") || !server.authenticator.isMinecraftUp) {
AuthRequest req=server.authenticator.getAuthRequest(player.getIPAddress());
if (req != null) {
name=req.playerName;
nameSet=server.authenticator.completeLogin(req,player);
}
if (req == null || !nameSet) {
if (!name.equals("String_Node_Str")) {
player.addTMessage(Color.RED,"String_Node_Str");
player.addTMessage(Color.RED,"String_Node_Str");
}
name=server.authenticator.getFreeGuestName();
player.setGuest(true);
nameSet=player.setName(name);
}
}
 else {
nameSet=player.setName(name);
if (nameSet) {
player.updateRealName(name);
}
}
if (player.isGuest() && !server.authenticator.allowGuestJoin()) {
player.kick(t("String_Node_Str"));
nameSet=false;
}
tunneler.setName(streamType + "String_Node_Str" + player.getName());
write(packetId);
write(version);
write(player.getName());
write(readUTF16());
write(in.readInt());
break;
case 0x03:
String message=readUTF16();
Matcher joinMatcher=JOIN_PATTERN.matcher(message);
if (isServerTunnel && joinMatcher.find()) {
if (server.bots.ninja(joinMatcher.group(1))) {
break;
}
if (message.contains("String_Node_Str")) {
player.addTMessage(Color.YELLOW,"String_Node_Str",joinMatcher.group(1));
}
 else {
player.addTMessage(Color.YELLOW,"String_Node_Str",joinMatcher.group(1));
}
break;
}
if (isServerTunnel && server.config.properties.getBoolean("String_Node_Str")) {
if (server.config.properties.getBoolean("String_Node_Str") && server.getMessager().wasForwarded(message)) {
break;
}
Matcher colorMatcher=COLOR_PATTERN.matcher(message);
String cleanMessage=colorMatcher.replaceAll("String_Node_Str");
Matcher messageMatcher=MESSAGE_PATTERN.matcher(cleanMessage);
if (messageMatcher.find()) {
}
 else if (cleanMessage.matches(CONSOLE_CHAT_PATTERN) && !server.config.properties.getBoolean("String_Node_Str")) {
break;
}
if (server.config.properties.getBoolean("String_Node_Str")) {
sendMessage(message);
}
 else {
if (message.length() > MAXIMUM_MESSAGE_SIZE) {
message=message.substring(0,MAXIMUM_MESSAGE_SIZE);
}
write(packetId);
write(message);
}
}
 else if (!isServerTunnel) {
if (player.isMuted() && !message.startsWith("String_Node_Str") && !message.startsWith("String_Node_Str")) {
player.addTMessage(Color.RED,"String_Node_Str");
break;
}
if (message.charAt(0) == commandPrefix) {
message=player.parseCommand(message,false);
if (message == null) {
break;
}
write(packetId);
write(message);
return;
}
player.sendMessage(message);
}
break;
case 0x04:
write(packetId);
write(in.readLong());
long time=in.readLong();
server.setTime(time);
write(time);
break;
case 0x05:
write(packetId);
write(in.readInt());
write(in.readShort());
copyItem();
break;
case 0x06:
write(packetId);
copyNBytes(12);
if (server.options.getBoolean("String_Node_Str")) {
server.eventhost.execute(server.eventhost.findEvent("String_Node_Str"),player,true,null);
}
break;
case 0x07:
int user=in.readInt();
int target=in.readInt();
Player targetPlayer=server.playerList.findPlayer(target);
if (targetPlayer != null) {
if (targetPlayer.godModeEnabled()) {
in.readBoolean();
break;
}
}
write(packetId);
write(user);
write(target);
copyNBytes(1);
break;
case 0x08:
write(packetId);
player.updateHealth(write(in.readShort()));
player.getHealth();
write(in.readShort());
write(in.readFloat());
break;
case 0x09:
write(packetId);
if (!isServerTunnel) {
break;
}
player.setDimension(Dimension.get(write(in.readInt())));
write(in.readByte());
write(in.readByte());
write(in.readShort());
write(readUTF16());
if (server.options.getBoolean("String_Node_Str") && isServerTunnel) {
server.eventhost.execute(server.eventhost.findEvent("String_Node_Str"),player,true,null);
}
break;
case 0x0a:
write(packetId);
copyNBytes(1);
if (!inGame && !isServerTunnel) {
player.sendMOTD();
if (server.config.properties.getBoolean("String_Node_Str")) {
player.execute(PlayerListCommand.class);
}
inGame=true;
}
break;
case 0x0b:
write(packetId);
copyPlayerLocation();
copyNBytes(1);
break;
case 0x0c:
write(packetId);
copyPlayerLook();
copyNBytes(1);
break;
case 0x0d:
write(packetId);
copyPlayerLocation();
copyPlayerLook();
copyNBytes(1);
break;
case 0x0e:
if (!isServerTunnel) {
byte status=in.readByte();
x=in.readInt();
y=in.readByte();
z=in.readInt();
byte face=in.readByte();
coordinate=new Coordinate(x,y,z,player);
if (!player.getGroup().ignoreAreas) {
BlockPermission perm=server.config.blockPermission(player,coordinate);
if (!perm.use && status == 0) {
player.addTMessage(Color.RED,"String_Node_Str");
break;
}
if (!perm.destroy && status == BLOCK_DESTROYED_STATUS) {
player.addTMessage(Color.RED,"String_Node_Str");
break;
}
}
boolean locked=server.data.chests.isLocked(coordinate);
if (!locked || player.ignoresChestLocks() || server.data.chests.canOpen(player,coordinate)) {
if (locked && status == BLOCK_DESTROYED_STATUS) {
server.data.chests.releaseLock(coordinate);
server.data.save();
}
write(packetId);
write(status);
write(x);
write(y);
write(z);
write(face);
if (player.instantDestroyEnabled()) {
packetFinished();
write(packetId);
write(BLOCK_DESTROYED_STATUS);
write(x);
write(y);
write(z);
write(face);
}
if (status == BLOCK_DESTROYED_STATUS) {
player.destroyedBlock();
}
}
}
 else {
write(packetId);
copyNBytes(11);
}
break;
case 0x0f:
x=in.readInt();
y=in.readByte();
z=in.readInt();
coordinate=new Coordinate(x,y,z,player);
final byte direction=in.readByte();
final short dropItem=in.readShort();
byte itemCount=0;
short uses=0;
byte[] data=null;
if (dropItem != -1) {
itemCount=in.readByte();
uses=in.readShort();
short dataLength=in.readShort();
if (dataLength != -1) {
data=new byte[dataLength];
in.readFully(data);
}
}
byte blockX=in.readByte();
byte blockY=in.readByte();
byte blockZ=in.readByte();
boolean writePacket=true;
boolean drop=false;
BlockPermission perm=server.config.blockPermission(player,coordinate,dropItem);
if (server.options.getBoolean("String_Node_Str")) {
player.checkButtonEvents(new Coordinate(x + (x < 0 ? 1 : 0),y + 1,z + (z < 0 ? 1 : 0)));
}
if (isServerTunnel || server.data.chests.isChest(coordinate)) {
}
 else if (!player.getGroup().ignoreAreas && ((dropItem != -1 && !perm.place) || !perm.use)) {
if (!perm.use) {
player.addTMessage(Color.RED,"String_Node_Str");
}
 else {
player.addTMessage(Color.RED,"String_Node_Str");
}
writePacket=false;
drop=true;
}
 else if (dropItem == 54) {
int xPosition=x;
byte yPosition=y;
int zPosition=z;
switch (direction) {
case 0:
--yPosition;
break;
case 1:
++yPosition;
break;
case 2:
--zPosition;
break;
case 3:
++zPosition;
break;
case 4:
--xPosition;
break;
case 5:
++xPosition;
break;
}
Coordinate targetBlock=new Coordinate(xPosition,yPosition,zPosition,player);
Chest adjacentChest=server.data.chests.adjacentChest(targetBlock);
if (adjacentChest != null && !adjacentChest.isOpen() && !adjacentChest.ownedBy(player)) {
player.addTMessage(Color.RED,"String_Node_Str");
writePacket=false;
drop=true;
}
 else {
player.placingChest(targetBlock);
}
}
if (writePacket) {
write(packetId);
write(x);
write(y);
write(z);
write(direction);
write(dropItem);
if (dropItem != -1) {
write(itemCount);
write(uses);
if (data != null) {
write((short)data.length);
out.write(data);
}
 else {
write((short)-1);
}
if (dropItem <= 94 && direction >= 0) {
player.placedBlock();
}
}
write(blockX);
write(blockY);
write(blockZ);
player.openingChest(coordinate);
}
 else if (drop) {
write((byte)0x0e);
write((byte)0x04);
write(x);
write(y);
write(z);
write(direction);
}
break;
case 0x10:
write(packetId);
copyNBytes(2);
break;
case 0x11:
write(packetId);
copyNBytes(14);
break;
case 0x12:
write(packetId);
copyNBytes(5);
break;
case 0x13:
write(packetId);
write(in.readInt());
write(in.readByte());
break;
case 0x14:
int eid=in.readInt();
name=readUTF16();
if (!server.bots.ninja(name)) {
write(packetId);
write(eid);
write(name);
copyNBytes(16);
copyUnknownBlob();
}
 else {
skipNBytes(16);
skipUnknownBlob();
}
break;
case 0x15:
write(packetId);
copyNBytes(4);
copyItem();
copyNBytes(15);
break;
case 0x16:
write(packetId);
copyNBytes(8);
break;
case 0x17:
write(packetId);
write(in.readInt());
write(in.readByte());
write(in.readInt());
write(in.readInt());
write(in.readInt());
int flag=in.readInt();
write(flag);
if (flag > 0) {
write(in.readShort());
write(in.readShort());
write(in.readShort());
}
break;
case 0x18:
write(packetId);
write(in.readInt());
write(in.readByte());
write(in.readInt());
write(in.readInt());
write(in.readInt());
write(in.readByte());
write(in.readByte());
write(in.readByte());
write(in.readShort());
write(in.readShort());
write(in.readShort());
copyUnknownBlob();
break;
case 0x19:
write(packetId);
write(in.readInt());
write(readUTF16());
write(in.readInt());
write(in.readInt());
write(in.readInt());
write(in.readInt());
break;
case 0x1a:
write(packetId);
write(in.readInt());
write(in.readInt());
write(in.readInt());
write(in.readInt());
write(in.readShort());
break;
case 0x1c:
write(packetId);
copyNBytes(10);
break;
case 0x1d:
write(packetId);
byte destoryCount=write(in.readByte());
if (destoryCount > 0) {
copyNBytes(destoryCount * 4);
}
break;
case 0x1e:
write(packetId);
copyNBytes(4);
break;
case 0x1f:
write(packetId);
copyNBytes(7);
break;
case 0x20:
write(packetId);
copyNBytes(6);
break;
case 0x21:
write(packetId);
copyNBytes(9);
break;
case 0x22:
write(packetId);
copyNBytes(18);
break;
case 0x23:
write(packetId);
write(in.readInt());
write(in.readByte());
break;
case 0x26:
write(packetId);
copyNBytes(5);
break;
case 0x27:
write(packetId);
copyNBytes(8);
break;
case 0x28:
write(packetId);
write(in.readInt());
copyUnknownBlob();
break;
case 0x29:
write(packetId);
write(in.readInt());
write(in.readByte());
write(in.readByte());
write(in.readShort());
break;
case 0x2a:
write(packetId);
write(in.readInt());
write(in.readByte());
break;
case 0x2b:
write(packetId);
player.updateExperience(write(in.readFloat()),write(in.readShort()),write(in.readShort()));
break;
case 0x33:
write(packetId);
write(in.readInt());
write(in.readInt());
write(in.readBoolean());
write(in.readShort());
write(in.readShort());
copyNBytes(write(in.readInt()));
break;
case 0x34:
write(packetId);
write(in.readInt());
write(in.readInt());
write(in.readShort());
copyNBytes(write(in.readInt()));
break;
case 0x35:
write(packetId);
x=in.readInt();
y=in.readByte();
z=in.readInt();
short blockType=in.readShort();
byte metadata=in.readByte();
coordinate=new Coordinate(x,y,z,player);
if (blockType == 54 && player.placedChest(coordinate)) {
lockChest(coordinate);
player.placingChest(null);
}
write(x);
write(y);
write(z);
write(blockType);
write(metadata);
break;
case 0x36:
write(packetId);
copyNBytes(14);
break;
case 0x37:
write(packetId);
write(in.readInt());
write(in.readInt());
write(in.readInt());
write(in.readInt());
write(in.readByte());
break;
case 0x38:
write(packetId);
copyNBytes(write(in.readShort()) * 12 + write(in.readInt()));
break;
case 0x3c:
write(packetId);
copyNBytes(28);
int recordCount=in.readInt();
write(recordCount);
copyNBytes(recordCount * 3);
write(in.readFloat());
write(in.readFloat());
write(in.readFloat());
break;
case 0x3d:
write(packetId);
write(in.readInt());
write(in.readInt());
write(in.readByte());
write(in.readInt());
write(in.readInt());
write(in.readByte());
break;
case 0x3e:
write(packetId);
write(readUTF16());
write(in.readInt());
write(in.readInt());
write(in.readInt());
write(in.readFloat());
write(in.readByte());
break;
case 0x46:
write(packetId);
write(in.readByte());
write(in.readByte());
break;
case 0x47:
write(packetId);
copyNBytes(17);
break;
case 0x64:
boolean allow=true;
byte id=in.readByte();
byte invtype=in.readByte();
String typeString=readUTF16();
byte unknownByte=in.readByte();
if (invtype == 0) {
Chest adjacent=server.data.chests.adjacentChest(player.openedChest());
if (!server.data.chests.isChest(player.openedChest())) {
if (adjacent == null) {
server.data.chests.addOpenChest(player.openedChest());
}
 else {
server.data.chests.giveLock(adjacent.owner,player.openedChest(),adjacent.name);
}
server.data.save();
}
if (!player.getGroup().ignoreAreas && (!server.config.blockPermission(player,player.openedChest()).chest || (adjacent != null && !server.config.blockPermission(player,adjacent.coordinate).chest))) {
player.addTMessage(Color.RED,"String_Node_Str");
allow=false;
}
 else if (server.data.chests.canOpen(player,player.openedChest()) || player.ignoresChestLocks()) {
if (server.data.chests.isLocked(player.openedChest())) {
if (player.isAttemptingUnlock()) {
server.data.chests.unlock(player.openedChest());
server.data.save();
player.setAttemptedAction(null);
player.addTMessage(Color.RED,"String_Node_Str");
typeString=t("String_Node_Str");
}
 else {
typeString=server.data.chests.chestName(player.openedChest());
}
}
 else {
typeString=t("String_Node_Str");
if (player.isAttemptLock()) {
lockChest(player.openedChest());
typeString=(player.nextChestName() == null) ? t("String_Node_Str") : player.nextChestName();
}
}
}
 else {
player.addTMessage(Color.RED,"String_Node_Str");
allow=false;
}
}
if (!allow) {
write((byte)0x65);
write(id);
}
 else {
write(packetId);
write(id);
write(invtype);
write(typeString);
write(unknownByte);
}
break;
case 0x65:
write(packetId);
write(in.readByte());
break;
case 0x66:
write(packetId);
write(in.readByte());
write(in.readShort());
write(in.readByte());
write(in.readShort());
write(in.readByte());
copyItem();
break;
case 0x67:
write(packetId);
write(in.readByte());
write(in.readShort());
copyItem();
break;
case 0x68:
write(packetId);
write(in.readByte());
short count=write(in.readShort());
for (int c=0; c < count; ++c) {
copyItem();
}
break;
case 0x69:
write(packetId);
write(in.readByte());
write(in.readShort());
write(in.readShort());
break;
case 0x6a:
write(packetId);
write(in.readByte());
write(in.readShort());
write(in.readByte());
break;
case 0x6b:
write(packetId);
write(in.readShort());
copyItem();
break;
case 0x6c:
write(packetId);
write(in.readByte());
write(in.readByte());
break;
case (byte)0x82:
write(packetId);
write(in.readInt());
write(in.readShort());
write(in.readInt());
write(readUTF16());
write(readUTF16());
write(readUTF16());
write(readUTF16());
break;
case (byte)0x83:
write(packetId);
write(in.readShort());
write(in.readShort());
short length=in.readShort();
write(length);
copyNBytes(length);
break;
case (byte)0x84:
write(packetId);
write(in.readInt());
write(in.readShort());
write(in.readInt());
write(in.readByte());
short nbtLength=write(in.readShort());
if (nbtLength > 0) {
copyNBytes(nbtLength);
}
break;
case (byte)0xc3:
write(packetId);
write(in.readInt());
copyNBytes(write(in.readInt()));
break;
case (byte)0xc8:
write(packetId);
copyNBytes(5);
break;
case (byte)0xc9:
write(packetId);
write(readUTF16());
write(in.readByte());
write(in.readShort());
break;
case (byte)0xca:
write(packetId);
write(in.readByte());
write(in.readByte());
write(in.readByte());
break;
case (byte)0xcb:
write(packetId);
write(readUTF16());
break;
case (byte)0xcc:
write(packetId);
write(readUTF16());
write(in.readByte());
write(in.readByte());
write(in.readByte());
write(in.readBoolean());
break;
case (byte)0xcd:
write(packetId);
write(in.readByte());
break;
case (byte)0xd3:
write(packetId);
copyNBytes(1);
copyVLC();
copyVLC();
copyVLC();
copyNBytes((int)copyVLC());
break;
case (byte)0xe6:
write(packetId);
write(in.readInt());
write(in.readInt());
copyNBytes(write(in.readInt()) * 4);
copyNBytes(write(in.readInt()) * 4);
copyNBytes(write(in.readInt()) * 8);
int sizeString=write(in.readInt());
for (int i=0; i < sizeString; i++) {
copyNBytes(write(in.readInt()));
}
break;
case (byte)0xfa:
write(packetId);
write(readUTF16());
copyNBytes(write(in.readShort()));
break;
case (byte)0xfc:
byte[] sharedKey=new byte[in.readShort()];
in.readFully(sharedKey);
byte[] challengeTokenResponse=new byte[in.readShort()];
in.readFully(challengeTokenResponse);
if (!isServerTunnel) {
if (!player.clientEncryption.checkChallengeToken(challengeTokenResponse)) {
player.kick("String_Node_Str");
break;
}
player.clientEncryption.setEncryptedSharedKey(sharedKey);
sharedKey=player.serverEncryption.getEncryptedSharedKey();
}
if (!isServerTunnel && server.authenticator.useCustAuth(player) && !server.authenticator.onlineAuthenticate(player)) {
player.kick(t("String_Node_Str","String_Node_Str"));
break;
}
write(packetId);
write((short)sharedKey.length);
write(sharedKey);
challengeTokenResponse=player.serverEncryption.encryptChallengeToken();
write((short)challengeTokenResponse.length);
write(challengeTokenResponse);
if (isServerTunnel) {
in=new DataInputStream(new BufferedInputStream(player.serverEncryption.encryptedInputStream(inputStream)));
out=new DataOutputStream(new BufferedOutputStream(player.clientEncryption.encryptedOutputStream(outputStream)));
}
 else {
in=new DataInputStream(new BufferedInputStream(player.clientEncryption.encryptedInputStream(inputStream)));
out=new DataOutputStream(new BufferedOutputStream(player.serverEncryption.encryptedOutputStream(outputStream)));
}
break;
case (byte)0xfd:
tunneler.setName(streamType + "String_Node_Str" + player.getName());
write(packetId);
String serverId=readUTF16();
if (!server.authenticator.useCustAuth(player)) {
serverId="String_Node_Str";
}
 else {
serverId=player.getConnectionHash();
}
write(serverId);
byte[] keyBytes=new byte[in.readShort()];
in.readFully(keyBytes);
byte[] challengeToken=new byte[in.readShort()];
in.readFully(challengeToken);
player.serverEncryption.setPublicKey(keyBytes);
byte[] key=player.clientEncryption.getPublicKey();
write((short)key.length);
write(key);
write((short)challengeToken.length);
write(challengeToken);
player.serverEncryption.setChallengeToken(challengeToken);
player.clientEncryption.setChallengeToken(challengeToken);
break;
case (byte)0xfe:
write(packetId);
write(in.readByte());
break;
case (byte)0xff:
write(packetId);
String reason=readUTF16();
if (reason.startsWith("String_Node_Str")) {
reason=String.format("String_Node_Str",Main.protocolVersion,Main.minecraftVersion,server.config.properties.get("String_Node_Str"),server.playerList.size(),server.config.properties.getInt("String_Node_Str"));
}
write(reason);
if (reason.startsWith("String_Node_Str")) {
server.addRobot(player);
}
player.close();
break;
default :
if (EXPENSIVE_DEBUG_LOGGING) {
while (true) {
skipNBytes(1);
flushAll();
}
}
 else {
if (lastPacket != null) {
throw new IOException("String_Node_Str" + streamType + "String_Node_Str"+ Integer.toHexString(packetId)+ "String_Node_Str"+ player.getName()+ "String_Node_Str"+ Integer.toHexString(lastPacket));
}
 else {
throw new IOException("String_Node_Str" + streamType + "String_Node_Str"+ Integer.toHexString(packetId)+ "String_Node_Str"+ player.getName());
}
}
}
packetFinished();
lastPacket=(packetId == 0x00) ? lastPacket : packetId;
}