Skip to content

Commit

Permalink
2.1.1 Update
Browse files Browse the repository at this point in the history
  • Loading branch information
LOOHP committed Apr 28, 2020
1 parent 80b17af commit b797749
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 13 deletions.
2 changes: 2 additions & 0 deletions src/com/loohp/interactivechat/ConfigManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ public static void reloadConfig() {
}

public static void loadConfig() {
InteractiveChat.FilterUselessColorCodes = getConfig().getBoolean("Settings.FilterUselessColorCodes");

InteractiveChat.AllowMention = getConfig().getBoolean("Chat.AllowMention");

InteractiveChat.NoPermission = ChatColor.translateAlternateColorCodes('&', getConfig().getString("Messages.NoPermission"));
Expand Down
2 changes: 2 additions & 0 deletions src/com/loohp/interactivechat/InteractiveChat.java
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,8 @@ public class InteractiveChat extends JavaPlugin {
public static int UpdaterTaskID = -1;

public static HashMap<Player, String> essenNick = new HashMap<Player, String>();

public static boolean FilterUselessColorCodes = true;

@Override
public void onEnable() {
Expand Down
2 changes: 1 addition & 1 deletion src/com/loohp/interactivechat/Utils/ChatColorFilter.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
public class ChatColorFilter {

public static String removeUselessColorCodes(String string) {
return string.replaceAll("(§[0-9,a-f]){2,}", "");
return string.replaceAll("^(§[0-9,a-f,l-o,r])*(?=§[0-9,a-f,r])", "");
}

public static String filterIllegalColorCodes(String string) {
Expand Down
24 changes: 13 additions & 11 deletions src/com/loohp/interactivechat/Utils/CustomStringUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -108,17 +108,19 @@ public static List<BaseComponent> loadExtras(List<BaseComponent> baseComp) {
}
}

Iterator<BaseComponent> itr = list.iterator();
while (itr.hasNext()) {
BaseComponent base = itr.next();
if (base instanceof TextComponent) {
TextComponent text = (TextComponent) base;
if (text.getText().matches("§.")) {
itr.remove();
} else {
text.setText(ChatColorFilter.removeUselessColorCodes(text.getText()));
}
}
if (InteractiveChat.FilterUselessColorCodes) {
Iterator<BaseComponent> itr = list.iterator();
while (itr.hasNext()) {
BaseComponent base = itr.next();
if (base instanceof TextComponent) {
TextComponent text = (TextComponent) base;
if (text.getText().matches("^(§[0-9,a-f,l-o,r])*$")) {
itr.remove();
} else {
text.setText(ChatColorFilter.removeUselessColorCodes(text.getText()));
}
}
}
}
return list;
}
Expand Down
2 changes: 2 additions & 0 deletions src/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ Messages:
LimitReached: "&cPlease do now use excessive amount of placeholders in one message!"

Settings:
#Turn this off if some colors are missing
FilterUselessColorCodes: true
#A list of private message commands on your server
#The plugin will attempt to parse placeholder inside these commands.
#This list is in REGEX so you can do some more advanced matches.
Expand Down
2 changes: 1 addition & 1 deletion src/plugin.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: InteractiveChat
author: loohp
version: 2.1.0
version: 2.1.1
main: com.loohp.interactivechat.InteractiveChat
api-version: 1.13
description: Make the chat interactive
Expand Down

0 comments on commit b797749

Please sign in to comment.