Check if player is standing in Lingering Potion

Discussion in 'Plugin Development' started by plisov, Aug 12, 2017.

Thread Status:
Not open for further replies.
  1. Offline

    plisov

    Hi,
    I'm trying to make a plugin where when the player clicks a lingering potion is dropped and if the player is standing in the lingering potion, it will continue adding 1 integer to a number in a config. Here is what I have currently. I don't know to check to see if the player is standing in the potion or not.

    Code:
    
                    ThrownPotion potion = (ThrownPotion) player.getWorld().spawnEntity(player.getLocation(),
                            EntityType.LINGERING_POTION);
    
                    Collection<PotionEffect> effects = potion.getEffects();
                    effects.clear();
     
  2. Offline

    Caderape2

    @plisov
    - on InventoryClickEvent, check if the clicked item is a lingering potion then drop it.
    - In the event PlayerPickUpItemEvent (something like this) , check if a player is near to a lingering potion.
     
  3. @plisov
    If you mean the circle effect from lingering potion, you can obtain by the following code:
    Code:
    Player player = event.getPlayer();
    
    Collection<Entity> entities = event.getTo().getWorld().getNearbyEntities(player.getEyeLocation(), 0, -1, 0);
    
    for(Entity ent : entities) {
        if(ent.getType() == EntityType.AREA_EFFECT_CLOUD) {
            player.sendMessage(ent.getType().name());
        }
    }
     
Thread Status:
Not open for further replies.

Share This Page