Java 类org.bukkit.event.player.PlayerInteractEvent 实例源码

项目:FactionsXL    文件:FBull.java   
@EventHandler
public void onPlayerInteract(PlayerInteractEvent event) {
    Player player = event.getPlayer();
    Location location = player.getLocation();
    ItemStack item = event.getItem();
    if (isBull(item) && event.getAction() == Action.RIGHT_CLICK_AIR | event.getAction() == Action.RIGHT_CLICK_BLOCK) {
        if (!FactionsXL.getInstance().getBoard().isAnnexable(location)) {
            ParsingUtil.sendMessage(player, FMessage.ERROR_LAND_NOT_FOR_SALE.getMessage());
            return;
        }
        FactionCache factions = FactionsXL.getInstance().getFactionCache();
        BookMeta meta = ((BookMeta) item.getItemMeta());
        String title = meta.getTitle().replace(" ", "-");
        if (factions.getByName(title) != null) {
            title += NumberUtil.generateRandomInt(0, 100);
        }
        FireworkUtil.spawnRandom(location);
        FactionsXL.getInstance().getFactionCache().create(player, title);
        player.getInventory().remove(item);
    }
}
项目: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());
        }
    }

}
项目:NeverLag    文件:AntiDamageSkull.java   
@EventHandler
public void onDamageSkull(PlayerInteractEvent e) {
    if (cm.isAntiDamageSkull) {
        if (Action.RIGHT_CLICK_BLOCK == e.getAction()) {
            if (e.getItem() != null) {
                Material type = e.getItem().getType();
                if (Material.LAVA_BUCKET == type || Material.WATER_BUCKET == type) {
                    fixSkull(e.getClickedBlock().getRelative(BlockFace.UP));
                } else if (Material.ANVIL == type) {
                    for (BlockFace face : BLOCKFACE) {
                        fixSkull(e.getClickedBlock().getRelative(face));
                    }
                }
            }
        }
    }
}
项目:HCFCore    文件:AssassinClass.java   
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
public void onPlayerInteract(PlayerInteractEvent event) {
    if (event.hasItem() && event.getItem().getType() == Material.GOLDEN_CARROT) {
        Player player = event.getPlayer();
        if (plugin.getPvpClassManager().getEquippedClass(player) == this) {
            long timestamp = cooldowns.get(player.getUniqueId());
            long millis = System.currentTimeMillis();
            long remaining = timestamp == cooldowns.getNoEntryValue() ? 0L : timestamp - millis;
            if (remaining > 0L) {
                player.sendMessage(ChatColor.RED + "Cooldown still for " + DurationFormatUtils.formatDurationWords(remaining, true, true) + ".");
                return;
            }

            cooldowns.put(player.getUniqueId(), millis + 15000L);
            plugin.getEffectRestorer().setRestoreEffect(player, new PotionEffect(PotionEffectType.SPEED, 100, 4));
            plugin.getEffectRestorer().setRestoreEffect(player, new PotionEffect(PotionEffectType.INVISIBILITY, 100, 0));
        }
    }
}
项目:ArchersBattle    文件:FireBall.java   
@EventHandler
public void onInteract(PlayerInteractEvent e) {
    if (!Utils.isInArena(e.getPlayer()))
        return;
    if (!SkillManager.getInstance().getSkillByShow(e.getPlayer().getItemInHand()).equals(this))
        return;
    Player p = e.getPlayer();
    if (!CooldownManager.getInstance().exists(p)) {
        launch(p, null);
    } else {
        long left = CooldownManager.getInstance().getLeft(p, 3000L);
        if (left == 0) {
            launch(p, null);
        } else {
            p.sendMessage(Messages.prefix + Messages.Cooldown.replace("%time%", String.valueOf(left)));
        }
    }
}
项目:AntiCheat    文件:OrebfuscatorPlayerListener.java   
@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());
    }
}
项目:MCLibrary    文件:LibraryCommand.java   
public static void init(MCLibrary plugin) {
    Bukkit.getPluginManager().registerEvents(new Listener() {
        @EventHandler
        @SuppressWarnings("deprecation")
        public void onInteract(PlayerInteractEvent event) {
            if (MCUtils.isOffHandSupport() && event.getHand() != EquipmentSlot.HAND)
                return;

            Player player = event.getPlayer();
            Block block = event.getClickedBlock();
            if (block == null || !INFO_LISTENERS.contains(player))
                return;

            Location loc = block.getLocation();
            CommandSenderWrapper wrapper = new CommandSenderWrapper(player);
            wrapper.sendMessage("---------------------------------------------");
            wrapper.sendMessage("&eworld: &f" + loc.getWorld().getName());
            wrapper.sendMessage(String.format("&ex: &f%s (%s)", loc.getBlockX(), loc.getX()));
            wrapper.sendMessage(String.format("&ey: &f%s (%s)", loc.getBlockY(), loc.getY()));
            wrapper.sendMessage(String.format("&ez: &f%s (%s)", loc.getBlockZ(), loc.getZ()));
            wrapper.sendMessage(String.format("&eblock: &f%s:%s (%s)", block.getTypeId(), block.getData(), block.getType().name()));
        }
    }, plugin);
}
项目:mczone    文件:Events.java   
@EventHandler
public void Compass(PlayerInteractEvent event) {
    if (event.getItem() != null && event.getItem().getType() != Material.AIR && event.getItem().getType()==Material.COMPASS) {
        Player p = event.getPlayer();
        for (int i = 0; i < 500; i+=20) {
            List<Entity> entities = p.getNearbyEntities(i, 256, i);
            for (Entity e : entities) {
                if (e instanceof Player) {
                    Player found = (Player) e;
                    if (Team.getTeam(p)!=Team.getTeam(found)) {
                        Chat.player(p, "&aCompass now points towards " + found.getDisplayName() + "&a!");
                        p.setCompassTarget(e.getLocation());
                        return;
                    }
                }
            }
        }
        Chat.player(p, "&cNo enemy players found near you!");
    }
}
项目: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);
}
项目: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);
    }
}
项目:kaosEssentials    文件:Core.java   
@EventHandler
public void jailDoorExit(PlayerInteractEvent e){
    jailLoc = new Location(Bukkit.getWorld("kaospvp"), 1106, 32, -236);
    jailLeaveLoc = new Location(Bukkit.getWorld("kaospvp"), 1103, 33, -238);
    Punished pj = Punished.isJailed(e.getPlayer().getUniqueId().toString());
    if(e.getClickedBlock() == null) return;
    Location cbl = e.getClickedBlock().getLocation(); // clicked block location
    boolean ird =  // is right door?
            cbl.getBlockX() == jailLeaveLoc.getBlockX() &&
            cbl.getBlockY() == jailLeaveLoc.getBlockY() &&
            cbl.getBlockZ() == jailLeaveLoc.getBlockZ();
    if(ird){
        if(pj.punished){
            e.getPlayer().sendMessage(
                    tag + ChatColor.GRAY + "You still have " +
                    ChatColor.RED + pj.expirySecs / (60*60*24) + ChatColor.GRAY + " days, " +
                    ChatColor.RED + ((pj.expirySecs/HOUR)%24) + ChatColor.GRAY + " hours, " +
                    ChatColor.RED + ((pj.expirySecs/MINUTE) % 60) + ChatColor.GRAY + " minutes!");
        }else{
            e.getPlayer().teleport(e.getPlayer().getWorld().getSpawnLocation());
            e.getPlayer().sendMessage(tag + ChatColor.GREEN + "You are free from jail!");
        }
    }
}
项目:SurvivalAPI    文件:GameListener.java   
/**
 * Block Minecraft utilization
 *
 * @param event Event
 */
