當前位置: 首頁>>代碼示例>>Java>>正文


Java PlayerInteractEvent.getClickedBlock方法代碼示例

本文整理匯總了Java中org.bukkit.event.player.PlayerInteractEvent.getClickedBlock方法的典型用法代碼示例。如果您正苦於以下問題:Java PlayerInteractEvent.getClickedBlock方法的具體用法?Java PlayerInteractEvent.getClickedBlock怎麽用?Java PlayerInteractEvent.getClickedBlock使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.bukkit.event.player.PlayerInteractEvent的用法示例。


在下文中一共展示了PlayerInteractEvent.getClickedBlock方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: onPlayerInteract

import org.bukkit.event.player.PlayerInteractEvent; //導入方法依賴的package包/類
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGH)
public void onPlayerInteract(PlayerInteractEvent event) {
    if (event.getAction() != Action.RIGHT_CLICK_BLOCK)
        return;

    Player player = event.getPlayer();
    if (player.getGameMode() == GameMode.CREATIVE && player.hasPermission(ProtectionListener.PROTECTION_BYPASS_PERMISSION)) {
        return;
    }

    if (plugin.getEotwHandler().isEndOfTheWorld()) {
        return;
    }

    Block block = event.getClickedBlock();
    if (!this.isSubclaimable(block)) {
        return;
    }

    if (!this.checkSubclaimIntegrity(player, block)) {
        event.setCancelled(true);
        player.sendMessage(ChatColor.RED + "You do not have access to this subclaimed " + block.getType().toString() + '.');
    }
}
 
開發者ID:funkemunky,項目名稱:HCFCore,代碼行數:25,代碼來源:SignSubclaimListener.java

示例2: onClick

import org.bukkit.event.player.PlayerInteractEvent; //導入方法依賴的package包/類
@EventHandler
public void onClick(PlayerInteractEvent e) {
	if (e.getClickedBlock() == null)
		return;
	if (e.getClickedBlock().getType() != Material.COAL_BLOCK)
		return;
	KingdomFactionsPlayer player = PlayerModule.getInstance().getPlayer(e.getPlayer());
	if (player.hasAction()) {
		if (player.getAction() instanceof SetCapitalAction) {
			e.setCancelled(true);
			SetCapitalAction action = (SetCapitalAction) player.getAction();
			action.setLocation(e.getClickedBlock().getLocation());
			action.execute();
			player.sendMessage(Messages.getInstance().getPrefix() + "Je hebt de HoofdStad Nexus gezet!");
		}
	}
}
 
開發者ID:ThEWiZ76,項目名稱:KingdomFactions,代碼行數:18,代碼來源:InteractEventListener.java

示例3: run

import org.bukkit.event.player.PlayerInteractEvent; //導入方法依賴的package包/類
@SuppressWarnings("deprecation")
@Override
public void run(PlayerInteractEvent evt) {
    Block target = evt.getClickedBlock();
    if (target == null) return;
    
    Player player = evt.getPlayer();
    if (fillFaceable(target) && !isFacedLog(target)) {
        target.setData(fillData(target));
        AzureAPI.playSound(player, Sound.BLOCK_WOOD_FALL, true);
        
        ItemStack item = evt.getItem();
        if (Item.isTool(item)) {
            item.setDurability((short) (item.getDurability() + 4));
            if (item.getType().getMaxDurability() <= item.getDurability()) {
                player.setItemInHand(null);
                AzureAPI.playSound(player, Sound.ENTITY_ITEM_BREAK, true);
            }
        }
    } else {
        AzureAPI.log(player, isFacedLog(target) ? "這塊木頭已削過皮了" : "這把刀隻能削樹皮用");
    }
}
 
開發者ID:Recraft,項目名稱:Recreator,代碼行數:24,代碼來源:ItemDrawKnife.java

示例4: onSignClick

import org.bukkit.event.player.PlayerInteractEvent; //導入方法依賴的package包/類
@EventHandler
public void onSignClick(PlayerInteractEvent event) {
	if (event.getAction() == Action.LEFT_CLICK_AIR || event.getAction() == Action.RIGHT_CLICK_AIR)
		return;
	
	Block b = event.getClickedBlock();
	if (b.getType() == Material.SIGN_POST || b.getType() == Material.WALL_SIGN) {
		Sign sign = (Sign) b.getState();
		SignClickEvent ev = new SignClickEvent(event.getPlayer(), sign, event.getClickedBlock(), event.getAction() == Action.RIGHT_CLICK_BLOCK);
		Bukkit.getServer().getPluginManager().callEvent(ev);
	}
}
 
