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


Java PlayerInteractEvent.hasBlock方法代码示例

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

示例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());
        }
    }
}
 
开发者ID:DRE2N,项目名称:FactionsXL,代码行数:26,代码来源:LandProtectionListener.java

示例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.
}
 
开发者ID:Kneesnap,项目名称:Kineticraft,代码行数:13,代码来源:Boost.java

示例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)));
    }
}
 
开发者ID:Kneesnap,项目名称:Kineticraft,代码行数:13,代码来源:Puzzle.java

示例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);
        }
    }
}
 
开发者ID:funkemunky,项目名称:HCFCore,代码行数:9,代码来源:BlockHitFixListener.java


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