@SuppressWarnings("deprecation")
@EventHandler(ignoreCancelled = true)
public void onPlayerInteract(PlayerInteractEvent event)
{
    if (event.getPlayer().getItemInHand() != null && event.getPlayer().getItemInHand().getType() == (Material.MINECART))
    {
        if (event.getPlayer().getItemInHand().getType() == Material.MINECART)
        {
            event.getPlayer().sendMessage(ChatColor.RED + "L'utilisation de Minecart est bloqué.");
            event.setCancelled(true);
        }
        else if (event.getPlayer().getItemInHand().getType() == Material.FLINT_AND_STEEL && !this.game.isPvPActivated())
        {
            event.getPlayer().sendMessage(ChatColor.RED + "L'utilisation du briquet est interdit en phase de préparation.");
            event.setCancelled(true);
        }
    }
}
项目:VanillaPlus    文件:CPManager.java   
@EventHandler (priority = EventPriority.HIGHEST, ignoreCancelled = false)
public void onInteract(PlayerInteractEvent event) {
    if(link.isEmpty())return;
    ItemStack stack = event.getItem();
    if(stack == null)
        return;
    NBTItem item = new NBTItem(stack);
    Integer cmdId = item.getInteger("cmd");
    if(cmdId == null)
        return;
    Link cmd = link.get(cmdId);
    if(cmd==null)
        return;
    VPPlayer sender = VanillaPlusCore.getPlayerManager().getPlayer(event.getPlayer());
    if(cmd.cmd.hasRequirement(sender)){
        cmd.onExecute(sender);
        event.setCancelled(cmd.cancel);
    }
}
项目: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);
            }
        }
    }
}
项目: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("&", "§"));
    }
}
项目:VoxelGamesLibv2    文件:SignPlaceholders.java   
@EventHandler
public void handleInteract(@Nonnull PlayerInteractEvent event) {
    if (event.getAction() == org.bukkit.event.block.Action.RIGHT_CLICK_BLOCK && event.getClickedBlock() != null) {
        if (event.getClickedBlock().getState() instanceof Sign) {
            Sign sign = (Sign) event.getClickedBlock().getState();
            if (sign.hasMetadata("UpdateCooldown")) {
                long cooldown = sign.getMetadata("UpdateCooldown").get(0).asLong();
                if (cooldown > System.currentTimeMillis() - 1 * 1000) {
                    return;
                }
            }
            sign.update();
            sign.setMetadata("UpdateCooldown", new FixedMetadataValue(voxelGamesLib, System.currentTimeMillis()));
        }
    }
}
项目:Bags2    文件:BagBase.java   
@Override
public void onInteract(PlayerInteractEvent e, EquipmentSlot es)
{
    ItemStack stack = es.equals(EquipmentSlot.HAND) ? e.getPlayer().getInventory().getItemInMainHand() : e.getPlayer().getInventory().getItemInOffHand();
    if(stack.hasItemMeta() ? !stack.getItemMeta().getDisplayName().equals(Translation.get(name)) : false)
    {
        if(stack.getItemMeta().getDisplayName().startsWith(ChatColor.RESET.toString()))
        {

            ItemMeta im = stack.getItemMeta();
            if(!im.getDisplayName().startsWith(ChatColor.ITALIC.toString()))
            im.setDisplayName(ChatColor.RESET + Translation.get(name));
            stack.setItemMeta(im);
            if(es.equals(EquipmentSlot.HAND))
            e.getPlayer().getInventory().setItemInMainHand(stack);
            else
            e.getPlayer().getInventory().setItemInOffHand(stack);
        }
    }
    super.onInteract(e, es);
}
项目:HCFCore    文件:ModeratorMode.java   
@EventHandler
public void onRecord(PlayerInteractEvent e)
{
  Player p = e.getPlayer();
  if ((modMode.contains(p.getName())) && (p.getItemInHand().getType() == Material.EYE_OF_ENDER) && (e.getAction().toString().contains("RIGHT")))
  { 
    Player random = Bukkit.getOnlinePlayers()[new java.util.Random().nextInt(Bukkit.getOnlinePlayers().length)];
    if (Bukkit.getOnlinePlayers().length == 1)
      p.sendMessage(ChatColor.RED + "§6§ §rOops, seems like there are not enough players to use this.");
      e.setCancelled(true);
    if (Bukkit.getOnlinePlayers().length > 1) {
      if (p != random) {
        p.teleport(random);
        p.sendMessage(ChatColor.YELLOW + " §6§ §rYou were teleported randomly to §c" + random.getName() + "§r.");
        e.setCancelled(true);
      }
      if (p == random) {
        p.sendMessage(ChatColor.YELLOW + "§6§ §rOops, seems like we accidently found you. Please try again!");
        e.setCancelled(true);
      }
    }
  }
}
项目: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
        }
    }
}
项目:Locked    文件:SubstanceListener.java   
@EventHandler
public void playerInteract(PlayerInteractEvent event) {
    Player player = event.getPlayer();
    ItemStack item = event.getItem();
    if (item != null) {
        ItemStack itemR = new ItemStack(item.getType(), 1);
        itemR.setItemMeta(item.getItemMeta());
        for (AbstractSubstance d : AbstractSubstance.getSubstances()) {
            if (d.getItemStack().getType().equals(item.getType())) {
                d.effect(player);
                if (!player.getGameMode().equals(GameMode.CREATIVE)) {
                    player.getInventory().removeItem(itemR);
                    player.updateInventory();
                }
                return;
            }
        }
    }
}
项目:ProjectAres    文件:LauncherGizmo.java   
@EventHandler
public void onPlayerInteract(PlayerInteractEvent event) {
    Player player = event.getPlayer();

    if (!(Gizmos.gizmoMap.get(player) instanceof LauncherGizmo)) return;

    if (event.getAction() != Action.RIGHT_CLICK_BLOCK && event.getAction() != Action.RIGHT_CLICK_AIR) return;
    if (player.getItemInHand().getType() != this.getIcon()) return;

    Firework oldFirework = this.launchedPlayers.get(player);
    if (oldFirework == null || oldFirework.isDead()) {
        Firework firework = this.buildFirework(player.getLocation());
        firework.setPassenger(player);
        this.launchedPlayers.put(player, firework);
    }
}
项目:ProjectAres    文件:ButtonManager.java   
@EventHandler(priority = EventPriority.LOW)
public void onInteract(PlayerInteractEvent event) {
    if(!event.hasItem()) return;

    final ClickType click;
    switch(event.getAction()) {
        case LEFT_CLICK_AIR:
        case LEFT_CLICK_BLOCK:
            click = ClickType.LEFT;
            break;

        case RIGHT_CLICK_AIR:
        case RIGHT_CLICK_BLOCK:
            click = ClickType.RIGHT;
            break;

        default:
            return;
    }

    if(onButtonClick(event.getItem(), event.getActor(), click, event)) {
        event.setUseItemInHand(Event.Result.DENY);
        event.setUseInteractedBlock(Event.Result.DENY);
    }
}
项目:SurvivalAPI    文件:CocoaEffectsModule.java   
/**
 * Give speed 1 & strenght 1 effect to all players, then give them slowness & weakness after 30sec.
 * @param event Event
 */
