diff --git a/paper-api/src/org/bukkit/event/Event.java b/paper-api/src/org/bukkit/event/Event.java new file mode 100644 index 0000000000..f2d17753e7 --- /dev/null +++ b/paper-api/src/org/bukkit/event/Event.java @@ -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; + } +} diff --git a/paper-api/src/org/bukkit/event/player/PlayerEvent.java b/paper-api/src/org/bukkit/event/player/PlayerEvent.java new file mode 100644 index 0000000000..631e745908 --- /dev/null +++ b/paper-api/src/org/bukkit/event/player/PlayerEvent.java @@ -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; + } +} diff --git a/paper-api/src/org/bukkit/event/player/PlayerJoinEvent.java b/paper-api/src/org/bukkit/event/player/PlayerJoinEvent.java new file mode 100644 index 0000000000..192abe204e --- /dev/null +++ b/paper-api/src/org/bukkit/event/player/PlayerJoinEvent.java @@ -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); + } +} diff --git a/paper-api/src/org/bukkit/event/player/PlayerListener.java b/paper-api/src/org/bukkit/event/player/PlayerListener.java new file mode 100644 index 0000000000..7fb30bae9e --- /dev/null +++ b/paper-api/src/org/bukkit/event/player/PlayerListener.java @@ -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); +} diff --git a/paper-api/src/org/bukkit/event/player/PlayerQuitEvent.java b/paper-api/src/org/bukkit/event/player/PlayerQuitEvent.java new file mode 100644 index 0000000000..101fe736f2 --- /dev/null +++ b/paper-api/src/org/bukkit/event/player/PlayerQuitEvent.java @@ -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 + } +}