SteamWar/BauSystem2.0
Archiviert
12
0

Fix KillAllCommand

Signed-off-by: yoyosource <yoyosource@nidido.de>
Dieser Commit ist enthalten in:
yoyosource 2021-05-15 16:26:01 +02:00
Ursprung 2000838f2a
Commit 93aaf02e3c

Datei anzeigen

@ -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");
}
}