2016-03-02 19:28:01 +00:00
|
|
|
package me.totalfreedom.totalfreedommod.command;
|
2011-10-19 00:37:00 +00:00
|
|
|
|
2019-01-29 04:57:41 +00:00
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.Collections;
|
|
|
|
import java.util.List;
|
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;
|
2019-01-28 01:49:07 +00:00
|
|
|
import me.totalfreedom.totalfreedommod.util.Groups;
|
|
|
|
import org.bukkit.ChatColor;
|
2011-10-19 00:37:00 +00:00
|
|
|
import org.bukkit.command.Command;
|
|
|
|
import org.bukkit.command.CommandSender;
|
2019-01-28 01:49:07 +00:00
|
|
|
import org.bukkit.entity.EntityType;
|
2018-07-31 07:05:28 +00:00
|
|
|
import org.bukkit.entity.Player;
|
2011-10-19 00:37:00 +00:00
|
|
|
|
2020-09-28 02:51:15 +00:00
|
|
|
@CommandPermissions(level = Rank.NEW_ADMIN, source = SourceType.BOTH)
|
2019-01-28 01:49:07 +00:00
|
|
|
@CommandParameters(description = "Purge all mobs in all worlds.", usage = "/<command> [name]", aliases = "mp")
|
2015-11-15 23:32:04 +00:00
|
|
|
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
|
|
|
{
|
2019-01-28 01:49:07 +00:00
|
|
|
EntityType type = null;
|
|
|
|
String mobName = null;
|
|
|
|
if (args.length > 0)
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
type = EntityType.valueOf(args[0].toUpperCase());
|
|
|
|
}
|
|
|
|
catch (Exception e)
|
|
|
|
{
|
|
|
|
msg(args[0] + " is not a valid mob type.", ChatColor.RED);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!Groups.MOB_TYPES.contains(type))
|
|
|
|
{
|
2020-01-25 06:27:16 +00:00
|
|
|
msg(FUtil.formatName(type.name()) + " is an entity, however it is not a mob.", ChatColor.RED);
|
2019-01-28 01:49:07 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (type != null)
|
|
|
|
{
|
2020-01-25 06:27:16 +00:00
|
|
|
mobName = FUtil.formatName(type.name());
|
2019-01-28 01:49:07 +00:00
|
|
|
}
|
|
|
|
|
2020-08-15 22:42:46 +00:00
|
|
|
FUtil.staffAction(sender.getName(), "Purging all " + (type != null ? mobName + "s" : "mobs"), true);
|
2020-01-25 06:27:16 +00:00
|
|
|
int count = plugin.ew.purgeMobs(type);
|
|
|
|
msg(count + " " + (type != null ? mobName : "mob") + FUtil.showS(count) + " removed.");
|
2013-07-27 21:49:25 +00:00
|
|
|
return true;
|
|
|
|
}
|
2011-10-19 00:37:00 +00:00
|
|
|
|
2019-01-29 04:57:41 +00:00
|
|
|
public static List<String> getAllMobNames()
|
|
|
|
{
|
|
|
|
List<String> names = new ArrayList<>();
|
|
|
|
for (EntityType entityType : Groups.MOB_TYPES)
|
|
|
|
{
|
|
|
|
names.add(entityType.name());
|
|
|
|
}
|
|
|
|
return names;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public List<String> getTabCompleteOptions(CommandSender sender, Command command, String alias, String[] args)
|
|
|
|
{
|
|
|
|
if (args.length == 1)
|
|
|
|
{
|
|
|
|
return getAllMobNames();
|
|
|
|
}
|
|
|
|
|
|
|
|
return Collections.emptyList();
|
|
|
|
}
|
2011-10-19 00:37:00 +00:00
|
|
|
}
|