From 8950be61d1b7e49cac5dd2828af5166b34e5cb8d Mon Sep 17 00:00:00 2001 From: Trent Hensler Date: Tue, 13 Mar 2018 23:41:15 -0700 Subject: [PATCH] Option to not always show chat tag. Fixes the issue of not being able to have groups without a faction tag in their name. --- src/main/java/com/massivecraft/factions/Conf.java | 1 + .../factions/listeners/FactionsChatListener.java | 10 +++------- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/massivecraft/factions/Conf.java b/src/main/java/com/massivecraft/factions/Conf.java index 2272d7a7..48bf1603 100644 --- a/src/main/java/com/massivecraft/factions/Conf.java +++ b/src/main/java/com/massivecraft/factions/Conf.java @@ -71,6 +71,7 @@ public class Conf { public static boolean chatTagPadBefore = false; public static boolean chatTagPadAfter = true; public static String chatTagFormat = "%s" + ChatColor.WHITE; + public static boolean alwaysShowChatTag = true; public static String factionChatFormat = "%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"; diff --git a/src/main/java/com/massivecraft/factions/listeners/FactionsChatListener.java b/src/main/java/com/massivecraft/factions/listeners/FactionsChatListener.java index 0ca29fc7..d9410455 100644 --- a/src/main/java/com/massivecraft/factions/listeners/FactionsChatListener.java +++ b/src/main/java/com/massivecraft/factions/listeners/FactionsChatListener.java @@ -119,7 +119,7 @@ public class FactionsChatListener implements Listener { String msg = event.getMessage(); String eventFormat = event.getFormat(); FPlayer me = FPlayers.getInstance().getByPlayer(talkingPlayer); - int InsertIndex; + int InsertIndex = Conf.chatTagInsertIndex; if (!Conf.chatTagReplaceString.isEmpty() && eventFormat.contains(Conf.chatTagReplaceString)) { // 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)) { // we're using the "insert before string" method InsertIndex = eventFormat.indexOf(Conf.chatTagInsertBeforeString); - } else { - // we'll fall back to using the index place method - InsertIndex = Conf.chatTagInsertIndex; - if (InsertIndex > eventFormat.length()) { - return; - } + } else if (!Conf.alwaysShowChatTag){ + return; } String formatStart = eventFormat.substring(0, InsertIndex) + ((Conf.chatTagPadBefore && !me.getChatTag().isEmpty()) ? " " : "");