fix autowiping

so it can work with reloads
This commit is contained in:
ayunami2000 2022-04-06 22:08:51 -04:00
parent 34d1eafaaf
commit 21bef1280d
2 changed files with 11 additions and 7 deletions

View File

@ -20,7 +20,7 @@ public class ServiceManager
registerService(new BanService());
registerService(new GameRuleService());
registerService(new UpdateCheckerService());
if (Plex.get().config.getBoolean("autowipe.enabled")) registerService(new AutoWipeService());
registerService(new AutoWipeService());
}
public void startServices()

View File

@ -1,5 +1,6 @@
package dev.plex.services.impl;
import dev.plex.Plex;
import dev.plex.services.AbstractService;
import org.bukkit.Bukkit;
import org.bukkit.World;
@ -18,15 +19,18 @@ public class AutoWipeService extends AbstractService
@Override
public void run()
{
List<String> entities = plugin.config.getStringList("autowipe.entities");
for (World world : Bukkit.getWorlds())
if (Plex.get().config.getBoolean("autowipe.enabled"))
{
for (Entity entity : world.getEntities())
List<String> entities = plugin.config.getStringList("autowipe.entities");
for (World world : Bukkit.getWorlds())
{
if (entities.stream().anyMatch(entityName -> entityName.equalsIgnoreCase(entity.getType().name())))
for (Entity entity : world.getEntities())
{
entity.remove();
if (entities.stream().anyMatch(entityName -> entityName.equalsIgnoreCase(entity.getType().name())))
{
entity.remove();
}
}
}
}