Search in sources :

Example 26 with PartyPlayerEntity

use of com.alessiodp.parties.players.objects.PartyPlayerEntity 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 27 with PartyPlayerEntity

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

the class CommandHelp method onCommand.

@Override
public void onCommand(CommandData commandData) {
    PartyPlayerEntity pp = commandData.getPartyPlayer();
    /*
		 * Command starts
		 */
    // Get all allowed commands
    List<String> list = new ArrayList<String>();
    LinkedHashMap<String, String> commands = pp.getAllowedCommands();
    for (Entry<String, String> entry : commands.entrySet()) {
        list.add(entry.getValue());
    }
    // Split commands per page
    int page = 1;
    int maxpages;
    if (list.size() == 0)
        maxpages = 1;
    else if ((list.size() % ConfigMain.COMMANDS_HELP_PERPAGE) == 0)
        maxpages = list.size() / ConfigMain.COMMANDS_HELP_PERPAGE;
    else
        maxpages = (list.size() / ConfigMain.COMMANDS_HELP_PERPAGE) + 1;
    if (commandData.getArgs().length > 1) {
        try {
            page = Integer.parseInt(commandData.getArgs()[1]);
        } catch (NumberFormatException ex) {
        }
        if (page > maxpages || page < 1)
            page = maxpages;
    }
    // Start priting
    int commandNumber = 0;
    String message = Messages.HELP_HEADER.replace("%page%", Integer.toString(page)).replace("%maxpages%", Integer.toString(maxpages)) + "\n";
    for (String string : list) {
        int currentChoosenPage = (page - 1) * ConfigMain.COMMANDS_HELP_PERPAGE;
        if (commandNumber >= currentChoosenPage && commandNumber < currentChoosenPage + ConfigMain.COMMANDS_HELP_PERPAGE) {
            message += string + "\n";
        }
        commandNumber++;
    }
    message += Messages.HELP_FOOTER.replace("%page%", Integer.toString(page)).replace("%maxpages%", Integer.toString(maxpages));
    pp.sendMessage(message);
}
Also used : PartyPlayerEntity(com.alessiodp.parties.players.objects.PartyPlayerEntity) ArrayList(java.util.ArrayList)

Example 28 with PartyPlayerEntity

use of com.alessiodp.parties.players.objects.PartyPlayerEntity 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)

Example 29 with PartyPlayerEntity

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

the class CommandHome 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.HOME.toString())) {
        pp.sendNoPermission(PartiesPermission.HOME);
        return false;
    }
    if (commandData.getArgs().length > 1) {
        if (!player.hasPermission(PartiesPermission.HOME_OTHERS.toString())) {
            pp.sendMessage(Messages.ADDCMD_HOME_WRONGCMD);
            return false;
        } else if (commandData.getArgs().length > 2) {
            pp.sendMessage(Messages.ADDCMD_HOME_WRONGCMD_ADMIN);
            return false;
        }
    }
    commandData.setPlayer(player);
    commandData.setPartyPlayer(pp);
    return true;
}
Also used : Player(org.bukkit.entity.Player) PartyPlayerEntity(com.alessiodp.parties.players.objects.PartyPlayerEntity)

Example 30 with PartyPlayerEntity

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

the class MotdTask method run.

@Override
public void run() {
    if (pl != null && pl.isOnline()) {
        PartyPlayerEntity pp = plugin.getPlayerManager().getPlayer(pl.getUniqueId());
        if (createID.equals(pp.getCreateID()) && !pp.getPartyName().isEmpty()) {
            PartyEntity party = plugin.getPartyManager().getParty(pp.getPartyName());
            if (party != null && !party.getMotd().isEmpty()) {
                StringBuilder sb = new StringBuilder();
                for (String str : Messages.ADDCMD_MOTD_CONTENT) {
                    sb.append(str.replace(Constants.PLACEHOLDER_PARTY_MOTD, "%temporary_motd%") + "\n");
                }
                String message = PartiesUtils.convertAllPlaceholders(sb.toString(), party, pp);
                sb = new StringBuilder();
                for (String str : party.getMotd().split(ConfigParties.MOTD_NEWLINECODE)) {
                    sb.append(str + "\n");
                }
                message = message.replace("%temporary_motd%", sb.toString());
                pp.sendMessage(message);
            }
        }
    }
}
Also used : PartyPlayerEntity(com.alessiodp.parties.players.objects.PartyPlayerEntity) 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