Interface MapManager
public interface MapManager
Creates and finds maps, and makes what plugins draw on them: canvases,
images, fonts and layers.
Maps are saved with the world, in data/minecraft/maps, under the same ids and in the
same format as vanilla, so maps made on a vanilla server keep working. They are loaded the first
time someone needs them and unloaded once nobody has looked at them for a while.
- Since:
- 0.1.0
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionintalignedCenter(int coordinate, MapScale scale) Snaps a coordinate to the center of the grid cell it falls in, as vanilla does for new maps, so that maps of the same scale tile the world without overlapping.Returns the color a block is drawn with on terrain maps.Creates a map of the terrain of a world, drawn as players carrying it explore.Creates a map that shows no world: a blank canvas for plugins to draw on.Creates a canvas that belongs to no map, filled with transparent pixels.Creates a blank map that is never saved, for content that only makes sense while the server runs: a game screen, a live chart.voidDeletes a map: its file for a saved map, its id for a temporary one.intdirectionOf(float yaw) Converts a yaw to the direction of an icon.fontBuilder(int lineHeight, int ascent) Starts a font of your own.get(int id) Finds a map, loading it from disk if needed.image(int width, int height, byte[] pixels) Wraps pixels that are already map pixels.image(int width, int height, int[] argb, MapImage.Dithering dithering) Converts colors to map pixels.image(BufferedImage image, int width, int height, MapImage.Dithering dithering) Scales a picture, then converts it to map pixels.image(BufferedImage image, MapImage.Dithering dithering) Converts a picture to map pixels, at its own size.layer(MapLayer.Scope scope, int repaintInterval, Consumer<MapLayer.Context> painter) Creates a layer from a painter.loaded()Returns the maps currently in memory.lockedCopy(MapView source) Copies a map as a cartography table locks it: a new map with the same pixels and markers whose terrain never changes again.Finds the map an item shows.palette()Returns the colors of map pixels.Returns the built-in font: proportional, 7 pixels high, with the accents of Western European languages above capitals.Makes the zoomed out version of a map, as a cartography table with paper does: a new, empty map of the next scale, centered on the grid cell holding the old center.
-
Method Details
-
create
Creates a map of the terrain of a world, drawn as players carrying it explore.- Parameters:
world- the worldcenterX- the X coordinate of the block at the centercenterZ- the Z coordinate of the block at the centerscale- how many blocks a pixel covers- Returns:
- the new map, saved with the world
- Since:
- 0.1.0
- See Also:
-
createBlank
MapView createBlank()Creates a map that shows no world: a blank canvas for plugins to draw on.- Returns:
- the new map, saved with the world
- Since:
- 0.1.0
-
createTemporary
MapView createTemporary()Creates a blank map that is never saved, for content that only makes sense while the server runs: a game screen, a live chart. Its id is taken from the top of the id range, far from the ids of saved maps, and given back bydelete(MapView).- Returns:
- the new map
- Since:
- 0.1.0
-
get
-
of
-
loaded
Collection<MapView> loaded()Returns the maps currently in memory.- Returns:
- the maps currently in memory
- Since:
- 0.1.0
-
delete
Deletes a map: its file for a saved map, its id for a temporary one. Items still showing it show an unknown map.- Parameters:
view- the map- Since:
- 0.1.0
-
lockedCopy
-
zoomedOut
Makes the zoomed out version of a map, as a cartography table with paper does: a new, empty map of the next scale, centered on the grid cell holding the old center.- Parameters:
source- the map to zoom out- Returns:
- the new map; a copy of the same scale if the source is already the widest
- Since:
- 0.1.0
-
colorOf
Returns the color a block is drawn with on terrain maps.That is the color given by the behaviour of the block if it gives one, or the vanilla one.
- Parameters:
block- a block state- Returns:
- its color,
MapColor.NONEfor blocks that maps look through - Since:
- 0.1.0
-
palette
MapPalette palette()Returns the colors of map pixels.- Returns:
- the colors of map pixels
- Since:
- 0.1.0
-
createCanvas
-
image
Wraps pixels that are already map pixels.- Parameters:
width- the width, at least1height- the height, at least1pixels-width * heightmap pixels, row by row; copied- Returns:
- the image
- Since:
- 0.1.0
-
image
Converts colors to map pixels. Colors with an alpha below128become transparent, the others take the closest map color.- Parameters:
width- the width, at least1height- the height, at least1argb-width * heightcolors as0xAARRGGBB, row by rowdithering- how to approximate colors- Returns:
- the image
- Since:
- 0.1.0
-
image
Converts a picture to map pixels, at its own size.- Parameters:
image- the picturedithering- how to approximate colors- Returns:
- the image
- Since:
- 0.1.0
-
image
Scales a picture, then converts it to map pixels. To fill a wall ofn×mmaps, scale to128n×128mand cut the result into tiles.- Parameters:
image- the picturewidth- the width to scale to, at least1height- the height to scale to, at least1dithering- how to approximate colors- Returns:
- the image
- Since:
- 0.1.0
-
standardFont
MapFont standardFont()Returns the built-in font: proportional, 7 pixels high, with the accents of Western European languages above capitals.- Returns:
- the built-in font: proportional, 7 pixels high, with the accents of Western European languages above capitals
- Since:
- 0.1.0
-
fontBuilder
Starts a font of your own.- Parameters:
lineHeight- how many pixels apart lines are, at least1ascent- how many pixels below the top of a line glyph row0is, at least0- Returns:
- the builder
- Since:
- 0.1.0
-
layer
Creates a layer from a painter.- Parameters:
scope- for whom it is paintedrepaintInterval- repaint every that many ticks;0only repaints onMapView.repaint()and, for a per-viewer layer, when someone starts seeing the mappainter- what to paint- Returns:
- the layer, to add to maps
- Since:
- 0.1.0
-
alignedCenter
Snaps a coordinate to the center of the grid cell it falls in, as vanilla does for new maps, so that maps of the same scale tile the world without overlapping.- Parameters:
coordinate- a block X or Z coordinatescale- the scale of the map- Returns:
- the X or Z of the center of the map covering that coordinate
- Since:
- 0.1.0
-
directionOf
int directionOf(float yaw) Converts a yaw to the direction of an icon.- Parameters:
yaw- a yaw in degrees, as in a location:0faces south,90west- Returns:
- the direction a player arrow must have to point the same way on a terrain map
- Since:
- 0.1.0
-