Merge pull request 'WorldEditShortcuts' (#115) from WorldEditShortcuts into master
Reviewed-by: Chaoscaot <chaoscaot444@gmail.com>
Dieser Commit ist enthalten in:
Commit
7bfabf2ddc
@ -20,6 +20,7 @@
|
||||
package de.steamwar.bausystem;
|
||||
|
||||
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;
|
||||
@ -66,14 +67,14 @@ public class BauSystem extends JavaPlugin implements Listener {
|
||||
plugin = this;
|
||||
|
||||
String worldName = Bukkit.getWorlds().get(0).getName();
|
||||
try{
|
||||
try {
|
||||
owner = UUID.fromString(worldName);
|
||||
sections = ArenaSection.loadFromFile(new File(Bukkit.getWorldContainer().getPath() + '/' + getOwner().toString() + "/sections.yml"));
|
||||
}catch(IllegalArgumentException e){
|
||||
try{
|
||||
} catch (IllegalArgumentException e) {
|
||||
try {
|
||||
owner = null;
|
||||
sections = ArenaSection.loadFromFile(new File(Bukkit.getWorldContainer().getPath() + '/' + worldName + "/sections.yml"));
|
||||
}catch(IOException | InvalidConfigurationException ex){
|
||||
} catch (IOException | InvalidConfigurationException ex) {
|
||||
getLogger().log(Level.SEVERE, "owner is no UUID / failed to load sections.yml", e);
|
||||
Bukkit.shutdown();
|
||||
return;
|
||||
@ -118,6 +119,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);
|
||||
@ -129,25 +140,28 @@ public class BauSystem extends JavaPlugin implements Listener {
|
||||
autoShutdown = Bukkit.getScheduler().runTaskLater(this, Bukkit::shutdown, 1200);
|
||||
}
|
||||
|
||||
public static BauSystem getPlugin(){
|
||||
public static BauSystem getPlugin() {
|
||||
return plugin;
|
||||
}
|
||||
public static UUID getOwner(){
|
||||
|
||||
public static UUID getOwner() {
|
||||
//Lazy loading to improve startup time of the server in 1.15
|
||||
if(owner == null){
|
||||
try{
|
||||
if (owner == null) {
|
||||
try {
|
||||
owner = SteamwarUser.get(Integer.parseInt(Bukkit.getWorlds().get(0).getName())).getUUID();
|
||||
}catch(NumberFormatException e){
|
||||
} catch (NumberFormatException e) {
|
||||
Bukkit.shutdown();
|
||||
throw new SecurityException("owner is not a UserID", e);
|
||||
}
|
||||
}
|
||||
return owner;
|
||||
}
|
||||
public static List<ArenaSection> getSections(){
|
||||
|
||||
public static List<ArenaSection> getSections() {
|
||||
return sections;
|
||||
}
|
||||
public static int getOwnerID(){
|
||||
|
||||
public static int getOwnerID() {
|
||||
return SteamwarUser.get(getOwner()).getId();
|
||||
}
|
||||
|
||||
@ -158,7 +172,7 @@ public class BauSystem extends JavaPlugin implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void onJoin(PlayerLoginEvent e) {
|
||||
if(autoShutdown != null){
|
||||
if (autoShutdown != null) {
|
||||
autoShutdown.cancel();
|
||||
autoShutdown = null;
|
||||
}
|
||||
|
@ -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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
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<String> 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<String> manageList(List<String> 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;
|
||||
}
|
||||
|
||||
}
|
@ -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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
@ -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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
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<String> onTabComplete(CommandSender sender, Command command, String s, String[] args) {
|
||||
List<String> tabCompletes = Arrays.asList("-a", "-b", "-e", "-n", "-o", "-s", "-m");
|
||||
if (args.length == 0) {
|
||||
return tabCompletes;
|
||||
}
|
||||
return manageList(tabCompletes, 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;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
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<String> onTabComplete(CommandSender sender, Command command, String s, String[] args) {
|
||||
List<String> tabCompletes = Arrays.asList("-a", "-b", "-e", "-n", "-o", "-s", "-m");
|
||||
if (args.length == 0) {
|
||||
return tabCompletes;
|
||||
}
|
||||
return manageList(tabCompletes, 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;
|
||||
}
|
||||
|
||||
}
|
@ -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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
@ -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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
@ -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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
@ -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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
@ -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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
@ -33,3 +33,13 @@ commands:
|
||||
lockschem:
|
||||
detonator:
|
||||
aliases: dt
|
||||
|
||||
/1:
|
||||
/2:
|
||||
/180:
|
||||
/90:
|
||||
/-90:
|
||||
/p:
|
||||
/c:
|
||||
/flopy:
|
||||
/flopyp:
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren