Updated CraftBukkit to 1.2

This commit is contained in:
Nathan Adams
2012-03-01 10:49:23 +00:00
parent e9ca87000c
commit 543c4879fe
143 changed files with 3710 additions and 4433 deletions

View File

@@ -62,11 +62,12 @@ public class NetServerHandler extends NetHandler implements ICommandListener {
private static Random k = new Random();
private long l;
private int m = 0;
private double x;
private int x = 0;
private double y;
private double z;
private double q;
private boolean checkMovement = true;
private IntHashMap r = new IntHashMap();
private IntHashMap s = new IntHashMap();
public NetServerHandler(MinecraftServer minecraftserver, NetworkManager networkmanager, EntityPlayer entityplayer) {
this.minecraftServer = minecraftserver;
@@ -119,6 +120,10 @@ public class NetServerHandler extends NetHandler implements ICommandListener {
if (this.m > 0) {
--this.m;
}
if (this.x > 0) {
--this.x;
}
}
public void disconnect(String s) {
@@ -137,7 +142,7 @@ public class NetServerHandler extends NetHandler implements ICommandListener {
s = event.getReason();
// CraftBukkit end
this.player.F();
this.player.I();
this.sendPacket(new Packet255KickDisconnect(s));
this.networkManager.d();
@@ -162,8 +167,8 @@ public class NetServerHandler extends NetHandler implements ICommandListener {
double d0;
if (!this.checkMovement) {
d0 = packet10flying.y - this.y;
if (packet10flying.x == this.x && d0 * d0 < 0.01D && packet10flying.z == this.z) {
d0 = packet10flying.y - this.z;
if (packet10flying.x == this.y && d0 * d0 < 0.01D && packet10flying.z == this.q) {
this.checkMovement = true;
}
}
@@ -243,7 +248,7 @@ public class NetServerHandler extends NetHandler implements ICommandListener {
float f = this.player.yaw;
float f1 = this.player.pitch;
this.player.vehicle.i();
this.player.vehicle.i_();
d1 = this.player.locX;
d2 = this.player.locY;
d3 = this.player.locZ;
@@ -278,28 +283,28 @@ public class NetServerHandler extends NetHandler implements ICommandListener {
}
if (this.player.vehicle != null) {
this.player.vehicle.i();
this.player.vehicle.i_();
}
this.minecraftServer.serverConfigurationManager.d(this.player);
this.x = this.player.locX;
this.y = this.player.locY;
this.z = this.player.locZ;
this.y = this.player.locX;
this.z = this.player.locY;
this.q = this.player.locZ;
worldserver.playerJoinedWorld(this.player);
return;
}
if (this.player.isSleeping()) {
this.player.a(true);
this.player.setLocation(this.x, this.y, this.z, this.player.yaw, this.player.pitch);
this.player.setLocation(this.y, this.z, this.q, this.player.yaw, this.player.pitch);
worldserver.playerJoinedWorld(this.player);
return;
}
d0 = this.player.locY;
this.x = this.player.locX;
this.y = this.player.locY;
this.z = this.player.locZ;
this.y = this.player.locX;
this.z = this.player.locY;
this.q = this.player.locZ;
d1 = this.player.locX;
d2 = this.player.locY;
d3 = this.player.locZ;
@@ -334,7 +339,7 @@ public class NetServerHandler extends NetHandler implements ICommandListener {
this.player.a(true);
this.player.bO = 0.0F;
this.player.setLocation(this.x, this.y, this.z, f2, f3);
this.player.setLocation(this.y, this.z, this.q, f2, f3);
if (!this.checkMovement) {
return;
}
@@ -383,7 +388,7 @@ public class NetServerHandler extends NetHandler implements ICommandListener {
boolean flag2 = worldserver.getCubes(this.player, this.player.boundingBox.clone().shrink((double) f4, (double) f4, (double) f4)).size() == 0;
if (flag && (flag1 || !flag2) && !this.player.isSleeping()) {
this.a(this.x, this.y, this.z, f2, f3);
this.a(this.y, this.z, this.q, f2, f3);
return;
}
@@ -452,9 +457,9 @@ public class NetServerHandler extends NetHandler implements ICommandListener {
// CraftBukkit end
this.checkMovement = false;
this.x = d0;
this.y = d1;
this.z = d2;
this.y = d0;
this.z = d1;
this.q = d2;
this.player.setLocation(d0, d1, d2, f, f1);
this.player.netServerHandler.sendPacket(new Packet13PlayerLookMove(d0, d1 + 1.6200000047683716D, d1, d2, f, f1, false));
}
@@ -480,9 +485,9 @@ public class NetServerHandler extends NetHandler implements ICommandListener {
}
}
// CraftBukkit end
this.player.O();
this.player.R();
} else if (packet14blockdig.e == 5) {
this.player.J();
this.player.M();
} else {
boolean flag = worldserver.weirdIsOpCache = worldserver.dimension != 0 || this.minecraftServer.serverConfigurationManager.isOp(this.player.name); // CraftBukkit
boolean flag1 = false;
@@ -508,6 +513,10 @@ public class NetServerHandler extends NetHandler implements ICommandListener {
if (d3 > 36.0D) {
return;
}
if (j >= this.minecraftServer.t) {
return;
}
}
ChunkCoordinates chunkcoordinates = worldserver.getSpawn();
@@ -577,7 +586,12 @@ public class NetServerHandler extends NetHandler implements ICommandListener {
// CraftBukkit end
ItemStack itemstack = this.player.inventory.getItemInHand();
boolean flag = worldserver.weirdIsOpCache = worldserver.dimension != 0 || this.minecraftServer.serverConfigurationManager.isOp(this.player.name); // CraftBukkit
boolean flag = false;
int i = packet15place.a;
int j = packet15place.b;
int k = packet15place.c;
int l = packet15place.face;
boolean flag1 = worldserver.weirdIsOpCache = worldserver.dimension != 0 || this.minecraftServer.serverConfigurationManager.isOp(this.player.name); // CraftBukkit
if (packet15place.face == 255) {
if (itemstack == null) {
@@ -596,11 +610,10 @@ public class NetServerHandler extends NetHandler implements ICommandListener {
// inventory update packet to get sent
always = (itemstack.count != itemstackAmount);
// CraftBukkit end
} else if (packet15place.b >= this.minecraftServer.t - 1 && (packet15place.face == 1 || packet15place.b >= this.minecraftServer.t)) {
this.player.netServerHandler.sendPacket(new Packet3Chat("\u00A77Height limit for building is " + this.minecraftServer.t));
flag = true;
} else {
int i = packet15place.a;
int j = packet15place.b;
int k = packet15place.c;
int l = packet15place.face;
ChunkCoordinates chunkcoordinates = worldserver.getSpawn();
int i1 = MathHelper.a(i - chunkcoordinates.x);
int j1 = MathHelper.a(k - chunkcoordinates.z);
@@ -614,13 +627,17 @@ public class NetServerHandler extends NetHandler implements ICommandListener {
if (Math.pow(eyeLoc.getX() - i, 2) + Math.pow(eyeLoc.getY() - j, 2) + Math.pow(eyeLoc.getZ() - k, 2) > PLACE_DISTANCE_SQUARED) {
return;
}
flag = true; // spawn protection moved to ItemBlock!!!
flag1 = true; // spawn protection moved to ItemBlock!!!
// CraftBukkit end
if (j1 > 16 || flag) {
if (j1 > 16 || flag1) {
this.player.itemInWorldManager.interact(this.player, worldserver, itemstack, i, j, k, l);
}
flag = true;
}
if (flag) {
this.player.netServerHandler.sendPacket(new Packet53BlockChange(i, j, k, worldserver));
if (l == 0) {
--j;
@@ -734,7 +751,7 @@ public class NetServerHandler extends NetHandler implements ICommandListener {
s = s.trim();
for (int i = 0; i < s.length(); ++i) {
if (SharedConstants.allowedCharacters.indexOf(s.charAt(i)) < 0 && s.charAt(i) < 32) {
if (!SharedConstants.isAllowedChatCharacter(s.charAt(i))) {
this.disconnect("Illegal characters in chat");
return;
}
@@ -876,7 +893,7 @@ public class NetServerHandler extends NetHandler implements ICommandListener {
if (event.isCancelled()) return;
// CraftBukkit end
this.player.s_();
this.player.D();
}
}
@@ -942,36 +959,45 @@ public class NetServerHandler extends NetHandler implements ICommandListener {
WorldServer worldserver = this.minecraftServer.getWorldServer(this.player.dimension);
Entity entity = worldserver.getEntity(packet7useentity.target);
if (entity != null && this.player.g(entity) && this.player.i(entity) < 36.0D) {
ItemStack itemInHand = this.player.inventory.getItemInHand(); // CraftBukkit
if (packet7useentity.action == 0) {
// CraftBukkit start
PlayerInteractEntityEvent event = new PlayerInteractEntityEvent((Player) this.getPlayer(), entity.getBukkitEntity());
this.server.getPluginManager().callEvent(event);
if (entity != null) {
boolean flag = this.player.h(entity);
double d0 = 36.0D;
if (event.isCancelled()) {
return;
}
// CraftBukkit end
this.player.e(entity);
// CraftBukkit start - update the client if the item is an infinite one
if (itemInHand != null && itemInHand.count <= -1) {
this.player.updateInventory(this.player.activeContainer);
}
} else if (packet7useentity.action == 1) {
if ((entity instanceof EntityItem) || (entity instanceof EntityExperienceOrb) || (entity instanceof EntityArrow)) {
String type = entity.getClass().getSimpleName();
disconnect("Attacking an " + type + " is not permitted");
System.out.println("Player " + player.name + " tried to attack an " + type + ", so I have disconnected them for exploiting.");
return;
}
if (!flag) {
d0 = 9.0D;
}
this.player.attack(entity);
if (this.player.j(entity) < d0) {
ItemStack itemInHand = this.player.inventory.getItemInHand(); // CraftBukkit
if (packet7useentity.action == 0) {
// CraftBukkit start
PlayerInteractEntityEvent event = new PlayerInteractEntityEvent((Player) this.getPlayer(), entity.getBukkitEntity());
this.server.getPluginManager().callEvent(event);
if (itemInHand != null && itemInHand.count <= -1) {
this.player.updateInventory(this.player.activeContainer);
if (event.isCancelled()) {
return;
}
// CraftBukkit end
this.player.e(entity);
// CraftBukkit start - update the client if the item is an infinite one
if (itemInHand != null && itemInHand.count <= -1) {
this.player.updateInventory(this.player.activeContainer);
}
} else if (packet7useentity.action == 1) {
if ((entity instanceof EntityItem) || (entity instanceof EntityExperienceOrb) || (entity instanceof EntityArrow)) {
String type = entity.getClass().getSimpleName();
disconnect("Attacking an " + type + " is not permitted");
System.out.println("Player " + player.name + " tried to attack an " + type + ", so I have disconnected them for exploiting.");
return;
}
this.player.attack(entity);
if (itemInHand != null && itemInHand.count <= -1) {
this.player.updateInventory(this.player.activeContainer);
}
// CraftBukkit end
}
// CraftBukkit end
}
}
}
@@ -1006,7 +1032,7 @@ public class NetServerHandler extends NetHandler implements ICommandListener {
this.player.activeContainer.transferTo(this.player.defaultContainer, getPlayer());
// CraftBukkit end
this.player.E();
this.player.H();
}
public void a(Packet102WindowClick packet102windowclick) {
@@ -1065,7 +1091,7 @@ public class NetServerHandler extends NetHandler implements ICommandListener {
this.player.broadcastCarriedItem();
this.player.h = false;
} else {
this.r.a(this.player.activeContainer.windowId, Short.valueOf(packet102windowclick.d));
this.s.a(this.player.activeContainer.windowId, Short.valueOf(packet102windowclick.d));
this.player.netServerHandler.sendPacket(new Packet106Transaction(packet102windowclick.a, packet102windowclick.d, false));
this.player.activeContainer.a(this.player, false);
ArrayList arraylist = new ArrayList();
@@ -1148,15 +1174,20 @@ public class NetServerHandler extends NetHandler implements ICommandListener {
}
this.player.defaultContainer.a(this.player, true);
} else if (flag && flag2 && flag3) {
this.player.drop(itemstack);
} else if (flag && flag2 && flag3 && this.x < 200) {
this.x += 20;
EntityItem entityitem = this.player.drop(itemstack);
if (entityitem != null) {
entityitem.k();
}
}
}
}
public void a(Packet106Transaction packet106transaction) {
if (this.player.dead) return; // CraftBukkit
Short oshort = (Short) this.r.get(this.player.activeContainer.windowId);
Short oshort = (Short) this.s.get(this.player.activeContainer.windowId);
if (oshort != null && packet106transaction.b == oshort.shortValue() && this.player.activeContainer.windowId == packet106transaction.a && !this.player.activeContainer.c(this.player)) {
this.player.activeContainer.a(this.player, true);