Program: 150427
Project: 150427
Buggy source:
private void handlePacket() throws IOException {
  Byte packetId=in.readByte();
  int x;
  byte y;
  int z;
switch (packetId) {
case 0x00:
    write(packetId);
  break;
case 0x01:
write(packetId);
if (isServerTunnel) {
player.setEntityId(in.readInt());
write(player.getEntityId());
}
 else {
write(in.readInt());
}
write(in.readUTF());
write(in.readUTF());
write(in.readLong());
write(in.readByte());
break;
case 0x02:
String name=in.readUTF();
if (isServerTunnel || player.setName(name)) {
tunneler.setName(streamType + "String_Node_Str" + player.getName());
write(packetId);
write(name);
}
break;
case 0x03:
String message=in.readUTF();
if (isServerTunnel && server.options.getBoolean("String_Node_Str")) {
Matcher colorMatcher=COLOR_PATTERN.matcher(message);
String cleanMessage=colorMatcher.replaceAll("String_Node_Str");
Matcher messageMatcher=MESSAGE_PATTERN.matcher(cleanMessage);
if (messageMatcher.find()) {
Player friend=server.findPlayerExact(messageMatcher.group(1));
if (friend != null) {
String color="String_Node_Str";
String title="String_Node_Str";
String format=server.options.get("String_Node_Str");
Group group=friend.getGroup();
if (group != null) {
color=group.getColor();
if (group.showTitle()) {
title=group.getName();
format=server.options.get("String_Node_Str");
}
}
try {
message=String.format(format,friend.getName(),title,color) + messageMatcher.group(2);
}
 catch (IllegalFormatException e) {
System.out.println("String_Node_Str");
}
}
}
}
if (!isServerTunnel) {
if (player.isMuted() && !message.startsWith("String_Node_Str") && !message.startsWith("String_Node_Str")) {
player.addMessage("String_Node_Str");
break;
}
if (player.parseCommand(message)) {
break;
}
if (player.localChat() && !message.startsWith("String_Node_Str") && !message.startsWith("String_Node_Str")) {
player.execute(LocalSayCommand.class,message);
break;
}
}
write(packetId);
write(message);
break;
case 0x04:
write(packetId);
copyNBytes(8);
break;
case 0x05:
write(packetId);
write(in.readInt());
write(in.readShort());
write(in.readShort());
write(in.readShort());
break;
case 0x06:
write(packetId);
copyNBytes(12);
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);
write(in.readBoolean());
break;
case 0x08:
write(packetId);
copyNBytes(2);
break;
case 0x09:
write(packetId);
break;
case 0x0a:
write(packetId);
copyNBytes(1);
if (!inGame && !isServerTunnel) {
player.sendMOTD();
if (server.options.getBoolean("String_Node_Str")) {
player.execute(PlayerListCommand.class);
}
inGame=true;
}
break;
case 0x0b:
write(packetId);
copyPlayerLocation();
break;
case 0x0c:
write(packetId);
copyNBytes(9);
break;
case 0x0d:
write(packetId);
copyPlayerLocation();
copyNBytes(8);
break;
case 0x0e:
if (!isServerTunnel) {
if (player.getGroupId() < 0) {
skipNBytes(11);
}
 else {
byte status=in.readByte();
x=in.readInt();
y=in.readByte();
z=in.readInt();
byte face=in.readByte();
if (!server.chests.isLocked(x,y,z) || player.isAdmin()) {
if (server.chests.isLocked(x,y,z) && status == BLOCK_DESTROYED_STATUS) {
server.chests.releaseLock(x,y,z);
}
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();
final byte direction=in.readByte();
final short dropItem=in.readShort();
byte itemCount=0;
short uses=0;
if (dropItem != -1) {
itemCount=in.readByte();
uses=in.readShort();
}
boolean writePacket=true;
boolean drop=false;
if (isServerTunnel || server.chests.isChest(x,y,z)) {
}
 else if ((player.getGroupId() < 0) || !server.blockFirewall.playerAllowed(player,dropItem)) {
String badBlock=String.format(server.l.get("String_Node_Str"),player.getName(),Short.toString(dropItem));
server.runCommand("String_Node_Str",badBlock);
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;
}
Chest adjacentChest=server.chests.adjacentChest(xPosition,yPosition,zPosition);
if (adjacentChest != null && !adjacentChest.isOpen() && !adjacentChest.ownedBy(player)) {
player.addMessage("String_Node_Str");
writePacket=false;
drop=true;
}
 else {
player.placingChest(new Coordinate(xPosition,yPosition,zPosition));
}
}
if (writePacket) {
write(packetId);
write(x);
write(y);
write(z);
write(direction);
write(dropItem);
if (dropItem != -1) {
write(itemCount);
write(uses);
if (dropItem <= 94 && direction >= 0) {
player.placedBlock();
}
}
player.openingChest(x,y,z);
}
 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:
write(packetId);
write(in.readInt());
write(in.readUTF());
copyNBytes(16);
break;
case 0x15:
if (player.getGroupId() < 0) {
skipNBytes(24);
break;
}
write(packetId);
copyNBytes(24);
break;
case 0x16:
write(packetId);
copyNBytes(8);
break;
case 0x17:
write(packetId);
copyNBytes(17);
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());
copyUnknownBlob();
break;
case 0x19:
write(packetId);
write(in.readInt());
write(in.readUTF());
write(in.readInt());
write(in.readInt());
write(in.readInt());
write(in.readInt());
break;
case 0x1b:
write(packetId);
copyNBytes(18);
break;
case 0x1c:
write(packetId);
copyNBytes(10);
break;
case 0x1d:
write(packetId);
copyNBytes(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 0x26:
write(packetId);
copyNBytes(5);
break;
case 0x27:
write(packetId);
copyNBytes(8);
break;
case 0x28:
write(packetId);
write(in.readInt());
copyUnknownBlob();
break;
case 0x32:
write(packetId);
copyNBytes(9);
break;
case 0x33:
write(packetId);
copyNBytes(13);
int chunkSize=in.readInt();
write(chunkSize);
copyNBytes(chunkSize);
break;
case 0x34:
write(packetId);
copyNBytes(8);
short arraySize=in.readShort();
write(arraySize);
copyNBytes(arraySize * 4);
break;
case 0x35:
write(packetId);
x=in.readInt();
y=in.readByte();
z=in.readInt();
byte blockType=in.readByte();
byte metadata=in.readByte();
if (blockType == 54 && player.placedChest(x,y,z)) {
lockChest(x,y,z);
player.placingChest(null);
}
write(x);
write(y);
write(z);
write(blockType);
write(metadata);
break;
case 0x36:
write(packetId);
copyNBytes(12);
break;
case 0x3c:
write(packetId);
copyNBytes(28);
int recordCount=in.readInt();
write(recordCount);
copyNBytes(recordCount * 3);
break;
case 0x46:
write(packetId);
copyNBytes(1);
break;
case 0x64:
byte id=in.readByte();
byte invtype=in.readByte();
String typeString=in.readUTF();
if (invtype == 0) {
if (server.chests.canOpen(player,player.openedChest()) || player.isAdmin()) {
if (server.chests.isLocked(player.openedChest())) {
if (player.isAttemptingUnlock()) {
server.chests.unlock(player.openedChest());
player.setAttemptedAction(null);
player.addMessage("String_Node_Str");
typeString="String_Node_Str";
}
 else {
typeString=server.chests.chestName(player.openedChest());
}
}
 else {
typeString="String_Node_Str";
if (player.isAttemptLock()) {
lockChest(player.openedChest());
typeString=player.nextChestName();
}
}
}
 else {
player.addMessage("String_Node_Str");
in.readByte();
break;
}
}
write(packetId);
write(id);
write(invtype);
write(typeString);
write(in.readByte());
break;
case 0x65:
write(packetId);
write(in.readByte());
break;
case 0x66:
byte typeFrom=in.readByte();
short slotFrom=in.readShort();
byte typeTo=in.readByte();
short slotTo=in.readShort();
if ((typeFrom < 0 && typeTo < 0) || player.getGroupId() >= 0) {
write(packetId);
write(typeFrom);
write(slotFrom);
write(typeTo);
write(slotTo);
short moveItem=in.readShort();
write(moveItem);
if (moveItem != -1) {
write(in.readByte());
write(in.readShort());
}
}
 else {
short moveItem=in.readShort();
if (moveItem != -1) {
in.readByte();
in.readShort();
}
}
break;
case 0x67:
byte type67=in.readByte();
if (type67 < 0 || player.getGroupId() >= 0) {
write(packetId);
short slot=in.readShort();
write(type67);
write(slot);
short setItem=in.readShort();
write(setItem);
if (setItem != -1) {
write(in.readByte());
write(in.readShort());
}
}
 else {
in.readShort();
short setItem=in.readShort();
if (setItem != -1) {
in.readByte();
in.readShort();
}
}
break;
case 0x68:
byte type=in.readByte();
if (type < 0 || player.getGroupId() >= 0) {
write(packetId);
write(type);
short count=in.readShort();
write(count);
for (int c=0; c < count; ++c) {
short item=in.readShort();
write(item);
if (item != -1) {
write(in.readByte());
write(in.readShort());
}
}
}
 else {
short count=in.readShort();
for (int c=0; c < count; ++c) {
short item=in.readShort();
if (item != -1) {
in.readByte();
in.readShort();
}
}
}
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 (byte)0x82:
write(packetId);
write(in.readInt());
write(in.readShort());
write(in.readInt());
write(in.readUTF());
write(in.readUTF());
write(in.readUTF());
write(in.readUTF());
break;
case (byte)0xff:
write(packetId);
String reason=in.readUTF();
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 {
throw new IOException("String_Node_Str" + streamType + "String_Node_Str"+ Integer.toHexString(packetId)+ "String_Node_Str"+ player.getName());
}
}
packetFinished();
}

Fixed version (ground truth):
private void handlePacket() throws IOException {
  Byte packetId=in.readByte();
  int x;
  byte y;
  int z;
switch (packetId) {
case 0x00:
    write(packetId);
  break;
case 0x01:
write(packetId);
if (isServerTunnel) {
player.setEntityId(in.readInt());
write(player.getEntityId());
}
 else {
write(in.readInt());
}
write(readUTF16());
write(in.readLong());
write(in.readByte());
break;
case 0x02:
String name=readUTF16();
if (isServerTunnel || player.setName(name)) {
tunneler.setName(streamType + "String_Node_Str" + player.getName());
write(packetId);
write(name);
}
break;
case 0x03:
String message=readUTF16();
System.out.println(message);
if (isServerTunnel && server.options.getBoolean("String_Node_Str")) {
Matcher colorMatcher=COLOR_PATTERN.matcher(message);
String cleanMessage=colorMatcher.replaceAll("String_Node_Str");
Matcher messageMatcher=MESSAGE_PATTERN.matcher(cleanMessage);
if (messageMatcher.find()) {
Player friend=server.findPlayerExact(messageMatcher.group(1));
if (friend != null) {
String color="String_Node_Str";
String title="String_Node_Str";
String format=server.options.get("String_Node_Str");
Group group=friend.getGroup();
if (group != null) {
color=group.getColor();
if (group.showTitle()) {
title=group.getName();
format=server.options.get("String_Node_Str");
}
}
try {
message=String.format(format,friend.getName(),title,color) + messageMatcher.group(2);
}
 catch (IllegalFormatException e) {
System.out.println("String_Node_Str");
}
}
}
}
if (!isServerTunnel) {
if (player.isMuted() && !message.startsWith("String_Node_Str") && !message.startsWith("String_Node_Str")) {
player.addMessage("String_Node_Str");
break;
}
if (player.parseCommand(message)) {
break;
}
if (player.localChat() && !message.startsWith("String_Node_Str") && !message.startsWith("String_Node_Str")) {
player.execute(LocalSayCommand.class,message);
break;
}
}
write(packetId);
write(message);
break;
case 0x04:
write(packetId);
copyNBytes(8);
break;
case 0x05:
write(packetId);
write(in.readInt());
write(in.readShort());
write(in.readShort());
write(in.readShort());
break;
case 0x06:
write(packetId);
copyNBytes(12);
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);
write(in.readBoolean());
break;
case 0x08:
write(packetId);
copyNBytes(2);
break;
case 0x09:
write(packetId);
break;
case 0x0a:
write(packetId);
copyNBytes(1);
if (!inGame && !isServerTunnel) {
player.sendMOTD();
if (server.options.getBoolean("String_Node_Str")) {
player.execute(PlayerListCommand.class);
}
inGame=true;
}
break;
case 0x0b:
write(packetId);
copyPlayerLocation();
break;
case 0x0c:
write(packetId);
copyNBytes(9);
break;
case 0x0d:
write(packetId);
copyPlayerLocation();
copyNBytes(8);
break;
case 0x0e:
if (!isServerTunnel) {
if (player.getGroupId() < 0) {
skipNBytes(11);
}
 else {
byte status=in.readByte();
x=in.readInt();
y=in.readByte();
z=in.readInt();
byte face=in.readByte();
if (!server.chests.isLocked(x,y,z) || player.isAdmin()) {
if (server.chests.isLocked(x,y,z) && status == BLOCK_DESTROYED_STATUS) {
server.chests.releaseLock(x,y,z);
}
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();
final byte direction=in.readByte();
final short dropItem=in.readShort();
byte itemCount=0;
short uses=0;
if (dropItem != -1) {
itemCount=in.readByte();
uses=in.readShort();
}
boolean writePacket=true;
boolean drop=false;
if (isServerTunnel || server.chests.isChest(x,y,z)) {
}
 else if ((player.getGroupId() < 0) || !server.blockFirewall.playerAllowed(player,dropItem)) {
String badBlock=String.format(server.l.get("String_Node_Str"),player.getName(),Short.toString(dropItem));
server.runCommand("String_Node_Str",badBlock);
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;
}
Chest adjacentChest=server.chests.adjacentChest(xPosition,yPosition,zPosition);
if (adjacentChest != null && !adjacentChest.isOpen() && !adjacentChest.ownedBy(player)) {
player.addMessage("String_Node_Str");
writePacket=false;
drop=true;
}
 else {
player.placingChest(new Coordinate(xPosition,yPosition,zPosition));
}
}
if (writePacket) {
write(packetId);
write(x);
write(y);
write(z);
write(direction);
write(dropItem);
if (dropItem != -1) {
write(itemCount);
write(uses);
if (dropItem <= 94 && direction >= 0) {
player.placedBlock();
}
}
player.openingChest(x,y,z);
}
 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:
write(packetId);
write(in.readInt());
write(readUTF16());
copyNBytes(16);
break;
case 0x15:
if (player.getGroupId() < 0) {
skipNBytes(24);
break;
}
write(packetId);
copyNBytes(24);
break;
case 0x16:
write(packetId);
copyNBytes(8);
break;
case 0x17:
write(packetId);
copyNBytes(17);
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());
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 0x1b:
write(packetId);
copyNBytes(18);
break;
case 0x1c:
write(packetId);
copyNBytes(10);
break;
case 0x1d:
write(packetId);
copyNBytes(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 0x26:
write(packetId);
copyNBytes(5);
break;
case 0x27:
write(packetId);
copyNBytes(8);
break;
case 0x28:
write(packetId);
write(in.readInt());
copyUnknownBlob();
break;
case 0x32:
write(packetId);
copyNBytes(9);
break;
case 0x33:
write(packetId);
copyNBytes(13);
int chunkSize=in.readInt();
write(chunkSize);
copyNBytes(chunkSize);
break;
case 0x34:
write(packetId);
copyNBytes(8);
short arraySize=in.readShort();
write(arraySize);
copyNBytes(arraySize * 4);
break;
case 0x35:
write(packetId);
x=in.readInt();
y=in.readByte();
z=in.readInt();
byte blockType=in.readByte();
byte metadata=in.readByte();
if (blockType == 54 && player.placedChest(x,y,z)) {
lockChest(x,y,z);
player.placingChest(null);
}
write(x);
write(y);
write(z);
write(blockType);
write(metadata);
break;
case 0x36:
write(packetId);
copyNBytes(12);
break;
case 0x3c:
write(packetId);
copyNBytes(28);
int recordCount=in.readInt();
write(recordCount);
copyNBytes(recordCount * 3);
break;
case 0x46:
write(packetId);
copyNBytes(1);
break;
case 0x47:
write(packetId);
copyNBytes(17);
break;
case 0x64:
byte id=in.readByte();
byte invtype=in.readByte();
String typeString=in.readUTF();
if (invtype == 0) {
if (server.chests.canOpen(player,player.openedChest()) || player.isAdmin()) {
if (server.chests.isLocked(player.openedChest())) {
if (player.isAttemptingUnlock()) {
server.chests.unlock(player.openedChest());
player.setAttemptedAction(null);
player.addMessage("String_Node_Str");
typeString="String_Node_Str";
}
 else {
typeString=server.chests.chestName(player.openedChest());
}
}
 else {
typeString="String_Node_Str";
if (player.isAttemptLock()) {
lockChest(player.openedChest());
typeString=player.nextChestName();
}
}
}
 else {
player.addMessage("String_Node_Str");
in.readByte();
break;
}
}
write(packetId);
write(id);
write(invtype);
write8(typeString);
write(in.readByte());
break;
case 0x65:
write(packetId);
write(in.readByte());
break;
case 0x66:
byte typeFrom=in.readByte();
short slotFrom=in.readShort();
byte typeTo=in.readByte();
short slotTo=in.readShort();
if ((typeFrom < 0 && typeTo < 0) || player.getGroupId() >= 0) {
write(packetId);
write(typeFrom);
write(slotFrom);
write(typeTo);
write(slotTo);
write(in.readBoolean());
short moveItem=in.readShort();
write(moveItem);
if (moveItem != -1) {
write(in.readByte());
write(in.readShort());
}
}
 else {
short moveItem=in.readShort();
if (moveItem != -1) {
in.readByte();
in.readShort();
}
}
break;
case 0x67:
byte type67=in.readByte();
if (type67 < 0 || player.getGroupId() >= 0) {
write(packetId);
short slot=in.readShort();
write(type67);
write(slot);
short setItem=in.readShort();
write(setItem);
if (setItem != -1) {
write(in.readByte());
write(in.readShort());
}
}
 else {
in.readShort();
short setItem=in.readShort();
if (setItem != -1) {
in.readByte();
in.readShort();
}
}
break;
case 0x68:
byte type=in.readByte();
if (type < 0 || player.getGroupId() >= 0) {
write(packetId);
write(type);
short count=in.readShort();
write(count);
for (int c=0; c < count; ++c) {
short item=in.readShort();
write(item);
if (item != -1) {
write(in.readByte());
write(in.readShort());
}
}
}
 else {
short count=in.readShort();
for (int c=0; c < count; ++c) {
short item=in.readShort();
if (item != -1) {
in.readByte();
in.readShort();
}
}
}
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 (byte)0x82:
write(packetId);
write(in.readInt());
write(in.readShort());
write(in.readInt());
write(readUTF16());
write(readUTF16());
write(readUTF16());
write(readUTF16());
break;
case (byte)0xc6:
write(packetId);
copyNBytes(5);
break;
case (byte)0xff:
write(packetId);
String reason=readUTF16();
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 {
throw new IOException("String_Node_Str" + streamType + "String_Node_Str"+ Integer.toHexString(packetId)+ "String_Node_Str"+ player.getName());
}
}
packetFinished();
}