mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-28 23:38:25 +01:00
Better docs for PlayerGameModeChangeEvent (#6461)
This commit is contained in:
parent
92d1ace250
commit
9169cf73cc
2 changed files with 13 additions and 1 deletions
|
@ -8,7 +8,17 @@ diff --git a/src/main/java/org/bukkit/event/player/PlayerGameModeChangeEvent.jav
|
|||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/org/bukkit/event/player/PlayerGameModeChangeEvent.java
|
||||
+++ b/src/main/java/org/bukkit/event/player/PlayerGameModeChangeEvent.java
|
||||
@@ -0,0 +0,0 @@ public class PlayerGameModeChangeEvent extends PlayerEvent implements Cancellabl
|
||||
@@ -0,0 +0,0 @@ import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Called when the GameMode of the player is changed.
|
||||
+ * <p>
|
||||
+ * <b>NOTE:</b> When {@link #getCause()} is {@link Cause#DEFAULT_GAMEMODE},
|
||||
+ * the Player from {@link #getPlayer()} might not be fully online at
|
||||
+ * the time this event is fired. Plugins should use {@link Player#isOnline()}
|
||||
+ * to check before changing player state.
|
||||
*/
|
||||
public class PlayerGameModeChangeEvent extends PlayerEvent implements Cancellable {
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
private boolean cancelled;
|
||||
private final GameMode newGameMode;
|
||||
|
|
|
@ -79,6 +79,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
}
|
||||
|
||||
public void loadGameTypes(@Nullable CompoundTag nbt) {
|
||||
+ // Paper start
|
||||
+ if (this.server.getForcedGameType() != null && this.server.getForcedGameType() != ServerPlayer.readPlayerMode(nbt, "playerGameType")) {
|
||||
+ if (new PlayerGameModeChangeEvent(this.getBukkitEntity(), GameMode.getByValue(this.server.getDefaultGameType().getId()), org.bukkit.event.player.PlayerGameModeChangeEvent.Cause.DEFAULT_GAMEMODE, null).callEvent()) {
|
||||
+ this.gameMode.setGameModeForPlayer(this.server.getForcedGameType(), GameType.DEFAULT_MODE);
|
||||
|
@ -87,6 +88,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
+ }
|
||||
+ return;
|
||||
+ }
|
||||
+ // Paper end
|
||||
this.gameMode.setGameModeForPlayer(this.calculateGameModeForNewPlayer(ServerPlayer.readPlayerMode(nbt, "playerGameType")), ServerPlayer.readPlayerMode(nbt, "previousPlayerGameType"));
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue