Rename Faction Tag to Faction Name. What did tag ever mean? Name makes more sense.

This commit is contained in:
Olof Larsson
2013-04-24 19:01:17 +02:00
parent 82e380cd3d
commit 5eed71fc67
34 changed files with 156 additions and 166 deletions

View File

@ -270,7 +270,7 @@ public class Board extends Entity<Board> implements BoardInterface
ArrayList<String> ret = new ArrayList<String>();
Faction centerFaction = this.getFactionAt(centerPs);
ret.add(Txt.titleize("("+centerPs.getChunkX() + "," + centerPs.getChunkZ()+") "+centerFaction.getTag(observer)));
ret.add(Txt.titleize("("+centerPs.getChunkX() + "," + centerPs.getChunkZ()+") "+centerFaction.getName(observer)));
int halfWidth = Const.MAP_WIDTH / 2;
int halfHeight = Const.MAP_HEIGHT / 2;
@ -280,7 +280,7 @@ public class Board extends Entity<Board> implements BoardInterface
int width = halfWidth * 2 + 1;
int height = halfHeight * 2 + 1;
//Make room for the list of tags
// Make room for the list of names
height--;
Map<Faction, Character> fList = new HashMap<Faction, Character>();
@ -327,7 +327,7 @@ public class Board extends Entity<Board> implements BoardInterface
String fRow = "";
for (Faction keyfaction : fList.keySet())
{
fRow += ""+keyfaction.getColorTo(observer) + fList.get(keyfaction) + ": " + keyfaction.getTag() + " ";
fRow += ""+keyfaction.getColorTo(observer) + fList.get(keyfaction) + ": " + keyfaction.getName() + " ";
}
fRow = fRow.trim();
ret.add(fRow);

View File

@ -43,7 +43,7 @@ public class Faction extends Entity<Faction> implements EconomyParticipator
@Override
public Faction load(Faction that)
{
this.setTag(that.tag);
this.setName(that.name);
this.setDescription(that.description);
this.setHome(that.home);
this.setPowerBoost(that.powerBoost);
@ -62,11 +62,11 @@ public class Faction extends Entity<Faction> implements EconomyParticipator
// In this section of the source code we place the field declarations only.
// Each field has it's own section further down since just the getter and setter logic takes up quite some place.
// TODO: The faction "tag" could/should also have been called "name".
// The actual faction id looks something like "54947df8-0e9e-4471-a2f9-9af509fb5889" and that is not too easy to remember for humans.
// Thus we make use of a name. Since the id is used in all foreign key situations changing the name is fine.
// Null should never happen. The tag must not be null.
private String tag = null;
// Null should never happen. The name must not be null.
@SerializedName("tag")
private String name = null;
// Factions can optionally set a description for themselves.
// This description can for example be seen in territorial alerts.
@ -124,18 +124,17 @@ public class Faction extends Entity<Faction> implements EconomyParticipator
}
// -------------------------------------------- //
// FIELD: tag
// FIELD: name
// -------------------------------------------- //
// TODO: Rename tag --> name ?
// RAW
public String getTag()
public String getName()
{
String ret = this.tag;
String ret = this.name;
UConf uconf = UConf.get(this);
if (uconf != null && UConf.get(this).factionTagForceUpperCase)
if (uconf != null && UConf.get(this).factionNameForceUpperCase)
{
ret = ret.toUpperCase();
}
@ -143,34 +142,34 @@ public class Faction extends Entity<Faction> implements EconomyParticipator
return ret;
}
public void setTag(String str)
public void setName(String str)
{
UConf uconf = UConf.get(this);
if (uconf != null && UConf.get(this).factionTagForceUpperCase)
if (uconf != null && UConf.get(this).factionNameForceUpperCase)
{
str = str.toUpperCase();
}
this.tag = str;
this.name = str;
this.changed();
}
// FINER
public String getComparisonTag()
public String getComparisonName()
{
return MiscUtil.getComparisonString(this.getTag());
return MiscUtil.getComparisonString(this.getName());
}
public String getTag(String prefix)
public String getName(String prefix)
{
return prefix + this.getTag();
return prefix + this.getName();
}
public String getTag(RelationParticipator observer)
public String getName(RelationParticipator observer)
{
if (observer == null) return getTag();
return this.getTag(this.getColorTo(observer).toString());
if (observer == null) return getName();
return this.getName(this.getColorTo(observer).toString());
}
// -------------------------------------------- //
@ -411,13 +410,13 @@ public class Faction extends Entity<Faction> implements EconomyParticipator
// TODO: What is this and where is it used?
public Map<Rel, List<String>> getFactionTagsPerRelation(RelationParticipator rp)
public Map<Rel, List<String>> getFactionNamesPerRelation(RelationParticipator rp)
{
return getFactionTagsPerRelation(rp, false);
return getFactionNamesPerRelation(rp, false);
}
// onlyNonNeutral option provides substantial performance boost on large servers for listing only non-neutral factions
public Map<Rel, List<String>> getFactionTagsPerRelation(RelationParticipator rp, boolean onlyNonNeutral)
public Map<Rel, List<String>> getFactionNamesPerRelation(RelationParticipator rp, boolean onlyNonNeutral)
{
Map<Rel, List<String>> ret = new HashMap<Rel, List<String>>();
for (Rel rel : Rel.values())
@ -428,7 +427,7 @@ public class Faction extends Entity<Faction> implements EconomyParticipator
{
Rel relation = faction.getRelationTo(this);
if (onlyNonNeutral && relation == Rel.NEUTRAL) continue;
ret.get(relation).add(faction.getTag(rp));
ret.get(relation).add(faction.getName(rp));
}
return ret;
}
@ -815,12 +814,12 @@ public class Faction extends Entity<Faction> implements EconomyParticipator
// no members left and faction isn't permanent, so disband it
if (MConf.get().logFactionDisband)
{
Factions.get().log("The faction "+this.getTag()+" ("+this.getId()+") has been disbanded since it has no members left.");
Factions.get().log("The faction "+this.getName()+" ("+this.getId()+") has been disbanded since it has no members left.");
}
for (UPlayer uplayer : UPlayerColls.get().get(this).getAllOnline())
{
uplayer.msg("The faction %s<i> was disbanded.", this.getTag(uplayer));
uplayer.msg("The faction %s<i> was disbanded.", this.getName(uplayer));
}
this.detach();
@ -834,7 +833,7 @@ public class Faction extends Entity<Faction> implements EconomyParticipator
replacements.get(0).setRole(Rel.LEADER);
this.msg("<i>Faction leader <h>%s<i> has been removed. %s<i> has been promoted as the new faction leader.", oldLeader == null ? "" : oldLeader.getName(), replacements.get(0).getName());
Factions.get().log("Faction "+this.getTag()+" ("+this.getId()+") leader was removed. Replacement leader: "+replacements.get(0).getName());
Factions.get().log("Faction "+this.getName()+" ("+this.getId()+") leader was removed. Replacement leader: "+replacements.get(0).getName());
}
}

