本文整理汇总了Java中org.bukkit.inventory.Inventory.getType方法的典型用法代码示例。如果您正苦于以下问题:Java Inventory.getType方法的具体用法?Java Inventory.getType怎么用?Java Inventory.getType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bukkit.inventory.Inventory
的用法示例。
在下文中一共展示了Inventory.getType方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: CraftContainer
import org.bukkit.inventory.Inventory; //导入方法依赖的package包/类
public CraftContainer(final Inventory inventory, final HumanEntity player, int id) {
this(new InventoryView() {
@Override
public Inventory getTopInventory() {
return inventory;
}
@Override
public Inventory getBottomInventory() {
return player.getInventory();
}
@Override
public HumanEntity getPlayer() {
return player;
}
@Override
public InventoryType getType() {
return inventory.getType();
}
}, id);
}
示例2: rowType
import org.bukkit.inventory.Inventory; //导入方法依赖的package包/类
public static boolean rowType(Integer row, Integer slot, Inventory inventory) {
if (slot != null && row != null) {
Integer mod = 9;
if (inventory != null) {
if (inventory.getType() == InventoryType.DISPENSER ||inventory.getType() == InventoryType.WORKBENCH || inventory.getType() == InventoryType.DROPPER) {
mod = 3;
} else if (inventory.getType() == InventoryType.CHEST || inventory.getType() == InventoryType.ENDER_CHEST || inventory.getType() == InventoryType.PLAYER){
mod = 9;
} else {
mod = inventory.getSize();
}
}
Integer calculate = row * mod;
return slot >= calculate - mod && slot < calculate;
}
return false;
}
示例3: GUIMaker
import org.bukkit.inventory.Inventory; //导入方法依赖的package包/类
public GUIMaker(Inventory inv) {
if (inv.getType() == InventoryType.CHEST) { // 自定义大小的 Inventory
this.inv = Bukkit.createInventory(inv.getHolder(), inv.getSize(), inv.getTitle());
} else { // 自定义类型的 Inventory
this.inv = Bukkit.createInventory(inv.getHolder(), inv.getType(), inv.getTitle());
}
this.inv.setContents(inv.getContents());
}
示例4: onInventoryDrag
import org.bukkit.inventory.Inventory; //导入方法依赖的package包/类
@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
import org.bukkit.inventory.Inventory; //导入方法依赖的package包/类
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: onBreakWorkbench
import org.bukkit.inventory.Inventory; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.HIGHEST)
public void onBreakWorkbench(BlockBreakEvent e)
{
if(e.isCancelled()) return;
Block workbench = e.getBlock();
if (!workbench.hasMetadata("shared_players") || workbench.getType() != Material.WORKBENCH)
return;
@SuppressWarnings("unchecked")
List<UUID> list = (workbench.getMetadata("shared_players").get(0).value() instanceof List<?>) ? (List<UUID>)workbench.getMetadata("shared_players").get(0).value() : new ArrayList<UUID>();
Iterator<UUID> iterator = list.iterator();
Inventory sharedInventory = Bukkit.createInventory(null, InventoryType.WORKBENCH);
while (iterator.hasNext())
{
UUID next = iterator.next();
iterator.remove();
final Player idPlayer = Bukkit.getPlayer(next);
if (idPlayer != null)
{
idPlayer.removeMetadata("shared_inv", Survival.instance);
if(idPlayer.isOnline())
{
final Inventory open = idPlayer.getOpenInventory().getTopInventory();
if (open != null && open.getType() == InventoryType.WORKBENCH)
{
sharedInventory.setContents(open.getContents());
open.clear();
idPlayer.closeInventory();
}
}
}
}
for(int i = 1; i < sharedInventory.getSize(); i++)
{
ItemStack item = sharedInventory.getItem(i);
if(item != null)
workbench.getWorld().dropItem(workbench.getLocation(), item);
}
workbench.removeMetadata("shared_players", Survival.instance);
}
示例7: ensureOurInventory
import org.bukkit.inventory.Inventory; //导入方法依赖的package包/类
private boolean ensureOurInventory(Inventory inventory) {
return inventory.getName().equals(this.inventory.getName()) && inventory.getType() == this.inventory.getType() && inventory.getViewers().equals(this.inventory.getViewers());
}
示例8: isSimilar
import org.bukkit.inventory.Inventory; //导入方法依赖的package包/类
public boolean isSimilar(Inventory inv) {
return inv != null &&
getType() == inv.getType() &&
getTitle().equals(inv.getTitle()) &&
getSize() == inv.getSize();
}