Changed FriendManager to start supporting expiry friend requests.

This commit is contained in:
Jonathan Williams 2014-12-26 07:36:07 -05:00
parent 8702bafbd0
commit d83a63ef57
2 changed files with 3 additions and 28 deletions

View File

@ -191,37 +191,12 @@ public class FriendManager extends MiniDbClientPlugin<FriendData>
public void removeFriend(final Player caller, final String name)
{
boolean delete = false;
for (Iterator<FriendStatus> 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()
{
if (deleteFinal)
{
_repository.removeFriend(caller.getName(), name);
}
else
{
_repository.updateFriend(caller.getName(), name, "Blocked");
_repository.updateFriend(name, caller.getName(), "Denied");
}
_repository.removeFriend(caller.getName(), name);
_repository.removeFriend(name, caller.getName());
Bukkit.getServer().getScheduler().runTask(_plugin, new Runnable()
{

View File

@ -16,7 +16,7 @@ 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, 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 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 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 = ?;";