Compare commits
2 Commits
Author | SHA1 | Date | |
---|---|---|---|
e0f9eb6f58 | |||
edddd93850 |
8
pom.xml
8
pom.xml
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
<groupId>net.t2code</groupId>
|
<groupId>net.t2code</groupId>
|
||||||
<artifactId>AutoResponse</artifactId>
|
<artifactId>AutoResponse</artifactId>
|
||||||
<version>0.2.2</version>
|
<version>1.2</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<name>T2C-AutoResponse</name>
|
<name>T2C-AutoResponse</name>
|
||||||
@@ -18,6 +18,7 @@
|
|||||||
<url>git.t2code.net</url>
|
<url>git.t2code.net</url>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
|
<finalName>${project.name}_${project.version}</finalName>
|
||||||
<plugins>
|
<plugins>
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
@@ -70,16 +71,19 @@
|
|||||||
<groupId>net.t2code.minecraft.1_8.r1</groupId>
|
<groupId>net.t2code.minecraft.1_8.r1</groupId>
|
||||||
<artifactId>spigot</artifactId>
|
<artifactId>spigot</artifactId>
|
||||||
<version>1.8r1</version>
|
<version>1.8r1</version>
|
||||||
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>net.t2code</groupId>
|
<groupId>net.t2code</groupId>
|
||||||
<artifactId>T2CodeLib</artifactId>
|
<artifactId>T2CodeLib</artifactId>
|
||||||
<version>13.4</version>
|
<version>14.4</version>
|
||||||
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>net.t2code</groupId>
|
<groupId>net.t2code</groupId>
|
||||||
<artifactId>bungee</artifactId>
|
<artifactId>bungee</artifactId>
|
||||||
<version>1615</version>
|
<version>1615</version>
|
||||||
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</project>
|
</project>
|
||||||
|
@@ -17,10 +17,8 @@ public class CmdExecuter implements CommandExecutor, TabCompleter {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||||
if (args.length == 0) {
|
if (args.length != 0) {
|
||||||
// Command
|
// Command
|
||||||
|
|
||||||
} else {
|
|
||||||
switch (args[0].toLowerCase()) {
|
switch (args[0].toLowerCase()) {
|
||||||
case "reload":
|
case "reload":
|
||||||
case "rl":
|
case "rl":
|
||||||
@@ -44,7 +42,7 @@ public class CmdExecuter implements CommandExecutor, TabCompleter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//TabCompleter
|
//TabCompleter
|
||||||
private static HashMap<String, String> arg1 = new HashMap<String, String>() {{
|
private static final HashMap<String, String> arg1 = new HashMap<String, String>() {{
|
||||||
put("reload", Permissions.admin);
|
put("reload", Permissions.admin);
|
||||||
put("rl", Permissions.admin);
|
put("rl", Permissions.admin);
|
||||||
put("info", Permissions.info);
|
put("info", Permissions.info);
|
||||||
@@ -57,7 +55,7 @@ public class CmdExecuter implements CommandExecutor, TabCompleter {
|
|||||||
Player p = (Player) sender;
|
Player p = (Player) sender;
|
||||||
if (args.length == 1) {
|
if (args.length == 1) {
|
||||||
for (String command : arg1.keySet()) {
|
for (String command : arg1.keySet()) {
|
||||||
Boolean passend = true;
|
boolean passend = true;
|
||||||
for (int i = 0; i < args[0].length(); i++) {
|
for (int i = 0; i < args[0].length(); i++) {
|
||||||
if (args[0].length() >= command.length()) {
|
if (args[0].length() >= command.length()) {
|
||||||
passend = false;
|
passend = false;
|
||||||
|
@@ -19,8 +19,7 @@ public class CreateConfig {
|
|||||||
T2Cconfig.set("Plugin.updateCheck.onJoin", true, yamlConfiguration);
|
T2Cconfig.set("Plugin.updateCheck.onJoin", true, yamlConfiguration);
|
||||||
T2Cconfig.set("Plugin.updateCheck.seePreReleaseUpdates", true, yamlConfiguration);
|
T2Cconfig.set("Plugin.updateCheck.seePreReleaseUpdates", true, yamlConfiguration);
|
||||||
T2Cconfig.set("Plugin.updateCheck.timeInterval", 60, yamlConfiguration);
|
T2Cconfig.set("Plugin.updateCheck.timeInterval", 60, yamlConfiguration);
|
||||||
|
T2Cconfig.set("Plugin.responseKeys.keywordSeperation", "##", yamlConfiguration);
|
||||||
T2Cconfig.set("BungeeCord.Enable", false, yamlConfiguration);
|
|
||||||
|
|
||||||
T2Cconfig.set("Log.Console.Enable", true, yamlConfiguration);
|
T2Cconfig.set("Log.Console.Enable", true, yamlConfiguration);
|
||||||
|
|
||||||
|
@@ -10,7 +10,7 @@ public class SelectConfig {
|
|||||||
public static Boolean updateCheckOnJoin;
|
public static Boolean updateCheckOnJoin;
|
||||||
public static Boolean updateCheckSeePreReleaseUpdates;
|
public static Boolean updateCheckSeePreReleaseUpdates;
|
||||||
public static Integer updateCheckTimeInterval;
|
public static Integer updateCheckTimeInterval;
|
||||||
public static Boolean bungee;
|
public static String keywordSeperation;
|
||||||
public static Boolean logConsole;
|
public static Boolean logConsole;
|
||||||
|
|
||||||
public static void onSelect() {
|
public static void onSelect() {
|
||||||
@@ -21,11 +21,8 @@ public class SelectConfig {
|
|||||||
updateCheckOnJoin = yamlConfiguration.getBoolean("Plugin.updateCheck.onJoin");
|
updateCheckOnJoin = yamlConfiguration.getBoolean("Plugin.updateCheck.onJoin");
|
||||||
updateCheckSeePreReleaseUpdates = yamlConfiguration.getBoolean("Plugin.updateCheck.seePreReleaseUpdates");
|
updateCheckSeePreReleaseUpdates = yamlConfiguration.getBoolean("Plugin.updateCheck.seePreReleaseUpdates");
|
||||||
updateCheckTimeInterval = yamlConfiguration.getInt("Plugin.updateCheck.timeInterval");
|
updateCheckTimeInterval = yamlConfiguration.getInt("Plugin.updateCheck.timeInterval");
|
||||||
|
keywordSeperation = yamlConfiguration.getString("Plugin.responseKeys.keywordSeperation");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
bungee = yamlConfiguration.getBoolean("BungeeCord.Enable");
|
|
||||||
logConsole = yamlConfiguration.getBoolean("Log.Console.Enable");
|
logConsole = yamlConfiguration.getBoolean("Log.Console.Enable");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -30,6 +30,9 @@ public class CreateExampleResponse {
|
|||||||
T2Cconfig.set("Response.Permission.Necessary", true, yamlConfiguration);
|
T2Cconfig.set("Response.Permission.Necessary", true, yamlConfiguration);
|
||||||
T2Cconfig.set("Response.Permission.Permission", "t2c-autoresponse.response.example", 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.Enable", false, yamlConfiguration);
|
||||||
T2Cconfig.set("Response.Command.CommandAsConsole", false, yamlConfiguration);
|
T2Cconfig.set("Response.Command.CommandAsConsole", false, yamlConfiguration);
|
||||||
T2Cconfig.set("Response.Command.BungeeCommand", false, yamlConfiguration);
|
T2Cconfig.set("Response.Command.BungeeCommand", false, yamlConfiguration);
|
||||||
|
@@ -22,10 +22,14 @@ public class SelectResponses {
|
|||||||
yamlConfiguration.getBoolean("Response.Enable"),
|
yamlConfiguration.getBoolean("Response.Enable"),
|
||||||
yamlConfiguration.getStringList("Response.ResponseKeys"),
|
yamlConfiguration.getStringList("Response.ResponseKeys"),
|
||||||
yamlConfiguration.getBoolean("Response.Contains"),
|
yamlConfiguration.getBoolean("Response.Contains"),
|
||||||
|
|
||||||
yamlConfiguration.getBoolean("Response.BlockKeyMessage"),
|
yamlConfiguration.getBoolean("Response.BlockKeyMessage"),
|
||||||
yamlConfiguration.getBoolean("Response.Permission.Necessary"),
|
yamlConfiguration.getBoolean("Response.Permission.Necessary"),
|
||||||
yamlConfiguration.getString("Response.Permission.Permission"),
|
yamlConfiguration.getString("Response.Permission.Permission"),
|
||||||
|
|
||||||
|
yamlConfiguration.getInt("Response.Response.DelayInTicks"),
|
||||||
|
yamlConfiguration.getBoolean("Response.Response.Async"),
|
||||||
|
|
||||||
yamlConfiguration.getBoolean("Response.Command.Enable"),
|
yamlConfiguration.getBoolean("Response.Command.Enable"),
|
||||||
yamlConfiguration.getBoolean("Response.Command.CommandAsConsole"),
|
yamlConfiguration.getBoolean("Response.Command.CommandAsConsole"),
|
||||||
yamlConfiguration.getBoolean("Response.Command.BungeeCommand"),
|
yamlConfiguration.getBoolean("Response.Command.BungeeCommand"),
|
||||||
|
@@ -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.T2Creplace;
|
||||||
import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend;
|
import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend;
|
||||||
import net.t2code.t2codelib.SPIGOT.api.plugins.T2CpluginCheck;
|
import net.t2code.t2codelib.SPIGOT.api.plugins.T2CpluginCheck;
|
||||||
|
import net.t2code.t2codelib.SPIGOT.api.yaml.T2CLibConfig;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
@@ -22,24 +23,38 @@ public class ResponseListener implements Listener {
|
|||||||
@EventHandler
|
@EventHandler
|
||||||
public static void ChatListener(AsyncPlayerChatEvent e) {
|
public static void ChatListener(AsyncPlayerChatEvent e) {
|
||||||
Player player = e.getPlayer();
|
Player player = e.getPlayer();
|
||||||
boolean bool = false;
|
/* boolean bool = false;
|
||||||
for (String s : Main.allResponse) {
|
for (String s : Main.allResponse) {
|
||||||
if (e.getMessage().contains(s)) bool = true;
|
if (e.getMessage().contains(s)) bool = true;
|
||||||
}
|
}
|
||||||
if (!bool) return;
|
if (!bool) return;
|
||||||
|
|
||||||
|
*/
|
||||||
for (ResponsesObject response : Main.allResponses) {
|
for (ResponsesObject response : Main.allResponses) {
|
||||||
if (!response.permNecessary || player.hasPermission(response.permission)) {
|
if (!response.permNecessary || player.hasPermission(response.permission)) {
|
||||||
if (response.contains) {
|
if (response.contains) {
|
||||||
for (String responseKey : response.responseKeys) {
|
for (String responseKey : response.responseKeys) {
|
||||||
if (e.getMessage().toLowerCase().contains(responseKey.toLowerCase())) {
|
if (responseKey.contains(SelectConfig.keywordSeperation)) {
|
||||||
execute(e, player, response, responseKey);
|
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;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for (String responseKey : response.responseKeys) {
|
for (String responseKey : response.responseKeys) {
|
||||||
if (e.getMessage().toLowerCase().equals(responseKey.toLowerCase())) {
|
if (e.getMessage().equalsIgnoreCase(responseKey)) {
|
||||||
execute(e, player, response, responseKey);
|
execute1(e, player, response, responseKey);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -48,8 +63,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.protectionGameModeEnable) {
|
||||||
if (response.protectionGameModeMode.equalsIgnoreCase("blacklist") && response.protectionGameModeList.contains(player.getGameMode().toString())) {
|
if (response.protectionGameModeMode.equalsIgnoreCase("blacklist") && response.protectionGameModeList.contains(player.getGameMode().toString())) {
|
||||||
return;
|
return;
|
||||||
@@ -67,11 +81,26 @@ public class ResponseListener implements Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
use(e, player, responseKey, response);
|
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) {
|
if (response.commandEnable) {
|
||||||
for (String cmd : response.command) {
|
for (String cmd : response.command) {
|
||||||
if (response.bungeeCommand) {
|
if (response.bungeeCommand) {
|
||||||
if (SelectConfig.bungee) {
|
if (T2CLibConfig.getBungee()) {
|
||||||
if (response.commandAsConsole) {
|
if (response.commandAsConsole) {
|
||||||
BCommand_Sender_Reciver.sendToBungee(player, cmd.replace("[player]", player.getName()), BungeeSend.BUNGEECOMMAND);
|
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);
|
} else BCommand_Sender_Reciver.sendToBungee(player, cmd.replace("[player]", player.getName()), BungeeSend.COMMAND);
|
||||||
|
@@ -11,6 +11,9 @@ public class ResponsesObject {
|
|||||||
public Boolean permNecessary;
|
public Boolean permNecessary;
|
||||||
public String permission;
|
public String permission;
|
||||||
|
|
||||||
|
public Integer delayInTicks;
|
||||||
|
public Boolean async;
|
||||||
|
|
||||||
public Boolean commandAsConsole;
|
public Boolean commandAsConsole;
|
||||||
public Boolean bungeeCommand;
|
public Boolean bungeeCommand;
|
||||||
public List<String> command;
|
public List<String> command;
|
||||||
@@ -33,6 +36,8 @@ public class ResponsesObject {
|
|||||||
Boolean blockKeyMessage,
|
Boolean blockKeyMessage,
|
||||||
Boolean permNecessary,
|
Boolean permNecessary,
|
||||||
String permission,
|
String permission,
|
||||||
|
Integer delayInTicks,
|
||||||
|
Boolean delayAsync,
|
||||||
Boolean commandEnable,
|
Boolean commandEnable,
|
||||||
Boolean commandAsConsole,
|
Boolean commandAsConsole,
|
||||||
Boolean bungeeCommand,
|
Boolean bungeeCommand,
|
||||||
@@ -49,8 +54,8 @@ public class ResponsesObject {
|
|||||||
List<String> protectionWorldList) {
|
List<String> protectionWorldList) {
|
||||||
this.enable = enable;
|
this.enable = enable;
|
||||||
this.responseKeys = responseKeys;
|
this.responseKeys = responseKeys;
|
||||||
this.contains=contains;
|
this.contains = contains;
|
||||||
this.blockKeyMessage=blockKeyMessage;
|
this.blockKeyMessage = blockKeyMessage;
|
||||||
this.permNecessary = permNecessary;
|
this.permNecessary = permNecessary;
|
||||||
this.permission = permission;
|
this.permission = permission;
|
||||||
this.commandEnable = commandEnable;
|
this.commandEnable = commandEnable;
|
||||||
@@ -62,6 +67,9 @@ public class ResponsesObject {
|
|||||||
this.messageGlobalBungee = messageGlobalBungee;
|
this.messageGlobalBungee = messageGlobalBungee;
|
||||||
this.messages = messages;
|
this.messages = messages;
|
||||||
|
|
||||||
|
this.delayInTicks = delayInTicks;
|
||||||
|
this.async = delayAsync;
|
||||||
|
|
||||||
this.protectionGameModeEnable = protectionGameModeEnable;
|
this.protectionGameModeEnable = protectionGameModeEnable;
|
||||||
this.protectionGameModeMode = protectionGameModeMode;
|
this.protectionGameModeMode = protectionGameModeMode;
|
||||||
this.protectionGameModeList = protectionGameModeList;
|
this.protectionGameModeList = protectionGameModeList;
|
||||||
|
@@ -12,6 +12,7 @@ import net.t2code.autoresponse.Spigot.config.response.SelectResponses;
|
|||||||
import net.t2code.autoresponse.Spigot.event.ResponseListener;
|
import net.t2code.autoresponse.Spigot.event.ResponseListener;
|
||||||
import net.t2code.t2codelib.SPIGOT.api.messages.T2Ctemplate;
|
import net.t2code.t2codelib.SPIGOT.api.messages.T2Ctemplate;
|
||||||
import net.t2code.t2codelib.SPIGOT.api.update.T2CupdateAPI;
|
import net.t2code.t2codelib.SPIGOT.api.update.T2CupdateAPI;
|
||||||
|
import net.t2code.t2codelib.SPIGOT.api.yaml.T2CLibConfig;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -30,7 +31,7 @@ public class Load {
|
|||||||
|
|
||||||
T2Ctemplate.onLoadFooter(prefix, long_,version);
|
T2Ctemplate.onLoadFooter(prefix, long_,version);
|
||||||
Metrics.Bstats(plugin, bstatsID);
|
Metrics.Bstats(plugin, bstatsID);
|
||||||
if (SelectConfig.bungee) {
|
if (T2CLibConfig.getBungee()) {
|
||||||
plugin.getServer().getMessenger().registerOutgoingPluginChannel(plugin, "BungeeCord");
|
plugin.getServer().getMessenger().registerOutgoingPluginChannel(plugin, "BungeeCord");
|
||||||
Bukkit.getMessenger().registerOutgoingPluginChannel(plugin, "t2car:bungee");
|
Bukkit.getMessenger().registerOutgoingPluginChannel(plugin, "t2car:bungee");
|
||||||
}
|
}
|
||||||
|
@@ -5,7 +5,7 @@ public class Util {
|
|||||||
public static String getInfoText() {
|
public static String getInfoText() {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
private static String requiredT2CodeLibVersion = "13.4";
|
private static String requiredT2CodeLibVersion = "14.4";
|
||||||
private static String Prefix = "§8[§4T2Code§7-§bAutoResponse§8]";
|
private static String Prefix = "§8[§4T2Code§7-§bAutoResponse§8]";
|
||||||
private static Integer SpigotID = 100603;
|
private static Integer SpigotID = 100603;
|
||||||
public static String getGit() {
|
public static String getGit() {
|
||||||
|
Reference in New Issue
Block a user