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

项目:ZentrelaRPG    文件:NPCManager.java   
@EventHandler
public void onEntityInteract(PlayerInteractEntityEvent event) {
    if (event.getRightClicked() != null && event.getRightClicked() instanceof Villager)
        event.setCancelled(true);
    if (event.getRightClicked() != null && npcs.containsKey(event.getRightClicked().getUniqueId())) {
        event.setCancelled(true);
        Player p = event.getPlayer();
        if (plugin.getPD(p) != null) {
            if (lastClick.containsKey(p.getUniqueId())) {
                if (System.currentTimeMillis() - lastClick.get(p.getUniqueId()) < 333) {
                    return;
                }
            }
            lastClick.put(p.getUniqueId(), System.currentTimeMillis());
            npcs.get(event.getRightClicked().getUniqueId()).interact(p, plugin.getPD(p));
        }
    }
}
项目:Warzone    文件:BuildFilterType.java   
@EventHandler
public void onPlayerClickItemFram(PlayerInteractEntityEvent event) {
    if (!event.isCancelled() && event.getRightClicked() != null && event.getRightClicked() instanceof ItemFrame) {
        for (Region region : regions) {
            if (region.contains(event.getRightClicked().getLocation())) {
                for (MatchTeam matchTeam : teams) {
                    if (matchTeam.containsPlayer(event.getPlayer())) {
                        FilterResult filterResult = evaluator.evaluate(event.getPlayer());
                        if (filterResult == FilterResult.DENY) {
                            event.setCancelled(true);
                            event.getPlayer().sendMessage(message);
                        } else if (filterResult == FilterResult.ALLOW) {
                            event.setCancelled(false);
                        }
                    }
                }
            }
        }
    }
}
项目:Arcadia-Spigot    文件:MusicalMinecartsGame.java   
@EventHandler
public void onMinecartEnter(PlayerInteractEntityEvent event) {
    if(!(event.getRightClicked() instanceof Minecart)) return;
    event.getRightClicked().setGlowing(false);
    event.getPlayer().playSound(event.getPlayer().getLocation(), Sound.ENTITY_PLAYER_LEVELUP, 1f, 1f);
    inMinecarts++;
    if(inMinecarts >= this.getAPI().getGameManager().getPlayersAlive()) {
        new BukkitRunnable() {
            public void run() {
                if(getAPI().getGameManager().getGameState() != GameState.INGAME) return;
                Bukkit.getOnlinePlayers().forEach(player -> {
                    if(getAPI().getGameManager().isAlive(player)) {
                        if(player.getVehicle() == null) getAPI().getGameManager().setAlive(player, false);
                    }
                });
                nextEvent();
            }
        }.runTaskLater(this.getAPI().getPlugin(), 20L);
    }
}
项目:ProjectAres    文件:EventRuleMatchModule.java   
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void checkItemFrameRotate(PlayerInteractEntityEvent event) {
    if(event.getRightClicked() instanceof ItemFrame) {
        ItemFrame itemFrame = (ItemFrame) event.getRightClicked();
        if(itemFrame.getItem() != null) {
            // If frame contains an item, right-click will rotate it, which is handled as a "use" event
            this.handleUse(event, getHangingBlockState(itemFrame), this.match.getParticipant(event.getPlayer()));
        } else if(event.getPlayer().getItemInHand() != null) {
            // If the frame is empty and it's right clicked with an item, this will place the item in the frame,
            // which is handled as a "place" event, with the placed item as the block material
            BlockState blockState = BlockStateUtils.cloneWithMaterial(itemFrame.getLocation().getBlock(),
                                                                      event.getPlayer().getItemInHand().getData());
            this.handleHangingPlace(event, blockState, event.getPlayer());
        }
    }
}
项目:Hub    文件:GraouManager.java   
@EventHandler
public void onPlayerInteractEntity(PlayerInteractEntityEvent event)
{
    if (event.getRightClicked().getType() == EntityType.OCELOT)
    {
        if (this.lock.contains(event.getPlayer().getUniqueId()))
            return;

        // Event called twice
        this.lock.add(event.getPlayer().getUniqueId());
        this.hub.getServer().getScheduler().runTaskLater(this.hub, () -> this.lock.remove(event.getPlayer().getUniqueId()), 10L);

        for (Graou graou : this.interactions)
        {
            if (graou.getGraouEntity().getBukkitEntity().getUniqueId().equals(event.getRightClicked().getUniqueId()))
            {
                graou.play(event.getPlayer());
                break;
            }
        }
    }
}
项目:Hub    文件:MeowManager.java   
@EventHandler
public void onPlayerInteractEntity(PlayerInteractEntityEvent event)
{
    if (event.getRightClicked().getType() == EntityType.OCELOT)
    {
        if (this.lock.contains(event.getPlayer().getUniqueId()))
            return;

        // Event called twice
        this.lock.add(event.getPlayer().getUniqueId());
        this.hub.getServer().getScheduler().runTaskLater(this.hub, () -> this.lock.remove(event.getPlayer().getUniqueId()), 10L);

        for (Meow meow : this.interactions)
        {
            if (meow.getMeowEntity().getBukkitEntity().getUniqueId().equals(event.getRightClicked().getUniqueId()))
            {
                meow.play(event.getPlayer());
                break;
            }
        }
    }
}
项目:FactionsXL    文件:FMob.java   
@EventHandler
public void onInteract(PlayerInteractEntityEvent event) {
    Player player = event.getPlayer();
    Entity entity = event.getRightClicked();
    Faction faction = FactionsXL.getInstance().getFactionCache().getByLocation(entity.getLocation());
    if (faction == null) {
        return;
    }
    if (isVillager(entity)) {
        event.setCancelled(true);
        faction.getPopulationMenu().openMain(player);
    } else if (isTrader(entity)) {
        event.setCancelled(true);
        faction.getEconomyMenu().open(player);
    }
}
项目:kaosEssentials    文件:Core.java   
@EventHandler(priority=EventPriority.HIGHEST)
public void onClickFrame(PlayerInteractEntityEvent e){
    if(!(e.getRightClicked() instanceof ItemFrame)) return;
    String uuid = e.getPlayer().getUniqueId().toString();
    long curTime = System.currentTimeMillis();
    int posInList;
    if(uuidsClickItem.contains(uuid)){
        posInList = uuidsClickItem.indexOf(uuid);
        if(curTime < (lastClickItem.get(posInList) + 200)){
            e.getPlayer().sendMessage(tag + ChatColor.RED + "Please slow down clicking item frames!");
            Vector movDirection = e.getPlayer().getEyeLocation().getDirection();
            movDirection = movDirection.normalize().multiply(-2);
            e.getPlayer().setVelocity(movDirection);
            e.setCancelled(true);
        }
        if(curTime < (lastClickItem.get(posInList) + 50)){
            e.getPlayer().kickPlayer(tag + ChatColor.RED + "Please do not spam item frames!");

        }
        lastClickItem.set(posInList, curTime);
    }else{
        uuidsClickItem.add(uuid);
        lastClickItem.add(curTime);
    }
}
项目:mczone    文件:PlayerEvents.java   
@EventHandler
public void onPlayerInteractEntity(PlayerInteractEntityEvent event) {
    Player p = event.getPlayer();
    Entity t = event.getRightClicked();
    PetInstance pet = PetInstance.get(t);
    if (pet == null)
        return;

    if (pet.getOwner().equalsIgnoreCase(p.getName())) {
        if (t.getPassenger() != null) {
            t.eject();
            t.setPassenger(null);
        }
        else {
            if (!p.isInsideVehicle())
                t.setPassenger(p);
        }
    }
    else {
        Chat.player(p, "&2[Pets] &cBuy pets at www.mczone.co/shop");
    }
}
项目:UltimateSpawn    文件:BasicFeatures.java   
@EventHandler
public void onplayerinteract(PlayerInteractEntityEvent e) {
    Player p = e.getPlayer();
    if (ConfigGProtection.getConfig().getBoolean("Protection.PlayerInteractEntity-ItemFrame.Enable")) {
        if (!ConfigGProtection.getConfig().getBoolean("Protection.PlayerInteractEntity-ItemFrame.World.All_World")) {
            if (WorldUtils.getWPIEIF().contains(p.getWorld().getName())) {
                if ((e.getRightClicked() instanceof ItemFrame)) {
                    e.setCancelled(true);
                }
            }
        } else {
            if ((e.getRightClicked() instanceof ItemFrame)) {
                e.setCancelled(true);
            }
        }
    }
}
项目:NeverLag    文件:AntiVillagerTrade.java   
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void onTouchEntity(PlayerInteractEntityEvent e) {
    if (!cm.isAntiVillagerTrade) {
        return;
    }
    Entity entity = e.getRightClicked();
    if (entity == null || NeverLagUtils.checkCustomNpc(entity)) {
        return;
    }
    World world = entity.getWorld();
    if (world == null) {
        return;
    }
    if (cm.disableVillagerTradeWorld.contains(world.getName())) {
        if (entity instanceof Villager) {
            e.setCancelled(true);
        }
    }
}
项目:HCFCore    文件:ModeratorMode.java   
@EventHandler
public void rightClick(PlayerInteractEntityEvent e)
{
  if (!(e.getRightClicked() instanceof Player)) {
    return;
  }
  Player player = e.getPlayer();
  Player p = (Player)e.getRightClicked();
  if ((modMode.contains(player.getName())) && ((p instanceof Player)) && ((player instanceof Player)) && (player.getItemInHand().getType() == Material.BOOK)) {
    player.openInventory(p.getInventory());
    player.sendMessage(ChatColor.GRAY + " §6§ §rNow opening the inventory of §e" + p.getName() + ChatColor.GRAY + "§r.");
  }

  else if ((modMode.contains(player.getName())) && ((p instanceof Player)) && ((player instanceof Player)) && (player.getItemInHand().getType() == Material.PACKED_ICE)) {
    player.sendMessage(ChatColor.GRAY + " §6§ §rAttempting to freeze §e"+ p.getName() + "§r.");
      player.chat("/ss " + p.getName());
  }
}
项目:PA    文件:PlayerEvents.java   
@EventHandler(priority = EventPriority.HIGHEST)
public void onInteractEntity(PlayerInteractEntityEvent e) {
    TOAUser u = TOA.getPlayer(e.getPlayer());

    e.setCancelled(true);

    if (e.getRightClicked() instanceof Villager) {
        Villager v = (Villager) e.getRightClicked();
        if (v.getCustomName().equalsIgnoreCase("") || v.getCustomName() == null) return;

        switch (ChatColor.stripColor(v.getCustomName())) {
            case "Comprador Variado":
                TOAMenu.openMenu(u, TOAMenu.MenuType.VARIADO);
                break;
            case "Comprador Armas":
                TOAMenu.openMenu(u, TOAMenu.MenuType.ARMAS);
                break;
        }
    }
}
项目:Locked    文件:MerchantListener.java   
@EventHandler
public void onPlayerInteractEntity(PlayerInteractEntityEvent event) {
    Player player = event.getPlayer();
    Entity entity = event.getRightClicked();
    try {
        int balance = ScrapsUtil.getScraps(player);
        if (entity.getType().equals(EntityType.VILLAGER)) {
            event.setCancelled(true);
            String npc = entity.getName();
            if (MerchantManager.getAllNPCs().contains(npc)) {
                ItemStack selling = MerchantManager.getItem(npc);
                int price = MerchantManager.getPrice(npc);
                if (balance >= price) {
                    player.getInventory().addItem(selling);
                    player.sendMessage(MerchantManager.getSuccessMessage(npc));
                    ScrapsUtil.removeScraps(player, price);
                } else {
                    player.sendMessage(MerchantManager.getDenialMessage(npc));
                }
            }
        }
    } catch (SQLException e) {
        e.printStackTrace();
    }
}
项目:Sddls    文件:HorseListener.java   
@EventHandler
public void onHorseAccess(final PlayerInteractEntityEvent event) {
    if (Sddls.isHorse(event.getRightClicked())) {
        final ItemStack saddle = Sddls.getSaddle(event.getRightClicked());
        if (saddle!=null && Sddls.isSigned(saddle)) {
            if (!Sddls.hasAccess(saddle, event.getPlayer())) {
                event.setCancelled(true);
                final OfflinePlayer owner = Sddls.getOwner(saddle);
                String name = "undefined";
                if (owner!=null) {
                    if (owner.hasPlayedBefore()) {
                        name = owner.getName();
                        if (owner.isOnline())
                            name = ((Player) owner).getDisplayName();
                    } else {
                        name = owner.getUniqueId().toString();
                    }
                }
                event.getPlayer().sendMessage(ChatColor.translateAlternateColorCodes('&', Sddls.noAccessMsg.replaceAll("%owner%", name)));
            }
        }
    }
}
项目:Skript    文件:ExprClicked.java   
@Override
public boolean init(final Expression<?>[] exprs, final int matchedPattern, final Kleenean isDelayed, final ParseResult parseResult) {
    final Object type = exprs[0] == null ? null : ((Literal<?>) exprs[0]).getSingle();
    if (type instanceof EntityData) {
        entityType = (EntityData<?>) type;
        if (!ScriptLoader.isCurrentEvent(PlayerInteractEntityEvent.class)) {
            Skript.error("The expression 'clicked entity' can only be used in a click event", ErrorQuality.SEMANTIC_ERROR);
            return false;
        }
    } else {
        itemType = (ItemType) type;
        if (!ScriptLoader.isCurrentEvent(PlayerInteractEvent.class)) {
            Skript.error("The expression 'clicked block' can only be used in a click event", ErrorQuality.SEMANTIC_ERROR);
            return false;
        }
    }
    return true;
}
项目:SonarPet    文件:PetOwnerListener.java   
@EventHandler
public void onPlayerInteractEntity(PlayerInteractEntityEvent event) {
    Player p = event.getPlayer();
    Entity e = event.getRightClicked();
    if (p.getItemInHand() != null && p.getItemInHand().isSimilar(SelectorLayout.getSelectorItem())) {
        SelectorLayout.getSelectorMenu().showTo(p);
        event.setCancelled(true);
        return;
    }

    if (ReflectionUtil.getEntityHandle(e) instanceof IEntityPet) {
        IPet pet = ((IEntityPet) ReflectionUtil.getEntityHandle(e)).getPet();
        event.setCancelled(true);
        PetInteractEvent iEvent = new PetInteractEvent(pet, p, PetInteractEvent.Action.RIGHT_CLICK, false);
        EchoPet.getPlugin().getServer().getPluginManager().callEvent(iEvent);
        if (!iEvent.isCancelled()) {
            pet.getEntityPet().onInteract(p);
            return;
        }
    }
}
项目:BedwarsRel    文件:PlayerListener.java   
@EventHandler
public void onInteractEntity(PlayerInteractEntityEvent iee) {
  Player p = iee.getPlayer();
  Game g = BedwarsRel.getInstance().getGameManager().getGameOfPlayer(p);
  if (g == null) {
    return;
  }

  if (g.getState() == GameState.WAITING) {
    iee.setCancelled(true);
    return;
  }

  if (g.getState() == GameState.RUNNING) {
    this.inGameInteractEntity(iee, g, p);
  }
}
项目:RedProtect    文件:RPEntityListener.java   
@EventHandler
public void onInteractEvent(PlayerInteractEntityEvent e){
    RedProtect.get().logger.debug("RPEntityListener - Is PlayerInteractEntityEvent");
    if (e.isCancelled()) {
           return;
       }
    Player p = e.getPlayer();
    if (p == null){
        return;
    }
    Location l = e.getRightClicked().getLocation();
    Region r = RedProtect.get().rm.getTopRegion(l); 
    Entity et = e.getRightClicked();
    if (r != null && !r.canInteractPassives(p) && (et instanceof Animals || et instanceof Villager || et instanceof Golem)) {
        if (et instanceof Tameable){
            Tameable tam = (Tameable) et;
            if (tam.isTamed() && tam.getOwner() != null && tam.getOwner().getName().equals(p.getName())){
                return;
            }
        }
        e.setCancelled(true);
        RPLang.sendMessage(p, "entitylistener.region.cantinteract");
    }
}
项目:Minecraft-UAPI    文件:UItemListener.java   
@EventHandler(priority = EventPriority.HIGHEST)
public void onPlayerInteractEntityEvent(PlayerInteractEntityEvent event) {
    User user = API.to(event.getPlayer());
    if (user == null) return;
    ItemStack item = user.getItemInHand();
    UItem object = UItemManager.getInstance().getItem(item);
    if (object == null) return;

    UItemEvent result = 
            object.call(new UItemEventClick(user, object, item, false),
            object.call(new UItemEventClickEntity(user, object, item, false, event.getRightClicked()))
            );
    if (result.isCancelled()) {
        user.setItemInHand(result.getItem());
        event.setCancelled(true);
    }
}
项目:gFeatures    文件:GetMenu.java   
public void start(PlayerInteractEntityEvent event){
    Bukkit.getLogger().info(event.getPlayer().getUniqueId().toString());
    Bukkit.getLogger().info(event.getRightClicked().getUniqueId().toString());
    Bukkit.getLogger().info(Blaze.autorifles.toString());
    if(event.getRightClicked().getUniqueId().equals(Blaze.autorifles)){
        Bukkit.getLogger().info(gFeatures.getgPlayer(event.getPlayer().getUniqueId().toString()).getValue("gFactionsTier"));
        if(!(gFeatures.getgPlayer(event.getPlayer().getUniqueId().toString()).getValue("gFactionsTier").equals("autorifle"))){
            autorifle.makeInventory(event.getPlayer(), gFeatures.getgPlayer(event.getPlayer().getUniqueId().toString()));
            Blaze.invtrigger.add(event.getPlayer().getName());
        }
    }
    else if(event.getRightClicked().getUniqueId().equals(Blaze.shotguns)){

    }
    else if(event.getRightClicked().getUniqueId().equals(Blaze.snipers)){

    }
}
项目:gFeatures    文件:gFactions.java   
@Override
public void eventTrigger(Event event) {
    if(event.getEventName().equalsIgnoreCase("playerjoinevent")){

    }
    else if(event.getEventName().equalsIgnoreCase("playerentityinteractevent")){
        eh.onPlayerInteract((PlayerInteractEntityEvent)event);
    }
    else if(event.getEventName().equalsIgnoreCase("worldloadevent")){
        eh.onWorldLoad((WorldLoadEvent)event);
    }
    else if(event.getEventName().equalsIgnoreCase("EntityDamageEvent")){
        eh.onEntityDamage((EntityDamageEvent)event);
    }
    else if(event.getEventName().equalsIgnoreCase("EntityDamageByEntityEvent")){
        eh.onEntityDamage((EntityDamageByEntityEvent)event);
    }
    else if(event.getEventName().equalsIgnoreCase("entityexplodeevent")){
        eh.onEntityExplode((EntityExplodeEvent)event);
    }
    else if(event.getEventName().equalsIgnoreCase("asyncplayerchatevent")){
        eh.onPlayerChat((AsyncPlayerChatEvent)event);
    }
}
项目:PetMaster    文件:PlayerInteractListener.java   
/**
 * Change the owner of a pet.
 * 
 * @param event
 * @param oldOwner
 * @param newOwner
 */
