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

@ -50,7 +50,7 @@ permissions:
factions.seechunk: {description: see the chunk you stand in, default: false}
factions.sethome: {description: set the faction home, default: false}
factions.show: {description: show faction information, default: false}
factions.tag: {description: set faction tag, default: false}
factions.name: {description: set faction name, default: false}
factions.title: {description: set player title, default: false}
factions.unclaim: {description: unclaim land where you stand, default: false}
factions.unclaimall: {description: unclaim all land, default: false}
@ -95,7 +95,7 @@ permissions:
factions.seechunk: true
factions.sethome: true
factions.show: true
factions.tag: true
factions.name: true
factions.title: true
factions.unclaim: true
factions.unclaimall: true
@ -165,7 +165,7 @@ permissions:
factions.seechunk: true
factions.sethome: true
factions.show: true
factions.tag: true
factions.name: true
factions.title: true
factions.unclaim: true
factions.unclaimall: true

View File

@ -15,8 +15,8 @@ import com.massivecraft.factions.chat.modifier.ChatModifierUcf;
import com.massivecraft.factions.chat.tag.ChatTagRelcolor;
import com.massivecraft.factions.chat.tag.ChatTagRole;
import com.massivecraft.factions.chat.tag.ChatTagRoleprefix;
import com.massivecraft.factions.chat.tag.ChatTagTag;
import com.massivecraft.factions.chat.tag.ChatTagTagforce;
import com.massivecraft.factions.chat.tag.ChatTagName;
import com.massivecraft.factions.chat.tag.ChatTagNameforce;
import com.massivecraft.factions.chat.tag.ChatTagTitle;
import com.massivecraft.factions.cmd.*;
import com.massivecraft.factions.entity.Board;
@ -146,8 +146,8 @@ public class Factions extends MPlugin
ChatTagRelcolor.get().register();
ChatTagRole.get().register();
ChatTagRoleprefix.get().register();
ChatTagTag.get().register();
ChatTagTagforce.get().register();
ChatTagName.get().register();
ChatTagNameforce.get().register();
ChatTagTitle.get().register();
postEnable();

View File

@ -52,7 +52,7 @@ public enum Perm
SEE_CHUNK("seechunk"),
SETHOME("sethome"),
SHOW("show"),
TAG("tag"),
NAME("name"),
TITLE("title"),
UNCLAIM("unclaim"),
UNCLAIM_ALL("unclaimall"),

View File

@ -136,7 +136,7 @@ public class TerritoryAccess
{
if (list.length() > 0)
list.append(", ");
list.append(FactionColls.get().get(universeExtractable).get(factionID).getTag());
list.append(FactionColls.get().get(universeExtractable).get(factionID).getName());
}
return list.toString();
}

View File

@ -4,15 +4,15 @@ import com.massivecraft.factions.chat.ChatTagAbstract;
import com.massivecraft.factions.entity.Faction;
import com.massivecraft.factions.entity.UPlayer;
public class ChatTagTag extends ChatTagAbstract
public class ChatTagName extends ChatTagAbstract
{
// -------------------------------------------- //
// INSTANCE & CONSTRUCT
// -------------------------------------------- //
private ChatTagTag() { super("factions_tag"); }
private static ChatTagTag i = new ChatTagTag();
public static ChatTagTag get() { return i; }
private ChatTagName() { super("factions_name"); }
private static ChatTagName i = new ChatTagName();
public static ChatTagName get() { return i; }
// -------------------------------------------- //
// OVERRIDE
@ -23,7 +23,7 @@ public class ChatTagTag extends ChatTagAbstract
{
Faction faction = fsender.getFaction();
if (faction.isNone()) return "";
return faction.getTag();
return faction.getName();
}
}

View File

