setColor() undefined for the type PotionMeta

Discussion in 'Plugin Development' started by Alexcamostyle, Jun 15, 2020.

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


    I'm trying to spawn in this custom potion, but I can't change its color:

    ItemStack item = new ItemStack(Material.POTION, 1);
    PotionMeta meta = (PotionMeta) item.getItemMeta();
    PotionEffect potion = new PotionEffect(PotionEffectType.SPEED, 2700, 0);
    meta.addCustomEffect(potion, true);
    meta.setColor(Color.AQUA);                     // This is where the problem lies
    meta.setDisplayName("§cSpeedy Potion");
    world.dropItemNaturally(loc, item);
    Eclipse gives me the error "The method setColor(Color) is undefined for the type PotionMeta", which I don't get because it should be a defined method.

    I imported org.bukkit.inventory.meta.PotionMeta

    What am I doing wrong? Thanks

    EDIT: Should mention this is for Bukkit 1.8.8
  2. Offline


    Alexcamostyle likes this.
  3. Offline


    I think the version is outdated and lacks of setColor() method.
    Alexcamostyle likes this.
  4. Offline


    Ah didn't realize thank you. Is there an alternative method to use instead? I couldn't seem to find anything on that website but there's gotta be a way to set the potion to the default colors right?
  5. Offline

    Machine Maker

    I don't know if minecraft supported custom colors for potions back in 1.8, you'd have to look that up, but if it did, then there is probably a way to do it using NMS code.
  6. Offline


    @Alexcamostyle @Machine Maker I don't think that's a possibility in earlier versions but, i believe you can work around it by making another potion (with your chosen color) with a custom name and lore.
Thread Status:
Not open for further replies.

Share This Page