Compare commits
6 Commits
Author | SHA1 | Date | |
---|---|---|---|
2aedb22959 | |||
60cd82ef1f | |||
ea4fb0b88d | |||
b9d20ffb06 | |||
4501fe550c | |||
d172ea3607 |
20
pom.xml
20
pom.xml
@ -5,8 +5,11 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>net.t2code</groupId>
|
||||
<artifactId>T2C-AutomatedMessages</artifactId>
|
||||
<version>0.1.3-BETA</version>
|
||||
<artifactId>AutomatedMessages</artifactId>
|
||||
<version>1.3_dev</version>
|
||||
<!--version>VERSION_snapshot-0</version-->
|
||||
<!--version>VERSION_beta-0</version-->
|
||||
<!--version>VERSION_dev-0</version-->
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>T2C-AutomatedMessages</name>
|
||||
@ -17,15 +20,15 @@
|
||||
</properties>
|
||||
|
||||
<build>
|
||||
<finalName>${project.artifactId}_${project.version}</finalName>
|
||||
<finalName>${project.name}_${project.version}</finalName>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<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>
|
||||
@ -74,21 +77,22 @@
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot-api</artifactId>
|
||||
<version>1.19.2-R0.1-SNAPSHOT</version>
|
||||
<version>1.21-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<!-- t2code -->
|
||||
<dependency>
|
||||
<groupId>net.t2code</groupId>
|
||||
<artifactId>T2CodeLib</artifactId>
|
||||
<version>13.4</version>
|
||||
<version>16.7</version>
|
||||
<classifier>dev-24</classifier>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<!-- https://mvnrepository.com/artifact/org.projectlombok/lombok -->
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>1.18.24</version>
|
||||
<version>1.18.30</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
@ -1,6 +1,10 @@
|
||||
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 {
|
||||
|
||||
@ -8,13 +12,13 @@ public class Util {
|
||||
private static String infoText = "";
|
||||
|
||||
@Getter
|
||||
private static String requiredT2CodeLibVersion = "13.4";
|
||||
private static String requiredT2CodeLibVersion = "16.7";
|
||||
|
||||
@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 = 0000; //todo
|
||||
private static Integer spigotID = 110801;
|
||||
|
||||
@Getter
|
||||
private static String git = "JaTiTV/T2C-AutomatedMessages";
|
||||
@ -28,4 +32,10 @@ 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,7 +2,8 @@
|
||||
|
||||
package net.t2code.automatedMessages.command;
|
||||
|
||||
import net.t2code.t2codelib.SPIGOT.api.commands.T2Ctab;
|
||||
import net.t2code.automatedMessages.Util;
|
||||
import net.t2code.t2codelib.SPIGOT.api.commands.T2C_Tab;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@ -16,6 +17,10 @@ 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 {
|
||||
@ -44,7 +49,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<>();
|
||||
T2Ctab.tab(list,sender,0,args,arg1);
|
||||
T2C_Tab.tab(list,sender,0,args,arg1);
|
||||
return list;
|
||||
}
|
||||
}
|
||||
|
@ -2,36 +2,31 @@ package net.t2code.automatedMessages.command;
|
||||
|
||||
import net.t2code.automatedMessages.Util;
|
||||
import net.t2code.automatedMessages.config.Config;
|
||||
import net.t2code.automatedMessages.config.FileBuild;
|
||||
import net.t2code.automatedMessages.config.Languages;
|
||||
import net.t2code.automatedMessages.config.Messages;
|
||||
import net.t2code.automatedMessages.messages.Management;
|
||||
import net.t2code.automatedMessages.system.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 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);
|
||||
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());
|
||||
Management.end();
|
||||
|
||||
FileBuild.selectConfig();
|
||||
Config.set(true);
|
||||
Languages.set(true);
|
||||
Messages.set(true);
|
||||
|
||||
Management.start();
|
||||
if (sender instanceof Player) T2Csend.sender(sender, Config.msgReloadEnd.valueString);
|
||||
T2Csend.console(Config.msgReloadEnd.valueString);
|
||||
if (sender instanceof Player) T2C_Send.sender(sender, Languages.VALUES.msgReloadEnd.getValue().toString());
|
||||
T2C_Send.console(Languages.VALUES.msgReloadEnd.getValue().toString());
|
||||
}
|
||||
|
||||
public static void info(CommandSender sender) {
|
||||
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());
|
||||
T2C_Template.sendInfo(sender, Main.getPlugin(), Util.getSpigotID(), Util.getDiscord(), Util.getInfoText());
|
||||
}
|
||||
}
|
||||
|
@ -1,149 +1,115 @@
|
||||
package net.t2code.automatedMessages.config;
|
||||
|
||||
import org.bukkit.Sound;
|
||||
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", "<dark_gray>[<dark_red>T2C</dark_red>-<color:#5cff5c>Automated</color><color:#69d2ff>Messages</color>]</dark_gray>", ConfigParam.STRING),
|
||||
sendConsole("plugin.broadcastInConsole", true, ConfigParam.BOOLEAN),
|
||||
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());
|
||||
}}),
|
||||
|
||||
timeFormat("plugin.timeFormat", "HH:mm:ss yyyy/MM/dd", 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());
|
||||
}}),
|
||||
|
||||
msgReloadStart("plugin.messages.reloadStart", "Reload start", ConfigParam.STRING),
|
||||
msgReloadEnd("plugin.messages.reloadEnd", "Reload end", ConfigParam.STRING),
|
||||
timeFormat("plugin.timeFormat", "HH:mm:ss yyyy/MM/dd",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.sound.enable", true,
|
||||
"messages.KEY.sound.sound", FileBuild.sound(),
|
||||
"messages.KEY.permissionNeededToSeeMessage.enable", false,
|
||||
"messages.KEY.permissionNeededToSeeMessage.permission", "",
|
||||
"messages.KEY.intervalInMin", 0,
|
||||
"messages.KEY.exactTime.enable", false,
|
||||
"messages.KEY.exactTime.timeMinute", "*/5",
|
||||
"messages.KEY.exactTime.timeHour", "*",
|
||||
"messages.KEY.exactTime.timeDayOfMonth", "*",
|
||||
"messages.KEY.exactTime.timeMonth", "*",
|
||||
"messages.KEY.exactTime.timeDayOfWeek", "*",
|
||||
ConfigParam.MESSAGE
|
||||
);
|
||||
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 path;
|
||||
public String valueString;
|
||||
public Boolean valueBoolean;
|
||||
public Integer valueInteger;
|
||||
;
|
||||
|
||||
public String msgPath;
|
||||
public String msgEnablePath;
|
||||
public Boolean msgEnable;
|
||||
private final String path;
|
||||
private Object value;
|
||||
private final boolean forceSet;
|
||||
private final HashMap<T2C_LanguageEnum, List<String>> comments;
|
||||
|
||||
public String msgMsgPath;
|
||||
public String msgMsg;
|
||||
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;
|
||||
}
|
||||
|
||||
public String soundEnablePath;
|
||||
public Boolean soundEnable;
|
||||
@Override
|
||||
public String getPath() {
|
||||
return path;
|
||||
}
|
||||
|
||||
public String soundPath;
|
||||
public Sound sound;
|
||||
@Override
|
||||
public Object getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public String permissionNeededToSeeMessagePath;
|
||||
public Boolean permissionNeededToSeeMessage;
|
||||
@Override
|
||||
public boolean getForceSet() {
|
||||
return forceSet;
|
||||
}
|
||||
|
||||
public String permissionPath;
|
||||
public String permission;
|
||||
@Override
|
||||
public HashMap<T2C_LanguageEnum, List<String>> getComments() {
|
||||
return comments;
|
||||
}
|
||||
|
||||
public String msgIntervalPath;
|
||||
public Integer msgInterval;
|
||||
@Override
|
||||
public String getLanguagePath() {
|
||||
return language.path;
|
||||
}
|
||||
|
||||
public String exactTimePath;
|
||||
public Boolean exactTime;
|
||||
|
||||
public String timeMinutePath;
|
||||
public String timeMinute;
|
||||
|
||||
public String timeHourPath;
|
||||
public String timeHour;
|
||||
|
||||
public String timeDayOfMonthPath;
|
||||
public String timeDayOfMonth;
|
||||
|
||||
public String timeMonthPath;
|
||||
public String timeMonth;
|
||||
|
||||
public String timeDayOfWeekPath;
|
||||
public String timeDayOfWeek;
|
||||
|
||||
public ConfigParam configParam;
|
||||
|
||||
Config(String path, String value, ConfigParam cEnum) {
|
||||
this.path = path;
|
||||
this.valueString = value;
|
||||
this.configParam = cEnum;
|
||||
@Override
|
||||
public void setValue(Object newValue) {
|
||||
value = newValue;
|
||||
}
|
||||
}
|
||||
|
||||
Config(String path, Integer value, ConfigParam cEnum) {
|
||||
this.path = path;
|
||||
this.valueInteger = 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, 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 soundEnablePath, Boolean soundEnable,
|
||||
String soundPath, Sound sound,
|
||||
String permissionNeededToSeeMessagePath, Boolean permissionNeededToSeeMessage,
|
||||
String permissionPath, String permission,
|
||||
String msgIntervalPath, Integer msgInterval,
|
||||
String exactTimePath, Boolean exactTime, String timeMinutePath, String timeMinute,
|
||||
String timeHourPath, String timeHour,
|
||||
String timeDayOfMonthPath, String timeDayOfMonth,
|
||||
String timeMonthPath, String timeMonth,
|
||||
String timeDayOfWeekPath, String timeDayOfWeek,
|
||||
ConfigParam configParam) {
|
||||
this.msgPath = msgPath;
|
||||
this.msgEnablePath = msgEnablePath;
|
||||
this.msgEnable = msgEnable;
|
||||
this.msgMsgPath = msgMsgPath;
|
||||
this.msgMsg = msgMsg;
|
||||
|
||||
this.soundEnablePath = soundEnablePath;
|
||||
this.soundEnable = soundEnable;
|
||||
this.soundPath = soundPath;
|
||||
this.sound = sound;
|
||||
|
||||
this.permissionNeededToSeeMessagePath = permissionNeededToSeeMessagePath;
|
||||
this.permissionNeededToSeeMessage = permissionNeededToSeeMessage;
|
||||
this.permissionPath = permissionPath;
|
||||
this.permission = permission;
|
||||
|
||||
this.msgIntervalPath = msgIntervalPath;
|
||||
this.msgInterval = msgInterval;
|
||||
this.exactTimePath = exactTimePath;
|
||||
this.exactTime = exactTime;
|
||||
this.timeMinutePath = timeMinutePath;
|
||||
this.timeMinute = timeMinute;
|
||||
this.timeHourPath = timeHourPath;
|
||||
this.timeHour = timeHour;
|
||||
|
||||
this.timeDayOfMonthPath = timeDayOfMonthPath;
|
||||
this.timeDayOfMonth = timeDayOfMonth;
|
||||
this.timeMonthPath = timeMonthPath;
|
||||
this.timeMonth = timeMonth;
|
||||
this.timeDayOfWeekPath = timeDayOfWeekPath;
|
||||
this.timeDayOfWeek = timeDayOfWeek;
|
||||
this.configParam = configParam;
|
||||
}
|
||||
}
|
||||
|
@ -1,8 +0,0 @@
|
||||
package net.t2code.automatedMessages.config;
|
||||
|
||||
public enum ConfigParam {
|
||||
STRING,
|
||||
INTEGER,
|
||||
BOOLEAN,
|
||||
MESSAGE
|
||||
}
|
@ -1,122 +0,0 @@
|
||||
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.minecraftVersion.T2CmcVersion;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
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>",
|
||||
true, sound(), false, "t2c.automatedmessages.messages.examplediscord", 20,
|
||||
false, "*", "*", "*", "*", "*", yamlConfiguration);
|
||||
setExample("exampleTime", true,
|
||||
"[prefix] <aqua>Es ist jetzt <yellow>[time]</yellow></aqua>",
|
||||
true, sound(), false, "t2c.automatedmessages.messages.exampletime", 0,
|
||||
true, "0/15/30/45", "*", "*", "*", "*", 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));
|
||||
Boolean soundEnable = yamlConfiguration.getBoolean(value.soundEnablePath.replace("KEY", key));
|
||||
|
||||
Sound sound;
|
||||
try {
|
||||
sound = Sound.valueOf(yamlConfiguration.getString(value.soundPath.replace("KEY", key)));
|
||||
} catch (Exception e) {
|
||||
sound = sound();
|
||||
}
|
||||
|
||||
|
||||
Integer interval = yamlConfiguration.getInt(value.msgIntervalPath.replace("KEY", key));
|
||||
|
||||
Boolean permissionNeededToSeeMessage = yamlConfiguration.getBoolean(value.permissionNeededToSeeMessagePath.replace("KEY", key));
|
||||
String permission = yamlConfiguration.getString(value.permissionPath.replace("KEY", key));
|
||||
|
||||
Boolean exactTime = yamlConfiguration.getBoolean(value.exactTimePath.replace("KEY", key));
|
||||
String timeMinute = yamlConfiguration.getString(value.timeMinutePath.replace("KEY", key));
|
||||
String timeHour = yamlConfiguration.getString(value.timeHourPath.replace("KEY", key));
|
||||
String timeDayOfMonth = yamlConfiguration.getString(value.timeDayOfMonthPath.replace("KEY", key));
|
||||
String timeMonth = yamlConfiguration.getString(value.timeMonthPath.replace("KEY", key));
|
||||
String timeDayOfWeek = yamlConfiguration.getString(value.timeDayOfWeekPath.replace("KEY", key));
|
||||
Message msg = new Message(key, enable, message, soundEnable, sound, permissionNeededToSeeMessage, permission, interval,
|
||||
exactTime, timeMinute, timeHour, timeDayOfMonth, timeMonth, timeDayOfWeek);
|
||||
messageHashMap.put(key, msg);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
try {
|
||||
yamlConfiguration.save(config);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
static Sound sound() {
|
||||
if (T2CmcVersion.isMc1_8()) {
|
||||
return Sound.valueOf("NOTE_PIANO");
|
||||
} else if (T2CmcVersion.isMc1_9() || T2CmcVersion.isMc1_10() || T2CmcVersion.isMc1_11() || T2CmcVersion.isMc1_12()) {
|
||||
return Sound.valueOf("BLOCK_NOTE_HARP");
|
||||
} else return Sound.BLOCK_NOTE_BLOCK_HARP;
|
||||
}
|
||||
|
||||
private static void setExample(String key, Boolean enable, String msg, Boolean soundEnable, Sound sound, Boolean permissionNeededToSeeMessage, String permission, Integer interval, Boolean exactTime, String timeMinute, String timeHour, String timeDayOfMonth,
|
||||
String timeMonth, String timeDayOfWeek, YamlConfiguration yamlConfiguration) {
|
||||
yamlConfiguration.set("messages." + key + ".enable", enable);
|
||||
yamlConfiguration.set("messages." + key + ".message", msg);
|
||||
yamlConfiguration.set("messages." + key + ".sound.enable", soundEnable);
|
||||
yamlConfiguration.set("messages." + key + ".sound.sound", sound.toString());
|
||||
yamlConfiguration.set("messages." + key + ".permissionNeededToSeeMessage.enable", permissionNeededToSeeMessage);
|
||||
yamlConfiguration.set("messages." + key + ".permissionNeededToSeeMessage.permission", permission);
|
||||
yamlConfiguration.set("messages." + key + ".intervalInMin", interval);
|
||||
yamlConfiguration.set("messages." + key + ".exactTime.enable", exactTime);
|
||||
yamlConfiguration.set("messages." + key + ".exactTime.timeMinute", timeMinute);
|
||||
yamlConfiguration.set("messages." + key + ".exactTime.timeHour", timeHour);
|
||||
yamlConfiguration.set("messages." + key + ".exactTime.timeDayOfMonth", timeDayOfMonth);
|
||||
yamlConfiguration.set("messages." + key + ".exactTime.timeMonth", timeMonth);
|
||||
yamlConfiguration.set("messages." + key + ".exactTime.timeDayOfWeek", timeDayOfWeek);
|
||||
}
|
||||
}
|
@ -0,0 +1,85 @@
|
||||
// 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());
|
||||
}
|
||||
}
|
201
src/main/java/net/t2code/automatedMessages/config/Messages.java
Normal file
201
src/main/java/net/t2code/automatedMessages/config/Messages.java
Normal file
@ -0,0 +1,201 @@
|
||||
// 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;
|
||||
}
|
||||
}
|
@ -2,8 +2,8 @@ package net.t2code.automatedMessages.messages;
|
||||
|
||||
import net.t2code.automatedMessages.objects.Message;
|
||||
import net.t2code.automatedMessages.system.Main;
|
||||
import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@ -12,7 +12,7 @@ public class CronJob {
|
||||
private Message message;
|
||||
private Boolean shutdown = false;
|
||||
|
||||
public CronJob(Message message) {
|
||||
public CronJob(@NotNull Message message) {
|
||||
this.message = message;
|
||||
String minuteString = message.timeMinute;
|
||||
String hourString = message.timeHour;
|
||||
@ -50,7 +50,7 @@ public class CronJob {
|
||||
SendMessage.send(message);
|
||||
}
|
||||
|
||||
private boolean check(String check, Integer value, String v) {
|
||||
private boolean check(@NotNull String check, Integer value, String v) {
|
||||
if (check.equals("*")) return false;
|
||||
if (check.contains("/")) {
|
||||
String[] strings = check.split("/");
|
||||
|
@ -1,6 +1,6 @@
|
||||
package net.t2code.automatedMessages.messages;
|
||||
|
||||
import net.t2code.automatedMessages.config.FileBuild;
|
||||
import net.t2code.automatedMessages.config.Messages;
|
||||
import net.t2code.automatedMessages.objects.Message;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@ -12,7 +12,7 @@ public class Management {
|
||||
private static final List<CronJob> cronJobs = new ArrayList<>();
|
||||
|
||||
public static void start() {
|
||||
for (Map.Entry<String, Message> value : FileBuild.getMessageHashMap().entrySet()) {
|
||||
for (Map.Entry<String, Message> value : Messages.getMessageHashMap().entrySet()) {
|
||||
Message message = value.getValue();
|
||||
if (!message.enable) continue;
|
||||
if (message.exactTime) {
|
||||
|
@ -2,22 +2,49 @@ package net.t2code.automatedMessages.messages;
|
||||
|
||||
import net.t2code.automatedMessages.config.Config;
|
||||
import net.t2code.automatedMessages.objects.Message;
|
||||
import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend;
|
||||
import net.t2code.t2codelib.SPIGOT.api.messages.T2C_Send;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
import java.util.*;
|
||||
|
||||
public class SendMessage {
|
||||
public static void send(Message message) {
|
||||
String timeStamp = new SimpleDateFormat(Config.timeFormat.valueString).format(Calendar.getInstance().getTime());
|
||||
if (Config.sendConsole.valueBoolean) T2Csend.console(message.message.replace("[time]", timeStamp).replace("[prefix]",Config.prefix.valueString));
|
||||
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())));
|
||||
}
|
||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||
if (player.hasPermission(message.permission) || !message.permissionNeededToSeeMessage){
|
||||
T2Csend.player(player, message.message.replace("[time]", timeStamp).replace("[prefix]",Config.prefix.valueString));
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@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,17 +1,13 @@
|
||||
package net.t2code.automatedMessages.messages;
|
||||
|
||||
import net.t2code.automatedMessages.config.Config;
|
||||
import net.t2code.automatedMessages.messages.SendMessage;
|
||||
import net.t2code.automatedMessages.objects.Message;
|
||||
import net.t2code.automatedMessages.system.Main;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class Timer {
|
||||
|
||||
public Timer(Message message) {
|
||||
public Timer(@NotNull Message message) {
|
||||
Bukkit.getScheduler().scheduleAsyncRepeatingTask(Main.getPlugin(), new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
@ -3,26 +3,30 @@ 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.FileBuild;
|
||||
import net.t2code.automatedMessages.config.Languages;
|
||||
import net.t2code.automatedMessages.config.Messages;
|
||||
import net.t2code.automatedMessages.messages.Management;
|
||||
import net.t2code.t2codelib.SPIGOT.api.messages.T2Ctemplate;
|
||||
import net.t2code.t2codelib.SPIGOT.api.update.T2CupdateAPI;
|
||||
import net.t2code.t2codelib.SPIGOT.api.messages.T2C_Template;
|
||||
import net.t2code.t2codelib.SPIGOT.api.update.T2C_UpdateAPI;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class Load {
|
||||
public static void onLoad(Main plugin, List<String> autor, String version) {
|
||||
long long_ = T2Ctemplate.onLoadHeader(Util.getPrefix(), autor, version, Util.getSpigot(), Util.getDiscord());
|
||||
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());
|
||||
plugin.getCommand("t2c-automatedmessages").setExecutor(new CmdExecuter());
|
||||
|
||||
FileBuild.selectConfig();
|
||||
Config.set(false);
|
||||
Languages.set(false);
|
||||
Messages.set(false);
|
||||
|
||||
Management.start();
|
||||
|
||||
T2CupdateAPI.onUpdateCheck(plugin, Util.getPrefix(),Util.getGit(),Util.getSpigotID(),Util.getDiscord(), Config.updateCheckOnJoin.valueBoolean,
|
||||
Config.updateCheckSeePreReleaseUpdates.valueBoolean, Config.updateCheckTimeInterval.valueInteger);
|
||||
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());
|
||||
Metrics.Bstats(plugin, Util.getBstatsID());
|
||||
T2Ctemplate.onLoadFooter(Util.getPrefix(), long_);
|
||||
T2C_Template.onLoadFooter(Util.getPrefix(), long_);
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -2,9 +2,12 @@ package net.t2code.automatedMessages.system;
|
||||
|
||||
import lombok.Getter;
|
||||
import net.t2code.automatedMessages.Util;
|
||||
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.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;
|
||||
@ -12,7 +15,8 @@ import java.util.logging.Level;
|
||||
|
||||
public final class Main extends JavaPlugin {
|
||||
|
||||
public static File getPath() {
|
||||
@Contract(pure = true)
|
||||
public static @NotNull File getPath() {
|
||||
return plugin.getDataFolder();
|
||||
}
|
||||
|
||||
@ -39,10 +43,10 @@ public final class Main extends JavaPlugin {
|
||||
@Override
|
||||
public void onDisable() {
|
||||
// Plugin shutdown logic
|
||||
if (t2codeLib) T2Ctemplate.onDisable(Util.getPrefix(), autor, version, Util.getSpigot(), Util.getDiscord());
|
||||
if (t2codeLib) T2C_Template.onDisable(Util.getPrefix(),plugin);
|
||||
}
|
||||
|
||||
private static Boolean pluginNotFound(String pl, Integer spigotID, String ver) {
|
||||
private static @NotNull 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: "
|
||||
@ -74,4 +78,7 @@ 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,13 +1,18 @@
|
||||
name: '${project.artifactId}'
|
||||
name: '${project.name}'
|
||||
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
|
||||
- amsg
|
||||
|
||||
permissions:
|
||||
t2c.automatedmessages.admin:
|
||||
default: op
|
Loading…
Reference in New Issue
Block a user