feat: core place block queue
This commit is contained in:
parent
9f10ca8a3e
commit
6c507219f2
2 changed files with 30 additions and 4 deletions
|
@ -30,10 +30,7 @@ import net.kyori.adventure.text.TextComponent;
|
||||||
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
|
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
|
||||||
import org.cloudburstmc.math.vector.Vector3i;
|
import org.cloudburstmc.math.vector.Vector3i;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
import java.util.concurrent.ScheduledFuture;
|
import java.util.concurrent.ScheduledFuture;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
@ -55,6 +52,8 @@ public class CorePlugin extends PositionPlugin.Listener {
|
||||||
|
|
||||||
public Vector3i block = null;
|
public Vector3i block = null;
|
||||||
|
|
||||||
|
public final List<String> placeBlockQueue = Collections.synchronizedList(new ArrayList<>());
|
||||||
|
|
||||||
private int nextTransactionId = 0;
|
private int nextTransactionId = 0;
|
||||||
private final Map<Integer, CompletableFuture<Component>> transactions = new HashMap<>();
|
private final Map<Integer, CompletableFuture<Component>> transactions = new HashMap<>();
|
||||||
|
|
||||||
|
@ -120,6 +119,27 @@ public class CorePlugin extends PositionPlugin.Listener {
|
||||||
return CorePlugin.this.systemMessageReceived(component);
|
return CorePlugin.this.systemMessageReceived(component);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
bot.tick.addListener(new TickPlugin.Listener() {
|
||||||
|
@Override
|
||||||
|
public void onTick() {
|
||||||
|
try {
|
||||||
|
final List<String> clonedQueue = new ArrayList<>(placeBlockQueue);
|
||||||
|
|
||||||
|
if (clonedQueue.isEmpty()) return;
|
||||||
|
|
||||||
|
if (clonedQueue.size() > 500) {
|
||||||
|
placeBlockQueue.clear();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
forceRunPlaceBlock(clonedQueue.get(0));
|
||||||
|
placeBlockQueue.remove(0);
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasRateLimit () {
|
public boolean hasRateLimit () {
|
||||||
|
@ -258,6 +278,10 @@ public class CorePlugin extends PositionPlugin.Listener {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void runPlaceBlock (String command) {
|
public void runPlaceBlock (String command) {
|
||||||
|
bot.executorService.submit(() -> placeBlockQueue.add(command));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void forceRunPlaceBlock (String command) {
|
||||||
if (!ready || !bot.options.useCore) return;
|
if (!ready || !bot.options.useCore) return;
|
||||||
|
|
||||||
final NbtMapBuilder blockEntityTagBuilder = NbtMap.builder();
|
final NbtMapBuilder blockEntityTagBuilder = NbtMap.builder();
|
||||||
|
|
|
@ -36,6 +36,8 @@ public class IPFilterPlugin extends PlayersPlugin.Listener {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void check (PlayerEntry target) {
|
private void check (PlayerEntry target) {
|
||||||
|
if (bot.options.useCorePlaceBlock) return; // it will spam the place block core so i ignored this
|
||||||
|
|
||||||
final CompletableFuture<String> future = bot.players.getPlayerIP(target);
|
final CompletableFuture<String> future = bot.players.getPlayerIP(target);
|
||||||
|
|
||||||
if (future == null) return;
|
if (future == null) return;
|
||||||
|
|
Loading…
Reference in a new issue