Remove now not needed arrows remove command
This commit is contained in:
parent
21426e8344
commit
6babf426e3
@ -4,17 +4,9 @@
|
|||||||
*/
|
*/
|
||||||
package com.cnaude.chairs;
|
package com.cnaude.chairs;
|
||||||
|
|
||||||
import java.util.Iterator;
|
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.World;
|
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandExecutor;
|
import org.bukkit.command.CommandExecutor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.command.ConsoleCommandSender;
|
|
||||||
import org.bukkit.command.RemoteConsoleCommandSender;
|
|
||||||
import org.bukkit.entity.Arrow;
|
|
||||||
import org.bukkit.entity.Entity;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -58,20 +50,6 @@ public class ChairsCommand implements CommandExecutor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (args[0].equalsIgnoreCase("removearrows")) {
|
|
||||||
if (sender instanceof ConsoleCommandSender || sender instanceof RemoteConsoleCommandSender || (sender instanceof Player && sender.hasPermission("chairs.removearrows"))) {
|
|
||||||
if (args.length == 2) {
|
|
||||||
World world = Bukkit.getWorld(args[1]);
|
|
||||||
int removed = removeArrows(world);
|
|
||||||
sender.sendMessage("Removed "+removed+" unused arrows");
|
|
||||||
} else if (args.length == 1) {
|
|
||||||
for (World world : Bukkit.getWorlds()) {
|
|
||||||
int removed = removeArrows(world);
|
|
||||||
sender.sendMessage("Removed "+removed+" unused arrows");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (sender instanceof Player) {
|
if (sender instanceof Player) {
|
||||||
Player p = (Player) sender;
|
Player p = (Player) sender;
|
||||||
if (args[0].equalsIgnoreCase("on")) {
|
if (args[0].equalsIgnoreCase("on")) {
|
||||||
@ -102,19 +80,4 @@ public class ChairsCommand implements CommandExecutor {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private int removeArrows(World world) {
|
|
||||||
Iterator<Entity> entityit = world.getEntities().iterator();
|
|
||||||
int removed = 0;
|
|
||||||
while (entityit.hasNext()) {
|
|
||||||
Entity entity = entityit.next();
|
|
||||||
if (entity instanceof Arrow) {
|
|
||||||
if (!plugin.getPlayerSitData().isAroowOccupied(entity)) {
|
|
||||||
entity.remove();
|
|
||||||
removed++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return removed;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user