From 338cd45b2cb18c09d5823dce1db104f89a803a2a Mon Sep 17 00:00:00 2001 From: luluxe Date: Sat, 20 May 2023 16:24:19 +0200 Subject: [PATCH] Update 1.0.4 to add command /community setup --- dependency-reduced-pom.xml | 2 +- pom.xml | 2 +- .../spigot/commands/DispatchCommand.java | 2 -- .../spigot/commands/HelpCommand.java | 9 ++++----- .../spigot/commands/SetupCommand.java | 18 +++++++++--------- .../spigot/managers/PlatformManager.java | 2 +- .../velocity/VelocityPlugin.java | 2 +- src/main/resources/bungee.yml | 2 +- src/main/resources/plugin.yml | 2 +- src/main/resources/velocity-plugin.json | 2 +- 10 files changed, 20 insertions(+), 23 deletions(-) diff --git a/dependency-reduced-pom.xml b/dependency-reduced-pom.xml index 4a41fb8..bdb9d31 100644 --- a/dependency-reduced-pom.xml +++ b/dependency-reduced-pom.xml @@ -4,7 +4,7 @@ net communityanalytics communityanalytics - 1.0.3 + 1.0.4 http://maven.apache.org diff --git a/pom.xml b/pom.xml index 8a6189c..78f9ac6 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ net communityanalytics - 1.0.3 + 1.0.4 jar communityanalytics diff --git a/src/main/java/net/communityanalytics/spigot/commands/DispatchCommand.java b/src/main/java/net/communityanalytics/spigot/commands/DispatchCommand.java index 1de950e..d2fb60e 100644 --- a/src/main/java/net/communityanalytics/spigot/commands/DispatchCommand.java +++ b/src/main/java/net/communityanalytics/spigot/commands/DispatchCommand.java @@ -11,7 +11,6 @@ import java.util.List; public class DispatchCommand implements CommandExecutor { - private final SpigotPlugin plugin; public DispatchCommand(SpigotPlugin plugin) { @@ -34,7 +33,6 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command break; case "setup": new SetupCommand("setup", getArgs(args,1), sender).execute(plugin); - main_command.execute(plugin); break; case "help": new HelpCommand("help", getArgs(args,1), sender).execute(plugin); diff --git a/src/main/java/net/communityanalytics/spigot/commands/HelpCommand.java b/src/main/java/net/communityanalytics/spigot/commands/HelpCommand.java index 14d9ccf..ced7077 100644 --- a/src/main/java/net/communityanalytics/spigot/commands/HelpCommand.java +++ b/src/main/java/net/communityanalytics/spigot/commands/HelpCommand.java @@ -9,14 +9,13 @@ public class HelpCommand extends Command { public HelpCommand(String name, List args, @NotNull CommandSender sender) { super(name, args, sender); - } @Override protected void execute(SpigotPlugin plugin) { - sender.sendMessage("§f(§b§lCommunityAnalytics§f) §aCommands:"); - sender.sendMessage("§f(§b§lCommunityAnalytics§f) §a- /communityanalytics setup "); - sender.sendMessage("§f(§b§lCommunityAnalytics§f) §a- /communityanalytics reload"); - sender.sendMessage("§f(§b§lCommunityAnalytics§f) §a- /communityanalytics help"); + sender.sendMessage("§f(§b§lCommunityAnalytics§f) §7List of commands:"); + sender.sendMessage("§e» §a/communityanalytics setup §b [server_id]"); + sender.sendMessage("§e» §a/communityanalytics reload"); + sender.sendMessage("§e» §a/communityanalytics help"); } } diff --git a/src/main/java/net/communityanalytics/spigot/commands/SetupCommand.java b/src/main/java/net/communityanalytics/spigot/commands/SetupCommand.java index 9ac8af1..90ff32c 100644 --- a/src/main/java/net/communityanalytics/spigot/commands/SetupCommand.java +++ b/src/main/java/net/communityanalytics/spigot/commands/SetupCommand.java @@ -5,6 +5,7 @@ import org.bukkit.command.CommandSender; import java.io.IOException; +import java.util.ArrayList; import java.util.List; public class SetupCommand extends Command { @@ -15,31 +16,30 @@ public SetupCommand(String name, List args, CommandSender sender) { @Override protected void execute(SpigotPlugin plugin) { - // /setup if (args.size() == 0) { - sender.sendMessage("§f(§b§lCommunityAnalytics§f) §cYou need to specify a key when entering the command !"); + sender.sendMessage("§7Missing arg usage: §a/community setup §b [server_id]"); return; } // Parsing - String server_id = ""; + String server_id = null; if (args.size() == 2) server_id = args.get(1); - String path_name = "plugins/CommunityAnalytics/config.yml"; + String path_name = "plugins/CommunityAnalytics/config.yml"; try { FileUtil.replace(path_name, "platform-api-token:", "platform-api-token: '" + args.get(0)+ "'"); - sender.sendMessage("§f(§b§lCommunityAnalytics§f) §aToken has been set!"); - - if (args.size() == 2) + if (server_id != null) FileUtil.replace(path_name, "server-id:", "server-id: '" + server_id + "'"); - sender.sendMessage("§f(§b§lCommunityAnalytics§f) §aServer id has been set!"); + sender.sendMessage("§f(§b§lCommunityAnalytics§f) §aConfig.yml was updated!"); plugin.reload(); sender.sendMessage("§f(§b§lCommunityAnalytics§f) §aConfig reload!"); + + new MainCommand("communityanalytics", new ArrayList<>(), sender).execute(SpigotPlugin.instance); } catch(IOException exception) { exception.printStackTrace(); - sender.sendMessage("§f(§b§lCommunityAnalytics§f) §cError: " + exception.getMessage()); + sender.sendMessage("§f(§b§lCommunityAnalytics§f) §cError was occurred: " + exception.getMessage()); } } } diff --git a/src/main/java/net/communityanalytics/spigot/managers/PlatformManager.java b/src/main/java/net/communityanalytics/spigot/managers/PlatformManager.java index 0921b94..99674af 100644 --- a/src/main/java/net/communityanalytics/spigot/managers/PlatformManager.java +++ b/src/main/java/net/communityanalytics/spigot/managers/PlatformManager.java @@ -6,7 +6,7 @@ public class PlatformManager { public boolean success = false; - public String version = "1.0.3"; + public String version = "1.0.4"; public void getPlatformInfo() { try { diff --git a/src/main/java/net/communityanalytics/velocity/VelocityPlugin.java b/src/main/java/net/communityanalytics/velocity/VelocityPlugin.java index f329897..e68b44a 100644 --- a/src/main/java/net/communityanalytics/velocity/VelocityPlugin.java +++ b/src/main/java/net/communityanalytics/velocity/VelocityPlugin.java @@ -13,7 +13,7 @@ import org.bstats.velocity.Metrics; import org.slf4j.Logger; -@Plugin(id = "communityanalytics", name = "CommunityAnalytics", version = "1.0.3") +@Plugin(id = "communityanalytics", name = "CommunityAnalytics", version = "1.0.4") public class VelocityPlugin { public static VelocityPlugin instance; private final ChannelIdentifier channel = new LegacyChannelIdentifier(CommunityAnalytics.CHANNEL_INFO); diff --git a/src/main/resources/bungee.yml b/src/main/resources/bungee.yml index 83adaf7..d28f162 100644 --- a/src/main/resources/bungee.yml +++ b/src/main/resources/bungee.yml @@ -1,4 +1,4 @@ name: CommunityAnalytics author: FNetwork main: net.communityanalytics.bungee.BungeePlugin -version: 1.0.3 \ No newline at end of file +version: 1.0.4 \ No newline at end of file diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 56668d3..449316c 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -2,7 +2,7 @@ name: CommunityAnalytics author: FNetwork main: net.communityanalytics.spigot.SpigotPlugin website: https://communityanalytics.net -version: 1.0.3 +version: 1.0.4 api-version: 1.13 commands: communityanalytics: diff --git a/src/main/resources/velocity-plugin.json b/src/main/resources/velocity-plugin.json index 431491e..02ecb34 100644 --- a/src/main/resources/velocity-plugin.json +++ b/src/main/resources/velocity-plugin.json @@ -1,7 +1,7 @@ { "id": "communityanalytics", "name": "CommunityAnalytics", - "version": "1.0.3", + "version": "1.0.4", "authors": [ "FNetwork" ],