use of com.alessiodp.parties.parties.objects.PartyEntity in project Parties by AlessioDP.
the class BungeeService method onPluginMessageReceived.
public void onPluginMessageReceived(String channel, Player player, byte[] message) {
if (!channel.equals(partiesChannel)) {
return;
}
ByteArrayInputStream stream = new ByteArrayInputStream(message);
DataInputStream in = new DataInputStream(stream);
// Load entities
PartyPlayerEntity pp = plugin.getPlayerManager().getPlayer(player.getUniqueId());
PartyEntity party = plugin.getPartyManager().getParty(pp.getPartyName());
try {
// Get packet in input
Packet packet = new Packet(in);
if (packet.getVersion().equals(plugin.getDescription().getVersion())) {
// Does the player have a party
if (party != null) {
// Check for rank needed to follow
if (pp.getRank() < packet.getRankNeeded())
return;
// Preparing a list that contains the name of each player to teleport
List<String> list = new ArrayList<String>();
for (Player pl : party.getOnlinePlayers()) {
UUID pUuid = pl.getUniqueId();
if (!pUuid.equals(player.getUniqueId())) {
// Have the player the minimum rank to follow?
if (plugin.getPlayerManager().getPlayer(pUuid).getRank() >= packet.getRankMinimum()) {
list.add(pUuid.toString());
}
}
}
// Set the info list
packet.setInfo(list);
// Set the message for the user
packet.setMessage(ChatColor.translateAlternateColorCodes('&', Messages.OTHER_FOLLOW_SERVER.replace("%server%", packet.getServer())));
// Send the output
ByteArrayOutputStream outstream = new ByteArrayOutputStream();
DataOutputStream out = new DataOutputStream(outstream);
packet.write(out);
try {
Player p = Bukkit.getServer().getOnlinePlayers().iterator().next();
if (p != null) {
LoggerManager.log(LogLevel.DEBUG, Constants.DEBUG_BUNGEE_REPLY, true);
p.sendPluginMessage(plugin, partiesChannel, outstream.toByteArray());
}
} catch (Exception ex) {
// Server empty
}
}
} else {
LoggerManager.printError(Constants.DEBUG_BUNGEE_VERSIONMISMATCH.replace("{packet}", packet.getVersion()));
}
} catch (IOException ex) {
ex.printStackTrace();
}
}
use of com.alessiodp.parties.parties.objects.PartyEntity in project Parties by AlessioDP.
the class ApiHandler method deleteParty.
@Override
public Status deleteParty(Party paramParty) {
Status ret = Status.NOEXIST;
PartyEntity party = new PartyEntity(paramParty, plugin);
if (party != null) {
party.removeParty();
ret = Status.SUCCESS;
}
return ret;
}
use of com.alessiodp.parties.parties.objects.PartyEntity in project Parties by AlessioDP.
the class ApiHandler method addPlayerIntoParty.
@Override
public Status addPlayerIntoParty(PartyPlayer paramPartyPlayer, Party paramParty) {
Status ret = Status.ALREADYINPARTY;
if (!paramPartyPlayer.getPartyName().isEmpty()) {
if (paramParty != null) {
if (ConfigParties.GENERAL_MEMBERSLIMIT < 0 || paramParty.getMembers().size() < ConfigParties.GENERAL_MEMBERSLIMIT) {
PartyEntity party = new PartyEntity(paramParty, plugin);
party.getMembers().add(paramPartyPlayer.getPlayerUUID());
paramPartyPlayer.setPartyName(party.getName());
party.refreshPlayers();
party.updateParty();
updatePartyPlayer(paramPartyPlayer);
party.callChange();
ret = Status.SUCCESS;
} else
ret = Status.PARTYFULL;
} else
ret = Status.NOEXIST;
}
return ret;
}
use of com.alessiodp.parties.parties.objects.PartyEntity in project Parties by AlessioDP.
the class ApiHandler method broadcastPartyMessage.
@Override
public Status broadcastPartyMessage(Party paramParty, PartyPlayer paramPartyPlayer, String paramMessage) {
Status ret = Status.NOEXIST;
PartyEntity party = new PartyEntity(paramParty, plugin);
if (party != null) {
party.sendBroadcast(new PartyPlayerEntity(paramPartyPlayer, plugin), paramMessage);
ret = Status.SUCCESS;
}
return ret;
}
use of com.alessiodp.parties.parties.objects.PartyEntity in project Parties by AlessioDP.
the class ApiHandler method removePlayerFromParty.
@Override
public Status removePlayerFromParty(PartyPlayer paramPartyPlayer) {
Status ret = Status.NOPARTY;
if (!paramPartyPlayer.getPartyName().isEmpty()) {
PartyPlayerEntity player = new PartyPlayerEntity(paramPartyPlayer, plugin);
PartyEntity party = plugin.getPartyManager().getParty(player.getPartyName());
if (party != null) {
if (player.getPlayerUUID().equals(party.getLeader())) {
party.removeParty();
} else {
if (party.getMembers().contains(player.getPlayerUUID())) {
party.getMembers().remove(player.getPlayerUUID());
party.updateParty();
party.callChange();
}
player.cleanupPlayer(true);
}
ret = Status.SUCCESS;
}
}
return ret;
}
Aggregations