@@ -62,15 +62,7 @@
|
||||
private int j;
|
||||
private final IntHashMap<Short> k = new IntHashMap();
|
||||
private double l;
|
||||
@@ -50,6 +96,7 @@
|
||||
private int E;
|
||||
private int receivedMovePackets;
|
||||
private int processedMovePackets;
|
||||
+ private boolean processedDisconnect; // CraftBukkit - Added
|
||||
|
||||
public PlayerConnection(MinecraftServer minecraftserver, NetworkManager networkmanager, EntityPlayer entityplayer) {
|
||||
this.minecraftServer = minecraftserver;
|
||||
@@ -57,7 +104,33 @@
|
||||
@@ -58,7 +104,34 @@
|
||||
networkmanager.setPacketListener(this);
|
||||
this.player = entityplayer;
|
||||
entityplayer.playerConnection = this;
|
||||
@@ -80,6 +72,7 @@
|
||||
+ }
|
||||
+
|
||||
+ private final org.bukkit.craftbukkit.CraftServer server;
|
||||
+ private boolean processedDisconnect;
|
||||
+ private int lastTick = MinecraftServer.currentTick;
|
||||
+ private int allowedPlayerTicks = 1;
|
||||
+ private int lastDropTick = MinecraftServer.currentTick;
|
||||
@@ -104,7 +97,7 @@
|
||||
|
||||
public void e() {
|
||||
this.syncPosition();
|
||||
@@ -109,15 +182,21 @@
|
||||
@@ -110,15 +183,21 @@
|
||||
}
|
||||
|
||||
this.minecraftServer.methodProfiler.b();
|
||||
@@ -126,7 +119,7 @@
|
||||
this.disconnect(new ChatMessage("multiplayer.disconnect.idling", new Object[0]));
|
||||
}
|
||||
|
||||
@@ -136,18 +215,48 @@
|
||||
@@ -137,18 +216,48 @@
|
||||
return this.networkManager;
|
||||
}
|
||||
|
||||
@@ -181,7 +174,7 @@
|
||||
}
|
||||
|
||||
public void a(PacketPlayInSteerVehicle packetplayinsteervehicle) {
|
||||
@@ -186,7 +295,34 @@
|
||||
@@ -187,7 +296,34 @@
|
||||
double d9 = entity.motX * entity.motX + entity.motY * entity.motY + entity.motZ * entity.motZ;
|
||||
double d10 = d6 * d6 + d7 * d7 + d8 * d8;
|
||||
|
||||
@@ -217,7 +210,7 @@
|
||||
PlayerConnection.LOGGER.warn("{} (vehicle of {}) moved too quickly! {},{},{}", entity.getName(), this.player.getName(), Double.valueOf(d6), Double.valueOf(d7), Double.valueOf(d8));
|
||||
this.networkManager.sendPacket(new PacketPlayOutVehicleMove(entity));
|
||||
return;
|
||||
@@ -224,6 +360,62 @@
|
||||
@@ -225,6 +361,62 @@
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -280,7 +273,7 @@
|
||||
this.minecraftServer.getPlayerList().d(this.player);
|
||||
this.player.checkMovement(this.player.locX - d0, this.player.locY - d1, this.player.locZ - d2);
|
||||
this.D = d11 >= -0.03125D && !this.minecraftServer.getAllowFlight() && !worldserver.c(entity.getBoundingBox().g(0.0625D).b(0.0D, -0.55D, 0.0D));
|
||||
@@ -282,7 +474,7 @@
|
||||
@@ -283,7 +475,7 @@
|
||||
} else {
|
||||
WorldServer worldserver = this.minecraftServer.getWorldServer(this.player.dimension);
|
||||
|
||||
@@ -289,7 +282,7 @@
|
||||
if (this.e == 0) {
|
||||
this.syncPosition();
|
||||
}
|
||||
@@ -292,13 +484,21 @@
|
||||
@@ -293,13 +485,21 @@
|
||||
this.A = this.e;
|
||||
this.a(this.teleportPos.x, this.teleportPos.y, this.teleportPos.z, this.player.yaw, this.player.pitch);
|
||||
}
|
||||
@@ -312,7 +305,7 @@
|
||||
double d0 = this.player.locX;
|
||||
double d1 = this.player.locY;
|
||||
double d2 = this.player.locZ;
|
||||
@@ -323,15 +523,33 @@
|
||||
@@ -324,15 +524,33 @@
|
||||
++this.receivedMovePackets;
|
||||
int i = this.receivedMovePackets - this.processedMovePackets;
|
||||
|
||||
@@ -348,7 +341,7 @@
|
||||
PlayerConnection.LOGGER.warn("{} moved too quickly! {},{},{}", this.player.getName(), Double.valueOf(d7), Double.valueOf(d8), Double.valueOf(d9));
|
||||
this.a(this.player.locX, this.player.locY, this.player.locZ, this.player.yaw, this.player.pitch);
|
||||
return;
|
||||
@@ -377,6 +595,69 @@
|
||||
@@ -378,6 +596,69 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -418,7 +411,7 @@
|
||||
this.B = d12 >= -0.03125D;
|
||||
this.B &= !this.minecraftServer.getAllowFlight() && !this.player.abilities.canFly;
|
||||
this.B &= !this.player.hasEffect(MobEffects.LEVITATION) && !this.player.cP() && !worldserver.c(this.player.getBoundingBox().g(0.0625D).b(0.0D, -0.55D, 0.0D));
|
||||
@@ -394,10 +675,76 @@
|
||||
@@ -395,10 +676,76 @@
|
||||
}
|
||||
|
||||
public void a(double d0, double d1, double d2, float f, float f1) {
|
||||
@@ -496,7 +489,7 @@
|
||||
double d3 = set.contains(PacketPlayOutPosition.EnumPlayerTeleportFlags.X) ? this.player.locX : 0.0D;
|
||||
double d4 = set.contains(PacketPlayOutPosition.EnumPlayerTeleportFlags.Y) ? this.player.locY : 0.0D;
|
||||
double d5 = set.contains(PacketPlayOutPosition.EnumPlayerTeleportFlags.Z) ? this.player.locZ : 0.0D;
|
||||
@@ -414,6 +761,14 @@
|
||||
@@ -415,6 +762,14 @@
|
||||
f3 = f1 + this.player.pitch;
|
||||
}
|
||||
|
||||
@@ -511,7 +504,7 @@
|
||||
if (++this.teleportAwait == Integer.MAX_VALUE) {
|
||||
this.teleportAwait = 0;
|
||||
}
|
||||
@@ -425,6 +780,7 @@
|
||||
@@ -426,6 +781,7 @@
|
||||
|
||||
public void a(PacketPlayInBlockDig packetplayinblockdig) {
|
||||
PlayerConnectionUtils.ensureMainThread(packetplayinblockdig, this, this.player.x());
|
||||
@@ -519,7 +512,7 @@
|
||||
WorldServer worldserver = this.minecraftServer.getWorldServer(this.player.dimension);
|
||||
BlockPosition blockposition = packetplayinblockdig.a();
|
||||
|
||||
@@ -434,7 +790,15 @@
|
||||
@@ -435,7 +791,15 @@
|
||||
if (!this.player.isSpectator()) {
|
||||
ItemStack itemstack = this.player.b(EnumHand.OFF_HAND);
|
||||
|
||||
@@ -536,7 +529,7 @@
|
||||
this.player.a(EnumHand.MAIN_HAND, itemstack);
|
||||
}
|
||||
|
||||
@@ -442,6 +806,21 @@
|
||||
@@ -443,6 +807,21 @@
|
||||
|
||||
case DROP_ITEM:
|
||||
if (!this.player.isSpectator()) {
|
||||
@@ -558,7 +551,7 @@
|
||||
this.player.a(false);
|
||||
}
|
||||
|
||||
@@ -475,7 +854,15 @@
|
||||
@@ -476,7 +855,15 @@
|
||||
if (!this.minecraftServer.a(worldserver, blockposition, this.player) && worldserver.getWorldBorder().a(blockposition)) {
|
||||
this.player.playerInteractManager.a(blockposition, packetplayinblockdig.b());
|
||||
} else {
|
||||
@@ -574,7 +567,7 @@
|
||||
}
|
||||
} else {
|
||||
if (packetplayinblockdig.c() == PacketPlayInBlockDig.EnumPlayerDigType.STOP_DESTROY_BLOCK) {
|
||||
@@ -495,10 +882,12 @@
|
||||
@@ -496,10 +883,12 @@
|
||||
default:
|
||||
throw new IllegalArgumentException("Invalid player action");
|
||||
}
|
||||
@@ -587,7 +580,7 @@
|
||||
WorldServer worldserver = this.minecraftServer.getWorldServer(this.player.dimension);
|
||||
EnumHand enumhand = packetplayinuseitem.c();
|
||||
ItemStack itemstack = this.player.b(enumhand);
|
||||
@@ -512,6 +901,13 @@
|
||||
@@ -513,6 +902,13 @@
|
||||
chatmessage.getChatModifier().setColor(EnumChatFormat.RED);
|
||||
this.player.playerConnection.sendPacket(new PacketPlayOutChat(chatmessage, ChatMessageType.GAME_INFO));
|
||||
} else if (this.teleportPos == null && this.player.d((double) blockposition.getX() + 0.5D, (double) blockposition.getY() + 0.5D, (double) blockposition.getZ() + 0.5D) < 64.0D && !this.minecraftServer.a(worldserver, blockposition, this.player) && worldserver.getWorldBorder().a(blockposition)) {
|
||||
@@ -601,7 +594,7 @@
|
||||
this.player.playerInteractManager.a(this.player, worldserver, itemstack, enumhand, blockposition, enumdirection, packetplayinuseitem.d(), packetplayinuseitem.e(), packetplayinuseitem.f());
|
||||
}
|
||||
|
||||
@@ -521,13 +917,52 @@
|
||||
@@ -522,13 +918,52 @@
|
||||
|
||||
public void a(PacketPlayInBlockPlace packetplayinblockplace) {
|
||||
PlayerConnectionUtils.ensureMainThread(packetplayinblockplace, this, this.player.x());
|
||||
@@ -655,7 +648,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -538,8 +973,8 @@
|
||||
@@ -539,8 +974,8 @@
|
||||
WorldServer[] aworldserver = this.minecraftServer.worldServer;
|
||||
int i = aworldserver.length;
|
||||
|
||||
@@ -666,7 +659,7 @@
|
||||
|
||||
if (worldserver != null) {
|
||||
entity = packetplayinspectate.a(worldserver);
|
||||
@@ -552,6 +987,8 @@
|
||||
@@ -553,6 +988,8 @@
|
||||
if (entity != null) {
|
||||
this.player.setSpectatorTarget(this.player);
|
||||
this.player.stopRiding();
|
||||
@@ -675,7 +668,7 @@
|
||||
if (entity.world == this.player.world) {
|
||||
this.player.enderTeleportTo(entity.locX, entity.locY, entity.locZ);
|
||||
} else {
|
||||
@@ -577,12 +1014,20 @@
|
||||
@@ -578,12 +1015,20 @@
|
||||
this.minecraftServer.getPlayerList().b(this.player, worldserver2);
|
||||
this.minecraftServer.getPlayerList().updateClient(this.player);
|
||||
}
|
||||
@@ -697,7 +690,7 @@
|
||||
|
||||
public void a(PacketPlayInBoatMove packetplayinboatmove) {
|
||||
PlayerConnectionUtils.ensureMainThread(packetplayinboatmove, this, this.player.x());
|
||||
@@ -595,14 +1040,29 @@
|
||||
@@ -596,14 +1041,29 @@
|
||||
}
|
||||
|
||||
public void a(IChatBaseComponent ichatbasecomponent) {
|
||||
@@ -728,7 +721,7 @@
|
||||
if (this.minecraftServer.R() && this.player.getName().equals(this.minecraftServer.Q())) {
|
||||
PlayerConnection.LOGGER.info("Stopping singleplayer server as player logged out");
|
||||
this.minecraftServer.safeShutdown();
|
||||
@@ -624,6 +1084,15 @@
|
||||
@@ -625,6 +1085,15 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -744,7 +737,7 @@
|
||||
try {
|
||||
this.networkManager.sendPacket(packet);
|
||||
} catch (Throwable throwable) {
|
||||
@@ -645,17 +1114,32 @@
|
||||
@@ -646,17 +1115,32 @@
|
||||
|
||||
public void a(PacketPlayInHeldItemSlot packetplayinhelditemslot) {
|
||||
PlayerConnectionUtils.ensureMainThread(packetplayinhelditemslot, this, this.player.x());
|
||||
@@ -779,7 +772,7 @@
|
||||
ChatMessage chatmessage = new ChatMessage("chat.cannotSend", new Object[0]);
|
||||
|
||||
chatmessage.getChatModifier().setColor(EnumChatFormat.RED);
|
||||
@@ -668,39 +1152,249 @@
|
||||
@@ -669,39 +1153,249 @@
|
||||
|
||||
for (int i = 0; i < s.length(); ++i) {
|
||||
if (!SharedConstants.isAllowedChatCharacter(s.charAt(i))) {
|
||||
@@ -1036,7 +1029,7 @@
|
||||
this.player.resetIdleTimer();
|
||||
IJumpable ijumpable;
|
||||
|
||||
@@ -772,6 +1466,7 @@
|
||||
@@ -773,6 +1467,7 @@
|
||||
|
||||
public void a(PacketPlayInUseEntity packetplayinuseentity) {
|
||||
PlayerConnectionUtils.ensureMainThread(packetplayinuseentity, this, this.player.x());
|
||||
@@ -1044,7 +1037,7 @@
|
||||
WorldServer worldserver = this.minecraftServer.getWorldServer(this.player.dimension);
|
||||
Entity entity = packetplayinuseentity.a((World) worldserver);
|
||||
|
||||
@@ -787,20 +1482,68 @@
|
||||
@@ -788,20 +1483,68 @@
|
||||
if (this.player.h(entity) < d0) {
|
||||
EnumHand enumhand;
|
||||
|
||||
@@ -1114,7 +1107,7 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -816,7 +1559,8 @@
|
||||
@@ -817,7 +1560,8 @@
|
||||
case PERFORM_RESPAWN:
|
||||
if (this.player.viewingCredits) {
|
||||
this.player.viewingCredits = false;
|
||||
@@ -1124,7 +1117,7 @@
|
||||
CriterionTriggers.u.a(this.player, DimensionManager.THE_END, DimensionManager.OVERWORLD);
|
||||
} else {
|
||||
if (this.player.getHealth() > 0.0F) {
|
||||
@@ -839,14 +1583,20 @@
|
||||
@@ -840,14 +1584,20 @@
|
||||
|
||||
public void a(PacketPlayInCloseWindow packetplayinclosewindow) {
|
||||
PlayerConnectionUtils.ensureMainThread(packetplayinclosewindow, this, this.player.x());
|
||||
@@ -1147,7 +1140,7 @@
|
||||
NonNullList nonnulllist = NonNullList.a();
|
||||
|
||||
for (int i = 0; i < this.player.activeContainer.c.size(); ++i) {
|
||||
@@ -855,8 +1605,274 @@
|
||||
@@ -856,8 +1606,274 @@
|
||||
|
||||
this.player.a(this.player.activeContainer, nonnulllist);
|
||||
} else {
|
||||
@@ -1159,7 +1152,7 @@
|
||||
+
|
||||
+ InventoryView inventory = this.player.activeContainer.getBukkitView();
|
||||
+ SlotType type = CraftInventoryView.getSlotType(inventory, packetplayinwindowclick.b());
|
||||
|
||||
+
|
||||
+ InventoryClickEvent event;
|
||||
+ ClickType click = ClickType.UNKNOWN;
|
||||
+ InventoryAction action = InventoryAction.UNKNOWN;
|
||||
@@ -1412,7 +1405,7 @@
|
||||
+ }
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
|
||||
+ if (event instanceof CraftItemEvent) {
|
||||
+ // Need to update the inventory on crafting to
|
||||
+ // correctly support custom recipes
|
||||
@@ -1423,20 +1416,7 @@
|
||||
if (ItemStack.matches(packetplayinwindowclick.e(), itemstack)) {
|
||||
this.player.playerConnection.sendPacket(new PacketPlayOutTransaction(packetplayinwindowclick.a(), packetplayinwindowclick.d(), true));
|
||||
this.player.f = true;
|
||||
@@ -886,6 +1902,12 @@
|
||||
public void a(PacketPlayInAutoRecipe packetplayinautorecipe) {
|
||||
PlayerConnectionUtils.ensureMainThread(packetplayinautorecipe, this, this.player.x());
|
||||
this.player.resetIdleTimer();
|
||||
+ // CraftBukkit start
|
||||
+ if (!player.getBukkitEntity().hasPermission("minecraft.autocraft")) {
|
||||
+ player.getBukkitEntity().updateInventory();
|
||||
+ return;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
if (this.player.activeContainer.windowId == packetplayinautorecipe.a() && this.player.activeContainer.c(this.player)) {
|
||||
this.player.playerConnection.sendPacket(new PacketPlayOutTransaction(packetplayinautorecipe.a(), packetplayinautorecipe.b(), true));
|
||||
Iterator iterator;
|
||||
@@ -958,6 +1980,7 @@
|
||||
@@ -894,6 +1910,7 @@
|
||||
|
||||
public void a(PacketPlayInEnchantItem packetplayinenchantitem) {
|
||||
PlayerConnectionUtils.ensureMainThread(packetplayinenchantitem, this, this.player.x());
|
||||
@@ -1444,7 +1424,7 @@
|
||||
this.player.resetIdleTimer();
|
||||
if (this.player.activeContainer.windowId == packetplayinenchantitem.a() && this.player.activeContainer.c(this.player) && !this.player.isSpectator()) {
|
||||
this.player.activeContainer.a(this.player, packetplayinenchantitem.b());
|
||||
@@ -991,7 +2014,45 @@
|
||||
@@ -927,7 +1944,45 @@
|
||||
}
|
||||
|
||||
boolean flag1 = packetplayinsetcreativeslot.a() >= 1 && packetplayinsetcreativeslot.a() <= 45;
|
||||
@@ -1491,7 +1471,7 @@
|
||||
|
||||
if (flag1 && flag2) {
|
||||
if (itemstack.isEmpty()) {
|
||||
@@ -1015,6 +2076,7 @@
|
||||
@@ -951,6 +2006,7 @@
|
||||
|
||||
public void a(PacketPlayInTransaction packetplayintransaction) {
|
||||
PlayerConnectionUtils.ensureMainThread(packetplayintransaction, this, this.player.x());
|
||||
@@ -1499,7 +1479,7 @@
|
||||
Short oshort = (Short) this.k.get(this.player.activeContainer.windowId);
|
||||
|
||||
if (oshort != null && packetplayintransaction.b() == oshort.shortValue() && this.player.activeContainer.windowId == packetplayintransaction.a() && !this.player.activeContainer.c(this.player) && !this.player.isSpectator()) {
|
||||
@@ -1025,6 +2087,7 @@
|
||||
@@ -961,6 +2017,7 @@
|
||||
|
||||
public void a(PacketPlayInUpdateSign packetplayinupdatesign) {
|
||||
PlayerConnectionUtils.ensureMainThread(packetplayinupdatesign, this, this.player.x());
|
||||
@@ -1507,7 +1487,7 @@
|
||||
this.player.resetIdleTimer();
|
||||
WorldServer worldserver = this.minecraftServer.getWorldServer(this.player.dimension);
|
||||
BlockPosition blockposition = packetplayinupdatesign.a();
|
||||
@@ -1041,14 +2104,30 @@
|
||||
@@ -977,14 +2034,30 @@
|
||||
|
||||
if (!tileentitysign.a() || tileentitysign.e() != this.player) {
|
||||
this.minecraftServer.warning("Player " + this.player.getName() + " just tried to change non-editable sign");
|
||||
@@ -1539,7 +1519,7 @@
|
||||
|
||||
tileentitysign.update();
|
||||
worldserver.notify(blockposition, iblockdata, iblockdata, 3);
|
||||
@@ -1071,11 +2150,27 @@
|
||||
@@ -1007,11 +2080,27 @@
|
||||
|
||||
public void a(PacketPlayInAbilities packetplayinabilities) {
|
||||
PlayerConnectionUtils.ensureMainThread(packetplayinabilities, this, this.player.x());
|
||||
@@ -1568,7 +1548,7 @@
|
||||
ArrayList arraylist = Lists.newArrayList();
|
||||
Iterator iterator = this.minecraftServer.tabCompleteCommand(this.player, packetplayintabcomplete.a(), packetplayintabcomplete.b(), packetplayintabcomplete.c()).iterator();
|
||||
|
||||
@@ -1101,6 +2196,13 @@
|
||||
@@ -1037,6 +2126,13 @@
|
||||
ItemStack itemstack1;
|
||||
|
||||
if ("MC|BEdit".equals(s)) {
|
||||
@@ -1582,7 +1562,7 @@
|
||||
packetdataserializer = packetplayincustompayload.b();
|
||||
|
||||
try {
|
||||
@@ -1119,15 +2221,25 @@
|
||||
@@ -1055,15 +2151,25 @@
|
||||
}
|
||||
|
||||
if (itemstack.getItem() == Items.WRITABLE_BOOK && itemstack.getItem() == itemstack1.getItem()) {
|
||||
@@ -1608,7 +1588,7 @@
|
||||
packetdataserializer = packetplayincustompayload.b();
|
||||
|
||||
try {
|
||||
@@ -1161,10 +2273,11 @@
|
||||
@@ -1097,10 +2203,11 @@
|
||||
}
|
||||
|
||||
itemstack2.a("pages", (NBTBase) nbttaglist);
|
||||
@@ -1621,7 +1601,7 @@
|
||||
}
|
||||
} else if ("MC|TrSel".equals(s)) {
|
||||
try {
|
||||
@@ -1176,6 +2289,7 @@
|
||||
@@ -1112,6 +2219,7 @@
|
||||
}
|
||||
} catch (Exception exception2) {
|
||||
PlayerConnection.LOGGER.error("Couldn\'t select trade", exception2);
|
||||
@@ -1629,7 +1609,7 @@
|
||||
}
|
||||
} else {
|
||||
TileEntity tileentity;
|
||||
@@ -1225,6 +2339,7 @@
|
||||
@@ -1161,6 +2269,7 @@
|
||||
}
|
||||
} catch (Exception exception3) {
|
||||
PlayerConnection.LOGGER.error("Couldn\'t set command block", exception3);
|
||||
@@ -1637,7 +1617,7 @@
|
||||
}
|
||||
} else if ("MC|AutoCmd".equals(s)) {
|
||||
if (!this.minecraftServer.getEnableCommandBlock()) {
|
||||
@@ -1292,6 +2407,7 @@
|
||||
@@ -1228,6 +2337,7 @@
|
||||
}
|
||||
} catch (Exception exception4) {
|
||||
PlayerConnection.LOGGER.error("Couldn\'t set command block", exception4);
|
||||
@@ -1645,7 +1625,7 @@
|
||||
}
|
||||
} else {
|
||||
int k;
|
||||
@@ -1315,6 +2431,7 @@
|
||||
@@ -1251,6 +2361,7 @@
|
||||
}
|
||||
} catch (Exception exception5) {
|
||||
PlayerConnection.LOGGER.error("Couldn\'t set beacon", exception5);
|
||||
@@ -1653,7 +1633,7 @@
|
||||
}
|
||||
}
|
||||
} else if ("MC|ItemName".equals(s)) {
|
||||
@@ -1401,6 +2518,7 @@
|
||||
@@ -1337,6 +2448,7 @@
|
||||
}
|
||||
} catch (Exception exception6) {
|
||||
PlayerConnection.LOGGER.error("Couldn\'t set structure block", exception6);
|
||||
@@ -1661,7 +1641,7 @@
|
||||
}
|
||||
} else if ("MC|PickItem".equals(s)) {
|
||||
packetdataserializer = packetplayincustompayload.b();
|
||||
@@ -1413,11 +2531,49 @@
|
||||
@@ -1349,11 +2461,49 @@
|
||||
this.player.playerConnection.sendPacket(new PacketPlayOutHeldItemSlot(this.player.inventory.itemInHandIndex));
|
||||
} catch (Exception exception7) {
|
||||
PlayerConnection.LOGGER.error("Couldn\'t pick item", exception7);
|
||||
|
||||
Reference in New Issue
Block a user