Search in sources :

Example 46 with PartyPlayerEntity

use of com.alessiodp.parties.players.objects.PartyPlayerEntity 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;
}
Also used : Status(com.alessiodp.partiesapi.enums.Status) PartyPlayerEntity(com.alessiodp.parties.players.objects.PartyPlayerEntity) PartyEntity(com.alessiodp.parties.parties.objects.PartyEntity)

Example 47 with PartyPlayerEntity

use of com.alessiodp.parties.players.objects.PartyPlayerEntity 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;
}
Also used : Status(com.alessiodp.partiesapi.enums.Status) PartyPlayerEntity(com.alessiodp.parties.players.objects.PartyPlayerEntity) PartyEntity(com.alessiodp.parties.parties.objects.PartyEntity)

Example 48 with PartyPlayerEntity

use of com.alessiodp.parties.players.objects.PartyPlayerEntity in project Parties by AlessioDP.

the class ApiHandler method createParty.

@Override
public Status createParty(PartyPlayer paramPartyPlayer, String paramPartyName) {
    Status ret = Status.ALREADYINPARTY;
    // Get an instance of PartyPlayerEntity, used to save same player
    PartyPlayerEntity player = null;
    if (paramPartyPlayer instanceof PartyPlayerEntity) {
        player = (PartyPlayerEntity) paramPartyPlayer;
    } else {
        player = (PartyPlayerEntity) getPartyPlayer(paramPartyPlayer.getPlayerUUID());
    }
    if (player.getPartyName().isEmpty()) {
        if (!plugin.getPartyManager().existParty(paramPartyName)) {
            PartyEntity party = new PartyEntity(paramPartyName, plugin);
            party.getMembers().add(player.getPlayerUUID());
            Player p = player.getPlayer();
            if (p != null)
                party.getOnlinePlayers().add(p);
            party.setLeader(player.getPlayerUUID());
            plugin.getPartyManager().getListParties().put(party.getName().toLowerCase(), party);
            player.setRank(ConfigParties.RANK_SET_HIGHER);
            player.setPartyName(party.getName());
            party.updateParty();
            player.updatePlayer();
            party.callChange();
            return Status.SUCCESS;
        } else
            ret = Status.ALREADYEXISTPARTY;
    }
    return ret;
}
Also used : Status(com.alessiodp.partiesapi.enums.Status) PartyPlayerEntity(com.alessiodp.parties.players.objects.PartyPlayerEntity) Player(org.bukkit.entity.Player) PartyPlayer(com.alessiodp.partiesapi.objects.PartyPlayer) PartyEntity(com.alessiodp.parties.parties.objects.PartyEntity)

Example 49 with PartyPlayerEntity

use of com.alessiodp.parties.players.objects.PartyPlayerEntity in project Parties by AlessioDP.

the class BMHook method onPlayerBan.

