本文整理汇总了Java中org.bukkit.event.player.PlayerInteractEvent.hasBlock方法的典型用法代码示例。如果您正苦于以下问题:Java PlayerInteractEvent.hasBlock方法的具体用法?Java PlayerInteractEvent.hasBlock怎么用?Java PlayerInteractEvent.hasBlock使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bukkit.event.player.PlayerInteractEvent
的用法示例。
在下文中一共展示了PlayerInteractEvent.hasBlock方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onConsumeCake
import org.bukkit.event.player.PlayerInteractEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.HIGHEST)
public void onConsumeCake(PlayerInteractEvent event)
{
if(event.isCancelled()) return;
Player player = event.getPlayer();
if(event.hasBlock() && event.getAction().equals(Action.RIGHT_CLICK_BLOCK))
{
Block cake = event.getClickedBlock();
if(cake.getType().equals(Material.CAKE_BLOCK))
{
if(player.getFoodLevel() < 20 && (player.getGameMode() == GameMode.SURVIVAL || player.getGameMode() == GameMode.ADVENTURE))
{
addStats(player, carbon, 171);
addStats(player, protein, 114);
addStats(player, salts, 3);
}
}
}
}
示例2: onPlayerInteract
import org.bukkit.event.player.PlayerInteractEvent; //导入方法依赖的package包/类
@EventHandler
public void onPlayerInteract(PlayerInteractEvent event) {
if (event.hasBlock() && NO_INTERACT.contains(event.getClickedBlock().getType())) {
Player breaker = event.getPlayer();
if (breaker == null) {
return;
}
if (FPermission.hasPermission(breaker, FPermission.BUILD)) {
return;
}
Region region = board.getByChunk(event.getClickedBlock().getChunk());
if (region == null || region.isNeutral()) {
return;
}
Faction bFaction = factions.getByMember(breaker);
Faction owner = region.getOwner();
Relation rel = owner.getRelation(bFaction);
if (!rel.canBuild()) {
event.setCancelled(true);
ParsingUtil.sendMessage(breaker, FMessage.PROTECTION_CANNOT_INTERACT_FACTION.getMessage(), event.getClickedBlock().getType().toString(), region.getOwner());
}
}
}
示例3: onInteract
import org.bukkit.event.player.PlayerInteractEvent; //导入方法依赖的package包/类
@EventHandler
public void onInteract(PlayerInteractEvent evt) {
if (evt.getAction() != Action.RIGHT_CLICK_BLOCK && evt.getAction() != Action.RIGHT_CLICK_AIR)
return;
Block bk = evt.getPlayer().getTargetBlock((Set<Material>) null, 25);
Player p = evt.getPlayer();
if (bk != null && !BANNED.contains(bk.getType())) // Boosting others.
bk.getWorld().getNearbyEntities(bk.getLocation(), 2, 2, 2).stream().filter(e -> !e.equals(p)).forEach(e -> boost(p, e));
if (evt.hasBlock() && p.getLocation().distance(evt.getClickedBlock().getLocation()) <= 3 && !BANNED.contains(evt.getClickedBlock().getType()))
boost(p, p); // Boosting themselves.
}
示例4: onPlayerInteract
import org.bukkit.event.player.PlayerInteractEvent; //导入方法依赖的package包/类
@EventHandler
public void onPlayerInteract(PlayerInteractEvent evt) {
if (!shouldHandleEvent(evt.getPlayer()) || !evt.hasBlock())
return;
Block bk = evt.getClickedBlock();
onBlockClick(evt, bk, evt.getAction() == Action.RIGHT_CLICK_BLOCK);
if (getFakeBlocks().containsKey(bk)) { // Make a block's fake material not fail.
evt.setCancelled(true);
Bukkit.getScheduler().runTask(Core.getInstance(), () -> setFakeBlock(bk, getFakeBlocks().get(bk)));
}
}
示例5: onPlayerInteract
import org.bukkit.event.player.PlayerInteractEvent; //导入方法依赖的package包/类
@EventHandler(ignoreCancelled = false, priority = EventPriority.HIGH)
public void onPlayerInteract(PlayerInteractEvent event) {
if (event.hasBlock() && event.getAction() != Action.PHYSICAL) {
if (NON_TRANSPARENT_ATTACK_INTERACT_TYPES.contains(event.getClickedBlock().getType())) {
cancelAttackingMillis(event.getPlayer().getUniqueId(), THRESHOLD);
}
}
}