Search in sources :

Example 16 with PartyEntity

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

the class CommandMotd method preRequisites.

@Override
public boolean preRequisites(CommandData commandData) {
    Player player = (Player) commandData.getSender();
    PartyPlayerEntity pp = plugin.getPlayerManager().getPlayer(player.getUniqueId());
    /*
		 * Checks for command prerequisites
		 */
    if (!player.hasPermission(PartiesPermission.MOTD.toString())) {
        pp.sendNoPermission(PartiesPermission.MOTD);
        return false;
    }
    PartyEntity party = pp.getPartyName().isEmpty() ? null : plugin.getPartyManager().getParty(pp.getPartyName());
    if (party == null) {
        pp.sendMessage(Messages.PARTIES_COMMON_NOTINPARTY);
        return false;
    }
    if (!PartiesUtils.checkPlayerRankAlerter(pp, PartiesPermission.PRIVATE_EDIT_MOTD))
        return false;
    if (commandData.getArgs().length < 2) {
        pp.sendMessage(Messages.ADDCMD_MOTD_WRONGCMD);
        return false;
    }
    commandData.setPlayer(player);
    commandData.setPartyPlayer(pp);
    commandData.setParty(party);
    return true;
}
Also used : Player(org.bukkit.entity.Player) PartyPlayerEntity(com.alessiodp.parties.players.objects.PartyPlayerEntity) PartyEntity(com.alessiodp.parties.parties.objects.PartyEntity)

Example 17 with PartyEntity

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

the class CommandAccept method onCommand.

@Override
public void onCommand(CommandData commandData) {
    PartyPlayerEntity pp = commandData.getPartyPlayer();
    PartyEntity party = plugin.getPartyManager().getParty(pp.getLastInvite());
    if (party == null) {
        pp.sendMessage(Messages.MAINCMD_ACCEPT_NOEXISTS);
        return;
    }
    if ((ConfigParties.GENERAL_MEMBERSLIMIT != -1) && (party.getMembers().size() >= ConfigParties.GENERAL_MEMBERSLIMIT)) {
        pp.sendMessage(Messages.PARTIES_COMMON_PARTYFULL);
        return;
    }
    /*
		 * Command starts
		 */
    party.acceptInvite(pp.getPlayerUUID());
    LoggerManager.log(LogLevel.MEDIUM, Constants.DEBUG_CMD_ACCEPT.replace("{player}", pp.getName()).replace("{party}", party.getName()), true);
}
Also used : PartyPlayerEntity(com.alessiodp.parties.players.objects.PartyPlayerEntity) PartyEntity(com.alessiodp.parties.parties.objects.PartyEntity)

Example 18 with PartyEntity

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

the class CommandClaim method onCommand.

@Override
public void onCommand(CommandData commandData) {
    PartyPlayerEntity pp = commandData.getPartyPlayer();
    PartyEntity party = commandData.getParty();
    /*
		 * Command handling
		 */
    if (commandData.getArgs().length != 2) {
        pp.sendMessage(Messages.ADDCMD_CLAIM_WRONGCMD);
        return;
    }
    Selection selection = Selection.FAILED_GENERAL;
    if (commandData.getArgs()[1].equalsIgnoreCase(ConfigMain.ADDONS_GRIEFPREVENTION_CMD_TRUST))
        selection = Selection.TRUST;
    else if (commandData.getArgs()[1].equalsIgnoreCase(ConfigMain.ADDONS_GRIEFPREVENTION_CMD_CONTAINER))
        selection = Selection.CONTAINER;
    else if (commandData.getArgs()[1].equalsIgnoreCase(ConfigMain.ADDONS_GRIEFPREVENTION_CMD_ACCESS))
        selection = Selection.ACCESS;
    else if (commandData.getArgs()[1].equalsIgnoreCase(ConfigMain.ADDONS_GRIEFPREVENTION_CMD_REMOVE))
        selection = Selection.REMOVE;
    if (!selection.equals(Selection.FAILED_GENERAL)) {
        Result res = GriefPreventionHandler.isManager(commandData.getPlayer());
        switch(res) {
            case NOEXIST:
                selection = Selection.FAILED_NOEXIST;
                break;
            case NOMANAGER:
                selection = Selection.FAILED_NOMANAGER;
                break;
            default:
                // Success, selection it's okay
                break;
        }
    }
    if (VaultHandler.payCommand(VaultHandler.VaultCommand.CLAIM, pp, commandData.getCommandLabel(), commandData.getArgs()))
        return;
    /*
		 * Command starts
		 */
    switch(selection) {
        case FAILED_NOEXIST:
            // Return: No exist claim
            pp.sendMessage(Messages.ADDCMD_CLAIM_CLAIMNOEXISTS);
            break;
        case FAILED_NOMANAGER:
            // Return: No manager
            pp.sendMessage(Messages.ADDCMD_CLAIM_NOMANAGER);
            break;
        case FAILED_GENERAL:
            // Return: Wrong command
            pp.sendMessage(Messages.ADDCMD_CLAIM_WRONGCMD);
            break;
        default:
            GriefPreventionHandler.addPartyPermission(commandData.getPlayer(), party, selection.getGPPermission());
            pp.sendMessage(Messages.ADDCMD_CLAIM_CLAIMED);
            LoggerManager.log(LogLevel.MEDIUM, Constants.DEBUG_CMD_CLAIM.replace("{player}", pp.getName()).replace("{value}", commandData.getArgs()[1].toLowerCase()), true);
    }
}
Also used : PartyPlayerEntity(com.alessiodp.parties.players.objects.PartyPlayerEntity) PartyEntity(com.alessiodp.parties.parties.objects.PartyEntity) Result(com.alessiodp.parties.addons.external.GriefPreventionHandler.Result)

