Compare commits
No commits in common. "main" and "1.1" have entirely different histories.
13
pom.xml
13
pom.xml
@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
<groupId>net.t2code</groupId>
|
<groupId>net.t2code</groupId>
|
||||||
<artifactId>AutomatedMessages</artifactId>
|
<artifactId>AutomatedMessages</artifactId>
|
||||||
<version>1.3_dev</version>
|
<version>1.1</version>
|
||||||
<!--version>VERSION_snapshot-0</version-->
|
<!--version>VERSION_snapshot-0</version-->
|
||||||
<!--version>VERSION_beta-0</version-->
|
<!--version>VERSION_beta-0</version-->
|
||||||
<!--version>VERSION_dev-0</version-->
|
<!--version>VERSION_dev-0</version-->
|
||||||
@ -27,8 +27,8 @@
|
|||||||
<artifactId>maven-compiler-plugin</artifactId>
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
<version>3.8.1</version>
|
<version>3.8.1</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<source>11</source>
|
<source>${java.version}</source>
|
||||||
<target>11</target>
|
<target>${java.version}</target>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
<plugin>
|
||||||
@ -77,22 +77,21 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.spigotmc</groupId>
|
<groupId>org.spigotmc</groupId>
|
||||||
<artifactId>spigot-api</artifactId>
|
<artifactId>spigot-api</artifactId>
|
||||||
<version>1.21-R0.1-SNAPSHOT</version>
|
<version>1.20-R0.1-SNAPSHOT</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!-- t2code -->
|
<!-- t2code -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>net.t2code</groupId>
|
<groupId>net.t2code</groupId>
|
||||||
<artifactId>T2CodeLib</artifactId>
|
<artifactId>T2CodeLib</artifactId>
|
||||||
<version>16.7</version>
|
<version>15.3</version>
|
||||||
<classifier>dev-24</classifier>
|
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!-- https://mvnrepository.com/artifact/org.projectlombok/lombok -->
|
<!-- https://mvnrepository.com/artifact/org.projectlombok/lombok -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.projectlombok</groupId>
|
<groupId>org.projectlombok</groupId>
|
||||||
<artifactId>lombok</artifactId>
|
<artifactId>lombok</artifactId>
|
||||||
<version>1.18.30</version>
|
<version>1.18.24</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
@ -1,10 +1,6 @@
|
|||||||
package net.t2code.automatedMessages;
|
package net.t2code.automatedMessages;
|
||||||
|
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import net.t2code.t2codelib.util.T2C_Util;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Arrays;
|
|
||||||
|
|
||||||
public class Util {
|
public class Util {
|
||||||
|
|
||||||
@ -12,7 +8,7 @@ public class Util {
|
|||||||
private static String infoText = "";
|
private static String infoText = "";
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
private static String requiredT2CodeLibVersion = "16.7";
|
private static String requiredT2CodeLibVersion = "15.3";
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
private static String prefix = "<dark_gray>[<dark_red>T2C</dark_red>-<color:#5cff5c>Automated</color><color:#69d2ff>Messages</color>]</dark_gray>";
|
private static String prefix = "<dark_gray>[<dark_red>T2C</dark_red>-<color:#5cff5c>Automated</color><color:#69d2ff>Messages</color>]</dark_gray>";
|
||||||
@ -32,10 +28,4 @@ public class Util {
|
|||||||
@Getter
|
@Getter
|
||||||
private static String discord = "http://dc.t2code.net";
|
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]);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
package net.t2code.automatedMessages.command;
|
package net.t2code.automatedMessages.command;
|
||||||
|
|
||||||
import net.t2code.automatedMessages.Util;
|
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.Command;
|
||||||
import org.bukkit.command.CommandExecutor;
|
import org.bukkit.command.CommandExecutor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
@ -49,7 +49,7 @@ public class CmdExecuter implements CommandExecutor, TabCompleter {
|
|||||||
@Override
|
@Override
|
||||||
public List<String> onTabComplete(CommandSender sender, Command cmd, String s, String[] args) {
|
public List<String> onTabComplete(CommandSender sender, Command cmd, String s, String[] args) {
|
||||||
List<String> list = new ArrayList<>();
|
List<String> list = new ArrayList<>();
|
||||||
T2C_Tab.tab(list,sender,0,args,arg1);
|
T2Ctab.tab(list,sender,0,args,arg1);
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,31 +2,30 @@ package net.t2code.automatedMessages.command;
|
|||||||
|
|
||||||
import net.t2code.automatedMessages.Util;
|
import net.t2code.automatedMessages.Util;
|
||||||
import net.t2code.automatedMessages.config.Config;
|
import net.t2code.automatedMessages.config.Config;
|
||||||
import net.t2code.automatedMessages.config.Languages;
|
import net.t2code.automatedMessages.config.FileBuild;
|
||||||
import net.t2code.automatedMessages.config.Messages;
|
import net.t2code.automatedMessages.config.messages.MessagesSelect;
|
||||||
import net.t2code.automatedMessages.messages.Management;
|
import net.t2code.automatedMessages.messages.Management;
|
||||||
import net.t2code.automatedMessages.system.Main;
|
import net.t2code.automatedMessages.system.Main;
|
||||||
import net.t2code.t2codelib.SPIGOT.api.messages.T2C_Send;
|
import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend;
|
||||||
import net.t2code.t2codelib.SPIGOT.api.messages.T2C_Template;
|
import net.t2code.t2codelib.SPIGOT.api.messages.T2Ctemplate;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
public class Commands {
|
public class Commands {
|
||||||
public static void reload(CommandSender sender) {
|
public static void reload(CommandSender sender) {
|
||||||
T2C_Send.console(Languages.VALUES.msgReloadStart.getValue().toString());
|
T2Csend.console(Config.msgReloadStart.valueString);
|
||||||
if (sender instanceof Player) T2C_Send.sender(sender, Languages.VALUES.msgReloadStart.getValue().toString());
|
if (sender instanceof Player) T2Csend.sender(sender, Config.msgReloadStart.valueString);
|
||||||
Management.end();
|
Management.end();
|
||||||
|
|
||||||
Config.set(true);
|
FileBuild.selectConfig();
|
||||||
Languages.set(true);
|
MessagesSelect.select();
|
||||||
Messages.set(true);
|
|
||||||
|
|
||||||
Management.start();
|
Management.start();
|
||||||
if (sender instanceof Player) T2C_Send.sender(sender, Languages.VALUES.msgReloadEnd.getValue().toString());
|
if (sender instanceof Player) T2Csend.sender(sender, Config.msgReloadEnd.valueString);
|
||||||
T2C_Send.console(Languages.VALUES.msgReloadEnd.getValue().toString());
|
T2Csend.console(Config.msgReloadEnd.valueString);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void info(CommandSender sender) {
|
public static void info(CommandSender sender) {
|
||||||
T2C_Template.sendInfo(sender, Main.getPlugin(), Util.getSpigotID(), Util.getDiscord(), Util.getInfoText());
|
T2Ctemplate.sendInfo(sender, Main.getPlugin(), Util.getSpigotID(), Util.getDiscord(), Util.getInfoText());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,115 +1,41 @@
|
|||||||
package net.t2code.automatedMessages.config;
|
package net.t2code.automatedMessages.config;
|
||||||
|
|
||||||
import net.t2code.automatedMessages.Util;
|
public enum Config {
|
||||||
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;
|
|
||||||
|
|
||||||
import java.io.File;
|
updateCheckOnJoin("plugin.updateCheck.onJoin", true, ConfigParam.BOOLEAN),
|
||||||
import java.util.HashMap;
|
updateCheckSeePreReleaseUpdates("plugin.updateCheck.seePreReleaseUpdates", true, ConfigParam.BOOLEAN),
|
||||||
import java.util.List;
|
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 {
|
timeFormat("plugin.timeFormat", "HH:mm:ss yyyy/MM/dd", ConfigParam.STRING),
|
||||||
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());
|
|
||||||
}}),
|
|
||||||
|
|
||||||
prefix("plugin.prefix", "<dark_gray>[<dark_red>T2C</dark_red>-<color:#5cff5c>Automated</color><color:#69d2ff>Messages</color>]</dark_gray>", true,
|
msgReloadStart("plugin.messages.reloadStart", "[prefix] Reload starting...", ConfigParam.STRING),
|
||||||
new HashMap<>() {{
|
msgReloadEnd("plugin.messages.reloadEnd", "[prefix] Reload successful.", ConfigParam.STRING);
|
||||||
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());
|
|
||||||
}}),
|
|
||||||
|
|
||||||
timeFormat("plugin.timeFormat", "HH:mm:ss yyyy/MM/dd",true,
|
|
||||||
new HashMap<>() {{
|
|
||||||
put(T2C_LanguageEnum.german, List.of());
|
|
||||||
put(T2C_LanguageEnum.english, List.of());
|
|
||||||
}}),
|
|
||||||
|
|
||||||
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 ConfigParam configParam;
|
||||||
|
|
||||||
private final String path;
|
Config(String path, String value, ConfigParam cEnum) {
|
||||||
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.path = path;
|
||||||
this.value = value;
|
this.valueString = value;
|
||||||
this.forceSet = forceSet;
|
this.configParam = cEnum;
|
||||||
this.comments = comments;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
Config(String path, Integer value, ConfigParam cEnum) {
|
||||||
public String getPath() {
|
this.path = path;
|
||||||
return path;
|
this.valueInteger = value;
|
||||||
|
this.configParam = cEnum;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
Config(String path, Boolean value, ConfigParam cEnum) {
|
||||||
public Object getValue() {
|
this.path = path;
|
||||||
return value;
|
this.valueBoolean = value;
|
||||||
}
|
this.configParam = cEnum;
|
||||||
|
|
||||||
@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) {
|
|
||||||
T2C_ConfigWriter.createConfig(Util.getPrefix(), new File(Main.getPath(), "config.yml"), VALUES.values(), isReload, Util.getConfigLogo());
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
@ -0,0 +1,7 @@
|
|||||||
|
package net.t2code.automatedMessages.config;
|
||||||
|
|
||||||
|
public enum ConfigParam {
|
||||||
|
STRING,
|
||||||
|
INTEGER,
|
||||||
|
BOOLEAN
|
||||||
|
}
|
@ -0,0 +1,47 @@
|
|||||||
|
package net.t2code.automatedMessages.config;
|
||||||
|
|
||||||
|
import net.t2code.automatedMessages.Util;
|
||||||
|
import net.t2code.automatedMessages.system.Main;
|
||||||
|
import net.t2code.t2codelib.SPIGOT.api.messages.T2Creplace;
|
||||||
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
public class FileBuild {
|
||||||
|
|
||||||
|
public static void selectConfig() {
|
||||||
|
|
||||||
|
File config = new File(Main.getPath(), "config.yml");
|
||||||
|
YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(config);
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
yamlConfiguration.save(config);
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -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;
|
|
||||||
}
|
|
||||||
}
|
|
@ -0,0 +1,105 @@
|
|||||||
|
package net.t2code.automatedMessages.config.messages;
|
||||||
|
|
||||||
|
import org.bukkit.Sound;
|
||||||
|
|
||||||
|
public enum Messages {
|
||||||
|
|
||||||
|
message("enable", false,
|
||||||
|
"message", "",
|
||||||
|
"sound.enable", true,
|
||||||
|
"sound.sound", MessagesSelect.sound(),
|
||||||
|
"permissionNeededToSeeMessage.enable", false,
|
||||||
|
"permissionNeededToSeeMessage.permission", "",
|
||||||
|
"intervalInMin", 0,
|
||||||
|
"exactTime.enable", false,
|
||||||
|
"exactTime.timeMinute", "*/5",
|
||||||
|
"exactTime.timeHour", "*",
|
||||||
|
"exactTime.timeDayOfMonth", "*",
|
||||||
|
"exactTime.timeMonth", "*",
|
||||||
|
"exactTime.timeDayOfWeek", "*"
|
||||||
|
);
|
||||||
|
|
||||||
|
public String msgEnablePath;
|
||||||
|
public Boolean msgEnable;
|
||||||
|
|
||||||
|
public String msgMsgPath;
|
||||||
|
public String msgMsg;
|
||||||
|
|
||||||
|
public String soundEnablePath;
|
||||||
|
public Boolean soundEnable;
|
||||||
|
|
||||||
|
public String soundPath;
|
||||||
|
public Sound sound;
|
||||||
|
|
||||||
|
public String permissionNeededToSeeMessagePath;
|
||||||
|
public Boolean permissionNeededToSeeMessage;
|
||||||
|
|
||||||
|
public String permissionPath;
|
||||||
|
public String permission;
|
||||||
|
|
||||||
|
public String msgIntervalPath;
|
||||||
|
public Integer msgInterval;
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
|
Messages(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) {
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,92 @@
|
|||||||
|
package net.t2code.automatedMessages.config.messages;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
import net.t2code.automatedMessages.objects.Message;
|
||||||
|
import net.t2code.automatedMessages.system.Main;
|
||||||
|
import net.t2code.t2codelib.SPIGOT.api.minecraftVersion.T2CmcVersion;
|
||||||
|
import org.bukkit.Sound;
|
||||||
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.HashMap;
|
||||||
|
|
||||||
|
public class MessagesSelect {
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
private static HashMap<String, Message> messageHashMap = new HashMap<>();
|
||||||
|
|
||||||
|
public static void select() {
|
||||||
|
messageHashMap.clear();
|
||||||
|
|
||||||
|
File f = new File(Main.getPath() + "/Messages/");
|
||||||
|
if (!f.exists()){
|
||||||
|
try {
|
||||||
|
Main.getPlugin().saveResource("Messages/exampleDiscord.yml", false);
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
Main.getPlugin().saveResource("Messages/exampleTime.yml", false);
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
Main.getPlugin().saveResource("Messages/xx_messagesDeclaration_xx.yml", true);
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
File[] fileArray = f.listFiles();
|
||||||
|
for (File config : fileArray) {
|
||||||
|
try {
|
||||||
|
if (config.getName().equals("xx_messagesDeclaration_xx.yml")) continue;
|
||||||
|
String sub = config.getName().substring(config.getName().length() - 4);
|
||||||
|
if (sub.equals(".yml")) {
|
||||||
|
String key = config.getName().replace(".yml", "");
|
||||||
|
YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(config);
|
||||||
|
|
||||||
|
for (Messages value : Messages.values()) {
|
||||||
|
Boolean enable = yamlConfiguration.getBoolean(value.msgEnablePath);
|
||||||
|
String message = yamlConfiguration.getString(value.msgMsgPath);
|
||||||
|
Boolean soundEnable = yamlConfiguration.getBoolean(value.soundEnablePath);
|
||||||
|
|
||||||
|
Sound sound;
|
||||||
|
try {
|
||||||
|
sound = Sound.valueOf(yamlConfiguration.getString(value.soundPath));
|
||||||
|
} catch (Exception e) {
|
||||||
|
sound = sound();
|
||||||
|
}
|
||||||
|
|
||||||
|
Integer interval = yamlConfiguration.getInt(value.msgIntervalPath);
|
||||||
|
|
||||||
|
Boolean permissionNeededToSeeMessage = yamlConfiguration.getBoolean(value.permissionNeededToSeeMessagePath);
|
||||||
|
String permission = yamlConfiguration.getString(value.permissionPath);
|
||||||
|
|
||||||
|
Boolean exactTime = yamlConfiguration.getBoolean(value.exactTimePath);
|
||||||
|
String timeMinute = yamlConfiguration.getString(value.timeMinutePath);
|
||||||
|
String timeHour = yamlConfiguration.getString(value.timeHourPath);
|
||||||
|
String timeDayOfMonth = yamlConfiguration.getString(value.timeDayOfMonthPath);
|
||||||
|
String timeMonth = yamlConfiguration.getString(value.timeMonthPath);
|
||||||
|
String timeDayOfWeek = yamlConfiguration.getString(value.timeDayOfWeekPath);
|
||||||
|
Message msg = new Message(key, enable, message, soundEnable, sound, permissionNeededToSeeMessage, permission, interval,
|
||||||
|
exactTime, timeMinute, timeHour, timeDayOfMonth, timeMonth, timeDayOfWeek);
|
||||||
|
messageHashMap.put(key, msg);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
Main.sendTryCatch(MessagesSelect.class, e.getStackTrace()[0]);
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
@ -1,6 +1,7 @@
|
|||||||
package net.t2code.automatedMessages.messages;
|
package net.t2code.automatedMessages.messages;
|
||||||
|
|
||||||
import net.t2code.automatedMessages.config.Messages;
|
import net.t2code.automatedMessages.config.FileBuild;
|
||||||
|
import net.t2code.automatedMessages.config.messages.MessagesSelect;
|
||||||
import net.t2code.automatedMessages.objects.Message;
|
import net.t2code.automatedMessages.objects.Message;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -12,7 +13,7 @@ public class Management {
|
|||||||
private static final List<CronJob> cronJobs = new ArrayList<>();
|
private static final List<CronJob> cronJobs = new ArrayList<>();
|
||||||
|
|
||||||
public static void start() {
|
public static void start() {
|
||||||
for (Map.Entry<String, Message> value : Messages.getMessageHashMap().entrySet()) {
|
for (Map.Entry<String, Message> value : MessagesSelect.getMessageHashMap().entrySet()) {
|
||||||
Message message = value.getValue();
|
Message message = value.getValue();
|
||||||
if (!message.enable) continue;
|
if (!message.enable) continue;
|
||||||
if (message.exactTime) {
|
if (message.exactTime) {
|
||||||
|
@ -2,49 +2,22 @@ package net.t2code.automatedMessages.messages;
|
|||||||
|
|
||||||
import net.t2code.automatedMessages.config.Config;
|
import net.t2code.automatedMessages.config.Config;
|
||||||
import net.t2code.automatedMessages.objects.Message;
|
import net.t2code.automatedMessages.objects.Message;
|
||||||
import net.t2code.t2codelib.SPIGOT.api.messages.T2C_Send;
|
import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.*;
|
import java.util.Calendar;
|
||||||
|
|
||||||
public class SendMessage {
|
public class SendMessage {
|
||||||
public static void send(Message message) {
|
public static void send(Message message) {
|
||||||
String timeStamp = new SimpleDateFormat(Config.VALUES.timeFormat.getValue().toString()).format(Calendar.getInstance().getTime());
|
String timeStamp = new SimpleDateFormat(Config.timeFormat.valueString).format(Calendar.getInstance().getTime());
|
||||||
if ((boolean)Config.VALUES.sendConsole.getValue()) {
|
if (Config.sendConsole.valueBoolean) T2Csend.console(message.message.replace("[time]", timeStamp).replace("[prefix]",Config.prefix.valueString));
|
||||||
T2C_Send.console(replace(message.message, Map.entry("[time]", timeStamp), Map.entry("[prefix]", Config.VALUES.prefix.getValue().toString())));
|
|
||||||
}
|
|
||||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||||
if (player.hasPermission(message.permission) || !message.permissionNeededToSeeMessage){
|
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())));
|
T2Csend.player(player, message.message.replace("[time]", timeStamp).replace("[prefix]",Config.prefix.valueString).replace("[player]",player.getName()));
|
||||||
player.playSound(player.getLocation(), message.sound, 3, 1);
|
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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -3,30 +3,29 @@ package net.t2code.automatedMessages.system;
|
|||||||
import net.t2code.automatedMessages.Util;
|
import net.t2code.automatedMessages.Util;
|
||||||
import net.t2code.automatedMessages.command.CmdExecuter;
|
import net.t2code.automatedMessages.command.CmdExecuter;
|
||||||
import net.t2code.automatedMessages.config.Config;
|
import net.t2code.automatedMessages.config.Config;
|
||||||
import net.t2code.automatedMessages.config.Languages;
|
import net.t2code.automatedMessages.config.FileBuild;
|
||||||
import net.t2code.automatedMessages.config.Messages;
|
import net.t2code.automatedMessages.config.messages.MessagesSelect;
|
||||||
import net.t2code.automatedMessages.messages.Management;
|
import net.t2code.automatedMessages.messages.Management;
|
||||||
import net.t2code.t2codelib.SPIGOT.api.messages.T2C_Template;
|
import net.t2code.t2codelib.SPIGOT.api.messages.T2Ctemplate;
|
||||||
import net.t2code.t2codelib.SPIGOT.api.update.T2C_UpdateAPI;
|
import net.t2code.t2codelib.SPIGOT.api.update.T2CupdateAPI;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class Load {
|
public class Load {
|
||||||
public static void onLoad(@NotNull Main plugin, List<String> autor, String version) {
|
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());
|
long long_ = T2Ctemplate.onLoadHeader(Util.getPrefix(), autor, version, Util.getSpigot(), Util.getDiscord());
|
||||||
plugin.getCommand("t2c-automatedmessages").setExecutor(new CmdExecuter());
|
plugin.getCommand("t2c-automatedmessages").setExecutor(new CmdExecuter());
|
||||||
|
|
||||||
Config.set(false);
|
FileBuild.selectConfig();
|
||||||
Languages.set(false);
|
MessagesSelect.select();
|
||||||
Messages.set(false);
|
|
||||||
|
|
||||||
Management.start();
|
Management.start();
|
||||||
|
|
||||||
T2C_UpdateAPI.onUpdateCheck(plugin, Util.getPrefix(), Util.getGit(), Util.getSpigotID(), Util.getDiscord(), (boolean) Config.VALUES.updateCheckOnJoin.getValue(),
|
T2CupdateAPI.onUpdateCheck(plugin, Util.getPrefix(), Util.getGit(), Util.getSpigotID(), Util.getDiscord(), Config.updateCheckOnJoin.valueBoolean,
|
||||||
(boolean) Config.VALUES.updateCheckSeePreReleaseUpdates.getValue(), (int) Config.VALUES.updateCheckTimeInterval.getValue());
|
Config.updateCheckSeePreReleaseUpdates.valueBoolean, Config.updateCheckTimeInterval.valueInteger);
|
||||||
Metrics.Bstats(plugin, Util.getBstatsID());
|
Metrics.Bstats(plugin, Util.getBstatsID());
|
||||||
T2C_Template.onLoadFooter(Util.getPrefix(), long_);
|
T2Ctemplate.onLoadFooter(Util.getPrefix(), long_);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,8 +2,8 @@ package net.t2code.automatedMessages.system;
|
|||||||
|
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import net.t2code.automatedMessages.Util;
|
import net.t2code.automatedMessages.Util;
|
||||||
import net.t2code.t2codelib.SPIGOT.api.messages.T2C_Send;
|
import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend;
|
||||||
import net.t2code.t2codelib.SPIGOT.api.messages.T2C_Template;
|
import net.t2code.t2codelib.SPIGOT.api.messages.T2Ctemplate;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
import org.jetbrains.annotations.Contract;
|
import org.jetbrains.annotations.Contract;
|
||||||
@ -43,7 +43,7 @@ public final class Main extends JavaPlugin {
|
|||||||
@Override
|
@Override
|
||||||
public void onDisable() {
|
public void onDisable() {
|
||||||
// Plugin shutdown logic
|
// 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 @NotNull Boolean pluginNotFound(String pl, Integer spigotID, String ver) {
|
||||||
@ -79,6 +79,6 @@ public final class Main extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
public static void sendTryCatch(Class c, StackTraceElement line) {
|
public static void sendTryCatch(Class c, StackTraceElement line) {
|
||||||
T2C_Send.error(plugin,c.getName() + " Line: " + line.getLineNumber());
|
T2Csend.error(plugin,c.getName() + " Line: " + line.getLineNumber());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
16
src/main/resources/Messages/exampleDiscord.yml
Normal file
16
src/main/resources/Messages/exampleDiscord.yml
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
enable: true
|
||||||
|
message: "[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:
|
||||||
|
enable: true
|
||||||
|
sound: BLOCK_NOTE_BLOCK_HARP
|
||||||
|
permissionNeededToSeeMessage:
|
||||||
|
enable: false
|
||||||
|
permission: t2c.automatedmessages.messages.examplediscord
|
||||||
|
intervalInMin: 20
|
||||||
|
exactTime:
|
||||||
|
enable: false
|
||||||
|
timeMinute: '*'
|
||||||
|
timeHour: '*'
|
||||||
|
timeDayOfMonth: '*'
|
||||||
|
timeMonth: '*'
|
||||||
|
timeDayOfWeek: '*'
|
16
src/main/resources/Messages/exampleTime.yml
Normal file
16
src/main/resources/Messages/exampleTime.yml
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
enable: true
|
||||||
|
message: "[prefix] <aqua>Es ist jetzt <yellow>[time]</yellow></aqua>"
|
||||||
|
sound:
|
||||||
|
enable: true
|
||||||
|
sound: BLOCK_NOTE_BLOCK_HARP
|
||||||
|
permissionNeededToSeeMessage:
|
||||||
|
enable: false
|
||||||
|
permission: t2c.automatedmessages.messages.exampletime
|
||||||
|
intervalInMin: 0
|
||||||
|
exactTime:
|
||||||
|
enable: true
|
||||||
|
timeMinute: 0/15/30/45
|
||||||
|
timeHour: '*'
|
||||||
|
timeDayOfMonth: '*'
|
||||||
|
timeMonth: '*'
|
||||||
|
timeDayOfWeek: '*'
|
58
src/main/resources/Messages/xx_messagesDeclaration_xx.yml
Normal file
58
src/main/resources/Messages/xx_messagesDeclaration_xx.yml
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
#####################################################
|
||||||
|
## To add another Function just create a new file. ##
|
||||||
|
#####################################################
|
||||||
|
|
||||||
|
# Here you can set whether the message should be activated or deactivated.
|
||||||
|
enable: false
|
||||||
|
# Specify here the message that the player should get.
|
||||||
|
#
|
||||||
|
# Placeholder:
|
||||||
|
# [player] = the player name of the recipient of the message.
|
||||||
|
# [time] = The current system time.
|
||||||
|
# [prefix] = The prefix set from config.yml.
|
||||||
|
#
|
||||||
|
# You can use Minecraft custom color codes: https://minecraft.fandom.com/de/wiki/Formatierungscodes
|
||||||
|
# You can use the hover module from T2Code:
|
||||||
|
# You can add a hover and/or clickable feature to all messages sent to players.
|
||||||
|
# Use /*/ to separate the message.
|
||||||
|
# Use [nl] to set a line break in a message or hover.
|
||||||
|
# Hover message: <message >/*/<hover>
|
||||||
|
# Message with hover and click function: <message >/*/<hover>/*/<action>/*/<actionValue>
|
||||||
|
# Message only with click function: <message >/*//*/<action>/*/<actionValue>
|
||||||
|
# Action:
|
||||||
|
# - OPEN_URL - Opens a URL under the path specified in ActionValue.
|
||||||
|
# - OPEN_FILE - Opens a file under the path specified by ActionValue.
|
||||||
|
# - RUN_COMMAND - Runs the command specified by ActionValue.
|
||||||
|
# - SUGGEST_COMMAND - Inserts the string specified in ActionValue into the player text box.
|
||||||
|
# - CHANGE_PAGE - Changes to the page number in a book specified by ActionValue.
|
||||||
|
# - COPY_TO_CLIPBOARD - Copies the string specified by ActionValue to the player's clipboard.
|
||||||
|
# You can also use MiniMessage:
|
||||||
|
# Wiki: https://docs.adventure.kyori.net/minimessage/format.html
|
||||||
|
# WebUI: https://webui.adventure.kyori.net
|
||||||
|
message: ''
|
||||||
|
sound:
|
||||||
|
# Here you can set whether a sound should be played with the message.
|
||||||
|
enable: true
|
||||||
|
# Here you can set which sound should be played.
|
||||||
|
sound: BLOCK_NOTE_BLOCK_HARP
|
||||||
|
permissionNeededToSeeMessage:
|
||||||
|
# Here you can set whether the players need a permission to receive the message.
|
||||||
|
enable: false
|
||||||
|
# Here you can set if the players need which permission to receive the message.
|
||||||
|
permission: t2c.automatedmessages.messages.exampletime
|
||||||
|
# Here you can set the time interval (in minutes) at which the message should be sent.
|
||||||
|
intervalInMin: 1
|
||||||
|
exactTime:
|
||||||
|
# Here you can set whether the message should be sent at certain times.
|
||||||
|
# If this option is used, then the intervalInMin option is disabled!
|
||||||
|
enable: false
|
||||||
|
# In these settings you can set at which minute, hour, day of the month, which month and on which day of the week the message should be sent.
|
||||||
|
# Time format examples:
|
||||||
|
# One: 5
|
||||||
|
# At several times: 5/10/15
|
||||||
|
# Every minute, hour, etc.: '*'
|
||||||
|
timeMinute: 0
|
||||||
|
timeHour: '*'
|
||||||
|
timeDayOfMonth: '*'
|
||||||
|
timeMonth: '*'
|
||||||
|
timeDayOfWeek: '*'
|
Loading…
Reference in New Issue
Block a user