From 154722eaccedc37a47d10d2f0d9cf6e5d7b090ce Mon Sep 17 00:00:00 2001 From: md_5 Date: Sun, 10 Feb 2013 17:41:34 +1100 Subject: [PATCH] Add perm debug command --- .../main/java/net/md_5/bungee/BungeeCord.java | 1 + .../net/md_5/bungee/command/CommandPerms.java | 36 +++++++++++++++++++ 2 files changed, 37 insertions(+) create mode 100644 proxy/src/main/java/net/md_5/bungee/command/CommandPerms.java diff --git a/proxy/src/main/java/net/md_5/bungee/BungeeCord.java b/proxy/src/main/java/net/md_5/bungee/BungeeCord.java index 57fc80a7..9a89831c 100644 --- a/proxy/src/main/java/net/md_5/bungee/BungeeCord.java +++ b/proxy/src/main/java/net/md_5/bungee/BungeeCord.java @@ -105,6 +105,7 @@ public class BungeeCord extends ProxyServer getPluginManager().registerCommand( new CommandIP() ); getPluginManager().registerCommand( new CommandAlert() ); getPluginManager().registerCommand( new CommandBungee() ); + getPluginManager().registerCommand( new CommandPerms() ); registerChannel( "BungeeCord" ); } diff --git a/proxy/src/main/java/net/md_5/bungee/command/CommandPerms.java b/proxy/src/main/java/net/md_5/bungee/command/CommandPerms.java new file mode 100644 index 00000000..79d74d14 --- /dev/null +++ b/proxy/src/main/java/net/md_5/bungee/command/CommandPerms.java @@ -0,0 +1,36 @@ +package net.md_5.bungee.command; + +import java.util.HashSet; +import java.util.Set; +import net.md_5.bungee.api.ChatColor; +import net.md_5.bungee.api.CommandSender; +import net.md_5.bungee.api.ProxyServer; +import net.md_5.bungee.api.plugin.Command; + +public class CommandPerms extends Command +{ + + public CommandPerms() + { + super( "perms" ); + } + + @Override + public void execute(CommandSender sender, String[] args) + { + StringBuilder groups = new StringBuilder(); + Set permissions = new HashSet<>(); + for ( String group : sender.getGroups() ) + { + groups.append( group ); + groups.append( ", " ); + permissions.addAll( ProxyServer.getInstance().getConfigurationAdapter().getPermissions( group ) ); + } + sender.sendMessage( ChatColor.GOLD + "You have the following groups: " + groups.substring( 0, groups.length() - 2 ) ); + + for ( String permission : permissions ) + { + sender.sendMessage( ChatColor.BLUE + "- " + permission ); + } + } +}