diff --git a/blacklist.txt b/blacklist.txt index 90821561..79c7c719 100644 --- a/blacklist.txt +++ b/blacklist.txt @@ -37,7 +37,8 @@ # - on-acquire (an item enters a player's inventory via some method) # # Actions (for events): -# - deny (deny completely) +# - deny (deny completely, used blacklist mode) +# - allow (used in whitelist mode) # - notify (notify admins) # - log (log to console/file/database) # - tell (tell a player that that's not allowed) diff --git a/config.yml b/config.yml index 1e2a4c31..20aad817 100644 --- a/config.yml +++ b/config.yml @@ -91,6 +91,7 @@ iconomy: buy-on-claim-price: 2 blacklist: + use-as-whitelist: off logging: console: enable: on diff --git a/src/com/sk89q/worldguard/blacklist/Blacklist.java b/src/com/sk89q/worldguard/blacklist/Blacklist.java index 5134fdcf..ee6ae66c 100644 --- a/src/com/sk89q/worldguard/blacklist/Blacklist.java +++ b/src/com/sk89q/worldguard/blacklist/Blacklist.java @@ -60,6 +60,14 @@ public abstract class Blacklist { Map lastAffected = new HashMap(); + + private boolean useAsWhitelist; + + public Blacklist(Boolean useAsWhitelist) + { + this.useAsWhitelist = useAsWhitelist; + } + /** * Returns whether the list is empty. * @@ -100,7 +108,7 @@ public boolean check(BlacklistEvent event, boolean forceRepeat, boolean silent) } boolean ret = true; for (BlacklistEntry entry : entries) { - if (!entry.check(event, forceRepeat, silent)) { + if (!entry.check(useAsWhitelist, event, forceRepeat, silent)) { ret = false; } } diff --git a/src/com/sk89q/worldguard/blacklist/BlacklistEntry.java b/src/com/sk89q/worldguard/blacklist/BlacklistEntry.java index 48199365..5dd56151 100644 --- a/src/com/sk89q/worldguard/blacklist/BlacklistEntry.java +++ b/src/com/sk89q/worldguard/blacklist/BlacklistEntry.java @@ -271,7 +271,7 @@ private String[] getActions(BlacklistEvent event) { * @param silent * @return */ - public boolean check(BlacklistEvent event, boolean forceRepeat, boolean silent) { + public boolean check(Boolean useAsWhitelist, BlacklistEvent event, boolean forceRepeat, boolean silent) { LocalPlayer player = event.getPlayer(); if (shouldIgnore(player)) { @@ -293,11 +293,13 @@ public boolean check(BlacklistEvent event, boolean forceRepeat, boolean silent) } String actions[] = getActions(event); - boolean ret = true; + + + boolean ret = useAsWhitelist ? false : true; // Nothing to do if (actions == null) { - return true; + return useAsWhitelist ? false : true; } for (String action : actions) { @@ -309,6 +311,14 @@ public boolean check(BlacklistEvent event, boolean forceRepeat, boolean silent) ret = false; + // Allow + } else if (action.equalsIgnoreCase("allow")) { + if (silent) { + return true; + } + + ret = true; + // Kick } else if (action.equalsIgnoreCase("kick")) { if (silent) { diff --git a/src/com/sk89q/worldguard/bukkit/BukkitBlacklist.java b/src/com/sk89q/worldguard/bukkit/BukkitBlacklist.java index 14b419b4..4d92aeed 100644 --- a/src/com/sk89q/worldguard/bukkit/BukkitBlacklist.java +++ b/src/com/sk89q/worldguard/bukkit/BukkitBlacklist.java @@ -25,7 +25,8 @@ public class BukkitBlacklist extends Blacklist { private WorldGuardPlugin plugin; - public BukkitBlacklist(WorldGuardPlugin plugin) { + public BukkitBlacklist(Boolean useAsWhitelist, WorldGuardPlugin plugin) { + super(useAsWhitelist); this.plugin = plugin; } diff --git a/src/com/sk89q/worldguard/bukkit/WorldGuardWorldConfiguration.java b/src/com/sk89q/worldguard/bukkit/WorldGuardWorldConfiguration.java index 586443d6..42d87839 100644 --- a/src/com/sk89q/worldguard/bukkit/WorldGuardWorldConfiguration.java +++ b/src/com/sk89q/worldguard/bukkit/WorldGuardWorldConfiguration.java @@ -227,6 +227,9 @@ private void loadConfiguration() { wp.getGlobalRegionManager().setGlobalFlags(worldName, globalFlags); + + boolean useBlacklistAsWhitelist = config.getBoolean("blacklist.use-as-whitelist", false); + // Console log configuration boolean logConsole = config.getBoolean("blacklist.logging.console.enable", true); @@ -250,7 +253,7 @@ private void loadConfiguration() { } // First load the blacklist data from worldguard-blacklist.txt - Blacklist blist = new BukkitBlacklist(wp); + Blacklist blist = new BukkitBlacklist(useBlacklistAsWhitelist, wp); blist.load(blacklistFile); // If the blacklist is empty, then set the field to null