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


Java Action.RIGHT_CLICK_BLOCK屬性代碼示例

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


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

示例1: onPlayerInteract

@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,代碼行數:24,代碼來源:SignSubclaimListener.java

示例2: onPlayerInteract

@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());
    }
}
 
開發者ID:SamaGames,項目名稱:AntiCheat,代碼行數:17,代碼來源:OrebfuscatorPlayerListener.java

示例3: onUseBackpack

@SuppressWarnings("deprecation")
@EventHandler(priority = EventPriority.LOWEST)
public void onUseBackpack(PlayerInteractEvent event) {
    ItemStack item = event.getItem();
    if (!event.hasItem() || !ItemUtils.hasTag(item, ItemUtils.BACKPACK_TAG)) {
        return;
    }

    Player player = event.getPlayer();
    Action action = event.getAction();
    if ((action == Action.RIGHT_CLICK_AIR || action == Action.RIGHT_CLICK_BLOCK)
            && InventoryManager.isQuickSlot(player.getInventory().getHeldItemSlot())) {
        BackpackManager.open(player, item);
    }

    event.setCancelled(true);
    player.updateInventory();
}
 
開發者ID:EndlessCodeGroup,項目名稱:RPGInventory,代碼行數:18,代碼來源:BackpackListener.java

示例4: openVoteMenu

@GameEvent
public void openVoteMenu(@Nonnull PlayerInteractEvent event, User user) {
    if ((event.getAction() == Action.RIGHT_CLICK_AIR || event.getAction() == Action.RIGHT_CLICK_BLOCK) && openMenuItem.equals(event.getItem())) {
        int pos = 0;
        BasicInventory basicInventory = inventoryHandler.createInventory(BasicInventory.class, user, "Vote for a map", availableMaps.size());
        for (int id : availableMaps.keySet()) {
            MapInfo info = availableMaps.get(id);
            ItemStack item = new ItemBuilder(Material.PAPER).amount(id).name(info.getName()).lore(info.getAuthor()).build();
            basicInventory.getBukkitInventory().setItem(pos++, item);
            basicInventory.addClickAction(item, ((itemStack, inventoryClickEvent) -> {
                confirmVote(user, id);
                basicInventory.close();

                // Destroy the inventory, we don't need it anymore
                inventoryHandler.removeInventory(basicInventory.getIdentifier());
            }));
        }
        user.getPlayer().openInventory(basicInventory.getBukkitInventory());
    }
}
 
開發者ID:VoxelGamesLib,項目名稱:VoxelGamesLibv2,代碼行數:20,代碼來源:VoteFeature.java

示例5: onArcherJumpClick

@EventHandler(ignoreCancelled=false, priority=EventPriority.HIGH)
public void onArcherJumpClick(PlayerInteractEvent event)
{
    Action action = event.getAction();
    if (((action == Action.RIGHT_CLICK_AIR) || (action == Action.RIGHT_CLICK_BLOCK)) &&
            (event.hasItem()) && (event.getItem().getType() == Material.FEATHER))
    {
        if (this.plugin.getPvpClassManager().getEquippedClass(event.getPlayer()) != this) {
            return;
        }
        Player player = event.getPlayer();
        UUID uuid = player.getUniqueId();
        long timestamp = this.archerJumpCooldowns.get(uuid);
        long millis = System.currentTimeMillis();
        long remaining = timestamp == this.archerJumpCooldowns.getNoEntryValue() ? -1L : timestamp - millis;
        if (remaining > 0L)
        {
            player.sendMessage(ChatColor.RED + "Cannot use Jump Boost for another " + DurationFormatUtils.formatDurationWords(remaining, true, true) + ".");
        }
        else
        {
            ItemStack stack = player.getItemInHand();
            if (stack.getAmount() == 1) {
                player.setItemInHand(new ItemStack(Material.AIR, 1));
            } else {
                stack.setAmount(stack.getAmount() - 1);
            }
            player.sendMessage(ChatColor.GREEN + "Jump Boost 4 activated for 7 seconds.");

            this.plugin.getEffectRestorer().setRestoreEffect(player, ARCHER_JUMP_EFFECT);
            this.archerJumpCooldowns.put(event.getPlayer().getUniqueId(), System.currentTimeMillis() + ARCHER_JUMP_COOLDOWN_DELAY);
        }
    }
}
 
開發者ID:funkemunky,項目名稱:HCFCore,代碼行數:34,代碼來源:ArcherClass.java

示例6: onCellPhoneInteract

