add preference to only allow friends to message you (default true)

This commit is contained in:
Spencer 2018-05-15 21:48:29 -04:00 committed by Alexander Meech
parent 22a36c6174
commit b45146cca4
2 changed files with 11 additions and 4 deletions

View File

@ -546,9 +546,7 @@ public class MessageManager extends MiniClientPlugin<ClientMessage>
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<ClientMessage>
}
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);
}
}

View File

@ -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<Integer, Preference> PREFERENCE_MAP = Maps.newHashMap();