PC Party bugs and tweaks.
This commit is contained in:
parent
06feb615a9
commit
584c8f50f0
@ -12,6 +12,7 @@ import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Uh, yeah, I'll get back to this when it isn't 2 AM
|
||||
@ -23,6 +24,7 @@ public class Party
|
||||
|
||||
private String _owner;
|
||||
private List<String> _members;
|
||||
private List<UUID> _membersByUUID;
|
||||
private Map<String, Long> _invites;
|
||||
private int size;
|
||||
|
||||
@ -37,6 +39,7 @@ public class Party
|
||||
_members = Lists.newArrayList();
|
||||
_invites = Maps.newHashMap();
|
||||
_members.add(owner);
|
||||
_membersByUUID = Lists.newArrayList();
|
||||
}
|
||||
|
||||
public String getOwner()
|
||||
@ -100,14 +103,15 @@ public class Party
|
||||
}
|
||||
if(reason == PartyRemoveReason.LEFT)
|
||||
{
|
||||
Lang.REMOVE_PLAYER.send(this, player);
|
||||
if(player.equalsIgnoreCase(_owner) && _members.size() > 1)
|
||||
{
|
||||
_owner = _members.get(0);
|
||||
Lang.TRANSFER_OWNER.send(this, player, _owner);
|
||||
PartyTransferOwnerEvent event = new PartyTransferOwnerEvent(this, _owner, player, TransferReason.LEFT);
|
||||
UtilServer.getServer().getPluginManager().callEvent(event);
|
||||
return;
|
||||
}
|
||||
Lang.REMOVE_PLAYER.send(this, player);
|
||||
return;
|
||||
}
|
||||
if(reason == PartyRemoveReason.OTHER)
|
||||
@ -134,4 +138,15 @@ public class Party
|
||||
{
|
||||
_owner = owner;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return "Party: " + _owner;
|
||||
}
|
||||
|
||||
public List<UUID> getMembersByUUID()
|
||||
{
|
||||
return _membersByUUID;
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package mineplex.core.party;
|
||||
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.party.event.PartyDataReceivedEvent;
|
||||
import mineplex.core.party.event.PartyMemberKickGUIEvent;
|
||||
import mineplex.core.party.event.PartyTransferOwnerEvent;
|
||||
import mineplex.core.party.manager.PartyRedisManager;
|
||||
@ -84,7 +85,14 @@ public class PartyEventListener implements Listener
|
||||
return;
|
||||
}
|
||||
|
||||
_plugin.removeFromParty(player, PartyRemoveReason.LEFT);
|
||||
PartyRemoveReason reason = PartyRemoveReason.LEFT;
|
||||
|
||||
if(_plugin.getJoinManager().isTransferring(player))
|
||||
{
|
||||
reason = PartyRemoveReason.OTHER;
|
||||
}
|
||||
|
||||
_plugin.removeFromParty(player, reason);
|
||||
}
|
||||
|
||||
|
||||
|
@ -74,6 +74,10 @@ public class PartyManager extends MiniPlugin
|
||||
_players.put(uuid, party);
|
||||
Player player = Bukkit.getPlayer(uuid);
|
||||
party.onPlayerAdd(player.getName());
|
||||
if(!party.getMembersByUUID().contains(uuid))
|
||||
{
|
||||
party.getMembersByUUID().add(uuid);
|
||||
}
|
||||
}
|
||||
|
||||
public void addToParty(Player player, Party party)
|
||||
@ -86,6 +90,17 @@ public class PartyManager extends MiniPlugin
|
||||
_parties.remove(party.getName());
|
||||
}
|
||||
|
||||
public void removeForTransfer(UUID uuid)
|
||||
{
|
||||
Party party = _players.remove(uuid);
|
||||
if(party == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
String player = Bukkit.getPlayer(uuid).getName();
|
||||
party.onPlayerRemove(player, PartyRemoveReason.OTHER);
|
||||
}
|
||||
|
||||
public void removeFromParty(UUID uuid, PartyRemoveReason reason)
|
||||
{
|
||||
Party party = _players.remove(uuid);
|
||||
@ -95,6 +110,7 @@ public class PartyManager extends MiniPlugin
|
||||
}
|
||||
Player player = Bukkit.getPlayer(uuid);
|
||||
party.getMembers().remove(player.getName());
|
||||
party.getMembersByUUID().remove(uuid);
|
||||
party.onPlayerRemove(player.getName(), reason);
|
||||
if(player.getOpenInventory() != null)
|
||||
{
|
||||
@ -132,12 +148,11 @@ public class PartyManager extends MiniPlugin
|
||||
public void transferOwner(String newOwner, String oldOwner)
|
||||
{
|
||||
Party party = _parties.remove(oldOwner.toLowerCase());
|
||||
_parties.put(newOwner.toLowerCase(), party);
|
||||
party.getMembers().stream().map(Bukkit::getPlayer).forEach(s ->
|
||||
if(party == null)
|
||||
{
|
||||
_players.remove(s.getUniqueId());
|
||||
_players.put(s.getUniqueId(), party);
|
||||
});
|
||||
return;
|
||||
}
|
||||
_parties.put(newOwner.toLowerCase(), party);
|
||||
party.setOwner(newOwner);
|
||||
party.getMembers().remove(oldOwner);
|
||||
party.getMembers().add(oldOwner);
|
||||
@ -179,5 +194,8 @@ public class PartyManager extends MiniPlugin
|
||||
return _joinManager;
|
||||
}
|
||||
|
||||
|
||||
public Map<UUID, Party> getPlayerParties()
|
||||
{
|
||||
return _players;
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package mineplex.core.party.manager;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
@ -10,6 +11,7 @@ import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
@ -38,11 +40,13 @@ public class PartyJoinManager
|
||||
|
||||
private final PartyManager _plugin;
|
||||
private final int _maxPLayers;
|
||||
private final List<UUID> _transferring;
|
||||
|
||||
public PartyJoinManager(PartyManager plugin)
|
||||
{
|
||||
_plugin = plugin;
|
||||
_maxPLayers = plugin.getPlugin().getServer().getMaxPlayers();
|
||||
_transferring = Lists.newArrayList();
|
||||
}
|
||||
|
||||
public void requestServerJoin(String server, Party party)
|
||||
@ -98,7 +102,14 @@ public class PartyJoinManager
|
||||
}
|
||||
party.sendMessage(F.main("Party", "Transferring servers..."));
|
||||
_plugin.getRedisManager().sendPartyInfo(server, party);
|
||||
|
||||
_transferring.addAll(party.getMembersByUUID());
|
||||
}
|
||||
|
||||
|
||||
public boolean isTransferring(Player player)
|
||||
{
|
||||
return _transferring.remove(player.getUniqueId());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -181,6 +181,7 @@ public class PartyRedisManager
|
||||
{
|
||||
publish(server, PARTY_INFO, GSON.toJson(party));
|
||||
List<String> members = party.getMembers();
|
||||
party.getMembersByUUID().stream().forEach(_plugin::removeForTransfer);
|
||||
members.stream().map(Bukkit::getPlayer).forEach(player1 ->
|
||||
{
|
||||
player1.leaveVehicle();
|
||||
@ -199,14 +200,7 @@ public class PartyRedisManager
|
||||
{
|
||||
Party party = GSON.fromJson(json, Party.class);
|
||||
_plugin.addParty(party);
|
||||
party.getMembers().forEach(s ->
|
||||
{
|
||||
Player player = Bukkit.getPlayerExact(s);
|
||||
if (player != null)
|
||||
{
|
||||
_plugin.addToParty(player, party);
|
||||
}
|
||||
});
|
||||
party.getMembersByUUID().forEach(s -> _plugin.addToParty(s, party));
|
||||
Bukkit.getServer().getPluginManager().callEvent(new PartyDataReceivedEvent(party));
|
||||
}
|
||||
}.runTaskLater(_plugin.getPlugin(), 10L);
|
||||
|
@ -705,9 +705,6 @@ public class HubManager extends MiniClientPlugin<HubClient>
|
||||
|
||||
for (Player player : UtilServer.getPlayers())
|
||||
{
|
||||
//Dont Waste Time
|
||||
if (_partyManager.GetParty(player) != null)
|
||||
continue;
|
||||
|
||||
//Return to Main Scoreboard
|
||||
if (!player.getScoreboard().equals(_scoreboards.get(player)))
|
||||
|
Loading…
Reference in New Issue
Block a user