From 80ffe4a632c9d1cc2c7021b990939916fd0155e0 Mon Sep 17 00:00:00 2001 From: HacktheTime Date: Mon, 23 Oct 2023 21:57:14 +0200 Subject: added Numpad codes. limitations: currently missing scroll pane so youre limited because you cant edit the lower ones commands are sent to the server so client side commands do not work unfortunately. --- .../src/main/java/de/hype/bbsentials/common/chat/Chat.java | 12 +++++++++--- .../java/de/hype/bbsentials/common/client/BBsentials.java | 2 +- .../main/java/de/hype/bbsentials/common/client/Config.java | 10 +++++++--- .../java/de/hype/bbsentials/common/mclibraries/MCChat.java | 11 +++++++++-- 4 files changed, 26 insertions(+), 9 deletions(-) (limited to 'common/src/main') diff --git a/common/src/main/java/de/hype/bbsentials/common/chat/Chat.java b/common/src/main/java/de/hype/bbsentials/common/chat/Chat.java index 0d3662d..000cd70 100644 --- a/common/src/main/java/de/hype/bbsentials/common/chat/Chat.java +++ b/common/src/main/java/de/hype/bbsentials/common/chat/Chat.java @@ -191,22 +191,28 @@ public class Chat { },10, TimeUnit.SECONDS); } - public Message onEvent(Message text) { + public Message onEvent(Message text, boolean actionbar) { if (!isSpam(text.getString())) { if (BBsentials.getConfig().isDetailedDevModeEnabled()) { System.out.println("got a message: " + text.getJson()); } BBsentials.executionService.execute(() -> processThreaded(text)); - return processNotThreaded(text); + return processNotThreaded(text, actionbar); } return text; // Return the original message if it is spam } //Handle in the messages which need to be modified here - public Message processNotThreaded(Message message) { + public Message processNotThreaded(Message message, boolean actionbar) { // if (message.isFromParty()) { // message.replaceInJson("\"action\":\"run_command\",\"value\":\"/viewprofile", "\"action\":\"run_command\",\"value\":\"/bviewprofile " + messageUnformatted.split(">", 1)[1].trim()); // } + if (actionbar && !BBsentials.config.overwriteActionBar.isEmpty()) { + if (message.getUnformattedString().equals(BBsentials.config.overwriteActionBar.replaceAll("ยง.", ""))) { + return message; + } + return null; + } if (message.isFromReportedUser()) { sendPrivateMessageToSelfBase(Formatting.RED + "B: " + message.getUnformattedString()); return null; diff --git a/common/src/main/java/de/hype/bbsentials/common/client/BBsentials.java b/common/src/main/java/de/hype/bbsentials/common/client/BBsentials.java index 9344c4c..173d8d0 100644 --- a/common/src/main/java/de/hype/bbsentials/common/client/BBsentials.java +++ b/common/src/main/java/de/hype/bbsentials/common/client/BBsentials.java @@ -18,6 +18,7 @@ public class BBsentials { public static SplashStatusUpdateListener splashStatusUpdateListener; private static Thread bbthread; private static boolean initialised = false; + public static Chat chat = new Chat(); public static Config getConfig() { return config; @@ -78,7 +79,6 @@ public class BBsentials { config = Config.load(); executionService.scheduleAtFixedRate(EnvironmentCore.debug, 0, 20, TimeUnit.SECONDS); if (config.doGammaOverride) EnvironmentCore.mcoptions.setGamma(10); - Chat chat = new Chat(); if (Config.isBingoTime() || config.overrideBingoTime()) { connectToBBserver(); } diff --git a/common/src/main/java/de/hype/bbsentials/common/client/Config.java b/common/src/main/java/de/hype/bbsentials/common/client/Config.java index ee74855..62e5c16 100644 --- a/common/src/main/java/de/hype/bbsentials/common/client/Config.java +++ b/common/src/main/java/de/hype/bbsentials/common/client/Config.java @@ -20,7 +20,9 @@ public class Config implements Serializable { //You can change again // set automatically - private transient boolean isLeader; + private transient boolean isPartyLeader; + public transient String overwriteActionBar = ""; + public transient String alreadyReported = ""; public String[] bbsentialsRoles = {""}; public static List partyMembers = new ArrayList<>(); @@ -127,11 +129,11 @@ public class Config implements Serializable { } public boolean isPartyLeader() { - return isLeader; + return isPartyLeader; } public void setIsLeader(boolean value) { - isLeader = value; + isPartyLeader = value; } public String getNickname() { @@ -193,6 +195,8 @@ public class Config implements Serializable { } public boolean hasBBRoles(String roleName) { + if (roleName == null) return true; + if (roleName.isEmpty()) return true; for (String role : bbsentialsRoles) { if (role.equalsIgnoreCase(roleName)) { return true; diff --git a/common/src/main/java/de/hype/bbsentials/common/mclibraries/MCChat.java b/common/src/main/java/de/hype/bbsentials/common/mclibraries/MCChat.java index 08cbff8..de46f84 100644 --- a/common/src/main/java/de/hype/bbsentials/common/mclibraries/MCChat.java +++ b/common/src/main/java/de/hype/bbsentials/common/mclibraries/MCChat.java @@ -1,13 +1,20 @@ package de.hype.bbsentials.common.mclibraries; import de.hype.bbsentials.common.chat.Message; +import de.hype.bbsentials.common.client.BBsentials; public interface MCChat { void init(); void sendChatMessage(String message); void sendClientSideMessage(Message message); - void sendClientSideMessage(Message message, boolean actionbar); - + default void sendClientSideMessage(Message message, boolean actionbar) { + if (BBsentials.config.swapActionBarChat && !BBsentials.config.swapOnlyNormal) { + actionbar = !actionbar; + } + else { + sendClientSideMessage(message); + } + } void showActionBar(Message message); } -- cgit