friend request cooldown resets when request accepted

This commit is contained in:
Indyuce 2019-08-31 15:03:54 +02:00
parent 93b62e8055
commit dbf5dea4dd
2 changed files with 6 additions and 1 deletions

View File

@ -393,8 +393,12 @@ public class PlayerData {
MMOCore.plugin.getLogger().log(level, "[Userdata:" + player.getName() + "] " + message); MMOCore.plugin.getLogger().log(level, "[Userdata:" + player.getName() + "] " + message);
} }
public void setLastFriendRequest(long ms) {
lastFriendRequest = Math.max(0, ms);
}
public void sendFriendRequest(PlayerData target) { public void sendFriendRequest(PlayerData target) {
lastFriendRequest = System.currentTimeMillis(); setLastFriendRequest(System.currentTimeMillis());
FriendRequest request = new FriendRequest(this, target); FriendRequest request = new FriendRequest(this, target);
new ConfigMessage("friend-request").addPlaceholders("player", getPlayer().getName(), "uuid", request.getUniqueId().toString()).sendAsJSon(target.getPlayer()); new ConfigMessage("friend-request").addPlaceholders("player", getPlayer().getName(), "uuid", request.getUniqueId().toString()).sendAsJSon(target.getPlayer());

View File

@ -24,6 +24,7 @@ public class FriendRequest extends Request {
} }
public void accept() { public void accept() {
getCreator().setLastFriendRequest(0);
getCreator().addFriend(target.getUniqueId()); getCreator().addFriend(target.getUniqueId());
target.addFriend(getCreator().getUniqueId()); target.addFriend(getCreator().getUniqueId());
getCreator().getPlayer().sendMessage(MMOCore.plugin.configManager.getSimpleMessage("now-friends", "player", target.getPlayer().getName())); getCreator().getPlayer().sendMessage(MMOCore.plugin.configManager.getSimpleMessage("now-friends", "player", target.getPlayer().getName()));