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 SummaryNested ClassesNested classes/interfaces inherited from class org.bukkit.event.EventEvent.Result
- 
Field SummaryFields inherited from class org.bukkit.event.player.PlayerEventplayer
- 
Constructor SummaryConstructorsConstructorDescriptionPlayerGameModeChangeEvent(@NotNull Player player, @NotNull GameMode newGameMode) Deprecated.PlayerGameModeChangeEvent(@NotNull Player player, @NotNull GameMode newGameMode, @NotNull PlayerGameModeChangeEvent.Cause cause, Component cancelMessage) 
- 
Method SummaryModifier and TypeMethodDescriptionOnly valid if the cause of the gamemode change was directly due to a command..voidcancelMessage(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.PlayerEventgetPlayerMethods inherited from class org.bukkit.event.EventcallEvent, getEventName, isAsynchronous
- 
Constructor Details
- 
Method Details- 
isCancelledpublic 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 interface- Cancellable
- Returns:
- true if this event is cancelled
 
- 
setCancelledpublic 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 interface- Cancellable
- Parameters:
- cancel- true if you wish to cancel this event
 
- 
getNewGameModeGets the GameMode the player is switched to.- Returns:
- player's new GameMode
 
- 
getHandlers- Specified by:
- getHandlersin class- Event
 
- 
getHandlerList
- 
getCauseGets the cause of this gamemode change.- Returns:
- the cause
 
- 
cancelMessageOnly valid if the cause of the gamemode change was directly due to a command.. Gets the message shown to the command user if the event is cancelled as a notification that a player's gamemode was not changed.This returns nullif the gamemode change was due to a plugin, or a player joining the game with a gamemode not equal to the server default gamemode andforce-gamemodeis set to true.- Returns:
- the error message shown to the command user, null if not directly caused by a command
 
- 
cancelMessageSets the message shown to the command user if the event was cancelled. The message is only shown to cancelled events that are directly called by a command not by a plugin or a player joining with the wrong gamemode.- Parameters:
- message- the error message shown to the command user, null to show no message.
 
 
-