Metadata not saving properly

Discussion in 'Plugin Development' started by TheMinecraftKnight, Apr 6, 2017.

Thread Status:
Not open for further replies.
  1. I'm trying to give an armor stand some metadata with two doubles in - Buy Price and Sell Price.
    On the creation of an armor stand (done with a command) I'm doing this to add the metadata
    armorStand.setMetadata("Buy", new FixedMetadataValue(ArmorShop.getInstance(), buyPrice+""));

    Which works fine, but (in a seperate class) the PlayerClickEvent doesn't seem to get the metadata properly.
    When I use buyPrice = Double.parseDouble(armorStand.getMetadata("Buy").toString());
    to get the metadata, it returns org.bukkit.metadata.FixedMetadataValue@....
    and so it cannot be parsed to a double.
    Why isn't this working?
     
  2. Offline

    Zombie_Striker

    @TheMinecraftKnight
    MetaData.value() should return the price.

    Also, there should be no reason to turn the double to a string. Remove the +"", the toString, and the parser.
     
  3. @Zombie_Striker How would I get MetaData.value()? MetaData isn't a class, and where would I reference the armor stand?
    Also, if I remove the double parser, I can't cast List<MetadataValue> to a double
     
  4. Offline

    Zombie_Striker

    @TheMinecraftKnight
    That line should be:
    And
    (The bold is where I made changes) I removed the +"", removed the parser and replaced it with a cast, and then called value()
     
  5. Value isn't a valid method for List<MetadataValue>
    Would iteration be necessary?
     
Thread Status:
Not open for further replies.

Share This Page