View File

@ -129,7 +129,7 @@ public class FactionColl extends Coll<Faction>
faction = this.create(id);
faction.setTag(ChatColor.DARK_GREEN+"Wilderness");
faction.setName(ChatColor.DARK_GREEN+"Wilderness");
faction.setDescription(null);
faction.setOpen(false);
@ -161,7 +161,7 @@ public class FactionColl extends Coll<Faction>
faction = this.create(id);
faction.setTag("SafeZone");
faction.setName("SafeZone");
faction.setDescription("Free from PVP and monsters");
faction.setOpen(false);
@ -193,7 +193,7 @@ public class FactionColl extends Coll<Faction>
faction = this.create(id);
faction.setTag("WarZone");
faction.setName("WarZone");
faction.setDescription("Not the safest place to be");
faction.setOpen(false);
@ -246,40 +246,40 @@ public class FactionColl extends Coll<Faction>
}
// -------------------------------------------- //
// FACTION TAG
// FACTION NAME
// -------------------------------------------- //
public ArrayList<String> validateTag(String str)
public ArrayList<String> validateName(String str)
{
ArrayList<String> errors = new ArrayList<String>();
if (MiscUtil.getComparisonString(str).length() < UConf.get(this).factionTagLengthMin)
if (MiscUtil.getComparisonString(str).length() < UConf.get(this).factionNameLengthMin)
{
errors.add(Txt.parse("<i>The faction tag can't be shorter than <h>%s<i> chars.", UConf.get(this).factionTagLengthMin));
errors.add(Txt.parse("<i>The faction name can't be shorter than <h>%s<i> chars.", UConf.get(this).factionNameLengthMin));
}
if (str.length() > UConf.get(this).factionTagLengthMax)
if (str.length() > UConf.get(this).factionNameLengthMax)
{
errors.add(Txt.parse("<i>The faction tag can't be longer than <h>%s<i> chars.", UConf.get(this).factionTagLengthMax));
errors.add(Txt.parse("<i>The faction name can't be longer than <h>%s<i> chars.", UConf.get(this).factionNameLengthMax));
}
for (char c : str.toCharArray())
{
if ( ! MiscUtil.substanceChars.contains(String.valueOf(c)))
{
errors.add(Txt.parse("<i>Faction tag must be alphanumeric. \"<h>%s<i>\" is not allowed.", c));
errors.add(Txt.parse("<i>Faction name must be alphanumeric. \"<h>%s<i>\" is not allowed.", c));
}
}
return errors;
}
public Faction getByTag(String str)
public Faction getByName(String str)
{
String compStr = MiscUtil.getComparisonString(str);
for (Faction faction : this.getAll())
{
if (faction.getComparisonTag().equals(compStr))
if (faction.getComparisonName().equals(compStr))
{
return faction;
}
@ -287,24 +287,24 @@ public class FactionColl extends Coll<Faction>
return null;
}
public Faction getBestTagMatch(String searchFor)
public Faction getBestNameMatch(String searchFor)
{
Map<String, Faction> tag2faction = new HashMap<String, Faction>();
Map<String, Faction> name2faction = new HashMap<String, Faction>();
// TODO: Slow index building
for (Faction faction : this.getAll())
{
tag2faction.put(ChatColor.stripColor(faction.getTag()), faction);
name2faction.put(ChatColor.stripColor(faction.getName()), faction);
}
String tag = Txt.getBestCIStart(tag2faction.keySet(), searchFor);
String tag = Txt.getBestCIStart(name2faction.keySet(), searchFor);
if (tag == null) return null;
return tag2faction.get(tag);
return name2faction.get(tag);
}
public boolean isTagTaken(String str)
public boolean isNameTaken(String str)
{
return this.getByTag(str) != null;
return this.getByName(str) != null;
}
}

