From a78a4dff9890c2e379d54317ec5efbd999043c11 Mon Sep 17 00:00:00 2001 From: Olof Larsson Date: Sat, 22 Oct 2011 17:03:49 +0200 Subject: [PATCH] Managed to get rid of some commands. This needs to be rethought even more though. --- src/com/massivecraft/factions/Conf.java | 5 +- src/com/massivecraft/factions/FPlayer.java | 33 +++++++---- src/com/massivecraft/factions/Factions.java | 6 +- .../factions/cmd/CmdAutoClaim.java | 41 ++++---------- .../factions/cmd/CmdAutoSafeclaim.java | 54 ------------------ .../factions/cmd/CmdAutoWarclaim.java | 55 ------------------- .../massivecraft/factions/cmd/CmdClaim.java | 2 +- .../massivecraft/factions/cmd/CmdHelp.java | 4 -- .../factions/cmd/CmdSafeclaim.java | 50 ----------------- .../factions/cmd/CmdUnclaimall.java | 50 ----------------- .../factions/cmd/CmdWarclaim.java | 48 ---------------- .../massivecraft/factions/cmd/FCmdRoot.java | 8 --- .../listeners/FactionsPlayerListener.java | 30 +--------- .../massivecraft/factions/util/MiscUtil.java | 3 + .../factions/util/RelationUtil.java | 19 ++++++- 15 files changed, 61 insertions(+), 347 deletions(-) delete mode 100644 src/com/massivecraft/factions/cmd/CmdAutoSafeclaim.java delete mode 100644 src/com/massivecraft/factions/cmd/CmdAutoWarclaim.java delete mode 100644 src/com/massivecraft/factions/cmd/CmdSafeclaim.java delete mode 100644 src/com/massivecraft/factions/cmd/CmdWarclaim.java diff --git a/src/com/massivecraft/factions/Conf.java b/src/com/massivecraft/factions/Conf.java index 7c8c39e7..fff1c4e2 100644 --- a/src/com/massivecraft/factions/Conf.java +++ b/src/com/massivecraft/factions/Conf.java @@ -16,10 +16,9 @@ public class Conf public static ChatColor colorNeutral = ChatColor.WHITE; public static ChatColor colorEnemy = ChatColor.RED; - // TODO: We need to change the relation color system. - // I would like peaceful factions to have the relation color gold. - // For this to be possible some refactoring needs to be done. public static ChatColor colorPeaceful = ChatColor.GOLD; + public static ChatColor colorWar = ChatColor.DARK_RED; + //public static ChatColor colorWilderness = ChatColor.DARK_GREEN; // Power public static double powerPlayerMax = 10.0; diff --git a/src/com/massivecraft/factions/FPlayer.java b/src/com/massivecraft/factions/FPlayer.java index 7f659d88..52b28f4a 100644 --- a/src/com/massivecraft/factions/FPlayer.java +++ b/src/com/massivecraft/factions/FPlayer.java @@ -14,6 +14,7 @@ import com.massivecraft.factions.integration.Econ; import com.massivecraft.factions.integration.SpoutFeatures; import com.massivecraft.factions.integration.Worldguard; import com.massivecraft.factions.struct.ChatMode; +import com.massivecraft.factions.struct.Permission; import com.massivecraft.factions.struct.Relation; import com.massivecraft.factions.struct.Role; import com.massivecraft.factions.util.RelationUtil; @@ -69,17 +70,17 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator private transient boolean mapAutoUpdating; // FIELD: autoClaimEnabled - private transient boolean autoClaimEnabled; - public boolean isAutoClaimEnabled() + private transient Faction autoClaimFor; + public Faction getAutoClaimFor() { - if (this.factionId.equals("0")) return false; - return autoClaimEnabled; + return autoClaimFor; } - public void setIsAutoClaimEnabled(boolean enabled) + public void setAutoClaimFor(Faction faction) { - this.autoClaimEnabled = enabled; - if (enabled) + this.autoClaimFor = faction; + if (this.autoClaimFor != null) { + // TODO: merge these into same autoclaim this.autoSafeZoneEnabled = false; this.autoWarZoneEnabled = false; } @@ -93,7 +94,7 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator this.autoSafeZoneEnabled = enabled; if (enabled) { - this.autoClaimEnabled = false; + this.autoClaimFor = null; this.autoWarZoneEnabled = false; } } @@ -106,7 +107,7 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator this.autoWarZoneEnabled = enabled; if (enabled) { - this.autoClaimEnabled = false; + this.autoClaimFor = null; this.autoSafeZoneEnabled = false; } } @@ -152,7 +153,7 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator this.lastPowerUpdateTime = System.currentTimeMillis(); this.lastLoginTime = System.currentTimeMillis(); this.mapAutoUpdating = false; - this.autoClaimEnabled = false; + this.autoClaimFor = null; this.autoSafeZoneEnabled = false; this.autoWarZoneEnabled = false; this.loginPvpDisabled = (Conf.noPVPDamageToOthersForXSecondsAfterLogin > 0) ? true : false; @@ -180,7 +181,7 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator this.chatMode = ChatMode.PUBLIC; this.role = Role.NORMAL; this.title = ""; - this.autoClaimEnabled = false; + this.autoClaimFor = null; if (doSpotUpdate) { @@ -647,6 +648,14 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator { return true; } + else if (forFaction.isSafeZone() && Permission.MANAGE_SAFE_ZONE.has(getPlayer())) + { + return true; + } + else if (forFaction.isWarZone() && Permission.MANAGE_WAR_ZONE.has(getPlayer())) + { + return true; + } else if (myFaction != forFaction) { error = P.p.txt.parse("You can't claim land for %s.", forFaction.describeTo(this)); @@ -734,7 +743,7 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator if ( ! this.canClaimForFactionAtLocation(forFaction, location, notifyFailure)) return false; // if economy is enabled and they're not on the bypass list, make 'em pay - if (Econ.shouldBeUsed() && ! this.isAdminBypassing()) + if (Econ.shouldBeUsed() && ! this.isAdminBypassing() && ! forFaction.isSafeZone() && ! forFaction.isWarZone()) { double cost = Econ.calculateClaimCost(ownedLand, currentFaction.isNormal()); //String costString = Econ.moneyString(cost); diff --git a/src/com/massivecraft/factions/Factions.java b/src/com/massivecraft/factions/Factions.java index 78ee5271..85d4250a 100644 --- a/src/com/massivecraft/factions/Factions.java +++ b/src/com/massivecraft/factions/Factions.java @@ -55,7 +55,7 @@ public class Factions extends EntityCollection if ( ! this.exists("-1")) { Faction faction = this.create("-1"); - faction.setTag(ChatColor.GOLD+"Safe Zone"); + faction.setTag("SafeZone"); faction.setDescription("Free from PVP and monsters"); } @@ -63,7 +63,7 @@ public class Factions extends EntityCollection if ( ! this.exists("-2")) { Faction faction = this.create("-2"); - faction.setTag(ChatColor.DARK_RED+"War Zone"); + faction.setTag("WarZone"); faction.setDescription("Not the safest place to be"); } @@ -153,7 +153,7 @@ public class Factions extends EntityCollection // TODO: Slow index building for (Faction faction : this.get()) { - tag2faction.put(faction.getTag(), faction); + tag2faction.put(ChatColor.stripColor(faction.getTag()), faction); } String tag = TextUtil.getWhereLongestCommonStartCI(tag2faction.keySet(), pattern); diff --git a/src/com/massivecraft/factions/cmd/CmdAutoClaim.java b/src/com/massivecraft/factions/cmd/CmdAutoClaim.java index 98951597..d07ad4e0 100644 --- a/src/com/massivecraft/factions/cmd/CmdAutoClaim.java +++ b/src/com/massivecraft/factions/cmd/CmdAutoClaim.java @@ -1,7 +1,6 @@ package com.massivecraft.factions.cmd; -import com.massivecraft.factions.Conf; -import com.massivecraft.factions.FLocation; +import com.massivecraft.factions.Faction; import com.massivecraft.factions.struct.Permission; public class CmdAutoClaim extends FCommand @@ -12,48 +11,32 @@ public class CmdAutoClaim extends FCommand this.aliases.add("autoclaim"); //this.requiredArgs.add(""); - this.optionalArgs.put("on/off", "flip"); + this.optionalArgs.put("faction", "your"); this.permission = Permission.AUTOCLAIM.node; this.disableOnLock = true; senderMustBePlayer = true; senderMustBeMember = false; - senderMustBeModerator = true; + senderMustBeModerator = false; senderMustBeAdmin = false; } @Override public void perform() { - boolean enabled = this.argAsBool(0, ! fme.isAutoClaimEnabled()); - - fme.setIsAutoClaimEnabled(enabled); - - if ( ! enabled) + Faction forFaction = this.argAsFaction(0, myFaction); + if (forFaction == null || (forFaction == myFaction && fme.getAutoClaimFor() == myFaction)) { + fme.setAutoClaimFor(null); msg("Auto-claiming of land disabled."); return; } - - FLocation flocation = new FLocation(fme); - - if (Conf.worldsNoClaiming.contains(flocation.getWorldName())) - { - msg("Sorry, this world has land claiming disabled."); - fme.setIsAutoClaimEnabled(false); - return; - } - - if (myFaction.getLandRounded() >= myFaction.getPowerRounded()) - { - msg("You can't claim more land! You need more power!"); - fme.setIsAutoClaimEnabled(false); - return; - } - - msg("Auto-claiming of land enabled."); - fme.attemptClaim(myFaction, me.getLocation(), false); + + fme.setAutoClaimFor(forFaction); + + msg("Now auto-claiming land for %s.", forFaction.describeTo(fme)); + fme.attemptClaim(forFaction, me.getLocation(), true); } -} +} \ No newline at end of file diff --git a/src/com/massivecraft/factions/cmd/CmdAutoSafeclaim.java b/src/com/massivecraft/factions/cmd/CmdAutoSafeclaim.java deleted file mode 100644 index f7ed9810..00000000 --- a/src/com/massivecraft/factions/cmd/CmdAutoSafeclaim.java +++ /dev/null @@ -1,54 +0,0 @@ -package com.massivecraft.factions.cmd; - -import com.massivecraft.factions.Board; -import com.massivecraft.factions.FLocation; -import com.massivecraft.factions.Factions; -import com.massivecraft.factions.struct.Permission; - -public class CmdAutoSafeclaim extends FCommand -{ - - public CmdAutoSafeclaim() - { - super(); - this.aliases.add("autosafe"); - - //this.requiredArgs.add(""); - this.optionalArgs.put("on/off", "flip"); - - this.permission = Permission.MANAGE_SAFE_ZONE.node; - this.disableOnLock = true; - - senderMustBePlayer = true; - senderMustBeMember = false; - senderMustBeModerator = true; - senderMustBeAdmin = false; - - this.setHelpShort("Auto-claim land for the safezone"); - } - - @Override - public void perform() - { - boolean enabled = this.argAsBool(0, ! fme.isAutoSafeClaimEnabled()); - - fme.setIsAutoSafeClaimEnabled(enabled); - - if ( ! enabled) - { - msg("Auto-claiming of safe zone disabled."); - return; - } - - msg("Auto-claiming of safe zone enabled."); - - FLocation playerFlocation = new FLocation(fme); - - if (!Board.getFactionAt(playerFlocation).isSafeZone()) - { - Board.setFactionAt(Factions.i.getSafeZone(), playerFlocation); - msg("This land is now a safe zone."); - } - } - -} diff --git a/src/com/massivecraft/factions/cmd/CmdAutoWarclaim.java b/src/com/massivecraft/factions/cmd/CmdAutoWarclaim.java deleted file mode 100644 index a58e459c..00000000 --- a/src/com/massivecraft/factions/cmd/CmdAutoWarclaim.java +++ /dev/null @@ -1,55 +0,0 @@ -package com.massivecraft.factions.cmd; - - -import com.massivecraft.factions.Board; -import com.massivecraft.factions.FLocation; -import com.massivecraft.factions.Factions; -import com.massivecraft.factions.struct.Permission; - -public class CmdAutoWarclaim extends FCommand -{ - - public CmdAutoWarclaim() - { - super(); - aliases.add("autowar"); - - //this.requiredArgs.add(""); - this.optionalArgs.put("on/off", "flip"); - - this.permission = Permission.MANAGE_WAR_ZONE.node; - this.disableOnLock = true; - - senderMustBePlayer = true; - senderMustBeMember = false; - senderMustBeModerator = true; - senderMustBeAdmin = false; - - this.setHelpShort("Auto-claim land for the warzone"); - } - - @Override - public void perform() - { - boolean enabled = this.argAsBool(0, ! fme.isAutoWarClaimEnabled()); - - fme.setIsAutoWarClaimEnabled(enabled); - - if ( ! enabled) - { - msg("Auto-claiming of war zone disabled."); - return; - } - - msg("Auto-claiming of war zone enabled."); - - FLocation playerFlocation = new FLocation(fme); - - if (!Board.getFactionAt(playerFlocation).isWarZone()) - { - Board.setFactionAt(Factions.i.getWarZone(), playerFlocation); - msg("This land is now a war zone."); - } - } - -} diff --git a/src/com/massivecraft/factions/cmd/CmdClaim.java b/src/com/massivecraft/factions/cmd/CmdClaim.java index f5c6b0d2..4d4cd9ce 100644 --- a/src/com/massivecraft/factions/cmd/CmdClaim.java +++ b/src/com/massivecraft/factions/cmd/CmdClaim.java @@ -18,7 +18,7 @@ public class CmdClaim extends FCommand this.disableOnLock = true; senderMustBePlayer = true; - senderMustBeMember = true; + senderMustBeMember = false; senderMustBeModerator = false; senderMustBeAdmin = false; diff --git a/src/com/massivecraft/factions/cmd/CmdHelp.java b/src/com/massivecraft/factions/cmd/CmdHelp.java index a688c6ba..b00e2e6d 100644 --- a/src/com/massivecraft/factions/cmd/CmdHelp.java +++ b/src/com/massivecraft/factions/cmd/CmdHelp.java @@ -160,11 +160,7 @@ public class CmdHelp extends FCommand pageLines = new ArrayList(); pageLines.add("Finally some commands for the server admins:"); pageLines.add( p.cmdBase.cmdBypass.getUseageTemplate(true) ); - pageLines.add( p.cmdBase.cmdSafeclaim.getUseageTemplate(true) ); - pageLines.add( p.cmdBase.cmdAutoSafeclaim.getUseageTemplate(true) ); pageLines.add( p.cmdBase.cmdSafeunclaimall.getUseageTemplate(true) ); - pageLines.add( p.cmdBase.cmdWarclaim.getUseageTemplate(true) ); - pageLines.add( p.cmdBase.cmdAutoWarclaim.getUseageTemplate(true) ); pageLines.add( p.cmdBase.cmdWarunclaimall.getUseageTemplate(true) ); pageLines.add(p.txt.parse("Note: " + p.cmdBase.cmdUnclaim.getUseageTemplate(false) + P.p.txt.parse("") + " works on safe/war zones as well.")); helpPages.add(pageLines); diff --git a/src/com/massivecraft/factions/cmd/CmdSafeclaim.java b/src/com/massivecraft/factions/cmd/CmdSafeclaim.java deleted file mode 100644 index f6169f00..00000000 --- a/src/com/massivecraft/factions/cmd/CmdSafeclaim.java +++ /dev/null @@ -1,50 +0,0 @@ -package com.massivecraft.factions.cmd; - -import com.massivecraft.factions.Board; -import com.massivecraft.factions.FLocation; -import com.massivecraft.factions.Factions; -import com.massivecraft.factions.struct.Permission; - -public class CmdSafeclaim extends FCommand -{ - - public CmdSafeclaim() - { - this.aliases.add("safeclaim"); - this.aliases.add("safe"); - - //this.requiredArgs.add(""); - this.optionalArgs.put("radius", "0"); - - this.permission = Permission.MANAGE_SAFE_ZONE.node; - this.disableOnLock = true; - - senderMustBePlayer = true; - senderMustBeMember = false; - senderMustBeModerator = false; - senderMustBeAdmin = false; - - this.setHelpShort("Claim land for the safezone"); - } - - @Override - public void perform() - { - // The current location of the player - FLocation playerFlocation = new FLocation(fme); - - int radius = this.argAsInt(0, 0); - if (radius < 0) radius = 0; - - FLocation from = playerFlocation.getRelative(radius, radius); - FLocation to = playerFlocation.getRelative(-radius, -radius); - - for (FLocation locToClaim : FLocation.getArea(from, to)) - { - Board.setFactionAt(Factions.i.getSafeZone(), locToClaim); - } - - msg("You claimed %d chunks for the safe zone.", (1+radius*2)*(1+radius*2)); - } - -} diff --git a/src/com/massivecraft/factions/cmd/CmdUnclaimall.java b/src/com/massivecraft/factions/cmd/CmdUnclaimall.java index d462d9c9..ddce85dc 100644 --- a/src/com/massivecraft/factions/cmd/CmdUnclaimall.java +++ b/src/com/massivecraft/factions/cmd/CmdUnclaimall.java @@ -36,56 +36,6 @@ public class CmdUnclaimall extends FCommand { if ( ! Econ.modifyMoney(fme , refund, "to unclaim all faction land", "for unclaiming all faction land")) return; } - - //String moneyBack = ""; - /*if (Econ.shouldBeUsed()) - { - double refund = Econ.calculateTotalLandRefund(myFaction.getLandRounded()); - // a real refund - if (refund > 0.0) - { - if(Conf.bankFactionPaysLandCosts) - { - Faction faction = myFaction; - faction.addMoney(refund); - moneyBack = " "+faction.getTag()+" received a refund of "+Econ.moneyString(refund)+"."; - } - else - { - Econ.addMoney(fme.getName(), refund); - moneyBack = " They received a refund of "+Econ.moneyString(refund)+"."; - } - } - // wait, you're charging people to unclaim land? outrageous - else if (refund < 0.0) - { - if(Conf.bankFactionPaysLandCosts) - { - Faction faction = myFaction; - if(!faction.removeMoney(-refund)) - { - msg("Unclaiming all faction land will cost "+Econ.moneyString(-refund)+", which your faction can't currently afford."); - return; - } - moneyBack = " It cost "+faction.getTag()+" "+Econ.moneyString(refund)+"."; - } - else - { - if (!Econ.deductMoney(fme.getName(), -refund)) - { - msg("Unclaiming all faction land will cost "+Econ.moneyString(-refund)+", which you can't currently afford."); - return; - } - moneyBack = " It cost them "+Econ.moneyString(refund)+"."; - } - moneyBack = " It cost them "+Econ.moneyString(refund)+"."; - } - // no refund - else - { - moneyBack = ""; - } - }*/ Board.unclaimAll(myFaction.getId()); myFaction.msg("%s unclaimed ALL of your faction's land.", fme.describeTo(myFaction, true)); diff --git a/src/com/massivecraft/factions/cmd/CmdWarclaim.java b/src/com/massivecraft/factions/cmd/CmdWarclaim.java deleted file mode 100644 index 6a460efc..00000000 --- a/src/com/massivecraft/factions/cmd/CmdWarclaim.java +++ /dev/null @@ -1,48 +0,0 @@ -package com.massivecraft.factions.cmd; - -import com.massivecraft.factions.Board; -import com.massivecraft.factions.FLocation; -import com.massivecraft.factions.Factions; -import com.massivecraft.factions.struct.Permission; - -public class CmdWarclaim extends FCommand -{ - - public CmdWarclaim() - { - this.aliases.add("warclaim"); - this.aliases.add("war"); - - //this.requiredArgs.add(""); - this.optionalArgs.put("radius", "0"); - - this.permission = Permission.MANAGE_WAR_ZONE.node; - this.disableOnLock = true; - - senderMustBePlayer = true; - senderMustBeMember = false; - senderMustBeModerator = false; - senderMustBeAdmin = false; - - this.setHelpShort("Claim land for the warzone"); - } - - public void perform() - { - // The current location of the player - FLocation playerFlocation = new FLocation(fme); - - int radius = this.argAsInt(0, 0); - if (radius < 0) radius = 0; - - FLocation from = playerFlocation.getRelative(radius, radius); - FLocation to = playerFlocation.getRelative(-radius, -radius); - - for (FLocation locToClaim : FLocation.getArea(from, to)) - { - Board.setFactionAt(Factions.i.getWarZone(), locToClaim); - } - - msg("You claimed %d chunks for the war zone.", (1+radius*2)*(1+radius*2)); - } -} diff --git a/src/com/massivecraft/factions/cmd/FCmdRoot.java b/src/com/massivecraft/factions/cmd/FCmdRoot.java index 52e1a22d..734d724c 100644 --- a/src/com/massivecraft/factions/cmd/FCmdRoot.java +++ b/src/com/massivecraft/factions/cmd/FCmdRoot.java @@ -8,8 +8,6 @@ public class FCmdRoot extends FCommand { public CmdAdmin cmdAdmin = new CmdAdmin(); public CmdAutoClaim cmdAutoClaim = new CmdAutoClaim(); - public CmdAutoSafeclaim cmdAutoSafeclaim = new CmdAutoSafeclaim(); - public CmdAutoWarclaim cmdAutoWarclaim = new CmdAutoWarclaim(); public CmdBoom cmdBoom = new CmdBoom(); public CmdBypass cmdBypass = new CmdBypass(); public CmdChat cmdChat = new CmdChat(); @@ -40,7 +38,6 @@ public class FCmdRoot extends FCommand public CmdRelationEnemy cmdRelationEnemy = new CmdRelationEnemy(); public CmdRelationNeutral cmdRelationNeutral = new CmdRelationNeutral(); public CmdReload cmdReload = new CmdReload(); - public CmdSafeclaim cmdSafeclaim = new CmdSafeclaim(); public CmdSafeunclaimall cmdSafeunclaimall = new CmdSafeunclaimall(); public CmdSaveAll cmdSaveAll = new CmdSaveAll(); public CmdSethome cmdSethome = new CmdSethome(); @@ -50,7 +47,6 @@ public class FCmdRoot extends FCommand public CmdUnclaim cmdUnclaim = new CmdUnclaim(); public CmdUnclaimall cmdUnclaimall = new CmdUnclaimall(); public CmdVersion cmdVersion = new CmdVersion(); - public CmdWarclaim cmdWarclaim = new CmdWarclaim(); public CmdWarunclaimall cmdWarunclaimall = new CmdWarunclaimall(); public FCmdRoot() @@ -77,8 +73,6 @@ public class FCmdRoot extends FCommand this.addSubCommand(this.cmdAdmin); this.addSubCommand(this.cmdAutoClaim); - this.addSubCommand(this.cmdAutoSafeclaim); - this.addSubCommand(this.cmdAutoWarclaim); this.addSubCommand(this.cmdBoom); this.addSubCommand(this.cmdBypass); this.addSubCommand(this.cmdChat); @@ -109,7 +103,6 @@ public class FCmdRoot extends FCommand this.addSubCommand(this.cmdRelationEnemy); this.addSubCommand(this.cmdRelationNeutral); this.addSubCommand(this.cmdReload); - this.addSubCommand(this.cmdSafeclaim); this.addSubCommand(this.cmdSafeunclaimall); this.addSubCommand(this.cmdSaveAll); this.addSubCommand(this.cmdSethome); @@ -119,7 +112,6 @@ public class FCmdRoot extends FCommand this.addSubCommand(this.cmdUnclaim); this.addSubCommand(this.cmdUnclaimall); this.addSubCommand(this.cmdVersion); - this.addSubCommand(this.cmdWarclaim); this.addSubCommand(this.cmdWarunclaimall); } diff --git a/src/com/massivecraft/factions/listeners/FactionsPlayerListener.java b/src/com/massivecraft/factions/listeners/FactionsPlayerListener.java index 902802ef..cfa8f36f 100644 --- a/src/com/massivecraft/factions/listeners/FactionsPlayerListener.java +++ b/src/com/massivecraft/factions/listeners/FactionsPlayerListener.java @@ -32,7 +32,6 @@ import com.massivecraft.factions.Factions; import com.massivecraft.factions.P; import com.massivecraft.factions.integration.SpoutFeatures; import com.massivecraft.factions.struct.Permission; -import com.massivecraft.factions.struct.Role; import com.massivecraft.factions.struct.Relation; import com.massivecraft.factions.zcore.util.TextUtil; @@ -252,34 +251,9 @@ public class FactionsPlayerListener extends PlayerListener } } - if (me.isAutoClaimEnabled()) + if (me.getAutoClaimFor() != null) { - Faction myFaction = me.getFaction(); - // TODO: Why is this ("cost") here and unused??? Should it be used somewhere Brettflan? :) - // Olof just commented it out to avoid the error. - // So sayeth Brettflan, answered in a comment since you asked in a comment: - // NOTHING MORE TODO: it was used, but apparently not needed after some changes including this commit: https://github.com/MassiveCraft/Factions/commit/5eaf9c68358c6076bb856baf80fd6496e2ab02ce - // - //Faction otherFaction = Board.getFactionAt(to); - //double cost = Econ.calculateClaimCost(myFaction.getLandRounded(), otherFaction.isNormal()); - - if (me.getRole().value < Role.MODERATOR.value) - { - me.msg("You must be %s to claim land.", Role.MODERATOR.toString()); - me.setIsAutoClaimEnabled(false); - } - else if (Conf.worldsNoClaiming.contains(to.getWorldName())) - { - me.msg("Sorry, this world has land claiming disabled."); - me.setIsAutoClaimEnabled(false); - } - else if (myFaction.getLandRounded() >= myFaction.getPowerRounded()) - { - me.msg("You can't claim more land! You need more power!"); - me.setIsAutoClaimEnabled(false); - } - else - me.attemptClaim(myFaction, player.getLocation(), false); + me.attemptClaim(me.getAutoClaimFor(), player.getLocation(), true); } else if (me.isAutoSafeClaimEnabled()) { diff --git a/src/com/massivecraft/factions/util/MiscUtil.java b/src/com/massivecraft/factions/util/MiscUtil.java index 9e8a24b3..4569c78e 100644 --- a/src/com/massivecraft/factions/util/MiscUtil.java +++ b/src/com/massivecraft/factions/util/MiscUtil.java @@ -3,6 +3,7 @@ package com.massivecraft.factions.util; import java.util.Arrays; import java.util.HashSet; +import org.bukkit.ChatColor; import org.bukkit.entity.Creature; import org.bukkit.entity.CreatureType; import org.bukkit.entity.Entity; @@ -51,6 +52,8 @@ public class MiscUtil { String ret = ""; + str = ChatColor.stripColor(str); + for (char c : str.toCharArray()) { if (substanceChars.contains(String.valueOf(c))) diff --git a/src/com/massivecraft/factions/util/RelationUtil.java b/src/com/massivecraft/factions/util/RelationUtil.java index 12104ca7..b574ea81 100644 --- a/src/com/massivecraft/factions/util/RelationUtil.java +++ b/src/com/massivecraft/factions/util/RelationUtil.java @@ -116,10 +116,25 @@ public class RelationUtil public static ChatColor getColorOfThatToMe(RelationParticipator that, RelationParticipator me) { - if (getFaction(that) != null && getFaction(that).isPeaceful() && getFaction(that) != getFaction(me)) + Faction thatFaction = getFaction(that); + if (thatFaction != null) { - return Conf.colorPeaceful; + if (thatFaction.isPeaceful() && thatFaction != getFaction(me)) + { + return Conf.colorPeaceful; + } + + if (thatFaction.isSafeZone() && thatFaction != getFaction(me)) + { + return Conf.colorPeaceful; + } + + if (thatFaction.isWarZone() && thatFaction != getFaction(me)) + { + return Conf.colorWar; + } } + return getRelationTo(that, me).getColor(); } }