Option to not always show chat tag.

Fixes the issue of not being able to have groups without a faction tag in their name.
This commit is contained in:
Trent Hensler 2018-03-13 23:41:15 -07:00
parent d7646516ec
commit 8950be61d1
2 changed files with 4 additions and 7 deletions

View File

@ -71,6 +71,7 @@ public class Conf {
public static boolean chatTagPadBefore = false; public static boolean chatTagPadBefore = false;
public static boolean chatTagPadAfter = true; public static boolean chatTagPadAfter = true;
public static String chatTagFormat = "%s" + ChatColor.WHITE; public static String chatTagFormat = "%s" + ChatColor.WHITE;
public static boolean alwaysShowChatTag = true;
public static String factionChatFormat = "%s:" + ChatColor.WHITE + " %s"; public static String factionChatFormat = "%s:" + ChatColor.WHITE + " %s";
public static String allianceChatFormat = ChatColor.LIGHT_PURPLE + "%s:" + ChatColor.WHITE + " %s"; public static String allianceChatFormat = ChatColor.LIGHT_PURPLE + "%s:" + ChatColor.WHITE + " %s";
public static String truceChatFormat = ChatColor.DARK_PURPLE + "%s:" + ChatColor.WHITE + " %s"; public static String truceChatFormat = ChatColor.DARK_PURPLE + "%s:" + ChatColor.WHITE + " %s";

View File

@ -119,7 +119,7 @@ public class FactionsChatListener implements Listener {
String msg = event.getMessage(); String msg = event.getMessage();
String eventFormat = event.getFormat(); String eventFormat = event.getFormat();
FPlayer me = FPlayers.getInstance().getByPlayer(talkingPlayer); FPlayer me = FPlayers.getInstance().getByPlayer(talkingPlayer);
int InsertIndex; int InsertIndex = Conf.chatTagInsertIndex;
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
@ -136,12 +136,8 @@ public class FactionsChatListener implements Listener {
} else if (!Conf.chatTagInsertBeforeString.isEmpty() && eventFormat.contains(Conf.chatTagInsertBeforeString)) { } else if (!Conf.chatTagInsertBeforeString.isEmpty() && eventFormat.contains(Conf.chatTagInsertBeforeString)) {
// we're using the "insert before string" method // we're using the "insert before string" method
InsertIndex = eventFormat.indexOf(Conf.chatTagInsertBeforeString); InsertIndex = eventFormat.indexOf(Conf.chatTagInsertBeforeString);
} else { } else if (!Conf.alwaysShowChatTag){
// we'll fall back to using the index place method return;
InsertIndex = Conf.chatTagInsertIndex;
if (InsertIndex > eventFormat.length()) {
return;
}
} }
String formatStart = eventFormat.substring(0, InsertIndex) + ((Conf.chatTagPadBefore && !me.getChatTag().isEmpty()) ? " " : ""); String formatStart = eventFormat.substring(0, InsertIndex) + ((Conf.chatTagPadBefore && !me.getChatTag().isEmpty()) ? " " : "");