From 7f14182b8ed7a5ccfe25d5623d55825e15b36bce Mon Sep 17 00:00:00 2001 From: Lixfel Date: Fri, 11 Dec 2020 13:00:36 +0100 Subject: [PATCH 1/2] Remove superflous chained command --- .../src/de/steamwar/bausystem/BauSystem.java | 13 ---- .../bausystem/commands/ChainedCommand.java | 75 ------------------- 2 files changed, 88 deletions(-) delete mode 100644 BauSystem_Main/src/de/steamwar/bausystem/commands/ChainedCommand.java diff --git a/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java b/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java index 45641d7..56309f2 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java @@ -48,7 +48,6 @@ import org.bukkit.scheduler.BukkitTask; import java.io.File; import java.io.IOException; -import java.util.Arrays; import java.util.List; import java.util.UUID; import java.util.logging.Level; @@ -119,18 +118,6 @@ public class BauSystem extends JavaPlugin implements Listener { getCommand("detonator").setExecutor(new CommandDetonator()); getCommand("detonator").setTabCompleter(new CommandDetonatorTabCompleter()); - new ChainedCommand("/1", "/pos1"); - new ChainedCommand("/2", "/pos2"); - new ChainedCommand("/90", "/rotate 90"); - new ChainedCommand("/-90", "/rotate -90"); - new ChainedCommand("/180", "/rotate 180"); - new ChainedCommand("/c", "/copy"); - new ChainedCommand("/p", Arrays.asList("-a", "-b", "-e", "-n", "-o", "-s", "-m"), "/paste {}"); - new ChainedCommand("/flopy", "/copy", "/flip"); - new ChainedCommand("/flopyp", Arrays.asList("-a", "-b", "-e", "-n", "-o", "-s", "-m"), "/copy", "/flip", "/paste {}"); - new ChainedCommand("/u", "/undo {}"); - new ChainedCommand("/r", "/redo {}"); - Bukkit.getPluginManager().registerEvents(this, this); Bukkit.getPluginManager().registerEvents(new RegionListener(), this); Bukkit.getPluginManager().registerEvents(new ScriptListener(), this); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/ChainedCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/ChainedCommand.java deleted file mode 100644 index 0bf3018..0000000 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/ChainedCommand.java +++ /dev/null @@ -1,75 +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 org.bukkit.command.Command; -import org.bukkit.command.CommandExecutor; -import org.bukkit.command.CommandSender; -import org.bukkit.command.TabCompleter; -import org.bukkit.entity.Player; - -import java.util.ArrayList; -import java.util.List; - -public class ChainedCommand implements CommandExecutor, TabCompleter { - - private String[] commands; - private List tabCompletes; - - public ChainedCommand(String command, final List tabCompletes, final String... commands) { - BauSystem.getPlugin().getCommand(command).setExecutor(this); - BauSystem.getPlugin().getCommand(command).setTabCompleter(this); - - this.commands = commands; - this.tabCompletes = tabCompletes; - if (tabCompletes == null) { - this.tabCompletes = new ArrayList<>(); - } - } - - public ChainedCommand(String command, final String... commands) { - this(command, null, commands); - } - - @Override - public boolean onCommand(CommandSender sender, Command command, String s, String[] args) { - if (!(sender instanceof Player)) { - return false; - } - Player player = (Player) sender; - - String argsString = ""; - if (args.length != 0) argsString = String.join(" ", args); - - for (String cmd : commands) { - if (!player.performCommand(cmd.replace("{}", argsString))) { - return false; - } - } - return true; - } - - @Override - public List onTabComplete(CommandSender sender, Command command, String s, String[] args) { - return tabCompletes; - } - -} From c6e8cad799c7b284add789c9258c7cefb0b44604 Mon Sep 17 00:00:00 2001 From: Lixfel Date: Fri, 11 Dec 2020 15:31:54 +0100 Subject: [PATCH 2/2] Fix WE Security issue --- .../de/steamwar/bausystem/world/RegionListener.java | 13 ++++++++++--- BauSystem_Main/src/plugin.yml | 12 ------------ 2 files changed, 10 insertions(+), 15 deletions(-) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/world/RegionListener.java b/BauSystem_Main/src/de/steamwar/bausystem/world/RegionListener.java index f2239dc..32b54c1 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/world/RegionListener.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/world/RegionListener.java @@ -86,12 +86,19 @@ public class RegionListener implements Listener { } } + private static final String[] shortcutCommands = {"//1", "//2", "//90", "//-90", "//180", "//p", "//c", "//flopy", "//floppy", "//flopyp", "//floppyp", "//u", "//r"}; + private boolean isWorldEditCommand(String command) { + for(String shortcut : shortcutCommands) + if(command.startsWith(shortcut)) + return true; + switch(Core.getVersion()){ - case 15: - return RegionListener_15.isWorldEditCommand(command); - default: + case 12: return RegionListener_12.isWorldEditCommand(command); + case 15: + default: + return RegionListener_15.isWorldEditCommand(command); } } diff --git a/BauSystem_Main/src/plugin.yml b/BauSystem_Main/src/plugin.yml index c167863..0c6a0f4 100644 --- a/BauSystem_Main/src/plugin.yml +++ b/BauSystem_Main/src/plugin.yml @@ -33,15 +33,3 @@ commands: lockschem: detonator: aliases: dt - - /1: - /2: - /180: - /90: - /-90: - /p: - /c: - /flopy: - /flopyp: - /u: - /r: