aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/io
diff options
context:
space:
mode:
authorNopoTheGamer <40329022+NopoTheGamer@users.noreply.github.com>2023-07-17 08:01:48 +1000
committerGitHub <noreply@github.com>2023-07-17 00:01:48 +0200
commit79e8fa011e79d79d9df4fb8f74421d920b38cd79 (patch)
treea7dc5dec89de98c0040fb8e176f5dc82c963b9bd /src/main/java/io
parent5cd149b7f1ee77db531eea14520e305515af5165 (diff)
downloadNotEnoughUpdates-79e8fa011e79d79d9df4fb8f74421d920b38cd79.tar.gz
NotEnoughUpdates-79e8fa011e79d79d9df4fb8f74421d920b38cd79.tar.bz2
NotEnoughUpdates-79e8fa011e79d79d9df4fb8f74421d920b38cd79.zip
Fix chat pv and ah (#771)
Diffstat (limited to 'src/main/java/io')
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/listener/ChatListener.java40
1 files changed, 17 insertions, 23 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 53b796ed..0817a7f9 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/listener/ChatListener.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/listener/ChatListener.java
@@ -118,25 +118,27 @@ public class ChatListener {
private IChatComponent replaceSocialControlsWithPV(IChatComponent chatComponent) {
+
if (NotEnoughUpdates.INSTANCE.config.misc.replaceSocialOptions1 > 0 &&
- ((chatComponent.getChatStyle() != null &&
- chatComponent.getChatStyle().getChatClickEvent() != null &&
- chatComponent.getChatStyle().getChatClickEvent().getAction() == ClickEvent.Action.RUN_COMMAND) ||
- // Party and guild chat components are different from global chats, so need to check for them here
- (!chatComponent.getSiblings().isEmpty() && chatComponent.getSiblings().get(0).getChatStyle() != null &&
+ NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard() &&
+ ((!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)) &&
- NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard()) {
+ 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
+ (!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;
- boolean partyOrGuildChat = false;
+ int partyOrPublic = 1;
List<IChatComponent> siblings = chatComponent.getSiblings();
if (!siblings.isEmpty() && siblings.get(0).getChatStyle() != null && siblings.get(0).getChatStyle().getChatClickEvent() != null && siblings.get(0).getChatStyle().getChatClickEvent().getValue().startsWith("/viewprofile")) {
startsWith = "/viewprofile";
- partyOrGuildChat = true;
- } else {
- ClickEvent chatClickEvent = chatComponent.getChatStyle().getChatClickEvent();
+ partyOrPublic = 0;
+ } else if (!siblings.isEmpty() && siblings.size() > 1 && siblings.get(1).getChatStyle() != null) {
+ ClickEvent chatClickEvent = chatComponent.getSiblings().get(1).getChatStyle().getChatClickEvent();
if (chatClickEvent != null) {
if (chatClickEvent.getValue().startsWith("/socialoptions")) {
startsWith = "/socialoptions";
@@ -145,18 +147,14 @@ public class ChatListener {
}
if (startsWith != null) {
- String username = partyOrGuildChat ?
+ String username = partyOrPublic == 0 ?
Utils.getNameFromChatComponent(chatComponent) :
- chatComponent.getChatStyle().getChatClickEvent().getValue().substring(15);
+ chatComponent.getSiblings().get(partyOrPublic/* Should always be 1 in this case lol*/).getChatStyle().getChatClickEvent().getValue().substring(15);
if (NotEnoughUpdates.INSTANCE.config.misc.replaceSocialOptions1 == 1) {
ChatStyle pvClickStyle = getPVChatStyle(username);
- if (partyOrGuildChat) {
- chatComponent.getSiblings().get(0).setChatStyle(pvClickStyle);
- } else {
- chatComponent.setChatStyle(pvClickStyle);
- }
+ chatComponent.getSiblings().get(partyOrPublic).setChatStyle(pvClickStyle);
return chatComponent;
} else if (NotEnoughUpdates.INSTANCE.config.misc.replaceSocialOptions1 == 2) {
@@ -167,11 +165,7 @@ public class ChatListener {
username + EnumChatFormatting.RESET + EnumChatFormatting.YELLOW + "'s /ah page"
);
- if (partyOrGuildChat) {
- chatComponent.getSiblings().get(0).setChatStyle(ahClickStyle);
- } else {
- chatComponent.setChatStyle(ahClickStyle);
- }
+ chatComponent.getSiblings().get(partyOrPublic).setChatStyle(ahClickStyle);
return chatComponent;
}
} // wanted to add this for guild but guild uses uuid :sad: