From 419a7d685a7e96ae6fc2fedb6c53e16dc3892446 Mon Sep 17 00:00:00 2001 From: Sam Date: Sat, 4 Aug 2018 17:04:40 +0100 Subject: [PATCH] Clean up friends --- .../mineplex/core/friend/FriendManager.java | 513 ++++++++++-------- .../mineplex/core/friend/FriendSorter.java | 43 -- .../core/friend/FriendVisibility.java | 10 + .../core/friend/command/AddFriend.java | 5 +- .../core/friend/command/DeleteFriend.java | 20 +- .../core/friend/command/FriendsDisplay.java | 5 +- .../core/friend/data/FriendRepository.java | 165 +++--- .../core/friend/data/FriendStatus.java | 3 + .../core/friend/redis/DeleteFriend.java | 24 - .../friend/redis/DeleteFriendHandler.java | 6 - .../core/friend/redis/FriendRequest.java | 24 - .../friend/redis/FriendRequestHandler.java | 6 - .../src/mineplex/game/clans/Clans.java | 2 +- .../src/mineplex/clanshub/ClansHub.java | 2 +- .../Mineplex.Hub/src/mineplex/hub/Hub.java | 2 +- .../src/nautilus/game/arcade/Arcade.java | 2 +- .../src/mineplex/mavericks/review/Hub.java | 2 +- .../src/mineplex/gemhunters/GemHunters.java | 2 +- 18 files changed, 402 insertions(+), 434 deletions(-) delete mode 100644 Plugins/Mineplex.Core/src/mineplex/core/friend/FriendSorter.java create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/friend/FriendVisibility.java delete mode 100644 Plugins/Mineplex.Core/src/mineplex/core/friend/redis/DeleteFriend.java delete mode 100644 Plugins/Mineplex.Core/src/mineplex/core/friend/redis/DeleteFriendHandler.java delete mode 100644 Plugins/Mineplex.Core/src/mineplex/core/friend/redis/FriendRequest.java delete mode 100644 Plugins/Mineplex.Core/src/mineplex/core/friend/redis/FriendRequestHandler.java diff --git a/Plugins/Mineplex.Core/src/mineplex/core/friend/FriendManager.java b/Plugins/Mineplex.Core/src/mineplex/core/friend/FriendManager.java index d2ec01e7e..87b30b033 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/friend/FriendManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/friend/FriendManager.java @@ -2,27 +2,28 @@ package mineplex.core.friend; import java.sql.ResultSet; import java.sql.SQLException; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Iterator; +import java.util.Comparator; +import java.util.LinkedHashMap; import java.util.List; +import java.util.Map; import java.util.UUID; +import net.md_5.bungee.api.ChatColor; +import net.md_5.bungee.api.chat.ClickEvent; +import net.md_5.bungee.api.chat.ComponentBuilder; +import net.md_5.bungee.api.chat.HoverEvent; +import net.md_5.bungee.api.chat.TextComponent; + import org.bukkit.Bukkit; -import org.bukkit.ChatColor; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; -import org.bukkit.plugin.java.JavaPlugin; import mineplex.core.MiniDbClientPlugin; -import mineplex.core.account.CoreClientManager; +import mineplex.core.ReflectivelyCreateMiniPlugin; import mineplex.core.account.permissions.Permission; import mineplex.core.account.permissions.PermissionGroup; -import mineplex.core.common.jsonchat.ChildJsonMessage; -import mineplex.core.common.jsonchat.JsonMessage; import mineplex.core.common.util.C; import mineplex.core.common.util.F; -import mineplex.core.common.util.NautHashMap; import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilTime; import mineplex.core.friend.command.AddFriend; @@ -38,34 +39,73 @@ import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.serverdata.data.PlayerStatus; +@ReflectivelyCreateMiniPlugin public class FriendManager extends MiniDbClientPlugin { + public enum Perm implements Permission { FRIEND_COMMAND, JOIN_STAFF, } - private static FriendSorter _friendSorter = new FriendSorter(); - - private PreferencesManager _preferenceManager; - private FriendRepository _repository; - private Portal _portal; - - public FriendManager(JavaPlugin plugin, CoreClientManager clientManager, PreferencesManager preferences, Portal portal) + private static final Comparator FRIEND_SORTER = (o1, o2) -> { - super("Friends", plugin, clientManager); + if (o1.Online && !o2.Online) + { + return 1; + } + + if (o2.Online && !o1.Online) + { + return -1; + } + + // If both online we sort by mutual + if (o1.Online) + { + if (o1.Status == FriendStatusType.Accepted && o2.Status != FriendStatusType.Accepted) + { + return 1; + } + else if (o2.Status == FriendStatusType.Accepted && o1.Status != FriendStatusType.Accepted) + { + return -1; + } + + if (o1.Name.compareTo(o2.Name) > 0) + { + return 1; + } + else if (o2.Name.compareTo(o1.Name) > 0) + { + return -1; + } + } + + return Long.compare(o2.LastSeenOnline, o1.LastSeenOnline); + }; + private static final int FRIENDS_PER_CHAT_PAGE = 20; + + private final PreferencesManager _preferenceManager; + private final Portal _portal; + + private final FriendRepository _repository; + + private FriendManager() + { + super("Friends"); + + _preferenceManager = require(PreferencesManager.class); + _portal = require(Portal.class); + + _repository = new FriendRepository(); - _preferenceManager = preferences; - _repository = new FriendRepository(plugin); - _portal = portal; - generatePermissions(); } - + private void generatePermissions() { - PermissionGroup.PLAYER.setPermission(Perm.FRIEND_COMMAND, true, true); PermissionGroup.TRAINEE.setPermission(Perm.JOIN_STAFF, true, true); } @@ -97,35 +137,34 @@ public class FriendManager extends MiniDbClientPlugin @EventHandler public void updateFriends(UpdateEvent event) { - if (event.getType() != UpdateType.SLOW || Bukkit.getOnlinePlayers().size() == 0) + if (event.getType() != UpdateType.SLOW || UtilServer.getPlayersCollection().isEmpty()) + { return; + } final Player[] onlinePlayers = UtilServer.getPlayers(); - Bukkit.getServer().getScheduler().runTaskAsynchronously(_plugin, new Runnable() + runAsync(() -> { - public void run() - { - final NautHashMap newData = _repository.getFriendsForAll(onlinePlayers); + final Map newData = _repository.getFriendsForAll(onlinePlayers); - Bukkit.getServer().getScheduler().runTask(_plugin, new Runnable() + runSync(() -> + { + for (Player player : Bukkit.getOnlinePlayers()) { - public void run() + FriendData playerData = Get(player); + FriendData newPlayerData = newData.get(player.getUniqueId().toString()); + + if (newPlayerData != null) { - for (Player player : Bukkit.getOnlinePlayers()) - { - if (newData.containsKey(player.getUniqueId().toString())) - { - Get(player).setFriends(newData.get(player.getUniqueId().toString()).getFriends()); - } - else - { - Get(player).getFriends().clear(); - } - } + playerData.setFriends(newPlayerData.getFriends()); } - }); - } + else + { + playerData.getFriends().clear(); + } + } + }); }); } @@ -133,11 +172,12 @@ public class FriendManager extends MiniDbClientPlugin { if (caller.getName().equalsIgnoreCase(name)) { - caller.sendMessage(F.main(getName(), ChatColor.GRAY + "You cannot add yourself as a friend")); + caller.sendMessage(F.main(getName(), "You cannot add yourself as a friend")); return; } boolean update = false; + for (FriendStatus status : Get(caller).getFriends()) { if (status.Name.equalsIgnoreCase(name)) @@ -149,19 +189,17 @@ public class FriendManager extends MiniDbClientPlugin } else if (status.Status == FriendStatusType.Denied) { - caller.sendMessage(F.main(getName(), ChatColor.GREEN + name + ChatColor.GRAY - + " has denied your friend request.")); + caller.sendMessage(F.main(getName(), F.name(name) + " has denied your friend request.")); return; } else if (status.Status == FriendStatusType.Accepted) { - caller.sendMessage(F.main(getName(), "You are already friends with " + ChatColor.GREEN + name)); + caller.sendMessage(F.main(getName(), "You are already friends with " + F.name(name))); return; } else if (status.Status == FriendStatusType.Sent) { - caller.sendMessage(F.main(getName(), ChatColor.GREEN + name + ChatColor.GRAY - + " has yet to respond to your friend request.")); + caller.sendMessage(F.main(getName(), F.name(name) + " has yet to respond to your friend request.")); return; } } @@ -169,238 +207,263 @@ public class FriendManager extends MiniDbClientPlugin final boolean updateFinal = update; - Bukkit.getServer().getScheduler().runTaskAsynchronously(getPlugin(), new Runnable() + runAsync(() -> { - public void run() + if (updateFinal) { - if (updateFinal) - { - _repository.updateFriend(caller.getName(), name, "Accepted"); - _repository.updateFriend(name, caller.getName(), "Accepted"); + String statusType = FriendStatusType.Accepted.toString(); - Bukkit.getServer().getScheduler().runTask(_plugin, new Runnable() + _repository.updateFriend(caller.getName(), name, statusType); + _repository.updateFriend(name, caller.getName(), statusType); + + runSync(() -> + { + for (FriendStatus status : Get(caller).getFriends()) { - public void run() + if (status.Name.equalsIgnoreCase(name)) { - for (Iterator statusIterator = Get(caller).getFriends().iterator(); statusIterator - .hasNext();) - { - FriendStatus status = statusIterator.next(); - - if (status.Name.equalsIgnoreCase(name)) - { - status.Status = FriendStatusType.Accepted; - break; - } - } + status.Status = FriendStatusType.Accepted; + break; } - }); - } - else - { - _repository.addFriend(caller, name); - - Bukkit.getServer().getScheduler().runTask(_plugin, new Runnable() - { - public void run() - { - for (Iterator statusIterator = Get(caller).getFriends().iterator(); statusIterator - .hasNext();) - { - FriendStatus status = statusIterator.next(); - - if (status.Name.equalsIgnoreCase(name)) - { - status.Status = FriendStatusType.Sent; - break; - } - } - } - }); - } - - Bukkit.getServer().getScheduler().runTask(_plugin, new Runnable() - { - public void run() - { - if (updateFinal) - caller.sendMessage(F.main(getName(), "You and " + ChatColor.GREEN + name + ChatColor.GRAY - + " are now friends!")); - else - caller.sendMessage(F.main(getName(), "Added " + ChatColor.GREEN + name + ChatColor.GRAY - + " to your friends list!")); } }); } + else + { + _repository.addFriend(caller, name); + + runSync(() -> + { + for (FriendStatus status : Get(caller).getFriends()) + { + if (status.Name.equalsIgnoreCase(name)) + { + status.Status = FriendStatusType.Sent; + break; + } + } + }); + } + + runSync(() -> + { + if (updateFinal) + { + caller.sendMessage(F.main(getName(), "You and " + F.name(name) + " are now friends!")); + } + else + { + caller.sendMessage(F.main(getName(), "Added " + F.name(name) + " to your friends list!")); + } + }); }); } public void removeFriend(final Player caller, final String name) { - Bukkit.getServer().getScheduler().runTaskAsynchronously(getPlugin(), new Runnable() + runAsync(() -> { - public void run() + _repository.removeFriend(caller.getName(), name); + _repository.removeFriend(name, caller.getName()); + + runSync(() -> { - _repository.removeFriend(caller.getName(), name); - _repository.removeFriend(name, caller.getName()); - - Bukkit.getServer().getScheduler().runTask(_plugin, new Runnable() + for (FriendStatus status : Get(caller).getFriends()) { - public void run() + if (status.Name.equalsIgnoreCase(name)) { - for (Iterator statusIterator = Get(caller).getFriends().iterator(); statusIterator - .hasNext();) - { - FriendStatus status = statusIterator.next(); - - if (status.Name.equalsIgnoreCase(name)) - { - status.Status = FriendStatusType.Blocked; - break; - } - } - - caller.sendMessage(F.main(getName(), "Deleted " + ChatColor.GREEN + name + ChatColor.GRAY - + " from your friends list!")); + status.Status = FriendStatusType.Blocked; + break; } - }); - } + } + + caller.sendMessage(F.main(getName(), "Deleted " + F.name(name) + " from your friends list!")); + }); }); } public void showFriends(Player caller) { boolean isStaff = ClientManager.Get(caller).hasPermission(Perm.JOIN_STAFF); - boolean gotAFriend = false; + boolean showPending = _preferenceManager.get(caller).isActive(Preference.PENDING_FRIEND_REQUESTS); + List friendStatuses = Get(caller).getFriends(); - Collections.sort(friendStatuses, _friendSorter); + friendStatuses.sort(FRIEND_SORTER); - caller.sendMessage(C.cAqua + C.Strike + "======================[" + ChatColor.RESET + C.cWhite + C.Bold + "Friends" - + ChatColor.RESET + C.cAqua + C.Strike + "]======================"); + caller.sendMessage(C.cAqua + C.Strike + "======================[" + C.cWhiteB + "Friends" + C.cAqua + C.Strike + "]======================"); - List sentLines = new ArrayList<>(); - List pendingLines = new ArrayList<>(); - List onlineLines = new ArrayList<>(); - List offlineLines = new ArrayList<>(); + // Use a LinkedHashMap so we maintain insertion order + Map messages = new LinkedHashMap<>(); + String joinCommand = "/server ", friendCommand = "/" + AddFriend.COMMAND, unfriendCommand = "/" + DeleteFriend.COMMAND + " "; for (FriendStatus friend : friendStatuses) { - if (friend.Status == FriendStatusType.Blocked || friend.Status == FriendStatusType.Denied) - continue; + FriendStatusType type = friend.Status; - if (!_preferenceManager.get(caller).isActive(Preference.PENDING_FRIEND_REQUESTS) && friend.Status == FriendStatusType.Pending) - continue; - - gotAFriend = true; - - ChildJsonMessage message = new JsonMessage("").color("white").extra("").color("white"); - - if (friend.Status == FriendStatusType.Accepted) + if (type == FriendStatusType.Blocked || type == FriendStatusType.Denied || type == FriendStatusType.Pending && !showPending) { - if (friend.Online) - { - if (friend.ServerName.contains("Staff") || friend.ServerName.contains("CUST")) + continue; + } + + TextComponent message = new TextComponent(); + boolean canJoin = canJoin(friend.ServerName, isStaff); + + switch (type) + { + case Accepted: + if (friend.Online) { - if (isStaff && friend.ServerName.contains("Staff")) - message.add("Teleport").color("green").bold().click("run_command", "/server " + friend.ServerName) - .hover("show_text", "Teleport to " + friend.Name + "'s server."); + if (canJoin) + { + TextComponent teleport = new TextComponent("Teleport"); + teleport.setColor(ChatColor.GREEN); + teleport.setBold(true); + teleport.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("Teleport to " + friend.Name + "'s Server") + .create())); + teleport.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, joinCommand + friend.ServerName)); + message.addExtra(teleport); + } else - message.add("No Teleport").color("yellow").bold(); + { + TextComponent noTeleport = new TextComponent("No Teleport"); + noTeleport.setColor(ChatColor.YELLOW); + noTeleport.setBold(true); + noTeleport.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("You cannot teleport to this server") + .create())); + message.addExtra(noTeleport); + } + + message.addExtra(" - "); + } + + TextComponent delete = new TextComponent("Delete"); + delete.setColor(ChatColor.RED); + delete.setBold(true); + delete.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("Remove " + friend.Name + " from your friend list") + .create())); + delete.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, unfriendCommand + friend.Name)); + message.addExtra(delete); + + TextComponent name = new TextComponent(friend.Name); + name.setColor(friend.Online ? ChatColor.GREEN : ChatColor.GRAY); + message.addExtra(name); + + message.addExtra(" - "); + + if (friend.Online) + { + if (canJoin) + { + TextComponent server = new TextComponent(friend.ServerName); + server.setColor(ChatColor.DARK_GREEN); + message.addExtra(server); + } + else + { + TextComponent server = new TextComponent("Private Staff Server"); + server.setColor(ChatColor.YELLOW); + message.addExtra(server); + } } else - message.add("Teleport").color("green").bold().click("run_command", "/server " + friend.ServerName) - .hover("show_text", "Teleport to " + friend.Name + "'s server."); - - message.add(" - ").color("white"); - message.add("Delete").color("red").bold().click("run_command", "/unfriend " + friend.Name) - .hover("show_text", "Remove " + friend.Name + " from your friends list."); - message.add(" - ").color("white"); - message.add(friend.Name).color(friend.Online ? "green" : "gray"); - message.add(" - ").color("white"); - - if (friend.ServerName.contains("Staff") || friend.ServerName.contains("CUST")) { - if (isStaff && friend.ServerName.contains("Staff")) - message.add(friend.ServerName).color("dark_green"); - else - message.add("Private Staff Server").color("dark_green"); + TextComponent offlineFor = new TextComponent("Offline for " + UtilTime.MakeStr(friend.LastSeenOnline)); + offlineFor.setColor(ChatColor.GRAY); + message.addExtra(offlineFor); } - else - message.add(friend.ServerName).color("dark_green"); - onlineLines.add(message); - } - // Offline Friend - else - { - message.add("Delete").color("red").bold().click("run_command", "/unfriend " + friend.Name) - .hover("show_text", "Remove " + friend.Name + " from your friends list."); - message.add(" - ").color("white"); - message.add(friend.Name).color(friend.Online ? "green" : "gray"); - message.add(" - ").color("white"); - message.add("Offline for ").color("gray").add(UtilTime.MakeStr(friend.LastSeenOnline)).color("gray"); + break; + case Pending: + TextComponent accept = new TextComponent("Accept"); + accept.setColor(ChatColor.GREEN); + accept.setBold(true); + accept.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("Accept " + friend.Name + "'s friend request") + .create())); + accept.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, friendCommand + friend.Name)); + message.addExtra(accept); - offlineLines.add(message); - } + message.addExtra(" - "); + + TextComponent deny = new TextComponent("Deny"); + deny.setColor(ChatColor.RED); + deny.setBold(true); + deny.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("Deny " + friend.Name + "'s friend request") + .create())); + deny.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, unfriendCommand + friend.Name)); + message.addExtra(deny); + + message.addExtra(" - "); + + TextComponent request = new TextComponent(friend.Name + " Requested Friendship"); + request.setColor(ChatColor.GRAY); + + message.addExtra(request); + + break; + case Sent: + TextComponent cancel = new TextComponent("Cancel"); + cancel.setColor(ChatColor.RED); + cancel.setBold(true); + cancel.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("Cancel your friend request to " + friend.Name) + .create())); + cancel.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, unfriendCommand + friend.Name)); + message.addExtra(cancel); + + break; } - // Pending - else if (friend.Status == FriendStatusType.Pending) - { - message.add("Accept").color("green").bold().click("run_command", "/friend " + friend.Name) - .hover("show_text", "Accept " + friend.Name + "'s friend request."); - message.add(" - ").color("white"); - message.add("Deny").color("red").bold().click("run_command", "/unfriend " + friend.Name) - .hover("show_text", "Deny " + friend.Name + "'s friend request."); - message.add(" - ").color("white"); - message.add(friend.Name + " Requested Friendship").color("gray"); - pendingLines.add(message); - } - // Sent - else if (friend.Status == FriendStatusType.Sent) - { - message.add("Cancel").color("red").bold().click("run_command", "/unfriend " + friend.Name) - .hover("show_text", "Cancel friend request to " + friend.Name); - message.add(" - ").color("white"); - message.add(friend.Name + " Friendship Request").color("gray"); - - sentLines.add(message); - } + messages.put(friend.Name, message); } - // Send In Order - for (JsonMessage msg : sentLines) - msg.sendToPlayer(caller); - - for (JsonMessage msg : offlineLines) - msg.sendToPlayer(caller); - - for (JsonMessage msg : pendingLines) - msg.sendToPlayer(caller); - - for (JsonMessage msg : onlineLines) - msg.sendToPlayer(caller); - - if (!gotAFriend) + if (messages.isEmpty()) { caller.sendMessage(" "); caller.sendMessage("Welcome to your Friends List!"); caller.sendMessage(" "); caller.sendMessage("To add friends, type " + C.cGreen + "/friend "); caller.sendMessage(" "); - caller.sendMessage("Type " + C.cGreen + "/friend" + ChatColor.RESET + " at any time to interact with your friends!"); + caller.sendMessage("Type " + C.cGreen + "/friend" + C.Reset + " at any time to interact with your friends!"); caller.sendMessage(" "); } + else + { + messages.values().forEach(textComponent -> caller.spigot().sendMessage(textComponent)); + } - ChildJsonMessage message = new JsonMessage("").extra(C.cAqua + C.Strike + "======================"); + TextComponent toggle = new TextComponent(); - message.add(C.cDAqua + "Toggle GUI").click("run_command", "/friendsdisplay"); + TextComponent line = new TextComponent("======================"); + line.setColor(ChatColor.AQUA); + line.setStrikethrough(true); - message.hover("show_text", C.cAqua + "Toggle friends to display in an inventory"); + TextComponent command = new TextComponent("Toggle GUI"); + command.setColor(ChatColor.DARK_AQUA); + command.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("Toggle friends to display in an inventory") + .create())); + command.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/" + FriendsDisplay.COMMAND)); - message.add(C.cAqua + C.Strike + "======================"); + toggle.addExtra(line); + toggle.addExtra(command); + toggle.addExtra(line); - message.sendToPlayer(caller); + caller.spigot().sendMessage(toggle); + } + + private boolean canJoin(String serverName, boolean isPlayerStaff) + { + if (serverName == null) + { + return false; + } + + boolean staff = serverName.startsWith("Staff"), cust = serverName.startsWith("CUST"); + + if (staff) + { + return isPlayerStaff; + } + + return !cust; } public boolean isFriends(Player player, String friend) @@ -418,7 +481,6 @@ public class FriendManager extends MiniDbClientPlugin return false; } - public void updatePlayerStatus(UUID playerUUID, PlayerStatus status) { _repository.updatePlayerStatus(playerUUID, status); @@ -438,7 +500,6 @@ public class FriendManager extends MiniDbClientPlugin @Override public String getQuery(int accountId, String uuid, String name) { - return "SELECT tA.Name, status, tA.lastLogin, now(), uuidTarget FROM accountFriend INNER Join accounts AS fA ON fA.uuid = uuidSource INNER JOIN accounts AS tA ON tA.uuid = uuidTarget WHERE uuidSource = '" - + uuid + "';"; + return "SELECT tA.Name, status, tA.lastLogin, now(), uuidTarget, favourite, " + FriendRepository.GET_VISIBILITY_QUERY + " FROM accountFriend INNER JOIN accounts AS fA ON fA.uuid = uuidSource INNER JOIN accounts AS tA ON tA.uuid = uuidTarget WHERE uuidSource = '" + uuid + "';"; } } \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/friend/FriendSorter.java b/Plugins/Mineplex.Core/src/mineplex/core/friend/FriendSorter.java deleted file mode 100644 index 680c3a913..000000000 --- a/Plugins/Mineplex.Core/src/mineplex/core/friend/FriendSorter.java +++ /dev/null @@ -1,43 +0,0 @@ -package mineplex.core.friend; - -import java.util.Comparator; - -import mineplex.core.friend.data.FriendStatus; - -public class FriendSorter implements Comparator -{ - public int compare(FriendStatus a, FriendStatus b) - { - if (a.Online && !b.Online) - { - return 1; - } - - if (b.Online && !a.Online) - { - return -1; - } - - // If online we sort by mutual - if (a.Online && b.Online) - { - if (a.Status == FriendStatusType.Accepted && b.Status != FriendStatusType.Accepted) - return 1; - else if (b.Status == FriendStatusType.Accepted && a.Status != FriendStatusType.Accepted) - return -1; - - if (a.Name.compareTo(b.Name) > 0) - return 1; - else if (b.Name.compareTo(a.Name) > 0) - return -1; - } - - if (a.LastSeenOnline < b.LastSeenOnline) - return 1; - - if (b.LastSeenOnline < a.LastSeenOnline) - return -1; - - return 0; - } -} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/friend/FriendVisibility.java b/Plugins/Mineplex.Core/src/mineplex/core/friend/FriendVisibility.java new file mode 100644 index 000000000..113f62480 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/friend/FriendVisibility.java @@ -0,0 +1,10 @@ +package mineplex.core.friend; + +public enum FriendVisibility +{ + + SHOWN, + PRESENCE, + HIDDEN + +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/friend/command/AddFriend.java b/Plugins/Mineplex.Core/src/mineplex/core/friend/command/AddFriend.java index ba1c32102..00d62a683 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/friend/command/AddFriend.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/friend/command/AddFriend.java @@ -12,9 +12,12 @@ import mineplex.core.preferences.Preference; public class AddFriend extends CommandBase { + + public static final String COMMAND = "friend"; + public AddFriend(FriendManager plugin) { - super(plugin, FriendManager.Perm.FRIEND_COMMAND, "friends", "friend", "f"); + super(plugin, FriendManager.Perm.FRIEND_COMMAND, "friends", COMMAND, "f"); } @Override diff --git a/Plugins/Mineplex.Core/src/mineplex/core/friend/command/DeleteFriend.java b/Plugins/Mineplex.Core/src/mineplex/core/friend/command/DeleteFriend.java index 477791c43..dbc3814a1 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/friend/command/DeleteFriend.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/friend/command/DeleteFriend.java @@ -9,28 +9,30 @@ import mineplex.core.friend.FriendManager; public class DeleteFriend extends CommandBase { + + public static final String COMMAND = "unfriend"; + public DeleteFriend(FriendManager plugin) { - super(plugin, FriendManager.Perm.FRIEND_COMMAND, "unfriend"); + super(plugin, FriendManager.Perm.FRIEND_COMMAND, COMMAND); } @Override public void Execute(final Player caller, final String[] args) { if (args == null) - F.main(Plugin.getName(), "You need to include a player's name."); + { + caller.sendMessage(F.main(Plugin.getName(), "You need to include a player's name.")); + } else { - _commandCenter.GetClientManager().checkPlayerName(caller, args[0], new Callback() + _commandCenter.GetClientManager().checkPlayerName(caller, args[0], result -> { - public void run(String result) + if (result != null) { - if (result != null) - { - Plugin.removeFriend(caller, result); - } + Plugin.removeFriend(caller, result); } - }); + }); } } } \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/friend/command/FriendsDisplay.java b/Plugins/Mineplex.Core/src/mineplex/core/friend/command/FriendsDisplay.java index a007e16df..fddf9b309 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/friend/command/FriendsDisplay.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/friend/command/FriendsDisplay.java @@ -11,9 +11,12 @@ import mineplex.core.preferences.UserPreferences; public class FriendsDisplay extends CommandBase { + + public static final String COMMAND = "friendsdisplay"; + public FriendsDisplay(FriendManager plugin) { - super(plugin, FriendManager.Perm.FRIEND_COMMAND, "friendsdisplay"); + super(plugin, FriendManager.Perm.FRIEND_COMMAND, COMMAND); } @Override diff --git a/Plugins/Mineplex.Core/src/mineplex/core/friend/data/FriendRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/friend/data/FriendRepository.java index c2bc5b608..17d3a975a 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/friend/data/FriendRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/friend/data/FriendRepository.java @@ -9,161 +9,162 @@ import java.util.Map; import java.util.Set; import java.util.UUID; -import mineplex.core.database.MinecraftRepository; import org.bukkit.entity.Player; -import org.bukkit.plugin.java.JavaPlugin; -import mineplex.core.common.util.NautHashMap; -import mineplex.serverdata.database.DBPool; -import mineplex.serverdata.database.RepositoryBase; -import mineplex.serverdata.database.ResultSetCallable; -import mineplex.serverdata.database.column.ColumnVarChar; import mineplex.core.friend.FriendStatusType; +import mineplex.core.friend.FriendVisibility; import mineplex.serverdata.Region; import mineplex.serverdata.data.DataRepository; import mineplex.serverdata.data.PlayerStatus; +import mineplex.serverdata.database.DBPool; +import mineplex.serverdata.database.RepositoryBase; +import mineplex.serverdata.database.column.ColumnVarChar; import mineplex.serverdata.redis.RedisDataRepository; -import mineplex.serverdata.servers.ServerManager; public class FriendRepository extends RepositoryBase { - private static String CREATE_FRIEND_TABLE = "CREATE TABLE IF NOT EXISTS accountFriend (id INT NOT NULL AUTO_INCREMENT, uuidSource VARCHAR(100), uuidTarget VARCHAR(100), status VARCHAR(100), PRIMARY KEY (id), UNIQUE INDEX uuidIndex (uuidSource, uuidTarget));"; - private static String RETRIEVE_MULTIPLE_FRIEND_RECORDS = "SELECT uuidSource, tA.Name, status, tA.lastLogin, now(), uuidTarget FROM accountFriend INNER Join accounts AS fA ON fA.uuid = uuidSource INNER JOIN accounts AS tA ON tA.uuid = uuidTarget WHERE uuidSource IN "; - private static String ADD_FRIEND_RECORD = "INSERT INTO accountFriend (uuidSource, uuidTarget, status, created) SELECT fA.uuid AS uuidSource, tA.uuid AS uuidTarget, ?, now() FROM accounts as fA LEFT JOIN accounts AS tA ON tA.name = ? WHERE fA.name = ?;"; - private static String UPDATE_MUTUAL_RECORD = "UPDATE accountFriend AS aF INNER JOIN accounts as fA ON aF.uuidSource = fA.uuid INNER JOIN accounts AS tA ON aF.uuidTarget = tA.uuid SET aF.status = ? WHERE tA.name = ? AND fA.name = ?;"; - private static String DELETE_FRIEND_RECORD = "DELETE aF FROM accountFriend AS aF INNER JOIN accounts as fA ON aF.uuidSource = fA.uuid INNER JOIN accounts AS tA ON aF.uuidTarget = tA.uuid WHERE fA.name = ? AND tA.name = ?;"; - + + private static final String CREATE_FRIEND_TABLE = "CREATE TABLE IF NOT EXISTS accountFriend (id INT NOT NULL AUTO_INCREMENT, uuidSource VARCHAR(100), uuidTarget VARCHAR(100), status VARCHAR(100), PRIMARY KEY (id), UNIQUE INDEX uuidIndex (uuidSource, uuidTarget));"; + public static final String GET_VISIBILITY_QUERY = "(SELECT accountFriendData.status FROM accountFriendData WHERE accountId = tA.id) AS visibility"; + private static final String RETRIEVE_MULTIPLE_FRIEND_RECORDS = "SELECT uuidSource, tA.Name, status, tA.lastLogin, now(), uuidTarget, favourite, " + GET_VISIBILITY_QUERY + " FROM accountFriend INNER Join accounts AS fA ON fA.uuid = uuidSource INNER JOIN accounts AS tA ON tA.uuid = uuidTarget WHERE uuidSource IN "; + private static final String ADD_FRIEND_RECORD = "INSERT INTO accountFriend (uuidSource, uuidTarget, status, created) SELECT fA.uuid AS uuidSource, tA.uuid AS uuidTarget, ?, now() FROM accounts as fA LEFT JOIN accounts AS tA ON tA.name = ? WHERE fA.name = ?;"; + private static final String UPDATE_MUTUAL_RECORD = "UPDATE accountFriend AS aF INNER JOIN accounts as fA ON aF.uuidSource = fA.uuid INNER JOIN accounts AS tA ON aF.uuidTarget = tA.uuid SET aF.status = ? WHERE tA.name = ? AND fA.name = ?;"; + private static final String DELETE_FRIEND_RECORD = "DELETE aF FROM accountFriend AS aF INNER JOIN accounts as fA ON aF.uuidSource = fA.uuid INNER JOIN accounts AS tA ON aF.uuidTarget = tA.uuid WHERE fA.name = ? AND tA.name = ?;"; + // Repository holding active PlayerStatus data. - private DataRepository _repository; - - public FriendRepository(JavaPlugin plugin) + private final DataRepository _repository; + + public FriendRepository() { super(DBPool.getAccount()); - - _repository = new RedisDataRepository(ServerManager.getMasterConnection(), ServerManager.getSlaveConnection(), - Region.currentRegion(), PlayerStatus.class, "playerStatus"); + + _repository = new RedisDataRepository<>(Region.currentRegion(), PlayerStatus.class, "playerStatus"); } public boolean addFriend(final Player caller, String name) { int rowsAffected = executeUpdate(ADD_FRIEND_RECORD, new ColumnVarChar("status", 100, "Sent"), new ColumnVarChar("name", 100, name), new ColumnVarChar("name", 100, caller.getName())); - + if (rowsAffected > 0) return executeUpdate(ADD_FRIEND_RECORD, new ColumnVarChar("status", 100, "Pending"), new ColumnVarChar("name", 100, caller.getName()), new ColumnVarChar("uuid", 100, name)) > 0; - + return false; } - + public boolean updateFriend(String caller, String name, String status) - { + { return executeUpdate(UPDATE_MUTUAL_RECORD, new ColumnVarChar("status", 100, status), new ColumnVarChar("uuid", 100, name), new ColumnVarChar("name", 100, caller)) > 0; } - + public boolean removeFriend(String caller, String name) { int rowsAffected = executeUpdate(DELETE_FRIEND_RECORD, new ColumnVarChar("name", 100, name), new ColumnVarChar("name", 100, caller)); - + if (rowsAffected > 0) return executeUpdate(DELETE_FRIEND_RECORD, new ColumnVarChar("name", 100, caller), new ColumnVarChar("uuid", 100, name)) > 0; - + return false; } - - public NautHashMap getFriendsForAll(Player...players) + + public Map getFriendsForAll(Player... players) { - final NautHashMap friends = new NautHashMap(); - + final Map friends = new HashMap<>(); + StringBuilder stringBuilder = new StringBuilder(); - stringBuilder.append(RETRIEVE_MULTIPLE_FRIEND_RECORDS + "("); - + stringBuilder.append(RETRIEVE_MULTIPLE_FRIEND_RECORDS).append("("); + for (Player player : players) { - stringBuilder.append("'" + player.getUniqueId() + "', "); + stringBuilder + .append("'") + .append(player.getUniqueId()) + .append("', "); } - + stringBuilder.delete(stringBuilder.length() - 2, stringBuilder.length()); stringBuilder.append(");"); - executeQuery(stringBuilder.toString(), new ResultSetCallable() + executeQuery(stringBuilder.toString(), resultSet -> { - public void processResultSet(ResultSet resultSet) throws SQLException + Set friendDatas = new HashSet<>(); + + while (resultSet.next()) { - Set friendDatas = new HashSet(); - while (resultSet.next()) - { - FriendStatus friend = new FriendStatus(); - - String uuidSource = resultSet.getString(1); - friend.Name = resultSet.getString(2); - friend.Status = Enum.valueOf(FriendStatusType.class, resultSet.getString(3)); - friend.LastSeenOnline = resultSet.getTimestamp(5).getTime() - resultSet.getTimestamp(4).getTime(); - friend.UUID = UUID.fromString(resultSet.getString(6)); - - if (!friends.containsKey(uuidSource)) - friends.put(uuidSource, new FriendData()); - - friends.get(uuidSource).getFriends().add(friend); - - friendDatas.add(friends.get(uuidSource)); - } - - // Load the server status of friends for all sources. - for(FriendData friendData : friendDatas) - { - loadFriendStatuses(friendData); - } + FriendStatus friend = new FriendStatus(); + + String uuidSource = resultSet.getString(1); + friend.Name = resultSet.getString(2); + friend.Status = FriendStatusType.valueOf(resultSet.getString(3)); + friend.LastSeenOnline = resultSet.getTimestamp(5).getTime() - resultSet.getTimestamp(4).getTime(); + friend.UUID = UUID.fromString(resultSet.getString(6)); + friend.Visibility = FriendVisibility.values()[resultSet.getByte("visibility")]; + friend.Favourite = resultSet.getBoolean("favourite"); + + FriendData data = friends.computeIfAbsent(uuidSource, k -> new FriendData()); + data.getFriends().add(friend); + friendDatas.add(data); + } + + // Load the server status of friends for all sources. + for (FriendData friendData : friendDatas) + { + loadFriendStatuses(friendData); } }); - + return friends; } - + public FriendData loadClientInformation(ResultSet resultSet) throws SQLException { FriendData friendData = new FriendData(); - + while (resultSet.next()) { FriendStatus friend = new FriendStatus(); - + friend.Name = resultSet.getString(1); - friend.Status = Enum.valueOf(FriendStatusType.class, resultSet.getString(2)); + friend.Status = FriendStatusType.valueOf(resultSet.getString(2)); friend.LastSeenOnline = resultSet.getTimestamp(4).getTime() - resultSet.getTimestamp(3).getTime(); friend.UUID = UUID.fromString(resultSet.getString(5)); friend.ServerName = null; - friend.Online = (friend.ServerName != null); + friend.Online = false; + friend.Visibility = FriendVisibility.values()[resultSet.getByte("visibility")]; + friend.Favourite = resultSet.getBoolean("favourite"); friendData.getFriends().add(friend); } loadFriendStatuses(friendData); - + return friendData; } - + /** * Load the server status information for a list of {@link FriendStatus}. + * * @param friendData - the {@link FriendStatus} object friends server status' are to be updated - * @param statuses - the fetched {@link PlayerStatus} associated with all online {@code friends}. - */ + */ public void loadFriendStatuses(FriendData friendData) { // Generate a set of all friend names Set friendUUIDS = new HashSet<>(); - for(FriendStatus status : friendData.getFriends()) + + for (FriendStatus status : friendData.getFriends()) { friendUUIDS.add(status.UUID.toString()); } - + // Load PlayerStatus' for friends Collection statuses = _repository.getElements(friendUUIDS); - + // Load player statuses into a mapping Map playerStatuses = new HashMap<>(); - for(PlayerStatus status : statuses) + + for (PlayerStatus status : statuses) { playerStatuses.put(status.getUUID(), status); } - + // Load status information into friend data. for (FriendStatus friend : friendData.getFriends()) { @@ -172,18 +173,6 @@ public class FriendRepository extends RepositoryBase friend.ServerName = (friend.Online) ? status.getServer() : null; } } - - /** - * @param playerName - the name of the player whose current server status is being fetched - * @return the name that the player matching {@code playerName} - * is currently online on, if they are online, null otherwise. - */ - public String fetchPlayerServer(UUID playerUUID) - { - PlayerStatus status = _repository.getElement(playerUUID.toString()); - - return (status == null) ? null : status.getServer(); - } public void updatePlayerStatus(UUID playerUUID, PlayerStatus status) { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/friend/data/FriendStatus.java b/Plugins/Mineplex.Core/src/mineplex/core/friend/data/FriendStatus.java index fa5f10870..2d5322cd7 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/friend/data/FriendStatus.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/friend/data/FriendStatus.java @@ -3,6 +3,7 @@ package mineplex.core.friend.data; import java.util.UUID; import mineplex.core.friend.FriendStatusType; +import mineplex.core.friend.FriendVisibility; public class FriendStatus { @@ -15,4 +16,6 @@ public class FriendStatus */ public long LastSeenOnline; public FriendStatusType Status; + public FriendVisibility Visibility; + public boolean Favourite; } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/friend/redis/DeleteFriend.java b/Plugins/Mineplex.Core/src/mineplex/core/friend/redis/DeleteFriend.java deleted file mode 100644 index 3f7ff0438..000000000 --- a/Plugins/Mineplex.Core/src/mineplex/core/friend/redis/DeleteFriend.java +++ /dev/null @@ -1,24 +0,0 @@ -package mineplex.core.friend.redis; - -import mineplex.serverdata.commands.ServerCommand; - -public class DeleteFriend extends ServerCommand -{ - private String _deleter; - private String _deleted; - - public String getDeleter() { return _deleter; } - public String getDeleted() { return _deleted; } - - public DeleteFriend(String deleter, String deleted) - { - _deleter = deleter; - _deleted = deleted; - } - - @Override - public void run() - { - // Utilitizes a callback functionality to seperate dependencies - } -} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/friend/redis/DeleteFriendHandler.java b/Plugins/Mineplex.Core/src/mineplex/core/friend/redis/DeleteFriendHandler.java deleted file mode 100644 index 2cff73b84..000000000 --- a/Plugins/Mineplex.Core/src/mineplex/core/friend/redis/DeleteFriendHandler.java +++ /dev/null @@ -1,6 +0,0 @@ -package mineplex.core.friend.redis; - -public class DeleteFriendHandler -{ - -} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/friend/redis/FriendRequest.java b/Plugins/Mineplex.Core/src/mineplex/core/friend/redis/FriendRequest.java deleted file mode 100644 index 3dfd23205..000000000 --- a/Plugins/Mineplex.Core/src/mineplex/core/friend/redis/FriendRequest.java +++ /dev/null @@ -1,24 +0,0 @@ -package mineplex.core.friend.redis; - -import mineplex.serverdata.commands.ServerCommand; - -public class FriendRequest extends ServerCommand -{ - private String _requester; - private String _requested; - - public String getRequester() { return _requester; } - public String getRequested() { return _requested; } - - public FriendRequest(String requester, String requested) - { - _requester = requester; - _requested = requested; - } - - @Override - public void run() - { - // Utilitizes a callback functionality to seperate dependencies - } -} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/friend/redis/FriendRequestHandler.java b/Plugins/Mineplex.Core/src/mineplex/core/friend/redis/FriendRequestHandler.java deleted file mode 100644 index 7e43e2922..000000000 --- a/Plugins/Mineplex.Core/src/mineplex/core/friend/redis/FriendRequestHandler.java +++ /dev/null @@ -1,6 +0,0 @@ -package mineplex.core.friend.redis; - -public class FriendRequestHandler -{ - -} diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/Clans.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/Clans.java index 48891dca3..998bbbf16 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/Clans.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/Clans.java @@ -162,7 +162,7 @@ public class Clans extends JavaPlugin EloManager eloManager = new EloManager(this, _clientManager); AchievementManager achievementManager = new AchievementManager(statsManager, _clientManager, _donationManager, incognito, eloManager); Chat chat = new Chat(); - new MessageManager(this, incognito, _clientManager, preferenceManager, ignoreManager, punish, new FriendManager(this, _clientManager, preferenceManager, portal), chat); + new MessageManager(this, incognito, _clientManager, preferenceManager, ignoreManager, punish, require(FriendManager.class), chat); new MemoryFix(this); new FoodDupeFix(this); diff --git a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/ClansHub.java b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/ClansHub.java index 9c0151458..c3df220f9 100644 --- a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/ClansHub.java +++ b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/ClansHub.java @@ -140,7 +140,7 @@ public class ClansHub extends JavaPlugin IgnoreManager ignoreManager = new IgnoreManager(this, clientManager, preferenceManager, portal); - FriendManager friendManager = new FriendManager(this, clientManager, preferenceManager, portal); + FriendManager friendManager = require(FriendManager.class); StatsManager statsManager = new StatsManager(this, clientManager); EloManager eloManager = new EloManager(this, clientManager); diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java b/Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java index 88f0a79ac..6d0bf9807 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java @@ -138,7 +138,7 @@ public class Hub extends JavaPlugin implements IRelation IgnoreManager ignoreManager = new IgnoreManager(this, clientManager, preferenceManager, portal); - FriendManager friendManager = new FriendManager(this, clientManager, preferenceManager, portal); + FriendManager friendManager = require(FriendManager.class); StatsManager statsManager = new StatsManager(this, clientManager); EloManager eloManager = new EloManager(this, clientManager); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/Arcade.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/Arcade.java index e575ed176..1f79b2a0f 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/Arcade.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/Arcade.java @@ -164,7 +164,7 @@ public class Arcade extends JavaPlugin StatsManager statsManager = new StatsManager(this, clientManager); EloManager eloManager = new EloManager(this, clientManager); AchievementManager achievementManager = new AchievementManager(statsManager, clientManager, donationManager, incognito, eloManager); - FriendManager friendManager = new FriendManager(this, clientManager, preferenceManager, portal); + FriendManager friendManager = require(FriendManager.class); Chat chat = new Chat(); new MessageManager(this, incognito, clientManager, preferenceManager, ignoreManager, punish, friendManager, chat); diff --git a/Plugins/mavericks-review-hub/src/mineplex/mavericks/review/Hub.java b/Plugins/mavericks-review-hub/src/mineplex/mavericks/review/Hub.java index 81c4a18ea..c248d3bc9 100644 --- a/Plugins/mavericks-review-hub/src/mineplex/mavericks/review/Hub.java +++ b/Plugins/mavericks-review-hub/src/mineplex/mavericks/review/Hub.java @@ -113,7 +113,7 @@ public class Hub extends JavaPlugin StatsManager statsManager = new StatsManager(this, _clientManager); EloManager eloManager = new EloManager(this, _clientManager); AchievementManager achievementManager = new AchievementManager(statsManager, _clientManager, _donationManager, incognito, eloManager); - FriendManager friendManager = new FriendManager(this, _clientManager, preferenceManager, portal); + FriendManager friendManager = require(FriendManager.class); Chat chat = new Chat(); new MessageManager(this, incognito, _clientManager, preferenceManager, ignoreManager, punish, friendManager, chat); diff --git a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/GemHunters.java b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/GemHunters.java index 6e8dfafdb..623d757d7 100644 --- a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/GemHunters.java +++ b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/GemHunters.java @@ -211,7 +211,7 @@ public class GemHunters extends JavaPlugin // Chat/Messaging Chat chat = new Chat(); - new MessageManager(this, incognito, clientManager, preferenceManager, ignoreManager, punish, new FriendManager(this, clientManager, preferenceManager, portal), chat); + new MessageManager(this, incognito, clientManager, preferenceManager, ignoreManager, punish, require(FriendManager.class), chat); // Parties new PartyManager();