Search in sources :

Example 36 with PartyImpl

use of com.alessiodp.parties.common.parties.objects.PartyImpl in project Parties by AlessioDP.

the class CommandCreate method createParty.

public static PartyImpl createParty(PartiesPlugin plugin, PartiesSubCommand subCommand, User sender, PartyPlayerImpl partyPlayer, String partyName, boolean fixed) {
    PartyImpl ret = null;
    IPartyPreCreateEvent partiesPreEvent = plugin.getEventManager().preparePartyPreCreateEvent(partyPlayer, partyName, fixed);
    plugin.getEventManager().callEvent(partiesPreEvent);
    String newPartyName = partiesPreEvent.getPartyName();
    boolean isFixed = partiesPreEvent.isFixed();
    if (!partiesPreEvent.isCancelled() && (isFixed || partyPlayer != null)) {
        PartyImpl party = plugin.getPartyManager().initializeParty();
        party.create(newPartyName, isFixed ? null : partyPlayer, partyPlayer);
        if (isFixed) {
            subCommand.sendMessage(sender, partyPlayer, Messages.MAINCMD_CREATE_CREATEDFIXED, party);
            plugin.getLoggerManager().logDebug(String.format(PartiesConstants.DEBUG_CMD_CREATE_FIXED, sender.getName(), party.getName() != null ? party.getName() : "_"), true);
        } else {
            subCommand.sendMessage(sender, partyPlayer, Messages.MAINCMD_CREATE_CREATED, party);
            plugin.getLoggerManager().logDebug(String.format(PartiesConstants.DEBUG_CMD_CREATE, sender.getName(), party.getName() != null ? party.getName() : "_"), true);
        }
        ret = party;
    } else {
        plugin.getLoggerManager().log(String.format(PartiesConstants.DEBUG_API_CREATEEVENT_DENY, partyName, sender.getName(), sender.getUUID().toString()), true);
    }
    return ret;
}
Also used : IPartyPreCreateEvent(com.alessiodp.parties.api.events.common.party.IPartyPreCreateEvent) PartyImpl(com.alessiodp.parties.common.parties.objects.PartyImpl)

Example 37 with PartyImpl

use of com.alessiodp.parties.common.parties.objects.PartyImpl in project Parties by AlessioDP.

the class CommandDelete method onCommand.

@Override
public void onCommand(@NotNull CommandData commandData) {
    User sender = commandData.getSender();
    PartyPlayerImpl partyPlayer = ((PartiesCommandData) commandData).getPartyPlayer();
    // Command handling
    PartyImpl party = getPlugin().getPartyManager().getParty(commandData.getArgs()[1]);
    if (party == null) {
        sendMessage(sender, partyPlayer, Messages.PARTIES_COMMON_PARTYNOTFOUND.replace("%party%", commandData.getArgs()[1]));
        return;
    }
    boolean isSilent = false;
    if (commandData.getArgs().length == 3) {
        if (commandData.havePermission(PartiesPermission.ADMIN_DELETE_SILENT) && commandData.getArgs()[2].equalsIgnoreCase(ConfigMain.COMMANDS_MISC_SILENT)) {
            isSilent = true;
        } else {
            sendMessage(sender, ((PartiesCommandData) commandData).getPartyPlayer(), Messages.PARTIES_SYNTAX_WRONG_MESSAGE.replace("%syntax%", getSyntaxForUser(sender)));
            return;
        }
    }
    // Command starts
    // Calling Pre API event
    IPartyPreDeleteEvent partiesPreDeleteEvent = getPlugin().getEventManager().preparePartyPreDeleteEvent(party, DeleteCause.DELETE, null, partyPlayer);
    getPlugin().getEventManager().callEvent(partiesPreDeleteEvent);
    if (!partiesPreDeleteEvent.isCancelled()) {
        if (isSilent) {
            sendMessage(sender, partyPlayer, Messages.MAINCMD_DELETE_DELETEDSILENTLY, party);
        } else {
            sendMessage(sender, partyPlayer, Messages.MAINCMD_DELETE_DELETED, party);
            party.broadcastMessage(Messages.MAINCMD_DELETE_BROADCAST, partyPlayer);
        }
        party.delete(DeleteCause.DELETE, null, partyPlayer);
        plugin.getLoggerManager().logDebug(String.format(PartiesConstants.DEBUG_CMD_DELETE, sender.getName(), party.getName() != null ? party.getName() : "_"), true);
    } else {
        plugin.getLoggerManager().logDebug(String.format(PartiesConstants.DEBUG_API_DELETEEVENT_DENY, party.getId(), sender.getName(), sender.getUUID().toString()), true);
    }
}
Also used : User(com.alessiodp.core.common.user.User) IPartyPreDeleteEvent(com.alessiodp.parties.api.events.common.party.IPartyPreDeleteEvent) PartyPlayerImpl(com.alessiodp.parties.common.players.objects.PartyPlayerImpl) PartiesCommandData(com.alessiodp.parties.common.commands.utils.PartiesCommandData) PartyImpl(com.alessiodp.parties.common.parties.objects.PartyImpl)

