TotalFreedomMod/src/main/java/me/totalfreedom/totalfreedommod/command/Command_entitywipe.java

38 lines
1.3 KiB
Java
Raw Normal View History

package me.totalfreedom.totalfreedommod.command;
import me.totalfreedom.totalfreedommod.rank.Rank;
import me.totalfreedom.totalfreedommod.util.FUtil;
2019-12-24 03:26:40 +00:00
import org.bukkit.Bukkit;
import org.bukkit.World;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
2019-12-24 03:26:40 +00:00
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH)
2019-01-29 04:57:41 +00:00
@CommandParameters(description = "Remove various server entities that may cause lag, such as dropped items, minecarts, and boats.", usage = "/<command>", aliases = "ew,rd")
public class Command_entitywipe extends FreedomCommand
{
@Override
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
2018-02-21 17:04:46 +00:00
FUtil.adminAction(sender.getName(), "Removing all server entities", true);
2019-12-24 03:26:40 +00:00
int removed = 0;
for (World world : Bukkit.getWorlds())
{
for (Entity entity : world.getEntities())
{
2019-12-24 04:21:52 +00:00
if (!(entity instanceof Player))
{
entity.remove();
removed++;
}
2019-12-24 03:26:40 +00:00
}
}
msg(removed + " entities removed.");
return true;
}
}