本文整理汇总了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;
}
示例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;
}
}
示例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
}
}
}
示例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;
}
}
}
}
示例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);
}
示例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;
}
示例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);
}
}
}
}
示例8: getType
@Override
public InventoryType getType() {
return InventoryType.CRAFTING;
}
示例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.
}