Search in sources :

Example 1 with InventoryContents

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("&current&", 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("&current&", 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("&current&", 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);
        }
    }
}
Also used : UniversalMaterial(fr.ph1lou.werewolfapi.enums.UniversalMaterial) Arrays(java.util.Arrays) SmartInventory(fr.minuskube.inv.SmartInventory) Main(fr.ph1lou.werewolfplugin.Main) WereWolfAPI(fr.ph1lou.werewolfapi.game.WereWolfAPI) Player(org.bukkit.entity.Player) Collectors(java.util.stream.Collectors) GameManager(fr.ph1lou.werewolfplugin.game.GameManager) ItemStack(org.bukkit.inventory.ItemStack) ArrayList(java.util.ArrayList) JavaPlugin(org.bukkit.plugin.java.JavaPlugin) SlotIterator(fr.minuskube.inv.content.SlotIterator) List(java.util.List) InventoryProvider(fr.minuskube.inv.content.InventoryProvider) InventoryContents(fr.minuskube.inv.content.InventoryContents) ItemBuilder(fr.ph1lou.werewolfapi.utils.ItemBuilder) Optional(java.util.Optional) IConfiguration(fr.ph1lou.werewolfapi.game.IConfiguration) Pagination(fr.minuskube.inv.content.Pagination) Formatter(fr.ph1lou.werewolfapi.player.utils.Formatter) ScenarioRegister(fr.ph1lou.werewolfapi.registers.impl.ScenarioRegister) Material(org.bukkit.Material) ClickableItem(fr.minuskube.inv.ClickableItem) GameManager(fr.ph1lou.werewolfplugin.game.GameManager) ClickableItem(fr.minuskube.inv.ClickableItem) ArrayList(java.util.ArrayList) ScenarioRegister(fr.ph1lou.werewolfapi.registers.impl.ScenarioRegister) Pagination(fr.minuskube.inv.content.Pagination) ItemBuilder(fr.ph1lou.werewolfapi.utils.ItemBuilder) IConfiguration(fr.ph1lou.werewolfapi.game.IConfiguration) ItemStack(org.bukkit.inventory.ItemStack) Main(fr.ph1lou.werewolfplugin.Main)

Example 2 with InventoryContents

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)));
}
Also used : UniversalMaterial(fr.ph1lou.werewolfapi.enums.UniversalMaterial) Arrays(java.util.Arrays) SmartInventory(fr.minuskube.inv.SmartInventory) Main(fr.ph1lou.werewolfplugin.Main) WereWolfAPI(fr.ph1lou.werewolfapi.game.WereWolfAPI) Player(org.bukkit.entity.Player) Collectors(java.util.stream.Collectors) GameManager(fr.ph1lou.werewolfplugin.game.GameManager) ItemStack(org.bukkit.inventory.ItemStack) ArrayList(java.util.ArrayList) JavaPlugin(org.bukkit.plugin.java.JavaPlugin) SlotIterator(fr.minuskube.inv.content.SlotIterator) List(java.util.List) InventoryProvider(fr.minuskube.inv.content.InventoryProvider) InventoryContents(fr.minuskube.inv.content.InventoryContents) ItemBuilder(fr.ph1lou.werewolfapi.utils.ItemBuilder) Optional(java.util.Optional) IConfiguration(fr.ph1lou.werewolfapi.game.IConfiguration) Pagination(fr.minuskube.inv.content.Pagination) Formatter(fr.ph1lou.werewolfapi.player.utils.Formatter) ScenarioRegister(fr.ph1lou.werewolfapi.registers.impl.ScenarioRegister) Material(org.bukkit.Material) ClickableItem(fr.minuskube.inv.ClickableItem) ItemBuilder(fr.ph1lou.werewolfapi.utils.ItemBuilder) WereWolfAPI(fr.ph1lou.werewolfapi.game.WereWolfAPI) Main(fr.ph1lou.werewolfplugin.Main)

Example 3 with InventoryContents

use of fr.minuskube.inv.content.InventoryContents in project WereWolfPlugin by Ph1Lou.

the class Stuffs method update.

