diff --git a/pom.xml b/pom.xml index 6ed9d3e..bcd21bc 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ net.t2code AutoResponse - 0.0.1-DEV-2 + 0.0.1 jar T2C-AutoResponse @@ -82,7 +82,7 @@ net.t2code T2CodeLib - 11.0 + 11.1 net.t2code diff --git a/src/main/java/net/t2code/autoresponse/Spigot/config/response/CreateExampleResponse.java b/src/main/java/net/t2code/autoresponse/Spigot/config/response/CreateExampleResponse.java index 340be50..fadd818 100644 --- a/src/main/java/net/t2code/autoresponse/Spigot/config/response/CreateExampleResponse.java +++ b/src/main/java/net/t2code/autoresponse/Spigot/config/response/CreateExampleResponse.java @@ -9,11 +9,12 @@ import org.bukkit.configuration.file.YamlConfiguration; import java.io.File; import java.io.IOException; import java.util.Arrays; +import java.util.Collections; public class CreateExampleResponse { public static void configCreate() { - Long long_ = Long.valueOf(System.currentTimeMillis()); + long long_ = System.currentTimeMillis(); if (new File(Main.getPath(), "config.yml").exists()) { if (Main.plugin.getConfig().getBoolean("Plugin.Debug")) send.console(Util.getPrefix() + " §5DEBUG: §6" + " §4config.yml are created / updated..."); } else send.console(Util.getPrefix() + " §4config.yml are created..."); @@ -24,7 +25,7 @@ public class CreateExampleResponse { Config.set("Response.Enable", true, yamlConfiguration); - Config.set("Response.ResponseKey", ".example", yamlConfiguration); + Config.set("Response.ResponseKeys", Collections.singletonList(".example"), yamlConfiguration); Config.set("Response.Contains", false, yamlConfiguration); Config.set("Response.Permission.Necessary", true, yamlConfiguration); Config.set("Response.Permission.Permission", "t2c-autoresponse.response.example", yamlConfiguration); @@ -32,7 +33,7 @@ public class CreateExampleResponse { Config.set("Response.Command.Enable", false, yamlConfiguration); Config.set("Response.Command.CommandAsConsole", false, yamlConfiguration); Config.set("Response.Command.BungeeCommand", false, yamlConfiguration); - Config.set("Response.Command.Commands", Arrays.asList("say hi"), yamlConfiguration); + Config.set("Response.Command.Commands", Collections.singletonList("say hi"), yamlConfiguration); Config.set("Response.Message.Enable", true, yamlConfiguration); Config.set("Response.Message.Messages", Arrays.asList("&2This is an Automated response from §8[§4T2Code§7-§bAutoResponse§8]&2.", "&6Contact us for questions / support on our Discord."), yamlConfiguration); @@ -46,6 +47,6 @@ public class CreateExampleResponse { } catch (IOException e) { e.printStackTrace(); } - send.console(Util.getPrefix() + " §2config.yml were successfully created / updated." + " §7- §e" + (System.currentTimeMillis() - long_.longValue()) + "ms"); + send.console(Util.getPrefix() + " §2config.yml were successfully created / updated." + " §7- §e" + (System.currentTimeMillis() - long_) + "ms"); } } diff --git a/src/main/java/net/t2code/autoresponse/Spigot/config/response/SelectResponses.java b/src/main/java/net/t2code/autoresponse/Spigot/config/response/SelectResponses.java index 1d74d45..65e307c 100644 --- a/src/main/java/net/t2code/autoresponse/Spigot/config/response/SelectResponses.java +++ b/src/main/java/net/t2code/autoresponse/Spigot/config/response/SelectResponses.java @@ -20,7 +20,7 @@ public class SelectResponses { YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(config_gui); ResponsesObject response = new ResponsesObject( yamlConfiguration.getBoolean("Response.Enable"), - yamlConfiguration.getString("Response.ResponseKey"), + yamlConfiguration.getStringList("Response.ResponseKeys"), yamlConfiguration.getBoolean("Response.Contains"), yamlConfiguration.getBoolean("Response.Permission.Necessary"), yamlConfiguration.getString("Response.Permission.Permission"), diff --git a/src/main/java/net/t2code/autoresponse/Spigot/event/ResponseListener.java b/src/main/java/net/t2code/autoresponse/Spigot/event/ResponseListener.java index 9079920..e760ebf 100644 --- a/src/main/java/net/t2code/autoresponse/Spigot/event/ResponseListener.java +++ b/src/main/java/net/t2code/autoresponse/Spigot/event/ResponseListener.java @@ -12,7 +12,6 @@ import net.t2code.lib.Spigot.Lib.messages.TextBuilder; import net.t2code.lib.Spigot.Lib.messages.send; import net.t2code.lib.Spigot.Lib.plugins.PluginCheck; import net.t2code.lib.Spigot.Lib.replace.Replace; -import org.bukkit.Bukkit; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; @@ -32,21 +31,27 @@ public class ResponseListener implements Listener { for (ResponsesObject response : Main.allResponses) { if (!response.permNecessary || player.hasPermission(response.permission)) { if (response.contains) { - if (e.getMessage().contains(response.responseKey)) { - execute(e, player, response); - return; + for (String responseKey : response.responseKeys){ + if (e.getMessage().contains(responseKey)) { + execute(e, player, response, responseKey); + return; + } } + } else { - if (e.getMessage().equals(response.responseKey)) { - execute(e, player, response); - return; + for (String responseKey : response.responseKeys){ + if (e.getMessage().equals(responseKey)) { + execute(e, player, response, responseKey); + return; + } } + } } } } - private static void execute(AsyncPlayerChatEvent e, Player player, ResponsesObject response) { + private static void execute(AsyncPlayerChatEvent e, Player player, ResponsesObject response, String responseKey) { if (response.commandEnable) { for (String cmd : response.command) { if (response.bungeeCommand) { @@ -69,7 +74,7 @@ public class ResponseListener implements Listener { Cmd.player(player, cmd.replace("[player]", player.getName())); } } - use(e, player, response); + use(e, player, responseKey); } } if (response.messageEnable) { @@ -93,13 +98,13 @@ public class ResponseListener implements Listener { } else { send.player(player, text); } - use(e, player, response); + use(e, player, responseKey); } } } - private static void use(AsyncPlayerChatEvent e, Player player, ResponsesObject response) { + private static void use(AsyncPlayerChatEvent e, Player player, String responseKey) { e.setCancelled(true); - if (SelectConfig.logConsole) send.console(Util.getPrefix() + " §6Player: §e" + player.getName() + " §6use AutoResponse: §e" + response.responseKey); + if (SelectConfig.logConsole) send.console(Util.getPrefix() + " §6Player: §e" + player.getName() + " §6use AutoResponse: §e" +responseKey); } } diff --git a/src/main/java/net/t2code/autoresponse/Spigot/objects/ResponsesObject.java b/src/main/java/net/t2code/autoresponse/Spigot/objects/ResponsesObject.java index 7b46c72..a6fb7f3 100644 --- a/src/main/java/net/t2code/autoresponse/Spigot/objects/ResponsesObject.java +++ b/src/main/java/net/t2code/autoresponse/Spigot/objects/ResponsesObject.java @@ -4,7 +4,7 @@ import java.util.List; public class ResponsesObject { public Boolean enable; - public String responseKey; + public List responseKeys; public Boolean contains; public Boolean commandEnable; public Boolean permNecessary; @@ -22,7 +22,7 @@ public class ResponsesObject { public String actionValue; public ResponsesObject(Boolean enable, - String responseKey, + List responseKeys, Boolean contains, Boolean permNecessary, String permission, @@ -38,7 +38,7 @@ public class ResponsesObject { String action, String actionValue) { this.enable = enable; - this.responseKey = responseKey; + this.responseKeys = responseKeys; this.contains=contains; this.permNecessary = permNecessary; this.permission = permission; diff --git a/src/main/java/net/t2code/autoresponse/Spigot/system/Permissions.java b/src/main/java/net/t2code/autoresponse/Spigot/system/Permissions.java index 972bb8e..35a64ea 100644 --- a/src/main/java/net/t2code/autoresponse/Spigot/system/Permissions.java +++ b/src/main/java/net/t2code/autoresponse/Spigot/system/Permissions.java @@ -7,7 +7,7 @@ import org.bukkit.permissions.PermissionDefault; public class Permissions { - public static final String key = "t2c-autoresponse."; + public static final String key = "t2code.autoresponse."; public static final String info = key + "command.info"; public static final String updatemsg = key + "updatemsg"; public static final String admin = key + "admin";