From 4faf507ad9dedf7a998551ad8b004e48636e2b2d Mon Sep 17 00:00:00 2001 From: Fabian Fassbender Date: Sat, 8 Feb 2014 14:17:01 +0100 Subject: [PATCH] Added getPermissions() to the CommandSender API to get a unmodifiable Collection of all Permissions. The ConsoleSender returns an empty Set where as the UserConnection gives its real Permissions. --- api/src/main/java/net/md_5/bungee/api/CommandSender.java | 6 ++++++ proxy/src/main/java/net/md_5/bungee/UserConnection.java | 6 ++++++ .../java/net/md_5/bungee/command/ConsoleCommandSender.java | 6 ++++++ 3 files changed, 18 insertions(+) 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 4a8f6bcd..f549aa9f 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 @@ -82,4 +82,10 @@ public interface CommandSender * @param value the value of the node */ public void setPermission(String permission, boolean value); + + /** + * Get all Permissions which this CommandSender has + * @return a unmodifiable Collection of Strings which represent their permissions + */ + public Collection getPermissions(); } diff --git a/proxy/src/main/java/net/md_5/bungee/UserConnection.java b/proxy/src/main/java/net/md_5/bungee/UserConnection.java index 762c91f2..109afea9 100644 --- a/proxy/src/main/java/net/md_5/bungee/UserConnection.java +++ b/proxy/src/main/java/net/md_5/bungee/UserConnection.java @@ -400,6 +400,12 @@ public final class UserConnection implements ProxiedPlayer } } + @Override + public Collection getPermissions() + { + return Collections.unmodifiableCollection(permissions); + } + @Override public String toString() { diff --git a/proxy/src/main/java/net/md_5/bungee/command/ConsoleCommandSender.java b/proxy/src/main/java/net/md_5/bungee/command/ConsoleCommandSender.java index d6e8b79f..49dde16f 100644 --- a/proxy/src/main/java/net/md_5/bungee/command/ConsoleCommandSender.java +++ b/proxy/src/main/java/net/md_5/bungee/command/ConsoleCommandSender.java @@ -82,4 +82,10 @@ public class ConsoleCommandSender implements CommandSender { throw new UnsupportedOperationException( "Console has all permissions" ); } + + @Override + public Collection getPermissions() + { + return Collections.emptySet(); + } }