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();
}