Search in sources :

Example 1 with SurvivalSlimefunGuide

use of io.github.thebusybiscuit.slimefun4.implementation.guide.SurvivalSlimefunGuide in project Slimefun4 by Slimefun.

the class SlimefunRegistry method load.

public void load(@Nonnull Slimefun plugin, @Nonnull Config cfg) {
    Validate.notNull(plugin, "The Plugin cannot be null!");
    Validate.notNull(cfg, "The Config cannot be null!");
    soulboundKey = new NamespacedKey(plugin, "soulbound");
    itemChargeKey = new NamespacedKey(plugin, "item_charge");
    guideKey = new NamespacedKey(plugin, "slimefun_guide_mode");
    boolean showVanillaRecipes = cfg.getBoolean("guide.show-vanilla-recipes");
    boolean showHiddenItemGroupsInSearch = cfg.getBoolean("guide.show-hidden-item-groups-in-search");
    guides.put(SlimefunGuideMode.SURVIVAL_MODE, new SurvivalSlimefunGuide(showVanillaRecipes, showHiddenItemGroupsInSearch));
    guides.put(SlimefunGuideMode.CHEAT_MODE, new CheatSheetSlimefunGuide());
    researchRanks.addAll(cfg.getStringList("research-ranks"));
    backwardsCompatibility = cfg.getBoolean("options.backwards-compatibility");
    freeCreativeResearches = cfg.getBoolean("researches.free-in-creative-mode");
    researchFireworks = cfg.getBoolean("researches.enable-fireworks");
    disableLearningAnimation = cfg.getBoolean("researches.disable-learning-animation");
    logDuplicateBlockEntries = cfg.getBoolean("options.log-duplicate-block-entries");
    talismanActionBarMessages = cfg.getBoolean("talismans.use-actionbar");
}
Also used : NamespacedKey(org.bukkit.NamespacedKey) CheatSheetSlimefunGuide(io.github.thebusybiscuit.slimefun4.implementation.guide.CheatSheetSlimefunGuide) SurvivalSlimefunGuide(io.github.thebusybiscuit.slimefun4.implementation.guide.SurvivalSlimefunGuide)

Example 2 with SurvivalSlimefunGuide

use of io.github.thebusybiscuit.slimefun4.implementation.guide.SurvivalSlimefunGuide in project Slimefun4 by Slimefun.

the class NestedItemGroup method openGuide.

@ParametersAreNonnullByDefault
private void openGuide(Player p, PlayerProfile profile, SlimefunGuideMode mode, int page) {
    GuideHistory history = profile.getGuideHistory();
    if (mode == SlimefunGuideMode.SURVIVAL_MODE) {
        history.add(this, page);
    }
    ChestMenu menu = new ChestMenu(Slimefun.getLocalization().getMessage(p, "guide.title.main"));
    SurvivalSlimefunGuide guide = (SurvivalSlimefunGuide) Slimefun.getRegistry().getSlimefunGuide(mode);
    menu.setEmptySlotsClickable(false);
    menu.addMenuOpeningHandler(pl -> pl.playSound(pl.getLocation(), guide.getSound(), 1, 1));
    guide.createHeader(p, profile, menu);
    menu.addItem(1, new CustomItemStack(ChestMenuUtils.getBackButton(p, "", ChatColor.GRAY + Slimefun.getLocalization().getMessage(p, "guide.back.guide"))));
    menu.addMenuClickHandler(1, (pl, s, is, action) -> {
        SlimefunGuide.openMainMenu(profile, mode, history.getMainMenuPage());
        return false;
    });
    int index = 9;
    int target = (GROUP_SIZE * (page - 1)) - 1;
    while (target < (subGroups.size() - 1) && index < GROUP_SIZE + 9) {
        target++;
        SubItemGroup itemGroup = subGroups.get(target);
        menu.addItem(index, itemGroup.getItem(p));
        menu.addMenuClickHandler(index, (pl, slot, item, action) -> {
            SlimefunGuide.openItemGroup(profile, itemGroup, mode, 1);
            return false;
        });
        index++;
    }
    int pages = target == subGroups.size() - 1 ? page : (subGroups.size() - 1) / GROUP_SIZE + 1;
    menu.addItem(46, ChestMenuUtils.getPreviousButton(p, page, pages));
    menu.addMenuClickHandler(46, (pl, slot, item, action) -> {
        int next = page - 1;
        if (next != page && next > 0) {
            openGuide(p, profile, mode, next);
        }
        return false;
    });
    menu.addItem(52, ChestMenuUtils.getNextButton(p, page, pages));
    menu.addMenuClickHandler(52, (pl, slot, item, action) -> {
        int next = page + 1;
        if (next != page && next <= pages) {
            openGuide(p, profile, mode, next);
        }
        return false;
    });
    menu.open(p);
}
Also used : CustomItemStack(io.github.bakedlibs.dough.items.CustomItemStack) SurvivalSlimefunGuide(io.github.thebusybiscuit.slimefun4.implementation.guide.SurvivalSlimefunGuide) GuideHistory(io.github.thebusybiscuit.slimefun4.core.guide.GuideHistory) ChestMenu(me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu) ParametersAreNonnullByDefault(javax.annotation.ParametersAreNonnullByDefault)

Aggregations

SurvivalSlimefunGuide (io.github.thebusybiscuit.slimefun4.implementation.guide.SurvivalSlimefunGuide)2 CustomItemStack (io.github.bakedlibs.dough.items.CustomItemStack)1 GuideHistory (io.github.thebusybiscuit.slimefun4.core.guide.GuideHistory)1 CheatSheetSlimefunGuide (io.github.thebusybiscuit.slimefun4.implementation.guide.CheatSheetSlimefunGuide)1 ParametersAreNonnullByDefault (javax.annotation.ParametersAreNonnullByDefault)1 ChestMenu (me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu)1 NamespacedKey (org.bukkit.NamespacedKey)1