Set/Remove metadata from offline Players

Discussion in 'Plugin Development' started by MarioG1, Feb 19, 2014.

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

    MarioG1

    Is it possible to set/remove metadata from offline players?

    You can do this on online players like this:

    Code:java
    1. player.setMetadata("name", new FixedMetadataValue(plugin, value));


    but is it also possible for offline players?
     
  2. Offline

    NathanWolf

    Sadly, it looks like OfflinePlayer doesn't implement Metadatable, so... no?
     
  3. Offline

    MarioG1

  4. Offline

    NathanWolf

    Hrm- well I certainly could be wrong! What happens when you try to do it? Like this line from your linked example

    getServer().getOfflinePlayer("deltahat").setMetadata("fromOffline",newFixedMetadataValue(this,true));
     
  5. Offline

    MarioG1

    If i use Bukkit.getServer()........ I get

    Code:
      E:\xxxxxxxx\OnlineSessionCache.java:107: error: cannot find symbol
                Bukkit.getServer().getOfflinePlayer("deltahat").setMetadata("fromOffline", new FixedMetadataValue(xxxx.getInstance(), true));
      symbol:  method setMetadata(String,FixedMetadataValue)
      location: interface OfflinePlayer
    if i try to compile the code.
     
  6. Offline

    Garris0n

    Code:
     public interface OfflinePlayer extends ServerOperator, AnimalTamer, ConfigurationSerializable {
    Nope, no metadatable.
     
  7. Offline

    staniboy

    I am trying to setmetadata for spawning entities...with no luck...to be specific SkeletonType of spawning skeletons...

    Code:java
    1. import org.bukkit.Bukkit;
    2. import org.bukkit.entity.Entity;
    3. import org.bukkit.entity.Skeleton;
    4. import org.bukkit.event.EventHandler;
    5. import org.bukkit.event.Listener;
    6. import org.bukkit.event.entity.CreatureSpawnEvent;
    7. import org.bukkit.metadata.FixedMetadataValue;
    8. import org.bukkit.plugin.Plugin;
    9. import org.bukkit.plugin.java.JavaPlugin;
    10.  
    11. public class Main extends JavaPlugin implements Listener {
    12.  
    13. Plugin plugin = null;
    14.  
    15. public void onEnable(){
    16. Bukkit.getServer().getPluginManager().registerEvents(this, this);
    17. }
    18.  
    19. @EventHandler
    20. public void listener (final CreatureSpawnEvent event, Main mainInstance) {
    21. if(event.getEntity() instanceof Skeleton) {
    22. this.plugin = mainInstance;
    23. byte s = 1;
    24. Entity creature = event.getEntity();
    25. creature.setMetadata("SkeletonType", new FixedMetadataValue(plugin,s));
    26.  
    27.  
    28. }
    29.  
    30. }
    31. }

    Anyone could help?
     
Thread Status:
Not open for further replies.

Share This Page