Adventure

Co-authored-by: zml <zml@stellardrift.ca>
Co-authored-by: Jake Potrebic <jake.m.potrebic@gmail.com>
Co-authored-by: Yannick Lamprecht <yannicklamprecht@live.de>
This commit is contained in:
Riley Park
2021-01-29 17:21:55 +01:00
parent 8888031206
commit 15081a5912
70 changed files with 3298 additions and 160 deletions

View File

@@ -17,7 +17,7 @@ public final class MapCursor {
private byte x, y;
private byte direction;
private boolean visible;
private String caption;
private net.kyori.adventure.text.Component caption; // Paper
private Type type;
/**
@@ -32,7 +32,7 @@ public final class MapCursor {
*/
@Deprecated(since = "1.6.2")
public MapCursor(byte x, byte y, byte direction, byte type, boolean visible) {
this(x, y, direction, type, visible, null);
this(x, y, direction, type, visible, (String) null); // Paper
}
/**
@@ -45,7 +45,7 @@ public final class MapCursor {
* @param visible Whether the cursor is visible by default.
*/
public MapCursor(byte x, byte y, byte direction, @NotNull Type type, boolean visible) {
this(x, y, direction, type, visible, null);
this(x, y, direction, type, visible, (String) null); // Paper
}
/**
@@ -57,7 +57,7 @@ public final class MapCursor {
* @param type The type (color/style) of the map cursor.
* @param visible Whether the cursor is visible by default.
* @param caption cursor caption
* @deprecated Magic value, use {@link #MapCursor(byte, byte, byte, Type, boolean, String)}
* @deprecated Magic value. Use {@link #MapCursor(byte, byte, byte, Type, boolean, net.kyori.adventure.text.Component)}
*/
@Deprecated(since = "1.13")
public MapCursor(byte x, byte y, byte direction, byte type, boolean visible, @Nullable String caption) {
@@ -66,8 +66,42 @@ public final class MapCursor {
setDirection(direction);
setRawType(type);
this.visible = visible;
this.caption = caption;
this.caption = caption == null ? null : net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(caption); // Paper
}
// Paper start
/**
* Initialize the map cursor.
*
* @param x The x coordinate, from -128 to 127.
* @param y The y coordinate, from -128 to 127.
* @param direction The facing of the cursor, from 0 to 15.
* @param type The type (color/style) of the map cursor.
* @param visible Whether the cursor is visible by default.
* @param caption cursor caption
* @deprecated Magic value
*/
@Deprecated
public MapCursor(byte x, byte y, byte direction, byte type, boolean visible, net.kyori.adventure.text.@Nullable Component caption) {
this.x = x; this.y = y; this.visible = visible; this.caption = caption;
setDirection(direction);
setRawType(type);
}
/**
* Initialize the map cursor.
*
* @param x The x coordinate, from -128 to 127.
* @param y The y coordinate, from -128 to 127.
* @param direction The facing of the cursor, from 0 to 15.
* @param type The type (color/style) of the map cursor.
* @param visible Whether the cursor is visible by default.
* @param caption cursor caption
*/
public MapCursor(byte x, byte y, byte direction, @NotNull Type type, boolean visible, net.kyori.adventure.text.@Nullable Component caption) {
this.x = x; this.y = y; this.visible = visible; this.caption = caption;
setDirection(direction);
setType(type);
}
// Paper end
/**
* Initialize the map cursor.
@@ -85,7 +119,7 @@ public final class MapCursor {
setDirection(direction);
this.type = type;
this.visible = visible;
this.caption = caption;
this.caption = caption == null ? null : net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(caption); // Paper
}
/**
@@ -204,23 +238,45 @@ public final class MapCursor {
this.visible = visible;
}
// Paper start
/**
* Gets the caption on this cursor.
*
* @return caption
*/
public net.kyori.adventure.text.@Nullable Component caption() {
return this.caption;
}
/**
* Sets the caption on this cursor.
*
* @param caption new caption
*/
public void caption(net.kyori.adventure.text.@Nullable Component caption) {
this.caption = caption;
}
// Paper end
/**
* Gets the caption on this cursor.
*
* @return caption
* @deprecated in favour of {@link #caption()}
*/
@Nullable
@Deprecated // Paper
public String getCaption() {
return caption;
return this.caption == null ? null : net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().serialize(this.caption); // Paper
}
/**
* Sets the caption on this cursor.
*
* @param caption new caption
* @deprecated in favour of {@link #caption(net.kyori.adventure.text.Component)}
*/
@Deprecated // Paper
public void setCaption(@Nullable String caption) {
this.caption = caption;
this.caption = caption == null ? null : net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(caption); // Paper
}
/**

View File

@@ -117,4 +117,22 @@ public final class MapCursorCollection {
public MapCursor addCursor(int x, int y, byte direction, byte type, boolean visible, @Nullable String caption) {
return addCursor(new MapCursor((byte) x, (byte) y, direction, type, visible, caption));
}
// Paper start
/**
* Add a cursor to the collection.
*
* @param x The x coordinate, from -128 to 127.
* @param y The y coordinate, from -128 to 127.
* @param direction The facing of the cursor, from 0 to 15.
* @param type The type (color/style) of the map cursor.
* @param visible Whether the cursor is visible.
* @param caption banner caption
* @return The newly added MapCursor.
* @deprecated Magic value
*/
@Deprecated
public @NotNull MapCursor addCursor(int x, int y, byte direction, byte type, boolean visible, net.kyori.adventure.text.@Nullable Component caption) {
return addCursor(new MapCursor((byte) x, (byte) y, direction, type, visible, caption));
}
// Paper end
}