use of me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu in project Slimefun4 by Slimefun.
the class VanillaAutoCrafter method updateRecipe.
@Override
protected void updateRecipe(@Nonnull Block b, @Nonnull Player p) {
ItemStack item = p.getInventory().getItemInMainHand();
List<Recipe> recipes = getRecipesFor(item);
if (recipes.isEmpty()) {
Slimefun.getLocalization().sendMessage(p, "messages.auto-crafting.no-recipes");
} else {
ChestMenu menu = new ChestMenu(getItemName());
menu.setPlayerInventoryClickable(false);
menu.setEmptySlotsClickable(false);
ChestMenuUtils.drawBackground(menu, background);
ChestMenuUtils.drawBackground(menu, 45, 47, 48, 50, 51, 53);
AsyncRecipeChoiceTask task = new AsyncRecipeChoiceTask();
offerRecipe(p, b, recipes, 0, menu, task);
menu.open(p);
task.start(menu.toInventory());
p.playSound(p.getLocation(), Sound.UI_BUTTON_CLICK, 1, 1);
}
}
use of me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu in project Slimefun4 by Slimefun.
the class PlayerLanguageOption method openLanguageSelection.
private void openLanguageSelection(Player p, ItemStack guide) {
ChestMenu menu = new ChestMenu(Slimefun.getLocalization().getMessage(p, "guide.title.languages"));
menu.setEmptySlotsClickable(false);
menu.addMenuOpeningHandler(pl -> pl.playSound(pl.getLocation(), Sound.BLOCK_NOTE_BLOCK_HARP, 0.7F, 0.7F));
for (int i = 0; i < 9; i++) {
if (i == 1) {
menu.addItem(1, ChestMenuUtils.getBackButton(p, "", "&7" + Slimefun.getLocalization().getMessage(p, "guide.back.settings")), (pl, slot, item, action) -> {
SlimefunGuideSettings.openSettings(pl, guide);
return false;
});
} else if (i == 7) {
menu.addItem(7, new CustomItemStack(SlimefunUtils.getCustomHead(HeadTexture.ADD_NEW_LANGUAGE.getTexture()), Slimefun.getLocalization().getMessage(p, "guide.languages.translations.name"), "", "&7\u21E8 &e" + Slimefun.getLocalization().getMessage(p, "guide.languages.translations.lore")), (pl, slot, item, action) -> {
ChatUtils.sendURL(pl, "https://github.com/Slimefun/Slimefun4/wiki/Translating-Slimefun");
pl.closeInventory();
return false;
});
} else {
menu.addItem(i, ChestMenuUtils.getBackground(), ChestMenuUtils.getEmptyClickHandler());
}
}
Language defaultLanguage = Slimefun.getLocalization().getDefaultLanguage();
String defaultLanguageString = Slimefun.getLocalization().getMessage(p, "languages.default");
menu.addItem(9, new CustomItemStack(defaultLanguage.getItem(), ChatColor.GRAY + defaultLanguageString + ChatColor.DARK_GRAY + " (" + defaultLanguage.getName(p) + ")", "", "&7\u21E8 &e" + Slimefun.getLocalization().getMessage(p, "guide.languages.select-default")), (pl, i, item, action) -> {
Slimefun.instance().getServer().getPluginManager().callEvent(new PlayerLanguageChangeEvent(pl, Slimefun.getLocalization().getLanguage(pl), defaultLanguage));
setSelectedOption(pl, guide, null);
Slimefun.getLocalization().sendMessage(pl, "guide.languages.updated", msg -> msg.replace("%lang%", defaultLanguageString));
SlimefunGuideSettings.openSettings(pl, guide);
return false;
});
int slot = 10;
for (Language language : Slimefun.getLocalization().getLanguages()) {
menu.addItem(slot, new CustomItemStack(language.getItem(), ChatColor.GREEN + language.getName(p), "&b" + language.getTranslationProgress() + '%', "", "&7\u21E8 &e" + Slimefun.getLocalization().getMessage(p, "guide.languages.select")), (pl, i, item, action) -> {
Slimefun.instance().getServer().getPluginManager().callEvent(new PlayerLanguageChangeEvent(pl, Slimefun.getLocalization().getLanguage(pl), language));
setSelectedOption(pl, guide, language.getId());
String name = language.getName(pl);
Slimefun.getLocalization().sendMessage(pl, "guide.languages.updated", msg -> msg.replace("%lang%", name));
SlimefunGuideSettings.openSettings(pl, guide);
return false;
});
slot++;
}
menu.open(p);
}
use of me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu in project Slimefun4 by Slimefun.
the class SlimefunGuideSettings method openSettings.
@ParametersAreNonnullByDefault
public static void openSettings(Player p, ItemStack guide) {
ChestMenu menu = new ChestMenu(Slimefun.getLocalization().getMessage(p, "guide.title.settings"));
menu.setEmptySlotsClickable(false);
menu.addMenuOpeningHandler(pl -> pl.playSound(pl.getLocation(), Sound.BLOCK_NOTE_BLOCK_HARP, 0.7F, 0.7F));
ChestMenuUtils.drawBackground(menu, BACKGROUND_SLOTS);
addHeader(p, menu, guide);
addConfigurableOptions(p, menu, guide);
menu.open(p);
}
use of me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu in project Slimefun4 by Slimefun.
the class ElevatorPlate 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)", "", ChatColor.WHITE + 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 Slimefun4 by Slimefun.
the class ElevatorPlate method openFloorSelector.
@ParametersAreNonnullByDefault
private void openFloorSelector(Block b, List<ElevatorFloor> floors, Player p, int page) {
ChestMenu menu = new ChestMenu(Slimefun.getLocalization().getMessage(p, "machines.ELEVATOR.pick-a-floor"));
menu.setEmptySlotsClickable(false);
int index = GUI_SIZE * (page - 1);
for (int i = 0; i < Math.min(GUI_SIZE, floors.size() - index); i++) {
ElevatorFloor floor = floors.get(index + i);
// @formatter:off
if (floor.getAltitude() == b.getY()) {
menu.addItem(i, new CustomItemStack(Material.COMPASS, ChatColor.GRAY.toString() + floor.getNumber() + ". " + ChatColor.BLACK + floor.getName(), Slimefun.getLocalization().getMessage(p, "machines.ELEVATOR.current-floor") + ' ' + ChatColor.WHITE + floor.getName()), ChestMenuUtils.getEmptyClickHandler());
} else {
menu.addItem(i, new CustomItemStack(Material.PAPER, ChatColor.GRAY.toString() + floor.getNumber() + ". " + ChatColor.BLACK + floor.getName(), Slimefun.getLocalization().getMessage(p, "machines.ELEVATOR.click-to-teleport") + ' ' + ChatColor.WHITE + floor.getName()), (player, slot, itemStack, clickAction) -> {
teleport(player, floor);
return false;
});
}
// @formatter:on
}
int pages = 1 + (floors.size() / GUI_SIZE);
// 0 index so size is the first slot of the last row.
for (int i = GUI_SIZE; i < GUI_SIZE + 9; i++) {
if (i == GUI_SIZE + 2 && pages > 1 && page != 1) {
menu.addItem(i, ChestMenuUtils.getPreviousButton(p, page, pages), (player, i1, itemStack, clickAction) -> {
openFloorSelector(b, floors, p, page - 1);
return false;
});
} else if (i == GUI_SIZE + 6 && pages > 1 && page != pages) {
menu.addItem(i, ChestMenuUtils.getNextButton(p, page, pages), (player, i1, itemStack, clickAction) -> {
openFloorSelector(b, floors, p, page + 1);
return false;
});
} else {
menu.addItem(i, ChestMenuUtils.getBackground(), (player, i1, itemStack, clickAction) -> false);
}
}
menu.open(p);
}
Aggregations