Fix KillAllCommand
Signed-off-by: yoyosource <yoyosource@nidido.de>
Dieser Commit ist enthalten in:
Ursprung
2000838f2a
Commit
93aaf02e3c
@ -33,6 +33,9 @@ import org.bukkit.World;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
|
||||
@Linked(LinkageType.COMMAND)
|
||||
public class KillAllCommand extends SWCommand {
|
||||
|
||||
@ -56,19 +59,26 @@ public class KillAllCommand extends SWCommand {
|
||||
@Register
|
||||
public void genericCommand(Player player, RegionSelectionType regionSelectionType) {
|
||||
Region region = Region.getRegion(player.getLocation());
|
||||
AtomicLong count = new AtomicLong(0);
|
||||
if (regionSelectionType == RegionSelectionType.GLOBAL || GlobalRegion.getInstance() == region) {
|
||||
long removedEntities = WORLD.getEntities()
|
||||
WORLD.getEntities()
|
||||
.stream()
|
||||
.filter(e -> !(e instanceof Player))
|
||||
.peek(Entity::remove).count();
|
||||
RegionUtils.actionBar(GlobalRegion.getInstance(), "§a" + removedEntities + " Entities aus der Welt entfernt");
|
||||
.forEach(entity -> {
|
||||
entity.remove();
|
||||
count.incrementAndGet();
|
||||
});
|
||||
RegionUtils.actionBar(GlobalRegion.getInstance(), "§a" + count.get() + " Entities aus der Welt entfernt");
|
||||
} else {
|
||||
long removedEntities = WORLD.getEntities()
|
||||
WORLD.getEntities()
|
||||
.stream()
|
||||
.filter(e -> !(e instanceof Player))
|
||||
.filter(e -> region.inRegion(e.getLocation(), RegionType.NORMAL, RegionExtensionType.NORMAL))
|
||||
.peek(Entity::remove).count();
|
||||
RegionUtils.actionBar(region, "§a" + removedEntities + " Entities aus der Region entfernt");
|
||||
.forEach(entity -> {
|
||||
entity.remove();
|
||||
count.incrementAndGet();
|
||||
});
|
||||
RegionUtils.actionBar(region, "§a" + count.get() + " Entities aus der Region entfernt");
|
||||
}
|
||||
}
|
||||
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren