Question about Splash Potions!

Discussion in 'Plugin Development' started by OllyHal, Jun 29, 2012.

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

    OllyHal

    Basically creating a cool down plugin for potions however when I use an event cancel on player interact event with splash potions however the potion is being removed from the inventory. Anyway to fix this?
     
  2. Offline

    EnvisionRed

    Post your code that you are using at the moment, please.
     
  3. Offline

    OllyHal

    Code:
    public void SplashPotionListener(final PlayerInteractEvent event){
        System.out.println("Testing");
     
        final Player p = event.getPlayer();
      if(p.getItemInHand().getTypeId() == 373 && (event.getAction() == Action.RIGHT_CLICK_AIR || event.getAction() == Action.RIGHT_CLICK_BLOCK )){
          System.out.println(p.getItemInHand().getTypeId());
         
    if(IsPlayerPotion.containsKey(p)){
            p.getInventory();
            System.out.println(p.getItemInHand().getType()); 
          
            p.sendMessage("You may not use this");
            event.setCancelled(true);
       
             
    }else {
       
     
              
                IsPlayerPotion.put(p, true);
        Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
         
         
        public void run() {
            IsPlayerPotion.remove(p);}}                     
           
     
    , 160L);    }
        }
       
        }
    }
     
    
     
  4. Offline

    bartboy8

    Just give the player a new one after use
     
  5. Offline

    OllyHal

    The problem with that is that you cannot retrieve potion n id
     
  6. Offline

    ftbastler

  7. Offline

    OllyHal

    I have tried that before and it will not work as I cannot get the player who has thrown it.

    Really need to find out how to perform a synchronous event when using a splash potion or finding out the id of splash potions from player interact events

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 26, 2016
  8. Offline

    Noxturno

    so after looking at the code what did you find ?
     
  9. Offline

    EnvisionRed

    It wasn't my answer but it's the one that will work.
     
Thread Status:
Not open for further replies.

Share This Page