@ -3,15 +3,15 @@ package com.massivecraft.factions.chat.tag;
import com.massivecraft.factions.chat.ChatTagAbstract;
import com.massivecraft.factions.entity.UPlayer;
public class ChatTagTagforce extends ChatTagAbstract
public class ChatTagNameforce extends ChatTagAbstract
{
// -------------------------------------------- //
// INSTANCE & CONSTRUCT
// -------------------------------------------- //
private ChatTagTagforce() { super("factions_tagforce"); }
private static ChatTagTagforce i = new ChatTagTagforce();
public static ChatTagTagforce get() { return i; }
private ChatTagNameforce() { super("factions_nameforce"); }
private static ChatTagNameforce i = new ChatTagNameforce();
public static ChatTagNameforce get() { return i; }
// -------------------------------------------- //
// OVERRIDE
@ -20,7 +20,7 @@ public class ChatTagTagforce extends ChatTagAbstract
@Override
public String getReplacement(UPlayer fsender, UPlayer frecipient)
{
return fsender.getFaction().getTag();
return fsender.getFaction().getName();
}
}

View File

@ -40,7 +40,7 @@ public class CmdFactions extends FCommand
public CmdFactionsSeeChunk cmdFactionsSeeChunk = new CmdFactionsSeeChunk();
public CmdFactionsSethome cmdFactionsSethome = new CmdFactionsSethome();
public CmdFactionsShow cmdFactionsShow = new CmdFactionsShow();
public CmdFactionsTag cmdFactionsTag = new CmdFactionsTag();
public CmdFactionsName cmdFactionsName = new CmdFactionsName();
public CmdFactionsTitle cmdFactionsTitle = new CmdFactionsTitle();
public CmdFactionsUnclaim cmdFactionsUnclaim = new CmdFactionsUnclaim();
public CmdFactionsUnclaimall cmdFactionsUnclaimall = new CmdFactionsUnclaimall();
@ -66,7 +66,7 @@ public class CmdFactions extends FCommand
this.addSubCommand(this.cmdFactionsHome);
this.addSubCommand(this.cmdFactionsCreate);
this.addSubCommand(this.cmdFactionsSethome);
this.addSubCommand(this.cmdFactionsTag);
this.addSubCommand(this.cmdFactionsName);
this.addSubCommand(this.cmdFactionsDemote);
this.addSubCommand(this.cmdFactionsDescription);
this.addSubCommand(this.cmdFactionsPerm);

View File

