当前位置: 首页>>代码示例>>Java>>正文


Java InventoryType.CRAFTING属性代码示例

本文整理汇总了Java中org.bukkit.event.inventory.InventoryType.CRAFTING属性的典型用法代码示例。如果您正苦于以下问题:Java InventoryType.CRAFTING属性的具体用法?Java InventoryType.CRAFTING怎么用?Java InventoryType.CRAFTING使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在org.bukkit.event.inventory.InventoryType的用法示例。


在下文中一共展示了InventoryType.CRAFTING属性的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getType

@Override
public InventoryType getType() {
    InventoryType type = viewing.getType();
    if (type == InventoryType.CRAFTING && player.getGameMode() == GameMode.CREATIVE) {
        return InventoryType.CREATIVE;
    }
    return type;
}
 
开发者ID:UraniumMC,项目名称:Uranium,代码行数:8,代码来源:CraftInventoryView.java

示例2: getType

public InventoryType getType() {
    // Thanks to Droppers extending Dispensers, order is important.
    if (inventory instanceof net.minecraft.inventory.InventoryCrafting) {
        return inventory.getSizeInventory() >= 9 ? InventoryType.WORKBENCH : InventoryType.CRAFTING;
    } else if (inventory instanceof net.minecraft.entity.player.InventoryPlayer) {
        return InventoryType.PLAYER;
    } else if (inventory instanceof net.minecraft.tileentity.TileEntityDropper) {
        return InventoryType.DROPPER;
    } else if (inventory instanceof net.minecraft.tileentity.TileEntityDispenser) {
        return InventoryType.DISPENSER;
    } else if (inventory instanceof net.minecraft.tileentity.TileEntityFurnace) {
        return InventoryType.FURNACE;
    } else if (inventory instanceof net.minecraft.inventory.ContainerEnchantTableInventory) {
        return InventoryType.ENCHANTING;
    } else if (inventory instanceof net.minecraft.tileentity.TileEntityBrewingStand) {
        return InventoryType.BREWING;
    } else if (inventory instanceof CraftInventoryCustom.MinecraftInventory) {
        return ((CraftInventoryCustom.MinecraftInventory) inventory).getType();
    } else if (inventory instanceof net.minecraft.inventory.InventoryEnderChest) {
        return InventoryType.ENDER_CHEST;
    } else if (inventory instanceof net.minecraft.inventory.InventoryMerchant) {
        return InventoryType.MERCHANT;
    } else if (inventory instanceof net.minecraft.tileentity.TileEntityBeacon) {
        return InventoryType.BEACON;
    } else if (inventory instanceof net.minecraft.inventory.ContainerRepairInventory) {
        return InventoryType.ANVIL;
    } else if (inventory instanceof net.minecraft.tileentity.IHopper) {
        return InventoryType.HOPPER;
    } else {
        return InventoryType.CHEST;
    }
}
 
开发者ID:UraniumMC,项目名称:Uranium,代码行数:32,代码来源:CraftInventory.java

示例3: cloneCraftingWindow