@EventHandler
public void onCellPhoneInteract(PlayerInteractEvent e) {
  Player p = e.getPlayer();
  
  if (p.getInventory().getItemInMainHand().getType() != Material.WATCH)
    return;
  
  e.setCancelled(true);
  
  CellularPhone phone = new CellularPhone(main);
  
  // Left click for recipient toggle
  if (e.getAction() == Action.LEFT_CLICK_AIR || e.getAction() == Action.LEFT_CLICK_BLOCK) {
    if (p.isSneaking()) {
      phone.getNextContact(p);
      
    } else {
      phone.getPreviousContact(p);
      
    }
  }
  
  // Right click for text messages
  if (e.getAction() == Action.RIGHT_CLICK_AIR || e.getAction() == Action.RIGHT_CLICK_BLOCK) {
    if (p.isSneaking()) {
      phone.checkTextMessages(p);
      
    } else {
      phone.deleteTextMessage(p);
      
    }
  }
  
}
 
開發者ID:kadeska,項目名稱:MT_Communication,代碼行數:34,代碼來源:CellularPhoneListener.java

示例7: onPlayerInteract_equipItem

@EventHandler
public void onPlayerInteract_equipItem(final PlayerInteractEvent event) {
    if (event.getAction() == Action.RIGHT_CLICK_AIR || event.getAction() == Action.RIGHT_CLICK_BLOCK) {
        RScheduler.schedule(plugin, new Runnable() {
            public void run() {
                PlayerDataRPG pd = plugin.getPD((Player) (event.getPlayer()));
                if (pd != null)
                    pd.updateEquipmentStats();
            }
        });
    }
}
 
開發者ID:edasaki,項目名稱:ZentrelaRPG,代碼行數:12,代碼來源:CombatManager.java

示例8: onMyPetItemUse

@EventHandler
public void onMyPetItemUse(PlayerInteractEvent event) {
    if (event.getItem() != null) {
        Player player = event.getPlayer();

        if (!InventoryManager.playerIsLoaded(player)) {
            return;
        }

        Inventory inventory = InventoryManager.get(player).getInventory();

        if (isMyPetItem(event.getItem())
                && (event.getAction() == Action.RIGHT_CLICK_BLOCK
                || event.getAction() == Action.RIGHT_CLICK_AIR)) {
            Slot petSlot = getMyPetSlot();

            ItemStack currentPet = inventory.getItem(petSlot.getSlotId());
            boolean hasPet = !petSlot.isCup(currentPet);
            ItemStack newPet = event.getItem();

            if (!hasPet) {
                currentPet = null;
            }

            player.getEquipment().setItemInMainHand(currentPet);
            inventory.setItem(petSlot.getSlotId(), newPet);

            swapMyPets(player, hasPet, newPet);
        }
    }
}
 
開發者ID:EndlessCodeGroup,項目名稱:RPGInventory,代碼行數:31,代碼來源:MyPetManager.java

示例9: onItemUse

@EventHandler(priority = EventPriority.HIGHEST)
public void onItemUse(PlayerInteractEvent event) {
    Player player = event.getPlayer();

    if (!InventoryManager.playerIsLoaded(player) || !event.hasItem()) {
        return;
    }

    if (!ItemManager.allowedForPlayer(player, event.getItem(), true)) {
        event.setCancelled(true);
        PlayerUtils.updateInventory(player);
        return;
    }

    if (CustomItem.isCustomItem(event.getItem())) {
        CustomItem customItem = ItemManager.getCustomItem(event.getItem());

        if (event.getAction() == Action.RIGHT_CLICK_AIR || event.getAction() == Action.RIGHT_CLICK_BLOCK) {
            customItem.onRightClick(player);
        } else {
            customItem.onLeftClick(player);
        }

        if (event.getItem().getType() != Material.BOW) {
            event.setCancelled(true);
        }
    }

    ItemManager.updateStats(player);
}
 
開發者ID:EndlessCodeGroup,項目名稱:RPGInventory,代碼行數:30,代碼來源:ItemListener.java

示例10: onInteract

@EventHandler
public void onInteract(PlayerInteractEvent event) {
	Game game = Chambers.getInstance().getGameManager().getGame();
	if (!game.hasStarted()) {
		return;
	}
	if (event.getAction() != Action.RIGHT_CLICK_BLOCK) {
		return;
	}
	Material material = event.getClickedBlock().getType();
	Location location = event.getClickedBlock().getLocation();
	Profile profile = Chambers.getInstance().getProfileManager().getProfileByUuid(event.getPlayer().getUniqueId());
	if (profile.isBypassMode()) {
		event.setCancelled(false);
		return;
	}
	if (profile.getTeam() == null) {
		event.setCancelled(true);
		return;
	}
	if (material.name().contains("FENCE") || material.name().contains("DOOR") || material.name().contains("CHEST") || material.name().contains("PLATE")) {
		Team team = Chambers.getInstance().getClaimManager().getTeamAt(location);
		if (team.isRaidable()) {
			event.setCancelled(false);
			return;
		}
		if (team != profile.getTeam()) {
			event.setCancelled(true);
			profile.sendMessage(ChatColor.YELLOW + "You cannot do that in the territory of " + team.getFormattedName() + ChatColor.YELLOW + ".");
		}
	}
}
 