private void changeOwner(PlayerInteractEntityEvent event, AnimalTamer oldOwner, Player newOwner) {
    if (chargePrice(event.getPlayer(), changeOwnerPrice)) {
        Tameable tameableAnimal = (Tameable) event.getRightClicked();
        // Change owner.
        tameableAnimal.setOwner(newOwner);
        event.getPlayer().sendMessage(plugin.getChatHeader()
                + plugin.getPluginLang().getString("owner-changed", "This pet was given to a new owner!"));
        newOwner.sendMessage(plugin.getChatHeader()
                + plugin.getPluginLang().getString("new-owner", "Player PLAYER gave you ownership of a pet!")
                        .replace("PLAYER", event.getPlayer().getName()));

        // Create new event to allow other plugins to be aware of the ownership change.
        PlayerChangeAnimalOwnershipEvent playerChangeAnimalOwnershipEvent = new PlayerChangeAnimalOwnershipEvent(
                oldOwner, newOwner, tameableAnimal);
        Bukkit.getServer().getPluginManager().callEvent(playerChangeAnimalOwnershipEvent);
    }
}
项目:PetMaster    文件:PlayerInteractListener.java   
/**
 * Frees a pet; it will no longer be tamed.
 * 
 * @param event
 * @param oldOwner
 */
