Package org.bukkit.map
Interface MapCanvas
public interface MapCanvas
Represents a canvas for drawing to a map. Each canvas is associated with a
specific
MapRenderer
and represents that renderer's layer on the
map.-
Method Summary
Modifier and TypeMethodDescriptionvoid
Draw an image to the map.void
Render text to the map using fancy formatting.byte
getBasePixel
(int x, int y) Deprecated, for removal: This API element is subject to removal in a future version.getBasePixelColor
(int x, int y) Get a pixel from the layers below this canvas.Get the cursor collection associated with this canvas.Get the map this canvas is attached to.byte
getPixel
(int x, int y) Deprecated, for removal: This API element is subject to removal in a future version.getPixelColor
(int x, int y) Get a pixel from the canvas.void
setCursors
(@NotNull MapCursorCollection cursors) Set the cursor collection associated with this canvas.void
setPixel
(int x, int y, byte color) Deprecated.Magic value, usesetPixelColor(int, int, Color)
void
setPixelColor
(int x, int y, @Nullable Color color) Draw a pixel to the canvas.
-
Method Details
-
getMapView
Get the map this canvas is attached to.- Returns:
- The MapView this canvas is attached to.
-
getCursors
Get the cursor collection associated with this canvas.- Returns:
- The MapCursorCollection associated with this canvas.
-
setCursors
Set the cursor collection associated with this canvas. This does not usually need to be called since a MapCursorCollection is already provided.- Parameters:
cursors
- The MapCursorCollection to associate with this canvas.
-
setPixelColor
Draw a pixel to the canvas.The provided color might be converted to another color, which is in the map color range. This means, that
getPixelColor(int, int)
might return another color than set. If null is used as color, then the color returned bygetBasePixelColor(int, int)
is shown on the map.- Parameters:
x
- The x coordinate, from 0 to 127.y
- The y coordinate, from 0 to 127.color
- The color.
-
getPixelColor
Get a pixel from the canvas. If no color is set at the given position for this canvas, then null is returned and the color returned bygetBasePixelColor(int, int)
is shown on the map.- Parameters:
x
- The x coordinate, from 0 to 127.y
- The y coordinate, from 0 to 127.- Returns:
- The color, or null if no color is set.
-
getBasePixelColor
Get a pixel from the layers below this canvas.- Parameters:
x
- The x coordinate, from 0 to 127.y
- The y coordinate, from 0 to 127.- Returns:
- The color.
-
setPixel
void setPixel(int x, int y, byte color) Deprecated.Magic value, usesetPixelColor(int, int, Color)
Draw a pixel to the canvas.- Parameters:
x
- The x coordinate, from 0 to 127.y
- The y coordinate, from 0 to 127.color
- The color. SeeMapPalette
.
-
getPixel
Deprecated, for removal: This API element is subject to removal in a future version.Get a pixel from the canvas.- Parameters:
x
- The x coordinate, from 0 to 127.y
- The y coordinate, from 0 to 127.- Returns:
- The color. See
MapPalette
.
-
getBasePixel
Deprecated, for removal: This API element is subject to removal in a future version.Get a pixel from the layers below this canvas.- Parameters:
x
- The x coordinate, from 0 to 127.y
- The y coordinate, from 0 to 127.- Returns:
- The color. See
MapPalette
.
-
drawImage
Draw an image to the map. The image will be clipped if necessary.- Parameters:
x
- The x coordinate of the image.y
- The y coordinate of the image.image
- The Image to draw.
-
drawText
Render text to the map using fancy formatting. Newline (\n) characters will move down one line and return to the original column, and the text color can be changed using sequences such as "ยง12;", replacing 12 with the palette index of the color (seeMapPalette
).- Parameters:
x
- The column to start rendering on.y
- The row to start rendering on.font
- The font to use.text
- The formatted text to render.
-
getBasePixelColor(int, int)