|
|
|
@ -23,62 +23,68 @@ import de.steamwar.bausystem.BauSystem;
|
|
|
|
|
import de.steamwar.bausystem.Permission;
|
|
|
|
|
import de.steamwar.bausystem.world.AutoLoader;
|
|
|
|
|
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 CommandLoader implements CommandExecutor {
|
|
|
|
|
public class CommandLoader extends SWCommand {
|
|
|
|
|
|
|
|
|
|
private void help(Player player) {
|
|
|
|
|
player.sendMessage("§8/§eloader setup §8- §7Startet die Aufnahme der Aktionen");
|
|
|
|
|
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)");
|
|
|
|
|
public CommandLoader() {
|
|
|
|
|
super("loader");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
|
|
|
|
if (!(sender instanceof Player))
|
|
|
|
|
return false;
|
|
|
|
|
Player player = (Player) sender;
|
|
|
|
|
@Register(help = true)
|
|
|
|
|
public void genericHelp(Player p, String... args) {
|
|
|
|
|
p.sendMessage("§8/§eloader setup §8- §7Startet die Aufnahme der Aktionen");
|
|
|
|
|
p.sendMessage("§8/§7loader undo §8- §7Entfernt die zuletzt aufgenommene Aktion");
|
|
|
|
|
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)) {
|
|
|
|
|
player.sendMessage(BauSystem.PREFIX + "§cDu darfst hier nicht den AutoLader verwenden");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void setup(Player player) {
|
|
|
|
@ -114,43 +120,26 @@ public class CommandLoader implements CommandExecutor {
|
|
|
|
|
AutoLoader.getLoader(player).stop();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void wait(Player player, String[] args) {
|
|
|
|
|
if (args.length != 2) {
|
|
|
|
|
help(player);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void wait(Player player, int time) {
|
|
|
|
|
AutoLoader loader = loader(player);
|
|
|
|
|
if (loader == null)
|
|
|
|
|
if (loader == null) {
|
|
|
|
|
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) {
|
|
|
|
|
if (args.length != 2) {
|
|
|
|
|
help(player);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void speed(Player player, int time) {
|
|
|
|
|
AutoLoader loader = loader(player);
|
|
|
|
|
if (loader == null)
|
|
|
|
|
if (loader == null) {
|
|
|
|
|
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) {
|
|
|
|
|
if (AutoLoader.hasLoader(player))
|
|
|
|
|
if (AutoLoader.hasLoader(player)) {
|
|
|
|
|
return AutoLoader.getLoader(player);
|
|
|
|
|
}
|
|
|
|
|
player.sendMessage(BauSystem.PREFIX + "§cDu hast keinen aktiven AutoLader");
|
|
|
|
|
player.sendMessage(BauSystem.PREFIX + "§7Es wird ein neuer AutoLader gestartet");
|
|
|
|
|
setup(player);
|
|
|
|
|