This commit is contained in:
JaTiTV 2023-06-27 19:13:21 +02:00
parent d172ea3607
commit 4501fe550c
19 changed files with 334 additions and 220 deletions

13
pom.xml
View File

@ -5,8 +5,11 @@
<modelVersion>4.0.0</modelVersion>
<groupId>net.t2code</groupId>
<artifactId>T2C-AutomatedMessages</artifactId>
<version>0.1.5</version>
<artifactId>AutomatedMessages</artifactId>
<version>1.0</version>
<!--version>VERSION_snapshot-0</version-->
<!--version>VERSION_beta-0</version-->
<!--version>VERSION_dev-0</version-->
<packaging>jar</packaging>
<name>T2C-AutomatedMessages</name>
@ -17,7 +20,7 @@
</properties>
<build>
<finalName>${project.artifactId}_${project.version}</finalName>
<finalName>${project.name}_${project.version}</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
@ -74,14 +77,14 @@
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.19.2-R0.1-SNAPSHOT</version>
<version>1.20-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<!-- t2code -->
<dependency>
<groupId>net.t2code</groupId>
<artifactId>T2CodeLib</artifactId>
<version>15.1</version>
<version>15.3</version>
<scope>provided</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/org.projectlombok/lombok -->

View File

@ -8,13 +8,13 @@ public class Util {
private static String infoText = "";
@Getter
private static String requiredT2CodeLibVersion = "15.0";
private static String requiredT2CodeLibVersion = "15.3";
@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";

View File

@ -2,6 +2,7 @@
package net.t2code.automatedMessages.command;
import net.t2code.automatedMessages.Util;
import net.t2code.t2codelib.SPIGOT.api.commands.T2Ctab;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
@ -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 {

View File

@ -12,10 +12,6 @@ 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);
Management.end();
@ -28,10 +24,6 @@ public class Commands {
}
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());
}
}

View File

@ -1,7 +1,5 @@
package net.t2code.automatedMessages.config;
import org.bukkit.Sound;
public enum Config {
updateCheckOnJoin("plugin.updateCheck.onJoin", true, ConfigParam.BOOLEAN),
@ -13,72 +11,14 @@ public enum Config {
timeFormat("plugin.timeFormat", "HH:mm:ss yyyy/MM/dd", ConfigParam.STRING),
msgReloadStart("plugin.messages.reloadStart", "Reload start", ConfigParam.STRING),
msgReloadEnd("plugin.messages.reloadEnd", "Reload end", ConfigParam.STRING),
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...", ConfigParam.STRING),
msgReloadEnd("plugin.messages.reloadEnd", "[prefix] Reload successful.", ConfigParam.STRING);
public String path;
public String valueString;
public Boolean valueBoolean;
public Integer valueInteger;
public String msgPath;
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;
public ConfigParam configParam;
Config(String path, String value, ConfigParam cEnum) {
@ -98,52 +38,4 @@ public enum Config {
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;
}
}

View File

@ -3,6 +3,5 @@ package net.t2code.automatedMessages.config;
public enum ConfigParam {
STRING,
INTEGER,
BOOLEAN,
MESSAGE
BOOLEAN
}

View File

@ -1,29 +1,20 @@
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:
@ -45,47 +36,6 @@ public class FileBuild {
}
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 {
@ -94,29 +44,4 @@ public class FileBuild {
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);
}
}

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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("/");

View File

@ -1,6 +1,7 @@
package net.t2code.automatedMessages.messages;
import net.t2code.automatedMessages.config.FileBuild;
import net.t2code.automatedMessages.config.messages.MessagesSelect;
import net.t2code.automatedMessages.objects.Message;
import java.util.ArrayList;
@ -12,7 +13,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 : MessagesSelect.getMessageHashMap().entrySet()) {
Message message = value.getValue();
if (!message.enable) continue;
if (message.exactTime) {

View File

@ -15,7 +15,7 @@ public class SendMessage {
if (Config.sendConsole.valueBoolean) T2Csend.console(message.message.replace("[time]", timeStamp).replace("[prefix]",Config.prefix.valueString));
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));
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);
}
}

View File

@ -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() {

View File

@ -4,23 +4,26 @@ 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.messages.MessagesSelect;
import net.t2code.automatedMessages.messages.Management;
import net.t2code.t2codelib.SPIGOT.api.messages.T2Ctemplate;
import net.t2code.t2codelib.SPIGOT.api.update.T2CupdateAPI;
import org.jetbrains.annotations.NotNull;
import java.util.List;
public class Load {
public static void onLoad(Main plugin, List<String> autor, String version) {
public static void onLoad(@NotNull Main plugin, List<String> autor, String version) {
long long_ = T2Ctemplate.onLoadHeader(Util.getPrefix(), autor, version, Util.getSpigot(), Util.getDiscord());
plugin.getCommand("t2c-automatedmessages").setExecutor(new CmdExecuter());
FileBuild.selectConfig();
MessagesSelect.select();
Management.start();
// todo T2CupdateAPI.onUpdateCheck(plugin, Util.getPrefix(),Util.getGit(),Util.getSpigotID(),Util.getDiscord(), Config.updateCheckOnJoin.valueBoolean,
// Config.updateCheckSeePreReleaseUpdates.valueBoolean, Config.updateCheckTimeInterval.valueInteger);
T2CupdateAPI.onUpdateCheck(plugin, Util.getPrefix(), Util.getGit(), Util.getSpigotID(), Util.getDiscord(), Config.updateCheckOnJoin.valueBoolean,
Config.updateCheckSeePreReleaseUpdates.valueBoolean, Config.updateCheckTimeInterval.valueInteger);
Metrics.Bstats(plugin, Util.getBstatsID());
T2Ctemplate.onLoadFooter(Util.getPrefix(), long_);

View File

@ -2,9 +2,12 @@ package net.t2code.automatedMessages.system;
import lombok.Getter;
import net.t2code.automatedMessages.Util;
import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend;
import net.t2code.t2codelib.SPIGOT.api.messages.T2Ctemplate;
import org.bukkit.Bukkit;
import org.bukkit.plugin.java.JavaPlugin;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull;
import java.io.File;
import java.util.List;
@ -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();
}
@ -42,7 +46,7 @@ public final class Main extends JavaPlugin {
if (t2codeLib) T2Ctemplate.onDisable(Util.getPrefix(), autor, version, Util.getSpigot(), Util.getDiscord());
}
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) {
T2Csend.error(plugin,c.getName() + " Line: " + line.getLineNumber());
}
}

View 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: '*'

View 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: '*'

View 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: '*'

View File

@ -1,4 +1,4 @@
name: '${project.artifactId}'
name: '${project.name}'
version: '${project.version}'
prefix: "[T2C-AutomatedMessages]"
main: net.t2code.automatedMessages.system.Main
@ -10,4 +10,8 @@ commands:
description: T2C-AutomatedMessages Main Command.
aliases:
- automatedmessages
- amsg
- amsg
permissions:
t2c.automatedmessages.admin:
default: op