diff --git a/pom.xml b/pom.xml index 2897c06..1191f07 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ net.t2code AutoResponse - 1.1 + 1.2 jar T2C-AutoResponse diff --git a/src/main/java/net/t2code/autoresponse/Spigot/config/config/CreateConfig.java b/src/main/java/net/t2code/autoresponse/Spigot/config/config/CreateConfig.java index c71dc17..9d4ca13 100644 --- a/src/main/java/net/t2code/autoresponse/Spigot/config/config/CreateConfig.java +++ b/src/main/java/net/t2code/autoresponse/Spigot/config/config/CreateConfig.java @@ -19,8 +19,7 @@ public class CreateConfig { T2Cconfig.set("Plugin.updateCheck.onJoin", true, yamlConfiguration); T2Cconfig.set("Plugin.updateCheck.seePreReleaseUpdates", true, yamlConfiguration); T2Cconfig.set("Plugin.updateCheck.timeInterval", 60, yamlConfiguration); - - T2Cconfig.set("BungeeCord.Enable", false, yamlConfiguration); + T2Cconfig.set("Plugin.responseKeys.keywordSeperation", "##", yamlConfiguration); T2Cconfig.set("Log.Console.Enable", true, yamlConfiguration); diff --git a/src/main/java/net/t2code/autoresponse/Spigot/config/config/SelectConfig.java b/src/main/java/net/t2code/autoresponse/Spigot/config/config/SelectConfig.java index e55f616..788ad30 100644 --- a/src/main/java/net/t2code/autoresponse/Spigot/config/config/SelectConfig.java +++ b/src/main/java/net/t2code/autoresponse/Spigot/config/config/SelectConfig.java @@ -10,7 +10,7 @@ public class SelectConfig { public static Boolean updateCheckOnJoin; public static Boolean updateCheckSeePreReleaseUpdates; public static Integer updateCheckTimeInterval; - public static Boolean bungee; + public static String keywordSeperation; public static Boolean logConsole; public static void onSelect() { @@ -21,11 +21,8 @@ public class SelectConfig { updateCheckOnJoin = yamlConfiguration.getBoolean("Plugin.updateCheck.onJoin"); updateCheckSeePreReleaseUpdates = yamlConfiguration.getBoolean("Plugin.updateCheck.seePreReleaseUpdates"); updateCheckTimeInterval = yamlConfiguration.getInt("Plugin.updateCheck.timeInterval"); + keywordSeperation = yamlConfiguration.getString("Plugin.responseKeys.keywordSeperation"); - - - - bungee = yamlConfiguration.getBoolean("BungeeCord.Enable"); logConsole = yamlConfiguration.getBoolean("Log.Console.Enable"); } } 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 38c099e..235a307 100644 --- a/src/main/java/net/t2code/autoresponse/Spigot/event/ResponseListener.java +++ b/src/main/java/net/t2code/autoresponse/Spigot/event/ResponseListener.java @@ -10,6 +10,7 @@ import net.t2code.t2codelib.SPIGOT.api.commands.T2Ccmd; import net.t2code.t2codelib.SPIGOT.api.messages.T2Creplace; import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend; import net.t2code.t2codelib.SPIGOT.api.plugins.T2CpluginCheck; +import net.t2code.t2codelib.SPIGOT.api.yaml.T2CLibConfig; import org.bukkit.Bukkit; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -22,18 +23,30 @@ public class ResponseListener implements Listener { @EventHandler public static void ChatListener(AsyncPlayerChatEvent e) { Player player = e.getPlayer(); - boolean bool = false; - for ( - String s : Main.allResponse) { + /* boolean bool = false; + for (String s : Main.allResponse) { if (e.getMessage().contains(s)) bool = true; } if (!bool) return; - for ( - ResponsesObject response : Main.allResponses) { + + */ + for (ResponsesObject response : Main.allResponses) { if (!response.permNecessary || player.hasPermission(response.permission)) { if (response.contains) { for (String responseKey : response.responseKeys) { - if (e.getMessage().toLowerCase().contains(responseKey.toLowerCase())) { + if (responseKey.contains(SelectConfig.keywordSeperation)) { + String[] key = responseKey.split(SelectConfig.keywordSeperation); + boolean allContains = false; + for (String s : key) { + if (e.getMessage().toLowerCase().contains(s.toLowerCase())) { + allContains = true; + } else return; + } + if (allContains) { + execute1(e, player, response, responseKey); + return; + } + } else if (e.getMessage().toLowerCase().contains(responseKey.toLowerCase())) { execute1(e, player, response, responseKey); return; } @@ -69,12 +82,10 @@ public class ResponseListener implements Listener { } use(e, player, responseKey, response); Bukkit.getScheduler().runTaskLaterAsynchronously(Main.getPlugin(), () -> { - if (response.async){ + if (response.async) { executeAsync(player, response); } else executeSync(player, response); }, 2L); - - } private static void executeSync(Player player, ResponsesObject response) { @@ -89,7 +100,7 @@ public class ResponseListener implements Listener { if (response.commandEnable) { for (String cmd : response.command) { if (response.bungeeCommand) { - if (SelectConfig.bungee) { + if (T2CLibConfig.getBungee()) { if (response.commandAsConsole) { BCommand_Sender_Reciver.sendToBungee(player, cmd.replace("[player]", player.getName()), BungeeSend.BUNGEECOMMAND); } else BCommand_Sender_Reciver.sendToBungee(player, cmd.replace("[player]", player.getName()), BungeeSend.COMMAND); @@ -131,10 +142,8 @@ public class ResponseListener implements Listener { } else T2Csend.player(player, text); } } - } - private static void use(AsyncPlayerChatEvent e, Player player, String responseKey, ResponsesObject response) { if (response.blockKeyMessage) e.setCancelled(true); if (SelectConfig.logConsole) T2Csend.console(Util.getPrefix() + " §6Player: §e" + player.getName() + " §6use AutoResponse: §e" + responseKey); diff --git a/src/main/java/net/t2code/autoresponse/Spigot/system/Load.java b/src/main/java/net/t2code/autoresponse/Spigot/system/Load.java index 0480258..9329a1e 100644 --- a/src/main/java/net/t2code/autoresponse/Spigot/system/Load.java +++ b/src/main/java/net/t2code/autoresponse/Spigot/system/Load.java @@ -12,6 +12,7 @@ import net.t2code.autoresponse.Spigot.config.response.SelectResponses; import net.t2code.autoresponse.Spigot.event.ResponseListener; import net.t2code.t2codelib.SPIGOT.api.messages.T2Ctemplate; import net.t2code.t2codelib.SPIGOT.api.update.T2CupdateAPI; +import net.t2code.t2codelib.SPIGOT.api.yaml.T2CLibConfig; import org.bukkit.Bukkit; import java.util.List; @@ -30,7 +31,7 @@ public class Load { T2Ctemplate.onLoadFooter(prefix, long_,version); Metrics.Bstats(plugin, bstatsID); - if (SelectConfig.bungee) { + if (T2CLibConfig.getBungee()) { plugin.getServer().getMessenger().registerOutgoingPluginChannel(plugin, "BungeeCord"); Bukkit.getMessenger().registerOutgoingPluginChannel(plugin, "t2car:bungee"); } diff --git a/src/main/java/net/t2code/autoresponse/Util.java b/src/main/java/net/t2code/autoresponse/Util.java index 145f06e..b0f345f 100644 --- a/src/main/java/net/t2code/autoresponse/Util.java +++ b/src/main/java/net/t2code/autoresponse/Util.java @@ -5,7 +5,7 @@ public class Util { public static String getInfoText() { return ""; } - private static String requiredT2CodeLibVersion = "13.4"; + private static String requiredT2CodeLibVersion = "14.4"; private static String Prefix = "§8[§4T2Code§7-§bAutoResponse§8]"; private static Integer SpigotID = 100603; public static String getGit() {