Moving over to the use of describeTo.

This commit is contained in:
Olof Larsson 2011-10-21 19:20:33 +02:00
parent 51161bbb55
commit 46f5849f9f
26 changed files with 55 additions and 84 deletions

View File

@ -16,6 +16,11 @@ 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;
// Power
public static double powerPlayerMax = 10.0;
public static double powerPlayerMin = -10.0;

View File

@ -319,16 +319,18 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator
return this.getRelationColor(fplayer)+this.getNameAndTitle();
}
public String getNameAndTag(Faction faction)
/*public String getNameAndTag(Faction faction)
{
return this.getRelationColor(faction)+this.getNameAndTag();
}
public String getNameAndTag(FPlayer fplayer)
{
return this.getRelationColor(fplayer)+this.getNameAndTag();
}
}*/
public String getNameAndRelevant(Faction faction)
// TODO: REmovded for refactoring.
/*public String getNameAndRelevant(Faction faction)
{
// Which relation?
Relation rel = this.getRelationTo(faction);
@ -344,7 +346,7 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator
public String getNameAndRelevant(FPlayer fplayer)
{
return getNameAndRelevant(fplayer.getFaction());
}
}*/
// Chat Tag:
// These are injected into the format of global chat messages.
@ -773,12 +775,12 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator
{
// ASDF claimed some of your land 450 blocks NNW of you.
// ASDf claimed some land from FACTION NAME
otherFaction.sendMessage(P.p.txt.parse(this.getNameAndRelevant(otherFaction)+"<i> stole some of your land :O"));
myFaction.sendMessage(P.p.txt.parse(this.getNameAndRelevant(myFaction)+"<i> claimed some land from "+otherFaction.getTag(myFaction)));
otherFaction.msg("%s<i> stole some of your land :O", this.describeTo(otherFaction, true));
myFaction.msg("%s<i> claimed some land from %s.", this.describeTo(myFaction, true), otherFaction.describeTo(myFaction));
}
else
{
myFaction.sendMessage(P.p.txt.parse(this.getNameAndRelevant(myFaction)+"<i> claimed some new land :D"));
myFaction.msg("%s<i> claimed some new land :D", this.describeTo(myFaction));
}
Board.setFactionAt(myFaction, flocation);

View File

@ -81,30 +81,4 @@ public class FPlayers extends PlayerEntityCollection<FPlayer>
}
return null;
}
/*public Set<VPlayer> findAllOnlineInfected()
{
Set<VPlayer> vplayers = new HashSet<VPlayer>();
for (VPlayer vplayer : this.getOnline())
{
if (vplayer.isInfected())
{
vplayers.add(vplayer);
}
}
return vplayers;
}
public Set<VPlayer> findAllOnlineVampires()
{
Set<VPlayer> vplayers = new HashSet<VPlayer>();
for (VPlayer vplayer : this.getOnline())
{
if (vplayer.isVampire())
{
vplayers.add(vplayer);
}
}
return vplayers;
}*/
}

View File

@ -103,10 +103,6 @@ public class Factions extends EntityCollection<Faction>
}
//----------------------------------------------//
// Faction tag
//----------------------------------------------//
@ -117,19 +113,19 @@ public class Factions extends EntityCollection<Faction>
if(MiscUtil.getComparisonString(str).length() < Conf.factionTagLengthMin)
{
errors.add(P.p.txt.parse("<i>The faction tag can't be shorter than "+Conf.factionTagLengthMin+ " chars."));
errors.add(P.p.txt.parse("<i>The faction tag can't be shorter than <h>%s<i> chars.", Conf.factionTagLengthMin));
}
if(str.length() > Conf.factionTagLengthMax)
{
errors.add(P.p.txt.parse("<i>The faction tag can't be longer than "+Conf.factionTagLengthMax+ " chars."));
errors.add(P.p.txt.parse("<i>The faction tag can't be longer than <h>%s<i> chars.", Conf.factionTagLengthMax));
}
for (char c : str.toCharArray())
{
if ( ! MiscUtil.substanceChars.contains(String.valueOf(c)))
{
errors.add(P.p.txt.parse("<i>Faction tag must be alphanumeric. \""+c+"\" is not allowed."));
errors.add(P.p.txt.parse("<i>Faction tag must be alphanumeric. \"<h>%s<i>\" is not allowed.", c));
}
}

View File