@ -82,7 +82,7 @@ public class CmdFactionsAccess extends FCommand
Faction targetFaction = this.arg(1, ARFaction.get(myFaction), myFaction);
if (targetFaction == null) return;
added = territory.toggleFaction(targetFaction);
target = "Faction \""+targetFaction.getTag()+"\"";
target = "Faction \""+targetFaction.getName()+"\"";
}
msg("<i>%s has been %s<i> the access list for this territory.", target, Txt.parse(added ? "<lime>added to" : "<rose>removed from"));
@ -91,7 +91,7 @@ public class CmdFactionsAccess extends FCommand
private void showAccessList(TerritoryAccess territory, Faction locFaction)
{
msg("<i>Host faction %s has %s<i> in this territory.", locFaction.getTag(), Txt.parse(territory.isHostFactionAllowed() ? "<lime>normal access" : "<rose>restricted access"));
msg("<i>Host faction %s has %s<i> in this territory.", locFaction.getName(), Txt.parse(territory.isHostFactionAllowed() ? "<lime>normal access" : "<rose>restricted access"));
String players = territory.fplayerList();
String factions = territory.factionList(locFaction);

View File

@ -22,7 +22,7 @@ public class CmdFactionsCreate extends FCommand
{
this.addAliases("create");
this.addRequiredArg("faction tag");
this.addRequiredArg("name");
this.addRequirements(ReqHasPerm.get(Perm.CREATE.node));
}
@ -31,7 +31,7 @@ public class CmdFactionsCreate extends FCommand
public void perform()
{
// Args
String newTag = this.arg(0);
String newName = this.arg(0);
// Verify
if (fme.getFaction().isNormal())
@ -42,16 +42,16 @@ public class CmdFactionsCreate extends FCommand
FactionColl coll = FactionColls.get().get(fme);
if (coll.isTagTaken(newTag))
if (coll.isNameTaken(newName))
{
msg("<b>That tag is already in use.");
msg("<b>That name is already in use.");
return;
}
ArrayList<String> tagValidationErrors = coll.validateTag(newTag);
if (tagValidationErrors.size() > 0)
ArrayList<String> nameValidationErrors = coll.validateName(newName);
if (nameValidationErrors.size() > 0)
{
sendMessage(tagValidationErrors);
sendMessage(nameValidationErrors);
return;
}
@ -59,13 +59,13 @@ public class CmdFactionsCreate extends FCommand
String factionId = coll.getIdStrategy().generate(coll);
// Event
FactionsEventCreate createEvent = new FactionsEventCreate(sender, coll.getUniverse(), factionId, newTag);
FactionsEventCreate createEvent = new FactionsEventCreate(sender, coll.getUniverse(), factionId, newName);
createEvent.run();
if (createEvent.isCancelled()) return;
// Apply
Faction faction = coll.create(factionId);
faction.setTag(newTag);
faction.setName(newName);
fme.setRole(Rel.LEADER);
fme.setFaction(faction);
@ -77,14 +77,14 @@ public class CmdFactionsCreate extends FCommand
// Inform
for (UPlayer follower : UPlayerColls.get().get(fme).getAllOnline())
{
follower.msg("%s<i> created a new faction %s", fme.describeTo(follower, true), faction.getTag(follower));
follower.msg("%s<i> created a new faction %s", fme.describeTo(follower, true), faction.getName(follower));
}
msg("<i>You should now: %s", Factions.get().getOuterCmdFactions().cmdFactionsDescription.getUseageTemplate());
if (MConf.get().logFactionCreate)
{
Factions.get().log(fme.getName()+" created a new faction: "+newTag);
Factions.get().log(fme.getName()+" created a new faction: "+newName);
}
}

View File

@ -67,13 +67,13 @@ public class CmdFactionsDisband extends FCommand
}
else
{
uplayer.msg("<h>%s<i> disbanded the faction %s.", who, faction.getTag(uplayer));
uplayer.msg("<h>%s<i> disbanded the faction %s.", who, faction.getName(uplayer));
}
}
if (MConf.get().logFactionDisband)
{
Factions.get().log("The faction "+faction.getTag()+" ("+faction.getId()+") was disbanded by "+(senderIsConsole ? "console command" : fme.getName())+".");
Factions.get().log("The faction "+faction.getName()+" ("+faction.getId()+") was disbanded by "+(senderIsConsole ? "console command" : fme.getName())+".");
}

View File

@ -36,7 +36,7 @@ public class CmdFactionsInvite extends FCommand
// Allready member?
if (uplayer.getFaction() == myFaction)
{
msg("%s<i> is already a member of %s", uplayer.getName(), myFaction.getTag());
msg("%s<i> is already a member of %s", uplayer.getName(), myFaction.getName());
msg("<i>You might want to: " + Factions.get().getOuterCmdFactions().cmdFactionsKick.getUseageTemplate(false));
return;
}

View File

