From 65a234c6b3a38ea34307c5789f14ad3ff2192d6c Mon Sep 17 00:00:00 2001 From: nossr50 Date: Sat, 18 May 2019 14:46:48 -0700 Subject: [PATCH] Wire up admin notification toggle --- .../nossr50/config/hocon/admin/ConfigAdmin.java | 7 +++++++ .../hocon/admin/ConfigAdminNotifications.java | 17 +++++++++++++++++ .../util/player/NotificationManager.java | 2 +- 3 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 src/main/java/com/gmail/nossr50/config/hocon/admin/ConfigAdminNotifications.java diff --git a/src/main/java/com/gmail/nossr50/config/hocon/admin/ConfigAdmin.java b/src/main/java/com/gmail/nossr50/config/hocon/admin/ConfigAdmin.java index a3561a167..af4dc0396 100644 --- a/src/main/java/com/gmail/nossr50/config/hocon/admin/ConfigAdmin.java +++ b/src/main/java/com/gmail/nossr50/config/hocon/admin/ConfigAdmin.java @@ -1,8 +1,15 @@ package com.gmail.nossr50.config.hocon.admin; +import ninja.leaping.configurate.objectmapping.Setting; import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable; @ConfigSerializable public class ConfigAdmin { + @Setting(value = "Admin-Notifications", comment = "Settings related to admin alerts in mcMMO.") + public ConfigAdminNotifications configAdminNotifications = new ConfigAdminNotifications(); + + public boolean isSendAdminNotifications() { + return configAdminNotifications.isSendAdminNotifications(); + } } \ No newline at end of file diff --git a/src/main/java/com/gmail/nossr50/config/hocon/admin/ConfigAdminNotifications.java b/src/main/java/com/gmail/nossr50/config/hocon/admin/ConfigAdminNotifications.java new file mode 100644 index 000000000..96af0610f --- /dev/null +++ b/src/main/java/com/gmail/nossr50/config/hocon/admin/ConfigAdminNotifications.java @@ -0,0 +1,17 @@ +package com.gmail.nossr50.config.hocon.admin; + +import ninja.leaping.configurate.objectmapping.Setting; +import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable; + +@ConfigSerializable +public class ConfigAdminNotifications { + private static final boolean SEND_ADMIN_NOTIFICATIONS_DEFAULT = true; + + @Setting(value = "Send-Admin-Notifications", comment = "Send admins notifications about sensitive commands being executed" + + "\nDefault value: "+ SEND_ADMIN_NOTIFICATIONS_DEFAULT) + private boolean sendAdminNotifications = SEND_ADMIN_NOTIFICATIONS_DEFAULT; + + public boolean isSendAdminNotifications() { + return sendAdminNotifications; + } +} diff --git a/src/main/java/com/gmail/nossr50/util/player/NotificationManager.java b/src/main/java/com/gmail/nossr50/util/player/NotificationManager.java index 81752b285..7c01312b5 100644 --- a/src/main/java/com/gmail/nossr50/util/player/NotificationManager.java +++ b/src/main/java/com/gmail/nossr50/util/player/NotificationManager.java @@ -158,7 +158,7 @@ public class NotificationManager { */ private static void sendAdminNotification(String msg) { //If its not enabled exit - if(!Config.getInstance().adminNotifications()) + if(!mcMMO.getConfigManager().getConfigAdmin().isSendAdminNotifications()) return; for(Player player : Bukkit.getServer().getOnlinePlayers())