diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandDetonator.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandDetonator.java
index f1a1ddb..310c395 100644
--- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandDetonator.java
+++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandDetonator.java
@@ -8,101 +8,81 @@ import de.steamwar.bausystem.world.Welt;
import de.steamwar.command.SWCommand;
import org.bukkit.entity.Player;
-
public class CommandDetonator extends SWCommand {
public CommandDetonator() {
super ("detonator", "dt");
}
-
@Register(help = true)
public void genericHelp(Player p, String... args) {
- help(p);
+ p.sendMessage("§8/§edetonator wand §8- §7Legt den Fernzünder ins Inventar");
+ p.sendMessage("§8/§edetonator detonate §8- §7Benutzt den nächst besten Fernzünder");
+ p.sendMessage("§8/§edetonator reset §8- §7Löscht alle markierten Positionen");
+ p.sendMessage("§8/§edetonator remove §8- §7Entfernt den Fernzünder");
}
@Register("wand")
public void wandCommand(Player p) {
- if (permissionCheck(p)) {
- SWUtils.giveItemToPlayer(p, Detonator.WAND);
- p.updateInventory();
- }
+ if (!permissionCheck(p)) return;
+ SWUtils.giveItemToPlayer(p, Detonator.WAND);
}
@Register("detonator")
public void detonatorCommand(Player p) {
- if (permissionCheck(p)) {
- SWUtils.giveItemToPlayer(p, Detonator.WAND);
- p.updateInventory();
- }
+ if (!permissionCheck(p)) return;
+ SWUtils.giveItemToPlayer(p, Detonator.WAND);
}
@Register("item")
public void itemCommand(Player p) {
- if (permissionCheck(p)) {
- SWUtils.giveItemToPlayer(p, Detonator.WAND);
- p.updateInventory();
- }
+ if (!permissionCheck(p)) return;
+ SWUtils.giveItemToPlayer(p, Detonator.WAND);
}
@Register("remove")
public void removeCommand(Player p) {
- if (permissionCheck(p)) {
- p.getInventory().removeItem(Detonator.WAND);
- }
+ if (!permissionCheck(p)) return;
+ p.getInventory().removeItem(Detonator.WAND);
}
@Register("detonate")
public void detonateCommand(Player p) {
- if (permissionCheck(p)) {
- Detonator.execute(p);
- }
+ if (!permissionCheck(p)) return;
+ Detonator.execute(p);
}
@Register("click")
public void clickCommand(Player p) {
- if (permissionCheck(p)) {
- Detonator.execute(p);
- }
+ if (!permissionCheck(p)) return;
+ Detonator.execute(p);
}
@Register("use")
public void useCommand(Player p) {
- if (permissionCheck(p)) {
- Detonator.execute(p);
- }
+ if (!permissionCheck(p)) return;
+ Detonator.execute(p);
}
@Register("clear")
public void clearCommand(Player p) {
- if (permissionCheck(p)) {
- p.getInventory().setItemInMainHand(Detonator.clearDetonator(p.getInventory().getItemInMainHand()));
- }
+ if (!permissionCheck(p)) return;
+ p.getInventory().setItemInMainHand(Detonator.clearDetonator(p.getInventory().getItemInMainHand()));
}
@Register("delete")
public void deleteCommand(Player p) {
- if (permissionCheck(p)) {
- p.getInventory().setItemInMainHand(Detonator.clearDetonator(p.getInventory().getItemInMainHand()));
- }
+ if (!permissionCheck(p)) return;
+ p.getInventory().setItemInMainHand(Detonator.clearDetonator(p.getInventory().getItemInMainHand()));
}
@Register("reset")
public void resetCommand(Player p) {
- if (permissionCheck(p)) {
- p.getInventory().setItemInMainHand(Detonator.clearDetonator(p.getInventory().getItemInMainHand()));
- }
- }
-
-
- private void help(Player player) {
- player.sendMessage("§8/§edetonator wand §8- §7Legt den Fernzünder ins Inventar");
- player.sendMessage("§8/§edetonator detonate §8- §7Benutzt den nächst besten Fernzünder");
- player.sendMessage("§8/§edetonator reset §8- §7Löscht alle markierten Positionen");
- player.sendMessage("§8/§edetonator remove §8- §7Entfernt den Fernzünder");
+ if (!permissionCheck(p)) return;
+ p.getInventory().setItemInMainHand(Detonator.clearDetonator(p.getInventory().getItemInMainHand()));
}
private boolean permissionCheck(Player player) {
diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandDetonatorTabCompleter.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandDetonatorTabCompleter.java
deleted file mode 100644
index f4a166a..0000000
--- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandDetonatorTabCompleter.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- This file is a part of the SteamWar software.
-
- Copyright (C) 2020 SteamWar.de-Serverteam
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU Affero General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Affero General Public License for more details.
-
- You should have received a copy of the GNU Affero General Public License
- along with this program. If not, see .
-*/
-
-package de.steamwar.bausystem.commands;
-
-import de.steamwar.bausystem.SWUtils;
-import org.bukkit.command.Command;
-import org.bukkit.command.CommandSender;
-import org.bukkit.command.TabCompleter;
-import org.bukkit.entity.Player;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-public class CommandDetonatorTabCompleter implements TabCompleter {
-
- private List arguments = new ArrayList<>(Arrays.asList("wand", "reset", "detonate", "remove"));
-
- @Override
- public List onTabComplete(CommandSender sender, Command command, String label, String[] args) {
- if(!(sender instanceof Player)) return new ArrayList<>();
- if (args.length != 1) {
- return new ArrayList<>();
- }
- return SWUtils.manageList(arguments, args);
- }
-}
diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/RegionUtils.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/RegionUtils.java
new file mode 100644
index 0000000..24dcedd
--- /dev/null
+++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/RegionUtils.java
@@ -0,0 +1,37 @@
+/*
+ * This file is a part of the SteamWar software.
+ *
+ * Copyright (C) 2020 SteamWar.de-Serverteam
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ */
+
+package de.steamwar.bausystem.commands;
+
+import de.steamwar.bausystem.world.Region;
+import net.md_5.bungee.api.ChatMessageType;
+import net.md_5.bungee.api.chat.TextComponent;
+import org.bukkit.Bukkit;
+
+public class RegionUtils {
+
+ public static void actionBar(Region region, String s) {
+ if (Region.GlobalRegion.isGlobalRegion(region)) {
+ Bukkit.getOnlinePlayers().stream().filter(player -> Region.getRegion(player.getLocation()) == null).forEach(player -> player.spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText(s)));
+ } else {
+ Bukkit.getOnlinePlayers().stream().filter(player -> region.inRegion(player.getLocation())).forEach(player -> player.spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText(s)));
+ }
+ }
+
+}