From c43bfbe53735d35a3be6513ff1825184e5f8a5c8 Mon Sep 17 00:00:00 2001 From: Olof Larsson Date: Mon, 22 Apr 2013 10:37:04 +0200 Subject: [PATCH] Moving stuff around in ConfServer and adding properm methods to the enums for DefaultDefaults. --- src/com/massivecraft/factions/ConfServer.java | 109 ++++++++---------- src/com/massivecraft/factions/FFlag.java | 45 +++++--- src/com/massivecraft/factions/FPerm.java | 25 +++- 3 files changed, 97 insertions(+), 82 deletions(-) diff --git a/src/com/massivecraft/factions/ConfServer.java b/src/com/massivecraft/factions/ConfServer.java index 1cfd2d6f..48a1441f 100644 --- a/src/com/massivecraft/factions/ConfServer.java +++ b/src/com/massivecraft/factions/ConfServer.java @@ -26,36 +26,26 @@ public class ConfServer extends SimpleConfig // DOUBTFULLY CONFIGURABLE DEFAULTS (TODO) // -------------------------------------------- // - public static Map factionFlagDefaults; - //public static Map factionFlagIsChangeable; - public static Map> factionPermDefaults; + public static Map factionFlagDefaults = FFlag.getDefaultDefaults(); + public static Map> factionPermDefaults = FPerm.getDefaultDefaults(); // TODO: Shouldn't this be a constant rather? public static Rel factionRankDefault = Rel.RECRUIT; // -------------------------------------------- // - // POWER + // DERPY OVERRIDES // -------------------------------------------- // - public static double powerMax = 10.0; - public static double powerMin = -10.0; - public static double powerStarting = 10.0; // New players start out with this power level + // mainly for other plugins/mods that use a fake player to take actions, which shouldn't be subject to our protections + public static Set playersWhoBypassAllProtection = new LinkedHashSet(); + + public static Set worldsNoClaiming = new LinkedHashSet(); - public static double powerPerDeath = -4.0; // A death makes you lose 4 power - - public static double powerPerHourOnline = 10.0; - public static double powerPerHourOffline = 0.0; - - // players will no longer lose power from being offline once their power drops to this amount or less - public static double powerLimitGainOnline = 10.0; - public static double powerLimitGainOffline = 0.0; - public static double powerLimitLossOnline = -10.0; - public static double powerLimitLossOffline = 0.0; - - public static boolean scaleNegativePower = false; // Power regeneration rate increase as power decreases - public static double scaleNegativeDivisor = 40.0; // Divisor for inverse power regeneration curve - - public static double powerFactionMax = 0.0; // if greater than 0, the cap on how much power a faction can have (additional power from players beyond that will act as a "buffer" of sorts) + // TODO: Should worldsNoPowerLoss rather be a bukkit permission node? + public static Set worldsNoPowerLoss = new LinkedHashSet(); + public static Set worldsIgnorePvP = new LinkedHashSet(); + // TODO: A better solution Would be to have One wilderness faction per world. + //public static Set worldsNoWildernessProtection = new LinkedHashSet(); // -------------------------------------------- // // CORE @@ -83,19 +73,30 @@ public class ConfServer extends SimpleConfig public static double autoLeaveAfterDaysOfInactivity = 10.0; public static double autoLeaveRoutineRunsEveryXMinutes = 5.0; public static boolean removePlayerDataWhenBanned = true; - + // -------------------------------------------- // - // INTEGRATION: WORLD GUARD + // POWER // -------------------------------------------- // - public static boolean worldGuardChecking = false; - - // -------------------------------------------- // - // INTEGRATION: LWC - // -------------------------------------------- // + public static double powerMax = 10.0; + public static double powerMin = -10.0; + public static double powerStarting = 10.0; // New players start out with this power level - public static boolean onUnclaimResetLwcLocks = false; - public static boolean onCaptureResetLwcLocks = false; + public static double powerPerDeath = -4.0; // A death makes you lose 4 power + + public static double powerPerHourOnline = 10.0; + public static double powerPerHourOffline = 0.0; + + // players will no longer lose power from being offline once their power drops to this amount or less + public static double powerLimitGainOnline = 10.0; + public static double powerLimitGainOffline = 0.0; + public static double powerLimitLossOnline = -10.0; + public static double powerLimitLossOffline = 0.0; + + public static boolean scaleNegativePower = false; // Power regeneration rate increase as power decreases + public static double scaleNegativeDivisor = 40.0; // Divisor for inverse power regeneration curve + + public static double powerFactionMax = 0.0; // if greater than 0, the cap on how much power a faction can have (additional power from players beyond that will act as a "buffer" of sorts) // -------------------------------------------- // // HOMES @@ -142,6 +143,19 @@ public class ConfServer extends SimpleConfig public static boolean pistonProtectionThroughDenyBuild = true; + // -------------------------------------------- // + // INTEGRATION: WORLD GUARD + // -------------------------------------------- // + + public static boolean worldGuardChecking = false; + + // -------------------------------------------- // + // INTEGRATION: LWC + // -------------------------------------------- // + + public static boolean onUnclaimResetLwcLocks = false; + public static boolean onCaptureResetLwcLocks = false; + // -------------------------------------------- // // INTEGRATION: SPOUT // -------------------------------------------- // @@ -216,39 +230,6 @@ public class ConfServer extends SimpleConfig //public static boolean bankMembersCanWithdraw = false; //Have to be at least moderator to withdraw or pay money to another faction public static boolean bankFactionPaysCosts = true; //The faction pays for faction command costs, such as sethome public static boolean bankFactionPaysLandCosts = true; //The faction pays for land claiming costs. - - // -------------------------------------------- // - // DERPY OVERRIDES - // -------------------------------------------- // - // mainly for other plugins/mods that use a fake player to take actions, which shouldn't be subject to our protections - public static Set playersWhoBypassAllProtection = new LinkedHashSet(); - - public static Set worldsNoClaiming = new LinkedHashSet(); - - // TODO: Should worldsNoPowerLoss rather be a bukkit permission node? - public static Set worldsNoPowerLoss = new LinkedHashSet(); - public static Set worldsIgnorePvP = new LinkedHashSet(); - // TODO: A better solution Would be to have One wilderness faction per world. - //public static Set worldsNoWildernessProtection = new LinkedHashSet(); - - // -------------------------------------------- // - // STATIC CONSTRUCTOR TO GET RID OF (TODO) - // -------------------------------------------- // - - static - { - factionFlagDefaults = new LinkedHashMap(); - for (FFlag flag : FFlag.values()) - { - factionFlagDefaults.put(flag, flag.defaultDefaultValue); - } - - factionPermDefaults = new LinkedHashMap>(); - for (FPerm perm: FPerm.values()) - { - factionPermDefaults.put(perm, perm.defaultDefaultValue); - } - } } diff --git a/src/com/massivecraft/factions/FFlag.java b/src/com/massivecraft/factions/FFlag.java index 9c73a340..0d1c0241 100644 --- a/src/com/massivecraft/factions/FFlag.java +++ b/src/com/massivecraft/factions/FFlag.java @@ -1,5 +1,8 @@ package com.massivecraft.factions; +import java.util.LinkedHashMap; +import java.util.Map; + /** * Flags that describe the nature of a faction and it's territory. @@ -43,34 +46,45 @@ public enum FFlag private final String desc; public String getDescription() { return this.desc; } - public final boolean defaultDefaultValue; + public final boolean defaultDefault; + public boolean getDefaultDefault() { return this.defaultDefault; } // -------------------------------------------- // // CONSTRUCT // -------------------------------------------- // - private FFlag(final String nicename, final String desc, final boolean defaultDefaultValue) + private FFlag(String nicename, final String desc, boolean defaultDefault) { this.nicename = nicename; this.desc = desc; - this.defaultDefaultValue = defaultDefaultValue; + this.defaultDefault = defaultDefault; + } + + // -------------------------------------------- // + // DEFAULTS + // -------------------------------------------- // + + public boolean getDefault() + { + Boolean ret = ConfServer.factionFlagDefaults.get(this); + if (ret == null) return this.getDefaultDefault(); + return ret; + } + + public static Map getDefaultDefaults() + { + Map ret = new LinkedHashMap(); + for (FFlag flag : values()) + { + ret.put(flag, flag.getDefaultDefault()); + } + return ret; } // -------------------------------------------- // // FRODOODODFOFL // -------------------------------------------- // - - /** - * The state for newly created factions. - */ - public boolean getDefault() - { - Boolean ret = ConfServer.factionFlagDefaults.get(this); - if (ret == null) return this.defaultDefaultValue; - return ret; - } - public static FFlag parse(String str) { str = str.toLowerCase(); @@ -96,4 +110,7 @@ public enum FFlag } return ret; } + + + } diff --git a/src/com/massivecraft/factions/FPerm.java b/src/com/massivecraft/factions/FPerm.java index 820a8f3f..8abf2ca7 100644 --- a/src/com/massivecraft/factions/FPerm.java +++ b/src/com/massivecraft/factions/FPerm.java @@ -3,7 +3,9 @@ package com.massivecraft.factions; import java.util.Arrays; import java.util.Collections; import java.util.EnumSet; +import java.util.LinkedHashMap; import java.util.LinkedHashSet; +import java.util.Map; import java.util.Set; import org.bukkit.Location; @@ -56,7 +58,8 @@ public enum FPerm private final String desc; public String getDescription() { return this.desc; } - public final Set defaultDefaultValue; + public final Set defaultDefault; + public Set getDefaultDefault() { return new LinkedHashSet(this.defaultDefault); } // -------------------------------------------- // // CONSTRUCT @@ -70,21 +73,35 @@ public enum FPerm Set defaultDefaultValue = new LinkedHashSet(); defaultDefaultValue.addAll(Arrays.asList(rels)); defaultDefaultValue = Collections.unmodifiableSet(defaultDefaultValue); - this.defaultDefaultValue = defaultDefaultValue; + this.defaultDefault = defaultDefaultValue; } // -------------------------------------------- // - // FROOODLDLLD + // DEFAULTS // -------------------------------------------- // public Set getDefault() { Set ret = ConfServer.factionPermDefaults.get(this); - if (ret == null) ret = this.defaultDefaultValue; + if (ret == null) return this.getDefaultDefault(); ret = new LinkedHashSet(ret); return ret; } + public static Map> getDefaultDefaults() + { + Map> ret = new LinkedHashMap>(); + for (FPerm fperm : values()) + { + ret.put(fperm, fperm.getDefaultDefault()); + } + return ret; + } + + // -------------------------------------------- // + // FROOODLDLLD + // -------------------------------------------- // + public static FPerm parse(String str) { str = str.toLowerCase();