Compare commits
No commits in common. "main" and "cronJob" have entirely different histories.
26
pom.xml
26
pom.xml
@ -5,11 +5,8 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>net.t2code</groupId>
|
||||
<artifactId>AutomatedMessages</artifactId>
|
||||
<version>1.3_dev</version>
|
||||
<!--version>VERSION_snapshot-0</version-->
|
||||
<!--version>VERSION_beta-0</version-->
|
||||
<!--version>VERSION_dev-0</version-->
|
||||
<artifactId>T2C-AutomatedMessages</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>T2C-AutomatedMessages</name>
|
||||
@ -20,15 +17,15 @@
|
||||
</properties>
|
||||
|
||||
<build>
|
||||
<finalName>${project.name}_${project.version}</finalName>
|
||||
<finalName>${project.artifactId}_${project.version}</finalName>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.8.1</version>
|
||||
<configuration>
|
||||
<source>11</source>
|
||||
<target>11</target>
|
||||
<source>${java.version}</source>
|
||||
<target>${java.version}</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
@ -77,23 +74,28 @@
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot-api</artifactId>
|
||||
<version>1.21-R0.1-SNAPSHOT</version>
|
||||
<version>1.19.2-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<!-- t2code -->
|
||||
<dependency>
|
||||
<groupId>net.t2code</groupId>
|
||||
<artifactId>T2CodeLib</artifactId>
|
||||
<version>16.7</version>
|
||||
<classifier>dev-24</classifier>
|
||||
<version>13.4</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<!-- https://mvnrepository.com/artifact/org.projectlombok/lombok -->
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>1.18.30</version>
|
||||
<version>1.18.24</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.quartz-scheduler</groupId>
|
||||
<artifactId>quartz</artifactId>
|
||||
<version>2.3.2</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
|
@ -1,10 +1,6 @@
|
||||
package net.t2code.automatedMessages;
|
||||
|
||||
import lombok.Getter;
|
||||
import net.t2code.t2codelib.util.T2C_Util;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
|
||||
public class Util {
|
||||
|
||||
@ -12,13 +8,13 @@ public class Util {
|
||||
private static String infoText = "";
|
||||
|
||||
@Getter
|
||||
private static String requiredT2CodeLibVersion = "16.7";
|
||||
private static String requiredT2CodeLibVersion = "13.4";
|
||||
|
||||
@Getter
|
||||
private static String prefix = "<dark_gray>[<dark_red>T2C</dark_red>-<color:#5cff5c>Automated</color><color:#69d2ff>Messages</color>]</dark_gray>";
|
||||
|
||||
@Getter
|
||||
private static Integer spigotID = 110801;
|
||||
private static Integer spigotID = 0000; //todo
|
||||
|
||||
@Getter
|
||||
private static String git = "JaTiTV/T2C-AutomatedMessages";
|
||||
@ -32,10 +28,4 @@ public class Util {
|
||||
@Getter
|
||||
private static String discord = "http://dc.t2code.net";
|
||||
|
||||
public static String[] getConfigLogo() {
|
||||
ArrayList<String> arrayList = new ArrayList<>(T2C_Util.getConfigT2CodeLogo());
|
||||
arrayList.addAll(Arrays.asList("", "# Spigot: " + spigot));
|
||||
return arrayList.toArray(new String[0]);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -2,8 +2,7 @@
|
||||
|
||||
package net.t2code.automatedMessages.command;
|
||||
|
||||
import net.t2code.automatedMessages.Util;
|
||||
import net.t2code.t2codelib.SPIGOT.api.commands.T2C_Tab;
|
||||
import net.t2code.t2codelib.SPIGOT.api.commands.T2Ctab;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@ -17,10 +16,6 @@ public class CmdExecuter implements CommandExecutor, TabCompleter {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (!sender.hasPermission("t2c.automatedmessages.admin")) {
|
||||
sender.sendMessage(Util.getPrefix() + "§cYou do not have permission for OPSecurity! §7<t2c.automatedmessages.admin>");
|
||||
return false;
|
||||
}
|
||||
if (args.length == 0) {
|
||||
Commands.reload(sender);
|
||||
} else {
|
||||
@ -49,7 +44,7 @@ public class CmdExecuter implements CommandExecutor, TabCompleter {
|
||||
@Override
|
||||
public List<String> onTabComplete(CommandSender sender, Command cmd, String s, String[] args) {
|
||||
List<String> list = new ArrayList<>();
|
||||
T2C_Tab.tab(list,sender,0,args,arg1);
|
||||
T2Ctab.tab(list,sender,0,args,arg1);
|
||||
return list;
|
||||
}
|
||||
}
|
||||
|
@ -2,31 +2,36 @@ package net.t2code.automatedMessages.command;
|
||||
|
||||
import net.t2code.automatedMessages.Util;
|
||||
import net.t2code.automatedMessages.config.Config;
|
||||
import net.t2code.automatedMessages.config.Languages;
|
||||
import net.t2code.automatedMessages.config.Messages;
|
||||
import net.t2code.automatedMessages.config.FileBuild;
|
||||
import net.t2code.automatedMessages.messages.Management;
|
||||
import net.t2code.automatedMessages.system.Main;
|
||||
import net.t2code.t2codelib.SPIGOT.api.messages.T2C_Send;
|
||||
import net.t2code.t2codelib.SPIGOT.api.messages.T2C_Template;
|
||||
import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend;
|
||||
import net.t2code.t2codelib.SPIGOT.api.messages.T2Ctemplate;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class Commands {
|
||||
public static void reload(CommandSender sender) {
|
||||
T2C_Send.console(Languages.VALUES.msgReloadStart.getValue().toString());
|
||||
if (sender instanceof Player) T2C_Send.sender(sender, Languages.VALUES.msgReloadStart.getValue().toString());
|
||||
public static void reload(CommandSender sender) {
|
||||
if (!sender.hasPermission("t2c.automatedmessages.admin")) {
|
||||
sender.sendMessage(Util.getPrefix() + "§cYou do not have permission for OPSecurity! §7<t2c.automatedmessages.admin>");
|
||||
return;
|
||||
}
|
||||
T2Csend.console(Config.msgReloadStart.valueString);
|
||||
if (sender instanceof Player) T2Csend.sender(sender, Config.msgReloadStart.valueString);
|
||||
Management.end();
|
||||
|
||||
Config.set(true);
|
||||
Languages.set(true);
|
||||
Messages.set(true);
|
||||
FileBuild.selectConfig();
|
||||
|
||||
Management.start();
|
||||
if (sender instanceof Player) T2C_Send.sender(sender, Languages.VALUES.msgReloadEnd.getValue().toString());
|
||||
T2C_Send.console(Languages.VALUES.msgReloadEnd.getValue().toString());
|
||||
if (sender instanceof Player) T2Csend.sender(sender, Config.msgReloadEnd.valueString);
|
||||
T2Csend.console(Config.msgReloadEnd.valueString);
|
||||
}
|
||||
|
||||
public static void info(CommandSender sender) {
|
||||
T2C_Template.sendInfo(sender, Main.getPlugin(), Util.getSpigotID(), Util.getDiscord(), Util.getInfoText());
|
||||
if (!sender.hasPermission("t2c.automatedmessages.admin")) {
|
||||
sender.sendMessage(Util.getPrefix() + "§cYou do not have permission for OPSecurity! §7<t2c.automatedmessages.admin>");
|
||||
return;
|
||||
}
|
||||
T2Ctemplate.sendInfo(sender, Main.getPlugin(), Util.getSpigotID(), Util.getDiscord(), Util.getInfoText());
|
||||
}
|
||||
}
|
||||
|
@ -1,115 +1,81 @@
|
||||
package net.t2code.automatedMessages.config;
|
||||
|
||||
import net.t2code.automatedMessages.Util;
|
||||
import net.t2code.automatedMessages.system.Main;
|
||||
import net.t2code.t2codelib.SPIGOT.api.yaml.T2C_ConfigWriter;
|
||||
import net.t2code.t2codelib.util.T2C_ConfigItem;
|
||||
import net.t2code.t2codelib.util.T2C_LanguageEnum;
|
||||
public enum Config {
|
||||
|
||||
import java.io.File;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
updateCheckOnJoin("plugin.updateCheck.onJoin", true, ConfigParam.BOOLEAN),
|
||||
updateCheckSeePreReleaseUpdates("plugin.updateCheck.seePreReleaseUpdates", true, ConfigParam.BOOLEAN),
|
||||
updateCheckTimeInterval("plugin.updateCheck.timeInterval", 60, ConfigParam.INTEGER),
|
||||
|
||||
public class Config {
|
||||
prefix("plugin.prefix", "", ConfigParam.STRING),
|
||||
|
||||
public enum VALUES implements T2C_ConfigItem {
|
||||
language("plugin.language", T2C_LanguageEnum.english, true,
|
||||
new HashMap<>() {{
|
||||
put(T2C_LanguageEnum.german, List.of());
|
||||
put(T2C_LanguageEnum.english, List.of());
|
||||
}}),
|
||||
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());
|
||||
}}),
|
||||
msgReloadStart("plugin.messages.reloadStart", "Reload start", ConfigParam.STRING),
|
||||
msgReloadEnd("plugin.messages.reloadEnd", "Reload end", ConfigParam.STRING),
|
||||
|
||||
prefix("plugin.prefix", "<dark_gray>[<dark_red>T2C</dark_red>-<color:#5cff5c>Automated</color><color:#69d2ff>Messages</color>]</dark_gray>", true,
|
||||
new HashMap<>() {{
|
||||
put(T2C_LanguageEnum.german, List.of());
|
||||
put(T2C_LanguageEnum.english, List.of());
|
||||
}}),
|
||||
sendConsole("plugin.broadcastInConsole", true, true,
|
||||
new HashMap<>() {{
|
||||
put(T2C_LanguageEnum.german, List.of());
|
||||
put(T2C_LanguageEnum.english, List.of());
|
||||
}}),
|
||||
message("messages",
|
||||
"messages.KEY.enable", false,
|
||||
"messages.KEY.message", "",
|
||||
"messages.KEY.intervalInMin", 0,
|
||||
"messages.KEY.useCronJob.enable", false,
|
||||
"messages.KEY.useCronJob.value", "",
|
||||
ConfigParam.MESSAGE
|
||||
);
|
||||
|
||||
timeFormat("plugin.timeFormat", "HH:mm:ss yyyy/MM/dd",true,
|
||||
new HashMap<>() {{
|
||||
put(T2C_LanguageEnum.german, List.of());
|
||||
put(T2C_LanguageEnum.english, List.of());
|
||||
}}),
|
||||
public String path;
|
||||
public String valueString;
|
||||
public Boolean valueBoolean;
|
||||
public Integer valueInteger;
|
||||
|
||||
msgReloadStart("plugin.messages.reloadStart", "[prefix] Reload starting...", true,
|
||||
new HashMap<>() {{
|
||||
put(T2C_LanguageEnum.german, List.of());
|
||||
put(T2C_LanguageEnum.english, List.of());
|
||||
}}),
|
||||
msgReloadEnd("plugin.messages.reloadEnd", "[prefix] Reload successful.", true,
|
||||
new HashMap<>() {{
|
||||
put(T2C_LanguageEnum.german, List.of());
|
||||
put(T2C_LanguageEnum.english, List.of());
|
||||
}}),
|
||||
public String msgPath;
|
||||
public String msgEnablePath;
|
||||
public Boolean msgEnable;
|
||||
|
||||
public String msgMsgPath;
|
||||
public String msgMsg;
|
||||
public String msgIntervalPath;
|
||||
public Integer msgInterval;
|
||||
public String msgCronJobPath;
|
||||
public Boolean msgCronJob;
|
||||
public String msgCronJobStringPath;
|
||||
public String msgCronJobString;
|
||||
|
||||
;
|
||||
public ConfigParam configParam;
|
||||
|
||||
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;
|
||||
}
|
||||
Config(String path, String value, ConfigParam cEnum) {
|
||||
this.path = path;
|
||||
this.valueString = value;
|
||||
this.configParam = cEnum;
|
||||
}
|
||||
|
||||
public static void set(boolean isReload) {
|
||||
T2C_ConfigWriter.createConfig(Util.getPrefix(), new File(Main.getPath(), "config.yml"), VALUES.values(), isReload, Util.getConfigLogo());
|
||||
Config(String path, Integer value, ConfigParam cEnum) {
|
||||
this.path = path;
|
||||
this.valueInteger = value;
|
||||
this.configParam = cEnum;
|
||||
}
|
||||
|
||||
Config(String path, Boolean value, ConfigParam cEnum) {
|
||||
this.path = path;
|
||||
this.valueBoolean = value;
|
||||
this.configParam = cEnum;
|
||||
}
|
||||
|
||||
Config(String msgPath,
|
||||
String msgEnablePath, Boolean msgEnable,
|
||||
String msgMsgPath, String msgMsg,
|
||||
String msgIntervalPath, Integer msgInterval,
|
||||
String msgCronJobPath, Boolean msgCronJob,
|
||||
String msgCronJobStringPath, String msgCronJobString,
|
||||
ConfigParam configParam) {
|
||||
this.msgPath = msgPath;
|
||||
this.msgEnablePath = msgEnablePath;
|
||||
this.msgEnable = msgEnable;
|
||||
this.msgMsgPath = msgMsgPath;
|
||||
this.msgMsg = msgMsg;
|
||||
this.msgIntervalPath = msgIntervalPath;
|
||||
this.msgInterval = msgInterval;
|
||||
this.msgCronJobPath = msgCronJobPath;
|
||||
this.msgCronJob = msgCronJob;
|
||||
this.msgCronJobStringPath = msgCronJobStringPath;
|
||||
this.msgCronJobString = msgCronJobString;
|
||||
this.configParam = configParam;
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,8 @@
|
||||
package net.t2code.automatedMessages.config;
|
||||
|
||||
public enum ConfigParam {
|
||||
STRING,
|
||||
INTEGER,
|
||||
BOOLEAN,
|
||||
MESSAGE
|
||||
}
|
@ -0,0 +1,87 @@
|
||||
package net.t2code.automatedMessages.config;
|
||||
|
||||
import lombok.Getter;
|
||||
import net.t2code.automatedMessages.Util;
|
||||
import net.t2code.automatedMessages.objects.Message;
|
||||
import net.t2code.automatedMessages.system.Main;
|
||||
import net.t2code.t2codelib.SPIGOT.api.messages.T2Creplace;
|
||||
import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
public class FileBuild {
|
||||
|
||||
@Getter
|
||||
private static HashMap<String, Message> messageHashMap = new HashMap<>();
|
||||
|
||||
public static void selectConfig() {
|
||||
|
||||
File config = new File(Main.getPath(), "config.yml");
|
||||
YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(config);
|
||||
messageHashMap.clear();
|
||||
for (Config value : Config.values()) {
|
||||
switch (value.configParam) {
|
||||
case STRING:
|
||||
if (!yamlConfiguration.contains(value.path)) {
|
||||
yamlConfiguration.set(value.path, value.valueString);
|
||||
}
|
||||
value.valueString = T2Creplace.replace(Util.getPrefix(), Objects.requireNonNull(yamlConfiguration.getString(value.path)));
|
||||
break;
|
||||
case BOOLEAN:
|
||||
if (!yamlConfiguration.contains(value.path)) {
|
||||
yamlConfiguration.set(value.path, value.valueBoolean);
|
||||
}
|
||||
value.valueBoolean = yamlConfiguration.getBoolean(value.path);
|
||||
break;
|
||||
|
||||
case INTEGER:
|
||||
if (!yamlConfiguration.contains(value.path)) {
|
||||
yamlConfiguration.set(value.path, value.valueInteger);
|
||||
}
|
||||
value.valueInteger = yamlConfiguration.getInt(value.path);
|
||||
break;
|
||||
|
||||
case MESSAGE:
|
||||
if (!yamlConfiguration.contains(value.msgPath)) {
|
||||
setExample("exampleDiscord", true,
|
||||
"[prefix] <aqua>If you need help, just contact us on our <color:#ffcb2e><hover:show_text:'<red>dc.t2code.net</red>'><click:open_url:'https://discord.t2code.net'>T2Code Support Discord server</click></hover></color>.</aqua>",
|
||||
20, false, "0 0/5 * ? * * *", yamlConfiguration);
|
||||
setExample("exampleTime", true,
|
||||
"[prefix] <aqua>Es ist jetzt <yellow>[time]</yellow></aqua>",
|
||||
0, true, "0 0/20 * ? * * *", yamlConfiguration);
|
||||
}
|
||||
for (String key : yamlConfiguration.getConfigurationSection(value.msgPath).getKeys(false)) {
|
||||
Boolean enable = yamlConfiguration.getBoolean(value.msgEnablePath.replace("KEY", key));
|
||||
String message = yamlConfiguration.getString(value.msgMsgPath.replace("KEY", key));
|
||||
Integer interval = yamlConfiguration.getInt(value.msgIntervalPath.replace("KEY", key));
|
||||
Boolean cronJob = yamlConfiguration.getBoolean(value.msgCronJobPath.replace("KEY", key));
|
||||
String cronJobString = yamlConfiguration.getString(value.msgCronJobStringPath.replace("KEY", key));
|
||||
Message msg = new Message(key, enable, message, interval, cronJob, cronJobString);
|
||||
T2Csend.debugmsg(Main.getPlugin(),key);
|
||||
T2Csend.debugmsg(Main.getPlugin(), String.valueOf(cronJob));
|
||||
T2Csend.debugmsg(Main.getPlugin(),cronJobString);
|
||||
messageHashMap.put(key, msg);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
try {
|
||||
yamlConfiguration.save(config);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private static void setExample(String key, Boolean enable, String msg, Integer interval, Boolean useCronJobEnable, String useCronJobValue,YamlConfiguration yamlConfiguration) {
|
||||
yamlConfiguration.set("messages." + key + ".enable", enable);
|
||||
yamlConfiguration.set("messages." + key + ".message", msg);
|
||||
yamlConfiguration.set("messages." + key + ".intervalInMin", interval);
|
||||
yamlConfiguration.set("messages." + key + ".useCronJob.enable", useCronJobEnable);
|
||||
yamlConfiguration.set("messages." + key + ".useCronJob.value", useCronJobValue);
|
||||
}
|
||||
}
|
@ -1,85 +0,0 @@
|
||||
// This class was created by JaTiTV.
|
||||
|
||||
package net.t2code.automatedMessages.config;
|
||||
|
||||
import net.t2code.automatedMessages.Util;
|
||||
import net.t2code.automatedMessages.system.Main;
|
||||
import net.t2code.t2codelib.SPIGOT.api.yaml.T2C_LanguageWriter;
|
||||
import net.t2code.t2codelib.util.T2C_ConfigItemLanguages;
|
||||
import net.t2code.t2codelib.util.T2C_LanguageEnum;
|
||||
|
||||
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.", ""));
|
||||
}}),
|
||||
msgReloadStart("plugin.reloadStart", null, new HashMap<>() {{
|
||||
put(T2C_LanguageEnum.german, List.of("[prefix] Plugin wird neu geladen..."));
|
||||
put(T2C_LanguageEnum.english, List.of("[prefix] Plugin is reloaded..."));
|
||||
}}, 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.", ""));
|
||||
}}),
|
||||
msgReloadEnd("plugin.reloadEnd", null, new HashMap<>() {{
|
||||
put(T2C_LanguageEnum.german, List.of());
|
||||
put(T2C_LanguageEnum.english, List.of());
|
||||
}}, 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, 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);
|
||||
}
|
||||
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) {
|
||||
T2C_LanguageWriter.createConfig(Util.getPrefix(), Main.getPath(), VALUES.values(), Config.VALUES.language.getValue().toString(), isReload, Util.getConfigLogo());
|
||||
}
|
||||
}
|
@ -1,201 +0,0 @@
|
||||
// This class was created by JaTiTV.
|
||||
|
||||
package net.t2code.automatedMessages.config;
|
||||
|
||||
import lombok.Getter;
|
||||
import net.t2code.automatedMessages.Util;
|
||||
import net.t2code.automatedMessages.objects.Message;
|
||||
import net.t2code.automatedMessages.system.Main;
|
||||
import net.t2code.t2codelib.SPIGOT.api.minecraftVersion.T2C_McVersion;
|
||||
import net.t2code.t2codelib.SPIGOT.api.yaml.T2C_ConfigWriter;
|
||||
import net.t2code.t2codelib.util.T2C_ConfigItem;
|
||||
import net.t2code.t2codelib.util.T2C_LanguageEnum;
|
||||
import org.bukkit.Sound;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
public class Messages {
|
||||
|
||||
@Getter
|
||||
private static HashMap<String, Message> messageHashMap = new HashMap<>();
|
||||
|
||||
public enum VALUES implements T2C_ConfigItem {
|
||||
enable("enable", false, true, new HashMap<>() {{
|
||||
put(T2C_LanguageEnum.german, List.of());
|
||||
put(T2C_LanguageEnum.english, List.of());
|
||||
}}),
|
||||
message("message", "", true, new HashMap<>() {{
|
||||
put(T2C_LanguageEnum.german, List.of());
|
||||
put(T2C_LanguageEnum.english, List.of());
|
||||
}}),
|
||||
soundEnable("sound.enable", true, true, new HashMap<>() {{
|
||||
put(T2C_LanguageEnum.german, List.of());
|
||||
put(T2C_LanguageEnum.english, List.of());
|
||||
}}),
|
||||
sound("sound.sound", sound(), true, new HashMap<>() {{
|
||||
put(T2C_LanguageEnum.german, List.of());
|
||||
put(T2C_LanguageEnum.english, List.of());
|
||||
}}),
|
||||
interval("permissionNeededToSeeMessage.enable", false, true, new HashMap<>() {{
|
||||
put(T2C_LanguageEnum.german, List.of());
|
||||
put(T2C_LanguageEnum.english, List.of());
|
||||
}}),
|
||||
permissionNeededToSeeMessage("permissionNeededToSeeMessage.permission", "", true, new HashMap<>() {{
|
||||
put(T2C_LanguageEnum.german, List.of());
|
||||
put(T2C_LanguageEnum.english, List.of());
|
||||
}}),
|
||||
permission("intervalInMin", 0, true, new HashMap<>() {{
|
||||
put(T2C_LanguageEnum.german, List.of());
|
||||
put(T2C_LanguageEnum.english, List.of());
|
||||
}}),
|
||||
exactTime("exactTime.enable", false, true, new HashMap<>() {{
|
||||
put(T2C_LanguageEnum.german, List.of());
|
||||
put(T2C_LanguageEnum.english, List.of());
|
||||
}}),
|
||||
timeMinute("exactTime.timeMinute", "*/5", true, new HashMap<>() {{
|
||||
put(T2C_LanguageEnum.german, List.of());
|
||||
put(T2C_LanguageEnum.english, List.of());
|
||||
}}),
|
||||
timeHour("exactTime.timeHour", "*", true, new HashMap<>() {{
|
||||
put(T2C_LanguageEnum.german, List.of());
|
||||
put(T2C_LanguageEnum.english, List.of());
|
||||
}}),
|
||||
timeDayOfMonth("exactTime.timeDayOfMonth", "*", true, new HashMap<>() {{
|
||||
put(T2C_LanguageEnum.german, List.of());
|
||||
put(T2C_LanguageEnum.english, List.of());
|
||||
}}),
|
||||
timeMonth("exactTime.timeMonth", "*", true, new HashMap<>() {{
|
||||
put(T2C_LanguageEnum.german, List.of());
|
||||
put(T2C_LanguageEnum.english, List.of());
|
||||
}}),
|
||||
timeDayOfWeek("exactTime.timeDayOfWeek", "*", 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) {
|
||||
messageHashMap.clear();
|
||||
File fo = new File(Main.getPath() + "/Messages/");
|
||||
File f = new File(Main.getPath() + "/messages/");
|
||||
if (!fo.exists()) {
|
||||
try {
|
||||
Files.move(Paths.get(fo.getAbsolutePath()), Paths.get(f.getAbsolutePath()));
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
if (!f.exists()) {
|
||||
createDefault("exampleTime.yml", "[prefix] <aqua>Es ist jetzt <yellow>[time]</yellow></aqua>", sound(), 0, "t2c.automatedmessages.messages.exampletime", true, "0/15/30/45");
|
||||
createDefault("exampleDiscord.yml", "[prefix] <aqua>If you need help, just contact us on our <color:#ffcb2e><hover:show_text:''<red>dc.t2code.net</red>''><click:open_url:''https://discord.t2code.net''>T2Code Support Discord server</click></hover></color>.</aqua>", sound(), 20, "t2c.automatedmessages.messages.examplediscord", false, "*");
|
||||
}
|
||||
|
||||
File[] fileArray = f.listFiles();
|
||||
for (File file : fileArray) {
|
||||
String sub = file.getName().substring(file.getName().length() - 4);
|
||||
if (sub.equals(".yml")) {
|
||||
String key = file.getName().replace(".yml", "");
|
||||
T2C_ConfigWriter.createConfig(Util.getPrefix(), file, VALUES.values(), false, Util.getConfigLogo());
|
||||
|
||||
Boolean enable = (boolean) VALUES.enable.value;
|
||||
String message = VALUES.message.value.toString();
|
||||
Boolean soundEnable = (boolean) VALUES.soundEnable.value;
|
||||
|
||||
Sound sound;
|
||||
try {
|
||||
sound = Sound.valueOf(VALUES.sound.value.toString());
|
||||
} catch (Exception e) {
|
||||
sound = sound();
|
||||
}
|
||||
|
||||
Integer interval = (int) VALUES.interval.value;
|
||||
|
||||
Boolean permissionNeededToSeeMessage = (boolean) VALUES.permissionNeededToSeeMessage.value;
|
||||
String permission = VALUES.permission.value.toString();
|
||||
|
||||
Boolean exactTime = (boolean) VALUES.exactTime.value;
|
||||
String timeMinute = VALUES.timeMinute.value.toString();
|
||||
String timeHour = VALUES.timeHour.value.toString();
|
||||
String timeDayOfMonth = VALUES.timeDayOfMonth.value.toString();
|
||||
String timeMonth = VALUES.timeMonth.value.toString();
|
||||
String timeDayOfWeek = VALUES.timeDayOfWeek.value.toString();
|
||||
Message msg = new Message(key, enable, message, soundEnable, sound, permissionNeededToSeeMessage, permission, interval,
|
||||
exactTime, timeMinute, timeHour, timeDayOfMonth, timeMonth, timeDayOfWeek);
|
||||
messageHashMap.put(key, msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void createDefault(String fileName, String message, Sound sound, Integer interval, String permission, Boolean exactTime, String timeMinute) {
|
||||
VALUES.enable.setValue(true);
|
||||
VALUES.message.setValue(message);
|
||||
VALUES.soundEnable.setValue(true);
|
||||
VALUES.sound.setValue(sound.toString());
|
||||
VALUES.interval.setValue(interval);
|
||||
VALUES.permissionNeededToSeeMessage.setValue(false);
|
||||
VALUES.permission.setValue(permission);
|
||||
VALUES.exactTime.setValue(exactTime);
|
||||
VALUES.timeMinute.setValue(timeMinute);
|
||||
VALUES.timeHour.setValue("*");
|
||||
VALUES.timeDayOfMonth.setValue("*");
|
||||
VALUES.timeMonth.setValue("*");
|
||||
VALUES.timeDayOfWeek.setValue("*");
|
||||
T2C_ConfigWriter.createConfig(Util.getPrefix(), new File(Main.getPath() + "/Messages/" + fileName), VALUES.values(), false, Util.getConfigLogo());
|
||||
}
|
||||
|
||||
private static Sound sound() {
|
||||
if (T2C_McVersion.isMc1_8()) {
|
||||
return Sound.valueOf("NOTE_PIANO");
|
||||
} else if (T2C_McVersion.isMc1_9() || T2C_McVersion.isMc1_10() || T2C_McVersion.isMc1_11() || T2C_McVersion.isMc1_12()) {
|
||||
return Sound.valueOf("BLOCK_NOTE_HARP");
|
||||
} else return Sound.BLOCK_NOTE_BLOCK_HARP;
|
||||
}
|
||||
}
|
@ -1,85 +1,18 @@
|
||||
package net.t2code.automatedMessages.messages;
|
||||
|
||||
import net.t2code.automatedMessages.objects.Message;
|
||||
import net.t2code.automatedMessages.system.Main;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.quartz.Job;
|
||||
import org.quartz.JobExecutionContext;
|
||||
import org.quartz.JobExecutionException;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
public class CronJob implements Job {
|
||||
public Message message;
|
||||
|
||||
public class CronJob {
|
||||
|
||||
private Message message;
|
||||
private Boolean shutdown = false;
|
||||
|
||||
public CronJob(@NotNull Message message) {
|
||||
this.message = message;
|
||||
String minuteString = message.timeMinute;
|
||||
String hourString = message.timeHour;
|
||||
|
||||
if (minuteString.contains("*/")) {
|
||||
timer(Integer.valueOf(minuteString.replace("*/", "")), 60);
|
||||
return;
|
||||
}
|
||||
if (hourString.contains("*/")) {
|
||||
timer(Integer.valueOf(hourString.replace("*/", "")), 60 * 60);
|
||||
return;
|
||||
}
|
||||
job();
|
||||
public CronJob(Message message) {
|
||||
this.message=message;
|
||||
}
|
||||
|
||||
private void job() {
|
||||
Bukkit.getScheduler().runTaskTimerAsynchronously(Main.getPlugin(), new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (shutdown) return;
|
||||
executeJob();
|
||||
}
|
||||
}, 0, 60 * 20L);
|
||||
}
|
||||
|
||||
private void executeJob() {
|
||||
LocalDateTime dateTime = LocalDateTime.now();
|
||||
|
||||
if (check(message.timeMinute, dateTime.getMinute(), "minute")) return;
|
||||
if (check(message.timeHour, dateTime.getHour(), "h")) return;
|
||||
if (check(message.timeDayOfMonth, dateTime.getDayOfMonth(), "dom")) return;
|
||||
if (check(message.timeMonth, dateTime.getMonth().getValue(), "mon")) return;
|
||||
if (check(message.timeDayOfWeek, dateTime.getDayOfWeek().getValue(), "dow")) return;
|
||||
|
||||
SendMessage.send(message);
|
||||
}
|
||||
|
||||
private boolean check(@NotNull String check, Integer value, String v) {
|
||||
if (check.equals("*")) return false;
|
||||
if (check.contains("/")) {
|
||||
String[] strings = check.split("/");
|
||||
for (String string : strings) {
|
||||
if (string.equals("*")) return false;
|
||||
if (Integer.parseInt(string) == value) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
try {
|
||||
if (Integer.parseInt(check) == value) return false;
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public void timer(Integer period, Integer value) {
|
||||
Bukkit.getScheduler().scheduleAsyncRepeatingTask(Main.getPlugin(), new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (shutdown) return;
|
||||
SendMessage.send(message);
|
||||
}
|
||||
}, 0, 20L * value * period);
|
||||
}
|
||||
|
||||
public void shutdown() {
|
||||
this.shutdown = true;
|
||||
public void execute(JobExecutionContext context) throws JobExecutionException {
|
||||
SendMessage.send(message.message);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,23 +1,33 @@
|
||||
package net.t2code.automatedMessages.messages;
|
||||
|
||||
import net.t2code.automatedMessages.config.Messages;
|
||||
import net.t2code.automatedMessages.config.FileBuild;
|
||||
import net.t2code.automatedMessages.objects.Message;
|
||||
import net.t2code.automatedMessages.system.Main;
|
||||
import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend;
|
||||
import org.quartz.*;
|
||||
import org.quartz.impl.StdSchedulerFactory;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class Management {
|
||||
|
||||
private static List<Scheduler> jobList = new ArrayList<>();
|
||||
|
||||
public static HashMap<JobDetail, Scheduler> hashMap = new HashMap<>();
|
||||
|
||||
private static final List<Timer> timerJobList = new ArrayList<>();
|
||||
private static final List<CronJob> cronJobs = new ArrayList<>();
|
||||
|
||||
public static void start() {
|
||||
for (Map.Entry<String, Message> value : Messages.getMessageHashMap().entrySet()) {
|
||||
for (Map.Entry<String, Message> value : FileBuild.getMessageHashMap().entrySet()) {
|
||||
Message message = value.getValue();
|
||||
if (!message.enable) continue;
|
||||
if (message.exactTime) {
|
||||
CronJob cronJob = new CronJob(message);
|
||||
cronJobs.add(cronJob);
|
||||
if (message.cronJob) {
|
||||
startCronJob(message);
|
||||
|
||||
|
||||
} else {
|
||||
Timer job = new Timer(message);
|
||||
timerJobList.add(job);
|
||||
@ -25,12 +35,37 @@ public class Management {
|
||||
}
|
||||
}
|
||||
|
||||
public static void startCronJob(Message message) {
|
||||
try {
|
||||
CronJob cronJob = new CronJob(message);
|
||||
JobDetail job = JobBuilder.newJob(cronJob.getClass())
|
||||
.withIdentity(message.key, message.key).build();
|
||||
Trigger trigger = TriggerBuilder.newTrigger()
|
||||
.withIdentity(message.key, message.key)
|
||||
.withSchedule(CronScheduleBuilder.cronSchedule(message.cronJobString))
|
||||
//.withSchedule(CronScheduleBuilder.cronSchedule("0/5 * * * * ?"))
|
||||
.build();
|
||||
Scheduler scheduler = new StdSchedulerFactory().getScheduler();
|
||||
scheduler.start();
|
||||
scheduler.scheduleJob(job, trigger);
|
||||
jobList.add(scheduler);
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static void end() {
|
||||
for (Timer job : timerJobList) {
|
||||
job.disable = true;
|
||||
}
|
||||
for (CronJob cronJob : cronJobs) {
|
||||
cronJob.shutdown();
|
||||
for (Scheduler scheduler : jobList) {
|
||||
try {
|
||||
scheduler.shutdown();
|
||||
} catch (SchedulerException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,50 +1,15 @@
|
||||
package net.t2code.automatedMessages.messages;
|
||||
|
||||
import net.t2code.automatedMessages.config.Config;
|
||||
import net.t2code.automatedMessages.objects.Message;
|
||||
import net.t2code.t2codelib.SPIGOT.api.messages.T2C_Send;
|
||||
import net.t2code.automatedMessages.system.Main;
|
||||
import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
|
||||
public class SendMessage {
|
||||
public static void send(Message message) {
|
||||
String timeStamp = new SimpleDateFormat(Config.VALUES.timeFormat.getValue().toString()).format(Calendar.getInstance().getTime());
|
||||
if ((boolean)Config.VALUES.sendConsole.getValue()) {
|
||||
T2C_Send.console(replace(message.message, Map.entry("[time]", timeStamp), Map.entry("[prefix]", Config.VALUES.prefix.getValue().toString())));
|
||||
}
|
||||
public static void send(String msg){
|
||||
T2Csend.debugmsg(Main.getPlugin(),msg);
|
||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||
if (player.hasPermission(message.permission) || !message.permissionNeededToSeeMessage) {
|
||||
T2C_Send.player(player, replace(message.message, Map.entry("[time]", timeStamp), Map.entry("[prefix]", Config.VALUES.prefix.getValue().toString()), Map.entry("[player]", player.getName())));
|
||||
player.playSound(player.getLocation(), message.sound, 3, 1);
|
||||
}
|
||||
T2Csend.player(player, msg);
|
||||
}
|
||||
}
|
||||
|
||||
@SafeVarargs
|
||||
private static Object replace(Object object, Map.Entry<String, String>... map) {
|
||||
Object o = null;
|
||||
if (object instanceof List) {
|
||||
ArrayList<String> res = (ArrayList<String>) object;
|
||||
ArrayList<String> out = new ArrayList<>();
|
||||
for (String s : res) {
|
||||
String re = s;
|
||||
for (Map.Entry<String, String> placeholder : map) {
|
||||
re = re.replace(placeholder.getKey(), placeholder.getValue());
|
||||
}
|
||||
out.add(re);
|
||||
}
|
||||
o = out;
|
||||
}
|
||||
if (object instanceof String) {
|
||||
String res = (String) object;
|
||||
for (Map.Entry<String, String> placeholder : map) {
|
||||
res = res.replace(placeholder.getKey(), placeholder.getValue());
|
||||
}
|
||||
o = res;
|
||||
}
|
||||
return o;
|
||||
}
|
||||
}
|
||||
|
@ -1,21 +1,20 @@
|
||||
package net.t2code.automatedMessages.messages;
|
||||
|
||||
import net.t2code.automatedMessages.messages.SendMessage;
|
||||
import net.t2code.automatedMessages.objects.Message;
|
||||
import net.t2code.automatedMessages.system.Main;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class Timer {
|
||||
|
||||
public Timer(@NotNull Message message) {
|
||||
public Timer(Message message) {
|
||||
Bukkit.getScheduler().scheduleAsyncRepeatingTask(Main.getPlugin(), new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (disable) return;
|
||||
SendMessage.send(message);
|
||||
SendMessage.send(message.message);
|
||||
}
|
||||
}, 0, 20L * 60 * message.interval);
|
||||
}
|
||||
|
||||
public Boolean disable = false;
|
||||
}
|
||||
|
@ -1,8 +1,5 @@
|
||||
package net.t2code.automatedMessages.objects;
|
||||
|
||||
import org.bukkit.Sound;
|
||||
|
||||
import javax.sound.midi.Soundbank;
|
||||
import java.util.List;
|
||||
|
||||
public class Message {
|
||||
@ -10,49 +7,21 @@ public class Message {
|
||||
public String key;
|
||||
public Boolean enable;
|
||||
public String message;
|
||||
|
||||
public Boolean soundEnable;
|
||||
public Sound sound;
|
||||
public Boolean permissionNeededToSeeMessage;
|
||||
public String permission;
|
||||
public Integer interval;
|
||||
public Boolean exactTime;
|
||||
public String timeMinute;
|
||||
public String timeHour;
|
||||
public String timeDayOfMonth;
|
||||
public String timeMonth;
|
||||
public String timeDayOfWeek;
|
||||
public Boolean cronJob;
|
||||
public String cronJobString;
|
||||
|
||||
public Message(String key,
|
||||
Boolean enable,
|
||||
String message,
|
||||
Boolean soundEnable,
|
||||
Sound sound,
|
||||
Boolean permissionNeededToSeeMessage,
|
||||
String permission,
|
||||
|
||||
Integer interval,
|
||||
|
||||
Boolean exactTime,
|
||||
String timeMinute,
|
||||
String timeHour,
|
||||
String timeDayOfMonth,
|
||||
String timeMonth,
|
||||
String timeDayOfWeek) {
|
||||
Boolean cronJob,
|
||||
String cronJobString) {
|
||||
this.key = key;
|
||||
this.enable = enable;
|
||||
this.message = message;
|
||||
this.soundEnable = soundEnable;
|
||||
this.sound = sound;
|
||||
this.permissionNeededToSeeMessage = permissionNeededToSeeMessage;
|
||||
this.permission = permission;
|
||||
this.interval = interval;
|
||||
this.exactTime = exactTime;
|
||||
this.timeMinute = timeMinute;
|
||||
this.timeHour = timeHour;
|
||||
this.timeDayOfMonth = timeDayOfMonth;
|
||||
this.timeMonth = timeMonth;
|
||||
this.timeDayOfWeek = timeDayOfWeek;
|
||||
|
||||
this.cronJob = cronJob;
|
||||
this.cronJobString=cronJobString;
|
||||
}
|
||||
}
|
||||
|
@ -3,30 +3,26 @@ package net.t2code.automatedMessages.system;
|
||||
import net.t2code.automatedMessages.Util;
|
||||
import net.t2code.automatedMessages.command.CmdExecuter;
|
||||
import net.t2code.automatedMessages.config.Config;
|
||||
import net.t2code.automatedMessages.config.Languages;
|
||||
import net.t2code.automatedMessages.config.Messages;
|
||||
import net.t2code.automatedMessages.config.FileBuild;
|
||||
import net.t2code.automatedMessages.messages.Management;
|
||||
import net.t2code.t2codelib.SPIGOT.api.messages.T2C_Template;
|
||||
import net.t2code.t2codelib.SPIGOT.api.update.T2C_UpdateAPI;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import net.t2code.t2codelib.SPIGOT.api.messages.T2Ctemplate;
|
||||
import net.t2code.t2codelib.SPIGOT.api.update.T2CupdateAPI;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class Load {
|
||||
public static void onLoad(@NotNull Main plugin, List<String> autor, String version) {
|
||||
long long_ = T2C_Template.onLoadHeader(Util.getPrefix(), autor, version, Util.getSpigot(), Util.getDiscord());
|
||||
public static void onLoad(Main plugin, List<String> autor, String version) {
|
||||
long long_ = T2Ctemplate.onLoadHeader(Util.getPrefix(), autor, version, Util.getSpigot(), Util.getDiscord());
|
||||
plugin.getCommand("t2c-automatedmessages").setExecutor(new CmdExecuter());
|
||||
|
||||
Config.set(false);
|
||||
Languages.set(false);
|
||||
Messages.set(false);
|
||||
FileBuild.selectConfig();
|
||||
|
||||
Management.start();
|
||||
|
||||
T2C_UpdateAPI.onUpdateCheck(plugin, Util.getPrefix(), Util.getGit(), Util.getSpigotID(), Util.getDiscord(), (boolean) Config.VALUES.updateCheckOnJoin.getValue(),
|
||||
(boolean) Config.VALUES.updateCheckSeePreReleaseUpdates.getValue(), (int) Config.VALUES.updateCheckTimeInterval.getValue());
|
||||
T2CupdateAPI.onUpdateCheck(plugin, Util.getPrefix(),Util.getGit(),Util.getSpigotID(),Util.getDiscord(), Config.updateCheckOnJoin.valueBoolean,
|
||||
Config.updateCheckSeePreReleaseUpdates.valueBoolean, Config.updateCheckTimeInterval.valueInteger);
|
||||
Metrics.Bstats(plugin, Util.getBstatsID());
|
||||
T2C_Template.onLoadFooter(Util.getPrefix(), long_);
|
||||
T2Ctemplate.onLoadFooter(Util.getPrefix(), long_);
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -2,12 +2,9 @@ package net.t2code.automatedMessages.system;
|
||||
|
||||
import lombok.Getter;
|
||||
import net.t2code.automatedMessages.Util;
|
||||
import net.t2code.t2codelib.SPIGOT.api.messages.T2C_Send;
|
||||
import net.t2code.t2codelib.SPIGOT.api.messages.T2C_Template;
|
||||
import net.t2code.t2codelib.SPIGOT.api.messages.T2Ctemplate;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.jetbrains.annotations.Contract;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
@ -15,8 +12,7 @@ import java.util.logging.Level;
|
||||
|
||||
public final class Main extends JavaPlugin {
|
||||
|
||||
@Contract(pure = true)
|
||||
public static @NotNull File getPath() {
|
||||
public static File getPath() {
|
||||
return plugin.getDataFolder();
|
||||
}
|
||||
|
||||
@ -43,10 +39,10 @@ public final class Main extends JavaPlugin {
|
||||
@Override
|
||||
public void onDisable() {
|
||||
// Plugin shutdown logic
|
||||
if (t2codeLib) T2C_Template.onDisable(Util.getPrefix(),plugin);
|
||||
if (t2codeLib) T2Ctemplate.onDisable(Util.getPrefix(), autor, version, Util.getSpigot(), Util.getDiscord());
|
||||
}
|
||||
|
||||
private static @NotNull Boolean pluginNotFound(String pl, Integer spigotID, String ver) {
|
||||
private static Boolean pluginNotFound(String pl, Integer spigotID, String ver) {
|
||||
if (Bukkit.getPluginManager().getPlugin(pl) == null) {
|
||||
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: "
|
||||
@ -78,7 +74,4 @@ public final class Main extends JavaPlugin {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
public static void sendTryCatch(Class c, StackTraceElement line) {
|
||||
T2C_Send.error(plugin,c.getName() + " Line: " + line.getLineNumber());
|
||||
}
|
||||
}
|
||||
|
@ -1,18 +1,13 @@
|
||||
name: '${project.name}'
|
||||
name: '${project.artifactId}'
|
||||
version: '${project.version}'
|
||||
prefix: "[T2C-AutomatedMessages]"
|
||||
main: net.t2code.automatedMessages.system.Main
|
||||
api-version: 1.13
|
||||
softdepend: [ T2CodeLib ]
|
||||
authors: [ JaTiTV ]
|
||||
website: https://www.spigotmc.org/resources/110801/
|
||||
commands:
|
||||
t2c-automatedmessages:
|
||||
description: T2C-AutomatedMessages Main Command.
|
||||
aliases:
|
||||
- automatedmessages
|
||||
- amsg
|
||||
|
||||
permissions:
|
||||
t2c.automatedmessages.admin:
|
||||
default: op
|
Loading…
Reference in New Issue
Block a user