Solved ItemStack To File

Discussion in 'Spigot Plugin Development' started by OhhhZenix, May 10, 2020.

  1. Hello there, I was wondering how I can stop ItemStack#serialize from changing color code & to \xa7.

  2. Make sure your file is encoded with UTF8
  3. how would I do that sir?
  4. If I'm correct, \xa7 changes the color of text. You'll need to somehow replace it. I'd recommend trying to get that file as a configuration (YamlConfiguration#loadConfiguration) and then setting the display name and lore to the display name and lore, but replacing \xa7 to nothing. This can be done with String#replace.

    Code (Java):
    ConfigurationSection section = config.getConfigurationSection("Items").getConfigurationSection("billy").getConfigurationSection("meta");
    section.set("display-name",section.getString("display-name").replace("\xa7", ""));
    List<String> lore = new ArrayList<>();
    for (String lore : section.getStringList("lore")){
    section.set("lore", lore);
    #4 Elier, May 10, 2020
    Last edited: May 10, 2020
  5. will the item still keep their color code? when I use ItemStack#Deserialize
  6. No. If you want to keep the color code, then keep the \xa7 part. You said in your first message that you wanted to stop color codes.

  7. Oh let me word it better. I want to stop the ItemStack#serialize from writing the color code in a HTML and rather in the regular way of &
  8. Then that is not possible unless you edit the methods or create your own methods for it.
  9. Hmmm yeah I guess, I really thought there be a way lol.