Moving stuff around in ConfServer and adding properm methods to the enums for DefaultDefaults.

This commit is contained in:
Olof Larsson 2013-04-22 10:37:04 +02:00
parent e901cae995
commit c43bfbe537
3 changed files with 97 additions and 82 deletions

View File

@ -26,36 +26,26 @@ public class ConfServer extends SimpleConfig
// DOUBTFULLY CONFIGURABLE DEFAULTS (TODO) // DOUBTFULLY CONFIGURABLE DEFAULTS (TODO)
// -------------------------------------------- // // -------------------------------------------- //
public static Map<FFlag, Boolean> factionFlagDefaults; public static Map<FFlag, Boolean> factionFlagDefaults = FFlag.getDefaultDefaults();
//public static Map<FFlag, Boolean> factionFlagIsChangeable; public static Map<FPerm, Set<Rel>> factionPermDefaults = FPerm.getDefaultDefaults();
public static Map<FPerm, Set<Rel>> factionPermDefaults;
// TODO: Shouldn't this be a constant rather? // TODO: Shouldn't this be a constant rather?
public static Rel factionRankDefault = Rel.RECRUIT; public static Rel factionRankDefault = Rel.RECRUIT;
// -------------------------------------------- // // -------------------------------------------- //
// POWER // DERPY OVERRIDES
// -------------------------------------------- // // -------------------------------------------- //
public static double powerMax = 10.0; // mainly for other plugins/mods that use a fake player to take actions, which shouldn't be subject to our protections
public static double powerMin = -10.0; public static Set<String> playersWhoBypassAllProtection = new LinkedHashSet<String>();
public static double powerStarting = 10.0; // New players start out with this power level
public static double powerPerDeath = -4.0; // A death makes you lose 4 power public static Set<String> worldsNoClaiming = new LinkedHashSet<String>();
public static double powerPerHourOnline = 10.0; // TODO: Should worldsNoPowerLoss rather be a bukkit permission node?
public static double powerPerHourOffline = 0.0; public static Set<String> worldsNoPowerLoss = new LinkedHashSet<String>();
public static Set<String> worldsIgnorePvP = new LinkedHashSet<String>();
// players will no longer lose power from being offline once their power drops to this amount or less // TODO: A better solution Would be to have One wilderness faction per world.
public static double powerLimitGainOnline = 10.0; //public static Set<String> worldsNoWildernessProtection = new LinkedHashSet<String>();
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)
// -------------------------------------------- // // -------------------------------------------- //
// CORE // CORE
@ -85,17 +75,28 @@ public class ConfServer extends SimpleConfig
public static boolean removePlayerDataWhenBanned = true; public static boolean removePlayerDataWhenBanned = true;
// -------------------------------------------- // // -------------------------------------------- //
// INTEGRATION: WORLD GUARD // POWER
// -------------------------------------------- // // -------------------------------------------- //
public static boolean worldGuardChecking = false; 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 double powerPerDeath = -4.0; // A death makes you lose 4 power
// INTEGRATION: LWC
// -------------------------------------------- //
public static boolean onUnclaimResetLwcLocks = false; public static double powerPerHourOnline = 10.0;
public static boolean onCaptureResetLwcLocks = false; 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 // HOMES
@ -142,6 +143,19 @@ public class ConfServer extends SimpleConfig
public static boolean pistonProtectionThroughDenyBuild = true; 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 // INTEGRATION: SPOUT
// -------------------------------------------- // // -------------------------------------------- //
@ -217,38 +231,5 @@ public class ConfServer extends SimpleConfig
public static boolean bankFactionPaysCosts = true; //The faction pays for faction command costs, such as sethome 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. 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<String> playersWhoBypassAllProtection = new LinkedHashSet<String>();
public static Set<String> worldsNoClaiming = new LinkedHashSet<String>();
// TODO: Should worldsNoPowerLoss rather be a bukkit permission node?
public static Set<String> worldsNoPowerLoss = new LinkedHashSet<String>();
public static Set<String> worldsIgnorePvP = new LinkedHashSet<String>();
// TODO: A better solution Would be to have One wilderness faction per world.
//public static Set<String> worldsNoWildernessProtection = new LinkedHashSet<String>();
// -------------------------------------------- //
// STATIC CONSTRUCTOR TO GET RID OF (TODO)
// -------------------------------------------- //
static
{
factionFlagDefaults = new LinkedHashMap<FFlag, Boolean>();
for (FFlag flag : FFlag.values())
{
factionFlagDefaults.put(flag, flag.defaultDefaultValue);
}
factionPermDefaults = new LinkedHashMap<FPerm, Set<Rel>>();
for (FPerm perm: FPerm.values())
{
factionPermDefaults.put(perm, perm.defaultDefaultValue);
}
}
} }

