1.2 SN
This commit is contained in:
parent
afe4297640
commit
8404ff9a42
2
pom.xml
2
pom.xml
@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
<groupId>net.t2code</groupId>
|
<groupId>net.t2code</groupId>
|
||||||
<artifactId>T2C-AutomatedMessages</artifactId>
|
<artifactId>T2C-AutomatedMessages</artifactId>
|
||||||
<version>1.0-SNAPSHOT</version>
|
<version>1.2-SNAPSHOT</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<name>T2C-AutomatedMessages</name>
|
<name>T2C-AutomatedMessages</name>
|
||||||
|
@ -21,6 +21,8 @@ public enum Config {
|
|||||||
"messages.KEY.message", "",
|
"messages.KEY.message", "",
|
||||||
"messages.KEY.sound.enable", true,
|
"messages.KEY.sound.enable", true,
|
||||||
"messages.KEY.sound.sound", FileBuild.sound(),
|
"messages.KEY.sound.sound", FileBuild.sound(),
|
||||||
|
"messages.KEY.permissionNeededToSeeMessage.enable", false,
|
||||||
|
"messages.KEY.permissionNeededToSeeMessage.permission", "",
|
||||||
"messages.KEY.intervalInMin", 0,
|
"messages.KEY.intervalInMin", 0,
|
||||||
"messages.KEY.exactTime.enable", false,
|
"messages.KEY.exactTime.enable", false,
|
||||||
"messages.KEY.exactTime.timeMinute", "*/5",
|
"messages.KEY.exactTime.timeMinute", "*/5",
|
||||||
@ -50,6 +52,12 @@ public enum Config {
|
|||||||
public String soundPath;
|
public String soundPath;
|
||||||
public Sound sound;
|
public Sound sound;
|
||||||
|
|
||||||
|
public String permissionNeededToSeeMessagePath;
|
||||||
|
public Boolean permissionNeededToSeeMessage;
|
||||||
|
|
||||||
|
public String permissionPath;
|
||||||
|
public String permission;
|
||||||
|
|
||||||
public String msgIntervalPath;
|
public String msgIntervalPath;
|
||||||
public Integer msgInterval;
|
public Integer msgInterval;
|
||||||
|
|
||||||
@ -96,6 +104,8 @@ public enum Config {
|
|||||||
String msgMsgPath, String msgMsg,
|
String msgMsgPath, String msgMsg,
|
||||||
String soundEnablePath, Boolean soundEnable,
|
String soundEnablePath, Boolean soundEnable,
|
||||||
String soundPath, Sound sound,
|
String soundPath, Sound sound,
|
||||||
|
String permissionNeededToSeeMessagePath, Boolean permissionNeededToSeeMessage,
|
||||||
|
String permissionPath, String permission,
|
||||||
String msgIntervalPath, Integer msgInterval,
|
String msgIntervalPath, Integer msgInterval,
|
||||||
String exactTimePath, Boolean exactTime, String timeMinutePath, String timeMinute,
|
String exactTimePath, Boolean exactTime, String timeMinutePath, String timeMinute,
|
||||||
String timeHourPath, String timeHour,
|
String timeHourPath, String timeHour,
|
||||||
@ -114,6 +124,11 @@ public enum Config {
|
|||||||
this.soundPath = soundPath;
|
this.soundPath = soundPath;
|
||||||
this.sound = sound;
|
this.sound = sound;
|
||||||
|
|
||||||
|
this.permissionNeededToSeeMessagePath = permissionNeededToSeeMessagePath;
|
||||||
|
this.permissionNeededToSeeMessage = permissionNeededToSeeMessage;
|
||||||
|
this.permissionPath = permissionPath;
|
||||||
|
this.permission = permission;
|
||||||
|
|
||||||
this.msgIntervalPath = msgIntervalPath;
|
this.msgIntervalPath = msgIntervalPath;
|
||||||
this.msgInterval = msgInterval;
|
this.msgInterval = msgInterval;
|
||||||
this.exactTimePath = exactTimePath;
|
this.exactTimePath = exactTimePath;
|
||||||
|
@ -5,7 +5,6 @@ import net.t2code.automatedMessages.Util;
|
|||||||
import net.t2code.automatedMessages.objects.Message;
|
import net.t2code.automatedMessages.objects.Message;
|
||||||
import net.t2code.automatedMessages.system.Main;
|
import net.t2code.automatedMessages.system.Main;
|
||||||
import net.t2code.t2codelib.SPIGOT.api.messages.T2Creplace;
|
import net.t2code.t2codelib.SPIGOT.api.messages.T2Creplace;
|
||||||
import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend;
|
|
||||||
import net.t2code.t2codelib.SPIGOT.api.minecraftVersion.T2CmcVersion;
|
import net.t2code.t2codelib.SPIGOT.api.minecraftVersion.T2CmcVersion;
|
||||||
import org.bukkit.Sound;
|
import org.bukkit.Sound;
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
@ -13,7 +12,6 @@ import org.bukkit.configuration.file.YamlConfiguration;
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
public class FileBuild {
|
public class FileBuild {
|
||||||
@ -52,10 +50,12 @@ public class FileBuild {
|
|||||||
if (!yamlConfiguration.contains(value.msgPath)) {
|
if (!yamlConfiguration.contains(value.msgPath)) {
|
||||||
setExample("exampleDiscord", true,
|
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>",
|
"[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(), 20, false, "*", "*", "*", "*", "*", yamlConfiguration);
|
true, sound(), false, "t2c.automatedmessages.messages.examplediscord", 20,
|
||||||
|
false, "*", "*", "*", "*", "*", yamlConfiguration);
|
||||||
setExample("exampleTime", true,
|
setExample("exampleTime", true,
|
||||||
"[prefix] <aqua>Es ist jetzt <yellow>[time]</yellow></aqua>",
|
"[prefix] <aqua>Es ist jetzt <yellow>[time]</yellow></aqua>",
|
||||||
true, sound(),0, true, "0/15/30/45", "*", "*", "*", "*", yamlConfiguration);
|
true, sound(), false, "t2c.automatedmessages.messages.exampletime", 0,
|
||||||
|
true, "0/15/30/45", "*", "*", "*", "*", yamlConfiguration);
|
||||||
}
|
}
|
||||||
for (String key : yamlConfiguration.getConfigurationSection(value.msgPath).getKeys(false)) {
|
for (String key : yamlConfiguration.getConfigurationSection(value.msgPath).getKeys(false)) {
|
||||||
Boolean enable = yamlConfiguration.getBoolean(value.msgEnablePath.replace("KEY", key));
|
Boolean enable = yamlConfiguration.getBoolean(value.msgEnablePath.replace("KEY", key));
|
||||||
@ -72,13 +72,17 @@ public class FileBuild {
|
|||||||
|
|
||||||
Integer interval = yamlConfiguration.getInt(value.msgIntervalPath.replace("KEY", key));
|
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));
|
Boolean exactTime = yamlConfiguration.getBoolean(value.exactTimePath.replace("KEY", key));
|
||||||
String timeMinute = yamlConfiguration.getString(value.timeMinutePath.replace("KEY", key));
|
String timeMinute = yamlConfiguration.getString(value.timeMinutePath.replace("KEY", key));
|
||||||
String timeHour = yamlConfiguration.getString(value.timeHourPath.replace("KEY", key));
|
String timeHour = yamlConfiguration.getString(value.timeHourPath.replace("KEY", key));
|
||||||
String timeDayOfMonth = yamlConfiguration.getString(value.timeDayOfMonthPath.replace("KEY", key));
|
String timeDayOfMonth = yamlConfiguration.getString(value.timeDayOfMonthPath.replace("KEY", key));
|
||||||
String timeMonth = yamlConfiguration.getString(value.timeMonthPath.replace("KEY", key));
|
String timeMonth = yamlConfiguration.getString(value.timeMonthPath.replace("KEY", key));
|
||||||
String timeDayOfWeek = yamlConfiguration.getString(value.timeDayOfWeekPath.replace("KEY", key));
|
String timeDayOfWeek = yamlConfiguration.getString(value.timeDayOfWeekPath.replace("KEY", key));
|
||||||
Message msg = new Message(key, enable, message, soundEnable, sound, interval, exactTime, timeMinute, timeHour, timeDayOfMonth, timeMonth, timeDayOfWeek);
|
Message msg = new Message(key, enable, message, soundEnable, sound, permissionNeededToSeeMessage, permission, interval,
|
||||||
|
exactTime, timeMinute, timeHour, timeDayOfMonth, timeMonth, timeDayOfWeek);
|
||||||
messageHashMap.put(key, msg);
|
messageHashMap.put(key, msg);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -99,12 +103,14 @@ public class FileBuild {
|
|||||||
} else return Sound.BLOCK_NOTE_BLOCK_HARP;
|
} else return Sound.BLOCK_NOTE_BLOCK_HARP;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void setExample(String key, Boolean enable, String msg,Boolean soundEnable,Sound sound, Integer interval, Boolean exactTime, String timeMinute, String timeHour, String timeDayOfMonth,
|
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) {
|
String timeMonth, String timeDayOfWeek, YamlConfiguration yamlConfiguration) {
|
||||||
yamlConfiguration.set("messages." + key + ".enable", enable);
|
yamlConfiguration.set("messages." + key + ".enable", enable);
|
||||||
yamlConfiguration.set("messages." + key + ".message", msg);
|
yamlConfiguration.set("messages." + key + ".message", msg);
|
||||||
yamlConfiguration.set("messages." + key + ".sound.enable", soundEnable);
|
yamlConfiguration.set("messages." + key + ".sound.enable", soundEnable);
|
||||||
yamlConfiguration.set("messages." + key + ".sound.sound", sound.toString());
|
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 + ".intervalInMin", interval);
|
||||||
yamlConfiguration.set("messages." + key + ".exactTime.enable", exactTime);
|
yamlConfiguration.set("messages." + key + ".exactTime.enable", exactTime);
|
||||||
yamlConfiguration.set("messages." + key + ".exactTime.timeMinute", timeMinute);
|
yamlConfiguration.set("messages." + key + ".exactTime.timeMinute", timeMinute);
|
||||||
|
@ -15,7 +15,9 @@ public class SendMessage {
|
|||||||
if (Config.sendConsole.valueBoolean) T2Csend.console(message.message.replace("[time]", timeStamp).replace("[prefix]",Config.prefix.valueString));
|
if (Config.sendConsole.valueBoolean) T2Csend.console(message.message.replace("[time]", timeStamp).replace("[prefix]",Config.prefix.valueString));
|
||||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||||
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));
|
||||||
|
if (player.hasPermission(message.permission) || !message.permissionNeededToSeeMessage){
|
||||||
player.playSound(player.getLocation(), message.sound, 3, 1);
|
player.playSound(player.getLocation(), message.sound, 3, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
@ -13,6 +13,8 @@ public class Message {
|
|||||||
|
|
||||||
public Boolean soundEnable;
|
public Boolean soundEnable;
|
||||||
public Sound sound;
|
public Sound sound;
|
||||||
|
public Boolean permissionNeededToSeeMessage;
|
||||||
|
public String permission;
|
||||||
public Integer interval;
|
public Integer interval;
|
||||||
public Boolean exactTime;
|
public Boolean exactTime;
|
||||||
public String timeMinute;
|
public String timeMinute;
|
||||||
@ -26,6 +28,9 @@ public class Message {
|
|||||||
String message,
|
String message,
|
||||||
Boolean soundEnable,
|
Boolean soundEnable,
|
||||||
Sound sound,
|
Sound sound,
|
||||||
|
Boolean permissionNeededToSeeMessage,
|
||||||
|
String permission,
|
||||||
|
|
||||||
Integer interval,
|
Integer interval,
|
||||||
|
|
||||||
Boolean exactTime,
|
Boolean exactTime,
|
||||||
@ -39,6 +44,8 @@ public class Message {
|
|||||||
this.message = message;
|
this.message = message;
|
||||||
this.soundEnable = soundEnable;
|
this.soundEnable = soundEnable;
|
||||||
this.sound = sound;
|
this.sound = sound;
|
||||||
|
this.permissionNeededToSeeMessage = permissionNeededToSeeMessage;
|
||||||
|
this.permission = permission;
|
||||||
this.interval = interval;
|
this.interval = interval;
|
||||||
this.exactTime = exactTime;
|
this.exactTime = exactTime;
|
||||||
this.timeMinute = timeMinute;
|
this.timeMinute = timeMinute;
|
||||||
|
Loading…
Reference in New Issue
Block a user