Properly replace chat. Hardcoding never helped anyone.
Fixes issue #30. Use ternaries where possible.
This commit is contained in:
parent
dbf8eabf39
commit
30f4fdf6c6
@ -296,7 +296,7 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator {
|
||||
// Base:
|
||||
|
||||
public String getTitle() {
|
||||
return this.title;
|
||||
return this.hasFaction() ? title : "";
|
||||
}
|
||||
|
||||
public void setTitle(String title) {
|
||||
@ -312,10 +312,7 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator {
|
||||
}
|
||||
|
||||
public String getTag() {
|
||||
if (!this.hasFaction()) {
|
||||
return "";
|
||||
}
|
||||
return this.getFaction().getTag();
|
||||
return this.hasFaction() ? this.getFaction().getTag() : "";
|
||||
}
|
||||
|
||||
// Base concatenations:
|
||||
@ -381,28 +378,16 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator {
|
||||
// These are injected into the format of global chat messages.
|
||||
|
||||
public String getChatTag() {
|
||||
if (!this.hasFaction()) {
|
||||
return "";
|
||||
}
|
||||
|
||||
return String.format(Conf.chatTagFormat, this.role.getPrefix() + this.getTag());
|
||||
return this.hasFaction() ? String.format(Conf.chatTagFormat, this.role.getPrefix() + this.getTag()) : "";
|
||||
}
|
||||
|
||||
// Colored Chat Tag
|
||||
public String getChatTag(Faction faction) {
|
||||
if (!this.hasFaction()) {
|
||||
return "";
|
||||
}
|
||||
|
||||
return this.getRelationTo(faction).getColor() + getChatTag();
|
||||
return this.hasFaction() ? this.getRelationTo(faction).getColor() + getChatTag() : "";
|
||||
}
|
||||
|
||||
public String getChatTag(FPlayer fplayer) {
|
||||
if (!this.hasFaction()) {
|
||||
return "";
|
||||
}
|
||||
|
||||
return this.getColorTo(fplayer) + getChatTag();
|
||||
return this.hasFaction() ? this.getColorTo(fplayer) + getChatTag() : "";
|
||||
}
|
||||
|
||||
// -------------------------------
|
||||
|
@ -98,12 +98,8 @@ public class FactionsChatListener implements Listener {
|
||||
|
||||
if (!Conf.chatTagReplaceString.isEmpty() && eventFormat.contains(Conf.chatTagReplaceString)) {
|
||||
// we're using the "replace" method of inserting the faction tags
|
||||
// if they stuck "[FACTION_TITLE]" in there, go ahead and do it too
|
||||
if (eventFormat.contains("[FACTION_TITLE]")) {
|
||||
eventFormat = eventFormat.replace("[FACTION_TITLE]", me.getTitle());
|
||||
}
|
||||
eventFormat = eventFormat.replace(Conf.chatTagReplaceString, me.getTitle());
|
||||
InsertIndex = eventFormat.indexOf(Conf.chatTagReplaceString);
|
||||
eventFormat = eventFormat.replace(Conf.chatTagReplaceString, "");
|
||||
Conf.chatTagPadAfter = false;
|
||||
Conf.chatTagPadBefore = false;
|
||||
} else if (!Conf.chatTagInsertAfterString.isEmpty() && eventFormat.contains(Conf.chatTagInsertAfterString)) {
|
||||
|
Loading…
Reference in New Issue
Block a user