fix issue in ServerPlayerGameMode

This commit is contained in:
Jake Potrebic 2024-12-15 15:20:33 -08:00
parent e3b23b59f3
commit 4912737b8d
No known key found for this signature in database
GPG key ID: ECE0B3C133C016C5

View file

@ -1,6 +1,6 @@
--- a/net/minecraft/server/level/ServerPlayerGameMode.java --- a/net/minecraft/server/level/ServerPlayerGameMode.java
+++ b/net/minecraft/server/level/ServerPlayerGameMode.java +++ b/net/minecraft/server/level/ServerPlayerGameMode.java
@@ -41,6 +_,8 @@ @@ -41,28 +_,49 @@
private BlockPos delayedDestroyPos = BlockPos.ZERO; private BlockPos delayedDestroyPos = BlockPos.ZERO;
private int delayedTickStart; private int delayedTickStart;
private int lastSentState = -1; private int lastSentState = -1;
@ -9,16 +9,17 @@
public ServerPlayerGameMode(ServerPlayer player) { public ServerPlayerGameMode(ServerPlayer player) {
this.player = player; this.player = player;
@@ -48,21 +_,39 @@ this.level = player.serverLevel();
} }
+ @Deprecated @io.papermc.paper.annotation.DoNotUse // Paper
public boolean changeGameModeForPlayer(GameType gameModeForPlayer) { public boolean changeGameModeForPlayer(GameType gameModeForPlayer) {
+ // Paper start - Expand PlayerGameModeChangeEvent + // Paper start - Expand PlayerGameModeChangeEvent
+ org.bukkit.event.player.PlayerGameModeChangeEvent event = this.changeGameModeForPlayer(gameModeForPlayer, org.bukkit.event.player.PlayerGameModeChangeEvent.Cause.UNKNOWN, null); + org.bukkit.event.player.PlayerGameModeChangeEvent event = this.changeGameModeForPlayer(gameModeForPlayer, org.bukkit.event.player.PlayerGameModeChangeEvent.Cause.UNKNOWN, null);
+ return event != null && event.isCancelled(); + return event != null && event.isCancelled();
+ } + }
+ @Nullable + @Nullable
+ public org.bukkit.event.player.PlayerGameModeChangeEvent changeGameModeForPlayer(GameType gameMode, org.bukkit.event.player.PlayerGameModeChangeEvent.Cause playerGameModeChangeCause, @Nullable net.kyori.adventure.text.Component cancelMessage) { + public org.bukkit.event.player.PlayerGameModeChangeEvent changeGameModeForPlayer(GameType gameModeForPlayer, org.bukkit.event.player.PlayerGameModeChangeEvent.Cause playerGameModeChangeCause, @Nullable net.kyori.adventure.text.Component cancelMessage) {
+ // Paper end - Expand PlayerGameModeChangeEvent + // Paper end - Expand PlayerGameModeChangeEvent
if (gameModeForPlayer == this.gameModeForPlayer) { if (gameModeForPlayer == this.gameModeForPlayer) {
- return false; - return false;
@ -28,7 +29,7 @@
+ // CraftBukkit start + // CraftBukkit start
+ org.bukkit.event.player.PlayerGameModeChangeEvent event = new org.bukkit.event.player.PlayerGameModeChangeEvent( + org.bukkit.event.player.PlayerGameModeChangeEvent event = new org.bukkit.event.player.PlayerGameModeChangeEvent(
+ this.player.getBukkitEntity(), + this.player.getBukkitEntity(),
+ org.bukkit.GameMode.getByValue(gameMode.getId()), + org.bukkit.GameMode.getByValue(gameModeForPlayer.getId()),
+ playerGameModeChangeCause, // Paper + playerGameModeChangeCause, // Paper
+ cancelMessage + cancelMessage
+ ); + );
@ -36,7 +37,7 @@
+ return event; // Paper - Expand PlayerGameModeChangeEvent + return event; // Paper - Expand PlayerGameModeChangeEvent
+ } + }
+ // CraftBukkit end + // CraftBukkit end
+ this.setGameModeForPlayer(gameMode, this.gameModeForPlayer); // Paper - Fix MC-259571 + this.setGameModeForPlayer(gameModeForPlayer, this.gameModeForPlayer); // Paper - Fix MC-259571
this.player.onUpdateAbilities(); this.player.onUpdateAbilities();
this.player this.player
.server .server