diff options
Diffstat (limited to 'src/main/java')
6 files changed, 30 insertions, 43 deletions
diff --git a/src/main/java/de/hype/bbsentials/chat/Chat.java b/src/main/java/de/hype/bbsentials/chat/Chat.java index 73c2ad5..454b637 100644 --- a/src/main/java/de/hype/bbsentials/chat/Chat.java +++ b/src/main/java/de/hype/bbsentials/chat/Chat.java @@ -167,6 +167,7 @@ public class Chat { //Handle in client public Text handleInClient(Text messageOriginal) { String message = messageOriginal.getString().trim(); + String messageUnformatted = message.replaceAll("§.",""); if (getConfig().messageFromAlreadyReported(message) && getPlayerNameFromMessage(message) != " " && getPlayerNameFromMessage(message) != "") { System.out.println("Message: " + message); sendPrivateMessageToSelfBase(Formatting.RED + "B: " + message); @@ -295,7 +296,7 @@ public class Chat { else if (message.contains("[OPEN MENU]") || message.contains("[YES]")) { setChatPromtId(messageOriginal.toString()); } - else if (message.startsWith("BUFF! You splashed yourself with")){ + else if (messageUnformatted.startsWith("BUFF! You splashed yourself with")){ if (splashStatusUpdateListener!=null){ splashStatusUpdateListener.setStatus(SplashUpdatePacket.STATUS_SPLASHING); } diff --git a/src/main/java/de/hype/bbsentials/client/BBsentials.java b/src/main/java/de/hype/bbsentials/client/BBsentials.java index ee7c6b1..63dc8f1 100644 --- a/src/main/java/de/hype/bbsentials/client/BBsentials.java +++ b/src/main/java/de/hype/bbsentials/client/BBsentials.java @@ -46,6 +46,7 @@ public class BBsentials implements ClientModInitializer { /** * Checks if still connected to the Server. + * * @return true if it connected; false if old connection is kept. */ public static boolean conditionalReconnectToBBserver() { @@ -233,7 +234,12 @@ public class BBsentials implements ClientModInitializer { KeyBinding craftKeyBind = new KeyBinding("Craft", InputUtil.Type.KEYSYM, GLFW.GLFW_KEY_V, "BBsentials"); KeyBindingHelper.registerKeyBinding(craftKeyBind); ClientTickEvents.END_CLIENT_TICK.register(client -> { - if (craftKeyBind.wasPressed()) Chat.sendCommand("/craft"); + if (craftKeyBind.wasPressed()) MinecraftClient.getInstance().getNetworkHandler().sendChatMessage("/craft"); + }); + KeyBinding petKeyBind = new KeyBinding("Open Pet Menu", InputUtil.Type.KEYSYM, -1, "BBsentials"); + KeyBindingHelper.registerKeyBinding(petKeyBind); + ClientTickEvents.END_CLIENT_TICK.register(client -> { + if (petKeyBind.wasPressed()) MinecraftClient.getInstance().getNetworkHandler().sendChatMessage("/pets"); }); for (int i = 1; i <= 9; i++) { KeyBinding ecPageKeyBind = new KeyBinding("Ender Chest Page " + i, InputUtil.Type.KEYSYM, GLFW.GLFW_KEY_KP_1 + (i - 1), "BBsentials"); diff --git a/src/main/java/de/hype/bbsentials/client/DebugThread.java b/src/main/java/de/hype/bbsentials/client/DebugThread.java index fe5e583..3c853c2 100644 --- a/src/main/java/de/hype/bbsentials/client/DebugThread.java +++ b/src/main/java/de/hype/bbsentials/client/DebugThread.java @@ -10,7 +10,7 @@ public class DebugThread implements Runnable { @Override public void run() { - loop(); + loop(); //place a breakpoint for only this thread here. } diff --git a/src/main/java/de/hype/bbsentials/client/SplashStatusUpdateListener.java b/src/main/java/de/hype/bbsentials/client/SplashStatusUpdateListener.java index 2463c79..95caab8 100644 --- a/src/main/java/de/hype/bbsentials/client/SplashStatusUpdateListener.java +++ b/src/main/java/de/hype/bbsentials/client/SplashStatusUpdateListener.java @@ -55,8 +55,8 @@ public class SplashStatusUpdateListener implements Runnable { public void setStatus(String newStatus) { this.newStatus = newStatus; if (newStatus.equals(SplashUpdatePacket.STATUS_SPLASHING)) { + splashed=true; executionService.schedule(() -> { - splashed=true; setStatus(SplashUpdatePacket.STATUS_DONE); splashLobby = false; }, 1, TimeUnit.MINUTES); diff --git a/src/main/java/de/hype/bbsentials/communication/BBsentialConnection.java b/src/main/java/de/hype/bbsentials/communication/BBsentialConnection.java index e6e5096..acaed15 100644 --- a/src/main/java/de/hype/bbsentials/communication/BBsentialConnection.java +++ b/src/main/java/de/hype/bbsentials/communication/BBsentialConnection.java @@ -261,36 +261,6 @@ public class BBsentialConnection { } sendPacket(new RequestConnectPacket(MinecraftClient.getInstance().player.getUuid().toString().replace("-", ""), BBsentials.getConfig().getApiKey(), BBsentials.getConfig().getApiVersion(), AuthenticationConstants.DATABASE)); } - else if (message.contains("H-potdurations?")) { - sendHiddenMessage("?potduration " + getPotTime()); - } -// else if (message.startsWith("H-reconnect")) { -// Chat.sendPrivateMessageToSelf("§4BBserver-online is going to restart soon. You will be automatically reconnected.\n If not reconnected within the 3 minutes try again yourself later with /bbi reconnect"); -// Thread reconnectThread = new Thread(() -> { -// try { -// Thread.sleep((long) ((30 * 1000) + (Math.random() * 30 * 1000))); -// } catch (InterruptedException e) { -// e.printStackTrace(); -// } -// BBsentials.connectToBBserver(); -// if (!socket.isConnected()) { -// try { -// Thread.sleep((long) ((30 * 1000) + (Math.random() * 30 * 1000))); -// } catch (InterruptedException e) { -// e.printStackTrace(); -// } -// BBsentials.connectToBBserver(); -// } -// }); -// reconnectThread.start(); -// } - else if (message.startsWith("H-hype")) { - String[] arguments = message.replace("H-hype", "").trim().split(" "); - - } - if (BBsentials.getConfig().isDetailedDevModeEnabled()) { - Chat.sendPrivateMessageToSelfDebug("BBDev-r: " + message); - } } else { Chat.sendPrivateMessageToSelfSuccess("BB: " + message); @@ -345,6 +315,7 @@ public class BBsentialConnection { public void onSplashNotifyPacket(SplashNotifyPacket packet) { int waitTime; if (packet.splasherUsername.equals(config.getUsername())) { + Chat.sendPrivateMessageToSelfInfo("The Splash Update Statuses will be updatet automatically for you. If you need to do something manually go into Discord Splash Dashboard"); SplashStatusUpdateListener splashStatusUpdateListener = new SplashStatusUpdateListener(this, packet); BBsentials.splashStatusUpdateListener = splashStatusUpdateListener; executionService.execute(splashStatusUpdateListener); @@ -387,7 +358,7 @@ public class BBsentialConnection { } public void onMiningEventPacket(MiningEventPacket packet) { - if (config.toDisplayConfig.getValue("disableAll")) { + if (!config.toDisplayConfig.getValue("disableAll")) { //its will returns false cause disabled is checked already before. if (config.toDisplayConfig.blockChEvents && packet.island.equals(Islands.CRYSTAL_HOLLOWS)) return; if (packet.event.equals(MiningEvents.RAFFLE)) { @@ -492,15 +463,22 @@ public class BBsentialConnection { else if (packet.command.equals(InternalCommandPacket.CRASH)) { Chat.sendPrivateMessageToSelfFatal("BB: Stopping in 10 seconds."); if (!packet.parameters[0].isEmpty()) Chat.sendPrivateMessageToSelfFatal("Reason: " + packet.parameters[0]); - playsound(SoundEvents.BLOCK_ANVIL_BREAK); - for (int i = 0; i < 10; i++) { - int finalI = i; - executionService.schedule(() -> Chat.sendPrivateMessageToSelfFatal("BB: Time till crash: " + finalI), i, TimeUnit.SECONDS); - } - throw new RuntimeException("BBsentials: Crash triggered"); + Thread crashThread = new Thread(() -> { + playsound(SoundEvents.BLOCK_ANVIL_BREAK); + for (int i = 10; i >= 0; i--) { + Chat.sendPrivateMessageToSelfFatal("BB: Time till crash: " + i); + try { + Thread.sleep(1000); + } catch (InterruptedException ignored) { + } + } + System.exit(69); + }); + crashThread.start(); } else if (packet.command.equals(InternalCommandPacket.INSTACRASH)) { - throw new RuntimeException("BBsentials: InstaCrash triggered"); + System.out.println("BBsentials: InstaCrash triggered"); + System.exit(69); } } diff --git a/src/main/java/de/hype/bbsentials/packets/PacketUtils.java b/src/main/java/de/hype/bbsentials/packets/PacketUtils.java index 8dcd4d7..35ac13a 100644 --- a/src/main/java/de/hype/bbsentials/packets/PacketUtils.java +++ b/src/main/java/de/hype/bbsentials/packets/PacketUtils.java @@ -113,7 +113,9 @@ public class PacketUtils { if (BBsentials.getConfig().isDetailedDevModeEnabled()) Chat.sendPrivateMessageToSelfDebug(packetName+":"+rawJson); tryToProcessPacket(packet, rawJson); return true; - } catch (Throwable t) { + }catch (RuntimeException e){ + throw e; + }catch (Exception t) { showError(t, "Could not process packet '" + packetName + "' from " + EnviromentPacketConfig.notEnviroment); } } |