aboutsummaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorHacktheTime <l4bg0jb7@duck.com>2023-10-19 23:10:56 +0200
committerHacktheTime <l4bg0jb7@duck.com>2023-10-19 23:10:56 +0200
commitd9501d4927e89da37274c3f20da2ecb657a7ae1f (patch)
tree2637291ddbaca128db66f56bbeadaad9de3d261d /common
parentc271e34e763ee0d89c5c35f9e27ac024306b1641 (diff)
downloadBBsentials-d9501d4927e89da37274c3f20da2ecb657a7ae1f.tar.gz
BBsentials-d9501d4927e89da37274c3f20da2ecb657a7ae1f.tar.bz2
BBsentials-d9501d4927e89da37274c3f20da2ecb657a7ae1f.zip
added party warp request
Diffstat (limited to 'common')
-rw-r--r--common/src/main/java/de/hype/bbsentials/common/chat/Chat.java72
-rw-r--r--common/src/main/java/de/hype/bbsentials/common/chat/Message.java4
-rw-r--r--common/src/main/java/de/hype/bbsentials/common/client/Config.java2
-rw-r--r--common/src/main/java/de/hype/bbsentials/common/communication/BBsentialConnection.java2
4 files changed, 38 insertions, 42 deletions
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 37a54b7..0d3662d 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
@@ -19,6 +19,7 @@ import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.concurrent.TimeUnit;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -167,47 +168,27 @@ public class Chat {
String lastPrompt = null;
if (cbMatcher.find()) {
lastPrompt = cbMatcher.group(1);
- String finalLastPrompt1 = lastPrompt;
- new Thread(new Runnable() {
- @Override
- public void run() {
- String promptCommand = "/cb " + finalLastPrompt1;
- BBsentials.getConfig().setLastChatPromptAnswer(promptCommand);
- if (BBsentials.config.isDevModeEnabled()) {
- Chat.sendPrivateMessageToSelfDebug("set the last prompt action too + \"" + promptCommand + "\"");
- }
- try {
- Thread.sleep(10 * 1000);
- } catch (InterruptedException e) {
- throw new RuntimeException(e);
- }
- BBsentials.getConfig().setLastChatPromptAnswer(null);
- return;
- }
- }).start();
+ setChatCommand("/cb " + lastPrompt,10);
}
if (yesMatcher.find()) {
lastPrompt = yesMatcher.group(1);
- String finalLastPrompt = lastPrompt;
- new Thread(new Runnable() {
- @Override
- public void run() {
- String promptCommand = "/chatprompt " + finalLastPrompt + " YES";
- BBsentials.getConfig().setLastChatPromptAnswer(promptCommand);
- if (BBsentials.config.isDevModeEnabled()) {
- Chat.sendPrivateMessageToSelfDebug("set the last prompt action too + \"" + promptCommand + "\"");
- }
- try {
- Thread.sleep(10 * 1000);
- } catch (InterruptedException e) {
- throw new RuntimeException(e);
- }
- BBsentials.getConfig().setLastChatPromptAnswer(null);
- return;
- }
- }).start();
+ setChatCommand("/chatprompt " + lastPrompt + " YES",10);
+ }
+ }
+ /**
+ *
+ * @param command the command to be executed
+ * @param timeBeforePerish in seconds before its reset to nothing
+ */
+ public static void setChatCommand(String command,int timeBeforePerish) {
+ BBsentials.getConfig().setLastChatPromptAnswer(command);
+ if (BBsentials.config.isDevModeEnabled()) {
+ Chat.sendPrivateMessageToSelfDebug("set the last prompt action too + \"" + command + "\"");
}
+ BBsentials.executionService.schedule(() -> {
+ BBsentials.getConfig().setLastChatPromptAnswer(null);
+ },10, TimeUnit.SECONDS);
}
public Message onEvent(Message text) {
@@ -315,7 +296,7 @@ public class Chat {
else if ((message.contains("Party Leader:") && !message.contains(BBsentials.getConfig().getUsername())) || message.equals("You are not currently in a party.") || (message.contains("warped the party into a Skyblock Dungeon") && !message.startsWith(BBsentials.getConfig().getUsername()) || (!message.startsWith("The party was transferred to " + BBsentials.getConfig().getUsername()) && message.startsWith("The party was transferred to"))) || messageUnformatted.endsWith(BBsentials.getConfig().getUsername() + " is now a Party Moderator") || (message.startsWith("The party was disbanded")) || (message.contains("You have joined ") && message.contains("'s party!")) || (message.contains("Party Leader, ") && message.contains(" , summoned you to their server.")) || (message.contains("warped to your dungeon"))) {
BBsentials.getConfig().setIsLeader(false);
if (BBsentials.getConfig().isDetailedDevModeEnabled()) {
- sendPrivateMessageToSelfDebug("Leader: " + BBsentials.getConfig().isLeader());
+ sendPrivateMessageToSelfDebug("Leader: " + BBsentials.getConfig().isPartyLeader());
}
}
else if (BBsentials.config.getPlayersInParty().length == 0 && messageUnformatted.endsWith("to the party! They have 60 seconds to accept")) {
@@ -334,7 +315,7 @@ public class Chat {
else if (((messageUnformatted.startsWith("Party Leader: ") && messageUnformatted.endsWith(BBsentials.getConfig().getUsername() + " ●"))) || (message.contains(BBsentials.getConfig().getUsername() + " warped the party to a SkyBlock dungeon!")) || message.startsWith("The party was transferred to " + BBsentials.getConfig().getUsername()) || message.getUnformattedString().endsWith(" has promoted " + BBsentials.getConfig().getUsername() + " to Party Leader") || (message.contains("warped to your dungeon"))) {
BBsentials.getConfig().setIsLeader(true);
if (BBsentials.getConfig().isDetailedDevModeEnabled()) {
- sendPrivateMessageToSelfDebug("Leader: " + BBsentials.getConfig().isLeader());
+ sendPrivateMessageToSelfDebug("Leader: " + BBsentials.getConfig().isPartyLeader());
}
}
else if (message.getUnformattedString().equals("Please type /report confirm to log your report for staff review.")) {
@@ -351,7 +332,18 @@ public class Chat {
}
else if (message.isFromParty()) {
-
+ if (message.getMessageContent().equals("warp")&&BBsentials.config.isPartyLeader()) {
+ if (BBsentials.config.getPlayersInParty().length == 1) {
+ Chat.sendCommand("/p warp");
+ }
+ else if (BBsentials.config.getPlayersInParty().length >= 10) {
+ //ignored because soo many players
+ }
+ else if (BBsentials.config.getPlayersInParty().length > 1) {
+ Chat.sendPrivateMessageToSelfText(Message.tellraw("[\"\",{\"text\":\"@username\",\"color\":\"red\"},\" \",\"is requesting a warp. Press \",{\"keybind\":\"Chat Prompt Yes / Open Menu\",\"color\":\"green\"},\" to warp the entire \",{\"text\":\"Party\",\"color\":\"gold\"},\".\"]"));
+ setChatCommand("/p warp",10);
+ }
+ }
}
else if (message.isMsg()) {
if (messageUnformatted.endsWith("bb:party me")) {
@@ -384,7 +376,7 @@ public class Chat {
}
public void sendNotification(String title, String text) {
- sendNotification(title, text,1);
+ sendNotification(title, text, 1);
}
public void sendNotification(String title, String text, float volume) {
diff --git a/common/src/main/java/de/hype/bbsentials/common/chat/Message.java b/common/src/main/java/de/hype/bbsentials/common/chat/Message.java
index a71b851..51f0646 100644
--- a/common/src/main/java/de/hype/bbsentials/common/chat/Message.java
+++ b/common/src/main/java/de/hype/bbsentials/common/chat/Message.java
@@ -25,6 +25,10 @@ public class Message {
String json = "{\"text\":\"" + escapedString + "\"}";
return new Message(json, string);
}
+ public static Message tellraw(String json) {
+ json=json.replace("@username",BBsentials.config.getUsername());
+ return new Message(json, "");
+ }
//
public String getJson() {
return text;
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 47809d9..ee74855 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
@@ -126,7 +126,7 @@ public class Config implements Serializable {
return username;
}
- public boolean isLeader() {
+ public boolean isPartyLeader() {
return isLeader;
}
diff --git a/common/src/main/java/de/hype/bbsentials/common/communication/BBsentialConnection.java b/common/src/main/java/de/hype/bbsentials/common/communication/BBsentialConnection.java
index 931252c..23eda94 100644
--- a/common/src/main/java/de/hype/bbsentials/common/communication/BBsentialConnection.java
+++ b/common/src/main/java/de/hype/bbsentials/common/communication/BBsentialConnection.java
@@ -313,7 +313,7 @@ public class BBsentialConnection {
if (!(packet.extraMessage == null || packet.extraMessage.isEmpty())) {
tellrawText = tellrawText.replace("@extramessage", " : " + packet.extraMessage);
}
- Chat.sendPrivateMessageToSelfText(new Message(tellrawText, ""));
+ Chat.sendPrivateMessageToSelfText(Message.tellraw(tellrawText));
}
}
else {