PaperMC/paper-server/patches/sources/net/minecraft/server/commands/DefaultGameModeCommands.java.patch

19 lines
1 KiB
Diff
Raw Normal View History

2021-05-15 19:04:43 +02:00
--- a/net/minecraft/server/commands/DefaultGameModeCommands.java
+++ b/net/minecraft/server/commands/DefaultGameModeCommands.java
2024-12-14 22:42:43 +01:00
@@ -28,9 +_,13 @@
GameType forcedGameType = server.getForcedGameType();
if (forcedGameType != null) {
for (ServerPlayer serverPlayer : server.getPlayerList().getPlayers()) {
- if (serverPlayer.setGameMode(forcedGameType)) {
2021-05-15 19:04:43 +02:00
- i++;
+ // Paper start - Expand PlayerGameModeChangeEvent
2024-12-14 22:42:43 +01:00
+ org.bukkit.event.player.PlayerGameModeChangeEvent event = serverPlayer.setGameMode(gamemode, org.bukkit.event.player.PlayerGameModeChangeEvent.Cause.DEFAULT_GAMEMODE, net.kyori.adventure.text.Component.empty());
2021-05-15 19:04:43 +02:00
+ if (event != null && event.isCancelled()) {
2024-12-14 22:42:43 +01:00
+ commandSource.sendSuccess(() -> io.papermc.paper.adventure.PaperAdventure.asVanilla(event.cancelMessage()), false);
2021-05-15 19:04:43 +02:00
}
+ // Paper end - Expand PlayerGameModeChangeEvent
+ i++;
}
}