(1.14.4) Custom Potion effects not working

Discussion in 'Plugin Development' started by thegoldenwool01, Jul 28, 2019.

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

    thegoldenwool01

    Im trying to make it so that players get a potion with custom effects when they join.
    It gives them the potion with the custom name when they join, but the potion doesn't have the custom effects.

    Here's my code.
    Code:
    @EventHandler
    public void onPlayerJoin(PlayerJoinEvent e) {
    Player p = e.getPlayer();
    ItemStack magic = new ItemStack(Material.POTION);
    PotionMeta magicmeta = (PotionMeta) magicgetItemMeta();
    magicmeta.setDisplayName("ยง2magic potion");
    PotionEffect effect = new PotionEffect(PotionEffectType.SLOW, 600, 1);
    PotionEffect effect2 = new PotionEffect(PotionEffectType.SLOW_FALLING, 600, 1);
    PotionEffect effect3 = new PotionEffect(PotionEffectType.INCREASE_DAMAGE, 600, 1);
    magicmeta.addCustomEffect(effect, true);
    magicmeta.addCustomEffect(effect2, true);
    magicmeta.addCustomEffect(effect3, true);
    magic.setItemMeta(magicmeta);
    p.getInventory().addItem(magic);
    p.playSound(p.getLocation(), Sound.ENTITY_VILLAGER_WORK_CLERIC, 100, 1);
    
    }
     
    Last edited by a moderator: Jul 28, 2019
Thread Status:
Not open for further replies.

Share This Page