New chat tag placement options to have it replace a specified string (such as the default "{FACTION}"), put the tag before or after a specified string (such as "<" or ">"), and whether to pad the front or back of the tag with an extra " ".
This commit is contained in:
parent
be177902fd
commit
0859854af0
@ -43,12 +43,16 @@ public class Conf {
|
|||||||
public static boolean CanLeaveWithNegativePower = true;
|
public static boolean CanLeaveWithNegativePower = true;
|
||||||
|
|
||||||
// Configuration on the Faction tag in chat messages.
|
// Configuration on the Faction tag in chat messages.
|
||||||
|
|
||||||
public static boolean preloadChatPlugins = true;
|
public static boolean preloadChatPlugins = true;
|
||||||
public static boolean chatTagEnabled = true;
|
public static boolean chatTagEnabled = true;
|
||||||
public static boolean chatTagRelationColored = true;
|
public static boolean chatTagRelationColored = true;
|
||||||
|
public static String chatTagReplaceString = "{FACTION}";
|
||||||
|
public static String chatTagInsertAfterString = "";
|
||||||
|
public static String chatTagInsertBeforeString = "";
|
||||||
public static int chatTagInsertIndex = 1;
|
public static int chatTagInsertIndex = 1;
|
||||||
public static String chatTagFormat = "%s"+ChatColor.WHITE+" ";
|
public static boolean chatTagPadBefore = false;
|
||||||
|
public static boolean chatTagPadAfter = true;
|
||||||
|
public static String chatTagFormat = "%s"+ChatColor.WHITE;
|
||||||
public static String factionChatFormat = "%s"+ChatColor.WHITE+" %s";
|
public static String factionChatFormat = "%s"+ChatColor.WHITE+" %s";
|
||||||
|
|
||||||
public static boolean allowNoSlashCommand = true;
|
public static boolean allowNoSlashCommand = true;
|
||||||
|
@ -67,14 +67,35 @@ public class FactionsPlayerListener extends PlayerListener{
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int InsertIndex = Conf.chatTagInsertIndex;
|
int InsertIndex = 0;
|
||||||
if (InsertIndex > event.getFormat().length())
|
String eventFormat = event.getFormat();
|
||||||
return;
|
|
||||||
|
|
||||||
String formatStart = event.getFormat().substring(0, InsertIndex);
|
|
||||||
String formatEnd = event.getFormat().substring(InsertIndex);
|
|
||||||
|
|
||||||
String nonColoredMsgFormat = formatStart + me.getChatTag() + formatEnd;
|
if (!Conf.chatTagReplaceString.isEmpty() && eventFormat.contains(Conf.chatTagReplaceString)) {
|
||||||
|
// we're using the "replace" method of inserting the faction tags
|
||||||
|
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)) {
|
||||||
|
// we're using the "insert after string" method
|
||||||
|
InsertIndex = eventFormat.indexOf(Conf.chatTagInsertAfterString) + Conf.chatTagInsertAfterString.length();
|
||||||
|
}
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
String formatStart = eventFormat.substring(0, InsertIndex) + (Conf.chatTagPadBefore ? " " : "");
|
||||||
|
String formatEnd = (Conf.chatTagPadAfter ? " " : "") + eventFormat.substring(InsertIndex);
|
||||||
|
|
||||||
|
String nonColoredMsgFormat = formatStart + me.getChatTag().trim() + formatEnd;
|
||||||
|
|
||||||
// Relation Colored?
|
// Relation Colored?
|
||||||
if (Conf.chatTagRelationColored) {
|
if (Conf.chatTagRelationColored) {
|
||||||
@ -84,7 +105,7 @@ public class FactionsPlayerListener extends PlayerListener{
|
|||||||
|
|
||||||
for (Player listeningPlayer : Factions.instance.getServer().getOnlinePlayers()) {
|
for (Player listeningPlayer : Factions.instance.getServer().getOnlinePlayers()) {
|
||||||
FPlayer you = FPlayer.get(listeningPlayer);
|
FPlayer you = FPlayer.get(listeningPlayer);
|
||||||
String yourFormat = formatStart + me.getChatTag(you) + formatEnd;
|
String yourFormat = formatStart + me.getChatTag(you).trim() + formatEnd;
|
||||||
listeningPlayer.sendMessage(String.format(yourFormat, talkingPlayer.getDisplayName(), msg));
|
listeningPlayer.sendMessage(String.format(yourFormat, talkingPlayer.getDisplayName(), msg));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user