diff options
author | Ole Maduch <120584379+Olemagic@users.noreply.github.com> | 2023-08-23 19:26:45 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-08-23 19:26:45 +0200 |
commit | e56431fb8e825471404de1a0ab41c75a8603a3c8 (patch) | |
tree | 301e6329433c5abdb47b45a0d1b96cd23b1ba550 | |
parent | 10defb84a6f3e742838b969110133351ed6e38a1 (diff) | |
download | NotEnoughUpdates-e56431fb8e825471404de1a0ab41c75a8603a3c8.tar.gz NotEnoughUpdates-e56431fb8e825471404de1a0ab41c75a8603a3c8.tar.bz2 NotEnoughUpdates-e56431fb8e825471404de1a0ab41c75a8603a3c8.zip |
Made opening pv/ah from clicking the name in chat work when you have sb levels disabled (#795)
* chatpv works with levels disabled
* fixed comments
-rw-r--r-- | src/main/java/io/github/moulberry/notenoughupdates/listener/ChatListener.java | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/listener/ChatListener.java b/src/main/java/io/github/moulberry/notenoughupdates/listener/ChatListener.java index 508db557..22448cbc 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/listener/ChatListener.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/listener/ChatListener.java @@ -124,21 +124,21 @@ public class ChatListener { ((!chatComponent.getSiblings().isEmpty() && chatComponent.getSiblings().get(0).getChatStyle() != null && chatComponent.getSiblings().get(0).getChatStyle().getChatClickEvent() != null && chatComponent.getSiblings().get(0).getChatStyle().getChatClickEvent().getAction() == ClickEvent.Action.RUN_COMMAND) || - // Party and guild chat components are different from global chats, so need to check for them here - // Party being 0 and global chat being 1 + // Party/global chat with levels off components are different from global chat with levels on, so need to check for them here + // Party/global without levels being 0 and global with levels being 1 (!chatComponent.getSiblings().isEmpty() && chatComponent.getSiblings().size() > 1 && chatComponent.getSiblings().get(1).getChatStyle() != null && chatComponent.getSiblings().get(1).getChatStyle().getChatClickEvent() != null && chatComponent.getSiblings().get(1).getChatStyle().getChatClickEvent().getAction() == ClickEvent.Action.RUN_COMMAND))) { String startsWith = null; - int partyOrPublic = 1; - List<IChatComponent> siblings = chatComponent.getSiblings(); + int chatComponentsCount = siblings.size()-2; + if (!siblings.isEmpty() && siblings.get(0).getChatStyle() != null && siblings.get(0).getChatStyle().getChatClickEvent() != null && siblings.get(0).getChatStyle().getChatClickEvent().getValue().startsWith("/viewprofile")) { startsWith = "/viewprofile"; - partyOrPublic = 0; } else if (!siblings.isEmpty() && siblings.size() > 1 && siblings.get(1).getChatStyle() != null) { - ClickEvent chatClickEvent = chatComponent.getSiblings().get(1).getChatStyle().getChatClickEvent(); + + ClickEvent chatClickEvent = chatComponent.getSiblings().get(chatComponentsCount).getChatStyle().getChatClickEvent(); if (chatClickEvent != null) { if (chatClickEvent.getValue().startsWith("/socialoptions")) { startsWith = "/socialoptions"; @@ -147,14 +147,14 @@ public class ChatListener { } if (startsWith != null) { - String username = partyOrPublic == 0 ? + String username = startsWith.equals("/viewprofile") ? Utils.getNameFromChatComponent(chatComponent) : - chatComponent.getSiblings().get(partyOrPublic/* Should always be 1 in this case lol*/).getChatStyle().getChatClickEvent().getValue().substring(15); + chatComponent.getSiblings().get(chatComponentsCount).getChatStyle().getChatClickEvent().getValue().substring(15); if (NotEnoughUpdates.INSTANCE.config.misc.replaceSocialOptions1 == 1) { ChatStyle pvClickStyle = getPVChatStyle(username); - chatComponent.getSiblings().get(partyOrPublic).setChatStyle(pvClickStyle); + chatComponent.getSiblings().get(chatComponentsCount).setChatStyle(pvClickStyle); return chatComponent; } else if (NotEnoughUpdates.INSTANCE.config.misc.replaceSocialOptions1 == 2) { @@ -165,7 +165,7 @@ public class ChatListener { username + EnumChatFormatting.RESET + EnumChatFormatting.YELLOW + "'s /ah page" ); - chatComponent.getSiblings().get(partyOrPublic).setChatStyle(ahClickStyle); + chatComponent.getSiblings().get(chatComponentsCount).setChatStyle(ahClickStyle); return chatComponent; } } // wanted to add this for guild but guild uses uuid :sad: |