From d9a23241ec1a80bcd9a939088e45dad14b1093c2 Mon Sep 17 00:00:00 2001 From: Olof Larsson Date: Wed, 24 Apr 2013 07:51:48 +0200 Subject: [PATCH] Move some more stuff from ConfServer --> UConf --- src/com/massivecraft/factions/ConfServer.java | 50 +++---------------- .../massivecraft/factions/entity/Board.java | 3 +- .../massivecraft/factions/entity/Faction.java | 3 +- .../massivecraft/factions/entity/UConf.java | 26 ++++++++-- .../massivecraft/factions/entity/UPlayer.java | 2 +- .../listeners/FactionsListenerMain.java | 25 +++++----- 6 files changed, 45 insertions(+), 64 deletions(-) diff --git a/src/com/massivecraft/factions/ConfServer.java b/src/com/massivecraft/factions/ConfServer.java index 563b211a..8dd6ca49 100644 --- a/src/com/massivecraft/factions/ConfServer.java +++ b/src/com/massivecraft/factions/ConfServer.java @@ -30,21 +30,6 @@ public class ConfServer extends SimpleConfig public static double autoLeaveRoutineRunsEveryXMinutes = 5.0; public static boolean removePlayerDataWhenBanned = true; - - - // -------------------------------------------- // - // PVP - // -------------------------------------------- // - - public static boolean disablePVPForFactionlessPlayers = false; - public static boolean enablePVPAgainstFactionlessInAttackersLand = false; - - // -------------------------------------------- // - // ASSORTED - // -------------------------------------------- // - - public static boolean permanentFactionsDisableLeaderPromotion = false; - // -------------------------------------------- // // CLAIMS // -------------------------------------------- // @@ -58,28 +43,7 @@ public class ConfServer extends SimpleConfig // if someone is doing a radius claim and the process fails to claim land this many times in a row, it will exit public static int radiusClaimFailureLimit = 9; - //public static double considerFactionsReallyOfflineAfterXMinutes = 0.0; - // -------------------------------------------- // - // ASSORTED - // -------------------------------------------- // - - public static int actionDeniedPainAmount = 2; - - // -------------------------------------------- // - // ASSORTED - // -------------------------------------------- // - - // TODO: Should this be based on a permission node lookup map? - public static double territoryShieldFactor = 0.3; - - // for claimed areas where further faction-member ownership can be defined - - // -------------------------------------------- // - // ASSORTED - // -------------------------------------------- // - - public static boolean pistonProtectionThroughDenyBuild = true; // -------------------------------------------- // // INTEGRATION: WORLD GUARD @@ -87,18 +51,19 @@ public class ConfServer extends SimpleConfig public static boolean worldGuardChecking = false; - // -------------------------------------------- // - // INTEGRATION: LWC - // -------------------------------------------- // - public static boolean onUnclaimResetLwcLocks = false; - public static boolean onCaptureResetLwcLocks = false; // -------------------------------------------- // // INTEGRATION: ECONOMY // -------------------------------------------- // + public static int econLandRewardTaskRunsEveryXMinutes = 20; + public static boolean econEnabled = false; + + // TODO: Rename to include unit. + public static double econLandReward = 0.00; + public static String econUniverseAccount = ""; public static double econCostClaimWilderness = 30.0; @@ -124,8 +89,7 @@ public class ConfServer extends SimpleConfig public static double econCostNeutral = 0.0; public static double econCostEnemy = 0.0; - public static int econLandRewardTaskRunsEveryXMinutes = 20; - public static double econLandReward = 0.00; + //Faction banks, to pay for land claiming and other costs instead of individuals paying for them public static boolean bankEnabled = true; diff --git a/src/com/massivecraft/factions/entity/Board.java b/src/com/massivecraft/factions/entity/Board.java index ea060201..870dbee3 100644 --- a/src/com/massivecraft/factions/entity/Board.java +++ b/src/com/massivecraft/factions/entity/Board.java @@ -10,7 +10,6 @@ import java.util.concurrent.ConcurrentSkipListMap; import org.bukkit.ChatColor; -import com.massivecraft.factions.ConfServer; import com.massivecraft.factions.Const; import com.massivecraft.factions.Factions; import com.massivecraft.factions.RelationParticipator; @@ -112,7 +111,7 @@ public class Board extends Entity implements BoardInterface { // TODO: Listen to an event instead! // NOTE: And this is probably the place where the event should be triggered! - if (ConfServer.onUnclaimResetLwcLocks && LWCFeatures.getEnabled()) + if (UConf.get(ps).onUnclaimResetLwcLocks && LWCFeatures.getEnabled()) { LWCFeatures.clearAllProtections(ps); } diff --git a/src/com/massivecraft/factions/entity/Faction.java b/src/com/massivecraft/factions/entity/Faction.java index 1fe35b12..4a1779c9 100644 --- a/src/com/massivecraft/factions/entity/Faction.java +++ b/src/com/massivecraft/factions/entity/Faction.java @@ -8,7 +8,6 @@ import org.bukkit.ChatColor; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; -import com.massivecraft.factions.ConfServer; import com.massivecraft.factions.Const; import com.massivecraft.factions.EconomyParticipator; import com.massivecraft.factions.FFlag; @@ -791,7 +790,7 @@ public class Faction extends Entity implements EconomyParticipator public void promoteNewLeader() { if ( ! this.isNormal()) return; - if (this.getFlag(FFlag.PERMANENT) && ConfServer.permanentFactionsDisableLeaderPromotion) return; + if (this.getFlag(FFlag.PERMANENT) && UConf.get(this).permanentFactionsDisableLeaderPromotion) return; UPlayer oldLeader = this.getLeader(); diff --git a/src/com/massivecraft/factions/entity/UConf.java b/src/com/massivecraft/factions/entity/UConf.java index 89db3281..75d6298c 100644 --- a/src/com/massivecraft/factions/entity/UConf.java +++ b/src/com/massivecraft/factions/entity/UConf.java @@ -26,9 +26,7 @@ public class UConf extends Entity // -------------------------------------------- // // CORE // -------------------------------------------- // - - public boolean canLeaveWithNegativePower = true; - + public int factionMemberLimit = 0; public double factionPowerMax = 1000.0; @@ -36,6 +34,19 @@ public class UConf extends Entity public int factionTagLengthMax = 10; public boolean factionTagForceUpperCase = false; + // -------------------------------------------- // + // ASSORTED + // -------------------------------------------- // + + public boolean permanentFactionsDisableLeaderPromotion = false; + + public int actionDeniedPainAmount = 2; + + public boolean disablePVPForFactionlessPlayers = false; + public boolean enablePVPAgainstFactionlessInAttackersLand = false; + + public double territoryShieldFactor = 0.3; + // -------------------------------------------- // // DEFAULTS // -------------------------------------------- // @@ -60,6 +71,8 @@ public class UConf extends Entity public double powerPerHour = 2.0; public double powerPerDeath = -2.0; + public boolean canLeaveWithNegativePower = true; + // -------------------------------------------- // // HOMES // -------------------------------------------- // @@ -88,4 +101,11 @@ public class UConf extends Entity Rel.MEMBER, new ArrayList() ); + // -------------------------------------------- // + // INTEGRATION: LWC + // -------------------------------------------- // + + public boolean onUnclaimResetLwcLocks = false; + public boolean onCaptureResetLwcLocks = false; + } diff --git a/src/com/massivecraft/factions/entity/UPlayer.java b/src/com/massivecraft/factions/entity/UPlayer.java index b731824f..3c99a4b5 100644 --- a/src/com/massivecraft/factions/entity/UPlayer.java +++ b/src/com/massivecraft/factions/entity/UPlayer.java @@ -660,7 +660,7 @@ public class UPlayer extends SenderEntity implements EconomyParticipato if (Econ.payForAction(cost, this, "claim this land")) return false; // TODO: The LWC integration should listen to Monitor for the claim event. - if (LWCFeatures.getEnabled() && forFaction.isNormal() && ConfServer.onCaptureResetLwcLocks) + if (LWCFeatures.getEnabled() && forFaction.isNormal() && UConf.get(forFaction).onCaptureResetLwcLocks) { LWCFeatures.clearOtherProtections(psChunk, this.getFaction()); } diff --git a/src/com/massivecraft/factions/listeners/FactionsListenerMain.java b/src/com/massivecraft/factions/listeners/FactionsListenerMain.java index 4891ecc9..f06d9466 100644 --- a/src/com/massivecraft/factions/listeners/FactionsListenerMain.java +++ b/src/com/massivecraft/factions/listeners/FactionsListenerMain.java @@ -226,20 +226,21 @@ public class FactionsListenerMain implements Listener Faction defendFaction = fdefender.getFaction(); Faction attackFaction = fattacker.getFaction(); + UConf uconf = UConf.get(attackFaction); - if (attackFaction.isNone() && ConfServer.disablePVPForFactionlessPlayers) + if (attackFaction.isNone() && uconf.disablePVPForFactionlessPlayers) { if (notify) fattacker.msg("You can't hurt other players until you join a faction."); return false; } else if (defendFaction.isNone()) { - if (defenderPsFaction == attackFaction && ConfServer.enablePVPAgainstFactionlessInAttackersLand) + if (defenderPsFaction == attackFaction && uconf.enablePVPAgainstFactionlessInAttackersLand) { // Allow PVP vs. Factionless in attacker's faction territory return true; } - else if (ConfServer.disablePVPForFactionlessPlayers) + else if (uconf.disablePVPForFactionlessPlayers) { if (notify) fattacker.msg("You can't hurt players who are not currently in a faction."); return false; @@ -269,15 +270,15 @@ public class FactionsListenerMain implements Listener // Damage will be dealt. However check if the damage should be reduced. int damage = event.getDamage(); - if (damage > 0.0 && fdefender.hasFaction() && ownTerritory && ConfServer.territoryShieldFactor > 0) + if (damage > 0.0 && fdefender.hasFaction() && ownTerritory && uconf.territoryShieldFactor > 0) { - int newDamage = (int)Math.ceil(damage * (1D - ConfServer.territoryShieldFactor)); + int newDamage = (int)Math.ceil(damage * (1D - uconf.territoryShieldFactor)); event.setDamage(newDamage); // Send message if (notify) { - String perc = MessageFormat.format("{0,number,#%}", (ConfServer.territoryShieldFactor)); // TODO does this display correctly?? + String perc = MessageFormat.format("{0,number,#%}", (uconf.territoryShieldFactor)); // TODO does this display correctly?? fdefender.msg("Enemy damage reduced by %s.", perc); } } @@ -516,7 +517,7 @@ public class FactionsListenerMain implements Listener if (!justCheck) { me.msg("It is painful to build in the territory of %s.", factionHere.describeTo(me)); - player.damage(ConfServer.actionDeniedPainAmount); + player.damage(UConf.get(player).actionDeniedPainAmount); } return true; } @@ -579,12 +580,12 @@ public class FactionsListenerMain implements Listener @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) public void blockBuild(BlockPistonExtendEvent event) { - if ( ! ConfServer.pistonProtectionThroughDenyBuild) return; + Block block = event.getBlock(); - Faction pistonFaction = BoardColls.get().getFactionAt(PS.valueOf(event.getBlock())); + Faction pistonFaction = BoardColls.get().getFactionAt(PS.valueOf(block)); // target end-of-the-line empty (air) block which is being pushed into, including if piston itself would extend into air - Block targetBlock = event.getBlock().getRelative(event.getDirection(), event.getLength() + 1); + Block targetBlock = block.getRelative(event.getDirection(), event.getLength() + 1); // members of faction might not have build rights in their own territory, but pistons should still work regardless; so, address that corner case Faction targetFaction = BoardColls.get().getFactionAt(PS.valueOf(targetBlock)); @@ -605,9 +606,7 @@ public class FactionsListenerMain implements Listener @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) public void blockBuild(BlockPistonRetractEvent event) - { - if (!ConfServer.pistonProtectionThroughDenyBuild) return; - + { // if not a sticky piston, retraction should be fine if (!event.isSticky()) return;