papermc/paper-server/patches/sources/net/minecraft/server/commands/GameModeCommand.java.patch

21 lines
1 KiB
Diff
Raw Normal View History

2021-05-15 10:04:43 -07:00
--- a/net/minecraft/server/commands/GameModeCommand.java
+++ b/net/minecraft/server/commands/GameModeCommand.java
@@ -69,9 +_,16 @@
}
2021-05-15 10:04:43 -07:00
private static boolean setGameMode(CommandSourceStack source, ServerPlayer player, GameType gameMode) {
- if (player.setGameMode(gameMode)) {
+ // Paper start
+ org.bukkit.event.player.PlayerGameModeChangeEvent event = player.setGameMode(gameMode, org.bukkit.event.player.PlayerGameModeChangeEvent.Cause.COMMAND, net.kyori.adventure.text.Component.empty());
+ if (event != null && !event.isCancelled()) {
+ // Paper end
logGamemodeChange(source, player, gameMode);
return true;
+ } else if (event != null && event.cancelMessage() != null) {
+ source.sendSuccess(() -> io.papermc.paper.adventure.PaperAdventure.asVanilla(event.cancelMessage()), true);
+ return false;
+ // Paper end - Expand PlayerGameModeChangeEvent
} else {
return false;
2021-05-15 10:04:43 -07:00
}