private void freePet(PlayerInteractEntityEvent event, AnimalTamer oldOwner) {
    if (chargePrice(event.getPlayer(), freePetPrice)) {
        Tameable tameableAnimal = (Tameable) event.getRightClicked();
        // Free pet.
        tameableAnimal.setTamed(false);
        // Make freed pet stand up.
        if (version >= 12 && tameableAnimal instanceof Sittable) {
            ((Sittable) tameableAnimal).setSitting(false);
        } else if (tameableAnimal instanceof Wolf) {
            ((Wolf) tameableAnimal).setSitting(false);
        } else if (tameableAnimal instanceof Ocelot) {
            ((Ocelot) tameableAnimal).setSitting(false);
        }

        event.getPlayer().sendMessage(plugin.getChatHeader()
                + plugin.getPluginLang().getString("pet-freed", "Say goodbye: this pet returned to the wild!"));

        // Create new event to allow other plugins to be aware of the freeing.
        PlayerChangeAnimalOwnershipEvent playerChangeAnimalOwnershipEvent = new PlayerChangeAnimalOwnershipEvent(
                oldOwner, null, tameableAnimal);
        Bukkit.getServer().getPluginManager().callEvent(playerChangeAnimalOwnershipEvent);
    }
}
项目:COD-Warfare    文件:Listeners.java   
@EventHandler
public void onEntityInteract(PlayerInteractEntityEvent e) {
    if (Main.PlayingPlayers.contains(e.getPlayer()) || Main.WaitingPlayers.contains(e.getPlayer())) {
        e.setCancelled(true);
    }

    if (e.getRightClicked() instanceof Villager) {
        Villager v = (Villager) e.getRightClicked();
        if (v.getCustomName().equals("Try Guns") || v.getCustomName().equals("§b§lTry Guns")) {
            if (Main.WaitingPlayers.contains(e.getPlayer())) {
                Player p = e.getPlayer();
                v.setCustomName("§b§lTry Guns");
                v.setCustomNameVisible(true);
                p.openInventory(Guns.tryGunsInventory);
            } else {
                e.setCancelled(true);
                e.getPlayer().sendMessage(Main.codSignature + "§cYou may only try guns when in COD-Warfare");
            }
        }
    }
}
项目:Bukkit-EQC    文件:EQCListener.java   
@EventHandler()
public void BlackHoleEntityInteract(PlayerInteractEntityEvent ev) {
    ItemStack item = ev.getPlayer().getItemInHand();

    if (StockItems.BlackHole().equals(item) && ev.getRightClicked().getType() != EntityType.PLAYER) {
        ev.setCancelled(true);

        Entity e = ev.getRightClicked();
        Player p = ev.getPlayer();
        UUID key = p.getUniqueId();
        if (!carrymap.containsKey(key)) {
            carrymap.put(key, e);
            e.teleport(playerSight(p));
        }
    }
}
项目:civcraft    文件:CustomItemManager.java   
@EventHandler(priority = EventPriority.LOW) 
public void onInteractEntity(PlayerInteractEntityEvent event) {
    if (event.isCancelled()) {
        return;
    }

    ItemStack stack = event.getPlayer().getItemInHand();
    if (stack == null) {
        return;
    }

    LoreMaterial material = LoreMaterial.getMaterial(stack);
    if (material != null) {
        material.onInteractEntity(event);
    }

}
项目:well-auction    文件:AuctionEntityShopListener.java   
/**
 * On player interact.
 * 
 * @param evt
 *            the evt
 */
