testserver/Spigot-Server-Patches/0143-Reimplement-PlayerEdit...

90 lines
4.2 KiB
Diff
Raw Normal View History

From df91c49a8a8472b88e89ad0634954ee2b495b793 Mon Sep 17 00:00:00 2001
2016-04-27 03:00:23 +00:00
From: willies952002 <admin@domnian.com>
Date: Sat, 23 Apr 2016 19:51:19 -0400
Subject: [PATCH] Reimplement PlayerEditBookEvent
diff --git a/src/main/java/net/minecraft/server/PlayerConnection.java b/src/main/java/net/minecraft/server/PlayerConnection.java
2016-05-12 02:07:46 +00:00
index 4d471ec..cf27086 100644
2016-04-27 03:00:23 +00:00
--- a/src/main/java/net/minecraft/server/PlayerConnection.java
+++ b/src/main/java/net/minecraft/server/PlayerConnection.java
2016-05-12 02:07:46 +00:00
@@ -2207,6 +2207,7 @@ public class PlayerConnection implements PacketListenerPlayIn, ITickable {
2016-04-27 03:00:23 +00:00
ItemStack itemstack;
ItemStack itemstack1;
+ try { // Paper - Reimplement BookEditEvent
if ("MC|BEdit".equals(s)) {
packetdataserializer = new PacketDataSerializer(Unpooled.wrappedBuffer(packetplayincustompayload.b()));
2016-05-12 02:07:46 +00:00
@@ -2224,12 +2225,14 @@ public class PlayerConnection implements PacketListenerPlayIn, ITickable {
2016-04-27 03:00:23 +00:00
if (itemstack1 != null) {
if (itemstack.getItem() == Items.WRITABLE_BOOK && itemstack.getItem() == itemstack1.getItem()) {
itemstack1.a("pages", (NBTBase) itemstack.getTag().getList("pages", 8));
+ CraftEventFactory.handleEditBookEvent(player, itemstack1); // Paper
}
return;
}
} catch (Exception exception) {
PlayerConnection.LOGGER.error("Couldn\'t handle book info", exception);
+ this.disconnect("Invalid Book Data!"); // Paper
return;
} finally {
packetdataserializer.release();
2016-05-12 02:07:46 +00:00
@@ -2269,12 +2272,14 @@ public class PlayerConnection implements PacketListenerPlayIn, ITickable {
2016-04-27 03:00:23 +00:00
itemstack1.a("pages", (NBTBase) nbttaglist);
itemstack1.setItem(Items.WRITTEN_BOOK);
+ CraftEventFactory.handleEditBookEvent(player, itemstack1); // Paper
}
return;
}
} catch (Exception exception1) {
PlayerConnection.LOGGER.error("Couldn\'t sign book", exception1);
+ this.disconnect("Invalid Book Data!"); // Paper
return;
} finally {
packetdataserializer.release();
2016-05-12 02:07:46 +00:00
@@ -2340,6 +2345,7 @@ public class PlayerConnection implements PacketListenerPlayIn, ITickable {
2016-04-27 03:00:23 +00:00
}
} catch (Exception exception3) {
PlayerConnection.LOGGER.error("Couldn\'t set command block", exception3);
+ this.disconnect("Invalid Command Block Data!"); // Paper
} finally {
packetdataserializer.release();
}
2016-05-12 02:07:46 +00:00
@@ -2409,6 +2415,7 @@ public class PlayerConnection implements PacketListenerPlayIn, ITickable {
2016-04-27 03:00:23 +00:00
}
} catch (Exception exception4) {
PlayerConnection.LOGGER.error("Couldn\'t set command block", exception4);
+ this.disconnect("Invalid Command Block Data!"); // Paper
} finally {
packetdataserializer.release();
}
2016-05-12 02:07:46 +00:00
@@ -2434,6 +2441,7 @@ public class PlayerConnection implements PacketListenerPlayIn, ITickable {
2016-04-27 03:00:23 +00:00
}
} catch (Exception exception5) {
PlayerConnection.LOGGER.error("Couldn\'t set beacon", exception5);
+ this.disconnect("Invalid Beacon Data!"); // Paper
}
}
} else if ("MC|ItemName".equals(s)) {
2016-05-12 02:07:46 +00:00
@@ -2536,6 +2544,13 @@ public class PlayerConnection implements PacketListenerPlayIn, ITickable {
2016-04-27 03:00:23 +00:00
}
}
}
+ // Paper start
+ } finally {
+ if (packetplayincustompayload.b().refCnt() > 0) {
+ packetplayincustompayload.b().release();
+ }
+ }
+ // Paper end
}
--
2.7.4 (Apple Git-66)
2016-04-27 03:00:23 +00:00