@ -46,13 +46,13 @@ public class CmdFactionsJoin extends FCommand
if (faction == uplayerFaction)
{
msg("<b>%s %s already a member of %s", uplayer.describeTo(fme, true), (samePlayer ? "are" : "is"), faction.getTag(fme));
msg("<b>%s %s already a member of %s", uplayer.describeTo(fme, true), (samePlayer ? "are" : "is"), faction.getName(fme));
return;
}
if (UConf.get(faction).factionMemberLimit > 0 && faction.getUPlayers().size() >= UConf.get(faction).factionMemberLimit)
{
msg(" <b>!<white> The faction %s is at the limit of %d members, so %s cannot currently join.", faction.getTag(fme), UConf.get(faction).factionMemberLimit, uplayer.describeTo(fme, false));
msg(" <b>!<white> The faction %s is at the limit of %d members, so %s cannot currently join.", faction.getName(fme), UConf.get(faction).factionMemberLimit, uplayer.describeTo(fme, false));
return;
}
@ -86,10 +86,10 @@ public class CmdFactionsJoin extends FCommand
// Inform
if (!samePlayer)
{
uplayer.msg("<i>%s moved you into the faction %s.", fme.describeTo(uplayer, true), faction.getTag(uplayer));
uplayer.msg("<i>%s moved you into the faction %s.", fme.describeTo(uplayer, true), faction.getName(uplayer));
}
faction.msg("<i>%s joined your faction.", uplayer.describeTo(faction, true));
fme.msg("<i>%s successfully joined %s.", uplayer.describeTo(fme, true), faction.getTag(fme));
fme.msg("<i>%s successfully joined %s.", uplayer.describeTo(fme, true), faction.getName(fme));
// Apply
uplayer.resetFactionData();
@ -101,9 +101,9 @@ public class CmdFactionsJoin extends FCommand
if (MConf.get().logFactionJoin)
{
if (samePlayer)
Factions.get().log("%s joined the faction %s.", uplayer.getName(), faction.getTag());
Factions.get().log("%s joined the faction %s.", uplayer.getName(), faction.getName());
else
Factions.get().log("%s moved the player %s into the faction %s.", fme.getName(), uplayer.getName(), faction.getTag());
Factions.get().log("%s moved the player %s into the faction %s.", fme.getName(), uplayer.getName(), faction.getName());
}
}
}

View File

@ -72,7 +72,7 @@ public class CmdFactionsKick extends FCommand
if (MConf.get().logFactionKick)
{
Factions.get().log(fme.getDisplayName() + " kicked " + uplayer.getName() + " from the faction " + uplayerFaction.getTag());
Factions.get().log(fme.getDisplayName() + " kicked " + uplayer.getName() + " from the faction " + uplayerFaction.getName());
}
// Apply

View File