開發者ID:thekeenant,項目名稱:mczone,代碼行數:13,代碼來源:GeneralEvents.java

示例5: CheckInterackBed

import org.bukkit.event.player.PlayerInteractEvent; //導入方法依賴的package包/類
@EventHandler
public void CheckInterackBed(PlayerInteractEvent e) {
    if (ConfigPatch.noBedExplore == true) {
        Player p = e.getPlayer();
        Block block = e.getClickedBlock();
        if (e.getAction() == Action.RIGHT_CLICK_BLOCK) {
            if (block.getType() == Material.BED_BLOCK) {
                if (p.getWorld().getEnvironment() == World.Environment.NETHER || p.getWorld().getEnvironment() == World.Environment.THE_END) {
                    e.setCancelled(true);
                    AzureAPI.log(p, ConfigPatch.AntiBedExplodeTipMessage);
                }
            }
        }
    }
}
 
開發者ID:GelandiAssociation,項目名稱:EscapeLag,代碼行數:16,代碼來源:AntiBedExplode.java

示例6: onChestOpen

import org.bukkit.event.player.PlayerInteractEvent; //導入方法依賴的package包/類
/**
 * Open public inventory
 *
 * @param event Interact Event instance
 */
@EventHandler(ignoreCancelled = true)
public void onChestOpen(PlayerInteractEvent event)
{
    if (event.getAction() == Action.RIGHT_CLICK_BLOCK
            && event.getClickedBlock() != null
            && event.getClickedBlock().getType() == Material.ENDER_CHEST
            && event.getClickedBlock().getLocation().getBlockX() == 0
            && event.getClickedBlock().getLocation().getBlockZ() == 0)
    {
        event.setCancelled(true);
        event.getPlayer().openInventory(this.inventory);
    }
}
 
開發者ID:SamaGames,項目名稱:SurvivalAPI,代碼行數:19,代碼來源:RiskyRetrievalModule.java

示例7: anvilStuff

import org.bukkit.event.player.PlayerInteractEvent; //導入方法依賴的package包/類
@SuppressWarnings("deprecation")
@EventHandler
public void anvilStuff(PlayerInteractEvent e){
	if(e.getClickedBlock() == null)return;
	if(e.getClickedBlock().getType().equals(Material.ANVIL)){
		e.setCancelled(true);
		Player p = e.getPlayer();
		String uuid = p.getUniqueId().toString();
		long tokens = getTokens(uuid);
		if(p.getItemInHand().getType() == Material.AIR ||
				p.getItemInHand().getType() == Material.GOLDEN_APPLE ||
				p.getItemInHand().getType() == Material.ARROW ||
				p.getItemInHand().getType() == Material.POTION){
			
			p.sendMessage(tag + ChatColor.RED + "You can\'t repair that!");
		}else{
			if(tokens < 1){
				p.sendMessage(tag + ChatColor.RED + "You need at least 1 token to repair things!!");
			}else{
				if(p.getItemInHand().getDurability() > 0){
					p.getItemInHand().setDurability((short) 0);
					setTokens(uuid, getTokens(uuid)-1);
					p.sendMessage(tag + ChatColor.BLUE + "Your item has been repaired");
				}else{
					p.sendMessage(tag + ChatColor.RED + "This item isn\'t broken");
				}
			}
		}
	}
}
 
開發者ID:OverloadedCore,項目名稱:kaosEssentials,代碼行數:31,代碼來源:Core.java

示例8: onInteract

