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.
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.
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?
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.
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.
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...
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.