diff --git a/pom.xml b/pom.xml
index 0ad79b8..2897c06 100644
--- a/pom.xml
+++ b/pom.xml
@@ -6,7 +6,7 @@
net.t2code
AutoResponse
- 0.2.2
+ 1.1
jar
T2C-AutoResponse
@@ -18,6 +18,7 @@
git.t2code.net
+ ${project.name}_${project.version}
org.apache.maven.plugins
@@ -70,16 +71,19 @@
net.t2code.minecraft.1_8.r1
spigot
1.8r1
+ provided
net.t2code
T2CodeLib
- 13.4
+ 14.4
+ provided
net.t2code
bungee
1615
+ provided
diff --git a/src/main/java/net/t2code/autoresponse/Spigot/cmdManagement/CmdExecuter.java b/src/main/java/net/t2code/autoresponse/Spigot/cmdManagement/CmdExecuter.java
index 5291fe8..68a2a27 100644
--- a/src/main/java/net/t2code/autoresponse/Spigot/cmdManagement/CmdExecuter.java
+++ b/src/main/java/net/t2code/autoresponse/Spigot/cmdManagement/CmdExecuter.java
@@ -17,10 +17,8 @@ public class CmdExecuter implements CommandExecutor, TabCompleter {
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
- if (args.length == 0) {
+ if (args.length != 0) {
// Command
-
- } else {
switch (args[0].toLowerCase()) {
case "reload":
case "rl":
@@ -44,7 +42,7 @@ public class CmdExecuter implements CommandExecutor, TabCompleter {
}
//TabCompleter
- private static HashMap arg1 = new HashMap() {{
+ private static final HashMap arg1 = new HashMap() {{
put("reload", Permissions.admin);
put("rl", Permissions.admin);
put("info", Permissions.info);
@@ -57,7 +55,7 @@ public class CmdExecuter implements CommandExecutor, TabCompleter {
Player p = (Player) sender;
if (args.length == 1) {
for (String command : arg1.keySet()) {
- Boolean passend = true;
+ boolean passend = true;
for (int i = 0; i < args[0].length(); i++) {
if (args[0].length() >= command.length()) {
passend = false;
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 2b532cd..0e31bc2 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
@@ -30,6 +30,9 @@ public class CreateExampleResponse {
T2Cconfig.set("Response.Permission.Necessary", true, yamlConfiguration);
T2Cconfig.set("Response.Permission.Permission", "t2c-autoresponse.response.example", yamlConfiguration);
+ T2Cconfig.set("Response.Response.DelayInTicks", 0, yamlConfiguration);
+ T2Cconfig.set("Response.Response.Async", true, yamlConfiguration);
+
T2Cconfig.set("Response.Command.Enable", false, yamlConfiguration);
T2Cconfig.set("Response.Command.CommandAsConsole", false, yamlConfiguration);
T2Cconfig.set("Response.Command.BungeeCommand", false, yamlConfiguration);
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 9ad77d0..ad25c30 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
@@ -22,10 +22,14 @@ public class SelectResponses {
yamlConfiguration.getBoolean("Response.Enable"),
yamlConfiguration.getStringList("Response.ResponseKeys"),
yamlConfiguration.getBoolean("Response.Contains"),
+
yamlConfiguration.getBoolean("Response.BlockKeyMessage"),
yamlConfiguration.getBoolean("Response.Permission.Necessary"),
yamlConfiguration.getString("Response.Permission.Permission"),
+ yamlConfiguration.getInt("Response.Response.DelayInTicks"),
+ yamlConfiguration.getBoolean("Response.Response.Async"),
+
yamlConfiguration.getBoolean("Response.Command.Enable"),
yamlConfiguration.getBoolean("Response.Command.CommandAsConsole"),
yamlConfiguration.getBoolean("Response.Command.BungeeCommand"),
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 147399b..38c099e 100644
--- a/src/main/java/net/t2code/autoresponse/Spigot/event/ResponseListener.java
+++ b/src/main/java/net/t2code/autoresponse/Spigot/event/ResponseListener.java
@@ -23,23 +23,25 @@ public class ResponseListener implements Listener {
public static void ChatListener(AsyncPlayerChatEvent e) {
Player player = e.getPlayer();
boolean bool = false;
- for (String s : Main.allResponse) {
+ 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())) {
- execute(e, player, response, responseKey);
+ execute1(e, player, response, responseKey);
return;
}
}
} else {
for (String responseKey : response.responseKeys) {
- if (e.getMessage().toLowerCase().equals(responseKey.toLowerCase())) {
- execute(e, player, response, responseKey);
+ if (e.getMessage().equalsIgnoreCase(responseKey)) {
+ execute1(e, player, response, responseKey);
return;
}
}
@@ -48,8 +50,7 @@ public class ResponseListener implements Listener {
}
}
- private static void execute(AsyncPlayerChatEvent e, Player player, ResponsesObject response, String responseKey) {
-
+ private static void execute1(AsyncPlayerChatEvent e, Player player, ResponsesObject response, String responseKey) {
if (response.protectionGameModeEnable) {
if (response.protectionGameModeMode.equalsIgnoreCase("blacklist") && response.protectionGameModeList.contains(player.getGameMode().toString())) {
return;
@@ -67,7 +68,24 @@ public class ResponseListener implements Listener {
}
}
use(e, player, responseKey, response);
+ Bukkit.getScheduler().runTaskLaterAsynchronously(Main.getPlugin(), () -> {
+ if (response.async){
+ executeAsync(player, response);
+ } else executeSync(player, response);
+ }, 2L);
+
+ }
+
+ private static void executeSync(Player player, ResponsesObject response) {
+ Bukkit.getScheduler().runTaskLater(Main.getPlugin(), () -> executeFinal(player, response), (long) response.delayInTicks);
+ }
+
+ private static void executeAsync(Player player, ResponsesObject response) {
+ Bukkit.getScheduler().runTaskLaterAsynchronously(Main.getPlugin(), () -> executeFinal(player, response), (long) response.delayInTicks);
+ }
+
+ private static void executeFinal(Player player, ResponsesObject response) {
if (response.commandEnable) {
for (String cmd : response.command) {
if (response.bungeeCommand) {
@@ -113,8 +131,10 @@ 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/objects/ResponsesObject.java b/src/main/java/net/t2code/autoresponse/Spigot/objects/ResponsesObject.java
index 9821400..71141cd 100644
--- a/src/main/java/net/t2code/autoresponse/Spigot/objects/ResponsesObject.java
+++ b/src/main/java/net/t2code/autoresponse/Spigot/objects/ResponsesObject.java
@@ -11,6 +11,9 @@ public class ResponsesObject {
public Boolean permNecessary;
public String permission;
+ public Integer delayInTicks;
+ public Boolean async;
+
public Boolean commandAsConsole;
public Boolean bungeeCommand;
public List command;
@@ -33,6 +36,8 @@ public class ResponsesObject {
Boolean blockKeyMessage,
Boolean permNecessary,
String permission,
+ Integer delayInTicks,
+ Boolean delayAsync,
Boolean commandEnable,
Boolean commandAsConsole,
Boolean bungeeCommand,
@@ -49,8 +54,8 @@ public class ResponsesObject {
List protectionWorldList) {
this.enable = enable;
this.responseKeys = responseKeys;
- this.contains=contains;
- this.blockKeyMessage=blockKeyMessage;
+ this.contains = contains;
+ this.blockKeyMessage = blockKeyMessage;
this.permNecessary = permNecessary;
this.permission = permission;
this.commandEnable = commandEnable;
@@ -62,6 +67,9 @@ public class ResponsesObject {
this.messageGlobalBungee = messageGlobalBungee;
this.messages = messages;
+ this.delayInTicks = delayInTicks;
+ this.async = delayAsync;
+
this.protectionGameModeEnable = protectionGameModeEnable;
this.protectionGameModeMode = protectionGameModeMode;
this.protectionGameModeList = protectionGameModeList;