Some of the bugs are fixed.

This commit is contained in:
Olof Larsson 2011-10-12 18:48:47 +02:00
parent 2566edfd8c
commit f25daa228a
25 changed files with 132 additions and 105 deletions

View File

@ -123,6 +123,7 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator
// FIELD: account // FIELD: account
public MethodAccount getAccount() public MethodAccount getAccount()
{ {
P.p.log("Econ.shouldBeUsed() "+Econ.shouldBeUsed());
if ( ! Econ.shouldBeUsed()) return null; if ( ! Econ.shouldBeUsed()) return null;
return Econ.getMethod().getAccount(this.getId()); return Econ.getMethod().getAccount(this.getId());
} }

View File

@ -113,9 +113,19 @@ public class Faction extends Entity implements EconomyParticipator
// FIELD: account (fake field) // FIELD: account (fake field)
// Bank functions // Bank functions
public double money; // Deprecated TODO: Hantera. public double money; // Deprecated TODO: Hantera.
public String getAccountId() { return "faction-"+this.getId(); }
public MethodAccount getAccount() 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; } /*public double getMoney() { return this.money; }
@ -727,6 +737,13 @@ public class Faction extends Entity implements EconomyParticipator
@Override @Override
public void postDetach() public void postDetach()
{ {
if (Econ.shouldBeUsed())
{
Econ.getMethod().getAccount(getAccountId()).remove();
}
this.getAccountId();
// Clean the board // Clean the board
Board.clean(); Board.clean();

View File

@ -48,7 +48,7 @@ public class CmdBalance extends FCommand
return; return;
} }
msg("<a>%s balance: %s", faction.getTag(fme), Econ.moneyString(faction.getAccount().balance())); msg("<a>%s<i> balance: <h>%s", faction.getTag(fme), Econ.moneyString(faction.getAccount().balance()));
} }
} }

View File

@ -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 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())); myFaction.setPeacefulExplosionsEnabled(this.argAsBool(0, ! myFaction.getPeacefulExplosionsEnabled()));

View File

@ -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 economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay
if (!payForCommand(Conf.econCostCreate)) if ( ! payForCommand(Conf.econCostCreate, "to create a new faction", "for creating a new faction")) return;
{
return;
}
Faction faction = Factions.i.create(); Faction faction = Factions.i.create();
faction.setTag(tag); faction.setTag(tag);

View File

@ -30,10 +30,7 @@ public class CmdDescription extends FCommand
public void perform() 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 economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay
if ( ! payForCommand(Conf.econCostDesc)) if ( ! payForCommand(Conf.econCostDesc, "to change faction description", "for changing faction description")) return;
{
return;
}
myFaction.setDescription(TextUtil.implode(args, " ")); myFaction.setDescription(TextUtil.implode(args, " "));

View File

@ -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 economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay
if ( ! payForCommand(Conf.econCostHome)) if ( ! payForCommand(Conf.econCostHome, "to change faction home", "for changing faction home")) return;
{
return;
}
me.teleport(myFaction.getHome()); me.teleport(myFaction.getHome());
} }

View File

@ -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 economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay
if ( ! payForCommand(Conf.econCostInvite)) if ( ! payForCommand(Conf.econCostInvite, "to invite someone", "for inviting someone")) return;
{
return;
}
myFaction.invite(you); myFaction.invite(you);

View File

@ -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 economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay
if (!payForCommand(Conf.econCostJoin)) if ( ! payForCommand(Conf.econCostJoin, "to join a faction", "for joining a faction")) return;
{
return;
}
fme.msg("<i>You successfully joined %s", faction.getTag(fme)); fme.msg("<i>You successfully joined %s", faction.getTag(fme));
faction.msg("<i>%s joined your faction.", fme.getNameAndRelevant(faction)); faction.msg("<i>%s joined your faction.", fme.getNameAndRelevant(faction));

View File

@ -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 economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay
if ( ! payForCommand(Conf.econCostKick)) if ( ! payForCommand(Conf.econCostKick, "to kick someone from the faction", "for kicking someone from the faction")) return;
{
return;
}
yourFaction.msg("%s<i> kicked %s<i> from the faction! :O", fme.getNameAndRelevant(yourFaction), you.getNameAndRelevant(yourFaction)); yourFaction.msg("%s<i> kicked %s<i> from the faction! :O", fme.getNameAndRelevant(yourFaction), you.getNameAndRelevant(yourFaction));
you.msg("%s<i> kicked you from %s<i>! :O", fme.getNameAndRelevant(you), yourFaction.getTag(you)); you.msg("%s<i> kicked you from %s<i>! :O", fme.getNameAndRelevant(you), yourFaction.getTag(you));

View File

@ -35,7 +35,7 @@ public class CmdList extends FCommand
public void perform() 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 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<Faction> factionList = new ArrayList<Faction>(Factions.i.get()); ArrayList<Faction> factionList = new ArrayList<Faction>(Factions.i.get());
factionList.remove(Factions.i.getNone()); factionList.remove(Factions.i.getNone());

View File

@ -35,7 +35,7 @@ public class CmdMap extends FCommand
// Turn on // Turn on
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay // 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); fme.setMapAutoUpdating(true);
msg("<i>Map auto update <green>ENABLED."); msg("<i>Map auto update <green>ENABLED.");
@ -53,7 +53,7 @@ public class CmdMap extends FCommand
else else
{ {
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay // 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(); showMap();
} }

View File

@ -28,7 +28,7 @@ public class CmdOpen extends FCommand
public void perform() 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 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())); myFaction.setOpen(this.argAsBool(0, ! myFaction.getOpen()));

View File

@ -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 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); myFaction.setPlayerAsOwner(playerName, flocation);
fme.msg("<i>You have added %s<i> to the owner list for this claimed land.", playerName); fme.msg("<i>You have added %s<i> to the owner list for this claimed land.", playerName);

View File

@ -34,7 +34,7 @@ public class CmdPower extends FCommand
if (target != me && ! Permission.POWER_ANY.has(sender, true)) return; 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 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<a> - Power / Maxpower: <i>%d / %d", target.getNameAndRelevant(fme), target.getPowerRounded(), target.getPowerMaxRounded()); msg("%s<a> - Power / Maxpower: <i>%d / %d", target.getNameAndRelevant(fme), target.getPowerRounded(), target.getPowerMaxRounded());
} }

View File

@ -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 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()); faction.setHome(me.getLocation());

View File

@ -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 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<FPlayer> admins = faction.getFPlayersWhereRole(Role.ADMIN); Collection<FPlayer> admins = faction.getFPlayersWhereRole(Role.ADMIN);
Collection<FPlayer> mods = faction.getFPlayersWhereRole(Role.MODERATOR); Collection<FPlayer> mods = faction.getFPlayersWhereRole(Role.MODERATOR);

View File

@ -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 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(); String oldtag = myFaction.getTag();
myFaction.setTag(tag); myFaction.setTag(tag);

View File

@ -36,7 +36,7 @@ public class CmdTitle extends FCommand
if ( ! canIAdministerYou(fme, you)) return; 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 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); you.setTitle(title);

View File

@ -86,10 +86,21 @@ public class CmdUnclaim extends FCommand
return; return;
} }
String moneyBack = "<i>"; //String moneyBack = "<i>";
if (Econ.enabled()) if (Econ.shouldBeUsed())
{ {
double refund = Econ.calculateClaimRefund(myFaction.getLandRounded()); 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 // a real refund
if (refund > 0.0) if (refund > 0.0)
{ {
@ -133,10 +144,11 @@ public class CmdUnclaim extends FCommand
{ {
moneyBack = ""; moneyBack = "";
} }
*/
} }
Board.removeAt(flocation); Board.removeAt(flocation);
myFaction.msg("%s<i> unclaimed some land."+moneyBack, fme.getNameAndRelevant(myFaction)); myFaction.msg("%s<i> unclaimed some land.", fme.getNameAndRelevant(myFaction));
} }
} }

