From e03a37676dbc40b5ac4e06ae0963f3f7070c6391 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Thu, 1 Apr 2021 19:00:18 +0200 Subject: [PATCH 01/51] Update CommandTrace to new SWCommand system --- .../src/de/steamwar/bausystem/BauSystem.java | 3 +- .../src/de/steamwar/bausystem/Mapper.java | 73 ++++++++ .../bausystem/commands/CommandTrace.java | 161 ++++++++++-------- .../commands/CommandTraceTabCompleter.java | 81 --------- .../tracer/show/ShowModeParameter.java | 45 ----- .../tracer/show/ShowModeParameterType.java | 44 +++++ BauSystem_Main/src/plugin.yml | 1 - 7 files changed, 206 insertions(+), 202 deletions(-) create mode 100644 BauSystem_Main/src/de/steamwar/bausystem/Mapper.java delete mode 100644 BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTraceTabCompleter.java create mode 100644 BauSystem_Main/src/de/steamwar/bausystem/tracer/show/ShowModeParameterType.java diff --git a/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java b/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java index 78869bc..f9958f8 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java @@ -75,8 +75,7 @@ public class BauSystem extends JavaPlugin implements Listener { return; } - getCommand("trace").setExecutor(new CommandTrace()); - getCommand("trace").setTabCompleter(new CommandTraceTabCompleter()); + new CommandTrace(); getCommand("tpslimit").setExecutor(new CommandTPSLimiter()); getCommand("tpslimit").setTabCompleter(new CommandTPSLimiterTabComplete()); getCommand("nightvision").setExecutor(new CommandNV()); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/Mapper.java b/BauSystem_Main/src/de/steamwar/bausystem/Mapper.java new file mode 100644 index 0000000..8419493 --- /dev/null +++ b/BauSystem_Main/src/de/steamwar/bausystem/Mapper.java @@ -0,0 +1,73 @@ +/* + * 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 . + */ + +package de.steamwar.bausystem; + +import de.steamwar.bausystem.tracer.show.ShowModeParameterType; +import de.steamwar.command.SWCommandUtils; +import de.steamwar.command.TypeMapper; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class Mapper { + + private Mapper() { + throw new IllegalStateException("Utility Class"); + } + + public static void init() { + SWCommandUtils.addMapper(ShowModeParameterType.class, showModeParameterTypesTypeMapper()); + } + + private static TypeMapper showModeParameterTypesTypeMapper() { + Map showModeParameterTypesMap = new HashMap<>(); + showModeParameterTypesMap.put("-water", ShowModeParameterType.WATER); + + showModeParameterTypesMap.put("-interpolatey", ShowModeParameterType.INTERPOLATE_Y); + showModeParameterTypesMap.put("-interpolate-y", ShowModeParameterType.INTERPOLATE_Y); + showModeParameterTypesMap.put("-interpolate_y", ShowModeParameterType.INTERPOLATE_Y); + showModeParameterTypesMap.put("-y", ShowModeParameterType.INTERPOLATE_Y); + + showModeParameterTypesMap.put("-interpolatex", ShowModeParameterType.INTERPOLATE_XZ); + showModeParameterTypesMap.put("-interpolate-x", ShowModeParameterType.INTERPOLATE_XZ); + showModeParameterTypesMap.put("-interpolate_x", ShowModeParameterType.INTERPOLATE_XZ); + showModeParameterTypesMap.put("-x", ShowModeParameterType.INTERPOLATE_XZ); + + showModeParameterTypesMap.put("-interpolatez", ShowModeParameterType.INTERPOLATE_XZ); + showModeParameterTypesMap.put("-interpolate-z", ShowModeParameterType.INTERPOLATE_XZ); + showModeParameterTypesMap.put("-interpolate_z", ShowModeParameterType.INTERPOLATE_XZ); + showModeParameterTypesMap.put("-z", ShowModeParameterType.INTERPOLATE_XZ); + + showModeParameterTypesMap.put("-interpolatexz", ShowModeParameterType.INTERPOLATE_XZ); + showModeParameterTypesMap.put("-interpolate-xz", ShowModeParameterType.INTERPOLATE_XZ); + showModeParameterTypesMap.put("-interpolate_xz", ShowModeParameterType.INTERPOLATE_XZ); + showModeParameterTypesMap.put("-xz", ShowModeParameterType.INTERPOLATE_XZ); + + showModeParameterTypesMap.put("-advanced", ShowModeParameterType.ADVANCED); + showModeParameterTypesMap.put("advanced", ShowModeParameterType.ADVANCED); + showModeParameterTypesMap.put("a", ShowModeParameterType.ADVANCED); + + List tabCompletes = new ArrayList<>(showModeParameterTypesMap.keySet()); + return SWCommandUtils.createMapper(s -> showModeParameterTypesMap.getOrDefault(s, null), s -> tabCompletes); + } + +} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTrace.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTrace.java index 529a118..9c2bb3b 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTrace.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTrace.java @@ -24,30 +24,102 @@ import de.steamwar.bausystem.Permission; import de.steamwar.bausystem.gui.GuiTraceShow; import de.steamwar.bausystem.tracer.record.RecordStateMachine; import de.steamwar.bausystem.tracer.show.ShowModeParameter; -import de.steamwar.bausystem.tracer.show.StoredRecords; +import de.steamwar.bausystem.tracer.show.ShowModeParameterType; import de.steamwar.bausystem.tracer.show.TraceShowManager; import de.steamwar.bausystem.tracer.show.mode.EntityShowMode; 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 CommandTrace implements CommandExecutor { +public class CommandTrace extends SWCommand { - private void help(Player player) { - player.sendMessage("§8/§etrace start §8- §7Startet die Aufnahme aller TNT-Positionen"); - player.sendMessage("§8/§etrace stop §8- §7Stoppt den TNT-Tracer"); - player.sendMessage("§8/§etrace toggleauto §8- §7Automatischer Aufnahmenstart"); - player.sendMessage("§8/§etrace show gui §8- §7Zeigt die Trace show gui"); - player.sendMessage("§8/§etrace show §8<§edefault§8|§eadvanced§8> §8<§e-water§8|§e-interpolate-xz§8|§e-interpolate-y§8> §8- §7Zeigt alle TNT-Positionen"); - player.sendMessage("§8/§etrace hide §8- §7Versteckt alle TNT-Positionen"); - player.sendMessage("§8/§etrace delete §8- §7Löscht alle TNT-Positionen"); - // player.sendMessage("§8/§etrace list §8<§7FRAME-ID§8> §8- §7Listet alle TNT auf"); - // player.sendMessage("§8/§etrace gui §8- §7Zeigt die Trace Oberfläche an"); - // player.sendMessage("§7Optionale Parameter mit §8<>§7, Benötigte Parameter mit §8[]"); + public CommandTrace() { + super("trace"); } + @Register(help = true) + public void genericHelp(Player p, String... args) { + p.sendMessage("§8/§etrace start §8- §7Startet die Aufnahme aller TNT-Positionen"); + p.sendMessage("§8/§etrace stop §8- §7Stoppt den TNT-Tracer"); + p.sendMessage("§8/§etrace toggleauto §8- §7Automatischer Aufnahmenstart"); + p.sendMessage("§8/§etrace show gui §8- §7Zeigt die Trace show gui"); + p.sendMessage("§8/§etrace show §8<§edefault§8|§eadvanced§8> §8<§e-water§8|§e-interpolate-xz§8|§e-interpolate-y§8> §8- §7Zeigt alle TNT-Positionen"); + p.sendMessage("§8/§etrace hide §8- §7Versteckt alle TNT-Positionen"); + p.sendMessage("§8/§etrace delete §8- §7Löscht alle TNT-Positionen"); + // p.sendMessage("§8/§etrace list §8<§7FRAME-ID§8> §8- §7Listet alle TNT auf"); + // p.sendMessage("§8/§etrace gui §8- §7Zeigt die Trace Oberfläche an"); + // p.sendMessage("§7Optionale Parameter mit §8<>§7, Benötigte Parameter mit §8[]"); + } + + @Register({"start"}) + public void startCommand(Player p) { + if (!permissionCheck(p)) return; + RecordStateMachine.commandStart(); + p.sendMessage(BauSystem.PREFIX + "§aTNT-Tracer gestartet"); + } + + @Register({"stop"}) + public void stopCommand(Player p) { + if (!permissionCheck(p)) return; + RecordStateMachine.commandStop(); + p.sendMessage(BauSystem.PREFIX + "§cTNT-Tracer gestoppt"); + } + + @Register({"toggleauto"}) + public void toggleAutoCommand(Player p) { + autoCommand(p); + } + + @Register({"auto"}) + public void autoCommand(Player p) { + if (!permissionCheck(p)) return; + RecordStateMachine.commandAuto(); + p.sendMessage(BauSystem.PREFIX + RecordStateMachine.getRecordStatus().getAutoMessage()); + } + + @Register({"clear"}) + public void clearCommand(Player p) { + deleteCommand(p); + } + + @Register({"delete"}) + public void deleteCommand(Player p) { + if (!permissionCheck(p)) return; + p.sendMessage(BauSystem.PREFIX + "§cAlle TNT-Positionen gelöscht"); + } + + @Register({"show"}) + public void showCommand(Player p) { + if (!permissionCheck(p)) return; + TraceShowManager.show(p, new EntityShowMode(p, new ShowModeParameter())); + p.sendMessage(BauSystem.PREFIX + "§aAlle TNT-Positionen angezeigt"); + } + + @Register({"show"}) + public void showCommand(Player p, ShowModeParameterType... showModeParameterTypes) { + if (!permissionCheck(p)) return; + ShowModeParameter showModeParameter = new ShowModeParameter(); + for (ShowModeParameterType showModeParameterType : showModeParameterTypes) { + showModeParameterType.getShowModeParameterConsumer().accept(showModeParameter); + } + TraceShowManager.show(p, new EntityShowMode(p, new ShowModeParameter())); + p.sendMessage(BauSystem.PREFIX + "§aAlle TNT-Positionen angezeigt"); + } + + @Register({"show", "gui"}) + public void showGuiCommand(Player p) { + if (!permissionCheck(p)) return; + GuiTraceShow.openGui(p); + } + + @Register({"hide"}) + public void hideCommand(Player p) { + if (!permissionCheck(p)) return; + TraceShowManager.hide(p); + p.sendMessage(BauSystem.PREFIX + "§cAlle TNT-Positionen ausgeblendet"); + } + + private boolean permissionCheck(Player player) { if (Welt.noPermission(player, Permission.world)) { player.sendMessage(BauSystem.PREFIX + "§cDu darfst hier nicht den TNT-Tracer nutzen"); @@ -55,61 +127,4 @@ public class CommandTrace implements CommandExecutor { } return true; } - - @Override - public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { - if (!(sender instanceof Player)) return false; - Player player = (Player) sender; - - if (args.length == 0) { - help(player); - return false; - } - - if (!permissionCheck(player)) return false; - - switch (args[0].toLowerCase()) { - case "start": - RecordStateMachine.commandStart(); - player.sendMessage(BauSystem.PREFIX + "§aTNT-Tracer gestartet"); - break; - case "stop": - RecordStateMachine.commandStop(); - player.sendMessage(BauSystem.PREFIX + "§cTNT-Tracer gestoppt"); - break; - case "toggleauto": - case "auto": - RecordStateMachine.commandAuto(); - player.sendMessage(BauSystem.PREFIX + RecordStateMachine.getRecordStatus().getAutoMessage()); - break; - case "clear": - case "delete": - StoredRecords.clear(); - player.sendMessage(BauSystem.PREFIX + "§cAlle TNT-Positionen gelöscht"); - break; - case "show": - if (args.length < 2) { - TraceShowManager.show(player, new EntityShowMode(player, new ShowModeParameter())); - } else { - if (args[1].equalsIgnoreCase("gui")) { - GuiTraceShow.openGui(player); - return false; - } - ShowModeParameter showModeParameter = ShowModeParameter.parseArguments(args, 1); - TraceShowManager.show(player, new EntityShowMode(player, showModeParameter)); - } - player.sendMessage(BauSystem.PREFIX + "§aAlle TNT-Positionen angezeigt"); - break; - case "hide": - TraceShowManager.hide(player); - player.sendMessage(BauSystem.PREFIX + "§cAlle TNT-Positionen ausgeblendet"); - break; - case "list": - case "gui": - break; - default: - help(player); - } - return false; - } } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTraceTabCompleter.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTraceTabCompleter.java deleted file mode 100644 index 3ad0680..0000000 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTraceTabCompleter.java +++ /dev/null @@ -1,81 +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 . -*/ - -package de.steamwar.bausystem.commands; - -import de.steamwar.bausystem.SWUtils; -import de.steamwar.bausystem.tracer.record.RecordStateMachine; -import de.steamwar.bausystem.tracer.record.RecordStatus; -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; -import java.util.function.BiPredicate; - -public class CommandTraceTabCompleter implements TabCompleter { - - private static List tabCompletes = new ArrayList<>(); - - static { - tabCompletes.add(new TabComplete((player, args) -> args.length == 1 && (RecordStateMachine.getRecordStatus() == RecordStatus.IDLE || RecordStateMachine.getRecordStatus() == RecordStatus.IDLE_AUTO), "start")); - tabCompletes.add(new TabComplete((player, args) -> args.length == 1 && (RecordStateMachine.getRecordStatus() != RecordStatus.IDLE && RecordStateMachine.getRecordStatus() != RecordStatus.IDLE_AUTO), "stop")); - tabCompletes.add(new TabComplete((player, args) -> args.length == 1, "toggleauto", "auto", "show", "hide", "delete", "clear")); - tabCompletes.add(new TabComplete((player, args) -> args.length == 2 && args[0].equalsIgnoreCase("show"), "gui", "-interpolate-xz", "-interpolate-y", "-water", "-advanced", "advanced")); - tabCompletes.add(new TabComplete((player, args) -> args.length > 2 && args[0].equalsIgnoreCase("show") && !args[1].equalsIgnoreCase("gui"), "-interpolate-xz", "-interpolate-y", "-water", "-advanced")); - } - - @Override - public List onTabComplete(CommandSender sender, Command command, String label, String[] args) { - if (!(sender instanceof Player)) return new ArrayList<>(); - return tracerTabComplete((Player) sender, args); - } - - private List tracerTabComplete(Player player, java.lang.String[] args) { - List tabComplete = new ArrayList<>(); - for (TabComplete tab : tabCompletes) { - if (tab.test(player, args)) tabComplete.addAll(Arrays.asList(tab.getTabCompletes())); - } - return SWUtils.manageList(tabComplete, args); - } - - private static class TabComplete { - - private BiPredicate function; - private String[] tabCompletes; - - private TabComplete(BiPredicate function, String... tabCompletes) { - this.function = function; - this.tabCompletes = tabCompletes; - } - - public boolean test(Player player, String[] args) { - return function.test(player, args); - } - - public String[] getTabCompletes() { - return tabCompletes; - } - - } - -} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/tracer/show/ShowModeParameter.java b/BauSystem_Main/src/de/steamwar/bausystem/tracer/show/ShowModeParameter.java index 7c4722d..ba67f71 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/tracer/show/ShowModeParameter.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/tracer/show/ShowModeParameter.java @@ -54,49 +54,4 @@ public class ShowModeParameter { public void setInterpolate_XZ(boolean interpolate_XZ) { this.interpolate_XZ = interpolate_XZ; } - - public boolean isAdvanced() { - return interpolate_Y || interpolate_XZ; - } - - public static ShowModeParameter parseArguments(String[] args, int index) { - ShowModeParameter showModeParameter = new ShowModeParameter(); - for (int i = index; i < args.length; i++) { - switch (args[i].toLowerCase()) { - case "-water": - showModeParameter.water = true; - break; - case "-interpolatey": - case "-interpolate-y": - case "-interpolate_y": - case "-y": - showModeParameter.interpolate_Y = true; - break; - case "-interpolatex": - case "-interpolate-x": - case "-interpolate_x": - case "-x": - case "-interpolatez": - case "-interpolate-z": - case "-interpolate_z": - case "-z": - case "-interpolatexz": - case "-interpolate-xz": - case "-interpolate_xz": - case "-xz": - showModeParameter.interpolate_XZ = true; - break; - case "advanced": - case "-advanced": - case "-a": - showModeParameter.interpolate_Y = true; - showModeParameter.interpolate_XZ = true; - break; - default: - break; - } - } - return showModeParameter; - } - } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/tracer/show/ShowModeParameterType.java b/BauSystem_Main/src/de/steamwar/bausystem/tracer/show/ShowModeParameterType.java new file mode 100644 index 0000000..5cb046c --- /dev/null +++ b/BauSystem_Main/src/de/steamwar/bausystem/tracer/show/ShowModeParameterType.java @@ -0,0 +1,44 @@ +/* + * 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 . + */ + +package de.steamwar.bausystem.tracer.show; + +import java.util.function.Consumer; + +public enum ShowModeParameterType { + + WATER(showModeParameter -> showModeParameter.setWater(true)), + INTERPOLATE_Y(showModeParameter -> showModeParameter.setInterpolate_Y(true)), + INTERPOLATE_XZ(showModeParameter -> showModeParameter.setInterpolate_XZ(true)), + ADVANCED(showModeParameter -> { + showModeParameter.setInterpolate_Y(true); + showModeParameter.setInterpolate_XZ(true); + }); + + private final Consumer showModeParameterConsumer; + + public Consumer getShowModeParameterConsumer() { + return showModeParameterConsumer; + } + + ShowModeParameterType(Consumer showModeParameterConsumer) { + this.showModeParameterConsumer = showModeParameterConsumer; + } + +} diff --git a/BauSystem_Main/src/plugin.yml b/BauSystem_Main/src/plugin.yml index dd285ac..b0ada63 100644 --- a/BauSystem_Main/src/plugin.yml +++ b/BauSystem_Main/src/plugin.yml @@ -12,7 +12,6 @@ commands: debugstick: tnt: fire: - trace: tpslimit: testblock: aliases: tb From 64b7814dd5e9613f113762084a890fc3148d5837 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Thu, 1 Apr 2021 19:10:03 +0200 Subject: [PATCH 02/51] Update CommandTPSLimiter to new SWCommand system --- .../src/de/steamwar/bausystem/BauSystem.java | 3 +- .../bausystem/commands/CommandTPSLimiter.java | 98 +++++++++++-------- .../CommandTPSLimiterTabComplete.java | 51 ---------- BauSystem_Main/src/plugin.yml | 1 - 4 files changed, 59 insertions(+), 94 deletions(-) delete mode 100644 BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTPSLimiterTabComplete.java diff --git a/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java b/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java index f9958f8..74b66d3 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java @@ -76,8 +76,7 @@ public class BauSystem extends JavaPlugin implements Listener { } new CommandTrace(); - getCommand("tpslimit").setExecutor(new CommandTPSLimiter()); - getCommand("tpslimit").setTabCompleter(new CommandTPSLimiterTabComplete()); + new CommandTPSLimiter(); getCommand("nightvision").setExecutor(new CommandNV()); getCommand("reset").setExecutor(new CommandReset()); getCommand("speed").setExecutor(new CommandSpeed()); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTPSLimiter.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTPSLimiter.java index 58f79ea..1ebdc0e 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTPSLimiter.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTPSLimiter.java @@ -23,18 +23,22 @@ import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.Permission; import de.steamwar.bausystem.world.TPSUtils; import de.steamwar.bausystem.world.Welt; +import de.steamwar.command.SWCommand; +import de.steamwar.command.SWCommandUtils; +import de.steamwar.command.TypeMapper; import de.steamwar.core.VersionedRunnable; import net.md_5.bungee.api.ChatMessageType; import net.md_5.bungee.api.chat.TextComponent; import org.bukkit.Bukkit; import org.bukkit.World; -import org.bukkit.command.Command; -import org.bukkit.command.CommandExecutor; -import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import org.bukkit.scheduler.BukkitTask; -public class CommandTPSLimiter implements CommandExecutor { +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +public class CommandTPSLimiter extends SWCommand { private static final World WORLD = Bukkit.getWorlds().get(0); private static double currentTPSLimit = 20; @@ -48,6 +52,56 @@ public class CommandTPSLimiter implements CommandExecutor { private BukkitTask tpsLimiter = null; + private List arguments = new ArrayList<>(Arrays.asList("1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20")); + + public CommandTPSLimiter() { + super("tpslimit"); + if (TPSUtils.isWarpAllowed()) { + arguments.addAll(Arrays.asList("21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31", "32", "33", "34", "35", "36", "37", "38", "39", "40")); + } + } + + @Register(help = true) + public void genericHelp(Player p, String... args) { + p.sendMessage(BauSystem.PREFIX + "Jetziges TPS limit: " + currentTPSLimit); + p.sendMessage(BauSystem.PREFIX + "Ändere das TPS limit mit: §8/§etpslimit §8[§7TPS§8|§edefault§8]"); + } + + @Register({"default"}) + public void defaultCommand(Player p) { + if (!permissionCheck(p)) return; + currentTPSLimit = 20; + sendNewTPSLimitMessage(); + tpsLimiter(); + } + + @Register + public void valueCommand(Player p, String tpsLimit) { + try { + double tpsLimitDouble = Double.parseDouble(tpsLimit.replace(',', '.')); + if (tpsLimitDouble < 0.5 || tpsLimitDouble > (TPSUtils.isWarpAllowed() ? 40 : 20)) { + sendInvalidArgumentMessage(p); + return; + } + currentTPSLimit = tpsLimitDouble; + sendNewTPSLimitMessage(); + tpsLimiter(); + } catch (NumberFormatException e) { + sendInvalidArgumentMessage(p); + } + } + + @ClassMapper(value = double.class, local = true) + public TypeMapper doubleTypeMapper() { + return SWCommandUtils.createMapper(s -> { + try { + return Double.parseDouble(s.replace(',', '.')); + } catch (NumberFormatException e) { + return null; + } + }, s -> arguments); + } + private boolean permissionCheck(Player player) { if (Welt.noPermission(player, Permission.world)) { player.sendMessage(BauSystem.PREFIX + "§cDu darfst hier nicht den TPS-Limiter nutzen"); @@ -56,42 +110,6 @@ public class CommandTPSLimiter implements CommandExecutor { return true; } - @Override - public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { - if (!(sender instanceof Player)) { - return false; - } else if (args.length == 0) { - sender.sendMessage(BauSystem.PREFIX + "Jetziges TPS limit: " + currentTPSLimit); - sender.sendMessage(BauSystem.PREFIX + "Ändere das TPS limit mit: §8/§etpslimit §8[§7TPS§8|§edefault§8]"); - return false; - } - Player player = (Player) sender; - if (!permissionCheck(player)) return false; - - String tpsLimit = args[0]; - if (tpsLimit.equals("default")) { - currentTPSLimit = 20; - sendNewTPSLimitMessage(); - tpsLimiter(); - return false; - } - - try { - double tpsLimitDouble = Double.parseDouble(tpsLimit.replace(',', '.')); - if (tpsLimitDouble < 0.5 || tpsLimitDouble > (TPSUtils.isWarpAllowed() ? 40 : 20)) { - sendInvalidArgumentMessage(player); - return false; - } - currentTPSLimit = tpsLimitDouble; - sendNewTPSLimitMessage(); - tpsLimiter(); - } catch (NumberFormatException e) { - sendInvalidArgumentMessage(player); - } - - return false; - } - private void sendNewTPSLimitMessage() { Bukkit.getOnlinePlayers().forEach(p -> p.spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText("§eTPS limit auf " + currentTPSLimit + " gesetzt."))); } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTPSLimiterTabComplete.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTPSLimiterTabComplete.java deleted file mode 100644 index cfd10a1..0000000 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTPSLimiterTabComplete.java +++ /dev/null @@ -1,51 +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 . -*/ - -package de.steamwar.bausystem.commands; - -import de.steamwar.bausystem.SWUtils; -import de.steamwar.bausystem.world.TPSUtils; -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 CommandTPSLimiterTabComplete implements TabCompleter { - - private List arguments = new ArrayList<>(Arrays.asList("default", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20")); - - public CommandTPSLimiterTabComplete() { - if (TPSUtils.isWarpAllowed()) - arguments.addAll(Arrays.asList("21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31", "32", "33", "34", "35", "36", "37", "38", "39", "40")); - } - - @Override - public List 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); - } - -} diff --git a/BauSystem_Main/src/plugin.yml b/BauSystem_Main/src/plugin.yml index b0ada63..ec636de 100644 --- a/BauSystem_Main/src/plugin.yml +++ b/BauSystem_Main/src/plugin.yml @@ -12,7 +12,6 @@ commands: debugstick: tnt: fire: - tpslimit: testblock: aliases: tb reset: From dda62edfaa695a715c18ff38d7e9ff4a53dc9713 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Thu, 1 Apr 2021 19:23:21 +0200 Subject: [PATCH 03/51] Fix permission Check in CommandTPSLimiter --- .../src/de/steamwar/bausystem/commands/CommandTPSLimiter.java | 1 + 1 file changed, 1 insertion(+) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTPSLimiter.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTPSLimiter.java index 1ebdc0e..e589a68 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTPSLimiter.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTPSLimiter.java @@ -77,6 +77,7 @@ public class CommandTPSLimiter extends SWCommand { @Register public void valueCommand(Player p, String tpsLimit) { + if (!permissionCheck(p)) return; try { double tpsLimitDouble = Double.parseDouble(tpsLimit.replace(',', '.')); if (tpsLimitDouble < 0.5 || tpsLimitDouble > (TPSUtils.isWarpAllowed() ? 40 : 20)) { From 34a3534d5010aa7e6024ba8b1ef08ab843e99a7f Mon Sep 17 00:00:00 2001 From: yoyosource Date: Thu, 1 Apr 2021 19:24:21 +0200 Subject: [PATCH 04/51] Update CommandTNT to new SWCommand system --- .../src/de/steamwar/bausystem/BauSystem.java | 3 +- .../bausystem/commands/CommandTNT.java | 108 ++++++++++-------- .../commands/CommandTNTTabComplete.java | 52 --------- BauSystem_Main/src/plugin.yml | 1 - 4 files changed, 63 insertions(+), 101 deletions(-) delete mode 100644 BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTNTTabComplete.java diff --git a/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java b/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java index 74b66d3..917921b 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java @@ -80,8 +80,7 @@ public class BauSystem extends JavaPlugin implements Listener { getCommand("nightvision").setExecutor(new CommandNV()); getCommand("reset").setExecutor(new CommandReset()); getCommand("speed").setExecutor(new CommandSpeed()); - getCommand("tnt").setExecutor(new CommandTNT()); - getCommand("tnt").setTabCompleter(new CommandTNTTabComplete()); + new CommandTNT(); getCommand("fire").setExecutor(new CommandFire()); getCommand("freeze").setExecutor(new CommandFreeze()); getCommand("testblock").setExecutor(new CommandTestblock()); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTNT.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTNT.java index d528f37..0909302 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTNT.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTNT.java @@ -23,16 +23,21 @@ import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.Permission; import de.steamwar.bausystem.world.Region; import de.steamwar.bausystem.world.Welt; +import de.steamwar.command.SWCommand; +import de.steamwar.command.SWCommandUtils; +import de.steamwar.command.TypeMapper; import org.bukkit.Bukkit; -import org.bukkit.command.Command; -import org.bukkit.command.CommandExecutor; -import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.entity.EntityExplodeEvent; -public class CommandTNT implements CommandExecutor, Listener { +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class CommandTNT extends SWCommand implements Listener { public enum TNTMode { ON("§aan"), @@ -48,13 +53,65 @@ public class CommandTNT implements CommandExecutor, Listener { public String getName() { return name; } - } public CommandTNT() { + super("tnt"); Bukkit.getPluginManager().registerEvents(this, BauSystem.getPlugin()); } + @Register + public void toggleCommand(Player p) { + if (!permissionCheck(p)) return; + Region region = Region.getRegion(p.getLocation()); + tntToggle(region, null, null); + } + + + @Register + public void setCommand(Player p, TNTMode tntMode) { + if (!permissionCheck(p)) return; + Region region = Region.getRegion(p.getLocation()); + tntToggle(region, null, null); + + String requestedMessage = null; + switch (tntMode) { + case ON: + requestedMessage = getEnableMessage(); + break; + case OFF: + requestedMessage = getDisableMessage(); + break; + case ONLY_TB: + requestedMessage = getTestblockEnableMessage(); + break; + } + tntToggle(region, tntMode, requestedMessage); + } + + private boolean permissionCheck(Player p) { + if (Welt.noPermission(p, Permission.world)) { + p.sendMessage(BauSystem.PREFIX + "§cDu darfst hier nicht TNT-Schaden (de-)aktivieren"); + return false; + } + return true; + } + + @ClassMapper(value = TNTMode.class, local = true) + public TypeMapper tntModeTypeMapper() { + Map tntModeMap = new HashMap<>(); + tntModeMap.put("an", TNTMode.ON); + tntModeMap.put("on", TNTMode.ON); + tntModeMap.put("aus", TNTMode.OFF); + tntModeMap.put("off", TNTMode.OFF); + if (Region.buildAreaEnabled()) { + tntModeMap.put("testblock", TNTMode.ONLY_TB); + tntModeMap.put("tb", TNTMode.ONLY_TB); + } + List tabCompletes = new ArrayList<>(tntModeMap.keySet()); + return SWCommandUtils.createMapper(s -> tntModeMap.getOrDefault(s, null), s -> tabCompletes); + } + private String getEnableMessage() { return "§aTNT-Schaden aktiviert"; } @@ -67,46 +124,6 @@ public class CommandTNT implements CommandExecutor, Listener { return "§aTNT-Schaden außerhalb Baurahmen aktiviert"; } - @Override - public boolean onCommand(CommandSender sender, Command command, String s, String[] args) { - if (!(sender instanceof Player)) return false; - Player player = (Player) sender; - - if (Welt.noPermission(player, Permission.world)) { - player.sendMessage(BauSystem.PREFIX + "§cDu darfst hier nicht TNT-Schaden (de-)aktivieren"); - return false; - } - - TNTMode requestedMode = null; - String requestedMessage = null; - if (args.length != 0) { - switch (args[0].toLowerCase()) { - case "an": - case "on": - requestedMode = TNTMode.ON; - requestedMessage = getEnableMessage(); - break; - case "aus": - case "off": - requestedMode = TNTMode.OFF; - requestedMessage = getDisableMessage(); - break; - case "testblock": - case "tb": - if (!Region.buildAreaEnabled()) break; - requestedMode = TNTMode.ONLY_TB; - requestedMessage = getTestblockEnableMessage(); - break; - default: - break; - } - } - - Region region = Region.getRegion(player.getLocation()); - tntToggle(region, requestedMode, requestedMessage); - return false; - } - private void tntToggle(Region region, TNTMode requestedMode, String requestedMessage) { if (requestedMode != null && region.hasTestblock()) { region.setTntMode(requestedMode); @@ -147,5 +164,4 @@ public class CommandTNT implements CommandExecutor, Listener { return region.getTntMode() == TNTMode.OFF; }); } - } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTNTTabComplete.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTNTTabComplete.java deleted file mode 100644 index 26dea52..0000000 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTNTTabComplete.java +++ /dev/null @@ -1,52 +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 . - * / - */ - -package de.steamwar.bausystem.commands; - -import de.steamwar.bausystem.SWUtils; -import de.steamwar.bausystem.world.Region; -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 CommandTNTTabComplete implements TabCompleter { - - private List arguments = new ArrayList<>(Arrays.asList("an", "on", "aus", "off")); - - public CommandTNTTabComplete() { - if (Region.buildAreaEnabled()) arguments.addAll(Arrays.asList("testblock", "tb")); - } - - @Override - public List 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); - } - -} diff --git a/BauSystem_Main/src/plugin.yml b/BauSystem_Main/src/plugin.yml index ec636de..ad1ec2e 100644 --- a/BauSystem_Main/src/plugin.yml +++ b/BauSystem_Main/src/plugin.yml @@ -10,7 +10,6 @@ description: "So unseriös wie wir sind: BauSystem nur besser." commands: debugstick: - tnt: fire: testblock: aliases: tb From a09784287bc1b89bc697f5ed3bb65d36c6fecba2 Mon Sep 17 00:00:00 2001 From: Zeanon Date: Thu, 1 Apr 2021 19:27:22 +0200 Subject: [PATCH 05/51] update for CommandBau --- .../src/de/steamwar/bausystem/BauSystem.java | 1 - .../bausystem/commands/CommandBau.java | 82 ++++++++++--------- BauSystem_Main/src/plugin.yml | 4 - 3 files changed, 42 insertions(+), 45 deletions(-) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java b/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java index 74b66d3..0f01ecc 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java @@ -85,7 +85,6 @@ public class BauSystem extends JavaPlugin implements Listener { getCommand("fire").setExecutor(new CommandFire()); getCommand("freeze").setExecutor(new CommandFreeze()); getCommand("testblock").setExecutor(new CommandTestblock()); - getCommand("bau").setExecutor(new CommandBau()); getCommand("bauinfo").setExecutor(new CommandInfo()); getCommand("protect").setExecutor(new CommandProtect()); getCommand("skull").setExecutor(new CommandSkull()); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandBau.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandBau.java index 083ee4a..5e991dd 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandBau.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandBau.java @@ -1,34 +1,46 @@ -/* - 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 . -*/ - package de.steamwar.bausystem.commands; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.world.Welt; +import de.steamwar.command.SWCommand; import de.steamwar.sql.BauweltMember; import de.steamwar.sql.SteamwarUser; -import org.bukkit.command.Command; -import org.bukkit.command.CommandExecutor; -import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; -public class CommandBau implements CommandExecutor { + +public class CommandBau extends SWCommand { + + public CommandBau() { + super("bau", "b", "gs"); + } + + + @Register() + public void genericCommand(Player p) { + permissionCheck(p); + } + + @Register("togglebuild") + public void toggleBuildCommand(Player p, String arg) { + if (permissionCheck(p)) { + onToggleBD(p, arg); + } + } + + @Register("togglewe") + public void toggleWECommand(Player p, String arg) { + if (permissionCheck(p)) { + onToggleWE(p, arg); + } + } + + @Register("toggleworld") + public void toggleWorldCommand(Player p, String arg) { + if (permissionCheck(p)) { + onToggleWorld(p, arg); + } + } + private void onToggleBD(Player p, String arg) { SteamwarUser id = SteamwarUser.get(arg); @@ -74,23 +86,13 @@ public class CommandBau implements CommandExecutor { return false; } - @Override - public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { - if (!(sender instanceof Player)) - return false; - Player player = (Player) sender; - if (!BauSystem.getOwner().equals(player.getUniqueId())) { - player.sendMessage(BauSystem.PREFIX + "§cDies ist nicht deine Welt!"); - return false; - } - if (args[0].equalsIgnoreCase("togglebuild")) { - onToggleBD(player, args[1]); - } else if (args[0].equalsIgnoreCase("togglewe")) { - onToggleWE(player, args[1]); - } else if (args[0].equalsIgnoreCase("toggleworld")) { - onToggleWorld(player, args[1]); + private boolean permissionCheck(Player p) { + if (!BauSystem.getOwner().equals(p.getUniqueId())) { + p.sendMessage(BauSystem.PREFIX + "§cDies ist nicht deine Welt!"); + return false; + } else { + return true; } - return false; } -} +} \ No newline at end of file diff --git a/BauSystem_Main/src/plugin.yml b/BauSystem_Main/src/plugin.yml index ec636de..dc63667 100644 --- a/BauSystem_Main/src/plugin.yml +++ b/BauSystem_Main/src/plugin.yml @@ -15,10 +15,6 @@ commands: testblock: aliases: tb reset: - bau: - aliases: - - gs - - b protect: bauinfo: speed: From 0ee83c6dd4e6466055d5b09a7adf6ccb804c58f3 Mon Sep 17 00:00:00 2001 From: Zeanon Date: Thu, 1 Apr 2021 19:31:28 +0200 Subject: [PATCH 06/51] update for CommandDebugStick --- .../bausystem/commands/CommandDebugStick.java | 53 ++++++------------- BauSystem_Main/src/plugin.yml | 1 - 2 files changed, 15 insertions(+), 39 deletions(-) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandDebugStick.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandDebugStick.java index b3ac2bf..14c711c 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandDebugStick.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandDebugStick.java @@ -1,49 +1,26 @@ -/* - 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 . -*/ - package de.steamwar.bausystem.commands; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.Permission; import de.steamwar.bausystem.world.Welt; +import de.steamwar.command.SWCommand; import de.steamwar.core.VersionedRunnable; -import org.bukkit.command.Command; -import org.bukkit.command.CommandExecutor; -import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; -public class CommandDebugStick implements CommandExecutor { +public class CommandDebugStick extends SWCommand { - @Override - public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { - if (!(sender instanceof Player)) - return false; - Player player = (Player) sender; - - if (Welt.noPermission(player, Permission.build)) { - player.sendMessage(BauSystem.PREFIX + "§cKein Debugstick für dich hier."); - return false; - } - - VersionedRunnable.call(new VersionedRunnable(() -> player.sendMessage(BauSystem.PREFIX + "§cDen Debugstick gibt es nicht in der 1.12."), 8), - new VersionedRunnable(() -> CommandDebugStick_15.giveStick(player), 15)); - return false; + public CommandDebugStick() { + super("debugstick"); } -} + + @Register + public void genericCommand(Player p) { + if (Welt.noPermission(p, Permission.build)) { + p.sendMessage(BauSystem.PREFIX + "§cKein Debugstick für dich hier."); + } else { + VersionedRunnable.call(new VersionedRunnable(() -> p.sendMessage(BauSystem.PREFIX + "§cDen Debugstick gibt es nicht in der 1.12."), 8), + new VersionedRunnable(() -> CommandDebugStick_15.giveStick(p), 15)); + } + } +} \ No newline at end of file diff --git a/BauSystem_Main/src/plugin.yml b/BauSystem_Main/src/plugin.yml index 86bf85e..b005649 100644 --- a/BauSystem_Main/src/plugin.yml +++ b/BauSystem_Main/src/plugin.yml @@ -9,7 +9,6 @@ website: "https://steamwar.de" description: "So unseriös wie wir sind: BauSystem nur besser." commands: - debugstick: fire: testblock: aliases: tb From 8f60ffdbf55db6ff7b744166b7e1b845b67d8cd3 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Thu, 1 Apr 2021 19:31:38 +0200 Subject: [PATCH 07/51] Update CommandTestblock to new SWCommand system --- .../src/de/steamwar/bausystem/BauSystem.java | 2 +- .../bausystem/commands/CommandTestblock.java | 71 ++++++++++++------- BauSystem_Main/src/plugin.yml | 2 - 3 files changed, 46 insertions(+), 29 deletions(-) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java b/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java index ded4172..5446e42 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java @@ -83,7 +83,7 @@ public class BauSystem extends JavaPlugin implements Listener { new CommandTNT(); getCommand("fire").setExecutor(new CommandFire()); getCommand("freeze").setExecutor(new CommandFreeze()); - getCommand("testblock").setExecutor(new CommandTestblock()); + new CommandTestblock(); getCommand("bauinfo").setExecutor(new CommandInfo()); getCommand("protect").setExecutor(new CommandProtect()); getCommand("skull").setExecutor(new CommandSkull()); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTestblock.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTestblock.java index ce431a7..60b9a48 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTestblock.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTestblock.java @@ -23,48 +23,67 @@ import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.Permission; import de.steamwar.bausystem.world.Region; import de.steamwar.bausystem.world.Welt; +import de.steamwar.command.SWCommand; import de.steamwar.sql.Schematic; import org.bukkit.Bukkit; -import org.bukkit.command.Command; -import org.bukkit.command.CommandExecutor; -import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; +import java.io.IOException; import java.util.logging.Level; -public class CommandTestblock implements CommandExecutor { +public class CommandTestblock extends SWCommand { - @Override - public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { - if (!(sender instanceof Player)) - return false; - Player player = (Player) sender; + public CommandTestblock() { + super("testblock", "tb"); + } + @Register + public void genericTestblockCommand(Player p) { + if (!permissionCheck(p)) return; + Region region = regionCheck(p); + if (region == null) return; + try { + region.resetTestblock(null); + p.sendMessage(BauSystem.PREFIX + "§7Testblock zurückgesetzt"); + } catch (IOException e) { + p.sendMessage(BauSystem.PREFIX + "§cFehler beim Zurücksetzen des Testblocks"); + Bukkit.getLogger().log(Level.WARNING, "Failed testblock", e); + } + } + + @Register + public void schematicTestblockCommand(Player p, String s) { + if (!permissionCheck(p)) return; + Region region = regionCheck(p); + if (region == null) return; + Schematic schem = Schematic.getSchemFromDB(s, p.getUniqueId()); + if (schem == null) { + p.sendMessage(BauSystem.PREFIX + "§cSchematic nicht gefunden"); + return; + } + try { + region.resetTestblock(null); + p.sendMessage(BauSystem.PREFIX + "§7Testblock zurückgesetzt"); + } catch (IOException e) { + p.sendMessage(BauSystem.PREFIX + "§cFehler beim Zurücksetzen des Testblocks"); + Bukkit.getLogger().log(Level.WARNING, "Failed testblock", e); + } + } + + private boolean permissionCheck(Player player) { if (Welt.noPermission(player, Permission.worldedit)) { player.sendMessage(BauSystem.PREFIX + "§cDu darfst hier nicht den Testblock zurücksetzen"); return false; } + return true; + } + private Region regionCheck(Player player) { Region region = Region.getRegion(player.getLocation()); if (!region.hasTestblock()) { player.sendMessage(BauSystem.PREFIX + "§cDu befindest dich derzeit in keiner Region"); - return false; + return region; } - try { - Schematic schem = null; - if (args.length > 0) { - schem = Schematic.getSchemFromDB(args[0], player.getUniqueId()); - if (schem == null) { - player.sendMessage(BauSystem.PREFIX + "§cSchematic nicht gefunden"); - return false; - } - } - region.resetTestblock(schem); - player.sendMessage(BauSystem.PREFIX + "§7Testblock zurückgesetzt"); - } catch (Exception e) { - player.sendMessage(BauSystem.PREFIX + "§cFehler beim Zurücksetzen des Testblocks"); - Bukkit.getLogger().log(Level.WARNING, "Failed testblock", e); - } - return false; + return null; } } diff --git a/BauSystem_Main/src/plugin.yml b/BauSystem_Main/src/plugin.yml index 86bf85e..4d25ab9 100644 --- a/BauSystem_Main/src/plugin.yml +++ b/BauSystem_Main/src/plugin.yml @@ -11,8 +11,6 @@ description: "So unseriös wie wir sind: BauSystem nur besser." commands: debugstick: fire: - testblock: - aliases: tb reset: protect: bauinfo: From daa47361e2e9e2cdca56803a9b0a834478996f42 Mon Sep 17 00:00:00 2001 From: Zeanon Date: Thu, 1 Apr 2021 19:32:16 +0200 Subject: [PATCH 08/51] update for CommandDebugStick --- BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java b/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java index ded4172..4a3d030 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java @@ -81,6 +81,7 @@ public class BauSystem extends JavaPlugin implements Listener { getCommand("reset").setExecutor(new CommandReset()); getCommand("speed").setExecutor(new CommandSpeed()); new CommandTNT(); + new CommandBau(); getCommand("fire").setExecutor(new CommandFire()); getCommand("freeze").setExecutor(new CommandFreeze()); getCommand("testblock").setExecutor(new CommandTestblock()); @@ -89,7 +90,7 @@ public class BauSystem extends JavaPlugin implements Listener { getCommand("skull").setExecutor(new CommandSkull()); getCommand("loader").setExecutor(new CommandLoader()); getCommand("lockschem").setExecutor(new CommandLockschem()); - getCommand("debugstick").setExecutor(new CommandDebugStick()); + new CommandDebugStick(); getCommand("watervision").setExecutor(new CommandGills()); getCommand("detonator").setExecutor(new CommandDetonator()); getCommand("detonator").setTabCompleter(new CommandDetonatorTabCompleter()); From 530252d96b994278b1e31511ae2309190436e375 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Thu, 1 Apr 2021 19:37:50 +0200 Subject: [PATCH 09/51] Update CommandSpeed to new SWCommand system --- .../src/de/steamwar/bausystem/BauSystem.java | 2 +- .../bausystem/commands/CommandSpeed.java | 62 +++++++++++-------- BauSystem_Main/src/plugin.yml | 1 - 3 files changed, 37 insertions(+), 28 deletions(-) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java b/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java index 5446e42..009683f 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java @@ -79,7 +79,7 @@ public class BauSystem extends JavaPlugin implements Listener { new CommandTPSLimiter(); getCommand("nightvision").setExecutor(new CommandNV()); getCommand("reset").setExecutor(new CommandReset()); - getCommand("speed").setExecutor(new CommandSpeed()); + new CommandSpeed(); new CommandTNT(); getCommand("fire").setExecutor(new CommandFire()); getCommand("freeze").setExecutor(new CommandFreeze()); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandSpeed.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandSpeed.java index 223af4d..1a4b31a 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandSpeed.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandSpeed.java @@ -20,40 +20,50 @@ package de.steamwar.bausystem.commands; import de.steamwar.bausystem.BauSystem; -import org.bukkit.command.Command; -import org.bukkit.command.CommandExecutor; -import org.bukkit.command.CommandSender; +import de.steamwar.command.SWCommand; +import de.steamwar.command.SWCommandUtils; +import de.steamwar.command.TypeMapper; import org.bukkit.entity.Player; -public class CommandSpeed implements CommandExecutor { +import java.util.Arrays; +import java.util.List; - @Override - public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { - if (!(sender instanceof Player)) - return false; - Player player = (Player) sender; +public class CommandSpeed extends SWCommand { - if (args.length == 0) { - player.sendMessage(BauSystem.PREFIX + "/speed [Geschwindigkeit]"); - return false; - } + public CommandSpeed() { + super("speed"); + } - float speed; - try { - speed = Float.parseFloat(args[0]); - } catch (NumberFormatException e) { - player.sendMessage(BauSystem.PREFIX + "§cBitte gib eine Zahl zwischen 0 und 10 an"); - return false; - } + @Register(help = true) + public void genericHelp(Player p, String... args) { + p.sendMessage(BauSystem.PREFIX + "/speed [Geschwindigkeit]"); + } + + @Register({"default"}) + public void defaultCommand(Player p) { + speedCommand(p, 1); + } + + public void speedCommand(Player p, float speed) { if (speed < 0 || speed > 10) { - player.sendMessage(BauSystem.PREFIX + "§cBitte gib eine Zahl zwischen 0 und 10 an"); - return false; + p.sendMessage(BauSystem.PREFIX + "§cBitte gib eine Zahl zwischen 0 und 10 an"); + return; } - player.sendMessage("§aGeschwindigkeit wurde auf §6" + speed + " §agesetzt"); + p.sendMessage("§aGeschwindigkeit wurde auf §6" + speed + " §agesetzt"); + p.setFlySpeed(speed / 10); + p.setWalkSpeed((speed >= 9 ? speed : speed + 1) / 10); + } - player.setFlySpeed(speed / 10); - player.setWalkSpeed((speed >= 9 ? speed : speed + 1) / 10); - return false; + @ClassMapper(value = float.class, local = true) + public TypeMapper doubleTypeMapper() { + List tabCompletes = Arrays.asList("0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10"); + return SWCommandUtils.createMapper(s -> { + try { + return Float.parseFloat(s.replace(',', '.')); + } catch (NumberFormatException e) { + return null; + } + }, s -> tabCompletes); } } diff --git a/BauSystem_Main/src/plugin.yml b/BauSystem_Main/src/plugin.yml index 4d25ab9..241c660 100644 --- a/BauSystem_Main/src/plugin.yml +++ b/BauSystem_Main/src/plugin.yml @@ -14,7 +14,6 @@ commands: reset: protect: bauinfo: - speed: skull: freeze: aliases: stoplag From d0ea73c56c39801fb647acd0933b606a4098374e Mon Sep 17 00:00:00 2001 From: Zeanon Date: Thu, 1 Apr 2021 19:41:24 +0200 Subject: [PATCH 10/51] update for CommandDetonator --- .../src/de/steamwar/bausystem/BauSystem.java | 3 +- .../bausystem/commands/CommandDetonator.java | 155 ++++++++++-------- BauSystem_Main/src/plugin.yml | 2 - 3 files changed, 92 insertions(+), 68 deletions(-) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java b/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java index 1bdc45e..42e4440 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java @@ -92,8 +92,7 @@ public class BauSystem extends JavaPlugin implements Listener { getCommand("lockschem").setExecutor(new CommandLockschem()); new CommandDebugStick(); getCommand("watervision").setExecutor(new CommandGills()); - getCommand("detonator").setExecutor(new CommandDetonator()); - getCommand("detonator").setTabCompleter(new CommandDetonatorTabCompleter()); + new CommandDetonator(); getCommand("script").setExecutor(new CommandScript()); getCommand("scriptvars").setExecutor(new CommandScriptVars()); getCommand("scriptvars").setTabCompleter(new CommandScriptVarsTabCompleter()); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandDetonator.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandDetonator.java index 1528920..f1a1ddb 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandDetonator.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandDetonator.java @@ -1,22 +1,3 @@ -/* - 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 . -*/ - package de.steamwar.bausystem.commands; import de.steamwar.bausystem.BauSystem; @@ -24,12 +5,98 @@ import de.steamwar.bausystem.Permission; import de.steamwar.bausystem.SWUtils; import de.steamwar.bausystem.world.Detonator; 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 CommandDetonator implements CommandExecutor { + +public class CommandDetonator extends SWCommand { + + public CommandDetonator() { + super ("detonator", "dt"); + } + + + @Register(help = true) + public void genericHelp(Player p, String... args) { + help(p); + } + + @Register("wand") + public void wandCommand(Player p) { + if (permissionCheck(p)) { + SWUtils.giveItemToPlayer(p, Detonator.WAND); + p.updateInventory(); + } + } + + @Register("detonator") + public void detonatorCommand(Player p) { + if (permissionCheck(p)) { + SWUtils.giveItemToPlayer(p, Detonator.WAND); + p.updateInventory(); + } + } + + @Register("item") + public void itemCommand(Player p) { + if (permissionCheck(p)) { + SWUtils.giveItemToPlayer(p, Detonator.WAND); + p.updateInventory(); + } + } + + + @Register("remove") + public void removeCommand(Player p) { + if (permissionCheck(p)) { + p.getInventory().removeItem(Detonator.WAND); + } + } + + + @Register("detonate") + public void detonateCommand(Player p) { + if (permissionCheck(p)) { + Detonator.execute(p); + } + } + + @Register("click") + public void clickCommand(Player p) { + if (permissionCheck(p)) { + Detonator.execute(p); + } + } + + @Register("use") + public void useCommand(Player p) { + if (permissionCheck(p)) { + Detonator.execute(p); + } + } + + + @Register("clear") + public void clearCommand(Player p) { + if (permissionCheck(p)) { + p.getInventory().setItemInMainHand(Detonator.clearDetonator(p.getInventory().getItemInMainHand())); + } + } + + @Register("delete") + public void deleteCommand(Player p) { + if (permissionCheck(p)) { + p.getInventory().setItemInMainHand(Detonator.clearDetonator(p.getInventory().getItemInMainHand())); + } + } + + @Register("reset") + public void resetCommand(Player p) { + if (permissionCheck(p)) { + 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"); @@ -45,44 +112,4 @@ public class CommandDetonator implements CommandExecutor { } return true; } - - @Override - public boolean onCommand(CommandSender sender, Command command, String s, String[] args) { - if (!(sender instanceof Player)) - return false; - Player player = (Player) sender; - - if (args.length == 0) { - help(player); - return false; - } - - if (!permissionCheck(player)) return false; - - switch (args[0].toLowerCase()) { - case "wand": - case "detonator": - case "item": - SWUtils.giveItemToPlayer(player, Detonator.WAND); - player.updateInventory(); - break; - case "remove": - player.getInventory().removeItem(Detonator.WAND); - break; - case "detonate": - case "click": - case "use": - Detonator.execute(player); - break; - case "clear": - case "delete": - case "reset": - player.getInventory().setItemInMainHand(Detonator.clearDetonator(player.getInventory().getItemInMainHand())); - break; - default: - help(player); - } - - return true; - } -} +} \ No newline at end of file diff --git a/BauSystem_Main/src/plugin.yml b/BauSystem_Main/src/plugin.yml index b976024..2ad2b19 100644 --- a/BauSystem_Main/src/plugin.yml +++ b/BauSystem_Main/src/plugin.yml @@ -23,8 +23,6 @@ commands: watervision: aliases: wv lockschem: - detonator: - aliases: dt script: scriptvars: simulator: From 70dc99de6fb94e1320e9e93ebc19e37a884b57f7 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Thu, 1 Apr 2021 20:23:24 +0200 Subject: [PATCH 11/51] Update CommandSkull to new SWCommand system --- .../src/de/steamwar/bausystem/BauSystem.java | 2 +- .../bausystem/commands/CommandSkull.java | 30 ++++++++----------- BauSystem_Main/src/plugin.yml | 1 - 3 files changed, 14 insertions(+), 19 deletions(-) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java b/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java index 4c5762a..f8f8243 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java @@ -87,7 +87,7 @@ public class BauSystem extends JavaPlugin implements Listener { new CommandTestblock(); getCommand("bauinfo").setExecutor(new CommandInfo()); getCommand("protect").setExecutor(new CommandProtect()); - getCommand("skull").setExecutor(new CommandSkull()); + new CommandSkull(); getCommand("loader").setExecutor(new CommandLoader()); getCommand("lockschem").setExecutor(new CommandLockschem()); new CommandDebugStick(); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandSkull.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandSkull.java index 7cbab3a..24a8b51 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandSkull.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandSkull.java @@ -21,34 +21,30 @@ package de.steamwar.bausystem.commands; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.SWUtils; +import de.steamwar.command.SWCommand; import de.steamwar.inventory.SWItem; -import org.bukkit.command.Command; -import org.bukkit.command.CommandExecutor; -import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.SkullMeta; -public class CommandSkull implements CommandExecutor { +public class CommandSkull extends SWCommand { - @Override - public boolean onCommand(CommandSender commandSender, Command command, String s, String[] args) { - if (!(commandSender instanceof Player)) - return false; - Player p = (Player) commandSender; + public CommandSkull() { + super("skull"); + } - if (args.length != 1) { - p.sendMessage(BauSystem.PREFIX + "§8/§eskull §8[§eSpieler§8]"); - return false; - } + @Register(help = true) + public void genericHelp(Player p, String... args) { + p.sendMessage(BauSystem.PREFIX + "§8/§eskull §8[§eSpieler§8]"); + } - ItemStack is = SWItem.getPlayerSkull(args[0]).getItemStack(); + @Register + public void giveHelp(Player p, String skull) { + ItemStack is = SWItem.getPlayerSkull(skull).getItemStack(); SkullMeta sm = (SkullMeta) is.getItemMeta(); assert sm != null; - sm.setDisplayName("§e" + args[0] + "§8s Kopf"); + sm.setDisplayName("§e" + skull + "§8s Kopf"); is.setItemMeta(sm); SWUtils.giveItemToPlayer(p, is); - - return false; } } diff --git a/BauSystem_Main/src/plugin.yml b/BauSystem_Main/src/plugin.yml index b8f6b67..0129c49 100644 --- a/BauSystem_Main/src/plugin.yml +++ b/BauSystem_Main/src/plugin.yml @@ -13,7 +13,6 @@ commands: reset: protect: bauinfo: - skull: freeze: aliases: stoplag loader: From fb4fa03d5d74f5a4c53bf5d5d0222d63e1029e69 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Thu, 1 Apr 2021 20:29:14 +0200 Subject: [PATCH 12/51] Update CommandSimulator to new SWCommand system --- .../src/de/steamwar/bausystem/BauSystem.java | 3 +- .../bausystem/commands/CommandSimulator.java | 74 +++++++++---------- .../CommandSimulatorTabCompleter.java | 46 ------------ BauSystem_Main/src/plugin.yml | 2 - 4 files changed, 37 insertions(+), 88 deletions(-) delete mode 100644 BauSystem_Main/src/de/steamwar/bausystem/commands/CommandSimulatorTabCompleter.java diff --git a/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java b/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java index f8f8243..53178f6 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java @@ -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()); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandSimulator.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandSimulator.java index ad876df..10e603d 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandSimulator.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandSimulator.java @@ -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; - } - } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandSimulatorTabCompleter.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandSimulatorTabCompleter.java deleted file mode 100644 index 9ece2fd..0000000 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandSimulatorTabCompleter.java +++ /dev/null @@ -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 . - */ - -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 arguments = new ArrayList<>(Arrays.asList("wand", "start", "delete")); - - @Override - public List 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); - } - -} diff --git a/BauSystem_Main/src/plugin.yml b/BauSystem_Main/src/plugin.yml index 0129c49..966b94c 100644 --- a/BauSystem_Main/src/plugin.yml +++ b/BauSystem_Main/src/plugin.yml @@ -23,8 +23,6 @@ commands: lockschem: script: scriptvars: - simulator: - aliases: sim gui: redstonetester: aliases: rt \ No newline at end of file From 6744b8e0edf84aba1fcefdd55f35add68d113457 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Thu, 1 Apr 2021 20:31:59 +0200 Subject: [PATCH 13/51] Update CommandScript to new SWCommand system --- .../src/de/steamwar/bausystem/BauSystem.java | 2 +- .../bausystem/commands/CommandScript.java | 20 +++++++++---------- BauSystem_Main/src/plugin.yml | 1 - 3 files changed, 10 insertions(+), 13 deletions(-) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java b/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java index 53178f6..c6a4af8 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java @@ -93,7 +93,7 @@ public class BauSystem extends JavaPlugin implements Listener { new CommandDebugStick(); getCommand("watervision").setExecutor(new CommandGills()); new CommandDetonator(); - getCommand("script").setExecutor(new CommandScript()); + new CommandScript(); getCommand("scriptvars").setExecutor(new CommandScriptVars()); getCommand("scriptvars").setTabCompleter(new CommandScriptVarsTabCompleter()); new CommandSimulator(); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandScript.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandScript.java index 1af6767..f54b373 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandScript.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandScript.java @@ -22,10 +22,8 @@ package de.steamwar.bausystem.commands; import de.steamwar.bausystem.SWUtils; +import de.steamwar.command.SWCommand; import org.bukkit.Material; -import org.bukkit.command.Command; -import org.bukkit.command.CommandExecutor; -import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.BookMeta; @@ -33,7 +31,11 @@ import org.bukkit.inventory.meta.BookMeta; import java.util.ArrayList; import java.util.List; -public class CommandScript implements CommandExecutor { +public class CommandScript extends SWCommand { + + public CommandScript() { + super("script"); + } public static final ItemStack BOOK = new ItemStack(Material.WRITTEN_BOOK, 1); @@ -79,13 +81,9 @@ public class CommandScript implements CommandExecutor { BOOK.setItemMeta(bookMeta); } - @Override - public boolean onCommand(CommandSender sender, Command command, String s, String[] args) { - if (!(sender instanceof Player)) { - return false; - } - SWUtils.giveItemToPlayer((Player) sender, BOOK); - return false; + @Register + public void giveCommand(Player p) { + SWUtils.giveItemToPlayer(p, BOOK); } } diff --git a/BauSystem_Main/src/plugin.yml b/BauSystem_Main/src/plugin.yml index 966b94c..a619a73 100644 --- a/BauSystem_Main/src/plugin.yml +++ b/BauSystem_Main/src/plugin.yml @@ -21,7 +21,6 @@ commands: watervision: aliases: wv lockschem: - script: scriptvars: gui: redstonetester: From 738a88ac0a2bbae89fbb0b1d3c42f09514c45491 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Thu, 1 Apr 2021 20:36:18 +0200 Subject: [PATCH 14/51] Update CommandReset to new SWCommand system --- .../src/de/steamwar/bausystem/BauSystem.java | 2 +- .../bausystem/commands/CommandReset.java | 69 ++++++++++++------- .../bausystem/commands/CommandTestblock.java | 4 +- BauSystem_Main/src/plugin.yml | 1 - 4 files changed, 48 insertions(+), 28 deletions(-) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java b/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java index c6a4af8..47fe646 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java @@ -78,7 +78,7 @@ public class BauSystem extends JavaPlugin implements Listener { new CommandTrace(); new CommandTPSLimiter(); getCommand("nightvision").setExecutor(new CommandNV()); - getCommand("reset").setExecutor(new CommandReset()); + new CommandReset(); new CommandSpeed(); new CommandTNT(); new CommandBau(); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandReset.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandReset.java index 0b8fcbb..2e9358e 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandReset.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandReset.java @@ -23,6 +23,7 @@ import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.Permission; import de.steamwar.bausystem.world.Region; import de.steamwar.bausystem.world.Welt; +import de.steamwar.command.SWCommand; import de.steamwar.sql.Schematic; import org.bukkit.Bukkit; import org.bukkit.command.Command; @@ -30,42 +31,62 @@ import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; +import java.io.IOException; import java.util.logging.Level; -public class CommandReset implements CommandExecutor { +public class CommandReset extends SWCommand { - @Override - public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { - if (!(sender instanceof Player)) - return false; - Player player = (Player) sender; + public CommandReset() { + super("reset"); + } + @Register + public void genericResetCommand(Player p) { + if (!permissionCheck(p)) return; + Region region = regionCheck(p); + if (region == null) return; + try { + region.reset(null); + p.sendMessage(BauSystem.PREFIX + "§7Region zurückgesetzt"); + } catch (IOException e) { + p.sendMessage(BauSystem.PREFIX + "§cFehler beim Zurücksetzen der Region"); + Bukkit.getLogger().log(Level.WARNING, "Failed testblock", e); + } + } + + @Register + public void schematicResetCommand(Player p, String s) { + if (!permissionCheck(p)) return; + Region region = regionCheck(p); + if (region == null) return; + Schematic schem = Schematic.getSchemFromDB(s, p.getUniqueId()); + if (schem == null) { + p.sendMessage(BauSystem.PREFIX + "§cSchematic nicht gefunden"); + return; + } + try { + region.reset(null); + p.sendMessage(BauSystem.PREFIX + "§7Region zurückgesetzt"); + } catch (IOException e) { + p.sendMessage(BauSystem.PREFIX + "§cFehler beim Zurücksetzen der Region"); + Bukkit.getLogger().log(Level.WARNING, "Failed reset", e); + } + } + + private boolean permissionCheck(Player player) { if (Welt.noPermission(player, Permission.world)) { player.sendMessage(BauSystem.PREFIX + "§cDu darfst hier nicht die Region zurücksetzen"); return false; } + return true; + } + private Region regionCheck(Player player) { Region region = Region.getRegion(player.getLocation()); if (region == Region.GlobalRegion.getInstance()) { player.sendMessage(BauSystem.PREFIX + "§cDu befindest dich derzeit in keiner Region"); - return false; + return null; } - try { - if (args.length > 0) { - Schematic schem = Schematic.getSchemFromDB(args[0], player.getUniqueId()); - if (schem == null) { - player.sendMessage(BauSystem.PREFIX + "§cSchematic nicht gefunden"); - return false; - } - region.reset(schem); - } else { - region.fastreset(); - } - player.sendMessage(BauSystem.PREFIX + "§7Region zurückgesetzt"); - } catch (Exception e) { - player.sendMessage(BauSystem.PREFIX + "§cFehler beim Zurücksetzen der Region"); - Bukkit.getLogger().log(Level.WARNING, "Failed reset", e); - } - return false; + return region; } } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTestblock.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTestblock.java index 60b9a48..17bcfc3 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTestblock.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTestblock.java @@ -82,8 +82,8 @@ public class CommandTestblock extends SWCommand { Region region = Region.getRegion(player.getLocation()); if (!region.hasTestblock()) { player.sendMessage(BauSystem.PREFIX + "§cDu befindest dich derzeit in keiner Region"); - return region; + return null; } - return null; + return region; } } diff --git a/BauSystem_Main/src/plugin.yml b/BauSystem_Main/src/plugin.yml index a619a73..afac841 100644 --- a/BauSystem_Main/src/plugin.yml +++ b/BauSystem_Main/src/plugin.yml @@ -10,7 +10,6 @@ description: "So unseriös wie wir sind: BauSystem nur besser." commands: fire: - reset: protect: bauinfo: freeze: From 8500fc136c9280db3b3a3cd4a6d22fa33c226dec Mon Sep 17 00:00:00 2001 From: yoyosource Date: Thu, 1 Apr 2021 20:38:31 +0200 Subject: [PATCH 15/51] Update CommandRedstoneTester to new SWCommand system --- .../src/de/steamwar/bausystem/BauSystem.java | 2 +- .../commands/CommandRedstoneTester.java | 41 +++++++++---------- .../bausystem/commands/CommandReset.java | 3 -- BauSystem_Main/src/plugin.yml | 4 +- 4 files changed, 22 insertions(+), 28 deletions(-) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java b/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java index 47fe646..04da67b 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java @@ -97,7 +97,7 @@ public class BauSystem extends JavaPlugin implements Listener { getCommand("scriptvars").setExecutor(new CommandScriptVars()); getCommand("scriptvars").setTabCompleter(new CommandScriptVarsTabCompleter()); new CommandSimulator(); - getCommand("redstonetester").setExecutor(new CommandRedstoneTester()); + new CommandRedstoneTester(); getCommand("gui").setExecutor(new CommandGUI()); Bukkit.getPluginManager().registerEvents(this, this); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandRedstoneTester.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandRedstoneTester.java index 08c794a..d3fe7d1 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandRedstoneTester.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandRedstoneTester.java @@ -24,13 +24,29 @@ import de.steamwar.bausystem.Permission; import de.steamwar.bausystem.SWUtils; import de.steamwar.bausystem.world.RedstoneListener; import de.steamwar.bausystem.world.Welt; +import de.steamwar.command.SWCommand; import de.steamwar.core.VersionedRunnable; -import org.bukkit.command.Command; -import org.bukkit.command.CommandExecutor; -import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; -public class CommandRedstoneTester implements CommandExecutor { +public class CommandRedstoneTester extends SWCommand { + + public CommandRedstoneTester() { + super("redstonetester", "rt"); + } + + @Register + public void genericCommand(Player p) { + VersionedRunnable.call(new VersionedRunnable(() -> { + p.sendMessage(BauSystem.PREFIX + "Der RedstoneTester ist nicht in der 1.12 verfügbar"); + }, 8), new VersionedRunnable(() -> { + if (!permissionCheck(p)) { + return; + } + p.sendMessage(BauSystem.PREFIX + "Messe die Zeit zwischen der Aktivierung zweier Redstone Komponenten"); + SWUtils.giveItemToPlayer(p, RedstoneListener.WAND); + }, 15)); + } + private boolean permissionCheck(Player player) { if (Welt.noPermission(player, Permission.build)) { @@ -40,21 +56,4 @@ public class CommandRedstoneTester 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; - VersionedRunnable.call(new VersionedRunnable(() -> { - player.sendMessage(BauSystem.PREFIX + "Der RedstoneTester ist nicht in der 1.12 verfügbar"); - }, 8), new VersionedRunnable(() -> { - if (!permissionCheck(player)) { - return; - } - player.sendMessage(BauSystem.PREFIX + "Messe die Zeit zwischen der Aktivierung zweier Redstone Komponenten"); - SWUtils.giveItemToPlayer(player, RedstoneListener.WAND); - }, 15)); - return false; - } - } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandReset.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandReset.java index 2e9358e..2ff81f8 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandReset.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandReset.java @@ -26,9 +26,6 @@ import de.steamwar.bausystem.world.Welt; import de.steamwar.command.SWCommand; import de.steamwar.sql.Schematic; import org.bukkit.Bukkit; -import org.bukkit.command.Command; -import org.bukkit.command.CommandExecutor; -import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import java.io.IOException; diff --git a/BauSystem_Main/src/plugin.yml b/BauSystem_Main/src/plugin.yml index afac841..c59d1a4 100644 --- a/BauSystem_Main/src/plugin.yml +++ b/BauSystem_Main/src/plugin.yml @@ -21,6 +21,4 @@ commands: aliases: wv lockschem: scriptvars: - gui: - redstonetester: - aliases: rt \ No newline at end of file + gui: \ No newline at end of file From 853b475b74234182cc6dc393a84ca575f4905dff Mon Sep 17 00:00:00 2001 From: yoyosource Date: Thu, 1 Apr 2021 20:41:58 +0200 Subject: [PATCH 16/51] Update CommandProtect to new SWCommand system --- .../src/de/steamwar/bausystem/BauSystem.java | 2 +- .../bausystem/commands/CommandProtect.java | 73 ++++++++++++------- BauSystem_Main/src/plugin.yml | 1 - 3 files changed, 47 insertions(+), 29 deletions(-) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java b/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java index 04da67b..40a3694 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java @@ -86,7 +86,7 @@ public class BauSystem extends JavaPlugin implements Listener { getCommand("freeze").setExecutor(new CommandFreeze()); new CommandTestblock(); getCommand("bauinfo").setExecutor(new CommandInfo()); - getCommand("protect").setExecutor(new CommandProtect()); + new CommandProtect(); new CommandSkull(); getCommand("loader").setExecutor(new CommandLoader()); getCommand("lockschem").setExecutor(new CommandLockschem()); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandProtect.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandProtect.java index 92e83bc..31d9ac2 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandProtect.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandProtect.java @@ -23,48 +23,67 @@ import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.Permission; import de.steamwar.bausystem.world.Region; import de.steamwar.bausystem.world.Welt; +import de.steamwar.command.SWCommand; import de.steamwar.sql.Schematic; import org.bukkit.Bukkit; -import org.bukkit.command.Command; -import org.bukkit.command.CommandExecutor; -import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; +import java.io.IOException; import java.util.logging.Level; -public class CommandProtect implements CommandExecutor { +public class CommandProtect extends SWCommand { - @Override - public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { - if (!(sender instanceof Player)) - return false; - Player player = (Player) sender; + public CommandProtect() { + super("protect"); + } + @Register + public void genericTestblockCommand(Player p) { + if (!permissionCheck(p)) return; + Region region = regionCheck(p); + if (region == null) return; + try { + region.protect(null); + p.sendMessage(BauSystem.PREFIX + "§7Boden geschützt"); + } catch (IOException e) { + p.sendMessage(BauSystem.PREFIX + "§cFehler beim Schützen der Region"); + Bukkit.getLogger().log(Level.WARNING, "Failed protect", e); + } + } + + @Register + public void schematicTestblockCommand(Player p, String s) { + if (!permissionCheck(p)) return; + Region region = regionCheck(p); + if (region == null) return; + Schematic schem = Schematic.getSchemFromDB(s, p.getUniqueId()); + if (schem == null) { + p.sendMessage(BauSystem.PREFIX + "§cSchematic nicht gefunden"); + return; + } + try { + region.protect(null); + p.sendMessage(BauSystem.PREFIX + "§7Boden geschützt"); + } catch (IOException e) { + p.sendMessage(BauSystem.PREFIX + "§cFehler beim Schützen der Region"); + Bukkit.getLogger().log(Level.WARNING, "Failed protect", e); + } + } + + private boolean permissionCheck(Player player) { if (Welt.noPermission(player, Permission.worldedit)) { player.sendMessage(BauSystem.PREFIX + "§cDu darfst hier nicht den Boden schützen"); return false; } + return true; + } + private Region regionCheck(Player player) { Region region = Region.getRegion(player.getLocation()); - if (region == null || !region.hasProtection()) { + if (!region.hasProtection()) { player.sendMessage(BauSystem.PREFIX + "§cDu befindest dich derzeit in keiner (M)WG-Region"); - return false; + return null; } - try { - Schematic schem = null; - if (args.length > 0) { - schem = Schematic.getSchemFromDB(args[0], player.getUniqueId()); - if (schem == null) { - player.sendMessage(BauSystem.PREFIX + "§cSchematic nicht gefunden"); - return false; - } - } - region.protect(schem); - player.sendMessage(BauSystem.PREFIX + "§7Boden geschützt"); - } catch (Exception e) { - player.sendMessage(BauSystem.PREFIX + "§cFehler beim Schützen der Region"); - Bukkit.getLogger().log(Level.WARNING, "Failed protect", e); - } - return false; + return region; } } diff --git a/BauSystem_Main/src/plugin.yml b/BauSystem_Main/src/plugin.yml index c59d1a4..f1fa10e 100644 --- a/BauSystem_Main/src/plugin.yml +++ b/BauSystem_Main/src/plugin.yml @@ -10,7 +10,6 @@ description: "So unseriös wie wir sind: BauSystem nur besser." commands: fire: - protect: bauinfo: freeze: aliases: stoplag From 91b8d2db1b0b10cda60aa6cdb7bee8b13414f8e8 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Thu, 1 Apr 2021 20:43:31 +0200 Subject: [PATCH 17/51] Update CommandNV to new SWCommand system --- .../src/de/steamwar/bausystem/BauSystem.java | 2 +- .../bausystem/commands/CommandNV.java | 20 +++++++++---------- BauSystem_Main/src/plugin.yml | 2 -- 3 files changed, 10 insertions(+), 14 deletions(-) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java b/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java index 40a3694..cae5a18 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java @@ -77,7 +77,7 @@ public class BauSystem extends JavaPlugin implements Listener { new CommandTrace(); new CommandTPSLimiter(); - getCommand("nightvision").setExecutor(new CommandNV()); + new CommandNV(); new CommandReset(); new CommandSpeed(); new CommandTNT(); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandNV.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandNV.java index 196887d..da22b91 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandNV.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandNV.java @@ -20,22 +20,20 @@ package de.steamwar.bausystem.commands; import de.steamwar.bausystem.BauSystem; -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; import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffectType; -public class CommandNV implements CommandExecutor { +public class CommandNV extends SWCommand { - @Override - public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { - if (!(sender instanceof Player)) - return false; - Player player = (Player) sender; - toggleNightvision(player); - return false; + public CommandNV() { + super("nightvision", "nv"); + } + + @Register + public void genericCommand(Player p) { + toggleNightvision(p); } public static void toggleNightvision(Player player) { diff --git a/BauSystem_Main/src/plugin.yml b/BauSystem_Main/src/plugin.yml index f1fa10e..b8c5d83 100644 --- a/BauSystem_Main/src/plugin.yml +++ b/BauSystem_Main/src/plugin.yml @@ -14,8 +14,6 @@ commands: freeze: aliases: stoplag loader: - nightvision: - aliases: nv watervision: aliases: wv lockschem: From 87ed69478f00ab74d41e177a9ecf5e4326fb3498 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Thu, 1 Apr 2021 20:51:50 +0200 Subject: [PATCH 18/51] Update CommandLoader to new SWCommand system --- .../src/de/steamwar/bausystem/BauSystem.java | 2 +- .../bausystem/commands/CommandLoader.java | 131 ++++++++---------- BauSystem_Main/src/plugin.yml | 1 - 3 files changed, 61 insertions(+), 73 deletions(-) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java b/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java index cae5a18..4ead747 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java @@ -88,7 +88,7 @@ public class BauSystem extends JavaPlugin implements Listener { getCommand("bauinfo").setExecutor(new CommandInfo()); new CommandProtect(); new CommandSkull(); - getCommand("loader").setExecutor(new CommandLoader()); + new CommandLoader(); getCommand("lockschem").setExecutor(new CommandLockschem()); new CommandDebugStick(); getCommand("watervision").setExecutor(new CommandGills()); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandLoader.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandLoader.java index 0cd79d0..fb3f5d6 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandLoader.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandLoader.java @@ -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); diff --git a/BauSystem_Main/src/plugin.yml b/BauSystem_Main/src/plugin.yml index b8c5d83..69afc4a 100644 --- a/BauSystem_Main/src/plugin.yml +++ b/BauSystem_Main/src/plugin.yml @@ -13,7 +13,6 @@ commands: bauinfo: freeze: aliases: stoplag - loader: watervision: aliases: wv lockschem: From d2c23a1b47479edd53351e9502a6b71136ffedcc Mon Sep 17 00:00:00 2001 From: yoyosource Date: Thu, 1 Apr 2021 20:54:01 +0200 Subject: [PATCH 19/51] Update CommandInfo to new SWCommand system --- .../src/de/steamwar/bausystem/BauSystem.java | 2 +- .../bausystem/commands/CommandInfo.java | 29 ++++++++----------- BauSystem_Main/src/plugin.yml | 1 - 3 files changed, 13 insertions(+), 19 deletions(-) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java b/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java index 4ead747..2f13c79 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java @@ -85,7 +85,7 @@ public class BauSystem extends JavaPlugin implements Listener { getCommand("fire").setExecutor(new CommandFire()); getCommand("freeze").setExecutor(new CommandFreeze()); new CommandTestblock(); - getCommand("bauinfo").setExecutor(new CommandInfo()); + new CommandInfo(); new CommandProtect(); new CommandSkull(); new CommandLoader(); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandInfo.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandInfo.java index 6043e74..0b9ce00 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandInfo.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandInfo.java @@ -22,30 +22,27 @@ package de.steamwar.bausystem.commands; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.world.Region; import de.steamwar.bausystem.world.TPSUtils; +import de.steamwar.command.SWCommand; import de.steamwar.core.TPSWatcher; import de.steamwar.sql.BauweltMember; import de.steamwar.sql.SteamwarUser; -import org.bukkit.command.Command; -import org.bukkit.command.CommandExecutor; -import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import java.util.List; import static de.steamwar.bausystem.world.TPSUtils.getTps; -public class CommandInfo implements CommandExecutor { +public class CommandInfo extends SWCommand { - @Override - public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { - if (!(sender instanceof Player)) { - return false; - } - Player player = (Player) sender; + public CommandInfo() { + super("bauinfo", "info"); + } - sender.sendMessage(BauSystem.PREFIX + "Besitzer: §e" + SteamwarUser.get(BauSystem.getOwnerID()).getUserName()); - Region region = Region.getRegion(player.getLocation()); - sender.sendMessage(BauSystem.PREFIX + "§eTNT§8: " + region.getTntMode().getName() + " §eFire§8: " + (region.isFire() ? "§aAUS" : "§cAN") + " §eFreeze§8: " + (region.isFreeze() ? "§aAN" : "§cAUS")); + @Register + public void genericCommand(Player p) { + p.sendMessage(BauSystem.PREFIX + "Besitzer: §e" + SteamwarUser.get(BauSystem.getOwnerID()).getUserName()); + Region region = Region.getRegion(p.getLocation()); + p.sendMessage(BauSystem.PREFIX + "§eTNT§8: " + region.getTntMode().getName() + " §eFire§8: " + (region.isFire() ? "§aAUS" : "§cAN") + " §eFreeze§8: " + (region.isFreeze() ? "§aAN" : "§cAUS")); List members = BauweltMember.getMembers(BauSystem.getOwnerID()); StringBuilder membermessage = new StringBuilder().append(BauSystem.PREFIX).append("Mitglieder: "); @@ -56,7 +53,7 @@ public class CommandInfo implements CommandExecutor { membermessage.append(member.isWorldEdit() ? "§a" : "§c").append("WE").append("§8,"); membermessage.append(member.isWorld() ? "§a" : "§c").append("W").append("§8]").append(" "); } - sender.sendMessage(membermessage.toString()); + p.sendMessage(membermessage.toString()); StringBuilder tpsMessage = new StringBuilder(); tpsMessage.append(BauSystem.PREFIX).append("TPS:§e"); @@ -67,8 +64,6 @@ public class CommandInfo implements CommandExecutor { tpsMessage.append(" ").append(TPSWatcher.getTPS(TPSWatcher.TPSType.FIVE_MINUTES)); tpsMessage.append(" ").append(TPSWatcher.getTPS(TPSWatcher.TPSType.TEN_MINUTES)); } - sender.sendMessage(tpsMessage.toString()); - return false; + p.sendMessage(tpsMessage.toString()); } - } diff --git a/BauSystem_Main/src/plugin.yml b/BauSystem_Main/src/plugin.yml index 69afc4a..37f2ca9 100644 --- a/BauSystem_Main/src/plugin.yml +++ b/BauSystem_Main/src/plugin.yml @@ -10,7 +10,6 @@ description: "So unseriös wie wir sind: BauSystem nur besser." commands: fire: - bauinfo: freeze: aliases: stoplag watervision: From 5795291819ff59a84d3bf16411be33c88994389f Mon Sep 17 00:00:00 2001 From: yoyosource Date: Thu, 1 Apr 2021 20:56:32 +0200 Subject: [PATCH 20/51] Update CommandGUI to new SWCommand system --- .../src/de/steamwar/bausystem/BauSystem.java | 2 +- .../bausystem/commands/CommandGUI.java | 32 ++++++++----------- BauSystem_Main/src/plugin.yml | 3 +- 3 files changed, 16 insertions(+), 21 deletions(-) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java b/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java index 2f13c79..75eeaca 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java @@ -98,7 +98,7 @@ public class BauSystem extends JavaPlugin implements Listener { getCommand("scriptvars").setTabCompleter(new CommandScriptVarsTabCompleter()); new CommandSimulator(); new CommandRedstoneTester(); - getCommand("gui").setExecutor(new CommandGUI()); + new CommandGUI(); Bukkit.getPluginManager().registerEvents(this, this); Bukkit.getPluginManager().registerEvents(new RegionListener(), this); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandGUI.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandGUI.java index 5038659..6260e03 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandGUI.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandGUI.java @@ -6,6 +6,7 @@ import de.steamwar.bausystem.SWUtils; import de.steamwar.bausystem.tracer.record.RecordStateMachine; import de.steamwar.bausystem.tracer.show.TraceShowManager; import de.steamwar.bausystem.world.*; +import de.steamwar.command.SWCommand; import de.steamwar.core.Core; import de.steamwar.inventory.SWAnvilInv; import de.steamwar.inventory.SWInventory; @@ -19,9 +20,6 @@ import net.md_5.bungee.api.chat.HoverEvent; import net.md_5.bungee.api.chat.TextComponent; import org.bukkit.Bukkit; import org.bukkit.Material; -import org.bukkit.command.Command; -import org.bukkit.command.CommandExecutor; -import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; @@ -34,7 +32,7 @@ import org.bukkit.potion.PotionEffectType; import java.util.*; -public class CommandGUI implements CommandExecutor, Listener { +public class CommandGUI extends SWCommand implements Listener { private static final Set OPEN_INVS = new HashSet<>(); private static final Set OPEN_TRACER_INVS = new HashSet<>(); @@ -42,9 +40,21 @@ public class CommandGUI implements CommandExecutor, Listener { private static boolean isRefreshing = false; public CommandGUI() { + super("gui"); Bukkit.getScheduler().runTaskTimerAsynchronously(BauSystem.getPlugin(), LAST_F_PLAYER::clear, 0, 20); } + @Register + public void genericCommand(Player p) { + openBauGui(p); + OPEN_INVS.add(p); + } + + @Register({"item"}) + public void itemCommand(Player p) { + SWUtils.giveItemToPlayer(p, new ItemStack(Material.NETHER_STAR)); + } + public static void openBauGui(Player player) { Region region = Region.getRegion(player.getLocation()); SWInventory inv = new SWInventory(player, 5 * 9, SteamwarUser.get(BauSystem.getOwner()).getUserName() + "s Bau"); @@ -584,20 +594,6 @@ public class CommandGUI implements CommandExecutor, Listener { return base; } - @Override - public boolean onCommand(CommandSender commandSender, Command command, String s, String[] strings) { - if (!(commandSender instanceof Player)) - return false; - Player player = ((Player) commandSender); - if (strings.length == 0) { - openBauGui(player); - OPEN_INVS.add(player); - } else if ("item".equalsIgnoreCase(strings[0])) { - SWUtils.giveItemToPlayer(player, new ItemStack(Material.NETHER_STAR)); - } - return true; - } - @EventHandler public void onPlayerInteract(PlayerInteractEvent event) { if (event.getAction() != Action.RIGHT_CLICK_AIR && event.getAction() != Action.RIGHT_CLICK_BLOCK) diff --git a/BauSystem_Main/src/plugin.yml b/BauSystem_Main/src/plugin.yml index 37f2ca9..79a1369 100644 --- a/BauSystem_Main/src/plugin.yml +++ b/BauSystem_Main/src/plugin.yml @@ -15,5 +15,4 @@ commands: watervision: aliases: wv lockschem: - scriptvars: - gui: \ No newline at end of file + scriptvars: \ No newline at end of file From c3f3a5b12ce5b004fd8795e5614516be7bd56372 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Thu, 1 Apr 2021 20:57:54 +0200 Subject: [PATCH 21/51] Update CommandGills to new SWCommand system --- .../src/de/steamwar/bausystem/BauSystem.java | 2 +- .../bausystem/commands/CommandGills.java | 20 +++++++++---------- BauSystem_Main/src/plugin.yml | 2 -- 3 files changed, 10 insertions(+), 14 deletions(-) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java b/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java index 75eeaca..d96921e 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java @@ -91,7 +91,7 @@ public class BauSystem extends JavaPlugin implements Listener { new CommandLoader(); getCommand("lockschem").setExecutor(new CommandLockschem()); new CommandDebugStick(); - getCommand("watervision").setExecutor(new CommandGills()); + new CommandGills(); new CommandDetonator(); new CommandScript(); getCommand("scriptvars").setExecutor(new CommandScriptVars()); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandGills.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandGills.java index 8095e91..1060008 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandGills.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandGills.java @@ -20,22 +20,20 @@ package de.steamwar.bausystem.commands; import de.steamwar.bausystem.BauSystem; -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; import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffectType; -public class CommandGills implements CommandExecutor { +public class CommandGills extends SWCommand { - @Override - public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { - if (!(sender instanceof Player)) - return false; - Player player = (Player) sender; - toggleGills(player); - return false; + public CommandGills() { + super("watervision", "wv"); + } + + @Register + public void genericCommand(Player p) { + toggleGills(p); } public static void toggleGills(Player player) { diff --git a/BauSystem_Main/src/plugin.yml b/BauSystem_Main/src/plugin.yml index 79a1369..caa4718 100644 --- a/BauSystem_Main/src/plugin.yml +++ b/BauSystem_Main/src/plugin.yml @@ -12,7 +12,5 @@ commands: fire: freeze: aliases: stoplag - watervision: - aliases: wv lockschem: scriptvars: \ No newline at end of file From 35f0108f70464ee17c80fabbe5973390b787f069 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Thu, 1 Apr 2021 21:01:55 +0200 Subject: [PATCH 22/51] Update CommandDetonator to new SWCommand system --- .../bausystem/commands/CommandDetonator.java | 68 +++++++------------ .../CommandDetonatorTabCompleter.java | 44 ------------ .../bausystem/commands/RegionUtils.java | 37 ++++++++++ 3 files changed, 61 insertions(+), 88 deletions(-) delete mode 100644 BauSystem_Main/src/de/steamwar/bausystem/commands/CommandDetonatorTabCompleter.java create mode 100644 BauSystem_Main/src/de/steamwar/bausystem/commands/RegionUtils.java diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandDetonator.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandDetonator.java index f1a1ddb..310c395 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandDetonator.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandDetonator.java @@ -8,101 +8,81 @@ 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)) { - SWUtils.giveItemToPlayer(p, Detonator.WAND); - p.updateInventory(); - } + if (!permissionCheck(p)) return; + SWUtils.giveItemToPlayer(p, Detonator.WAND); } @Register("detonator") public void detonatorCommand(Player p) { - if (permissionCheck(p)) { - SWUtils.giveItemToPlayer(p, Detonator.WAND); - p.updateInventory(); - } + if (!permissionCheck(p)) return; + SWUtils.giveItemToPlayer(p, Detonator.WAND); } @Register("item") public void itemCommand(Player p) { - if (permissionCheck(p)) { - SWUtils.giveItemToPlayer(p, Detonator.WAND); - p.updateInventory(); - } + if (!permissionCheck(p)) return; + SWUtils.giveItemToPlayer(p, Detonator.WAND); } @Register("remove") public void removeCommand(Player p) { - if (permissionCheck(p)) { - p.getInventory().removeItem(Detonator.WAND); - } + if (!permissionCheck(p)) return; + p.getInventory().removeItem(Detonator.WAND); } @Register("detonate") public void detonateCommand(Player p) { - if (permissionCheck(p)) { - Detonator.execute(p); - } + if (!permissionCheck(p)) return; + Detonator.execute(p); } @Register("click") public void clickCommand(Player p) { - if (permissionCheck(p)) { - Detonator.execute(p); - } + if (!permissionCheck(p)) return; + Detonator.execute(p); } @Register("use") public void useCommand(Player p) { - if (permissionCheck(p)) { - Detonator.execute(p); - } + if (!permissionCheck(p)) return; + Detonator.execute(p); } @Register("clear") public void clearCommand(Player p) { - if (permissionCheck(p)) { - p.getInventory().setItemInMainHand(Detonator.clearDetonator(p.getInventory().getItemInMainHand())); - } + if (!permissionCheck(p)) return; + p.getInventory().setItemInMainHand(Detonator.clearDetonator(p.getInventory().getItemInMainHand())); } @Register("delete") public void deleteCommand(Player p) { - if (permissionCheck(p)) { - p.getInventory().setItemInMainHand(Detonator.clearDetonator(p.getInventory().getItemInMainHand())); - } + if (!permissionCheck(p)) return; + p.getInventory().setItemInMainHand(Detonator.clearDetonator(p.getInventory().getItemInMainHand())); } @Register("reset") public void resetCommand(Player p) { - if (permissionCheck(p)) { - 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"); + if (!permissionCheck(p)) return; + p.getInventory().setItemInMainHand(Detonator.clearDetonator(p.getInventory().getItemInMainHand())); } private boolean permissionCheck(Player player) { diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandDetonatorTabCompleter.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandDetonatorTabCompleter.java deleted file mode 100644 index f4a166a..0000000 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandDetonatorTabCompleter.java +++ /dev/null @@ -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 . -*/ - -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 arguments = new ArrayList<>(Arrays.asList("wand", "reset", "detonate", "remove")); - - @Override - public List 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); - } -} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/RegionUtils.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/RegionUtils.java new file mode 100644 index 0000000..24dcedd --- /dev/null +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/RegionUtils.java @@ -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 . + */ + +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))); + } + } + +} From 6eb34d118c8666d11e61de909ee52c9fec7f4c19 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Thu, 1 Apr 2021 21:02:24 +0200 Subject: [PATCH 23/51] Update CommandBau to new SWCommand system --- .../src/de/steamwar/bausystem/commands/CommandBau.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandBau.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandBau.java index 5e991dd..ff3f6b2 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandBau.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandBau.java @@ -15,7 +15,7 @@ public class CommandBau extends SWCommand { } - @Register() + @Register public void genericCommand(Player p) { permissionCheck(p); } From 5c1e6ca74a0404220cee3814bece6c2e9f712d94 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Thu, 1 Apr 2021 21:07:42 +0200 Subject: [PATCH 24/51] Update CommandSpeed to new SWCommand system --- .../src/de/steamwar/bausystem/commands/CommandSpeed.java | 1 + 1 file changed, 1 insertion(+) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandSpeed.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandSpeed.java index 1a4b31a..192274c 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandSpeed.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandSpeed.java @@ -44,6 +44,7 @@ public class CommandSpeed extends SWCommand { speedCommand(p, 1); } + @Register public void speedCommand(Player p, float speed) { if (speed < 0 || speed > 10) { p.sendMessage(BauSystem.PREFIX + "§cBitte gib eine Zahl zwischen 0 und 10 an"); From d16af698bfc58ace70b4b85b731b0fa6f104e973 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Thu, 1 Apr 2021 21:25:08 +0200 Subject: [PATCH 25/51] Fix CommandInfo Fix CommandLockschem Fix CommandRedstoneTester Fix CommandSkull Fix CommandTNT Fix CommandTPSLimiter Fix CommandTrace --- .../src/de/steamwar/bausystem/BauSystem.java | 2 ++ .../bausystem/commands/CommandInfo.java | 2 +- .../bausystem/commands/CommandLockschem.java | 1 + .../commands/CommandRedstoneTester.java | 4 +--- .../bausystem/commands/CommandSkull.java | 2 +- .../bausystem/commands/CommandTNT.java | 1 - .../bausystem/commands/CommandTPSLimiter.java | 21 +++++++------------ .../bausystem/commands/CommandTrace.java | 2 +- 8 files changed, 15 insertions(+), 20 deletions(-) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java b/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java index d96921e..1281ae1 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java @@ -63,6 +63,8 @@ public class BauSystem extends JavaPlugin implements Listener { owner = null; } + Mapper.init(); + try { CommandRemover.removeAll("tp", "gamemode", "time", "clear"); CommandInjector.injectCommand(new CommandTeleport()); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandInfo.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandInfo.java index 0b9ce00..3a48e27 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandInfo.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandInfo.java @@ -35,7 +35,7 @@ import static de.steamwar.bausystem.world.TPSUtils.getTps; public class CommandInfo extends SWCommand { public CommandInfo() { - super("bauinfo", "info"); + super("bauinfo"); } @Register diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandLockschem.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandLockschem.java index 6ac4742..75fca1e 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandLockschem.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandLockschem.java @@ -30,6 +30,7 @@ import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; public class CommandLockschem implements CommandExecutor { + @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { if (!(sender instanceof Player)) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandRedstoneTester.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandRedstoneTester.java index d3fe7d1..5859ba6 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandRedstoneTester.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandRedstoneTester.java @@ -39,9 +39,7 @@ public class CommandRedstoneTester extends SWCommand { VersionedRunnable.call(new VersionedRunnable(() -> { p.sendMessage(BauSystem.PREFIX + "Der RedstoneTester ist nicht in der 1.12 verfügbar"); }, 8), new VersionedRunnable(() -> { - if (!permissionCheck(p)) { - return; - } + if (!permissionCheck(p)) return; p.sendMessage(BauSystem.PREFIX + "Messe die Zeit zwischen der Aktivierung zweier Redstone Komponenten"); SWUtils.giveItemToPlayer(p, RedstoneListener.WAND); }, 15)); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandSkull.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandSkull.java index 24a8b51..470e2b6 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandSkull.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandSkull.java @@ -39,7 +39,7 @@ public class CommandSkull extends SWCommand { } @Register - public void giveHelp(Player p, String skull) { + public void giveCommand(Player p, String skull) { ItemStack is = SWItem.getPlayerSkull(skull).getItemStack(); SkullMeta sm = (SkullMeta) is.getItemMeta(); assert sm != null; diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTNT.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTNT.java index 0909302..bda7dfc 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTNT.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTNT.java @@ -67,7 +67,6 @@ public class CommandTNT extends SWCommand implements Listener { tntToggle(region, null, null); } - @Register public void setCommand(Player p, TNTMode tntMode) { if (!permissionCheck(p)) return; diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTPSLimiter.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTPSLimiter.java index e589a68..62ccaba 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTPSLimiter.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTPSLimiter.java @@ -52,7 +52,7 @@ public class CommandTPSLimiter extends SWCommand { private BukkitTask tpsLimiter = null; - private List arguments = new ArrayList<>(Arrays.asList("1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20")); + private List arguments = new ArrayList<>(Arrays.asList("0,5", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20")); public CommandTPSLimiter() { super("tpslimit"); @@ -76,20 +76,15 @@ public class CommandTPSLimiter extends SWCommand { } @Register - public void valueCommand(Player p, String tpsLimit) { + public void valueCommand(Player p, double tpsLimitDouble) { if (!permissionCheck(p)) return; - try { - double tpsLimitDouble = Double.parseDouble(tpsLimit.replace(',', '.')); - if (tpsLimitDouble < 0.5 || tpsLimitDouble > (TPSUtils.isWarpAllowed() ? 40 : 20)) { - sendInvalidArgumentMessage(p); - return; - } - currentTPSLimit = tpsLimitDouble; - sendNewTPSLimitMessage(); - tpsLimiter(); - } catch (NumberFormatException e) { + if (tpsLimitDouble < 0.5 || tpsLimitDouble > (TPSUtils.isWarpAllowed() ? 40 : 20)) { sendInvalidArgumentMessage(p); + return; } + currentTPSLimit = tpsLimitDouble; + sendNewTPSLimitMessage(); + tpsLimiter(); } @ClassMapper(value = double.class, local = true) @@ -98,7 +93,7 @@ public class CommandTPSLimiter extends SWCommand { try { return Double.parseDouble(s.replace(',', '.')); } catch (NumberFormatException e) { - return null; + return 0D; } }, s -> arguments); } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTrace.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTrace.java index 9c2bb3b..fc32547 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTrace.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTrace.java @@ -43,7 +43,7 @@ public class CommandTrace extends SWCommand { p.sendMessage("§8/§etrace stop §8- §7Stoppt den TNT-Tracer"); p.sendMessage("§8/§etrace toggleauto §8- §7Automatischer Aufnahmenstart"); p.sendMessage("§8/§etrace show gui §8- §7Zeigt die Trace show gui"); - p.sendMessage("§8/§etrace show §8<§edefault§8|§eadvanced§8> §8<§e-water§8|§e-interpolate-xz§8|§e-interpolate-y§8> §8- §7Zeigt alle TNT-Positionen"); + p.sendMessage("§8/§etrace show §8<§e-water§8|§e-interpolate-xz§8|§e-interpolate-y§8> §8- §7Zeigt alle TNT-Positionen"); p.sendMessage("§8/§etrace hide §8- §7Versteckt alle TNT-Positionen"); p.sendMessage("§8/§etrace delete §8- §7Löscht alle TNT-Positionen"); // p.sendMessage("§8/§etrace list §8<§7FRAME-ID§8> §8- §7Listet alle TNT auf"); From 3d6d2cbc73d9b513017e9ab63529e45f7aa030ca Mon Sep 17 00:00:00 2001 From: Zeanon Date: Thu, 1 Apr 2021 21:42:57 +0200 Subject: [PATCH 26/51] update for CommandGamemode --- .../src/de/steamwar/bausystem/BauSystem.java | 4 +- .../bausystem/commands/CommandGamemode.java | 118 +++++------------- 2 files changed, 36 insertions(+), 86 deletions(-) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java b/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java index 1281ae1..589e233 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java @@ -66,9 +66,8 @@ public class BauSystem extends JavaPlugin implements Listener { Mapper.init(); try { - CommandRemover.removeAll("tp", "gamemode", "time", "clear"); + CommandRemover.removeAll("tp", "time", "clear"); CommandInjector.injectCommand(new CommandTeleport()); - CommandInjector.injectCommand(new CommandGamemode()); CommandInjector.injectCommand(new CommandTime()); CommandInjector.injectCommand(new CommandClear()); } catch (Exception e) { @@ -84,6 +83,7 @@ public class BauSystem extends JavaPlugin implements Listener { new CommandSpeed(); new CommandTNT(); new CommandBau(); + new CommandGamemode(); getCommand("fire").setExecutor(new CommandFire()); getCommand("freeze").setExecutor(new CommandFreeze()); new CommandTestblock(); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandGamemode.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandGamemode.java index 757f08d..5c2608b 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandGamemode.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandGamemode.java @@ -1,60 +1,51 @@ -/* - 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 . -*/ - package de.steamwar.bausystem.commands; -import com.google.common.collect.ImmutableList; import de.steamwar.bausystem.BauSystem; +import de.steamwar.command.SWCommand; import de.steamwar.sql.BauweltMember; -import org.apache.commons.lang.Validate; import org.bukkit.GameMode; -import org.bukkit.command.CommandSender; -import org.bukkit.command.defaults.BukkitCommand; import org.bukkit.entity.Player; -import org.bukkit.util.StringUtil; -import java.util.ArrayList; -import java.util.List; -public class CommandGamemode extends BukkitCommand { - private static final List GAMEMODE_NAMES = ImmutableList.of("adventure", "creative", "survival", - "spectator"); +public class CommandGamemode extends SWCommand { public CommandGamemode() { - super("gamemode"); - List aliases = new ArrayList<>(); - aliases.add("gm"); - this.setAliases(aliases); - this.description = "Ändert den Spielmodus eines Spielers"; - this.usageMessage = "/gm [Spielmodus]"; + super("gamemode", "gm"); } - public boolean execute(CommandSender sender, String currentAlias, String[] args) { - if (!(sender instanceof Player)) { - return false; - } else if (args.length == 0) { - sender.sendMessage(BauSystem.PREFIX + this.usageMessage); - return false; + + @Register(help = true) + public void gamemodeHelp(Player p, String... args) { + p.sendMessage(BauSystem.PREFIX + "§cUnbekannter Spielmodus"); + } + + @Register + public void genericCommand(Player p) { + if (!permissionCheck(p)) { + //noinspection UnnecessaryReturnStatement + return; + } else { + if (p.getGameMode() == GameMode.CREATIVE) { + p.setGameMode(GameMode.SPECTATOR); + } else { + p.setGameMode(GameMode.CREATIVE); + } } + } - Player p = (Player) sender; + @Register + public void gamemodeCommand(Player p, GameMode gameMode) { + if (!permissionCheck(p)) { + //noinspection UnnecessaryReturnStatement + return; + } else { + p.setGameMode(gameMode); + } + } + + + private boolean permissionCheck(Player p) { if (!p.getUniqueId().equals(BauSystem.getOwner())) { BauweltMember member = BauweltMember.getBauMember(BauSystem.getOwner(), p.getUniqueId()); if (member == null || !member.isBuild()) { @@ -62,47 +53,6 @@ public class CommandGamemode extends BukkitCommand { return false; } } - - GameMode mode = createMode(args[0]); - - if (mode == null) { - p.sendMessage(BauSystem.PREFIX + "§cUnbekannter Spielmodus"); - return false; - } - - p.setGameMode(mode); return true; } - - @SuppressWarnings("deprecation") - private GameMode createMode(String modeArg) { - try { - return GameMode.getByValue(Integer.parseInt(modeArg)); - } catch (NumberFormatException ignored) { - if ((modeArg.equalsIgnoreCase("creative")) || (modeArg.equalsIgnoreCase("c"))) - return GameMode.CREATIVE; - else if ((modeArg.equalsIgnoreCase("adventure")) || (modeArg.equalsIgnoreCase("a"))) - return GameMode.ADVENTURE; - else if ((modeArg.equalsIgnoreCase("spectator")) || (modeArg.equalsIgnoreCase("sp"))) - return GameMode.SPECTATOR; - else if ((modeArg.equalsIgnoreCase("survival")) || (modeArg.equalsIgnoreCase("s"))) - return GameMode.SURVIVAL; - } - return null; - } - - @Override - public List tabComplete(CommandSender sender, String alias, String[] args) { - Validate.notNull(sender, "Sender cannot be null"); - Validate.notNull(args, "Arguments cannot be null"); - Validate.notNull(alias, "Alias cannot be null"); - - if (args.length == 1) - return StringUtil.copyPartialMatches(args[0], GAMEMODE_NAMES, - new ArrayList<>(GAMEMODE_NAMES.size())); - if (args.length == 2) { - return super.tabComplete(sender, alias, args); - } - return ImmutableList.of(); - } -} +} \ No newline at end of file From 7116fed5b28fcc3f59a56a4bdd2baa2433346711 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Thu, 1 Apr 2021 21:47:23 +0200 Subject: [PATCH 27/51] Update CommandScriptVars to new SWCommand system --- .../src/de/steamwar/bausystem/BauSystem.java | 3 +- .../bausystem/commands/CommandScriptVars.java | 142 +++++++++++------- .../CommandScriptVarsTabCompleter.java | 34 ----- BauSystem_Main/src/plugin.yml | 3 +- 4 files changed, 89 insertions(+), 93 deletions(-) delete mode 100644 BauSystem_Main/src/de/steamwar/bausystem/commands/CommandScriptVarsTabCompleter.java diff --git a/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java b/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java index 589e233..37fa04a 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java @@ -96,8 +96,7 @@ public class BauSystem extends JavaPlugin implements Listener { new CommandGills(); new CommandDetonator(); new CommandScript(); - getCommand("scriptvars").setExecutor(new CommandScriptVars()); - getCommand("scriptvars").setTabCompleter(new CommandScriptVarsTabCompleter()); + new CommandScriptVars(); new CommandSimulator(); new CommandRedstoneTester(); new CommandGUI(); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandScriptVars.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandScriptVars.java index 946e07b..1b420dc 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandScriptVars.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandScriptVars.java @@ -2,67 +2,99 @@ package de.steamwar.bausystem.commands; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.world.ScriptListener; +import de.steamwar.command.SWCommand; +import de.steamwar.command.SWCommandUtils; +import de.steamwar.command.TypeMapper; import org.bukkit.command.Command; -import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; -import java.util.HashMap; -import java.util.Map; +import java.util.*; -public class CommandScriptVars implements CommandExecutor { +public class CommandScriptVars extends SWCommand { - @Override - public boolean onCommand(CommandSender sender, Command command, String s, String[] args) { - if (!(sender instanceof Player)) { - return false; - } - Player player = (Player) sender; - if (args.length == 0) { - Map globalVariables = ScriptListener.GLOBAL_VARIABLES.get(player); - if (globalVariables == null) { - player.sendMessage(BauSystem.PREFIX + "§cKeine globalen Variablen definiert"); - return false; - } - int i = 0; - player.sendMessage(BauSystem.PREFIX + globalVariables.size() + " Variable(n)"); - for (Map.Entry var : globalVariables.entrySet()) { - if (i++ >= 40) break; - player.sendMessage("- " + var.getKey() + "=" + var.getValue()); - } - return false; - } - String varName = args[0]; - if (args.length == 1) { - Map globalVariables = ScriptListener.GLOBAL_VARIABLES.get(player); - if (globalVariables == null) { - player.sendMessage(BauSystem.PREFIX + "§cKeine globalen Variablen definiert"); - return false; - } - if (!globalVariables.containsKey(varName)) { - player.sendMessage(BauSystem.PREFIX + "§cUnbekannte Variable"); - return false; - } - player.sendMessage(BauSystem.PREFIX + varName + "=" + globalVariables.get(varName)); - return false; - } - switch (args[1].toLowerCase()) { - case "delete": - case "clear": - case "remove": - if (!ScriptListener.GLOBAL_VARIABLES.containsKey(player)) { - player.sendMessage(BauSystem.PREFIX + "§cKeine globalen Variablen definiert"); - break; - } - ScriptListener.GLOBAL_VARIABLES.get(player).remove(varName); - player.sendMessage(BauSystem.PREFIX + "Variable " + varName + " gelöscht"); - break; - default: - int value = ScriptListener.parseValue(args[1]); - ScriptListener.GLOBAL_VARIABLES.computeIfAbsent(player, p -> new HashMap<>()).put(varName, value); - player.sendMessage(BauSystem.PREFIX + varName + " auf " + value + " gesetzt"); - } - return false; + public CommandScriptVars() { + super("scripvars"); } + @Register + public void genericCommand(Player p) { + Map globalVariables = ScriptListener.GLOBAL_VARIABLES.get(p); + if (globalVariables == null) { + p.sendMessage(BauSystem.PREFIX + "§cKeine globalen Variablen definiert"); + return; + } + int i = 0; + p.sendMessage(BauSystem.PREFIX + globalVariables.size() + " Variable(n)"); + for (Map.Entry var : globalVariables.entrySet()) { + if (i++ >= 40) break; + p.sendMessage("- " + var.getKey() + "=" + var.getValue()); + } + } + + @Register + public void removeCommand(Player p, String varName) { + Map globalVariables = ScriptListener.GLOBAL_VARIABLES.get(p); + if (globalVariables == null) { + p.sendMessage(BauSystem.PREFIX + "§cKeine globalen Variablen definiert"); + return; + } + if (!globalVariables.containsKey(varName)) { + p.sendMessage(BauSystem.PREFIX + "§cUnbekannte Variable"); + return; + } + p.sendMessage(BauSystem.PREFIX + varName + "=" + globalVariables.get(varName)); + } + + @Register + public void booleanValueCommand(Player p, String varName, @Mapper(value = "BooleanString") int value) { + valueCommand(p, varName, value); + } + + @Register + public void valueCommand(Player p, String varName, int value) { + ScriptListener.GLOBAL_VARIABLES.computeIfAbsent(p, player -> new HashMap<>()).put(varName, value); + p.sendMessage(BauSystem.PREFIX + varName + " auf " + value + " gesetzt"); + } + + @Register + public void removeCommand(Player p, String varName, @Mapper(value = "ClearString") String remove) { + if (!ScriptListener.GLOBAL_VARIABLES.containsKey(p)) { + p.sendMessage(BauSystem.PREFIX + "§cKeine globalen Variablen definiert"); + return; + } + ScriptListener.GLOBAL_VARIABLES.get(p).remove(varName); + p.sendMessage(BauSystem.PREFIX + "Variable " + varName + " gelöscht"); + } + + @ClassMapper(value = String.class, local = true) + public TypeMapper stringTypeMapper() { + return SWCommandUtils.createMapper(s -> s, (commandSender, s) -> { + if (commandSender instanceof Player) { + Player player = (Player) commandSender; + return new ArrayList<>(ScriptListener.GLOBAL_VARIABLES.getOrDefault(player, new HashMap<>()).keySet()); + } + return null; + }); + } + + @Mapper(value = "ClearString", local = true) + public TypeMapper clearStringTypeMapper() { + List tabCompletes = Arrays.asList("delete", "clear", "remove"); + return SWCommandUtils.createMapper(s -> s, s -> tabCompletes); + } + + @Mapper(value = "BooleanString", local = true) + public TypeMapper booleanStringTypeMapper() { + List tabCompletes = Arrays.asList("yes", "no", "true", "false"); + return SWCommandUtils.createMapper(s -> { + if (s.equalsIgnoreCase("yes") || s.equals("true")) { + return 1; + } + if (s.equalsIgnoreCase("no") || s.equals("false")) { + return 0; + } + return null; + }, s -> tabCompletes); + } } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandScriptVarsTabCompleter.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandScriptVarsTabCompleter.java deleted file mode 100644 index f9fa6ef..0000000 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandScriptVarsTabCompleter.java +++ /dev/null @@ -1,34 +0,0 @@ -package de.steamwar.bausystem.commands; - -import de.steamwar.bausystem.SWUtils; -import de.steamwar.bausystem.world.ScriptListener; -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.HashMap; -import java.util.List; - -public class CommandScriptVarsTabCompleter implements TabCompleter { - - @Override - public List onTabComplete(CommandSender sender, Command command, String s, String[] args) { - if (!(sender instanceof Player)) { - return new ArrayList<>(); - } - Player player = (Player) sender; - if (args.length == 1) { - List variables = new ArrayList<>(ScriptListener.GLOBAL_VARIABLES.getOrDefault(player, new HashMap<>()).keySet()); - return SWUtils.manageList(variables, args); - } - if (args.length != 2) { - return new ArrayList<>(); - } - int value = ScriptListener.GLOBAL_VARIABLES.getOrDefault(player, new HashMap<>()).getOrDefault(args[0], 0); - return SWUtils.manageList(Arrays.asList(value + "", "true", "false", "yes", "no", "delete", "clear", "remove"), args); - } - -} diff --git a/BauSystem_Main/src/plugin.yml b/BauSystem_Main/src/plugin.yml index caa4718..e0eac26 100644 --- a/BauSystem_Main/src/plugin.yml +++ b/BauSystem_Main/src/plugin.yml @@ -12,5 +12,4 @@ commands: fire: freeze: aliases: stoplag - lockschem: - scriptvars: \ No newline at end of file + lockschem: \ No newline at end of file From 932da846a27b8ed114b35d9de87ada9302e6631f Mon Sep 17 00:00:00 2001 From: yoyosource Date: Thu, 1 Apr 2021 21:56:31 +0200 Subject: [PATCH 28/51] Update CommandScriptVars to new SWCommand system --- .../bausystem/commands/CommandScriptVars.java | 35 ++++++++----------- 1 file changed, 14 insertions(+), 21 deletions(-) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandScriptVars.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandScriptVars.java index 1b420dc..45c2d79 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandScriptVars.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandScriptVars.java @@ -5,8 +5,6 @@ import de.steamwar.bausystem.world.ScriptListener; import de.steamwar.command.SWCommand; import de.steamwar.command.SWCommandUtils; import de.steamwar.command.TypeMapper; -import org.bukkit.command.Command; -import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import java.util.*; @@ -47,18 +45,13 @@ public class CommandScriptVars extends SWCommand { } @Register - public void booleanValueCommand(Player p, String varName, @Mapper(value = "BooleanString") int value) { - valueCommand(p, varName, value); - } - - @Register - public void valueCommand(Player p, String varName, int value) { + public void booleanValueCommand(Player p, String varName, int value) { ScriptListener.GLOBAL_VARIABLES.computeIfAbsent(p, player -> new HashMap<>()).put(varName, value); p.sendMessage(BauSystem.PREFIX + varName + " auf " + value + " gesetzt"); } @Register - public void removeCommand(Player p, String varName, @Mapper(value = "ClearString") String remove) { + public void removeCommand(Player p, String varName, @Mapper(value = "Delete") String remove) { if (!ScriptListener.GLOBAL_VARIABLES.containsKey(p)) { p.sendMessage(BauSystem.PREFIX + "§cKeine globalen Variablen definiert"); return; @@ -78,23 +71,23 @@ public class CommandScriptVars extends SWCommand { }); } - @Mapper(value = "ClearString", local = true) + @Mapper(value = "Delete", local = true) public TypeMapper clearStringTypeMapper() { List tabCompletes = Arrays.asList("delete", "clear", "remove"); - return SWCommandUtils.createMapper(s -> s, s -> tabCompletes); - } - - @Mapper(value = "BooleanString", local = true) - public TypeMapper booleanStringTypeMapper() { - List tabCompletes = Arrays.asList("yes", "no", "true", "false"); return SWCommandUtils.createMapper(s -> { - if (s.equalsIgnoreCase("yes") || s.equals("true")) { - return 1; - } - if (s.equalsIgnoreCase("no") || s.equals("false")) { - return 0; + if (s.equalsIgnoreCase("delete") || s.equalsIgnoreCase("clear") || s.equalsIgnoreCase("remove")) { + return s; } return null; }, s -> tabCompletes); } + + @ClassMapper(value = int.class, local = true) + public TypeMapper integerTypeMapper() { + List tabCompletes = Arrays.asList("true", "false", "yes", "no"); + return SWCommandUtils.createMapper(s -> { + if (s.equalsIgnoreCase("remove") || s.equalsIgnoreCase("clear") || s.equalsIgnoreCase("delete")) return null; + return ScriptListener.parseValue(s); + }, s -> tabCompletes); + } } From 9eb36a05a6afeb3450d5e2893d47860830ba6ce3 Mon Sep 17 00:00:00 2001 From: Zeanon Date: Thu, 1 Apr 2021 22:00:29 +0200 Subject: [PATCH 29/51] update for CommandClear --- .../src/de/steamwar/bausystem/BauSystem.java | 4 +- .../bausystem/commands/CommandClear.java | 69 ++++++------------- 2 files changed, 23 insertions(+), 50 deletions(-) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java b/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java index 37fa04a..a19fef0 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java @@ -66,10 +66,9 @@ public class BauSystem extends JavaPlugin implements Listener { Mapper.init(); try { - CommandRemover.removeAll("tp", "time", "clear"); + CommandRemover.removeAll("tp", "time"); CommandInjector.injectCommand(new CommandTeleport()); CommandInjector.injectCommand(new CommandTime()); - CommandInjector.injectCommand(new CommandClear()); } catch (Exception e) { getLogger().log(Level.SEVERE, "Failed to replace commands", e); Bukkit.shutdown(); @@ -84,6 +83,7 @@ public class BauSystem extends JavaPlugin implements Listener { new CommandTNT(); new CommandBau(); new CommandGamemode(); + new CommandClear(); getCommand("fire").setExecutor(new CommandFire()); getCommand("freeze").setExecutor(new CommandFreeze()); new CommandTestblock(); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandClear.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandClear.java index e976c13..4c621e5 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandClear.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandClear.java @@ -1,68 +1,41 @@ -/* - 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 . -*/ - package de.steamwar.bausystem.commands; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.Permission; import de.steamwar.bausystem.world.Welt; +import de.steamwar.command.SWCommand; import org.bukkit.Bukkit; import org.bukkit.Material; -import org.bukkit.command.CommandSender; -import org.bukkit.command.defaults.BukkitCommand; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; -public class CommandClear extends BukkitCommand { + +public class CommandClear extends SWCommand { public CommandClear() { super("clear"); - description = "Leere dein Inventar oder das eines anderen Spielers."; - usageMessage = "/clear [Spieler]"; } - public boolean execute(CommandSender sender, String currentAlias, String[] args) { - if (!(sender instanceof Player)) - return false; - Player player = (Player) sender; - if (args.length == 0) { - clear(player); - player.sendMessage(BauSystem.PREFIX + "Dein Inventar wurde geleert."); - return true; - } - // check if admin - if (Welt.noPermission(player, Permission.world)) { - player.sendMessage(BauSystem.PREFIX + "$cDu darfst hier keine fremden Inventare leeren."); - return false; - } - Player target = Bukkit.getPlayerExact(args[0]); - if (!(target instanceof Player)) { - player.sendMessage(BauSystem.PREFIX + "§cDas ist kein Spieler."); - return false; - } - clear(target); - target.sendMessage(BauSystem.PREFIX + "Dein Inventar wurde von" + player.getDisplayName() + " §7geleert."); - player.sendMessage(BauSystem.PREFIX + "Das Inventar von " + target.getDisplayName() + " §7wurde geleert."); - return true; + @Register + public void genericClearCommand(Player p) { + clear(p); + p.sendMessage(BauSystem.PREFIX + "Dein Inventar wurde geleert."); } + @Register + public void clearPlayerCommand(Player p, Player target) { + if (Welt.noPermission(p, Permission.world)) { + p.sendMessage(BauSystem.PREFIX + "$cDu darfst hier keine fremden Inventare leeren."); + return; + } else { + clear(target); + target.sendMessage(BauSystem.PREFIX + "Dein Inventar wurde von" + p.getDisplayName() + " §7geleert."); + p.sendMessage(BauSystem.PREFIX + "Das Inventar von " + target.getDisplayName() + " §7wurde geleert."); + } + } + + private void clear(Player player) { player.getInventory().clear(); player.getInventory().setHelmet(new ItemStack(Material.AIR)); @@ -70,4 +43,4 @@ public class CommandClear extends BukkitCommand { player.getInventory().setLeggings(new ItemStack(Material.AIR)); player.getInventory().setBoots(new ItemStack(Material.AIR)); } -} +} \ No newline at end of file From 4534e0bbb4323f762645eef271e0a9b228ef9b6a Mon Sep 17 00:00:00 2001 From: yoyosource Date: Thu, 1 Apr 2021 22:03:15 +0200 Subject: [PATCH 30/51] Add CommandBau help Add CommandClear help --- .../bausystem/commands/CommandBau.java | 25 +++++++++--------- .../bausystem/commands/CommandClear.java | 26 ++++++++++++------- 2 files changed, 29 insertions(+), 22 deletions(-) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandBau.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandBau.java index ff3f6b2..f8bcc4f 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandBau.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandBau.java @@ -14,31 +14,30 @@ public class CommandBau extends SWCommand { super("bau", "b", "gs"); } - - @Register - public void genericCommand(Player p) { - permissionCheck(p); + @Register(help = true) + public void genericHelp(Player p, String... args) { + if (!permissionCheck(p)) return; + p.sendMessage(BauSystem.PREFIX + "§e/bau togglebuild §8[§7Player§8] §8- §7Editiere die Bau Rechte eines Spielers"); + p.sendMessage(BauSystem.PREFIX + "§e/bau togglewe §8[§7Player§8] §8- §7Editiere die WorldEdit Rechte eines Spielers"); + p.sendMessage(BauSystem.PREFIX + "§e/bau toggleworld §8[§7Player§8] §8- §7Editiere die Werlt Rechte eines Spielers"); } @Register("togglebuild") public void toggleBuildCommand(Player p, String arg) { - if (permissionCheck(p)) { - onToggleBD(p, arg); - } + if (!permissionCheck(p)) return; + onToggleBD(p, arg); } @Register("togglewe") public void toggleWECommand(Player p, String arg) { - if (permissionCheck(p)) { - onToggleWE(p, arg); - } + if (!permissionCheck(p)) return; + onToggleWE(p, arg); } @Register("toggleworld") public void toggleWorldCommand(Player p, String arg) { - if (permissionCheck(p)) { - onToggleWorld(p, arg); - } + if (!permissionCheck(p)) return; + onToggleWorld(p, arg); } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandClear.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandClear.java index 4c621e5..2c397a5 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandClear.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandClear.java @@ -4,7 +4,6 @@ import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.Permission; import de.steamwar.bausystem.world.Welt; import de.steamwar.command.SWCommand; -import org.bukkit.Bukkit; import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; @@ -16,6 +15,12 @@ public class CommandClear extends SWCommand { super("clear"); } + @Register(help = true) + public void genericHelp(Player p, String... args) { + p.sendMessage(BauSystem.PREFIX + "§e/clear §8- §7Leere dein Inventar"); + if (!permissionCheck(p)) return; + p.sendMessage(BauSystem.PREFIX + "§e/bau clear §8[§7Player§8] §8- §7Leere ein Spieler Inventar"); + } @Register public void genericClearCommand(Player p) { @@ -25,16 +30,19 @@ public class CommandClear extends SWCommand { @Register public void clearPlayerCommand(Player p, Player target) { - if (Welt.noPermission(p, Permission.world)) { - p.sendMessage(BauSystem.PREFIX + "$cDu darfst hier keine fremden Inventare leeren."); - return; - } else { - clear(target); - target.sendMessage(BauSystem.PREFIX + "Dein Inventar wurde von" + p.getDisplayName() + " §7geleert."); - p.sendMessage(BauSystem.PREFIX + "Das Inventar von " + target.getDisplayName() + " §7wurde geleert."); - } + if (!permissionCheck(p)) return; + clear(target); + target.sendMessage(BauSystem.PREFIX + "Dein Inventar wurde von" + p.getDisplayName() + " §7geleert."); + p.sendMessage(BauSystem.PREFIX + "Das Inventar von " + target.getDisplayName() + " §7wurde geleert."); } + private boolean permissionCheck(Player player) { + if (Welt.noPermission(player, Permission.world)) { + player.sendMessage(BauSystem.PREFIX + "$cDu darfst hier keine fremden Inventare leeren."); + return false; + } + return true; + } private void clear(Player player) { player.getInventory().clear(); From d599d43f5623e809642d81433747372d304b6bf4 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Thu, 1 Apr 2021 22:26:26 +0200 Subject: [PATCH 31/51] Add help command to various Commands --- .../bausystem/commands/CommandBau.java | 7 +++--- .../bausystem/commands/CommandClear.java | 5 ++-- .../bausystem/commands/CommandDebugStick.java | 5 ++++ .../bausystem/commands/CommandGUI.java | 6 +++++ .../bausystem/commands/CommandGamemode.java | 23 +++++-------------- .../bausystem/commands/CommandGills.java | 5 ++++ .../bausystem/commands/CommandInfo.java | 5 ++++ .../bausystem/commands/CommandNV.java | 5 ++++ .../bausystem/commands/CommandProtect.java | 6 +++++ .../commands/CommandRedstoneTester.java | 5 ++++ .../bausystem/commands/CommandReset.java | 6 +++++ .../bausystem/commands/CommandScript.java | 6 +++++ .../bausystem/commands/CommandScriptVars.java | 8 +++++++ .../bausystem/commands/CommandSkull.java | 2 +- .../bausystem/commands/CommandSpeed.java | 2 +- .../bausystem/commands/CommandTNT.java | 6 +++++ .../bausystem/commands/CommandTestblock.java | 6 +++++ 17 files changed, 82 insertions(+), 26 deletions(-) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandBau.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandBau.java index f8bcc4f..8abce2a 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandBau.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandBau.java @@ -16,10 +16,9 @@ public class CommandBau extends SWCommand { @Register(help = true) public void genericHelp(Player p, String... args) { - if (!permissionCheck(p)) return; - p.sendMessage(BauSystem.PREFIX + "§e/bau togglebuild §8[§7Player§8] §8- §7Editiere die Bau Rechte eines Spielers"); - p.sendMessage(BauSystem.PREFIX + "§e/bau togglewe §8[§7Player§8] §8- §7Editiere die WorldEdit Rechte eines Spielers"); - p.sendMessage(BauSystem.PREFIX + "§e/bau toggleworld §8[§7Player§8] §8- §7Editiere die Werlt Rechte eines Spielers"); + p.sendMessage(BauSystem.PREFIX + "§8/§ebau togglebuild §8[§7Player§8] §8- §7Editiere die Bau Rechte eines Spielers"); + p.sendMessage(BauSystem.PREFIX + "§8/§ebau togglewe §8[§7Player§8] §8- §7Editiere die WorldEdit Rechte eines Spielers"); + p.sendMessage(BauSystem.PREFIX + "§8/§ebau toggleworld §8[§7Player§8] §8- §7Editiere die Werlt Rechte eines Spielers"); } @Register("togglebuild") diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandClear.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandClear.java index 2c397a5..6afc95f 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandClear.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandClear.java @@ -17,9 +17,8 @@ public class CommandClear extends SWCommand { @Register(help = true) public void genericHelp(Player p, String... args) { - p.sendMessage(BauSystem.PREFIX + "§e/clear §8- §7Leere dein Inventar"); - if (!permissionCheck(p)) return; - p.sendMessage(BauSystem.PREFIX + "§e/bau clear §8[§7Player§8] §8- §7Leere ein Spieler Inventar"); + p.sendMessage(BauSystem.PREFIX + "§8/§eclear §8- §7Leere dein Inventar"); + p.sendMessage(BauSystem.PREFIX + "§8/§ebau clear §8[§7Player§8] §8- §7Leere ein Spieler Inventar"); } @Register diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandDebugStick.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandDebugStick.java index 14c711c..c84f4a3 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandDebugStick.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandDebugStick.java @@ -14,6 +14,11 @@ public class CommandDebugStick extends SWCommand { super("debugstick"); } + @Register(help = true) + public void genericHelp(Player p, String... args) { + p.sendMessage(BauSystem.PREFIX + "§8/§edebugstick §8- §7Erhalte einen DebugStick"); + } + @Register public void genericCommand(Player p) { if (Welt.noPermission(p, Permission.build)) { diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandGUI.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandGUI.java index 6260e03..8d4017e 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandGUI.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandGUI.java @@ -44,6 +44,12 @@ public class CommandGUI extends SWCommand implements Listener { Bukkit.getScheduler().runTaskTimerAsynchronously(BauSystem.getPlugin(), LAST_F_PLAYER::clear, 0, 20); } + @Register(help = true) + public void genericHelp(Player p, String... args) { + p.sendMessage(BauSystem.PREFIX + "§8/§egui §8- §7Öffne die GUI"); + p.sendMessage(BauSystem.PREFIX + "§8/§egui item §8- §7Gebe das GUI item"); + } + @Register public void genericCommand(Player p) { openBauGui(p); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandGamemode.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandGamemode.java index 5c2608b..3b657a3 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandGamemode.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandGamemode.java @@ -13,7 +13,6 @@ public class CommandGamemode extends SWCommand { super("gamemode", "gm"); } - @Register(help = true) public void gamemodeHelp(Player p, String... args) { p.sendMessage(BauSystem.PREFIX + "§cUnbekannter Spielmodus"); @@ -21,30 +20,20 @@ public class CommandGamemode extends SWCommand { @Register public void genericCommand(Player p) { - if (!permissionCheck(p)) { - //noinspection UnnecessaryReturnStatement - return; + if (!permissionCheck(p)) return; + if (p.getGameMode() == GameMode.CREATIVE) { + p.setGameMode(GameMode.SPECTATOR); } else { - if (p.getGameMode() == GameMode.CREATIVE) { - p.setGameMode(GameMode.SPECTATOR); - } else { - p.setGameMode(GameMode.CREATIVE); - } + p.setGameMode(GameMode.CREATIVE); } } - @Register public void gamemodeCommand(Player p, GameMode gameMode) { - if (!permissionCheck(p)) { - //noinspection UnnecessaryReturnStatement - return; - } else { - p.setGameMode(gameMode); - } + if (!permissionCheck(p)) return; + p.setGameMode(gameMode); } - private boolean permissionCheck(Player p) { if (!p.getUniqueId().equals(BauSystem.getOwner())) { BauweltMember member = BauweltMember.getBauMember(BauSystem.getOwner(), p.getUniqueId()); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandGills.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandGills.java index 1060008..60186bc 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandGills.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandGills.java @@ -31,6 +31,11 @@ public class CommandGills extends SWCommand { super("watervision", "wv"); } + @Register(help = true) + public void genericHelp(Player p, String... args) { + p.sendMessage(BauSystem.PREFIX + "§8/§ewatervision §8- §7Toggle WaterBreathing"); + } + @Register public void genericCommand(Player p) { toggleGills(p); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandInfo.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandInfo.java index 3a48e27..fd6728d 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandInfo.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandInfo.java @@ -38,6 +38,11 @@ public class CommandInfo extends SWCommand { super("bauinfo"); } + @Register(help = true) + public void genericHelp(Player p, String... args) { + p.sendMessage(BauSystem.PREFIX + "§8/§ebauinfo §8- §7Gebe Informationen über den Bau"); + } + @Register public void genericCommand(Player p) { p.sendMessage(BauSystem.PREFIX + "Besitzer: §e" + SteamwarUser.get(BauSystem.getOwnerID()).getUserName()); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandNV.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandNV.java index da22b91..e56408a 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandNV.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandNV.java @@ -31,6 +31,11 @@ public class CommandNV extends SWCommand { super("nightvision", "nv"); } + @Register(help = true) + public void genericHelp(Player p, String... args) { + p.sendMessage(BauSystem.PREFIX + "§8/§enightvision §8- §7Toggle NightVision"); + } + @Register public void genericCommand(Player p) { toggleNightvision(p); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandProtect.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandProtect.java index 31d9ac2..95dc923 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandProtect.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandProtect.java @@ -37,6 +37,12 @@ public class CommandProtect extends SWCommand { super("protect"); } + @Register(help = true) + public void genericHelp(Player p, String... args) { + p.sendMessage(BauSystem.PREFIX + "§8/§eprotect §8- §7Schütze die Region"); + p.sendMessage(BauSystem.PREFIX + "§8/§eprotect §8[§7Schematic§8] §8- §7Schütze die Region mit einer Schematic"); + } + @Register public void genericTestblockCommand(Player p) { if (!permissionCheck(p)) return; diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandRedstoneTester.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandRedstoneTester.java index 5859ba6..899e804 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandRedstoneTester.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandRedstoneTester.java @@ -34,6 +34,11 @@ public class CommandRedstoneTester extends SWCommand { super("redstonetester", "rt"); } + @Register(help = true) + public void genericHelp(Player p, String... args) { + p.sendMessage(BauSystem.PREFIX + "§8/§eredstonetester §8- §7Gibt den RedstoneTester"); + } + @Register public void genericCommand(Player p) { VersionedRunnable.call(new VersionedRunnable(() -> { diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandReset.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandReset.java index 2ff81f8..19d25fd 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandReset.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandReset.java @@ -37,6 +37,12 @@ public class CommandReset extends SWCommand { super("reset"); } + @Register(help = true) + public void genericHelp(Player p, String... args) { + p.sendMessage(BauSystem.PREFIX + "§8/§ereset §8- §7Setzte die Region zurück"); + p.sendMessage(BauSystem.PREFIX + "§8/§ereset §8[§7Schematic§8] §8- §7Setzte die Region mit einer Schematic zurück"); + } + @Register public void genericResetCommand(Player p) { if (!permissionCheck(p)) return; diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandScript.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandScript.java index f54b373..9e6caa1 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandScript.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandScript.java @@ -21,6 +21,7 @@ package de.steamwar.bausystem.commands; +import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.SWUtils; import de.steamwar.command.SWCommand; import org.bukkit.Material; @@ -81,6 +82,11 @@ public class CommandScript extends SWCommand { BOOK.setItemMeta(bookMeta); } + @Register(help = true) + public void genericHelp(Player p, String... args) { + p.sendMessage(BauSystem.PREFIX + "§8/§escript §8- §7Gibt das Script Buch"); + } + @Register public void giveCommand(Player p) { SWUtils.giveItemToPlayer(p, BOOK); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandScriptVars.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandScriptVars.java index 45c2d79..8ac0eff 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandScriptVars.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandScriptVars.java @@ -15,6 +15,14 @@ public class CommandScriptVars extends SWCommand { super("scripvars"); } + @Register(help = true) + public void genericHelp(Player p, String... args) { + p.sendMessage(BauSystem.PREFIX + "§8/§escriptvars §8- §7Zähle alle globalen Variablen auf"); + p.sendMessage(BauSystem.PREFIX + "§8/§escriptvars §8[§7Variable§8] §8- §7Gebe den Wert der Variable zurück"); + p.sendMessage(BauSystem.PREFIX + "§8/§escriptvars §8[§7Variable§8] §8[§7Value§8] §8- §7Setzte eine Variable auf einen Wert"); + p.sendMessage(BauSystem.PREFIX + "§8/§escriptvars §8[§7Variable§8] §8<§7remove§8|§7delete§8|§7clear§8> §8- §7Lösche eine Variable"); + } + @Register public void genericCommand(Player p) { Map globalVariables = ScriptListener.GLOBAL_VARIABLES.get(p); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandSkull.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandSkull.java index 470e2b6..e971404 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandSkull.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandSkull.java @@ -35,7 +35,7 @@ public class CommandSkull extends SWCommand { @Register(help = true) public void genericHelp(Player p, String... args) { - p.sendMessage(BauSystem.PREFIX + "§8/§eskull §8[§eSpieler§8]"); + p.sendMessage(BauSystem.PREFIX + "§8/§eskull §8[§eSpieler§8] §8- §7Gibt einen SpielerKopf"); } @Register diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandSpeed.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandSpeed.java index 192274c..a31fa3b 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandSpeed.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandSpeed.java @@ -36,7 +36,7 @@ public class CommandSpeed extends SWCommand { @Register(help = true) public void genericHelp(Player p, String... args) { - p.sendMessage(BauSystem.PREFIX + "/speed [Geschwindigkeit]"); + p.sendMessage(BauSystem.PREFIX + "§8/§espeed §8[§7Geschwindigkeit§8] §8- §7Setzte deine Flug- und Gehgeschwindigkeit"); } @Register({"default"}) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTNT.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTNT.java index bda7dfc..71ded24 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTNT.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTNT.java @@ -60,6 +60,12 @@ public class CommandTNT extends SWCommand implements Listener { Bukkit.getPluginManager().registerEvents(this, BauSystem.getPlugin()); } + @Register(help = true) + public void genericHelp(Player p, String... args) { + p.sendMessage(BauSystem.PREFIX + "§8/§etnt §8- §7Ändere das TNT verhalten"); + p.sendMessage(BauSystem.PREFIX + "§8/§etnt §8[§7Mode§8] §8- §7Setzte das TNT verhalten auf einen Modus"); + } + @Register public void toggleCommand(Player p) { if (!permissionCheck(p)) return; diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTestblock.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTestblock.java index 17bcfc3..e00815b 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTestblock.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTestblock.java @@ -37,6 +37,12 @@ public class CommandTestblock extends SWCommand { super("testblock", "tb"); } + @Register(help = true) + public void genericHelp(Player p, String... args) { + p.sendMessage(BauSystem.PREFIX + "§8/§etestblock §8- §7Setzte den Testblock zurück"); + p.sendMessage(BauSystem.PREFIX + "§8/§etestblock §8[§7Schematic§8] §8- §7Setzte den Testblock mit einer Schematic zurück"); + } + @Register public void genericTestblockCommand(Player p) { if (!permissionCheck(p)) return; From 5d37594efc10412c536b78a2b5408475876ef3be Mon Sep 17 00:00:00 2001 From: Zeanon Date: Thu, 1 Apr 2021 22:27:06 +0200 Subject: [PATCH 32/51] update for CommandTime --- .../src/de/steamwar/bausystem/BauSystem.java | 4 +- .../bausystem/commands/CommandTPSLimiter.java | 6 +- .../bausystem/commands/CommandTime.java | 124 ++++++++++-------- 3 files changed, 77 insertions(+), 57 deletions(-) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java b/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java index a19fef0..4e2b153 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java @@ -66,9 +66,8 @@ public class BauSystem extends JavaPlugin implements Listener { Mapper.init(); try { - CommandRemover.removeAll("tp", "time"); + CommandRemover.removeAll("tp"); CommandInjector.injectCommand(new CommandTeleport()); - CommandInjector.injectCommand(new CommandTime()); } catch (Exception e) { getLogger().log(Level.SEVERE, "Failed to replace commands", e); Bukkit.shutdown(); @@ -84,6 +83,7 @@ public class BauSystem extends JavaPlugin implements Listener { new CommandBau(); new CommandGamemode(); new CommandClear(); + new CommandTime(); getCommand("fire").setExecutor(new CommandFire()); getCommand("freeze").setExecutor(new CommandFreeze()); new CommandTestblock(); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTPSLimiter.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTPSLimiter.java index 62ccaba..4e36c75 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTPSLimiter.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTPSLimiter.java @@ -52,12 +52,12 @@ public class CommandTPSLimiter extends SWCommand { private BukkitTask tpsLimiter = null; - private List arguments = new ArrayList<>(Arrays.asList("0,5", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20")); + private List tabCompletions = new ArrayList<>(Arrays.asList("0,5", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20")); public CommandTPSLimiter() { super("tpslimit"); if (TPSUtils.isWarpAllowed()) { - arguments.addAll(Arrays.asList("21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31", "32", "33", "34", "35", "36", "37", "38", "39", "40")); + tabCompletions.addAll(Arrays.asList("21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31", "32", "33", "34", "35", "36", "37", "38", "39", "40")); } } @@ -95,7 +95,7 @@ public class CommandTPSLimiter extends SWCommand { } catch (NumberFormatException e) { return 0D; } - }, s -> arguments); + }, s -> tabCompletions); } private boolean permissionCheck(Player player) { diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTime.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTime.java index 425658f..fd455e7 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTime.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTime.java @@ -1,67 +1,87 @@ -/* - 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 . -*/ - package de.steamwar.bausystem.commands; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.Permission; import de.steamwar.bausystem.world.Welt; +import de.steamwar.command.SWCommand; +import de.steamwar.command.SWCommandUtils; +import de.steamwar.command.TypeMapper; +import java.util.Arrays; +import java.util.List; import org.bukkit.Bukkit; -import org.bukkit.command.CommandSender; -import org.bukkit.command.defaults.BukkitCommand; import org.bukkit.entity.Player; -public class CommandTime extends BukkitCommand { + +public class CommandTime extends SWCommand { + + private static List tabCompletions = Arrays.asList("0", "6000", "12000", "18000"); + public CommandTime() { super("time"); - this.description = "Ändert die Zeit auf der Spielwelt"; - this.usageMessage = "/time "; } - public boolean execute(CommandSender sender, String currentAlias, String[] args) { - if (!(sender instanceof Player)) { - return false; - } else if (args.length == 0) { - sender.sendMessage(BauSystem.PREFIX + this.usageMessage); - return false; - } - Player player = (Player) sender; - if (Welt.noPermission(player, Permission.world)) { - player.sendMessage(BauSystem.PREFIX + "§cDu darfst hier nicht die Zeit ändern"); - return false; - } - - int time; - try { - time = Integer.valueOf(args[0]); - } catch (NumberFormatException e) { - player.sendMessage(BauSystem.PREFIX + "§cBitte gib eine Zahl zwischen 0 und 24000 an"); - return false; - } - if (time < 0 || time > 24000) { - player.sendMessage(BauSystem.PREFIX + "§cBitte gib eine Zahl zwischen 0 und 24000 an"); - return false; - } - - Bukkit.getWorlds().get(0).setTime(time); - return false; + @Register(help = true) + public void genericHelp(Player p, String... args) { + p.sendMessage(BauSystem.PREFIX + "/time "); } -} + + @Register + public void genericCommand(Player p, int time) { + if (Welt.noPermission(p, Permission.world)) { + p.sendMessage(BauSystem.PREFIX + "§cDu darfst hier nicht die Zeit ändern"); + return; + } else { + if (time < 0 || time > 24000) { + p.sendMessage(BauSystem.PREFIX + "§cBitte gib eine Zahl zwischen 0 und 24000 an"); + return; + } else { + Bukkit.getWorlds().get(0).setTime(time); + } + } + } + + @Register + public void genericCommand(Player p, Time time) { + if (Welt.noPermission(p, Permission.world)) { + p.sendMessage(BauSystem.PREFIX + "§cDu darfst hier nicht die Zeit ändern"); + return; + } else { + Bukkit.getWorlds().get(0).setTime(time.getValue()); + } + } + + + @ClassMapper(value = int.class, local = true) + public TypeMapper doubleTypeMapper() { + return SWCommandUtils.createMapper(s -> { + try { + return Integer.parseInt(s); + } catch (NumberFormatException e) { + return 0; + } + }, s -> tabCompletions); + } + + public enum Time { + NIGHT(18000), + DAY(6000), + DAWN(0), + SUNSET(12000), + NACHT(18000), + TAG(6000), + MORGEN(0), + ABEND(12000); + + private int value; + + private Time(int value) { + this.value = value; + } + + public int getValue() { + return value; + } + } +} \ No newline at end of file From cf4eaf042cf2ea3d28e08e398a9d1c2ad785e1c7 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Thu, 1 Apr 2021 22:30:25 +0200 Subject: [PATCH 33/51] Add help command to various Commands --- .../bausystem/commands/CommandTPSLimiter.java | 2 +- .../bausystem/commands/CommandTime.java | 21 +++++++------------ 2 files changed, 8 insertions(+), 15 deletions(-) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTPSLimiter.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTPSLimiter.java index 4e36c75..9e8ce9c 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTPSLimiter.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTPSLimiter.java @@ -64,7 +64,7 @@ public class CommandTPSLimiter extends SWCommand { @Register(help = true) public void genericHelp(Player p, String... args) { p.sendMessage(BauSystem.PREFIX + "Jetziges TPS limit: " + currentTPSLimit); - p.sendMessage(BauSystem.PREFIX + "Ändere das TPS limit mit: §8/§etpslimit §8[§7TPS§8|§edefault§8]"); + p.sendMessage(BauSystem.PREFIX + "§8/§etpslimit §8[§7TPS§8|§edefault§8] §8- §7Setzte die TPS auf dem Bau"); } @Register({"default"}) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTime.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTime.java index fd455e7..31088e9 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTime.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTime.java @@ -11,20 +11,17 @@ import java.util.List; import org.bukkit.Bukkit; import org.bukkit.entity.Player; - public class CommandTime extends SWCommand { private static List tabCompletions = Arrays.asList("0", "6000", "12000", "18000"); - public CommandTime() { super("time"); } - @Register(help = true) public void genericHelp(Player p, String... args) { - p.sendMessage(BauSystem.PREFIX + "/time "); + p.sendMessage(BauSystem.PREFIX + "§8/§etime §8<§7Zeit 0=Morgen§8, §76000=Mittag§8, §718000=Mitternacht§8> §8- §7Setzt die Zeit auf dem Bau"); } @Register @@ -32,14 +29,12 @@ public class CommandTime extends SWCommand { if (Welt.noPermission(p, Permission.world)) { p.sendMessage(BauSystem.PREFIX + "§cDu darfst hier nicht die Zeit ändern"); return; - } else { - if (time < 0 || time > 24000) { - p.sendMessage(BauSystem.PREFIX + "§cBitte gib eine Zahl zwischen 0 und 24000 an"); - return; - } else { - Bukkit.getWorlds().get(0).setTime(time); - } } + if (time < 0 || time > 24000) { + p.sendMessage(BauSystem.PREFIX + "§cBitte gib eine Zahl zwischen 0 und 24000 an"); + return; + } + Bukkit.getWorlds().get(0).setTime(time); } @Register @@ -47,12 +42,10 @@ public class CommandTime extends SWCommand { if (Welt.noPermission(p, Permission.world)) { p.sendMessage(BauSystem.PREFIX + "§cDu darfst hier nicht die Zeit ändern"); return; - } else { - Bukkit.getWorlds().get(0).setTime(time.getValue()); } + Bukkit.getWorlds().get(0).setTime(time.getValue()); } - @ClassMapper(value = int.class, local = true) public TypeMapper doubleTypeMapper() { return SWCommandUtils.createMapper(s -> { From e025a4e0c15aee09c547f9cf2b585ba0bb57a07e Mon Sep 17 00:00:00 2001 From: Zeanon Date: Thu, 1 Apr 2021 22:31:03 +0200 Subject: [PATCH 34/51] update for CommandTeleport --- .../src/de/steamwar/bausystem/BauSystem.java | 9 +-- .../bausystem/commands/CommandTeleport.java | 65 +++---------------- 2 files changed, 10 insertions(+), 64 deletions(-) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java b/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java index 4e2b153..3735659 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java @@ -65,14 +65,6 @@ public class BauSystem extends JavaPlugin implements Listener { Mapper.init(); - try { - CommandRemover.removeAll("tp"); - CommandInjector.injectCommand(new CommandTeleport()); - } catch (Exception e) { - getLogger().log(Level.SEVERE, "Failed to replace commands", e); - Bukkit.shutdown(); - return; - } new CommandTrace(); new CommandTPSLimiter(); @@ -84,6 +76,7 @@ public class BauSystem extends JavaPlugin implements Listener { new CommandGamemode(); new CommandClear(); new CommandTime(); + new CommandTeleport(); getCommand("fire").setExecutor(new CommandFire()); getCommand("freeze").setExecutor(new CommandFreeze()); new CommandTestblock(); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTeleport.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTeleport.java index 27f37e9..93848ab 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTeleport.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTeleport.java @@ -1,81 +1,34 @@ -/* - 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 . -*/ - package de.steamwar.bausystem.commands; import de.steamwar.bausystem.BauSystem; +import de.steamwar.command.SWCommand; import de.steamwar.sql.BauweltMember; -import org.apache.commons.lang.Validate; -import org.bukkit.Bukkit; -import org.bukkit.command.CommandSender; -import org.bukkit.command.defaults.BukkitCommand; import org.bukkit.entity.Player; import org.bukkit.event.player.PlayerTeleportEvent; -import java.util.List; -public class CommandTeleport extends BukkitCommand { +public class CommandTeleport extends SWCommand { + public CommandTeleport() { - super("tp"); - description = "Teleportiert dich zu einem genannten Spieler."; - usageMessage = "/tp [Spieler]"; + super("teleport"); } - public boolean execute(CommandSender sender, String currentAlias, String[] args) { - if (!(sender instanceof Player)) - return false; - else if (args.length != 1) { - sender.sendMessage(BauSystem.PREFIX + usageMessage); - return false; - } - - Player p = (Player) sender; - - Player target = Bukkit.getPlayerExact(args[0]); - - if (target == null) { - p.sendMessage(BauSystem.PREFIX + "§cDieser Spieler ist derzeit offline."); - return true; - } + @Register + public void genericCommand(Player p, Player target) { if (p.getUniqueId().equals(target.getUniqueId())) { p.sendMessage(BauSystem.PREFIX + "§cSei eins mit dir selbst!"); - return false; + return; } if (!BauSystem.getOwner().equals(p.getUniqueId())) { BauweltMember member = BauweltMember.getBauMember(BauSystem.getOwner(), p.getUniqueId()); if (member == null || !member.isBuild()) { p.sendMessage(BauSystem.PREFIX + "§cDu darfst dich auf dieser Welt nicht teleportieren!"); - return false; + return; } } p.teleport(target, PlayerTeleportEvent.TeleportCause.COMMAND); - return true; } - - public List tabComplete(CommandSender sender, String alias, String[] args) throws IllegalArgumentException { - Validate.notNull(sender, "Sender cannot be null"); - Validate.notNull(args, "Arguments cannot be null"); - Validate.notNull(alias, "Alias cannot be null"); - - return super.tabComplete(sender, alias, args); - } -} +} \ No newline at end of file From 22722c7e1a55505888235be1985b056ee75a77e9 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Thu, 1 Apr 2021 22:43:44 +0200 Subject: [PATCH 35/51] Add help command to various Commands --- .../src/de/steamwar/bausystem/BauSystem.java | 5 +- .../bausystem/commands/CommandBau.java | 6 +- .../bausystem/commands/CommandClear.java | 4 +- .../bausystem/commands/CommandDebugStick.java | 2 +- .../bausystem/commands/CommandFire.java | 54 +++++++++--- .../bausystem/commands/CommandFreeze.java | 56 ++++++++++--- .../bausystem/commands/CommandGUI.java | 4 +- .../bausystem/commands/CommandGamemode.java | 2 +- .../bausystem/commands/CommandGills.java | 2 +- .../bausystem/commands/CommandInfo.java | 2 +- .../bausystem/commands/CommandInjector.java | 43 ---------- .../bausystem/commands/CommandNV.java | 2 +- .../bausystem/commands/CommandProtect.java | 4 +- .../commands/CommandRedstoneTester.java | 2 +- .../bausystem/commands/CommandReset.java | 4 +- .../bausystem/commands/CommandScript.java | 2 +- .../bausystem/commands/CommandScriptVars.java | 8 +- .../bausystem/commands/CommandSkull.java | 2 +- .../bausystem/commands/CommandSpeed.java | 2 +- .../bausystem/commands/CommandTNT.java | 16 ++-- .../bausystem/commands/CommandTPSLimiter.java | 2 +- .../bausystem/commands/CommandTeleport.java | 4 + .../bausystem/commands/CommandTestblock.java | 4 +- .../bausystem/commands/CommandTime.java | 2 +- .../commands/RegionToggleCommand.java | 82 ------------------- BauSystem_Main/src/plugin.yml | 3 - 26 files changed, 129 insertions(+), 190 deletions(-) delete mode 100644 BauSystem_Main/src/de/steamwar/bausystem/commands/CommandInjector.java delete mode 100644 BauSystem_Main/src/de/steamwar/bausystem/commands/RegionToggleCommand.java diff --git a/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java b/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java index 3735659..f1dc6b4 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java @@ -65,7 +65,6 @@ public class BauSystem extends JavaPlugin implements Listener { Mapper.init(); - new CommandTrace(); new CommandTPSLimiter(); new CommandNV(); @@ -77,8 +76,8 @@ public class BauSystem extends JavaPlugin implements Listener { new CommandClear(); new CommandTime(); new CommandTeleport(); - getCommand("fire").setExecutor(new CommandFire()); - getCommand("freeze").setExecutor(new CommandFreeze()); + new CommandFire(); + new CommandFreeze(); new CommandTestblock(); new CommandInfo(); new CommandProtect(); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandBau.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandBau.java index 8abce2a..ee945f6 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandBau.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandBau.java @@ -16,9 +16,9 @@ public class CommandBau extends SWCommand { @Register(help = true) public void genericHelp(Player p, String... args) { - p.sendMessage(BauSystem.PREFIX + "§8/§ebau togglebuild §8[§7Player§8] §8- §7Editiere die Bau Rechte eines Spielers"); - p.sendMessage(BauSystem.PREFIX + "§8/§ebau togglewe §8[§7Player§8] §8- §7Editiere die WorldEdit Rechte eines Spielers"); - p.sendMessage(BauSystem.PREFIX + "§8/§ebau toggleworld §8[§7Player§8] §8- §7Editiere die Werlt Rechte eines Spielers"); + p.sendMessage("§8/§ebau togglebuild §8[§7Player§8] §8- §7Editiere die Bau Rechte eines Spielers"); + p.sendMessage("§8/§ebau togglewe §8[§7Player§8] §8- §7Editiere die WorldEdit Rechte eines Spielers"); + p.sendMessage("§8/§ebau toggleworld §8[§7Player§8] §8- §7Editiere die Werlt Rechte eines Spielers"); } @Register("togglebuild") diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandClear.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandClear.java index 6afc95f..ec72043 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandClear.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandClear.java @@ -17,8 +17,8 @@ public class CommandClear extends SWCommand { @Register(help = true) public void genericHelp(Player p, String... args) { - p.sendMessage(BauSystem.PREFIX + "§8/§eclear §8- §7Leere dein Inventar"); - p.sendMessage(BauSystem.PREFIX + "§8/§ebau clear §8[§7Player§8] §8- §7Leere ein Spieler Inventar"); + p.sendMessage("§8/§eclear §8- §7Leere dein Inventar"); + p.sendMessage("§8/§ebau clear §8[§7Player§8] §8- §7Leere ein Spieler Inventar"); } @Register diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandDebugStick.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandDebugStick.java index c84f4a3..97877ca 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandDebugStick.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandDebugStick.java @@ -16,7 +16,7 @@ public class CommandDebugStick extends SWCommand { @Register(help = true) public void genericHelp(Player p, String... args) { - p.sendMessage(BauSystem.PREFIX + "§8/§edebugstick §8- §7Erhalte einen DebugStick"); + p.sendMessage("§8/§edebugstick §8- §7Erhalte einen DebugStick"); } @Register diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandFire.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandFire.java index a1ea0e3..0c9d5c2 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandFire.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandFire.java @@ -19,34 +19,66 @@ package de.steamwar.bausystem.commands; +import de.steamwar.bausystem.BauSystem; +import de.steamwar.bausystem.Permission; import de.steamwar.bausystem.world.Region; +import de.steamwar.bausystem.world.Welt; +import de.steamwar.command.SWCommand; +import org.bukkit.Bukkit; +import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; import org.bukkit.event.block.BlockBurnEvent; import org.bukkit.event.block.BlockSpreadEvent; -public class CommandFire extends RegionToggleCommand { +public class CommandFire extends SWCommand implements Listener { - @Override - String getNoPermMessage() { + public CommandFire() { + super("fire"); + Bukkit.getPluginManager().registerEvents(this, BauSystem.getPlugin()); + } + + @Register(help = true) + public void genericHelp(Player p, String... args) { + p.sendMessage("§8/§efire §8- §7Toggle Feuerschaden"); + } + + @Register + public void toggleCommand(Player p) { + if (!permissionCheck(p)) return; + Region region = Region.getRegion(p.getLocation()); + if (toggle(region)) { + RegionUtils.actionBar(region, getEnableMessage()); + } else { + RegionUtils.actionBar(region, getDisableMessage()); + } + } + + private String getNoPermMessage() { return "§cDu darfst hier nicht Feuerschaden (de-)aktivieren"; } - @Override - String getEnableMessage() { - return "§cFeuerschaden deaktiviert"; + private String getEnableMessage() { + return "§cRegions Feuerschaden deaktiviert"; } - @Override - String getDisableMessage() { - return "§aFeuerschaden aktiviert"; + private String getDisableMessage() { + return "§aRegions Feuerschaden aktiviert"; } - @Override - boolean toggle(Region region) { + private boolean toggle(Region region) { region.setFire(!region.isFire()); return region.isFire(); } + private boolean permissionCheck(Player player) { + if (Welt.noPermission(player, Permission.world)) { + player.sendMessage(BauSystem.PREFIX + getNoPermMessage()); + return false; + } + return true; + } + @EventHandler public void onFireDamage(BlockBurnEvent e) { if (Region.getRegion(e.getBlock().getLocation()).isFire()) e.setCancelled(true); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandFreeze.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandFreeze.java index 47953a3..2baeb2a 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandFreeze.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandFreeze.java @@ -20,38 +20,70 @@ package de.steamwar.bausystem.commands; import de.steamwar.bausystem.BauSystem; +import de.steamwar.bausystem.Permission; import de.steamwar.bausystem.world.Region; +import de.steamwar.bausystem.world.Welt; +import de.steamwar.command.SWCommand; import de.steamwar.core.Core; import org.bukkit.Bukkit; import org.bukkit.Material; import org.bukkit.entity.EntityType; +import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; import org.bukkit.event.block.*; import org.bukkit.event.entity.EntityChangeBlockEvent; import org.bukkit.event.entity.EntitySpawnEvent; import org.bukkit.event.inventory.InventoryMoveItemEvent; -public class CommandFreeze extends RegionToggleCommand { +public class CommandFreeze extends SWCommand implements Listener { - @Override - String getNoPermMessage() { + public CommandFreeze() { + super("freeze", "stoplag"); + Bukkit.getPluginManager().registerEvents(this, BauSystem.getPlugin()); + } + + @Register(help = true) + public void genericHelp(Player p, String... args) { + p.sendMessage("§8/§efreeze §8- §7Toggle Freeze"); + } + + @Register + public void toggleCommand(Player p) { + if (!permissionCheck(p)) return; + Region region = Region.getRegion(p.getLocation()); + if (toggle(region)) { + RegionUtils.actionBar(region, getEnableMessage()); + } else { + RegionUtils.actionBar(region, getDisableMessage()); + } + } + + private String getNoPermMessage() { return "§cDu darfst diese Welt nicht einfrieren"; } - @Override - String getEnableMessage(){ - return "§cWelt eingefroren"; - } - @Override - String getDisableMessage(){ - return "§aWelt aufgetaut"; + + private String getEnableMessage(){ + return "§cRegion eingefroren"; } - @Override - boolean toggle(Region region) { + private String getDisableMessage(){ + return "§aRegion aufgetaut"; + } + + private boolean toggle(Region region) { region.setFreeze(!region.isFreeze()); return region.isFreeze(); } + private boolean permissionCheck(Player player) { + if (Welt.noPermission(player, Permission.world)) { + player.sendMessage(BauSystem.PREFIX + getNoPermMessage()); + return false; + } + return true; + } + @EventHandler public void onEntitySpawn(EntitySpawnEvent e) { if (!Region.getRegion(e.getLocation()).isFreeze()) return; diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandGUI.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandGUI.java index 8d4017e..a51e629 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandGUI.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandGUI.java @@ -46,8 +46,8 @@ public class CommandGUI extends SWCommand implements Listener { @Register(help = true) public void genericHelp(Player p, String... args) { - p.sendMessage(BauSystem.PREFIX + "§8/§egui §8- §7Öffne die GUI"); - p.sendMessage(BauSystem.PREFIX + "§8/§egui item §8- §7Gebe das GUI item"); + p.sendMessage("§8/§egui §8- §7Öffne die GUI"); + p.sendMessage("§8/§egui item §8- §7Gebe das GUI item"); } @Register diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandGamemode.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandGamemode.java index 3b657a3..a4b2cfc 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandGamemode.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandGamemode.java @@ -15,7 +15,7 @@ public class CommandGamemode extends SWCommand { @Register(help = true) public void gamemodeHelp(Player p, String... args) { - p.sendMessage(BauSystem.PREFIX + "§cUnbekannter Spielmodus"); + p.sendMessage("§cUnbekannter Spielmodus"); } @Register diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandGills.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandGills.java index 60186bc..051ea10 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandGills.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandGills.java @@ -33,7 +33,7 @@ public class CommandGills extends SWCommand { @Register(help = true) public void genericHelp(Player p, String... args) { - p.sendMessage(BauSystem.PREFIX + "§8/§ewatervision §8- §7Toggle WaterBreathing"); + p.sendMessage("§8/§ewatervision §8- §7Toggle WaterBreathing"); } @Register diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandInfo.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandInfo.java index fd6728d..afcc68f 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandInfo.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandInfo.java @@ -40,7 +40,7 @@ public class CommandInfo extends SWCommand { @Register(help = true) public void genericHelp(Player p, String... args) { - p.sendMessage(BauSystem.PREFIX + "§8/§ebauinfo §8- §7Gebe Informationen über den Bau"); + p.sendMessage("§8/§ebauinfo §8- §7Gebe Informationen über den Bau"); } @Register diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandInjector.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandInjector.java deleted file mode 100644 index b1b322e..0000000 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandInjector.java +++ /dev/null @@ -1,43 +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 . -*/ - -package de.steamwar.bausystem.commands; - -import org.bukkit.Bukkit; -import org.bukkit.command.Command; -import org.bukkit.command.SimpleCommandMap; - -import java.lang.reflect.Field; - -public class CommandInjector { - - private CommandInjector() { - } - - private static final String PACKAGE_NAME = Bukkit.getServer().getClass().getPackage().getName(); - private static final String VERSION = PACKAGE_NAME.substring(PACKAGE_NAME.lastIndexOf('.') + 1); - - public static void injectCommand(Command cmd) throws Exception { - Class serverClass = Class.forName("org.bukkit.craftbukkit." + VERSION + ".CraftServer"); - Field f1 = serverClass.getDeclaredField("commandMap"); - f1.setAccessible(true); - SimpleCommandMap commandMap = (SimpleCommandMap) f1.get(Bukkit.getServer()); - commandMap.register("BauSystem", cmd); - } -} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandNV.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandNV.java index e56408a..7b232a2 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandNV.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandNV.java @@ -33,7 +33,7 @@ public class CommandNV extends SWCommand { @Register(help = true) public void genericHelp(Player p, String... args) { - p.sendMessage(BauSystem.PREFIX + "§8/§enightvision §8- §7Toggle NightVision"); + p.sendMessage("§8/§enightvision §8- §7Toggle NightVision"); } @Register diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandProtect.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandProtect.java index 95dc923..fed21f5 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandProtect.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandProtect.java @@ -39,8 +39,8 @@ public class CommandProtect extends SWCommand { @Register(help = true) public void genericHelp(Player p, String... args) { - p.sendMessage(BauSystem.PREFIX + "§8/§eprotect §8- §7Schütze die Region"); - p.sendMessage(BauSystem.PREFIX + "§8/§eprotect §8[§7Schematic§8] §8- §7Schütze die Region mit einer Schematic"); + p.sendMessage("§8/§eprotect §8- §7Schütze die Region"); + p.sendMessage("§8/§eprotect §8[§7Schematic§8] §8- §7Schütze die Region mit einer Schematic"); } @Register diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandRedstoneTester.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandRedstoneTester.java index 899e804..3038690 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandRedstoneTester.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandRedstoneTester.java @@ -36,7 +36,7 @@ public class CommandRedstoneTester extends SWCommand { @Register(help = true) public void genericHelp(Player p, String... args) { - p.sendMessage(BauSystem.PREFIX + "§8/§eredstonetester §8- §7Gibt den RedstoneTester"); + p.sendMessage("§8/§eredstonetester §8- §7Gibt den RedstoneTester"); } @Register diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandReset.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandReset.java index 19d25fd..5c7b31b 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandReset.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandReset.java @@ -39,8 +39,8 @@ public class CommandReset extends SWCommand { @Register(help = true) public void genericHelp(Player p, String... args) { - p.sendMessage(BauSystem.PREFIX + "§8/§ereset §8- §7Setzte die Region zurück"); - p.sendMessage(BauSystem.PREFIX + "§8/§ereset §8[§7Schematic§8] §8- §7Setzte die Region mit einer Schematic zurück"); + p.sendMessage("§8/§ereset §8- §7Setzte die Region zurück"); + p.sendMessage("§8/§ereset §8[§7Schematic§8] §8- §7Setzte die Region mit einer Schematic zurück"); } @Register diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandScript.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandScript.java index 9e6caa1..c5b9bcc 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandScript.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandScript.java @@ -84,7 +84,7 @@ public class CommandScript extends SWCommand { @Register(help = true) public void genericHelp(Player p, String... args) { - p.sendMessage(BauSystem.PREFIX + "§8/§escript §8- §7Gibt das Script Buch"); + p.sendMessage("§8/§escript §8- §7Gibt das Script Buch"); } @Register diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandScriptVars.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandScriptVars.java index 8ac0eff..419b320 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandScriptVars.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandScriptVars.java @@ -17,10 +17,10 @@ public class CommandScriptVars extends SWCommand { @Register(help = true) public void genericHelp(Player p, String... args) { - p.sendMessage(BauSystem.PREFIX + "§8/§escriptvars §8- §7Zähle alle globalen Variablen auf"); - p.sendMessage(BauSystem.PREFIX + "§8/§escriptvars §8[§7Variable§8] §8- §7Gebe den Wert der Variable zurück"); - p.sendMessage(BauSystem.PREFIX + "§8/§escriptvars §8[§7Variable§8] §8[§7Value§8] §8- §7Setzte eine Variable auf einen Wert"); - p.sendMessage(BauSystem.PREFIX + "§8/§escriptvars §8[§7Variable§8] §8<§7remove§8|§7delete§8|§7clear§8> §8- §7Lösche eine Variable"); + p.sendMessage("§8/§escriptvars §8- §7Zähle alle globalen Variablen auf"); + p.sendMessage("§8/§escriptvars §8[§7Variable§8] §8- §7Gebe den Wert der Variable zurück"); + p.sendMessage("§8/§escriptvars §8[§7Variable§8] §8[§7Value§8] §8- §7Setzte eine Variable auf einen Wert"); + p.sendMessage("§8/§escriptvars §8[§7Variable§8] §8<§7remove§8|§7delete§8|§7clear§8> §8- §7Lösche eine Variable"); } @Register diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandSkull.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandSkull.java index e971404..821c12b 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandSkull.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandSkull.java @@ -35,7 +35,7 @@ public class CommandSkull extends SWCommand { @Register(help = true) public void genericHelp(Player p, String... args) { - p.sendMessage(BauSystem.PREFIX + "§8/§eskull §8[§eSpieler§8] §8- §7Gibt einen SpielerKopf"); + p.sendMessage("§8/§eskull §8[§eSpieler§8] §8- §7Gibt einen SpielerKopf"); } @Register diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandSpeed.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandSpeed.java index a31fa3b..195cefc 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandSpeed.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandSpeed.java @@ -36,7 +36,7 @@ public class CommandSpeed extends SWCommand { @Register(help = true) public void genericHelp(Player p, String... args) { - p.sendMessage(BauSystem.PREFIX + "§8/§espeed §8[§7Geschwindigkeit§8] §8- §7Setzte deine Flug- und Gehgeschwindigkeit"); + p.sendMessage("§8/§espeed §8[§7Geschwindigkeit§8] §8- §7Setzte deine Flug- und Gehgeschwindigkeit"); } @Register({"default"}) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTNT.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTNT.java index 71ded24..c96ff53 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTNT.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTNT.java @@ -62,8 +62,8 @@ public class CommandTNT extends SWCommand implements Listener { @Register(help = true) public void genericHelp(Player p, String... args) { - p.sendMessage(BauSystem.PREFIX + "§8/§etnt §8- §7Ändere das TNT verhalten"); - p.sendMessage(BauSystem.PREFIX + "§8/§etnt §8[§7Mode§8] §8- §7Setzte das TNT verhalten auf einen Modus"); + p.sendMessage("§8/§etnt §8- §7Ändere das TNT verhalten"); + p.sendMessage("§8/§etnt §8[§7Mode§8] §8- §7Setzte das TNT verhalten auf einen Modus"); } @Register @@ -132,22 +132,22 @@ public class CommandTNT extends SWCommand implements Listener { private void tntToggle(Region region, TNTMode requestedMode, String requestedMessage) { if (requestedMode != null && region.hasTestblock()) { region.setTntMode(requestedMode); - RegionToggleCommand.actionBar(region, requestedMessage); + RegionUtils.actionBar(region, requestedMessage); return; } switch (region.getTntMode()) { case ON: case ONLY_TB: region.setTntMode(TNTMode.OFF); - RegionToggleCommand.actionBar(region, getDisableMessage()); + RegionUtils.actionBar(region, getDisableMessage()); break; case OFF: if (Region.buildAreaEnabled() && region.hasTestblock()) { region.setTntMode(TNTMode.ONLY_TB); - RegionToggleCommand.actionBar(region, getTestblockEnableMessage()); + RegionUtils.actionBar(region, getTestblockEnableMessage()); } else { region.setTntMode(TNTMode.ON); - RegionToggleCommand.actionBar(region, getEnableMessage()); + RegionUtils.actionBar(region, getEnableMessage()); } break; } @@ -159,11 +159,11 @@ public class CommandTNT extends SWCommand implements Listener { Region region = Region.getRegion(block.getLocation()); if (region.getTntMode() == TNTMode.ON) return false; if (region.hasBuildRegion() && region.inBuildRegion(block.getLocation())) { - RegionToggleCommand.actionBar(region, "§cEine Explosion hätte Blöcke im Baubereich zerstört"); + RegionUtils.actionBar(region, "§cEine Explosion hätte Blöcke im Baubereich zerstört"); return true; } if (region.hasBuildRegion() && region.inBuildRegionExtension(block.getLocation())) { - RegionToggleCommand.actionBar(region, "§cEine Explosion hätte Blöcke im Ausfahrbereich zerstört"); + RegionUtils.actionBar(region, "§cEine Explosion hätte Blöcke im Ausfahrbereich zerstört"); return true; } return region.getTntMode() == TNTMode.OFF; diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTPSLimiter.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTPSLimiter.java index 9e8ce9c..4169f1f 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTPSLimiter.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTPSLimiter.java @@ -64,7 +64,7 @@ public class CommandTPSLimiter extends SWCommand { @Register(help = true) public void genericHelp(Player p, String... args) { p.sendMessage(BauSystem.PREFIX + "Jetziges TPS limit: " + currentTPSLimit); - p.sendMessage(BauSystem.PREFIX + "§8/§etpslimit §8[§7TPS§8|§edefault§8] §8- §7Setzte die TPS auf dem Bau"); + p.sendMessage("§8/§etpslimit §8[§7TPS§8|§edefault§8] §8- §7Setzte die TPS auf dem Bau"); } @Register({"default"}) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTeleport.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTeleport.java index 93848ab..ce6debd 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTeleport.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTeleport.java @@ -13,6 +13,10 @@ public class CommandTeleport extends SWCommand { super("teleport"); } + @Register(help = true) + public void genericHelp(Player p, String... args) { + p.sendMessage("§8/§etp §8[§7Player§8] §8- §7Teleportiere dich zu einem Spieler"); + } @Register public void genericCommand(Player p, Player target) { diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTestblock.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTestblock.java index e00815b..a340d02 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTestblock.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTestblock.java @@ -39,8 +39,8 @@ public class CommandTestblock extends SWCommand { @Register(help = true) public void genericHelp(Player p, String... args) { - p.sendMessage(BauSystem.PREFIX + "§8/§etestblock §8- §7Setzte den Testblock zurück"); - p.sendMessage(BauSystem.PREFIX + "§8/§etestblock §8[§7Schematic§8] §8- §7Setzte den Testblock mit einer Schematic zurück"); + p.sendMessage("§8/§etestblock §8- §7Setzte den Testblock zurück"); + p.sendMessage("§8/§etestblock §8[§7Schematic§8] §8- §7Setzte den Testblock mit einer Schematic zurück"); } @Register diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTime.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTime.java index 31088e9..7d2b159 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTime.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTime.java @@ -21,7 +21,7 @@ public class CommandTime extends SWCommand { @Register(help = true) public void genericHelp(Player p, String... args) { - p.sendMessage(BauSystem.PREFIX + "§8/§etime §8<§7Zeit 0=Morgen§8, §76000=Mittag§8, §718000=Mitternacht§8> §8- §7Setzt die Zeit auf dem Bau"); + p.sendMessage("§8/§etime §8<§7Zeit 0=Morgen§8, §76000=Mittag§8, §718000=Mitternacht§8> §8- §7Setzt die Zeit auf dem Bau"); } @Register diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/RegionToggleCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/RegionToggleCommand.java deleted file mode 100644 index 5b8c549..0000000 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/RegionToggleCommand.java +++ /dev/null @@ -1,82 +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 . - * / - */ - -package de.steamwar.bausystem.commands; - -import de.steamwar.bausystem.BauSystem; -import de.steamwar.bausystem.Permission; -import de.steamwar.bausystem.world.Region; -import de.steamwar.bausystem.world.Welt; -import net.md_5.bungee.api.ChatMessageType; -import net.md_5.bungee.api.chat.TextComponent; -import org.bukkit.Bukkit; -import org.bukkit.command.Command; -import org.bukkit.command.CommandExecutor; -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; -import org.bukkit.event.Listener; - -public abstract class RegionToggleCommand implements CommandExecutor, Listener { - - public RegionToggleCommand() { - Bukkit.getPluginManager().registerEvents(this, BauSystem.getPlugin()); - } - - @Override - public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { - if (!(sender instanceof Player)) - return false; - Player player = (Player) sender; - - if (Welt.noPermission(player, Permission.world)) { - player.sendMessage(BauSystem.PREFIX + getNoPermMessage()); - return false; - } - - Region region = Region.getRegion(player.getLocation()); - if (toggle(region)) { - actionBar(region, getEnableMessage()); - } else { - actionBar(region, getDisableMessage()); - } - return false; - } - - 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))); - } - } - - abstract String getNoPermMessage(); - - abstract String getEnableMessage(); - - abstract String getDisableMessage(); - - /** - * {@code true} for {@link #getEnableMessage()}, {@code false} for {@link #getDisableMessage()} - */ - abstract boolean toggle(Region region); - -} diff --git a/BauSystem_Main/src/plugin.yml b/BauSystem_Main/src/plugin.yml index e0eac26..2f25ee7 100644 --- a/BauSystem_Main/src/plugin.yml +++ b/BauSystem_Main/src/plugin.yml @@ -9,7 +9,4 @@ website: "https://steamwar.de" description: "So unseriös wie wir sind: BauSystem nur besser." commands: - fire: - freeze: - aliases: stoplag lockschem: \ No newline at end of file From 49f045d81739e80df27439d222aa9253d8c74b41 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Thu, 1 Apr 2021 22:48:50 +0200 Subject: [PATCH 36/51] Update CommandLockschem to new SWCommand system --- .../src/de/steamwar/bausystem/BauSystem.java | 2 +- .../bausystem/commands/CommandLockschem.java | 58 +++++++++++-------- BauSystem_Main/src/plugin.yml | 1 - 3 files changed, 34 insertions(+), 27 deletions(-) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java b/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java index f1dc6b4..e70ad9e 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java @@ -83,7 +83,7 @@ public class BauSystem extends JavaPlugin implements Listener { new CommandProtect(); new CommandSkull(); new CommandLoader(); - getCommand("lockschem").setExecutor(new CommandLockschem()); + new CommandLockschem(); new CommandDebugStick(); new CommandGills(); new CommandDetonator(); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandLockschem.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandLockschem.java index 75fca1e..08a4f57 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandLockschem.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandLockschem.java @@ -20,55 +20,63 @@ package de.steamwar.bausystem.commands; import de.steamwar.bausystem.BauSystem; +import de.steamwar.command.SWCommand; import de.steamwar.sql.Schematic; import de.steamwar.sql.SchematicType; import de.steamwar.sql.SteamwarUser; import de.steamwar.sql.UserGroup; -import org.bukkit.command.Command; -import org.bukkit.command.CommandExecutor; -import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; -public class CommandLockschem implements CommandExecutor { +public class CommandLockschem extends SWCommand { - @Override - public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { - if (!(sender instanceof Player)) - return false; - Player player = (Player) sender; + public CommandLockschem() { + super("lockschem"); + } - SteamwarUser steamwarUser = SteamwarUser.get(player.getUniqueId()); + @Register(help = true) + public void genericHelp(Player p, String... args) { + SteamwarUser steamwarUser = SteamwarUser.get(p.getUniqueId()); UserGroup userGroup = steamwarUser.getUserGroup(); if (userGroup != UserGroup.Admin && userGroup != UserGroup.Developer && userGroup != UserGroup.Moderator && - userGroup != UserGroup.Supporter) - return false; - - if (args.length != 2) { - sendHelp(player); - return false; + userGroup != UserGroup.Supporter) { + return; } - SteamwarUser schemOwner = SteamwarUser.get(args[0]); + sendHelp(p); + } + + @Register + public void genericCommand(Player p, String owner, String schematicName) { + SteamwarUser steamwarUser = SteamwarUser.get(p.getUniqueId()); + UserGroup userGroup = steamwarUser.getUserGroup(); + + if (userGroup != UserGroup.Admin && + userGroup != UserGroup.Developer && + userGroup != UserGroup.Moderator && + userGroup != UserGroup.Supporter) { + return; + } + + SteamwarUser schemOwner = SteamwarUser.get(owner); if (schemOwner == null) { - player.sendMessage(BauSystem.PREFIX + "Dieser Spieler existiert nicht!"); - return false; + p.sendMessage(BauSystem.PREFIX + "Dieser Spieler existiert nicht!"); + return; } - Schematic schematic = Schematic.getSchemFromDB(args[1], schemOwner.getUUID()); + Schematic schematic = Schematic.getSchemFromDB(schematicName, schemOwner.getUUID()); if (schematic == null) { - player.sendMessage(BauSystem.PREFIX + "Dieser Spieler besitzt keine Schematic mit diesem Namen!"); - return false; + p.sendMessage(BauSystem.PREFIX + "Dieser Spieler besitzt keine Schematic mit diesem Namen!"); + return; } - player.sendMessage(BauSystem.PREFIX + "Schematic " + schematic.getSchemName() + " von " + + p.sendMessage(BauSystem.PREFIX + "Schematic " + schematic.getSchemName() + " von " + SteamwarUser.get(schematic.getSchemOwner()).getUserName() + " von " + schematic.getSchemType().toString() + " auf NORMAL zurückgesetzt!"); schematic.setSchemType(SchematicType.Normal); - return false; } private void sendHelp(Player player) { - player.sendMessage(BauSystem.PREFIX + "/schemlock [OWNER] [SCHEM NAME]"); + player.sendMessage("§8/§eschemlock §8[§7Owner§8] §8[§7Schematic§8] §8- §7 Sperre eine Schematic"); } } diff --git a/BauSystem_Main/src/plugin.yml b/BauSystem_Main/src/plugin.yml index 2f25ee7..8eb1ee4 100644 --- a/BauSystem_Main/src/plugin.yml +++ b/BauSystem_Main/src/plugin.yml @@ -9,4 +9,3 @@ website: "https://steamwar.de" description: "So unseriös wie wir sind: BauSystem nur besser." commands: - lockschem: \ No newline at end of file From e5d13d420b9c94054e5dec4765e982f7c045e5f4 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Thu, 1 Apr 2021 22:51:31 +0200 Subject: [PATCH 37/51] Fix CommandInfo help message --- .../src/de/steamwar/bausystem/commands/CommandInfo.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandInfo.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandInfo.java index afcc68f..6b804d6 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandInfo.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandInfo.java @@ -40,7 +40,7 @@ public class CommandInfo extends SWCommand { @Register(help = true) public void genericHelp(Player p, String... args) { - p.sendMessage("§8/§ebauinfo §8- §7Gebe Informationen über den Bau"); + p.sendMessage("§8/§ebauinfo §8- §7Gibt Informationen über den Bau"); } @Register From a9b4905129b42e0b3d8a7333b16dbd0bdf7dc7de Mon Sep 17 00:00:00 2001 From: yoyosource Date: Thu, 1 Apr 2021 23:02:23 +0200 Subject: [PATCH 38/51] Fix License Header --- .../bausystem/commands/CommandBau.java | 20 ++++++++++++++++++- .../bausystem/commands/CommandClear.java | 20 ++++++++++++++++++- .../bausystem/commands/CommandDebugStick.java | 20 ++++++++++++++++++- .../bausystem/commands/CommandDetonator.java | 19 ++++++++++++++++++ .../bausystem/commands/CommandGUI.java | 19 ++++++++++++++++++ .../bausystem/commands/CommandGamemode.java | 20 ++++++++++++++++++- .../bausystem/commands/CommandScript.java | 1 - .../bausystem/commands/CommandScriptVars.java | 19 ++++++++++++++++++ .../bausystem/commands/CommandSkull.java | 1 - .../bausystem/commands/CommandTeleport.java | 20 ++++++++++++++++++- .../bausystem/commands/CommandTime.java | 19 ++++++++++++++++++ 11 files changed, 171 insertions(+), 7 deletions(-) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandBau.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandBau.java index ee945f6..375267f 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandBau.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandBau.java @@ -1,3 +1,22 @@ +/* + * 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 . + */ + package de.steamwar.bausystem.commands; import de.steamwar.bausystem.BauSystem; @@ -7,7 +26,6 @@ import de.steamwar.sql.BauweltMember; import de.steamwar.sql.SteamwarUser; import org.bukkit.entity.Player; - public class CommandBau extends SWCommand { public CommandBau() { diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandClear.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandClear.java index ec72043..81225a8 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandClear.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandClear.java @@ -1,3 +1,22 @@ +/* + * 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 . + */ + package de.steamwar.bausystem.commands; import de.steamwar.bausystem.BauSystem; @@ -8,7 +27,6 @@ import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; - public class CommandClear extends SWCommand { public CommandClear() { diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandDebugStick.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandDebugStick.java index 97877ca..604122f 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandDebugStick.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandDebugStick.java @@ -1,3 +1,22 @@ +/* + * 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 . + */ + package de.steamwar.bausystem.commands; import de.steamwar.bausystem.BauSystem; @@ -7,7 +26,6 @@ import de.steamwar.command.SWCommand; import de.steamwar.core.VersionedRunnable; import org.bukkit.entity.Player; - public class CommandDebugStick extends SWCommand { public CommandDebugStick() { diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandDetonator.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandDetonator.java index 310c395..226e498 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandDetonator.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandDetonator.java @@ -1,3 +1,22 @@ +/* + * 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 . + */ + package de.steamwar.bausystem.commands; import de.steamwar.bausystem.BauSystem; diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandGUI.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandGUI.java index a51e629..b2fa3db 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandGUI.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandGUI.java @@ -1,3 +1,22 @@ +/* + * 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 . + */ + package de.steamwar.bausystem.commands; import de.steamwar.bausystem.BauSystem; diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandGamemode.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandGamemode.java index a4b2cfc..da8e0e1 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandGamemode.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandGamemode.java @@ -1,3 +1,22 @@ +/* + * 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 . + */ + package de.steamwar.bausystem.commands; import de.steamwar.bausystem.BauSystem; @@ -6,7 +25,6 @@ import de.steamwar.sql.BauweltMember; import org.bukkit.GameMode; import org.bukkit.entity.Player; - public class CommandGamemode extends SWCommand { public CommandGamemode() { diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandScript.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandScript.java index c5b9bcc..8e071ea 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandScript.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandScript.java @@ -21,7 +21,6 @@ package de.steamwar.bausystem.commands; -import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.SWUtils; import de.steamwar.command.SWCommand; import org.bukkit.Material; diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandScriptVars.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandScriptVars.java index 419b320..f352fca 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandScriptVars.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandScriptVars.java @@ -1,3 +1,22 @@ +/* + * 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 . + */ + package de.steamwar.bausystem.commands; import de.steamwar.bausystem.BauSystem; diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandSkull.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandSkull.java index 821c12b..ca98a7e 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandSkull.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandSkull.java @@ -19,7 +19,6 @@ package de.steamwar.bausystem.commands; -import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.SWUtils; import de.steamwar.command.SWCommand; import de.steamwar.inventory.SWItem; diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTeleport.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTeleport.java index ce6debd..5940f2c 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTeleport.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTeleport.java @@ -1,3 +1,22 @@ +/* + * 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 . + */ + package de.steamwar.bausystem.commands; import de.steamwar.bausystem.BauSystem; @@ -6,7 +25,6 @@ import de.steamwar.sql.BauweltMember; import org.bukkit.entity.Player; import org.bukkit.event.player.PlayerTeleportEvent; - public class CommandTeleport extends SWCommand { public CommandTeleport() { diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTime.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTime.java index 7d2b159..ce07c8a 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTime.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTime.java @@ -1,3 +1,22 @@ +/* + * 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 . + */ + package de.steamwar.bausystem.commands; import de.steamwar.bausystem.BauSystem; From 1c9d88638c101b128e2926342e9425f9c9841f7d Mon Sep 17 00:00:00 2001 From: yoyosource Date: Thu, 1 Apr 2021 23:12:10 +0200 Subject: [PATCH 39/51] Add Zeanon to plugin.yml --- BauSystem_Main/src/plugin.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BauSystem_Main/src/plugin.yml b/BauSystem_Main/src/plugin.yml index 8eb1ee4..ac778a3 100644 --- a/BauSystem_Main/src/plugin.yml +++ b/BauSystem_Main/src/plugin.yml @@ -1,5 +1,5 @@ name: BauSystem -authors: [Lixfel, YoyoNow, Chaoscaot] +authors: [Lixfel, YoyoNow, Chaoscaot, Zeanon] version: "1.0" depend: [WorldEdit, SpigotCore, ProtocolLib] load: POSTWORLD From c2fc3e68e29bf864d7a648892289440fe9678aba Mon Sep 17 00:00:00 2001 From: Zeanon Date: Thu, 1 Apr 2021 23:12:24 +0200 Subject: [PATCH 40/51] added /bau info as separate command to /bauinfo --- .../src/de/steamwar/bausystem/commands/CommandBau.java | 5 +++++ .../src/de/steamwar/bausystem/commands/CommandInfo.java | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandBau.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandBau.java index 8abce2a..856ed12 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandBau.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandBau.java @@ -21,6 +21,11 @@ public class CommandBau extends SWCommand { p.sendMessage(BauSystem.PREFIX + "§8/§ebau toggleworld §8[§7Player§8] §8- §7Editiere die Werlt Rechte eines Spielers"); } + @Register("info") + public void infoCommand(Player p) { + CommandInfo.sendBauInfo(p); + } + @Register("togglebuild") public void toggleBuildCommand(Player p, String arg) { if (!permissionCheck(p)) return; diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandInfo.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandInfo.java index fd6728d..e488a65 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandInfo.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandInfo.java @@ -45,6 +45,10 @@ public class CommandInfo extends SWCommand { @Register public void genericCommand(Player p) { + CommandInfo.sendBauInfo(p); + } + + public static void sendBauInfo(Player p) { p.sendMessage(BauSystem.PREFIX + "Besitzer: §e" + SteamwarUser.get(BauSystem.getOwnerID()).getUserName()); Region region = Region.getRegion(p.getLocation()); p.sendMessage(BauSystem.PREFIX + "§eTNT§8: " + region.getTntMode().getName() + " §eFire§8: " + (region.isFire() ? "§aAUS" : "§cAN") + " §eFreeze§8: " + (region.isFreeze() ? "§aAN" : "§cAUS")); From 1565fab35da934243bd279d12369eacac56f6d24 Mon Sep 17 00:00:00 2001 From: Zeanon Date: Thu, 1 Apr 2021 23:45:10 +0200 Subject: [PATCH 41/51] added tab completion for bau toggle commands --- .../bausystem/commands/CommandBau.java | 38 ++++++++++++++++--- 1 file changed, 32 insertions(+), 6 deletions(-) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandBau.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandBau.java index c34e4d4..43c92f3 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandBau.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandBau.java @@ -22,8 +22,13 @@ package de.steamwar.bausystem.commands; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.world.Welt; import de.steamwar.command.SWCommand; +import de.steamwar.command.SWCommandUtils; +import de.steamwar.command.TypeMapper; +import de.steamwar.comms.handlers.BungeeHandler; import de.steamwar.sql.BauweltMember; import de.steamwar.sql.SteamwarUser; +import java.util.stream.Collectors; +import org.bukkit.Bukkit; import org.bukkit.entity.Player; public class CommandBau extends SWCommand { @@ -45,21 +50,21 @@ public class CommandBau extends SWCommand { } @Register("togglebuild") - public void toggleBuildCommand(Player p, String arg) { + public void toggleBuildCommand(Player p, LocalPlayer arg) { if (!permissionCheck(p)) return; - onToggleBD(p, arg); + onToggleBD(p, arg.getName()); } @Register("togglewe") - public void toggleWECommand(Player p, String arg) { + public void toggleWECommand(Player p, LocalPlayer arg) { if (!permissionCheck(p)) return; - onToggleWE(p, arg); + onToggleWE(p, arg.getName()); } @Register("toggleworld") - public void toggleWorldCommand(Player p, String arg) { + public void toggleWorldCommand(Player p, LocalPlayer arg) { if (!permissionCheck(p)) return; - onToggleWorld(p, arg); + onToggleWorld(p, arg.getName()); } @@ -116,4 +121,25 @@ public class CommandBau extends SWCommand { return true; } } + + + @ClassMapper(value = LocalPlayer.class, local = true) + private TypeMapper mapCommandConfirmation() { + return SWCommandUtils.createMapper(LocalPlayer::new, + s -> Bukkit.getOnlinePlayers().stream().map(Player::getName).collect(Collectors.toList())); + } + + + public class LocalPlayer { + + private String name; + + public LocalPlayer(String name) { + this.name = name; + } + + public String getName() { + return name; + } + } } \ No newline at end of file From f00561f064c0b251b511998dcb7ea497077b6e6e Mon Sep 17 00:00:00 2001 From: Zeanon Date: Fri, 2 Apr 2021 00:02:55 +0200 Subject: [PATCH 42/51] removed self from bau toggle tab completion --- .../src/de/steamwar/bausystem/commands/CommandBau.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandBau.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandBau.java index 43c92f3..bcf16f0 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandBau.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandBau.java @@ -24,13 +24,13 @@ import de.steamwar.bausystem.world.Welt; import de.steamwar.command.SWCommand; import de.steamwar.command.SWCommandUtils; import de.steamwar.command.TypeMapper; -import de.steamwar.comms.handlers.BungeeHandler; import de.steamwar.sql.BauweltMember; import de.steamwar.sql.SteamwarUser; import java.util.stream.Collectors; import org.bukkit.Bukkit; import org.bukkit.entity.Player; + public class CommandBau extends SWCommand { public CommandBau() { @@ -126,7 +126,7 @@ public class CommandBau extends SWCommand { @ClassMapper(value = LocalPlayer.class, local = true) private TypeMapper mapCommandConfirmation() { return SWCommandUtils.createMapper(LocalPlayer::new, - s -> Bukkit.getOnlinePlayers().stream().map(Player::getName).collect(Collectors.toList())); + (c, s) -> Bukkit.getOnlinePlayers().stream().map(Player::getName).filter(n -> !c.getName().equals(n)).collect(Collectors.toList())); } From 7413c96888f9dc4f0db2729bf97e4e8b99e0cbb7 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Fri, 2 Apr 2021 16:25:05 +0200 Subject: [PATCH 43/51] Add CommandSpawn --- .../bausystem/commands/CommandSpawn.java | 45 +++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 BauSystem_Main/src/de/steamwar/bausystem/commands/CommandSpawn.java diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandSpawn.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandSpawn.java new file mode 100644 index 0000000..8d40a75 --- /dev/null +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandSpawn.java @@ -0,0 +1,45 @@ +/* + * 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 . + */ + +package de.steamwar.bausystem.commands; + +import de.steamwar.command.SWCommand; +import org.bukkit.Bukkit; +import org.bukkit.World; +import org.bukkit.entity.Player; +import org.bukkit.event.player.PlayerTeleportEvent; + +public class CommandSpawn extends SWCommand { + + private World world = Bukkit.getWorlds().get(0); + + public CommandSpawn() { + super("spawn"); + } + + @Register(help = true) + public void genericHelp(Player p, String... args) { + p.sendMessage("§8/§espawn §8- §7Teleportiere dich zum Spawn"); + } + + @Register + public void genericCommand(Player p) { + p.teleport(world.getSpawnLocation(), PlayerTeleportEvent.TeleportCause.COMMAND); + } +} From cccd0153dc7ff81fdbeb073bebce0757f8142f6d Mon Sep 17 00:00:00 2001 From: yoyosource Date: Fri, 2 Apr 2021 16:25:24 +0200 Subject: [PATCH 44/51] Add CommandSpawn --- BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java | 1 + 1 file changed, 1 insertion(+) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java b/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java index e70ad9e..72c8421 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java @@ -92,6 +92,7 @@ public class BauSystem extends JavaPlugin implements Listener { new CommandSimulator(); new CommandRedstoneTester(); new CommandGUI(); + new CommandSpawn(); Bukkit.getPluginManager().registerEvents(this, this); Bukkit.getPluginManager().registerEvents(new RegionListener(), this); From 9b1f4433cac86c55042e55ad1fe284f6780af078 Mon Sep 17 00:00:00 2001 From: Zeanon Date: Fri, 2 Apr 2021 17:03:58 +0200 Subject: [PATCH 45/51] updated bau toggle-commands tab completion --- .../src/de/steamwar/bausystem/Mapper.java | 15 +++++- .../bausystem/commands/CommandBau.java | 51 ++++++++----------- 2 files changed, 35 insertions(+), 31 deletions(-) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/Mapper.java b/BauSystem_Main/src/de/steamwar/bausystem/Mapper.java index 8419493..8dee240 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/Mapper.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/Mapper.java @@ -22,11 +22,14 @@ package de.steamwar.bausystem; import de.steamwar.bausystem.tracer.show.ShowModeParameterType; import de.steamwar.command.SWCommandUtils; import de.steamwar.command.TypeMapper; - +import de.steamwar.sql.BauweltMember; +import de.steamwar.sql.SteamwarUser; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.stream.Collectors; + public class Mapper { @@ -36,6 +39,7 @@ public class Mapper { public static void init() { SWCommandUtils.addMapper(ShowModeParameterType.class, showModeParameterTypesTypeMapper()); + SWCommandUtils.addMapper(BauweltMember.class, bauweltMemberTypeMapper()); } private static TypeMapper showModeParameterTypesTypeMapper() { @@ -70,4 +74,13 @@ public class Mapper { return SWCommandUtils.createMapper(s -> showModeParameterTypesMap.getOrDefault(s, null), s -> tabCompletes); } + private static TypeMapper bauweltMemberTypeMapper() { + return SWCommandUtils.createMapper(s -> BauweltMember.getMembers(BauSystem.getOwnerID()) + .stream() + .filter(m -> SteamwarUser.get(m.getMemberID()).getUserName().equals(s)).findFirst().orElse(null), + s -> BauweltMember.getMembers(BauSystem.getOwnerID()) + .stream() + .map(m -> SteamwarUser.get(m.getMemberID()).getUserName()) + .collect(Collectors.toList())); + } } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandBau.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandBau.java index bcf16f0..4bdc212 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandBau.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandBau.java @@ -50,26 +50,25 @@ public class CommandBau extends SWCommand { } @Register("togglebuild") - public void toggleBuildCommand(Player p, LocalPlayer arg) { + public void toggleBuildCommand(Player p, SteamwarUser user) { if (!permissionCheck(p)) return; - onToggleBD(p, arg.getName()); + onToggleBD(p, user); } @Register("togglewe") - public void toggleWECommand(Player p, LocalPlayer arg) { + public void toggleWECommand(Player p, SteamwarUser user) { if (!permissionCheck(p)) return; - onToggleWE(p, arg.getName()); + onToggleWE(p, user); } @Register("toggleworld") - public void toggleWorldCommand(Player p, LocalPlayer arg) { + public void toggleWorldCommand(Player p, SteamwarUser user) { if (!permissionCheck(p)) return; - onToggleWorld(p, arg.getName()); + onToggleWorld(p, user); } - private void onToggleBD(Player p, String arg) { - SteamwarUser id = SteamwarUser.get(arg); + private void onToggleBD(Player p, SteamwarUser id) { if (negativeToggleCheck(p, id)) { return; } @@ -78,8 +77,7 @@ public class CommandBau extends SWCommand { Welt.toggleBuild(p, target); } - private void onToggleWE(Player p, String arg) { - SteamwarUser id = SteamwarUser.get(arg); + private void onToggleWE(Player p, SteamwarUser id) { if (negativeToggleCheck(p, id)) { return; } @@ -88,8 +86,7 @@ public class CommandBau extends SWCommand { Welt.toggleWE(p, target); } - private void onToggleWorld(Player p, String arg) { - SteamwarUser id = SteamwarUser.get(arg); + private void onToggleWorld(Player p, SteamwarUser id) { if (negativeToggleCheck(p, id)) { return; } @@ -123,23 +120,17 @@ public class CommandBau extends SWCommand { } - @ClassMapper(value = LocalPlayer.class, local = true) - private TypeMapper mapCommandConfirmation() { - return SWCommandUtils.createMapper(LocalPlayer::new, - (c, s) -> Bukkit.getOnlinePlayers().stream().map(Player::getName).filter(n -> !c.getName().equals(n)).collect(Collectors.toList())); - } - - - public class LocalPlayer { - - private String name; - - public LocalPlayer(String name) { - this.name = name; - } - - public String getName() { - return name; - } + @ClassMapper(value = SteamwarUser.class, local = true) + private TypeMapper steamwarUserTypeMapper() { + return SWCommandUtils.createMapper(s -> BauweltMember.getMembers(BauSystem.getOwnerID()) + .stream() + .map(m -> SteamwarUser.get(m.getMemberID())) + .filter(u -> u.getUserName().equals(s)) + .findFirst() + .orElse(null), + s -> BauweltMember.getMembers(BauSystem.getOwnerID()) + .stream() + .map(m -> SteamwarUser.get(m.getMemberID()).getUserName()) + .collect(Collectors.toList())); } } \ No newline at end of file From 73d492cdf02c5adff52604a466b8450206d9f95a Mon Sep 17 00:00:00 2001 From: Zeanon Date: Fri, 2 Apr 2021 17:13:27 +0200 Subject: [PATCH 46/51] updated bau toggle-commands tab completion to tab complete adequately for executing user --- .../bausystem/commands/CommandBau.java | 27 +++++++++++++------ 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandBau.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandBau.java index 4bdc212..a02e6bb 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandBau.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandBau.java @@ -27,7 +27,6 @@ import de.steamwar.command.TypeMapper; import de.steamwar.sql.BauweltMember; import de.steamwar.sql.SteamwarUser; import java.util.stream.Collectors; -import org.bukkit.Bukkit; import org.bukkit.entity.Player; @@ -51,19 +50,25 @@ public class CommandBau extends SWCommand { @Register("togglebuild") public void toggleBuildCommand(Player p, SteamwarUser user) { - if (!permissionCheck(p)) return; + if (!permissionCheck(p)) { + return; + } onToggleBD(p, user); } @Register("togglewe") public void toggleWECommand(Player p, SteamwarUser user) { - if (!permissionCheck(p)) return; + if (!permissionCheck(p)) { + return; + } onToggleWE(p, user); } @Register("toggleworld") public void toggleWorldCommand(Player p, SteamwarUser user) { - if (!permissionCheck(p)) return; + if (!permissionCheck(p)) { + return; + } onToggleWorld(p, user); } @@ -128,9 +133,15 @@ public class CommandBau extends SWCommand { .filter(u -> u.getUserName().equals(s)) .findFirst() .orElse(null), - s -> BauweltMember.getMembers(BauSystem.getOwnerID()) - .stream() - .map(m -> SteamwarUser.get(m.getMemberID()).getUserName()) - .collect(Collectors.toList())); + (c, s) -> { + if (!(c instanceof Player)) { + return null; + } + Player p = (Player) c; + return BauweltMember.getMembers(SteamwarUser.get(p.getUniqueId()).getId()) + .stream() + .map(m -> SteamwarUser.get(m.getMemberID()).getUserName()) + .collect(Collectors.toList()); + }); } } \ No newline at end of file From 03165acbb87d480b59bab0d0add17e4de3703031 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Fri, 2 Apr 2021 17:25:25 +0200 Subject: [PATCH 47/51] Add CommandTeleport tp alias --- .../src/de/steamwar/bausystem/commands/CommandTeleport.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTeleport.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTeleport.java index 5940f2c..769da8f 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTeleport.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTeleport.java @@ -28,7 +28,7 @@ import org.bukkit.event.player.PlayerTeleportEvent; public class CommandTeleport extends SWCommand { public CommandTeleport() { - super("teleport"); + super("teleport", "tp"); } @Register(help = true) From c0925f31d2b23e1cb22e11b81a52e89ffa2ba9de Mon Sep 17 00:00:00 2001 From: Zeanon Date: Fri, 2 Apr 2021 17:27:47 +0200 Subject: [PATCH 48/51] added alias /g for /gm --- .../src/de/steamwar/bausystem/commands/CommandGamemode.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandGamemode.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandGamemode.java index da8e0e1..8747a1c 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandGamemode.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandGamemode.java @@ -28,7 +28,7 @@ import org.bukkit.entity.Player; public class CommandGamemode extends SWCommand { public CommandGamemode() { - super("gamemode", "gm"); + super("gamemode", "gm", "g"); } @Register(help = true) From da5c5f45e4186b57eae75bef2cd788c08a0850e5 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Fri, 2 Apr 2021 17:50:29 +0200 Subject: [PATCH 49/51] Add CommandWorldSpawn --- BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java | 4 +--- .../{CommandSpawn.java => CommandWorldSpawn.java} | 8 ++++---- 2 files changed, 5 insertions(+), 7 deletions(-) rename BauSystem_Main/src/de/steamwar/bausystem/commands/{CommandSpawn.java => CommandWorldSpawn.java} (87%) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java b/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java index 72c8421..86d425a 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java @@ -21,7 +21,6 @@ package de.steamwar.bausystem; import de.steamwar.bausystem.commands.*; import de.steamwar.bausystem.world.*; -import de.steamwar.core.CommandRemover; import de.steamwar.core.Core; import de.steamwar.core.VersionedRunnable; import de.steamwar.scoreboard.SWScoreboard; @@ -44,7 +43,6 @@ import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.scheduler.BukkitTask; import java.util.UUID; -import java.util.logging.Level; public class BauSystem extends JavaPlugin implements Listener { private static BauSystem plugin; @@ -92,7 +90,7 @@ public class BauSystem extends JavaPlugin implements Listener { new CommandSimulator(); new CommandRedstoneTester(); new CommandGUI(); - new CommandSpawn(); + new CommandWorldSpawn(); Bukkit.getPluginManager().registerEvents(this, this); Bukkit.getPluginManager().registerEvents(new RegionListener(), this); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandSpawn.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandWorldSpawn.java similarity index 87% rename from BauSystem_Main/src/de/steamwar/bausystem/commands/CommandSpawn.java rename to BauSystem_Main/src/de/steamwar/bausystem/commands/CommandWorldSpawn.java index 8d40a75..2f9c134 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandSpawn.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandWorldSpawn.java @@ -25,17 +25,17 @@ import org.bukkit.World; import org.bukkit.entity.Player; import org.bukkit.event.player.PlayerTeleportEvent; -public class CommandSpawn extends SWCommand { +public class CommandWorldSpawn extends SWCommand { private World world = Bukkit.getWorlds().get(0); - public CommandSpawn() { - super("spawn"); + public CommandWorldSpawn() { + super("worldspawn"); } @Register(help = true) public void genericHelp(Player p, String... args) { - p.sendMessage("§8/§espawn §8- §7Teleportiere dich zum Spawn"); + p.sendMessage("§8/§eworldspawn §8- §7Teleportiere dich zum Spawn"); } @Register From 68643025ad80eaf3add839b29c74b8526f934160 Mon Sep 17 00:00:00 2001 From: Zeanon Date: Fri, 2 Apr 2021 18:01:37 +0200 Subject: [PATCH 50/51] started implementing CommandSelect --- .../bausystem/commands/CommandSelect.java | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 BauSystem_Main/src/de/steamwar/bausystem/commands/CommandSelect.java diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandSelect.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandSelect.java new file mode 100644 index 0000000..30016ac --- /dev/null +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandSelect.java @@ -0,0 +1,24 @@ +package de.steamwar.bausystem.commands; + +import de.steamwar.bausystem.BauSystem; +import de.steamwar.bausystem.world.Region; +import de.steamwar.command.SWCommand; +import org.bukkit.entity.Player; + + +public class CommandSelect extends SWCommand { + + public CommandSelect() { + super("select"); + } + + + @Register("baurahmen") + public void baurahmenCommand(Player p) { + Region region = Region.getRegion(p.getLocation()); + if (region == Region.GlobalRegion.getInstance()) { + p.sendMessage(BauSystem.PREFIX + "§cDu befindest dich derzeit in keiner Region"); + return; + } + } +} \ No newline at end of file From 40efbfacb3d8474b60a7522c9bb87a8fe2b590d3 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Fri, 2 Apr 2021 18:03:38 +0200 Subject: [PATCH 51/51] Remove CommandSelect.java --- .../bausystem/commands/CommandSelect.java | 24 ------------------- 1 file changed, 24 deletions(-) delete mode 100644 BauSystem_Main/src/de/steamwar/bausystem/commands/CommandSelect.java diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandSelect.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandSelect.java deleted file mode 100644 index 30016ac..0000000 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandSelect.java +++ /dev/null @@ -1,24 +0,0 @@ -package de.steamwar.bausystem.commands; - -import de.steamwar.bausystem.BauSystem; -import de.steamwar.bausystem.world.Region; -import de.steamwar.command.SWCommand; -import org.bukkit.entity.Player; - - -public class CommandSelect extends SWCommand { - - public CommandSelect() { - super("select"); - } - - - @Register("baurahmen") - public void baurahmenCommand(Player p) { - Region region = Region.getRegion(p.getLocation()); - if (region == Region.GlobalRegion.getInstance()) { - p.sendMessage(BauSystem.PREFIX + "§cDu befindest dich derzeit in keiner Region"); - return; - } - } -} \ No newline at end of file