@EventHandler
public void onInteract(PlayerInteractEvent event)
{
    if (event.getItem() != null && event.getItem().isSimilar(this.cocoa))
    {
        event.getPlayer().addPotionEffect(PotionEffectType.SPEED.createEffect(this.bonusTime * 20, 1));
        event.getPlayer().addPotionEffect(PotionEffectType.INCREASE_DAMAGE.createEffect(this.bonusTime * 20, 1));

        this.plugin.getServer().getScheduler().runTaskLater(this.plugin, () ->
        {
            event.getPlayer().addPotionEffect(PotionEffectType.SLOW.createEffect(this.penaltyTime * 20, 1));
            event.getPlayer().addPotionEffect(PotionEffectType.WEAKNESS.createEffect(this.penaltyTime * 20, 1));
        }, this.bonusTime * 20);

        if (event.getItem().getAmount() > 1)
            event.getItem().setAmount(event.getItem().getAmount() - 1);
        else
            event.getPlayer().setItemInHand(new ItemStack(Material.AIR));

        event.setCancelled(true);
    }
}
项目:Recreator    文件:ItemDrawKnife.java   
@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) ? "这块木头已削过皮了" : "这把刀只能削树皮用");
    }
}
项目: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);
            }
        }
    }
}
项目:mczone    文件:GeneralEvents.java   
@EventHandler
public void onPlayerInteract(PlayerInteractEvent event) {       
    Gamer g = Gamer.get(event.getPlayer());
    event.setCancelled(true);

    if (g.getVariable("arena") != null) {
        Arena a = (Arena) g.getVariable("arena");
        if (a.getState() == ArenaState.STARTED)
            event.setCancelled(false);
    }

    if (g.getVariable("edit") != null) {
        if ((boolean) g.getVariable("edit"))
            event.setCancelled(false);
    }
}
项目:BedwarsXP    文件:OldEventListeners.java   
@EventHandler
public void onPlayerInteract(PlayerInteractEvent e) {
    Game bw = io.github.yannici.bedwars.Main.getInstance().getGameManager()
            .getGameOfPlayer(e.getPlayer());
    if (bw == null) {
        return;
    }
    if (!Config.isGameEnabledXP(bw.getName())) {
        return;
    }
    XPManager.updateXPBar(bw.getName(), e.getPlayer());
}
项目:SurvivalAPI    文件:SurvivalTeamSelector.java   
/**
 * Event fired when a player uses his nether star
 *
 * @param event Event
 */