@ -32,7 +32,7 @@ public class CmdAdmin extends FCommand
if (fyou.getFaction() != myFaction)
{
msg("%s<i> is not a member in your faction.", fyou.getNameAndRelevant(fme));
msg("%s<i> is not a member in your faction.", fyou.describeTo(fme, true));
return;
}
@ -48,14 +48,7 @@ public class CmdAdmin extends FCommand
// Inform all players
for (FPlayer fplayer : FPlayers.i.getOnline())
{
if (fplayer.getFaction() == myFaction)
{
fplayer.msg("%s<i> gave %s<i> the leadership of your faction.", fme.getNameAndRelevant(fme), fyou.getNameAndRelevant(fme));
}
else
{
fplayer.msg("%s<i> gave %s<i> the leadership of %s", fme.getNameAndRelevant(fplayer), fyou.getNameAndRelevant(fplayer), myFaction.getTag(fplayer));
}
fplayer.msg("%s<i> gave %s<i> the leadership of %s", fme.describeTo(fplayer, true), fyou.describeTo(fplayer), myFaction.describeTo(fplayer));
}
}

View File

@ -59,6 +59,7 @@ public class CmdCreate extends FCommand
Faction faction = Factions.i.create();
// TODO: Why would this even happen???
if (faction == null)
{
msg("<b>There was an internal error while trying to create your faction. Please try again.");
@ -71,7 +72,7 @@ public class CmdCreate extends FCommand
for (FPlayer follower : FPlayers.i.getOnline())
{
follower.msg("%s<i> created a new faction %s", fme.getNameAndRelevant(follower), faction.getTag(follower));
follower.msg("%s<i> created a new faction %s", fme.describeTo(follower, true), faction.getTag(follower));
}
msg("<i>You should now: %s", p.cmdBase.cmdDescription.getUseageTemplate());

View File

@ -39,8 +39,9 @@ public class CmdDeinvite extends FCommand
myFaction.deinvite(you);
you.msg("%s<i> revoked your invitation to %s", fme.getNameAndRelevant(you), myFaction.getTag(you));
myFaction.msg("%s<i> revoked %s's<i> invitation.", fme.getNameAndRelevant(fme), you.getNameAndRelevant(fme));
you.msg("%s<i> revoked your invitation to <h>%s<i>.", fme.describeTo(you), myFaction.describeTo(you));
myFaction.msg("%s<i> revoked %s's<i> invitation.", fme.describeTo(myFaction), you.describeTo(myFaction));
}
}

View File

@ -37,7 +37,7 @@ public class CmdDescription extends FCommand
// Broadcast the description to everyone
for (FPlayer fplayer : FPlayers.i.getOnline())
{
fplayer.msg("<i>The faction "+fplayer.getRelationColor(fme)+myFaction.getTag()+"<i> changed their description to:");
fplayer.msg("<i>The faction %s<i> changed their description to:", myFaction.describeTo(fplayer));
fplayer.msg("<h>"+myFaction.getDescription());
}
}

View File

@ -59,7 +59,7 @@ public class CmdDisband extends FCommand
// Inform all players
for (FPlayer fplayer : FPlayers.i.getOnline())
{
String who = senderIsConsole ? "A server admin" : fme.getNameAndRelevant(fplayer);
String who = senderIsConsole ? "A server admin" : fme.describeTo(fplayer);
if (fplayer.getFaction() == faction)
{
fplayer.msg("<h>%s<i> disbanded your faction.", who);

View File

@ -42,8 +42,8 @@ public class CmdInvite extends FCommand
myFaction.invite(you);
you.msg("%s<i> invited you to %s", fme.getNameAndRelevant(you), myFaction.getTag(you));
myFaction.msg("%s<i> invited %s<i> to your faction.", fme.getNameAndRelevant(fme), you.getNameAndRelevant(fme));
you.msg("%s<i> invited you to %s", fme.describeTo(you, true), myFaction.describeTo(you));
myFaction.msg("%s<i> invited %s<i> to your faction.", fme.describeTo(myFaction, true), you.describeTo(myFaction));
}
}

View File

@ -56,7 +56,7 @@ public class CmdJoin extends FCommand
if( ! (faction.getOpen() || faction.isInvited(fme) || fme.isAdminBypassing()))
{
msg("<i>This faction requires invitation.");
faction.msg("%s<i> tried to join your faction.", fme.getNameAndRelevant(faction));
faction.msg("%s<i> tried to join your faction.", fme.describeTo(faction, true));
return;
}
@ -64,7 +64,7 @@ public class CmdJoin extends FCommand
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));
faction.msg("<i>%s joined your faction.", fme.describeTo(faction, true));
fme.resetFactionData();
fme.setFaction(faction);

