Files
FindIt/src/main/java/com/gtnh/findit/service/cooldown/SearchCooldownService.java
T
Oleg Ivanov dad262c9cb Full mod rewrite (#3)
* Full mod rewrite

* Remove legacy code

* Remove second draw call for position particle
2022-02-15 10:10:52 +01:00

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;
}
}