Package net.citizensnpcs.questers.data

Examples of net.citizensnpcs.questers.data.PlayerProfile


        Player other = Bukkit.getServer().getPlayer(args.getString(1));
        if (other == null && !new File("plugins/Citizens/profiles/" + name + ".yml").exists()) {
            sender.sendMessage(ChatColor.GRAY + "Couldn't find the offline player quest file.");
            return;
        }
        PlayerProfile profile = PlayerProfile.getProfile(args.getString(1), false);
        if (profile.hasQuest() && !args.hasFlag('f')) {
            sender.sendMessage(ChatColor.GRAY + "Player already has a quest. Use the -f flag to force add the quest.");
            return;
        }
        profile.setProgress(new QuestProgress(args.getInteger(2), other, quest, System.currentTimeMillis()));
        if (other == null)
            profile.save();
        sender.sendMessage(ChatColor.GREEN + "Quest added.");
    }
View Full Code Here


                return;
            }
            for (File file : dir.listFiles()) {
                if (!file.isFile())
                    continue;
                PlayerProfile profile = PlayerProfile.getProfile(file.getName().replace(".yml", ""), false);
                if (profile != null)
                    profiles.add(profile);
            }
        } else {
            if (!new File("plugins/Citizens/profiles/" + name + ".yml").exists() && !PlayerProfile.isOnline(name)) {
                sender.sendMessage(ChatColor.GRAY + "Couldn't find that player.");
                return;
            }
            profiles.add(PlayerProfile.getProfile(name, false));
        }
        boolean clearCompleted = args.hasFlag('c'), matchAny = quest.equals("*");
        for (PlayerProfile profile : profiles) {
            if (profile == null)
                throw new IllegalStateException("player profile was null");
            boolean changed = false;
            if (profile.hasQuest() && (matchAny || profile.getQuest().equalsIgnoreCase(quest))) {
                profile.setProgress(null);
                changed = true;
            }
            if (clearCompleted) {
                if (matchAny)
                    profile.removeAllCompletedQuests();
                else
                    profile.removeCompletedQuest(quest);
                changed = true;
            }
            if (changed && !profile.isOnline())
                profile.save();
        }
        sender.sendMessage(ChatColor.GREEN + "Quests cleared.");
    }
View Full Code Here

    @CommandRequirements()
    @Command(aliases = "quest", usage = "save", desc = "saves current progress", modifiers = "save", min = 1, max = 1)
    @CommandPermissions("quester.use.quests.save")
    public static void saveProfile(CommandContext args, Player player, HumanNPC npc) {
        PlayerProfile profile = PlayerProfile.getProfile(player.getName());
        if (System.currentTimeMillis() - profile.getLastSaveTime() < Settings.getInt("QuestSaveDelay")) {
            player.sendMessage(ChatColor.GRAY
                    + "Please wait "
                    + TimeUnit.SECONDS.convert(Settings.getInt("QuestSaveDelay")
                            - (System.currentTimeMillis() - profile.getLastSaveTime()), TimeUnit.MILLISECONDS)
                    + " seconds before saving again.");
            return;
        }
        profile.save();
        player.sendMessage(ChatColor.GREEN + "Saved current progress.");
    }