View File

@ -58,7 +58,7 @@ public class MConf extends Entity<MConf>
// We offer a simple standard way to set the format
public boolean chatSetFormat = false;
public EventPriority chatSetFormatAt = EventPriority.LOWEST;
public String chatSetFormatTo = "<{factions_relcolor}§l{factions_roleprefix}§r{factions_relcolor}{factions_tag|rp}§f%1$s> %2$s";
public String chatSetFormatTo = "<{factions_relcolor}§l{factions_roleprefix}§r{factions_relcolor}{factions_name|rp}§f%1$s> %2$s";
// We offer a simple standard way to parse the chat tags
public boolean chatParseTags = true;
@ -78,7 +78,7 @@ public class MConf extends Entity<MConf>
// HeroChat: The Allies Channel
public String herochatAlliesName = "Allies";
public String herochatAlliesNick = "A";
public String herochatAlliesFormat = "{color}[&l{nick}&r&f {factions_relcolor}&l{factions_roleprefix}&r{factions_relcolor}{factions_tag|rp}{sender}{color}] &f{msg}";
public String herochatAlliesFormat = "{color}[&l{nick}&r&f {factions_relcolor}&l{factions_roleprefix}&r{factions_relcolor}{factions_name|rp}{sender}{color}] &f{msg}";
public ChatColor herochatAlliesColor = ChatColor.DARK_PURPLE;
public int herochatAlliesDistance = 0;
public boolean herochatAlliesIsShortcutAllowed = false;

View File

@ -62,9 +62,9 @@ public class UConf extends Entity<UConf>
public int factionMemberLimit = 0;
public double factionPowerMax = 1000.0;
public int factionTagLengthMin = 3;
public int factionTagLengthMax = 10;
public boolean factionTagForceUpperCase = false;
public int factionNameLengthMin = 3;
public int factionNameLengthMax = 16;
public boolean factionNameForceUpperCase = false;
// -------------------------------------------- //
// CLAIMS
@ -154,7 +154,7 @@ public class UConf extends Entity<UConf>
public double econCostInvite = 0.0;
public double econCostDeinvite = 0.0;
public double econCostHome = 0.0;
public double econCostTag = 0.0;
public double econCostName = 0.0;
public double econCostDescription = 0.0;
public double econCostTitle = 0.0;
public double econCostOpen = 0.0;

View File

@ -332,7 +332,7 @@ public class UPlayer extends SenderEntity<UPlayer> implements EconomyParticipato
}
// -------------------------------------------- //
// TITLE, NAME, FACTION TAG AND CHAT
// TITLE, NAME, FACTION NAME AND CHAT
// -------------------------------------------- //
public String getName()
@ -340,11 +340,11 @@ public class UPlayer extends SenderEntity<UPlayer> implements EconomyParticipato
return this.getFixedId();
}
public String getTag()
public String getFactionName()
{
Faction faction = this.getFaction();
if (faction.isNone()) return "";
return faction.getTag();
return faction.getName();
}
// Base concatenations:
@ -372,9 +372,9 @@ public class UPlayer extends SenderEntity<UPlayer> implements EconomyParticipato
}
}
public String getNameAndTag()
public String getNameAndFactionName()
{
return this.getNameAndSomething(this.getTag());
return this.getNameAndSomething(this.getFactionName());
}
// Colored concatenations:
@ -498,7 +498,7 @@ public class UPlayer extends SenderEntity<UPlayer> implements EconomyParticipato
if (MConf.get().logFactionLeave)
{
Factions.get().log(this.getName()+" left the faction: "+myFaction.getTag());
Factions.get().log(this.getName()+" left the faction: "+myFaction.getName());
}
}
@ -515,7 +515,7 @@ public class UPlayer extends SenderEntity<UPlayer> implements EconomyParticipato
myFaction.detach();
if (MConf.get().logFactionDisband)
{
Factions.get().log("The faction "+myFaction.getTag()+" ("+myFaction.getId()+") was disbanded due to the last player ("+this.getName()+") leaving.");
Factions.get().log("The faction "+myFaction.getName()+" ("+myFaction.getId()+") was disbanded due to the last player ("+this.getName()+") leaving.");
}
}
}
@ -596,7 +596,7 @@ public class UPlayer extends SenderEntity<UPlayer> implements EconomyParticipato
if (!oldFaction.hasLandInflation())
{
msg("%s<i> owns this land and is strong enough to keep it.", oldFaction.getTag(this));
msg("%s<i> owns this land and is strong enough to keep it.", oldFaction.getName(this));
return false;
}