mirror of
https://github.com/filoghost/HolographicDisplays.git
synced 2024-11-20 01:15:15 +01:00
Remove unnecessary cooldown on hologram line click
This commit is contained in:
parent
2da7d318df
commit
1aa8a17dab
@ -13,13 +13,8 @@ import org.bukkit.entity.Player;
|
|||||||
import org.jetbrains.annotations.MustBeInvokedByOverriders;
|
import org.jetbrains.annotations.MustBeInvokedByOverriders;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.WeakHashMap;
|
|
||||||
|
|
||||||
public abstract class BaseClickableLine extends BaseHologramLine {
|
public abstract class BaseClickableLine extends BaseHologramLine {
|
||||||
|
|
||||||
private static final Map<Player, Long> lastClickByPlayer = new WeakHashMap<>();
|
|
||||||
|
|
||||||
private ClickListener clickListener;
|
private ClickListener clickListener;
|
||||||
|
|
||||||
protected BaseClickableLine(BaseHologram hologram) {
|
protected BaseClickableLine(BaseHologram hologram) {
|
||||||
@ -31,14 +26,6 @@ public abstract class BaseClickableLine extends BaseHologramLine {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Long lastClick = lastClickByPlayer.get(player);
|
|
||||||
long now = System.currentTimeMillis();
|
|
||||||
if (lastClick != null && now - lastClick < 100) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
lastClickByPlayer.put(player, now);
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
clickListener.onClick(player);
|
clickListener.onClick(player);
|
||||||
} catch (Throwable t) {
|
} catch (Throwable t) {
|
||||||
|
Loading…
Reference in New Issue
Block a user