@Override
public void update(Player player, InventoryContents contents) {
    Main main = JavaPlugin.getPlugin(Main.class);
    WereWolfAPI game = main.getWereWolfAPI();
    UUID uuid = player.getUniqueId();
    contents.set(0, 2, ClickableItem.of((new ItemBuilder(Material.EGG).setDisplayName(game.translate("werewolf.menu.stuff.normal"))).build(), e -> game.getStuffs().loadAllStuffDefault()));
    contents.set(0, 4, ClickableItem.of((new ItemBuilder(UniversalMaterial.GOLDEN_SWORD.getType()).setDisplayName(game.translate("werewolf.menu.stuff.meet_up"))).build(), e -> game.getStuffs().loadAllStuffMeetUP()));
    contents.set(0, 6, ClickableItem.of((new ItemBuilder(Material.JUKEBOX).setDisplayName(game.translate("werewolf.menu.stuff.chill"))).build(), e -> game.getStuffs().loadStuffChill()));
    contents.set(1, 1, ClickableItem.of((new ItemBuilder(Material.BARRIER).setDisplayName(game.translate("werewolf.menu.stuff.delete"))).build(), e -> {
        game.getStuffs().clearStartLoot();
        game.getStuffs().clearDeathLoot();
    }));
    contents.set(1, 4, ClickableItem.of((new ItemBuilder(Material.CHEST).setDisplayName(game.translate("werewolf.menu.stuff.start"))).build(), e -> {
        if (!game.getModerationManager().checkAccessAdminCommand("werewolf.commands.admin.stuff_start.command", player)) {
            return;
        }
        IStuffManager stuffManager = game.getStuffs();
        PlayerInventory inventory = player.getInventory();
        player.setGameMode(GameMode.CREATIVE);
        if (!stuffManager.getTempStuff().containsKey(uuid)) {
            Inventory inventoryTemp = Bukkit.createInventory(player, 45);
            for (int j = 0; j < 40; j++) {
                inventoryTemp.setItem(j, inventory.getItem(j));
            }
            stuffManager.getTempStuff().put(uuid, inventoryTemp);
        }
        for (int j = 0; j < 40; j++) {
            inventory.setItem(j, game.getStuffs().getStartLoot().getItem(j));
        }
        TextComponent msg = new TextComponent(game.translate(Prefix.YELLOW.getKey(), "werewolf.commands.admin.stuff_start.valid"));
        msg.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, String.format("/a %s", game.translate("werewolf.commands.admin.stuff_start.command"))));
        player.spigot().sendMessage(msg);
        player.closeInventory();
    }));
    contents.set(1, 7, ClickableItem.of((new ItemBuilder(Material.ENDER_CHEST).setDisplayName(game.translate("werewolf.menu.stuff.death"))).build(), e -> {
        if (!game.getModerationManager().checkAccessAdminCommand("werewolf.commands.admin.loot_death.command", player)) {
            return;
        }
        IStuffManager stuffManager = game.getStuffs();
        PlayerInventory inventory = player.getInventory();
        player.setGameMode(GameMode.CREATIVE);
        if (!stuffManager.getTempStuff().containsKey(uuid)) {
            Inventory inventoryTemp = Bukkit.createInventory(player, 45);
            for (int j = 0; j < 40; j++) {
                inventoryTemp.setItem(j, inventory.getItem(j));
            }
            stuffManager.getTempStuff().put(uuid, inventoryTemp);
        }
        for (int j = 0; j < 40; j++) {
            inventory.setItem(j, null);
        }
        for (ItemStack i : stuffManager.getDeathLoot()) {
            if (i != null) {
                inventory.addItem(i);
            }
        }
        TextComponent msg = new TextComponent(game.translate(Prefix.YELLOW.getKey(), "werewolf.commands.admin.loot_death.valid"));
        msg.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, String.format("/a %s", game.translate("werewolf.commands.admin.loot_death.command"))));
        player.spigot().sendMessage(msg);
        player.closeInventory();
    }));
}
Also used : UniversalMaterial(fr.ph1lou.werewolfapi.enums.UniversalMaterial) SmartInventory(fr.minuskube.inv.SmartInventory) ClickEvent(net.md_5.bungee.api.chat.ClickEvent) Main(fr.ph1lou.werewolfplugin.Main) WereWolfAPI(fr.ph1lou.werewolfapi.game.WereWolfAPI) IStuffManager(fr.ph1lou.werewolfapi.game.IStuffManager) Player(org.bukkit.entity.Player) UUID(java.util.UUID) Inventory(org.bukkit.inventory.Inventory) ItemStack(org.bukkit.inventory.ItemStack) TextComponent(net.md_5.bungee.api.chat.TextComponent) JavaPlugin(org.bukkit.plugin.java.JavaPlugin) GameMode(org.bukkit.GameMode) InventoryProvider(fr.minuskube.inv.content.InventoryProvider) InventoryContents(fr.minuskube.inv.content.InventoryContents) Prefix(fr.ph1lou.werewolfapi.enums.Prefix) ItemBuilder(fr.ph1lou.werewolfapi.utils.ItemBuilder) PlayerInventory(org.bukkit.inventory.PlayerInventory) Material(org.bukkit.Material) ClickableItem(fr.minuskube.inv.ClickableItem) Bukkit(org.bukkit.Bukkit) TextComponent(net.md_5.bungee.api.chat.TextComponent) ItemBuilder(fr.ph1lou.werewolfapi.utils.ItemBuilder) IStuffManager(fr.ph1lou.werewolfapi.game.IStuffManager) ClickEvent(net.md_5.bungee.api.chat.ClickEvent) PlayerInventory(org.bukkit.inventory.PlayerInventory) WereWolfAPI(fr.ph1lou.werewolfapi.game.WereWolfAPI) UUID(java.util.UUID) ItemStack(org.bukkit.inventory.ItemStack) Main(fr.ph1lou.werewolfplugin.Main) SmartInventory(fr.minuskube.inv.SmartInventory) Inventory(org.bukkit.inventory.Inventory) PlayerInventory(org.bukkit.inventory.PlayerInventory)