@EventHandler
public void onPlayerInteract(PlayerInteractEntityEvent evt) {

    EntityShopEntity shopEntity = EntityShopEntity.forEntity(evt.getRightClicked());

    if (shopEntity != null) {
        evt.setCancelled(true);
        Player player = evt.getPlayer();

        try {
            shopEntityManager.open(shopEntity, player);
        } catch (WellPermissionException e) {
            plugin.getLogger().log(Level.INFO, String.format("%s couldn't open auction house (%s)", player.getName(), e.getKey()));
        }
    }
}
项目:Factoid    文件:PlayerListener.java   
/**
 * On player interact entity.
 * 
 * @param event
 *            the event
 */
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onPlayerInteractEntity(PlayerInteractEntityEvent event) {
    if (!playerConf.get(event.getPlayer()).isAdminMod()
            && event.getRightClicked() instanceof ItemFrame) {

        Player player = (Player) event.getPlayer();
        IDummyLand land = Factoid.getThisPlugin().iLands().getLandOrOutsideArea(
                event.getRightClicked().getLocation());

        if ((land instanceof ILand && ((ILand) land).isBanned(player))
                || !checkPermission(land, player,
                        PermissionList.BUILD.getPermissionType())
                || !checkPermission(land, player,
                        PermissionList.BUILD_PLACE.getPermissionType())) {
            messagePermission(player);
            event.setCancelled(true);
        }
    }
}
项目:parchment    文件:GlobalListenerHeavy.java   
@EventHandler
public void onPlayerInteractEntity(PlayerInteractEntityEvent event) {
    /*
       if (event.getPlayer().getItemInHand().getType() == Material.STRING) {
           if (event.getRightClicked() instanceof Wolf) {
               Wolf wolf = (Wolf) event.getRightClicked();
               plugin.debugMessage("Is tamed: " + wolf.isTamed());
               plugin.debugMessage("Owner: " + wolf.getOwner());
               wolf.setTamed(wolf.isTamed() ? false : true);
               plugin.debugMessage("Is tamed: " + wolf.isTamed());
               plugin.debugMessage("Owner: " + wolf.getOwner());
           }
           event.getPlayer().setItemInHand(null);
       }
    */
    plugin.handleEvent(event);
}
项目:UltimateSurvivalGames    文件:PlayerListener.java   
@EventHandler
public void onPlayerRightClick(PlayerInteractEntityEvent event) {
    User user = um.getUser(event.getPlayer().getName());
    if(user != null) {
        GameState state = user.getGame().getState();
        if(event.getRightClicked() instanceof ItemFrame || state == GameState.WAITING || state == GameState.VOTING || state == GameState.COOLDOWN) {
            event.setCancelled(true);
        }
    } else {
        for(Game game : SurvivalGames.gameManager.getGames()) {
            for(Arena arena : game.getArenas()) {
                if(arena.containsBlock(event.getRightClicked().getLocation()))
                    event.setCancelled(true);
            }
        }
    }

}
项目:Dexoria-Hub    文件:Interact.java   
@EventHandler
public void i(PlayerInteractEntityEvent e){
    Player p = e.getPlayer();
    Entity ent = e.getRightClicked();

    if(!(ent instanceof Villager)){
        return;
    }
    e.setCancelled(true);
    Villager v = (Villager) ent;

    if(v.getCustomName().equalsIgnoreCase(ChatColor.RED + "" + ChatColor.BOLD + "Mineageddon")){
        p.sendMessage(ChatColor.AQUA + "" + ChatColor.BOLD + "--------" + ChatColor.RED + "" + ChatColor.BOLD + "Mineageddon" + ChatColor.AQUA + "" + ChatColor.BOLD + "--------");
        p.sendMessage(ChatColor.BLUE + "Description: " + ChatColor.GRAY + "Use our amazing custom items to kill other players whilst destorying everything!");
        p.sendMessage(ChatColor.BLUE + "Category: " + ChatColor.GRAY + "Kit PvP");
        p.sendMessage(ChatColor.BLUE + "Coded by: " + ChatColor.GRAY + "nxsupert");
        p.sendMessage(ChatColor.AQUA + "" + ChatColor.BOLD + "------------------" + ChatColor.AQUA + "" + ChatColor.BOLD + "--------");
    }   
}
项目:NamedProtect    文件:InteractListener.java   
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onFeed(PlayerInteractEntityEvent event){

    //Return when entity not allow to protect.
    if(!isProtectList(event.getRightClicked().getType())){
        event.getPlayer().sendMessage("[NP] this entiyt is not allow to protect.");
        return;
    }

    //Cancel event when Entity is protected.
    String customName = ((LivingEntity)event.getRightClicked()).getCustomName();
    if(customName != null){
        if(!isOwner(customName, event.getPlayer().getName())){
            event.getPlayer().sendMessage("[NP] you can't rename entity owned by other.");
            event.setCancelled(true);
            return;
        }
    }

}
项目:PrisonPolice    文件:PrisonPoliceListener.java   
@EventHandler
public void jailStickHandling(PlayerInteractEntityEvent event) {
    if (!(event.getRightClicked() instanceof Player))
        return;

    Player policeman = event.getPlayer();
    Player criminal = (Player) event.getRightClicked();

    if (plugin.getConfig().getList("batons")
            .contains(policeman.getItemInHand().getType().toString())) {
        if (policeman.hasPermission("prisonpolice.stick")) {
            if (criminal.hasPermission("prisonpolice.fugitive")
                    || plugin.sql.isOnList(criminal.getUniqueId())) {
                policeman.sendMessage("You've managed to arrest "
                        + criminal.getName() + ".");
                criminal.sendMessage("You've been arrested. Have fun back in jail, criminal scum.");
                plugin.jailCommands(policeman, criminal);
                plugin.sql.removeEvidenceList(criminal.getUniqueId());
            }
        } else {
        }
    }
}
项目:BetonQuest    文件:QuestItemHandler.java   
@SuppressWarnings("deprecation")
   @EventHandler
