當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。