diff --git a/pom.xml b/pom.xml
index 574f460..611dfed 100644
--- a/pom.xml
+++ b/pom.xml
@@ -6,7 +6,7 @@
net.t2code
T2C-AutomatedMessages
- 1.0-SNAPSHOT
+ 1.2-SNAPSHOT
jar
T2C-AutomatedMessages
diff --git a/src/main/java/net/t2code/automatedMessages/config/Config.java b/src/main/java/net/t2code/automatedMessages/config/Config.java
index 798d4e2..ee3e53d 100644
--- a/src/main/java/net/t2code/automatedMessages/config/Config.java
+++ b/src/main/java/net/t2code/automatedMessages/config/Config.java
@@ -20,7 +20,9 @@ public enum Config {
"messages.KEY.enable", false,
"messages.KEY.message", "",
"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.exactTime.enable", false,
"messages.KEY.exactTime.timeMinute", "*/5",
@@ -50,6 +52,12 @@ public enum Config {
public String soundPath;
public Sound sound;
+ public String permissionNeededToSeeMessagePath;
+ public Boolean permissionNeededToSeeMessage;
+
+ public String permissionPath;
+ public String permission;
+
public String msgIntervalPath;
public Integer msgInterval;
@@ -95,7 +103,9 @@ public enum Config {
String msgEnablePath, Boolean msgEnable,
String msgMsgPath, String msgMsg,
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 exactTimePath, Boolean exactTime, String timeMinutePath, String timeMinute,
String timeHourPath, String timeHour,
@@ -110,9 +120,14 @@ public enum Config {
this.msgMsg = msgMsg;
this.soundEnablePath = soundEnablePath;
- this.soundEnable=soundEnable;
- this.soundPath=soundPath;
- this.sound=sound;
+ 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;
diff --git a/src/main/java/net/t2code/automatedMessages/config/FileBuild.java b/src/main/java/net/t2code/automatedMessages/config/FileBuild.java
index 0460c8c..4743380 100644
--- a/src/main/java/net/t2code/automatedMessages/config/FileBuild.java
+++ b/src/main/java/net/t2code/automatedMessages/config/FileBuild.java
@@ -5,7 +5,6 @@ import net.t2code.automatedMessages.Util;
import net.t2code.automatedMessages.objects.Message;
import net.t2code.automatedMessages.system.Main;
import net.t2code.t2codelib.SPIGOT.api.messages.T2Creplace;
-import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend;
import net.t2code.t2codelib.SPIGOT.api.minecraftVersion.T2CmcVersion;
import org.bukkit.Sound;
import org.bukkit.configuration.file.YamlConfiguration;
@@ -13,7 +12,6 @@ import org.bukkit.configuration.file.YamlConfiguration;
import java.io.File;
import java.io.IOException;
import java.util.HashMap;
-import java.util.List;
import java.util.Objects;
public class FileBuild {
@@ -52,10 +50,12 @@ public class FileBuild {
if (!yamlConfiguration.contains(value.msgPath)) {
setExample("exampleDiscord", true,
"[prefix] If you need help, just contact us on our dc.t2code.net'>T2Code Support Discord server.",
- true, sound(), 20, false, "*", "*", "*", "*", "*", yamlConfiguration);
+ true, sound(), false, "t2c.automatedmessages.messages.examplediscord", 20,
+ false, "*", "*", "*", "*", "*", yamlConfiguration);
setExample("exampleTime", true,
"[prefix] Es ist jetzt [time]",
- 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)) {
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));
+ 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, 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);
}
break;
@@ -99,12 +103,14 @@ public class FileBuild {
} 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) {
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);
diff --git a/src/main/java/net/t2code/automatedMessages/messages/SendMessage.java b/src/main/java/net/t2code/automatedMessages/messages/SendMessage.java
index 0448c7f..ac9650b 100644
--- a/src/main/java/net/t2code/automatedMessages/messages/SendMessage.java
+++ b/src/main/java/net/t2code/automatedMessages/messages/SendMessage.java
@@ -15,7 +15,9 @@ public class SendMessage {
if (Config.sendConsole.valueBoolean) T2Csend.console(message.message.replace("[time]", timeStamp).replace("[prefix]",Config.prefix.valueString));
for (Player player : Bukkit.getOnlinePlayers()) {
T2Csend.player(player, message.message.replace("[time]", timeStamp).replace("[prefix]",Config.prefix.valueString));
- player.playSound(player.getLocation(), message.sound, 3, 1);
+ if (player.hasPermission(message.permission) || !message.permissionNeededToSeeMessage){
+ player.playSound(player.getLocation(), message.sound, 3, 1);
+ }
}
}
}
diff --git a/src/main/java/net/t2code/automatedMessages/objects/Message.java b/src/main/java/net/t2code/automatedMessages/objects/Message.java
index 7e819c8..9054254 100644
--- a/src/main/java/net/t2code/automatedMessages/objects/Message.java
+++ b/src/main/java/net/t2code/automatedMessages/objects/Message.java
@@ -13,6 +13,8 @@ public class Message {
public Boolean soundEnable;
public Sound sound;
+ public Boolean permissionNeededToSeeMessage;
+ public String permission;
public Integer interval;
public Boolean exactTime;
public String timeMinute;
@@ -26,6 +28,9 @@ public class Message {
String message,
Boolean soundEnable,
Sound sound,
+ Boolean permissionNeededToSeeMessage,
+ String permission,
+
Integer interval,
Boolean exactTime,
@@ -38,7 +43,9 @@ public class Message {
this.enable = enable;
this.message = message;
this.soundEnable = soundEnable;
- this.sound=sound;
+ this.sound = sound;
+ this.permissionNeededToSeeMessage = permissionNeededToSeeMessage;
+ this.permission = permission;
this.interval = interval;
this.exactTime = exactTime;
this.timeMinute = timeMinute;