From ded4d52151d6a3c3e79a141d29127bce9483d77c Mon Sep 17 00:00:00 2001 From: md_5 Date: Sat, 12 Jan 2013 14:17:02 +1100 Subject: [PATCH] Add ping event, change group management and other stuff. --- .../net/md_5/bungee/api/CommandSender.java | 39 ++++++++++++++++++- .../api/config/ConfigurationAdapter.java | 23 ++++++++--- .../api/connection/ConnectedPlayer.java | 2 +- .../net/md_5/bungee/api/event/LoginEvent.java | 7 +++- .../md_5/bungee/api/event/ProxyPingEvent.java | 32 +++++++++++++++ 5 files changed, 94 insertions(+), 9 deletions(-) create mode 100644 api/src/main/java/net/md_5/bungee/api/event/ProxyPingEvent.java diff --git a/api/src/main/java/net/md_5/bungee/api/CommandSender.java b/api/src/main/java/net/md_5/bungee/api/CommandSender.java index 7ba6288a..7570f457 100644 --- a/api/src/main/java/net/md_5/bungee/api/CommandSender.java +++ b/api/src/main/java/net/md_5/bungee/api/CommandSender.java @@ -5,17 +5,54 @@ import java.util.Collection; public interface CommandSender { + /** + * Get the unique name of this command sender. + * + * @return the senders username + */ public String getName(); + /** + * Send a message to this sender. + * + * @param message the message to send + */ public void sendMessage(String message); + /** + * Get all groups this user is part of. + * + * @return the users groups + */ public Collection getGroups(); + /** + * Adds groups to a this user for the current session only. + * + * @param groups the groups to add + */ public void addGroups(String... groups); + /** + * Remove groups from this user for the current session only. + * + * @param groups the groups to remove + */ public void removeGroups(String... groups); + /** + * Checks if this user has the specified permission node. + * + * @param permission the node to check + * @return whether they have this node + */ public boolean hasPermission(String permission); - public boolean setPermission(String permission, boolean value); + /** + * Set a permission node for this user. + * + * @param permission the node to set + * @param value the value of the node + */ + public void setPermission(String permission, boolean value); } diff --git a/api/src/main/java/net/md_5/bungee/api/config/ConfigurationAdapter.java b/api/src/main/java/net/md_5/bungee/api/config/ConfigurationAdapter.java index dc5f6fd8..0f3c3d14 100644 --- a/api/src/main/java/net/md_5/bungee/api/config/ConfigurationAdapter.java +++ b/api/src/main/java/net/md_5/bungee/api/config/ConfigurationAdapter.java @@ -1,5 +1,6 @@ package net.md_5.bungee.api.config; +import java.util.Collection; import java.util.List; import net.md_5.bungee.api.CommandSender; @@ -32,26 +33,36 @@ public interface ConfigurationAdapter * @param path the path to retrieve the list from. * @return the retrieved list. */ - public List getStringList(String path); + public Collection getStrings(String path); /** * Get the configuration all servers which may be accessible via the proxy. * * @return all accessible servers */ - public List getServers(); + public Collection getServers(); /** * Get information about all hosts to bind the proxy to. * * @return a list of all hosts to bind to */ - public List getListeners(); + public Collection getListeners(); /** - * Set the permissions of the specified {@link CommandSender} + * Get all groups this user is in. * - * @param sender the sender to set permissions on. + * @param user the user to check + * @return all the user's groups. */ - public void setPermissions(CommandSender sender); + public Collection getGroups(String user); + + /** + * Get all permission corresponding to the specified group. The result of + * this method may or may not be cached, depending on the implementation. + * + * @param group the group to check + * @return all true permissions for this group + */ + public Collection getPermissions(String group); } diff --git a/api/src/main/java/net/md_5/bungee/api/connection/ConnectedPlayer.java b/api/src/main/java/net/md_5/bungee/api/connection/ConnectedPlayer.java index cf09a65a..904edfb7 100644 --- a/api/src/main/java/net/md_5/bungee/api/connection/ConnectedPlayer.java +++ b/api/src/main/java/net/md_5/bungee/api/connection/ConnectedPlayer.java @@ -3,6 +3,6 @@ package net.md_5.bungee.api.connection; /** * Represents a player physically connected to the world hosted on this server. */ -public interface ConnectedPlayer extends ProxiedPlayer +public abstract class ConnectedPlayer extends ProxiedPlayer { } diff --git a/api/src/main/java/net/md_5/bungee/api/event/LoginEvent.java b/api/src/main/java/net/md_5/bungee/api/event/LoginEvent.java index 8b7db16c..2da25457 100644 --- a/api/src/main/java/net/md_5/bungee/api/event/LoginEvent.java +++ b/api/src/main/java/net/md_5/bungee/api/event/LoginEvent.java @@ -1,14 +1,19 @@ package net.md_5.bungee.api.event; import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.ToString; import net.md_5.bungee.api.connection.PendingConnection; import net.md_5.bungee.api.plugin.Cancellable; +import net.md_5.bungee.api.plugin.Event; /** * Event called to represent a player logging in. */ @Data -public class LoginEvent implements Cancellable +@ToString(callSuper = true) +@EqualsAndHashCode(callSuper = true) +public class LoginEvent extends Event implements Cancellable { /** diff --git a/api/src/main/java/net/md_5/bungee/api/event/ProxyPingEvent.java b/api/src/main/java/net/md_5/bungee/api/event/ProxyPingEvent.java new file mode 100644 index 00000000..e48e59cf --- /dev/null +++ b/api/src/main/java/net/md_5/bungee/api/event/ProxyPingEvent.java @@ -0,0 +1,32 @@ +package net.md_5.bungee.api.event; + +import java.net.InetSocketAddress; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.ToString; +import net.md_5.bungee.api.ServerPing; +import net.md_5.bungee.api.config.ListenerInfo; +import net.md_5.bungee.api.plugin.Event; + +/** + * Called when the proxy is pinged with packet 0xFE from the server list. + */ +@Data +@ToString(callSuper = true) +@EqualsAndHashCode(callSuper = true) +public class ProxyPingEvent extends Event +{ + + /** + * The address of the user pinging. + */ + private final InetSocketAddress remoteAddress; + /** + * The data corresponding to the server which received this ping. + */ + private final ListenerInfo server; + /** + * The data to respond with. + */ + private ServerPing response; +}