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

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

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

View File

@ -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." + @Setting(value = "Player-Notifications", comment = "Settings for player notifications" +
"\nThe action bar is the area above your health and armor.") "\nPlayer notifications are often sent to the action bar (The action bar is the location above player health/armor/hunger displays)" +
private ConfigActionBarNotifications actionBarNotifications = new ConfigActionBarNotifications(); "\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() { public ConfigPlayerNotifications getPlayerNotificationsConfig() {
return actionBarNotifications; 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);
}
} }

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

View File

@ -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(),
HARDCORE_MODE("HardcoreMode"), NO_PERMISSION(),
NO_PERMISSION("NoPermission"), SUBSKILL_UNLOCKED(),
SUBSKILL_UNLOCKED("SubSkillUnlocked"), LEVEL_UP_MESSAGE(),
LEVEL_UP_MESSAGE("LevelUps"), HOLIDAY(),
HOLIDAY("Holiday"), SUBSKILL_MESSAGE(),
SUBSKILL_MESSAGE("SubSkillInteraction"), SUBSKILL_MESSAGE_FAILED(),
SUBSKILL_MESSAGE_FAILED("SubSkillFailed"), TOOL(),
TOOL("ToolReady"), REQUIREMENTS_NOT_MET(),
REQUIREMENTS_NOT_MET("RequirementsNotMet"), ABILITY_OFF(),
ABILITY_OFF("AbilityOff"), ABILITY_COOLDOWN(),
ABILITY_COOLDOWN("AbilityCoolDown"), ABILITY_REFRESHED(),
ABILITY_REFRESHED("AbilityRefreshed"), SUPER_ABILITY(),
SUPER_ABILITY("SuperAbilityInteraction"), SUPER_ABILITY_ALERT_OTHERS(),
SUPER_ABILITY_ALERT_OTHERS("SuperAbilityAlertOthers"), ITEM_MESSAGE(),
ITEM_MESSAGE("ItemMessage"), PARTY_MESSAGE()
CHAT_ONLY("ChatOnly"),
PARTY_MESSAGE("PartyMessage");
final String niceName;
NotificationType(String niceName) {
this.niceName = niceName;
}
@Override
public String toString() {
return niceName;
}
} }