diff --git a/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java b/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java index b3ce821..5389522 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java @@ -19,7 +19,9 @@ package de.steamwar.bausystem; +import com.sk89q.worldedit.command.WorldEditCommands; import de.steamwar.bausystem.commands.*; +import de.steamwar.bausystem.commands.worldedit.*; import de.steamwar.bausystem.tracer.ShowManager; import de.steamwar.bausystem.tracer.TNTTracer; import de.steamwar.bausystem.tracer.TraceListener; @@ -118,6 +120,16 @@ public class BauSystem extends JavaPlugin implements Listener { getCommand("detonator").setExecutor(new CommandDetonator()); getCommand("detonator").setTabCompleter(new CommandDetonatorTabCompleter()); + getCommand("/1").setExecutor(new WECommandPos1()); + getCommand("/2").setExecutor(new WECommandPos2()); + getCommand("/90").setExecutor(new WECommandRotate90()); + getCommand("/-90").setExecutor(new WECommandRotateN90()); + getCommand("/180").setExecutor(new WECommandRotate180()); + getCommand("/c").setExecutor(new WECommandCopy()); + getCommand("/p").setExecutor(new WECommandPaste()); + getCommand("/flopy").setExecutor(new WECommandFlopy()); + getCommand("/flopyp").setExecutor(new WECommandFlopyp()); + Bukkit.getPluginManager().registerEvents(this, this); Bukkit.getPluginManager().registerEvents(new RegionListener(), this); Bukkit.getPluginManager().registerEvents(new BauScoreboard(), this); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/worldedit/WECommand.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/worldedit/WECommand.java new file mode 100644 index 0000000..069c9e0 --- /dev/null +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/worldedit/WECommand.java @@ -0,0 +1,58 @@ +/* + 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.worldedit; + +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 abstract class WECommand implements CommandExecutor, TabCompleter { + + @Override + public List onTabComplete(CommandSender sender, Command command, String s, String[] args) { + return new ArrayList<>(); + } + + protected final boolean performCommand(Player p, String command) { + return p.performCommand(command); + } + + protected final boolean performCommands(Player p, String... commands) { + for (String command : commands) { + if (!performCommand(p, command)) return false; + } + return true; + } + + protected final List manageList(List strings, String[] args, int index) { + for (int i = strings.size() - 1; i >= 0; i--) { + if (!strings.get(i).startsWith(args[index])) { + strings.remove(i); + } + } + return strings; + } + +} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/worldedit/WECommandCopy.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/worldedit/WECommandCopy.java new file mode 100644 index 0000000..9e6a47f --- /dev/null +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/worldedit/WECommandCopy.java @@ -0,0 +1,35 @@ +/* + 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.worldedit; + +import org.bukkit.command.Command; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +public class WECommandCopy extends WECommand { + + @Override + public boolean onCommand(CommandSender sender, Command command, String s, String[] args) { + if (!(sender instanceof Player)) return false; + performCommands((Player) sender, "/copy"); + return false; + } + +} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/worldedit/WECommandFlopy.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/worldedit/WECommandFlopy.java new file mode 100644 index 0000000..368d091 --- /dev/null +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/worldedit/WECommandFlopy.java @@ -0,0 +1,35 @@ +/* + 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.worldedit; + +import org.bukkit.command.Command; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +public class WECommandFlopy extends WECommand { + + @Override + public boolean onCommand(CommandSender sender, Command command, String s, String[] args) { + if (!(sender instanceof Player)) return false; + performCommands((Player) sender, "/copy", "/flip"); + return false; + } + +} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/worldedit/WECommandFlopyp.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/worldedit/WECommandFlopyp.java new file mode 100644 index 0000000..4b9d3c2 --- /dev/null +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/worldedit/WECommandFlopyp.java @@ -0,0 +1,42 @@ +/* + 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.worldedit; + +import org.bukkit.command.Command; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +import java.util.Arrays; +import java.util.List; + +public class WECommandFlopyp extends WECommand { + + public List onTabComplete(CommandSender sender, Command command, String s, String[] args) { + return manageList(Arrays.asList("-a", "-b", "-e", "-n", "-o", "-s", "-m"), args, args.length - 1); + } + + @Override + public boolean onCommand(CommandSender sender, Command command, String s, String[] args) { + if (!(sender instanceof Player)) return false; + performCommands((Player) sender, "/copy", "/flip", "/paste " + String.join(" ", args)); + return false; + } + +} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/worldedit/WECommandPaste.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/worldedit/WECommandPaste.java new file mode 100644 index 0000000..ee3b940 --- /dev/null +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/worldedit/WECommandPaste.java @@ -0,0 +1,42 @@ +/* + 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.worldedit; + +import org.bukkit.command.Command; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +import java.util.Arrays; +import java.util.List; + +public class WECommandPaste extends WECommand { + + public List onTabComplete(CommandSender sender, Command command, String s, String[] args) { + return manageList(Arrays.asList("-a", "-b", "-e", "-n", "-o", "-s", "-m"), args, args.length - 1); + } + + @Override + public boolean onCommand(CommandSender sender, Command command, String s, String[] args) { + if (!(sender instanceof Player)) return false; + performCommands((Player) sender, "/paste " + String.join(" ", args)); + return false; + } + +} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/worldedit/WECommandPos1.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/worldedit/WECommandPos1.java new file mode 100644 index 0000000..b32f60b --- /dev/null +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/worldedit/WECommandPos1.java @@ -0,0 +1,35 @@ +/* + 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.worldedit; + +import org.bukkit.command.Command; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +public class WECommandPos1 extends WECommand { + + @Override + public boolean onCommand(CommandSender sender, Command command, String s, String[] args) { + if (!(sender instanceof Player)) return false; + performCommands((Player) sender, "/pos1"); + return false; + } + +} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/worldedit/WECommandPos2.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/worldedit/WECommandPos2.java new file mode 100644 index 0000000..ecb0046 --- /dev/null +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/worldedit/WECommandPos2.java @@ -0,0 +1,35 @@ +/* + 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.worldedit; + +import org.bukkit.command.Command; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +public class WECommandPos2 extends WECommand { + + @Override + public boolean onCommand(CommandSender sender, Command command, String s, String[] args) { + if (!(sender instanceof Player)) return false; + performCommands((Player) sender, "/pos2"); + return false; + } + +} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/worldedit/WECommandReplace.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/worldedit/WECommandReplace.java new file mode 100644 index 0000000..814a4c0 --- /dev/null +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/worldedit/WECommandReplace.java @@ -0,0 +1,35 @@ +/* + 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.worldedit; + +import org.bukkit.command.Command; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +public class WECommandReplace extends WECommand { + + @Override + public boolean onCommand(CommandSender sender, Command command, String s, String[] args) { + if (!(sender instanceof Player)) return false; + performCommands((Player) sender, "/rep " + String.join(" ", args)); + return false; + } + +} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/worldedit/WECommandRotate180.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/worldedit/WECommandRotate180.java new file mode 100644 index 0000000..e38dc7f --- /dev/null +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/worldedit/WECommandRotate180.java @@ -0,0 +1,35 @@ +/* + 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.worldedit; + +import org.bukkit.command.Command; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +public class WECommandRotate180 extends WECommand { + + @Override + public boolean onCommand(CommandSender sender, Command command, String s, String[] args) { + if (!(sender instanceof Player)) return false; + performCommands((Player) sender, "/rotate 180"); + return false; + } + +} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/worldedit/WECommandRotate90.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/worldedit/WECommandRotate90.java new file mode 100644 index 0000000..6c6397f --- /dev/null +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/worldedit/WECommandRotate90.java @@ -0,0 +1,35 @@ +/* + 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.worldedit; + +import org.bukkit.command.Command; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +public class WECommandRotate90 extends WECommand { + + @Override + public boolean onCommand(CommandSender sender, Command command, String s, String[] args) { + if (!(sender instanceof Player)) return false; + performCommands((Player) sender, "/rotate 90"); + return false; + } + +} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/worldedit/WECommandRotateN90.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/worldedit/WECommandRotateN90.java new file mode 100644 index 0000000..236b2a2 --- /dev/null +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/worldedit/WECommandRotateN90.java @@ -0,0 +1,35 @@ +/* + 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.worldedit; + +import org.bukkit.command.Command; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +public class WECommandRotateN90 extends WECommand { + + @Override + public boolean onCommand(CommandSender sender, Command command, String s, String[] args) { + if (!(sender instanceof Player)) return false; + performCommands((Player) sender, "/rotate -90"); + return false; + } + +} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/worldedit/WECommandSet.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/worldedit/WECommandSet.java new file mode 100644 index 0000000..190918a --- /dev/null +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/worldedit/WECommandSet.java @@ -0,0 +1,35 @@ +/* + 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.worldedit; + +import org.bukkit.command.Command; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +public class WECommandSet extends WECommand { + + @Override + public boolean onCommand(CommandSender sender, Command command, String s, String[] args) { + if (!(sender instanceof Player)) return false; + performCommands((Player) sender, "/set " + String.join(" ", args)); + return false; + } + +} diff --git a/BauSystem_Main/src/plugin.yml b/BauSystem_Main/src/plugin.yml index bfd4616..ce245cb 100644 --- a/BauSystem_Main/src/plugin.yml +++ b/BauSystem_Main/src/plugin.yml @@ -32,4 +32,14 @@ commands: aliases: wv lockschem: detonator: - aliases: dt \ No newline at end of file + aliases: dt + + /1: + /2: + /180: + /90: + /-90: + /p: + /c: + /flopy: + /flopyp: