Java 类org.bukkit.event.block.Action 实例源码

项目:NeverLag    文件:AntiUseEggsChangeSpawnerType.java   
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onPlayerInteract(PlayerInteractEvent e) {
    if (!cm.isDisableChangeSpawnerType) {
        return;
    }
    if (e.getAction() == Action.RIGHT_CLICK_BLOCK) {
        if (e.getClickedBlock().getType() == Material.MOB_SPAWNER) {
            if (e.getItem() == null) {
                return;
            }
            if (e.getPlayer().isOp()) {
                return;
            }
            if (e.getItem().getType() == Material.MONSTER_EGG || e.getItem().getType() == Material.MONSTER_EGGS) {
                e.setCancelled(true);
            }
        }
    }
}
项目:MT_Communication    文件:WalkieTalkieListener.java   
@EventHandler
public void onWalkieTalkieInteract(PlayerInteractEvent e) {
    if (e.getPlayer().getInventory().getItemInMainHand().getType() != Material.REDSTONE_COMPARATOR)
        return;
    if (e.getHand() == EquipmentSlot.OFF_HAND)
        return;

    WalkieTalkie wt = new WalkieTalkie(main,
            main.getPlayerManager().getPlayer(e.getPlayer()).getCurrentWalkieTalkieFrequency());

    // Left click to tune frequency.
    if (e.getAction() == Action.LEFT_CLICK_AIR || e.getAction() == Action.LEFT_CLICK_BLOCK) {
        if (e.getPlayer().isSneaking()) {
            wt.decreaseFrequency(e.getPlayer());
        } else {
            wt.increaseFrequency(e.getPlayer());
        }
    }

}
项目:CloudNet    文件:SignSelector.java   
@EventHandler
public void handleInteract(PlayerInteractEvent e)
{
    if (e.getAction().equals(Action.RIGHT_CLICK_BLOCK) && (e.getClickedBlock().getType().equals(Material.SIGN_POST) || e.getClickedBlock().getType().equals(Material.WALL_SIGN)))
    {
        if (containsPosition(e.getClickedBlock().getLocation()))
        {
            Sign sign = getSignByPosition(e.getClickedBlock().getLocation());
            if (sign.getServerInfo() != null)
            {
                String s = sign.getServerInfo().getServiceId().getServerId();
                ByteArrayDataOutput output = ByteStreams.newDataOutput();
                output.writeUTF("Connect");
                output.writeUTF(s);
                e.getPlayer().sendPluginMessage(CloudServer.getInstance().getPlugin(), "BungeeCord", output.toByteArray());
            }
        }
    }
}
项目:bankomat    文件:BankMenuListener.java   
@EventHandler
public void onPlayerInteract(PlayerInteractEvent e) {   
    if (e.getAction() == Action.RIGHT_CLICK_BLOCK) { // This check needs to be there, 'cause RightClickAction has only the getType function, LeftClickAction doesnt and boooom!!
        Player player = (Player) e.getPlayer();
        ItemStack item = e.getItem();
        Block block = e.getClickedBlock();
        String bankId = BukkitUtils.getNBTTag(item, "bankid");

        if (item == null || block == null) return;

        if (bankId != null && bankId.length() > 0 && item.getType() == Material.PAPER && block.getType() == Material.ENDER_STONE) {
            // got a foreign card?
            if (!bankId.equals(player.getUniqueId().toString())) {
                player.getInventory().remove(item);
                BankomatCommand.appendCreditCardToUser(player); 
            } 

            player.openInventory(bankUi); // Dispatch our event by opening bankUi here:
        }   
    }
}
项目:ZentrelaRPG    文件:ItemManager.java   
@EventHandler
public void onPlayerInteract(PlayerInteractEvent event) {
    Player p = event.getPlayer();
    ItemStack item = event.getPlayer().getEquipment().getItemInMainHand();
    if (event.getHand() == EquipmentSlot.HAND && item != null && item.hasItemMeta() && item.getItemMeta().hasDisplayName() && (event.getAction() == Action.RIGHT_CLICK_AIR || event.getAction() == Action.RIGHT_CLICK_BLOCK)) {
        String name = item.getItemMeta().getDisplayName();
        if (itemNameToIdentifierMap.containsKey(name)) {
            String identifier = itemNameToIdentifierMap.get(name);
            if (itemIdentifierToRunnableMap.containsKey(identifier)) {
                PlayerDataRPG pd = plugin.getPD(p);
                if (pd != null)
                    itemIdentifierToRunnableMap.get(identifier).run(event, p, pd);
                event.setCancelled(true);
            }
        }
    }
}
项目:ZentrelaRPG    文件:EtcItem.java   
public static void healWithPotion(int amount, String name, Event event, Player p) {
    if (!(event instanceof PlayerInteractEvent))
        return;
    PlayerInteractEvent e = (PlayerInteractEvent) event;
    if (!(e.getAction() == Action.RIGHT_CLICK_AIR || e.getAction() == Action.RIGHT_CLICK_BLOCK))
        return;
    if (lastHealItem.containsKey(p.getName()) && System.currentTimeMillis() - lastHealItem.get(p.getName()) < 500) {
        return;
    }
    lastHealItem.put(p.getName(), System.currentTimeMillis());
    p.getEquipment().setItemInMainHand(new ItemStack(Material.AIR));
    PlayerDataRPG pd = plugin.getPD(p);
    pd.heal(amount, HealType.POTION);
    for (int k = 0; k < p.getInventory().getContents().length; k++) {
        if (ItemManager.isItem(p.getInventory().getItem(k), name)) {
            p.getEquipment().setItemInMainHand(p.getInventory().getItem(k));
            p.getInventory().setItem(k, new ItemStack(Material.AIR));
            break;
        }
    }
    RSound.playSound(p, Sound.ENTITY_GENERIC_DRINK);
}
项目:bskyblock    文件:IslandGuard.java   
/**
 * Prevents usage of an Ender Chest
 *
 * @param event
 */

