Update CommandDetonator to new SWCommand system
Dieser Commit ist enthalten in:
Ursprung
c3f3a5b12c
Commit
35f0108f70
@ -8,101 +8,81 @@ import de.steamwar.bausystem.world.Welt;
|
|||||||
import de.steamwar.command.SWCommand;
|
import de.steamwar.command.SWCommand;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
|
||||||
public class CommandDetonator extends SWCommand {
|
public class CommandDetonator extends SWCommand {
|
||||||
|
|
||||||
public CommandDetonator() {
|
public CommandDetonator() {
|
||||||
super ("detonator", "dt");
|
super ("detonator", "dt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Register(help = true)
|
@Register(help = true)
|
||||||
public void genericHelp(Player p, String... args) {
|
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")
|
@Register("wand")
|
||||||
public void wandCommand(Player p) {
|
public void wandCommand(Player p) {
|
||||||
if (permissionCheck(p)) {
|
if (!permissionCheck(p)) return;
|
||||||
SWUtils.giveItemToPlayer(p, Detonator.WAND);
|
SWUtils.giveItemToPlayer(p, Detonator.WAND);
|
||||||
p.updateInventory();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Register("detonator")
|
@Register("detonator")
|
||||||
public void detonatorCommand(Player p) {
|
public void detonatorCommand(Player p) {
|
||||||
if (permissionCheck(p)) {
|
if (!permissionCheck(p)) return;
|
||||||
SWUtils.giveItemToPlayer(p, Detonator.WAND);
|
SWUtils.giveItemToPlayer(p, Detonator.WAND);
|
||||||
p.updateInventory();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Register("item")
|
@Register("item")
|
||||||
public void itemCommand(Player p) {
|
public void itemCommand(Player p) {
|
||||||
if (permissionCheck(p)) {
|
if (!permissionCheck(p)) return;
|
||||||
SWUtils.giveItemToPlayer(p, Detonator.WAND);
|
SWUtils.giveItemToPlayer(p, Detonator.WAND);
|
||||||
p.updateInventory();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Register("remove")
|
@Register("remove")
|
||||||
public void removeCommand(Player p) {
|
public void removeCommand(Player p) {
|
||||||
if (permissionCheck(p)) {
|
if (!permissionCheck(p)) return;
|
||||||
p.getInventory().removeItem(Detonator.WAND);
|
p.getInventory().removeItem(Detonator.WAND);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Register("detonate")
|
@Register("detonate")
|
||||||
public void detonateCommand(Player p) {
|
public void detonateCommand(Player p) {
|
||||||
if (permissionCheck(p)) {
|
if (!permissionCheck(p)) return;
|
||||||
Detonator.execute(p);
|
Detonator.execute(p);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Register("click")
|
@Register("click")
|
||||||
public void clickCommand(Player p) {
|
public void clickCommand(Player p) {
|
||||||
if (permissionCheck(p)) {
|
if (!permissionCheck(p)) return;
|
||||||
Detonator.execute(p);
|
Detonator.execute(p);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Register("use")
|
@Register("use")
|
||||||
public void useCommand(Player p) {
|
public void useCommand(Player p) {
|
||||||
if (permissionCheck(p)) {
|
if (!permissionCheck(p)) return;
|
||||||
Detonator.execute(p);
|
Detonator.execute(p);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Register("clear")
|
@Register("clear")
|
||||||
public void clearCommand(Player p) {
|
public void clearCommand(Player p) {
|
||||||
if (permissionCheck(p)) {
|
if (!permissionCheck(p)) return;
|
||||||
p.getInventory().setItemInMainHand(Detonator.clearDetonator(p.getInventory().getItemInMainHand()));
|
p.getInventory().setItemInMainHand(Detonator.clearDetonator(p.getInventory().getItemInMainHand()));
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Register("delete")
|
@Register("delete")
|
||||||
public void deleteCommand(Player p) {
|
public void deleteCommand(Player p) {
|
||||||
if (permissionCheck(p)) {
|
if (!permissionCheck(p)) return;
|
||||||
p.getInventory().setItemInMainHand(Detonator.clearDetonator(p.getInventory().getItemInMainHand()));
|
p.getInventory().setItemInMainHand(Detonator.clearDetonator(p.getInventory().getItemInMainHand()));
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Register("reset")
|
@Register("reset")
|
||||||
public void resetCommand(Player p) {
|
public void resetCommand(Player p) {
|
||||||
if (permissionCheck(p)) {
|
if (!permissionCheck(p)) return;
|
||||||
p.getInventory().setItemInMainHand(Detonator.clearDetonator(p.getInventory().getItemInMainHand()));
|
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) {
|
private boolean permissionCheck(Player player) {
|
||||||
|
@ -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