Force wipe entities when using /entitywipe

This commit is contained in:
JeromSar 2016-10-02 22:42:36 +02:00
parent 25fafa7a6c
commit c10b08df27
4 changed files with 9 additions and 13 deletions

View File

@ -11,7 +11,6 @@ import me.totalfreedom.totalfreedommod.util.FUtil;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Chunk; import org.bukkit.Chunk;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.block.BlockState;
import org.bukkit.entity.AreaEffectCloud; import org.bukkit.entity.AreaEffectCloud;
import org.bukkit.entity.Boat; import org.bukkit.entity.Boat;
import org.bukkit.entity.EnderCrystal; import org.bukkit.entity.EnderCrystal;
@ -28,10 +27,7 @@ import org.bukkit.entity.ThrownExpBottle;
import org.bukkit.entity.ThrownPotion; import org.bukkit.entity.ThrownPotion;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.entity.ItemSpawnEvent; import org.bukkit.event.entity.ItemSpawnEvent;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.InventoryHolder;
import org.bukkit.scheduler.BukkitRunnable; import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.scheduler.BukkitTask; import org.bukkit.scheduler.BukkitTask;
@ -40,7 +36,7 @@ public class EntityWiper extends FreedomService
public static final long ENTITY_WIPE_RATE = 5 * 20L; public static final long ENTITY_WIPE_RATE = 5 * 20L;
public static final long ITEM_DESPAWN_RATE = 20L * 20L; public static final long ITEM_DESPAWN_RATE = 20L * 20L;
public static final int CHUNK_ENTITY_MAX = 30; public static final int CHUNK_ENTITY_MAX = 20;
// //
private final List<Class<? extends Entity>> wipables = new ArrayList<>(); private final List<Class<? extends Entity>> wipables = new ArrayList<>();
// //
@ -78,7 +74,7 @@ public class EntityWiper extends FreedomService
@Override @Override
public void run() public void run()
{ {
wipeEntities(); wipeEntities(false);
} }
}.runTaskTimer(plugin, ENTITY_WIPE_RATE, ENTITY_WIPE_RATE); }.runTaskTimer(plugin, ENTITY_WIPE_RATE, ENTITY_WIPE_RATE);
@ -104,19 +100,19 @@ public class EntityWiper extends FreedomService
return false; return false;
} }
public int wipeEntities() public int wipeEntities(boolean force)
{ {
int removed = 0; int removed = 0;
Iterator<World> worlds = Bukkit.getWorlds().iterator(); Iterator<World> worlds = Bukkit.getWorlds().iterator();
while (worlds.hasNext()) while (worlds.hasNext())
{ {
removed += wipeEntities(worlds.next()); removed += wipeEntities(worlds.next(), force);
} }
return removed; return removed;
} }
public int wipeEntities(World world) public int wipeEntities(World world, boolean force)
{ {
int removed = 0; int removed = 0;
@ -159,7 +155,7 @@ public class EntityWiper extends FreedomService
{ {
List<Entity> cel = cem.get(c); List<Entity> cel = cem.get(c);
if (cel.size() < CHUNK_ENTITY_MAX) if (!force && cel.size() < CHUNK_ENTITY_MAX)
{ {
continue; continue;
} }

View File

@ -15,7 +15,7 @@ public class Command_entitywipe extends FreedomCommand
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole) public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{ {
FUtil.adminAction(sender.getName(), "Removing all server entities.", true); FUtil.adminAction(sender.getName(), "Removing all server entities.", true);
msg((plugin.ew.wipeEntities()) + " entities removed."); msg((plugin.ew.wipeEntities(true)) + " entities removed.");
return true; return true;
} }

View File

@ -9,7 +9,7 @@ import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin; import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.PluginManager; import org.bukkit.plugin.PluginManager;
@CommandPermissions(level = Rank.SENIOR_ADMIN, source = SourceType.BOTH) @CommandPermissions(level = Rank.TELNET_ADMIN, source = SourceType.BOTH)
@CommandParameters(description = "Manage plugins", usage = "/<command> <<enable | disable | reload> <pluginname>> | list>", aliases = "plc") @CommandParameters(description = "Manage plugins", usage = "/<command> <<enable | disable | reload> <pluginname>> | list>", aliases = "plc")
public class Command_plugincontrol extends FreedomCommand public class Command_plugincontrol extends FreedomCommand
{ {

View File

@ -19,7 +19,7 @@ public class Command_purgeall extends FreedomCommand
FUtil.adminAction(sender.getName(), "Purging all player data", true); FUtil.adminAction(sender.getName(), "Purging all player data", true);
// Purge entities // Purge entities
plugin.ew.wipeEntities(); plugin.ew.wipeEntities(true);
for (Player player : server.getOnlinePlayers()) for (Player player : server.getOnlinePlayers())
{ {