001 package org.bukkit.event.player; 002 003 import org.bukkit.GameMode; 004 import org.bukkit.entity.Player; 005 import org.bukkit.event.Cancellable; 006 import org.bukkit.event.HandlerList; 007 008 /** 009 * Called when the GameMode of the player is changed. 010 */ 011 public class PlayerGameModeChangeEvent extends PlayerEvent implements Cancellable { 012 private static final HandlerList handlers = new HandlerList(); 013 private boolean cancelled; 014 private final GameMode newGameMode; 015 016 public PlayerGameModeChangeEvent(final Player player, final GameMode newGameMode) { 017 super(player); 018 this.newGameMode = newGameMode; 019 } 020 021 public boolean isCancelled() { 022 return cancelled; 023 } 024 025 public void setCancelled(boolean cancel) { 026 this.cancelled = cancel; 027 } 028 029 /** 030 * Gets the GameMode the player is switched to. 031 * 032 * @return player's new GameMode 033 */ 034 public GameMode getNewGameMode() { 035 return newGameMode; 036 } 037 038 @Override 039 public HandlerList getHandlers() { 040 return handlers; 041 } 042 043 public static HandlerList getHandlerList() { 044 return handlers; 045 } 046 }