Example 19 with PartyEntity

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

the class CommandDeny method onCommand.

@Override
public void onCommand(CommandData commandData) {
    PartyPlayerEntity pp = commandData.getPartyPlayer();
    PartyEntity party = commandData.getParty();
    /*
		 * Command starts
		 */
    party.denyInvite(pp.getPlayerUUID());
    LoggerManager.log(LogLevel.MEDIUM, Constants.DEBUG_CMD_DENY.replace("{player}", pp.getName()).replace("{party}", party.getName()), true);
}
Also used : PartyPlayerEntity(com.alessiodp.parties.players.objects.PartyPlayerEntity) PartyEntity(com.alessiodp.parties.parties.objects.PartyEntity)

Example 20 with PartyEntity

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

the class CommandHome method onCommand.

@Override
public void onCommand(CommandData commandData) {
    PartyPlayerEntity pp = commandData.getPartyPlayer();
    /*
		 * Command handling
		 */
    PartyEntity party;
    if (commandData.getArgs().length > 1)
        party = plugin.getPartyManager().getParty(commandData.getArgs()[1]);
    else
        party = plugin.getPartyManager().getParty(pp.getPartyName());
    if (party == null) {
        if (commandData.getArgs().length > 1)
            pp.sendMessage(Messages.ADDCMD_HOME_NOEXISTS);
        else
            pp.sendMessage(Messages.PARTIES_COMMON_NOTINPARTY);
        return;
    }
    if (commandData.getArgs().length == 1 && !PartiesUtils.checkPlayerRankAlerter(pp, PartiesPermission.PRIVATE_HOME))
        return;
    if (party.getHome() == null) {
        pp.sendMessage(Messages.ADDCMD_HOME_NOHOME, party);
        return;
    }
    if (VaultHandler.payCommand(VaultHandler.VaultCommand.HOME, pp, commandData.getCommandLabel(), commandData.getArgs()))
        return;
    /*
		 * Command starts
		 */
    int delay = ConfigParties.HOME_DELAY;
    for (PermissionAttachmentInfo pa : commandData.getPlayer().getEffectivePermissions()) {
        String perm = pa.getPermission();
        if (perm.startsWith("parties.home.")) {
            String[] splitted = perm.split("\\.");
            try {
                delay = Integer.parseInt(splitted[2]);
            } catch (Exception ex) {
            }
        }
    }
    if (delay > 0) {
        pp.setHomeFrom(commandData.getPlayer().getLocation());
        plugin.getPlayerManager().addHomeCount();
        BukkitTask it = new HomeTask(plugin, pp, party.getHome()).runTaskLater(plugin, delay * 20);
        pp.setHomeTask(it.getTaskId());
        pp.sendMessage(Messages.ADDCMD_HOME_TELEPORTIN.replace("%time%", Integer.toString(delay)));
    } else {
        plugin.getPartiesScheduler().runSync(() -> {
            commandData.getPlayer().teleport(party.getHome());
        });
        pp.sendMessage(Messages.ADDCMD_HOME_TELEPORTED);
    }
    LoggerManager.log(LogLevel.MEDIUM, Constants.DEBUG_CMD_HOME.replace("{player}", pp.getName()).replace("{party}", party.getName()), true);
}
Also used : PartyPlayerEntity(com.alessiodp.parties.players.objects.PartyPlayerEntity) BukkitTask(org.bukkit.scheduler.BukkitTask) PartyEntity(com.alessiodp.parties.parties.objects.PartyEntity) PermissionAttachmentInfo(org.bukkit.permissions.PermissionAttachmentInfo) HomeTask(com.alessiodp.parties.tasks.HomeTask)

Aggregations

PartyEntity (com.alessiodp.parties.parties.objects.PartyEntity)67 PartyPlayerEntity (com.alessiodp.parties.players.objects.PartyPlayerEntity)56 Player (org.bukkit.entity.Player)31 EventHandler (org.bukkit.event.EventHandler)11 PartyPlayer (com.alessiodp.partiesapi.objects.PartyPlayer)6 Status (com.alessiodp.partiesapi.enums.Status)5 PartiesPartyPostDeleteEvent (com.alessiodp.partiesapi.events.PartiesPartyPostDeleteEvent)5 PartiesPartyPreDeleteEvent (com.alessiodp.partiesapi.events.PartiesPartyPreDeleteEvent)5 UUID (java.util.UUID)5 PartiesPlayerLeaveEvent (com.alessiodp.partiesapi.events.PartiesPlayerLeaveEvent)3 Party (com.alessiodp.partiesapi.objects.Party)3 ArrayList (java.util.ArrayList)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 Rank (com.alessiodp.partiesapi.interfaces.Rank)2 Matcher (java.util.regex.Matcher)2 OfflinePlayer (org.bukkit.OfflinePlayer)2 Result (com.alessiodp.parties.addons.external.GriefPreventionHandler.Result)1