@EventHandler(ignoreCancelled = true)
public void onPlayerBan(PlayerBannedEvent event) {
    PlayerData pl = event.getBan().getPlayer();
    PartyPlayerEntity pp = plugin.getPlayerManager().getPlayer(pl.getUUID());
    // Spy listener
    if (pp.isSpy())
        plugin.getSpyManager().removeSpy(pp.getPlayerUUID());
    // Party checking
    if (!pp.getPartyName().isEmpty()) {
        PartyEntity party = plugin.getPartyManager().getParty(pp.getPartyName());
        if (party != null) {
            PartyPlayerEntity kickerPp = plugin.getPlayerManager().getPlayer(event.getBan().getActor().getUUID());
            // Calling API event
            PartiesPlayerLeaveEvent partiesLeaveEvent = new PartiesPlayerLeaveEvent(pp, party, true, kickerPp);
            Bukkit.getServer().getPluginManager().callEvent(partiesLeaveEvent);
            if (!partiesLeaveEvent.isCancelled()) {
                if (party.getLeader().equals(pl.getUUID())) {
                    // Calling Pre API event
                    PartiesPartyPreDeleteEvent partiesPreDeleteEvent = new PartiesPartyPreDeleteEvent(party, PartiesPartyPreDeleteEvent.DeleteCause.BAN, pp, kickerPp);
                    Bukkit.getServer().getPluginManager().callEvent(partiesPreDeleteEvent);
                    if (!partiesPreDeleteEvent.isCancelled()) {
                        party.sendBroadcast(pp, Messages.MAINCMD_LEAVE_DISBANDED);
                        party.removeParty();
                        // Calling Post API event
                        PartiesPartyPostDeleteEvent partiesPostDeleteEvent = new PartiesPartyPostDeleteEvent(party.getName(), PartiesPartyPostDeleteEvent.DeleteCause.BAN, pp, kickerPp);
                        Bukkit.getServer().getPluginManager().callEvent(partiesPostDeleteEvent);
                        LoggerManager.log(LogLevel.BASIC, Constants.DEBUG_LIB_BANMANAGER_BAN.replace("{party}", party.getName()).replace("{player}", pl.getName()), true, ConsoleColor.CYAN);
                    } else {
                        // Event is cancelled, block ban chain
                        LoggerManager.log(LogLevel.DEBUG, Constants.DEBUG_API_DELETEEVENT_DENY_GENERIC.replace("{party}", party.getName()), true);
                        return;
                    }
                } else {
                    party.getMembers().remove(pl.getUUID());
                    party.getOnlinePlayers().remove(pl.getPlayer());
                    party.sendBroadcast(pp, Messages.MAINCMD_KICK_BROADCAST);
                    party.updateParty();
                }
            } else
                LoggerManager.log(LogLevel.DEBUG, Constants.DEBUG_API_LEAVEEVENT_DENY.replace("{player}", pl.getName()).replace("{party}", party.getName()), true);
        }
        pp.cleanupPlayer(true);
    }
}
Also used : PartiesPartyPostDeleteEvent(com.alessiodp.partiesapi.events.PartiesPartyPostDeleteEvent) PartyPlayerEntity(com.alessiodp.parties.players.objects.PartyPlayerEntity) PartiesPartyPreDeleteEvent(com.alessiodp.partiesapi.events.PartiesPartyPreDeleteEvent) PartyEntity(com.alessiodp.parties.parties.objects.PartyEntity) PartiesPlayerLeaveEvent(com.alessiodp.partiesapi.events.PartiesPlayerLeaveEvent) PlayerData(me.confuser.banmanager.data.PlayerData) EventHandler(org.bukkit.event.EventHandler)

Example 50 with PartyPlayerEntity

use of com.alessiodp.parties.players.objects.PartyPlayerEntity in project Parties by AlessioDP.

the class PAPIHook method onPlaceholderRequest.

@Override
public String onPlaceholderRequest(Player p, String identifier) {
    PartyPlayerEntity pp = plugin.getPlayerManager().getPlayer(p.getUniqueId());
    PartyEntity party = plugin.getPartyManager().getParty(pp.getPartyName());
    PartiesPlaceholder ph = PartiesPlaceholder.getPlaceholder(identifier);
    return ph != null ? ph.formatPlaceholder(pp, party) : "";
}
Also used : PartyPlayerEntity(com.alessiodp.parties.players.objects.PartyPlayerEntity) PartiesPlaceholder(com.alessiodp.parties.addons.internal.PartiesPlaceholder) PartyEntity(com.alessiodp.parties.parties.objects.PartyEntity)

Aggregations

PartyPlayerEntity (com.alessiodp.parties.players.objects.PartyPlayerEntity)92 PartyEntity (com.alessiodp.parties.parties.objects.PartyEntity)56 Player (org.bukkit.entity.Player)53 EventHandler (org.bukkit.event.EventHandler)13 PartyPlayer (com.alessiodp.partiesapi.objects.PartyPlayer)9 UUID (java.util.UUID)8 ArrayList (java.util.ArrayList)6 PartiesPartyPostDeleteEvent (com.alessiodp.partiesapi.events.PartiesPartyPostDeleteEvent)4 PartiesPartyPreDeleteEvent (com.alessiodp.partiesapi.events.PartiesPartyPreDeleteEvent)4 OfflinePlayer (org.bukkit.OfflinePlayer)4 Status (com.alessiodp.partiesapi.enums.Status)3 PartiesPlayerLeaveEvent (com.alessiodp.partiesapi.events.PartiesPlayerLeaveEvent)3 PartiesPlaceholder (com.alessiodp.parties.addons.internal.PartiesPlaceholder)2 ChatTask (com.alessiodp.parties.tasks.ChatTask)2 PartiesChatEvent (com.alessiodp.partiesapi.events.PartiesChatEvent)2 PartiesFriendlyFireBlockedEvent (com.alessiodp.partiesapi.events.PartiesFriendlyFireBlockedEvent)2 PartiesPlayerJoinEvent (com.alessiodp.partiesapi.events.PartiesPlayerJoinEvent)2 Rank (com.alessiodp.partiesapi.interfaces.Rank)2 Matcher (java.util.regex.Matcher)2 Result (com.alessiodp.parties.addons.external.GriefPreventionHandler.Result)1