Update CommandDetonator to new SWCommand system
Dieser Commit ist enthalten in:
Ursprung
c3f3a5b12c
Commit
35f0108f70
@ -8,102 +8,82 @@ 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)) {
|
||||
if (!permissionCheck(p)) return;
|
||||
SWUtils.giveItemToPlayer(p, Detonator.WAND);
|
||||
p.updateInventory();
|
||||
}
|
||||
}
|
||||
|
||||
@Register("detonator")
|
||||
public void detonatorCommand(Player p) {
|
||||
if (permissionCheck(p)) {
|
||||
if (!permissionCheck(p)) return;
|
||||
SWUtils.giveItemToPlayer(p, Detonator.WAND);
|
||||
p.updateInventory();
|
||||
}
|
||||
}
|
||||
|
||||
@Register("item")
|
||||
public void itemCommand(Player p) {
|
||||
if (permissionCheck(p)) {
|
||||
if (!permissionCheck(p)) return;
|
||||
SWUtils.giveItemToPlayer(p, Detonator.WAND);
|
||||
p.updateInventory();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Register("remove")
|
||||
public void removeCommand(Player p) {
|
||||
if (permissionCheck(p)) {
|
||||
if (!permissionCheck(p)) return;
|
||||
p.getInventory().removeItem(Detonator.WAND);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Register("detonate")
|
||||
public void detonateCommand(Player p) {
|
||||
if (permissionCheck(p)) {
|
||||
if (!permissionCheck(p)) return;
|
||||
Detonator.execute(p);
|
||||
}
|
||||
}
|
||||
|
||||
@Register("click")
|
||||
public void clickCommand(Player p) {
|
||||
if (permissionCheck(p)) {
|
||||
if (!permissionCheck(p)) return;
|
||||
Detonator.execute(p);
|
||||
}
|
||||
}
|
||||
|
||||
@Register("use")
|
||||
public void useCommand(Player p) {
|
||||
if (permissionCheck(p)) {
|
||||
if (!permissionCheck(p)) return;
|
||||
Detonator.execute(p);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Register("clear")
|
||||
public void clearCommand(Player p) {
|
||||
if (permissionCheck(p)) {
|
||||
if (!permissionCheck(p)) return;
|
||||
p.getInventory().setItemInMainHand(Detonator.clearDetonator(p.getInventory().getItemInMainHand()));
|
||||
}
|
||||
}
|
||||
|
||||
@Register("delete")
|
||||
public void deleteCommand(Player p) {
|
||||
if (permissionCheck(p)) {
|
||||
if (!permissionCheck(p)) return;
|
||||
p.getInventory().setItemInMainHand(Detonator.clearDetonator(p.getInventory().getItemInMainHand()));
|
||||
}
|
||||
}
|
||||
|
||||
@Register("reset")
|
||||
public void resetCommand(Player p) {
|
||||
if (permissionCheck(p)) {
|
||||
if (!permissionCheck(p)) return;
|
||||
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");
|
||||
}
|
||||
|
||||
private boolean permissionCheck(Player player) {
|
||||
if (Welt.noPermission(player, Permission.world)) {
|
||||
|
@ -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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
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<String> arguments = new ArrayList<>(Arrays.asList("wand", "reset", "detonate", "remove"));
|
||||
|
||||
@Override
|
||||
public List<String> 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);
|
||||
}
|
||||
}
|
37
BauSystem_Main/src/de/steamwar/bausystem/commands/RegionUtils.java
Normale Datei
37
BauSystem_Main/src/de/steamwar/bausystem/commands/RegionUtils.java
Normale Datei
@ -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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
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)));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
In neuem Issue referenzieren
Einen Benutzer sperren