mirror of
https://github.com/AtlasMediaGroup/TotalFreedomMod.git
synced 2024-11-17 04:46:11 +00:00
055973aa37
Refractoring Reworked /saconfig Reworked part of the command system Removed unused config sections Refractored part of the config Fixed bugs with admin list Actually allow CONSOLE to have senior perms
47 lines
1.4 KiB
Java
47 lines
1.4 KiB
Java
package me.totalfreedom.totalfreedommod.command;
|
|
|
|
import me.totalfreedom.totalfreedommod.rank.PlayerRank;
|
|
import org.bukkit.Bukkit;
|
|
import org.bukkit.World;
|
|
import org.bukkit.command.Command;
|
|
import org.bukkit.command.CommandSender;
|
|
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;
|
|
|
|
@CommandPermissions(level = PlayerRank.SUPER_ADMIN, source = SourceType.BOTH)
|
|
@CommandParameters(description = "Purge all mobs in all worlds.", usage = "/<command>", aliases = "mp")
|
|
public class Command_mobpurge extends FreedomCommand
|
|
{
|
|
|
|
@Override
|
|
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
|
{
|
|
msg("Purging all mobs...");
|
|
msg(purgeMobs() + " mobs removed.");
|
|
return true;
|
|
}
|
|
|
|
public static int purgeMobs()
|
|
{
|
|
int removed = 0;
|
|
for (World world : Bukkit.getWorlds())
|
|
{
|
|
for (Entity ent : world.getLivingEntities())
|
|
{
|
|
if (ent instanceof Creature || ent instanceof Ghast || ent instanceof Slime || ent instanceof EnderDragon || ent instanceof Ambient)
|
|
{
|
|
ent.remove();
|
|
removed++;
|
|
}
|
|
}
|
|
}
|
|
|
|
return removed;
|
|
}
|
|
}
|