當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。