Search in sources :

Example 1 with ChestMenu

use of me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu in project FluffyMachines by NCBPFluffyBear.

the class AlternateElevatorPlate method openEditor.

@ParametersAreNonnullByDefault
public void openEditor(Player p, Block b) {
    ChestMenu menu = new ChestMenu("Elevator Settings");
    menu.addItem(4, new CustomItemStack(Material.NAME_TAG, "&7Floor Name &e(Click to edit)", "", "&f" + ChatColors.color(BlockStorage.getLocationInfo(b.getLocation(), DATA_KEY))));
    menu.addMenuClickHandler(4, (pl, slot, item, action) -> {
        pl.closeInventory();
        pl.sendMessage("");
        Slimefun.getLocalization().sendMessage(p, "machines.ELEVATOR.enter-name");
        pl.sendMessage("");
        ChatUtils.awaitInput(pl, message -> {
            BlockStorage.addBlockInfo(b, DATA_KEY, message.replace(ChatColor.COLOR_CHAR, '&'));
            pl.sendMessage("");
            Slimefun.getLocalization().sendMessage(p, "machines.ELEVATOR.named", msg -> msg.replace("%floor" + "%", message));
            pl.sendMessage("");
            openEditor(pl, b);
        });
        return false;
    });
    menu.open(p);
}
Also used : CustomItemStack(io.github.thebusybiscuit.slimefun4.libraries.dough.items.CustomItemStack) ChestMenu(me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu) ParametersAreNonnullByDefault(javax.annotation.ParametersAreNonnullByDefault)

Example 2 with ChestMenu

use of me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu in project FluffyMachines by NCBPFluffyBear.

the class AlternateElevatorPlate method openFloorSelector.

@ParametersAreNonnullByDefault
private void openFloorSelector(Block b, List<Block> floors, Player p) {
    ChestMenu elevatorMenu = new ChestMenu("Elevator");
    for (int i = 0; i < floors.size(); i++) {
        if (i > MAX_CHEST_INDEX) {
            break;
        }
        Block destination = floors.get(i);
        String floor = ChatColors.color(BlockStorage.getLocationInfo(destination.getLocation(), DATA_KEY));
        addFloor(elevatorMenu, i, p, floor, b, destination);
    }
    if (floors.size() < MAX_CHEST_INDEX) {
        for (int i = floors.size(); i <= MAX_CHEST_INDEX; i++) {
            elevatorMenu.addItem(i, new CustomItemStack(Material.LIGHT_GRAY_STAINED_GLASS_PANE, ""));
            elevatorMenu.addMenuClickHandler(i, ChestMenuUtils.getEmptyClickHandler());
        }
    }
    elevatorMenu.open(p);
}
Also used : CustomItemStack(io.github.thebusybiscuit.slimefun4.libraries.dough.items.CustomItemStack) Block(org.bukkit.block.Block) ChestMenu(me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu) ParametersAreNonnullByDefault(javax.annotation.ParametersAreNonnullByDefault)

Example 3 with ChestMenu

use of me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu in project Slimefun4 by Slimefun.

the class SurvivalSlimefunGuide method openItemGroup.

@Override
@ParametersAreNonnullByDefault
public void openItemGroup(PlayerProfile profile, ItemGroup itemGroup, int page) {
    Player p = profile.getPlayer();
    if (p == null) {
        return;
    }
    if (itemGroup instanceof FlexItemGroup) {
        ((FlexItemGroup) itemGroup).open(p, profile, getMode());
        return;
    }
    if (isSurvivalMode()) {
        profile.getGuideHistory().add(itemGroup, page);
    }
    ChestMenu menu = create(p);
    createHeader(p, profile, menu);
    addBackButton(menu, 1, p, profile);
    int pages = (itemGroup.getItems().size() - 1) / MAX_ITEM_GROUPS + 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) {
            openItemGroup(profile, itemGroup, 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) {
            openItemGroup(profile, itemGroup, next);
        }
        return false;
    });
    int index = 9;
    int itemGroupIndex = MAX_ITEM_GROUPS * (page - 1);
    for (int i = 0; i < MAX_ITEM_GROUPS; i++) {
        int target = itemGroupIndex + i;
        if (target >= itemGroup.getItems().size()) {
            break;
        }
        SlimefunItem sfitem = itemGroup.getItems().get(target);
        if (!sfitem.isDisabledIn(p.getWorld())) {
            displaySlimefunItem(menu, itemGroup, p, profile, sfitem, page, index);
            index++;
        }
    }
    menu.open(p);
}
Also used : Player(org.bukkit.entity.Player) SlimefunItem(io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem) ChestMenu(me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu) FlexItemGroup(io.github.thebusybiscuit.slimefun4.api.items.groups.FlexItemGroup) ParametersAreNonnullByDefault(javax.annotation.ParametersAreNonnullByDefault)

