diff options
author | sk89q <the.sk89q@gmail.com> | 2011-09-26 15:32:01 -0700 |
---|---|---|
committer | sk89q <the.sk89q@gmail.com> | 2011-09-26 15:32:01 -0700 |
commit | fff5598704b2d59fd2e0b1a48b0b157aa27589e0 (patch) | |
tree | 56f0d22f8f9886edd4daa365b33ce19c2d66f997 | |
parent | d38c63837f9400719767701e26d4f21564017ffa (diff) | |
download | bukkit-fff5598704b2d59fd2e0b1a48b0b157aa27589e0.tar bukkit-fff5598704b2d59fd2e0b1a48b0b157aa27589e0.tar.gz bukkit-fff5598704b2d59fd2e0b1a48b0b157aa27589e0.tar.lz bukkit-fff5598704b2d59fd2e0b1a48b0b157aa27589e0.tar.xz bukkit-fff5598704b2d59fd2e0b1a48b0b157aa27589e0.zip |
Added server list ping event.
4 files changed, 100 insertions, 0 deletions
diff --git a/src/main/java/org/bukkit/event/Event.java b/src/main/java/org/bukkit/event/Event.java index eb4c87d8..80e28132 100644 --- a/src/main/java/org/bukkit/event/Event.java +++ b/src/main/java/org/bukkit/event/Event.java @@ -504,6 +504,12 @@ public abstract class Event implements Serializable { * @see org.bukkit.event.server.MapInitializeEvent */ MAP_INITIALIZE (Category.SERVER), + /** + * Called when a client pings a server. + * + * @see org.bukkit.event.server.ServerListPingEvent + */ + SERVER_LIST_PING (Category.SERVER), /** * WORLD EVENTS diff --git a/src/main/java/org/bukkit/event/server/ServerListPingEvent.java b/src/main/java/org/bukkit/event/server/ServerListPingEvent.java new file mode 100644 index 00000000..b1f588f1 --- /dev/null +++ b/src/main/java/org/bukkit/event/server/ServerListPingEvent.java @@ -0,0 +1,80 @@ +package org.bukkit.event.server; + +import java.net.InetAddress; + +import org.bukkit.event.Event; + +/** + * Called when a server list ping is coming in. + * + * @author sk89q + */ +public class ServerListPingEvent extends ServerEvent { + + private InetAddress address; + private String motd; + private int numPlayers; + private int maxPlayers; + + public ServerListPingEvent(InetAddress address, String motd, int numPlayers, int maxPlayers) { + super(Event.Type.SERVER_LIST_PING); + this.address = address; + this.motd = motd; + this.numPlayers = numPlayers; + this.maxPlayers = maxPlayers; + } + + /** + * Get the address the ping is coming from. + * + * @return the address + */ + public InetAddress getAddress() { + return address; + } + + /** + * Get the message of the day message. + * + * @return the message of the day + */ + public String getMotd() { + return motd; + } + + /** + * Change the message of the day message. + * + * @param motd the message of the day + */ + public void setMotd(String motd) { + this.motd = motd; + } + + /** + * Get the number of players sent. + * + * @return the number of players + */ + public int getNumPlayers() { + return numPlayers; + } + + /** + * Get the maximum number of players sent. + * + * @return the the maximum number of player + */ + public int getMaxPlayers() { + return maxPlayers; + } + + /** + * Set the maximum number of players sent. + * + * @param maxPlayers the maximum number of player + */ + public void setMaxPlayers(int maxPlayers) { + this.maxPlayers = maxPlayers; + } +} diff --git a/src/main/java/org/bukkit/event/server/ServerListener.java b/src/main/java/org/bukkit/event/server/ServerListener.java index f4bf722a..d49b1e0a 100644 --- a/src/main/java/org/bukkit/event/server/ServerListener.java +++ b/src/main/java/org/bukkit/event/server/ServerListener.java @@ -34,4 +34,11 @@ public class ServerListener implements Listener { * @param event Relevant event details */ public void onMapInitialize(MapInitializeEvent event) {} + + /** + * Called when a server list ping has come in. + * + * @param event Relevant event details + */ + public void onServerListPing(ServerListPingEvent event) {} } diff --git a/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java b/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java index 33d8bbe6..5489b852 100644 --- a/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java +++ b/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java @@ -584,6 +584,13 @@ public class JavaPluginLoader implements PluginLoader { } }; + case SERVER_LIST_PING: + return new EventExecutor() { + public void execute(Listener listener, Event event) { + ((ServerListener) listener).onServerListPing((ServerListPingEvent) event); + } + }; + // World Events case CHUNK_LOAD: return new EventExecutor() { |