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


Java InventoryClickEvent.getCursor方法代码示例

本文整理汇总了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);
                }
            }
        }
    }
}
 
开发者ID:GelandiAssociation,项目名称:EscapeLag,代码行数:20,代码来源:AntiLongStringCrash.java

示例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);
	}
}
 
开发者ID:jiongjionger,项目名称:NeverLag,代码行数:16,代码来源:AntiNegativeItemDupe.java

示例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;
	}
}
 
开发者ID:FattyMieo,项目名称:SurvivalPlus,代码行数:70,代码来源:FirestrikerClick.java


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