From 422554c627db1c0bf8867135fa32f4a988ea0e9c Mon Sep 17 00:00:00 2001 From: LOOHP Date: Wed, 6 May 2020 12:43:02 +0800 Subject: [PATCH] 2.1.10 Update --- .../Modules/PlayernameDisplay.java | 3 ++- .../Utils/ChatComponentUtils.java | 25 +++++++++++++++++++ src/plugin.yml | 2 +- 3 files changed, 28 insertions(+), 2 deletions(-) diff --git a/src/com/loohp/interactivechat/Modules/PlayernameDisplay.java b/src/com/loohp/interactivechat/Modules/PlayernameDisplay.java index 30ef1086..3020a69e 100644 --- a/src/com/loohp/interactivechat/Modules/PlayernameDisplay.java +++ b/src/com/loohp/interactivechat/Modules/PlayernameDisplay.java @@ -15,6 +15,7 @@ import com.loohp.interactivechat.InteractiveChat; import com.loohp.interactivechat.ObjectHolders.ReplaceTextBundle; import com.loohp.interactivechat.Utils.ChatColorUtils; +import com.loohp.interactivechat.Utils.ChatComponentUtils; import com.loohp.interactivechat.Utils.CustomStringUtils; import me.clip.placeholderapi.PlaceholderAPI; @@ -53,7 +54,7 @@ public static BaseComponent processPlayer(String placeholder, Player player, Str List newlist = new ArrayList(); for (BaseComponent base : basecomponentlist) { - if (matched.contains(base)) { + if (matched.stream().anyMatch(each -> ChatComponentUtils.areSimilar(each, base))) { newlist.add(base); } else if (!(base instanceof TextComponent)) { newlist.add(base); diff --git a/src/com/loohp/interactivechat/Utils/ChatComponentUtils.java b/src/com/loohp/interactivechat/Utils/ChatComponentUtils.java index 5d9de882..dcc535f7 100644 --- a/src/com/loohp/interactivechat/Utils/ChatComponentUtils.java +++ b/src/com/loohp/interactivechat/Utils/ChatComponentUtils.java @@ -10,6 +10,31 @@ public class ChatComponentUtils { + public static boolean areSimilar(BaseComponent base1, BaseComponent base2) { + if (!areEventsSimilar(base1, base2)) { + return false; + } + if (!base1.getColor().equals(base2.getColor())) { + return false; + } + if (base1.isBold() != base2.isBold()) { + return false; + } + if (base1.isItalic() != base2.isItalic()) { + return false; + } + if (base1.isObfuscated() != base2.isObfuscated()) { + return false; + } + if (base1.isStrikethrough() != base2.isStrikethrough()) { + return false; + } + if (base1.isUnderlined() != base2.isUnderlined()) { + return false; + } + return true; + } + public static boolean areEventsSimilar(BaseComponent base1, BaseComponent base2) { boolean clickSim = false; boolean hoverSim = false; diff --git a/src/plugin.yml b/src/plugin.yml index 9589385c..a05d9484 100644 --- a/src/plugin.yml +++ b/src/plugin.yml @@ -1,6 +1,6 @@ name: InteractiveChat author: loohp -version: 2.1.9 +version: 2.1.10 main: com.loohp.interactivechat.InteractiveChat api-version: 1.13 description: Make the chat interactive