0.2.0_DEV

- It is now possible to set whether the key message should be blocked or sent to other players.
- It can now be set whether the response should be sent to the player or to all players. This is also possible across bungees (no MiniMessage format support).
- MiniMessage format is supported. Not if it should be sent to all bungee players!
- TZ2Code minimum requirement 12.5
This commit is contained in:
JaTiTV 2022-07-26 00:46:29 +02:00
parent d527152ebc
commit 3051d68de4
18 changed files with 152 additions and 119 deletions

19
pom.xml
View File

@ -6,7 +6,7 @@
<groupId>net.t2code</groupId> <groupId>net.t2code</groupId>
<artifactId>AutoResponse</artifactId> <artifactId>AutoResponse</artifactId>
<version>0.1.0</version> <version>0.2.0</version>
<packaging>jar</packaging> <packaging>jar</packaging>
<name>T2C-AutoResponse</name> <name>T2C-AutoResponse</name>
@ -54,14 +54,6 @@
</build> </build>
<repositories> <repositories>
<repository>
<id>spigotmc-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
</repository>
<repository>
<id>sonatype</id>
<url>https://oss.sonatype.org/content/groups/public/</url>
</repository>
<repository> <repository>
<id>T2Code</id> <id>T2Code</id>
<url>https://repo.t2code.net/repository/T2Code/</url> <url>https://repo.t2code.net/repository/T2Code/</url>
@ -74,15 +66,14 @@
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>org.spigotmc</groupId> <groupId>net.t2code.minecraft.1_8.r1</groupId>
<artifactId>spigot-api</artifactId> <artifactId>spigot</artifactId>
<version>1.8-R0.1-SNAPSHOT</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>12.0</version> <version>12.5</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>net.t2code</groupId> <groupId>net.t2code</groupId>

View File

