当前位置: 首页>>代码示例>>Java>>正文


Java InventoryView类代码示例

本文整理汇总了Java中org.bukkit.inventory.InventoryView的典型用法代码示例。如果您正苦于以下问题:Java InventoryView类的具体用法?Java InventoryView怎么用?Java InventoryView使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


InventoryView类属于org.bukkit.inventory包,在下文中一共展示了InventoryView类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: openWorkbench

import org.bukkit.inventory.InventoryView; //导入依赖的package包/类
public InventoryView openWorkbench(Location location, boolean force) {
    if (!force) {
        Block block = location.getBlock();
        if (block.getType() != Material.WORKBENCH) {
            return null;
        }
    }
    if (location == null) {
        location = getLocation();
    }
    getHandle().displayGUIWorkbench(location.getBlockX(), location.getBlockY(), location.getBlockZ());
    if (force) {
        getHandle().openContainer.checkReachable = false;
    }
    return getHandle().openContainer.getBukkitView();
}
 
开发者ID:UraniumMC,项目名称:Uranium,代码行数:17,代码来源:CraftHumanEntity.java

示例2: openEnchanting

import org.bukkit.inventory.InventoryView; //导入依赖的package包/类
public InventoryView openEnchanting(Location location, boolean force) {
    if (!force) {
        Block block = location.getBlock();
        if (block.getType() != Material.ENCHANTMENT_TABLE) {
            return null;
        }
    }
    if (location == null) {
        location = getLocation();
    }
    getHandle().displayGUIEnchantment(location.getBlockX(), location.getBlockY(), location.getBlockZ(), null);
    if (force) {
        getHandle().openContainer.checkReachable = false;
    }
    return getHandle().openContainer.getBukkitView();
}
 
开发者ID:UraniumMC,项目名称:Uranium,代码行数:17,代码来源:CraftHumanEntity.java

示例3: CraftContainer

import org.bukkit.inventory.InventoryView; //导入依赖的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);
}
 
开发者ID:UraniumMC,项目名称:Uranium,代码行数:24,代码来源:CraftContainer.java

示例4: registerWindow

import org.bukkit.inventory.InventoryView; //导入依赖的package包/类
/**
 * Register the given {@link WindowListener} to receive notifications about the given {@link InventoryView}.
 */
