mirror of
https://github.com/AtlasMediaGroup/TotalFreedomMod.git
synced 2025-07-02 04:56:40 +00:00
kuper kant kode
This commit is contained in:
@ -1,9 +1,12 @@
|
||||
package me.totalfreedom.totalfreedommod;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import me.totalfreedom.totalfreedommod.util.Groups;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
import org.bukkit.scheduler.BukkitTask;
|
||||
|
||||
@ -16,29 +19,34 @@ public class EntityWiper extends FreedomService
|
||||
super(plugin);
|
||||
}
|
||||
|
||||
public List<EntityType> BLACKLIST = Arrays.asList(
|
||||
EntityType.ARMOR_STAND,
|
||||
EntityType.PAINTING,
|
||||
EntityType.BOAT,
|
||||
EntityType.PLAYER,
|
||||
EntityType.LEASH_HITCH,
|
||||
EntityType.ITEM_FRAME
|
||||
);
|
||||
|
||||
@Override
|
||||
protected void onStart()
|
||||
{
|
||||
BLACKLIST.addAll(Groups.MOB_TYPES);
|
||||
// Continuous Entity Wiper
|
||||
wiper = new BukkitRunnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
for (World world : Bukkit.getWorlds())
|
||||
{
|
||||
if (world.getEntities().size() > 400)
|
||||
{
|
||||
world.getEntities().clear();
|
||||
}
|
||||
}
|
||||
wipe();
|
||||
}
|
||||
}.runTaskTimer(plugin, 0, 1);
|
||||
}.runTaskTimer(plugin, 1L, 300 * 5); // 5 minutes
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStop()
|
||||
{
|
||||
BLACKLIST.removeAll(Groups.MOB_TYPES);
|
||||
wiper.cancel();
|
||||
wiper = null;
|
||||
}
|
||||
@ -52,7 +60,7 @@ public class EntityWiper extends FreedomService
|
||||
{
|
||||
for (Entity entity : world.getEntities())
|
||||
{
|
||||
if (!(entity instanceof Player))
|
||||
if (!BLACKLIST.contains(entity.getType()))
|
||||
{
|
||||
entity.remove();
|
||||
removed++;
|
||||
@ -61,18 +69,4 @@ public class EntityWiper extends FreedomService
|
||||
}
|
||||
return removed;
|
||||
}
|
||||
|
||||
public int wipe(World world)
|
||||
{
|
||||
int removed = 0;
|
||||
for (Entity entity : world.getEntities())
|
||||
{
|
||||
if (!(entity instanceof Player))
|
||||
{
|
||||
entity.remove();
|
||||
removed++;
|
||||
}
|
||||
}
|
||||
return removed;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user