@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onEnderChestEvent(PlayerInteractEvent event) {
    if (DEBUG) {
        plugin.getLogger().info("Ender chest " + event.getEventName());
    }
    Player player = (Player) event.getPlayer();
    if (Util.inWorld(player) || player.getWorld().equals(IslandWorld.getNetherWorld())) {
        if (event.getAction() == Action.RIGHT_CLICK_BLOCK) {
            if (event.getClickedBlock().getType() == Material.ENDER_CHEST) {
                if (!(event.getPlayer().hasPermission(Settings.PERMPREFIX + "craft.enderchest"))) {
                    Util.sendMessage(player, plugin.getLocale(player.getUniqueId()).get("general.errors.no-permission"));
                    event.setCancelled(true);
                }
            }
        }
    }
}
项目:HCFCore    文件:SignSubclaimListener.java   
@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() + '.');
    }
}
项目:HCFCore    文件:PearlGlitchListener.java   
@EventHandler(ignoreCancelled = true, priority = EventPriority.NORMAL)
public void onPlayerInteract(PlayerInteractEvent event) {
    if (event.getAction() == Action.RIGHT_CLICK_BLOCK && event.hasItem() && event.getItem().getType() == Material.ENDER_PEARL) {
        Block block = event.getClickedBlock();
        // Don't prevent opening chests, etc, as these won't throw the Enderpearls anyway
        if (block.getType().isSolid() && !(block.getState() instanceof InventoryHolder)) {
            Faction factionAt = HCF.getPlugin().getFactionManager().getFactionAt(block.getLocation());
            if (!(factionAt instanceof ClaimableFaction)) {
                return;
            }

            event.setCancelled(true);
            Player player = event.getPlayer();
            player.setItemInHand(event.getItem()); // required to update Enderpearl count
        }
    }
}
项目:VoxelGamesLibv2    文件:VoteFeature.java   
@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());
    }
}
项目:chaoticWeapons    文件:Core.java   
@SuppressWarnings("deprecation")
@EventHandler
public void grenadeEvent(PlayerInteractEvent e){
    final Player p = e.getPlayer();
    if(e.getAction().equals(Action.RIGHT_CLICK_AIR) || e.getAction().equals(Action.RIGHT_CLICK_BLOCK)){
        if(p.getItemInHand().hasItemMeta()){
            if(p.getItemInHand().getItemMeta().getLore() == null) return;
            if(p.getItemInHand().getItemMeta().getLore().contains(ChatColor.GRAY + "Grenade I")){
                p.getItemInHand().setDurability((short) (p.getItemInHand().getDurability() - 4));
                final Item grenade = p.getWorld().dropItem(p.getEyeLocation(), new ItemStack(Material.CLAY_BALL));
                grenade.setVelocity(p.getEyeLocation().getDirection().normalize().multiply(0.8D));
                Bukkit.getScheduler().scheduleSyncDelayedTask(this, new Runnable(){
                    public void run(){
                        p.getWorld().createExplosion(grenade.getLocation().getX(), grenade.getLocation().getY(), 
                                grenade.getLocation().getZ(), 3, false, false);
                        grenade.remove();
                    }
                },30L);
            }
        }
    }
}
项目:ProjectAres    文件:GunGizmo.java   
@EventHandler
public void playerInteract(final PlayerInteractEvent event) {
    if(event.getAction() == Action.PHYSICAL
            || !(Gizmos.gizmoMap.get(event.getPlayer()) instanceof GunGizmo)
            || event.getItem() == null || event.getItem().getType() != this.getIcon()) return;

    final Player player = event.getPlayer();
    RaindropUtil.giveRaindrops(Users.playerId(player), -1, new RaindropResult() {
        @Override
        public void run() {
            if(success) {
                Vector velocity = player.getLocation().getDirection().multiply(1.75D);

                Item item = player.getWorld().dropItem(event.getPlayer().getEyeLocation(), new ItemStack(Material.GHAST_TEAR));
                item.setVelocity(velocity);
                item.setTicksLived((5 * 60 * 20) - (5 * 20)); // 5 minutes - 5 seconds
                items.put(item, player.getUniqueId());
            } else {
                player.sendMessage(ChatColor.RED + LobbyTranslations.get().t("gizmo.gun.empty", player));
                player.playSound(player.getLocation(), Sound.UI_BUTTON_CLICK, 1f, 1f);
            }
        }
    }, null, false, true, false);
}
项目:RPGInventory    文件:ArmorEquipListener.java   
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
public void onQuickEquip(PlayerInteractEvent event) {
    final Player player = event.getPlayer();
    if (!InventoryManager.playerIsLoaded(player) || event.getAction() != Action.RIGHT_CLICK_AIR &&
            event.getAction() != Action.RIGHT_CLICK_BLOCK || event.getAction() == Action.RIGHT_CLICK_BLOCK &&
            !event.getClickedBlock().getState().getClass().getSimpleName().contains("BlockState")) {
        return;
    }

    ItemStack item = event.getItem();
    if (ItemUtils.isEmpty(item)) {
        return;
    }

    ArmorType armorType = ArmorType.matchType(item);
    if (InventoryUtils.playerNeedArmor(player, armorType)) {
        Slot armorSlot = SlotManager.instance().getSlot(armorType.name());
        if (armorSlot == null) {
            return;
        }

        event.setCancelled(!InventoryManager.validateArmor(player, InventoryAction.PLACE_ONE, armorSlot, item));

        PlayerUtils.updateInventory(player);
    }
}
项目:KingdomFactions    文件:EmpireWandInteractEventListener.java   
@SuppressWarnings("deprecation")
@EventHandler
public void onClick(PlayerInteractEvent e) {
    if(e.getAction() == Action.PHYSICAL) return;
    KingdomFactionsPlayer p = PlayerModule.getInstance().getPlayer(e.getPlayer());
    if(p.getPlayer().getInventory() == null) return;
    if(p.getPlayer().getItemInHand() == null) return;
    if(p.getPlayer().getItemInHand().getType() != Material.BLAZE_ROD) return;
    if(!p.getPlayer().getItemInHand().hasItemMeta()) return;
    if(!p.getPlayer().getItemInHand().getItemMeta().getDisplayName().equals(ChatColor.RED + "Empire Wand")) return;
    e.setCancelled(true);
    if(e.getAction() == Action.LEFT_CLICK_AIR || e.getAction() == Action.LEFT_CLICK_BLOCK) { 
        if(p.hasCooldown(CooldownType.WAND)) {
            p.sendMessage(ChatColor.GOLD + "[" + ChatColor.GRAY + "X" + ChatColor.GOLD + "] "
                    + "Je moet nog " + ChatColor.GRAY + p.getCooldown(CooldownType.WAND).getCooldown() + " seconde(n)" + ChatColor.GOLD + " wachten!");
            return;
        }
            if(p.getSpell() == null) {
            p.setSpell(SpellModule.getInstance().getSpell("Spark"));
        }
       p.getSpell().execute(p);
       p.addCooldown(new Cooldown(CooldownType.WAND, p, 60));
    } else if(e.getAction() == Action.RIGHT_CLICK_AIR || e.getAction() == Action.RIGHT_CLICK_BLOCK) {
        p.rotateSpells();
    }
}
项目:RPGInventory    文件:BackpackListener.java   
@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();
}
项目:SurvivalPlus    文件:FoodDiversityConsume.java   
@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);
            }
        }
    }
}
项目:DynamicAC    文件:PlayerListener.java   
@EventHandler
public void onPlayerInteract2(PlayerInteractEvent e) {
    Player player = e.getPlayer();
    PlayerInventory inventory = player.getInventory();
    if(e.getAction() == Action.RIGHT_CLICK_AIR || e.getAction() == Action.RIGHT_CLICK_BLOCK) {
        Material material = inventory.getItemInHand().getType();
        if(material == Material.BOW) {
            DynamicAC.getManager().getBackend().logBowWindUp(player, System.currentTimeMillis());
        } else if(Utilities.isFood(material)) {
            DynamicAC.getManager().getBackend().logEatingStart(player);
        }
    }
    Block block = e.getClickedBlock();
    if(block != null) {
        Distance distance = new Distance(player.getLocation(), block.getLocation());
        DynamicAC.getManager().getBackend().checkLongReachBlock(player,distance.getXDifference(),distance
                .getYDifference(),distance.getZDifference());
    }
}
项目:Hub    文件:DevelopperListener.java   
@EventHandler
public void onPlayerInteract(PlayerInteractEvent event)
{
    this.hub.getServer().getScheduler().runTaskAsynchronously(this.hub, () ->
    {
        if (SamaGamesAPI.get().getPermissionsManager().hasPermission(event.getPlayer(), "hub.sign.selection"))
        {
            if (event.getItem() != null && event.getItem().getType() == Material.WOOD_AXE)
            {
                Action act = event.getAction();

                if (act == Action.LEFT_CLICK_BLOCK)
                {
                    this.hub.getPlayerManager().setSelection(event.getPlayer(), event.getClickedBlock().getLocation());
                    event.getPlayer().sendMessage(ChatColor.GOLD + "Point sélectionné !");
                }
            }
        }
    });
}
项目:HCFCore    文件:PearlGlitchListener.java   
@EventHandler(ignoreCancelled = true, priority = EventPriority.NORMAL)
public void onPlayerInteract(PlayerInteractEvent event) {
    if (event.getAction() == Action.RIGHT_CLICK_BLOCK && event.hasItem() && event.getItem().getType() == Material.ENDER_PEARL) {
        Block block = event.getClickedBlock();
        // Don't prevent opening chests, etc, as these won't throw the Enderpearls anyway
        if (block.getType().isSolid() && !(block.getState() instanceof InventoryHolder)) {
            Faction factionAt = HCF.getPlugin().getFactionManager().getFactionAt(block.getLocation());
            if (!(factionAt instanceof ClaimableFaction)) {
                return;
            }

            event.setCancelled(true);
            Player player = event.getPlayer();
            player.setItemInHand(event.getItem()); // required to update Enderpearl count
        }
    }
}
项目:HCFCore    文件:BookDeenchantListener.java   
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGH)
public void onPlayerInteract(PlayerInteractEvent event) {
    if (event.getAction() == Action.LEFT_CLICK_BLOCK && event.hasItem()) {
        // The player didn't click an enchantment table, Creative players will instantly destroy.
        Player player = event.getPlayer();
        if (event.getClickedBlock().getType() == Material.ENCHANTMENT_TABLE && player.getGameMode() != GameMode.CREATIVE) {

            // The player didn't click with an enchanted book.
            ItemStack stack = event.getItem();
            if (stack != null && stack.getType() == Material.ENCHANTED_BOOK) {
                ItemMeta meta = stack.getItemMeta();
                if (meta instanceof EnchantmentStorageMeta) {
                    EnchantmentStorageMeta enchantmentStorageMeta = (EnchantmentStorageMeta) meta;
                    for (Enchantment enchantment : enchantmentStorageMeta.getStoredEnchants().keySet()) {
                        enchantmentStorageMeta.removeStoredEnchant(enchantment);
                    }

                    event.setCancelled(true);
                    player.setItemInHand(EMPTY_BOOK);
                    player.sendMessage(ChatColor.GREEN + "You reverted this item to its original form.");
                }
            }
        }
    }
}
项目:RealSurvival    文件:TestCMD.java   
@EventHandler
private void getDatas(PlayerInteractEvent e){
    if(!(e.getAction()==Action.LEFT_CLICK_BLOCK||e.getAction()==Action.LEFT_CLICK_AIR))return;
    if(!canUsePeople.contains(e.getPlayer().getUniqueId()))return;
    e.setCancelled(true);
    Block block=e.getPlayer().getWorld().getBlockAt(e.getPlayer().getTargetBlock((Set<Material>)null, 6).getLocation()); 
    if(block!=null)
        e.getPlayer().sendMessage("��b������: ��3��l"+block.getType());
    if(e.getPlayer().getInventory().getItemInMainHand()!=null)
        e.getPlayer().sendMessage("��b��Ʒ��: ��3��l"+e.getPlayer().getInventory().getItemInMainHand().getType());
    double _temper1=getTemper(e.getPlayer(),e.getPlayer().getWorld().getTemperature(e.getPlayer().getLocation().getBlockX(), e.getPlayer().getLocation().getBlockZ()));
    e.getPlayer().sendMessage("��b�����¶�: ��3��l"+_temper1+"��");
    if(block!=null){
        double _temper2=getTemper(e.getPlayer(),e.getPlayer().getWorld().getTemperature(block.getX(), block.getZ()));
        e.getPlayer().sendMessage("��bĿ�귽���¶�: ��3��l"+_temper2+"��");
        e.getPlayer().sendMessage("��bĿ�귽������Ⱥϵ: ��3��l"+block.getBiome());
    }


}
项目:mczone    文件:Events.java   
@EventHandler
public void onSpectatorInteract(PlayerInteractEvent event) {
    Player p = event.getPlayer();
    Gamer g = Gamer.get(p.getName());
    if (!g.isInvisible())
        return;

    if (event.getAction() == Action.RIGHT_CLICK_AIR || event.getAction() == Action.RIGHT_CLICK_BLOCK || event.getAction() == Action.PHYSICAL) {
        event.setCancelled(true);
        return;
    }


    int cur = 0;
    if (g.getVariable("spectating") != null)
        cur = (Integer) g.getVariable("spectating");
    int next = cur + 1;
    if (next + 1 >= Game.getTributes().size())
        next = 0;
    g.setVariable("spectating", next);
    Gamer t = Game.getTributes().get(next);
    g.getPlayer().teleport(t.getPlayer().getLocation());
    Chat.player(g.getPlayer(), "&2[SG] &eCurrently spectating " + g.getPrefix() + g.getName());
    event.setCancelled(true);
}
项目:SurvivalAPI    文件:CookieHeadModule.java   
/**
 * Give old player enchants on head eating
 *
 * @param event Event
 */
