From b7abfe7c06fc9830333abc578f28052d7002f520 Mon Sep 17 00:00:00 2001 From: Mike Primm Date: Fri, 14 Jun 2013 01:49:49 -0500 Subject: [PATCH] Add settings for player-sort-permission-nodes support --- .../java/org/dynmap/bukkit/DynmapPlugin.java | 25 +++++++++++++++++++ .../bukkit/permissions/BukkitPermissions.java | 2 +- src/main/resources/configuration.txt | 5 ++++ 3 files changed, 31 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/dynmap/bukkit/DynmapPlugin.java b/src/main/java/org/dynmap/bukkit/DynmapPlugin.java index ea603f22..94d8c03b 100644 --- a/src/main/java/org/dynmap/bukkit/DynmapPlugin.java +++ b/src/main/java/org/dynmap/bukkit/DynmapPlugin.java @@ -111,6 +111,8 @@ public class DynmapPlugin extends JavaPlugin implements DynmapAPI { private Method ismodloaded; private HashMap world_by_name = new HashMap(); private HashSet modsused = new HashSet(); + + private HashMap sortWeights = new HashMap(); /* Lookup cache */ private World last_world; private BukkitWorld last_bworld; @@ -629,6 +631,22 @@ public class DynmapPlugin extends JavaPlugin implements DynmapAPI { } return false; } + @Override + public int getSortWeight() { + Integer wt = sortWeights.get(getName()); + if (wt != null) + return wt; + return 0; + } + @Override + public void setSortWeight(int wt) { + if (wt == 0) { + sortWeights.remove(getName()); + } + else { + sortWeights.put(getName(), wt); + } + } } /* Handler for generic console command sender */ public class BukkitCommandSender implements DynmapCommandSender { @@ -664,6 +682,13 @@ public class DynmapPlugin extends JavaPlugin implements DynmapAPI { else return false; } + @Override + public boolean hasPermissionNode(String node) { + if (sender != null) { + return sender.hasPermission(node); + } + return false; + } } public void loadExtraBiomes() { diff --git a/src/main/java/org/dynmap/bukkit/permissions/BukkitPermissions.java b/src/main/java/org/dynmap/bukkit/permissions/BukkitPermissions.java index 3fe69f60..5163c6b0 100644 --- a/src/main/java/org/dynmap/bukkit/permissions/BukkitPermissions.java +++ b/src/main/java/org/dynmap/bukkit/permissions/BukkitPermissions.java @@ -39,7 +39,7 @@ public class BukkitPermissions implements PermissionProvider { } @Override public Set hasOfflinePermissions(String player, Set perms) { - Player p = Bukkit.getPlayerExact(name); + Player p = Bukkit.getPlayerExact(player); HashSet hasperms = null; if (p != null) { hasperms = new HashSet(); diff --git a/src/main/resources/configuration.txt b/src/main/resources/configuration.txt index 186cf49c..1094b6ba 100644 --- a/src/main/resources/configuration.txt +++ b/src/main/resources/configuration.txt @@ -319,6 +319,11 @@ showplayerfacesinmenu: true # Control whether players that are hidden or not on current map are grayed out (true=yes) grayplayerswhenhidden: true +# Use player permissions to order player list: first to last, players are ordered by first permission listed that they have +# That is, anyone with first listed permission goes before anyone with second, etc, with users with none of the nodes going last +player-sort-permission-nodes: + - bukkit.command.op + # Set sidebaropened: 'true' to pin menu sidebar opened permanently, 'pinned' to default the sidebar to pinned, but allow it to unpin #sidebaropened: true