2015-10-19 17:43:46 +00:00
|
|
|
package me.totalfreedom.totalfreedommod.commands;
|
2011-10-19 00:37:00 +00:00
|
|
|
|
2015-11-15 23:32:04 +00:00
|
|
|
import me.totalfreedom.totalfreedommod.rank.PlayerRank;
|
2013-07-27 21:49:25 +00:00
|
|
|
import org.bukkit.Bukkit;
|
2011-10-19 00:37:00 +00:00
|
|
|
import org.bukkit.World;
|
|
|
|
import org.bukkit.command.Command;
|
|
|
|
import org.bukkit.command.CommandSender;
|
2014-12-21 09:23:50 +00:00
|
|
|
import org.bukkit.entity.Ambient;
|
|
|
|
import org.bukkit.entity.Creature;
|
|
|
|
import org.bukkit.entity.EnderDragon;
|
|
|
|
import org.bukkit.entity.Entity;
|
|
|
|
import org.bukkit.entity.Ghast;
|
|
|
|
import org.bukkit.entity.Player;
|
|
|
|
import org.bukkit.entity.Slime;
|
2011-10-19 00:37:00 +00:00
|
|
|
|
2015-10-19 17:43:46 +00:00
|
|
|
@CommandPermissions(level = PlayerRank.SUPER_ADMIN, source = SourceType.BOTH)
|
2015-11-15 23:32:04 +00:00
|
|
|
@CommandParameters(description = "Purge all mobs in all worlds.", usage = "/<command>", aliases = "mp")
|
|
|
|
public class Command_mobpurge extends FreedomCommand
|
2011-10-19 00:37:00 +00:00
|
|
|
{
|
|
|
|
@Override
|
|
|
|
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
|
|
|
{
|
2013-07-27 21:49:25 +00:00
|
|
|
playerMsg("Purging all mobs...");
|
|
|
|
playerMsg(purgeMobs() + " mobs removed.");
|
|
|
|
return true;
|
|
|
|
}
|
2011-10-19 00:37:00 +00:00
|
|
|
|
2013-07-27 21:49:25 +00:00
|
|
|
public static int purgeMobs()
|
|
|
|
{
|
2012-11-24 01:22:52 +00:00
|
|
|
int removed = 0;
|
2013-07-27 21:49:25 +00:00
|
|
|
for (World world : Bukkit.getWorlds())
|
2012-11-24 01:22:52 +00:00
|
|
|
{
|
|
|
|
for (Entity ent : world.getLivingEntities())
|
2011-10-19 00:37:00 +00:00
|
|
|
{
|
2012-11-24 01:22:52 +00:00
|
|
|
if (ent instanceof Creature || ent instanceof Ghast || ent instanceof Slime || ent instanceof EnderDragon || ent instanceof Ambient)
|
2011-10-19 00:37:00 +00:00
|
|
|
{
|
2012-11-24 01:22:52 +00:00
|
|
|
ent.remove();
|
|
|
|
removed++;
|
2011-10-19 00:37:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-07-27 21:49:25 +00:00
|
|
|
return removed;
|
2011-10-19 00:37:00 +00:00
|
|
|
}
|
|
|
|
}
|