Player Interact Event - Get Potion Effect

Discussion in 'Plugin Development' started by Hausbauer, Nov 8, 2015.

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

    Hausbauer

    Hello,

    on writing a Varo Plugin, I want a easy Anti-Potion System. I want, that the Player will get kicked if he click for example on to the Strenght Potion. But I did'nt find a way to get the Potion Type in the Player Interact Event. I just have found the Material Potoin. Do you know how to do this?

    PS: If you know a bether and easier way to disable some potions please tell it.
     
  2. Online

    timtower Administrator Administrator Moderator

  3. Offline

    FreeMotion45

    You can use :

    Code:
    player.removePotionEffect()
    At least I think that's how you do it.
     
  4. Offline

    Hausbauer

    @FreeMotion45
    No, I want to check if the Player CLICK on the potion. With the code
    Code:
    @EventHandler
       public void PlayerInteractEvent(org.bukkit.event.player.PlayerInteractEvent e) {
         if(e.getAction()== Action.LEFT_CLICK_AIR || e.getAction()== Action.LEFT_CLICK_BLOCK) {
           if(e.getMaterial().equals(Material.POTION)) {
             Item i = (Item) e.getItem();
             Potion p = (Potion) e.getItem().getType().;
             //How can I check if the Potion is a Strengh Potion or a Weakness Potion or ....
    
           }
         }
       }
    
    Or isn't there any way?
     
  5. Offline

    CoolDude53

    @Hausbauer

    Code:
    Potion potion = Potion.fromItemStack(item);
     
  6. Offline

    Hausbauer

    Thank you CoolDude53
     
Thread Status:
Not open for further replies.

Share This Page