summaryrefslogtreecommitdiffstats
path: root/nms-patches
diff options
context:
space:
mode:
authorThinkofdeath <thinkofdeath@spigotmc.org>2014-12-15 14:14:59 +0000
committerThinkofdeath <thinkofdeath@spigotmc.org>2014-12-15 14:14:59 +0000
commit4207eeffe027b6231b3f4fd416fcf33a55a1c28e (patch)
treea11639834c105dd3bb4791179554a8ff7ea9168e /nms-patches
parent55e592e542b6a0fd20e46987b7f4870bb7e85814 (diff)
downloadcraftbukkit-4207eeffe027b6231b3f4fd416fcf33a55a1c28e.tar
craftbukkit-4207eeffe027b6231b3f4fd416fcf33a55a1c28e.tar.gz
craftbukkit-4207eeffe027b6231b3f4fd416fcf33a55a1c28e.tar.lz
craftbukkit-4207eeffe027b6231b3f4fd416fcf33a55a1c28e.tar.xz
craftbukkit-4207eeffe027b6231b3f4fd416fcf33a55a1c28e.zip
SPIGOT-212: Modify the vanilla change gamemode method to call our version
Diffstat (limited to 'nms-patches')
-rw-r--r--nms-patches/CommandGamemode.patch38
-rw-r--r--nms-patches/EntityPlayer.patch27
2 files changed, 60 insertions, 5 deletions
diff --git a/nms-patches/CommandGamemode.patch b/nms-patches/CommandGamemode.patch
new file mode 100644
index 00000000..3f4dd212
--- /dev/null
+++ b/nms-patches/CommandGamemode.patch
@@ -0,0 +1,38 @@
+--- ../work/decompile-8eb82bde/net/minecraft/server/CommandGamemode.java 2014-12-15 14:13:23.910966159 +0000
++++ src/main/java/net/minecraft/server/CommandGamemode.java 2014-12-15 14:13:23.910966159 +0000
+@@ -18,7 +18,7 @@
+ return "commands.gamemode.usage";
+ }
+
+- public void execute(ICommandListener icommandlistener, String[] astring) {
++ public void execute(ICommandListener icommandlistener, String[] astring) throws ExceptionUsage { // CraftBukkit - added throws
+ if (astring.length <= 0) {
+ throw new ExceptionUsage("commands.gamemode.usage", new Object[0]);
+ } else {
+@@ -26,6 +26,14 @@
+ EntityPlayer entityplayer = astring.length >= 2 ? a(icommandlistener, astring[1]) : b(icommandlistener);
+
+ entityplayer.a(enumgamemode);
++
++ // CraftBukkit start - handle event cancelling the change
++ if (entityplayer.playerInteractManager.getGameMode() != enumgamemode) {
++ icommandlistener.sendMessage(new ChatComponentText("Failed to set the gamemode of '" + entityplayer.getName() + "'"));
++ return;
++ }
++ // CraftBukkit end
++
+ entityplayer.fallDistance = 0.0F;
+ if (icommandlistener.getWorld().getGameRules().getBoolean("sendCommandFeedback")) {
+ entityplayer.sendMessage(new ChatMessage("gameMode.changed", new Object[0]));
+@@ -57,4 +65,11 @@
+ public boolean isListStart(String[] astring, int i) {
+ return i == 1;
+ }
++
++ // CraftBukkit start - fix decompiler error
++ @Override
++ public int compareTo(Object o) {
++ return a((ICommand) o);
++ }
++ // CraftBukkit end
+ }
diff --git a/nms-patches/EntityPlayer.patch b/nms-patches/EntityPlayer.patch
index 77026b1a..a9a827c2 100644
--- a/nms-patches/EntityPlayer.patch
+++ b/nms-patches/EntityPlayer.patch
@@ -1,5 +1,5 @@
---- ../work/decompile-8eb82bde/net/minecraft/server/EntityPlayer.java 2014-12-12 19:26:14.249913563 +0000
-+++ src/main/java/net/minecraft/server/EntityPlayer.java 2014-12-12 19:25:07.997914283 +0000
+--- ../work/decompile-8eb82bde/net/minecraft/server/EntityPlayer.java 2014-12-15 14:13:24.430966154 +0000
++++ src/main/java/net/minecraft/server/EntityPlayer.java 2014-12-15 14:13:24.434966154 +0000
@@ -13,6 +13,17 @@
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
@@ -446,7 +446,24 @@
public void b(IChatBaseComponent ichatbasecomponent) {
this.playerConnection.sendPacket(new PacketPlayOutChat(ichatbasecomponent));
-@@ -768,6 +936,7 @@
+@@ -747,6 +915,8 @@
+ }
+
+ public void a(EnumGamemode enumgamemode) {
++ getBukkitEntity().setGameMode(org.bukkit.GameMode.getByValue(enumgamemode.getId()));
++ /* CraftBukkit start - defer to our setGameMode
+ this.playerInteractManager.setGameMode(enumgamemode);
+ this.playerConnection.sendPacket(new PacketPlayOutGameStateChange(3, (float) enumgamemode.getId()));
+ if (enumgamemode == EnumGamemode.SPECTATOR) {
+@@ -757,6 +927,7 @@
+
+ this.updateAbilities();
+ this.bO();
++ // CraftBukkit end */
+ }
+
+ public boolean v() {
+@@ -768,6 +939,7 @@
}
public boolean a(int i, String s) {
@@ -454,7 +471,7 @@
if ("seed".equals(s) && !this.server.ad()) {
return true;
} else if (!"tell".equals(s) && !"help".equals(s) && !"me".equals(s) && !"trigger".equals(s)) {
-@@ -781,6 +950,9 @@
+@@ -781,6 +953,9 @@
} else {
return true;
}
@@ -464,7 +481,7 @@
}
public String w() {
-@@ -867,6 +1039,129 @@
+@@ -867,6 +1042,129 @@
}
public IChatBaseComponent getPlayerListName() {