View File

@ -3,7 +3,6 @@ package com.massivecraft.factions.cmd;
import com.massivecraft.factions.Board; import com.massivecraft.factions.Board;
import com.massivecraft.factions.Conf; import com.massivecraft.factions.Conf;
import com.massivecraft.factions.integration.Econ; import com.massivecraft.factions.integration.Econ;
import com.massivecraft.factions.Faction;
import com.massivecraft.factions.struct.Permission; import com.massivecraft.factions.struct.Permission;
public class CmdUnclaimall extends FCommand public class CmdUnclaimall extends FCommand
@ -28,8 +27,18 @@ public class CmdUnclaimall extends FCommand
@Override @Override
public void perform() public void perform()
{ {
String moneyBack = "<i>"; double refund = Econ.calculateTotalLandRefund(myFaction.getLandRounded());
if (Econ.shouldBeUsed()) 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 = "<i>";
/*if (Econ.shouldBeUsed())
{ {
double refund = Econ.calculateTotalLandRefund(myFaction.getLandRounded()); double refund = Econ.calculateTotalLandRefund(myFaction.getLandRounded());
// a real refund // a real refund
@ -76,10 +85,10 @@ public class CmdUnclaimall extends FCommand
{ {
moneyBack = ""; moneyBack = "";
} }
} }*/
Board.unclaimAll(myFaction.getId()); Board.unclaimAll(myFaction.getId());
myFaction.msg("%s<i> unclaimed ALL of your faction's land."+moneyBack, fme.getNameAndRelevant(myFaction)); myFaction.msg("%s<i> unclaimed ALL of your faction's land.", fme.getNameAndRelevant(myFaction));
} }
} }