@EventHandler
public void onPlayerInteract(PlayerInteractEvent event)
{
    if (this.game.getStatus().equals(Status.IN_GAME))
        event.getHandlers().unregister(this);
    else if (event.getItem() != null && event.getItem().getType() == Material.NETHER_STAR)
        this.openGui(event.getPlayer(), new GuiSelectTeam());
}
项目:Crescent    文件:DetectionListener.java   
@EventHandler
public void onPlayerInteract(PlayerInteractEvent event) {
    final Player player = event.getPlayer();

    getCheckVersion(player, CheckType.AUTOCLICKER, "A").call(event);

    getCheckVersion(player, CheckType.NOSWING, "A").call(event);
}
项目:MT_Communication    文件:CellularPhoneListener.java   
@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);

    }
  }

}
项目:Recreator    文件:ItemDirectionStick.java   
@Override
public void run(PlayerInteractEvent evt) {
    Player player = evt.getPlayer();
    if (!ControlTicker.isTracking(player)) {
        AzureAPI.playSound(player, Sound.UI_BUTTON_CLICK, true);
        AzureAPI.log(player, "未找到信号接收源!");
        return;
    }

    AzureAPI.log(player, "弹道方向设定完成!");
    AzureAPI.playSound(player, Sound.ENTITY_TNT_PRIMED);
    ControlTicker.sudo(player);
}
项目:MT_Communication    文件:CellularPhoneListener.java   
@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);

    }
  }

}
项目:PA    文件:SpawnMob.java   
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onSpawn(PlayerInteractEvent e){
    Player p = e.getPlayer();

    if (e.getAction() == Action.RIGHT_CLICK_AIR || e.getAction() == Action.RIGHT_CLICK_BLOCK) {
        if(e.getHand() != EquipmentSlot.HAND) return;
        if (e.getItem() == null || !e.getItem().hasItemMeta() || !e.getItem().getItemMeta().hasDisplayName() || e.getItem().getType() != Material.MONSTER_EGG) return;
        if (!ChatColor.stripColor(e.getItem().getItemMeta().getDisplayName()).contains("Spawn")) return;
        int id = Integer.parseInt(e.getItem().getItemMeta().getLore().get(0));
        String s = e.getItem().getItemMeta().getLore().get(1);

        boolean canCatch = true;
        ApplicableRegionSet region = plugin.getWg().getRegionManager(p.getWorld()).getApplicableRegions(p.getLocation());
        for (ProtectedRegion r : region.getRegions()) if (!r.getOwners().contains(p.getName())) canCatch = false;

        if (!canCatch) {
            p.sendMessage(SafariNet.getInstance().getPrefix() + ChatColor.RED + "No puedes spawnear un mob en parcelas ajenas");
            return;
        }

        SNMob mob = new SNMob(p);
        if (!mob.isOwner(id)) {
           p.sendMessage(SafariNet.getInstance().getPrefix() + ChatColor.RED + "No eres el dueño de este huevo");
            return;
        }
        mob.spawnMob(id, s);
        p.getInventory().getItemInMainHand().setAmount(-1);
    }
}
项目:AsgardAscension    文件:RuneListener.java   
@EventHandler
public void onRuneUse(PlayerInteractEvent event) {
    if(!(event.getAction().equals(Action.RIGHT_CLICK_AIR) || event.getAction().equals(Action.RIGHT_CLICK_BLOCK))) {
        return;
    }

    if(event.getHand() == null || !event.getHand().equals(EquipmentSlot.HAND)) {
        return;
    }

    ItemStack item = event.getPlayer().getInventory().getItemInMainHand();
    if(item == null || item.getItemMeta() == null || !item.getType().equals(Material.ENCHANTED_BOOK)) {
        return;
    }

    Player player = event.getPlayer();
    Rune rune = plugin.getRuneManager().getRune(item.getItemMeta().getDisplayName().substring(2));
    if(rune == null) {
        return;
    }

    event.setCancelled(true);

    if(plugin.getRuneManager().hasActiveRune(player)) {
        player.sendMessage(Lang.HEADERS_TOKENS.toString() + Lang.TOKENS_RUNE_ALREADY_ACTIVE.toString());
        return;
    }

    if(Cooldowns.getCooldown(player, "rune") > 0) {
        player.sendMessage(Lang.HEADERS_TOKENS.toString() + Lang.TOKENS_RUNE_COOLDOWN.toString()
            .replaceAll("%d", Convert.timeToString((int) (Cooldowns.getCooldown(player, "rune") / 1000))));
        return;
    }

    plugin.getRuneManager().start(player, rune);
}
项目:RPGPlus    文件:Effects.java   
public static void fireBarrier(PlayerInteractEvent event){
    final Player player = (Player) event.getPlayer();
    final Location loc = (Location) player.getLocation();
    new BukkitRunnable() {
        double phi = 0;
        @Override
        public void run() {
            phi += (Math.PI/10);
            for(double theta = 0; theta <= 2*Math.PI; theta += Math.PI/40){
                double r = 1.5;
                double x = r*Math.cos(theta)*Math.sin(phi);
                double y = r* Math.cos(phi) + 1.5;
                double z = r*Math.sin(theta)*Math.sin(phi);
                loc.add(x,y,z);
                ParticleEffect.FLAME.display(0, 0, 0, 3, 3, loc, 40);
                loc.subtract(x,y,z);
                if(theta == 0){
                    ActionBarAPI.sendActionBar(player, Main.colorThis("&c&lFire BARRIER SPELL &7&lACTIVATED")); 

                }
            }
            if(phi > 4*Math.PI){
                this.cancel();
            }

        }
    }.runTaskTimer(Main.getInstance(), 0, 1);
}
项目:MT_Core    文件:GeneratorListener.java   
@EventHandler
public void onLeverOrButton(PlayerInteractEvent event) {
    Block clickedBlock = event.getClickedBlock();
    Player player = event.getPlayer();

    if (clickedBlock == null)
        return;

    String chunk = clickedBlock.getLocation().getChunk().getX() + ";"
            + clickedBlock.getLocation().getChunk().getZ();
    if (event.getAction() != Action.RIGHT_CLICK_BLOCK)
        return;
    if (!powerable.containsKey(clickedBlock.getWorld().getName()))
        return;
    if (powerable.get(clickedBlock.getWorld().getName()).getList(chunk).contains(clickedBlock.getLocation()))
        return;

    // We cancel; send smoke particles for button, and we just turn off the
    // lever (if it was, for some reason, on).
    if (clickedBlock.getType() == Material.STONE_BUTTON || clickedBlock.getType() == Material.WOOD_BUTTON) {

        clickedBlock.getWorld().spawnParticle(Particle.SMOKE_NORMAL, clickedBlock.getLocation().add(0.5, 1, 0.5), 7,
                0, 0.2, 0, 0.03);
        player.sendMessage(MortuusTerraCore.NOTI_PREFIX + ChatColor.RED + " There is no generator in range!");

    } else if (clickedBlock.getType() == Material.LEVER) {
        BlockState state = clickedBlock.getState();
        Lever lever = (Lever) state.getData();

        lever.setPowered(false);
        state.setData(lever);
        state.update();
        clickedBlock.getWorld().spawnParticle(Particle.SMOKE_NORMAL, clickedBlock.getLocation().add(0.5, 1, 0.5), 7,
                0, 0.2, 0, 0.03);
        player.sendMessage(MortuusTerraCore.NOTI_PREFIX + ChatColor.RED + " There is no generator in range!");
    }

}
项目:HCFCore    文件:ElevatorListener.java   
@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;
        }
    }
}
项目:HCFCore    文件:ModeratorMode.java   
@EventHandler
public void onRightClick2(PlayerInteractEvent event)
{
    if(event.getAction().equals(Action.RIGHT_CLICK_AIR) || event.getAction().equals(Action.RIGHT_CLICK_BLOCK)) {
          Player player = event.getPlayer();
          if ((modMode.contains(player.getName())) && (player.getItemInHand().getType() == Material.FEATHER)) {
              player.chat("/v");
          }
    }
}
项目:HCFCore    文件:MinerClass.java   
/**
 * Applies the {@link MinerClass} invisibility {@link PotionEffect} depending on the {@link Player}s {@link Location}.
 *
 * @param player
 *            the {@link Player} to apply for
 * @param from
 *            the from {@link Location}
 * @param to
 *            the to {@link Location}
 */

