Solved Not getting value correctly from config.yml

Discussion in 'Spigot Plugin Development' started by MaxKrissigo, Jun 30, 2016.

  1. I've debugged everything of this code but still have no idea why it isn't working. I'm currently using this code but it always returns the not yours message. Below are my code and the .yml file.
    Code (Text):
                    String name = e.getCurrentItem().getItemMeta().getDisplayName();
                    String byname = settings.getPublishedFireworks().getString(name + ".by");
                    String pname = p.getName();
                    if (pname.equals(byname)) {
                        p.sendMessage(settings.getPublishedFireworks().getString(name + ".by"));
                    } else {
                        p.sendMessage(settings.getPublishedFireworks().getString(name + ".by"));
                        p.sendMessage("not yours");
    Code (Text):
      by: MaxKrissigo
  2. Is the displayName colored?
    What is the value of byname?
  3. The displayName is not coloured, although that shouldn't matter because I'm getting the player's name not display name and the value of byname is in the code.
  4. Can we get the whole class?
    And you don't get any errors.

    And I think what @CraftBang ment was if the items displayname was colored.
  5. Ok but, when you get the String from config you use the ItemStack displayName. Try to put ChatColor.stripColors(name) before getting the String from config, just to be sure! Then... remember that the ItemMeta and the CustomName can be null so it's probabily that in certain cases you're attempt to do this pname.equals(null). Anyway, try also to debug by printing out pname and byname variables.
    • Like Like x 1
  6. After some debugging byname is null, don't really know why still because it all exists in the .yml file.
    • Like Like x 1
  7. what do you want to do with this code?
  8. I'm checking a clicked item's display name and using that get who created it from a config.yml. With the person who created it, I want to check if the person who clicked it is the person who created it.
  9. settings.getPublishedFireworks().getString(name + ".by")
    in your config,it is randomName
  10. String name = e.getCurrentItem().getItemMeta().getDisplayName(); is equal to randomName.
  11. I just started playing around with my code and I fixed it. o_O Still not sure why it wasn't working. Thanks everyone for the help.