本文整理汇总了Java中org.bukkit.event.inventory.InventoryClickEvent.getCursor方法的典型用法代码示例。如果您正苦于以下问题:Java InventoryClickEvent.getCursor方法的具体用法?Java InventoryClickEvent.getCursor怎么用?Java InventoryClickEvent.getCursor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bukkit.event.inventory.InventoryClickEvent
的用法示例。
在下文中一共展示了InventoryClickEvent.getCursor方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: ClickCheckItem
import org.bukkit.event.inventory.InventoryClickEvent; //导入方法依赖的package包/类
@EventHandler
public void ClickCheckItem(InventoryClickEvent evt){
if(ConfigPatch.AntiLongStringCrashenable == true){
if(evt.getWhoClicked().getType() != EntityType.PLAYER){
return;
}
Player player = (Player) evt.getWhoClicked();
ItemStack item = evt.getCursor();
if(item != null){
if(item.hasItemMeta() && item.getItemMeta().getDisplayName() != null){
if(item.getItemMeta().getDisplayName().length() >= 127){
evt.setCancelled(true);
evt.setCurrentItem(null);
AzureAPI.log(player, ConfigPatch.AntiLongStringCrashWarnMessage);
}
}
}
}
}
示例2: onClick
import org.bukkit.event.inventory.InventoryClickEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onClick(InventoryClickEvent e) {
if (!cm.isAntiNegativeItemDupe) {
return;
}
ItemStack item = null;
if (e.getCurrentItem() != null && e.getCurrentItem().getType() != Material.AIR) {
item = e.getCurrentItem();
} else if (e.getCursor() != null && e.getCursor().getType() != Material.AIR) {
item = e.getCursor();
}
if (item != null && item.getAmount() <= 0) {
item.setType(Material.AIR);
}
}
示例3: onInventoryClick
import org.bukkit.event.inventory.InventoryClickEvent; //导入方法依赖的package包/类
@SuppressWarnings("deprecation")
@EventHandler
public void onInventoryClick(InventoryClickEvent event)
{
if(event.getInventory().getTitle() != Survival.Words.get("Firestriker"))
return;
final Player player = (Player) event.getWhoClicked();
switch(event.getRawSlot())
{
case 1:
event.setCancelled(true);
player.closeInventory();
break;
case 2:
event.setCancelled(true);
if(event.getClick() == ClickType.LEFT)
{
if(event.getCursor() == null || event.getCursor().getType() == Material.AIR)
{
if(event.getInventory().getItem(2) == null || event.getInventory().getItem(2).getType() == Material.AIR)
{
if(event.getInventory().getItem(1) != null && event.getInventory().getItem(1).getType() == Material.WOOD_SPADE)
{
if(smeltCheck(event.getInventory(), event.getInventory().getItem(0)))
{
event.setCancelled(true);
Random randBurn = new Random();
player.getLocation().getWorld().playSound(player.getLocation(), Sound.ITEM_FLINTANDSTEEL_USE, 1.0F, randBurn.nextFloat() * 0.4F + 0.8F);
player.getLocation().getWorld().playSound(player.getLocation(), Sound.ENTITY_GENERIC_BURN, 1.0F, randBurn.nextFloat() * 0.4F + 0.8F);
ItemStack i_smelt = event.getInventory().getItem(0);
i_smelt.setAmount(i_smelt.getAmount() - 1);
event.getInventory().setItem(0, i_smelt);
ItemStack i_firecracker = event.getInventory().getItem(1);
i_firecracker.setDurability((short)(i_firecracker.getDurability() + 7));
if(i_firecracker.getDurability() >= 56)
{
Random rand = new Random();
player.getLocation().getWorld().playSound(player.getLocation(), Sound.ENTITY_ITEM_BREAK, 1.0F, rand.nextFloat() * 0.4F + 0.8F);
event.getInventory().setItem(1, null);
}
}
}
}
else
{
event.setCursor(event.getInventory().getItem(2));
event.getInventory().setItem(2, null);
}
}
else
event.setCancelled(true);
}
else
event.setCancelled(true);
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(Survival.instance, new Runnable()
{
public void run()
{
player.updateInventory();
}
}, 1L);
break;
}
}