From b45146cca4355069c4d26e3c4b25da8e38330290 Mon Sep 17 00:00:00 2001 From: Spencer Date: Tue, 15 May 2018 21:48:29 -0400 Subject: [PATCH] add preference to only allow friends to message you (default true) --- .../src/mineplex/core/message/MessageManager.java | 9 ++++++--- .../src/mineplex/core/preferences/Preference.java | 6 +++++- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/message/MessageManager.java b/Plugins/Mineplex.Core/src/mineplex/core/message/MessageManager.java index 4a87fe786..22141925e 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/message/MessageManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/message/MessageManager.java @@ -546,9 +546,7 @@ public class MessageManager extends MiniClientPlugin for (FriendStatus friendInfo : friends.getFriends()) { // Don't consider them "the friend" if their request has not been accepted - // and the player doesn't want pending/prior requesting players to msg them - if (friendInfo.Status != FriendStatusType.Accepted - && !_preferences.get(sender).isActive(Preference.UNCONFIRMED_FRIEND_MESSAGES)) + if (friendInfo.Status != FriendStatusType.Accepted) { continue; } @@ -613,6 +611,11 @@ public class MessageManager extends MiniClientPlugin } else { + if (_preferences.get(to).isActive(Preference.FRIEND_MESSAGES_ONLY)) { + sender.sendMessage(F.main(getName(), F.name(target) + " only allows messages from friends.")); + return; + } + DoMessage(sender, to, message); } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/preferences/Preference.java b/Plugins/Mineplex.Core/src/mineplex/core/preferences/Preference.java index fcf28e15e..5739dcea2 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/preferences/Preference.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/preferences/Preference.java @@ -59,11 +59,15 @@ public enum Preference implements Permission UNLOCK_KITS(true, PreferenceCategory.EXCLUSIVE, Material.IRON_DOOR, "Unlock All Kits", "Enabling this will allow you", "to have access to every kit ", "in every game for free!"), AUTO_QUEUE(true, PreferenceCategory.USER, Material.EMERALD, "Teleport to Game Area", "Enabling this will teleport you to the", "game area instead of opening the server", "selector when choosing a game."), - UNCONFIRMED_FRIEND_MESSAGES(true, PreferenceCategory.SOCIAL, Material.SKULL_ITEM, "Unconfirmed Friend Messages", "Enabling this will allow you to receive", "private messages from players who", "have a pending/prior friend request with you!"), + FRIEND_MESSAGES_ONLY(true, PreferenceCategory.SOCIAL, Material.SKULL_ITEM, "Friend Messages Only", + "Enabling this will only allow", "friends to send you private", "messages.", + "", "If you have private messages", "disabled, this preference", "has no effect."), BYPASS_CHAT_FILTER(false, PreferenceCategory.EXCLUSIVE, Material.GLASS, "Bypass Chat Filter", "Enabling this will allow you", "to bypass the chat filter everywhere.", "", "Proceed with caution."), COLOR_SUFFIXES(true, PreferenceCategory.USER, Material.WOOL, "Color Chat Suffixes", "Enabling this will color your", "chat suffixes like ¯\\_(ツ)_/¯", "based on your rank.") + + ; private static final Map PREFERENCE_MAP = Maps.newHashMap();