Search in sources :

Example 1 with DuctFilterCarrier

use of org.cubeengine.module.itemduct.DuctFilterCarrier in project modules-extra by CubeEngine.

the class ItemDuctFilterListener method openFilter.

private void openFilter(Player player, DuctData ductData, Direction dir, Location<World> loc) {
    if (!player.hasPermission(viewFilterPerm.getId())) {
        i18n.send(ChatTypes.ACTION_BAR, player, NEGATIVE, "You are not allowed to edit filters");
        return;
    }
    List<ItemStack> list = ductData.get(dir).get();
    DuctFilterCarrier carrier = new DuctFilterCarrier(ductData, loc, dir);
    boolean canEdit = player.hasPermission(editFilterPerm.getId());
    Inventory inventory = Inventory.builder().property(InventoryTitle.PROPERTY_NAME, InventoryTitle.of(canEdit ? i18n.translate(player, TextFormat.NONE, "ItemDuct Filters") : i18n.translate(player, TextFormat.NONE, "View ItemDuct Filters"))).withCarrier(carrier).build(plugin);
    carrier.init(((CarriedInventory<?>) inventory));
    for (ItemStack itemStack : list) {
        inventory.offer(itemStack);
    }
    Sponge.getCauseStackManager().pushCause(player);
    if (canEdit) {
        player.openInventory(inventory);
    } else {
        igf.prepareInv(inventory, player.getUniqueId()).blockPutInAll().blockTakeOutAll().submitInventory(Itemduct.class, true);
    }
    player.getProgress(module.filters).grant();
}
Also used : DuctFilterCarrier(org.cubeengine.module.itemduct.DuctFilterCarrier) CarriedInventory(org.spongepowered.api.item.inventory.type.CarriedInventory) ItemStack(org.spongepowered.api.item.inventory.ItemStack) Inventory(org.spongepowered.api.item.inventory.Inventory) CarriedInventory(org.spongepowered.api.item.inventory.type.CarriedInventory)

Aggregations

DuctFilterCarrier (org.cubeengine.module.itemduct.DuctFilterCarrier)1 Inventory (org.spongepowered.api.item.inventory.Inventory)1 ItemStack (org.spongepowered.api.item.inventory.ItemStack)1 CarriedInventory (org.spongepowered.api.item.inventory.type.CarriedInventory)1