From 52c2a93f3e28f89d5d90890fee718eb8377d1b73 Mon Sep 17 00:00:00 2001 From: Travis CI Date: Tue, 11 Jun 2019 07:05:05 +0200 Subject: [PATCH] Rework for Multiserver-System (region system missing) --- .gitignore | 1 + pom.xml | 20 +- .../commandframework/BukkitCommand.java | 93 --- .../commandframework/BukkitCompleter.java | 60 -- .../commandframework/Command.java | 74 --- .../commandframework/CommandArgs.java | 105 ---- .../commandframework/CommandFramework.java | 242 -------- .../commandframework/Completer.java | 38 -- src/de/steamwar/bausystem/BauSystem.java | 89 +++ .../bausystem/CommandRemover.java | 17 +- .../bausystem}/Permission.java | 2 +- src/de/steamwar/bausystem/Region.java | 20 + .../bausystem}/RegionListener.java | 35 +- .../bausystem}/TNTTracer.java | 72 +-- .../bausystem/commands/CommandBau.java | 46 +- .../bausystem/commands/CommandFire.java | 19 + .../bausystem/commands/CommandGamemode.java | 65 +- .../bausystem/commands/CommandNV.java | 30 + .../bausystem/commands/CommandReset.java | 19 + .../bausystem/commands/CommandSpeed.java | 40 ++ .../bausystem/commands/CommandTNT.java | 19 + .../bausystem/commands/CommandTeleport.java | 44 +- .../bausystem/commands/CommandTestblock.java | 19 + .../bausystem/commands/CommandTime.java | 47 ++ .../bausystem/commands/CommandTrace.java | 100 ++++ .../bausystem/commands/Welt.java} | 109 +--- src/de/warking/bausystem/BauSystem.java | 257 -------- .../bausystem/commands/CommandGui.java | 556 ------------------ .../warking/bausystem/commands/CommandNV.java | 25 - .../bausystem/commands/CommandTrace.java | 93 --- src/de/warking/bausystem/config/Config.java | 133 ----- .../bausystem/world/LagDetectorRunnable.java | 65 -- src/plugin.yml | 17 +- 33 files changed, 519 insertions(+), 2052 deletions(-) delete mode 100644 src/de/pro_crafting/commandframework/BukkitCommand.java delete mode 100644 src/de/pro_crafting/commandframework/BukkitCompleter.java delete mode 100644 src/de/pro_crafting/commandframework/Command.java delete mode 100644 src/de/pro_crafting/commandframework/CommandArgs.java delete mode 100644 src/de/pro_crafting/commandframework/CommandFramework.java delete mode 100644 src/de/pro_crafting/commandframework/Completer.java create mode 100644 src/de/steamwar/bausystem/BauSystem.java rename src/de/{warking => steamwar}/bausystem/CommandRemover.java (59%) rename src/de/{warking/bausystem/world => steamwar/bausystem}/Permission.java (70%) create mode 100644 src/de/steamwar/bausystem/Region.java rename src/de/{warking/bausystem/world => steamwar/bausystem}/RegionListener.java (64%) rename src/de/{warking/bausystem/world => steamwar/bausystem}/TNTTracer.java (60%) rename src/de/{warking => steamwar}/bausystem/commands/CommandBau.java (92%) create mode 100644 src/de/steamwar/bausystem/commands/CommandFire.java rename src/de/{warking => steamwar}/bausystem/commands/CommandGamemode.java (59%) create mode 100644 src/de/steamwar/bausystem/commands/CommandNV.java create mode 100644 src/de/steamwar/bausystem/commands/CommandReset.java create mode 100644 src/de/steamwar/bausystem/commands/CommandSpeed.java create mode 100644 src/de/steamwar/bausystem/commands/CommandTNT.java rename src/de/{warking => steamwar}/bausystem/commands/CommandTeleport.java (57%) create mode 100644 src/de/steamwar/bausystem/commands/CommandTestblock.java create mode 100644 src/de/steamwar/bausystem/commands/CommandTime.java create mode 100644 src/de/steamwar/bausystem/commands/CommandTrace.java rename src/de/{warking/bausystem/world/BauWorld.java => steamwar/bausystem/commands/Welt.java} (52%) delete mode 100644 src/de/warking/bausystem/BauSystem.java delete mode 100644 src/de/warking/bausystem/commands/CommandGui.java delete mode 100644 src/de/warking/bausystem/commands/CommandNV.java delete mode 100644 src/de/warking/bausystem/commands/CommandTrace.java delete mode 100644 src/de/warking/bausystem/config/Config.java delete mode 100644 src/de/warking/bausystem/world/LagDetectorRunnable.java diff --git a/.gitignore b/.gitignore index 485dee6..ec376bb 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ .idea +target \ No newline at end of file diff --git a/pom.xml b/pom.xml index a251b4b..b7669fe 100644 --- a/pom.xml +++ b/pom.xml @@ -15,11 +15,7 @@ maven - https://warking.de:81/maven/ - - - spigotmc-repo - https://hub.spigotmc.org/nexus/content/repositories/snapshots/ + https://steamwar.de:81/maven/ @@ -49,31 +45,31 @@ - org.spigotmc - spigot-api - 1.12.2-R0.1-SNAPSHOT + steamwar + Spigot + 1.0 provided - warking + steamwar SpigotCore 1.0 provided - warking + steamwar WorldEdit 1.0 provided - warking + steamwar WorldGuard 1.0 provided - warking + steamwar FAWE 1.0 provided diff --git a/src/de/pro_crafting/commandframework/BukkitCommand.java b/src/de/pro_crafting/commandframework/BukkitCommand.java deleted file mode 100644 index 3b1b92e..0000000 --- a/src/de/pro_crafting/commandframework/BukkitCommand.java +++ /dev/null @@ -1,93 +0,0 @@ -package de.pro_crafting.commandframework; - -import org.apache.commons.lang.Validate; -import org.bukkit.command.CommandException; -import org.bukkit.command.CommandExecutor; -import org.bukkit.command.CommandSender; -import org.bukkit.command.TabCompleter; -import org.bukkit.plugin.Plugin; - -import java.util.List; - -/** - * Command Framework - BukkitCommand
- * An implementation of Bukkit's Command class allowing for registering of - * commands without plugin.yml - * - * @author minnymin3 - * - */ -class BukkitCommand extends org.bukkit.command.Command { - - private final Plugin owningPlugin; - private final CommandExecutor executor; - BukkitCompleter completer; - - BukkitCommand(String label, CommandExecutor executor, Plugin owner) { - super(label); - this.executor = executor; - this.owningPlugin = owner; - this.usageMessage = ""; - } - - @Override - public boolean execute(CommandSender sender, String commandLabel, String[] args) { - boolean success; - - if (!owningPlugin.isEnabled()) { - return false; - } - - if (!testPermission(sender)) { - return true; - } - - try { - success = executor.onCommand(sender, this, commandLabel, args); - } catch (Throwable ex) { - throw new CommandException("Unhandled exception executing command '" + commandLabel + "' in plugin " - + owningPlugin.getDescription().getFullName(), ex); - } - - if (!success && usageMessage.length() > 0) { - for (String line : usageMessage.replace("", commandLabel).split("\n")) { - sender.sendMessage(line); - } - } - - return success; - } - - @Override - public java.util.List tabComplete(CommandSender sender, String alias, String[] args) - throws CommandException, IllegalArgumentException { - Validate.notNull(sender, "Sender cannot be null"); - Validate.notNull(args, "Arguments cannot be null"); - Validate.notNull(alias, "Alias cannot be null"); - - List completions = null; - try { - if (completer != null) { - completions = completer.onTabComplete(sender, this, alias, args); - } - if (completions == null && executor instanceof TabCompleter) { - completions = ((TabCompleter) executor).onTabComplete(sender, this, alias, args); - } - } catch (Throwable ex) { - StringBuilder message = new StringBuilder(); - message.append("Unhandled exception during tab completion for command '/").append(alias).append(' '); - for (String arg : args) { - message.append(arg).append(' '); - } - message.deleteCharAt(message.length() - 1).append("' in plugin ") - .append(owningPlugin.getDescription().getFullName()); - throw new CommandException(message.toString(), ex); - } - - if (completions == null) { - return super.tabComplete(sender, alias, args); - } - return completions; - } - -} diff --git a/src/de/pro_crafting/commandframework/BukkitCompleter.java b/src/de/pro_crafting/commandframework/BukkitCompleter.java deleted file mode 100644 index d8c3736..0000000 --- a/src/de/pro_crafting/commandframework/BukkitCompleter.java +++ /dev/null @@ -1,60 +0,0 @@ -package de.pro_crafting.commandframework; - -import org.bukkit.command.Command; -import org.bukkit.command.CommandSender; -import org.bukkit.command.TabCompleter; - -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; -import java.util.AbstractMap; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; - -/** - * Command Framework - BukkitCompleter
- * An implementation of the TabCompleter class allowing for multiple tab - * completers per command - * - * @author minnymin3 - * - */ -public class BukkitCompleter implements TabCompleter { - - private final Map> completers = new HashMap<>(); - - public void addCompleter(String label, Method m, Object obj) { - completers.put(label, new AbstractMap.SimpleEntry<>(m, obj)); - } - - @SuppressWarnings("unchecked") - public List onTabComplete(CommandSender sender, Command command, String label, String[] args) { - for (int i = args.length; i >= 0; i--) { - StringBuilder buffer = new StringBuilder(); - buffer.append(label.toLowerCase()); - for (int x = 0; x < i; x++) { - if (!args[x].equals("") && !args[x].equals(" ")) { - buffer.append(".").append(args[x].toLowerCase()); - } - } - String cmdLabel = buffer.toString(); - if (completers.containsKey(cmdLabel)) { - Entry entry = completers.get(cmdLabel); - try { - List labelParts = (List) entry.getKey().invoke(entry.getValue(), - new CommandArgs(sender, command, cmdLabel, args, cmdLabel.split("\\.").length - 1)); - if (labelParts == null || labelParts.size() == 0) - { - return null; - } - return labelParts; - } catch (IllegalArgumentException | InvocationTargetException | IllegalAccessException e) { - e.printStackTrace(); - } - } - } - return null; - } - -} \ No newline at end of file diff --git a/src/de/pro_crafting/commandframework/Command.java b/src/de/pro_crafting/commandframework/Command.java deleted file mode 100644 index 633289f..0000000 --- a/src/de/pro_crafting/commandframework/Command.java +++ /dev/null @@ -1,74 +0,0 @@ -package de.pro_crafting.commandframework; - -import de.warking.bausystem.BauSystem; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * Command Framework - Command
- * The command annotation used to designate methods as commands. All methods - * should have a single CommandArgs argument - * - * @author minnymin3 - * - */ -@Target(ElementType.METHOD) -@Retention(RetentionPolicy.RUNTIME) -public @interface Command { - - /** - * The name of the command. If it is a sub command then its values would be - * separated by periods. ie. a command that would be a subcommand of test - * would be 'test.subcommandname' - * - * @return - */ - String name(); - - /** - * Gets the required permission of the command - * - * @return - */ - String permission() default ""; - - /** - * The message sent to the player when they do not have permission to - * execute it - * - * @return - */ - String noPerm() default BauSystem.PREFIX + "§cFür diesen Befehl hast du keine Rechte"; - - /** - * A list of alternate names that the command is executed under. See - * name() for details on how names work - * - * @return - */ - String[] aliases() default {}; - - /** - * The description that will appear in /help of the command - * - * @return - */ - String description() default ""; - - /** - * The usage that will appear in /help (commandname) - * - * @return - */ - String usage() default ""; - - /** - * Whether or not the command is available to players only - * - * @return - */ - boolean inGameOnly() default false; -} diff --git a/src/de/pro_crafting/commandframework/CommandArgs.java b/src/de/pro_crafting/commandframework/CommandArgs.java deleted file mode 100644 index 06cc5d0..0000000 --- a/src/de/pro_crafting/commandframework/CommandArgs.java +++ /dev/null @@ -1,105 +0,0 @@ -package de.pro_crafting.commandframework; - -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; - -/** - * Command Framework - CommandArgs
- * This class is passed to the command methods and contains various utilities as - * well as the command info. - * - * @author minnymin3 - * - */ -public class CommandArgs { - - private final CommandSender sender; - private final org.bukkit.command.Command command; - private final String label; - private final String[] args; - - CommandArgs(CommandSender sender, org.bukkit.command.Command command, String label, String[] args, - int subCommand) { - String[] modArgs = new String[args.length - subCommand]; - if (args.length - subCommand >= 0) System.arraycopy(args, 0 + subCommand, modArgs, 0, args.length - subCommand); - - StringBuilder buffer = new StringBuilder(); - buffer.append(label); - for (int x = 0; x < subCommand; x++) { - buffer.append(".").append(args[x]); - } - String cmdLabel = buffer.toString(); - this.sender = sender; - this.command = command; - this.label = cmdLabel; - this.args = modArgs; - } - - /** - * Gets the command sender - * - * @return - */ - public CommandSender getSender() { - return sender; - } - - /** - * Gets the original command object - * - * @return - */ - public org.bukkit.command.Command getCommand() { - return command; - } - - /** - * Gets the label including sub command labels of this command - * - * @return Something like 'test.subcommand' - */ - public String getLabel() { - return label; - } - - /** - * Gets all the arguments after the command's label. ie. if the command - * label was test.subcommand and the arguments were subcommand foo foo, it - * would only return 'foo foo' because 'subcommand' is part of the command - * - * @return - */ - public String[] getArgs() { - return args; - } - - /** - * Gets the argument at the specified index - * @param index The index to get - * @return The string at the specified index - */ - public String getArgs(int index) { - return args[index]; - } - - /** - * Returns the length of the command arguments - * @return int length of args - */ - public int length() { - return args.length; - } - - public boolean isPlayer() { - return sender instanceof Player; - } - - public Player getPlayer() { - if (sender instanceof Player) { - return (Player) sender; - } else { - return null; - } - } - -} diff --git a/src/de/pro_crafting/commandframework/CommandFramework.java b/src/de/pro_crafting/commandframework/CommandFramework.java deleted file mode 100644 index d48db31..0000000 --- a/src/de/pro_crafting/commandframework/CommandFramework.java +++ /dev/null @@ -1,242 +0,0 @@ -package de.pro_crafting.commandframework; - -import org.bukkit.Bukkit; -import org.bukkit.command.CommandExecutor; -import org.bukkit.command.CommandMap; -import org.bukkit.command.CommandSender; -import org.bukkit.command.PluginCommand; -import org.bukkit.entity.Player; -import org.bukkit.help.GenericCommandHelpTopic; -import org.bukkit.help.HelpTopic; -import org.bukkit.help.HelpTopicComparator; -import org.bukkit.help.IndexHelpTopic; -import org.bukkit.plugin.Plugin; -import org.bukkit.plugin.SimplePluginManager; - -import java.lang.reflect.Field; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; -import java.util.*; -import java.util.Map.Entry; - -/** - * Command Framework - CommandFramework
- * The main command framework class used for controlling the framework. - * - * @author minnymin3 - * - */ -public class CommandFramework implements CommandExecutor { - - private final Map> commandMap = new HashMap<>(); - private CommandMap map; - private final Plugin plugin; - private String noPermMessage = null; - - private String inGameOnlyMessage; - - /** - * Initializes the command framework and sets up the command maps - */ - public CommandFramework(Plugin plugin) { - this.plugin = plugin; - if (plugin.getServer().getPluginManager() instanceof SimplePluginManager) { - SimplePluginManager manager = (SimplePluginManager) plugin.getServer().getPluginManager(); - try { - Field field = SimplePluginManager.class.getDeclaredField("commandMap"); - field.setAccessible(true); - map = (CommandMap) field.get(manager); - } catch (IllegalArgumentException | NoSuchFieldException | IllegalAccessException | SecurityException e) { - e.printStackTrace(); - } - } - - this.inGameOnlyMessage = "This command is only performable in game"; - } - - public String[] getCommandLabels() - { - return this.commandMap.keySet().toArray(new String[0]); - } - - public boolean onCommand(CommandSender sender, org.bukkit.command.Command cmd, String label, String[] args) { - return handleCommand(sender, cmd, label, args); - } - - /** - * Handles commands. Used in the onCommand method in your JavaPlugin class - * - * @param sender The {@link org.bukkit.command.CommandSender} parsed from - * onCommand - * @param cmd The {@link org.bukkit.command.Command} parsed from onCommand - * @param label The label parsed from onCommand - * @param args The arguments parsed from onCommand - * @return Always returns true for simplicity's sake in onCommand - */ - private boolean handleCommand(CommandSender sender, org.bukkit.command.Command cmd, String label, String[] args) { - for (int i = args.length; i >= 0; i--) { - StringBuilder buffer = new StringBuilder(); - buffer.append(label.toLowerCase()); - for (int x = 0; x < i; x++) { - buffer.append(".").append(args[x].toLowerCase()); - } - String cmdLabel = buffer.toString(); - if (commandMap.containsKey(cmdLabel)) { - Method method = commandMap.get(cmdLabel).getKey(); - Object methodObject = commandMap.get(cmdLabel).getValue(); - Command command = method.getAnnotation(Command.class); - command.permission(); - if (!command.permission().isEmpty() && !sender.hasPermission(command.permission())) { - if(!command.noPerm().equals("You do not have permission to perform that action") || this.noPermMessage == null){ - sender.sendMessage(command.noPerm()); - return true; - } - - sender.sendMessage(this.noPermMessage); - return true; - - - } - if (command.inGameOnly() && !(sender instanceof Player)) { - sender.sendMessage(this.inGameOnlyMessage); - return true; - } - try { - method.invoke(methodObject, new CommandArgs(sender, cmd, label, args, - cmdLabel.split("\\.").length - 1)); - } catch (IllegalArgumentException | InvocationTargetException | IllegalAccessException e) { - e.printStackTrace(); - } - return true; - } - } - defaultCommand(new CommandArgs(sender, cmd, label, args, 0)); - return true; - } - - public void setNoPermMessage(String message){ - this.noPermMessage = message; - } - - public String getNoPermMessage(){ - return this.noPermMessage; - } - - /** - * Registers all command and completer methods inside of the object. Similar - * to Bukkit's registerEvents method. - * - * @param obj The object to register the commands of - */ - public void registerCommands(Object obj) { - for (Method m : obj.getClass().getMethods()) { - if (m.getAnnotation(Command.class) != null) { - Command command = m.getAnnotation(Command.class); - if (m.getParameterTypes().length != 1 || m.getParameterTypes()[0] != CommandArgs.class) { - plugin.getLogger().warning("Unable to register command " + m.getName() + - ". Unexpected method arguments"); - continue; - } - registerCommand(command, command.name(), m, obj); - for (String alias : command.aliases()) { - registerCommand(command, alias, m, obj); - } - } else if (m.getAnnotation(Completer.class) != null) { - Completer comp = m.getAnnotation(Completer.class); - if (m.getParameterTypes().length > 1 || m.getParameterTypes().length == 0 || m.getParameterTypes()[0] != CommandArgs.class) { - plugin.getLogger().warning("Unable to register tab completer " + m.getName() + - ". Unexpected method arguments"); - continue; - } - if (m.getReturnType() != List.class) { - plugin.getLogger().warning("Unable to register command " + m.getName() + - ". Unexpected return type"); - continue; - } - registerCompleter(comp.name(), m, obj); - for (String alias : comp.aliases()) { - registerCompleter(alias, m, obj); - } - } - } - } - - /** - * Registers all the commands under the plugin's help - */ - public void registerHelp() { - Set help = new TreeSet<>(HelpTopicComparator.helpTopicComparatorInstance()); - for (String s : commandMap.keySet()) { - if (!s.contains(".")) { - org.bukkit.command.Command cmd = map.getCommand(s); - HelpTopic topic = new GenericCommandHelpTopic(cmd); - help.add(topic); - } - } - IndexHelpTopic topic = new IndexHelpTopic(plugin.getName(), "All commands for " + plugin.getName(), null, help, - "Below is a list of all " + plugin.getName() + " commands:"); - Bukkit.getServer().getHelpMap().addTopic(topic); - } - - private void registerCommand(Command command, String label, Method m, Object obj) { - commandMap.put(label.toLowerCase(), new AbstractMap.SimpleEntry<>(m, obj)); - String cmdLabel = label.replace(".", ",").split(",")[0].toLowerCase(); - if (map.getCommand(cmdLabel) == null) { - org.bukkit.command.Command cmd = new BukkitCommand(cmdLabel, this, plugin); - map.register(plugin.getName(), cmd); - } - if (!command.description().equalsIgnoreCase("") && cmdLabel.equals(label)) { - map.getCommand(cmdLabel).setDescription(command.description()); - } - if (!command.usage().equalsIgnoreCase("") && cmdLabel.equals(label)) { - map.getCommand(cmdLabel).setUsage(command.usage()); - } - } - - public void registerCompleter(String label, Method m, Object obj) { - String cmdLabel = label.replace(".", ",").split(",")[0].toLowerCase(); - if (map.getCommand(cmdLabel) == null) { - org.bukkit.command.Command command = new BukkitCommand(cmdLabel, this, plugin); - map.register(plugin.getName(), command); - } - if (map.getCommand(cmdLabel) instanceof BukkitCommand) { - BukkitCommand command = (BukkitCommand) map.getCommand(cmdLabel); - if (command.completer == null) { - command.completer = new BukkitCompleter(); - } - command.completer.addCompleter(label, m, obj); - } else if (map.getCommand(cmdLabel) instanceof PluginCommand) { - try { - Object command = map.getCommand(cmdLabel); - Field field = command.getClass().getDeclaredField("completer"); - field.setAccessible(true); - if (field.get(command) == null) { - BukkitCompleter completer = new BukkitCompleter(); - completer.addCompleter(label, m, obj); - field.set(command, completer); - } else if (field.get(command) instanceof BukkitCompleter) { - BukkitCompleter completer = (BukkitCompleter) field.get(command); - completer.addCompleter(label, m, obj); - } else { - plugin.getLogger().warning("Unable to register tab completer " + m.getName() - + ". A tab completer is already registered for that command!"); - } - } catch (Exception ex) { - ex.printStackTrace(); - } - } - } - - private void defaultCommand(CommandArgs args) { - args.getSender().sendMessage(args.getLabel() + " is not handled! Oh noes!"); - } - - public String getInGameOnlyMessage() { - return this.inGameOnlyMessage; - } - - public void setInGameOnlyMessage(String inGameOnlyMessage) { - this.inGameOnlyMessage = inGameOnlyMessage; - } - -} diff --git a/src/de/pro_crafting/commandframework/Completer.java b/src/de/pro_crafting/commandframework/Completer.java deleted file mode 100644 index c17e5ce..0000000 --- a/src/de/pro_crafting/commandframework/Completer.java +++ /dev/null @@ -1,38 +0,0 @@ -package de.pro_crafting.commandframework; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * Command Framework - Completer
- * The completer annotation used to designate methods as command completers. All - * methods should have a single CommandArgs argument and return a String List - * object - * - * @author minnymin3 - * - */ -@Target(ElementType.METHOD) -@Retention(RetentionPolicy.RUNTIME) -public @interface Completer { - - /** - * The command that this completer completes. If it is a sub command then - * its values would be separated by periods. ie. a command that would be a - * subcommand of test would be 'test.subcommandname' - * - * @return - */ - String name(); - - /** - * A list of alternate names that the completer is executed under. See - * name() for details on how names work - * - * @return - */ - String[] aliases() default {}; - -} diff --git a/src/de/steamwar/bausystem/BauSystem.java b/src/de/steamwar/bausystem/BauSystem.java new file mode 100644 index 0000000..510ae06 --- /dev/null +++ b/src/de/steamwar/bausystem/BauSystem.java @@ -0,0 +1,89 @@ +package de.steamwar.bausystem; + +import de.steamwar.bausystem.commands.*; +import de.warking.hunjy.MySQL.Bauwelt; +import org.bukkit.Bukkit; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.event.entity.PlayerDeathEvent; +import org.bukkit.event.player.PlayerJoinEvent; +import org.bukkit.permissions.PermissionAttachment; +import org.bukkit.plugin.java.JavaPlugin; + +import java.util.UUID; + +public class BauSystem extends JavaPlugin implements Listener { + private static BauSystem plugin; + private static UUID owner; + private static Bauwelt welt; + private static TNTTracer tracer; + public static final String PREFIX = "§eBauSystem§8» §7"; + + @Override + public void onEnable() { + plugin = this; + + try{ + owner = UUID.fromString(Bukkit.getWorlds().get(0).getName()); + }catch(IllegalArgumentException e){ + e.printStackTrace(); + Bukkit.shutdown(); + return; + } + welt = Bauwelt.getBauwelt(owner); + tracer = new TNTTracer(); + + try { + CommandRemover.removeCommand("tp"); + CommandRemover.injectCommand(new CommandTeleport()); + CommandRemover.removeCommand("gamemode"); + CommandRemover.injectCommand(new CommandGamemode()); + CommandRemover.removeCommand("time"); + CommandRemover.injectCommand(new CommandTime()); + } catch (Exception e) { + e.printStackTrace(); + Bukkit.shutdown(); + return; + } + + getCommand("trace").setExecutor(new CommandTrace()); + getCommand("nightvision").setExecutor(new CommandNV()); + getCommand("reset").setExecutor(new CommandReset()); + getCommand("speed").setExecutor(new CommandSpeed()); + getCommand("tnt").setExecutor(new CommandTNT()); + getCommand("fire").setExecutor(new CommandFire()); + getCommand("testblock").setExecutor(new CommandTestblock()); + + Bukkit.getPluginManager().registerEvents(this, this); + Bukkit.getPluginManager().registerEvents(new RegionListener(), this); + } + + public static BauSystem getPlugin(){ + return plugin; + } + public static UUID getOwner(){ + return owner; + } + public static Bauwelt getWelt(){ + return welt; + } + public static TNTTracer getTracer(){ + return tracer; + } + + @EventHandler + public void onDeath(PlayerDeathEvent e) { + e.setDeathMessage(null); + } + + @EventHandler + public void onJoin(PlayerJoinEvent e) { + Player p = e.getPlayer(); + PermissionAttachment attachment = p.addAttachment(this); + attachment.setPermission("F3NPerm.use", true); + attachment.setPermission("fawe.permpack.basic", true); + attachment.setPermission("worldedit.navigation.jumpto.tool", true); + attachment.setPermission("worldedit.navigation.thru.tool", true); + } +} diff --git a/src/de/warking/bausystem/CommandRemover.java b/src/de/steamwar/bausystem/CommandRemover.java similarity index 59% rename from src/de/warking/bausystem/CommandRemover.java rename to src/de/steamwar/bausystem/CommandRemover.java index 1447cda..7aabdef 100644 --- a/src/de/warking/bausystem/CommandRemover.java +++ b/src/de/steamwar/bausystem/CommandRemover.java @@ -1,4 +1,4 @@ -package de.warking.bausystem; +package de.steamwar.bausystem; import org.bukkit.Bukkit; import org.bukkit.command.Command; @@ -9,8 +9,10 @@ import java.util.Map; class CommandRemover { - private static final String packageName = Bukkit.getServer().getClass().getPackage().getName(); - private static final String version = packageName.substring(packageName.lastIndexOf(".") + 1); + private CommandRemover(){} + + 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 removeAll(String... cmds) throws Exception { for (String cmd : cmds) removeCommand(cmd); @@ -24,7 +26,7 @@ class CommandRemover { * @throws Exception */ public static void removeCommand(String command) throws Exception { - Class serverClass = Class.forName("org.bukkit.craftbukkit." + version + ".CraftServer"); + Class serverClass = Class.forName("org.bukkit.craftbukkit." + VERSION + ".CraftServer"); Field f1 = serverClass.getDeclaredField("commandMap"); f1.setAccessible(true); @@ -37,5 +39,12 @@ class CommandRemover { knownCommands.remove(command.toLowerCase()); } + 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/src/de/warking/bausystem/world/Permission.java b/src/de/steamwar/bausystem/Permission.java similarity index 70% rename from src/de/warking/bausystem/world/Permission.java rename to src/de/steamwar/bausystem/Permission.java index be28fb3..707bf85 100644 --- a/src/de/warking/bausystem/world/Permission.java +++ b/src/de/steamwar/bausystem/Permission.java @@ -1,4 +1,4 @@ -package de.warking.bausystem.world; +package de.steamwar.bausystem; public enum Permission { world, diff --git a/src/de/steamwar/bausystem/Region.java b/src/de/steamwar/bausystem/Region.java new file mode 100644 index 0000000..93bfe74 --- /dev/null +++ b/src/de/steamwar/bausystem/Region.java @@ -0,0 +1,20 @@ +package de.steamwar.bausystem; + +public class Region { + + int SchemsizeX; + int SchemsizeY; + int SchemsizeZ; + + int MinX; + int MinY; + int MinZ; + + int MaxX; + int MaxY; + int MaxZ; + + boolean TestblockSouth; + + //TODO: ADD MORE +} diff --git a/src/de/warking/bausystem/world/RegionListener.java b/src/de/steamwar/bausystem/RegionListener.java similarity index 64% rename from src/de/warking/bausystem/world/RegionListener.java rename to src/de/steamwar/bausystem/RegionListener.java index 432acc2..980b172 100644 --- a/src/de/warking/bausystem/world/RegionListener.java +++ b/src/de/steamwar/bausystem/RegionListener.java @@ -1,9 +1,8 @@ -package de.warking.bausystem.world; +package de.steamwar.bausystem; import com.sk89q.worldedit.bukkit.WorldEditPlugin; -import de.warking.bausystem.BauSystem; -import de.warking.hunjy.MySQL.Bauwelt; +import de.steamwar.bausystem.commands.Welt; import org.bukkit.Bukkit; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -15,16 +14,9 @@ import org.bukkit.event.block.BlockPlaceEvent; import org.bukkit.event.block.BlockSpreadEvent; import org.bukkit.event.entity.EntityExplodeEvent; import org.bukkit.event.player.PlayerCommandPreprocessEvent; -import org.bukkit.plugin.java.JavaPlugin; - -import java.util.UUID; public class RegionListener implements Listener { - public RegionListener(JavaPlugin plugin) { - plugin.getServer().getPluginManager().registerEvents(this, plugin); - } - @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) public void playerCommandHandler(PlayerCommandPreprocessEvent e) { if (!isWorldEditCommand(e.getMessage().split(" ")[0])) @@ -32,8 +24,7 @@ public class RegionListener implements Listener { Player p = e.getPlayer(); - UUID worldOwner = BauWorld.getWorldUUID(p.getWorld()); - if (!BauWorld.hasPermission(worldOwner, p, Permission.worldedit)){ + if (!Welt.hasPermission(p, Permission.worldedit)){ p.sendMessage(BauSystem.PREFIX + "§cDu darfst hier kein WorldEdit benutzen"); e.setCancelled(true); } @@ -42,8 +33,8 @@ public class RegionListener implements Listener { @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) public void onBlockBreak(BlockBreakEvent e) { Player p = e.getPlayer(); - UUID worldOwner = BauWorld.getWorldUUID(p.getWorld()); - if (!BauWorld.hasPermission(worldOwner, p, Permission.build)){ + + if (!Welt.hasPermission(p, Permission.build)){ p.sendMessage(BauSystem.PREFIX + "§cDu darfst hier keine Blöcke abbauen"); e.setCancelled(true); } @@ -52,8 +43,8 @@ public class RegionListener implements Listener { @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) public void onBlockPlace(BlockPlaceEvent e) { Player p = e.getPlayer(); - UUID worldOwner = BauWorld.getWorldUUID(p.getWorld()); - if (!BauWorld.hasPermission(worldOwner, p, Permission.build)){ + + if (!Welt.hasPermission(p, Permission.build)){ p.sendMessage(BauSystem.PREFIX + "§cDu darfst hier keine Blöcke platzieren"); e.setCancelled(true); } @@ -70,25 +61,19 @@ public class RegionListener implements Listener { @EventHandler public void onExplode(EntityExplodeEvent e) { - UUID worldOwner = BauWorld.getWorldUUID(e.getLocation().getWorld()); - - if(worldOwner == null || Bauwelt.getBauwelt(worldOwner) == null || !Bauwelt.getBauwelt(worldOwner).isTNTDmg()) + if(!BauSystem.getWelt().isTNTDmg()) e.setCancelled(true); } @EventHandler public void onFireDamage(BlockBurnEvent e) { - UUID worldOwner = BauWorld.getWorldUUID(e.getBlock().getWorld()); - - if(worldOwner == null || Bauwelt.getBauwelt(worldOwner) == null || !Bauwelt.getBauwelt(worldOwner).isFireDmg()) + if(!BauSystem.getWelt().isFireDmg()) e.setCancelled(true); } @EventHandler public void onFireSpread(BlockSpreadEvent e){ - UUID worldOwner = BauWorld.getWorldUUID(e.getBlock().getWorld()); - - if(worldOwner == null || Bauwelt.getBauwelt(worldOwner) == null || !Bauwelt.getBauwelt(worldOwner).isFireDmg()) + if(!BauSystem.getWelt().isFireDmg()) e.setCancelled(true); } } diff --git a/src/de/warking/bausystem/world/TNTTracer.java b/src/de/steamwar/bausystem/TNTTracer.java similarity index 60% rename from src/de/warking/bausystem/world/TNTTracer.java rename to src/de/steamwar/bausystem/TNTTracer.java index 1db3336..d09de56 100644 --- a/src/de/warking/bausystem/world/TNTTracer.java +++ b/src/de/steamwar/bausystem/TNTTracer.java @@ -1,6 +1,5 @@ -package de.warking.bausystem.world; +package de.steamwar.bausystem; -import de.warking.bausystem.BauSystem; import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.Material; @@ -9,52 +8,53 @@ import org.bukkit.block.Block; import org.bukkit.entity.Entity; import org.bukkit.entity.Player; import org.bukkit.entity.TNTPrimed; -import org.bukkit.event.EventHandler; -import org.bukkit.event.HandlerList; -import org.bukkit.event.Listener; -import org.bukkit.event.world.WorldUnloadEvent; import org.bukkit.scheduler.BukkitTask; -import java.util.HashMap; import java.util.HashSet; -import java.util.Map; import java.util.Set; -public class TNTTracer implements Listener, Runnable { +public class TNTTracer implements Runnable { - private static final Map allTracer = new HashMap<>(); - - private final World world; - private final BukkitTask task; + private BukkitTask task; private final Set locations; private boolean printed; + private boolean active; - private TNTTracer(World world){ - this.world = world; + TNTTracer(){ this.locations = new HashSet<>(); this.printed = false; - this.task = Bukkit.getScheduler().runTaskTimer(BauSystem.getInstance(), this, 1, 1); - Bukkit.getPluginManager().registerEvents(this, BauSystem.getInstance()); - allTracer.put(world, this); + this.active = false; } - private void stop(){ + public void start(){ + active = true; + this.task = Bukkit.getScheduler().runTaskTimer(BauSystem.getPlugin(), this, 1, 1); + } + + private void end(){ + active = false; task.cancel(); - HandlerList.unregisterAll(this); } - public void end(){ - stop(); + public boolean isActive(){ + return active; + } + public boolean isPrinted(){ + return printed; + } + + public void stop(){ + end(); if(!printed){ locations.clear(); - allTracer.remove(world); } } public void show(){ - stop(); + end(); printed = true; Set unsetLoc = new HashSet<>(); + World world = Bukkit.getWorlds().get(0); for(Location l : locations){ Block b = world.getBlockAt(l); if(b.getType() != Material.AIR){ @@ -70,6 +70,7 @@ public class TNTTracer implements Listener, Runnable { public void hide(){ if(!printed) return; + World world = Bukkit.getWorlds().get(0); for(Location l : locations){ Block b = world.getBlockAt(l); if(b.getType() != Material.STAINED_GLASS || b.getData() != 1) @@ -77,20 +78,13 @@ public class TNTTracer implements Listener, Runnable { b.setType(Material.AIR); } printed = false; - end(); - } - - @EventHandler - public void onUnloadWorld(WorldUnloadEvent e){ - if(e.getWorld().equals(world)){ - printed = false; - end(); - } + stop(); } @Override public void run() { if(locations.size() < 20000){ + World world = Bukkit.getWorlds().get(0); for(Entity e : world.getEntitiesByClass(TNTPrimed.class)){ locations.add(e.getLocation()); } @@ -101,16 +95,4 @@ public class TNTTracer implements Listener, Runnable { } } } - - public static void newTracer(World w){ - if(allTracer.containsKey(w)){ - TNTTracer existing = allTracer.get(w); - existing.end(); - } - new TNTTracer(w); - } - - public static TNTTracer get(World w){ - return allTracer.get(w); - } } diff --git a/src/de/warking/bausystem/commands/CommandBau.java b/src/de/steamwar/bausystem/commands/CommandBau.java similarity index 92% rename from src/de/warking/bausystem/commands/CommandBau.java rename to src/de/steamwar/bausystem/commands/CommandBau.java index 1ae238e..0434022 100644 --- a/src/de/warking/bausystem/commands/CommandBau.java +++ b/src/de/steamwar/bausystem/commands/CommandBau.java @@ -1,36 +1,10 @@ -package de.warking.bausystem.commands; - -import com.sk89q.worldedit.CuboidClipboard; -import com.sk89q.worldedit.EditSession; -import com.sk89q.worldedit.Vector; -import com.sk89q.worldedit.blocks.BaseBlock; -import com.sk89q.worldedit.bukkit.BukkitWorld; -import com.sk89q.worldedit.bukkit.selections.CuboidSelection; -import com.sk89q.worldedit.schematic.MCEditSchematicFormat; -import com.sk89q.worldguard.protection.regions.ProtectedRegion; -import de.pro_crafting.commandframework.Command; -import de.pro_crafting.commandframework.CommandArgs; -import de.warking.bausystem.BauSystem; -import de.warking.bausystem.world.BauWorld; -import de.warking.bausystem.world.Permission; -import de.warking.hunjy.MySQL.Bauwelt; -import de.warking.hunjy.MySQL.BauweltMember; -import de.warking.hunjy.MySQL.WarkingUser; -import org.bukkit.Bukkit; -import org.bukkit.GameMode; -import org.bukkit.Location; -import org.bukkit.World; -import org.bukkit.entity.Player; - -import java.io.File; -import java.io.IOException; -import java.util.HashSet; -import java.util.List; -import java.util.Set; -import java.util.UUID; +package de.steamwar.bausystem.commands; public class CommandBau { + //TODO: Move to BungeeCore + + /* @Command(name = "bau", aliases = {"bau.help", "gs", "gs.help"}, inGameOnly = true) public void onHelp(CommandArgs args) { Player p = args.getPlayer(); @@ -43,9 +17,6 @@ public class CommandBau { p.sendMessage("§6/testblock §7- Erneuert den nächsten Testblock"); p.sendMessage("§6/reset §7- Setzt die derzeitige Region zurück"); p.sendMessage("§6/bau resetall §7- Setzt deine Welt zurück"); - p.sendMessage("§6/bau replace §7- Ersetzt in einer Region Obsidian zu TNT und Grundgestein zu Schleim"); - p.sendMessage("§6/bau tp §7- Teleportiert dich auf eine Welt"); - p.sendMessage("§6/bau info §7- Informationen über die aktuelle Welt"); p.sendMessage("§6/speed §7- Ändert deine Fluggeschwindigkeit"); p.sendMessage("§6/nv §7- (de)aktiviert Nachtsicht"); p.sendMessage("§6/trace §7- Gibt einen Überblick über den TNT-Tracer"); @@ -157,13 +128,6 @@ public class CommandBau { BauWorld.removePlayer(p, target); } - /*@Command(name = "bau.gui", aliases = "gs.gui", inGameOnly = true) - public boolean ongui(CommandArgs args) { - final Player p = args.getPlayer(); - p.openInventory(CommandGui.mainmenu()); - return true; - }*/ - @Command(name = "bau.togglebuild", aliases = "gs.togglebuild", inGameOnly = true) public void onToggleBD(CommandArgs args) { Player p = args.getPlayer(); @@ -486,5 +450,5 @@ public class CommandBau { return false; } return true; - } + }*/ } diff --git a/src/de/steamwar/bausystem/commands/CommandFire.java b/src/de/steamwar/bausystem/commands/CommandFire.java new file mode 100644 index 0000000..9f36045 --- /dev/null +++ b/src/de/steamwar/bausystem/commands/CommandFire.java @@ -0,0 +1,19 @@ +package de.steamwar.bausystem.commands; + +import org.bukkit.command.Command; +import org.bukkit.command.CommandExecutor; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +public class CommandFire implements CommandExecutor { + + @Override + public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + if(!(sender instanceof Player)) + return false; + Player player = (Player) sender; + + Welt.switchFire(player); + return false; + } +} diff --git a/src/de/warking/bausystem/commands/CommandGamemode.java b/src/de/steamwar/bausystem/commands/CommandGamemode.java similarity index 59% rename from src/de/warking/bausystem/commands/CommandGamemode.java rename to src/de/steamwar/bausystem/commands/CommandGamemode.java index eaba9ed..342b135 100644 --- a/src/de/warking/bausystem/commands/CommandGamemode.java +++ b/src/de/steamwar/bausystem/commands/CommandGamemode.java @@ -1,11 +1,9 @@ -package de.warking.bausystem.commands; +package de.steamwar.bausystem.commands; import com.google.common.collect.ImmutableList; -import de.warking.bausystem.BauSystem; +import de.steamwar.bausystem.BauSystem; import de.warking.hunjy.MySQL.BauweltMember; -import de.warking.hunjy.MySQL.WarkingUser; import org.apache.commons.lang.Validate; -import org.bukkit.Bukkit; import org.bukkit.GameMode; import org.bukkit.command.CommandSender; import org.bukkit.command.defaults.BukkitCommand; @@ -14,16 +12,15 @@ import org.bukkit.util.StringUtil; import java.util.ArrayList; import java.util.List; -import java.util.UUID; public class CommandGamemode extends BukkitCommand { private static final List GAMEMODE_NAMES = ImmutableList.of("adventure", "creative", "survival", "spectator"); public CommandGamemode() { - super("gm"); + super("gamemode"); List aliases = new ArrayList<>(); - aliases.add("gamemode"); + aliases.add("gm"); this.setAliases(aliases); this.description = "Ändert den Spielmodus eines Spielers"; this.usageMessage = "/gm [Spielmodus]"; @@ -39,52 +36,12 @@ public class CommandGamemode extends BukkitCommand { Player p = (Player) sender; - WarkingUser user = WarkingUser.get(p.getUniqueId()); - - if(p.hasPermission("bau.team")){ - GameMode mode = createMode(args[0]); - - if(mode == null){ - p.sendMessage(BauSystem.PREFIX + "§cUnbekannter Spielmodus."); + if(!p.getUniqueId().equals(BauSystem.getOwner())){ + BauweltMember member = BauweltMember.getBauMember(BauSystem.getOwner(), p.getUniqueId()); + if(member == null || !member.isBuild()){ + p.sendMessage(BauSystem.PREFIX + "§cDu darfst hier deinen Spielmodus nicht ändern"); return false; } - - if(args.length == 2){ - Player target = Bukkit.getPlayerExact(args[1]); - - if (target == null) { - p.sendMessage(BauSystem.PREFIX + "§cDieser Spieler ist derzeit offline."); - return true; - } - if(p.getUniqueId().equals(target)){ - p.sendMessage(BauSystem.PREFIX + "§cSei eins mit dir selbst!"); - return false; - } - target.setGameMode(mode); - }else{ - p.setGameMode(mode); - } - return true; - }else if(args.length > 1){ - p.sendMessage(BauSystem.PREFIX + "§cDu darfst den Spielmodus anderer Spieler nicht ändern"); - return false; - }else{ - UUID worldOwner; - - try{ - worldOwner = UUID.fromString(p.getWorld().getName()); - }catch(IllegalArgumentException E){ - p.sendMessage(BauSystem.PREFIX + "§cDu befindest dich auf keiner Bauwelt"); - return false; - } - - if(!p.getUniqueId().equals(worldOwner)){ - BauweltMember member = BauweltMember.getBauMember(worldOwner, p.getUniqueId()); - if(member == null || !member.isBuild()){ - p.sendMessage(BauSystem.PREFIX + "§cDu darfst hier deinen Spielmodus nicht ändern"); - return false; - } - } } GameMode mode = createMode(args[0]); @@ -108,13 +65,11 @@ public class CommandGamemode extends BukkitCommand { return GameMode.ADVENTURE; else if ((modeArg.equalsIgnoreCase("spectator")) || (modeArg.equalsIgnoreCase("sp"))) return GameMode.SPECTATOR; - else { - 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"); diff --git a/src/de/steamwar/bausystem/commands/CommandNV.java b/src/de/steamwar/bausystem/commands/CommandNV.java new file mode 100644 index 0000000..e96f26c --- /dev/null +++ b/src/de/steamwar/bausystem/commands/CommandNV.java @@ -0,0 +1,30 @@ +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.entity.Player; +import org.bukkit.potion.PotionEffect; +import org.bukkit.potion.PotionEffectType; + +public class CommandNV implements CommandExecutor { + + @Override + public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + if(!(sender instanceof Player)) + return false; + Player player = (Player) sender; + + for(PotionEffect effect : player.getActivePotionEffects()){ + if(effect.getType().equals(PotionEffectType.NIGHT_VISION)){ + player.sendMessage(BauSystem.PREFIX + "Nachtsicht deaktiviert"); + player.removePotionEffect(PotionEffectType.NIGHT_VISION); + return false; + } + } + player.addPotionEffect(new PotionEffect(PotionEffectType.NIGHT_VISION, 1000000, 255, false, false)); + player.sendMessage(BauSystem.PREFIX + "Nachtsicht aktiviert"); + return false; + } +} diff --git a/src/de/steamwar/bausystem/commands/CommandReset.java b/src/de/steamwar/bausystem/commands/CommandReset.java new file mode 100644 index 0000000..2bccd5a --- /dev/null +++ b/src/de/steamwar/bausystem/commands/CommandReset.java @@ -0,0 +1,19 @@ +package de.steamwar.bausystem.commands; + +import org.bukkit.command.Command; +import org.bukkit.command.CommandExecutor; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +public class CommandReset implements CommandExecutor { + + @Override + public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + if(!(sender instanceof Player)) + return false; + Player player = (Player) sender; + + + return false; + } +} diff --git a/src/de/steamwar/bausystem/commands/CommandSpeed.java b/src/de/steamwar/bausystem/commands/CommandSpeed.java new file mode 100644 index 0000000..f32fde1 --- /dev/null +++ b/src/de/steamwar/bausystem/commands/CommandSpeed.java @@ -0,0 +1,40 @@ +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.entity.Player; + +public class CommandSpeed implements CommandExecutor { + + @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){ + player.sendMessage(BauSystem.PREFIX + "/speed [Geschwindigkeit]"); + return false; + } + + float speed; + try{ + speed = Float.valueOf(args[0]); + }catch(NumberFormatException e){ + player.sendMessage(BauSystem.PREFIX + "§cBitte gib eine Zahl zwischen 0 und 10 an"); + return false; + } + if (speed < 0 || speed > 10) { + player.sendMessage(BauSystem.PREFIX + "§cBitte gib eine Zahl zwischen 0 und 10 an"); + return false; + } + + player.sendMessage("§aGeschwindigkeit wurde auf §6" + speed + " §agesetzt"); + + player.setFlySpeed(speed / 10); + player.setWalkSpeed((speed >= 9 ? speed : speed + 1) / 10); + return false; + } +} diff --git a/src/de/steamwar/bausystem/commands/CommandTNT.java b/src/de/steamwar/bausystem/commands/CommandTNT.java new file mode 100644 index 0000000..27178ae --- /dev/null +++ b/src/de/steamwar/bausystem/commands/CommandTNT.java @@ -0,0 +1,19 @@ +package de.steamwar.bausystem.commands; + +import org.bukkit.command.Command; +import org.bukkit.command.CommandExecutor; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +public class CommandTNT implements CommandExecutor { + + @Override + public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + if(!(sender instanceof Player)) + return false; + Player player = (Player) sender; + + Welt.switchTNT(player); + return false; + } +} diff --git a/src/de/warking/bausystem/commands/CommandTeleport.java b/src/de/steamwar/bausystem/commands/CommandTeleport.java similarity index 57% rename from src/de/warking/bausystem/commands/CommandTeleport.java rename to src/de/steamwar/bausystem/commands/CommandTeleport.java index 2697adf..e4e5083 100644 --- a/src/de/warking/bausystem/commands/CommandTeleport.java +++ b/src/de/steamwar/bausystem/commands/CommandTeleport.java @@ -1,8 +1,7 @@ -package de.warking.bausystem.commands; +package de.steamwar.bausystem.commands; -import de.warking.bausystem.BauSystem; +import de.steamwar.bausystem.BauSystem; import de.warking.hunjy.MySQL.BauweltMember; -import de.warking.hunjy.MySQL.WarkingUser; import org.apache.commons.lang.Validate; import org.bukkit.Bukkit; import org.bukkit.command.CommandSender; @@ -11,7 +10,6 @@ import org.bukkit.entity.Player; import org.bukkit.event.player.PlayerTeleportEvent; import java.util.List; -import java.util.UUID; public class CommandTeleport extends BukkitCommand { public CommandTeleport() { @@ -23,7 +21,7 @@ public class CommandTeleport extends BukkitCommand { public boolean execute(CommandSender sender, String currentAlias, String[] args) { if (!(sender instanceof Player)) return false; - else if ((args.length < 1) || (args.length > 2)) { + else if (args.length != 1) { sender.sendMessage(BauSystem.PREFIX + usageMessage); return false; } @@ -37,43 +35,13 @@ public class CommandTeleport extends BukkitCommand { return true; } - WarkingUser user = WarkingUser.get(p.getUniqueId()); - - if(p.hasPermission("bau.team")){ - if(args.length == 1){ - p.teleport(target, PlayerTeleportEvent.TeleportCause.COMMAND); - }else{ - Player target2 = Bukkit.getPlayerExact(args[1]); - - if (target2 == null) { - p.sendMessage(BauSystem.PREFIX + "§cDieser Spieler ist derzeit offline."); - return false; - } - - target.teleport(target2, PlayerTeleportEvent.TeleportCause.COMMAND); - } - return true; - }else if(args.length == 2){ - p.sendMessage(BauSystem.PREFIX + "§cDu darfst keine anderen Spieler teleportieren."); - return false; - } - - if(p.getUniqueId().equals(target)){ + if(p.getUniqueId().equals(target.getUniqueId())){ p.sendMessage(BauSystem.PREFIX + "§cSei eins mit dir selbst!"); return false; } - UUID worldOwner; - - try{ - worldOwner = UUID.fromString(target.getWorld().getName()); - }catch(IllegalArgumentException E){ - p.sendMessage(BauSystem.PREFIX + "§cDer Spieler befindet sich auf keiner Bauwelt!"); - return false; - } - - if(!worldOwner.equals(p.getUniqueId())){ - BauweltMember member = BauweltMember.getBauMember(worldOwner, p.getUniqueId()); + 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; diff --git a/src/de/steamwar/bausystem/commands/CommandTestblock.java b/src/de/steamwar/bausystem/commands/CommandTestblock.java new file mode 100644 index 0000000..3906671 --- /dev/null +++ b/src/de/steamwar/bausystem/commands/CommandTestblock.java @@ -0,0 +1,19 @@ +package de.steamwar.bausystem.commands; + +import org.bukkit.command.Command; +import org.bukkit.command.CommandExecutor; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +public class CommandTestblock implements CommandExecutor { + + @Override + public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + if(!(sender instanceof Player)) + return false; + Player player = (Player) sender; + + + return false; + } +} diff --git a/src/de/steamwar/bausystem/commands/CommandTime.java b/src/de/steamwar/bausystem/commands/CommandTime.java new file mode 100644 index 0000000..cf54ccb --- /dev/null +++ b/src/de/steamwar/bausystem/commands/CommandTime.java @@ -0,0 +1,47 @@ +package de.steamwar.bausystem.commands; + +import de.steamwar.bausystem.BauSystem; +import de.steamwar.bausystem.Permission; +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 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.hasPermission(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; + } +} \ No newline at end of file diff --git a/src/de/steamwar/bausystem/commands/CommandTrace.java b/src/de/steamwar/bausystem/commands/CommandTrace.java new file mode 100644 index 0000000..4830d1f --- /dev/null +++ b/src/de/steamwar/bausystem/commands/CommandTrace.java @@ -0,0 +1,100 @@ +package de.steamwar.bausystem.commands; + +import de.steamwar.bausystem.BauSystem; +import de.steamwar.bausystem.Permission; +import de.steamwar.bausystem.TNTTracer; +import org.bukkit.command.Command; +import org.bukkit.command.CommandExecutor; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +public class CommandTrace implements CommandExecutor { + + private void help(Player player){ + player.sendMessage("§8/§etrace start §7- Startet die Aufnahme aller TNT-Positionen"); + player.sendMessage("§8/§etrace show §7- Zeigt alle TNT-Positionen"); + player.sendMessage("§8/§etrace hide §7- Versteckt die TNT-Positionen wieder"); + player.sendMessage("§8/§etrace stop §7- Bricht die Aufnahme ab"); + } + + private void start(Player p){ + if(!Welt.hasPermission(p, Permission.world)){ + p.sendMessage(BauSystem.PREFIX + "§cDu darfst hier nicht den TNT-Tracer nutzen"); + return; + } + + BauSystem.getTracer().start(); + p.sendMessage(BauSystem.PREFIX + "§aAufnahme gestartet"); + } + + private void stop(Player p){ + if(!Welt.hasPermission(p, Permission.world)){ + p.sendMessage(BauSystem.PREFIX + "§cDu darfst hier nicht den TNT-Tracer nutzen"); + return; + } + + if(!BauSystem.getTracer().isActive()){ + p.sendMessage(BauSystem.PREFIX + "§cKein laufender TNT-Tracer"); + return; + } + + BauSystem.getTracer().stop(); + p.sendMessage(BauSystem.PREFIX + "§aAufnahme abgebrochen"); + } + + private void show(Player p){ + if(!Welt.hasPermission(p, Permission.world)){ + p.sendMessage(BauSystem.PREFIX + "§cDu darfst hier nicht den TNT-Tracer nutzen"); + return; + } + + if(!BauSystem.getTracer().isActive()){ + p.sendMessage(BauSystem.PREFIX + "§cKein laufender TNT-Tracer"); + return; + } + + BauSystem.getTracer().show(); + p.sendMessage(BauSystem.PREFIX + "§aTNT-Positionen angezeigt"); + } + + private void hide(Player p){ + if(!Welt.hasPermission(p, Permission.world)){ + p.sendMessage(BauSystem.PREFIX + "§cDu darfst hier nicht den TNT-Tracer nutzen"); + return; + } + + if(!BauSystem.getTracer().isPrinted()){ + p.sendMessage(BauSystem.PREFIX + "§cDerzeit werden keine Blöcke angezeigt"); + return; + } + + BauSystem.getTracer().hide(); + p.sendMessage(BauSystem.PREFIX + "§aTNT-Positionen versteckt"); + } + + @Override + public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + if(!(sender instanceof Player)) + return false; + Player player = (Player) sender; + + switch(args.length){ + case 1: + if(args[0].equalsIgnoreCase("start")){ + start(player); + }else if(args[0].equalsIgnoreCase("stop")){ + stop(player); + }else if(args[0].equalsIgnoreCase("show")){ + show(player); + }else if(args[0].equalsIgnoreCase("hide")){ + hide(player); + }else{ + help(player); + } + break; + default: + help(player); + } + return false; + } +} diff --git a/src/de/warking/bausystem/world/BauWorld.java b/src/de/steamwar/bausystem/commands/Welt.java similarity index 52% rename from src/de/warking/bausystem/world/BauWorld.java rename to src/de/steamwar/bausystem/commands/Welt.java index bb067e0..11fa210 100644 --- a/src/de/warking/bausystem/world/BauWorld.java +++ b/src/de/steamwar/bausystem/commands/Welt.java @@ -1,71 +1,21 @@ -package de.warking.bausystem.world; +package de.steamwar.bausystem.commands; -import de.warking.bausystem.BauSystem; +import de.steamwar.bausystem.BauSystem; +import de.steamwar.bausystem.Permission; import de.warking.hunjy.MySQL.Bauwelt; import de.warking.hunjy.MySQL.BauweltMember; -import de.warking.hunjy.MySQL.WarkingUser; -import org.apache.commons.io.FileUtils; -import org.bukkit.*; +import org.bukkit.Bukkit; import org.bukkit.entity.Player; -import java.io.File; -import java.io.IOException; -import java.util.UUID; +public class Welt { + private Welt(){} -public class BauWorld { - - public static void loadWorld(UUID owner) throws IOException{ - World world = Bukkit.getWorld(owner.toString()); - if(world != null) - return; - - File w = new File("plugins/BauSystem/worlds/" + owner); - File region = new File("plugins/WorldGuard/worlds/" + owner); - if (!region.exists() || !region.isDirectory()) - FileUtils.copyDirectory(new File(BauSystem.getInstance().config.regionDir), new File("plugins/WorldGuard/worlds/" + owner)); - if (!w.exists() || !w.isDirectory()) - FileUtils.copyDirectory(new File(BauSystem.getInstance().config.backupDir), new File("plugins/BauSystem/worlds/" + owner.toString())); - - Bukkit.createWorld(new WorldCreator(owner.toString())); - } - - public static void unloadWorld(UUID owner) { - World world = Bukkit.getWorld(owner.toString()); - - if (world != null) { - for (Player p : world.getPlayers()) { - p.teleport(BauSystem.getInstance().config.spawn); - p.setGameMode(GameMode.ADVENTURE); - } - - for (Chunk c : world.getLoadedChunks()) { - c.unload(); - } - - if(!Bukkit.unloadWorld(world, true)) - System.out.println("Unloading world failed!"); - System.gc(); - } - } - - public static void broadcast(UUID owner, String string) { - for (Player p : getWorld(owner).getPlayers()) { - p.sendMessage(string); - } - } - - public static World getWorld(UUID owner) { - return Bukkit.getWorld(owner.toString()); - } - - public static boolean hasPermission(UUID owner, Player member, Permission perm){ - if(owner == null) - return false; - if(member.hasPermission("bau.team") || member.getUniqueId().equals(owner)) + public static boolean hasPermission(Player member, Permission perm){ + if(member.getUniqueId().equals(BauSystem.getOwner())) return true; - BauweltMember member1 = BauweltMember.getBauMember(owner, member.getUniqueId()); + BauweltMember member1 = BauweltMember.getBauMember(BauSystem.getOwner(), member.getUniqueId()); if(member1 == null) return false; @@ -78,51 +28,42 @@ public class BauWorld { return member1.isTestblock(); case member: return true; - case owner: + default: return false; } - return false; - } - - public static UUID getWorldUUID(World w){ - try{ - return UUID.fromString(w.getName()); - }catch(IllegalArgumentException E){ - return null; - } } public static void switchTNT(Player p){ - UUID worldOwner = getWorldUUID(p.getWorld()); - if (!hasPermission(worldOwner, p, Permission.world)){ + if (!hasPermission(p, Permission.world)){ p.sendMessage(BauSystem.PREFIX + "§cDu darfst hier nicht TNT-Schaden (de)aktivieren"); return; } - Bauwelt welt = Bauwelt.getBauwelt(worldOwner); + Bauwelt welt = BauSystem.getWelt(); welt.setTNTDmg(!welt.isTNTDmg()); if (welt.isTNTDmg()) - broadcast(worldOwner, BauSystem.PREFIX + "§aTNT-Schaden erlaubt"); + Bukkit.broadcastMessage(BauSystem.PREFIX + "§aTNT-Schaden erlaubt"); else - broadcast(worldOwner, BauSystem.PREFIX + "§cTNT-Schaden verboten"); + Bukkit.broadcastMessage(BauSystem.PREFIX + "§cTNT-Schaden verboten"); } public static void switchFire(Player p){ - UUID worldOwner = getWorldUUID(p.getWorld()); - if (!hasPermission(worldOwner, p, Permission.world)){ + if (!hasPermission(p, Permission.world)){ p.sendMessage(BauSystem.PREFIX + "§cDu darfst hier nicht Feuerschaden (de)aktivieren"); return; } - Bauwelt welt = Bauwelt.getBauwelt(worldOwner); + Bauwelt welt = BauSystem.getWelt(); welt.setFireDmg(!welt.isFireDmg()); if (welt.isFireDmg()) - broadcast(worldOwner, BauSystem.PREFIX + "§aFeuer-Schaden erlaubt"); + Bukkit.broadcastMessage(BauSystem.PREFIX + "§aFeuer-Schaden erlaubt"); else - broadcast(worldOwner, BauSystem.PREFIX + "§cFeuer-Schaden verboten"); + Bukkit.broadcastMessage(BauSystem.PREFIX + "§cFeuer-Schaden verboten"); } - public static void toggleBuild(Player p, BauweltMember target){ + //TODO: To BungeeCore + + /*public static void toggleBuild(Player p, BauweltMember target){ target.setBuild(!target.isBuild()); Player z = Bukkit.getPlayer(WarkingUser.get(target.getMemberID()).getUUID()); if (z != null) { @@ -177,12 +118,8 @@ public class BauWorld { target.remove(); Player z = Bukkit.getPlayer(WarkingUser.get(target.getMemberID()).getUUID()); if(z != null){ - z.sendMessage(BauSystem.PREFIX + "§cDu wurdest von der Welt von §6" + p.getName() + " §centfernt"); - if (z.getWorld().getName().equals(p.getUniqueId().toString())) { - z.teleport(BauSystem.getInstance().config.spawn); - z.setGameMode(GameMode.ADVENTURE); - } + z.kickPlayer(BauSystem.PREFIX + "§cDu wurdest von der Welt von §6" + p.getName() + " §centfernt"); } p.sendMessage(BauSystem.PREFIX + "§cDer Spieler wurde entfernt"); - } + }*/ } diff --git a/src/de/warking/bausystem/BauSystem.java b/src/de/warking/bausystem/BauSystem.java deleted file mode 100644 index 8f63f30..0000000 --- a/src/de/warking/bausystem/BauSystem.java +++ /dev/null @@ -1,257 +0,0 @@ -package de.warking.bausystem; - -import com.sk89q.worldedit.bukkit.WorldEditPlugin; -import com.sk89q.worldguard.bukkit.WorldGuardPlugin; -import de.pro_crafting.commandframework.CommandArgs; -import de.pro_crafting.commandframework.CommandFramework; -import de.pro_crafting.commandframework.Completer; -import de.warking.bausystem.commands.*; -import de.warking.bausystem.config.Config; -import de.warking.bausystem.world.LagDetectorRunnable; -import de.warking.bausystem.world.RegionListener; -import de.warking.hunjy.MySQL.Bauwelt; -import de.warking.hunjy.MySQL.WarkingUser; -import org.bukkit.Bukkit; -import org.bukkit.command.Command; -import org.bukkit.command.SimpleCommandMap; -import org.bukkit.configuration.file.FileConfiguration; -import org.bukkit.configuration.file.YamlConfiguration; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.Listener; -import org.bukkit.event.entity.PlayerDeathEvent; -import org.bukkit.event.player.PlayerJoinEvent; -import org.bukkit.event.player.PlayerRespawnEvent; -import org.bukkit.event.player.PlayerTeleportEvent; -import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause; -import org.bukkit.permissions.PermissionAttachment; -import org.bukkit.plugin.java.JavaPlugin; - -import java.io.File; -import java.lang.reflect.Field; -import java.lang.reflect.Method; -import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.Date; -import java.util.List; - -public class BauSystem extends JavaPlugin implements Listener { - - public static final String PREFIX = "§6BauSystem§8» §7"; - - public Config config; - private CommandFramework cmdFramework; - private final File regions = new File("plugins/BauSystem", "regions.data"); - public final FileConfiguration getRegionData = YamlConfiguration.loadConfiguration(regions); - - private static BauSystem plugin; - - private void saveRegionData() { - try { getRegionData.save(regions); } catch (Exception ignored) { } - } - @Override - public void onEnable() { - getServer().getPluginManager().registerEvents(new CommandGui(), this); - File checkFile = new File("plugins/BauSystem", "regions.data"); - if(!checkFile.exists()) { - - getRegionData.options().header("Config auf dieser Basis unendlich erweiterbar"); - - getRegionData.set("schematic.resetall.position.X", " "); - getRegionData.set("schematic.resetall.position.Y", " "); - getRegionData.set("schematic.resetall.position.Z", " "); - getRegionData.set("schematic.resetall.schematic", " "); - - getRegionData.set("regions.wargear1mini.position.X", " "); - getRegionData.set("regions.wargear1mini.position.Y", " "); - getRegionData.set("regions.wargear1mini.position.Z", " "); - getRegionData.set("regions.wargear1mini.schematic.testblock", " "); - getRegionData.set("regions.wargear1mini.schematic.reset", " "); - - getRegionData.set("regions.wargear1standart.position.X", " "); - getRegionData.set("regions.wargear1standart.position.Y", " "); - getRegionData.set("regions.wargear1standart.position.Z", " "); - getRegionData.set("regions.wargear1standart.schematic.testblock", " "); - getRegionData.set("regions.wargear1standart.schematic.reset", " "); - - getRegionData.set("regions.airship1.position.X", " "); - getRegionData.set("regions.airship1.position.Y", " "); - getRegionData.set("regions.airship1.position.Z", " "); - getRegionData.set("regions.airship1.schematic.testblock", " "); - getRegionData.set("regions.airship1.schematic.reset", " "); - - saveRegionData(); - } - - try { - CommandRemover.removeCommand("tp"); - CommandInjector.injectCommand(new CommandTeleport()); - CommandRemover.removeCommand("gamemode"); - CommandInjector.injectCommand(new CommandGamemode()); - } catch (Exception e1) { - e1.printStackTrace(); - } - - new File("plugins/BauSystem/worlds/").mkdirs(); - config = new Config(); - config.initConfig(); - - cmdFramework = new CommandFramework(this); - cmdFramework.setInGameOnlyMessage(PREFIX + "Dieser Befehl darf nur Ingame verwendet werden!"); - cmdFramework.setNoPermMessage(PREFIX + "§cUnbekannter Befehl"); - Bukkit.getPluginManager().registerEvents(this, this); - Method[] methods = this.getClass().getMethods(); - for (Method m : methods) { - if (m.getName().equalsIgnoreCase("completeCommands")) { - this.cmdFramework.registerCompleter("bau", m, this); - } - } - - cmdFramework.registerCommands(new CommandBau()); - cmdFramework.registerCommands(new CommandNV()); - cmdFramework.registerCommands(new CommandTrace()); - Bukkit.getPluginManager().registerEvents(new RegionListener(this), this); - - Bukkit.getScheduler().scheduleSyncRepeatingTask(this, () -> { - SimpleDateFormat df = new SimpleDateFormat("HH:mm:ss"); - Date d = new Date(); - if (df.format(d).equalsIgnoreCase("02:55:00")) { - Bukkit.broadcastMessage(PREFIX + "Der Server startet in 5 Minuten neu"); - } - if (df.format(d).equalsIgnoreCase("02:59:00")) { - Bukkit.broadcastMessage(PREFIX + "Der Server startet in 1 Minute neu"); - } - if (df.format(d).equalsIgnoreCase("02:59:30")) { - Bukkit.broadcastMessage(PREFIX + "Der Server startet in 30 Sekunden neu"); - } - if (df.format(d).equalsIgnoreCase("02:59:50")) { - Bukkit.broadcastMessage(PREFIX + "Der Server startet in 10 Sekunden neu"); - } - if (df.format(d).equalsIgnoreCase("02:59:55")) { - Bukkit.broadcastMessage(PREFIX + "Der Server startet in 5 Sekunden neu"); - } - if (df.format(d).equalsIgnoreCase("02:59:56")) { - Bukkit.broadcastMessage(PREFIX + "Der Server startet in 4 Sekunden neu"); - } - if (df.format(d).equalsIgnoreCase("02:59:57")) { - Bukkit.broadcastMessage(PREFIX + "Der Server startet in 3 Sekunden neu"); - } - if (df.format(d).equalsIgnoreCase("02:59:58")) { - Bukkit.broadcastMessage(PREFIX + "Der Server startet in 2 Sekunden neu"); - } - if (df.format(d).equalsIgnoreCase("02:59:59")) { - Bukkit.broadcastMessage(PREFIX + "Der Server startet in 1 Sekunde neu"); - } - if (df.format(d).equalsIgnoreCase("03:00:00")) { - Bukkit.spigot().restart(); - } - }, 20L, 20L); - plugin = this; - Bukkit.getScheduler().runTaskTimer(BauSystem.getInstance(), new LagDetectorRunnable(), 20, 20); - } - - public static BauSystem getPlugin() { - return plugin; - } - - public static WorldEditPlugin getWorldEdit() { - return (WorldEditPlugin) Bukkit.getPluginManager().getPlugin("WorldEdit"); - } - - public static WorldGuardPlugin getWorldGuard() { - return (WorldGuardPlugin) Bukkit.getPluginManager().getPlugin("WorldGuard"); - } - - @Override - public void onDisable() { - } - - public static BauSystem getInstance() { - return JavaPlugin.getPlugin(BauSystem.class); - } - - @Completer(name = "bau", aliases = "gs") - public List completeCommands(CommandArgs args) { - List ret = new ArrayList<>(); - StringBuilder label = new StringBuilder(args.getCommand().getLabel()); - for (String arg : args.getArgs()) { - label.append(" ").append(arg); - } - for (String currentLabel : this.cmdFramework.getCommandLabels()) { - String current = currentLabel.replace('.', ' '); - if (current.contains(label.toString())) { - current = current.substring(label.toString().lastIndexOf(' ')).trim(); - current = current.substring(0, current.indexOf(' ') != -1 ? current.indexOf(' ') : current.length()) - .trim(); - if (!ret.contains(current)) { - ret.add(current); - } - } - } - return ret; - } - - static class CommandInjector { - private static final String packageName = Bukkit.getServer().getClass().getPackage().getName(); - private static final String version; - - static { - version = packageName.substring(packageName.lastIndexOf(".") + 1); - } - - 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); - } - } - - @EventHandler - public void onDeath(PlayerDeathEvent e) { - e.setDeathMessage(null); - } - - @EventHandler - public void onRespawn(PlayerRespawnEvent e) { - Player p = e.getPlayer(); - if (Bauwelt.getBauwelt(p.getUniqueId()) == null) { - e.setRespawnLocation(config.spawn); - }else{ - e.setRespawnLocation(Bukkit.getWorld(p.getUniqueId().toString()).getSpawnLocation()); - } - } - - @EventHandler - public void onJoin(PlayerJoinEvent e) { - Player p = e.getPlayer(); - p.teleport(config.spawn); - WarkingUser user = WarkingUser.get(p.getUniqueId()); - PermissionAttachment attachment = p.addAttachment(this); - switch(user.getUserGroup()){ - case Admin: - case Moderator: - case Developer: - case Supporter: - case Builder: - attachment.setPermission("bau.team", true); - } - attachment.setPermission("F3NPerm.use", true); - attachment.setPermission("fawe.permpack.basic", true); - attachment.setPermission("worldedit.navigation.jumpto.tool", true); - attachment.setPermission("worldedit.navigation.thru.tool", true); - } - - @EventHandler - public void onTpGM3(PlayerTeleportEvent e) { - if (e.getPlayer().hasPermission("bukkit.command.teleport")) { - return; - } - if (e.getCause() == TeleportCause.SPECTATE) { - e.setCancelled(true); - e.getPlayer().sendMessage(BauSystem.PREFIX + "§cDu darfst die Zuschauer-Teleportfunktion nicht benutzen!"); - } - } - -} diff --git a/src/de/warking/bausystem/commands/CommandGui.java b/src/de/warking/bausystem/commands/CommandGui.java deleted file mode 100644 index 51fdabd..0000000 --- a/src/de/warking/bausystem/commands/CommandGui.java +++ /dev/null @@ -1,556 +0,0 @@ -package de.warking.bausystem.commands; - -import de.warking.bausystem.BauSystem; -import de.warking.hunjy.MySQL.Bauwelt; -import de.warking.hunjy.MySQL.BauweltMember; -import de.warking.hunjy.MySQL.WarkingUser; -import org.bukkit.Bukkit; -import org.bukkit.ChatColor; -import org.bukkit.Location; -import org.bukkit.Material; -import org.bukkit.entity.Player; -import org.bukkit.event.Listener; -import org.bukkit.event.inventory.InventoryClickEvent; -import org.bukkit.inventory.Inventory; -import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.meta.ItemMeta; -import org.bukkit.inventory.meta.SkullMeta; - -public class CommandGui implements Listener { - - private void handleEvent(InventoryClickEvent e, Player p, String m, Location l){ - p.teleport(l); - p.sendMessage(BauSystem.PREFIX + BauSystem.getInstance().config.cfg.getString(m)); - e.getView().close(); - } - - /*@EventHandler - public void onPlayerClickInventory(InventoryClickEvent e) { - if (e.getCurrentItem() == null || e.getCurrentItem().getItemMeta() == null || e.getCurrentItem().getItemMeta().getDisplayName() != null) - return; - - e.setCancelled(true); - String itemName = e.getCurrentItem().getItemMeta().getDisplayName(); - Player p = (Player) e.getWhoClicked(); - if (e.getInventory().getTitle().equals("§7Grundstücksregionen")) { - if (itemName.equals("§bWarShip §aTestGelände 1")) - handleEvent(e, p, "WarShip1.Message", - new Location(p.getWorld(), BauSystem.getInstance().config.cfg.getDouble("WarShip1.loc.x"), BauSystem.getInstance().config.cfg.getDouble("WarShip1.loc.y"), BauSystem.getInstance().config.cfg.getDouble("WarShip1.loc.z"))); - else if (itemName.equals("§bWarShip §aTestGelände 2")) - handleEvent(e, p, "WarShip2.Message", - new Location(p.getWorld(), BauSystem.getInstance().config.cfg.getDouble("WarShip2.loc.x"), BauSystem.getInstance().config.cfg.getDouble("WarShip2.loc.y"), BauSystem.getInstance().config.cfg.getDouble("WarShip2.loc.z"))); - else if (itemName.equals("§bWarGear §aTestGelände 5")) - handleEvent(e, p, "WarGear5.Message", - new Location(p.getWorld(), BauSystem.getInstance().config.cfg.getDouble("WarGear5.loc.x"), BauSystem.getInstance().config.cfg.getDouble("WarGear5.loc.y"), BauSystem.getInstance().config.cfg.getDouble("WarGear5.loc.z"))); - else if (itemName.equals("§bWarGear §aTestGelände 6")) - handleEvent(e, p, "WarGear6.Message", - new Location(p.getWorld(), BauSystem.getInstance().config.cfg.getDouble("WarGear6.loc.x"), BauSystem.getInstance().config.cfg.getDouble("WarGear6.loc.y"), BauSystem.getInstance().config.cfg.getDouble("WarGear6.loc.z"))); - else if (itemName.equals("§bWarGear §aTestGelände 7")) - handleEvent(e, p, "WarGear7.Message", - new Location(p.getWorld(), BauSystem.getInstance().config.cfg.getDouble("WarGear7.loc.x"), BauSystem.getInstance().config.cfg.getDouble("WarGear7.loc.y"), BauSystem.getInstance().config.cfg.getDouble("WarGear7.loc.z"))); - else if (itemName.equals("§bWarGear §aTestGelände 8")) - handleEvent(e, p, "WarGear8.Message", - new Location(p.getWorld(), BauSystem.getInstance().config.cfg.getDouble("WarGear8.loc.x"), BauSystem.getInstance().config.cfg.getDouble("WarGear8.loc.y"), BauSystem.getInstance().config.cfg.getDouble("WarGear8.loc.z"))); - else if (itemName.equals("§bMiniWarGear §aTestGelände 1")) - handleEvent(e, p, "MiniWargear1.Message", - new Location(p.getWorld(), BauSystem.getInstance().config.cfg.getDouble("MiniWargear1.loc.x"), BauSystem.getInstance().config.cfg.getDouble("MiniWargear1.loc.y"), BauSystem.getInstance().config.cfg.getDouble("MiniWargear1.loc.z"))); - else if (itemName.equals("§bMiniWarGear §aTestGelände 2")) - handleEvent(e, p, "MiniWargear2.Message", - new Location(p.getWorld(), BauSystem.getInstance().config.cfg.getDouble("MiniWargear2.loc.x"), BauSystem.getInstance().config.cfg.getDouble("MiniWargear2.loc.y"), BauSystem.getInstance().config.cfg.getDouble("MiniWargear2.loc.z"))); - else if (itemName.equals("§bMiniWarGear §aTestGelände 7")) - handleEvent(e, p, "MiniWargear7.Message", - new Location(p.getWorld(), BauSystem.getInstance().config.cfg.getDouble("MiniWargear7.loc.x"), BauSystem.getInstance().config.cfg.getDouble("MiniWargear7.loc.y"), BauSystem.getInstance().config.cfg.getDouble("MiniWargear7.loc.z"))); - else if (itemName.equals("§bMiniWarGear §aTestGelände 8")) - handleEvent(e, p, "MiniWargear8.Message", - new Location(p.getWorld(), BauSystem.getInstance().config.cfg.getDouble("MiniWargear8.loc.x"), BauSystem.getInstance().config.cfg.getDouble("MiniWargear8.loc.y"), BauSystem.getInstance().config.cfg.getDouble("MiniWargear8.loc.z"))); - else if (itemName.equals("§bAirShip §aTestGelände 1")) - handleEvent(e, p, "AirShip1.Message", - new Location(p.getWorld(), BauSystem.getInstance().config.cfg.getDouble("AirShip1.loc.x"), BauSystem.getInstance().config.cfg.getDouble("AirShip1.loc.y"), BauSystem.getInstance().config.cfg.getDouble("AirShip1.loc.z"))); - else if (itemName.equals("§bAirShip §aTestGelände 2")) - handleEvent(e, p, "AirShip2.Message", - new Location(p.getWorld(), BauSystem.getInstance().config.cfg.getDouble("AirShip2.loc.x"), BauSystem.getInstance().config.cfg.getDouble("AirShip2.loc.y"), BauSystem.getInstance().config.cfg.getDouble("AirShip2.loc.z"))); - else if (itemName.equals("§bAirShip §aTestGelände 3")) - handleEvent(e, p, "AirShip3.Message", - new Location(p.getWorld(), BauSystem.getInstance().config.cfg.getDouble("AirShip3.loc.x"), BauSystem.getInstance().config.cfg.getDouble("AirShip3.loc.y"), BauSystem.getInstance().config.cfg.getDouble("AirShip3.loc.z"))); - else if (itemName.equals("§bAirShip §aTestGelände 4")) - handleEvent(e, p, "AirShip4.Message", - new Location(p.getWorld(), BauSystem.getInstance().config.cfg.getDouble("AirShip4.loc.x"), BauSystem.getInstance().config.cfg.getDouble("AirShip4.loc.y"), BauSystem.getInstance().config.cfg.getDouble("AirShip4.loc.z"))); - else if (itemName.equals("§bAirShip §aTestGelände 5")) - handleEvent(e, p, "AirShip5.Message", - new Location(p.getWorld(), BauSystem.getInstance().config.cfg.getDouble("AirShip5.loc.x"), BauSystem.getInstance().config.cfg.getDouble("AirShip5.loc.y"), BauSystem.getInstance().config.cfg.getDouble("AirShip5.loc.z"))); - else if (itemName.equals("§bAirShip §aTestGelände 6")) - handleEvent(e, p, "AirShip6.Message", - new Location(p.getWorld(), BauSystem.getInstance().config.cfg.getDouble("AirShip6.loc.x"), BauSystem.getInstance().config.cfg.getDouble("AirShip6.loc.y"), BauSystem.getInstance().config.cfg.getDouble("AirShip6.loc.z"))); - else if (itemName.equals("§bAirShip §aTestGelände 7")) - handleEvent(e, p, "AirShip7.Message", - new Location(p.getWorld(), BauSystem.getInstance().config.cfg.getDouble("AirShip7.loc.x"), BauSystem.getInstance().config.cfg.getDouble("AirShip7.loc.y"), BauSystem.getInstance().config.cfg.getDouble("AirShip7.loc.z"))); - else if (itemName.equals("§bAirShip §aTestGelände 8")) - handleEvent(e, p, "AirShip8.Message", - new Location(p.getWorld(), BauSystem.getInstance().config.cfg.getDouble("AirShip8.loc.x"), BauSystem.getInstance().config.cfg.getDouble("AirShip8.loc.y"), BauSystem.getInstance().config.cfg.getDouble("AirShip8.loc.z"))); - else if (itemName.equals("§bZurück")){ - e.getView().close(); - p.openInventory(mainmenu()); - } - }else if (e.getInventory().getTitle().equals("§7Weltoptionen")) { - if (itemName.equals("§aTNT-Schaden")) { - BauWorld.switchTNT(p); - e.getView().close(); - p.openInventory(weltoption(p)); - }else if (itemName.equals("§aFeuer-Schaden")) { - BauWorld.switchFire(p); - e.getView().close(); - p.openInventory(weltoption(p)); - }else if (itemName.equals("§bZurück")) { - e.getView().close(); - p.openInventory(mainmenu()); - } - }else if (e.getInventory().getTitle().equals("§aBauoptionen")) { - if (itemName.equals("§bBauregionen")) { - p.openInventory(bauabteilung()); - }else if (itemName.equals("§bWelten Optionen")) { - p.openInventory(weltoption(p)); - }else if (itemName.equals("§bSpieler Optionen")) { - p.openInventory(spieleroption(p)); - } - }else if (e.getInventory().getTitle().equals("§bSpieler Optionen")) { - if (itemName.equals("§bZurück")) { - e.getView().close(); - p.openInventory(mainmenu()); - }else if (e.getCurrentItem() != null) { - Material material = e.getCurrentItem().getType(); - if (material == Material.SKULL_ITEM) { - SkullMeta skullMeta = (SkullMeta) getSkull(material.getData().getCanonicalName()).getItemMeta(); - SkullTeleport(p, e.getCurrentItem()); - } - } - }else if (itemName.equals("§bZurück")) { - e.getView().close(); - p.closeInventory(); - p.openInventory(spieleroption(p)); - }else{ - for (BauweltMember member : BauweltMember.getMembers(p.getUniqueId())) { - if (e.getInventory().getTitle().equals(WarkingUser.get(member.getMemberID()).getUserName())) { - ItemStack skull = new ItemStack(Material.SKULL_ITEM); - if (itemName.equals("§aSpieler hinzufügen")) { - /*if(member != null){ - p.sendMessage(BauSystem.PREFIX + "§cDieser Spieler ist bereits Mitglied auf deiner Welt"); - p.openInventory(skullOwnerInventory(member, p)); - }else{ - new BauweltMember(p.getUniqueId(),target.getUniqueId(), true, false, false, false, false); - p.sendMessage(BauSystem.PREFIX + "§aDu hast " + target.getName() + " §azu der Welt hinzugefügt"); - target.sendMessage(BauSystem.PREFIX + "§aDu wurdest zu der Welt von §6" + p.getName() + " §ahinzugefügt"); - p.openInventory(skullOwnerInventory(member, p)); - }*//* - }else if (member == null){ - p.sendMessage(BauSystem.PREFIX + "§cDieser Spieler ist kein Mitglied auf deiner Welt"); - }else if (itemName.equals("§aToggle Worldedit")) { - BauWorld.toggleWE(p, member); - p.closeInventory(); - p.openInventory(skullOwnerInventory(member, p)); - }else if (itemName.equals("§aToggle Teleport")) { - BauWorld.toggleTP(p, member); - p.closeInventory(); - p.openInventory(skullOwnerInventory(member, p)); - }else if (itemName.equals("§aToggle Build")) { - BauWorld.toggleBuild(p, member); - p.closeInventory(); - p.openInventory(skullOwnerInventory(member, p)); - }else if (itemName.equals("§aToggle ChangeGamemode")) { - BauWorld.toggleGM(p, member); - p.closeInventory(); - p.openInventory(skullOwnerInventory(member, p)); - }else if (itemName.equals("§aToggle Replace") || itemName.equals("§aToggle Reset") || itemName.equals("§aToggle TestBlock")){ - BauWorld.toggleTestblock(p, member); - p.closeInventory(); - p.openInventory(skullOwnerInventory(member, p)); - }else if (itemName.equals("§cSpieler entfernen")){ - BauWorld.removePlayer(p, WarkingUser.get(member.getMemberID()).getUUID()); - p.openInventory(spieleroption(p)); - } - break; - } - } - } - }*/ - - private ItemStack getSkull(String name) { - ItemStack skull = new ItemStack(397, 1, (short) 3); - SkullMeta skullmeta = (SkullMeta) skull.getItemMeta(); - skullmeta.setDisplayName(name); - skullmeta.setOwner(name); - skull.setItemMeta(skullmeta); - return skull; - } - - private void SkullTeleport(Player player, ItemStack item) { - SkullMeta skullmeta = (SkullMeta) item.getItemMeta(); - if (skullmeta.getDisplayName() != null) { - if (Bukkit.getPlayer(skullmeta.getDisplayName()) != null) { - Player target = Bukkit.getPlayer(skullmeta.getDisplayName()); - player.openInventory(skullOwnerInventory(BauweltMember.getBauMember(player.getUniqueId(), target.getUniqueId()), player)); - } - } - } - - private Inventory skullOwnerInventory(BauweltMember member, Player player) { - - Inventory inv2 = Bukkit.createInventory(null, 18, WarkingUser.get(member.getMemberID()).getUserName()); - ItemStack skull = new ItemStack(Material.SKULL_ITEM); - ItemMeta meta = skull.getItemMeta(); - meta = skull.getItemMeta(); - meta.setDisplayName(ChatColor.RED + "§aSpieler hinzufügen"); - skull.setItemMeta(meta); - inv2.addItem(skull); - - ItemStack skull1 = new ItemStack(Material.SKULL_ITEM); - meta = skull1.getItemMeta(); - meta.setDisplayName(ChatColor.RED + "§cSpieler entfernen"); - skull1.setItemMeta(meta); - inv2.setItem(9, skull1); - - ItemStack togglewe = new ItemStack(Material.WOOD_AXE); - meta = togglewe.getItemMeta(); - meta.setDisplayName(ChatColor.RED + "§aToggle Worldedit"); - togglewe.setItemMeta(meta); - inv2.setItem(1, togglewe); - - ItemStack toggletp = new ItemStack(Material.COMPASS); - meta = toggletp.getItemMeta(); - meta.setDisplayName(ChatColor.RED + "§aToggle Teleport"); - toggletp.setItemMeta(meta); - inv2.setItem(2, toggletp); - - ItemStack togglebuild = new ItemStack(Material.GRASS); - meta = togglebuild.getItemMeta(); - meta.setDisplayName(ChatColor.RED + "§aToggle Build"); - togglebuild.setItemMeta(meta); - inv2.setItem(3, togglebuild); - - ItemStack togglegm = new ItemStack(Material.LADDER); - meta = togglegm.getItemMeta(); - meta.setDisplayName(ChatColor.RED + "§aToggle ChangeGamemode"); - togglegm.setItemMeta(meta); - inv2.setItem(4, togglegm); - - ItemStack togglerep = new ItemStack(Material.BREWING_STAND_ITEM); - meta = togglerep.getItemMeta(); - meta.setDisplayName(ChatColor.RED + "§aToggle Replace"); - togglerep.setItemMeta(meta); - inv2.setItem(5, togglerep); - - ItemStack togglereset = new ItemStack(Material.BARRIER); - meta = togglereset.getItemMeta(); - meta.setDisplayName(ChatColor.RED + "§aToggle Reset"); - togglereset.setItemMeta(meta); - inv2.setItem(6, togglereset); - - ItemStack toggletestblock = new ItemStack(Material.ENDER_STONE); - meta = toggletestblock.getItemMeta(); - meta.setDisplayName(ChatColor.RED + "§aToggle TestBlock"); - toggletestblock.setItemMeta(meta); - inv2.setItem(7, toggletestblock); - - ItemStack back = new ItemStack(Material.SLIME_BALL); - meta = back.getItemMeta(); - meta.setDisplayName(ChatColor.RED + "§bZurück"); - back.setItemMeta(meta); - inv2.setItem(8, back); - - if (Bauwelt.getBauwelt(player.getUniqueId()).getUUID() == null) { - player.sendMessage(BauSystem.PREFIX + "§cDu hast keine Welt"); - }else if (BauweltMember.getBauMember(player.getUniqueId(), WarkingUser.get(member.getMemberID()).getUUID()) == null) { - player.sendMessage(BauSystem.PREFIX + "§cDer Spieler ist kein Mitglied deiner Welt"); - } else { - if (member.isWorldEdit()) { - ItemStack tntst = new ItemStack(351, 1, (short) 10); - meta = tntst.getItemMeta(); - meta.setDisplayName(ChatColor.RED + "§eStatus §2An"); - tntst.setItemMeta(meta); - inv2.setItem(10, tntst); - } else { - ItemStack tntst1 = new ItemStack(351, 1, (short) 8); - meta = tntst1.getItemMeta(); - meta.setDisplayName(ChatColor.RED + "§eStatus §4Aus"); - tntst1.setItemMeta(meta); - inv2.setItem(10, tntst1); - } - if (member.isTeleport()) { - ItemStack tntst = new ItemStack(351, 1, (short) 10); - meta = tntst.getItemMeta(); - meta.setDisplayName(ChatColor.RED + "§eStatus §2An"); - tntst.setItemMeta(meta); - inv2.setItem(11, tntst); - } else { - ItemStack tntst1 = new ItemStack(351, 1, (short) 8); - meta = tntst1.getItemMeta(); - meta.setDisplayName(ChatColor.RED + "§eStatus §4Aus"); - tntst1.setItemMeta(meta); - inv2.setItem(11, tntst1); - } - if (member.isBuild()) { - ItemStack tntst = new ItemStack(351, 1, (short) 10); - meta = tntst.getItemMeta(); - meta.setDisplayName(ChatColor.RED + "§eStatus §2An"); - tntst.setItemMeta(meta); - inv2.setItem(12, tntst); - } else { - ItemStack tntst1 = new ItemStack(351, 1, (short) 8); - meta = tntst1.getItemMeta(); - meta.setDisplayName(ChatColor.RED + "§eStatus §4Aus"); - tntst1.setItemMeta(meta); - inv2.setItem(12, tntst1); - } - if (member.isChangeGM()) { - ItemStack tntst = new ItemStack(351, 1, (short) 10); - meta = tntst.getItemMeta(); - meta.setDisplayName(ChatColor.RED + "§eStatus §2An"); - tntst.setItemMeta(meta); - inv2.setItem(13, tntst); - } else { - ItemStack tntst1 = new ItemStack(351, 1, (short) 8); - meta = tntst1.getItemMeta(); - meta.setDisplayName(ChatColor.RED + "§eStatus §4Aus"); - tntst1.setItemMeta(meta); - inv2.setItem(13, tntst1); - } - if (member.isWorldEdit()) { - ItemStack tntst = new ItemStack(351, 1, (short) 10); - meta = tntst.getItemMeta(); - meta.setDisplayName(ChatColor.RED + "§eStatus §2An"); - tntst.setItemMeta(meta); - inv2.setItem(14, tntst); - } else { - ItemStack tntst1 = new ItemStack(351, 1, (short) 8); - meta = tntst1.getItemMeta(); - meta.setDisplayName(ChatColor.RED + "§eStatus §4Aus"); - tntst1.setItemMeta(meta); - inv2.setItem(14, tntst1); - } - if (member.isWorldEdit()) { - ItemStack tntst = new ItemStack(351, 1, (short) 10); - meta = tntst.getItemMeta(); - meta.setDisplayName(ChatColor.RED + "§eStatus §2An"); - tntst.setItemMeta(meta); - inv2.setItem(15, tntst); - } else { - ItemStack tntst1 = new ItemStack(351, 1, (short) 8); - meta = tntst1.getItemMeta(); - meta.setDisplayName(ChatColor.RED + "§eStatus §4Aus"); - tntst1.setItemMeta(meta); - inv2.setItem(15, tntst1); - } - if (member.isWorldEdit()) { - ItemStack tntst = new ItemStack(351, 1, (short) 10); - meta = tntst.getItemMeta(); - meta.setDisplayName(ChatColor.RED + "§eStatus §2An"); - tntst.setItemMeta(meta); - inv2.setItem(16, tntst); - } else { - ItemStack tntst1 = new ItemStack(351, 1, (short) 8); - meta = tntst1.getItemMeta(); - meta.setDisplayName(ChatColor.RED + "§eStatus §4Aus"); - tntst1.setItemMeta(meta); - inv2.setItem(16, tntst1); - } - } - return inv2; - } - - public static Inventory mainmenu() { - - Inventory inv = Bukkit.createInventory(null, 9, "§aBau Optionen"); - { - ItemStack bau = new ItemStack(Material.COMPASS); - ItemMeta meta = bau.getItemMeta(); - meta.setDisplayName(ChatColor.RED + "§bBauregionen"); - bau.setItemMeta(meta); - inv.addItem(bau); - ItemStack optionen = new ItemStack(Material.ENCHANTED_BOOK); - meta = optionen.getItemMeta(); - meta.setDisplayName("§bWeltoptionen"); - optionen.setItemMeta(meta); - inv.setItem(8, optionen); - ItemStack spieler = new ItemStack(Material.REDSTONE_BLOCK); - meta = spieler.getItemMeta(); - meta.setDisplayName(ChatColor.RED + "§bSpieleroptionen"); - spieler.setItemMeta(meta); - inv.setItem(4, spieler); - } - return inv; - } - - private Inventory spieleroption(Player player) { - Inventory inv = Bukkit.createInventory(null, 54, "§bSpieleroptionen"); - { - inv.clear(); - int slot = 0; - for (Player p : Bukkit.getOnlinePlayers()) { - inv.setItem(slot, getSkull(p.getName())); - slot++; - } - ItemStack skull1 = new ItemStack(Material.SLIME_BALL); - ItemMeta meta1 = skull1.getItemMeta(); - meta1 = skull1.getItemMeta(); - meta1.setDisplayName(ChatColor.RED + "§bZurück"); - skull1.setItemMeta(meta1); - inv.setItem(53, skull1); - }return inv; - } - - private Inventory bauabteilung() { - Inventory inv1 = Bukkit.createInventory(null, 54, "§bBauregionen"); - { - ItemStack warship1 = new ItemStack(Material.WATER_BUCKET); - ItemMeta meta = warship1.getItemMeta(); - meta.setDisplayName("§bWarShip §aTestGelände 1"); - warship1.setItemMeta(meta); - inv1.addItem(warship1); - ItemStack warship2 = new ItemStack(Material.WATER_BUCKET); - meta = warship2.getItemMeta(); - meta.setDisplayName("§bWarShip §aTestGelände 2"); - warship2.setItemMeta(meta); - inv1.setItem(1, warship2); - ItemStack wargear1 = new ItemStack(Material.REDSTONE_BLOCK); - meta = wargear1.getItemMeta(); - meta.setDisplayName("§bWarGear §aTestGelände 5"); - wargear1.setItemMeta(meta); - inv1.setItem(9, wargear1); - ItemStack wargear2 = new ItemStack(Material.REDSTONE_BLOCK); - meta = wargear2.getItemMeta(); - meta.setDisplayName("§bWarGear §aTestGelände 6"); - wargear2.setItemMeta(meta); - inv1.setItem(10, wargear2); - ItemStack wargear3 = new ItemStack(Material.REDSTONE_BLOCK); - meta = wargear3.getItemMeta(); - meta.setDisplayName("§bWarGear §aTestGelände 7"); - wargear3.setItemMeta(meta); - inv1.setItem(11, wargear3); - ItemStack wargear4 = new ItemStack(Material.REDSTONE_BLOCK); - meta = wargear4.getItemMeta(); - meta.setDisplayName("§bWarGear §aTestGelände 8"); - wargear4.setItemMeta(meta); - inv1.setItem(12, wargear4); - ItemStack miniwargear1 = new ItemStack(Material.REDSTONE); - meta = miniwargear1.getItemMeta(); - meta.setDisplayName("§bMiniWarGear §aTestGelände 1"); - miniwargear1.setItemMeta(meta); - inv1.setItem(18, miniwargear1); - ItemStack miniwargear2 = new ItemStack(Material.REDSTONE); - meta = miniwargear2.getItemMeta(); - meta.setDisplayName("§bMiniWarGear §aTestGelände 2"); - miniwargear2.setItemMeta(meta); - inv1.setItem(19, miniwargear2); - ItemStack miniwargear3 = new ItemStack(Material.REDSTONE); - meta = miniwargear3.getItemMeta(); - meta.setDisplayName("§bMiniWarGear §aTestGelände 7"); - miniwargear3.setItemMeta(meta); - inv1.setItem(20, miniwargear3); - ItemStack miniwargear4 = new ItemStack(Material.REDSTONE); - meta = miniwargear4.getItemMeta(); - meta.setDisplayName("§bMiniWarGear §aTestGelände 8"); - miniwargear4.setItemMeta(meta); - inv1.setItem(21, miniwargear4); - ItemStack airship1 = new ItemStack(Material.ELYTRA); - meta = airship1.getItemMeta(); - meta.setDisplayName("§bAirShip §aTestGelände 1"); - airship1.setItemMeta(meta); - inv1.setItem(27, airship1); - ItemStack airship2 = new ItemStack(Material.ELYTRA); - meta = airship2.getItemMeta(); - meta.setDisplayName("§bAirShip §aTestGelände 2"); - airship2.setItemMeta(meta); - inv1.setItem(28, airship2); - ItemStack airship3 = new ItemStack(Material.ELYTRA); - meta = airship3.getItemMeta(); - meta.setDisplayName("§bAirShip §aTestGelände 3"); - airship3.setItemMeta(meta); - inv1.setItem(29, airship3); - ItemStack airship4 = new ItemStack(Material.ELYTRA); - meta = airship4.getItemMeta(); - meta.setDisplayName("§bAirShip §aTestGelände 4"); - airship4.setItemMeta(meta); - inv1.setItem(30, airship4); - ItemStack airship5 = new ItemStack(Material.ELYTRA); - meta = airship5.getItemMeta(); - meta.setDisplayName("§bAirShip §aTestGelände 5"); - airship5.setItemMeta(meta); - inv1.setItem(31, airship5); - ItemStack airship6 = new ItemStack(Material.ELYTRA); - meta = airship6.getItemMeta(); - meta.setDisplayName("§bAirShip §aTestGelände 6"); - airship6.setItemMeta(meta); - inv1.setItem(32, airship6); - ItemStack airship7 = new ItemStack(Material.ELYTRA); - meta = airship7.getItemMeta(); - meta.setDisplayName("§bAirShip §aTestGelände 7"); - airship7.setItemMeta(meta); - inv1.setItem(33, airship7); - ItemStack airship8 = new ItemStack(Material.ELYTRA); - meta = airship8.getItemMeta(); - meta.setDisplayName("§bAirShip §aTestGelände 8"); - airship8.setItemMeta(meta); - inv1.setItem(34, airship8); - ItemStack back = new ItemStack(Material.SLIME_BALL); - ItemMeta meta1 = back.getItemMeta(); - meta1.setDisplayName("§bZurück"); - back.setItemMeta(meta1); - inv1.setItem(53, back); - }return inv1; - } - - private Inventory weltoption(Player p) { - Inventory inv2 = Bukkit.createInventory(null, 18, "§bWeltoptionen"); - { - ItemStack tnt = new ItemStack(Material.TNT); - ItemMeta meta = tnt.getItemMeta(); - meta.setDisplayName("§aTNT Schaden"); - tnt.setItemMeta(meta); - inv2.addItem(tnt); - ItemStack back = new ItemStack(Material.SLIME_BALL); - meta = back.getItemMeta(); - meta.setDisplayName("§bZurück"); - back.setItemMeta(meta); - inv2.setItem(4, back); - ItemStack fire = new ItemStack(Material.LAVA_BUCKET); - meta = fire.getItemMeta(); - meta.setDisplayName("§aFeuer Schaden"); - fire.setItemMeta(meta); - inv2.setItem(8, fire); - p.openInventory(inv2); - if (Bauwelt.getBauwelt(p.getUniqueId()).isTNTDmg()) { - ItemStack tntst = new ItemStack(351, 1, (short) 10); - meta = tntst.getItemMeta(); - meta.setDisplayName("§eStatus §2An"); - tntst.setItemMeta(meta); - inv2.setItem(9, tntst); - p.closeInventory(); - p.openInventory(inv2); - } else { - ItemStack tntst1 = new ItemStack(351, 1, (short) 8); - meta = tntst1.getItemMeta(); - meta.setDisplayName("§eStatus §4Aus"); - tntst1.setItemMeta(meta); - inv2.setItem(9, tntst1); - p.closeInventory(); - p.openInventory(inv2); - } - if (Bauwelt.getBauwelt(p.getUniqueId()).isFireDmg()) { - ItemStack tntst = new ItemStack(351, 1, (short) 10); - meta = tntst.getItemMeta(); - meta.setDisplayName("§eStatus §2An"); - tntst.setItemMeta(meta); - inv2.setItem(17, tntst); - p.closeInventory(); - p.openInventory(inv2); - } else { - ItemStack tntst1 = new ItemStack(351, 1, (short) 8); - meta = tntst1.getItemMeta(); - meta.setDisplayName("§eStatus §4Aus"); - tntst1.setItemMeta(meta); - inv2.setItem(17, tntst1); - p.closeInventory(); - p.openInventory(inv2); - } - }return inv2; - } -} \ No newline at end of file diff --git a/src/de/warking/bausystem/commands/CommandNV.java b/src/de/warking/bausystem/commands/CommandNV.java deleted file mode 100644 index 17f3685..0000000 --- a/src/de/warking/bausystem/commands/CommandNV.java +++ /dev/null @@ -1,25 +0,0 @@ -package de.warking.bausystem.commands; - -import de.pro_crafting.commandframework.Command; -import de.pro_crafting.commandframework.CommandArgs; -import de.warking.bausystem.BauSystem; -import org.bukkit.entity.Player; -import org.bukkit.potion.PotionEffect; -import org.bukkit.potion.PotionEffectType; - -public class CommandNV { - - @Command(name = "nv", aliases = "nightvision", inGameOnly = true) - public void onNightVision(CommandArgs args){ - Player p = args.getPlayer(); - for(PotionEffect effect : p.getActivePotionEffects()){ - if(effect.getType().equals(PotionEffectType.NIGHT_VISION)){ - p.sendMessage(BauSystem.PREFIX + "Nachtsicht deaktiviert"); - p.removePotionEffect(PotionEffectType.NIGHT_VISION); - return; - } - } - p.addPotionEffect(new PotionEffect(PotionEffectType.NIGHT_VISION, 1000000, 255, false, false)); - p.sendMessage(BauSystem.PREFIX + "Nachtsicht aktiviert"); - } -} diff --git a/src/de/warking/bausystem/commands/CommandTrace.java b/src/de/warking/bausystem/commands/CommandTrace.java deleted file mode 100644 index f276d46..0000000 --- a/src/de/warking/bausystem/commands/CommandTrace.java +++ /dev/null @@ -1,93 +0,0 @@ -package de.warking.bausystem.commands; - -import de.pro_crafting.commandframework.Command; -import de.pro_crafting.commandframework.CommandArgs; -import de.warking.bausystem.BauSystem; -import de.warking.bausystem.world.BauWorld; -import de.warking.bausystem.world.Permission; -import de.warking.bausystem.world.TNTTracer; -import org.bukkit.entity.Player; - -import java.util.UUID; - -public class CommandTrace { - - @Command(name = "trace", inGameOnly = true) - public void onTrace(CommandArgs args){ - Player p = args.getPlayer(); - p.sendMessage("§6/trace start §7- Startet die Aufnahme aller TNT-Positionen"); - p.sendMessage("§6/trace show §7- Zeigt alle TNT-Positionen"); - p.sendMessage("§6/trace hide §7- Versteckt die TNT-Positionen wieder"); - p.sendMessage("§6/trace stop §7- Bricht die Aufnahme ab"); - } - - @Command(name = "trace.start", inGameOnly = true) - public void onStart(CommandArgs args){ - Player p = args.getPlayer(); - UUID id = BauWorld.getWorldUUID(p.getWorld()); - if(!BauWorld.hasPermission(id, p, Permission.world)){ - p.sendMessage(BauSystem.PREFIX + "§cDu darfst hier nicht den TNT-Tracer nutzen"); - return; - } - - TNTTracer.newTracer(p.getWorld()); - p.sendMessage(BauSystem.PREFIX + "§aAufnahme gestartet"); - } - - @Command(name = "trace.stop", inGameOnly = true) - public void onStop(CommandArgs args){ - Player p = args.getPlayer(); - UUID id = BauWorld.getWorldUUID(p.getWorld()); - if(!BauWorld.hasPermission(id, p, Permission.world)){ - p.sendMessage(BauSystem.PREFIX + "§cDu darfst hier nicht den TNT-Tracer nutzen"); - return; - } - - TNTTracer t = TNTTracer.get(p.getWorld()); - if(t == null){ - p.sendMessage(BauSystem.PREFIX + "§cKein laufender TNT-Tracer"); - return; - } - - t.end(); - p.sendMessage(BauSystem.PREFIX + "§aAufnahme abgebrochen"); - } - - @Command(name = "trace.show", inGameOnly = true) - public void onShow(CommandArgs args){ - Player p = args.getPlayer(); - UUID id = BauWorld.getWorldUUID(p.getWorld()); - if(!BauWorld.hasPermission(id, p, Permission.world)){ - p.sendMessage(BauSystem.PREFIX + "§cDu darfst hier nicht den TNT-Tracer nutzen"); - return; - } - - TNTTracer t = TNTTracer.get(p.getWorld()); - if(t == null){ - p.sendMessage(BauSystem.PREFIX + "§cKein laufender TNT-Tracer"); - return; - } - - t.show(); - p.sendMessage(BauSystem.PREFIX + "§aTNT-Positionen angezeigt"); - } - - @Command(name = "trace.hide", inGameOnly = true) - public void onHide(CommandArgs args){ - Player p = args.getPlayer(); - UUID id = BauWorld.getWorldUUID(p.getWorld()); - if(!BauWorld.hasPermission(id, p, Permission.world)){ - p.sendMessage(BauSystem.PREFIX + "§cDu darfst hier nicht den TNT-Tracer nutzen"); - return; - } - - TNTTracer t = TNTTracer.get(p.getWorld()); - if(t == null){ - p.sendMessage(BauSystem.PREFIX + "§cKein laufender TNT-Tracer"); - return; - } - - t.hide(); - p.sendMessage(BauSystem.PREFIX + "§aTNT-Positionen versteckt"); - } -} diff --git a/src/de/warking/bausystem/config/Config.java b/src/de/warking/bausystem/config/Config.java deleted file mode 100644 index b698c60..0000000 --- a/src/de/warking/bausystem/config/Config.java +++ /dev/null @@ -1,133 +0,0 @@ -package de.warking.bausystem.config; - -import org.bukkit.Bukkit; -import org.bukkit.Location; -import org.bukkit.WorldCreator; -import org.bukkit.configuration.file.FileConfiguration; -import org.bukkit.configuration.file.YamlConfiguration; - -import java.io.File; -import java.io.IOException; - -public class Config { - - private final File file; - public final FileConfiguration cfg; - - public String backupDir; - public String regionDir; - public Location spawn; - private Location pasteloc; - - public Config() { - this.file = new File("plugins/BauSystem/config.yml"); - this.cfg = YamlConfiguration.loadConfiguration(this.file); - } - - public void initConfig() { - this.cfg.options().copyDefaults(true); - cfg.options().header("Locations are in format: world/x/y/z/yaw/pitch"); - this.cfg.addDefault("WorldSource.dir", "dirHere"); - this.cfg.addDefault("RegionSource.dir", "dirHere"); - cfg.addDefault("Location.spawn", "world/0/64/0/90/0"); - - cfg.addDefault("Coords.loc.x", 0); - cfg.addDefault("Coords.loc.y", 0); - cfg.addDefault("Coords.loc.z", 0); - cfg.addDefault("MiniWargear1.loc.x", -907); - cfg.addDefault("MiniWargear1.loc.y", 122); - cfg.addDefault("MiniWargear1.loc.z", -29); - cfg.addDefault("MiniWargear1.Message", "§aDu wurdest zum MiniWarGear-Testgelände 1 teleportiert."); - cfg.addDefault("MiniWargear2.loc.x", -841); - cfg.addDefault("MiniWargear2.loc.y", 122); - cfg.addDefault("MiniWargear2.loc.z", -29); - cfg.addDefault("MiniWargear2.Message", "§aDu wurdest zum MiniWarGear-Testgelände 2 teleportiert."); - cfg.addDefault("MiniWargear7.loc.x", -907); - cfg.addDefault("MiniWargear7.loc.y", 122); - cfg.addDefault("MiniWargear7.loc.z", -29); - cfg.addDefault("MiniWargear7.Message", "§aDu wurdest zum MiniWarGear-Testgelände 7 teleportiert."); - cfg.addDefault("MiniWargear8.loc.x", -841); - cfg.addDefault("MiniWargear8.loc.y", 122); - cfg.addDefault("MiniWargear8.loc.z", -120); - cfg.addDefault("MiniWargear8.Message", "§aDu wurdest zum MiniWarGear-Testgelände 8 teleportiert."); - cfg.addDefault("WarGear5.loc.x", -1332); - cfg.addDefault("WarGear5.loc.y", 122); - cfg.addDefault("WarGear5.loc.z", -53); - cfg.addDefault("WarGear5.Message", "§aDu wurdest zum WarGear-Testgelände 5 teleportiert."); - cfg.addDefault("WarGear6.loc.x", -1220); - cfg.addDefault("WarGear6.loc.y", 122); - cfg.addDefault("WarGear6.loc.z", -53); - cfg.addDefault("WarGear6.Message", "§aDu wurdest zum WarGear-Testgelände 6 teleportiert."); - cfg.addDefault("WarGear7.loc.x", -1108); - cfg.addDefault("WarGear7.loc.y", 122); - cfg.addDefault("WarGear7.loc.z", -53); - cfg.addDefault("WarGear7.Message", "§aDu wurdest zum WarGear-Testgelände 7 teleportiert."); - cfg.addDefault("WarGear8.loc.x", -996); - cfg.addDefault("WarGear8.loc.y", 122); - cfg.addDefault("WarGear8.loc.z", -53); - cfg.addDefault("WarGear8.Message", "§aDu wurdest zum WarGear-Testgelände 8 teleportiert."); - cfg.addDefault("WarShip1.loc.x", -943); - cfg.addDefault("WarShip1.loc.y", 122); - cfg.addDefault("WarShip1.loc.z", 149); - cfg.addDefault("WarShip1.Message", "§aDu wurdest zum WarShip-Testgelände 1 teleportiert."); - cfg.addDefault("WarShip2.loc.x", -1200); - cfg.addDefault("WarShip2.loc.y", 122); - cfg.addDefault("WarShip2.loc.z", 149); - cfg.addDefault("WarShip2.Message", "§aDu wurdest zum WarShip-Testgelände 2 teleportiert."); - cfg.addDefault("AirShip1.loc.x", -674); - cfg.addDefault("AirShip1.loc.y", 122); - cfg.addDefault("AirShip1.loc.z", -45); - cfg.addDefault("AirShip1.Message", "§aDu wurdest zum AirShip-Testgelände 1 teleportiert."); - cfg.addDefault("AirShip2.loc.x", -487); - cfg.addDefault("AirShip2.loc.y", 122); - cfg.addDefault("AirShip2.loc.z", -45); - cfg.addDefault("AirShip2.Message", "§aDu wurdest zum AirShip-Testgelände 2 teleportiert."); - cfg.addDefault("AirShip3.loc.x", -302); - cfg.addDefault("AirShip3.loc.y", 122); - cfg.addDefault("AirShip3.loc.z", -45); - cfg.addDefault("AirShip3.Message", "§aDu wurdest zum AirShip-Testgelände 3 teleportiert."); - cfg.addDefault("AirShip4.loc.x", -115); - cfg.addDefault("AirShip4.loc.y", 122); - cfg.addDefault("AirShip4.loc.z", -45); - cfg.addDefault("AirShip4.Message", "§aDu wurdest zum AirShip-Testgelände 4 teleportiert."); - cfg.addDefault("AirShip5.loc.x", -115); - cfg.addDefault("AirShip5.loc.y", 122); - cfg.addDefault("AirShip5.loc.z", 201); - cfg.addDefault("AirShip5.Message", "§aDu wurdest zum AirShip-Testgelände 5 teleportiert."); - cfg.addDefault("AirShip6.loc.x", -302); - cfg.addDefault("AirShip6.loc.y", 122); - cfg.addDefault("AirShip6.loc.z", 201); - cfg.addDefault("AirShip6.Message", "§aDu wurdest zum AirShip-Testgelände 6 teleportiert."); - cfg.addDefault("AirShip7.loc.x", -487); - cfg.addDefault("AirShip7.loc.y", 122); - cfg.addDefault("AirShip7.loc.z", 201); - cfg.addDefault("AirShip7.Message", "§aDu wurdest zum AirShip-Testgelände 7 teleportiert."); - cfg.addDefault("AirShip8.loc.x", -674); - cfg.addDefault("AirShip8.loc.y", 122); - cfg.addDefault("AirShip8.loc.z", 201); - cfg.addDefault("AirShip8.Message", "§aDu wurdest zum AirShip-Testgelände 8 teleportiert."); - cfg.addDefault("Lobby.name", "Lobby"); - try { - this.cfg.save(this.file); - } catch (IOException e) { - e.printStackTrace(); - } - backupDir = cfg.getString("WorldSource.dir"); - regionDir = cfg.getString("RegionSource.dir"); - spawn = toLocation(cfg.getString("Location.spawn")); - pasteloc = new Location(null, cfg.getDouble("Coords.loc.x"), cfg.getDouble("Coords.loc.y"), cfg.getDouble("Coords.loc.z")); - } - - private Location toLocation(String configString) { - String[] splitted = configString.split("/"); - String wName = splitted[0]; - double x = Double.parseDouble(splitted[1]); - double y = Double.parseDouble(splitted[2]); - double z = Double.parseDouble(splitted[3]); - float yaw = Float.parseFloat(splitted[4]); - float pitch = Float.parseFloat(splitted[5]); - if(Bukkit.getWorld(wName) == null) - Bukkit.createWorld(new WorldCreator(wName)); - return new Location(Bukkit.getWorld(wName), x, y, z, yaw, pitch); - } -} diff --git a/src/de/warking/bausystem/world/LagDetectorRunnable.java b/src/de/warking/bausystem/world/LagDetectorRunnable.java deleted file mode 100644 index 6cd159f..0000000 --- a/src/de/warking/bausystem/world/LagDetectorRunnable.java +++ /dev/null @@ -1,65 +0,0 @@ -package de.warking.bausystem.world; - -import de.warking.bausystem.BauSystem; -import org.bukkit.Bukkit; -import org.bukkit.World; -import org.bukkit.entity.Entity; -import org.bukkit.entity.Player; - -import java.util.HashMap; -import java.util.UUID; - -public class LagDetectorRunnable implements Runnable { - - private HashMap timerstart = new HashMap<>(); - - @Override - public void run() { - for(World world : Bukkit.getWorlds()){ - world.setStorm(false); - world.setThundering(false); - world.setMonsterSpawnLimit(0); - world.setAnimalSpawnLimit(0); - world.setGameRuleValue("announceAdvancements", "false"); - - UUID worldOwner; - - try{ - worldOwner = UUID.fromString(world.getName()); - }catch(IllegalArgumentException E){ - continue; - } - - int players = 0; - int other = 0; - for (Entity e : world.getEntities()) { - if (e instanceof Player) - players++; - else - other++; - } - - if(timerstart.containsKey(worldOwner)) { - if(players == 0){ - if (System.currentTimeMillis() - timerstart.get(worldOwner) > 60000) { - BauWorld.unloadWorld(worldOwner); - continue; - } - }else{ - timerstart.remove(worldOwner); - } - }else if(players == 0){ - timerstart.put(worldOwner, System.currentTimeMillis()); - } - - if (other > 1000) { - for (Entity e : world.getEntities()) { - if (e instanceof Player) - continue; - e.remove(); - } - BauWorld.broadcast(worldOwner, BauSystem.PREFIX +"§cLagverursachung erkannt. Es wurden §6"+other+" Entities§c entfernt."); - } - } - } -} diff --git a/src/plugin.yml b/src/plugin.yml index 9ce4876..29ec693 100644 --- a/src/plugin.yml +++ b/src/plugin.yml @@ -1,6 +1,15 @@ name: BauSystem -author: Exceptionflug, RedstoneTechnik, Lixfel +author: Lixfel version: 1.0 -depend: [WorldEdit, WorldGuard] - -main: de.warking.bausystem.BauSystem \ No newline at end of file +depend: [WorldEdit, CoreSystem] +load: POSTWORLD +main: de.steamwar.bausystem.BauSystem +commands: + tnt: + fire: + trace: + testblock: + reset: + speed: + nightvision: + aliases: nv \ No newline at end of file