Example 4 with InventoryContents

use of fr.minuskube.inv.content.InventoryContents in project WereWolfPlugin by Ph1Lou.

the class TrollChoice method init.

@Override
public void init(Player player, InventoryContents contents) {
    WereWolfAPI game = JavaPlugin.getPlugin(Main.class).getWereWolfAPI();
    contents.set(0, 0, ClickableItem.of((new ItemBuilder(UniversalMaterial.COMPASS.getType()).setDisplayName(game.translate("werewolf.menu.return")).build()), e -> AdvancedConfig.INVENTORY.open(player)));
}
Also used : UniversalMaterial(fr.ph1lou.werewolfapi.enums.UniversalMaterial) SmartInventory(fr.minuskube.inv.SmartInventory) Main(fr.ph1lou.werewolfplugin.Main) WereWolfAPI(fr.ph1lou.werewolfapi.game.WereWolfAPI) HashMap(java.util.HashMap) Player(org.bukkit.entity.Player) UUID(java.util.UUID) Collectors(java.util.stream.Collectors) ArrayList(java.util.ArrayList) JavaPlugin(org.bukkit.plugin.java.JavaPlugin) SlotIterator(fr.minuskube.inv.content.SlotIterator) Category(fr.ph1lou.werewolfapi.enums.Category) List(java.util.List) InventoryProvider(fr.minuskube.inv.content.InventoryProvider) RoleRegister(fr.ph1lou.werewolfapi.registers.impl.RoleRegister) InventoryContents(fr.minuskube.inv.content.InventoryContents) Map(java.util.Map) Camp(fr.ph1lou.werewolfapi.enums.Camp) ItemBuilder(fr.ph1lou.werewolfapi.utils.ItemBuilder) IConfiguration(fr.ph1lou.werewolfapi.game.IConfiguration) Pagination(fr.minuskube.inv.content.Pagination) Formatter(fr.ph1lou.werewolfapi.player.utils.Formatter) Material(org.bukkit.Material) ClickableItem(fr.minuskube.inv.ClickableItem) ItemBuilder(fr.ph1lou.werewolfapi.utils.ItemBuilder) WereWolfAPI(fr.ph1lou.werewolfapi.game.WereWolfAPI) Main(fr.ph1lou.werewolfplugin.Main)

Example 5 with InventoryContents

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)));
}
Also used : UniversalMaterial(fr.ph1lou.werewolfapi.enums.UniversalMaterial) JavaPlugin(org.bukkit.plugin.java.JavaPlugin) InventoryProvider(fr.minuskube.inv.content.InventoryProvider) SmartInventory(fr.minuskube.inv.SmartInventory) InventoryContents(fr.minuskube.inv.content.InventoryContents) StateGame(fr.ph1lou.werewolfapi.enums.StateGame) ItemBuilder(fr.ph1lou.werewolfapi.utils.ItemBuilder) Main(fr.ph1lou.werewolfplugin.Main) Player(org.bukkit.entity.Player) ClickableItem(fr.minuskube.inv.ClickableItem) GameManager(fr.ph1lou.werewolfplugin.game.GameManager) ItemStack(org.bukkit.inventory.ItemStack) ItemBuilder(fr.ph1lou.werewolfapi.utils.ItemBuilder) GameManager(fr.ph1lou.werewolfplugin.game.GameManager) ItemStack(org.bukkit.inventory.ItemStack)

Aggregations

ClickableItem (fr.minuskube.inv.ClickableItem)113 InventoryContents (fr.minuskube.inv.content.InventoryContents)113 Player (org.bukkit.entity.Player)113 InventoryProvider (fr.minuskube.inv.content.InventoryProvider)98 Material (org.bukkit.Material)97 SmartInventory (fr.minuskube.inv.SmartInventory)78 ItemStack (org.bukkit.inventory.ItemStack)72 List (java.util.List)59 MenuUtils (gg.projecteden.nexus.features.menus.MenuUtils)55 ItemBuilder (gg.projecteden.nexus.utils.ItemBuilder)55 ArrayList (java.util.ArrayList)52 UniversalMaterial (fr.ph1lou.werewolfapi.enums.UniversalMaterial)33 ItemBuilder (fr.ph1lou.werewolfapi.utils.ItemBuilder)33 Main (fr.ph1lou.werewolfplugin.Main)33 JavaPlugin (org.bukkit.plugin.java.JavaPlugin)33 WereWolfAPI (fr.ph1lou.werewolfapi.game.WereWolfAPI)30 Pagination (fr.minuskube.inv.content.Pagination)27 Formatter (fr.ph1lou.werewolfapi.player.utils.Formatter)27 Arrays (java.util.Arrays)27 PlayerUtils (gg.projecteden.nexus.utils.PlayerUtils)26