Bladeren bron

Wire up admin notification toggle

nossr50 6 jaren geleden
bovenliggende
commit
65a234c6b3

+ 7 - 0
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();
+    }
 }

+ 17 - 0
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;
+    }
+}

+ 1 - 1
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())