diff --git a/src/main/java/com/massivecraft/factions/WorldExceptionSet.java b/src/main/java/com/massivecraft/factions/WorldExceptionSet.java new file mode 100644 index 00000000..21603813 --- /dev/null +++ b/src/main/java/com/massivecraft/factions/WorldExceptionSet.java @@ -0,0 +1,33 @@ +package com.massivecraft.factions; + +import java.util.LinkedHashSet; +import java.util.Set; + +import org.bukkit.World; + +public class WorldExceptionSet +{ + // -------------------------------------------- // + // FIELDS + // -------------------------------------------- // + + public boolean standard = true; + + public Set exceptions = new LinkedHashSet(); + + // -------------------------------------------- // + // CONTAINS + // -------------------------------------------- // + + public boolean contains(String world) + { + if (this.exceptions.contains(world)) return !this.standard; + return this.standard; + } + + public boolean contains(World world) + { + return this.contains(world.getName()); + } + +} diff --git a/src/main/java/com/massivecraft/factions/entity/MConf.java b/src/main/java/com/massivecraft/factions/entity/MConf.java index a0735457..07f7accf 100644 --- a/src/main/java/com/massivecraft/factions/entity/MConf.java +++ b/src/main/java/com/massivecraft/factions/entity/MConf.java @@ -6,7 +6,6 @@ import java.util.LinkedHashSet; import java.util.List; import java.util.Map; import java.util.Set; -import java.util.TreeSet; import java.util.UUID; import org.bukkit.ChatColor; @@ -18,6 +17,7 @@ import com.massivecraft.factions.FFlag; import com.massivecraft.factions.FPerm; import com.massivecraft.factions.Factions; import com.massivecraft.factions.Rel; +import com.massivecraft.factions.WorldExceptionSet; import com.massivecraft.factions.event.EventFactionsChunkChangeType; import com.massivecraft.factions.integration.dynmap.DynmapStyle; import com.massivecraft.factions.listeners.FactionsListenerChat; @@ -55,6 +55,21 @@ public class MConf extends Entity public List aliasesF = MUtil.list("f"); + // -------------------------------------------- // + // WORLDS FEATURE ENABLED + // -------------------------------------------- // + + public WorldExceptionSet worldsClaimingEnabled = new WorldExceptionSet(); + public WorldExceptionSet worldsPowerLossEnabled = new WorldExceptionSet(); + public WorldExceptionSet worldsPvpRulesEnabled = new WorldExceptionSet(); + + // -------------------------------------------- // + // DERPY OVERRIDES + // -------------------------------------------- // + + // mainly for other plugins/mods that use a fake player to take actions, which shouldn't be subject to our protections + public Set playersWhoBypassAllProtection = new LinkedHashSet(); + // -------------------------------------------- // // TASKS // -------------------------------------------- // @@ -268,41 +283,6 @@ public class MConf extends Entity public String prefixMember = "+"; public String prefixRecruit = "-"; - // -------------------------------------------- // - // DERPY OVERRIDES - // -------------------------------------------- // - // TODO: Should worldsNoPowerLoss rather be a bukkit permission node? - // TODO: These are derpy because they possibly use an invalid design approach. - // After universe support is added. Would some of these be removed? - // Could it also be more customizeable using some sort of permission lookup map? - - // mainly for other plugins/mods that use a fake player to take actions, which shouldn't be subject to our protections - public Set playersWhoBypassAllProtection = new LinkedHashSet(); - - public Set worldsNoClaiming = new LinkedHashSet(); - public Set getWorldsNoClaiming() - { - Set ret = new TreeSet(String.CASE_INSENSITIVE_ORDER); - ret.addAll(this.worldsNoClaiming); - return ret; - } - - public Set worldsNoPowerLoss = new LinkedHashSet(); - public Set getWorldsNoPowerLoss() - { - Set ret = new TreeSet(String.CASE_INSENSITIVE_ORDER); - ret.addAll(this.worldsNoPowerLoss); - return ret; - } - - public Set worldsIgnorePvP = new LinkedHashSet(); - public Set getWorldsIgnlorePvP() - { - Set ret = new TreeSet(String.CASE_INSENSITIVE_ORDER); - ret.addAll(this.worldsIgnorePvP); - return ret; - } - // -------------------------------------------- // // EXPLOITS // -------------------------------------------- // diff --git a/src/main/java/com/massivecraft/factions/entity/MPlayer.java b/src/main/java/com/massivecraft/factions/entity/MPlayer.java index 0b652e21..cfbabb08 100644 --- a/src/main/java/com/massivecraft/factions/entity/MPlayer.java +++ b/src/main/java/com/massivecraft/factions/entity/MPlayer.java @@ -702,11 +702,11 @@ public class MPlayer extends SenderEntity implements EconomyParticipato return true; } - if (!this.isUsingAdminMode()) + if ( ! this.isUsingAdminMode()) { if (newFaction.isNormal()) { - if (mconf.getWorldsNoClaiming().contains(ps.getWorld())) + if (!mconf.worldsClaimingEnabled.contains(ps.getWorld())) { msg("Sorry, this world has land claiming disabled."); return false; diff --git a/src/main/java/com/massivecraft/factions/listeners/FactionsListenerMain.java b/src/main/java/com/massivecraft/factions/listeners/FactionsListenerMain.java index 62adf642..5666749d 100644 --- a/src/main/java/com/massivecraft/factions/listeners/FactionsListenerMain.java +++ b/src/main/java/com/massivecraft/factions/listeners/FactionsListenerMain.java @@ -201,7 +201,7 @@ public class FactionsListenerMain implements Listener return; } - if (MConf.get().getWorldsNoPowerLoss().contains(player.getWorld().getName())) + if (!MConf.get().worldsPowerLossEnabled.contains(player.getWorld())) { mplayer.msg("You didn't lose any power due to the world you died in."); return; @@ -342,7 +342,7 @@ public class FactionsListenerMain implements Listener } // ... are PVP rules completely ignored in this world? ... - if (MConf.get().getWorldsIgnlorePvP().contains(defenderPs.getWorld())) return true; + if (!MConf.get().worldsPvpRulesEnabled.contains(defenderPs.getWorld())) return true; Faction defendFaction = udefender.getFaction(); Faction attackFaction = uattacker.getFaction();