@EventHandler(priority = EventPriority.MONITOR)
public void cloneCraftingWindow(final PlayerInteractEvent event) {
    if(!AntiGrief.CraftProtect.enabled()) {
        return;
    }

    if(!event.isCancelled() && event.getAction() == Action.RIGHT_CLICK_BLOCK && event.getPlayer().getOpenInventory().getType() == InventoryType.CRAFTING /* nothing open */) {
        Block block = event.getClickedBlock();
        if(block != null && block.getType() == Material.WORKBENCH && !event.getPlayer().isSneaking()) {
            // create the window ourself
            event.setCancelled(true);
            event.getPlayer().openWorkbench(null, true); // doesn't check reachable
        }
    }
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:15,代码来源:CraftingProtect.java

示例4: onInventoryDrag

@EventHandler(ignoreCancelled = true)
public void onInventoryDrag(InventoryDragEvent event) {
    Player player = (Player) event.getWhoClicked();

    if (!InventoryManager.playerIsLoaded(player)) {
        return;
    }

    for (Integer rawSlotId : event.getRawSlots()) {
        ItemStack cursor = event.getOldCursor();
        Inventory inventory = event.getInventory();

        if (PetManager.isPetItem(cursor)) {
            event.setCancelled(true);
            return;
        }

        if (inventory.getType() == InventoryType.CRAFTING) {
            if (InventoryManager.get(player).isOpened()) {
                return;
            }

            // Shield slot is QUICKBAR and has rawId - 45 o.O
            if (rawSlotId >= 1 && rawSlotId <= 8 || rawSlotId == 45) {
                event.setCancelled(true);
                return;
            }
        } else if (InventoryAPI.isRPGInventory(inventory)) {
            if (rawSlotId < 54) {
                event.setCancelled(true);
                return;
            }
        }
    }
}
 
开发者ID:EndlessCodeGroup,项目名称:RPGInventory,代码行数:35,代码来源:InventoryListener.java

示例5: refresh

public void refresh(VPPlayer viewer) {
	if(viewer.getMenu() != null)
		viewer.getMenu().refresh(viewer, viewer.getPlayer().getInventory());
	Inventory inv = viewer.getPlayer().getOpenInventory().getTopInventory();
	if(inv == null || inv.getType() == InventoryType.CRAFTING) {
		return;
	}
	if (inv.getHolder() instanceof MenuLink)
		((MenuLink) inv.getHolder()).getIconMenu().refresh(viewer, inv);
}
 
开发者ID:dracnis,项目名称:VanillaPlus,代码行数:10,代码来源:MenuManager.java

示例6: getSlotType

public static SlotType getSlotType(InventoryView inventory, int slot) {
    SlotType type = SlotType.CONTAINER;
    if (inventory == null) return type; // Cauldron - modded inventories with no Bukkit wrapper
    if (slot >= 0 && slot < inventory.getTopInventory().getSize()) {
        switch(inventory.getType()) {
        case FURNACE:
            if (slot == 2) {
                type = SlotType.RESULT;
            } else if(slot == 1) {
                type = SlotType.FUEL;
            } else {
                type = SlotType.CRAFTING;
            }
            break;
        case BREWING:
            if (slot == 3) {
                type = SlotType.FUEL;
            } else {
                type = SlotType.CRAFTING;
            }
            break;
        case ENCHANTING:
            type = SlotType.CRAFTING;
            break;
        case WORKBENCH:
        case CRAFTING:
            if (slot == 0) {
                type = SlotType.RESULT;
            } else {
                type = SlotType.CRAFTING;
            }
            break;
        case MERCHANT:
            if (slot == 2) {
                type = SlotType.RESULT;
            } else {
                type = SlotType.CRAFTING;
            }
            break;
        case BEACON:
            type = SlotType.CRAFTING;
            break;
        case ANVIL:
            if (slot == 2) {
                type = SlotType.RESULT;
            } else {
                type = SlotType.CRAFTING;
            }
            break;
        default:
            // Nothing to do, it's a CONTAINER slot
        }
    } else {
        if (slot == -999) {
            type = SlotType.OUTSIDE;
        } else if (inventory.getType() == InventoryType.CRAFTING) {
            if (slot < 9) {
            type = SlotType.ARMOR;
            } else if (slot > 35) {
                type = SlotType.QUICKBAR;
            }
        } else if (slot >= (inventory.countSlots() - 9)) {
            type = SlotType.QUICKBAR;
        }
    }
    return type;
}
 
开发者ID:UraniumMC,项目名称:Uranium,代码行数:67,代码来源:CraftInventoryView.java

示例7: updateMonitoredClick

@EventHandler(priority = EventPriority.MONITOR)
public void updateMonitoredClick(final InventoryClickedEvent event) {
    if(event.getWhoClicked() instanceof Player) {
        Player player = (Player) event.getWhoClicked();

        boolean playerInventory = event.getInventory().getType() == InventoryType.CRAFTING; // cb bug fix
        Inventory inventory;

        if(playerInventory) {
            inventory = player.getInventory();
        } else {
            inventory = event.getInventory();
        }

        invLoop: for(Map.Entry<Player, View> entry : new HashSet<>(this.views.entrySet())) { // avoid ConcurrentModificationException
            final Player viewer = entry.getKey();
            View view = entry.getValue();

            // because a player can only be viewing one inventory at a time,
            // this is how we determine if we have a match
            if(inventory.getViewers().isEmpty() ||
               view.watched.getViewers().isEmpty() ||
               inventory.getViewers().size() > view.watched.getViewers().size()) continue invLoop;

            for(int i = 0; i < inventory.getViewers().size(); i++) {
                if(!inventory.getViewers().get(i).equals(view.watched.getViewers().get(i))) {
                    continue invLoop;
                }
            }

            // a watched user is in a chest
            if(view.isPlayerInventory() && !playerInventory) {
                inventory = view.getPlayerInventory().getHolder().getInventory();
                playerInventory = true;
            }

            if(playerInventory) {
                this.previewPlayerInventory(viewer, (PlayerInventory) inventory);
            } else {
                this.previewInventory(viewer, inventory);
            }
        }
    }
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:44,代码来源:ViewInventoryMatchModule.java

示例8: getType

@Override
public InventoryType getType() {
    return InventoryType.CRAFTING;
}
 
开发者ID:lukas81298,项目名称:FlexMC,代码行数:4,代码来源:FlexWorkbenchInventory.java

示例9: hasOpenInventory

/**
 * Returns whether or not the player has an open inventory, excluding their own.
 * @param player
 * @return hasOpen
 */
public static boolean hasOpenInventory(Player player) {
    InventoryType type = player.getOpenInventory().getType();
    return type != InventoryType.CREATIVE && type != InventoryType.CRAFTING; // Crafting = Survival, while Workbench = Crafting Table.
}
 
开发者ID:Kneesnap,项目名称:Kineticraft,代码行数:9,代码来源:Utils.java


注:本文中的org.bukkit.event.inventory.InventoryType.CRAFTING属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。