Program: 150434
Project: 150434
Buggy source:
private void handlePacket() throws IOException {
  Byte packetId=in.readByte();
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 messageMatcher=MESSAGE_PATTERN.matcher(message);
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;
}
}
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());
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();
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();
int x=in.readInt();
byte y=in.readByte();
int z=in.readInt();
byte face=in.readByte();
if (!server.chests.hasLock(x,y,z) || player.isAdmin()) {
if (server.chests.hasLock(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()) {
for (int c=1; c < DESTROY_HITS; ++c) {
packetFinished();
write(packetId);
write(status);
write(x);
write(y);
write(z);
write(face);
}
packetFinished();
write(packetId);
write(BLOCK_DESTROYED_STATUS);
write(x);
write(y);
write(z);
write(face);
}
}
}
}
 else {
write(packetId);
copyNBytes(11);
}
break;
case 0x0f:
final int x=in.readInt();
final byte y=in.readByte();
final int z=in.readInt();
final byte direction=in.readByte();
final short dropItem=in.readShort();
byte itemCount=0;
byte uses=0;
if (dropItem != -1) {
itemCount=in.readByte();
uses=in.readByte();
}
boolean writePacket=true;
if (isServerTunnel) {
}
 else if (server.chests.hasLock(x,y,z) && !player.isAdmin() && !server.chests.ownsLock(player.getName(),x,y,z)) {
player.addMessage("String_Node_Str");
writePacket=false;
}
 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;
}
 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;
}
if (server.chests.hasAdjacentLock(xPosition,yPosition,zPosition)) {
player.addMessage("String_Node_Str");
writePacket=false;
}
 else if (player.isAttemptLock()) {
if (server.chests.hasLock(xPosition,yPosition,zPosition)) {
player.addMessage("String_Node_Str");
}
 else if (server.chests.giveLock(player.getName(),xPosition,yPosition,zPosition,false)) {
player.addMessage("String_Node_Str");
}
 else {
player.addMessage("String_Node_Str");
}
player.setAttemptLock(false);
}
}
if (writePacket) {
write(packetId);
write(x);
write(y);
write(z);
write(direction);
write(dropItem);
if (dropItem != -1) {
write(itemCount);
write(uses);
}
}
break;
case 0x10:
write(packetId);
copyNBytes(2);
break;
case 0x12:
write(packetId);
copyNBytes(5);
break;
case 0x14:
write(packetId);
write(in.readInt());
write(in.readUTF());
copyNBytes(16);
break;
case 0x15:
if (player.getGroupId() < 0) {
skipNBytes(22);
break;
}
write(packetId);
copyNBytes(22);
break;
case 0x16:
write(packetId);
copyNBytes(8);
break;
case 0x17:
write(packetId);
copyNBytes(17);
break;
case 0x18:
write(packetId);
copyNBytes(19);
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 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);
copyNBytes(11);
break;
case 0x3c:
write(packetId);
copyNBytes(28);
int recordCount=in.readInt();
write(recordCount);
copyNBytes(recordCount * 3);
break;
case 0x64:
write(packetId);
write(in.readByte());
write(in.readByte());
write(in.readUTF());
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.readByte());
}
}
 else {
short moveItem=in.readShort();
if (moveItem != -1) {
in.readByte();
in.readByte();
}
}
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.readByte());
}
}
 else {
in.readShort();
short setItem=in.readShort();
if (setItem != -1) {
in.readByte();
in.readByte();
}
}
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();
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 messageMatcher=MESSAGE_PATTERN.matcher(message);
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;
}
}
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());
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();
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();
int x=in.readInt();
byte y=in.readByte();
int z=in.readInt();
byte face=in.readByte();
if (!server.chests.hasLock(x,y,z) || player.isAdmin()) {
if (server.chests.hasLock(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()) {
for (int c=1; c < DESTROY_HITS; ++c) {
packetFinished();
write(packetId);
write(status);
write(x);
write(y);
write(z);
write(face);
}
packetFinished();
write(packetId);
write(BLOCK_DESTROYED_STATUS);
write(x);
write(y);
write(z);
write(face);
}
}
}
}
 else {
write(packetId);
copyNBytes(11);
}
break;
case 0x0f:
final int x=in.readInt();
final byte y=in.readByte();
final int z=in.readInt();
final byte direction=in.readByte();
final short dropItem=in.readShort();
byte itemCount=0;
byte uses=0;
if (dropItem != -1) {
itemCount=in.readByte();
uses=in.readByte();
}
boolean writePacket=true;
if (isServerTunnel) {
}
 else if (server.chests.hasLock(x,y,z) && !player.isAdmin() && !server.chests.ownsLock(player.getName(),x,y,z)) {
player.addMessage("String_Node_Str");
writePacket=false;
}
 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);
write((byte)0x0e);
write((byte)0x04);
write(x);
write(y);
write(z);
write(direction);
writePacket=false;
}
 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;
}
if (server.chests.hasAdjacentLock(xPosition,yPosition,zPosition)) {
player.addMessage("String_Node_Str");
writePacket=false;
}
 else if (player.isAttemptLock()) {
if (server.chests.hasLock(xPosition,yPosition,zPosition)) {
player.addMessage("String_Node_Str");
}
 else if (server.chests.giveLock(player.getName(),xPosition,yPosition,zPosition,false)) {
player.addMessage("String_Node_Str");
}
 else {
player.addMessage("String_Node_Str");
}
player.setAttemptLock(false);
}
}
if (writePacket) {
write(packetId);
write(x);
write(y);
write(z);
write(direction);
write(dropItem);
if (dropItem != -1) {
write(itemCount);
write(uses);
}
}
break;
case 0x10:
write(packetId);
copyNBytes(2);
break;
case 0x12:
write(packetId);
copyNBytes(5);
break;
case 0x14:
write(packetId);
write(in.readInt());
write(in.readUTF());
copyNBytes(16);
break;
case 0x15:
if (player.getGroupId() < 0) {
skipNBytes(22);
break;
}
write(packetId);
copyNBytes(22);
break;
case 0x16:
write(packetId);
copyNBytes(8);
break;
case 0x17:
write(packetId);
copyNBytes(17);
break;
case 0x18:
write(packetId);
copyNBytes(19);
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 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);
copyNBytes(11);
break;
case 0x3c:
write(packetId);
copyNBytes(28);
int recordCount=in.readInt();
write(recordCount);
copyNBytes(recordCount * 3);
break;
case 0x64:
write(packetId);
write(in.readByte());
write(in.readByte());
write(in.readUTF());
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.readByte());
}
}
 else {
short moveItem=in.readShort();
if (moveItem != -1) {
in.readByte();
in.readByte();
}
}
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.readByte());
}
}
 else {
in.readShort();
short setItem=in.readShort();
if (setItem != -1) {
in.readByte();
in.readByte();
}
}
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();
}