2016-03-02 19:28:01 +00:00
|
|
|
package me.totalfreedom.totalfreedommod.command;
|
2011-10-19 00:37:00 +00:00
|
|
|
|
2016-03-06 15:56:15 +00:00
|
|
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
2016-05-12 19:40:39 +00:00
|
|
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
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
|
|
|
|
2016-03-06 15:56:15 +00:00
|
|
|
@CommandPermissions(level = Rank.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
|
|
|
{
|
2015-11-22 18:26:47 +00:00
|
|
|
|
2011-10-19 00:37:00 +00:00
|
|
|
@Override
|
2015-11-22 18:26:47 +00:00
|
|
|
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
2011-10-19 00:37:00 +00:00
|
|
|
{
|
2016-05-12 19:40:39 +00:00
|
|
|
FUtil.adminAction(sender.getName(), "Purging all mobs", true);
|
2016-03-02 19:28:01 +00:00
|
|
|
msg(purgeMobs() + " mobs removed.");
|
2013-07-27 21:49:25 +00:00
|
|
|
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
|
|
|
}
|
|
|
|
}
|