本文整理汇总了Java中org.bukkit.inventory.InventoryView.convertSlot方法的典型用法代码示例。如果您正苦于以下问题:Java InventoryView.convertSlot方法的具体用法?Java InventoryView.convertSlot怎么用?Java InventoryView.convertSlot使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bukkit.inventory.InventoryView
的用法示例。
在下文中一共展示了InventoryView.convertSlot方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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);
}
示例2: fromViewIndex
import org.bukkit.inventory.InventoryView; //导入方法依赖的package包/类
public static InventorySlot<?> fromViewIndex(InventoryView view, int rawIndex) {
final Slot slot = Slot.forViewIndex(view, rawIndex);
if(slot == null) {
throw new IllegalArgumentException("Could not determine slot at index " + rawIndex + " in view " + view);
}
final Inventory inventory = rawIndex == view.convertSlot(rawIndex) ? view.getTopInventory()
: view.getBottomInventory();
return new InventorySlot<>(inventory, slot);
}
示例3: InventoryClickEvent
import org.bukkit.inventory.InventoryView; //导入方法依赖的package包/类
public InventoryClickEvent(InventoryView view, SlotType type, int slot, ClickType click, InventoryAction action) {
super(view);
this.slot_type = type;
this.rawSlot = slot;
this.whichSlot = view.convertSlot(slot);
this.click = click;
this.action = action;
}
示例4: forViewIndex
import org.bukkit.inventory.InventoryView; //导入方法依赖的package包/类
public static @Nullable Slot<?, ?> forViewIndex(InventoryView view, int rawIndex) {
final int cookedIndex = view.convertSlot(rawIndex);
return forInventoryIndex((rawIndex == cookedIndex ? view.getTopInventory()
: view.getBottomInventory()).getClass(),
cookedIndex);
}
示例5: onInventoryClick
import org.bukkit.inventory.InventoryView; //导入方法依赖的package包/类
@EventHandler
public void onInventoryClick(InventoryClickEvent e)
{
Inventory inv = e.getInventory();
if(inv instanceof AnvilInventory)
{
AnvilInventory anvil = (AnvilInventory)inv;
InventoryView view = e.getView();
int rawSlot = e.getRawSlot();
// compare raw slot to the inventory view to make sure we are in the upper inventory
if(rawSlot == view.convertSlot(rawSlot))
{
// 2 = result slot
if(rawSlot == 2)
{
// item in the left slot
ItemStack item = anvil.getContents()[0];
if(item != null)
{
if
(
item.getType() == Material.GOLD_AXE
|| item.getType() == Material.GOLD_PICKAXE
|| item.getType() == Material.GOLD_SPADE
|| item.getType() == Material.GOLD_HOE
|| item.getType() == Material.GOLD_SWORD
|| item.getType() == Material.WOOD_AXE
|| item.getType() == Material.WOOD_PICKAXE
|| item.getType() == Material.WOOD_SPADE
|| item.getType() == Material.WOOD_HOE
|| item.getType() == Material.WOOD_SWORD
)
{
e.setCancelled(true);
e.getWhoClicked().closeInventory();
e.getWhoClicked().sendMessage(ChatColor.RED + Survival.Words.get("You cannot rename or repair ") + item.getItemMeta().getDisplayName() + ChatColor.RED + Survival.Words.get("period"));
}
}
}
}
}
}