From b4d1fcf4573ca7ca70716328fbcd7f92110306f2 Mon Sep 17 00:00:00 2001 From: JaTiTV Date: Thu, 10 Mar 2022 22:54:01 +0100 Subject: [PATCH] 0.1.0 | Add Update Checker --- pom.xml | 2 +- .../response/CreateExampleResponse.java | 11 +++++++-- .../config/response/SelectResponses.java | 11 +++++++-- .../Spigot/event/ResponseListener.java | 23 ++++++++++++++---- .../Spigot/objects/ResponsesObject.java | 24 ++++++++++++++++++- .../java/net/t2code/autoresponse/Util.java | 2 +- 6 files changed, 62 insertions(+), 11 deletions(-) diff --git a/pom.xml b/pom.xml index bcd21bc..36e6fe6 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ net.t2code AutoResponse - 0.0.1 + 0.1.0 jar T2C-AutoResponse 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 fadd818..992ee67 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 @@ -23,7 +23,6 @@ public class CreateExampleResponse { File config = new File(Main.getPath(), "Responses/responseexample.yml"); YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(config); - Config.set("Response.Enable", true, yamlConfiguration); Config.set("Response.ResponseKeys", Collections.singletonList(".example"), yamlConfiguration); Config.set("Response.Contains", false, yamlConfiguration); @@ -41,7 +40,15 @@ public class CreateExampleResponse { Config.set("Response.Message.TextBuilder.Hover", "&5Discord: &edc.t2code.net", yamlConfiguration); Config.set("Response.Message.TextBuilder.ClickEvent.Enable", true, yamlConfiguration); Config.set("Response.Message.TextBuilder.ClickEvent.Action", "OPEN_URL", yamlConfiguration); - Config.set("Response.Message.TextBuilder.ClickEvent.ActionValue", "dc.t2code.net", yamlConfiguration); + Config.set("Response.Message.TextBuilder.ClickEvent.ActionValue", "http://dc.t2code.net", yamlConfiguration); + + Config.set("Response.Protection.GameMode.Enable", false, yamlConfiguration); + Config.set("Response.Protection.GameMode.Mode", "blacklist", yamlConfiguration); + Config.set("Response.Protection.GameMode.List", Arrays.asList("CREATIVE","SPECTATOR"), yamlConfiguration); + Config.set("Response.Protection.World.Enable", false, yamlConfiguration); + Config.set("Response.Protection.World.Mode", "blacklist", yamlConfiguration); + Config.set("Response.Protection.World.List", Arrays.asList("World1","World2"), yamlConfiguration); + try { yamlConfiguration.save(config); } catch (IOException e) { 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 65e307c..f2f08c4 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 @@ -36,9 +36,16 @@ public class SelectResponses { yamlConfiguration.getString("Response.Message.TextBuilder.Hover"), yamlConfiguration.getBoolean("Response.Message.TextBuilder.ClickEvent.Enable"), yamlConfiguration.getString("Response.Message.TextBuilder.ClickEvent.Action"), - yamlConfiguration.getString("Response.Message.TextBuilder.ClickEvent.ActionValue")); + yamlConfiguration.getString("Response.Message.TextBuilder.ClickEvent.ActionValue"), + + yamlConfiguration.getBoolean("Response.Protection.GameMode.Enable"), + yamlConfiguration.getString("Response.Protection.GameMode.Mode"), + yamlConfiguration.getStringList("Response.Protection.GameMode.List"), + yamlConfiguration.getBoolean("Response.Protection.World.Enable"), + yamlConfiguration.getString("Response.Protection.World.Mode"), + yamlConfiguration.getStringList("Response.Protection.World.List")); Main.allResponses.add(response); - Main.allResponse.add(yamlConfiguration.getString("Response.ResponseKey")); + Main.allResponse.addAll(yamlConfiguration.getStringList("Response.ResponseKeys")); } } } 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 e760ebf..e949d62 100644 --- a/src/main/java/net/t2code/autoresponse/Spigot/event/ResponseListener.java +++ b/src/main/java/net/t2code/autoresponse/Spigot/event/ResponseListener.java @@ -37,7 +37,6 @@ public class ResponseListener implements Listener { return; } } - } else { for (String responseKey : response.responseKeys){ if (e.getMessage().equals(responseKey)) { @@ -45,13 +44,31 @@ public class ResponseListener implements Listener { return; } } - } } } } private static void execute(AsyncPlayerChatEvent e, Player player, ResponsesObject response, String responseKey) { + + if (response.protectionGameModeEnable) { + if (response.protectionGameModeMode.equalsIgnoreCase("blacklist") && response.protectionGameModeList.contains(player.getGameMode().toString())) { + return; + } + if (response.protectionGameModeMode.equalsIgnoreCase("whitelist") && !response.protectionGameModeList.contains(player.getGameMode().toString())) { + return; + } + } + if (response.protectionWorldEnable) { + if (response.protectionWorldMode.equalsIgnoreCase("blacklist") && response.protectionWorldList.contains(player.getWorld().getName())) { + return; + } + if (response.protectionWorldMode.equalsIgnoreCase("whitelist") && !response.protectionWorldList.contains(player.getWorld().getName())) { + return; + } + } + use(e, player, responseKey); + if (response.commandEnable) { for (String cmd : response.command) { if (response.bungeeCommand) { @@ -74,7 +91,6 @@ public class ResponseListener implements Listener { Cmd.player(player, cmd.replace("[player]", player.getName())); } } - use(e, player, responseKey); } } if (response.messageEnable) { @@ -98,7 +114,6 @@ public class ResponseListener implements Listener { } else { send.player(player, text); } - use(e, player, 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 a6fb7f3..f839146 100644 --- a/src/main/java/net/t2code/autoresponse/Spigot/objects/ResponsesObject.java +++ b/src/main/java/net/t2code/autoresponse/Spigot/objects/ResponsesObject.java @@ -21,6 +21,14 @@ public class ResponsesObject { public String action; public String actionValue; + public Boolean protectionGameModeEnable; + public String protectionGameModeMode; + public List protectionGameModeList; + + public Boolean protectionWorldEnable; + public String protectionWorldMode; + public List protectionWorldList; + public ResponsesObject(Boolean enable, List responseKeys, Boolean contains, @@ -36,7 +44,13 @@ public class ResponsesObject { String hover, Boolean clickEvent, String action, - String actionValue) { + String actionValue, + Boolean protectionGameModeEnable, + String protectionGameModeMode, + List protectionGameModeList, + Boolean protectionWorldEnable, + String protectionWorldMode, + List protectionWorldList) { this.enable = enable; this.responseKeys = responseKeys; this.contains=contains; @@ -53,5 +67,13 @@ public class ResponsesObject { this.clickEvent = clickEvent; this.action = action; this.actionValue = actionValue; + + this.protectionGameModeEnable = protectionGameModeEnable; + this.protectionGameModeMode = protectionGameModeMode; + this.protectionGameModeList = protectionGameModeList; + + this.protectionWorldEnable = protectionWorldEnable; + this.protectionWorldMode = protectionWorldMode; + this.protectionWorldList = protectionWorldList; } } diff --git a/src/main/java/net/t2code/autoresponse/Util.java b/src/main/java/net/t2code/autoresponse/Util.java index cee6e7d..c08102c 100644 --- a/src/main/java/net/t2code/autoresponse/Util.java +++ b/src/main/java/net/t2code/autoresponse/Util.java @@ -3,7 +3,7 @@ package net.t2code.autoresponse; public class Util { private static double requiredT2CodeLibVersion = 11.0; private static String Prefix = "§8[§4T2Code§7-§bAutoResponse§8]"; - private static Integer SpigotID = 00000; + private static Integer SpigotID = 100603; private static Integer BstatsID = 14091; private static String Spigot = "https://www.spigotmc.org/resources/" + SpigotID; private static String Discord = "http://dc.t2code.net";