mirror of
https://gitlab.com/phoenix-dvpmt/mmocore.git
synced 2024-11-23 00:05:52 +01:00
added creator to request object
party invite cooldown resets when invitation accepted
This commit is contained in:
parent
07bf1c78ae
commit
93b62e8055
@ -6,15 +6,12 @@ import net.Indyuce.mmocore.MMOCore;
|
||||
import net.Indyuce.mmocore.api.player.PlayerData;
|
||||
|
||||
public class FriendRequest extends Request {
|
||||
private PlayerData creator, target;
|
||||
private final PlayerData target;
|
||||
|
||||
public FriendRequest(PlayerData creator, PlayerData target) {
|
||||
this.creator = creator;
|
||||
this.target = target;
|
||||
}
|
||||
super(creator);
|
||||
|
||||
public PlayerData getCreator() {
|
||||
return creator;
|
||||
this.target = target;
|
||||
}
|
||||
|
||||
public PlayerData getTarget() {
|
||||
@ -27,10 +24,10 @@ public class FriendRequest extends Request {
|
||||
}
|
||||
|
||||
public void accept() {
|
||||
creator.addFriend(target.getUniqueId());
|
||||
target.addFriend(creator.getUniqueId());
|
||||
creator.getPlayer().sendMessage(MMOCore.plugin.configManager.getSimpleMessage("now-friends", "player", target.getPlayer().getName()));
|
||||
target.getPlayer().sendMessage(MMOCore.plugin.configManager.getSimpleMessage("now-friends", "player", creator.getPlayer().getName()));
|
||||
getCreator().addFriend(target.getUniqueId());
|
||||
target.addFriend(getCreator().getUniqueId());
|
||||
getCreator().getPlayer().sendMessage(MMOCore.plugin.configManager.getSimpleMessage("now-friends", "player", target.getPlayer().getName()));
|
||||
target.getPlayer().sendMessage(MMOCore.plugin.configManager.getSimpleMessage("now-friends", "player", getCreator().getPlayer().getName()));
|
||||
MMOCore.plugin.requestManager.unregisterRequest(getUniqueId());
|
||||
}
|
||||
}
|
@ -45,6 +45,10 @@ public class Party {
|
||||
return invites.containsKey(player.getUniqueId()) ? invites.get(player.getUniqueId()) : 0;
|
||||
}
|
||||
|
||||
public void removeLastInvite(Player player) {
|
||||
invites.remove(player.getUniqueId());
|
||||
}
|
||||
|
||||
public void removeMember(PlayerData data) {
|
||||
if (data.isOnline() && data.getPlayer().getOpenInventory() != null && data.getPlayer().getOpenInventory().getTopInventory().getHolder() instanceof PartyViewInventory)
|
||||
InventoryManager.PARTY_CREATION.newInventory(data).open();
|
||||
@ -83,10 +87,10 @@ public class Party {
|
||||
((PluginInventory) member.getPlayer().getOpenInventory().getTopInventory().getHolder()).open();
|
||||
}
|
||||
|
||||
public void sendPartyInvite(Player inviter, PlayerData target) {
|
||||
public void sendPartyInvite(PlayerData inviter, PlayerData target) {
|
||||
invites.put(target.getUniqueId(), System.currentTimeMillis());
|
||||
Request request = new PartyInvite(this, target);
|
||||
new ConfigMessage("party-invite").addPlaceholders("player", inviter.getName(), "uuid", request.getUniqueId().toString()).sendAsJSon(target.getPlayer());
|
||||
Request request = new PartyInvite(this, inviter, target);
|
||||
new ConfigMessage("party-invite").addPlaceholders("player", inviter.getPlayer().getName(), "uuid", request.getUniqueId().toString()).sendAsJSon(target.getPlayer());
|
||||
MMOCore.plugin.requestManager.registerRequest(request);
|
||||
}
|
||||
|
||||
@ -122,7 +126,7 @@ public class Party {
|
||||
refreshAttributes();
|
||||
refreshAttributes(player);
|
||||
}
|
||||
|
||||
|
||||
public void forEach(Consumer<? super PlayerData> action) {
|
||||
members.forEach(action);
|
||||
}
|
||||
|
@ -5,10 +5,12 @@ import net.Indyuce.mmocore.api.player.PlayerData;
|
||||
import net.Indyuce.mmocore.manager.InventoryManager;
|
||||
|
||||
public class PartyInvite extends Request {
|
||||
private PlayerData target;
|
||||
private Party party;
|
||||
private final PlayerData target;
|
||||
private final Party party;
|
||||
|
||||
public PartyInvite(Party party, PlayerData creator, PlayerData target) {
|
||||
super(creator);
|
||||
|
||||
public PartyInvite(Party party, PlayerData target) {
|
||||
this.party = party;
|
||||
this.target = target;
|
||||
}
|
||||
@ -26,6 +28,7 @@ public class PartyInvite extends Request {
|
||||
}
|
||||
|
||||
public void accept() {
|
||||
party.removeLastInvite(getCreator().getPlayer());
|
||||
party.getMembers().forEach(member -> member.getPlayer().sendMessage(MMOCore.plugin.configManager.getSimpleMessage("party-joined-other", "player", target.getPlayer().getName())));
|
||||
target.getPlayer().sendMessage(MMOCore.plugin.configManager.getSimpleMessage("party-joined", "owner", party.getOwner().getPlayer().getName()));
|
||||
party.addMember(target);
|
||||
|
@ -2,9 +2,20 @@ package net.Indyuce.mmocore.api.player.social;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import net.Indyuce.mmocore.api.player.PlayerData;
|
||||
|
||||
public abstract class Request {
|
||||
private UUID uuid = UUID.randomUUID();
|
||||
private long date = System.currentTimeMillis();
|
||||
private final UUID uuid = UUID.randomUUID();
|
||||
private final long date = System.currentTimeMillis();
|
||||
private final PlayerData creator;
|
||||
|
||||
public Request(PlayerData creator) {
|
||||
this.creator = creator;
|
||||
}
|
||||
|
||||
public PlayerData getCreator() {
|
||||
return creator;
|
||||
}
|
||||
|
||||
public UUID getUniqueId() {
|
||||
return uuid;
|
||||
|
@ -164,7 +164,7 @@ public class EditablePartyView extends EditableInventory {
|
||||
return;
|
||||
}
|
||||
|
||||
playerData.getParty().sendPartyInvite(player, targetData);
|
||||
playerData.getParty().sendPartyInvite(playerData, targetData);
|
||||
player.sendMessage(MMOCore.plugin.configManager.getSimpleMessage("sent-party-invite", "player", target.getName()));
|
||||
player.playSound(player.getLocation(), Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 1, 1);
|
||||
open();
|
||||
|
Loading…
Reference in New Issue
Block a user