View File

@ -273,22 +273,17 @@ public abstract class FCommand extends MCommand<P>
} }
// if economy is enabled and they're not on the bypass list, make 'em pay; returns true unless person can't afford the cost // 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()) if ( ! Econ.shouldBeUsed() || this.fme == null || cost == 0.0 || fme.isAdminBypassing()) return true;
{
return true;
}
String desc = this.getHelpShort().toLowerCase();
if(Conf.bankFactionPaysLandCosts && fme.hasFaction()) 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 else
{ {
if ( ! Econ.modifyMoney(fme, -cost, "to "+desc, "for "+desc)) return false; if ( ! Econ.modifyMoney(fme, -cost, toDoThis, forDoingThis)) return false;
} }
return true; return true;
/* /*

View File

@ -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 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); myFaction.setRelationWish(them, targetRelation);
Relation currentRelation = myFaction.getRelationTo(them, true); Relation currentRelation = myFaction.getRelationTo(them, true);

View File

@ -28,12 +28,12 @@ public class Econ
public static boolean shouldBeUsed() public static boolean shouldBeUsed()
{ {
return Conf.econEnabled && getMethod() != null; return Conf.econEnabled && register != null && register.isEnabled() && getMethod() != null;
} }
public static boolean isSetup() public static boolean isSetup()
{ {
return register != null && register.isEnabled(); return register != null;
} }
public static void doSetup() public static void doSetup()
@ -41,17 +41,20 @@ public class Econ
if (isSetup()) return; if (isSetup()) return;
Plugin plug = Bukkit.getServer().getPluginManager().getPlugin("Register"); 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) 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 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(); P.p.cmdBase.cmdHelp.updateHelp();
@ -118,6 +121,10 @@ public class Econ
//Faction fInvoker = RelationUtil.getFaction(invoker); //Faction fInvoker = RelationUtil.getFaction(invoker);
// Is there enough money for the transaction to happen? // 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)) if ( ! from.getAccount().hasEnough(amount))
{ {
// There was not enough money to pay // There was not enough money to pay
@ -140,13 +147,13 @@ public class Econ
} }
else if (invoker == from || invoker == to) else if (invoker == from || invoker == to)
{ {
from.msg("<h>%s<i> transfered <h>%s<i> to <h>%s<i>.", from.describeTo(from), moneyString(amount), to.describeTo(from)); from.msg("<h>%s<i> transfered <h>%s<i> to <h>%s<i>.", from.describeTo(from, true), moneyString(amount), to.describeTo(from));
to.msg ("<h>%s<i> transfered <h>%s<i> to <h>%s<i>.", from.describeTo(to), moneyString(amount), to.describeTo(to)); to.msg ("<h>%s<i> transfered <h>%s<i> to <h>%s<i>.", from.describeTo(to, true), moneyString(amount), to.describeTo(to));
} }
else else
{ {
from.msg("<h>%s<b> was transfered from <h>%s<b> to <h>%s<b> by <h>%s<g>.", moneyString(amount), from.describeTo(from), to.describeTo(from), invoker.describeTo(from)); from.msg("<h>%s<i> was transfered from <h>%s<i> to <h>%s<i> by <h>%s<i>.", moneyString(amount), from.describeTo(from), to.describeTo(from), invoker.describeTo(from));
to.msg ("<h>%s<g> was transfered from <h>%s<g> to <h>%s<g> by <h>%s<g>.", moneyString(amount), from.describeTo(to), to.describeTo(to), invoker.describeTo(to)); to.msg ("<h>%s<i> was transfered from <h>%s<i> to <h>%s<i> by <h>%s<i>.", moneyString(amount), from.describeTo(to), to.describeTo(to), invoker.describeTo(to));
} }
return true; return true;
@ -163,7 +170,7 @@ public class Econ
// There is no risk of failure // There is no risk of failure
acc.add(delta); acc.add(delta);
modifyUniverseMoney(-delta); modifyUniverseMoney(-delta);
ep.msg("<h>%<g> gained %s<i> %s.", You, moneyString(delta), forDoingThis); ep.msg("<h>%s<i> gained <h>%s<i> %s.", You, moneyString(delta), forDoingThis);
return true; return true;
} }
else else
@ -176,13 +183,13 @@ public class Econ
// There is enough money to pay // There is enough money to pay
acc.add(delta); acc.add(delta);
modifyUniverseMoney(-delta); modifyUniverseMoney(-delta);
ep.msg("<h>%<b> lost %s<i> %s.", You, moneyString(-delta), forDoingThis); ep.msg("<h>%s<i> lost <h>%s<i> %s.", You, moneyString(-delta), forDoingThis);
return true; return true;
} }
else else
{ {
// There was not enough money to pay // There was not enough money to pay
ep.msg("<h>%<g> can't afford %s<i> %s.", You, moneyString(-delta), toDoThis); ep.msg("<h>%s<i> can't afford <h>%s<i> %s.", You, moneyString(-delta), toDoThis);
return false; return false;
} }
} }

View File

@ -14,31 +14,31 @@ public class RelationUtil
{ {
String ret = ""; String ret = "";
Faction fthat = getFaction(that); Faction thatFaction = getFaction(that);
if (fthat == null) return "ERROR"; // ERROR if (thatFaction == null) return "ERROR"; // ERROR
Faction fme = getFaction(me); Faction myFaction = getFaction(me);
if (fme == null) return "ERROR"; // ERROR if (myFaction == null) return "ERROR"; // ERROR
if (that instanceof Faction) if (that instanceof Faction)
{ {
if (me instanceof FPlayer && fme == fthat) if (me instanceof FPlayer && myFaction == thatFaction)
{ {
ret = "your faction"; ret = "your faction";
} }
else 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) if (that == me)
{ {
ret = "you"; ret = "you";
} }
else if (fthat == fme) else if (thatFaction == myFaction)
{ {
ret = fplayerthat.getNameAndTitle(); ret = fplayerthat.getNameAndTitle();
} }
@ -53,20 +53,23 @@ public class RelationUtil
ret = TextUtil.upperCaseFirst(ret); 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); 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); 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); Faction fthat = getFaction(that);
if (fthat == null) return Relation.NEUTRAL; // ERROR if (fthat == null) return Relation.NEUTRAL; // ERROR
@ -74,7 +77,7 @@ public class RelationUtil
Faction fme = getFaction(me); Faction fme = getFaction(me);
if (fme == null) return Relation.NEUTRAL; // ERROR if (fme == null) return Relation.NEUTRAL; // ERROR
if ( ! fthat.isNormal() || ! fme.isNormal()) if (!fthat.isNormal() || !fme.isNormal())
{ {
return Relation.NEUTRAL; return Relation.NEUTRAL;
} }
@ -84,12 +87,12 @@ public class RelationUtil
return Relation.MEMBER; return Relation.MEMBER;
} }
if ( ! ignorePeaceful && (fme.isPeaceful() || fthat.isPeaceful())) if (!ignorePeaceful && (fme.isPeaceful() || fthat.isPeaceful()))
{ {
return Relation.NEUTRAL; 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 fthat.getRelationWish(fme);
} }
@ -101,19 +104,20 @@ public class RelationUtil
{ {
if (rp instanceof Faction) if (rp instanceof Faction)
{ {
return (Faction)rp; return (Faction) rp;
} }
if (rp instanceof FPlayer) if (rp instanceof FPlayer)
{ {
return ((FPlayer)rp).getFaction(); return ((FPlayer) rp).getFaction();
} }
// ERROR // ERROR
return null; return null;
} }
public static ChatColor getRelationColor(RelationParticipator me, RelationParticipator that) public static ChatColor getRelationColor(RelationParticipator me,
RelationParticipator that)
{ {
return getRelationTo(that, me).getColor(); return getRelationTo(that, me).getColor();
} }