diff --git a/Changelog.txt b/Changelog.txt index 827dca26d..d0c3331a3 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -40,6 +40,7 @@ Version 2.2.0 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 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 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. diff --git a/src/main/java/com/gmail/nossr50/config/hocon/notifications/ActionBarNotificationSetting.java b/src/main/java/com/gmail/nossr50/config/hocon/notifications/ActionBarNotificationSetting.java deleted file mode 100644 index 26d0c0ac9..000000000 --- a/src/main/java/com/gmail/nossr50/config/hocon/notifications/ActionBarNotificationSetting.java +++ /dev/null @@ -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; - } -} \ No newline at end of file diff --git a/src/main/java/com/gmail/nossr50/config/hocon/notifications/ConfigActionBarNotifications.java b/src/main/java/com/gmail/nossr50/config/hocon/notifications/ConfigActionBarNotifications.java deleted file mode 100644 index 2f0159ce8..000000000 --- a/src/main/java/com/gmail/nossr50/config/hocon/notifications/ConfigActionBarNotifications.java +++ /dev/null @@ -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 notificationSettingHashMap; - - public HashMap getNotificationSettingHashMap() { - return notificationSettingHashMap; - } -} \ No newline at end of file diff --git a/src/main/java/com/gmail/nossr50/config/hocon/notifications/ConfigNotificationGeneral.java b/src/main/java/com/gmail/nossr50/config/hocon/notifications/ConfigNotificationGeneral.java index 99fd360c9..dd44ba64e 100644 --- a/src/main/java/com/gmail/nossr50/config/hocon/notifications/ConfigNotificationGeneral.java +++ b/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 { 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." + "\n Default value: " + PLAYER_TIPS_DEFAULT) private boolean playerTips = PLAYER_TIPS_DEFAULT; diff --git a/src/main/java/com/gmail/nossr50/config/hocon/notifications/ConfigNotifications.java b/src/main/java/com/gmail/nossr50/config/hocon/notifications/ConfigNotifications.java index 163358e18..abce3a9bf 100644 --- a/src/main/java/com/gmail/nossr50/config/hocon/notifications/ConfigNotifications.java +++ b/src/main/java/com/gmail/nossr50/config/hocon/notifications/ConfigNotifications.java @@ -1,16 +1,20 @@ 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 ConfigNotifications { 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") @@ -37,11 +41,19 @@ public class ConfigNotifications { return superAbilityToolMessage; } - public ConfigActionBarNotifications getActionBarNotifications() { - return actionBarNotifications; + public ConfigPlayerNotifications getPlayerNotificationsConfig() { + return playerNotifications; } public ConfigNotificationGeneral getConfigNotificationGeneral() { return configNotificationGeneral; } + + public HashMap getNotificationSettingHashMap() { + return playerNotifications.getNotificationSettingHashMap(); + } + + public PlayerNotification getPlayerNotification(NotificationType notificationType) { + return playerNotifications.getPlayerNotification(notificationType); + } } diff --git a/src/main/java/com/gmail/nossr50/config/hocon/notifications/ConfigPlayerNotifications.java b/src/main/java/com/gmail/nossr50/config/hocon/notifications/ConfigPlayerNotifications.java new file mode 100644 index 000000000..f7a17e6fb --- /dev/null +++ b/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 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 notificationSettingHashMap = NOTIFICATION_MAP_DEFAULT; + + public HashMap getNotificationSettingHashMap() { + return notificationSettingHashMap; + } + + public PlayerNotification getPlayerNotification(NotificationType notificationType) { + return notificationSettingHashMap.get(notificationType); + } +} \ No newline at end of file diff --git a/src/main/java/com/gmail/nossr50/config/hocon/notifications/PlayerNotification.java b/src/main/java/com/gmail/nossr50/config/hocon/notifications/PlayerNotification.java new file mode 100644 index 000000000..b195f505a --- /dev/null +++ b/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; + } +} \ No newline at end of file diff --git a/src/main/java/com/gmail/nossr50/datatypes/interactions/NotificationType.java b/src/main/java/com/gmail/nossr50/datatypes/interactions/NotificationType.java index 3f3a8a086..ac7b02ed3 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/interactions/NotificationType.java +++ b/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 */ 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() }