From 1e8c85d2bbf1d8a6fb7bc125becd790c15654dbe Mon Sep 17 00:00:00 2001 From: HacktheTime Date: Tue, 26 Sep 2023 17:01:49 +0200 Subject: null pointer connection bug fixes added contributers to mod json --- src/main/java/de/hype/bbsentials/chat/Chat.java | 3 ++- .../bbsentials/client/Commands/CommandsOLD.java | 25 ++++------------------ .../communication/BBsentialConnection.java | 12 +++++++---- 3 files changed, 14 insertions(+), 26 deletions(-) (limited to 'src/main/java/de/hype') diff --git a/src/main/java/de/hype/bbsentials/chat/Chat.java b/src/main/java/de/hype/bbsentials/chat/Chat.java index 9e6a01e..1685cf7 100644 --- a/src/main/java/de/hype/bbsentials/chat/Chat.java +++ b/src/main/java/de/hype/bbsentials/chat/Chat.java @@ -188,8 +188,9 @@ public class Chat { else if (message.contains("invited you to join their party")) { if (lastPartyDisbandedMessage != null && partyDisbandedMap != null) { Instant lastDisbandedInstant = partyDisbandedMap.get(getPlayerNameFromMessage(lastPartyDisbandedMessage)); + if (config.acceptReparty){ if (lastDisbandedInstant != null && lastDisbandedInstant.isAfter(Instant.now().minusSeconds(20)) && (getPlayerNameFromMessage(message).equals(getPlayerNameFromMessage(lastPartyDisbandedMessage)))) { - sendCommand("/p accept " + getPlayerNameFromMessage(lastPartyDisbandedMessage)); + sendCommand("/p accept " + getPlayerNameFromMessage(lastPartyDisbandedMessage));} } } if (!MinecraftClient.getInstance().isWindowFocused()) { diff --git a/src/main/java/de/hype/bbsentials/client/Commands/CommandsOLD.java b/src/main/java/de/hype/bbsentials/client/Commands/CommandsOLD.java index 11b3dda..74de17a 100644 --- a/src/main/java/de/hype/bbsentials/client/Commands/CommandsOLD.java +++ b/src/main/java/de/hype/bbsentials/client/Commands/CommandsOLD.java @@ -158,7 +158,7 @@ public class CommandsOLD { .then(ClientCommandManager.argument("Z", IntegerArgumentType.integer()) .then(ClientCommandManager.argument("ContactWay", StringArgumentType.string()) .suggests(((context, builder) -> { - return CommandSource.suggestMatching(new String[]{"/msg " + getConfig().getUsername() + " bb:party me", "/p join " + config.getUsername()}, builder); + return CommandSource.suggestMatching(new String[]{"\"/msg " + getConfig().getUsername() + " bb:party me\"", "\"/p join " + config.getUsername()+"\""}, builder); })) .executes((context) -> { String item = StringArgumentType.getString(context, "Item"); @@ -178,23 +178,6 @@ public class CommandsOLD { ) ); });/*chchest*/ - event.register((dispatcher, registryAccess) -> { - dispatcher.register( - ClientCommandManager.literal("bbserver") - .then(ClientCommandManager.argument("Message", StringArgumentType.greedyString()) - .executes((context) -> { - String message = StringArgumentType.getString(context, "Message"); - if (message.equals("bb:reconnect")) { - BBsentials.connectToBBserver(); - } - else { - BBsentials.bbserver.sendMessage(message); - } - return 1; - }) - ) - ); - });/*BBserver*/ event.register((dispatcher, registryAccess) -> { dispatcher.register( ClientCommandManager.literal("bc") @@ -283,7 +266,7 @@ public class CommandsOLD { ) .executes((context) -> { int hub = IntegerArgumentType.getInteger(context, "Hub"); - String location = "bea"; + String location = StringArgumentType.getString(context, "location"); boolean lessWaste = Boolean.parseBoolean(StringArgumentType.getString(context, "lasswaste")); splashAnnounce(hub, location, "", lessWaste); return 1; @@ -291,7 +274,7 @@ public class CommandsOLD { )) .executes((context) -> { int hub = IntegerArgumentType.getInteger(context, "Hub"); - String location = StringArgumentType.getString(context, "location"); + String location = "bea"; splashAnnounce(hub, location, "", true); return 1; }) @@ -320,7 +303,7 @@ public class CommandsOLD { ClientCommandManager.literal(commandName) .executes((context) -> { try { - BBsentials.bbserver.sendPacket(new MiningEventPacket(event,//TODO get the island + BBsentials.bbserver.sendPacket(new MiningEventPacket(event, config.getUsername(), Objects.requireNonNull(BBUtils.getCurrentIsland()))); } catch (Exception e) { Chat.sendPrivateMessageToSelf("§c" + e.getMessage()); diff --git a/src/main/java/de/hype/bbsentials/communication/BBsentialConnection.java b/src/main/java/de/hype/bbsentials/communication/BBsentialConnection.java index 53e534c..a40c621 100644 --- a/src/main/java/de/hype/bbsentials/communication/BBsentialConnection.java +++ b/src/main/java/de/hype/bbsentials/communication/BBsentialConnection.java @@ -198,6 +198,7 @@ public class BBsentialConnection { } } catch (InterruptedException e) { e.printStackTrace(); + } catch (NullPointerException ignored) { } }); messageSenderThread.start(); @@ -227,8 +228,11 @@ public class BBsentialConnection { if (BBsentials.getConfig().isDetailedDevModeEnabled()) { Chat.sendPrivateMessageToSelf("§bBBDev-s: " + message); } - if (socket.isConnected() && writer != null) { - writer.println(message); + try { + if (socket.isConnected() && writer != null) { + writer.println(message); + } + } catch (NullPointerException ignored) { } } @@ -348,7 +352,7 @@ public class BBsentialConnection { int waitTime; if (packet.splasherUsername.equals(config.getUsername())) { - SplashStatusUpdateListener splashStatusUpdateListener = new SplashStatusUpdateListener(this,packet); + SplashStatusUpdateListener splashStatusUpdateListener = new SplashStatusUpdateListener(this, packet); BBsentials.splashStatusUpdateListener = splashStatusUpdateListener; executionService.submit(splashStatusUpdateListener); } @@ -362,7 +366,7 @@ public class BBsentialConnection { } BBsentials.executionService.schedule(() -> { SplashManager.display(packet.splashId); - }, waitTime, TimeUnit.MILLISECONDS); + }, waitTime, TimeUnit.MILLISECONDS); } } -- cgit