From dbf5dea4dd7a82f64bf80360cb53e0f29b43b734 Mon Sep 17 00:00:00 2001 From: Indyuce Date: Sat, 31 Aug 2019 15:03:54 +0200 Subject: [PATCH] friend request cooldown resets when request accepted --- .../java/net/Indyuce/mmocore/api/player/PlayerData.java | 6 +++++- .../Indyuce/mmocore/api/player/social/FriendRequest.java | 1 + 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/main/java/net/Indyuce/mmocore/api/player/PlayerData.java b/src/main/java/net/Indyuce/mmocore/api/player/PlayerData.java index 940195cd..eae23e31 100644 --- a/src/main/java/net/Indyuce/mmocore/api/player/PlayerData.java +++ b/src/main/java/net/Indyuce/mmocore/api/player/PlayerData.java @@ -393,8 +393,12 @@ public class PlayerData { MMOCore.plugin.getLogger().log(level, "[Userdata:" + player.getName() + "] " + message); } + public void setLastFriendRequest(long ms) { + lastFriendRequest = Math.max(0, ms); + } + public void sendFriendRequest(PlayerData target) { - lastFriendRequest = System.currentTimeMillis(); + setLastFriendRequest(System.currentTimeMillis()); FriendRequest request = new FriendRequest(this, target); new ConfigMessage("friend-request").addPlaceholders("player", getPlayer().getName(), "uuid", request.getUniqueId().toString()).sendAsJSon(target.getPlayer()); diff --git a/src/main/java/net/Indyuce/mmocore/api/player/social/FriendRequest.java b/src/main/java/net/Indyuce/mmocore/api/player/social/FriendRequest.java index d2456d1d..36226eb6 100644 --- a/src/main/java/net/Indyuce/mmocore/api/player/social/FriendRequest.java +++ b/src/main/java/net/Indyuce/mmocore/api/player/social/FriendRequest.java @@ -24,6 +24,7 @@ public class FriendRequest extends Request { } public void accept() { + getCreator().setLastFriendRequest(0); getCreator().addFriend(target.getUniqueId()); target.addFriend(getCreator().getUniqueId()); getCreator().getPlayer().sendMessage(MMOCore.plugin.configManager.getSimpleMessage("now-friends", "player", target.getPlayer().getName()));