import org.bukkit.event.player.PlayerInteractEvent; //導入方法依賴的package包/類
@EventHandler
public void onInteract(PlayerInteractEvent e) {
    final TOAUser u = TOA.getPlayer(e.getPlayer());

    if (e.getItem() != null) {
        Material m = e.getItem().getType();
        if (m == Material.WRITTEN_BOOK || m == Material.BOW || m == Material.SHEARS || m == Material.DIAMOND_SWORD) return;
        Ability.useAbility(u, e.getItem().getType());
        e.setCancelled(true);
    }

    if (!u.isOnRank(PACmd.Grupo.Builder)) {
        if (e.getClickedBlock() != null) {
            if (e.getClickedBlock().getType().equals(Material.TRAP_DOOR) || e.getClickedBlock().getType().equals(Material.IRON_TRAPDOOR)
                    || e.getClickedBlock().getType().equals(Material.FENCE_GATE) || e.getClickedBlock().getType().equals(Material.FIRE)
                    || e.getClickedBlock().getType().equals(Material.CAULDRON) || e.getClickedBlock().getRelative(BlockFace.UP).getType().equals(Material.FIRE)
                    || e.getClickedBlock().getType() == Material.CHEST || e.getClickedBlock().getType() == Material.TRAPPED_CHEST
                    || e.getClickedBlock().getType() == Material.DROPPER || e.getClickedBlock().getType() == Material.DISPENSER
                    || e.getClickedBlock().getType() == Material.BED_BLOCK || e.getClickedBlock().getType() == Material.BED
                    || e.getClickedBlock().getType() == Material.WORKBENCH || e.getClickedBlock().getType() == Material.BREWING_STAND
                    || e.getClickedBlock().getType() == Material.ANVIL || e.getClickedBlock().getType() == Material.DARK_OAK_FENCE_GATE
                    || e.getClickedBlock().getType() == Material.SPRUCE_FENCE_GATE || e.getClickedBlock().getType() == Material.FURNACE
                    || e.getClickedBlock().getType() == Material.BURNING_FURNACE || e.getClickedBlock().getType() == Material.HOPPER
                    || e.getClickedBlock().getType() == Material.STONE_BUTTON || e.getClickedBlock().getType() == Material.WOOD_BUTTON) {
                e.setCancelled(true);
            }
        }
    }
}
 
開發者ID:cadox8,項目名稱:PA,代碼行數:30,代碼來源:GameEvents.java

示例9: 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

示例10: onInteractBusy

import org.bukkit.event.player.PlayerInteractEvent; //導入方法依賴的package包/類
@EventHandler
public void onInteractBusy(PlayerInteractEvent event) {
	if (event.getClickedBlock() == null)
		return;
	if (!inUse.contains(event.getClickedBlock().getLocation()))
		return;

	event.setCancelled(true);

	if (event.getHand() == EquipmentSlot.HAND)
		event.getPlayer().sendMessage(ChatColor.RED + "That generator is busy right now!");
}
 
開發者ID:kadeska,項目名稱:MT_Core,代碼行數:13,代碼來源:GeneratorListener.java

示例11: onSignElevator

import org.bukkit.event.player.PlayerInteractEvent; //導入方法依賴的package包/類
@EventHandler
public void onSignElevator(PlayerInteractEvent e) {
    if (e.getClickedBlock() == null) {
        return;
    }
    Block block = e.getClickedBlock();
    BlockState state = block.getState();
    if (state instanceof Sign) {
    	if(e.getAction() == Action.RIGHT_CLICK_BLOCK) {
    		Sign sign = (Sign)state;
            double zdif = Math.abs(e.getPlayer().getLocation().getZ() - block.getLocation().getZ());
            double xdif = Math.abs(e.getPlayer().getLocation().getX() - block.getLocation().getX());
            String lineZero = sign.getLine(0);
            String lineOne = sign.getLine(1);
            if(ChatColor.stripColor(lineZero).equalsIgnoreCase("[Elevator]")) {
                if(zdif < 1.5D && xdif < 1.5D ) {
                	if (ChatColor.stripColor(lineOne).equalsIgnoreCase("Up")) {
                        e.getPlayer().teleport(this.teleportSpotUp(block.getLocation(), block.getLocation().getBlockY(), 254));
                    }
                    if (ChatColor.stripColor(lineOne).equalsIgnoreCase("Down")) {
                        e.getPlayer().teleport(this.teleportSpotDown(block.getLocation(), block.getLocation().getBlockY(), 1));
                    }
                } else {
                	e.getPlayer().sendMessage(ChatColor.RED + "You must be standing next to the sign!");
                }
            }
            e.setCancelled(true);
            return;
    	}
    }
}
 
開發者ID:funkemunky,項目名稱:HCFCore,代碼行數:32,代碼來源:ElevatorListener.java

示例12: protect36

import org.bukkit.event.player.PlayerInteractEvent; //導入方法依賴的package包/類
@EventHandler(ignoreCancelled = true)
public void protect36(final PlayerInteractEvent event) {
    if(event.getClickedBlock() != null) {
        if(event.getClickedBlock().getType() == Material.PISTON_MOVING_PIECE) {
            event.setCancelled(true);
        }
    }
}
 
開發者ID:OvercastNetwork,項目名稱:ProjectAres,代碼行數:9,代碼來源:PGMListener.java

