Package org.bukkit.event.player
Class PlayerGameModeChangeEvent
java.lang.Object
org.bukkit.event.Event
org.bukkit.event.player.PlayerEvent
org.bukkit.event.player.PlayerGameModeChangeEvent
- All Implemented Interfaces:
Cancellable
Called when the GameMode of the player is changed.
NOTE: When getCause() is PlayerGameModeChangeEvent.Cause.DEFAULT_GAMEMODE,
the Player from PlayerEvent.getPlayer() might not be fully online at
the time this event is fired. Plugins should use OfflinePlayer.isOnline()
to check before changing player state.
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from class org.bukkit.event.Event
Event.Result -
Field Summary
Fields inherited from class org.bukkit.event.player.PlayerEvent
player -
Constructor Summary
ConstructorsConstructorDescriptionPlayerGameModeChangeEvent(@NotNull Player player, @NotNull GameMode newGameMode) Deprecated, for removal: This API element is subject to removal in a future version.PlayerGameModeChangeEvent(@NotNull Player player, @NotNull GameMode newGameMode, @NotNull PlayerGameModeChangeEvent.Cause cause, Component cancelMessage) -
Method Summary
Modifier and TypeMethodDescriptionOnly valid if the gamemode change was caused by the/gamemodecommand or the gamemode switcher. Gets the message shown to the command user if the event is cancelled as a notification that a player's gamemode was not changed.voidcancelMessage(@Nullable Component message) Sets the message shown to the command user if the event was cancelled.getCause()Gets the cause of this gamemode change.static @NotNull HandlerListGets the GameMode the player is switched to.booleanGets the cancellation state of this event.voidsetCancelled(boolean cancel) Sets the cancellation state of this event.Methods inherited from class org.bukkit.event.player.PlayerEvent
getPlayerMethods inherited from class org.bukkit.event.Event
callEvent, getEventName, isAsynchronous
-
Constructor Details
-
PlayerGameModeChangeEvent
@Internal @Deprecated(forRemoval=true) public PlayerGameModeChangeEvent(@NotNull @NotNull Player player, @NotNull @NotNull GameMode newGameMode) Deprecated, for removal: This API element is subject to removal in a future version. -
PlayerGameModeChangeEvent
-
-
Method Details
-
getNewGameMode
Gets the GameMode the player is switched to.- Returns:
- player's new GameMode
-
getCause
Gets the cause of this gamemode change.- Returns:
- the cause
-
cancelMessage
Only valid if the gamemode change was caused by the/gamemodecommand or the gamemode switcher. Gets the message shown to the command user if the event is cancelled as a notification that a player's gamemode was not changed.- Returns:
- the error message shown to the command user,
nullby default
-
cancelMessage
Sets the message shown to the command user if the event was cancelled. The message is only shown to cancelled events that are called by the/gamemodecommand or the gamemode switcher.- Parameters:
message- the error message shown to the command user,nullto show no message.
-
isCancelled
public boolean isCancelled()Description copied from interface:CancellableGets the cancellation state of this event. A cancelled event will not be executed in the server, but will still pass to other plugins- Specified by:
isCancelledin interfaceCancellable- Returns:
trueif this event is cancelled
-
setCancelled
public void setCancelled(boolean cancel) Description copied from interface:CancellableSets the cancellation state of this event. A cancelled event will not be executed in the server, but will still pass to other plugins.- Specified by:
setCancelledin interfaceCancellable- Parameters:
cancel-trueif you wish to cancel this event
-
getHandlers
- Specified by:
getHandlersin classEvent
-
getHandlerList
-