@ -57,7 +57,7 @@ public class CmdFactionsList extends FCommand
continue;
}
lines.add(Txt.parse("%s<i> %d/%d online, %d/%d/%d",
faction.getTag(fme),
faction.getName(fme),
faction.getUPlayersWhereOnline(true).size(),
faction.getUPlayers().size(),
faction.getLandCount(),

View File

@ -8,20 +8,20 @@ import com.massivecraft.factions.cmd.req.ReqRoleIsAtLeast;
import com.massivecraft.factions.entity.Faction;
import com.massivecraft.factions.entity.FactionColl;
import com.massivecraft.factions.entity.FactionColls;
import com.massivecraft.factions.event.FactionsEventTagChange;
import com.massivecraft.factions.event.FactionsEventNameChange;
import com.massivecraft.factions.util.MiscUtil;
import com.massivecraft.mcore.cmd.req.ReqHasPerm;
public class CmdFactionsTag extends FCommand
public class CmdFactionsName extends FCommand
{
public CmdFactionsTag()
public CmdFactionsName()
{
this.addAliases("tag");
this.addAliases("name");
this.addRequiredArg("new tag");
this.addRequiredArg("new name");
this.addRequirements(ReqHasPerm.get(Perm.TAG.node));
this.addRequirements(ReqHasPerm.get(Perm.NAME.node));
this.addRequirements(ReqRoleIsAtLeast.get(Rel.OFFICER));
}
@ -29,19 +29,19 @@ public class CmdFactionsTag extends FCommand
public void perform()
{
// Arg
String newTag = this.arg(0);
String newName = this.arg(0);
// TODO does not first test cover selfcase?
FactionColl factionColl = FactionColls.get().get(myFaction);
if (factionColl.isTagTaken(newTag) && ! MiscUtil.getComparisonString(newTag).equals(myFaction.getComparisonTag()))
if (factionColl.isNameTaken(newName) && ! MiscUtil.getComparisonString(newName).equals(myFaction.getComparisonName()))
{
msg("<b>That tag is already taken");
msg("<b>That name is already taken");
return;
}
ArrayList<String> errors = new ArrayList<String>();
errors.addAll(factionColl.validateTag(newTag));
errors.addAll(factionColl.validateName(newName));
if (errors.size() > 0)
{
sendMessage(errors);
@ -49,24 +49,24 @@ public class CmdFactionsTag extends FCommand
}
// Event
FactionsEventTagChange event = new FactionsEventTagChange(sender, myFaction, newTag);
FactionsEventNameChange event = new FactionsEventNameChange(sender, myFaction, newName);
event.run();
if (event.isCancelled()) return;
newTag = event.getNewTag();
newName = event.getNewName();
// Apply
String oldtag = myFaction.getTag();
myFaction.setTag(newTag);
String oldName = myFaction.getName();
myFaction.setName(newName);
// Inform
myFaction.msg("%s<i> changed your faction tag to %s", fme.describeTo(myFaction, true), myFaction.getTag(myFaction));
myFaction.msg("%s<i> changed your faction name to %s", fme.describeTo(myFaction, true), myFaction.getName(myFaction));
for (Faction faction : FactionColls.get().get(myFaction).getAll())
{
if (faction == myFaction)
{
continue;
}
faction.msg("<i>The faction %s<i> changed their name to %s.", fme.getColorTo(faction)+oldtag, myFaction.getTag(faction));
faction.msg("<i>The faction %s<i> changed their name to %s.", fme.getColorTo(faction)+oldName, myFaction.getName(faction));
}
}

View File

@ -30,9 +30,9 @@ public class CmdFactionsPowerBoost extends FCommand
faction.setPowerBoost(amount);
msg("<i>"+faction.getTag()+" now has a power bonus/penalty of "+amount+" to min and max power levels.");
msg("<i>"+faction.getName()+" now has a power bonus/penalty of "+amount+" to min and max power levels.");
// TODO: Inconsistent. Why is there no boolean to toggle this logging of?
Factions.get().log(fme.getName()+" has set the power bonus/penalty for "+faction.getTag()+" to "+amount+".");
Factions.get().log(fme.getName()+" has set the power bonus/penalty for "+faction.getName()+" to "+amount+".");
}
}

View File

@ -47,7 +47,7 @@ public abstract class CmdFactionsRelationAbstract extends FCommand
if (myFaction.getRelationWish(otherFaction) == newRelation)
{
msg("<b>You already have that relation wish set with %s.", otherFaction.getTag());
msg("<b>You already have that relation wish set with %s.", otherFaction.getName());
return;
}
@ -71,7 +71,7 @@ public abstract class CmdFactionsRelationAbstract extends FCommand
else
{
otherFaction.msg("%s<i> wishes to be %s.", myFaction.describeTo(otherFaction, true), newRelation.getColor()+newRelation.getDescFactionOne());
otherFaction.msg("<i>Type <c>/"+ConfServer.baseCommandAliases.get(0)+" "+newRelation+" "+myFaction.getTag()+"<i> to accept.");
otherFaction.msg("<i>Type <c>/"+ConfServer.baseCommandAliases.get(0)+" "+newRelation+" "+myFaction.getName()+"<i> to accept.");
myFaction.msg("%s<i> were informed that you wish to be %s<i>.", otherFaction.describeTo(myFaction, true), newRelation.getColor()+newRelation.getDescFactionOne());
}

View File

@ -63,7 +63,7 @@ public class CmdFactionsSethome extends FCommand
faction.sendMessage(Factions.get().getOuterCmdFactions().cmdFactionsHome.getUseageTemplate());
if (faction != myFaction)
{
fme.msg("<b>You have set the home for the "+faction.getTag(fme)+"<i> faction.");
fme.msg("<b>You have set the home for the "+faction.getName(fme)+"<i> faction.");
}
}

View File

