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