Potion Turns pink when setting displayname

Discussion in 'Plugin Development' started by Ilomiswir, Mar 25, 2017.

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

    Ilomiswir

    Hello everyone,

    i have a problem when i set the displayname of a potion it turns pink

    if i have this he is just normal blue
    Code:
    ItemStack C2 = new ItemStack(Material.POTION, 1, (short) 0);
    ItemMeta M2 = C2.getItemMeta();
    C2.setItemMeta(M2);
    
    but when i add this line
    Code:
    M2.setDisplayName(ChatColor.WHITE+"GHB");
    the potion turns pink

    can anyone help me with this?

    EDIT: the version im using is 1.10
     
    Last edited: Mar 25, 2017
  2. Offline

    mine-care

    @Ilomiswir I don't see any reason why that would happend on the API, i think we need some more of your code.
    Also please ensure that your code complies with Java Naming Conventions!
     
  3. Offline

    Ilomiswir

    @mine-care actaully it is in the API, i made a plugin only for this to test it, and it doesn't work
     
  4. Offline

    mine-care

    @Ilomiswir This is strange, i have not heared anything similar :/
    Tried using a different server version?
     
  5. Offline

    Ilomiswir

    @mine-care i will take a look

    EDIT: 1.9, 1.10 and 1.11 it doesn't work on all of these versions
     
    Last edited: Mar 25, 2017
  6. Offline

    raunak114

    Now isn't that just a bit too weird xD?

    Maybe, if you can't fix this, there might be a way around this, using player interact events? IDK maybe is what I am saying here :D
     
  7. Offline

    Zombie_Striker

    @Ilomiswir
    Try casting the itemmeta to PotionMeta instead, and then try re-setting the potion type.
     
  8. Offline

    Ilomiswir

    @Zombie_Striker i cant find something to reset the potiontype, but when i was searching i found something "setcolor()" so i can use that, i only need the RGB from a water bottle
     
  9. Offline

    Zombie_Striker

    @Ilomiswir
    No need. Before setting the displayname, return the current color. After setting the displayname, set the color equal to the existing one.
     
  10. Offline

    Ilomiswir

    @Zombie_Striker this is very strange,
    it looks like that he already is changing the color before even setting the displayname

    when i set the color to Color.BLACK it turns black

    Code:
        ItemStack c = new ItemStack(Material.POTION, 1, (short)0);
           
            PotionMeta MD = (PotionMeta) c.getItemMeta();
            Color cf = MD.getColor();
            c.setItemMeta(MD);
           
            PotionMeta m = (PotionMeta) c.getItemMeta();
           
            m.setDisplayName(ChatColor.WHITE+"GHB");
            m.setColor(cf);
            c.setItemMeta(m);
           
            PotionMeta M = (PotionMeta) c.getItemMeta();
           
            M.setColor(cf);
            c.setItemMeta(M);
     
  11. Offline

    Ilomiswir

  12. Offline

    Ilomiswir

    bump, still didn't found it
     
Thread Status:
Not open for further replies.

Share This Page