Update CraftBukkit to 1.6.1

This commit is contained in:
Nate Mortensen
2013-07-01 06:03:00 -05:00
committed by Wesley Wolfe
parent f887b76a25
commit 6c09066e22
228 changed files with 6426 additions and 5442 deletions

View File

@@ -1,7 +1,7 @@
package net.minecraft.server;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.DataInput;
import java.io.DataOutput;
import java.io.EOFException;
import java.io.IOException;
import java.net.Socket;
@@ -10,6 +10,8 @@ import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import org.bukkit.craftbukkit.inventory.CraftItemStack; // CraftBukkit
public abstract class Packet {
public static IntHashMap l = new IntHashMap();
@@ -17,12 +19,12 @@ public abstract class Packet {
private static Set b = new HashSet();
private static Set c = new HashSet();
protected IConsoleLogManager m;
public final long timestamp = System.currentTimeMillis();
public final long timestamp = MinecraftServer.aq();
public static long o;
public static long p;
public static long q;
public static long r;
public boolean lowPriority = false;
public boolean lowPriority;
// CraftBukkit start - Calculate packet ID once - used a bunch of times
private int packetID;
@@ -61,20 +63,20 @@ public abstract class Packet {
}
}
public static void a(DataOutputStream dataoutputstream, byte[] abyte) throws IOException { // CraftBukkit - throws IOException
dataoutputstream.writeShort(abyte.length);
dataoutputstream.write(abyte);
public static void a(DataOutput dataoutput, byte[] abyte) throws IOException { // CraftBukkit - throws IOException
dataoutput.writeShort(abyte.length);
dataoutput.write(abyte);
}
public static byte[] b(DataInputStream datainputstream) throws IOException { // CraftBukkit - throws IOException
short short1 = datainputstream.readShort();
public static byte[] b(DataInput datainput) throws IOException { // CraftBukkit - throws IOException
short short1 = datainput.readShort();
if (short1 < 0) {
throw new IOException("Key was smaller than nothing! Weird key!");
} else {
byte[] abyte = new byte[short1];
datainputstream.readFully(abyte);
datainput.readFully(abyte);
return abyte;
}
}
@@ -83,7 +85,7 @@ public abstract class Packet {
return packetID; // ((Integer) a.get(this.getClass())).intValue(); // CraftBukkit
}
public static Packet a(IConsoleLogManager iconsolelogmanager, DataInputStream datainputstream, boolean flag, Socket socket) throws IOException { // CraftBukkit - throws IOException
public static Packet a(IConsoleLogManager iconsolelogmanager, DataInput datainput, boolean flag, Socket socket) throws IOException { // CraftBukkit - throws IOException
boolean flag1 = false;
Packet packet = null;
int i = socket.getSoTimeout();
@@ -91,11 +93,7 @@ public abstract class Packet {
int j;
try {
j = datainputstream.read();
if (j == -1) {
return null;
}
j = datainput.readUnsignedByte();
if (flag && !c.contains(Integer.valueOf(j)) || !flag && !b.contains(Integer.valueOf(j))) {
throw new IOException("Bad packet id " + j);
}
@@ -110,11 +108,11 @@ public abstract class Packet {
socket.setSoTimeout(1500);
}
packet.a(datainputstream);
packet.a(datainput);
++o;
p += (long) packet.a();
} catch (EOFException eofexception) {
iconsolelogmanager.severe("Reached end of stream");
iconsolelogmanager.severe("Reached end of stream for " + socket.getInetAddress());
return null;
}
@@ -135,24 +133,24 @@ public abstract class Packet {
return packet;
}
public static void a(Packet packet, DataOutputStream dataoutputstream) throws IOException { // CraftBukkit - throws IOException
dataoutputstream.write(packet.n());
packet.a(dataoutputstream);
public static void a(Packet packet, DataOutput dataoutput) throws IOException { // CraftBukkit - throws IOException
dataoutput.write(packet.n());
packet.a(dataoutput);
++q;
r += (long) packet.a();
}
public static void a(String s, DataOutputStream dataoutputstream) throws IOException { // CraftBukkit - throws IOException
public static void a(String s, DataOutput dataoutput) throws IOException { // CraftBukkit - throws IOException
if (s.length() > 32767) {
throw new IOException("String too big");
} else {
dataoutputstream.writeShort(s.length());
dataoutputstream.writeChars(s);
dataoutput.writeShort(s.length());
dataoutput.writeChars(s);
}
}
public static String a(DataInputStream datainputstream, int i) throws IOException { // CraftBukkit - throws IOException
short short1 = datainputstream.readShort();
public static String a(DataInput datainput, int i) throws IOException { // CraftBukkit - throws IOException
short short1 = datainput.readShort();
if (short1 > i) {
throw new IOException("Received string length longer than maximum allowed (" + short1 + " > " + i + ")");
@@ -162,16 +160,16 @@ public abstract class Packet {
StringBuilder stringbuilder = new StringBuilder();
for (int j = 0; j < short1; ++j) {
stringbuilder.append(datainputstream.readChar());
stringbuilder.append(datainput.readChar());
}
return stringbuilder.toString();
}
}
public abstract void a(DataInputStream datainputstream) throws IOException; // CraftBukkit - throws IOException
public abstract void a(DataInput datainput) throws IOException; // CraftBukkit - throws IOException
public abstract void a(DataOutputStream dataoutputstream) throws IOException; // CraftBukkit - throws IOException
public abstract void a(DataOutput dataoutput) throws IOException; // CraftBukkit - throws IOException
public abstract void handle(Connection connection);
@@ -186,7 +184,7 @@ public abstract class Packet {
}
public boolean a_() {
return false;
return this instanceof Packet3Chat && !((Packet3Chat) this).message.startsWith("/"); // CraftBukkit - async chat
}
public String toString() {
@@ -195,59 +193,64 @@ public abstract class Packet {
return s;
}
public static ItemStack c(DataInputStream datainputstream) throws IOException { // CraftBukkit - throws IOException
public static ItemStack c(DataInput datainput) throws IOException { // CraftBukkit - throws IOException
ItemStack itemstack = null;
short short1 = datainputstream.readShort();
short short1 = datainput.readShort();
if (short1 >= 0) {
byte b0 = datainputstream.readByte();
short short2 = datainputstream.readShort();
byte b0 = datainput.readByte();
short short2 = datainput.readShort();
itemstack = new ItemStack(short1, b0, short2);
itemstack.tag = d(datainputstream);
itemstack.tag = d(datainput);
// CraftBukkit start
if (itemstack.tag != null) {
CraftItemStack.setItemMeta(itemstack, CraftItemStack.getItemMeta(itemstack));
}
// CraftBukkit end
}
return itemstack;
}
public static void a(ItemStack itemstack, DataOutputStream dataoutputstream) throws IOException { // CraftBukkit - throws IOException
public static void a(ItemStack itemstack, DataOutput dataoutput) throws IOException { // CraftBukkit - throws IOException
if (itemstack == null || itemstack.getItem() == null) { // CraftBukkit - NPE fix itemstack.getItem()
dataoutputstream.writeShort(-1);
dataoutput.writeShort(-1);
} else {
dataoutputstream.writeShort(itemstack.id);
dataoutputstream.writeByte(itemstack.count);
dataoutputstream.writeShort(itemstack.getData());
dataoutput.writeShort(itemstack.id);
dataoutput.writeByte(itemstack.count);
dataoutput.writeShort(itemstack.getData());
NBTTagCompound nbttagcompound = null;
if (itemstack.getItem().usesDurability() || itemstack.getItem().r()) {
if (itemstack.getItem().usesDurability() || itemstack.getItem().s()) {
nbttagcompound = itemstack.tag;
}
a(nbttagcompound, dataoutputstream);
a(nbttagcompound, dataoutput);
}
}
public static NBTTagCompound d(DataInputStream datainputstream) throws IOException { // CraftBukkit - throws IOException
short short1 = datainputstream.readShort();
public static NBTTagCompound d(DataInput datainput) throws IOException { // CraftBukkit - throws IOException
short short1 = datainput.readShort();
if (short1 < 0) {
return null;
} else {
byte[] abyte = new byte[short1];
datainputstream.readFully(abyte);
datainput.readFully(abyte);
return NBTCompressedStreamTools.a(abyte);
}
}
protected static void a(NBTTagCompound nbttagcompound, DataOutputStream dataoutputstream) throws IOException { // CraftBukkit - throws IOException
protected static void a(NBTTagCompound nbttagcompound, DataOutput dataoutput) throws IOException { // CraftBukkit - throws IOException
if (nbttagcompound == null) {
dataoutputstream.writeShort(-1);
dataoutput.writeShort(-1);
} else {
byte[] abyte = NBTCompressedStreamTools.a(nbttagcompound);
dataoutputstream.writeShort((short) abyte.length);
dataoutputstream.write(abyte);
dataoutput.writeShort((short) abyte.length);
dataoutput.write(abyte);
}
}
@@ -278,6 +281,7 @@ public abstract class Packet {
a(24, true, false, Packet24MobSpawn.class);
a(25, true, false, Packet25EntityPainting.class);
a(26, true, false, Packet26AddExpOrb.class);
a(27, false, true, Packet27PlayerInput.class);
a(28, true, false, Packet28EntityVelocity.class);
a(29, true, false, Packet29DestroyEntity.class);
a(30, true, false, Packet30Entity.class);
@@ -292,6 +296,7 @@ public abstract class Packet {
a(41, true, false, Packet41MobEffect.class);
a(42, true, false, Packet42RemoveMobEffect.class);
a(43, true, false, Packet43SetExperience.class);
a(44, true, false, Packet44UpdateAttributes.class);
a(51, true, false, Packet51MapChunk.class);
a(52, true, false, Packet52MultiBlockChange.class);
a(53, true, false, Packet53BlockChange.class);