@ -43,7 +43,7 @@ public class CmdFactionsShow extends FCommand
Collection<UPlayer> normals = faction.getUPlayersWhereRole(Rel.MEMBER);
Collection<UPlayer> recruits = faction.getUPlayersWhereRole(Rel.RECRUIT);
msg(Txt.titleize(faction.getTag(fme)));
msg(Txt.titleize(faction.getName(fme)));
msg("<a>Description: <i>%s", faction.getDescription());
// Display important flags
@ -99,7 +99,7 @@ public class CmdFactionsShow extends FCommand
String sepparator = Txt.parse("<i>")+", ";
// List the relations to other factions
Map<Rel, List<String>> relationTags = faction.getFactionTagsPerRelation(fme, true);
Map<Rel, List<String>> relationNames = faction.getFactionNamesPerRelation(fme, true);
if (faction.getFlag(FFlag.PEACEFUL))
{
@ -107,11 +107,11 @@ public class CmdFactionsShow extends FCommand
}
else
{
sendMessage(Txt.parse("<a>In Truce with: ") + Txt.implode(relationTags.get(Rel.TRUCE), sepparator));
sendMessage(Txt.parse("<a>In Truce with: ") + Txt.implode(relationNames.get(Rel.TRUCE), sepparator));
}
sendMessage(Txt.parse("<a>Allied to: ") + Txt.implode(relationTags.get(Rel.ALLY), sepparator));
sendMessage(Txt.parse("<a>Enemies: ") + Txt.implode(relationTags.get(Rel.ENEMY), sepparator));
sendMessage(Txt.parse("<a>Allied to: ") + Txt.implode(relationNames.get(Rel.ALLY), sepparator));
sendMessage(Txt.parse("<a>Enemies: ") + Txt.implode(relationNames.get(Rel.ENEMY), sepparator));
// List the members...
List<String> memberOnlineNames = new ArrayList<String>();

View File

@ -30,15 +30,6 @@ public class CmdFactionsUnclaim extends FCommand
// Apply
if (fme.tryClaim(newFaction, chunk, true, true)) return;
// Inform
// TODO: Move the logging stuff into the try-method
/*myFaction.msg("%s<i> unclaimed some land.", fme.describeTo(myFaction, true));
if (MConf.get().logLandUnclaims)
{
Factions.get().log(fme.getName()+" unclaimed land at ("+chunk.getChunkX()+","+chunk.getChunkZ()+") from the faction: "+oldFaction.getTag());
}*/
}
}

View File

@ -63,7 +63,7 @@ public class CmdFactionsUnclaimall extends FCommand
// Log
if (MConf.get().logLandUnclaims)
{
Factions.get().log(fme.getName()+" unclaimed everything for the faction: "+myFaction.getTag());
Factions.get().log(fme.getName()+" unclaimed everything for the faction: "+myFaction.getName());
}
}

View File

@ -39,12 +39,12 @@ public class ARFaction extends ArgReaderAbstract<Faction>
{
ArgResult<Faction> result = new ArgResult<Faction>();
// Faction Tag Exact
result.setResult(this.getColl().getByTag(str));
// Faction Name Exact
result.setResult(this.getColl().getByName(str));
if (result.hasResult()) return result;
// Faction Tag Match
result.setResult(this.getColl().getBestTagMatch(str));
// Faction Name Match
result.setResult(this.getColl().getBestNameMatch(str));
if (result.hasResult()) return result;
// UPlayer Name Exact

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

View File

@ -23,19 +23,19 @@ public class FactionsEventCreate extends FactionsEventAbstractSender
private final String factionId;
public final String getFactionId() { return this.factionId; }
private final String factionTag;
public final String getFactionTag() { return this.factionTag; }
private final String factionName;
public final String getFactionName() { return this.factionName; }
// -------------------------------------------- //
// CONSTRUCT
// -------------------------------------------- //
public FactionsEventCreate(CommandSender sender, String universe, String factionId, String factionTag)
public FactionsEventCreate(CommandSender sender, String universe, String factionId, String factionName)
{
super(sender);
this.universe = universe;
this.factionId = factionId;
this.factionTag = factionTag;
this.factionName = factionName;
}
}

