001 package org.bukkit.event.player; 002 003 import org.bukkit.entity.Player; 004 import org.bukkit.event.Cancellable; 005 import org.bukkit.event.HandlerList; 006 007 /** 008 * Called when a player gets kicked from the server 009 */ 010 public class PlayerKickEvent extends PlayerEvent implements Cancellable { 011 private static final HandlerList handlers = new HandlerList(); 012 private String leaveMessage; 013 private String kickReason; 014 private Boolean cancel; 015 016 public PlayerKickEvent(final Player playerKicked, final String kickReason, final String leaveMessage) { 017 super(playerKicked); 018 this.kickReason = kickReason; 019 this.leaveMessage = leaveMessage; 020 this.cancel = false; 021 } 022 023 /** 024 * Gets the reason why the player is getting kicked 025 * 026 * @return string kick reason 027 */ 028 public String getReason() { 029 return kickReason; 030 } 031 032 /** 033 * Gets the leave message send to all online players 034 * 035 * @return string kick reason 036 */ 037 public String getLeaveMessage() { 038 return leaveMessage; 039 } 040 041 public boolean isCancelled() { 042 return cancel; 043 } 044 045 public void setCancelled(boolean cancel) { 046 this.cancel = cancel; 047 } 048 049 /** 050 * Sets the reason why the player is getting kicked 051 * 052 * @param kickReason kick reason 053 */ 054 public void setReason(String kickReason) { 055 this.kickReason = kickReason; 056 } 057 058 /** 059 * Sets the leave message send to all online players 060 * 061 * @param leaveMessage leave message 062 */ 063 public void setLeaveMessage(String leaveMessage) { 064 this.leaveMessage = leaveMessage; 065 } 066 067 @Override 068 public HandlerList getHandlers() { 069 return handlers; 070 } 071 072 public static HandlerList getHandlerList() { 073 return handlers; 074 } 075 }