View File

@ -1,5 +1,8 @@
package com.massivecraft.factions; package com.massivecraft.factions;
import java.util.LinkedHashMap;
import java.util.Map;
/** /**
* Flags that describe the nature of a faction and it's territory. * Flags that describe the nature of a faction and it's territory.
@ -43,34 +46,45 @@ public enum FFlag
private final String desc; private final String desc;
public String getDescription() { return this.desc; } public String getDescription() { return this.desc; }
public final boolean defaultDefaultValue; public final boolean defaultDefault;
public boolean getDefaultDefault() { return this.defaultDefault; }
// -------------------------------------------- // // -------------------------------------------- //
// CONSTRUCT // 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.nicename = nicename;
this.desc = desc; 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<FFlag, Boolean> getDefaultDefaults()
{
Map<FFlag, Boolean> ret = new LinkedHashMap<FFlag, Boolean>();
for (FFlag flag : values())
{
ret.put(flag, flag.getDefaultDefault());
}
return ret;
} }
// -------------------------------------------- // // -------------------------------------------- //
// FRODOODODFOFL // 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) public static FFlag parse(String str)
{ {
str = str.toLowerCase(); str = str.toLowerCase();
@ -96,4 +110,7 @@ public enum FFlag
} }
return ret; return ret;
} }
} }

View File

@ -3,7 +3,9 @@ package com.massivecraft.factions;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
import java.util.EnumSet; import java.util.EnumSet;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet; import java.util.LinkedHashSet;
import java.util.Map;
import java.util.Set; import java.util.Set;
import org.bukkit.Location; import org.bukkit.Location;
@ -56,7 +58,8 @@ public enum FPerm
private final String desc; private final String desc;
public String getDescription() { return this.desc; } public String getDescription() { return this.desc; }
public final Set<Rel> defaultDefaultValue; public final Set<Rel> defaultDefault;
public Set<Rel> getDefaultDefault() { return new LinkedHashSet<Rel>(this.defaultDefault); }
// -------------------------------------------- // // -------------------------------------------- //
// CONSTRUCT // CONSTRUCT
@ -70,21 +73,35 @@ public enum FPerm
Set<Rel> defaultDefaultValue = new LinkedHashSet<Rel>(); Set<Rel> defaultDefaultValue = new LinkedHashSet<Rel>();
defaultDefaultValue.addAll(Arrays.asList(rels)); defaultDefaultValue.addAll(Arrays.asList(rels));
defaultDefaultValue = Collections.unmodifiableSet(defaultDefaultValue); defaultDefaultValue = Collections.unmodifiableSet(defaultDefaultValue);
this.defaultDefaultValue = defaultDefaultValue; this.defaultDefault = defaultDefaultValue;
} }
// -------------------------------------------- // // -------------------------------------------- //
// FROOODLDLLD // DEFAULTS
// -------------------------------------------- // // -------------------------------------------- //
public Set<Rel> getDefault() public Set<Rel> getDefault()
{ {
Set<Rel> ret = ConfServer.factionPermDefaults.get(this); Set<Rel> ret = ConfServer.factionPermDefaults.get(this);
if (ret == null) ret = this.defaultDefaultValue; if (ret == null) return this.getDefaultDefault();
ret = new LinkedHashSet<Rel>(ret); ret = new LinkedHashSet<Rel>(ret);
return ret; return ret;
} }
public static Map<FPerm, Set<Rel>> getDefaultDefaults()
{
Map<FPerm, Set<Rel>> ret = new LinkedHashMap<FPerm, Set<Rel>>();
for (FPerm fperm : values())
{
ret.put(fperm, fperm.getDefaultDefault());
}
return ret;
}
// -------------------------------------------- //
// FROOODLDLLD
// -------------------------------------------- //
public static FPerm parse(String str) public static FPerm parse(String str)
{ {
str = str.toLowerCase(); str = str.toLowerCase();