2022-04-07 01:48:51 +00:00
|
|
|
package dev.plex.services.impl;
|
|
|
|
|
2022-04-07 02:08:51 +00:00
|
|
|
import dev.plex.Plex;
|
2022-04-07 01:48:51 +00:00
|
|
|
import dev.plex.services.AbstractService;
|
|
|
|
import org.bukkit.Bukkit;
|
|
|
|
import org.bukkit.World;
|
|
|
|
import org.bukkit.entity.Entity;
|
|
|
|
|
2023-03-08 20:26:10 +00:00
|
|
|
import java.util.List;
|
|
|
|
|
2022-04-07 01:48:51 +00:00
|
|
|
public class AutoWipeService extends AbstractService
|
|
|
|
{
|
|
|
|
public AutoWipeService()
|
|
|
|
{
|
|
|
|
super(true, false);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void run()
|
|
|
|
{
|
2022-04-07 02:08:51 +00:00
|
|
|
if (Plex.get().config.getBoolean("autowipe.enabled"))
|
2022-04-07 01:48:51 +00:00
|
|
|
{
|
2022-04-07 02:08:51 +00:00
|
|
|
List<String> entities = plugin.config.getStringList("autowipe.entities");
|
|
|
|
|
|
|
|
for (World world : Bukkit.getWorlds())
|
2022-04-07 01:48:51 +00:00
|
|
|
{
|
2022-04-07 02:08:51 +00:00
|
|
|
for (Entity entity : world.getEntities())
|
2022-04-07 01:48:51 +00:00
|
|
|
{
|
2022-04-07 02:08:51 +00:00
|
|
|
if (entities.stream().anyMatch(entityName -> entityName.equalsIgnoreCase(entity.getType().name())))
|
|
|
|
{
|
|
|
|
entity.remove();
|
|
|
|
}
|
2022-04-07 01:48:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public int repeatInSeconds()
|
|
|
|
{
|
|
|
|
return Math.max(1, plugin.config.getInt("autowipe.interval"));
|
|
|
|
}
|
|
|
|
}
|