fix: be careful with querying when the bot doesn't have enough permissions
This commit is contained in:
@@ -1 +1 @@
|
||||
3361
|
||||
3363
|
||||
@@ -3,6 +3,7 @@ package me.chayapak1.chomens_bot.plugins;
|
||||
import com.google.gson.JsonSyntaxException;
|
||||
import me.chayapak1.chomens_bot.Bot;
|
||||
import me.chayapak1.chomens_bot.data.listener.Listener;
|
||||
import me.chayapak1.chomens_bot.data.selfCare.SelfData;
|
||||
import me.chayapak1.chomens_bot.util.MathUtilities;
|
||||
import me.chayapak1.chomens_bot.util.StringUtilities;
|
||||
import net.kyori.adventure.text.Component;
|
||||
@@ -16,6 +17,7 @@ import org.geysermc.mcprotocollib.network.Session;
|
||||
import org.geysermc.mcprotocollib.network.event.session.ConnectedEvent;
|
||||
import org.geysermc.mcprotocollib.network.event.session.DisconnectedEvent;
|
||||
import org.geysermc.mcprotocollib.protocol.data.game.entity.object.Direction;
|
||||
import org.geysermc.mcprotocollib.protocol.data.game.entity.player.GameMode;
|
||||
import org.geysermc.mcprotocollib.protocol.data.game.entity.player.Hand;
|
||||
import org.geysermc.mcprotocollib.protocol.data.game.entity.player.PlayerAction;
|
||||
import org.geysermc.mcprotocollib.protocol.data.game.item.ItemStack;
|
||||
@@ -97,7 +99,7 @@ public class CorePlugin implements Listener {
|
||||
public void onTick () {
|
||||
if (!pendingCommands.isEmpty() && exists) {
|
||||
// people that pre-order on TEMU application. Shop Like A Billionaire!!!
|
||||
if (pendingCommands.size() > 256) {
|
||||
if (pendingCommands.size() > 256 * 3) {
|
||||
pendingCommands.clear();
|
||||
} else {
|
||||
for (final String pendingCommand : pendingCommands) {
|
||||
@@ -198,7 +200,7 @@ public class CorePlugin implements Listener {
|
||||
}
|
||||
|
||||
public void run (final String command) {
|
||||
if (!exists) {
|
||||
if (!exists || !hasEnoughPermissions()) {
|
||||
// Add to TEMU shopping cart
|
||||
pendingCommands.add(command);
|
||||
return;
|
||||
@@ -371,6 +373,14 @@ public class CorePlugin implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
public boolean hasEnoughPermissions () {
|
||||
final SelfData data = bot.selfCare.data;
|
||||
|
||||
if (data == null) return false;
|
||||
|
||||
return data.permissionLevel >= 2 && data.gameMode == GameMode.CREATIVE;
|
||||
}
|
||||
|
||||
public boolean isCoreComplete () {
|
||||
if (!ready) return false;
|
||||
|
||||
|
||||
@@ -140,6 +140,11 @@ public class QueryPlugin implements Listener {
|
||||
return ObjectObjectImmutablePair.of(id, future);
|
||||
}
|
||||
|
||||
private void addComponent (final Component component, final boolean useCargo) {
|
||||
if (useCargo) cargosQueue.add(component);
|
||||
else sendQueueComponent(component);
|
||||
}
|
||||
|
||||
public CompletableFuture<String> block (final Vector3i location, final String path) { return block(false, location, path, false); }
|
||||
|
||||
public CompletableFuture<String> block (final boolean useCargo, final Vector3i location, final String path, final boolean interpret) {
|
||||
@@ -163,8 +168,7 @@ public class QueryPlugin implements Listener {
|
||||
)
|
||||
);
|
||||
|
||||
if (useCargo) cargosQueue.add(component);
|
||||
else sendQueueComponent(component);
|
||||
addComponent(component, useCargo);
|
||||
|
||||
return pair.right();
|
||||
}
|
||||
@@ -185,8 +189,7 @@ public class QueryPlugin implements Listener {
|
||||
)
|
||||
);
|
||||
|
||||
if (useCargo) cargosQueue.add(component);
|
||||
else sendQueueComponent(component);
|
||||
addComponent(component, useCargo);
|
||||
|
||||
return pair.right();
|
||||
}
|
||||
@@ -196,5 +199,6 @@ public class QueryPlugin implements Listener {
|
||||
@Override
|
||||
public void disconnected (final DisconnectedEvent event) {
|
||||
requests.clear();
|
||||
cargosQueue.clear();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user