summaryrefslogtreecommitdiffstats
path: root/nms-patches/PlayerConnection.patch
diff options
context:
space:
mode:
Diffstat (limited to 'nms-patches/PlayerConnection.patch')
-rw-r--r--nms-patches/PlayerConnection.patch115
1 files changed, 57 insertions, 58 deletions
diff --git a/nms-patches/PlayerConnection.patch b/nms-patches/PlayerConnection.patch
index e4b9ae11..c31a92b5 100644
--- a/nms-patches/PlayerConnection.patch
+++ b/nms-patches/PlayerConnection.patch
@@ -102,7 +102,7 @@
+ private final static HashSet<Integer> invalidItems = new HashSet<Integer>(java.util.Arrays.asList(8, 9, 10, 11, 26, 34, 36, 43, 51, 55, 59, 62, 63, 64, 68, 71, 74, 75, 83, 90, 92, 93, 94, 104, 105, 115, 117, 118, 119, 125, 127, 132, 140, 141, 142, 144)); // TODO: Check after every update.
+ // CraftBukkit end
- public void F_() {
+ public void e() {
this.syncPosition();
@@ -109,15 +182,21 @@
}
@@ -121,7 +121,7 @@
--this.j;
}
- if (this.player.I() > 0L && this.minecraftServer.getIdleTimeout() > 0 && MinecraftServer.aw() - this.player.I() > (long) (this.minecraftServer.getIdleTimeout() * 1000 * 60)) {
+ if (this.player.J() > 0L && this.minecraftServer.getIdleTimeout() > 0 && MinecraftServer.aw() - this.player.J() > (long) (this.minecraftServer.getIdleTimeout() * 1000 * 60)) {
+ this.player.resetIdleTimer(); // CraftBukkit - SPIGOT-854
this.disconnect("You have been idle for too long!");
}
@@ -212,7 +212,7 @@
+
+ if (d10 - d9 > Math.max(100.0D, Math.pow((double) (10.0F * (float) i * speed), 2)) && (!this.minecraftServer.R() || !this.minecraftServer.Q().equals(entity.getName()))) {
+ // CraftBukkit end
- PlayerConnection.LOGGER.warn("{} (vehicle of {}) moved too quickly! {},{},{}", new Object[] { entity.getName(), this.player.getName(), Double.valueOf(d6), Double.valueOf(d7), Double.valueOf(d8)});
+ 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;
@@ -226,6 +353,62 @@
@@ -278,7 +278,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));
-@@ -260,7 +443,7 @@
+@@ -271,7 +454,7 @@
} else {
WorldServer worldserver = this.minecraftServer.getWorldServer(this.player.dimension);
@@ -287,7 +287,7 @@
if (this.e == 0) {
this.syncPosition();
}
-@@ -270,13 +453,21 @@
+@@ -281,13 +464,21 @@
this.A = this.e;
this.a(this.teleportPos.x, this.teleportPos.y, this.teleportPos.z, this.player.yaw, this.player.pitch);
}
@@ -310,7 +310,7 @@
double d0 = this.player.locX;
double d1 = this.player.locY;
double d2 = this.player.locZ;
-@@ -301,15 +492,33 @@
+@@ -312,15 +503,33 @@
++this.receivedMovePackets;
int i = this.receivedMovePackets - this.processedMovePackets;
@@ -321,7 +321,7 @@
+ this.lastTick = (int) (System.currentTimeMillis() / 50);
+
+ if (i > Math.max(this.allowedPlayerTicks, 5)) {
- PlayerConnection.LOGGER.debug("{} is sending move packets too frequently ({} packets since last tick)", new Object[] { this.player.getName(), Integer.valueOf(i)});
+ PlayerConnection.LOGGER.debug("{} is sending move packets too frequently ({} packets since last tick)", this.player.getName(), Integer.valueOf(i));
i = 1;
}
@@ -337,16 +337,16 @@
+ speed = player.abilities.walkSpeed * 10f;
+ }
+
- if (!this.player.K() && (!this.player.x().getGameRules().getBoolean("disableElytraMovementCheck") || !this.player.cH())) {
- float f2 = this.player.cH() ? 300.0F : 100.0F;
+ if (!this.player.L() && (!this.player.x().getGameRules().getBoolean("disableElytraMovementCheck") || !this.player.cN())) {
+ float f2 = this.player.cN() ? 300.0F : 100.0F;
- if (d11 - d10 > (double) (f2 * (float) i) && (!this.minecraftServer.R() || !this.minecraftServer.Q().equals(this.player.getName()))) {
+ if (d11 - d10 > Math.max(f2, Math.pow((double) (10.0F * (float) i * speed), 2)) && (!this.minecraftServer.R() || !this.minecraftServer.Q().equals(this.player.getName()))) {
+ // CraftBukkit end
- PlayerConnection.LOGGER.warn("{} moved too quickly! {},{},{}", new Object[] { this.player.getName(), Double.valueOf(d7), Double.valueOf(d8), Double.valueOf(d9)});
+ 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;
-@@ -355,6 +564,69 @@
+@@ -366,6 +575,69 @@
}
}
@@ -415,8 +415,8 @@
+
this.B = d12 >= -0.03125D;
this.B &= !this.minecraftServer.getAllowFlight() && !this.player.abilities.canFly;
- this.B &= !this.player.hasEffect(MobEffects.LEVITATION) && !this.player.cH() && !worldserver.c(this.player.getBoundingBox().g(0.0625D).b(0.0D, -0.55D, 0.0D));
-@@ -372,10 +644,76 @@
+ this.B &= !this.player.hasEffect(MobEffects.LEVITATION) && !this.player.cN() && !worldserver.c(this.player.getBoundingBox().g(0.0625D).b(0.0D, -0.55D, 0.0D));
+@@ -383,10 +655,76 @@
}
public void a(double d0, double d1, double d2, float f, float f1) {
@@ -494,7 +494,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;
-@@ -392,6 +730,14 @@
+@@ -403,6 +741,14 @@
f3 = f1 + this.player.pitch;
}
@@ -509,7 +509,7 @@
if (++this.teleportAwait == Integer.MAX_VALUE) {
this.teleportAwait = 0;
}
-@@ -403,6 +749,7 @@
+@@ -414,6 +760,7 @@
public void a(PacketPlayInBlockDig packetplayinblockdig) {
PlayerConnectionUtils.ensureMainThread(packetplayinblockdig, this, this.player.x());
@@ -517,7 +517,7 @@
WorldServer worldserver = this.minecraftServer.getWorldServer(this.player.dimension);
BlockPosition blockposition = packetplayinblockdig.a();
-@@ -412,7 +759,15 @@
+@@ -423,7 +770,15 @@
if (!this.player.isSpectator()) {
ItemStack itemstack = this.player.b(EnumHand.OFF_HAND);
@@ -534,7 +534,7 @@
this.player.a(EnumHand.MAIN_HAND, itemstack);
}
-@@ -420,6 +775,21 @@
+@@ -431,6 +786,21 @@
case DROP_ITEM:
if (!this.player.isSpectator()) {
@@ -556,7 +556,7 @@
this.player.a(false);
}
-@@ -453,7 +823,15 @@
+@@ -464,7 +834,15 @@
if (!this.minecraftServer.a(worldserver, blockposition, this.player) && worldserver.getWorldBorder().a(blockposition)) {
this.player.playerInteractManager.a(blockposition, packetplayinblockdig.b());
} else {
@@ -572,7 +572,7 @@
}
} else {
if (packetplayinblockdig.c() == PacketPlayInBlockDig.EnumPlayerDigType.STOP_DESTROY_BLOCK) {
-@@ -473,10 +851,12 @@
+@@ -484,10 +862,12 @@
default:
throw new IllegalArgumentException("Invalid player action");
}
@@ -585,9 +585,9 @@
WorldServer worldserver = this.minecraftServer.getWorldServer(this.player.dimension);
EnumHand enumhand = packetplayinuseitem.c();
ItemStack itemstack = this.player.b(enumhand);
-@@ -490,6 +870,13 @@
+@@ -501,6 +881,13 @@
chatmessage.getChatModifier().setColor(EnumChatFormat.RED);
- this.player.playerConnection.sendPacket(new PacketPlayOutChat(chatmessage, (byte) 2));
+ 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)) {
+ // CraftBukkit start - Check if we can actually do something over this large a distance
+ Location eyeLoc = this.getPlayer().getEyeLocation();
@@ -599,7 +599,7 @@
this.player.playerInteractManager.a(this.player, worldserver, itemstack, enumhand, blockposition, enumdirection, packetplayinuseitem.d(), packetplayinuseitem.e(), packetplayinuseitem.f());
}
-@@ -499,13 +886,52 @@
+@@ -510,13 +897,52 @@
public void a(PacketPlayInBlockPlace packetplayinblockplace) {
PlayerConnectionUtils.ensureMainThread(packetplayinblockplace, this, this.player.x());
@@ -653,7 +653,7 @@
}
}
-@@ -516,8 +942,8 @@
+@@ -527,8 +953,8 @@
WorldServer[] aworldserver = this.minecraftServer.worldServer;
int i = aworldserver.length;
@@ -664,7 +664,7 @@
if (worldserver != null) {
entity = packetplayinspectate.a(worldserver);
-@@ -530,6 +956,8 @@
+@@ -541,6 +967,8 @@
if (entity != null) {
this.player.setSpectatorTarget(this.player);
this.player.stopRiding();
@@ -673,7 +673,7 @@
if (entity.world == this.player.world) {
this.player.enderTeleportTo(entity.locX, entity.locY, entity.locZ);
} else {
-@@ -555,12 +983,20 @@
+@@ -566,12 +994,20 @@
this.minecraftServer.getPlayerList().b(this.player, worldserver2);
this.minecraftServer.getPlayerList().updateClient(this.player);
}
@@ -695,11 +695,11 @@
public void a(PacketPlayInBoatMove packetplayinboatmove) {
PlayerConnectionUtils.ensureMainThread(packetplayinboatmove, this, this.player.x());
-@@ -573,14 +1009,29 @@
+@@ -584,14 +1020,29 @@
}
public void a(IChatBaseComponent ichatbasecomponent) {
-- PlayerConnection.LOGGER.info("{} lost connection: {}", new Object[] { this.player.getName(), ichatbasecomponent});
+- PlayerConnection.LOGGER.info("{} lost connection: {}", this.player.getName(), ichatbasecomponent);
+ // CraftBukkit start - Rarely it would send a disconnect line twice
+ if (this.processedDisconnect) {
+ return;
@@ -707,7 +707,7 @@
+ this.processedDisconnect = true;
+ }
+ // CraftBukkit end
-+ PlayerConnection.LOGGER.info("{} lost connection: {}", new Object[] { this.player.getName(), ichatbasecomponent.toPlainText()});// CraftBukkit - Don't toString().
++ PlayerConnection.LOGGER.info("{} lost connection: {}", this.player.getName(), ichatbasecomponent.toPlainText()); // CraftBukkit - Don't toString().
+ // CraftBukkit start - Replace vanilla quit message handling with our own.
+ /*
this.minecraftServer.aD();
@@ -717,7 +717,7 @@
this.minecraftServer.getPlayerList().sendMessage(chatmessage);
+ */
+
- this.player.t();
+ this.player.s();
- this.minecraftServer.getPlayerList().disconnect(this.player);
+ String quitMessage = this.minecraftServer.getPlayerList().disconnect(this.player);
+ if ((quitMessage != null) && (quitMessage.length() > 0)) {
@@ -727,7 +727,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();
-@@ -602,6 +1053,15 @@
+@@ -613,6 +1064,15 @@
}
}
@@ -743,7 +743,7 @@
try {
this.networkManager.sendPacket(packet);
} catch (Throwable throwable) {
-@@ -623,17 +1083,32 @@
+@@ -634,17 +1094,32 @@
public void a(PacketPlayInHeldItemSlot packetplayinhelditemslot) {
PlayerConnectionUtils.ensureMainThread(packetplayinhelditemslot, this, this.player.x());
@@ -760,7 +760,7 @@
this.player.inventory.itemInHandIndex = packetplayinhelditemslot.a();
this.player.resetIdleTimer();
} else {
- PlayerConnection.LOGGER.warn("{} tried to set an invalid carried item", new Object[] { this.player.getName()});
+ PlayerConnection.LOGGER.warn("{} tried to set an invalid carried item", this.player.getName());
+ this.disconnect("Nope!"); // CraftBukkit
}
}
@@ -778,7 +778,7 @@
ChatMessage chatmessage = new ChatMessage("chat.cannotSend", new Object[0]);
chatmessage.getChatModifier().setColor(EnumChatFormat.RED);
-@@ -646,39 +1121,249 @@
+@@ -657,39 +1132,249 @@
for (int i = 0; i < s.length(); ++i) {
if (!SharedConstants.isAllowedChatCharacter(s.charAt(i))) {
@@ -871,8 +871,6 @@
}
}
-- private void handleCommand(String s) {
-- this.minecraftServer.getCommandHandler().a(this.player, s);
+ // CraftBukkit start - add method
+ public void chat(String s, boolean async) {
+ if (s.isEmpty() || this.player.getChatFlags() == EntityHuman.EnumChatVisibility.HIDDEN) {
@@ -947,7 +945,8 @@
+ }
+ // CraftBukkit end
+
-+ private void handleCommand(String s) {
+ private void handleCommand(String s) {
+- this.minecraftServer.getCommandHandler().b(this.player, s);
+ // CraftBukkit start - whole method
+ this.LOGGER.info(this.player.getName() + " issued server command: " + s);
+
@@ -969,7 +968,7 @@
+ java.util.logging.Logger.getLogger(PlayerConnection.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
+ return;
+ }
-+ // this.minecraftServer.getCommandHandler().a(this.player, s);
++ // this.minecraftServer.getCommandHandler().b(this.player, s);
+ // CraftBukkit end
}
@@ -1036,7 +1035,7 @@
this.player.resetIdleTimer();
IJumpable ijumpable;
-@@ -750,6 +1435,7 @@
+@@ -761,6 +1446,7 @@
public void a(PacketPlayInUseEntity packetplayinuseentity) {
PlayerConnectionUtils.ensureMainThread(packetplayinuseentity, this, this.player.x());
@@ -1044,7 +1043,7 @@
WorldServer worldserver = this.minecraftServer.getWorldServer(this.player.dimension);
Entity entity = packetplayinuseentity.a((World) worldserver);
-@@ -765,20 +1451,68 @@
+@@ -776,20 +1462,68 @@
if (this.player.h(entity) < d0) {
EnumHand enumhand;
@@ -1114,7 +1113,7 @@
}
}
}
-@@ -794,7 +1528,8 @@
+@@ -805,7 +1539,8 @@
case PERFORM_RESPAWN:
if (this.player.viewingCredits) {
this.player.viewingCredits = false;
@@ -1124,7 +1123,7 @@
} else {
if (this.player.getHealth() > 0.0F) {
return;
-@@ -820,14 +1555,20 @@
+@@ -827,14 +1562,20 @@
public void a(PacketPlayInCloseWindow packetplayinclosewindow) {
PlayerConnectionUtils.ensureMainThread(packetplayinclosewindow, this, this.player.x());
@@ -1132,7 +1131,7 @@
+ if (this.player.isFrozen()) return; // CraftBukkit
+ CraftEventFactory.handleInventoryCloseEvent(this.player); // CraftBukkit
+
- this.player.s();
+ this.player.r();
}
public void a(PacketPlayInWindowClick packetplayinwindowclick) {
@@ -1147,7 +1146,7 @@
NonNullList nonnulllist = NonNullList.a();
for (int i = 0; i < this.player.activeContainer.c.size(); ++i) {
-@@ -836,8 +1577,274 @@
+@@ -843,8 +1584,274 @@
this.player.a(this.player.activeContainer, nonnulllist);
} else {
@@ -1423,7 +1422,7 @@
if (ItemStack.matches(packetplayinwindowclick.e(), itemstack)) {
this.player.playerConnection.sendPacket(new PacketPlayOutTransaction(packetplayinwindowclick.a(), packetplayinwindowclick.d(), true));
this.player.f = true;
-@@ -866,6 +1873,7 @@
+@@ -946,6 +1953,7 @@
public void a(PacketPlayInEnchantItem packetplayinenchantitem) {
PlayerConnectionUtils.ensureMainThread(packetplayinenchantitem, this, this.player.x());
@@ -1431,7 +1430,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());
-@@ -899,7 +1907,46 @@
+@@ -979,7 +1987,46 @@
}
boolean flag1 = packetplayinsetcreativeslot.a() >= 1 && packetplayinsetcreativeslot.a() <= 45;
@@ -1479,7 +1478,7 @@
if (flag1 && flag2) {
if (itemstack.isEmpty()) {
-@@ -923,6 +1970,7 @@
+@@ -1003,6 +2050,7 @@
public void a(PacketPlayInTransaction packetplayintransaction) {
PlayerConnectionUtils.ensureMainThread(packetplayintransaction, this, this.player.x());
@@ -1487,7 +1486,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()) {
-@@ -933,6 +1981,7 @@
+@@ -1013,6 +2061,7 @@
public void a(PacketPlayInUpdateSign packetplayinupdatesign) {
PlayerConnectionUtils.ensureMainThread(packetplayinupdatesign, this, this.player.x());
@@ -1495,7 +1494,7 @@
this.player.resetIdleTimer();
WorldServer worldserver = this.minecraftServer.getWorldServer(this.player.dimension);
BlockPosition blockposition = packetplayinupdatesign.a();
-@@ -949,14 +1998,30 @@
+@@ -1029,14 +2078,30 @@
if (!tileentitysign.a() || tileentitysign.e() != this.player) {
this.minecraftServer.warning("Player " + this.player.getName() + " just tried to change non-editable sign");
@@ -1527,7 +1526,7 @@
tileentitysign.update();
worldserver.notify(blockposition, iblockdata, iblockdata, 3);
-@@ -979,11 +2044,27 @@
+@@ -1059,11 +2124,27 @@
public void a(PacketPlayInAbilities packetplayinabilities) {
PlayerConnectionUtils.ensureMainThread(packetplayinabilities, this, this.player.x());
@@ -1556,7 +1555,7 @@
ArrayList arraylist = Lists.newArrayList();
Iterator iterator = this.minecraftServer.tabCompleteCommand(this.player, packetplayintabcomplete.a(), packetplayintabcomplete.b(), packetplayintabcomplete.c()).iterator();
-@@ -1009,6 +2090,13 @@
+@@ -1089,6 +2170,13 @@
ItemStack itemstack1;
if ("MC|BEdit".equals(s)) {
@@ -1570,7 +1569,7 @@
packetdataserializer = packetplayincustompayload.b();
try {
-@@ -1027,15 +2115,25 @@
+@@ -1107,15 +2195,25 @@
}
if (itemstack.getItem() == Items.WRITABLE_BOOK && itemstack.getItem() == itemstack1.getItem()) {
@@ -1596,7 +1595,7 @@
packetdataserializer = packetplayincustompayload.b();
try {
-@@ -1069,10 +2167,11 @@
+@@ -1149,10 +2247,11 @@
}
itemstack2.a("pages", (NBTBase) nbttaglist);
@@ -1609,7 +1608,7 @@
}
} else if ("MC|TrSel".equals(s)) {
try {
-@@ -1084,6 +2183,7 @@
+@@ -1164,6 +2263,7 @@
}
} catch (Exception exception2) {
PlayerConnection.LOGGER.error("Couldn\'t select trade", exception2);
@@ -1617,7 +1616,7 @@
}
} else {
TileEntity tileentity;
-@@ -1133,6 +2233,7 @@
+@@ -1213,6 +2313,7 @@
}
} catch (Exception exception3) {
PlayerConnection.LOGGER.error("Couldn\'t set command block", exception3);
@@ -1625,7 +1624,7 @@
}
} else if ("MC|AutoCmd".equals(s)) {
if (!this.minecraftServer.getEnableCommandBlock()) {
-@@ -1200,6 +2301,7 @@
+@@ -1280,6 +2381,7 @@
}
} catch (Exception exception4) {
PlayerConnection.LOGGER.error("Couldn\'t set command block", exception4);
@@ -1633,7 +1632,7 @@
}
} else {
int k;
-@@ -1223,6 +2325,7 @@
+@@ -1303,6 +2405,7 @@
}
} catch (Exception exception5) {
PlayerConnection.LOGGER.error("Couldn\'t set beacon", exception5);
@@ -1641,7 +1640,7 @@
}
}
} else if ("MC|ItemName".equals(s)) {
-@@ -1309,6 +2412,7 @@
+@@ -1389,6 +2492,7 @@
}
} catch (Exception exception6) {
PlayerConnection.LOGGER.error("Couldn\'t set structure block", exception6);
@@ -1649,7 +1648,7 @@
}
} else if ("MC|PickItem".equals(s)) {
packetdataserializer = packetplayincustompayload.b();
-@@ -1321,11 +2425,49 @@
+@@ -1401,11 +2505,49 @@
this.player.playerConnection.sendPacket(new PacketPlayOutHeldItemSlot(this.player.inventory.itemInHandIndex));
} catch (Exception exception7) {
PlayerConnection.LOGGER.error("Couldn\'t pick item", exception7);