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