Solved Mob Info?

Discussion in 'Plugin Development' started by Elimnator, Oct 25, 2014.

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

    Elimnator

    Is there any way to put meta-data or tags or somthing on a mob?
     
  2. Offline

    JjPwN1

    To give metadata to an entity:
    Code:java
    1. entity.setMetadata("myMetadata", new FixedMetadataValue(plugin, object));

    To retrieve metadata:
    Code:java
    1. String value = null;
    2. for(MetadataValue v : entity.getMetadata("myMetadata")){
    3. value = v.asString();
    4. }
     
  3. Offline

    Elimnator

    JjPwN1
    The meta data is not staying after a server restart.

    Is there a way to make it save over restarts?
     
  4. Offline

    teej107

    Elimnator Save the data to a Collection or Map, save the Collection or Map to a file on plugin disable, reload from file on server start and re-apply metadata?
     
  5. Offline

    RingOfStorms

    A mob will also not necessarily be there after restart, they could despawn. Metadata is temporary, if you want persistence over restarts you'll need to save to the disk, then check when creatures are spawned back in to see when to apply the data again.
     
  6. Offline

    Elimnator

Thread Status:
Not open for further replies.

Share This Page