本文整理汇总了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();
}
示例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();
}
示例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);
}
示例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;
}
示例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);
}
示例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)));
}
}
示例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);
}
示例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();
}
示例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);
}
示例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();
}
示例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();
}
示例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();
}
示例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;
}
示例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;
}
示例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();
}
}
}