feat: /tp cooldown when going down from height limit

This commit is contained in:
ChomeNS
2025-03-31 17:13:56 +07:00
parent bb0900eeb6
commit 156a5af47f
2 changed files with 10 additions and 5 deletions

View File

@@ -29,6 +29,8 @@ public class PositionPlugin extends Bot.Listener implements TickPlugin.Listener
public boolean isGoingDownFromHeightLimit = false; // cool variable name
private long tpCommandCooldownTime = 0;
private final Map<Integer, PlayerEntry> entityIdMap = new HashMap<>();
private final Map<Integer, Vector3d> positionMap = new HashMap<>();
private final Map<Integer, Rotation> rotationMap = new HashMap<>();
@@ -205,13 +207,16 @@ public class PositionPlugin extends Bot.Listener implements TickPlugin.Listener
isGoingDownFromHeightLimit = true;
if (y > maxY + 500 || y < minY) {
String command = "/";
if ((System.currentTimeMillis() - tpCommandCooldownTime) < 400) return;
if (bot.serverFeatures.hasEssentials) command += "essentials:";
tpCommandCooldownTime = System.currentTimeMillis();
command += String.format("tp ~ %s ~", maxY);
final StringBuilder command = new StringBuilder();
bot.chat.send(command);
if (bot.serverFeatures.hasEssentials) command.append("essentials:");
command.append(String.format("tp ~ %s ~", maxY));
bot.chat.sendCommandInstantly(command.toString());
return;
}