From c641eab3c7d9540881cc33d31abbba07ab044565 Mon Sep 17 00:00:00 2001 From: Jonathan Williams Date: Fri, 3 Oct 2014 01:50:23 -0700 Subject: [PATCH] Fixed up friends. --- .../repository/MysqlAccountRepository.java | 3 - .../mineplex/core/friend/FriendManager.java | 181 ++++++++++++++++-- .../mineplex/core/friend/FriendSorter.java | 18 +- .../core/friend/FriendStatusType.java | 10 + .../core/friend/command/AddFriend.java | 2 +- .../core/friend/data/FriendRepository.java | 37 ++-- .../core/friend/data/FriendStatus.java | 4 +- .../core/friend/ui/FriendTabList.java | 54 ------ .../preferences/PreferencesRepository.java | 8 +- .../core/preferences/UserPreferences.java | 1 + .../core/preferences/ui/PreferencesPage.java | 55 ++++-- .../Mineplex.Hub/src/mineplex/hub/Hub.java | 2 +- .../src/nautilus/game/arcade/Arcade.java | 5 +- 13 files changed, 251 insertions(+), 129 deletions(-) create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/friend/FriendStatusType.java delete mode 100644 Plugins/Mineplex.Core/src/mineplex/core/friend/ui/FriendTabList.java diff --git a/Plugins/Mineplex.Core/src/mineplex/core/account/repository/MysqlAccountRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/account/repository/MysqlAccountRepository.java index 638c3b8cd..f442a4213 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/account/repository/MysqlAccountRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/account/repository/MysqlAccountRepository.java @@ -30,9 +30,6 @@ public class MysqlAccountRepository extends RepositoryBase int affectedRows = executeUpdate(ACCOUNT_LOGIN_UPDATE, new ColumnVarChar("uuid", 100, uuid), new ColumnVarChar("name", 40, name), new ColumnVarChar("uuid", 100, uuid)); if (affectedRows == 0) - { executeUpdate(ACCOUNT_LOGIN_NEW, new ColumnVarChar("uuid", 100, uuid), new ColumnVarChar("name", 40, name)); - System.out.println("Executed LOGIN_NEW"); - } } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/friend/FriendManager.java b/Plugins/Mineplex.Core/src/mineplex/core/friend/FriendManager.java index 02706fe38..20be01b3e 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/friend/FriendManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/friend/FriendManager.java @@ -1,6 +1,7 @@ package mineplex.core.friend; import java.util.Collections; +import java.util.Iterator; import java.util.List; import org.bukkit.Bukkit; @@ -23,6 +24,7 @@ import mineplex.core.friend.command.DeleteFriend; import mineplex.core.friend.data.FriendData; import mineplex.core.friend.data.FriendRepository; import mineplex.core.friend.data.FriendStatus; +import mineplex.core.preferences.PreferencesManager; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; @@ -30,12 +32,14 @@ public class FriendManager extends MiniClientPlugin { private static FriendSorter _friendSorter = new FriendSorter(); + private PreferencesManager _preferenceManager; private FriendRepository _repository; - public FriendManager(JavaPlugin plugin) + public FriendManager(JavaPlugin plugin, PreferencesManager preferences) { super("Friends", plugin); + _preferenceManager = preferences; _repository = new FriendRepository(plugin); } @@ -72,11 +76,13 @@ public class FriendManager extends MiniClientPlugin if (event.getType() != UpdateType.SLOW || Bukkit.getOnlinePlayers().size() == 0) return; + final Player[] onlinePlayers = UtilServer.getPlayers(); + Bukkit.getServer().getScheduler().runTaskAsynchronously(_plugin, new Runnable() { public void run() { - final NautHashMap newData = _repository.getFriendsForAll(UtilServer.getPlayers()); + final NautHashMap newData = _repository.getFriendsForAll(onlinePlayers); Bukkit.getServer().getScheduler().runTask(_plugin, new Runnable() { @@ -101,17 +107,92 @@ public class FriendManager extends MiniClientPlugin public void addFriend(final Player caller, final String name) { + boolean update = false; + for (FriendStatus status : Get(caller).Friends) + { + if (status.Name.equalsIgnoreCase(name)) + { + if (status.Status == FriendStatusType.Pending || status.Status == FriendStatusType.Blocked) + { + update = true; + break; + } + else if (status.Status == FriendStatusType.Denied) + { + caller.sendMessage(F.main(GetName(), ChatColor.GREEN + name + ChatColor.GRAY + " 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)); + 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.")); + return; + } + } + } + + final boolean updateFinal = update; + Bukkit.getServer().getScheduler().runTaskAsynchronously(GetPlugin(), new Runnable() { public void run() { - _repository.addFriend(caller, name); + if (updateFinal) + { + _repository.updateFriend(caller.getName(), name, "Accepted"); + _repository.updateFriend(name, caller.getName(), "Accepted"); + + Bukkit.getServer().getScheduler().runTask(_plugin, new Runnable() + { + public void run() + { + for (Iterator statusIterator = Get(caller).Friends.iterator(); statusIterator.hasNext();) + { + FriendStatus status = statusIterator.next(); + + if (status.Name.equalsIgnoreCase(name)) + { + 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).Friends.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() { - caller.sendMessage(F.main(GetName(), "Added " + ChatColor.GREEN + name + " to your friends list!")); + 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!")); } }); } @@ -120,17 +201,54 @@ public class FriendManager extends MiniClientPlugin public void removeFriend(final Player caller, final String name) { + boolean delete = false; + + for (Iterator statusIterator = Get(caller).Friends.iterator(); statusIterator.hasNext();) + { + FriendStatus status = statusIterator.next(); + + if (status.Name.equalsIgnoreCase(name)) + { + if (status.Status == FriendStatusType.Sent) + { + delete = true; + statusIterator.remove(); + } + break; + } + } + + final boolean deleteFinal = delete; Bukkit.getServer().getScheduler().runTaskAsynchronously(GetPlugin(), new Runnable() { public void run() { - _repository.removeFriend(caller.getUniqueId().toString(), name); + if (deleteFinal) + { + _repository.removeFriend(caller.getName(), name); + } + else + { + _repository.updateFriend(caller.getName(), name, "Blocked"); + _repository.updateFriend(name, caller.getName(), "Denied"); + } Bukkit.getServer().getScheduler().runTask(_plugin, new Runnable() { public void run() { - caller.sendMessage(F.main(GetName(), "Deleted " + ChatColor.GREEN + name + " from your friends list!")); + for (Iterator statusIterator = Get(caller).Friends.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!")); } }); } @@ -139,28 +257,55 @@ public class FriendManager extends MiniClientPlugin public void showFriends(Player caller) { + boolean gotAFriend = false; List friendStatuses = Get(caller).Friends; Collections.sort(friendStatuses, _friendSorter); - caller.sendMessage(C.cBlue + "======================[" + ChatColor.RESET + C.cYellow + C.Bold + "Friends" + ChatColor.RESET + C.cBlue + "]======================"); - + caller.sendMessage(C.cAqua + C.Strike + "======================[" + ChatColor.RESET + C.cWhite + C.Bold + "Friends" + ChatColor.RESET + C.cAqua + C.Strike + "]======================"); + for (FriendStatus friend : friendStatuses) { - ChildJsonMessage message = new JsonMessage(friend.Name).color(friend.Online ? "gold" : "gray").extra(" - ").color("white"); + if (friend.Status == FriendStatusType.Blocked || friend.Status == FriendStatusType.Denied) + continue; - if (friend.Online) + if (!_preferenceManager.Get(caller).PendingFriendRequests && friend.Status == FriendStatusType.Pending) + continue; + + gotAFriend = true; + + ChildJsonMessage message = new JsonMessage(friend.Name).color(friend.Online ? "green" : "gray").extra(" - ").color("white"); + + + if (friend.Status == FriendStatusType.Accepted) { - if (friend.Mutual) - message.add(friend.ServerName + " Connect").color("green").bold().click("run_command", "/server " + friend.ServerName).add(" - ").color("white"); + if (friend.Online) + { + message.add(friend.ServerName).color("dark_green").add(" - ").color("white"); + message.add("Teleport").color("green").bold().click("run_command", "/server " + friend.ServerName).hover("show_text", "Change to " + friend.Name + "'s server.").add(" - ").color("white"); + } else - message.add("Friend request pending").color("yellow").add(" - ").color("white"); + message.add("Last online : ").color("gray").add(UtilTime.MakeStr(friend.LastSeenOnline)).color("gray").add(" - ").color("white"); + + message.add("Unfriend").color("red").bold().click("run_command", "/unfriend " + friend.Name).hover("show_text", "Remove " + friend.Name + " from your friends list.").sendToPlayer(caller); } - else - message.add("Last online : ").color("blue").add(UtilTime.when(friend.LastSeenOnline)).color("yellow").add(" - ").color("white"); - - message.add("Unfriend").color("red").bold().click("run_command", "/unfriend " + friend.Name).sendToPlayer(caller); + else if (friend.Status == FriendStatusType.Pending) + { + message.add("Friendship Pending").color("gray").add(" - ").color("white"); + message.add("Accept").color("green").bold().click("run_command", "/friend " + friend.Name).hover("show_text", "Accept " + friend.Name + "'s friend request.").add(" - ").color("white"); + message.add("Deny").color("red").bold().click("run_command", "/unfriend " + friend.Name).hover("show_text", "Deny " + friend.Name + "'s friend request.").sendToPlayer(caller); + } + else if (friend.Status == FriendStatusType.Sent) + { + message.add("Friendship Requested").color("gray").add(" - ").color("white"); + message.add("Cancel").color("red").bold().click("run_command", "/unfriend " + friend.Name).hover("show_text", "Cancel friend request to " + friend.Name).sendToPlayer(caller); + } + } + + if (!gotAFriend) + { + caller.sendMessage(C.cGray + "You don't have any friends. Type " + ChatColor.GREEN + "/friend name" + ChatColor.GRAY + " to add someone!"); } - caller.sendMessage(C.cBlue + "====================================================="); + caller.sendMessage(C.cAqua + C.Strike + "====================================================="); } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/friend/FriendSorter.java b/Plugins/Mineplex.Core/src/mineplex/core/friend/FriendSorter.java index 6951a362c..680c3a913 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/friend/FriendSorter.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/friend/FriendSorter.java @@ -10,33 +10,33 @@ public class FriendSorter implements Comparator { if (a.Online && !b.Online) { - return -1; + return 1; } if (b.Online && !a.Online) { - return 1; + return -1; } // If online we sort by mutual if (a.Online && b.Online) { - if (a.Mutual && !b.Mutual) - return -1; - else if (b.Mutual && !a.Mutual) + 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; + else if (b.Name.compareTo(a.Name) > 0) + return -1; } if (a.LastSeenOnline < b.LastSeenOnline) - return -1; + return 1; if (b.LastSeenOnline < a.LastSeenOnline) - return 1; + return -1; return 0; } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/friend/FriendStatusType.java b/Plugins/Mineplex.Core/src/mineplex/core/friend/FriendStatusType.java new file mode 100644 index 000000000..195e98e24 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/friend/FriendStatusType.java @@ -0,0 +1,10 @@ +package mineplex.core.friend; + +public enum FriendStatusType +{ + Sent, + Pending, + Accepted, + Denied, + Blocked +} 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 ddecfeb66..45dbbe2c9 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/friend/command/AddFriend.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/friend/command/AddFriend.java @@ -12,7 +12,7 @@ public class AddFriend extends CommandBase { public AddFriend(FriendManager plugin) { - super(plugin, Rank.ALL, "friend"); + super(plugin, Rank.ALL, "friend", "f"); } @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 9ce7a3ec9..229399c1d 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/friend/data/FriendRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/friend/data/FriendRepository.java @@ -11,16 +11,16 @@ import mineplex.core.common.util.NautHashMap; import mineplex.core.database.RepositoryBase; import mineplex.core.database.ResultSetCallable; import mineplex.core.database.column.ColumnVarChar; +import mineplex.core.friend.FriendStatusType; 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, serverName, tA.lastLogin FROM accountFriend INNER Join accounts AS fA ON fA.uuid = uuidSource INNER JOIN accounts AS tA ON tA.uuid = uuidTarget LEFT JOIN playerMap ON tA.name = playerName WHERE uuidSource IN "; - private static String RETRIEVE_FRIEND_RECORDS = "SELECT tA.Name, mutual, serverName, tA.lastLogin FROM accountFriend INNER Join accounts AS fA ON fA.uuid = uuidSource INNER JOIN accounts AS tA ON tA.uuid = uuidTarget LEFT JOIN playerMap ON tA.name = playerName WHERE uuidSource = ?;"; - private static String RETRIEVE_OTHER_FRIEND_RECORDS_BY_NAME = "SELECT tA.Name, mutual, serverName, tA.lastLogin FROM accountFriend INNER Join accounts AS fA ON fA.uuid = uuidSource INNER JOIN accounts AS tA ON tA.uuid = uuidTarget LEFT JOIN playerMap ON tA.name = playerName WHERE name = ?;"; - private static String ADD_FRIEND_RECORD = "INSERT INTO accountFriend (uuidSource, uuidTarget, status) SELECT fA.uuid AS uuidSource, tA.uuid AS uuidTarget, 'Pending' FROM accounts as fA LEFT JOIN accounts AS tA ON tA.name = ? WHERE fA.name = ?;"; - private static String UPDATE_MUTUAL_RECORD = "UPDATE aF SET status = ? FROM accountFriend AS aF INNER JOIN accounts as fA LEFT JOIN accounts AS tA ON tA.name = ? WHERE fA.name = ?;"; - private static String DELETE_FRIEND_RECORD = "DELETE aF FROM accountFriend AS aF INNER JOIN accounts ON accounts.name = ? WHERE uuidSource = ? AND uuidTarget = accounts.uuid;"; + private static String RETRIEVE_MULTIPLE_FRIEND_RECORDS = "SELECT uuidSource, tA.Name, status, serverName, tA.lastLogin, now() FROM accountFriend INNER Join accounts AS fA ON fA.uuid = uuidSource INNER JOIN accounts AS tA ON tA.uuid = uuidTarget LEFT JOIN playerMap ON tA.name = playerName WHERE uuidSource IN "; + private static String RETRIEVE_FRIEND_RECORDS = "SELECT tA.Name, status, serverName, tA.lastLogin, now() FROM accountFriend INNER Join accounts AS fA ON fA.uuid = uuidSource INNER JOIN accounts AS tA ON tA.uuid = uuidTarget LEFT JOIN playerMap ON tA.name = playerName WHERE uuidSource = ?;"; + private static String ADD_FRIEND_RECORD = "INSERT INTO accountFriend (uuidSource, uuidTarget, status) SELECT fA.uuid AS uuidSource, tA.uuid AS uuidTarget, ? 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 = ?;"; // Not mutual, need to drop accountFriend to recreate with constraint. @@ -44,22 +44,17 @@ public class FriendRepository extends RepositoryBase public boolean addFriend(final Player caller, String name) { - int rowsAffected = executeUpdate(ADD_FRIEND_RECORD, new ColumnVarChar("name", 100, name), new ColumnVarChar("name", 100, caller.getName())); + 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("name", 100, caller.getName()), new ColumnVarChar("uuid", 100, name)) > 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(Player caller, String name, String status) - { - int rowsAffected = executeUpdate(UPDATE_MUTUAL_RECORD, new ColumnVarChar("status", 100, status), new ColumnVarChar("name", 100, name), new ColumnVarChar("name", 100, caller.getName())); - - if (rowsAffected > 0) - return executeUpdate(UPDATE_MUTUAL_RECORD, new ColumnVarChar("status", 100, status), 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) @@ -97,11 +92,11 @@ public class FriendRepository extends RepositoryBase String uuidSource = resultSet.getString(1); friend.Name = resultSet.getString(2); - friend.Mutual = resultSet.getBoolean(3); + friend.Status = Enum.valueOf(FriendStatusType.class, resultSet.getString(3)); friend.ServerName = resultSet.getString(4); - friend.Online = !friend.ServerName.isEmpty(); + friend.Online = !(friend.ServerName == null || friend.ServerName.isEmpty()); - friend.LastSeenOnline = resultSet.getTimestamp(5).getTime(); + friend.LastSeenOnline = resultSet.getTimestamp(6).getTime() - resultSet.getTimestamp(5).getTime(); if (!friends.containsKey(uuidSource)) friends.put(uuidSource, new FriendData()); @@ -127,9 +122,9 @@ public class FriendRepository extends RepositoryBase FriendStatus friend = new FriendStatus(); friend.Name = resultSet.getString(1); - friend.Mutual = resultSet.getBoolean(2); + friend.Status = Enum.valueOf(FriendStatusType.class, resultSet.getString(2)); friend.ServerName = resultSet.getString(3); - friend.LastSeenOnline = resultSet.getLong(4); + friend.LastSeenOnline = resultSet.getTimestamp(5).getTime() - resultSet.getTimestamp(5).getTime(); friendData.Friends.add(friend); } 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 b173b2fd9..90fdd42d3 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/friend/data/FriendStatus.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/friend/data/FriendStatus.java @@ -1,10 +1,12 @@ package mineplex.core.friend.data; +import mineplex.core.friend.FriendStatusType; + public class FriendStatus { public String Name; public String ServerName; public boolean Online; public long LastSeenOnline; - public boolean Mutual; + public FriendStatusType Status; } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/friend/ui/FriendTabList.java b/Plugins/Mineplex.Core/src/mineplex/core/friend/ui/FriendTabList.java deleted file mode 100644 index a75566137..000000000 --- a/Plugins/Mineplex.Core/src/mineplex/core/friend/ui/FriendTabList.java +++ /dev/null @@ -1,54 +0,0 @@ -package mineplex.core.friend.ui; - -import java.util.Collections; -import java.util.List; - -import mineplex.core.common.util.UtilTime; -import mineplex.core.common.util.UtilTime.TimeUnit; -import mineplex.core.friend.FriendSorter; -import mineplex.core.friend.data.FriendStatus; - -import org.bukkit.ChatColor; - -public class FriendTabList extends TabList -{ - private static FriendSorter _friendSorter = new FriendSorter(); - - public FriendTabList(List friends) - { - super(); - - set(0, 0, ChatColor.GOLD + "" + ChatColor.BOLD + " Name"); - set(1, 0, ChatColor.GOLD + "" + ChatColor.BOLD + " Location"); - set(2, 0, ChatColor.GOLD + "" + ChatColor.BOLD + " Status"); - - updateFriends(friends); - } - - public void updateFriends(List friends) - { - Collections.sort(friends, _friendSorter); - - int row = 1; - for (int i = 0; i < 16; i++) - { - if (i < friends.size()) - { - FriendStatus status = friends.get(i); - - set(0, row, (status.Mutual ? ChatColor.GREEN : ChatColor.YELLOW) + status.Name); - set(1, row, status.Mutual ? ChatColor.GREEN + status.ServerName : ChatColor.YELLOW + "Unknown"); - set(2, row, (status.Mutual ? ChatColor.GREEN : ChatColor.YELLOW) + (status.Online ? "Online" : UtilTime.convert(status.LastSeenOnline, 2, TimeUnit.MINUTES) + "")); - } - else - { - set(0, row, null); - set(1, row, null); - set(2, row, null); - } - - row++; - } - } -} - diff --git a/Plugins/Mineplex.Core/src/mineplex/core/preferences/PreferencesRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/preferences/PreferencesRepository.java index 7e647126c..767ecbad2 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/preferences/PreferencesRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/preferences/PreferencesRepository.java @@ -17,8 +17,8 @@ public class PreferencesRepository extends RepositoryBase { private static String CREATE_ACCOUNT_TABLE = "CREATE TABLE IF NOT EXISTS accountPreferences (id INT NOT NULL AUTO_INCREMENT, uuid VARCHAR(256), games BOOL NOT NULL DEFAULT 1, visibility BOOL NOT NULL DEFAULT 1, showChat BOOL NOT NULL DEFAULT 1, friendChat BOOL NOT NULL DEFAULT 1, privateMessaging BOOL NOT NULL DEFAULT 1, partyRequests BOOL NOT NULL DEFAULT 0, invisibility BOOL NOT NULL DEFAULT 0, forcefield BOOL NOT NULL DEFAULT 0, showMacReports BOOL NOT NULL DEFAULT 0, ignoreVelocity BOOL NOT NULL DEFAULT 0, PRIMARY KEY (id), UNIQUE INDEX uuid_index (uuid));"; private static String INSERT_ACCOUNT = "INSERT INTO accountPreferences (uuid) VALUES (?) ON DUPLICATE KEY UPDATE uuid=uuid;"; - private static String RETRIEVE_ACCOUNT_PREFERENCES = "SELECT games, visibility, showChat, friendChat, privateMessaging, partyRequests, invisibility, forcefield, showMacReports, ignoreVelocity FROM accountPreferences WHERE uuid = ?;"; - private static String UPDATE_ACCOUNT_PREFERENCES = "UPDATE accountPreferences SET games = ?, visibility = ?, showChat = ?, friendChat = ?, privateMessaging = ?, partyRequests = ?, invisibility = ?, forcefield = ?, showMacReports = ?, ignoreVelocity = ? WHERE uuid=?;"; + private static String RETRIEVE_ACCOUNT_PREFERENCES = "SELECT games, visibility, showChat, friendChat, privateMessaging, partyRequests, invisibility, forcefield, showMacReports, ignoreVelocity, pendingFriendRequests FROM accountPreferences WHERE uuid = ?;"; + private static String UPDATE_ACCOUNT_PREFERENCES = "UPDATE accountPreferences SET games = ?, visibility = ?, showChat = ?, friendChat = ?, privateMessaging = ?, partyRequests = ?, invisibility = ?, forcefield = ?, showMacReports = ?, ignoreVelocity = ?, pendingFriendRequests = ? WHERE uuid=?;"; public PreferencesRepository(JavaPlugin plugin, String connectionString) { @@ -56,7 +56,8 @@ public class PreferencesRepository extends RepositoryBase preparedStatement.setBoolean(8, entry.getValue().HubForcefield); preparedStatement.setBoolean(9, entry.getValue().ShowMacReports); preparedStatement.setBoolean(10, entry.getValue().IgnoreVelocity); - preparedStatement.setString(11, entry.getKey()); + preparedStatement.setBoolean(11, entry.getValue().PendingFriendRequests); + preparedStatement.setString(12, entry.getKey()); preparedStatement.addBatch(); } @@ -107,6 +108,7 @@ public class PreferencesRepository extends RepositoryBase preferences.HubForcefield = resultSet.getBoolean(8); preferences.ShowMacReports = resultSet.getBoolean(9); preferences.IgnoreVelocity = resultSet.getBoolean(10); + preferences.PendingFriendRequests = resultSet.getBoolean(11); } } }, new ColumnVarChar("uuid", 100, uuid.toString())); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/preferences/UserPreferences.java b/Plugins/Mineplex.Core/src/mineplex/core/preferences/UserPreferences.java index 7eb95ea1f..45700ccf1 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/preferences/UserPreferences.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/preferences/UserPreferences.java @@ -13,4 +13,5 @@ public class UserPreferences public boolean HubForcefield = false; public boolean ShowMacReports = false; public boolean IgnoreVelocity = false; + public boolean PendingFriendRequests = true; } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/preferences/ui/PreferencesPage.java b/Plugins/Mineplex.Core/src/mineplex/core/preferences/ui/PreferencesPage.java index fc2cb8f83..16f5ac716 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/preferences/ui/PreferencesPage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/preferences/ui/PreferencesPage.java @@ -20,6 +20,7 @@ public class PreferencesPage extends ShopPageBase