本文整理汇总了Java中org.bukkit.inventory.Inventory.getHolder方法的典型用法代码示例。如果您正苦于以下问题:Java Inventory.getHolder方法的具体用法?Java Inventory.getHolder怎么用?Java Inventory.getHolder使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bukkit.inventory.Inventory
的用法示例。
在下文中一共展示了Inventory.getHolder方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onInventoryClose
import org.bukkit.inventory.Inventory; //导入方法依赖的package包/类
@EventHandler
public void onInventoryClose(InventoryCloseEvent e)
{
if(!(e.getPlayer() instanceof Player))
return;
Inventory inv = e.getInventory();
InventoryHolder holder = inv.getHolder();
if(holder != null && holder instanceof Menu)
{
Menu menu = (Menu) holder;
menu.viewers.remove(e.getPlayer());
if(menu.viewers.size() == 0)
openMenus.remove(menu);
}
}
示例2: onInventoryOpen
import org.bukkit.inventory.Inventory; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.LOW)
public void onInventoryOpen(InventoryOpenEvent event) {
Inventory inventory = event.getInventory();
HumanEntity player = event.getPlayer();
if (!InventoryManager.playerIsLoaded(player)) {
return;
}
if (InventoryAPI.isRPGInventory(inventory)) {
PlayerWrapper playerWrapper = (PlayerWrapper) inventory.getHolder();
InventoryManager.syncQuickSlots(playerWrapper);
InventoryManager.syncInfoSlots(playerWrapper);
InventoryManager.syncShieldSlot(playerWrapper);
InventoryManager.syncArmor(playerWrapper);
}
}
示例3: onBackpackClose
import org.bukkit.inventory.Inventory; //导入方法依赖的package包/类
@EventHandler
public void onBackpackClose(InventoryCloseEvent event) {
Inventory inventory = event.getInventory();
Player player = (Player) event.getPlayer();
if (!InventoryManager.playerIsLoaded(player)
|| !(inventory.getHolder() instanceof BackpackHolder)) {
return;
}
PlayerWrapper playerWrapper = InventoryManager.get(player);
Backpack backpack = playerWrapper.getBackpack();
if (backpack == null) {
return;
}
backpack.onUse();
playerWrapper.setBackpack(null);
}
示例4: onInvClick
import org.bukkit.inventory.Inventory; //导入方法依赖的package包/类
@EventHandler
public void onInvClick(InventoryClickEvent event) {
HumanEntity human = event.getWhoClicked();
if (human instanceof Player) {
Player player = (Player) human;
Inventory inv = event.getView().getTopInventory();
if (inv.getHolder() != null && inv.getHolder() instanceof InventoryMenu && event.getRawSlot() >= 0 && event.getRawSlot() < size) {
event.setCancelled(true);
MenuIcon icon = slots.get(event.getSlot());
if (icon != null) {
icon.onClick(player);
player.closeInventory();
}
}
}
}
示例5: onInventoryOpen
import org.bukkit.inventory.Inventory; //导入方法依赖的package包/类
@EventHandler
public void onInventoryOpen(InventoryOpenEvent e)
{
if(!(e.getPlayer() instanceof Player))
return;
Inventory inv = e.getInventory();
InventoryHolder holder = inv.getHolder();
if(holder != null && holder instanceof Menu)
{
Menu menu = (Menu) holder;
menu.viewers.add((Player) e.getPlayer());
openMenus.add(menu);
}
}
示例6: onInventoryClick
import org.bukkit.inventory.Inventory; //导入方法依赖的package包/类
@EventHandler
public void onInventoryClick(InventoryClickEvent e)
{
if(!(e.getWhoClicked() instanceof Player))
return;
Inventory inv = e.getInventory();
InventoryHolder holder = inv.getHolder();
if(holder != null && holder instanceof Menu)
{
Menu menu = (Menu) holder;
menu.onClick(e);
}
}
示例7: onBackpackClick
import org.bukkit.inventory.Inventory; //导入方法依赖的package包/类
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
public void onBackpackClick(final InventoryClickEvent event) {
final Inventory inventory = event.getInventory();
final Player player = (Player) event.getWhoClicked();
if (!InventoryManager.playerIsLoaded(player)) {
return;
}
if (inventory.getHolder() instanceof BackpackHolder) {
// Click inside backpack
if (BackpackManager.isBackpack(event.getCurrentItem())
|| BackpackManager.isBackpack(event.getCursor())
|| InventoryManager.isFilledSlot(event.getCurrentItem())
|| InventoryManager.isFilledSlot(event.getCursor())) {
event.setCancelled(true);
return;
}
// Save changes
if (event.getAction() == InventoryAction.NOTHING) {
return;
}
BackpackUpdater.update(inventory, InventoryManager.get(player).getBackpack());
} else if ((event.getRawSlot() >= event.getView().getTopInventory().getSize()
|| event.getSlot() == SlotManager.instance().getBackpackSlot().getSlotId()
&& InventoryAPI.isRPGInventory(event.getInventory()))
&& !BackpackManager.playerCanTakeBackpack(player)
&& BackpackManager.isBackpack(event.getCursor())
&& ActionType.getTypeOfAction(event.getAction()) == ActionType.SET) {
// Prevent placing new backpack in bottom inventory if player can't take backpack
int limit = BackpackManager.getLimit();
String message = RPGInventory.getLanguage().getMessage("backpack.limit", limit);
PlayerUtils.sendMessage(player, message);
event.setCancelled(true);
}
}
示例8: refresh
import org.bukkit.inventory.Inventory; //导入方法依赖的package包/类
public void refresh(VPPlayer viewer, Inventory inv){
MenuLink ml = (MenuLink) ((inv.getHolder() instanceof MenuLink) ? inv.getHolder() : null);
for (int i = 1; i < icons.length; i++) {
if (icons[i] != null && !icons[i].isStatic()){
Icon icon = icons[i].getIcon(viewer);
if(icon == null) {
if(type == InventoryType.PLAYER) {
ItemStack[] memory = viewer.getInventory(false);
if(memory[i-1] != null) {
inv.setItem(i-1, memory[i-1]);
memory[i-1] = null;
viewer.setInventory(memory, false);
}
}else
inv.setItem(i-1, new ItemStack(Material.AIR));
continue;
}
if(icon.skullSelf()){
ItemStack item = inv.getItem(i-1);
if(item != null && item.getType() == Material.SKULL_ITEM){
ItemMeta itemMeta = item.getItemMeta();
itemMeta.setLore(icon.getLores(ml == null ? viewer : ml.getView(), viewer.getLanguage()));
itemMeta.setDisplayName(icon.getName(ml == null ? viewer : ml.getView(), viewer.getLanguage()));
((SkullMeta)itemMeta).setOwner(ml == null ? viewer.getName() : ml.getView().getName());
item.setItemMeta(itemMeta);
continue;
}
}
if(icon != null)
inv.setItem(i-1, icon.getItemstack(ml == null ? viewer : ml.getView(), viewer.getLanguage()));
}
}
}
示例9: 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);
}
示例10: disable
import org.bukkit.inventory.Inventory; //导入方法依赖的package包/类
public void disable() {
for (VPPlayer player : VanillaPlusCore.getPlayerManager().getOnlinePlayers()) {
InventoryView view = player.getPlayer().getOpenInventory();
if (view == null) {
return;
}
Inventory topInventory = view.getTopInventory();
if (topInventory.getHolder() instanceof MenuLink) {
player.getPlayer().closeInventory();
}
}
}
示例11: onInvClick
import org.bukkit.inventory.Inventory; //导入方法依赖的package包/类
@EventHandler(ignoreCancelled = true)
public void onInvClick(InventoryClickEvent e){
Inventory inv = e.getClickedInventory();
Player p = (Player) e.getWhoClicked();
if(inv == null) return;
if(e.getCurrentItem() == null) return;
Inventory tagGUI = getTagInventory(p);
if(inv.getHolder() == tagGUI.getHolder()){
if(inv.getTitle().equalsIgnoreCase(tagGUI.getTitle())){
e.setCancelled(true);
if(e.getCurrentItem().isSimilar(getRemoveItem(p))){
p.sendMessage(TagLang.CLEARED.get());
p.closeInventory();
StorageHandler.clearPlayerTag(p);
return;
}
if(e.getSlot() > DogTags.getTags().size()) return;
DogTag dt = DogTags.getTags().get(e.getSlot());
if(!hasPermission(p, dt)){
return;
}
if(e.isLeftClick() || e.isRightClick()) {
DTSelectEvent selectEvent = new DTSelectEvent(p, dt.getId());
Bukkit.getPluginManager().callEvent(selectEvent);
if(selectEvent.isCancelled()) return;
p.sendMessage(TagLang.SET.get().replace("%id%", dt.getId()).replace("%prefix%", dt.getPrefix()));
StorageHandler.setUser(p, dt.getId());
p.closeInventory();
}
}
}
}
示例12: isRPGInventory
import org.bukkit.inventory.Inventory; //导入方法依赖的package包/类
/**
* Checks if opened inventory is RPGInventory
*
* @param inventory - opened inventory
* @return true - if opened RPGInventory, false - otherwise
*/
public static boolean isRPGInventory(Inventory inventory) {
InventoryHolder holder = inventory.getHolder();
return holder != null && holder instanceof PlayerWrapper;
}