2022-02-15 13:07:31 +00:00
|
|
|
package me.ryanhamshire.GriefPrevention.alttd.tasks;
|
|
|
|
|
|
|
|
|
|
import me.ryanhamshire.GriefPrevention.GriefPrevention;
|
2022-02-15 15:41:32 +00:00
|
|
|
import me.ryanhamshire.GriefPrevention.alttd.config.Config;
|
2022-02-15 13:07:31 +00:00
|
|
|
import org.bukkit.scheduler.BukkitRunnable;
|
|
|
|
|
|
|
|
|
|
import java.util.Iterator;
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
|
2022-02-24 17:58:38 +00:00
|
|
|
public class AdminClaimExpireTask extends BukkitRunnable
|
2022-02-15 13:07:31 +00:00
|
|
|
{
|
|
|
|
|
private GriefPrevention plugin;
|
|
|
|
|
|
2022-02-24 17:58:38 +00:00
|
|
|
public AdminClaimExpireTask(GriefPrevention plugin)
|
2022-02-15 13:07:31 +00:00
|
|
|
{
|
|
|
|
|
this.plugin = plugin;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void init()
|
|
|
|
|
{
|
2022-02-24 17:58:38 +00:00
|
|
|
runTaskTimer(plugin, 0, Config.adminClaimExpireCheckRate);
|
2022-02-15 13:07:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void run()
|
|
|
|
|
{
|
|
|
|
|
//Config.expiringClaims.entrySet().removeIf(entry -> System.currentTimeMillis() >= entry.getValue());
|
2022-02-15 15:41:32 +00:00
|
|
|
for(Iterator<Map.Entry<Long, Long>> it = Config.expiringClaims.entrySet().iterator(); it.hasNext(); ) {
|
2022-02-15 13:07:31 +00:00
|
|
|
Map.Entry<Long, Long> entry = it.next();
|
|
|
|
|
if(System.currentTimeMillis() >= entry.getValue()) {
|
|
|
|
|
it.remove();
|
|
|
|
|
plugin.getLogger().info("Removed temporary admin claim with id " + entry.getKey());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|