diff --git a/Plugins/Mineplex.Core/src/mineplex/core/friend/FriendManager.java b/Plugins/Mineplex.Core/src/mineplex/core/friend/FriendManager.java index 87b30b033..164dfdf41 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/friend/FriendManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/friend/FriendManager.java @@ -294,7 +294,7 @@ public class FriendManager extends MiniDbClientPlugin // Use a LinkedHashMap so we maintain insertion order Map messages = new LinkedHashMap<>(); - String joinCommand = "/server ", friendCommand = "/" + AddFriend.COMMAND, unfriendCommand = "/" + DeleteFriend.COMMAND + " "; + String joinCommand = "/server ", friendCommand = "/" + AddFriend.COMMAND + " ", unfriendCommand = "/" + DeleteFriend.COMMAND + " ", favouriteCommand = "/Hello"; for (FriendStatus friend : friendStatuses) { @@ -305,8 +305,8 @@ public class FriendManager extends MiniDbClientPlugin continue; } - TextComponent message = new TextComponent(); - boolean canJoin = canJoin(friend.ServerName, isStaff); + TextComponent message = new TextComponent(""); + boolean canJoin = canJoin(friend.ServerName, isStaff) && friend.Visibility == FriendVisibility.SHOWN; switch (type) { @@ -344,13 +344,32 @@ public class FriendManager extends MiniDbClientPlugin delete.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, unfriendCommand + friend.Name)); message.addExtra(delete); + message.addExtra(" - "); + TextComponent name = new TextComponent(friend.Name); + + if (friend.Favourite) + { + name.setColor(ChatColor.YELLOW); + } + else if (friend.Online) + { + name.setColor(ChatColor.GREEN); + } + else + { + name.setColor(ChatColor.GRAY); + } + name.setColor(friend.Online ? ChatColor.GREEN : ChatColor.GRAY); + name.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(friend.Favourite ? ("Add " + friend.Name + " to") : ("Remove " + friend.Name + " from") + " your favourite friends") + .create())); + name.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, favouriteCommand + friend.Name)); message.addExtra(name); message.addExtra(" - "); - if (friend.Online) + if (friend.Online && friend.Visibility != FriendVisibility.INVISIBLE) { if (canJoin) { @@ -358,6 +377,14 @@ public class FriendManager extends MiniDbClientPlugin server.setColor(ChatColor.DARK_GREEN); message.addExtra(server); } + else if (friend.Visibility == FriendVisibility.PRESENCE) + { + TextComponent server = new TextComponent("Hidden"); + server.setColor(ChatColor.DARK_GREEN); + server.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(friend.Name + " is in hidden mode") + .create())); + message.addExtra(server); + } else { TextComponent server = new TextComponent("Private Staff Server"); @@ -409,6 +436,12 @@ public class FriendManager extends MiniDbClientPlugin cancel.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, unfriendCommand + friend.Name)); message.addExtra(cancel); + message.addExtra(" - "); + + TextComponent pending = new TextComponent(friend.Name + " Request Pending"); + pending.setColor(ChatColor.GRAY); + + message.addExtra(pending); break; } @@ -430,7 +463,7 @@ public class FriendManager extends MiniDbClientPlugin messages.values().forEach(textComponent -> caller.spigot().sendMessage(textComponent)); } - TextComponent toggle = new TextComponent(); + TextComponent toggle = new TextComponent(""); TextComponent line = new TextComponent("======================"); line.setColor(ChatColor.AQUA); @@ -449,7 +482,7 @@ public class FriendManager extends MiniDbClientPlugin caller.spigot().sendMessage(toggle); } - private boolean canJoin(String serverName, boolean isPlayerStaff) + public boolean canJoin(String serverName, boolean isPlayerStaff) { if (serverName == null) { @@ -466,31 +499,11 @@ public class FriendManager extends MiniDbClientPlugin return !cust; } - public boolean isFriends(Player player, String friend) - { - FriendData friendData = Get(player); - - for (FriendStatus friendStatus : friendData.getFriends()) - { - if (friendStatus.Name.equalsIgnoreCase(friend)) - { - return true; - } - } - - return false; - } - public void updatePlayerStatus(UUID playerUUID, PlayerStatus status) { _repository.updatePlayerStatus(playerUUID, status); } - public PlayerStatus getStatus(UUID playerUUID) - { - return _repository.getStatus(playerUUID); - } - @Override public void processLoginResultSet(String playerName, UUID uuid, int accountId, ResultSet resultSet) throws SQLException { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/friend/FriendVisibility.java b/Plugins/Mineplex.Core/src/mineplex/core/friend/FriendVisibility.java index 113f62480..028b6de6c 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/friend/FriendVisibility.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/friend/FriendVisibility.java @@ -5,6 +5,6 @@ public enum FriendVisibility SHOWN, PRESENCE, - HIDDEN + INVISIBLE }