Search in sources :

Example 91 with PlayerData

use of com.archyx.aureliumskills.data.PlayerData in project AureliumSkills by Archy-X.

the class LevelProgressionMenu method init.

@Override
public void init(Player player, InventoryContents contents) {
    int currentLevel = playerData.getSkillLevel(skill);
    // Fill item
    if (options.isFillEnabled()) {
        contents.fill(ClickableItem.empty(options.getFillItem()));
    }
    SkillItem skillItem = (SkillItem) options.getItem(ItemType.SKILL);
    contents.set(skillItem.getPos(), ClickableItem.empty(skillItem.getItem(skill, playerData, player, locale)));
    BackItem backItem = (BackItem) options.getItem(ItemType.BACK);
    contents.set(backItem.getPos(), ClickableItem.of(backItem.getItem(player, locale), e -> SkillsMenu.getInventory(player, plugin).open(player)));
    CloseItem closeItem = (CloseItem) options.getItem(ItemType.CLOSE);
    contents.set(closeItem.getPos(), ClickableItem.of(closeItem.getItem(player, locale), e -> player.closeInventory()));
    RankItem rankItem = (RankItem) options.getItem(ItemType.RANK);
    contents.set(rankItem.getPos(), ClickableItem.empty(rankItem.getItem(skill, player, locale)));
    Pagination pagination = contents.pagination();
    ClickableItem[] items = new ClickableItem[36 * pages];
    if (options.isFillEnabled() && options.getFillItem() != null) {
        for (int i = 0; i < items.length; i++) {
            items[i] = ClickableItem.empty(options.getFillItem());
        }
    }
    UnlockedTemplate unlocked = (UnlockedTemplate) options.getTemplate(TemplateType.UNLOCKED);
    InProgressTemplate inProgress = (InProgressTemplate) options.getTemplate(TemplateType.IN_PROGRESS);
    LockedTemplate locked = (LockedTemplate) options.getTemplate(TemplateType.LOCKED);
    for (int i = pagination.getPage() * 24; i < pagination.getPage() * 24 + 24; i++) {
        if (i + 2 <= OptionL.getMaxLevel(skill)) {
            if (i + 2 <= currentLevel) {
                items[track.get(i)] = ClickableItem.empty(unlocked.getItem(skill, i + 2, player, locale));
            } else if (i + 2 == currentLevel + 1) {
                items[track.get(i)] = ClickableItem.empty(inProgress.getItem(skill, playerData, i + 2, player, locale));
            } else {
                items[track.get(i)] = ClickableItem.empty(locked.getItem(skill, i + 2, player, locale));
            }
        } else {
            if (options.isFillEnabled() && options.getFillItem() != null) {
                items[track.get(i)] = ClickableItem.empty(options.getFillItem());
            } else {
                items[track.get(i)] = ClickableItem.empty(new ItemStack(Material.AIR));
            }
        }
    }
    pagination.setItems(items);
    pagination.setItemsPerPage(36);
    int a = 0;
    for (int i = 9; i < 45; i++) {
        int row = i / 9;
        int column = i % 9;
        contents.set(row, column, pagination.getPageItems()[a]);
        a++;
    }
    NextPageItem nextPageItem = (NextPageItem) options.getItem(ItemType.NEXT_PAGE);
    if (pagination.getPage() + 1 < pages) {
        contents.set(nextPageItem.getPos(), ClickableItem.of(nextPageItem.getItem(player, locale), e -> {
            int page = pagination.next().getPage();
            SmartInventory inventory = getInventory(player, skill, page, plugin);
            if (inventory != null) {
                inventory.open(player, page);
            }
        }));
    }
    PreviousPageItem previousPageItem = (PreviousPageItem) options.getItem(ItemType.PREVIOUS_PAGE);
    if (pagination.getPage() - 1 >= 0) {
        contents.set(previousPageItem.getPos(), ClickableItem.of(previousPageItem.getItem(player, locale), e -> {
            int previous = pagination.previous().getPage();
            SmartInventory inventory = getInventory(player, skill, previous, plugin);
            if (inventory != null) {
                inventory.open(player, previous);
            }
        }));
    }
}
Also used : TemplateType(com.archyx.aureliumskills.menu.templates.TemplateType) MenuMessage(com.archyx.aureliumskills.lang.MenuMessage) SmartInventory(fr.minuskube.inv.SmartInventory) InProgressTemplate(com.archyx.aureliumskills.menu.templates.InProgressTemplate) OptionL(com.archyx.aureliumskills.configuration.OptionL) com.archyx.aureliumskills.menu.items(com.archyx.aureliumskills.menu.items) UnlockedTemplate(com.archyx.aureliumskills.menu.templates.UnlockedTemplate) Player(org.bukkit.entity.Player) ItemStack(org.bukkit.inventory.ItemStack) ArrayList(java.util.ArrayList) Nullable(org.jetbrains.annotations.Nullable) List(java.util.List) LockedTemplate(com.archyx.aureliumskills.menu.templates.LockedTemplate) AureliumSkills(com.archyx.aureliumskills.AureliumSkills) Lang(com.archyx.aureliumskills.lang.Lang) InventoryProvider(fr.minuskube.inv.content.InventoryProvider) InventoryContents(fr.minuskube.inv.content.InventoryContents) Locale(java.util.Locale) PlayerData(com.archyx.aureliumskills.data.PlayerData) Skill(com.archyx.aureliumskills.skills.Skill) Pagination(fr.minuskube.inv.content.Pagination) Material(org.bukkit.Material) ClickableItem(fr.minuskube.inv.ClickableItem) InProgressTemplate(com.archyx.aureliumskills.menu.templates.InProgressTemplate) ClickableItem(fr.minuskube.inv.ClickableItem) Pagination(fr.minuskube.inv.content.Pagination) SmartInventory(fr.minuskube.inv.SmartInventory) UnlockedTemplate(com.archyx.aureliumskills.menu.templates.UnlockedTemplate) ItemStack(org.bukkit.inventory.ItemStack) LockedTemplate(com.archyx.aureliumskills.menu.templates.LockedTemplate)