Example 38 with PartyImpl

use of com.alessiodp.parties.common.parties.objects.PartyImpl in project Parties by AlessioDP.

the class CommandFollow method onCommand.

@Override
public void onCommand(@NotNull CommandData commandData) {
    User sender = commandData.getSender();
    PartyPlayerImpl partyPlayer = ((PartiesCommandData) commandData).getPartyPlayer();
    PartyImpl party = ((PartiesCommandData) commandData).getParty();
    // Command handling
    Boolean follow = plugin.getCommandManager().getCommandUtils().handleOnOffCommand(party.isFollowEnabled(), commandData.getArgs());
    if (follow == null) {
        sendMessage(sender, partyPlayer, Messages.PARTIES_SYNTAX_WRONG_MESSAGE.replace("%syntax%", syntax));
        return;
    }
    if (follow && getPlugin().getEconomyManager().payCommand(EconomyManager.PaidCommand.FOLLOW, partyPlayer, commandData.getCommandLabel(), commandData.getArgs()))
        return;
    // Command starts
    party.setFollowEnabled(follow);
    if (follow)
        sendMessage(sender, partyPlayer, Messages.ADDCMD_FOLLOW_ON);
    else
        sendMessage(sender, partyPlayer, Messages.ADDCMD_FOLLOW_OFF);
    plugin.getLoggerManager().logDebug(String.format(PartiesConstants.DEBUG_CMD_FOLLOW, partyPlayer.getName(), follow, party.getName() != null ? party.getName() : "_"), true);
}
Also used : User(com.alessiodp.core.common.user.User) PartyPlayerImpl(com.alessiodp.parties.common.players.objects.PartyPlayerImpl) PartiesCommandData(com.alessiodp.parties.common.commands.utils.PartiesCommandData) PartyImpl(com.alessiodp.parties.common.parties.objects.PartyImpl)

Example 39 with PartyImpl

use of com.alessiodp.parties.common.parties.objects.PartyImpl in project Parties by AlessioDP.

the class CommandInfo method onCommand.

@Override
public void onCommand(@NotNull CommandData commandData) {
    User sender = commandData.getSender();
    PartyPlayerImpl partyPlayer = ((PartiesCommandData) commandData).getPartyPlayer();
    PartyImpl party;
    // Command handling
    if (commandData.getArgs().length == 1 && sender.isPlayer()) {
        party = getPlugin().getPartyManager().getPartyOfPlayer(partyPlayer);
    } else if (commandData.getArgs().length == 2 && commandData.havePermission(PartiesPermission.USER_INFO_OTHERS)) {
        party = getPlugin().getPartyManager().getParty(commandData.getArgs()[1]);
    } else {
        sendMessage(sender, partyPlayer, Messages.PARTIES_SYNTAX_WRONG_MESSAGE.replace("%syntax%", getSyntaxForUser(sender)));
        return;
    }
    if (party == null) {
        if (commandData.getArgs().length > 1)
            sendMessage(sender, partyPlayer, Messages.PARTIES_COMMON_PARTYNOTFOUND.replace("%party%", commandData.getArgs()[1]));
        else
            sendMessage(sender, partyPlayer, Messages.PARTIES_COMMON_NOTINPARTY);
        return;
    }
    // Command starts
    for (String line : Messages.MAINCMD_INFO_CONTENT) {
        line = getPlugin().getMessageUtils().convertPlaceholders(line, partyPlayer, party, Messages.PARTIES_LIST_MISSING);
        sendMessage(sender, partyPlayer, line);
    }
    plugin.getLoggerManager().logDebug(String.format(PartiesConstants.DEBUG_CMD_INFO, sender.getName(), party.getName() != null ? party.getName() : "_"), true);
}
Also used : User(com.alessiodp.core.common.user.User) PartyPlayerImpl(com.alessiodp.parties.common.players.objects.PartyPlayerImpl) PartiesCommandData(com.alessiodp.parties.common.commands.utils.PartiesCommandData) PartyImpl(com.alessiodp.parties.common.parties.objects.PartyImpl)

