mirror of
https://github.com/GTNewHorizons/FindIt.git
synced 2026-11-22 17:29:38 +00:00
* Full mod rewrite * Remove legacy code * Remove second draw call for position particle
26 lines
729 B
Java
26 lines
729 B
Java
package com.gtnh.findit.service.cooldown;
|
|
|
|
import com.gtnh.findit.FindItConfig;
|
|
import net.minecraft.entity.player.EntityPlayerMP;
|
|
|
|
import java.util.WeakHashMap;
|
|
|
|
public class SearchCooldownService {
|
|
|
|
private final WeakHashMap<EntityPlayerMP, Long> lastSearchTime = new WeakHashMap<>();
|
|
|
|
/**
|
|
* @return true if player has active cooldown
|
|
*/
|
|
public boolean checkSearchCooldown(EntityPlayerMP player) {
|
|
long time = player.getEntityWorld().getTotalWorldTime();
|
|
Long lastTime = lastSearchTime.get(player);
|
|
|
|
if (lastTime != null && time - lastTime < FindItConfig.SEARCH_COOLDOWN) {
|
|
return true;
|
|
}
|
|
lastSearchTime.put(player, time);
|
|
return false;
|
|
}
|
|
}
|