本文整理匯總了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();
}