@EventHandler
public void onPlayerInteract(PlayerInteractEvent event)
{
    if (event.getItem() == null || event.getItem().getType() != Material.SKULL_ITEM || event.getItem().getDurability() != 3
            || (event.getAction() != Action.RIGHT_CLICK_AIR && event.getAction() != Action.RIGHT_CLICK_BLOCK))
        return;

    SkullMeta skullMeta = (SkullMeta)event.getItem().getItemMeta();
    List<PotionEffect> effectList = this.effects.get(skullMeta.getOwner());

    if (effectList != null)
    {
        effectList.forEach(event.getPlayer()::addPotionEffect);
        this.effects.remove(skullMeta.getOwner());
        event.getPlayer().getWorld().playSound(event.getPlayer().getLocation(), Sound.BURP, 1F, 1F);
    }
}
项目:DungeonGen    文件:Passageway.java   
/**Event handler for a player pressing the button of this Passageway. Will callback to DunGen to generate the next DunGen part.
 * Also moves all other players to this Passageway.
 * @param event
 */
@EventHandler(priority = EventPriority.MONITOR)
public void onNextRoomButtonPress(PlayerInteractEvent event) {
    //Player p = event.getPlayer();
    if (event.getAction() == Action.RIGHT_CLICK_BLOCK) {
        Block clicked = event.getClickedBlock();
        if (   clicked.getType() == Material.STONE_BUTTON 
            && modVolume.contains(BukkitUtil.toVector(clicked.getLocation())) ) {

            unregister(); // button cannot be pushed twice
            // If double button push appears more often, then use flag here
            // Here we need the activePlayers list. This is not present in the entry, so don't teleport during STARTUP phase.
            // This might be solvable better somehow...

            // only teleport if the dungeon runs, not during entry startup state
            if (parent.state == State.RUNNING) 
                for (Player p : parent.activePlayers) {
                    if (!modVolume.contains(BukkitUtil.toVector(p.getLocation()))) {
                        p.teleport(BukkitUtil.toLocation(parent.world, toGlobal(respawnLoc).add(0.5, 0, 0.5)));
                    }
                }

            parent.genNextRoom();
        }
    }
}
项目:SlimefunBugFixer    文件:Listeners.java   
@EventHandler
public void onClick(PlayerInteractEvent e) {
    Action act = e.getAction();
    if (!(act.equals(Action.RIGHT_CLICK_AIR) || act.equals(Action.RIGHT_CLICK_BLOCK)))
        return;
    ItemStack item = e.getItem();
    if (item == null)
        return;
    if (!item.hasItemMeta())
        return;
    if (!item.getItemMeta().hasDisplayName())
        return;
    if (!item.getItemMeta().getDisplayName().contains(ConfigManager.getInstance().getBackpackName()))
        return;
    Player p = e.getPlayer();
    String name = p.getName();
    if (BackpackCooldown.getInstance().isReady(name, 500)) {
        BackpackCooldown.getInstance().put(name);
    } else {
        e.setCancelled(true);
        p.closeInventory();
        p.sendMessage(Messages.getMessages().getNoQuickOpen().replace("&", "§"));
    }
}
项目:HCFCore    文件:ArcherClass.java   
@EventHandler(ignoreCancelled=false, priority=EventPriority.HIGH)
public void onArcherSpeedClick(PlayerInteractEvent event)
{
    Action action = event.getAction();
    if (((action == Action.RIGHT_CLICK_AIR) || (action == Action.RIGHT_CLICK_BLOCK)) &&
            (event.hasItem()) && (event.getItem().getType() == Material.SUGAR))
    {
        if (this.plugin.getPvpClassManager().getEquippedClass(event.getPlayer()) != this) {
            return;
        }
        Player player = event.getPlayer();
        UUID uuid = player.getUniqueId();
        long timestamp = this.archerSpeedCooldowns.get(uuid);
        long millis = System.currentTimeMillis();
        long remaining = timestamp == this.archerSpeedCooldowns.getNoEntryValue() ? -1L : timestamp - millis;
        if (remaining > 0L)
        {
            player.sendMessage(ChatColor.RED + "Cannot use Speed 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 + "Speed 4 activated for 7 seconds.");

            this.plugin.getEffectRestorer().setRestoreEffect(player, ARCHER_SPEED_EFFECT);
            this.archerSpeedCooldowns.put(event.getPlayer().getUniqueId(), System.currentTimeMillis() + ARCHER_SPEED_COOLDOWN_DELAY);
        }
    }
}
项目:AsgardAscension    文件:GodFoodListener.java   
@SuppressWarnings("deprecation")
@EventHandler
public void onFoodEat(PlayerInteractEvent event) {
    if(!(event.getAction().equals(Action.RIGHT_CLICK_AIR) || event.getAction().equals(Action.RIGHT_CLICK_BLOCK))) {
        return;
    }
    if(!event.getPlayer().isSneaking() || event.getPlayer().getInventory().getItemInMainHand() == null) {
        return;
    }

    Player player = event.getPlayer();
    List<Integer> ids = GodFoodFile.getFoodId(player.getInventory().getItemInMainHand().getTypeId());
    for(int id : ids) {
        byte data = (byte)GodFoodFile.getData(id);

        if(player.getInventory().getItemInMainHand().getData().getData() != data || id == 0)
            continue;

        if(player.getInventory().getItemInMainHand().getAmount() > GodFoodFile.getAmount(id)) {
            ItemStack item = player.getInventory().getItemInMainHand();
            item.setAmount(item.getAmount() - GodFoodFile.getAmount(id));
            player.setItemInHand(item);
        } else if(player.getInventory().getItemInMainHand().getAmount() == GodFoodFile.getAmount(id)) {
            player.setItemInHand(new ItemStack(Material.AIR));
        } else {
            return;
        }
        event.setCancelled(true);

        addPotionEffects(player, id);
        player.sendMessage(Lang.HEADERS_FOG.toString() + "You used " 
                + ChatColor.RED + GodFoodFile.getName(id) + ChatColor.GRAY + "!");
    }
}
项目:uppercore    文件:HotbarManager.java   
@EventHandler
public void onPlayerInteract(PlayerInteractEvent e) {
    try {
        if (e.getHand() != EquipmentSlot.HAND)
            return;
    } catch (Error ignored) {
    }
    if (e.getAction() != Action.PHYSICAL)
        onClick(e); // this method cancels the event by himself
}
项目:ZorahPractice    文件:PearlFix.java   
@EventHandler(ignoreCancelled = true, priority = EventPriority.NORMAL)
public void onInteract(PlayerInteractEvent event) {
    if ((event.getAction() == Action.RIGHT_CLICK_BLOCK) && (event.hasItem()) && (event.getItem().getType() == Material.ENDER_PEARL)) {
        Block block = event.getClickedBlock();

        if ((block.getType().isSolid()) && (!(block.getState() instanceof InventoryHolder))) {
            event.setCancelled(true);
            Player player = event.getPlayer();
            player.setItemInHand(event.getItem());
        }
    }
}
项目:ZentrelaRPG    文件:EnvironmentManager.java   
@EventHandler
public void onPlayerInteractCrops(PlayerInteractEvent event) {
    if (event.getAction() == Action.PHYSICAL) {
        Block b = event.getClickedBlock();
        if (b.getType() == Material.SOIL) {
            event.setCancelled(true);
            b.setTypeIdAndData(b.getType().getId(), b.getData(), true);
        }
        if (b.getType() == Material.CROPS) {
            event.setCancelled(true);
            b.setTypeIdAndData(b.getType().getId(), b.getData(), true);
        }
    }
}
项目:ZentrelaRPG    文件:EnvironmentManager.java   
@EventHandler
public void onAnvilOrEnchantInteract(PlayerInteractEvent event) {
    if (event.getClickedBlock() != null) {
        if (event.getPlayer().getGameMode() == GameMode.CREATIVE && (event.getAction() == Action.LEFT_CLICK_AIR || event.getAction() == Action.LEFT_CLICK_BLOCK))
            return;
        Material type = event.getClickedBlock().getType();
        for (Material m : RESTRICTED_TYPES) {
            if (m == type) {
                event.setCancelled(true);
                break;
            }
        }
    }
}
项目:ZentrelaRPG    文件:CombatManager.java   
@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();
            }
        });
    }
}
项目:ZorahPractice    文件:KitEditManager.java   
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
public void onPearl(PlayerInteractEvent event) {
    if ((event.getAction() == Action.RIGHT_CLICK_AIR || event.getAction() == Action.RIGHT_CLICK_BLOCK) && event.getItem() != null && event.getItem().getType() == Material.ENDER_PEARL) {
        if (this.editKits.containsKey(event.getPlayer().getUniqueId())) {
            event.setCancelled(true);
        }
    }
}
项目:EscapeLag    文件:SpawnerController.java   
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onModify(PlayerInteractEvent evt) {
    if (!preventSpawnerModify || evt.getItem() == null || evt.getAction() != Action.RIGHT_CLICK_BLOCK) return;

    Player player = evt.getPlayer();
    if (Perms.has(player)) return;

    if (evt.getClickedBlock().getType() == Material.MOB_SPAWNER) {
        Material type = evt.getItem().getType();
        if (type == Material.MONSTER_EGG || type == Material.MONSTER_EGGS) {
            evt.setCancelled(true);
            AzureAPI.log(player, messagePreventSpawnerModify);
        }
    }
}
项目:bskyblock    文件:IslandGuard1_9.java   
/**
 * Handle blocks that need special treatment
 * Tilling of coarse dirt into dirt using off-hand (regular hand is in 1.8)
 * Usually prevented because it could lead to an endless supply of dirt with gravel
 *
 * @param e
 */