View File

@ -46,7 +46,7 @@ public class CmdKick extends FCommand
{
if (yourFaction != myFaction)
{
msg("%s<b> is not a member of %s", you.getNameAndRelevant(fme), myFaction.getTag(fme));
msg("%s<b> is not a member of %s", you.describeTo(fme, true), myFaction.describeTo(fme));
return;
}
@ -67,11 +67,11 @@ 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, "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));
yourFaction.msg("%s<i> kicked %s<i> from the faction! :O", fme.describeTo(yourFaction, true), you.describeTo(yourFaction, true));
you.msg("%s<i> kicked you from %s<i>! :O", fme.describeTo(you, true), yourFaction.describeTo(you));
if (yourFaction != myFaction)
{
fme.msg("<i>You kicked %s<i> from the faction %s<i>!", you.getNameAndRelevant(myFaction), yourFaction.getTag(fme));
fme.msg("<i>You kicked %s<i> from the faction %s<i>!", you.describeTo(fme), yourFaction.describeTo(fme));
}
yourFaction.deinvite(you);

View File

@ -32,7 +32,7 @@ public class CmdMod extends FCommand
if (you.getFaction() != myFaction)
{
msg("%s<b> is not a member in your faction.", you.getNameAndRelevant(fme));
msg("%s<b> is not a member in your faction.", you.describeTo(fme, true));
return;
}
@ -46,13 +46,13 @@ public class CmdMod extends FCommand
{
// Revoke
you.setRole(Role.NORMAL);
myFaction.msg("%s<i> is no longer moderator in your faction.", you.getNameAndRelevant(myFaction));
myFaction.msg("%s<i> is no longer moderator in your faction.", you.describeTo(myFaction, true));
}
else
{
// Give
you.setRole(Role.MODERATOR);
myFaction.msg("%s<i> was promoted to moderator in your faction.", you.getNameAndRelevant(myFaction));
myFaction.msg("%s<i> was promoted to moderator in your faction.", you.describeTo(myFaction, true));
}
}

View File

@ -35,7 +35,7 @@ public class CmdOpen extends FCommand
String open = myFaction.getOpen() ? "open" : "closed";
// Inform
myFaction.msg("%s<i> changed the faction to <h>%s<i>.", fme.getNameAndRelevant(myFaction), open);
myFaction.msg("%s<i> changed the faction to <h>%s<i>.", fme.describeTo(myFaction, true), open);
for (Faction faction : Factions.i.get())
{
if (faction == myFaction)

View File

@ -49,11 +49,11 @@ public class CmdPeaceful extends FCommand
{
if (fplayer.getFaction() == faction)
{
fplayer.msg((fme == null ? "A server admin" : fme.getNameAndRelevant(fplayer))+"<i> has "+change+" your faction.");
fplayer.msg((fme == null ? "A server admin" : fme.describeTo(fplayer, true))+"<i> has "+change+" your faction.");
}
else
{
fplayer.msg((fme == null ? "A server admin" : fme.getNameAndRelevant(fplayer))+"<i> has "+change+" the faction \"" + faction.getTag(fplayer) + "\".");
fplayer.msg((fme == null ? "A server admin" : fme.describeTo(fplayer, true))+"<i> has "+change+" the faction \"" + faction.getTag(fplayer) + "\".");
}
}

View File

@ -48,11 +48,11 @@ public class CmdPermanent extends FCommand
{
if (fplayer.getFaction() == faction)
{
fplayer.msg((fme == null ? "A server admin" : fme.getNameAndRelevant(fplayer))+"<i> has "+change+" your faction.");
fplayer.msg((fme == null ? "A server admin" : fme.describeTo(fplayer, true))+"<i> has "+change+" your faction.");
}
else
{
fplayer.msg((fme == null ? "A server admin" : fme.getNameAndRelevant(fplayer))+"<i> has "+change+" the faction \"" + faction.getTag(fplayer) + "\".");
fplayer.msg((fme == null ? "A server admin" : fme.describeTo(fplayer, true))+"<i> has "+change+" the faction \"" + faction.getTag(fplayer) + "\".");
}
}
}

View File

@ -36,7 +36,7 @@ public class CmdPower 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.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.describeTo(fme, true), target.getPowerRounded(), target.getPowerMaxRounded());
}
}

View File