Example 92 with PlayerData

use of com.archyx.aureliumskills.data.PlayerData in project AureliumSkills by Archy-X.

the class LootHandler method getXp.

private double getXp(Player player, double input) {
    PlayerData playerData = plugin.getPlayerManager().getPlayerData(player);
    if (playerData != null) {
        double output = input;
        if (ability != null) {
            if (plugin.getAbilityManager().isEnabled(ability)) {
                double modifier = 1;
                modifier += plugin.getAbilityManager().getValue(ability, playerData.getAbilityLevel(ability)) / 100;
                output *= modifier;
            }
        }
        return output;
    }
    return 0.0;
}
Also used : PlayerData(com.archyx.aureliumskills.data.PlayerData)

Example 93 with PlayerData

use of com.archyx.aureliumskills.data.PlayerData in project AureliumSkills by Archy-X.

the class SkillsMenu method getInventory.

@Nullable
public static SmartInventory getInventory(Player player, AureliumSkills plugin) {
    PlayerData playerData = plugin.getPlayerManager().getPlayerData(player);
    if (playerData == null) {
        return null;
    }
    Locale locale = playerData.getLocale();
    MenuOption menuOption = plugin.getMenuLoader().getMenu(MenuType.SKILLS);
    return SmartInventory.builder().provider(new SkillsMenu(playerData, locale, menuOption, plugin)).size(menuOption.getRows(), 9).title(Lang.getMessage(MenuMessage.SKILLS_MENU_TITLE, locale)).manager(plugin.getInventoryManager()).build();
}
Also used : Locale(java.util.Locale) PlayerData(com.archyx.aureliumskills.data.PlayerData) Nullable(org.jetbrains.annotations.Nullable)

Example 94 with PlayerData

use of com.archyx.aureliumskills.data.PlayerData in project AureliumSkills by Archy-X.

the class StatsMenu method init.