View File

@ -5,7 +5,7 @@ import org.bukkit.event.HandlerList;
import com.massivecraft.factions.entity.Faction;
public class FactionsEventTagChange extends FactionsEventAbstractSender
public class FactionsEventNameChange extends FactionsEventAbstractSender
{
// -------------------------------------------- //
// REQUIRED EVENT CODE
@ -22,19 +22,19 @@ public class FactionsEventTagChange extends FactionsEventAbstractSender
private final Faction faction;
public Faction getFaction() { return this.faction; }
private String newTag;
public String getNewTag() { return this.newTag; }
public void setNewTag(String newTag) { this.newTag = newTag; }
private String newName;
public String getNewName() { return this.newName; }
public void setNewName(String newName) { this.newName = newName; }
// -------------------------------------------- //
// CONSTRUCT
// -------------------------------------------- //
public FactionsEventTagChange(CommandSender sender, Faction faction, String newTag)
public FactionsEventNameChange(CommandSender sender, Faction faction, String newName)
{
super(sender);
this.faction = faction;
this.newTag = newTag;
this.newName = newName;
}
}

View File

@ -22,7 +22,7 @@ import com.massivecraft.factions.event.FactionsEventMembershipChange;
import com.massivecraft.factions.event.FactionsEventMembershipChange.MembershipChangeReason;
import com.massivecraft.factions.event.FactionsEventOpenChange;
import com.massivecraft.factions.event.FactionsEventRelationChange;
import com.massivecraft.factions.event.FactionsEventTagChange;
import com.massivecraft.factions.event.FactionsEventNameChange;
import com.massivecraft.factions.event.FactionsEventTitleChange;
import com.massivecraft.factions.integration.Econ;
import com.massivecraft.mcore.money.Money;
@ -88,7 +88,7 @@ public class FactionsListenerEcon implements Listener
Econ.transferMoney(usender, faction, usender, amount, false);
usender.msg("<i>You have been given the disbanded faction's bank, totaling %s.", amountString);
Factions.get().log(usender.getName() + " has been given bank holdings of "+amountString+" from disbanding "+faction.getTag()+".");
Factions.get().log(usender.getName() + " has been given bank holdings of "+amountString+" from disbanding "+faction.getName()+".");
}
// -------------------------------------------- //
@ -191,10 +191,10 @@ public class FactionsListenerEcon implements Listener
}
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void payForCommand(FactionsEventTagChange event)
public void payForCommand(FactionsEventNameChange event)
{
Double cost = UConf.get(event.getSender()).econCostTag;
String desc = Factions.get().getOuterCmdFactions().cmdFactionsTag.getDesc();
Double cost = UConf.get(event.getSender()).econCostName;
String desc = Factions.get().getOuterCmdFactions().cmdFactionsName.getDesc();
payForAction(event, cost, desc);
}

View File

@ -125,7 +125,7 @@ public class FactionsListenerMain implements Listener
}
else if (factionFrom != factionTo)
{
String msg = Txt.parse("<i>") + " ~ " + factionTo.getTag(uplayer);
String msg = Txt.parse("<i>") + " ~ " + factionTo.getName(uplayer);
if (factionTo.hasDescription())
{
msg += " - " + factionTo.getDescription();

View File

@ -24,7 +24,7 @@ public class MiscUtil
return values;
}
/// TODO create tag whitelist!!
/// TODO create name whitelist!!?
public static HashSet<String> substanceChars = new HashSet<String>(Arrays.asList(new String []{
"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F", "G", "H",
"I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z",

View File

@ -35,7 +35,7 @@ public class RelationUtil
}
else
{
ret = thatFaction.getTag();
ret = thatFaction.getName();
}
}
else if (that instanceof UPlayer)
@ -51,7 +51,7 @@ public class RelationUtil
}
else
{
ret = uplayerthat.getNameAndTag();
ret = uplayerthat.getNameAndFactionName();
}
}