java类org.bukkit.event.player.PlayerInteractEntityEvent的实例源码

NPCManager.java 文件源码 项目:ZentrelaRPG 阅读 26 收藏 0 点赞 0 评论 0
@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));
        }
    }
}
BuildFilterType.java 文件源码 项目:Warzone 阅读 25 收藏 0 点赞 0 评论 0
@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);
                        }
                    }
                }
            }
        }
    }
}
MusicalMinecartsGame.java 文件源码 项目:Arcadia-Spigot 阅读 21 收藏 0 点赞 0 评论 0
@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);
    }
}
EventRuleMatchModule.java 文件源码 项目:ProjectAres 阅读 31 收藏 0 点赞 0 评论 0
@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());
        }
    }
}
GraouManager.java 文件源码 项目:Hub 阅读 20 收藏 0 点赞 0 评论 0
@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;
            }
        }
    }
}
MeowManager.java 文件源码 项目:Hub 阅读 17 收藏 0 点赞 0 评论 0
@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;
            }
        }
    }
}
FMob.java 文件源码 项目:FactionsXL 阅读 19 收藏 0 点赞 0 评论 0
@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);
    }
}
Core.java 文件源码 项目:kaosEssentials 阅读 19 收藏 0 点赞 0 评论 0
@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);
    }
}
PlayerEvents.java 文件源码 项目:mczone 阅读 31 收藏 0 点赞 0 评论 0
@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");
    }
}
BasicFeatures.java 文件源码 项目:UltimateSpawn 阅读 27 收藏 0 点赞 0 评论 0
@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);
            }
        }
    }
}
AntiVillagerTrade.java 文件源码 项目:NeverLag 阅读 27 收藏 0 点赞 0 评论 0
@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);
        }
    }
}
ModeratorMode.java 文件源码 项目:HCFCore 阅读 24 收藏 0 点赞 0 评论 0
@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());
  }
}
PlayerEvents.java 文件源码 项目:PA 阅读 30 收藏 0 点赞 0 评论 0
@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;
        }
    }
}
MerchantListener.java 文件源码 项目:Locked 阅读 25 收藏 0 点赞 0 评论 0
@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();
    }
}
HorseListener.java 文件源码 项目:Sddls 阅读 22 收藏 0 点赞 0 评论 0
@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)));
            }
        }
    }
}
ExprClicked.java 文件源码 项目:Skript 阅读 23 收藏 0 点赞 0 评论 0
@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;
}
PetOwnerListener.java 文件源码 项目:SonarPet 阅读 20 收藏 0 点赞 0 评论 0
@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;
        }
    }
}
PlayerListener.java 文件源码 项目:BedwarsRel 阅读 22 收藏 0 点赞 0 评论 0
@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);
  }
}
RPEntityListener.java 文件源码 项目:RedProtect 阅读 31 收藏 0 点赞 0 评论 0
@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");
    }
}
UItemListener.java 文件源码 项目:Minecraft-UAPI 阅读 30 收藏 0 点赞 0 评论 0
@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);
    }
}
GetMenu.java 文件源码 项目:gFeatures 阅读 22 收藏 0 点赞 0 评论 0
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)){

    }
}
gFactions.java 文件源码 项目:gFeatures 阅读 19 收藏 0 点赞 0 评论 0
@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);
    }
}
PlayerInteractListener.java 文件源码 项目:PetMaster 阅读 29 收藏 0 点赞 0 评论 0
/**
 * 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);
    }
}
PlayerInteractListener.java 文件源码 项目:PetMaster 阅读 32 收藏 0 点赞 0 评论 0
/**
 * 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);
    }
}
Listeners.java 文件源码 项目:COD-Warfare 阅读 22 收藏 0 点赞 0 评论 0
@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");
            }
        }
    }
}
EQCListener.java 文件源码 项目:Bukkit-EQC 阅读 26 收藏 0 点赞 0 评论 0
@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));
        }
    }
}
CustomItemManager.java 文件源码 项目:civcraft 阅读 22 收藏 0 点赞 0 评论 0
@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);
    }

}
AuctionEntityShopListener.java 文件源码 项目:well-auction 阅读 21 收藏 0 点赞 0 评论 0
/**
 * 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()));
        }
    }
}
PlayerListener.java 文件源码 项目:Factoid 阅读 23 收藏 0 点赞 0 评论 0
/**
 * 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);
        }
    }
}
GlobalListenerHeavy.java 文件源码 项目:parchment 阅读 22 收藏 0 点赞 0 评论 0
@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);
}


问题


面经


文章

微信
公众号

扫码关注公众号