Examples of PlayerProfile


Examples of com.gmail.nossr50.datatypes.player.PlayerProfile

    public void run() {
        int convertedUsers = 0;
        long startMillis = System.currentTimeMillis();
        for (String playerName : mcMMO.getDatabaseManager().getStoredUsers()) {
            McMMOPlayer mcMMOPlayer = UserManager.getOfflinePlayer(playerName);
            PlayerProfile profile;

            // If the mcMMOPlayer doesn't exist, create a temporary profile and check if it's present in the database. If it's not, abort the process.
            if (mcMMOPlayer == null) {
                profile = mcMMO.getDatabaseManager().loadPlayerProfile(playerName, false);

                if (!profile.isLoaded()) {
                    mcMMO.p.debug("Profile not loaded.");
                    continue;
                }

                editValues(profile);
                // Since this is a temporary profile, we save it here.
                profile.scheduleAsyncSave();
            }
            else {
                profile = mcMMOPlayer.getProfile();
                editValues(profile);
            }
View Full Code Here

Examples of com.onarandombox.multiverseinventories.api.profile.PlayerProfile

                        }
                        String group = mvgroup.getName();
                        groups.set(group, exampleGroup);
                        MIYamlFiles.saveYamlFile(groups, "groups.yml");
                        for(OfflinePlayer player1 : Bukkit.getServer().getOfflinePlayers()) {
                            PlayerProfile playerdata = mvgroup.getPlayerData(ProfileTypes.SURVIVAL, player1);
                            if(playerdata != null && playerdata.get(Sharables.INVENTORY) != null) {
                                ItemStack[] inventory = playerdata.get(Sharables.INVENTORY);
                                ItemStack[] armor = playerdata.get(Sharables.ARMOR);
                                Integer health = playerdata.get(Sharables.HEALTH);
                                Integer hunger = playerdata.get(Sharables.FOOD_LEVEL);
                                Float saturation = playerdata.get(Sharables.SATURATION);
                                Integer totalexp = playerdata.get(Sharables.TOTAL_EXPERIENCE);
                                PotionEffect[] potioneffects = playerdata.get(Sharables.POTIONS);
                                LinkedList<PotionEffect> effects = new LinkedList<PotionEffect>();
                                if(potioneffects != null) {
                                    for(int i = 0; i < potioneffects.length; i++) {
                                        effects.add(potioneffects[i]);
                                    }
                                }
                                if(MIYamlFiles.usesql) {
                                    MIYamlFiles.con.saveInventory(player, group, new MIInventory(inventory, armor, effects), "SURVIVAL");
                                    MIYamlFiles.con.saveHealth(player, group, health);
                                    MIYamlFiles.con.saveHunger(player, group, hunger);
                                    MIYamlFiles.con.saveSaturation(player, group, saturation);
                                    MIYamlFiles.con.saveExperience(player, group, totalexp);
                                } else {
                                    MIPlayerFile config = new MIPlayerFile(player1, group);
                                    config.saveInventory(new MIInventory(inventory, armor, effects), "SURVIVAL");
                                    config.saveHealth(health);
                                    config.saveHunger(hunger);
                                    config.saveSaturation(saturation);
                                    int[] levels = plugin.getXP(totalexp);
                                    config.saveExperience(totalexp, levels[0], (float) ((float) levels[1] / (float) levels[2]));
                                }
                            }
                            PlayerProfile adventureplayerdata = mvgroup.getPlayerData(ProfileTypes.ADVENTURE, player1);
                            if(adventureplayerdata != null && adventureplayerdata.get(Sharables.INVENTORY) != null) {
                                ItemStack[] inventory = adventureplayerdata.get(Sharables.INVENTORY);
                                ItemStack[] armor = adventureplayerdata.get(Sharables.ARMOR);
                                PotionEffect[] potioneffects = adventureplayerdata.get(Sharables.POTIONS);
                                LinkedList<PotionEffect> effects = new LinkedList<PotionEffect>();
                                if(potioneffects != null) {
                                    for(int i = 0; i < potioneffects.length; i++) {
                                        effects.add(potioneffects[i]);
                                    }
                                }
                                if(MIYamlFiles.usesql) {
                                    MIYamlFiles.con.saveInventory(player, group, new MIInventory(inventory, armor, effects), "ADVENTURE");
                                } else {
                                    MIPlayerFile config = new MIPlayerFile(player1, group);
                                    config.saveInventory(new MIInventory(inventory, armor, effects), "ADVENTURE");
                                }
                            }
                        }
                    }
                    for(World world : Bukkit.getWorlds()) {
                        String worldName = world.getName();
                        if(!MIYamlFiles.getGroups().containsKey(worldName)) {
                            WorldProfile worldprofile = mvinventories.getWorldManager().getWorldProfile(worldName);
                            for(OfflinePlayer player1 : Bukkit.getServer().getOfflinePlayers()) {
                                PlayerProfile playerdata = worldprofile.getPlayerData(ProfileTypes.SURVIVAL, player1);
                                if(playerdata != null && playerdata.get(Sharables.INVENTORY) != null) {
                                    ItemStack[] inventory = playerdata.get(Sharables.INVENTORY);
                                    ItemStack[] armor = playerdata.get(Sharables.ARMOR);
                                    Integer health = playerdata.get(Sharables.HEALTH);
                                    Integer hunger = playerdata.get(Sharables.FOOD_LEVEL);
                                    Float saturation = playerdata.get(Sharables.SATURATION);
                                    Integer totalexp = playerdata.get(Sharables.TOTAL_EXPERIENCE);
                                    PotionEffect[] potioneffects = playerdata.get(Sharables.POTIONS);
                                    LinkedList<PotionEffect> effects = new LinkedList<PotionEffect>();
                                    if(potioneffects != null) {
                                        for(int i = 0; i < potioneffects.length; i++) {
                                            effects.add(potioneffects[i]);
                                        }
                                    }
                                    if(MIYamlFiles.usesql) {
                                        MIYamlFiles.con.saveInventory(player, worldName, new MIInventory(inventory, armor, effects), "SURVIVAL");
                                        MIYamlFiles.con.saveHealth(player, worldName, health);
                                        MIYamlFiles.con.saveHunger(player, worldName, hunger);
                                        MIYamlFiles.con.saveSaturation(player, worldName, saturation);
                                        MIYamlFiles.con.saveExperience(player, worldName, totalexp);
                                    } else {
                                        MIPlayerFile config = new MIPlayerFile(player1, worldName);
                                        config.saveInventory(new MIInventory(inventory, armor, effects), "SURVIVAL");
                                        config.saveHealth(health);
                                        config.saveHunger(hunger);
                                        config.saveSaturation(saturation);
                                        int[] levels = plugin.getXP(totalexp);
                                        config.saveExperience(totalexp, levels[0], (float) ((float) levels[1] / (float) levels[2]));
                                    }
                                }
                                PlayerProfile adventureplayerdata = worldprofile.getPlayerData(ProfileTypes.ADVENTURE, player1);
                                if(adventureplayerdata != null && adventureplayerdata.get(Sharables.INVENTORY) != null) {
                                    ItemStack[] inventory = adventureplayerdata.get(Sharables.INVENTORY);
                                    ItemStack[] armor = adventureplayerdata.get(Sharables.ARMOR);
                                    PotionEffect[] potioneffects = adventureplayerdata.get(Sharables.POTIONS);
                                    LinkedList<PotionEffect> effects = new LinkedList<PotionEffect>();
                                    if(potioneffects != null) {
                                        for(int i = 0; i < potioneffects.length; i++) {
                                            effects.add(potioneffects[i]);
                                        }
View Full Code Here

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

Examples of net.citizensnpcs.questers.data.PlayerProfile

                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

Examples of net.citizensnpcs.questers.data.PlayerProfile

    @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

Examples of net.citizensnpcs.questers.data.PlayerProfile

            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

Examples of net.citizensnpcs.questers.data.PlayerProfile

            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

Examples of net.citizensnpcs.questers.data.PlayerProfile

    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

Examples of net.citizensnpcs.questers.data.PlayerProfile

    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

Examples of net.citizensnpcs.questers.data.PlayerProfile

            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
TOP
Copyright © 2018 www.massapi.com. 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.