View Full Code Here

            modifiers = "completed",
            min = 1,
            max = 2)
    @CommandPermissions("quester.use.quests.status")
    public static void viewCompleted(CommandContext args, Player player, HumanNPC npc) {
        PlayerProfile profile = PlayerProfile.getProfile(player.getName());
        if (profile.getAllCompleted().size() == 0) {
            player.sendMessage(ChatColor.GRAY + "You haven't completed any quests yet.");
            return;
        }
        int page = args.argsLength() == 2 ? args.getInteger(1) : 1;
        if (page < 0)
            page = 1;
        PageInstance instance = PageUtils.newInstance(player);
        instance.header(ChatColor.GREEN
                + StringUtils.listify("Completed Quests " + ChatColor.WHITE + "<%x/%y>" + ChatColor.GREEN));
        for (CompletedQuest quest : profile.getAllCompleted()) {
            if (instance.maxPages() > page)
                break;
            instance.push(StringUtils.wrap(quest.getName()) + " - taking " + StringUtils.wrap(quest.getMinutes())
                    + " minutes. Completed " + StringUtils.wrap(quest.getTimesCompleted()) + " times.");
        }
View Full Code Here

            modifiers = "status",
            min = 1,
            max = 1)
    @CommandPermissions("quester.use.quests.status")
    public static void viewCurrentQuestStatus(CommandContext args, Player player, HumanNPC npc) {
        PlayerProfile profile = PlayerProfile.getProfile(player.getName());
        if (!profile.hasQuest()) {
            player.sendMessage(ChatColor.GRAY + "You don't have a quest at the moment.");
        } else {
            player.sendMessage(ChatColor.GREEN
                    + "Currently in the middle of "
                    + StringUtils.wrap(profile.getProgress().getQuestName())
                    + ". You have been on this quest for "
                    + StringUtils.wrap(TimeUnit.MINUTES.convert(System.currentTimeMillis()
                            - profile.getProgress().getStartTime(), TimeUnit.MILLISECONDS)) + " minutes.");
            if (profile.getProgress().isFullyCompleted()) {
                player.sendMessage(ChatColor.AQUA + "Quest is completed.");
            } else {
                player.sendMessage(ChatColor.GREEN + "-" + ChatColor.AQUA + " Progress report " + ChatColor.GREEN + "-");
                boolean override = QuestManager.getQuest(profile.getQuest()).sendProgressText(player);
                for (ObjectiveProgress progress : profile.getProgress().getProgress()) {
                    if (progress == null)
                        continue;
                    try {
                        String progressText = progress.getStatusText(override);
                        if (!progressText.isEmpty())
                            Messaging.send(player, StringUtils.wrap("  - ", ChatColor.WHITE) + progressText);
                    } catch (QuestCancelException ex) {
                        player.sendMessage(ChatColor.GRAY + "Cancelling quest. Reason: " + ex.getReason());
                        profile.setProgress(null);
                    }
                }
            }
        }
    }
View Full Code Here

    public static boolean canRepeat(Player player, Quest quest) {
        if (quest == null) {
            return false;
        }
        PlayerProfile profile = PlayerProfile.getProfile(player.getName());
        return !profile.hasCompleted(quest.getName())
                || (quest.getRepeatLimit() == -1 || profile.getCompletedQuest(quest.getName())
                        .getTimesCompleted() < quest.getRepeatLimit());
    }
View Full Code Here

    public static void clearQuests() {
        quests.clear();
    }

    public static void completeQuest(Player player) {
        PlayerProfile profile = PlayerProfile.getProfile(player.getName());
        Quest quest = QuestManager.getQuest(profile.getProgress().getQuestName());
        quest.onCompletion(player, profile.getProgress());
        int UID = profile.getProgress().getQuesterUID();
        long elapsed = System.currentTimeMillis() - profile.getProgress().getStartTime();
        profile.setProgress(null);
        int completed = profile.hasCompleted(quest.getName()) ? profile.getCompletedQuest(quest.getName())
                .getTimesCompleted() + 1 : 1;
        CompletedQuest comp = new CompletedQuest(quest.getName(), UID, completed, elapsed,
                System.currentTimeMillis());
        profile.addCompletedQuest(comp);
        Bukkit.getServer().getPluginManager().callEvent(new QuestCompleteEvent(quest, comp, player));
    }
View Full Code Here

            pending.remove(player);
        }
    }

    private void checkCompletion(Player player, HumanNPC npc) {
        PlayerProfile profile = PlayerProfile.getProfile(player.getName());
        if (profile.getProgress().getQuesterUID() == npc.getUID()) {
            if (profile.getProgress().isFullyCompleted()) {
                QuestManager.completeQuest(player);
            } else {
                player.sendMessage(ChatColor.GRAY + "The quest isn't completed yet.");
            }
        } else {
View Full Code Here

    @CommandRequirements()
    @Command(aliases = "quest", usage = "abort", desc = "aborts current quest", modifiers = "abort", min = 1, max = 1)
    @CommandPermissions("quester.use.quests.abort")
    public static void abortCurrentQuest(CommandContext args, Player player, HumanNPC npc) {
        PlayerProfile profile = PlayerProfile.getProfile(player.getName());
        if (!profile.hasQuest()) {
            player.sendMessage(ChatColor.GRAY + "You don't have a quest at the moment.");
        } else {
            Bukkit.getPluginManager().callEvent(
                    new QuestCancelEvent(QuestManager.getQuest(profile.getProgress().getQuestName()), player));
            List<Reward> abort = QuestManager.getQuest(profile.getQuest()).getAbortRewards();
            if (abort != null) {
                for (Reward reward : abort)
                    reward.grant(player, profile.getProgress().getQuesterUID());
            }
            profile.setProgress(null);
            player.sendMessage(ChatColor.GREEN + "Quest cleared.");
        }
    }
View Full Code Here

TOP

Related Classes of net.citizensnpcs.questers.data.PlayerProfile

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.