PaperMC/paper-server/patches/sources/net/minecraft/server/commands/GameModeCommand.java.patch
2024-12-14 13:42:45 -08:00

18 lines
1,005 B
Diff

--- a/net/minecraft/server/commands/GameModeCommand.java
+++ b/net/minecraft/server/commands/GameModeCommand.java
@@ -54,9 +_,14 @@
int i = 0;
for (ServerPlayer serverPlayer : players) {
- if (serverPlayer.setGameMode(gameType)) {
+ // Paper start - Expand PlayerGameModeChangeEvent
+ org.bukkit.event.player.PlayerGameModeChangeEvent event = serverPlayer.setGameMode(gameType, org.bukkit.event.player.PlayerGameModeChangeEvent.Cause.COMMAND, net.kyori.adventure.text.Component.empty());
+ if (event != null && !event.isCancelled()) {
logGamemodeChange(source.getSource(), serverPlayer, gameType);
i++;
+ } else if (event != null && event.cancelMessage() != null) {
+ source.getSource().sendSuccess(() -> io.papermc.paper.adventure.PaperAdventure.asVanilla(event.cancelMessage()), true);
+ // Paper end - Expand PlayerGameModeChangeEvent
}
}