開發者ID:HuliPvP,項目名稱:Chambers,代碼行數:32,代碼來源:TeamInteractListener.java

示例11: onClickBed

@EventHandler
public void onClickBed(PlayerInteractEvent event)
{
	if(event.getAction() == Action.RIGHT_CLICK_BLOCK)
	{
		Block clicked = event.getClickedBlock();
		if(clicked.getType() == Material.BED_BLOCK)
		{
               event.setCancelled(true);
               sleepPlayer(event.getPlayer(), clicked.getX(), clicked.getY(), clicked.getZ());
		}
	}
}
 
開發者ID:FattyMieo,項目名稱:SurvivalPlus,代碼行數:13,代碼來源:BedFatigue.java

示例12: onPlayerInteract

@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
public void onPlayerInteract(PlayerInteractEvent event) {
    if (event.getAction() == Action.RIGHT_CLICK_BLOCK) {
        Player player = event.getPlayer();
        BlockState state = event.getClickedBlock().getState();
        if (state instanceof Skull) {
            Skull skull = (Skull) state;
            player.sendMessage(ChatColor.YELLOW + "This is " + ChatColor.WHITE
                    + (skull.getSkullType() == SkullType.PLAYER && skull.hasOwner() ? skull.getOwner() : "a " + WordUtils.capitalizeFully(skull.getSkullType().name()) + " skull") + ChatColor.YELLOW
                    + '.');
        }
    }
}
 
開發者ID:funkemunky,項目名稱:HCFCore,代碼行數:13,代碼來源:SkullListener.java

示例13: onPlayerInteract

@EventHandler
public void onPlayerInteract(PlayerInteractEvent e) {
	if ((e.getAction() == Action.RIGHT_CLICK_AIR || e.getAction() == Action.RIGHT_CLICK_BLOCK) && e.getItem() != null && e.getItem().getType().equals(Material.KNOWLEDGE_BOOK)) {
		//e.getPlayer().sendMessage("HE");
		
		e.getPlayer().openInventory(getKnowledgeMain().inv);
		e.setCancelled(true);
	}
}
 
開發者ID:GigaGamma,項目名稱:SuperiorCraft,代碼行數:9,代碼來源:CustomCrafting.java

示例14: onInteract

@EventHandler
public void onInteract(PlayerInteractEvent e){
    Player p = e.getPlayer();
    Weapon weapon;

    if (e.getItem() == null || e.getHand() != EquipmentSlot.HAND) return;

    if (e.getAction() == Action.RIGHT_CLICK_AIR || e.getAction() == Action.RIGHT_CLICK_BLOCK){
        if (e.getItem().getType() == Material.POTION) return;
        if (e.getItem() == null || Weapon.getWeaponByItemStack(e.getItem()) == null || !Weapon.isWeapon(e.getItem())) return;
        weapon = Weapon.getWeaponByItemStack(e.getItem());

        if (weapon != null) e.setCancelled(true);
        if (weapon == null) return;

        weapon.shoot(p);
        return;
    }

    if (e.getAction() == Action.LEFT_CLICK_AIR || e.getAction() == Action.LEFT_CLICK_BLOCK){
        if (e.getItem() == null || Weapon.getWeaponByItemStack(e.getItem()) == null || !Weapon.isWeapon(e.getItem())) return;
        weapon = Weapon.getWeaponByItemStack(e.getItem());

        if (weapon != null) e.setCancelled(true);
        if (weapon == null) return;

        if (weapon.getId() == 0) return;

        weapon.watch(p);
    }
}
 
開發者ID:cadox8,項目名稱:WC,代碼行數:31,代碼來源:Weapons.java

示例15: handle

@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void handle(PlayerInteractEvent evt) {
    if (evt.getAction() != Action.RIGHT_CLICK_BLOCK) return;
    Block source = evt.getClickedBlock();
    Structure s = match(source);
    if (s == null) return;
    
    if (s instanceof ClickableStructure) {
        ((ClickableStructure) s).run(evt);
    }
}
 
開發者ID:Recraft,項目名稱:Recreator,代碼行數:11,代碼來源:StructureChangeListener.java


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