PaperMC/paper-server/patches/sources/net/minecraft/server/commands/DefaultGameModeCommands.java.patch
2021-05-15 10:04:43 -07:00

18 lines
1 KiB
Diff

--- a/net/minecraft/server/commands/DefaultGameModeCommands.java
+++ b/net/minecraft/server/commands/DefaultGameModeCommands.java
@@ -28,9 +28,13 @@
GameType gameType = minecraftServer.getForcedGameType();
if (gameType != null) {
for (ServerPlayer serverPlayer : minecraftServer.getPlayerList().getPlayers()) {
- if (serverPlayer.setGameMode(gameType)) {
- i++;
+ // Paper start - Expand PlayerGameModeChangeEvent
+ org.bukkit.event.player.PlayerGameModeChangeEvent event = serverPlayer.setGameMode(gameType, org.bukkit.event.player.PlayerGameModeChangeEvent.Cause.DEFAULT_GAMEMODE, net.kyori.adventure.text.Component.empty());
+ if (event != null && event.isCancelled()) {
+ source.sendSuccess(() -> io.papermc.paper.adventure.PaperAdventure.asVanilla(event.cancelMessage()), false);
}
+ // Paper end - Expand PlayerGameModeChangeEvent
+ i++;
}
}