Improved packet handling

This commit is contained in:
Tahg
2011-05-27 11:01:37 -04:00
committed by Erik Broes
parent 1784e42d5f
commit 9ec5d8b5df
2 changed files with 11 additions and 1 deletions

View File

@@ -69,6 +69,11 @@ public abstract class Packet {
int i;
try {
// CraftBukkit start - sleep while nothing to do
while(datainputstream.available() <= 0) {
Thread.sleep(10);
}
// CraftBukkit end
i = datainputstream.read();
if (i == -1) {
return null;
@@ -97,6 +102,10 @@ public abstract class Packet {
System.out.println("Connection reset");
return null;
}
catch (InterruptedException exception) {
System.out.println("Thread exception");
return null;
}
// CraftBukkit end
PacketCounter packetcounter = (PacketCounter) e.get(Integer.valueOf(i));