mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-26 22:40:21 +01:00
What an event!
By: Dinnerbone <dinnerbone@dinnerbone.com>
This commit is contained in:
parent
0a517194ca
commit
130fc2576a
5 changed files with 113 additions and 0 deletions
19
paper-api/src/org/bukkit/event/Event.java
Normal file
19
paper-api/src/org/bukkit/event/Event.java
Normal file
|
@ -0,0 +1,19 @@
|
|||
|
||||
package org.bukkit.event;
|
||||
|
||||
import org.bukkit.Server;
|
||||
|
||||
/**
|
||||
* Represents an event
|
||||
*/
|
||||
public abstract class Event {
|
||||
private final Server server;
|
||||
|
||||
protected Event(final Server instance) {
|
||||
server = instance;
|
||||
}
|
||||
|
||||
public final Server getServer() {
|
||||
return server;
|
||||
}
|
||||
}
|
22
paper-api/src/org/bukkit/event/player/PlayerEvent.java
Normal file
22
paper-api/src/org/bukkit/event/player/PlayerEvent.java
Normal file
|
@ -0,0 +1,22 @@
|
|||
|
||||
package org.bukkit.event.player;
|
||||
|
||||
import org.bukkit.Player;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.event.Event;
|
||||
|
||||
/**
|
||||
* Represents a player related event
|
||||
*/
|
||||
public abstract class PlayerEvent extends Event {
|
||||
private final Player player;
|
||||
|
||||
protected PlayerEvent(final Server server, final Player who) {
|
||||
super(server);
|
||||
player = who;
|
||||
}
|
||||
|
||||
public final Player getPlayer() {
|
||||
return player;
|
||||
}
|
||||
}
|
14
paper-api/src/org/bukkit/event/player/PlayerJoinEvent.java
Normal file
14
paper-api/src/org/bukkit/event/player/PlayerJoinEvent.java
Normal file
|
@ -0,0 +1,14 @@
|
|||
|
||||
package org.bukkit.event.player;
|
||||
|
||||
import org.bukkit.Player;
|
||||
import org.bukkit.Server;
|
||||
|
||||
/**
|
||||
* Handles all event arguments in relation to a player joining a server
|
||||
*/
|
||||
public class PlayerJoinEvent extends PlayerEvent {
|
||||
public PlayerJoinEvent(final Server server, final Player player) {
|
||||
super(server, player);
|
||||
}
|
||||
}
|
13
paper-api/src/org/bukkit/event/player/PlayerListener.java
Normal file
13
paper-api/src/org/bukkit/event/player/PlayerListener.java
Normal file
|
@ -0,0 +1,13 @@
|
|||
|
||||
package org.bukkit.event.player;
|
||||
|
||||
/**
|
||||
* Handles all events thrown in relation to a Player
|
||||
*/
|
||||
public abstract class PlayerListener {
|
||||
private PlayerListener() {
|
||||
}
|
||||
|
||||
public abstract void onPlayerJoin(PlayerJoinEvent event);
|
||||
public abstract void onPlayerQuit(PlayerQuitEvent event);
|
||||
}
|
45
paper-api/src/org/bukkit/event/player/PlayerQuitEvent.java
Normal file
45
paper-api/src/org/bukkit/event/player/PlayerQuitEvent.java
Normal file
|
@ -0,0 +1,45 @@
|
|||
|
||||
package org.bukkit.event.player;
|
||||
|
||||
import org.bukkit.Player;
|
||||
import org.bukkit.Server;
|
||||
|
||||
/**
|
||||
* Handles all event arguments in relation to a player joining a server
|
||||
*/
|
||||
public class PlayerQuitEvent extends PlayerEvent {
|
||||
private final PlayerQuitReason reason;
|
||||
|
||||
public PlayerQuitEvent(final Server server, final Player player, final PlayerQuitReason because) {
|
||||
super(server, player);
|
||||
reason = because;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the reason for a player quitting the game
|
||||
* @return PlayerQuitReason with the relevant reason
|
||||
*/
|
||||
public PlayerQuitReason getReason() {
|
||||
return reason;
|
||||
}
|
||||
|
||||
/**
|
||||
* The reason a player quit the game
|
||||
*/
|
||||
public enum PlayerQuitReason {
|
||||
/**
|
||||
* A player willingly quit the game
|
||||
*/
|
||||
Quit,
|
||||
|
||||
/**
|
||||
* A player disconnected due to a technical fault
|
||||
*/
|
||||
Disconnected,
|
||||
|
||||
/**
|
||||
* A player was kicked by another player
|
||||
*/
|
||||
Kicked
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue