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:
@@ -17,18 +17,38 @@ public class SignChangeEvent extends BlockEvent implements Cancellable {
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
private boolean cancel = false;
|
||||
private final Player player;
|
||||
private final String[] lines;
|
||||
private final java.util.List<net.kyori.adventure.text.Component> adventure$lines; // Paper
|
||||
private final Side side;
|
||||
|
||||
// Paper start
|
||||
public SignChangeEvent(@NotNull final Block theBlock, @NotNull final Player player, @NotNull final java.util.List<net.kyori.adventure.text.Component> adventure$lines, @NotNull Side side) {
|
||||
super(theBlock);
|
||||
this.player = player;
|
||||
this.adventure$lines = adventure$lines;
|
||||
this.side = side;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public SignChangeEvent(@NotNull final Block theBlock, @NotNull final Player player, @NotNull final java.util.List<net.kyori.adventure.text.Component> adventure$lines) {
|
||||
this(theBlock, player, adventure$lines, Side.FRONT);
|
||||
}
|
||||
// Paper end
|
||||
|
||||
@Deprecated(since = "1.19.4")
|
||||
public SignChangeEvent(@NotNull final Block theBlock, @NotNull final Player thePlayer, @NotNull final String[] theLines) {
|
||||
this(theBlock, thePlayer, theLines, Side.FRONT);
|
||||
}
|
||||
|
||||
@Deprecated // Paper
|
||||
public SignChangeEvent(@NotNull final Block theBlock, @NotNull final Player thePlayer, @NotNull final String[] theLines, @NotNull Side side) {
|
||||
super(theBlock);
|
||||
this.player = thePlayer;
|
||||
this.lines = theLines;
|
||||
// Paper start
|
||||
this.adventure$lines = new java.util.ArrayList<>();
|
||||
for (String theLine : theLines) {
|
||||
this.adventure$lines.add(net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(theLine));
|
||||
}
|
||||
// Paper end
|
||||
this.side = side;
|
||||
}
|
||||
|
||||
@@ -42,14 +62,14 @@ public class SignChangeEvent extends BlockEvent implements Cancellable {
|
||||
return player;
|
||||
}
|
||||
|
||||
// Paper start
|
||||
/**
|
||||
* Gets all of the lines of text from the sign involved in this event.
|
||||
*
|
||||
* @return the String array for the sign's lines new text
|
||||
*/
|
||||
@NotNull
|
||||
public String[] getLines() {
|
||||
return lines;
|
||||
public @NotNull java.util.List<net.kyori.adventure.text.Component> lines() {
|
||||
return this.adventure$lines;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -61,9 +81,8 @@ public class SignChangeEvent extends BlockEvent implements Cancellable {
|
||||
* @throws IndexOutOfBoundsException thrown when the provided index is {@literal > 3
|
||||
* or < 0}
|
||||
*/
|
||||
@Nullable
|
||||
public String getLine(int index) throws IndexOutOfBoundsException {
|
||||
return lines[index];
|
||||
public net.kyori.adventure.text.@Nullable Component line(int index) throws IndexOutOfBoundsException {
|
||||
return this.adventure$lines.get(index);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -74,8 +93,51 @@ public class SignChangeEvent extends BlockEvent implements Cancellable {
|
||||
* @throws IndexOutOfBoundsException thrown when the provided index is {@literal > 3
|
||||
* or < 0}
|
||||
*/
|
||||
public void line(int index, net.kyori.adventure.text.@Nullable Component line) throws IndexOutOfBoundsException {
|
||||
this.adventure$lines.set(index, line);
|
||||
}
|
||||
// Paper end
|
||||
|
||||
/**
|
||||
* Gets all of the lines of text from the sign involved in this event.
|
||||
*
|
||||
* @return the String array for the sign's lines new text
|
||||
* @deprecated in favour of {@link #lines()}
|
||||
*/
|
||||
@NotNull
|
||||
@Deprecated // Paper
|
||||
public String[] getLines() {
|
||||
return adventure$lines.stream().map(net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection()::serialize).toArray(String[]::new); // Paper
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a single line of text from the sign involved in this event.
|
||||
*
|
||||
* @param index index of the line to get
|
||||
* @return the String containing the line of text associated with the
|
||||
* provided index
|
||||
* @throws IndexOutOfBoundsException thrown when the provided index is {@literal > 3
|
||||
* or < 0}
|
||||
* @deprecated in favour of {@link #line(int)}
|
||||
*/
|
||||
@Nullable
|
||||
@Deprecated // Paper
|
||||
public String getLine(int index) throws IndexOutOfBoundsException {
|
||||
return net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().serialize(this.adventure$lines.get(index)); // Paper
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a single line for the sign involved in this event
|
||||
*
|
||||
* @param index index of the line to set
|
||||
* @param line text to set
|
||||
* @throws IndexOutOfBoundsException thrown when the provided index is {@literal > 3
|
||||
* or < 0}
|
||||
* @deprecated in favour of {@link #line(int, net.kyori.adventure.text.Component)}
|
||||
*/
|
||||
@Deprecated // Paper
|
||||
public void setLine(int index, @Nullable String line) throws IndexOutOfBoundsException {
|
||||
lines[index] = line;
|
||||
adventure$lines.set(index, line != null ? net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(line) : null); // Paper
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user