ANOTHER improvement
This commit is contained in:
parent
be31cb7a0d
commit
5e7f10cb0d
1 changed files with 12 additions and 3 deletions
|
@ -56,6 +56,8 @@ public class CorePlugin extends PositionPlugin.Listener {
|
||||||
|
|
||||||
private int commandsPerSecond = 0;
|
private int commandsPerSecond = 0;
|
||||||
|
|
||||||
|
private boolean shouldRefill = false;
|
||||||
|
|
||||||
public CorePlugin (Bot bot) {
|
public CorePlugin (Bot bot) {
|
||||||
this.bot = bot;
|
this.bot = bot;
|
||||||
this.kaboom = bot.options.kaboom;
|
this.kaboom = bot.options.kaboom;
|
||||||
|
@ -82,6 +84,13 @@ public class CorePlugin extends PositionPlugin.Listener {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bot.executor.scheduleAtFixedRate(() -> {
|
||||||
|
if (!shouldRefill) return;
|
||||||
|
|
||||||
|
refill();
|
||||||
|
shouldRefill = false;
|
||||||
|
}, 0, 1, TimeUnit.SECONDS);
|
||||||
|
|
||||||
bot.addListener(new Bot.Listener() {
|
bot.addListener(new Bot.Listener() {
|
||||||
@Override
|
@Override
|
||||||
public void disconnected (DisconnectedEvent event) {
|
public void disconnected (DisconnectedEvent event) {
|
||||||
|
@ -194,7 +203,7 @@ public class CorePlugin extends PositionPlugin.Listener {
|
||||||
|
|
||||||
final Vector3i position = entry.getPosition();
|
final Vector3i position = entry.getPosition();
|
||||||
|
|
||||||
if (isCore(position)) refill();
|
if (isCore(position)) shouldRefill = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void packetReceived (ClientboundSectionBlocksUpdatePacket packet) {
|
public void packetReceived (ClientboundSectionBlocksUpdatePacket packet) {
|
||||||
|
@ -210,7 +219,7 @@ public class CorePlugin extends PositionPlugin.Listener {
|
||||||
if (isCore(position)) willRefill = true;
|
if (isCore(position)) willRefill = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (willRefill) refill();
|
if (willRefill) shouldRefill = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isCommandBlockUpdate(int blockState) {
|
private boolean isCommandBlockUpdate(int blockState) {
|
||||||
|
@ -235,7 +244,7 @@ public class CorePlugin extends PositionPlugin.Listener {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void packetReceived (ClientboundLevelChunkWithLightPacket packet) {
|
public void packetReceived (ClientboundLevelChunkWithLightPacket packet) {
|
||||||
refill(); // TODO: improve, this is probably the worst way to check
|
shouldRefill = true; // TODO: improve, this is probably the worst way to check
|
||||||
}
|
}
|
||||||
|
|
||||||
// ported from chomens bot js
|
// ported from chomens bot js
|
||||||
|
|
Loading…
Reference in a new issue