@SuppressWarnings("deprecation")
@EventHandler(priority = EventPriority.LOW, ignoreCancelled=true)
public void onPlayerInteract(final PlayerInteractEvent e) {
    if (DEBUG) {
        plugin.getLogger().info("1.9 " + e.getEventName());
    }
    if (!e.getAction().equals(Action.RIGHT_CLICK_BLOCK)) {
        return;
    }
    if (!Util.inWorld(e.getPlayer())) {
        return;
    }
    if (e.getPlayer().isOp()) {
        return;
    }
    // This permission bypasses protection
    if (VaultHelper.hasPerm(e.getPlayer(), Settings.PERMPREFIX + "mod.bypassprotect")
            || VaultHelper.hasPerm(e.getPlayer(), Settings.PERMPREFIX + "craft.dirt")) {
        return;
    }
    // Prevents tilling of coarse dirt into dirt
    ItemStack inHand = e.getPlayer().getInventory().getItemInOffHand();
    if (inHand.getType() == Material.WOOD_HOE || inHand.getType() == Material.IRON_HOE || inHand.getType() == Material.GOLD_HOE
            || inHand.getType() == Material.DIAMOND_HOE || inHand.getType() == Material.STONE_HOE) {
        // plugin.getLogger().info("1.8 " + "DEBUG: hoe in hand");
        Block block = e.getClickedBlock();
        // plugin.getLogger().info("1.8 " + "DEBUG: block is " + block.getType() +
        // ":" + block.getData());
        // Check if coarse dirt
        if (block.getType() == Material.DIRT && block.getData() == (byte) 1) {
            // plugin.getLogger().info("1.8 " + "DEBUG: hitting coarse dirt!");
            e.setCancelled(true);
        }
    }
}
项目:bskyblock    文件:IslandGuard.java   
/**
 * Pressure plates
 * @param e
 */
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onPlateStep(PlayerInteractEvent e) {
    if (DEBUG) {
        plugin.getLogger().info("pressure plate = " + e.getEventName());
        plugin.getLogger().info("action = " + e.getAction());
    }
    if (!Util.inWorld(e.getPlayer()) || !e.getAction().equals(Action.PHYSICAL)
            || e.getPlayer().isOp() || VaultHelper.hasPerm(e.getPlayer(), Settings.PERMPREFIX + "mod.bypassprotect")
            || plugin.getIslands().playerIsOnIsland(e.getPlayer())) {
        //plugin.getLogger().info("DEBUG: Not in world");
        return;
    }
    // Check island
    Island island = plugin.getIslands().getProtectedIslandAt(e.getPlayer().getLocation());
    if ((island == null && Settings.defaultWorldSettings.get(SettingsFlag.PRESSURE_PLATE))) {
        return;
    }
    if (island != null && island.getFlag(SettingsFlag.PRESSURE_PLATE)) {
        return;
    }
    // Block action
    UUID playerUUID = e.getPlayer().getUniqueId();
    if (!onPlate.containsKey(playerUUID)) {
        Util.sendMessage(e.getPlayer(), plugin.getLocale(playerUUID).get("island.protected"));
        Vector v = e.getPlayer().getLocation().toVector();
        onPlate.put(playerUUID, new Vector(v.getBlockX(), v.getBlockY(), v.getBlockZ()));
    }
    e.setCancelled(true);
}
项目:bskyblock    文件:IslandGuard1_8.java   
/**
 * Handle V1.8 blocks that need special treatment
 * Tilling of coarse dirt into dirt
 * Usually prevented because it could lead to an endless supply of dirt with gravel
 *
 * @param e
 */
