mirror of
https://github.com/PaperMC/Paper.git
synced 2025-02-18 11:22:15 +01:00
Added PlayerKick (setReason, setLeaveMessage, setCancelled) and PlayerRespawn (setLocation)
By: Forsaken <darkmaster87@gmx.de>
This commit is contained in:
parent
98a9148cf0
commit
566638ff0c
5 changed files with 147 additions and 0 deletions
paper-api/src/main/java/org/bukkit
|
@ -150,6 +150,20 @@ public abstract class Event {
|
|||
*/
|
||||
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
|
||||
*
|
||||
|
|
|
@ -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) {
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
*
|
||||
|
@ -57,6 +66,14 @@ public class PlayerListener implements Listener {
|
|||
*/
|
||||
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
|
||||
|
|
|
@ -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 );
|
||||
}
|
||||
};
|
||||
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:
|
||||
return new EventExecutor() { public void execute( Listener listener, Event event ) {
|
||||
((PlayerListener)listener).onPlayerCommand( (PlayerChatEvent)event );
|
||||
|
|
Loading…
Add table
Reference in a new issue