1.4_dev-1
T2CodeLib API update to 16.7 New config creator
This commit is contained in:
parent
b84d0dc02b
commit
4c57fec686
15
pom.xml
15
pom.xml
@ -6,7 +6,7 @@
|
||||
|
||||
<groupId>net.t2code</groupId>
|
||||
<artifactId>AutoResponse</artifactId>
|
||||
<version>1.3</version>
|
||||
<version>1.4_dev-1</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>T2C-AutoResponse</name>
|
||||
@ -25,8 +25,8 @@
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.8.1</version>
|
||||
<configuration>
|
||||
<source>${java.version}</source>
|
||||
<target>${java.version}</target>
|
||||
<source>11</source>
|
||||
<target>11</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
@ -76,7 +76,8 @@
|
||||
<dependency>
|
||||
<groupId>net.t2code</groupId>
|
||||
<artifactId>T2CodeLib</artifactId>
|
||||
<version>15.0</version>
|
||||
<version>16.7</version>
|
||||
<classifier>dev-24</classifier>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
@ -85,5 +86,11 @@
|
||||
<version>1615</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>1.18.30</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
|
@ -3,7 +3,8 @@ package net.t2code.autoresponse.Spigot;
|
||||
import net.t2code.autoresponse.Spigot.objects.ResponsesObject;
|
||||
import net.t2code.autoresponse.Spigot.system.Load;
|
||||
import net.t2code.autoresponse.Util;
|
||||
import net.t2code.t2codelib.SPIGOT.api.messages.T2Ctemplate;
|
||||
|
||||
import net.t2code.t2codelib.SPIGOT.api.messages.T2C_Template;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
@ -34,7 +35,6 @@ public final class Main extends JavaPlugin {
|
||||
version = plugin.getDescription().getVersion();
|
||||
if (pluginNotFound("T2CodeLib", 96388, Util.getRequiredT2CodeLibVersion())) return;
|
||||
Load.onLoad(Util.getPrefix(), autor, version, Util.getSpigot(), Util.getSpigotID(), Util.getDiscord(), Util.getBstatsID());
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -42,7 +42,7 @@ public final class Main extends JavaPlugin {
|
||||
// Plugin shutdown logic
|
||||
allResponses.clear();
|
||||
if (Bukkit.getPluginManager().getPlugin("T2CodeLib") == null) return;
|
||||
T2Ctemplate.onDisable(Util.getPrefix(), autor, version, Util.getSpigot(), Util.getDiscord());
|
||||
T2C_Template.onDisable(Util.getPrefix(), plugin);
|
||||
}
|
||||
|
||||
public static Boolean pluginNotFound(String pl, Integer spigotID, String ver) {
|
||||
|
@ -1,8 +1,8 @@
|
||||
package net.t2code.autoresponse.Spigot.cmdManagement;
|
||||
|
||||
import net.t2code.autoresponse.Spigot.config.languages.SelectMessages;
|
||||
import net.t2code.autoresponse.Spigot.config.languages.Languages;
|
||||
import net.t2code.autoresponse.Spigot.system.Permissions;
|
||||
import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend;
|
||||
import net.t2code.t2codelib.SPIGOT.api.messages.T2C_Send;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@ -24,7 +24,7 @@ public class CmdExecuter implements CommandExecutor, TabCompleter {
|
||||
case "rl":
|
||||
if (sender.hasPermission(Permissions.admin) || sender.isOp()) {
|
||||
Commands.reload(sender);
|
||||
} else T2Csend.sender(sender, SelectMessages.NoPermissionForCommand.replace("[cmd]", "/t2code-autoresponse reload")
|
||||
} else T2C_Send.sender(sender, Languages.VALUES.noPermissionForCommand.getValue().toString().replace("[cmd]", "/t2code-autoresponse reload")
|
||||
.replace("[perm]", Permissions.admin));
|
||||
break;
|
||||
case "info":
|
||||
@ -32,7 +32,7 @@ public class CmdExecuter implements CommandExecutor, TabCompleter {
|
||||
case "version":
|
||||
if (sender.hasPermission(Permissions.info)) {
|
||||
Commands.info(sender);
|
||||
} else T2Csend.sender(sender, SelectMessages.NoPermissionForCommand.replace("[cmd]", "/t2code-autoresponse info")
|
||||
} else T2C_Send.sender(sender, Languages.VALUES.noPermissionForCommand.getValue().toString().replace("[cmd]", "/t2code-autoresponse info")
|
||||
.replace("[perm]", Permissions.info));
|
||||
break;
|
||||
|
||||
|
@ -1,28 +1,28 @@
|
||||
package net.t2code.autoresponse.Spigot.cmdManagement;
|
||||
|
||||
import net.t2code.autoresponse.Spigot.config.languages.Languages;
|
||||
import net.t2code.autoresponse.Util;
|
||||
import net.t2code.autoresponse.Spigot.config.languages.SelectMessages;
|
||||
import net.t2code.autoresponse.Spigot.system.Load;
|
||||
import net.t2code.autoresponse.Spigot.Main;
|
||||
import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend;
|
||||
import net.t2code.t2codelib.SPIGOT.api.messages.T2Ctemplate;
|
||||
import net.t2code.t2codelib.SPIGOT.api.messages.T2C_Send;
|
||||
import net.t2code.t2codelib.SPIGOT.api.messages.T2C_Template;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class Commands {
|
||||
public static void info(CommandSender sender) {
|
||||
T2Ctemplate.sendInfo(sender,Main.getPlugin(),Util.getSpigotID(),Util.getDiscord(),Util.getInfoText());
|
||||
T2C_Template.sendInfo(sender,Main.getPlugin(),Util.getSpigotID(),Util.getDiscord(),Util.getInfoText());
|
||||
}
|
||||
|
||||
public static void reload(CommandSender sender) {
|
||||
if (sender instanceof Player) sender.sendMessage(SelectMessages.ReloadStart);
|
||||
T2Csend.console(Util.getPrefix() + "§8-------------------------------");
|
||||
T2Csend.console(Util.getPrefix() + " §6Plugin reload...");
|
||||
T2Csend.console(Util.getPrefix() + "§8-------------------------------");
|
||||
Load.loadReload();
|
||||
if (sender instanceof Player) sender.sendMessage(SelectMessages.ReloadEnd);
|
||||
T2Csend.console(Util.getPrefix() + "§8-------------------------------");
|
||||
T2Csend.console(Util.getPrefix() + " §2Plugin successfully reloaded.");
|
||||
T2Csend.console(Util.getPrefix() + "§8-------------------------------");
|
||||
if (sender instanceof Player) sender.sendMessage(Languages.VALUES.reloadStart.getValue().toString());
|
||||
T2C_Send.console(Util.getPrefix() + "§8-------------------------------");
|
||||
T2C_Send.console(Util.getPrefix() + " §6Plugin reload...");
|
||||
T2C_Send.console(Util.getPrefix() + "§8-------------------------------");
|
||||
Load.loadReload(true);
|
||||
if (sender instanceof Player) sender.sendMessage(Languages.VALUES.reloadEnd.getValue().toString());
|
||||
T2C_Send.console(Util.getPrefix() + "§8-------------------------------");
|
||||
T2C_Send.console(Util.getPrefix() + " §2Plugin successfully reloaded.");
|
||||
T2C_Send.console(Util.getPrefix() + "§8-------------------------------");
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,116 @@
|
||||
// This class was created by JaTiTV.
|
||||
|
||||
package net.t2code.autoresponse.Spigot.config.config;
|
||||
|
||||
import net.t2code.autoresponse.Spigot.Main;
|
||||
import net.t2code.autoresponse.Util;
|
||||
import net.t2code.t2codelib.SPIGOT.api.yaml.T2C_ConfigWriter;
|
||||
import net.t2code.t2codelib.SPIGOT.system.T2C_Main;
|
||||
import net.t2code.t2codelib.SPIGOT.system.config.config.T2C_LibConfig;
|
||||
import net.t2code.t2codelib.util.T2C_ConfigItem;
|
||||
import net.t2code.t2codelib.util.T2C_LanguageEnum;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
public class Config {
|
||||
public enum VALUES implements T2C_ConfigItem {
|
||||
language("plugin.language", T2C_LanguageEnum.english, true, new HashMap<>() {{
|
||||
put(T2C_LanguageEnum.german, List.of("In dieser Option kannst du die Sprache des Plugins einstellen."));
|
||||
put(T2C_LanguageEnum.english, List.of("In this option you can set the language of the plugin."));
|
||||
}}),
|
||||
updateCheckOnJoin("plugin.updateCheck.onJoin", true, true, new HashMap<>() {{
|
||||
put(T2C_LanguageEnum.german, List.of());
|
||||
put(T2C_LanguageEnum.english, List.of());
|
||||
}}),
|
||||
updateCheckSeePreReleaseUpdates("plugin.updateCheck.seePreReleaseUpdates", true, true, new HashMap<>() {{
|
||||
put(T2C_LanguageEnum.german, List.of());
|
||||
put(T2C_LanguageEnum.english, List.of());
|
||||
}}),
|
||||
updateCheckTimeInterval("plugin.updateCheck.timeInterval", 60, true, new HashMap<>() {{
|
||||
put(T2C_LanguageEnum.german, List.of());
|
||||
put(T2C_LanguageEnum.english, List.of());
|
||||
}}),
|
||||
keywordSeparation("plugin.responseKeys.keywordSeparation", "##", true, new HashMap<>() {{
|
||||
put(T2C_LanguageEnum.german, List.of());
|
||||
put(T2C_LanguageEnum.english, List.of());
|
||||
}}),
|
||||
logConsole("log.console.enable", true, true, new HashMap<>() {{
|
||||
put(T2C_LanguageEnum.german, List.of());
|
||||
put(T2C_LanguageEnum.english, List.of());
|
||||
}}),
|
||||
|
||||
;
|
||||
|
||||
private final String path;
|
||||
private Object value;
|
||||
private final boolean forceSet;
|
||||
private final HashMap<T2C_LanguageEnum, List<String>> comments;
|
||||
|
||||
VALUES(String path, Object value, boolean forceSet, HashMap<T2C_LanguageEnum, List<String>> comments) {
|
||||
this.path = path;
|
||||
this.value = value;
|
||||
this.forceSet = forceSet;
|
||||
this.comments = comments;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPath() {
|
||||
return path;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getForceSet() {
|
||||
return forceSet;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HashMap<T2C_LanguageEnum, List<String>> getComments() {
|
||||
return comments;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getLanguagePath() {
|
||||
return language.path;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setValue(Object newValue) {
|
||||
value = newValue;
|
||||
}
|
||||
}
|
||||
|
||||
public static void set(boolean isReload) {
|
||||
convert();
|
||||
T2C_ConfigWriter.createConfig(Util.getPrefix(), new File(Main.getPath(), "config.yml"), T2C_LibConfig.VALUES.values(), isReload, Util.getConfigLogo());
|
||||
}
|
||||
|
||||
private static void convert() {
|
||||
File config = new File(Main.getPath(), "config.yml");
|
||||
|
||||
if (!config.exists()) return;
|
||||
YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(config);
|
||||
|
||||
if (!yamlConfiguration.contains("Plugin")) return;
|
||||
|
||||
set("Plugin.language", VALUES.language, yamlConfiguration);
|
||||
set("Plugin.updateCheck.onJoin", VALUES.updateCheckOnJoin, yamlConfiguration);
|
||||
set("Plugin.updateCheck.seePreReleaseUpdates", VALUES.updateCheckSeePreReleaseUpdates, yamlConfiguration);
|
||||
set("Plugin.updateCheck.timeInterval", VALUES.updateCheckTimeInterval, yamlConfiguration);
|
||||
set("Plugin.responseKeys.keywordSeperation", VALUES.keywordSeparation, yamlConfiguration);
|
||||
set("Log.Console.Enable", VALUES.logConsole, yamlConfiguration);
|
||||
}
|
||||
|
||||
private static void set(String path, T2C_ConfigItem item, YamlConfiguration yamlConfiguration) {
|
||||
if (yamlConfiguration.contains(path)) {
|
||||
item.setValue(yamlConfiguration.get(path));
|
||||
}
|
||||
}
|
||||
}
|
@ -1,33 +0,0 @@
|
||||
package net.t2code.autoresponse.Spigot.config.config;
|
||||
|
||||
import net.t2code.autoresponse.Util;
|
||||
import net.t2code.autoresponse.Spigot.Main;
|
||||
import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend;
|
||||
import net.t2code.t2codelib.SPIGOT.api.yaml.T2Cconfig;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
public class CreateConfig {
|
||||
public static void configCreate() {
|
||||
long long_ = System.currentTimeMillis();
|
||||
File config = new File(Main.getPath(), "config.yml");
|
||||
YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(config);
|
||||
|
||||
T2Cconfig.set("Plugin.language", "english", yamlConfiguration);
|
||||
T2Cconfig.set("Plugin.updateCheck.onJoin", true, yamlConfiguration);
|
||||
T2Cconfig.set("Plugin.updateCheck.seePreReleaseUpdates", true, yamlConfiguration);
|
||||
T2Cconfig.set("Plugin.updateCheck.timeInterval", 60, yamlConfiguration);
|
||||
T2Cconfig.set("Plugin.responseKeys.keywordSeperation", "##", yamlConfiguration);
|
||||
|
||||
T2Cconfig.set("Log.Console.Enable", true, yamlConfiguration);
|
||||
|
||||
try {
|
||||
yamlConfiguration.save(config);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
T2Csend.console(Util.getPrefix() + " §2config.yml were successfully created / updated." + " §7- §e" + (System.currentTimeMillis() - long_) + "ms");
|
||||
}
|
||||
}
|
@ -1,28 +0,0 @@
|
||||
package net.t2code.autoresponse.Spigot.config.config;
|
||||
|
||||
import net.t2code.autoresponse.Spigot.Main;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class SelectConfig {
|
||||
public static String language;
|
||||
public static Boolean updateCheckOnJoin;
|
||||
public static Boolean updateCheckSeePreReleaseUpdates;
|
||||
public static Integer updateCheckTimeInterval;
|
||||
public static String keywordSeperation;
|
||||
public static Boolean logConsole;
|
||||
|
||||
public static void onSelect() {
|
||||
File config = new File(Main.getPath(), "config.yml");
|
||||
YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(config);
|
||||
|
||||
language = yamlConfiguration.getString("Plugin.language");
|
||||
updateCheckOnJoin = yamlConfiguration.getBoolean("Plugin.updateCheck.onJoin");
|
||||
updateCheckSeePreReleaseUpdates = yamlConfiguration.getBoolean("Plugin.updateCheck.seePreReleaseUpdates");
|
||||
updateCheckTimeInterval = yamlConfiguration.getInt("Plugin.updateCheck.timeInterval");
|
||||
keywordSeperation = yamlConfiguration.getString("Plugin.responseKeys.keywordSeperation");
|
||||
|
||||
logConsole = yamlConfiguration.getBoolean("Log.Console.Enable");
|
||||
}
|
||||
}
|
@ -1,63 +0,0 @@
|
||||
package net.t2code.autoresponse.Spigot.config.languages;
|
||||
|
||||
import net.t2code.autoresponse.Util;
|
||||
import net.t2code.autoresponse.Spigot.Main;
|
||||
import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend;
|
||||
import net.t2code.t2codelib.SPIGOT.api.yaml.T2Cconfig;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
public class CreateMessages {
|
||||
private static Plugin plugin = Main.getPlugin();
|
||||
|
||||
public static void langCreate() {
|
||||
T2Csend.debug(plugin,"§4Language files are created / updated...");
|
||||
Long long_ = Long.valueOf(System.currentTimeMillis());
|
||||
|
||||
/**
|
||||
*
|
||||
* ENGLISH
|
||||
*
|
||||
*/
|
||||
|
||||
File messagesEN = new File(Main.getPath(), "languages/english_messages.yml");
|
||||
YamlConfiguration yamlConfigurationEN = YamlConfiguration.loadConfiguration(messagesEN);
|
||||
|
||||
T2Cconfig.set("Plugin.Reload.Start", MSG.EN_ReloadStart, yamlConfigurationEN);
|
||||
T2Cconfig.set("Plugin.Reload.End", MSG.EN_ReloadEnd, yamlConfigurationEN);
|
||||
T2Cconfig.set("Plugin.ForCommand", MSG.EN_NoPermissionForCommand, yamlConfigurationEN);
|
||||
|
||||
try {
|
||||
yamlConfigurationEN.save(messagesEN);
|
||||
} catch (IOException e) {
|
||||
T2Csend.warning(plugin,e.getMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* GERMAN
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
File messagesDE = new File(Main.getPath(), "languages/german_messages.yml");
|
||||
YamlConfiguration yamlConfigurationDE = YamlConfiguration.loadConfiguration(messagesDE);
|
||||
|
||||
T2Cconfig.set("Plugin.Reload.Start", MSG.DE_ReloadStart, yamlConfigurationDE);
|
||||
T2Cconfig.set("Plugin.Reload.End", MSG.DE_ReloadEnd, yamlConfigurationDE);
|
||||
T2Cconfig.set("Plugin.ForCommand", MSG.DE_NoPermissionForCommand, yamlConfigurationDE);
|
||||
|
||||
try {
|
||||
yamlConfigurationDE.save(messagesDE);
|
||||
} catch (IOException e) {
|
||||
T2Csend.warning(plugin,e.getMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
T2Csend.console(Util.getPrefix() + " §2Language files were successfully created / updated." + " §7- §e" + (System.currentTimeMillis() - long_.longValue()) + "ms");
|
||||
}
|
||||
}
|
@ -0,0 +1,116 @@
|
||||
// This class was created by JaTiTV.
|
||||
|
||||
package net.t2code.autoresponse.Spigot.config.languages;
|
||||
|
||||
import lombok.NonNull;
|
||||
import net.t2code.autoresponse.Spigot.Main;
|
||||
import net.t2code.autoresponse.Util;
|
||||
import net.t2code.t2codelib.SPIGOT.api.yaml.T2C_LanguageWriter;
|
||||
import net.t2code.t2codelib.SPIGOT.system.T2C_Main;
|
||||
import net.t2code.t2codelib.SPIGOT.system.config.config.T2C_LibConfig;
|
||||
import net.t2code.t2codelib.SPIGOT.system.config.languages.T2CLibLanguages;
|
||||
import net.t2code.t2codelib.util.T2C_ConfigItemLanguages;
|
||||
import net.t2code.t2codelib.util.T2C_LanguageEnum;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
public class Languages {
|
||||
public enum VALUES implements T2C_ConfigItemLanguages {
|
||||
otherLang("plugin", null, new HashMap<>() {{
|
||||
put(T2C_LanguageEnum.german, null);
|
||||
put(T2C_LanguageEnum.english, null);
|
||||
}}, new HashMap<>() {{
|
||||
put(T2C_LanguageEnum.german, List.of("Wenn du eine Eigene Sprache hinzufügen magst, dann kopiere einfach eine Sprachdatei und benenne sie in deine Sprache, dies kannst du dann in der config.yml einstellen.", ""));
|
||||
put(T2C_LanguageEnum.english, List.of("If you want to add your own language, simply copy a language file and rename it to your language, you can then set this in config.yml.", ""));
|
||||
}}),
|
||||
reloadStart("plugin.reload.start", null, new HashMap<>() {{
|
||||
put(T2C_LanguageEnum.german, List.of("[prefix] &6Plugin wird neu geladen..."));
|
||||
put(T2C_LanguageEnum.english, List.of("[prefix] &6Plugin is reloaded..."));
|
||||
}}, new HashMap<>() {{
|
||||
put(T2C_LanguageEnum.german, List.of());
|
||||
put(T2C_LanguageEnum.english, List.of());
|
||||
}}),
|
||||
reloadEnd("plugin.reload.end", null, new HashMap<>() {{
|
||||
put(T2C_LanguageEnum.german, List.of("[prefix] &2Plugin wurde erfolgreich neu geladen."));
|
||||
put(T2C_LanguageEnum.english, List.of("[prefix] &2Plugin was successfully reloaded."));
|
||||
}}, new HashMap<>() {{
|
||||
put(T2C_LanguageEnum.german, List.of());
|
||||
put(T2C_LanguageEnum.english, List.of());
|
||||
}}),
|
||||
noPermissionForCommand("plugin.forCommand", null, new HashMap<>() {{
|
||||
put(T2C_LanguageEnum.german, List.of("[prefix] &cF[ue]r &b[cmd] &cfehlt dir die Permission &6[perm]&c!"));
|
||||
put(T2C_LanguageEnum.english, List.of("[prefix] &cFor &b[cmd] &cyou lack the permission &6[perm]&c!"));
|
||||
}}, new HashMap<>() {{
|
||||
put(T2C_LanguageEnum.german, List.of());
|
||||
put(T2C_LanguageEnum.english, List.of());
|
||||
}}),
|
||||
;
|
||||
private final String path;
|
||||
private Object value;
|
||||
private final HashMap<T2C_LanguageEnum, List<String>> lang;
|
||||
private final HashMap<T2C_LanguageEnum, List<String>> comments;
|
||||
|
||||
VALUES(String path, Object value, @NonNull HashMap<T2C_LanguageEnum, List<String>> lang, HashMap<T2C_LanguageEnum, List<String>> comments) {
|
||||
this.path = path;
|
||||
this.value = value;
|
||||
this.lang = lang;
|
||||
this.comments = comments;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPath() {
|
||||
return path;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getValue() {
|
||||
if (value == null) {
|
||||
return lang.get(T2C_LanguageEnum.english);
|
||||
} else return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HashMap<T2C_LanguageEnum, List<String>> getLanguage() {
|
||||
return lang;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HashMap<T2C_LanguageEnum, List<String>> getComments() {
|
||||
return comments;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setValue(Object newValue) {
|
||||
value = newValue;
|
||||
}
|
||||
}
|
||||
|
||||
public static void set(boolean isReload) {
|
||||
convert(isReload);
|
||||
T2C_LanguageWriter.createConfig(Util.getPrefix(), Main.getPath(), T2CLibLanguages.VALUES.values(), T2C_LibConfig.VALUES.language.getValue().toString(), isReload, Util.getConfigLogo());
|
||||
}
|
||||
|
||||
private static void convert(boolean isReload) {
|
||||
File f = new File(Main.getPath() + "/languages/");
|
||||
File[] fileArray = f.listFiles();
|
||||
if (fileArray == null) return;
|
||||
|
||||
for (File file : fileArray) {
|
||||
String sub = file.getName().substring(file.getName().length() - 4);
|
||||
if (sub.equals(".yml")) {
|
||||
if (file.getName().contains("_messages")) {
|
||||
File nf = new File(file.getName().replace("_messages", ""));
|
||||
if (file.renameTo(nf)) {
|
||||
YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(nf);
|
||||
VALUES.reloadStart.setValue(yamlConfiguration.getString("Plugin.Reload.Start"));
|
||||
VALUES.reloadEnd.setValue(yamlConfiguration.getString("Plugin.Reload.End"));
|
||||
VALUES.noPermissionForCommand.setValue(yamlConfiguration.getString("Plugin.ForCommand"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,25 +0,0 @@
|
||||
// This claas was created by JaTiTV
|
||||
|
||||
// -----------------------------
|
||||
// _____ _____ _ _ _____
|
||||
// / ____/ ____| | | |_ _|
|
||||
// | | | | __| | | | | |
|
||||
// | | | | |_ | | | | | |
|
||||
// | |___| |__| | |__| |_| |_
|
||||
// \_____\_____|\____/|_____|
|
||||
// -----------------------------
|
||||
|
||||
package net.t2code.autoresponse.Spigot.config.languages;
|
||||
|
||||
public class MSG {
|
||||
|
||||
// EN
|
||||
protected static String EN_ReloadStart = "[prefix] &6Plugin is reloaded...";
|
||||
protected static String EN_ReloadEnd = "[prefix] &2Plugin was successfully reloaded.";
|
||||
protected static String EN_NoPermissionForCommand = "[prefix] &cFor &b[cmd] &cyou lack the permission &6[perm]&c!";
|
||||
|
||||
// DE
|
||||
protected static String DE_ReloadStart = "[prefix] &6Plugin wird neu geladen...";
|
||||
protected static String DE_ReloadEnd = "[prefix] &2Plugin wurde erfolgreich neu geladen.";
|
||||
protected static String DE_NoPermissionForCommand = "[prefix] &cF[ue]r &b[cmd] &cfehlt dir die Permission &6[perm]&c!";
|
||||
}
|
@ -1,51 +0,0 @@
|
||||
package net.t2code.autoresponse.Spigot.config.languages;
|
||||
|
||||
import net.t2code.autoresponse.Util;
|
||||
import net.t2code.autoresponse.Spigot.config.config.SelectConfig;
|
||||
import net.t2code.autoresponse.Spigot.Main;
|
||||
import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend;
|
||||
import net.t2code.t2codelib.SPIGOT.api.yaml.T2Cconfig;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class SelectMessages {
|
||||
private static String prefix = Util.getPrefix();
|
||||
|
||||
public static String selectMSG;
|
||||
|
||||
public static String OnlyForPlayer;
|
||||
public static String ReloadStart;
|
||||
public static String ReloadEnd;
|
||||
|
||||
public static String NoPermissionForCommand;
|
||||
public static String AliasDisabled;
|
||||
|
||||
|
||||
public static void onSelect(String Prefix) {
|
||||
|
||||
T2Csend.debug(Main.getPlugin(), "§4Select language...");
|
||||
long long_ = System.currentTimeMillis();
|
||||
|
||||
File msg;
|
||||
|
||||
msg = new File(Main.getPath(), "languages/" + SelectConfig.language + "_messages.yml");
|
||||
if (!msg.isFile()) {
|
||||
T2Csend.console(Prefix);
|
||||
T2Csend.console(Prefix + " §4!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
|
||||
T2Csend.console(Prefix + " §4The selected §c" + SelectConfig.language + " §4language file was not found.");
|
||||
T2Csend.console(Prefix + " §6The default language §eEnglish §6is used!");
|
||||
T2Csend.console(Prefix + " §4!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
|
||||
T2Csend.console(Prefix);
|
||||
msg = new File(Main.getPath(), "languages/" + "english_messages.yml");
|
||||
selectMSG = "english";
|
||||
} else selectMSG = SelectConfig.language;
|
||||
YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(msg);
|
||||
|
||||
ReloadStart = T2Cconfig.select(prefix, "Plugin.Reload.Start", yamlConfiguration);
|
||||
ReloadEnd = T2Cconfig.select(prefix, "Plugin.Reload.End", yamlConfiguration);
|
||||
NoPermissionForCommand = T2Cconfig.select(prefix, "Plugin.ForCommand", yamlConfiguration);
|
||||
|
||||
T2Csend.console(Prefix + " §2Language successfully selected to: §6" + selectMSG + " §7- §e" + (System.currentTimeMillis() - long_) + "ms");
|
||||
}
|
||||
}
|
@ -1,60 +0,0 @@
|
||||
package net.t2code.autoresponse.Spigot.config.response;
|
||||
|
||||
import net.t2code.autoresponse.Util;
|
||||
import net.t2code.autoresponse.Spigot.Main;
|
||||
import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend;
|
||||
import net.t2code.t2codelib.SPIGOT.api.yaml.T2Cconfig;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
|
||||
public class CreateExampleResponse {
|
||||
|
||||
public static void configCreate() {
|
||||
long long_ = System.currentTimeMillis();
|
||||
if (new File(Main.getPath(), "config.yml").exists()) {
|
||||
if (Main.getPlugin().getConfig().getBoolean("Plugin.Debug")) T2Csend.console(Util.getPrefix() + " §5DEBUG: §6" + " §4config.yml are created / updated...");
|
||||
} else T2Csend.console(Util.getPrefix() + " §4config.yml are created...");
|
||||
|
||||
|
||||
File config = new File(Main.getPath(), "Responses/responseexample.yml");
|
||||
YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(config);
|
||||
|
||||
T2Cconfig.set("Response.Enable", true, yamlConfiguration);
|
||||
T2Cconfig.set("Response.ResponseKeys", Collections.singletonList(".example"), yamlConfiguration);
|
||||
T2Cconfig.set("Response.Contains", false, yamlConfiguration);
|
||||
T2Cconfig.set("Response.BlockKeyMessage", true, yamlConfiguration);
|
||||
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);
|
||||
T2Cconfig.set("Response.Command.Commands", Collections.singletonList("say hi"), yamlConfiguration);
|
||||
|
||||
T2Cconfig.set("Response.Message.Enable", true, yamlConfiguration);
|
||||
T2Cconfig.set("Response.Message.Global.Enable", false, yamlConfiguration);
|
||||
T2Cconfig.set("Response.Message.Global.Bungee", false, yamlConfiguration);
|
||||
T2Cconfig.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);
|
||||
|
||||
T2Cconfig.set("Response.Protection.GameMode.Enable", false, yamlConfiguration);
|
||||
T2Cconfig.set("Response.Protection.GameMode.Mode", "blacklist", yamlConfiguration);
|
||||
T2Cconfig.set("Response.Protection.GameMode.List", Arrays.asList("CREATIVE","SPECTATOR"), yamlConfiguration);
|
||||
T2Cconfig.set("Response.Protection.World.Enable", false, yamlConfiguration);
|
||||
T2Cconfig.set("Response.Protection.World.Mode", "blacklist", yamlConfiguration);
|
||||
T2Cconfig.set("Response.Protection.World.List", Arrays.asList("World1","World2"), yamlConfiguration);
|
||||
|
||||
try {
|
||||
yamlConfiguration.save(config);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
T2Csend.console(Util.getPrefix() + " §2config.yml were successfully created / updated." + " §7- §e" + (System.currentTimeMillis() - long_) + "ms");
|
||||
}
|
||||
}
|
@ -0,0 +1,270 @@
|
||||
// This class was created by JaTiTV.
|
||||
|
||||
package net.t2code.autoresponse.Spigot.config.response;
|
||||
|
||||
import net.t2code.autoresponse.Spigot.Main;
|
||||
import net.t2code.autoresponse.Spigot.config.config.Config;
|
||||
import net.t2code.autoresponse.Spigot.objects.ResponsesObject;
|
||||
import net.t2code.autoresponse.Util;
|
||||
import net.t2code.t2codelib.SPIGOT.api.yaml.T2C_ConfigWriter;
|
||||
import net.t2code.t2codelib.SPIGOT.system.T2C_Main;
|
||||
import net.t2code.t2codelib.util.T2C_ConfigItem;
|
||||
import net.t2code.t2codelib.util.T2C_LanguageEnum;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
public class ResponseFile {
|
||||
public enum VALUES implements T2C_ConfigItem {
|
||||
enable("response.enable", true, true, new HashMap<>() {{
|
||||
put(T2C_LanguageEnum.german, List.of("In dieser Option kannst du die Sprache des Plugins einstellen."));
|
||||
put(T2C_LanguageEnum.english, List.of("In this option you can set the language of the plugin."));
|
||||
}}),
|
||||
responseKeys("response.responseKeys", List.of(".example"), true, new HashMap<>() {{
|
||||
put(T2C_LanguageEnum.german, List.of());
|
||||
put(T2C_LanguageEnum.english, List.of());
|
||||
}}),
|
||||
contains("response.contains", false, true, new HashMap<>() {{
|
||||
put(T2C_LanguageEnum.german, List.of());
|
||||
put(T2C_LanguageEnum.english, List.of());
|
||||
}}),
|
||||
blockKeyMessage("response.blockKeyMessage", true, true, new HashMap<>() {{
|
||||
put(T2C_LanguageEnum.german, List.of());
|
||||
put(T2C_LanguageEnum.english, List.of());
|
||||
}}),
|
||||
permNecessary("response.permission.necessary", true, true, new HashMap<>() {{
|
||||
put(T2C_LanguageEnum.german, List.of());
|
||||
put(T2C_LanguageEnum.english, List.of());
|
||||
}}),
|
||||
permission("response.permission.permission", "t2c-autoresponse.response.example", true, new HashMap<>() {{
|
||||
put(T2C_LanguageEnum.german, List.of());
|
||||
put(T2C_LanguageEnum.english, List.of());
|
||||
}}),
|
||||
delayInTicks("response.response.delayInTicks", 0, true, new HashMap<>() {{
|
||||
put(T2C_LanguageEnum.german, List.of());
|
||||
put(T2C_LanguageEnum.english, List.of());
|
||||
}}),
|
||||
delayAsync("response.response.async", true, true, new HashMap<>() {{
|
||||
put(T2C_LanguageEnum.german, List.of());
|
||||
put(T2C_LanguageEnum.english, List.of());
|
||||
}}),
|
||||
commandEnable("response.command.enable", false, true, new HashMap<>() {{
|
||||
put(T2C_LanguageEnum.german, List.of());
|
||||
put(T2C_LanguageEnum.english, List.of());
|
||||
}}),
|
||||
commandAsConsole("response.command.commandAsConsole", false, true, new HashMap<>() {{
|
||||
put(T2C_LanguageEnum.german, List.of());
|
||||
put(T2C_LanguageEnum.english, List.of());
|
||||
}}),
|
||||
bungeeCommand("response.command.proxyCommand", false, true, new HashMap<>() {{
|
||||
put(T2C_LanguageEnum.german, List.of());
|
||||
put(T2C_LanguageEnum.english, List.of());
|
||||
}}),
|
||||
command("response.command.commands", List.of("say hi"), true, new HashMap<>() {{
|
||||
put(T2C_LanguageEnum.german, List.of());
|
||||
put(T2C_LanguageEnum.english, List.of());
|
||||
}}),
|
||||
messageEnable("response.message.enable", true, true, new HashMap<>() {{
|
||||
put(T2C_LanguageEnum.german, List.of());
|
||||
put(T2C_LanguageEnum.english, List.of());
|
||||
}}),
|
||||
messageGlobalServer("response.message.global.enable", false, true, new HashMap<>() {{
|
||||
put(T2C_LanguageEnum.german, List.of());
|
||||
put(T2C_LanguageEnum.english, List.of());
|
||||
}}),
|
||||
messageGlobalProxy("response.message.global.proxy", false, true, new HashMap<>() {{
|
||||
put(T2C_LanguageEnum.german, List.of());
|
||||
put(T2C_LanguageEnum.english, List.of());
|
||||
}}),
|
||||
messages("response.message.messages", List.of("[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>"), true, new HashMap<>() {{
|
||||
put(T2C_LanguageEnum.german, List.of());
|
||||
put(T2C_LanguageEnum.english, List.of());
|
||||
}}),
|
||||
protectionGameModeEnable("response.protection.gameMode.enable", false, true, new HashMap<>() {{
|
||||
put(T2C_LanguageEnum.german, List.of());
|
||||
put(T2C_LanguageEnum.english, List.of());
|
||||
}}),
|
||||
protectionGameModeMode("response.protection.gameMode.mode", "blacklist", true, new HashMap<>() {{
|
||||
put(T2C_LanguageEnum.german, List.of());
|
||||
put(T2C_LanguageEnum.english, List.of());
|
||||
}}),
|
||||
protectionGameModeList("response.protection.gameMode.list", List.of("CREATIVE", "SPECTATOR"), true, new HashMap<>() {{
|
||||
put(T2C_LanguageEnum.german, List.of());
|
||||
put(T2C_LanguageEnum.english, List.of());
|
||||
}}),
|
||||
protectionWorldEnable("response.protection.world.enable", false, true, new HashMap<>() {{
|
||||
put(T2C_LanguageEnum.german, List.of());
|
||||
put(T2C_LanguageEnum.english, List.of());
|
||||
}}),
|
||||
protectionWorldMode("response.protection.world.mode", "blacklist", true, new HashMap<>() {{
|
||||
put(T2C_LanguageEnum.german, List.of());
|
||||
put(T2C_LanguageEnum.english, List.of());
|
||||
}}),
|
||||
protectionWorldList("response.protection.world.list", List.of("World1", "World2"), true, new HashMap<>() {{
|
||||
put(T2C_LanguageEnum.german, List.of());
|
||||
put(T2C_LanguageEnum.english, List.of());
|
||||
}}),
|
||||
|
||||
|
||||
;
|
||||
|
||||
private final String path;
|
||||
private Object value;
|
||||
private final boolean forceSet;
|
||||
private final HashMap<T2C_LanguageEnum, List<String>> comments;
|
||||
|
||||
VALUES(String path, Object value, boolean forceSet, HashMap<T2C_LanguageEnum, List<String>> comments) {
|
||||
this.path = path;
|
||||
this.value = value;
|
||||
this.forceSet = forceSet;
|
||||
this.comments = comments;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPath() {
|
||||
return path;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getForceSet() {
|
||||
return forceSet;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HashMap<T2C_LanguageEnum, List<String>> getComments() {
|
||||
return comments;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getLanguagePath() {
|
||||
return Config.VALUES.language.getValue().toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setValue(Object newValue) {
|
||||
value = newValue;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static void set(boolean isReload) {
|
||||
File of = new File(Main.getPath() + "/Responses/");
|
||||
if (of.exists()){
|
||||
convert(isReload);
|
||||
}
|
||||
|
||||
Main.allResponses.clear();
|
||||
Main.allResponse.clear();
|
||||
File f = new File(Main.getPath() + "/responses/");
|
||||
File[] fileArray = f.listFiles();
|
||||
if (fileArray == null) {
|
||||
T2C_ConfigWriter.createConfig(Util.getPrefix(), new File(Main.getPath(), "/responses/responseExample.yml"), VALUES.values(), isReload, Util.getConfigLogo());
|
||||
}
|
||||
|
||||
for (File file : fileArray) {
|
||||
String sub = file.getName().substring(file.getName().length() - 4);
|
||||
if (sub.equals(".yml")) {
|
||||
T2C_ConfigWriter.createConfig(Util.getPrefix(), new File(Main.getPath(), "/responses/" + file.getName()), VALUES.values(), isReload, Util.getConfigLogo());
|
||||
ResponsesObject response = new ResponsesObject(
|
||||
(boolean) VALUES.enable.value,
|
||||
(List<String>) VALUES.responseKeys.value,
|
||||
(boolean) VALUES.contains.value,
|
||||
(boolean) VALUES.blockKeyMessage.value,
|
||||
(boolean) VALUES.permNecessary.value,
|
||||
VALUES.permission.value.toString(),
|
||||
(int) VALUES.delayInTicks.value,
|
||||
(boolean) VALUES.delayAsync.value,
|
||||
(boolean) VALUES.commandEnable.value,
|
||||
(boolean) VALUES.commandAsConsole.value,
|
||||
(boolean) VALUES.bungeeCommand.value,
|
||||
(List<String>) VALUES.command.value,
|
||||
(boolean) VALUES.messageEnable.value,
|
||||
(boolean) VALUES.messageGlobalServer.value,
|
||||
(boolean) VALUES.messageGlobalProxy.value,
|
||||
(List<String>) VALUES.messages.value,
|
||||
(boolean) VALUES.protectionGameModeEnable.value,
|
||||
VALUES.protectionGameModeMode.value.toString(),
|
||||
(List<String>) VALUES.protectionGameModeList.value,
|
||||
(boolean) VALUES.protectionWorldEnable.value,
|
||||
VALUES.protectionWorldMode.value.toString(),
|
||||
(List<String>) VALUES.protectionWorldList.value
|
||||
);
|
||||
Main.allResponses.add(response);
|
||||
Main.allResponse.addAll((List<String>) VALUES.responseKeys.value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void convert(boolean isReload) {
|
||||
File x = new File(Main.getPath() + "/Responses/");
|
||||
x.renameTo(new File(Main.getPath() + "/oldResponses/"));
|
||||
|
||||
File f = new File(Main.getPath() + "/oldResponses/");
|
||||
File[] fileArray = f.listFiles();
|
||||
if (fileArray == null) return;
|
||||
for (File file : fileArray) {
|
||||
String sub = file.getName().substring(file.getName().length() - 4);
|
||||
if (sub.equals(".yml")) {
|
||||
YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(file);
|
||||
|
||||
ResponseFile.VALUES.enable.setValue(yamlConfiguration.getBoolean("Response.Enable"));
|
||||
ResponseFile.VALUES.responseKeys.setValue(yamlConfiguration.getStringList("Response.ResponseKeys"));
|
||||
ResponseFile.VALUES.contains.setValue(yamlConfiguration.getBoolean("Response.Contains"));
|
||||
|
||||
ResponseFile.VALUES.blockKeyMessage.setValue(yamlConfiguration.getBoolean("Response.BlockKeyMessage"));
|
||||
ResponseFile.VALUES.permNecessary.setValue(yamlConfiguration.getBoolean("Response.Permission.Necessary"));
|
||||
ResponseFile.VALUES.permission.setValue(yamlConfiguration.getString("Response.Permission.Permission"));
|
||||
|
||||
ResponseFile.VALUES.delayInTicks.setValue(yamlConfiguration.getInt("Response.Response.DelayInTicks"));
|
||||
ResponseFile.VALUES.delayAsync.setValue(yamlConfiguration.getBoolean("Response.Response.Async"));
|
||||
|
||||
ResponseFile.VALUES.commandEnable.setValue(yamlConfiguration.getBoolean("Response.Command.Enable"));
|
||||
ResponseFile.VALUES.commandAsConsole.setValue(yamlConfiguration.getBoolean("Response.Command.CommandAsConsole"));
|
||||
ResponseFile.VALUES.bungeeCommand.setValue(yamlConfiguration.getBoolean("Response.Command.BungeeCommand"));
|
||||
ResponseFile.VALUES.command.setValue(yamlConfiguration.getStringList("Response.Command.Commands"));
|
||||
|
||||
ResponseFile.VALUES.messageEnable.setValue(yamlConfiguration.getBoolean("Response.Message.Enable"));
|
||||
ResponseFile.VALUES.messageGlobalServer.setValue(yamlConfiguration.getBoolean("Response.Message.Global.Enable"));
|
||||
ResponseFile.VALUES.messageGlobalProxy.setValue(yamlConfiguration.getBoolean("Response.Message.Global.Bungee"));
|
||||
ResponseFile.VALUES.messages.setValue(yamlConfiguration.getStringList("Response.Message.Messages"));
|
||||
|
||||
ResponseFile.VALUES.protectionGameModeEnable.setValue(yamlConfiguration.getBoolean("Response.Protection.GameMode.Enable"));
|
||||
ResponseFile.VALUES.protectionGameModeMode.setValue(yamlConfiguration.getString("Response.Protection.GameMode.Mode"));
|
||||
ResponseFile.VALUES.protectionGameModeList.setValue(yamlConfiguration.getStringList("Response.Protection.GameMode.List"));
|
||||
ResponseFile.VALUES.protectionWorldEnable.setValue(yamlConfiguration.getBoolean("Response.Protection.World.Enable"));
|
||||
ResponseFile.VALUES.protectionWorldMode.setValue(yamlConfiguration.getString("Response.Protection.World.Mode"));
|
||||
ResponseFile.VALUES.protectionWorldList.setValue(yamlConfiguration.getStringList("Response.Protection.World.List"));
|
||||
T2C_ConfigWriter.createConfig(Util.getPrefix(), new File(Main.getPath(), "/responses/" + file.getName()), VALUES.values(), isReload, Util.getConfigLogo());
|
||||
|
||||
}
|
||||
}
|
||||
File[] fileArray2 = f.listFiles();
|
||||
if (fileArray2 == null) return;
|
||||
Path directory = Paths.get(Main.getPath() + "/oldResponses/");
|
||||
try {
|
||||
Files.walk(directory)
|
||||
.sorted(Comparator.reverseOrder())
|
||||
.forEach(path -> {
|
||||
try {
|
||||
Files.delete(path);
|
||||
} catch (IOException e) {
|
||||
System.err.println("Error when deleting " + path + ": " + e.getMessage());
|
||||
}
|
||||
});
|
||||
} catch (IOException e) {
|
||||
System.err.println("Error when going through the directory: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
@ -1,54 +0,0 @@
|
||||
package net.t2code.autoresponse.Spigot.config.response;
|
||||
|
||||
import net.t2code.autoresponse.Util;
|
||||
import net.t2code.autoresponse.Spigot.objects.ResponsesObject;
|
||||
import net.t2code.autoresponse.Spigot.Main;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class SelectResponses {
|
||||
private static String Prefix = Util.getPrefix();
|
||||
public static void onSelect() {
|
||||
Main.allResponses.clear();
|
||||
Main.allResponse.clear();
|
||||
File f = new File(Main.getPath() + "/Responses/");
|
||||
File[] fileArray = f.listFiles();
|
||||
for (File config_gui : fileArray) {
|
||||
String sub = config_gui.getName().substring(config_gui.getName().length() - 4);
|
||||
if (sub.equals(".yml")) {
|
||||
YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(config_gui);
|
||||
ResponsesObject response = new ResponsesObject(
|
||||
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"),
|
||||
yamlConfiguration.getStringList("Response.Command.Commands"),
|
||||
|
||||
yamlConfiguration.getBoolean("Response.Message.Enable"),
|
||||
yamlConfiguration.getBoolean("Response.Message.Global.Enable"),
|
||||
yamlConfiguration.getBoolean("Response.Message.Global.Bungee"),
|
||||
yamlConfiguration.getStringList("Response.Message.Messages"),
|
||||
|
||||
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.addAll(yamlConfiguration.getStringList("Response.ResponseKeys"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,16 +1,16 @@
|
||||
package net.t2code.autoresponse.Spigot.event;
|
||||
|
||||
import net.t2code.autoresponse.Spigot.Main;
|
||||
import net.t2code.autoresponse.Spigot.config.config.SelectConfig;
|
||||
import net.t2code.autoresponse.Spigot.config.config.Config;
|
||||
import net.t2code.autoresponse.Spigot.objects.ResponsesObject;
|
||||
import net.t2code.autoresponse.Spigot.system.BCommand_Sender_Reciver;
|
||||
import net.t2code.autoresponse.Spigot.system.BungeeSend;
|
||||
import net.t2code.autoresponse.Spigot.system.ProxyCommandSenderReciver;
|
||||
import net.t2code.autoresponse.Spigot.system.ProxySend;
|
||||
import net.t2code.autoresponse.Util;
|
||||
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 net.t2code.t2codelib.SPIGOT.api.commands.T2C_Cmd;
|
||||
import net.t2code.t2codelib.SPIGOT.api.messages.T2C_Replace;
|
||||
import net.t2code.t2codelib.SPIGOT.api.messages.T2C_Send;
|
||||
import net.t2code.t2codelib.SPIGOT.api.plugins.T2C_PluginCheck;
|
||||
import net.t2code.t2codelib.SPIGOT.system.config.config.T2C_LibConfig;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
@ -30,12 +30,12 @@ public class ResponseListener implements Listener {
|
||||
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 (responseKey.contains(SelectConfig.keywordSeperation)) {
|
||||
String[] key = responseKey.split(SelectConfig.keywordSeperation);
|
||||
if (responseKey.contains(Config.VALUES.keywordSeparation.getValue().toString())) {
|
||||
String[] key = responseKey.split(Config.VALUES.keywordSeparation.getValue().toString());
|
||||
boolean allContains = false;
|
||||
for (String s : key) {
|
||||
if (e.getMessage().toLowerCase().contains(s.toLowerCase())) {
|
||||
@ -100,25 +100,25 @@ public class ResponseListener implements Listener {
|
||||
if (response.commandEnable) {
|
||||
for (String cmd : response.command) {
|
||||
if (response.bungeeCommand) {
|
||||
if (T2CLibConfig.getBungee()) {
|
||||
if ((boolean) T2C_LibConfig.VALUES.proxy.getValue()) {
|
||||
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);
|
||||
ProxyCommandSenderReciver.sendToBungee(player, cmd.replace("[player]", player.getName()), ProxySend.BUNGEECOMMAND);
|
||||
} else ProxyCommandSenderReciver.sendToBungee(player, cmd.replace("[player]", player.getName()), ProxySend.COMMAND);
|
||||
} else {
|
||||
T2Csend.console(Util.getPrefix() + " §4To use bungee commands, enable the Bungee option in the config.");
|
||||
T2Csend.sender(player, Util.getPrefix() + " §4To use bungee commands, enable the Bungee option in the config.");
|
||||
T2C_Send.console(Util.getPrefix() + " §4To use bungee commands, enable the Bungee option in the config.");
|
||||
T2C_Send.sender(player, Util.getPrefix() + " §4To use bungee commands, enable the Bungee option in the config.");
|
||||
}
|
||||
} else {
|
||||
if (response.commandAsConsole) {
|
||||
new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
T2Ccmd.console(cmd.replace("[player]", player.getName()));
|
||||
T2C_Cmd.console(cmd.replace("[player]", player.getName()));
|
||||
}
|
||||
}.runTaskLater(Main.getPlugin(), 1L);
|
||||
|
||||
} else {
|
||||
T2Ccmd.player(player, cmd.replace("[player]", player.getName()));
|
||||
T2C_Cmd.player(player, cmd.replace("[player]", player.getName()));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -126,26 +126,26 @@ public class ResponseListener implements Listener {
|
||||
if (response.messageEnable) {
|
||||
for (String msg : response.messages) {
|
||||
String text;
|
||||
if (T2CpluginCheck.papi()) {
|
||||
text = T2Creplace.replace(Util.getPrefix(), player, msg);
|
||||
if (T2C_PluginCheck.papi()) {
|
||||
text = T2C_Replace.replace(Util.getPrefix(), player, msg);
|
||||
} else {
|
||||
text = T2Creplace.replace(Util.getPrefix(), msg);
|
||||
text = T2C_Replace.replace(Util.getPrefix(), msg);
|
||||
}
|
||||
if (response.messageGlobal) {
|
||||
if (response.messageGlobalBungee) {
|
||||
BCommand_Sender_Reciver.sendToBungee(player, text, BungeeSend.ALLPLAYERMSG);
|
||||
ProxyCommandSenderReciver.sendToBungee(player, text, ProxySend.ALLPLAYERMSG);
|
||||
} else {
|
||||
for (Player player1 : Bukkit.getOnlinePlayers()) {
|
||||
T2Csend.player(player1, text);
|
||||
T2C_Send.player(player1, text);
|
||||
}
|
||||
}
|
||||
} else T2Csend.player(player, text);
|
||||
} else T2C_Send.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);
|
||||
if ((boolean) Config.VALUES.logConsole.getValue()) T2C_Send.console(Util.getPrefix() + " §6Player: §e" + player.getName() + " §6use AutoResponse: §e" + responseKey);
|
||||
}
|
||||
}
|
||||
|
@ -4,7 +4,7 @@ package net.t2code.autoresponse.Spigot.system;
|
||||
|
||||
import net.t2code.autoresponse.Spigot.Main;
|
||||
import net.t2code.autoresponse.Util;
|
||||
import net.t2code.t2codelib.SPIGOT.api.update.T2CupdateAPI;
|
||||
import net.t2code.t2codelib.SPIGOT.api.update.T2C_UpdateAPI;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
@ -18,6 +18,6 @@ public class JoinEvent implements Listener {
|
||||
return;
|
||||
}
|
||||
Player player = event.getPlayer();
|
||||
T2CupdateAPI.join(Main.getPlugin(), Util.getPrefix(),Permissions.updatemsg,player,Util.getSpigotID(), Util.getDiscord());
|
||||
T2C_UpdateAPI.join(Main.getPlugin(), Util.getPrefix(),Permissions.updatemsg,player,Util.getSpigotID(), Util.getDiscord());
|
||||
}
|
||||
}
|
@ -1,50 +1,44 @@
|
||||
package net.t2code.autoresponse.Spigot.system;
|
||||
|
||||
import net.t2code.autoresponse.Spigot.Main;
|
||||
import net.t2code.autoresponse.Spigot.config.config.Config;
|
||||
import net.t2code.autoresponse.Spigot.config.languages.Languages;
|
||||
import net.t2code.autoresponse.Spigot.config.response.ResponseFile;
|
||||
import net.t2code.autoresponse.Util;
|
||||
import net.t2code.autoresponse.Spigot.cmdManagement.CmdExecuter;
|
||||
import net.t2code.autoresponse.Spigot.config.config.CreateConfig;
|
||||
import net.t2code.autoresponse.Spigot.config.config.SelectConfig;
|
||||
import net.t2code.autoresponse.Spigot.config.languages.CreateMessages;
|
||||
import net.t2code.autoresponse.Spigot.config.languages.SelectMessages;
|
||||
import net.t2code.autoresponse.Spigot.config.response.CreateExampleResponse;
|
||||
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 net.t2code.t2codelib.SPIGOT.api.messages.T2C_Template;
|
||||
import net.t2code.t2codelib.SPIGOT.api.update.T2C_UpdateAPI;
|
||||
import net.t2code.t2codelib.SPIGOT.system.config.config.T2C_LibConfig;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class Load {
|
||||
static Main plugin = Main.getPlugin();
|
||||
public static void onLoad(String prefix, List<String> autor, String version, String spigot, int spigotID, String discord, int bstatsID) {
|
||||
Long long_ = T2Ctemplate.onLoadHeader(prefix, autor, version, spigot, discord);
|
||||
plugin.getCommand("t2code-autoresponse").setExecutor( new CmdExecuter());
|
||||
|
||||
loadReload();
|
||||
T2CupdateAPI.onUpdateCheck(plugin, prefix,Util.getGit(), spigotID, discord,
|
||||
SelectConfig.updateCheckOnJoin,SelectConfig.updateCheckSeePreReleaseUpdates,SelectConfig.updateCheckTimeInterval);
|
||||
public static void onLoad(String prefix, List<String> autor, String version, String spigot, int spigotID, String discord, int bstatsID) {
|
||||
Long long_ = T2C_Template.onLoadHeader(prefix, autor, version, spigot, discord);
|
||||
plugin.getCommand("t2code-autoresponse").setExecutor(new CmdExecuter());
|
||||
|
||||
loadReload(false);
|
||||
T2C_UpdateAPI.onUpdateCheck(plugin, prefix, Util.getGit(), spigotID, discord,
|
||||
(boolean) Config.VALUES.updateCheckOnJoin.getValue(), (boolean) Config.VALUES.updateCheckSeePreReleaseUpdates.getValue(), (int) Config.VALUES.updateCheckTimeInterval.getValue());
|
||||
Bukkit.getServer().getPluginManager().registerEvents(new JoinEvent(), plugin);
|
||||
Bukkit.getServer().getPluginManager().registerEvents(new ResponseListener(), plugin);
|
||||
|
||||
T2Ctemplate.onLoadFooter(prefix, long_,version);
|
||||
T2C_Template.onLoadFooter(prefix, long_);
|
||||
Metrics.Bstats(plugin, bstatsID);
|
||||
if (T2CLibConfig.getBungee()) {
|
||||
if ((boolean) T2C_LibConfig.VALUES.proxy.getValue()) {
|
||||
plugin.getServer().getMessenger().registerOutgoingPluginChannel(plugin, "BungeeCord");
|
||||
Bukkit.getMessenger().registerOutgoingPluginChannel(plugin, "t2car:bungee");
|
||||
}
|
||||
Permissions.register();
|
||||
}
|
||||
|
||||
public static void loadReload() {
|
||||
CreateConfig.configCreate();
|
||||
CreateMessages.langCreate();
|
||||
CreateExampleResponse.configCreate();
|
||||
|
||||
SelectConfig.onSelect();
|
||||
SelectMessages.onSelect(Util.getPrefix());
|
||||
SelectResponses.onSelect();
|
||||
public static void loadReload(boolean isReload) {
|
||||
Config.set(isReload);
|
||||
Languages.set(isReload);
|
||||
ResponseFile.set(isReload);
|
||||
}
|
||||
}
|
||||
|
@ -2,7 +2,7 @@ package net.t2code.autoresponse.Spigot.system;
|
||||
|
||||
import net.t2code.autoresponse.Spigot.Main;
|
||||
import net.t2code.autoresponse.Spigot.objects.ResponsesObject;
|
||||
import net.t2code.t2codelib.SPIGOT.api.register.T2Cregister;
|
||||
import net.t2code.t2codelib.SPIGOT.api.register.T2C_Register;
|
||||
import org.bukkit.permissions.PermissionDefault;
|
||||
|
||||
public class Permissions {
|
||||
@ -15,12 +15,12 @@ public class Permissions {
|
||||
public static final PermissionDefault notOp = PermissionDefault.NOT_OP;
|
||||
|
||||
protected static void register() {
|
||||
T2Cregister.permission(info, op, Main.getPlugin());
|
||||
T2Cregister.permission(updatemsg, op, Main.getPlugin());
|
||||
T2Cregister.permission(admin, op, info, true, Main.getPlugin());
|
||||
T2Cregister.permission(admin, op, updatemsg, true, Main.getPlugin());
|
||||
T2C_Register.permission(info, op, Main.getPlugin());
|
||||
T2C_Register.permission(updatemsg, op, Main.getPlugin());
|
||||
T2C_Register.permission(admin, op, info, true, Main.getPlugin());
|
||||
T2C_Register.permission(admin, op, updatemsg, true, Main.getPlugin());
|
||||
for (ResponsesObject response : Main.allResponses) {
|
||||
T2Cregister.permission(response.permission, op, Main.getPlugin());
|
||||
T2C_Register.permission(response.permission, op, Main.getPlugin());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -9,9 +9,9 @@ import java.io.ByteArrayOutputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
public class BCommand_Sender_Reciver {
|
||||
public class ProxyCommandSenderReciver {
|
||||
|
||||
public static void sendToBungee(CommandSender sender, String information, BungeeSend type) {
|
||||
public static void sendToBungee(CommandSender sender, String information, ProxySend type) {
|
||||
ByteArrayOutputStream stream = new ByteArrayOutputStream();
|
||||
DataOutputStream output = new DataOutputStream(stream);
|
||||
|
@ -1,6 +1,6 @@
|
||||
package net.t2code.autoresponse.Spigot.system;
|
||||
|
||||
public enum BungeeSend {
|
||||
public enum ProxySend {
|
||||
BUNGEECOMMAND,
|
||||
COMMAND,
|
||||
ALLPLAYERMSG
|
@ -1,41 +1,36 @@
|
||||
package net.t2code.autoresponse;
|
||||
|
||||
|
||||
import lombok.Getter;
|
||||
import net.t2code.t2codelib.util.T2C_Util;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
|
||||
public class Util {
|
||||
|
||||
public static String getInfoText() {
|
||||
return "";
|
||||
}
|
||||
private static String requiredT2CodeLibVersion = "15.0";
|
||||
private static String Prefix = "§8[§4T2Code§7-§bAutoResponse§8]";
|
||||
private static Integer SpigotID = 100603;
|
||||
public static String getGit() {
|
||||
return "JaTiTV/T2C-AutoResponse";
|
||||
}
|
||||
private static Integer BstatsID = 14091;
|
||||
private static String Spigot = "https://www.spigotmc.org/resources/" + SpigotID;
|
||||
private static String Discord = "http://dc.t2code.net";
|
||||
@Getter
|
||||
private static final String infoText = "";
|
||||
@Getter
|
||||
private static final String requiredT2CodeLibVersion = "16.7";
|
||||
@Getter
|
||||
private static final String prefix = "§8[§4T2Code§7-§bAutoResponse§8]";
|
||||
@Getter
|
||||
private static final Integer spigotID = 100603;
|
||||
@Getter
|
||||
private static final String Git="JaTiTV/T2C-AutoResponse";
|
||||
@Getter
|
||||
private static final Integer bstatsID = 14091;
|
||||
@Getter
|
||||
private static final String spigot = "https://spigotmc.org/resources/" +spigotID;
|
||||
@Getter
|
||||
private static final String discord = "http://dc.t2code.net";
|
||||
|
||||
public static String getRequiredT2CodeLibVersion() {
|
||||
return requiredT2CodeLibVersion;
|
||||
public static String[] getConfigLogo() {
|
||||
ArrayList<String> arrayList = new ArrayList<>(T2C_Util.getConfigT2CodeLogo());
|
||||
arrayList.addAll(Arrays.asList("", "# Spigot: " + spigot));
|
||||
return arrayList.toArray(new String[0]);
|
||||
}
|
||||
|
||||
public static String getPrefix() {
|
||||
return Prefix;
|
||||
}
|
||||
|
||||
public static Integer getSpigotID() {
|
||||
return SpigotID;
|
||||
}
|
||||
|
||||
public static Integer getBstatsID() {
|
||||
return BstatsID;
|
||||
}
|
||||
|
||||
public static String getSpigot() {
|
||||
return Spigot;
|
||||
}
|
||||
|
||||
public static String getDiscord() {
|
||||
return Discord;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user