@SuppressWarnings("deprecation")
@EventHandler(priority = EventPriority.LOW, ignoreCancelled=true)
public void onPlayerInteract(final PlayerInteractEvent e) {
    if (DEBUG) {
        plugin.getLogger().info("1.8 " + e.getEventName());
    }
    if (!e.getAction().equals(Action.RIGHT_CLICK_BLOCK)) {
        return;
    }
    if (!Util.inWorld(e.getPlayer())) {
        return;
    }
    if (e.getPlayer().isOp()) {
        return;
    }
    // This permission bypasses protection
    if (VaultHelper.hasPerm(e.getPlayer(), Settings.PERMPREFIX + "mod.bypassprotect")
            || VaultHelper.hasPerm(e.getPlayer(), Settings.PERMPREFIX + "craft.dirt")) {
        return;
    }
    // Prevents tilling of coarse dirt into dirt
    ItemStack inHand = e.getPlayer().getItemInHand();
    if (inHand.getType() == Material.WOOD_HOE || inHand.getType() == Material.IRON_HOE || inHand.getType() == Material.GOLD_HOE
            || inHand.getType() == Material.DIAMOND_HOE || inHand.getType() == Material.STONE_HOE) {
        // plugin.getLogger().info("1.8 " + "DEBUG: hoe in hand");
        Block block = e.getClickedBlock();
        // plugin.getLogger().info("1.8 " + "DEBUG: block is " + block.getType() +
        // ":" + block.getData());
        // Check if coarse dirt
        if (block.getType() == Material.DIRT && block.getData() == (byte) 1) {
            // plugin.getLogger().info("1.8 " + "DEBUG: hitting coarse dirt!");
            e.setCancelled(true);
        }
    }
}
项目:Absorption    文件:InteractionListener.java   
@EventHandler
public void onPlayerInteract(PlayerInteractEvent e) {
    if(e.getPlayer().getGameMode() != GameMode.CREATIVE)
        e.setCancelled(true);

    GamePlayer player = Absorption.getPlayer(e.getPlayer());
    if(player == null) return;

    if(e.getPlayer().getItemInHand().getType() == Material.AIR) return;

    if(player.getState() == PlayerState.WAITING) {

    } else if(player.getState() == PlayerState.PLAYING) {
        int slot = e.getPlayer().getInventory().getHeldItemSlot();
        if(e.getAction() == Action.LEFT_CLICK_AIR || e.getAction() == Action.LEFT_CLICK_BLOCK) {
            if(slot == 0) {
                player.getKit().onLeftClick(player);
            } else if(slot == 1) {
                player.getKit().getSecondaryWeapon().onLeftClick(player);
            } else if(slot == 2) {
                player.getKit().getSpecialWeapon().onLeftClick(player);
            }
        } else if(e.getAction() == Action.RIGHT_CLICK_AIR || e.getAction() == Action.RIGHT_CLICK_BLOCK) {
            if(slot == 0) {
                player.getKit().onRightClick(player);
            } else if(slot == 1) {
                player.getKit().getSecondaryWeapon().onRightClick(player);
            } else if(slot == 2) {
                player.getKit().getSpecialWeapon().onRightClick(player);
            }
        }
    } else if(player.getState() == PlayerState.RESPAWNING) {

    } else if(player.getState() == PlayerState.END) {
        // Nothing
    }
}
项目:WC    文件:Weapons.java   
@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);
    }
}
项目:McLink    文件:VItem.java   
public static Map<Item.ActionType, Method> getActions(Class<?> c) {
    Map<Item.ActionType, Method> a = new HashMap<Item.ActionType, Method>();

    for (Method m : c.getMethods()) {
        if (m.isAnnotationPresent(Item.Action.class)) {
            a.put(m.getAnnotation(Item.Action.class).type(), m);
        }
    }

    return a;
}