From 0d64b59851da5e025886b44a169f83018d463404 Mon Sep 17 00:00:00 2001 From: Rigby Date: Mon, 14 Mar 2011 01:57:10 +0000 Subject: [PATCH] Start of the MV Permissions Handler... centralise all Permission checks and fall back to isOP(). --- .../MultiVerseCore/MVPermissions.java | 21 ++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/src/com/onarandombox/MultiVerseCore/MVPermissions.java b/src/com/onarandombox/MultiVerseCore/MVPermissions.java index 6de3a006..00acdb4c 100644 --- a/src/com/onarandombox/MultiVerseCore/MVPermissions.java +++ b/src/com/onarandombox/MultiVerseCore/MVPermissions.java @@ -9,6 +9,10 @@ public class MVPermissions { private MultiVerseCore plugin; + /** + * Constructor FTW + * @param plugin Pass along the Core Plugin. + */ public MVPermissions(MultiVerseCore plugin){ this.plugin = plugin; } @@ -26,14 +30,16 @@ public class MVPermissions { boolean returnValue = true; - if (blackList.size() == 0) + if (blackList.size() == 0) { returnValue = true; + } - for (int i = 0; i < blackList.size(); i++) + for (int i = 0; i < blackList.size(); i++) { if (blackList.get(i).equalsIgnoreCase(p.getWorld().getName())) { returnValue = false; break; } + } return returnValue; } @@ -45,14 +51,22 @@ public class MVPermissions { * @return */ public Boolean canEnterWorld(Player p, World w) { + // First check if we've got the Permissions plugin, we can't perform the group checks without it. + if(MultiVerseCore.Permissions==null) { + return true; // If we don't have it we must return true otherwise we are forcing people to use the Permissions plugin. + } + List whiteList = this.plugin.worlds.get(w.getName()).joinWhitelist; List blackList = this.plugin.worlds.get(w.getName()).joinBlacklist; + @SuppressWarnings("deprecation") String group = MultiVerseCore.Permissions.getGroup(p.getName()); boolean returnValue = true; - if (whiteList.size() > 0) + // TODO: Not sure if I want this. + if (whiteList.size() > 0) { returnValue = false; + } for (int i = 0; i < whiteList.size(); i++){ if (whiteList.get(i).contains("g:") && group.equalsIgnoreCase(whiteList.get(i).split(":")[1])) { @@ -81,6 +95,7 @@ public class MVPermissions { break; } } + return returnValue; } }