RadioBoard
RadioBoard copied to clipboard
Could not create board which id is much larger than the previous id
Bug reproduce
- Install a new server (ensure that the server folder does not contain the world)
- Install the plugin
- Use
/radioboard board create example 0
to create new board - Use
/radioboard board create example-1 1000
to create another new board with id1000
- Use
/radioboard display create example-1 1000 example-canvas.yml 6 6
to create a new display with same id1000
- Seen nothing on the board
- Middle click to one of the item frame and get map, you will find the map id is between 36 to 71 instead of the 1000 just defined
- Use
/radioboard board create example-2 73
to create another new board with id73
(not start with next 72) - Use
/radioboard display create example-2 73 example-canvas.yml 6 6
to create a new display with same id73
- Seen confused image on this board
- Middle click to one of the item frame and get map, you will find the map id is between 72 to 107 instead of the 73 just defined
Screenshort
The left one was example, middle one was example-1, right was example-2
Description
It seems like map can only generate in order and not according to the command definition, i tried to find where the problem happened, and i think that is in NMSHandler.getMapItem(int id)
, i added a log output in this method:
@Override
public ItemStack getMapItem( int id ) {
ItemStack map = new ItemStack( Material.FILLED_MAP );
MapMeta meta = ( MapMeta ) map.getItemMeta();
meta.setMapId( id );
map.setItemMeta( meta );
// log output i added
RadioBoard.getInstance().getServer().getLogger().info(this.getClass().getName() + ": Map has been make itemstack with id " + id);
return map;
}
And i can see the id that printed in console was i defined, the code of this plugin has no problems, but MapMeta.setMapId did not works. In spigot java doc, this method have marked as deprecated
Deprecated. These methods are poor API: They rely on the caller to pass in an only an integer property, and have poorly defined implementation behavior if that integer is not a valid map (the current implementation for example will generate a new map with a different ID). The xxxMapView family of methods should be used instead.
In NMSHandler.registerMap(int id)
method, Bukkit.getMap(int)
was deprecated too.