public InventoryView registerWindow(WindowListener listener, InventoryView window) {
    final Player player = (Player) window.getPlayer();

    final View old = views.get(player);
    if(old == null || !old.window.equals(window)) {
        if(old != null) {
            old.notifyClose();
        }

        final View view = new View(player, window, listener);
        views.put(player, view);
        view.notifyOpen();
    }

    return window;
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:20,代码来源:WindowManager.java

示例5: afterEquipChange

import org.bukkit.inventory.InventoryView; //导入依赖的package包/类
@EventHandler(priority = EventPriority.MONITOR)
public void afterEquipChange(final InventoryDragEvent event) {
    final Player player = (Player) event.getWhoClicked();

    if (!InventoryManager.playerIsLoaded(player)) {
        return;
    }

    new BukkitRunnable() {
        @Override
        public void run() {
            InventoryView inventoryView = event.getView();
            for (int slot : event.getRawSlots()) {
                ItemStack item = inventoryView.getItem(slot);
                if (CustomItem.isCustomItem(item)) {
                    ItemManager.updateStats((Player) event.getWhoClicked());
                }
            }
        }
    }.runTaskLater(RPGInventory.getInstance(), 1);
}
 
开发者ID:EndlessCodeGroup,项目名称:RPGInventory,代码行数:22,代码来源:ItemListener.java

示例6: run

import org.bukkit.inventory.InventoryView; //导入依赖的package包/类
@Override
public void run() {
    AgarMC plugin = AgarMC.get();
    if (plugin.getGame().getPlayers().isEmpty())
        return ;

    if(plugin.getGame().getVirus().size() < plugin.getGame().getMaxVirus()) {
        VirusCell virus = new VirusCell(Utils.randomLocation(plugin.getGame().getOrigin().getX(), plugin.getGame().getDimensions()), Utils.randomLocation(plugin.getGame().getOrigin().getZ(), plugin.getGame().getDimensions()));
        plugin.getGame().addVirus(virus);
    }

    for (CPlayer player : plugin.getGame().getPlayers())
    {
        player.getPlayer().getInventory().setItem(1, updateColorBlock(player.getPlayer().getInventory().getItem(1)));
        InventoryView iv = player.getPlayer().getOpenInventory();
        if (iv == null)
            continue ;
        Inventory i = iv.getTopInventory();
        if (i == null || !i.getName().equals(MenuGui.INV_NAME))
            continue ;
        i.setItem(0, updateColorBlock(i.getItem(0)));
    }
}
 
开发者ID:SamaGames,项目名称:AgarMC,代码行数:24,代码来源:CellSpawner.java

示例7: onRepair

import org.bukkit.inventory.InventoryView; //导入依赖的package包/类
@EventHandler
public void onRepair(InventoryClickEvent event) {
	if(event.isCancelled() || !(event.getWhoClicked() instanceof Player) || !(event.getInventory() instanceof AnvilInventory))
		return;
	
	InventoryView view = event.getView();
	int rawSlot = event.getRawSlot();
	
	if(rawSlot != view.convertSlot(rawSlot) || rawSlot != 2)
		return;
	
	ItemStack item = event.getInventory().getItem(0);
	if(!plugin.getAbilityManager().hasAbility(item) || !plugin.getAbilityManager().isTemporaryItem(item))
		return;
	
	Ability ability = plugin.getAbilityManager().getAbility(item);
	event.getInventory().setItem(0, plugin.getAbilityManager().removeItemLore(item, ability));
	event.setCancelled(true);
}
 
开发者ID:benNek,项目名称:AsgardAscension,代码行数:20,代码来源:AbilityListener.java

示例8: InventoryDragEvent

import org.bukkit.inventory.InventoryView; //导入依赖的package包/类
public InventoryDragEvent(InventoryView what, ItemStack newCursor, ItemStack oldCursor, boolean right, Map<Integer, ItemStack> slots) {
    super(what);

    Validate.notNull(oldCursor);
    Validate.notNull(slots);

    type = right ? DragType.SINGLE : DragType.EVEN;
    this.newCursor = newCursor;
    this.oldCursor = oldCursor;
    this.addedItems = slots;
    ImmutableSet.Builder<Integer> b = ImmutableSet.builder();
    for (Integer slot : slots.keySet()) {
        b.add(what.convertSlot(slot));
    }
    this.containerSlots = b.build();
}
 
开发者ID:CyberdyneCC,项目名称:Thermos-Bukkit,代码行数:17,代码来源:InventoryDragEvent.java

示例9: showPerkMenu

import org.bukkit.inventory.InventoryView; //导入依赖的package包/类
public static InventoryView showPerkMenu(BPPlayer bpPlayer)
{
	Player player = bpPlayer.getPlayer();
	List<Perk> perks = bpPlayer.getPerks();
	
	if(perks.size() <= 0)
	{
		player.sendMessage(MessageType.MENU_PERKS_EMPTY.getTranslation().getValue());
		return null;
	}
	
	int rows = bpPlayer.getPerkInventoryRows();
	Inventory inv = Bukkit.getServer().createInventory(player, 9 * rows, MENU_TITLE);
	
	equipMenu(bpPlayer, inv);
	player.closeInventory();
	
	return player.openInventory(inv);
}
 
开发者ID:Limeth,项目名称:Breakpoint,代码行数:20,代码来源:Perk.java

示例10: openWorkbench

import org.bukkit.inventory.InventoryView; //导入依赖的package包/类
public InventoryView openWorkbench(Location location, boolean force) {
    if (!force) {
        Block block = location.getBlock();
        if (block.getType() != Material.WORKBENCH) {
            return null;
        }
    }
    if (location == null) {
        location = getLocation();
    }
    getHandle().openTileEntity(new BlockWorkbench.TileEntityContainerWorkbench(getHandle().world, new BlockPosition(location.getBlockX(), location.getBlockY(), location.getBlockZ())));
    if (force) {
        getHandle().activeContainer.checkReachable = false;
    }
    return getHandle().activeContainer.getBukkitView();
}
 
开发者ID:tgnmc,项目名称:Craftbukkit,代码行数:17,代码来源:CraftHumanEntity.java

示例11: openWorkbench

import org.bukkit.inventory.InventoryView; //导入依赖的package包/类
public InventoryView openWorkbench(Location location, boolean force) {
    if (!force) {
        Block block = location.getBlock();
        if (block.getType() != Material.WORKBENCH) {
            return null;
        }
    }
    if (location == null) {
        location = getLocation();
    }
    getHandle().startCrafting(location.getBlockX(), location.getBlockY(), location.getBlockZ());
    if (force) {
        getHandle().activeContainer.checkReachable = false;
    }
    return getHandle().activeContainer.getBukkitView();
}
 
开发者ID:OvercastNetwork,项目名称:CraftBukkit,代码行数:17,代码来源:CraftHumanEntity.java

示例12: openEnchanting

import org.bukkit.inventory.InventoryView; //导入依赖的package包/类
public InventoryView openEnchanting(Location location, boolean force) {
    if (!force) {
        Block block = location.getBlock();
        if (block.getType() != Material.ENCHANTMENT_TABLE) {
            return null;
        }
    }
    if (location == null) {
        location = getLocation();
    }
    getHandle().startEnchanting(location.getBlockX(), location.getBlockY(), location.getBlockZ(), null);
    if (force) {
        getHandle().activeContainer.checkReachable = false;
    }
    return getHandle().activeContainer.getBukkitView();
}
 
开发者ID:OvercastNetwork,项目名称:CraftBukkit,代码行数:17,代码来源:CraftHumanEntity.java

示例13: isOpenFor

import org.bukkit.inventory.InventoryView; //导入依赖的package包/类
@Override
public boolean isOpenFor(Player p)
{
    InventoryView iview = p.getOpenInventory();
    if(null == iview)
        return false;
    Inventory inv = iview.getTopInventory();
    if(null == inv)
        return false;
    InventoryHolder holder = inv.getHolder();
    if(!(holder instanceof BusyHolder))
        return false;
    IBusyMenu menu = ((BusyHolder)holder).getMenu();
    if(!menu.equals(this))
        return false;
    return true;
}
 
开发者ID:Cnly,项目名称:BusyInv,代码行数:18,代码来源:BusyMenu.java

示例14: reloadFor

import org.bukkit.inventory.InventoryView; //导入依赖的package包/类
/**
 * If a BusyMenu is opened for the target player, this method will reload
 * the menu for the player.
 * 
 * @see {@link IBusyMenu#reload}
 * 
 * @param p
 *            Target player
 * @return true if and only if the menu is reloaded. Otherwise false(for
 *         example the player didn't open an inventory or the inventory
 *         isn't a menu)
 */
public static boolean reloadFor(Player p)
{
    InventoryView iview = p.getOpenInventory();
    if(null == iview)
        return false;
    Inventory inv = iview.getTopInventory();
    if(null == inv)
        return false;
    InventoryHolder holder = inv.getHolder();
    if(!(holder instanceof BusyHolder))
        return false;
    ((BusyHolder)holder).getMenu().updateFor(p);
    p.updateInventory();
    return true;
}
 
开发者ID:Cnly,项目名称:BusyInv,代码行数:28,代码来源:BusyMenu.java

示例15: clearInventory

import org.bukkit.inventory.InventoryView; //导入依赖的package包/类
public void clearInventory(Player p) {
	PlayerInventory inv = p.getInventory();
	inv.clear();
	inv.setHelmet(null);
	inv.setChestplate(null);
	inv.setLeggings(null);
	inv.setBoots(null);
	InventoryView view = p.getOpenInventory();
	if (view != null) {
		view.setCursor(null);
		Inventory i = view.getTopInventory();
		if (i != null) {
			i.clear();
		}
	}
}
 
开发者ID:Hansdekip,项目名称:BlockParty-1.8,代码行数:17,代码来源:InventoryManager.java


注:本文中的org.bukkit.inventory.InventoryView类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。