From f25daa228a69af5f536192a46a878a9bb266d2b7 Mon Sep 17 00:00:00 2001 From: Olof Larsson Date: Wed, 12 Oct 2011 18:48:47 +0200 Subject: [PATCH] Some of the bugs are fixed. --- src/com/massivecraft/factions/FPlayer.java | 1 + src/com/massivecraft/factions/Faction.java | 19 ++++- .../massivecraft/factions/cmd/CmdBalance.java | 2 +- .../massivecraft/factions/cmd/CmdBoom.java | 2 +- .../massivecraft/factions/cmd/CmdCreate.java | 5 +- .../factions/cmd/CmdDescription.java | 5 +- .../massivecraft/factions/cmd/CmdHome.java | 5 +- .../massivecraft/factions/cmd/CmdInvite.java | 5 +- .../massivecraft/factions/cmd/CmdJoin.java | 5 +- .../massivecraft/factions/cmd/CmdKick.java | 5 +- .../massivecraft/factions/cmd/CmdList.java | 2 +- src/com/massivecraft/factions/cmd/CmdMap.java | 4 +- .../massivecraft/factions/cmd/CmdOpen.java | 2 +- .../massivecraft/factions/cmd/CmdOwner.java | 2 +- .../massivecraft/factions/cmd/CmdPower.java | 2 +- .../massivecraft/factions/cmd/CmdSethome.java | 2 +- .../massivecraft/factions/cmd/CmdShow.java | 2 +- src/com/massivecraft/factions/cmd/CmdTag.java | 2 +- .../massivecraft/factions/cmd/CmdTitle.java | 2 +- .../massivecraft/factions/cmd/CmdUnclaim.java | 18 ++++- .../factions/cmd/CmdUnclaimall.java | 19 +++-- .../massivecraft/factions/cmd/FCommand.java | 13 +--- .../factions/cmd/FRelationCommand.java | 2 +- .../factions/integration/Econ.java | 33 ++++---- .../factions/util/RelationUtil.java | 78 ++++++++++--------- 25 files changed, 132 insertions(+), 105 deletions(-) diff --git a/src/com/massivecraft/factions/FPlayer.java b/src/com/massivecraft/factions/FPlayer.java index 30fecb64..ecdf0889 100644 --- a/src/com/massivecraft/factions/FPlayer.java +++ b/src/com/massivecraft/factions/FPlayer.java @@ -123,6 +123,7 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator // FIELD: account public MethodAccount getAccount() { + P.p.log("Econ.shouldBeUsed() "+Econ.shouldBeUsed()); if ( ! Econ.shouldBeUsed()) return null; return Econ.getMethod().getAccount(this.getId()); } diff --git a/src/com/massivecraft/factions/Faction.java b/src/com/massivecraft/factions/Faction.java index 72aa7fbf..94765456 100644 --- a/src/com/massivecraft/factions/Faction.java +++ b/src/com/massivecraft/factions/Faction.java @@ -113,9 +113,19 @@ public class Faction extends Entity implements EconomyParticipator // FIELD: account (fake field) // Bank functions public double money; // Deprecated TODO: Hantera. + public String getAccountId() { return "faction-"+this.getId(); } public MethodAccount getAccount() { - return Econ.getMethod().getAccount("faction-"+this.getId()); + String aid = this.getAccountId(); + + // We need to override the default money given to players. + if ( ! Econ.getMethod().hasAccount(aid)) + { + MethodAccount acc = Econ.getMethod().getAccount(aid); + acc.set(0); + } + + return Econ.getMethod().getAccount(aid); } /*public double getMoney() { return this.money; } @@ -727,6 +737,13 @@ public class Faction extends Entity implements EconomyParticipator @Override public void postDetach() { + if (Econ.shouldBeUsed()) + { + Econ.getMethod().getAccount(getAccountId()).remove(); + } + + this.getAccountId(); + // Clean the board Board.clean(); diff --git a/src/com/massivecraft/factions/cmd/CmdBalance.java b/src/com/massivecraft/factions/cmd/CmdBalance.java index 0fabbb38..44072cfd 100644 --- a/src/com/massivecraft/factions/cmd/CmdBalance.java +++ b/src/com/massivecraft/factions/cmd/CmdBalance.java @@ -48,7 +48,7 @@ public class CmdBalance extends FCommand return; } - msg("%s balance: %s", faction.getTag(fme), Econ.moneyString(faction.getAccount().balance())); + msg("%s balance: %s", faction.getTag(fme), Econ.moneyString(faction.getAccount().balance())); } } diff --git a/src/com/massivecraft/factions/cmd/CmdBoom.java b/src/com/massivecraft/factions/cmd/CmdBoom.java index 245fb81c..1f83c964 100644 --- a/src/com/massivecraft/factions/cmd/CmdBoom.java +++ b/src/com/massivecraft/factions/cmd/CmdBoom.java @@ -32,7 +32,7 @@ public class CmdBoom extends FCommand } // if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay - if ( ! payForCommand(Conf.econCostNoBoom)) return; + if ( ! payForCommand(Conf.econCostNoBoom, "to toggle explosions", "for toggling explosions")) return; myFaction.setPeacefulExplosionsEnabled(this.argAsBool(0, ! myFaction.getPeacefulExplosionsEnabled())); diff --git a/src/com/massivecraft/factions/cmd/CmdCreate.java b/src/com/massivecraft/factions/cmd/CmdCreate.java index 81eeaaec..57e8aacb 100644 --- a/src/com/massivecraft/factions/cmd/CmdCreate.java +++ b/src/com/massivecraft/factions/cmd/CmdCreate.java @@ -55,10 +55,7 @@ public class CmdCreate extends FCommand } // if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay - if (!payForCommand(Conf.econCostCreate)) - { - return; - } + if ( ! payForCommand(Conf.econCostCreate, "to create a new faction", "for creating a new faction")) return; Faction faction = Factions.i.create(); faction.setTag(tag); diff --git a/src/com/massivecraft/factions/cmd/CmdDescription.java b/src/com/massivecraft/factions/cmd/CmdDescription.java index a1aee2be..311dd125 100644 --- a/src/com/massivecraft/factions/cmd/CmdDescription.java +++ b/src/com/massivecraft/factions/cmd/CmdDescription.java @@ -30,10 +30,7 @@ public class CmdDescription extends FCommand public void perform() { // if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay - if ( ! payForCommand(Conf.econCostDesc)) - { - return; - } + if ( ! payForCommand(Conf.econCostDesc, "to change faction description", "for changing faction description")) return; myFaction.setDescription(TextUtil.implode(args, " ")); diff --git a/src/com/massivecraft/factions/cmd/CmdHome.java b/src/com/massivecraft/factions/cmd/CmdHome.java index 88176774..79abd519 100644 --- a/src/com/massivecraft/factions/cmd/CmdHome.java +++ b/src/com/massivecraft/factions/cmd/CmdHome.java @@ -120,10 +120,7 @@ public class CmdHome extends FCommand } // if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay - if ( ! payForCommand(Conf.econCostHome)) - { - return; - } + if ( ! payForCommand(Conf.econCostHome, "to change faction home", "for changing faction home")) return; me.teleport(myFaction.getHome()); } diff --git a/src/com/massivecraft/factions/cmd/CmdInvite.java b/src/com/massivecraft/factions/cmd/CmdInvite.java index a58f7e32..db0480e3 100644 --- a/src/com/massivecraft/factions/cmd/CmdInvite.java +++ b/src/com/massivecraft/factions/cmd/CmdInvite.java @@ -38,10 +38,7 @@ public class CmdInvite extends FCommand } // if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay - if ( ! payForCommand(Conf.econCostInvite)) - { - return; - } + if ( ! payForCommand(Conf.econCostInvite, "to invite someone", "for inviting someone")) return; myFaction.invite(you); diff --git a/src/com/massivecraft/factions/cmd/CmdJoin.java b/src/com/massivecraft/factions/cmd/CmdJoin.java index bc08f90f..961d2c5c 100644 --- a/src/com/massivecraft/factions/cmd/CmdJoin.java +++ b/src/com/massivecraft/factions/cmd/CmdJoin.java @@ -61,10 +61,7 @@ public class CmdJoin extends FCommand } // if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay - if (!payForCommand(Conf.econCostJoin)) - { - return; - } + if ( ! payForCommand(Conf.econCostJoin, "to join a faction", "for joining a faction")) return; fme.msg("You successfully joined %s", faction.getTag(fme)); faction.msg("%s joined your faction.", fme.getNameAndRelevant(faction)); diff --git a/src/com/massivecraft/factions/cmd/CmdKick.java b/src/com/massivecraft/factions/cmd/CmdKick.java index e0609e87..e1e953d7 100644 --- a/src/com/massivecraft/factions/cmd/CmdKick.java +++ b/src/com/massivecraft/factions/cmd/CmdKick.java @@ -65,10 +65,7 @@ public class CmdKick extends FCommand } // if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay - if ( ! payForCommand(Conf.econCostKick)) - { - return; - } + if ( ! payForCommand(Conf.econCostKick, "to kick someone from the faction", "for kicking someone from the faction")) return; yourFaction.msg("%s kicked %s from the faction! :O", fme.getNameAndRelevant(yourFaction), you.getNameAndRelevant(yourFaction)); you.msg("%s kicked you from %s! :O", fme.getNameAndRelevant(you), yourFaction.getTag(you)); diff --git a/src/com/massivecraft/factions/cmd/CmdList.java b/src/com/massivecraft/factions/cmd/CmdList.java index 33e32165..bc4da1e0 100644 --- a/src/com/massivecraft/factions/cmd/CmdList.java +++ b/src/com/massivecraft/factions/cmd/CmdList.java @@ -35,7 +35,7 @@ public class CmdList extends FCommand public void perform() { // if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay - if ( ! payForCommand(Conf.econCostList)) return; + if ( ! payForCommand(Conf.econCostList, "to list the factions", "for listing the factions")) return; ArrayList factionList = new ArrayList(Factions.i.get()); factionList.remove(Factions.i.getNone()); diff --git a/src/com/massivecraft/factions/cmd/CmdMap.java b/src/com/massivecraft/factions/cmd/CmdMap.java index 50bca56b..aac8ac11 100644 --- a/src/com/massivecraft/factions/cmd/CmdMap.java +++ b/src/com/massivecraft/factions/cmd/CmdMap.java @@ -35,7 +35,7 @@ public class CmdMap extends FCommand // Turn on // if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay - if ( ! payForCommand(Conf.econCostMap)) return; + if ( ! payForCommand(Conf.econCostMap, "to show the map", "for showing the map")) return; fme.setMapAutoUpdating(true); msg("Map auto update ENABLED."); @@ -53,7 +53,7 @@ public class CmdMap extends FCommand else { // if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay - if ( ! payForCommand(Conf.econCostMap)) return; + if ( ! payForCommand(Conf.econCostMap, "to show the map", "for showing the map")) return; showMap(); } diff --git a/src/com/massivecraft/factions/cmd/CmdOpen.java b/src/com/massivecraft/factions/cmd/CmdOpen.java index 5478c478..9397aa37 100644 --- a/src/com/massivecraft/factions/cmd/CmdOpen.java +++ b/src/com/massivecraft/factions/cmd/CmdOpen.java @@ -28,7 +28,7 @@ public class CmdOpen extends FCommand public void perform() { // if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay - if ( ! payForCommand(Conf.econCostOpen)) return; + if ( ! payForCommand(Conf.econCostOpen, "to open or close the faction", "for opening or closing the faction")) return; myFaction.setOpen(this.argAsBool(0, ! myFaction.getOpen())); diff --git a/src/com/massivecraft/factions/cmd/CmdOwner.java b/src/com/massivecraft/factions/cmd/CmdOwner.java index 0928b4cb..8d81ab42 100644 --- a/src/com/massivecraft/factions/cmd/CmdOwner.java +++ b/src/com/massivecraft/factions/cmd/CmdOwner.java @@ -102,7 +102,7 @@ public class CmdOwner extends FCommand } // if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay - if ( ! payForCommand(Conf.econCostOwner)) return; + if ( ! payForCommand(Conf.econCostOwner, "to set ownership of claimed land", "for setting ownership of claimed land")) return; myFaction.setPlayerAsOwner(playerName, flocation); fme.msg("You have added %s to the owner list for this claimed land.", playerName); diff --git a/src/com/massivecraft/factions/cmd/CmdPower.java b/src/com/massivecraft/factions/cmd/CmdPower.java index bbefc5bf..6e7d0c7d 100644 --- a/src/com/massivecraft/factions/cmd/CmdPower.java +++ b/src/com/massivecraft/factions/cmd/CmdPower.java @@ -34,7 +34,7 @@ public class CmdPower extends FCommand if (target != me && ! Permission.POWER_ANY.has(sender, true)) return; // if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay - if ( ! payForCommand(Conf.econCostPower)) return; + if ( ! payForCommand(Conf.econCostPower, "to show player power info", "for showing player power info")) return; msg("%s - Power / Maxpower: %d / %d", target.getNameAndRelevant(fme), target.getPowerRounded(), target.getPowerMaxRounded()); } diff --git a/src/com/massivecraft/factions/cmd/CmdSethome.java b/src/com/massivecraft/factions/cmd/CmdSethome.java index 465f8590..f00f655a 100644 --- a/src/com/massivecraft/factions/cmd/CmdSethome.java +++ b/src/com/massivecraft/factions/cmd/CmdSethome.java @@ -62,7 +62,7 @@ public class CmdSethome extends FCommand } // if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay - if ( ! payForCommand(Conf.econCostSethome)) return; + if ( ! payForCommand(Conf.econCostSethome, "to set the faction home", "for setting the faction home")) return; faction.setHome(me.getLocation()); diff --git a/src/com/massivecraft/factions/cmd/CmdShow.java b/src/com/massivecraft/factions/cmd/CmdShow.java index 42673b4d..b7626306 100644 --- a/src/com/massivecraft/factions/cmd/CmdShow.java +++ b/src/com/massivecraft/factions/cmd/CmdShow.java @@ -41,7 +41,7 @@ public class CmdShow extends FCommand } // if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay - if ( ! payForCommand(Conf.econCostShow)) return; + if ( ! payForCommand(Conf.econCostShow, "to show faction information", "for showing faction information")) return; Collection admins = faction.getFPlayersWhereRole(Role.ADMIN); Collection mods = faction.getFPlayersWhereRole(Role.MODERATOR); diff --git a/src/com/massivecraft/factions/cmd/CmdTag.java b/src/com/massivecraft/factions/cmd/CmdTag.java index f9b0d105..95d03a6c 100644 --- a/src/com/massivecraft/factions/cmd/CmdTag.java +++ b/src/com/massivecraft/factions/cmd/CmdTag.java @@ -49,7 +49,7 @@ public class CmdTag extends FCommand } // if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay - if ( ! payForCommand(Conf.econCostTag)) return; + if ( ! payForCommand(Conf.econCostTag, "to change the faction tag", "for changing the faction tag")) return; String oldtag = myFaction.getTag(); myFaction.setTag(tag); diff --git a/src/com/massivecraft/factions/cmd/CmdTitle.java b/src/com/massivecraft/factions/cmd/CmdTitle.java index 28a6c6ca..3a237300 100644 --- a/src/com/massivecraft/factions/cmd/CmdTitle.java +++ b/src/com/massivecraft/factions/cmd/CmdTitle.java @@ -36,7 +36,7 @@ public class CmdTitle extends FCommand if ( ! canIAdministerYou(fme, you)) return; // if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay - if ( ! payForCommand(Conf.econCostTitle)) return; + if ( ! payForCommand(Conf.econCostTitle, "to change a players title", "for changing a players title")) return; you.setTitle(title); diff --git a/src/com/massivecraft/factions/cmd/CmdUnclaim.java b/src/com/massivecraft/factions/cmd/CmdUnclaim.java index 4ddf55d7..29701a7f 100644 --- a/src/com/massivecraft/factions/cmd/CmdUnclaim.java +++ b/src/com/massivecraft/factions/cmd/CmdUnclaim.java @@ -86,10 +86,21 @@ public class CmdUnclaim extends FCommand return; } - String moneyBack = ""; - if (Econ.enabled()) + //String moneyBack = ""; + if (Econ.shouldBeUsed()) { double refund = Econ.calculateClaimRefund(myFaction.getLandRounded()); + + if(Conf.bankFactionPaysLandCosts) + { + if ( ! Econ.modifyMoney(myFaction, refund, "to unclaim this land", "for unclaiming this land")) return; + } + else + { + if ( ! Econ.modifyMoney(fme , refund, "to unclaim this land", "for unclaiming this land")) return; + } + + /* // a real refund if (refund > 0.0) { @@ -133,10 +144,11 @@ public class CmdUnclaim extends FCommand { moneyBack = ""; } + */ } Board.removeAt(flocation); - myFaction.msg("%s unclaimed some land."+moneyBack, fme.getNameAndRelevant(myFaction)); + myFaction.msg("%s unclaimed some land.", fme.getNameAndRelevant(myFaction)); } } diff --git a/src/com/massivecraft/factions/cmd/CmdUnclaimall.java b/src/com/massivecraft/factions/cmd/CmdUnclaimall.java index e798bb4e..2dd9bc78 100644 --- a/src/com/massivecraft/factions/cmd/CmdUnclaimall.java +++ b/src/com/massivecraft/factions/cmd/CmdUnclaimall.java @@ -3,7 +3,6 @@ package com.massivecraft.factions.cmd; import com.massivecraft.factions.Board; import com.massivecraft.factions.Conf; import com.massivecraft.factions.integration.Econ; -import com.massivecraft.factions.Faction; import com.massivecraft.factions.struct.Permission; public class CmdUnclaimall extends FCommand @@ -28,8 +27,18 @@ public class CmdUnclaimall extends FCommand @Override public void perform() { - String moneyBack = ""; - if (Econ.shouldBeUsed()) + double refund = Econ.calculateTotalLandRefund(myFaction.getLandRounded()); + if(Conf.bankFactionPaysLandCosts) + { + if ( ! Econ.modifyMoney(myFaction, refund, "to unclaim all faction land", "for unclaiming all faction land")) return; + } + else + { + 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 @@ -76,10 +85,10 @@ public class CmdUnclaimall extends FCommand { moneyBack = ""; } - } + }*/ Board.unclaimAll(myFaction.getId()); - myFaction.msg("%s unclaimed ALL of your faction's land."+moneyBack, fme.getNameAndRelevant(myFaction)); + myFaction.msg("%s unclaimed ALL of your faction's land.", fme.getNameAndRelevant(myFaction)); } } diff --git a/src/com/massivecraft/factions/cmd/FCommand.java b/src/com/massivecraft/factions/cmd/FCommand.java index de74c4ca..0feb45fb 100644 --- a/src/com/massivecraft/factions/cmd/FCommand.java +++ b/src/com/massivecraft/factions/cmd/FCommand.java @@ -273,22 +273,17 @@ public abstract class FCommand extends MCommand

} // if economy is enabled and they're not on the bypass list, make 'em pay; returns true unless person can't afford the cost - public boolean payForCommand(double cost) + public boolean payForCommand(double cost, String toDoThis, String forDoingThis) { - if ( ! Econ.shouldBeUsed() || this.fme == null || cost == 0.0 || fme.isAdminBypassing()) - { - return true; - } - - String desc = this.getHelpShort().toLowerCase(); + if ( ! Econ.shouldBeUsed() || this.fme == null || cost == 0.0 || fme.isAdminBypassing()) return true; if(Conf.bankFactionPaysLandCosts && fme.hasFaction()) { - if ( ! Econ.modifyMoney(myFaction, -cost, "to "+desc, "for "+desc)) return false; + if ( ! Econ.modifyMoney(myFaction, -cost, toDoThis, forDoingThis)) return false; } else { - if ( ! Econ.modifyMoney(fme, -cost, "to "+desc, "for "+desc)) return false; + if ( ! Econ.modifyMoney(fme, -cost, toDoThis, forDoingThis)) return false; } return true; /* diff --git a/src/com/massivecraft/factions/cmd/FRelationCommand.java b/src/com/massivecraft/factions/cmd/FRelationCommand.java index 7602e861..e2636faa 100644 --- a/src/com/massivecraft/factions/cmd/FRelationCommand.java +++ b/src/com/massivecraft/factions/cmd/FRelationCommand.java @@ -46,7 +46,7 @@ public abstract class FRelationCommand extends FCommand } // if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay - if ( ! payForCommand(targetRelation.getRelationCost())) return; + if ( ! payForCommand(targetRelation.getRelationCost(), "to change a relation wish", "for changing a relation wish")) return; myFaction.setRelationWish(them, targetRelation); Relation currentRelation = myFaction.getRelationTo(them, true); diff --git a/src/com/massivecraft/factions/integration/Econ.java b/src/com/massivecraft/factions/integration/Econ.java index 5b168740..366f1ad3 100644 --- a/src/com/massivecraft/factions/integration/Econ.java +++ b/src/com/massivecraft/factions/integration/Econ.java @@ -28,12 +28,12 @@ public class Econ public static boolean shouldBeUsed() { - return Conf.econEnabled && getMethod() != null; + return Conf.econEnabled && register != null && register.isEnabled() && getMethod() != null; } public static boolean isSetup() { - return register != null && register.isEnabled(); + return register != null; } public static void doSetup() @@ -41,17 +41,20 @@ public class Econ if (isSetup()) return; Plugin plug = Bukkit.getServer().getPluginManager().getPlugin("Register"); - if (plug != null && plug.getClass().getName().equals("com.nijikokun.register.Register") && plug.isEnabled()) + + if (plug != null && plug.getClass().getName().equals("com.nijikokun.register.Register")) { - P.p.log("Integration with Register (economy): successful"); + register = (Register)plug; + + P.p.log("Economy integration through register successful."); if ( ! Conf.econEnabled) { - P.p.log("NOTE: Economy is disabled. Enable in conf \"econRegisterEnabled\": true"); + P.p.log("NOTE: Economy is disabled. Enable in conf \"econEnabled\": true"); } } else { - P.p.log("Integration with Register (economy): failed"); + P.p.log("Economy integration failed. The plugin \"Register\" is not installed."); } P.p.cmdBase.cmdHelp.updateHelp(); @@ -118,6 +121,10 @@ public class Econ //Faction fInvoker = RelationUtil.getFaction(invoker); // Is there enough money for the transaction to happen? + + P.p.log("from "+from); + P.p.log("from.getAccount() "+from.getAccount()); + if ( ! from.getAccount().hasEnough(amount)) { // There was not enough money to pay @@ -140,13 +147,13 @@ public class Econ } else if (invoker == from || invoker == to) { - from.msg("%s transfered %s to %s.", from.describeTo(from), moneyString(amount), to.describeTo(from)); - to.msg ("%s transfered %s to %s.", from.describeTo(to), moneyString(amount), to.describeTo(to)); + from.msg("%s transfered %s to %s.", from.describeTo(from, true), moneyString(amount), to.describeTo(from)); + to.msg ("%s transfered %s to %s.", from.describeTo(to, true), moneyString(amount), to.describeTo(to)); } else { - from.msg("%s was transfered from %s to %s by %s.", moneyString(amount), from.describeTo(from), to.describeTo(from), invoker.describeTo(from)); - to.msg ("%s was transfered from %s to %s by %s.", moneyString(amount), from.describeTo(to), to.describeTo(to), invoker.describeTo(to)); + from.msg("%s was transfered from %s to %s by %s.", moneyString(amount), from.describeTo(from), to.describeTo(from), invoker.describeTo(from)); + to.msg ("%s was transfered from %s to %s by %s.", moneyString(amount), from.describeTo(to), to.describeTo(to), invoker.describeTo(to)); } return true; @@ -163,7 +170,7 @@ public class Econ // There is no risk of failure acc.add(delta); modifyUniverseMoney(-delta); - ep.msg("% gained %s %s.", You, moneyString(delta), forDoingThis); + ep.msg("%s gained %s %s.", You, moneyString(delta), forDoingThis); return true; } else @@ -176,13 +183,13 @@ public class Econ // There is enough money to pay acc.add(delta); modifyUniverseMoney(-delta); - ep.msg("% lost %s %s.", You, moneyString(-delta), forDoingThis); + ep.msg("%s lost %s %s.", You, moneyString(-delta), forDoingThis); return true; } else { // There was not enough money to pay - ep.msg("% can't afford %s %s.", You, moneyString(-delta), toDoThis); + ep.msg("%s can't afford %s %s.", You, moneyString(-delta), toDoThis); return false; } } diff --git a/src/com/massivecraft/factions/util/RelationUtil.java b/src/com/massivecraft/factions/util/RelationUtil.java index 77dfa542..089b7470 100644 --- a/src/com/massivecraft/factions/util/RelationUtil.java +++ b/src/com/massivecraft/factions/util/RelationUtil.java @@ -13,32 +13,32 @@ public class RelationUtil public static String describeThatToMe(RelationParticipator that, RelationParticipator me, boolean ucfirst) { String ret = ""; - - Faction fthat = getFaction(that); - if (fthat == null) return "ERROR"; // ERROR - - Faction fme = getFaction(me); - if (fme == null) return "ERROR"; // ERROR - + + Faction thatFaction = getFaction(that); + if (thatFaction == null) return "ERROR"; // ERROR + + Faction myFaction = getFaction(me); + if (myFaction == null) return "ERROR"; // ERROR + if (that instanceof Faction) { - if (me instanceof FPlayer && fme == fthat) + if (me instanceof FPlayer && myFaction == thatFaction) { ret = "your faction"; } else { - ret = "the faction "+fthat.getTag(); + ret = "the faction " + thatFaction.getTag(); } } - else if(that instanceof FPlayer) + else if (that instanceof FPlayer) { - FPlayer fplayerthat = (FPlayer)that; + FPlayer fplayerthat = (FPlayer) that; if (that == me) { ret = "you"; } - else if (fthat == fme) + else if (thatFaction == myFaction) { ret = fplayerthat.getNameAndTitle(); } @@ -47,73 +47,77 @@ public class RelationUtil ret = fplayerthat.getNameAndTag(); } } - + if (ucfirst) { ret = TextUtil.upperCaseFirst(ret); } - - return ""+getRelationColor(me, that)+ret; + + return "" + getRelationColor(me, that) + ret; } - - public static String describeThatToMe(RelationParticipator that, RelationParticipator me) + + public static String describeThatToMe(RelationParticipator that, + RelationParticipator me) { return describeThatToMe(that, me, false); } - - public static Relation getRelationTo(RelationParticipator me, RelationParticipator that) + + public static Relation getRelationTo(RelationParticipator me, + RelationParticipator that) { return getRelationTo(that, me, false); } - - public static Relation getRelationTo(RelationParticipator me, RelationParticipator that, boolean ignorePeaceful) + + public static Relation getRelationTo(RelationParticipator me, + RelationParticipator that, boolean ignorePeaceful) { Faction fthat = getFaction(that); if (fthat == null) return Relation.NEUTRAL; // ERROR - + Faction fme = getFaction(me); if (fme == null) return Relation.NEUTRAL; // ERROR - - if ( ! fthat.isNormal() || ! fme.isNormal()) + + if (!fthat.isNormal() || !fme.isNormal()) { return Relation.NEUTRAL; } - + if (fthat.equals(fme)) { return Relation.MEMBER; } - - if ( ! ignorePeaceful && (fme.isPeaceful() || fthat.isPeaceful())) + + if (!ignorePeaceful && (fme.isPeaceful() || fthat.isPeaceful())) { return Relation.NEUTRAL; } - - if(fme.getRelationWish(fthat).value >= fthat.getRelationWish(fme).value) + + if (fme.getRelationWish(fthat).value >= fthat.getRelationWish(fme).value) { return fthat.getRelationWish(fme); } - + return fme.getRelationWish(fthat); } - + public static Faction getFaction(RelationParticipator rp) { if (rp instanceof Faction) { - return (Faction)rp; + return (Faction) rp; } - + if (rp instanceof FPlayer) { - return ((FPlayer)rp).getFaction(); + return ((FPlayer) rp).getFaction(); } - + // ERROR return null; } - - public static ChatColor getRelationColor(RelationParticipator me, RelationParticipator that) + + public static ChatColor getRelationColor(RelationParticipator me, + RelationParticipator that) { return getRelationTo(that, me).getColor(); }