Added PlayerKick (setReason, setLeaveMessage, setCancelled) and PlayerRespawn (setLocation)
This commit is contained in:
parent
1d8cd948d2
commit
0b998a2fe4
@ -150,6 +150,20 @@ public abstract class Event {
|
|||||||
*/
|
*/
|
||||||
PLAYER_LOGIN (Category.PLAYER),
|
PLAYER_LOGIN (Category.PLAYER),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when a player respawns
|
||||||
|
*
|
||||||
|
* @see org.bukkit.event.player.PlayerEvent
|
||||||
|
*/
|
||||||
|
PLAYER_RESPAWN (Category.PLAYER),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when a player gets kicked a server
|
||||||
|
*
|
||||||
|
* @see org.bukkit.event.player.PlayerEvent
|
||||||
|
*/
|
||||||
|
PLAYER_KICK (Category.PLAYER),
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when a player sends a chat message
|
* Called when a player sends a chat message
|
||||||
*
|
*
|
||||||
|
75
src/main/java/org/bukkit/event/player/PlayerKickEvent.java
Normal file
75
src/main/java/org/bukkit/event/player/PlayerKickEvent.java
Normal file
@ -0,0 +1,75 @@
|
|||||||
|
package org.bukkit.event.player;
|
||||||
|
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.Cancellable;
|
||||||
|
|
||||||
|
public class PlayerKickEvent extends PlayerEvent implements Cancellable {
|
||||||
|
private String leaveMessage;
|
||||||
|
private String kickReason;
|
||||||
|
private Boolean cancel;
|
||||||
|
|
||||||
|
public PlayerKickEvent(Type eventType, Player playerKicked, String kickReason, String leaveMessage) {
|
||||||
|
super(eventType, playerKicked);
|
||||||
|
this.kickReason = kickReason;
|
||||||
|
this.leaveMessage = leaveMessage;
|
||||||
|
this.cancel = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the cancellation state of this event. Set to true if you
|
||||||
|
* want to prevent the player from getting kicked.
|
||||||
|
*
|
||||||
|
* @return boolean cancellation state
|
||||||
|
*/
|
||||||
|
public boolean isCancelled() {
|
||||||
|
return cancel;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the reason why the player is getting kicked
|
||||||
|
*
|
||||||
|
* @return string kick reason
|
||||||
|
*/
|
||||||
|
public String getReason() {
|
||||||
|
return kickReason;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the leave message send to all online players
|
||||||
|
*
|
||||||
|
* @return string kick reason
|
||||||
|
*/
|
||||||
|
public String getLeaveMessage() {
|
||||||
|
return leaveMessage;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the cancellation state of this event. A cancelled event will not
|
||||||
|
* be executed in the server, but will still pass to other plugins
|
||||||
|
*
|
||||||
|
* Cancelling this event will prevent the kick of the targetted player
|
||||||
|
*
|
||||||
|
* @param cancel true if you wish to cancel this event
|
||||||
|
*/
|
||||||
|
public void setCancelled(boolean cancel) {
|
||||||
|
this.cancel = cancel;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the reason why the player is getting kicked
|
||||||
|
*
|
||||||
|
* @param kickReason kick reason
|
||||||
|
*/
|
||||||
|
public void setReason(String kickReason) {
|
||||||
|
this.kickReason = kickReason;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the leave message send to all online players
|
||||||
|
*
|
||||||
|
* @param leaveMessage leave message
|
||||||
|
*/
|
||||||
|
public void setLeaveMessage(String leaveMessage) {
|
||||||
|
this.leaveMessage = leaveMessage;
|
||||||
|
}
|
||||||
|
}
|
@ -26,6 +26,15 @@ public class PlayerListener implements Listener {
|
|||||||
public void onPlayerQuit(PlayerEvent event) {
|
public void onPlayerQuit(PlayerEvent event) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when a player gets kicked from the server
|
||||||
|
*
|
||||||
|
* @param event Relevant event details
|
||||||
|
*/
|
||||||
|
public void onPlayerKick(PlayerKickEvent event) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when a player sends a chat message
|
* Called when a player sends a chat message
|
||||||
*
|
*
|
||||||
@ -58,6 +67,14 @@ public class PlayerListener implements Listener {
|
|||||||
public void onPlayerTeleport(PlayerMoveEvent event) {
|
public void onPlayerTeleport(PlayerMoveEvent event) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when a player respawns
|
||||||
|
*
|
||||||
|
* @param event Relevant event details
|
||||||
|
*/
|
||||||
|
public void onPlayerRespawn(PlayerRespawnEvent event) {
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when a player uses an item
|
* Called when a player uses an item
|
||||||
*
|
*
|
||||||
|
@ -0,0 +1,31 @@
|
|||||||
|
package org.bukkit.event.player;
|
||||||
|
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
public class PlayerRespawnEvent extends PlayerEvent {
|
||||||
|
private Location respawnLocation;
|
||||||
|
|
||||||
|
public PlayerRespawnEvent(Type type, Player respawnPlayer, Location respawnLocation) {
|
||||||
|
super(type, respawnPlayer);
|
||||||
|
this.respawnLocation = respawnLocation;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the current respawn location
|
||||||
|
*
|
||||||
|
* @return Location current respawn location
|
||||||
|
*/
|
||||||
|
public Location getRespawnLocation() {
|
||||||
|
return this.respawnLocation;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the new respawn location
|
||||||
|
*
|
||||||
|
* @param respawnLocation new location for the respawn
|
||||||
|
*/
|
||||||
|
public void setRespawnLocation(Location respawnLocation) {
|
||||||
|
this.respawnLocation = respawnLocation;
|
||||||
|
}
|
||||||
|
}
|
@ -128,6 +128,16 @@ public final class JavaPluginLoader implements PluginLoader {
|
|||||||
((PlayerListener)listener).onPlayerQuit( (PlayerEvent)event );
|
((PlayerListener)listener).onPlayerQuit( (PlayerEvent)event );
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
case PLAYER_RESPAWN:
|
||||||
|
return new EventExecutor() { public void execute( Listener listener, Event event ) {
|
||||||
|
((PlayerListener)listener).onPlayerRespawn( (PlayerRespawnEvent)event );
|
||||||
|
}
|
||||||
|
};
|
||||||
|
case PLAYER_KICK:
|
||||||
|
return new EventExecutor() { public void execute( Listener listener, Event event ) {
|
||||||
|
((PlayerListener)listener).onPlayerKick( (PlayerKickEvent)event );
|
||||||
|
}
|
||||||
|
};
|
||||||
case PLAYER_COMMAND:
|
case PLAYER_COMMAND:
|
||||||
return new EventExecutor() { public void execute( Listener listener, Event event ) {
|
return new EventExecutor() { public void execute( Listener listener, Event event ) {
|
||||||
((PlayerListener)listener).onPlayerCommand( (PlayerChatEvent)event );
|
((PlayerListener)listener).onPlayerCommand( (PlayerChatEvent)event );
|
||||||
|
Loading…
x
Reference in New Issue
Block a user