public void onItemFrameClick(PlayerInteractEntityEvent event) {
    if (event.getPlayer().getGameMode() == GameMode.CREATIVE) {
        return;
    }
    // this prevents the journal from being placed inside of item frame
    if (event.getRightClicked() instanceof ItemFrame) {
        ItemStack item = null;
        try {
            item = (event.getHand() == EquipmentSlot.HAND) ? event.getPlayer().getInventory().getItemInMainHand() : event.getPlayer().getInventory().getItemInOffHand();
        } catch (LinkageError e) {
            item = event.getPlayer().getItemInHand();
        }
        String playerID = PlayerConverter.getID(event.getPlayer());
        if (Journal.isJournal(playerID, item) || Utils.isQuestItem(item)) {
            event.setCancelled(true);
        }
    }
}
项目:RandomStuff    文件:randomStuff.java   
@EventHandler
public void PlayerRightClick(PlayerInteractEntityEvent event)
{
    if(event.getRightClicked() instanceof Villager)
    {
        Player p = event.getPlayer();
        if(p.getInventory().getHelmet() != null) {
            p.getInventory().getHelmet().setDurability((short) 0);
        }
        if(p.getInventory().getChestplate() != null){
            p.getInventory().getChestplate().setDurability((short) 0);
        }
        if(p.getInventory().getLeggings() != null) {
            p.getInventory().getLeggings().setDurability((short) 0);
        }
        if(p.getInventory().getLeggings() != null) {
            p.getInventory().getBoots().setDurability((short) 0);
        }
    }
}
项目:sensibletoolbox    文件:EnderLeash.java   
@Override
public void onInteractEntity(PlayerInteractEntityEvent event) {
    Entity target = event.getRightClicked();
    Player player = event.getPlayer();
    if (target instanceof Animals && isPassive(target) && player.getItemInHand().getAmount() == 1) {
        if (capturedConf == null || !capturedConf.contains("type")) {
            Animals animal = (Animals) target;
            if (!checkLeash(animal)) {
                STBUtil.complain(player, "Can't capture a leashed animal!");
            } else if (!verifyOwner(player, animal)) {
                STBUtil.complain(player, "This animal is owned by someone else!");
            } else {
                capturedConf = freezeEntity(animal);
                target.getWorld().playEffect(target.getLocation(), Effect.ENDER_SIGNAL, 0);
                target.remove();
                player.setItemInHand(this.toItemStack());
            }
        } else {
            // workaround CB bug to ensure client is updated properly
            STBUtil.complain(event.getPlayer(), "Ender Leash already has a captured animal");
            player.updateInventory();
        }
    }
    event.setCancelled(true);
}
项目:SR-PlayerRider    文件:PlayerListener.java   
@EventHandler
public void onPlayerClicked (final PlayerInteractEntityEvent event) {
    final Player player = event.getPlayer();
    if (event.getRightClicked() instanceof Player) {
        final Player target = (Player) event.getRightClicked();
        if (!duckEjectPassenger(player, target) && playerCanRide(player)) {
            Player vehicle = getVehicle(player);
            if (vehicle == null) {
                vehicle = (Player) event.getRightClicked();
                Player duck = getRootVehicle(vehicle);
                getLastPassenger(vehicle).setPassenger(player);
                Util.message(player, "&7%PLAYER%が%TARGET%に乗りました!"
                        .replace("%PLAYER%", player.getName())
                        .replace("%TARGET%", target.getName()));
                Util.message((Player) target, "&7%PLAYER%が%TARGET%に乗りました!"
                        .replace("%PLAYER%", player.getName())
                        .replace("%TARGET%", target.getName()));
            } else {
                vehicle.eject();
            }
        }
    }
}
项目:CraftoPlugin    文件:ContextModule.java   
@EventHandler
public void onPlayerInteractAtEntity(final PlayerInteractAtEntityEvent event) { // TEST
    try {
        if (event.getPlayer() == null || event.getRightClicked() == null) { return; }

        if (!this.entityHandlers.isEmpty() && !event.isCancelled()) {
            final Menu menu = new Menu("Kontextmen�: " + event.getRightClicked().getType());

            for (final BiConsumer<PlayerInteractEntityEvent, Menu> consumer : this.entityHandlers) {
                try { consumer.accept(event, menu); }
                catch (final Exception e) { CraftoMessenger.report(this.getClass(), "A playerinteractATentityevent consumer ("+consumer+") got an exception!", e); }
            }

            if (!menu.isEmpty()) {
                menu.show(event.getPlayer());
                event.setCancelled(true);
                event.getPlayer().playSound(event.getPlayer().getLocation(), Sound.BLOCK_WOODEN_DOOR_OPEN, 1.0f, 2.0f);
            }
        }
    }
    catch (Exception outsideException) { CraftoMessenger.report(getClass(), "Failed to handle PlayerInteractEntityEvent!", outsideException); }
}
项目:CraftoPlugin    文件:ContextModule.java   
@EventHandler
public void onPlayerInteractWithEntity(final PlayerInteractEntityEvent event) {
    try {
        if (!this.entityHandlers.isEmpty() && !event.isCancelled()) {
            final Menu menu = new Menu("Kontextmen�: " + event.getRightClicked().getType());

            for (final BiConsumer<PlayerInteractEntityEvent, Menu> consumer : this.entityHandlers) {
                try { consumer.accept(event, menu); }
                catch (final Exception e) { CraftoMessenger.report(this.getClass(), "A playerinteractentityevent consumer ("+consumer+") got an exception!", e); }
            }

            if (!menu.isEmpty()) {
                menu.show(event.getPlayer());
                event.setCancelled(true);
                event.getPlayer().playSound(event.getPlayer().getLocation(), Sound.BLOCK_WOODEN_DOOR_OPEN, 1.0f, 2.0f);
            }
        }
    }
    catch (Exception outsideException) { CraftoMessenger.report(getClass(), "Failed to handle PlayerInteractEntityEvent!", outsideException); }
}