What an event!

By: Dinnerbone <dinnerbone@dinnerbone.com>
This commit is contained in:
Bukkit/Spigot 2010-12-25 20:28:11 +00:00
parent 0a517194ca
commit 130fc2576a
5 changed files with 113 additions and 0 deletions

View 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;
}
}

View 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;
}
}

View 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);
}
}

View 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);
}

View 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
}
}