@Override
public void init(Player player, InventoryContents contents) {
    PlayerData playerData = plugin.getPlayerManager().getPlayerData(player);
    if (playerData != null) {
        // Fill item
        if (options.isFillEnabled()) {
            contents.fill(ClickableItem.empty(options.getFillItem()));
        }
        SkullItem skullItem = (SkullItem) options.getItem(ItemType.SKULL);
        contents.set(skullItem.getPos(), ClickableItem.empty(skullItem.getItem(player, playerData, locale)));
        StatTemplate statTemplate = (StatTemplate) options.getTemplate(TemplateType.STAT);
        contents.set(statTemplate.getPos(Stats.STRENGTH), ClickableItem.empty(statTemplate.getItem(Stats.STRENGTH, playerData, player, locale)));
        contents.set(statTemplate.getPos(Stats.HEALTH), ClickableItem.empty(statTemplate.getItem(Stats.HEALTH, playerData, player, locale)));
        contents.set(statTemplate.getPos(Stats.REGENERATION), ClickableItem.empty(statTemplate.getItem(Stats.REGENERATION, playerData, player, locale)));
        contents.set(statTemplate.getPos(Stats.LUCK), ClickableItem.empty(statTemplate.getItem(Stats.LUCK, playerData, player, locale)));
        contents.set(statTemplate.getPos(Stats.WISDOM), ClickableItem.empty(statTemplate.getItem(Stats.WISDOM, playerData, player, locale)));
        contents.set(statTemplate.getPos(Stats.TOUGHNESS), ClickableItem.empty(statTemplate.getItem(Stats.TOUGHNESS, playerData, player, locale)));
    }
}
Also used : SkullItem(com.archyx.aureliumskills.menu.items.SkullItem) StatTemplate(com.archyx.aureliumskills.menu.templates.StatTemplate) PlayerData(com.archyx.aureliumskills.data.PlayerData)

Example 95 with PlayerData

use of com.archyx.aureliumskills.data.PlayerData in project AureliumSkills by Archy-X.

the class ChargedShot method onToggle.

@EventHandler
public void onToggle(PlayerInteractEvent event) {
    if (blockDisabled(MAbility.CHARGED_SHOT))
        return;
    Player player = event.getPlayer();
    if (blockAbility(player))
        return;
    ItemStack item = event.getItem();
    if (item == null)
        return;
    if (item.getType() != Material.BOW)
        return;
    if (event.getAction() == Action.LEFT_CLICK_BLOCK || event.getAction() == Action.LEFT_CLICK_AIR) {
        PlayerData playerData = plugin.getPlayerManager().getPlayerData(player);
        if (playerData == null)
            return;
        if (playerData.getManaAbilityLevel(MAbility.CHARGED_SHOT) == 0)
            return;
        Locale locale = playerData.getLocale();
        AbilityData abilityData = playerData.getAbilityData(MAbility.CHARGED_SHOT);
        if (abilityData.getInt("cooldown") == 0) {
            if (!abilityData.getBoolean("enabled")) {
                // Toggle on
                abilityData.setData("enabled", true);
                plugin.getAbilityManager().sendMessage(player, Lang.getMessage(ManaAbilityMessage.CHARGED_SHOT_ENABLE, locale));
            } else {
                // Toggle off
                abilityData.setData("enabled", false);
                plugin.getAbilityManager().sendMessage(player, Lang.getMessage(ManaAbilityMessage.CHARGED_SHOT_DISABLE, locale));
            }
            abilityData.setData("cooldown", 8);
        }
    }
}
Also used : Locale(java.util.Locale) Player(org.bukkit.entity.Player) ItemStack(org.bukkit.inventory.ItemStack) PlayerData(com.archyx.aureliumskills.data.PlayerData) AbilityData(com.archyx.aureliumskills.data.AbilityData) EventHandler(org.bukkit.event.EventHandler)

Aggregations

PlayerData (com.archyx.aureliumskills.data.PlayerData)111 Player (org.bukkit.entity.Player)54 EventHandler (org.bukkit.event.EventHandler)43 Locale (java.util.Locale)27 ItemStack (org.bukkit.inventory.ItemStack)25 Skill (com.archyx.aureliumskills.skills.Skill)15 BukkitRunnable (org.bukkit.scheduler.BukkitRunnable)10 Stat (com.archyx.aureliumskills.stats.Stat)9 AttributeInstance (org.bukkit.attribute.AttributeInstance)8 PlayerLootDropEvent (com.archyx.aureliumskills.api.event.PlayerLootDropEvent)7 StatModifier (com.archyx.aureliumskills.modifier.StatModifier)7 Material (org.bukkit.Material)7 LivingEntity (org.bukkit.entity.LivingEntity)7 KeyIntPair (com.archyx.aureliumskills.util.misc.KeyIntPair)6 AureliumSkills (com.archyx.aureliumskills.AureliumSkills)5 OptionL (com.archyx.aureliumskills.configuration.OptionL)5 AbilityData (com.archyx.aureliumskills.data.AbilityData)5 File (java.io.File)5 IOException (java.io.IOException)5 PlayerDataLoadEvent (com.archyx.aureliumskills.data.PlayerDataLoadEvent)4