فهرست منبع

Add notification settings

nossr50 6 سال پیش
والد
کامیت
b03abcdee8

+ 1 - 0
Changelog.txt

@@ -40,6 +40,7 @@ Version 2.2.0
     Lily pads were removed from the Alchemy Ingredient list as they are unused
     Lily pads were removed from the Alchemy Ingredient list as they are unused
     Experience formula conversion command no longer relies on a file to determine what formula you were using previously, instead it determines this from command parameters
     Experience formula conversion command no longer relies on a file to determine what formula you were using previously, instead it determines this from command parameters
     Fixed some tab completion bugs for /mcconvert command
     Fixed some tab completion bugs for /mcconvert command
+    Nearby players using super abilities is now sent to your chat instead of the action bar by default
     Increased the default recipe cost for Chimaera Wing from 5 to 40
     Increased the default recipe cost for Chimaera Wing from 5 to 40
     Admins will now be notified if a player trips over-fishing exploit detection 3+ times in a row (Locale: "Fishing.OverFishingDetected")
     Admins will now be notified if a player trips over-fishing exploit detection 3+ times in a row (Locale: "Fishing.OverFishingDetected")
         Note: Admins are players who are an operator or have adminchat permission.
         Note: Admins are players who are an operator or have adminchat permission.

+ 0 - 12
src/main/java/com/gmail/nossr50/config/hocon/notifications/ActionBarNotificationSetting.java

@@ -1,12 +0,0 @@
-package com.gmail.nossr50.config.hocon.notifications;
-
-public class ActionBarNotificationSetting {
-
-    public boolean enabled;
-    public boolean sendCopyOfMessageToChat;
-
-    public ActionBarNotificationSetting(boolean enabled, boolean sendCopyOfMessageToChat) {
-        this.enabled = enabled;
-        this.sendCopyOfMessageToChat = sendCopyOfMessageToChat;
-    }
-}

+ 0 - 18
src/main/java/com/gmail/nossr50/config/hocon/notifications/ConfigActionBarNotifications.java

@@ -1,18 +0,0 @@
-package com.gmail.nossr50.config.hocon.notifications;
-
-import com.gmail.nossr50.datatypes.interactions.NotificationType;
-import ninja.leaping.configurate.objectmapping.Setting;
-import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable;
-
-import java.util.HashMap;
-
-@ConfigSerializable
-public class ConfigActionBarNotifications {
-
-    @Setting(value = "Notification-Settings")
-    private HashMap<NotificationType, ActionBarNotificationSetting> notificationSettingHashMap;
-
-    public HashMap<NotificationType, ActionBarNotificationSetting> getNotificationSettingHashMap() {
-        return notificationSettingHashMap;
-    }
-}

+ 2 - 1
src/main/java/com/gmail/nossr50/config/hocon/notifications/ConfigNotificationGeneral.java

