本文整理汇总了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());
}
}
示例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();
}
}
示例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:
}
}