Add notification settings

This commit is contained in:
nossr50
2019-06-12 09:51:22 -07:00
parent b29d87df8c
commit b03abcdee8
8 changed files with 124 additions and 65 deletions

View File

@@ -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;
}
}

View File

@@ -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;
}
}

View File

@@ -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;

View File

@@ -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<NotificationType, PlayerNotification> getNotificationSettingHashMap() {
return playerNotifications.getNotificationSettingHashMap();
}
public PlayerNotification getPlayerNotification(NotificationType notificationType) {
return playerNotifications.getPlayerNotification(notificationType);
}
}

View File

@@ -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);
}
}

View File

@@ -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;
}
}