本文整理汇总了Java中org.bukkit.inventory.InventoryView.countSlots方法的典型用法代码示例。如果您正苦于以下问题:Java InventoryView.countSlots方法的具体用法?Java InventoryView.countSlots怎么用?Java InventoryView.countSlots使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bukkit.inventory.InventoryView
的用法示例。
在下文中一共展示了InventoryView.countSlots方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: buildWindowClickPacket
import org.bukkit.inventory.InventoryView; //导入方法依赖的package包/类
public Object buildWindowClickPacket(Player p, ItemTransaction storage) {
if (!supported) {
return null;
}
InventoryView inv = p.getOpenInventory();
short slotId = storage.getSlotId();
if (slotId > inv.countSlots()) {
return null; // wrong container open?
}
ItemStack itemstack = inv.getItem(slotId);
if (itemstack == null) {
return null;
}
Object packet = null;
try {
packet = windowClickPacketClass.newInstance();
Object nmsItem = nmsItemMethod.invoke(null, itemstack);
ReflectionUtil.set(packet, "a", (int) storage.getWindowId());
ReflectionUtil.set(packet, "slot", (int) slotId);
ReflectionUtil.set(packet, "button", 0); // shift + left mouse click
ReflectionUtil.set(packet, "d", storage.getActionId());
ReflectionUtil.set(packet, "item", nmsItem);
int protocolId = ProtocolRegistry.SERVER_PROTOCOL;
if (protocolId == ProtocolVersion.v1_8.getId()) {
ReflectionUtil.set(packet, "shift", 1);
} else if (protocolId >= ProtocolVersion.v1_9.getId()) { // 1.9+
ReflectionUtil.set(packet, "shift", clickTypeEnum);
}
} catch (Exception e) {
e.printStackTrace();
}
return packet;
}
示例2: getSlotType
import org.bukkit.inventory.InventoryView; //导入方法依赖的package包/类
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;
}
示例3: getSlotType
import org.bukkit.inventory.InventoryView; //导入方法依赖的package包/类
public static SlotType getSlotType(InventoryView inventory, int slot) {
SlotType type = SlotType.CONTAINER;
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;
}