From a09784287bc1b89bc697f5ed3bb65d36c6fecba2 Mon Sep 17 00:00:00 2001 From: Zeanon Date: Thu, 1 Apr 2021 19:27:22 +0200 Subject: [PATCH] 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: