Files
CatServer/patches/net/minecraft/command/CommandGameMode.java.patch
2019-02-24 22:29:41 +08:00

28 lines
1.5 KiB
Diff

--- ../src-base/minecraft/net/minecraft/command/CommandGameMode.java
+++ ../src-work/minecraft/net/minecraft/command/CommandGameMode.java
@@ -4,9 +4,11 @@
import java.util.List;
import javax.annotation.Nullable;
import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.server.MinecraftServer;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.text.ITextComponent;
+import net.minecraft.util.text.TextComponentString;
import net.minecraft.util.text.TextComponentTranslation;
import net.minecraft.world.GameType;
import net.minecraft.world.WorldSettings;
@@ -39,6 +41,12 @@
GameType gametype = this.getGameModeFromCommand(sender, args[0]);
EntityPlayer entityplayer = args.length >= 2 ? getPlayer(server, sender, args[1]) : getCommandSenderAsPlayer(sender);
entityplayer.setGameType(gametype);
+ // CraftBukkit start - handle event cancelling the change
+ if (((EntityPlayerMP) entityplayer).interactionManager.getGameType() != gametype) {
+ sender.sendMessage(new TextComponentString("Failed to set the gamemode of '" + entityplayer.getName() + "'"));
+ return;
+ }
+ // CraftBukkit end
ITextComponent itextcomponent = new TextComponentTranslation("gameMode." + gametype.getName(), new Object[0]);
if (sender.getEntityWorld().getGameRules().getBoolean("sendCommandFeedback"))