extras/src/main/java/pw/kaboom/extras/modules/player/PlayerInteract.java

28 lines
766 B
Java
Raw Normal View History

2019-12-17 12:37:59 +00:00
package pw.kaboom.extras.modules.player;
2019-07-30 17:14:24 +00:00
2019-12-11 01:36:35 +00:00
import java.util.HashMap;
2019-07-30 17:14:24 +00:00
import java.util.UUID;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerInteractEvent;
2019-12-17 12:37:59 +00:00
public class PlayerInteract implements Listener {
2019-12-17 18:23:24 +00:00
static HashMap<UUID, Long> interactMillisList = new HashMap<UUID, Long>();
2019-12-11 01:36:35 +00:00
2019-07-30 17:14:24 +00:00
@EventHandler
void onPlayerInteract(PlayerInteractEvent event) {
final UUID playerUuid = event.getPlayer().getUniqueId();
2019-12-17 18:23:24 +00:00
2019-12-11 01:36:35 +00:00
if (interactMillisList.get(playerUuid) != null) {
final long millisDifference = System.currentTimeMillis() - interactMillisList.get(playerUuid);
2019-12-17 18:23:24 +00:00
2019-09-18 20:17:45 +00:00
if (millisDifference < 150) {
event.setCancelled(true);
}
2019-07-30 17:14:24 +00:00
}
2019-12-17 18:23:24 +00:00
2019-12-11 01:36:35 +00:00
interactMillisList.put(playerUuid, System.currentTimeMillis());
2019-07-30 17:14:24 +00:00
}
}