@ -11,9 +11,9 @@ import java.util.logging.Level;
public final class BMain extends Plugin { public final class BMain extends Plugin {
public static Plugin plugin; private static Plugin plugin;
public static String version; private static String version;
public static String autor; private static String autor;
@Override @Override
public void onEnable() { public void onEnable() {

View File

@ -5,6 +5,7 @@ import net.md_5.bungee.api.connection.ProxiedPlayer;
import net.md_5.bungee.api.event.PluginMessageEvent; import net.md_5.bungee.api.event.PluginMessageEvent;
import net.md_5.bungee.api.plugin.Listener; import net.md_5.bungee.api.plugin.Listener;
import net.md_5.bungee.event.EventHandler; import net.md_5.bungee.event.EventHandler;
import net.t2code.lib.Bungee.Lib.messages.Bsend;
import java.io.ByteArrayInputStream; import java.io.ByteArrayInputStream;
import java.io.DataInputStream; import java.io.DataInputStream;
@ -16,18 +17,28 @@ public class BListener implements Listener {
public void onPluginmessage(PluginMessageEvent event) { public void onPluginmessage(PluginMessageEvent event) {
if (event.getTag().equalsIgnoreCase("t2car:bungee")) { if (event.getTag().equalsIgnoreCase("t2car:bungee")) {
DataInputStream stream = new DataInputStream(new ByteArrayInputStream(event.getData())); DataInputStream stream = new DataInputStream(new ByteArrayInputStream(event.getData()));
event.setCancelled(true);
try { try {
String channel = stream.readUTF(); String channel = stream.readUTF();
String input = stream.readUTF(); String input = stream.readUTF();
if (channel.equals("T2Code-Console")) {
switch (channel) {
case "ConC":
ProxyServer.getInstance().getConsole().sendMessage("Command Console: " + input); ProxyServer.getInstance().getConsole().sendMessage("Command Console: " + input);
ProxyServer.getInstance().getPluginManager().dispatchCommand(ProxyServer.getInstance().getConsole(), input); ProxyServer.getInstance().getPluginManager().dispatchCommand(ProxyServer.getInstance().getConsole(), input);
} else { break;
case "ALLPMSG":
for (ProxiedPlayer player : ProxyServer.getInstance().getPlayers()) {
Bsend.player(player, input);
}
break;
default:
ProxiedPlayer player = ProxyServer.getInstance().getPlayer(channel); ProxiedPlayer player = ProxyServer.getInstance().getPlayer(channel);
if (player != null) { if (player != null) {
ProxyServer.getInstance().getConsole().sendMessage("Command " + player + ": " + input); ProxyServer.getInstance().getConsole().sendMessage("Command " + player + ": " + input);
ProxyServer.getInstance().getPluginManager().dispatchCommand(player, input); ProxyServer.getInstance().getPluginManager().dispatchCommand(player, input);
} }
break;
} }
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();

View File

@ -10,7 +10,6 @@ import org.bukkit.plugin.java.JavaPlugin;
import java.io.File; import java.io.File;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Objects;
import java.util.logging.Level; import java.util.logging.Level;
public final class Main extends JavaPlugin { public final class Main extends JavaPlugin {
@ -19,10 +18,10 @@ public final class Main extends JavaPlugin {
return plugin.getDataFolder(); return plugin.getDataFolder();
} }
public static String version; private static String version;
public static List<String> autor; private static List<String> autor;
public static Main plugin; private static Main plugin;
public static ArrayList<ResponsesObject> allResponses = new ArrayList<>(); public static ArrayList<ResponsesObject> allResponses = new ArrayList<>();
public static ArrayList<String> allResponse = new ArrayList<>(); public static ArrayList<String> allResponse = new ArrayList<>();
@ -46,21 +45,48 @@ public final class Main extends JavaPlugin {
T2CodeTemplate.onDisable(Util.getPrefix(), autor, version, Util.getSpigot(), Util.getDiscord()); T2CodeTemplate.onDisable(Util.getPrefix(), autor, version, Util.getSpigot(), Util.getDiscord());
} }
public static Boolean pluginNotFound(String pl, Integer spigotID, double ver) { public static Boolean pluginNotFound(String pl, Integer spigotID, String ver) {
if (Bukkit.getPluginManager().getPlugin(pl) == null) { if (Bukkit.getPluginManager().getPlugin(pl) == null) {
plugin.getLogger().log(Level.SEVERE, "Plugin can not be loaded!"); plugin.getLogger().log(Level.SEVERE, "Plugin can not be loaded!");
Bukkit.getConsoleSender().sendMessage(Util.getPrefix() + " §e" + pl + " §4could not be found. Please download it here: " + Bukkit.getConsoleSender().sendMessage(Util.getPrefix() + " §e" + pl + " §4could not be found. Please download it here: "
"§6https://spigotmc.org/resources/" + pl + "." + spigotID + " §4to be able to use this plugin."); + "§6https://spigotmc.org/resources/" + pl + "." + spigotID + " §4to be able to use this plugin.");
Main.plugin.getPluginLoader().disablePlugin(Main.plugin); Main.plugin.getPluginLoader().disablePlugin(Main.plugin);
return true; return true;
} else { } else {
if (Double.parseDouble(Objects.requireNonNull(Bukkit.getPluginManager().getPlugin(pl)).getDescription().getVersion()) < ver) { String plVer = Bukkit.getPluginManager().getPlugin(pl).getDescription().getVersion();
if (ver.contains("_")) {
if (!plVer.equals(ver)) {
plugin.getLogger().log(Level.SEVERE, "Plugin can not be loaded!"); plugin.getLogger().log(Level.SEVERE, "Plugin can not be loaded!");
Bukkit.getConsoleSender().sendMessage(Util.getPrefix() + " §e" + pl + " §4is out of date! This plugin requires at least version §2" + ver + " §4of §6" + pl + " §4Please update it here: §6https://spigotmc.org/resources/" + pl + "." + spigotID + " §4to use this version of " + plugin.getDescription().getName() + "."); Bukkit.getConsoleSender().sendMessage(Util.getPrefix() + " §e" + pl + " §4is out of date! This plugin requires the version §2"
+ ver + " §4of §6" + pl + " §4Please use this version! Please download it here or contact us in Discord: §6https://spigotmc.org/resources/"
+ pl + "." + spigotID + " Or contact us in Discord: http://dc.t2code.net");
Main.plugin.getPluginLoader().disablePlugin(Main.plugin);
return true;
}
return false;
}
String[] split = plVer.split("_");
if (Double.parseDouble(split[0]) < Double.parseDouble(ver)) {
plugin.getLogger().log(Level.SEVERE, "Plugin can not be loaded!");
Bukkit.getConsoleSender().sendMessage(Util.getPrefix() + " §e" + pl + " §4is out of date! This plugin requires at least version §2"
+ ver + " §4of §6" + pl + " §4Please update it here: §6https://spigotmc.org/resources/" + pl + "." + spigotID
+ " §4to use this version of " + plugin.getDescription().getName() + ".");
Main.plugin.getPluginLoader().disablePlugin(Main.plugin); Main.plugin.getPluginLoader().disablePlugin(Main.plugin);
return true; return true;
} }
return false; return false;
} }
} }
public static String getVersion() {
return version;
}
public static List<String> getAutor() {
return autor;
}
public static Main getPlugin() {
return plugin;
}
} }

View File

@ -12,7 +12,7 @@ import org.bukkit.entity.Player;
public class Commands { public class Commands {
public static void info(CommandSender sender) { public static void info(CommandSender sender) {
T2CodeTemplate.sendInfo(sender, Util.getPrefix(),Util.getSpigot(),Util.getDiscord(), Main.autor,Main.version, UpdateAPI.PluginVersionen.get(Main.plugin.getName()).publicVersion); T2CodeTemplate.sendInfo(sender, Util.getPrefix(),Util.getSpigot(),Util.getDiscord(), Main.getAutor(),Main.getVersion(), UpdateAPI.PluginVersionen.get(Main.getPlugin().getName()).publicVersion);
} }
public static void reload(CommandSender sender) { public static void reload(CommandSender sender) {

View File

@ -11,7 +11,7 @@ import java.io.File;
import java.io.IOException; import java.io.IOException;
public class CreateMessages { public class CreateMessages {
private static Plugin plugin = Main.plugin; private static Plugin plugin = Main.getPlugin();
public static void langCreate() { public static void langCreate() {
send.debug(plugin,"§4Language files are created / updated..."); send.debug(plugin,"§4Language files are created / updated...");

View File

@ -14,12 +14,12 @@ package net.t2code.autoresponse.Spigot.config.languages;
public class MSG { public class MSG {
// EN // EN
public static String EN_ReloadStart = "[prefix] &6Plugin is reloaded..."; protected static String EN_ReloadStart = "[prefix] &6Plugin is reloaded...";
public static String EN_ReloadEnd = "[prefix] &2Plugin was successfully reloaded."; protected static String EN_ReloadEnd = "[prefix] &2Plugin was successfully reloaded.";
public static String EN_NoPermissionForCommand = "[prefix] &cFor &b[cmd] &cyou lack the permission &6[perm]&c!"; protected static String EN_NoPermissionForCommand = "[prefix] &cFor &b[cmd] &cyou lack the permission &6[perm]&c!";
// DE // DE
public static String DE_ReloadStart = "[prefix] &6Plugin wird neu geladen..."; protected static String DE_ReloadStart = "[prefix] &6Plugin wird neu geladen...";
public static String DE_ReloadEnd = "[prefix] &2Plugin wurde erfolgreich neu geladen."; protected static String DE_ReloadEnd = "[prefix] &2Plugin wurde erfolgreich neu geladen.";
public static String DE_NoPermissionForCommand = "[prefix] &cF[ue]r &b[cmd] &cfehlt dir die Permission &6[perm]&c!"; protected static String DE_NoPermissionForCommand = "[prefix] &cF[ue]r &b[cmd] &cfehlt dir die Permission &6[perm]&c!";
} }

View File

@ -24,8 +24,8 @@ public class SelectMessages {
public static void onSelect(String Prefix) { public static void onSelect(String Prefix) {
send.debug(Main.plugin, "§4Select language..."); send.debug(Main.getPlugin(), "§4Select language...");
Long long_ = Long.valueOf(System.currentTimeMillis()); long long_ = System.currentTimeMillis();
File msg; File msg;
@ -46,6 +46,6 @@ public class SelectMessages {
ReloadEnd = Config.select(prefix, "Plugin.Reload.End", yamlConfiguration); ReloadEnd = Config.select(prefix, "Plugin.Reload.End", yamlConfiguration);
NoPermissionForCommand = Config.select(prefix, "Plugin.ForCommand", yamlConfiguration); NoPermissionForCommand = Config.select(prefix, "Plugin.ForCommand", yamlConfiguration);
send.console(Prefix + " §2Language successfully selected to: §6" + selectMSG + " §7- §e" + (System.currentTimeMillis() - long_.longValue()) + "ms"); send.console(Prefix + " §2Language successfully selected to: §6" + selectMSG + " §7- §e" + (System.currentTimeMillis() - long_) + "ms");
} }
} }

View File

@ -16,7 +16,7 @@ public class CreateExampleResponse {
public static void configCreate() { public static void configCreate() {
long long_ = System.currentTimeMillis(); long long_ = System.currentTimeMillis();
if (new File(Main.getPath(), "config.yml").exists()) { 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..."); if (Main.getPlugin().getConfig().getBoolean("Plugin.Debug")) send.console(Util.getPrefix() + " §5DEBUG: §6" + " §4config.yml are created / updated...");
} else send.console(Util.getPrefix() + " §4config.yml are created..."); } else send.console(Util.getPrefix() + " §4config.yml are created...");
@ -26,6 +26,7 @@ public class CreateExampleResponse {
Config.set("Response.Enable", true, yamlConfiguration); Config.set("Response.Enable", true, yamlConfiguration);
Config.set("Response.ResponseKeys", Collections.singletonList(".example"), yamlConfiguration); Config.set("Response.ResponseKeys", Collections.singletonList(".example"), yamlConfiguration);
Config.set("Response.Contains", false, yamlConfiguration); Config.set("Response.Contains", false, yamlConfiguration);
Config.set("Response.BlockKeyMessage", true, yamlConfiguration);
Config.set("Response.Permission.Necessary", true, yamlConfiguration); Config.set("Response.Permission.Necessary", true, yamlConfiguration);
Config.set("Response.Permission.Permission", "t2c-autoresponse.response.example", yamlConfiguration); Config.set("Response.Permission.Permission", "t2c-autoresponse.response.example", yamlConfiguration);
@ -35,12 +36,9 @@ public class CreateExampleResponse {
Config.set("Response.Command.Commands", Collections.singletonList("say hi"), yamlConfiguration); Config.set("Response.Command.Commands", Collections.singletonList("say hi"), yamlConfiguration);
Config.set("Response.Message.Enable", true, 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); Config.set("Response.Message.Global.Enable", false, yamlConfiguration);
Config.set("Response.Message.TextBuilder.Enable", true, yamlConfiguration); Config.set("Response.Message.Global.Bungee", false, yamlConfiguration);
Config.set("Response.Message.TextBuilder.Hover", "&5Discord: &edc.t2code.net", yamlConfiguration); Config.set("Response.Message.Messages", Arrays.asList("[prefix] <dark_green>This is an Automated response from <dark_gray>[<dark_red>T2Code</dark_red><gray>-</gray><aqua>AutoResponse</aqua>]</dark_gray>.</dark_green>", "[prefix] <gold>Contact us for questions / support on our <dark_purple><hover:show_text:'<dark_purple>Discord:</dark_purple> <yellow>dc.t2code.net</yellow>'><click:open_url:'http://dc.t2code.net'>Discord</click></hover></dark_purple>.</gold>"), 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", "http://dc.t2code.net", yamlConfiguration);
Config.set("Response.Protection.GameMode.Enable", false, yamlConfiguration); Config.set("Response.Protection.GameMode.Enable", false, yamlConfiguration);
Config.set("Response.Protection.GameMode.Mode", "blacklist", yamlConfiguration); Config.set("Response.Protection.GameMode.Mode", "blacklist", yamlConfiguration);

View File

@ -22,6 +22,7 @@ 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.Permission.Necessary"), yamlConfiguration.getBoolean("Response.Permission.Necessary"),
yamlConfiguration.getString("Response.Permission.Permission"), yamlConfiguration.getString("Response.Permission.Permission"),
@ -31,12 +32,9 @@ public class SelectResponses {
yamlConfiguration.getStringList("Response.Command.Commands"), yamlConfiguration.getStringList("Response.Command.Commands"),
yamlConfiguration.getBoolean("Response.Message.Enable"), yamlConfiguration.getBoolean("Response.Message.Enable"),
yamlConfiguration.getBoolean("Response.Message.Global.Enable"),
yamlConfiguration.getBoolean("Response.Message.Global.Bungee"),
yamlConfiguration.getStringList("Response.Message.Messages"), yamlConfiguration.getStringList("Response.Message.Messages"),
yamlConfiguration.getBoolean("Response.Message.TextBuilder.Enable"),
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.getBoolean("Response.Protection.GameMode.Enable"), yamlConfiguration.getBoolean("Response.Protection.GameMode.Enable"),
yamlConfiguration.getString("Response.Protection.GameMode.Mode"), yamlConfiguration.getString("Response.Protection.GameMode.Mode"),

View File

@ -1,6 +1,7 @@
package net.t2code.autoresponse.Spigot.event; package net.t2code.autoresponse.Spigot.event;
import net.md_5.bungee.api.chat.ClickEvent; import net.md_5.bungee.api.chat.ClickEvent;
import net.t2code.autoresponse.Spigot.system.BungeeSend;
import net.t2code.autoresponse.Util; import net.t2code.autoresponse.Util;
import net.t2code.autoresponse.Spigot.config.config.SelectConfig; import net.t2code.autoresponse.Spigot.config.config.SelectConfig;
import net.t2code.autoresponse.Spigot.objects.ResponsesObject; import net.t2code.autoresponse.Spigot.objects.ResponsesObject;
@ -12,6 +13,7 @@ import net.t2code.lib.Spigot.Lib.messages.TextBuilder;
import net.t2code.lib.Spigot.Lib.messages.send; import net.t2code.lib.Spigot.Lib.messages.send;
import net.t2code.lib.Spigot.Lib.plugins.PluginCheck; import net.t2code.lib.Spigot.Lib.plugins.PluginCheck;
import net.t2code.lib.Spigot.Lib.replace.Replace; import net.t2code.lib.Spigot.Lib.replace.Replace;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
@ -67,13 +69,15 @@ public class ResponseListener implements Listener {
return; return;
} }
} }
use(e, player, responseKey); use(e, player, responseKey, 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 (SelectConfig.bungee) {
BCommand_Sender_Reciver.sendToBungee(player, cmd.replace("[player]", player.getName()), response.commandAsConsole); 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);
} else { } else {
send.console(Util.getPrefix() + " §4To use bungee commands, enable the Bungee option in the config."); send.console(Util.getPrefix() + " §4To use bungee commands, enable the Bungee option in the config.");
send.sender(player, Util.getPrefix() + " §4To use bungee commands, enable the Bungee option in the config."); send.sender(player, Util.getPrefix() + " §4To use bungee commands, enable the Bungee option in the config.");
@ -85,7 +89,7 @@ public class ResponseListener implements Listener {
public void run() { public void run() {
Cmd.console(cmd.replace("[player]", player.getName())); Cmd.console(cmd.replace("[player]", player.getName()));
} }
}.runTaskLater(Main.plugin, 1L); }.runTaskLater(Main.getPlugin(), 1L);
} else { } else {
Cmd.player(player, cmd.replace("[player]", player.getName())); Cmd.player(player, cmd.replace("[player]", player.getName()));
@ -96,30 +100,26 @@ public class ResponseListener implements Listener {
if (response.messageEnable) { if (response.messageEnable) {
for (String msg : response.messages) { for (String msg : response.messages) {
String text; String text;
String hover;
if (PluginCheck.papi()) { if (PluginCheck.papi()) {
text = Replace.replace(Util.getPrefix(), player, msg); text = Replace.replace(Util.getPrefix(), player, msg);
hover = Replace.replace(Util.getPrefix(), player, response.hover);
} else { } else {
text = Replace.replace(Util.getPrefix(), msg); text = Replace.replace(Util.getPrefix(), msg);
hover = Replace.replace(Util.getPrefix(), response.hover);
} }
if (response.textBuilder) { if (response.messageGlobal) {
TextBuilder textBuilder = new TextBuilder(text); if (response.messageGlobalBungee) {
textBuilder.addHover(hover); BCommand_Sender_Reciver.sendToBungee(player, text, BungeeSend.ALLPLAYERMSG);
if (response.clickEvent) {
textBuilder.addClickEvent(ClickEvent.Action.valueOf(response.action), response.actionValue);
}
player.spigot().sendMessage(textBuilder.build());
} else { } else {
send.player(player, text); for (Player player1 : Bukkit.getOnlinePlayers()) {
send.player(player1, text);
} }
} }
} else send.player(player, text);
}
} }
} }
private static void use(AsyncPlayerChatEvent e, Player player, String responseKey) { private static void use(AsyncPlayerChatEvent e, Player player, String responseKey, ResponsesObject response) {
e.setCancelled(true); if (response.blockKeyMessage) e.setCancelled(true);
if (SelectConfig.logConsole) send.console(Util.getPrefix() + " §6Player: §e" + player.getName() + " §6use AutoResponse: §e" + responseKey); if (SelectConfig.logConsole) send.console(Util.getPrefix() + " §6Player: §e" + player.getName() + " §6use AutoResponse: §e" + responseKey);
} }
} }

View File

@ -6,6 +6,7 @@ public class ResponsesObject {
public Boolean enable; public Boolean enable;
public List<String> responseKeys; public List<String> responseKeys;
public Boolean contains; public Boolean contains;
public Boolean blockKeyMessage;
public Boolean commandEnable; public Boolean commandEnable;
public Boolean permNecessary; public Boolean permNecessary;
public String permission; public String permission;
@ -14,12 +15,9 @@ public class ResponsesObject {
public Boolean bungeeCommand; public Boolean bungeeCommand;
public List<String> command; public List<String> command;
public Boolean messageEnable; public Boolean messageEnable;
public Boolean messageGlobal;
public Boolean messageGlobalBungee;
public List<String> messages; public List<String> messages;
public Boolean textBuilder;
public String hover;
public Boolean clickEvent;
public String action;
public String actionValue;
public Boolean protectionGameModeEnable; public Boolean protectionGameModeEnable;
public String protectionGameModeMode; public String protectionGameModeMode;
@ -32,6 +30,7 @@ public class ResponsesObject {
public ResponsesObject(Boolean enable, public ResponsesObject(Boolean enable,
List<String> responseKeys, List<String> responseKeys,
Boolean contains, Boolean contains,
Boolean blockKeyMessage,
Boolean permNecessary, Boolean permNecessary,
String permission, String permission,
Boolean commandEnable, Boolean commandEnable,
@ -39,12 +38,9 @@ public class ResponsesObject {
Boolean bungeeCommand, Boolean bungeeCommand,
List<String> command, List<String> command,
Boolean messageEnable, Boolean messageEnable,
Boolean messageGlobal,
Boolean messageGlobalBungee,
List<String> messages, List<String> messages,
Boolean textBuilder,
String hover,
Boolean clickEvent,
String action,
String actionValue,
Boolean protectionGameModeEnable, Boolean protectionGameModeEnable,
String protectionGameModeMode, String protectionGameModeMode,
List<String> protectionGameModeList, List<String> protectionGameModeList,
@ -54,6 +50,7 @@ public class ResponsesObject {
this.enable = enable; this.enable = enable;
this.responseKeys = responseKeys; this.responseKeys = responseKeys;
this.contains=contains; this.contains=contains;
this.blockKeyMessage=blockKeyMessage;
this.permNecessary = permNecessary; this.permNecessary = permNecessary;
this.permission = permission; this.permission = permission;
this.commandEnable = commandEnable; this.commandEnable = commandEnable;
@ -61,12 +58,9 @@ public class ResponsesObject {
this.bungeeCommand = bungeeCommand; this.bungeeCommand = bungeeCommand;
this.command = command; this.command = command;
this.messageEnable = messageEnable; this.messageEnable = messageEnable;
this.messageGlobal = messageGlobal;
this.messageGlobalBungee = messageGlobalBungee;
this.messages = messages; this.messages = messages;
this.textBuilder = textBuilder;
this.hover = hover;
this.clickEvent = clickEvent;
this.action = action;
this.actionValue = actionValue;
this.protectionGameModeEnable = protectionGameModeEnable; this.protectionGameModeEnable = protectionGameModeEnable;
this.protectionGameModeMode = protectionGameModeMode; this.protectionGameModeMode = protectionGameModeMode;

View File

@ -11,29 +11,37 @@ import java.io.IOException;
public class BCommand_Sender_Reciver { public class BCommand_Sender_Reciver {
public static void sendToBungee(CommandSender sender, String information, Boolean console) { public static void sendToBungee(CommandSender sender, String information, BungeeSend type) {
ByteArrayOutputStream stream = new ByteArrayOutputStream(); ByteArrayOutputStream stream = new ByteArrayOutputStream();
DataOutputStream output = new DataOutputStream(stream); DataOutputStream output = new DataOutputStream(stream);
try { try {
if (console) { switch (type) {
output.writeUTF("T2Code-Console"); case BUNGEECOMMAND:
} else { output.writeUTF("ConC");
break;
case COMMAND:
if (sender instanceof Player) { if (sender instanceof Player) {
output.writeUTF(sender.getName()); output.writeUTF(sender.getName());
} else { } else {
output.writeUTF("T2Code-Console"); output.writeUTF("ConC");
} }
break;
case ALLPLAYERMSG:
output.writeUTF("ALLPMSG");
break;
} }
output.writeUTF(information); output.writeUTF(information);
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} }
if (sender instanceof Player) { if (sender instanceof Player) {
Player player = (Player) sender; Player player = (Player) sender;
player.sendPluginMessage(Main.plugin, "t2car:bungee", stream.toByteArray()); player.sendPluginMessage(Main.getPlugin(), "t2car:bungee", stream.toByteArray());
} else { } else {
for (Player player : Bukkit.getOnlinePlayers()) { for (Player player : Bukkit.getOnlinePlayers()) {
player.sendPluginMessage(Main.plugin, "t2car:bungee", stream.toByteArray()); player.sendPluginMessage(Main.getPlugin(), "t2car:bungee", stream.toByteArray());
return; return;
} }
} }

View File

@ -0,0 +1,7 @@
package net.t2code.autoresponse.Spigot.system;
public enum BungeeSend {
BUNGEECOMMAND,
COMMAND,
ALLPLAYERMSG
}

View File

@ -14,10 +14,10 @@ public class JoinEvent implements Listener {
@EventHandler @EventHandler
public void onJoinEvent(PlayerLoginEvent event) { public void onJoinEvent(PlayerLoginEvent event) {
if (Main.version.toUpperCase().contains("DEV")) { if (Main.getVersion().toUpperCase().contains("DEV")) {
return; return;
} }
Player player = event.getPlayer(); Player player = event.getPlayer();
UpdateAPI.join(Main.plugin, Util.getPrefix(),Permissions.updatemsg,player,Util.getSpigot(), Util.getDiscord()); UpdateAPI.join(Main.getPlugin(), Util.getPrefix(),Permissions.updatemsg,player,Util.getSpigot(), Util.getDiscord());
} }
} }

View File

@ -18,10 +18,10 @@ import org.bukkit.plugin.Plugin;
import java.util.List; import java.util.List;
public class Load { public class Load {
static Plugin plugin = Main.plugin; static Main plugin = Main.getPlugin();
public static void onLoad(String prefix, List<String> autor, String version, String spigot, int spigotID, String discord, int bstatsID) { public static void onLoad(String prefix, List<String> autor, String version, String spigot, int spigotID, String discord, int bstatsID) {
Long long_ = T2CodeTemplate.onLoadHeader(prefix, autor, version, spigot, discord); Long long_ = T2CodeTemplate.onLoadHeader(prefix, autor, version, spigot, discord);
Main.plugin.getCommand("t2code-autoresponse").setExecutor( new CmdExecuter()); plugin.getCommand("t2code-autoresponse").setExecutor( new CmdExecuter());
loadReload(); loadReload();
UpdateAPI.onUpdateCheck(plugin, prefix, spigot, spigotID, discord); UpdateAPI.onUpdateCheck(plugin, prefix, spigot, spigotID, discord);
@ -31,8 +31,8 @@ public class Load {
T2CodeTemplate.onLoadFooter(prefix, long_,version); T2CodeTemplate.onLoadFooter(prefix, long_,version);
Metrics.Bstats(plugin, bstatsID); Metrics.Bstats(plugin, bstatsID);
if (SelectConfig.bungee) { if (SelectConfig.bungee) {
Main.plugin.getServer().getMessenger().registerOutgoingPluginChannel(Main.plugin, "BungeeCord"); plugin.getServer().getMessenger().registerOutgoingPluginChannel(plugin, "BungeeCord");
Bukkit.getMessenger().registerOutgoingPluginChannel(Main.plugin, "t2car:bungee"); Bukkit.getMessenger().registerOutgoingPluginChannel(plugin, "t2car:bungee");
} }
Permissions.register(); Permissions.register();
} }

View File

@ -15,12 +15,12 @@ public class Permissions {
public static final PermissionDefault notOp = PermissionDefault.NOT_OP; public static final PermissionDefault notOp = PermissionDefault.NOT_OP;
protected static void register() { protected static void register() {
Register.permission(info, op, Main.plugin); Register.permission(info, op, Main.getPlugin());
Register.permission(updatemsg, op, Main.plugin); Register.permission(updatemsg, op, Main.getPlugin());
Register.permission(admin, op, info, true, Main.plugin); Register.permission(admin, op, info, true, Main.getPlugin());
Register.permission(admin, op, updatemsg, true, Main.plugin); Register.permission(admin, op, updatemsg, true, Main.getPlugin());
for (ResponsesObject response : Main.allResponses) { for (ResponsesObject response : Main.allResponses) {
Register.permission(response.permission, op,Main.plugin); Register.permission(response.permission, op, Main.getPlugin());
} }
} }
} }

View File

@ -1,14 +1,14 @@
package net.t2code.autoresponse; package net.t2code.autoresponse;
public class Util { public class Util {
private static double requiredT2CodeLibVersion = 12.0; private static String requiredT2CodeLibVersion = "12.5";
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;
private static Integer BstatsID = 14091; private static Integer BstatsID = 14091;
private static String Spigot = "https://www.spigotmc.org/resources/" + SpigotID; private static String Spigot = "https://www.spigotmc.org/resources/" + SpigotID;
private static String Discord = "http://dc.t2code.net"; private static String Discord = "http://dc.t2code.net";
public static double getRequiredT2CodeLibVersion() { public static String getRequiredT2CodeLibVersion() {
return requiredT2CodeLibVersion; return requiredT2CodeLibVersion;
} }