41 lines
1.3 KiB
Java
41 lines
1.3 KiB
Java
package me.ryanhamshire.GriefPrevention.alttd.tasks;
|
|
|
|
import me.ryanhamshire.GriefPrevention.Claim;
|
|
import me.ryanhamshire.GriefPrevention.GriefPrevention;
|
|
import me.ryanhamshire.GriefPrevention.alttd.config.Config;
|
|
import org.bukkit.scheduler.BukkitRunnable;
|
|
|
|
import java.util.Iterator;
|
|
import java.util.Map;
|
|
|
|
public class AdminClaimExpireTask extends BukkitRunnable
|
|
{
|
|
private GriefPrevention plugin;
|
|
|
|
public AdminClaimExpireTask(GriefPrevention plugin)
|
|
{
|
|
this.plugin = plugin;
|
|
}
|
|
|
|
public void init()
|
|
{
|
|
runTaskTimer(plugin, 0, Config.adminClaimExpireCheckRate);
|
|
}
|
|
|
|
@Override
|
|
public void run()
|
|
{
|
|
//Config.expiringClaims.entrySet().removeIf(entry -> System.currentTimeMillis() >= entry.getValue());
|
|
for(Iterator<Map.Entry<Long, Long>> it = Config.expiringClaims.entrySet().iterator(); it.hasNext(); ) {
|
|
Map.Entry<Long, Long> entry = it.next();
|
|
if(System.currentTimeMillis() >= entry.getValue()) {
|
|
Claim claim = plugin.dataStore.getClaim(entry.getKey());
|
|
plugin.dataStore.deleteClaim(claim, false, true);
|
|
it.remove();
|
|
plugin.getLogger().info("Removed temporary admin claim with id " + entry.getKey());
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|