@EventHandler(ignoreCancelled=false, priority=EventPriority.HIGH)
public void onMinerSpeedClick(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.minerSpeedCooldowns.get(uuid);
        long millis = System.currentTimeMillis();
        long remaining = timestamp == this.minerSpeedCooldowns.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 3 activated for 10 seconds.");

            this.plugin.getEffectRestorer().setRestoreEffect(player, MINER_SPEED_EFFECT);
            this.minerSpeedCooldowns.put(event.getPlayer().getUniqueId(), System.currentTimeMillis() + MINER_SPEED_COOLDOWN_DELAY);
        }
    }
}
项目:UHC    文件:HeadEatHandler.java   
@EventHandler
public void onInteract(final PlayerInteractEvent event) {
    if (event.getAction() == Action.LEFT_CLICK_AIR || event.getAction() == Action.LEFT_CLICK_BLOCK) return;

    ItemStack item = event.getItem();
    if (item instanceof PlayerheadItemStack) {
        event.setCancelled(true);
        Player player = event.getPlayer();

        //Use the item
        if (item.getAmount() > 1) item.setAmount(item.getAmount() - 1);
        else player.getInventory().remove(item);

        MainConfiguration config = UHC.getInstance().getMainConfig();

        //Give effects & crap
        PlayerheadItemStack playerhead = (PlayerheadItemStack) item;
        boolean golden = playerhead.isGolden();
        player.sendMessage(colour("&aYou ate " + playerhead.getFrom() + "'s playerhead!"));

        int regenDuration = golden ? config.getGoldenHeadRegenerationDuration() : config.getHeadRegenerationDuration();
        int regenAmpf = golden ? config.getGoldenHeadRegenerationAmplifier() : config.getHeadRegenerationAmplifier();
        int absorpDuration = golden ? config.getGoldenHeadAbsorptionDuration() : config.getHeadAbsorptionDuration();
        int absorpAmpf = golden ? config.getGoldenHeadAbsorptionAmplifier() : config.getHeadAbsorptionAmplifier();

        player.addPotionEffect(new PotionEffect(PotionEffectType.REGENERATION, regenDuration, regenAmpf, false, true));
        player.addPotionEffect(new PotionEffect(PotionEffectType.ABSORPTION, absorpDuration, absorpAmpf, false, true));
    }
}