SPIGOT-5984: Add non deprecated / magic value way to set pixel in MapCanvas

This commit is contained in:
DerFrZocker 2022-06-09 21:27:21 +10:00 committed by md_5
parent 20caf8ff2d
commit 830db7d55f
No known key found for this signature in database
GPG key ID: E8E901AC7C617C11

View file

@ -1,5 +1,6 @@
package org.bukkit.map; package org.bukkit.map;
import java.awt.Color;
import java.awt.Image; import java.awt.Image;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
@ -35,12 +36,47 @@ public interface MapCanvas {
*/ */
public void setCursors(@NotNull MapCursorCollection cursors); public void setCursors(@NotNull MapCursorCollection cursors);
/**
* Draw a pixel to the canvas.
* <p>
* The provided color might be converted to another color,
* which is in the map color range. This means, that
* {@link #getPixelColor(int, int)} might return another
* color than set.
*
* @param x The x coordinate, from 0 to 127.
* @param y The y coordinate, from 0 to 127.
* @param color The color.
*/
void setPixelColor(int x, int y, @NotNull Color color);
/**
* Get a pixel from the canvas.
*
* @param x The x coordinate, from 0 to 127.
* @param y The y coordinate, from 0 to 127.
* @return The color.
*/
@NotNull
Color getPixelColor(int x, int y);
/**
* Get a pixel from the layers below this canvas.
*
* @param x The x coordinate, from 0 to 127.
* @param y The y coordinate, from 0 to 127.
* @return The color.
*/
@NotNull
Color getBasePixelColor(int x, int y);
/** /**
* Draw a pixel to the canvas. * Draw a pixel to the canvas.
* *
* @param x The x coordinate, from 0 to 127. * @param x The x coordinate, from 0 to 127.
* @param y The y coordinate, from 0 to 127. * @param y The y coordinate, from 0 to 127.
* @param color The color. See {@link MapPalette}. * @param color The color. See {@link MapPalette}.
* @deprecated Magic value, use {@link #setPixelColor(int, int, Color)}
*/ */
public void setPixel(int x, int y, byte color); public void setPixel(int x, int y, byte color);
@ -50,7 +86,9 @@ public interface MapCanvas {
* @param x The x coordinate, from 0 to 127. * @param x The x coordinate, from 0 to 127.
* @param y The y coordinate, from 0 to 127. * @param y The y coordinate, from 0 to 127.
* @return The color. See {@link MapPalette}. * @return The color. See {@link MapPalette}.
* @deprecated Magic value, use {@link #getPixelColor(int, int)}
*/ */
@Deprecated
public byte getPixel(int x, int y); public byte getPixel(int x, int y);
/** /**
@ -59,7 +97,9 @@ public interface MapCanvas {
* @param x The x coordinate, from 0 to 127. * @param x The x coordinate, from 0 to 127.
* @param y The y coordinate, from 0 to 127. * @param y The y coordinate, from 0 to 127.
* @return The color. See {@link MapPalette}. * @return The color. See {@link MapPalette}.
* @deprecated Magic value, use {@link #getBasePixelColor(int, int)}
*/ */
@Deprecated
public byte getBasePixel(int x, int y); public byte getBasePixel(int x, int y);
/** /**