Merge branch 'master' into gradle
Dieser Commit ist enthalten in:
Commit
c0c3a4f6f8
@ -55,7 +55,7 @@ public class CommandClear extends SWCommand {
|
|||||||
|
|
||||||
private boolean permissionCheck(Player player) {
|
private boolean permissionCheck(Player player) {
|
||||||
if (Welt.noPermission(player, Permission.WORLD)) {
|
if (Welt.noPermission(player, Permission.WORLD)) {
|
||||||
player.sendMessage(BauSystem.PREFIX + "$cDu darfst hier keine fremden Inventare leeren.");
|
player.sendMessage(BauSystem.PREFIX + "§cDu darfst hier keine fremden Inventare leeren.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@ -89,19 +89,19 @@ public class CommandDetonator extends SWCommand {
|
|||||||
@Register("clear")
|
@Register("clear")
|
||||||
public void clearCommand(Player p) {
|
public void clearCommand(Player p) {
|
||||||
if (!permissionCheck(p)) return;
|
if (!permissionCheck(p)) return;
|
||||||
p.getInventory().setItemInMainHand(Detonator.clearDetonator(p.getInventory().getItemInMainHand()));
|
Detonator.clear(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Register("delete")
|
@Register("delete")
|
||||||
public void deleteCommand(Player p) {
|
public void deleteCommand(Player p) {
|
||||||
if (!permissionCheck(p)) return;
|
if (!permissionCheck(p)) return;
|
||||||
p.getInventory().setItemInMainHand(Detonator.clearDetonator(p.getInventory().getItemInMainHand()));
|
Detonator.clear(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Register("reset")
|
@Register("reset")
|
||||||
public void resetCommand(Player p) {
|
public void resetCommand(Player p) {
|
||||||
if (!permissionCheck(p)) return;
|
if (!permissionCheck(p)) return;
|
||||||
p.getInventory().setItemInMainHand(Detonator.clearDetonator(p.getInventory().getItemInMainHand()));
|
Detonator.clear(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean permissionCheck(Player player) {
|
private boolean permissionCheck(Player player) {
|
||||||
|
@ -21,9 +21,9 @@ package de.steamwar.bausystem.commands;
|
|||||||
|
|
||||||
import de.steamwar.bausystem.world.regions.*;
|
import de.steamwar.bausystem.world.regions.*;
|
||||||
import de.steamwar.command.SWCommand;
|
import de.steamwar.command.SWCommand;
|
||||||
|
import java.util.concurrent.atomic.AtomicLong;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.entity.Entity;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
public class CommandKillAll extends SWCommand {
|
public class CommandKillAll extends SWCommand {
|
||||||
@ -48,19 +48,26 @@ public class CommandKillAll extends SWCommand {
|
|||||||
@Register
|
@Register
|
||||||
public void genericCommand(Player player, RegionSelectionType regionSelectionType) {
|
public void genericCommand(Player player, RegionSelectionType regionSelectionType) {
|
||||||
Region region = Region.getRegion(player.getLocation());
|
Region region = Region.getRegion(player.getLocation());
|
||||||
|
AtomicLong removedEntities = new AtomicLong();
|
||||||
if (regionSelectionType == RegionSelectionType.GLOBAL || GlobalRegion.isGlobalRegion(region)) {
|
if (regionSelectionType == RegionSelectionType.GLOBAL || GlobalRegion.isGlobalRegion(region)) {
|
||||||
long removedEntities = WORLD.getEntities()
|
WORLD.getEntities()
|
||||||
.stream()
|
.stream()
|
||||||
.filter(e -> !(e instanceof Player))
|
.filter(e -> !(e instanceof Player))
|
||||||
.peek(Entity::remove).count();
|
.forEach(entity -> {
|
||||||
RegionUtils.actionBar(GlobalRegion.getInstance(), "§a" + removedEntities + " Entities aus der Welt entfernt");
|
entity.remove();
|
||||||
|
removedEntities.getAndIncrement();
|
||||||
|
});
|
||||||
|
RegionUtils.actionBar(GlobalRegion.getInstance(), "§a" + removedEntities.get() + " Entities aus der Welt entfernt");
|
||||||
} else {
|
} else {
|
||||||
long removedEntities = WORLD.getEntities()
|
WORLD.getEntities()
|
||||||
.stream()
|
.stream()
|
||||||
.filter(e -> !(e instanceof Player))
|
.filter(e -> !(e instanceof Player))
|
||||||
.filter(e -> region.inRegion(e.getLocation(), RegionType.NORMAL, RegionExtensionType.NORMAL))
|
.filter(e -> region.inRegion(e.getLocation(), RegionType.NORMAL, RegionExtensionType.NORMAL))
|
||||||
.peek(Entity::remove).count();
|
.forEach(entity -> {
|
||||||
RegionUtils.actionBar(region, "§a" + removedEntities + " Entities aus der Region entfernt");
|
entity.remove();
|
||||||
|
removedEntities.getAndIncrement();
|
||||||
|
});
|
||||||
|
RegionUtils.actionBar(region, "§a" + removedEntities.get() + " Entities aus der Region entfernt");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -239,6 +239,16 @@ public class Detonator implements Listener {
|
|||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void clear(Player player) {
|
||||||
|
VersionedRunnable.call(new VersionedRunnable(() -> PLAYER_LOCS.computeIfAbsent(player, player1 -> new HashSet<>()).clear(), 12), new VersionedRunnable(() -> {
|
||||||
|
if (player.getInventory().getItemInMainHand().getItemMeta().getPersistentDataContainer().has(new NamespacedKey(BauSystem.getPlugin(), "deto"), PersistentDataType.BYTE)) {
|
||||||
|
player.sendMessage(BauSystem.PREFIX + "§cDu hast keinen Detonator im Inventar");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
player.getInventory().setItemInMainHand(clearDetonator(player.getInventory().getItemInMainHand()));
|
||||||
|
}, 15));
|
||||||
|
}
|
||||||
|
|
||||||
public static ItemStack clearDetonator(ItemStack item) {
|
public static ItemStack clearDetonator(ItemStack item) {
|
||||||
ItemMeta meta = item.getItemMeta();
|
ItemMeta meta = item.getItemMeta();
|
||||||
PersistentDataContainer container = meta.getPersistentDataContainer();
|
PersistentDataContainer container = meta.getPersistentDataContainer();
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren