Give a player a effect when drinking a milk

Discussion in 'Plugin Development' started by RedstonecraftHD, Jun 17, 2019.

Thread Status:
Not open for further replies.
  1. Why the player dont become the effect, but the message sends successfully

    Heres my Code:
    Code:
        @EventHandler
        public void onPlayerItemConsume(PlayerItemConsumeEvent e) {
            if(config.getBoolean("MilkEvent")) {
            Player p = e.getPlayer();
            if(e.getItem().getType().equals(Material.MILK_BUCKET)) {
                p.sendMessage("Yes");
                p.addPotionEffect(new PotionEffect(PotionEffectType.FIRE_RESISTANCE, 10 * 20, 1));
            }
            }
        }
    I hope somebody can help me
     
  2. Offline

    Kars

    Code:
    p.addPotionEffect(PotionEffectType.FIRE_RESISTANCE.createEffect(10*20, 1));
     
  3. Online

    timtower Administrator Administrator Moderator

    @RedstonecraftHD Might want to delay the adding of the effect as drinking milk stops it.
     
  4. How can I do this?
     
  5. Online

    timtower Administrator Administrator Moderator

    Start a BukkitRunnable to run a tick later.
     
Thread Status:
Not open for further replies.

Share This Page