mirror of
https://github.com/rockyhawk64/CommandPanels.git
synced 2025-11-18 07:14:17 +01:00
command and teleport tag fix folia
This commit is contained in:
parent
7d27cc133b
commit
732995f2f2
@ -70,7 +70,10 @@ public class CommandRunner {
|
||||
}
|
||||
|
||||
// Run the command
|
||||
runCommand(panel, player, command);
|
||||
Bukkit.getGlobalRegionScheduler().run(
|
||||
ctx.plugin,
|
||||
task -> runCommand(panel, player, command)
|
||||
);
|
||||
|
||||
// Move to the next command
|
||||
runCommands(panel, player, commands, index + 1);
|
||||
|
||||
@ -47,7 +47,7 @@ public class TeleportTag implements CommandTagResolver {
|
||||
}
|
||||
Location teleportLocation = new Location(teleportedWorld, x, y, z, yaw, pitch);
|
||||
if (teleportedPlayer != null) {
|
||||
teleportedPlayer.teleport(teleportLocation);
|
||||
player.teleportAsync(teleportLocation);
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
ctx.text.sendError(player, Message.TELEPORT_ERROR);
|
||||
|
||||
@ -52,10 +52,10 @@ public abstract class Panel {
|
||||
// Checks for opening fresh panels
|
||||
public boolean canOpen(Player p, Context ctx) {
|
||||
// Do not open if user is in cooldown period
|
||||
NamespacedKey keyTime = new NamespacedKey(ctx.plugin, "last_open_tick");
|
||||
Integer lastOpenTick = p.getPersistentDataContainer().get(keyTime, PersistentDataType.INTEGER);
|
||||
int cooldownTicks = ctx.fileHandler.config.getInt("cooldown-ticks");
|
||||
if (lastOpenTick != null && Bukkit.getCurrentTick() - lastOpenTick < cooldownTicks) {
|
||||
NamespacedKey keyTime = new NamespacedKey(ctx.plugin, "last_open_time");
|
||||
Long lastOpenTime = p.getPersistentDataContainer().get(keyTime, PersistentDataType.LONG);
|
||||
long cooldownMillis = ctx.fileHandler.config.getLong("cooldown-ticks") * 50L;
|
||||
if (lastOpenTime != null && System.currentTimeMillis() - lastOpenTime < cooldownMillis) {
|
||||
ctx.text.sendError(p, Message.COOLDOWN_ERROR);
|
||||
return false;
|
||||
}
|
||||
@ -69,11 +69,11 @@ public abstract class Panel {
|
||||
public void updatePanelData(Context ctx, Player p) {
|
||||
NamespacedKey keyCurrent = new NamespacedKey(ctx.plugin, "current");
|
||||
NamespacedKey keyPrevious = new NamespacedKey(ctx.plugin, "previous");
|
||||
NamespacedKey keyTick = new NamespacedKey(ctx.plugin, "last_open_tick");
|
||||
NamespacedKey keyMillis = new NamespacedKey(ctx.plugin, "last_open_time");
|
||||
PersistentDataContainer container = p.getPersistentDataContainer();
|
||||
|
||||
// Time the player last opened any panel
|
||||
container.set(keyTick, PersistentDataType.INTEGER, Bukkit.getCurrentTick());
|
||||
container.set(keyMillis, PersistentDataType.LONG, System.currentTimeMillis());
|
||||
|
||||
// Move current → previous
|
||||
String current = container.get(keyCurrent, PersistentDataType.STRING);
|
||||
|
||||
@ -67,14 +67,14 @@ public class ClickEvents implements Listener {
|
||||
e.setResult(Event.Result.DENY);
|
||||
|
||||
// Do not run commands if user is in cooldown (item click cooldown should match heartbeat updater speed)
|
||||
NamespacedKey lastClickTick = new NamespacedKey(ctx.plugin, "last_click_tick");
|
||||
Integer lastOpen = player.getPersistentDataContainer().get(lastClickTick, PersistentDataType.INTEGER);
|
||||
int currentTick = Bukkit.getCurrentTick();
|
||||
if (lastOpen != null && currentTick - lastOpen < 2) {
|
||||
NamespacedKey lastClick = new NamespacedKey(ctx.plugin, "last_click_time");
|
||||
Long lastOpenMillis = player.getPersistentDataContainer().get(lastClick, PersistentDataType.LONG);
|
||||
long currentMillis = System.currentTimeMillis();
|
||||
if (lastOpenMillis != null && currentMillis - lastOpenMillis < 100L) {
|
||||
return;
|
||||
}
|
||||
|
||||
player.getPersistentDataContainer().set(lastClickTick, PersistentDataType.INTEGER, currentTick);
|
||||
player.getPersistentDataContainer().set(lastClick, PersistentDataType.LONG, currentMillis);
|
||||
String itemId = container.get(baseIdKey, PersistentDataType.STRING);
|
||||
|
||||
// Check valid interaction types
|
||||
|
||||
Loading…
Reference in New Issue
Block a user