示例13: onPlayerInteract

import org.bukkit.event.player.PlayerInteractEvent; //導入方法依賴的package包/類
@EventHandler
public void onPlayerInteract(PlayerInteractEvent event) {
	if (event.getAction() == Action.LEFT_CLICK_AIR || event.getAction() == Action.RIGHT_CLICK_AIR || event.getAction() == Action.LEFT_CLICK_BLOCK)
		return;
	
	Player p = event.getPlayer();
	Gamer g = Gamer.get(p);
	
	Block b = event.getClickedBlock();
	for (Course c : Course.getList()) {
		Block test1 = c.getButton();
		Block test2 = c.getEnd();

		if (test1 != null && test1.getX() == b.getX() && test1.getY() == b.getY() && test1.getZ() == b.getZ()) {
			g.setVariable("parkour", c);
			p.teleport(c.getStart());
			return;
		}
		
		if (test2 != null && test2.getX() == b.getX() && test2.getY() == b.getY() && test2.getZ() == b.getZ()) {
			Chat.server(Gamer.get(p.getName()).getRank().getPrefix() + p.getDisplayName() + " &ejust beat &2&l" + c.getTitle() + "");
			if (c.getNextCourse() != null) {
				Course next = Course.get(c.getNextCourse());
				if (next != null) {
					g.setVariable("parkour", next);
					p.teleport(next.getStart());
					return;
				}
			}
			p.teleport(c.getStart());
			return;
		}
	}
}
 
開發者ID:thekeenant,項目名稱:mczone,代碼行數:35,代碼來源:Parkour.java

示例14: onPlayerInteract

import org.bukkit.event.player.PlayerInteractEvent; //導入方法依賴的package包/類
public void onPlayerInteract(PlayerInteractEvent e) {
	if (e.isCancelled()) return;
     KingdomFactionsPlayer p = PlayerModule.getInstance().getPlayer(e.getPlayer());        
		if(p.getSettingsProfile().hasAdminMode()) return;
	if (e.getAction().equals(Action.RIGHT_CLICK_BLOCK)) {
		if (e.getClickedBlock() == null) return;

		Block clickedBlock = e.getClickedBlock();
	

		if (clickedBlock.getType().equals(Material.CHEST) || clickedBlock.getType().equals(Material.TRAPPED_CHEST) || clickedBlock.getType().equals(Material.BEACON)) {
			e.setCancelled(!ProtectionModule.getInstance().tryInfluence(p, 500));
			return;
		}

		if (clickedBlock.getType().equals(Material.BURNING_FURNACE) || clickedBlock.getType().equals(Material.FURNACE) || clickedBlock.getType().equals(Material.DISPENSER) || clickedBlock.getType().equals(Material.HOPPER) || clickedBlock.getType().equals(Material.DROPPER)) {
			e.setCancelled(!ProtectionModule.getInstance().tryInfluence(p, 150));
			return;
		}

		MaterialData data = clickedBlock.getState() != null ? clickedBlock.getState().getData() : null;
		if (data instanceof Openable) {
			if (clickedBlock.getType() == Material.IRON_TRAPDOOR || clickedBlock.getType() == Material.IRON_DOOR) return;
			e.setCancelled(!ProtectionModule.getInstance().tryInfluence(p, 150));
			return;
		}
	}
}
 
開發者ID:ThEWiZ76,項目名稱:KingdomFactions,代碼行數:29,代碼來源:PlayerInteractEventListener.java

示例15: soilChangePlayer

import org.bukkit.event.player.PlayerInteractEvent; //導入方法依賴的package包/類
@EventHandler
public void soilChangePlayer(PlayerInteractEvent e) {
      if(e.getClickedBlock() == null) return;
	if ((e.getAction() == Action.PHYSICAL) && (e.getClickedBlock().getType() == Material.SOIL)) {
		KingdomFactionsPlayer p = PlayerModule.getInstance().getPlayer(e.getPlayer());
		if(p.isVanished()) return;
		if(e.isCancelled()) return;
		if(!p.canBuild(e.getClickedBlock().getLocation())) {
			e.setCancelled(!ProtectionModule.getInstance().tryInfluence(p, 50));
		} 

	}
	}
 
開發者ID:ThEWiZ76,項目名稱:KingdomFactions,代碼行數:14,代碼來源:BuildEventListener.java


注:本文中的org.bukkit.event.player.PlayerInteractEvent.getClickedBlock方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。