refactor: use HashMap#remove on the transactions instead of getting then removing
This commit is contained in:
@@ -74,15 +74,15 @@ public class EvalPlugin {
|
||||
socket.on("codeOutput", (args) -> {
|
||||
if (args.length < 3) return;
|
||||
|
||||
final int id = (int) args[0];
|
||||
final boolean isError = (boolean) args[1];
|
||||
final String output = (String) args[2];
|
||||
try {
|
||||
final int id = (int) args[0];
|
||||
final boolean isError = (boolean) args[1];
|
||||
final String output = (String) args[2];
|
||||
|
||||
final CompletableFuture<EvalOutput> future = futures.get(id);
|
||||
final CompletableFuture<EvalOutput> future = futures.remove(id);
|
||||
|
||||
future.complete(new EvalOutput(isError, output));
|
||||
|
||||
futures.remove(id);
|
||||
future.complete(new EvalOutput(isError, output));
|
||||
} catch (NumberFormatException ignored) {}
|
||||
});
|
||||
|
||||
socket.connect();
|
||||
|
||||
@@ -41,8 +41,8 @@ public class TabCompletePlugin extends Bot.Listener {
|
||||
public void packetReceived (ClientboundCommandSuggestionsPacket packet) {
|
||||
final int id = packet.getTransactionId();
|
||||
|
||||
transactions.get(id).complete(packet);
|
||||
if (!transactions.containsKey(id)) return;
|
||||
|
||||
transactions.remove(id);
|
||||
transactions.remove(id).complete(packet);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user