@ -66,7 +66,7 @@ public class CmdSethome extends FCommand
faction.setHome(me.getLocation());
faction.msg("%s<i> set the home for your faction. You can now use:", fme.getNameAndRelevant(myFaction));
faction.msg("%s<i> set the home for your faction. You can now use:", fme.describeTo(myFaction, true));
faction.sendMessage(p.cmdBase.cmdHome.getUseageTemplate());
if (faction != myFaction)
{

View File

@ -55,7 +55,7 @@ public class CmdTag extends FCommand
myFaction.setTag(tag);
// Inform
myFaction.msg("%s<i> changed your faction tag to %s", fme.getNameAndRelevant(myFaction), myFaction.getTag(myFaction));
myFaction.msg("%s<i> changed your faction tag to %s", fme.describeTo(myFaction, true), myFaction.getTag(myFaction));
for (Faction faction : Factions.i.get())
{
if (faction == myFaction)

View File

@ -41,7 +41,7 @@ public class CmdTitle extends FCommand
you.setTitle(title);
// Inform
myFaction.msg("%s<i> changed a title: %s", fme.getNameAndRelevant(myFaction), you.getNameAndRelevant(myFaction));
myFaction.msg("%s<i> changed a title: %s", fme.describeTo(myFaction, true), you.describeTo(myFaction, true));
if (Conf.spoutFactionTitlesOverNames)
{

View File

@ -64,7 +64,7 @@ public class CmdUnclaim extends FCommand
{
Board.removeAt(flocation);
otherFaction.msg("%s<i> unclaimed some of your land.", fme.getNameAndRelevant(otherFaction));
otherFaction.msg("%s<i> unclaimed some of your land.", fme.describeTo(otherFaction, true));
msg("<i>You unclaimed this land.");
return;
}
@ -148,7 +148,7 @@ public class CmdUnclaim extends FCommand
}
Board.removeAt(flocation);
myFaction.msg("%s<i> unclaimed some land.", fme.getNameAndRelevant(myFaction));
myFaction.msg("%s<i> unclaimed some land.", fme.describeTo(myFaction, true));
}
}

View File

@ -88,7 +88,7 @@ public class CmdUnclaimall extends FCommand
}*/
Board.unclaimAll(myFaction.getId());
myFaction.msg("%s<i> unclaimed ALL of your faction's land.", fme.getNameAndRelevant(myFaction));
myFaction.msg("%s<i> unclaimed ALL of your faction's land.", fme.describeTo(myFaction, true));
}
}

View File

@ -258,7 +258,7 @@ public abstract class FCommand extends MCommand<P>
{
if ( ! i.getFaction().equals(you.getFaction()))
{
i.sendMessage(p.txt.parse("%s <b>is not in the same faction as you.",you.getNameAndRelevant(i)));
i.sendMessage(p.txt.parse("%s <b>is not in the same faction as you.",you.describeTo(i, true)));
return false;
}

View File

@ -46,7 +46,7 @@ public class FactionsChatEarlyListener extends PlayerListener
if (me.getChatMode() == ChatMode.FACTION)
{
String message = String.format(Conf.factionChatFormat, me.getNameAndRelevant(me), msg);
String message = String.format(Conf.factionChatFormat, me.describeTo(me), msg);
me.getFaction().sendMessage(message);
P.p.log(Level.INFO, ChatColor.stripColor("FactionChat "+me.getFaction().getTag()+": "+message));

View File

@ -340,7 +340,7 @@ public class FactionsEntityListener extends EntityListener
// You can never hurt faction members or allies
if (relation.isMember() || relation.isAlly())
{
attacker.msg("<i>You can't hurt "+defender.getNameAndRelevant(attacker));
attacker.msg("<i>You can't hurt %s<i>.", defender.describeTo(attacker));
return false;
}
@ -349,8 +349,8 @@ public class FactionsEntityListener extends EntityListener
// You can not hurt neutrals in their own territory.
if (ownTerritory && relation.isNeutral())
{
attacker.msg("<i>You can't hurt "+relation.getColor()+defender.getNameAndRelevant(attacker)+"<i> in their own territory unless you declare them as an enemy.");
defender.msg(attacker.getNameAndRelevant(defender)+"<i> tried to hurt you.");
attacker.msg("<i>You can't hurt %s<i> in their own territory unless you declare them as an enemy.", defender.describeTo(attacker));
defender.msg("%s<i> tried to hurt you.", attacker.describeTo(defender, true));
return false;
}

View File

@ -113,8 +113,7 @@ public class RelationUtil
return null;
}
public static ChatColor getRelationColor(RelationParticipator me,
RelationParticipator that)
public static ChatColor getRelationColor(RelationParticipator me, RelationParticipator that)
{
return getRelationTo(that, me).getColor();
}