diff --git a/src/main/java/land/chipmunk/chayapak/chomens_bot/Bot.java b/src/main/java/land/chipmunk/chayapak/chomens_bot/Bot.java index 8b960eb..2edab2d 100644 --- a/src/main/java/land/chipmunk/chayapak/chomens_bot/Bot.java +++ b/src/main/java/land/chipmunk/chayapak/chomens_bot/Bot.java @@ -30,7 +30,7 @@ public class Bot { @Getter private String username; - @Getter private Session session; + @Getter public Session session; @Getter private ScheduledExecutorService executor = Executors.newScheduledThreadPool(100); @@ -92,13 +92,13 @@ public class Bot { } public void reconnect () { - if (session != null) session.disconnect("Disconnect"); - if (_username == null) username = RandomStringUtils.randomAlphabetic(8); else username = _username; Session session = new TcpClientSession(host, port, new MinecraftProtocol(username), null); + this.session = session; + session.addListener(new SessionAdapter() { // same stuff over and over yup @@ -156,8 +156,6 @@ public class Bot { } }); - this.session = session; - session.connect(); } diff --git a/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/EndCommand.java b/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/EndCommand.java index 7bcaaad..4caee50 100644 --- a/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/EndCommand.java +++ b/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/EndCommand.java @@ -36,7 +36,7 @@ public class EndCommand implements Command { public Component execute(CommandContext context, String[] args, String[] fullArgs) { final Bot bot = context.bot(); - bot.reconnect(); + bot.session().disconnect("End command"); return Component.text("success"); } diff --git a/src/main/java/land/chipmunk/chayapak/chomens_bot/song/NBSConverter.java b/src/main/java/land/chipmunk/chayapak/chomens_bot/song/NBSConverter.java index 6bedd2d..b60ab26 100644 --- a/src/main/java/land/chipmunk/chayapak/chomens_bot/song/NBSConverter.java +++ b/src/main/java/land/chipmunk/chayapak/chomens_bot/song/NBSConverter.java @@ -168,9 +168,10 @@ public class NBSConverter { // key += customInstrument.pitch; } - if (key < 33 || key > 57) { - continue; - } + // when the imposter is sus!!1! +// if (key < 33 || key > 57) { +// continue; +// } byte layerVolume = 100; if (nbsLayers.size() > note.layer) { diff --git a/src/main/java/land/chipmunk/chayapak/chomens_bot/util/NumberUtilities.java b/src/main/java/land/chipmunk/chayapak/chomens_bot/util/NumberUtilities.java index 91bbbb3..f14abe5 100644 --- a/src/main/java/land/chipmunk/chayapak/chomens_bot/util/NumberUtilities.java +++ b/src/main/java/land/chipmunk/chayapak/chomens_bot/util/NumberUtilities.java @@ -8,12 +8,10 @@ public class NumberUtilities { } public static float clamp (float value, float min, float max) { - if (value < min) return min; - return Math.min(value, max); + return Math.max(Math.min(value, max), min); } public static double clamp (double value, double min, double max) { - if (value < min) return min; - return Math.min(value, max); + return Math.max(Math.min(value, max), min); } }