Example 4 with ChestMenu

use of me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu in project Slimefun4 by Slimefun.

the class SurvivalSlimefunGuide method create.

@Nonnull
private ChestMenu create(@Nonnull Player p) {
    ChestMenu menu = new ChestMenu(Slimefun.getLocalization().getMessage(p, "guide.title.main"));
    menu.setEmptySlotsClickable(false);
    menu.addMenuOpeningHandler(pl -> pl.playSound(pl.getLocation(), sound, 1, 1));
    return menu;
}
Also used : ChestMenu(me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu) Nonnull(javax.annotation.Nonnull)

Example 5 with ChestMenu

use of me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu in project Slimefun4 by Slimefun.

the class SurvivalSlimefunGuide method openMainMenu.

@Override
public void openMainMenu(PlayerProfile profile, int page) {
    Player p = profile.getPlayer();
    if (p == null) {
        return;
    }
    if (isSurvivalMode()) {
        GuideHistory history = profile.getGuideHistory();
        history.clear();
        history.setMainMenuPage(page);
    }
    ChestMenu menu = create(p);
    List<ItemGroup> itemGroups = getVisibleItemGroups(p, profile);
    int index = 9;
    createHeader(p, profile, menu);
    int target = (MAX_ITEM_GROUPS * (page - 1)) - 1;
    while (target < (itemGroups.size() - 1) && index < MAX_ITEM_GROUPS + 9) {
        target++;
        ItemGroup group = itemGroups.get(target);
        showItemGroup(menu, p, profile, group, index);
        index++;
    }
    int pages = target == itemGroups.size() - 1 ? page : (itemGroups.size() - 1) / MAX_ITEM_GROUPS + 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) {
            openMainMenu(profile, 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) {
            openMainMenu(profile, next);
        }
        return false;
    });
    menu.open(p);
}
Also used : Player(org.bukkit.entity.Player) ItemGroup(io.github.thebusybiscuit.slimefun4.api.items.ItemGroup) LockedItemGroup(io.github.thebusybiscuit.slimefun4.api.items.groups.LockedItemGroup) FlexItemGroup(io.github.thebusybiscuit.slimefun4.api.items.groups.FlexItemGroup) SubItemGroup(io.github.thebusybiscuit.slimefun4.api.items.groups.SubItemGroup) GuideHistory(io.github.thebusybiscuit.slimefun4.core.guide.GuideHistory) ChestMenu(me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu)

Aggregations

ChestMenu (me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu)33 CustomItemStack (io.github.bakedlibs.dough.items.CustomItemStack)23 ParametersAreNonnullByDefault (javax.annotation.ParametersAreNonnullByDefault)18 ItemStack (org.bukkit.inventory.ItemStack)17 Player (org.bukkit.entity.Player)11 SlimefunItem (io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem)9 SlimefunItemStack (io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack)7 Slimefun (io.github.thebusybiscuit.slimefun4.implementation.Slimefun)7 AsyncRecipeChoiceTask (io.github.thebusybiscuit.slimefun4.implementation.tasks.AsyncRecipeChoiceTask)7 ChestMenuUtils (io.github.thebusybiscuit.slimefun4.utils.ChestMenuUtils)7 Nonnull (javax.annotation.Nonnull)7 ChatColor (org.bukkit.ChatColor)7 CustomItemStack (io.github.thebusybiscuit.slimefun4.libraries.dough.items.CustomItemStack)6 ArrayList (java.util.ArrayList)6 List (java.util.List)6 ItemGroup (io.github.thebusybiscuit.slimefun4.api.items.ItemGroup)5 FlexItemGroup (io.github.thebusybiscuit.slimefun4.api.items.groups.FlexItemGroup)5 ChatUtils (io.github.thebusybiscuit.slimefun4.utils.ChatUtils)5 Location (org.bukkit.Location)5 Sound (org.bukkit.Sound)5