Added server list ping event.

By: sk89q <the.sk89q@gmail.com>
This commit is contained in:
Bukkit/Spigot 2011-09-26 15:32:01 -07:00
parent bbcdbdda16
commit d0f0db958d
4 changed files with 100 additions and 0 deletions

View File

@ -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

View File

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

View File

@ -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) {}
}

View File

@ -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() {