Some of the bugs are fixed.
This commit is contained in:
parent
2566edfd8c
commit
f25daa228a
@ -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());
|
||||
}
|
||||
|
@ -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();
|
||||
|
||||
|
@ -48,7 +48,7 @@ public class CmdBalance extends FCommand
|
||||
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()));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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()));
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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, " "));
|
||||
|
||||
|
@ -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());
|
||||
}
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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("<i>You successfully joined %s", faction.getTag(fme));
|
||||
faction.msg("<i>%s joined your faction.", fme.getNameAndRelevant(faction));
|
||||
|
@ -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<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));
|
||||
|
@ -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<Faction> factionList = new ArrayList<Faction>(Factions.i.get());
|
||||
factionList.remove(Factions.i.getNone());
|
||||
|
@ -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("<i>Map auto update <green>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();
|
||||
}
|
||||
|
@ -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()));
|
||||
|
||||
|
@ -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("<i>You have added %s<i> to the owner list for this claimed land.", playerName);
|
||||
|
@ -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<a> - Power / Maxpower: <i>%d / %d", target.getNameAndRelevant(fme), target.getPowerRounded(), target.getPowerMaxRounded());
|
||||
}
|
||||
|
@ -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());
|
||||
|
||||
|
@ -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<FPlayer> admins = faction.getFPlayersWhereRole(Role.ADMIN);
|
||||
Collection<FPlayer> mods = faction.getFPlayersWhereRole(Role.MODERATOR);
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
||||
|
@ -86,10 +86,21 @@ public class CmdUnclaim extends FCommand
|
||||
return;
|
||||
}
|
||||
|
||||
String moneyBack = "<i>";
|
||||
if (Econ.enabled())
|
||||
//String moneyBack = "<i>";
|
||||
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<i> unclaimed some land."+moneyBack, fme.getNameAndRelevant(myFaction));
|
||||
myFaction.msg("%s<i> unclaimed some land.", fme.getNameAndRelevant(myFaction));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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 = "<i>";
|
||||
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 = "<i>";
|
||||
/*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<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));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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
|
||||
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;
|
||||
/*
|
||||
|
@ -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);
|
||||
|
@ -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("<h>%s<i> transfered <h>%s<i> to <h>%s<i>.", from.describeTo(from), 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));
|
||||
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, true), moneyString(amount), to.describeTo(to));
|
||||
}
|
||||
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));
|
||||
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));
|
||||
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<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;
|
||||
@ -163,7 +170,7 @@ public class Econ
|
||||
// There is no risk of failure
|
||||
acc.add(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;
|
||||
}
|
||||
else
|
||||
@ -176,13 +183,13 @@ public class Econ
|
||||
// There is enough money to pay
|
||||
acc.add(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;
|
||||
}
|
||||
else
|
||||
{
|
||||
// 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;
|
||||
}
|
||||
}
|
||||
|
@ -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();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user