aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCalMWolfs <94038482+CalMWolfs@users.noreply.github.com>2024-03-12 09:27:31 +1100
committerGitHub <noreply@github.com>2024-03-11 23:27:31 +0100
commite6cf81f7fd2389d1fd4a3d312cdfa3308d09279c (patch)
treea18a286ea97047fbc1984ae4eff8d9ba05ecca60
parent4fc87fe42d9668c94c2e9208a15abd39dbb0c3ff (diff)
downloadNotEnoughUpdates-e6cf81f7fd2389d1fd4a3d312cdfa3308d09279c.tar.gz
NotEnoughUpdates-e6cf81f7fd2389d1fd4a3d312cdfa3308d09279c.tar.bz2
NotEnoughUpdates-e6cf81f7fd2389d1fd4a3d312cdfa3308d09279c.zip
Fix: Click for pv in chat (#1041)
* fix pv in chat * change string name
-rw-r--r--build.gradle.kts7
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/listener/ChatListener.java88
2 files changed, 49 insertions, 46 deletions
diff --git a/build.gradle.kts b/build.gradle.kts
index 9c859169..c465df33 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -21,6 +21,7 @@
import neubs.NEUBuildFlags
import neubs.applyPublishingInformation
import neubs.setVersionFromEnvironment
+import org.apache.commons.lang3.SystemUtils
import java.net.URL
plugins {
@@ -56,6 +57,12 @@ loom {
}
}
runConfigs {
+ "client" {
+ if (SystemUtils.IS_OS_MAC_OSX) {
+ vmArgs.remove("-XstartOnFirstThread")
+ }
+ vmArgs.add("-Xmx4G")
+ }
"server" {
isIdeConfigGenerated = false
}
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 16b8493f..22d360e5 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/listener/ChatListener.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/listener/ChatListener.java
@@ -117,62 +117,58 @@ public class ChatListener {
private IChatComponent replaceSocialControlsWithPV(IChatComponent chatComponent) {
+ if (NotEnoughUpdates.INSTANCE.config.misc.replaceSocialOptions1 == 0 || !NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard()) {
+ return chatComponent;
+ }
- if (NotEnoughUpdates.INSTANCE.config.misc.replaceSocialOptions1 > 0 &&
- 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) ||
- // 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;
- 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";
- } else if (!siblings.isEmpty() && siblings.size() > 1 && siblings.get(1).getChatStyle() != null) {
-
- ClickEvent chatClickEvent = chatComponent.getSiblings().get(chatComponentsCount).getChatStyle().getChatClickEvent();
- if (chatClickEvent != null) {
- if (chatClickEvent.getValue().startsWith("/socialoptions")) {
- startsWith = "/socialoptions";
- }
- }
- }
+ List<IChatComponent> siblings = chatComponent.getSiblings();
+ if (siblings.size() < 2) return chatComponent;
+
+ IChatComponent targetedComponent = siblings.get(siblings.size() - 2);
- if (startsWith != null) {
- String username = startsWith.equals("/viewprofile") ?
- Utils.getNameFromChatComponent(chatComponent) :
- chatComponent.getSiblings().get(chatComponentsCount).getChatStyle().getChatClickEvent().getValue().substring(15);
- username = username.replaceAll("[^a-zA-Z0-9_]", "");
+ String chatClickCommand = getChatClickEvent(siblings.get(0));
- if (NotEnoughUpdates.INSTANCE.config.misc.replaceSocialOptions1 == 1) {
+ if (chatClickCommand == null) {
+ chatClickCommand = getChatClickEvent(targetedComponent);
+ }
+ if (chatClickCommand == null) return chatComponent;
- ChatStyle pvClickStyle = getPVChatStyle(username);
- chatComponent.getSiblings().get(chatComponentsCount).setChatStyle(pvClickStyle);
- return chatComponent;
- } else if (NotEnoughUpdates.INSTANCE.config.misc.replaceSocialOptions1 == 2) {
+ String username = chatClickCommand.equals("/viewprofile") ?
+ Utils.getNameFromChatComponent(chatComponent) :
+ targetedComponent.getChatStyle().getChatClickEvent().getValue().substring(15);
+ username = username.replaceAll("[^a-zA-Z0-9_]", "");
- ChatStyle ahClickStyle = Utils.createClickStyle(
- ClickEvent.Action.RUN_COMMAND,
- "/ah " + username,
- "" + EnumChatFormatting.YELLOW + "Click to open " + EnumChatFormatting.AQUA + EnumChatFormatting.BOLD +
- username + EnumChatFormatting.RESET + EnumChatFormatting.YELLOW + "'s /ah page"
- );
+ if (NotEnoughUpdates.INSTANCE.config.misc.replaceSocialOptions1 == 1) {
- chatComponent.getSiblings().get(chatComponentsCount).setChatStyle(ahClickStyle);
- return chatComponent;
- }
- } // wanted to add this for guild but guild uses uuid :sad:
+ ChatStyle pvClickStyle = getPVChatStyle(username);
+ targetedComponent.setChatStyle(pvClickStyle);
+
+ return chatComponent;
+ } else if (NotEnoughUpdates.INSTANCE.config.misc.replaceSocialOptions1 == 2) {
+
+ ChatStyle ahClickStyle = Utils.createClickStyle(
+ ClickEvent.Action.RUN_COMMAND,
+ "/ah " + username,
+ "" + EnumChatFormatting.YELLOW + "Click to open " + EnumChatFormatting.AQUA + EnumChatFormatting.BOLD +
+ username + EnumChatFormatting.RESET + EnumChatFormatting.YELLOW + "'s /ah page"
+ );
+
+ targetedComponent.setChatStyle(ahClickStyle);
+ return chatComponent;
}
return chatComponent;
}
+ private String getChatClickEvent(IChatComponent sibling) {
+ if (sibling.getChatStyle() != null && sibling.getChatStyle().getChatClickEvent() != null) {
+ String clickEvent = sibling.getChatStyle().getChatClickEvent().getValue();
+
+ if (clickEvent.startsWith("/socialoptions")) return "/socialoptions";
+ if (clickEvent.startsWith("/viewprofile")) return "/viewprofile";
+ }
+ return null;
+ }
+
private static ChatStyle getPVChatStyle(String username) {
username = username.replaceAll("[^a-zA-Z0-9_]", "");
return Utils.createClickStyle(