diff --git a/dependency-reduced-pom.xml b/dependency-reduced-pom.xml new file mode 100644 index 0000000..d5c355b --- /dev/null +++ b/dependency-reduced-pom.xml @@ -0,0 +1,84 @@ + + + 4.0.0 + nl.iobyte + themeparkconnector + 3.0.1 + + + + maven-shade-plugin + 3.2.0 + + + package + + shade + + + + + + + + + vault-repo + http://nexus.hc.to/content/repositories/pub_releases + + + codemc-repo + https://repo.codemc.org/repository/maven-public/ + + + + + org.spigotmc + spigot-api + 1.12.2-R0.1-SNAPSHOT + provided + + + commons-lang + commons-lang + + + json-simple + com.googlecode.json-simple + + + guava + com.google.guava + + + gson + com.google.code.gson + + + snakeyaml + org.yaml + + + bungeecord-chat + net.md-5 + + + + + nl.iobyte + themepark + 3.0.2 + provided + + + net.milkbowl.vault + VaultAPI + 1.7 + provided + + + + 11 + 11 + UTF-8 + + diff --git a/pom.xml b/pom.xml index 41fa513..21a7d71 100644 --- a/pom.xml +++ b/pom.xml @@ -12,7 +12,7 @@ nl.iobyte themeparkconnector - 3.0.0 + 3.0.1 @@ -41,7 +41,7 @@ nl.iobyte themepark - 3.0.0 + 3.0.2 provided diff --git a/src/main/java/nl/iobyte/themeparkconnector/commands/ThemeParkConnectorCommand.java b/src/main/java/nl/iobyte/themeparkconnector/commands/ThemeParkConnectorCommand.java index 6c826fb..4f1bfc8 100644 --- a/src/main/java/nl/iobyte/themeparkconnector/commands/ThemeParkConnectorCommand.java +++ b/src/main/java/nl/iobyte/themeparkconnector/commands/ThemeParkConnectorCommand.java @@ -1,10 +1,14 @@ package nl.iobyte.themeparkconnector.commands; import nl.iobyte.commandapi.CommandFactory; +import nl.iobyte.commandapi.interfaces.ICommandExecutor; import nl.iobyte.commandapi.middlewares.PermissionMiddleware; +import nl.iobyte.themepark.commands.executors.ConsoleExecutor; +import nl.iobyte.themepark.commands.executors.PlayerExecutor; import nl.iobyte.themeparkconnector.ThemeParkConnector; import nl.iobyte.themeparkconnector.commands.subcommands.*; import nl.iobyte.themeparkconnector.commands.subcommands.operator.OperatorCommands; +import org.bukkit.entity.Player; public class ThemeParkConnectorCommand { @@ -26,7 +30,14 @@ public class ThemeParkConnectorCommand { factory.addMiddleware(new PermissionMiddleware()); //Register command - factory.registerCommand(ThemeParkConnector.getInstance()); + ThemeParkConnector.getInstance().getCommand(factory.getName()).setExecutor((sender, command, s, args) -> { + ICommandExecutor executor = new ConsoleExecutor(sender); + if(sender instanceof Player) + executor = new PlayerExecutor((Player) sender); + + factory.onCommand(executor, args); + return true; + }); } } diff --git a/src/main/java/nl/iobyte/themeparkconnector/commands/arguments/OperatorArgument.java b/src/main/java/nl/iobyte/themeparkconnector/commands/arguments/OperatorArgument.java index 226d6f6..10a8662 100644 --- a/src/main/java/nl/iobyte/themeparkconnector/commands/arguments/OperatorArgument.java +++ b/src/main/java/nl/iobyte/themeparkconnector/commands/arguments/OperatorArgument.java @@ -7,7 +7,7 @@ import nl.iobyte.themeparkconnector.api.operator.objects.AttractionOperator; import nl.iobyte.themeparkconnector.api.operator.objects.panel.OperatorItem; import nl.iobyte.themeparkconnector.api.operator.objects.panel.OperatorItemState; import org.bukkit.ChatColor; -import org.bukkit.command.CommandSender; +import nl.iobyte.commandapi.interfaces.ICommandExecutor; import java.util.Arrays; import java.util.List; @@ -27,12 +27,12 @@ public class OperatorArgument implements ICommandArgument { /** * Check if argument is valid OperatorItemState - * @param sender CommandSender + * @param sender ICommandExecutor * @param args Arguments passed by Command * @param previousArguments Previous arguments * @return Boolean */ - public ArgumentCheck checkArgument(CommandSender sender, String[] args, List previousArguments) { + public ArgumentCheck checkArgument(ICommandExecutor sender, String[] args, List previousArguments) { if(args.length < 3) return new ArgumentCheck(false, 1); @@ -49,12 +49,12 @@ public class OperatorArgument implements ICommandArgument { /** * Get OperatorItemState passed by command - * @param sender CommandSender + * @param sender ICommandExecutor * @param args Arguments passed by Command * @param previousArguments Previous arguments * @return OperatorItemState */ - public OperatorItemState getArgument(CommandSender sender, String[] args, List previousArguments) { + public OperatorItemState getArgument(ICommandExecutor sender, String[] args, List previousArguments) { AttractionOperator operator = ThemeParkConnector.getInstance().getAPI().getOperatorService().getOperator(args[0]); previousArguments.add(operator); diff --git a/src/main/java/nl/iobyte/themeparkconnector/commands/subcommands/ConnectCommand.java b/src/main/java/nl/iobyte/themeparkconnector/commands/subcommands/ConnectCommand.java index a5ede0d..ffc3878 100644 --- a/src/main/java/nl/iobyte/themeparkconnector/commands/subcommands/ConnectCommand.java +++ b/src/main/java/nl/iobyte/themeparkconnector/commands/subcommands/ConnectCommand.java @@ -1,13 +1,13 @@ package nl.iobyte.themeparkconnector.commands.subcommands; -import nl.iobyte.commandapi.interfaces.SubCommand; +import nl.iobyte.commandapi.objects.SubCommand; import nl.iobyte.themepark.api.attraction.objects.Attraction; import nl.iobyte.themepark.commands.arguments.AttractionArgument; import nl.iobyte.themeparkconnector.ThemeParkConnector; import nl.iobyte.themeparkconnector.api.client.ClientConnection; import nl.iobyte.themeparkconnector.api.message.Text; import nl.iobyte.themeparkconnector.api.operator.objects.AttractionOperator; -import org.bukkit.command.CommandSender; +import nl.iobyte.commandapi.interfaces.ICommandExecutor; import org.bukkit.entity.Player; import java.util.List; @@ -22,7 +22,8 @@ public class ConnectCommand extends SubCommand { } //Attempt to generate an url for the Player - public void onPlayerCommand(Player player, List list, int i) { + public void onCommand(ICommandExecutor sender, List list, int i) { + Player player = (Player) sender.getOriginal(); Attraction attraction = (Attraction) list.get(0); AttractionOperator operator = ThemeParkConnector.getInstance().getAPI().getOperatorService().getOperator(attraction.getID()); if(operator == null) { @@ -41,6 +42,4 @@ public class ConnectCommand extends SubCommand { client.publishURL(attraction.getID()); } - public void onConsoleCommand(CommandSender commandSender, List list, int i) { } - } diff --git a/src/main/java/nl/iobyte/themeparkconnector/commands/subcommands/DisconnectCommand.java b/src/main/java/nl/iobyte/themeparkconnector/commands/subcommands/DisconnectCommand.java index 23e5d35..335535c 100644 --- a/src/main/java/nl/iobyte/themeparkconnector/commands/subcommands/DisconnectCommand.java +++ b/src/main/java/nl/iobyte/themeparkconnector/commands/subcommands/DisconnectCommand.java @@ -1,11 +1,10 @@ package nl.iobyte.themeparkconnector.commands.subcommands; -import nl.iobyte.commandapi.interfaces.SubCommand; +import nl.iobyte.commandapi.objects.SubCommand; import nl.iobyte.themeparkconnector.ThemeParkConnector; import nl.iobyte.themeparkconnector.api.ThemeParkConnectorAPI; import nl.iobyte.themeparkconnector.api.message.Text; -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; +import nl.iobyte.commandapi.interfaces.ICommandExecutor; import java.util.List; public class DisconnectCommand extends SubCommand { @@ -17,11 +16,7 @@ public class DisconnectCommand extends SubCommand { } //Attempt to generate an url for the Player - public void onPlayerCommand(Player player, List list, int i) { - onConsoleCommand(player, list, i); - } - - public void onConsoleCommand(CommandSender sender, List list, int i) { + public void onCommand(ICommandExecutor sender, List list, int i) { ThemeParkConnectorAPI api = ThemeParkConnector.getInstance().getAPI(); try { if (api.getStateService().isConnected()) diff --git a/src/main/java/nl/iobyte/themeparkconnector/commands/subcommands/HelpCommand.java b/src/main/java/nl/iobyte/themeparkconnector/commands/subcommands/HelpCommand.java index 72b5922..c0047ce 100644 --- a/src/main/java/nl/iobyte/themeparkconnector/commands/subcommands/HelpCommand.java +++ b/src/main/java/nl/iobyte/themeparkconnector/commands/subcommands/HelpCommand.java @@ -2,9 +2,9 @@ package nl.iobyte.themeparkconnector.commands.subcommands; import nl.iobyte.commandapi.CommandFactory; import nl.iobyte.commandapi.arguments.number.IntegerArgument; -import nl.iobyte.commandapi.interfaces.SubCommand; +import nl.iobyte.commandapi.objects.SubCommand; import nl.iobyte.themeparkconnector.api.message.Text; -import org.bukkit.command.CommandSender; +import nl.iobyte.commandapi.interfaces.ICommandExecutor; import org.bukkit.entity.Player; import java.util.List; @@ -21,12 +21,8 @@ public class HelpCommand extends SubCommand { .addArgument(new IntegerArgument()); } - public void onPlayerCommand(Player player, List list, int i) { - onConsoleCommand(player, list, i); - } - - //Send CommandSender list of commands it has access to - public void onConsoleCommand(CommandSender sender, List list, int i) { + //Send ICommandExecutor list of commands it has access to + public void onCommand(ICommandExecutor sender, List list, int i) { List commands = factory.getApplicableSubCommands(sender); if(commands.size() <= 5) { sendSinglePage(sender, commands); @@ -36,7 +32,7 @@ public class HelpCommand extends SubCommand { sendMultiPage(sender, commands, list, i); } - private void sendSinglePage(CommandSender sender, List commands) { + private void sendSinglePage(ICommandExecutor sender, List commands) { sender.sendMessage(Text.color("&f&l>==== &6&lThemeParkConnector &l&f====<")); for (SubCommand command : commands) sender.sendMessage(Text.color("&f" + command.getApplicableSyntaxList(sender).get(0).getUsage())); @@ -44,7 +40,7 @@ public class HelpCommand extends SubCommand { sender.sendMessage(Text.color("&f&l>==== &6&lThemeParkConnector &l&f====<")); } - private void sendMultiPage(CommandSender sender, List commands, List list, int i) { + private void sendMultiPage(ICommandExecutor sender, List commands, List list, int i) { int page = 1; int pages = (int) Math.ceil(((double) commands.size()) / 5); if(i == 1) diff --git a/src/main/java/nl/iobyte/themeparkconnector/commands/subcommands/NotificationCommand.java b/src/main/java/nl/iobyte/themeparkconnector/commands/subcommands/NotificationCommand.java index c2e3e72..be6e81d 100644 --- a/src/main/java/nl/iobyte/themeparkconnector/commands/subcommands/NotificationCommand.java +++ b/src/main/java/nl/iobyte/themeparkconnector/commands/subcommands/NotificationCommand.java @@ -1,13 +1,13 @@ package nl.iobyte.themeparkconnector.commands.subcommands; import nl.iobyte.commandapi.arguments.MessageArgument; -import nl.iobyte.commandapi.arguments.PlayersArgument; -import nl.iobyte.commandapi.interfaces.SubCommand; +import nl.iobyte.commandapi.objects.SubCommand; +import nl.iobyte.themepark.commands.arguments.PlayersArgument; import nl.iobyte.themeparkconnector.ThemeParkConnector; import nl.iobyte.themeparkconnector.api.message.Text; import nl.iobyte.themeparkconnector.api.client.ClientConnection; import nl.iobyte.themeparkconnector.api.client.objects.Notification; -import org.bukkit.command.CommandSender; +import nl.iobyte.commandapi.interfaces.ICommandExecutor; import org.bukkit.entity.Player; import java.util.List; @@ -22,12 +22,9 @@ public class NotificationCommand extends SubCommand { .addArgument(new MessageArgument()); } - public void onPlayerCommand(Player player, List objects, int i) { - onConsoleCommand(player, objects, i); - } - //Get Notification data and send to Player(s) - public void onConsoleCommand(CommandSender sender, List objects, int i) { + @SuppressWarnings("unchecked") + public void onCommand(ICommandExecutor sender, List objects, int i) { Notification notification = new Notification((String) objects.get(1), (String) objects.get(2)); for(Player player : (List) objects.get(0)) { ClientConnection client = ThemeParkConnector.getInstance().getAPI().getNetworkingService().getClient(player.getUniqueId()); diff --git a/src/main/java/nl/iobyte/themeparkconnector/commands/subcommands/StatusCommand.java b/src/main/java/nl/iobyte/themeparkconnector/commands/subcommands/StatusCommand.java index 94f75b0..27320e9 100644 --- a/src/main/java/nl/iobyte/themeparkconnector/commands/subcommands/StatusCommand.java +++ b/src/main/java/nl/iobyte/themeparkconnector/commands/subcommands/StatusCommand.java @@ -1,13 +1,13 @@ package nl.iobyte.themeparkconnector.commands.subcommands; -import nl.iobyte.commandapi.interfaces.SubCommand; +import nl.iobyte.commandapi.objects.SubCommand; import nl.iobyte.themeparkconnector.ThemeParkConnector; import nl.iobyte.themeparkconnector.api.ThemeParkConnectorAPI; import nl.iobyte.themeparkconnector.api.client.ClientConnection; import nl.iobyte.themeparkconnector.api.state.objects.AbstractState; import nl.iobyte.themeparkconnector.api.message.Text; import org.bukkit.Bukkit; -import org.bukkit.command.CommandSender; +import nl.iobyte.commandapi.interfaces.ICommandExecutor; import org.bukkit.entity.Player; import java.util.List; @@ -19,12 +19,8 @@ public class StatusCommand extends SubCommand { addSyntax("/themeparkconnector status"); } - public void onPlayerCommand(Player player, List objects, int i) { - onConsoleCommand(player, objects, i); - } - - //Give CommandSender overview of Plugin status - public void onConsoleCommand(CommandSender sender, List objects, int i) { + //Give ICommandExecutor overview of Plugin status + public void onCommand(ICommandExecutor sender, List objects, int i) { ThemeParkConnectorAPI api = ThemeParkConnector.getInstance().getAPI(); AbstractState state = api.getStateService().getCurrentState(); diff --git a/src/main/java/nl/iobyte/themeparkconnector/commands/subcommands/operator/OperatorReloadCommand.java b/src/main/java/nl/iobyte/themeparkconnector/commands/subcommands/operator/OperatorReloadCommand.java index 9adbb9e..a6dadaf 100644 --- a/src/main/java/nl/iobyte/themeparkconnector/commands/subcommands/operator/OperatorReloadCommand.java +++ b/src/main/java/nl/iobyte/themeparkconnector/commands/subcommands/operator/OperatorReloadCommand.java @@ -1,10 +1,9 @@ package nl.iobyte.themeparkconnector.commands.subcommands.operator; -import nl.iobyte.commandapi.interfaces.SubCommand; +import nl.iobyte.commandapi.objects.SubCommand; import nl.iobyte.themeparkconnector.api.load.objects.OperatorDataLoader; import nl.iobyte.themeparkconnector.api.message.Text; -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; +import nl.iobyte.commandapi.interfaces.ICommandExecutor; import java.util.List; public class OperatorReloadCommand extends SubCommand { @@ -15,13 +14,7 @@ public class OperatorReloadCommand extends SubCommand { addSyntax("/themeparkconnector operator reload"); } - @Override - public void onPlayerCommand(Player player, List list, int i) { - onConsoleCommand(player, list, i); - } - - @Override - public void onConsoleCommand(CommandSender sender, List list, int i) { + public void onCommand(ICommandExecutor sender, List list, int i) { sender.sendMessage(Text.color("&6&lThemeParkConnectorMC &f➢ &6Attempting to load ride operators")); new OperatorDataLoader().load(); } diff --git a/src/main/java/nl/iobyte/themeparkconnector/commands/subcommands/operator/OperatorStateCommand.java b/src/main/java/nl/iobyte/themeparkconnector/commands/subcommands/operator/OperatorStateCommand.java index f2d722f..afaec6b 100644 --- a/src/main/java/nl/iobyte/themeparkconnector/commands/subcommands/operator/OperatorStateCommand.java +++ b/src/main/java/nl/iobyte/themeparkconnector/commands/subcommands/operator/OperatorStateCommand.java @@ -1,7 +1,7 @@ package nl.iobyte.themeparkconnector.commands.subcommands.operator; import nl.iobyte.commandapi.arguments.StringArgument; -import nl.iobyte.commandapi.interfaces.SubCommand; +import nl.iobyte.commandapi.objects.SubCommand; import nl.iobyte.themeparkconnector.ThemeParkConnector; import nl.iobyte.themeparkconnector.api.event.operator.OperatorStateEvent; import nl.iobyte.themeparkconnector.api.message.Text; @@ -9,8 +9,7 @@ import nl.iobyte.themeparkconnector.api.operator.objects.AttractionOperator; import nl.iobyte.themeparkconnector.api.operator.objects.panel.OperatorItem; import nl.iobyte.themeparkconnector.api.operator.objects.panel.OperatorItemState; import nl.iobyte.themeparkconnector.commands.arguments.OperatorArgument; -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; +import nl.iobyte.commandapi.interfaces.ICommandExecutor; import java.util.List; public class OperatorStateCommand extends SubCommand { @@ -26,19 +25,13 @@ public class OperatorStateCommand extends SubCommand { .addArgument(new StringArgument()); } - @Override - public void onPlayerCommand(Player player, List list, int i) { - onConsoleCommand(player, list, i); - } - - @Override - public void onConsoleCommand(CommandSender sender, List list, int i) { + public void onCommand(ICommandExecutor sender, List list, int i) { AttractionOperator operator = (AttractionOperator) list.get(0); OperatorItem item = (OperatorItem) list.get(1); OperatorItemState state = (OperatorItemState) list.get(2); OperatorItemState old = item.getActiveState(); if(state.getID().equals(old.getID())) { - if(sender instanceof Player) + if(sender.isPlayer()) sender.sendMessage(Text.color("&6&lThemeParkConnectorMC &f➢ &4Item already in state: &f"+state.getID())); return; @@ -53,7 +46,7 @@ public class OperatorStateCommand extends SubCommand { i == 0 ? "" : (String) list.get(3) )); - if(sender instanceof Player) + if(sender.isPlayer()) sender.sendMessage(Text.color("&6&lThemeParkConnectorMC &f➢ &aSuccessfully changed state of item to: &f"+state.getID())); } diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 9e93e58..1d49add 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -1,5 +1,5 @@ name: ThemeParkConnector -version: 3.0.0 +version: 3.0.1 author: IOByte website: 'https://www.iobyte.nl' main: nl.iobyte.themeparkconnector.ThemeParkConnector @@ -7,5 +7,5 @@ depend: [ThemePark] softdepend: [Vault,PlaceholderAPI,Train_Carts,Multiverse-Core,MultiWorld] api-version: 1.13 commands: - tpc: - aliases: [themeparkconnector] \ No newline at end of file + themeparkconnector: + aliases: [tpc] \ No newline at end of file diff --git a/themeparkconnector.iml b/themeparkconnector.iml deleted file mode 100644 index 6c99dbb..0000000 --- a/themeparkconnector.iml +++ /dev/null @@ -1,35 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file