Example 40 with PartyImpl

use of com.alessiodp.parties.common.parties.objects.PartyImpl in project Parties by AlessioDP.

the class BukkitFightListener method onEntityDieKill.

@EventHandler(ignoreCancelled = true)
public void onEntityDieKill(EntityDeathEvent event) {
    if (BukkitConfigParties.ADDITIONAL_KILLS_ENABLE && event.getEntity().getKiller() != null) {
        Player killer = event.getEntity().getKiller();
        PartyPlayerImpl ppKiller = plugin.getPlayerManager().getPlayer(killer.getUniqueId());
        PartyImpl party = plugin.getPartyManager().getParty(ppKiller.getPartyId());
        if (party != null) {
            boolean gotKill = false;
            if (BukkitConfigParties.ADDITIONAL_KILLS_MOB_HOSTILE && event.getEntity() instanceof Monster)
                gotKill = true;
            else if (BukkitConfigParties.ADDITIONAL_KILLS_MOB_NEUTRAL && event.getEntity() instanceof Animals)
                gotKill = true;
            else if (BukkitConfigParties.ADDITIONAL_KILLS_MOB_PLAYERS && event.getEntity() instanceof Player)
                gotKill = true;
            if (gotKill) {
                party.setKills(party.getKills() + 1);
                plugin.getLoggerManager().logDebug(String.format(PartiesConstants.DEBUG_KILL_ADD, party.getId(), killer.getUniqueId()), true);
            }
        }
    }
}
Also used : Player(org.bukkit.entity.Player) Animals(org.bukkit.entity.Animals) PartyPlayerImpl(com.alessiodp.parties.common.players.objects.PartyPlayerImpl) BukkitPartyPlayerImpl(com.alessiodp.parties.bukkit.players.objects.BukkitPartyPlayerImpl) Monster(org.bukkit.entity.Monster) BukkitPartyImpl(com.alessiodp.parties.bukkit.parties.objects.BukkitPartyImpl) PartyImpl(com.alessiodp.parties.common.parties.objects.PartyImpl) EventHandler(org.bukkit.event.EventHandler)

Aggregations

PartyImpl (com.alessiodp.parties.common.parties.objects.PartyImpl)106 PartyPlayerImpl (com.alessiodp.parties.common.players.objects.PartyPlayerImpl)75 User (com.alessiodp.core.common.user.User)39 PartiesCommandData (com.alessiodp.parties.common.commands.utils.PartiesCommandData)31 ADPPlugin (com.alessiodp.core.common.ADPPlugin)11 UUID (java.util.UUID)11 ConfigMain (com.alessiodp.parties.common.configuration.data.ConfigMain)10 ConfigParties (com.alessiodp.parties.common.configuration.data.ConfigParties)10 PartiesPlugin (com.alessiodp.parties.common.PartiesPlugin)9 PartiesConstants (com.alessiodp.parties.common.configuration.PartiesConstants)9 PartyHomeImpl (com.alessiodp.parties.common.parties.objects.PartyHomeImpl)8 LinkedList (java.util.LinkedList)8 LinkedHashSet (java.util.LinkedHashSet)7 List (java.util.List)7 HashMap (java.util.HashMap)6 ADPMainCommand (com.alessiodp.core.common.commands.utils.ADPMainCommand)5 CommandData (com.alessiodp.core.common.commands.utils.CommandData)5 OfflineUser (com.alessiodp.core.common.user.OfflineUser)5 CommonCommands (com.alessiodp.parties.common.commands.list.CommonCommands)5 PartiesSubCommand (com.alessiodp.parties.common.commands.utils.PartiesSubCommand)5