private HashMap <UUID, Long> cooldown = new HashMap <UUID, Long>();
private int cooldownDuration = 5;
// Methode für den Doppeljump
public void doppelJump() {
Long time = System.currentTimeMillis();
if (this.cooldown.containsKey(player.getUniqueId())) {
long lastUsage = this.cooldown.get(player.getUniqueId());
if (lastUsage + cooldownDuration * 1000 > time) {
// Code abbrechen, damit Doppeljump nicht ausgeführt wird
// oder etwas in der Art
return;
}
}
// wenn Doppeljump ausgeführt wird,
//muss der Eintrag in der Hashmap aktualisiert werden
this.cooldown.put(player.getUniqueId(), time);
}