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


Java PlayerInteractEvent.getMaterial方法代码示例

本文整理汇总了Java中org.bukkit.event.player.PlayerInteractEvent.getMaterial方法的典型用法代码示例。如果您正苦于以下问题:Java PlayerInteractEvent.getMaterial方法的具体用法?Java PlayerInteractEvent.getMaterial怎么用?Java PlayerInteractEvent.getMaterial使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.bukkit.event.player.PlayerInteractEvent的用法示例。


在下文中一共展示了PlayerInteractEvent.getMaterial方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onPlayerInteract

import org.bukkit.event.player.PlayerInteractEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.MONITOR)
public void onPlayerInteract(PlayerInteractEvent event) {
    if (event.getAction() != Action.RIGHT_CLICK_BLOCK || event.useInteractedBlock() == Result.DENY)
        return;

    //For using a hoe for farming
    if (event.getItem() != null &&
            event.getItem().getType() != null &&
            (event.getMaterial() == Material.DIRT || event.getMaterial() == Material.GRASS) &&
            ((event.getItem().getType() == Material.WOOD_HOE) ||
                    (event.getItem().getType() == Material.IRON_HOE) ||
                    (event.getItem().getType() == Material.GOLD_HOE) ||
                    (event.getItem().getType() == Material.DIAMOND_HOE)))
    {
        BlockUpdate.Update(event.getClickedBlock());
    }
}
 
开发者ID:SamaGames,项目名称:AntiCheat,代码行数:18,代码来源:OrebfuscatorPlayerListener.java

示例2: onInteract

import org.bukkit.event.player.PlayerInteractEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.HIGHEST)
public void onInteract(final PlayerInteractEvent event) {
    if(cancelUnlessInteracting(event, event.getPlayer())) {
        // Allow the how-to book to be read
        if(event.getMaterial() == Material.WRITTEN_BOOK) {
            event.setUseItemInHand(Event.Result.ALLOW);
        } else {
            event.setUseItemInHand(Event.Result.DENY);
            event.setUseInteractedBlock(Event.Result.DENY);
        }

        MatchPlayer player = getMatch().getPlayer(event.getPlayer());
        if(player == null) return;

        if(!player.isSpawned()) {
            ClickType clickType = convertClick(event.getAction(), event.getPlayer());
            if(clickType == null) return;

            getMatch().callEvent(new ObserverInteractEvent(player, clickType, event.getClickedBlock(), null, event.getItem()));
        }

        // Right-clicking armor will put it on unless we do this
        event.getPlayer().updateInventory();
    }
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:26,代码来源:EventFilterMatchModule.java

示例3: onInteractBlock

import org.bukkit.event.player.PlayerInteractEvent; //导入方法依赖的package包/类
@EventHandler
public void onInteractBlock(PlayerInteractEvent event)
{
	switch(event.getAction())
	{
		case RIGHT_CLICK_BLOCK:
			switch(event.getMaterial())
			{
				case WOOD_HOE:
				if(Survival.settings.getBoolean("Survival.Enabled"))
				{
					switch(event.getClickedBlock().getType())
					{
						case DIRT:
						case GRASS:
							event.setCancelled(true);
						break;
						
						default:
					}
				}
				break;
				case GOLD_HOE:
					if(Survival.settings.getBoolean("LegendaryItems.GiantBlade"))
					{
						switch(event.getClickedBlock().getType())
						{
							case DIRT:
							case GRASS:
								event.setCancelled(true);
							break;
							
							default:
						}
					}
				break;
				
				case WOOD_SPADE:
					if(Survival.settings.getBoolean("Survival.Enabled"))
					{
						switch(event.getClickedBlock().getType())
						{
							case GRASS:
								event.setCancelled(true);
							break;
							
							default:
						}
					}
				break;
				case GOLD_SPADE:
					if(Survival.settings.getBoolean("LegendaryItems.ObsidianMace"))
					{
						switch(event.getClickedBlock().getType())
						{
							case GRASS:
								event.setCancelled(true);
							break;
							
							default:
						}
					}
				break;
				
				default:
			}
			break;
			
		default:
	}
}
 
开发者ID:FattyMieo,项目名称:SurvivalPlus,代码行数:72,代码来源:SpecialItemInteractCancel.java


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