Bukkit and map ids

Discussion in 'Plugin Development' started by Zupsub, Aug 24, 2014.

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

    Zupsub

    So, I'm calling Bukkit.createMap(...) to get a new map. This map as an uid (short), that is then not available for other maps/crafting/etc.

    So I'm asking how to 'free' this id? I'm going to need this map only a short time, and then acquiring a new.
    So how does bukkit manage the ids? 'Frees' it an id, if is no longer used?

    Sorry for my bad english.
     
  2. Offline

    NathanWolf

    I don't think you can. You can re-use the same map over and over, but once a map id is allocated, I don't think you can force the World to forget it.
     
  3. Offline

    Syd

    Maybe by deleting the associated file, but I'm not sure if this actually frees this ID...
     
  4. Offline

    Zupsub

    NathanWolf Syd
    Thank you both. That's sad. I looked into the world/data/ folder and there are lots of map files. So they don't get removed automatically.

    I don't want to delete files, if I'm not 100% sure it's ok to do so, especially not in a plugin. So this isn't a way.:(

    Maybe someone else has an idea?
     
  5. Offline

    NathanWolf

    Well what are you trying to do? You can't pick one map id and reuse it each time?
     
  6. Offline

    Zupsub

    I'm going to do that, but depending on the server administrator / other plugins, I have to acquire multiple maps - and I just find it bad practice to store the ids, even if I actually don't need it.
     
  7. Offline

    Syd

    Zupsub
    If you tell us what exactly you're trying to do, we might come up with a solution that saves you maps.
    Because maps are limited resources (65536 in total), it's always good to save some. ;)
     
  8. Offline

    Zupsub

    Syd
    I'm using custom MapRenderer to display information to players.

    But I feel stupid now, thinking I found the solution: the MapRender's render() method has a Player object; probably I can use one map/id and one renderer and then just decide from the player object which text needs to be displayed. If this work without performance problems, it would be so easy and I'm really stupid...
     
  9. Offline

    Syd

    Zupsub
    Yep, you can let the MapRenderer use a context. Just call super(true) in the Constructor of your MapRenderer.
    This reduces your map usage to 1. (In general, your minimal map usage is defined by the amount of unique plugin handled maps/views a player can view at once, e.g. maps in ItemFrames)

    Performancewise you should know, that the render() method is called every tick, as long someone is looking at it. For contextual maps, it's once per viewing player.
    Optimising your code in there is highly recommended.
     
Thread Status:
Not open for further replies.

Share This Page