@@ -7,7 +7,8 @@ import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable;
 public class ConfigNotificationGeneral {
 public class ConfigNotificationGeneral {
 
 
     private static final boolean PLAYER_TIPS_DEFAULT = true;
     private static final boolean PLAYER_TIPS_DEFAULT = true;
-    public static final boolean PROFILE_LOADED_DEFAULT = false;
+    private static final boolean PROFILE_LOADED_DEFAULT = false;
+
     @Setting(value = "Player-Tips", comment = "Allows mcMMO to send players automated helpful tips." +
     @Setting(value = "Player-Tips", comment = "Allows mcMMO to send players automated helpful tips." +
             "\n Default value: " + PLAYER_TIPS_DEFAULT)
             "\n Default value: " + PLAYER_TIPS_DEFAULT)
     private boolean playerTips = PLAYER_TIPS_DEFAULT;
     private boolean playerTips = PLAYER_TIPS_DEFAULT;

+ 17 - 5
src/main/java/com/gmail/nossr50/config/hocon/notifications/ConfigNotifications.java

@@ -1,16 +1,20 @@
 package com.gmail.nossr50.config.hocon.notifications;
 package com.gmail.nossr50.config.hocon.notifications;
 
 
+import com.gmail.nossr50.datatypes.interactions.NotificationType;
 import ninja.leaping.configurate.objectmapping.Setting;
 import ninja.leaping.configurate.objectmapping.Setting;
 import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable;
 import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable;
 
 
+import java.util.HashMap;
+
 @ConfigSerializable
 @ConfigSerializable
 public class ConfigNotifications {
 public class ConfigNotifications {
 
 
     private static final boolean SUPER_ABILITY_TOOL_NOTIFICATION_DEFAULT = true;
     private static final boolean SUPER_ABILITY_TOOL_NOTIFICATION_DEFAULT = true;
 
 
-    @Setting(value = "Action-Bar-Notifications", comment = "Settings related to action bar messages." +
-            "\nThe action bar is the area above your health and armor.")
-    private ConfigActionBarNotifications actionBarNotifications = new ConfigActionBarNotifications();
+    @Setting(value = "Player-Notifications", comment = "Settings for player notifications" +
+            "\nPlayer notifications are often sent to the action bar (The action bar is the location above player health/armor/hunger displays)" +
+            "\nYou can configure where these notifications are sent and whether or not they are sent at all.")
+    private ConfigPlayerNotifications playerNotifications = new ConfigPlayerNotifications();
 
 
 
 
     @Setting(value = "General", comment = "General settings for Notifications")
     @Setting(value = "General", comment = "General settings for Notifications")
@@ -37,11 +41,19 @@ public class ConfigNotifications {
         return superAbilityToolMessage;
         return superAbilityToolMessage;
     }
     }
 
 
-    public ConfigActionBarNotifications getActionBarNotifications() {
-        return actionBarNotifications;
+    public ConfigPlayerNotifications getPlayerNotificationsConfig() {
+        return playerNotifications;
     }
     }
 
 
     public ConfigNotificationGeneral getConfigNotificationGeneral() {
     public ConfigNotificationGeneral getConfigNotificationGeneral() {
         return configNotificationGeneral;
         return configNotificationGeneral;
     }
     }
+
+    public HashMap<NotificationType, PlayerNotification> getNotificationSettingHashMap() {
+        return playerNotifications.getNotificationSettingHashMap();
+    }
+
+    public PlayerNotification getPlayerNotification(NotificationType notificationType) {
+        return playerNotifications.getPlayerNotification(notificationType);
+    }
 }
 }

+ 44 - 0
src/main/java/com/gmail/nossr50/config/hocon/notifications/ConfigPlayerNotifications.java

@@ -0,0 +1,44 @@
+package com.gmail.nossr50.config.hocon.notifications;
+
+import com.gmail.nossr50.datatypes.interactions.NotificationType;
+import ninja.leaping.configurate.objectmapping.Setting;
+import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable;
+
+import java.util.HashMap;
+
+@ConfigSerializable
+public class ConfigPlayerNotifications {
+
+    private final static HashMap<NotificationType, PlayerNotification> NOTIFICATION_MAP_DEFAULT;
+
+    static {
+        NOTIFICATION_MAP_DEFAULT = new HashMap<>();
+
+        NOTIFICATION_MAP_DEFAULT.put(NotificationType.ABILITY_OFF, new PlayerNotification(true, false, true));
+        NOTIFICATION_MAP_DEFAULT.put(NotificationType.HARDCORE_MODE, new PlayerNotification(true, true, true));
+        NOTIFICATION_MAP_DEFAULT.put(NotificationType.REQUIREMENTS_NOT_MET, new PlayerNotification(true, false, true));
+        NOTIFICATION_MAP_DEFAULT.put(NotificationType.ABILITY_COOLDOWN, new PlayerNotification(true, false, true));
+        NOTIFICATION_MAP_DEFAULT.put(NotificationType.LEVEL_UP_MESSAGE, new PlayerNotification(true, true, true));
+        NOTIFICATION_MAP_DEFAULT.put(NotificationType.HOLIDAY, new PlayerNotification(true, true, true));
+        NOTIFICATION_MAP_DEFAULT.put(NotificationType.TOOL, new PlayerNotification(true, false, true));
+        NOTIFICATION_MAP_DEFAULT.put(NotificationType.SUBSKILL_MESSAGE, new PlayerNotification(true, false, true));
+        NOTIFICATION_MAP_DEFAULT.put(NotificationType.SUBSKILL_MESSAGE_FAILED, new PlayerNotification(true, true, false));
+        NOTIFICATION_MAP_DEFAULT.put(NotificationType.SUBSKILL_UNLOCKED, new PlayerNotification(true, true, true));
+        NOTIFICATION_MAP_DEFAULT.put(NotificationType.SUPER_ABILITY, new PlayerNotification(true, false, true));
+        NOTIFICATION_MAP_DEFAULT.put(NotificationType.SUPER_ABILITY_ALERT_OTHERS, new PlayerNotification(true, true, false));
+        NOTIFICATION_MAP_DEFAULT.put(NotificationType.ITEM_MESSAGE, new PlayerNotification(true, false, true));
+        NOTIFICATION_MAP_DEFAULT.put(NotificationType.NO_PERMISSION, new PlayerNotification(true, true, false));
+        NOTIFICATION_MAP_DEFAULT.put(NotificationType.PARTY_MESSAGE, new PlayerNotification(true, true, false));
+    }
+
+    @Setting(value = "Notification-Settings")
+    private HashMap<NotificationType, PlayerNotification> notificationSettingHashMap = NOTIFICATION_MAP_DEFAULT;
+
+    public HashMap<NotificationType, PlayerNotification> getNotificationSettingHashMap() {
+        return notificationSettingHashMap;
+    }
+
+    public PlayerNotification getPlayerNotification(NotificationType notificationType) {
+        return notificationSettingHashMap.get(notificationType);
+    }
+}

+ 44 - 0
src/main/java/com/gmail/nossr50/config/hocon/notifications/PlayerNotification.java

@@ -0,0 +1,44 @@
+package com.gmail.nossr50.config.hocon.notifications;
+
+public class PlayerNotification {
+
+    private boolean enabled;
+    private boolean sendToChat;
+    private boolean sendToActionBar;
+
+    public PlayerNotification(boolean enabled, boolean sendToChat, boolean sendToActionBar) {
+        this.enabled = enabled;
+        this.sendToChat = sendToChat;
+        this.sendToActionBar = sendToActionBar;
+    }
+
+    public void setEnabled(boolean enabled) {
+        this.enabled = enabled;
+    }
+
+    public void setSendToChat(boolean sendToChat) {
+        this.sendToChat = sendToChat;
+    }
+
+    public boolean isEnabled() {
+        return enabled;
+    }
+
+    public boolean isSendToChat() {
+        if(enabled)
+            return sendToChat;
+        else
+            return false;
+    }
+
+    public boolean isSendToActionBar() {
+        if(enabled)
+            return sendToActionBar;
+        else
+            return false;
+    }
+
+    public void setSendToActionBar(boolean sendToActionBar) {
+        this.sendToActionBar = sendToActionBar;
+    }
+}

+ 16 - 29
src/main/java/com/gmail/nossr50/datatypes/interactions/NotificationType.java

@@ -4,33 +4,20 @@ package com.gmail.nossr50.datatypes.interactions;
  * This class helps define the types of information interactions we will have with players
  * This class helps define the types of information interactions we will have with players
  */
  */
 public enum NotificationType {
 public enum NotificationType {
-    XP_GAIN("ExperienceGain"),
-    HARDCORE_MODE("HardcoreMode"),
-    NO_PERMISSION("NoPermission"),
-    SUBSKILL_UNLOCKED("SubSkillUnlocked"),
-    LEVEL_UP_MESSAGE("LevelUps"),
-    HOLIDAY("Holiday"),
-    SUBSKILL_MESSAGE("SubSkillInteraction"),
-    SUBSKILL_MESSAGE_FAILED("SubSkillFailed"),
-    TOOL("ToolReady"),
-    REQUIREMENTS_NOT_MET("RequirementsNotMet"),
-    ABILITY_OFF("AbilityOff"),
-    ABILITY_COOLDOWN("AbilityCoolDown"),
-    ABILITY_REFRESHED("AbilityRefreshed"),
-    SUPER_ABILITY("SuperAbilityInteraction"),
-    SUPER_ABILITY_ALERT_OTHERS("SuperAbilityAlertOthers"),
-    ITEM_MESSAGE("ItemMessage"),
-    CHAT_ONLY("ChatOnly"),
-    PARTY_MESSAGE("PartyMessage");
-
-    final String niceName;
-
-    NotificationType(String niceName) {
-        this.niceName = niceName;
-    }
-
-    @Override
-    public String toString() {
-        return niceName;
-    }
+    HARDCORE_MODE(),
+    NO_PERMISSION(),
+    SUBSKILL_UNLOCKED(),
+    LEVEL_UP_MESSAGE(),
+    HOLIDAY(),
+    SUBSKILL_MESSAGE(),
+    SUBSKILL_MESSAGE_FAILED(),
+    TOOL(),
+    REQUIREMENTS_NOT_MET(),
+    ABILITY_OFF(),
+    ABILITY_COOLDOWN(),
+    ABILITY_REFRESHED(),
+    SUPER_ABILITY(),
+    SUPER_ABILITY_ALERT_OTHERS(),
+    ITEM_MESSAGE(),
+    PARTY_MESSAGE()
 }
 }