Update BauSystem to new CommandFramework #217
@ -96,8 +96,7 @@ public class BauSystem extends JavaPlugin implements Listener {
|
||||
getCommand("script").setExecutor(new CommandScript());
|
||||
getCommand("scriptvars").setExecutor(new CommandScriptVars());
|
||||
getCommand("scriptvars").setTabCompleter(new CommandScriptVarsTabCompleter());
|
||||
getCommand("simulator").setExecutor(new CommandSimulator());
|
||||
getCommand("simulator").setTabCompleter(new CommandSimulatorTabCompleter());
|
||||
new CommandSimulator();
|
||||
getCommand("redstonetester").setExecutor(new CommandRedstoneTester());
|
||||
getCommand("gui").setExecutor(new CommandGUI());
|
||||
|
||||
|
@ -25,18 +25,45 @@ import de.steamwar.bausystem.Permission;
|
||||
import de.steamwar.bausystem.SWUtils;
|
||||
import de.steamwar.bausystem.world.TNTSimulator;
|
||||
import de.steamwar.bausystem.world.Welt;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import de.steamwar.command.SWCommand;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class CommandSimulator implements CommandExecutor {
|
||||
public class CommandSimulator extends SWCommand {
|
||||
|
||||
private void help(Player player) {
|
||||
player.sendMessage("§8/§esimulator §8- §7Öffnet die Simulations GUI");
|
||||
player.sendMessage("§8/§esimulator start §8- §7Startet die Simulation");
|
||||
player.sendMessage("§8/§esimulator wand §8- §7Legt dir den Simulatorstab ins Inventar");
|
||||
player.sendMessage("§8/§esimulator delete §8- §7Löscht alle TNT");
|
||||
public CommandSimulator() {
|
||||
super("simulator", "sim");
|
||||
}
|
||||
|
||||
@Register(help = true)
|
||||
public void genericHelp(Player p, String... args) {
|
||||
p.sendMessage("§8/§esimulator §8- §7Öffnet die Simulations GUI");
|
||||
p.sendMessage("§8/§esimulator start §8- §7Startet die Simulation");
|
||||
p.sendMessage("§8/§esimulator wand §8- §7Legt dir den Simulatorstab ins Inventar");
|
||||
p.sendMessage("§8/§esimulator delete §8- §7Löscht alle TNT");
|
||||
}
|
||||
|
||||
@Register
|
||||
public void genericCommand(Player p) {
|
||||
if (!permissionCheck(p)) return;
|
||||
TNTSimulator.openSimulator(p);
|
||||
}
|
||||
|
||||
@Register({"wand"})
|
||||
public void wandCommand(Player p) {
|
||||
if (!permissionCheck(p)) return;
|
||||
SWUtils.giveItemToPlayer(p, TNTSimulator.WAND);
|
||||
}
|
||||
|
||||
@Register({"start"})
|
||||
public void startCommand(Player p) {
|
||||
if (!permissionCheck(p)) return;
|
||||
TNTSimulator.get(p).start();
|
||||
}
|
||||
|
||||
@Register({"delete"})
|
||||
public void deleteCommand(Player p) {
|
||||
if (!permissionCheck(p)) return;
|
||||
TNTSimulator.get(p).delete();
|
||||
}
|
||||
|
||||
private boolean permissionCheck(Player player) {
|
||||
@ -47,33 +74,4 @@ public class CommandSimulator implements CommandExecutor {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender commandSender, Command command, String s, String[] args) {
|
||||
if (!(commandSender instanceof Player))
|
||||
return false;
|
||||
Player player = (Player) commandSender;
|
||||
if (!permissionCheck(player)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (args.length == 1) {
|
||||
switch (args[0].toLowerCase()) {
|
||||
case "wand":
|
||||
SWUtils.giveItemToPlayer(player, TNTSimulator.WAND);
|
||||
break;
|
||||
case "start":
|
||||
TNTSimulator.get(player).start();
|
||||
break;
|
||||
case "delete":
|
||||
TNTSimulator.get(player).delete();
|
||||
default:
|
||||
help(player);
|
||||
break;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
TNTSimulator.openSimulator(player);
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,46 +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 CommandSimulatorTabCompleter implements TabCompleter {
|
||||
|
||||
private List<String> arguments = new ArrayList<>(Arrays.asList("wand", "start", "delete"));
|
||||
|
||||
@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);
|
||||
}
|
||||
|
||||
}
|
@ -23,8 +23,6 @@ commands:
|
||||
lockschem:
|
||||
script:
|
||||
scriptvars:
|
||||
simulator:
|
||||
aliases: sim
|
||||
gui:
|
||||
redstonetester:
|
||||
aliases: rt
|
In neuem Issue referenzieren
Einen Benutzer sperren