end command fix + mess with clamp and nbs

seems real
This commit is contained in:
Chayapak 2023-04-01 07:39:32 +07:00
parent e739e07a32
commit 99a773a116
4 changed files with 10 additions and 13 deletions

View file

@ -30,7 +30,7 @@ public class Bot {
@Getter private String username; @Getter private String username;
@Getter private Session session; @Getter public Session session;
@Getter private ScheduledExecutorService executor = Executors.newScheduledThreadPool(100); @Getter private ScheduledExecutorService executor = Executors.newScheduledThreadPool(100);
@ -92,13 +92,13 @@ public class Bot {
} }
public void reconnect () { public void reconnect () {
if (session != null) session.disconnect("Disconnect");
if (_username == null) username = RandomStringUtils.randomAlphabetic(8); if (_username == null) username = RandomStringUtils.randomAlphabetic(8);
else username = _username; else username = _username;
Session session = new TcpClientSession(host, port, new MinecraftProtocol(username), null); Session session = new TcpClientSession(host, port, new MinecraftProtocol(username), null);
this.session = session;
session.addListener(new SessionAdapter() { session.addListener(new SessionAdapter() {
// same stuff over and over yup // same stuff over and over yup
@ -156,8 +156,6 @@ public class Bot {
} }
}); });
this.session = session;
session.connect(); session.connect();
} }

View file

@ -36,7 +36,7 @@ public class EndCommand implements Command {
public Component execute(CommandContext context, String[] args, String[] fullArgs) { public Component execute(CommandContext context, String[] args, String[] fullArgs) {
final Bot bot = context.bot(); final Bot bot = context.bot();
bot.reconnect(); bot.session().disconnect("End command");
return Component.text("success"); return Component.text("success");
} }

View file

@ -168,9 +168,10 @@ public class NBSConverter {
// key += customInstrument.pitch; // key += customInstrument.pitch;
} }
if (key < 33 || key > 57) { // when the imposter is sus!!1!
continue; // if (key < 33 || key > 57) {
} // continue;
// }
byte layerVolume = 100; byte layerVolume = 100;
if (nbsLayers.size() > note.layer) { if (nbsLayers.size() > note.layer) {

View file

@ -8,12 +8,10 @@ public class NumberUtilities {
} }
public static float clamp (float value, float min, float max) { public static float clamp (float value, float min, float max) {
if (value < min) return min; return Math.max(Math.min(value, max), min);
return Math.min(value, max);
} }
public static double clamp (double value, double min, double max) { public static double clamp (double value, double min, double max) {
if (value < min) return min; return Math.max(Math.min(value, max), min);
return Math.min(value, max);
} }
} }