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);
}
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);
}
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);
}
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;
}
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);
}
Aggregations