Update CommandLoader to new SWCommand system
Dieser Commit ist enthalten in:
Ursprung
91b8d2db1b
Commit
87ed69478f
@ -88,7 +88,7 @@ public class BauSystem extends JavaPlugin implements Listener {
|
|||||||
getCommand("bauinfo").setExecutor(new CommandInfo());
|
getCommand("bauinfo").setExecutor(new CommandInfo());
|
||||||
new CommandProtect();
|
new CommandProtect();
|
||||||
new CommandSkull();
|
new CommandSkull();
|
||||||
getCommand("loader").setExecutor(new CommandLoader());
|
new CommandLoader();
|
||||||
getCommand("lockschem").setExecutor(new CommandLockschem());
|
getCommand("lockschem").setExecutor(new CommandLockschem());
|
||||||
new CommandDebugStick();
|
new CommandDebugStick();
|
||||||
getCommand("watervision").setExecutor(new CommandGills());
|
getCommand("watervision").setExecutor(new CommandGills());
|
||||||
|
@ -23,62 +23,68 @@ import de.steamwar.bausystem.BauSystem;
|
|||||||
import de.steamwar.bausystem.Permission;
|
import de.steamwar.bausystem.Permission;
|
||||||
import de.steamwar.bausystem.world.AutoLoader;
|
import de.steamwar.bausystem.world.AutoLoader;
|
||||||
import de.steamwar.bausystem.world.Welt;
|
import de.steamwar.bausystem.world.Welt;
|
||||||
import org.bukkit.command.Command;
|
import de.steamwar.command.SWCommand;
|
||||||
import org.bukkit.command.CommandExecutor;
|
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
public class CommandLoader implements CommandExecutor {
|
public class CommandLoader extends SWCommand {
|
||||||
|
|
||||||
private void help(Player player) {
|
public CommandLoader() {
|
||||||
player.sendMessage("§8/§eloader setup §8- §7Startet die Aufnahme der Aktionen");
|
super("loader");
|
||||||
player.sendMessage("§8/§7loader undo §8- §7Entfernt die zuletzt aufgenommene Aktion");
|
|
||||||
player.sendMessage("§8/§eloader start §8- §7Spielt die zuvor aufgenommenen Aktionen ab");
|
|
||||||
player.sendMessage("§8/§7loader wait §8[§7Ticks§8] - §7Setzt die Wartezeit zwischen Schüssen");
|
|
||||||
player.sendMessage("§8/§7loader speed §8[§7Ticks§8] - §7Setzt die Wartezeit zwischen Aktionen");
|
|
||||||
player.sendMessage("§8/§eloader stop §8- §7Stoppt die Aufnahme bzw. das Abspielen");
|
|
||||||
player.sendMessage("§7Der AutoLader arbeitet mit §eIngame§8-§eTicks §8(20 Ticks pro Sekunde)");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Register(help = true)
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
public void genericHelp(Player p, String... args) {
|
||||||
if (!(sender instanceof Player))
|
p.sendMessage("§8/§eloader setup §8- §7Startet die Aufnahme der Aktionen");
|
||||||
return false;
|
p.sendMessage("§8/§7loader undo §8- §7Entfernt die zuletzt aufgenommene Aktion");
|
||||||
Player player = (Player) sender;
|
p.sendMessage("§8/§eloader start §8- §7Spielt die zuvor aufgenommenen Aktionen ab");
|
||||||
|
p.sendMessage("§8/§7loader wait §8[§7Ticks§8] - §7Setzt die Wartezeit zwischen Schüssen");
|
||||||
|
p.sendMessage("§8/§7loader speed §8[§7Ticks§8] - §7Setzt die Wartezeit zwischen Aktionen");
|
||||||
|
p.sendMessage("§8/§eloader stop §8- §7Stoppt die Aufnahme bzw. das Abspielen");
|
||||||
|
p.sendMessage("§7Der AutoLader arbeitet mit §eIngame§8-§eTicks §8(20 Ticks pro Sekunde)");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Register({"setup"})
|
||||||
|
public void setupCommand(Player p) {
|
||||||
|
if (!permissionCheck(p)) return;
|
||||||
|
setup(p);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Register({"undo"})
|
||||||
|
public void undoCommand(Player p) {
|
||||||
|
if (!permissionCheck(p)) return;
|
||||||
|
undo(p);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Register({"start"})
|
||||||
|
public void startCommand(Player p) {
|
||||||
|
if (!permissionCheck(p)) return;
|
||||||
|
start(p);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Register({"stop"})
|
||||||
|
public void stopCommand(Player p) {
|
||||||
|
if (!permissionCheck(p)) return;
|
||||||
|
stop(p);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Register({"wait"})
|
||||||
|
public void waitCommand(Player p, int time) {
|
||||||
|
if (!permissionCheck(p)) return;
|
||||||
|
wait(p, time);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Register({"speed"})
|
||||||
|
public void speedCommand(Player p, int time) {
|
||||||
|
if (!permissionCheck(p)) return;
|
||||||
|
speed(p, time);
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean permissionCheck(Player player) {
|
||||||
if (Welt.noPermission(player, Permission.build)) {
|
if (Welt.noPermission(player, Permission.build)) {
|
||||||
player.sendMessage(BauSystem.PREFIX + "§cDu darfst hier nicht den AutoLader verwenden");
|
player.sendMessage(BauSystem.PREFIX + "§cDu darfst hier nicht den AutoLader verwenden");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
if (args.length == 0) {
|
|
||||||
help(player);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (args[0].toLowerCase()) {
|
|
||||||
case "setup":
|
|
||||||
setup(player);
|
|
||||||
break;
|
|
||||||
case "undo":
|
|
||||||
undo(player);
|
|
||||||
break;
|
|
||||||
case "start":
|
|
||||||
start(player);
|
|
||||||
break;
|
|
||||||
case "stop":
|
|
||||||
stop(player);
|
|
||||||
break;
|
|
||||||
case "wait":
|
|
||||||
wait(player, args);
|
|
||||||
break;
|
|
||||||
case "speed":
|
|
||||||
speed(player, args);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
help(player);
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setup(Player player) {
|
private void setup(Player player) {
|
||||||
@ -114,43 +120,26 @@ public class CommandLoader implements CommandExecutor {
|
|||||||
AutoLoader.getLoader(player).stop();
|
AutoLoader.getLoader(player).stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void wait(Player player, String[] args) {
|
private void wait(Player player, int time) {
|
||||||
if (args.length != 2) {
|
|
||||||
help(player);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
AutoLoader loader = loader(player);
|
AutoLoader loader = loader(player);
|
||||||
if (loader == null)
|
if (loader == null) {
|
||||||
loader = AutoLoader.getLoader(player);
|
loader = AutoLoader.getLoader(player);
|
||||||
|
|
||||||
try {
|
|
||||||
loader.wait(Integer.parseInt(args[1]));
|
|
||||||
} catch (NumberFormatException e) {
|
|
||||||
player.sendMessage(BauSystem.PREFIX + "§cBitte gib eine Ganzzahl an");
|
|
||||||
}
|
}
|
||||||
|
loader.wait(time);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void speed(Player player, String[] args) {
|
private void speed(Player player, int time) {
|
||||||
if (args.length != 2) {
|
|
||||||
help(player);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
AutoLoader loader = loader(player);
|
AutoLoader loader = loader(player);
|
||||||
if (loader == null)
|
if (loader == null) {
|
||||||
loader = AutoLoader.getLoader(player);
|
loader = AutoLoader.getLoader(player);
|
||||||
|
|
||||||
try {
|
|
||||||
loader.blockWait(Integer.parseInt(args[1]));
|
|
||||||
} catch (NumberFormatException e) {
|
|
||||||
player.sendMessage(BauSystem.PREFIX + "§cBitte gib eine Ganzzahl an");
|
|
||||||
}
|
}
|
||||||
|
loader.blockWait(time);
|
||||||
}
|
}
|
||||||
|
|
||||||
private AutoLoader loader(Player player) {
|
private AutoLoader loader(Player player) {
|
||||||
if (AutoLoader.hasLoader(player))
|
if (AutoLoader.hasLoader(player)) {
|
||||||
return AutoLoader.getLoader(player);
|
return AutoLoader.getLoader(player);
|
||||||
|
}
|
||||||
player.sendMessage(BauSystem.PREFIX + "§cDu hast keinen aktiven AutoLader");
|
player.sendMessage(BauSystem.PREFIX + "§cDu hast keinen aktiven AutoLader");
|
||||||
player.sendMessage(BauSystem.PREFIX + "§7Es wird ein neuer AutoLader gestartet");
|
player.sendMessage(BauSystem.PREFIX + "§7Es wird ein neuer AutoLader gestartet");
|
||||||
setup(player);
|
setup(player);
|
||||||
|
@ -13,7 +13,6 @@ commands:
|
|||||||
bauinfo:
|
bauinfo:
|
||||||
freeze:
|
freeze:
|
||||||
aliases: stoplag
|
aliases: stoplag
|
||||||
loader:
|
|
||||||
watervision:
|
watervision:
|
||||||
aliases: wv
|
aliases: wv
|
||||||
lockschem:
|
lockschem:
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren