use of fr.minuskube.inv.content.InventoryContents in project WereWolfPlugin by Ph1Lou.
the class ScenariosGUI method init.
@Override
public void init(Player player, InventoryContents contents) {
Main main = JavaPlugin.getPlugin(Main.class);
WereWolfAPI game = main.getWereWolfAPI();
contents.set(0, 0, ClickableItem.of((new ItemBuilder(UniversalMaterial.COMPASS.getType()).setDisplayName(game.translate("werewolf.menu.return")).build()), e -> Config.INVENTORY.open(player)));
}
use of fr.minuskube.inv.content.InventoryContents in project WereWolfPlugin by Ph1Lou.
the class ScenariosGUI method update.
@Override
public void update(Player player, InventoryContents contents) {
Main main = JavaPlugin.getPlugin(Main.class);
GameManager game = (GameManager) main.getWereWolfAPI();
IConfiguration config = game.getConfig();
Pagination pagination = contents.pagination();
List<ClickableItem> items = new ArrayList<>();
for (ScenarioRegister scenarioRegister : main.getRegisterManager().getScenariosRegister()) {
List<String> lore = new ArrayList<>();
scenarioRegister.getLoreKey().stream().map(game::translate).map(s -> Arrays.stream(s.split("\\n")).collect(Collectors.toList())).forEach(lore::addAll);
ItemStack itemStack;
if (config.isScenarioActive(scenarioRegister.getKey())) {
lore.add(0, game.translate("werewolf.utils.enable"));
itemStack = UniversalMaterial.GREEN_TERRACOTTA.getStack();
} else {
lore.add(0, game.translate("werewolf.utils.disable"));
itemStack = UniversalMaterial.RED_TERRACOTTA.getStack();
}
Optional<String> incompatible = scenarioRegister.getIncompatibleScenarios().stream().filter(s -> game.getConfig().isScenarioActive(s)).map(game::translate).findFirst();
incompatible.ifPresent(scenario -> lore.add(game.translate("werewolf.menu.scenarios.incompatible", Formatter.format("&scenario&", scenario))));
items.add(ClickableItem.of((new ItemBuilder(scenarioRegister.getItem().isPresent() ? scenarioRegister.getItem().get() : itemStack).setDisplayName(game.translate(scenarioRegister.getKey())).setLore(lore).build()), e -> {
if (!incompatible.isPresent() || config.isScenarioActive(scenarioRegister.getKey())) {
config.switchScenarioValue(scenarioRegister.getKey());
scenarioRegister.getScenario().register(config.isScenarioActive(scenarioRegister.getKey()));
}
}));
}
if (items.size() > 45) {
pagination.setItems(items.toArray(new ClickableItem[0]));
pagination.setItemsPerPage(36);
pagination.addToIterator(contents.newIterator(SlotIterator.Type.HORIZONTAL, 1, 0));
int page = pagination.getPage() + 1;
contents.set(5, 0, null);
contents.set(5, 1, null);
contents.set(5, 3, null);
contents.set(5, 5, null);
contents.set(5, 7, null);
contents.set(5, 8, null);
contents.set(5, 2, ClickableItem.of(new ItemBuilder(Material.ARROW).setDisplayName(game.translate("werewolf.menu.roles.previous", Formatter.format("¤t&", page), Formatter.format("&previous&", pagination.isFirst() ? page : page - 1))).build(), e -> INVENTORY.open(player, pagination.previous().getPage())));
contents.set(5, 6, ClickableItem.of(new ItemBuilder(Material.ARROW).setDisplayName(game.translate("werewolf.menu.roles.next", Formatter.format("¤t&", page), Formatter.format("&next&", pagination.isLast() ? page : page + 1))).build(), e -> INVENTORY.open(player, pagination.next().getPage())));
contents.set(5, 4, ClickableItem.empty(new ItemBuilder(UniversalMaterial.SIGN.getType()).setDisplayName(game.translate("werewolf.menu.roles.current", Formatter.format("¤t&", page), Formatter.format("&sum&", items.size() / 36 + 1))).build()));
} else {
int i = 0;
for (ClickableItem clickableItem : items) {
contents.set(i / 9 + 1, i % 9, clickableItem);
i++;
}
for (int k = i; k < (i / 9 + 1) * 9; k++) {
contents.set(k / 9 + 1, k % 9, null);
}
}
}
use of fr.minuskube.inv.content.InventoryContents in project WereWolfPlugin by Ph1Lou.
the class Start method init.
@Override
public void init(Player player, InventoryContents contents) {
GameManager game = (GameManager) JavaPlugin.getPlugin(Main.class).getWereWolfAPI();
contents.fillBorders(ClickableItem.empty(new ItemStack(UniversalMaterial.ORANGE_STAINED_GLASS_PANE.getStack())));
contents.set(0, 0, ClickableItem.of((new ItemBuilder(UniversalMaterial.COMPASS.getType()).setDisplayName(game.translate("werewolf.menu.return")).build()), e -> Config.INVENTORY.open(player)));
}
use of fr.minuskube.inv.content.InventoryContents in project WereWolfPlugin by Ph1Lou.
the class AdvancedConfigRole method update.
@Override
public void update(Player player, InventoryContents contents) {
Main main = JavaPlugin.getPlugin(Main.class);
WereWolfAPI game = main.getWereWolfAPI();
Pagination pagination = contents.pagination();
List<ClickableItem> items = new ArrayList<>();
for (RoleRegister roleRegister : main.getRegisterManager().getRolesRegister()) {
for (Function<WereWolfAPI, ClickableItem> item : roleRegister.getConfig()) {
items.add(item.apply(game));
}
items.addAll(getTimersRole(main, roleRegister));
items.addAll(getConfigsRole(main, roleRegister));
}
if (items.size() > 45) {
pagination.setItems(items.toArray(new ClickableItem[0]));
pagination.setItemsPerPage(36);
pagination.addToIterator(contents.newIterator(SlotIterator.Type.HORIZONTAL, 1, 0));
int page = pagination.getPage() + 1;
contents.set(5, 0, null);
contents.set(5, 1, null);
contents.set(5, 3, null);
contents.set(5, 5, null);
contents.set(5, 7, null);
contents.set(5, 8, null);
contents.set(5, 2, ClickableItem.of(new ItemBuilder(Material.ARROW).setDisplayName(game.translate("werewolf.menu.roles.previous", Formatter.format("¤t&", page), Formatter.format("&previous&", pagination.isFirst() ? page : page - 1))).build(), e -> getInventory().open(player, pagination.previous().getPage())));
contents.set(5, 6, ClickableItem.of(new ItemBuilder(Material.ARROW).setDisplayName(game.translate("werewolf.menu.roles.next", Formatter.format("¤t&", page), Formatter.format("&next&", pagination.isLast() ? page : page + 1))).build(), e -> getInventory().open(player, pagination.next().getPage())));
contents.set(5, 4, ClickableItem.empty(new ItemBuilder(UniversalMaterial.SIGN.getType()).setDisplayName(game.translate("werewolf.menu.roles.current", Formatter.format("¤t&", page), Formatter.format("&sum&", items.size() / 36 + 1))).build()));
} else {
int i = 0;
for (ClickableItem clickableItem : items) {
contents.set(i / 9 + 1, i % 9, clickableItem);
i++;
}
for (int k = i; k < (i / 9 + 1) * 9; k++) {
contents.set(k / 9 + 1, k % 9, null);
}
}
}
use of fr.minuskube.inv.content.InventoryContents in project WereWolfPlugin by Ph1Lou.
the class AdvancedRoleMenu method init.
@Override
public void init(Player player, InventoryContents contents) {
Main main = JavaPlugin.getPlugin(Main.class);
WereWolfAPI game = main.getWereWolfAPI();
contents.set(0, 0, ClickableItem.of(new ItemBuilder(UniversalMaterial.COMPASS.getType()).setDisplayName(game.translate("werewolf.menu.return")).build(), e -> Roles.getInventory(player, Category.WEREWOLF).open(player)));
contents.set(0, 2, ClickableItem.of(new ItemBuilder(UniversalMaterial.CHEST.getType()).setDisplayName(game.translate("werewolf.menu.advanced_tool_role.config", Formatter.role(game.translate(register.getKey())))).build(), event -> manageStuff(player)));
}
Aggregations