Skip to content

Commit 18d8714

Browse files
committed
Initial work on Adventure 5.0 update
1 parent 062aadc commit 18d8714

23 files changed

Lines changed: 114 additions & 257 deletions

File tree

paper-api/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ java {
1212
}
1313

1414
val annotationsVersion = "26.0.2"
15-
val adventureVersion = "4.26.1"
15+
val adventureVersion = "5.0.0-SNAPSHOT"
1616
val bungeeCordChatVersion = "1.21-R0.2-deprecated+build.21"
1717
val slf4jVersion = "2.0.16"
1818
val log4jVersion = "2.24.1"

paper-api/src/main/java/co/aikar/timings/TimingsReportListener.java

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
import com.google.common.base.Preconditions;
44
import com.google.common.collect.Lists;
5+
import net.kyori.adventure.audience.ForwardingAudience;
6+
import net.kyori.adventure.chat.ChatType;
7+
import net.kyori.adventure.chat.SignedMessage;
8+
import net.kyori.adventure.text.Component;
59
import org.bukkit.Bukkit;
610
import org.bukkit.command.CommandSender;
711
import org.bukkit.command.ConsoleCommandSender;
@@ -61,8 +65,18 @@ public void done(@Nullable String url) {
6165
}
6266

6367
@Override
64-
public void sendMessage(final @NotNull net.kyori.adventure.identity.Identity source, final @NotNull net.kyori.adventure.text.Component message, final @NotNull net.kyori.adventure.audience.MessageType type) {
65-
net.kyori.adventure.audience.ForwardingAudience.super.sendMessage(source, message, type);
68+
public void sendMessage(final @NotNull Component message) {
69+
ForwardingAudience.super.sendMessage(message);
70+
}
71+
72+
@Override
73+
public void sendMessage(final @NotNull Component message, final ChatType.@NotNull Bound boundChatType) {
74+
ForwardingAudience.super.sendMessage(message, boundChatType);
75+
}
76+
77+
@Override
78+
public void sendMessage(final @NotNull SignedMessage signedMessage, final ChatType.@NotNull Bound boundChatType) {
79+
ForwardingAudience.super.sendMessage(signedMessage, boundChatType);
6680
}
6781

6882
@NotNull

paper-api/src/main/java/com/destroystokyo/paper/event/server/AsyncTabCompleteEvent.java

Lines changed: 4 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,7 @@
2828
import java.util.ArrayList;
2929
import java.util.List;
3030
import java.util.Objects;
31-
import java.util.stream.Stream;
3231
import net.kyori.adventure.text.Component;
33-
import net.kyori.examination.Examinable;
34-
import net.kyori.examination.ExaminableProperty;
35-
import net.kyori.examination.string.StringExaminer;
3632
import org.bukkit.Location;
3733
import org.bukkit.command.Command;
3834
import org.bukkit.command.CommandSender;
@@ -240,10 +236,8 @@ private static List<Completion> fromStrings(final List<String> suggestions) {
240236

241237
/**
242238
* A rich tab completion, consisting of a string suggestion, and a nullable {@link Component} tooltip.
243-
* <p>
244-
* <b>Warning:</b> In a future update, this class will no longer implement {@link Examinable}.
245239
*/
246-
public interface Completion extends Examinable {
240+
public interface Completion {
247241

248242
/**
249243
* Get the suggestion string for this {@link Completion}.
@@ -259,12 +253,6 @@ public interface Completion extends Examinable {
259253
*/
260254
@Nullable Component tooltip();
261255

262-
@Override
263-
@Deprecated(forRemoval = true, since = "1.21.11")
264-
default Stream<? extends ExaminableProperty> examinableProperties() {
265-
return Stream.of(ExaminableProperty.of("suggestion", this.suggestion()), ExaminableProperty.of("tooltip", this.tooltip()));
266-
}
267-
268256
/**
269257
* Create a new {@link Completion} from a suggestion string.
270258
*
@@ -290,47 +278,9 @@ static Completion completion(final String suggestion, final @Nullable Component
290278
}
291279

292280
@ApiStatus.Internal
293-
static final class CompletionImpl implements Completion {
294-
295-
private final String suggestion;
296-
private final @Nullable Component tooltip;
297-
298-
CompletionImpl(final String suggestion, final @Nullable Component tooltip) {
299-
this.suggestion = suggestion;
300-
this.tooltip = tooltip;
301-
}
302-
303-
@Override
304-
public String suggestion() {
305-
return this.suggestion;
306-
}
307-
308-
@Override
309-
public @Nullable Component tooltip() {
310-
return this.tooltip;
311-
}
312-
313-
@Override
314-
public boolean equals(final @Nullable Object o) {
315-
if (this == o) {
316-
return true;
317-
}
318-
if (o == null || this.getClass() != o.getClass()) {
319-
return false;
320-
}
321-
final CompletionImpl that = (CompletionImpl) o;
322-
return this.suggestion.equals(that.suggestion)
323-
&& Objects.equals(this.tooltip, that.tooltip);
324-
}
325-
326-
@Override
327-
public int hashCode() {
328-
return Objects.hash(this.suggestion, this.tooltip);
329-
}
330-
331-
@Override
332-
public String toString() {
333-
return StringExaminer.simpleEscaping().examine(this);
281+
record CompletionImpl(String suggestion, @Nullable Component tooltip) implements Completion {
282+
CompletionImpl {
283+
Objects.requireNonNull(suggestion, "suggestion");
334284
}
335285
}
336286
}

paper-api/src/main/java/io/papermc/paper/text/PaperComponents.java

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
import net.kyori.adventure.text.format.NamedTextColor;
77
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
88
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
9-
import net.kyori.adventure.text.serializer.plain.PlainComponentSerializer;
109
import net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer;
1110
import org.bukkit.Bukkit;
1211
import org.bukkit.command.CommandSender;
@@ -95,21 +94,6 @@ public static ComponentFlattener flattener() {
9594
return Bukkit.getUnsafe().componentFlattener();
9695
}
9796

98-
/**
99-
* Get a serializer for {@link Component}s that will convert components to
100-
* a plain-text string.
101-
*
102-
* <p>Implementations may provide a serializer capable of processing any
103-
* information that requires access to implementation details.</p>
104-
*
105-
* @return a serializer to plain text
106-
* @deprecated will be removed in adventure 5.0.0, use {@link PlainTextComponentSerializer#plainText()}
107-
*/
108-
@Deprecated(forRemoval = true, since = "1.18.1")
109-
public static PlainComponentSerializer plainSerializer() {
110-
return Bukkit.getUnsafe().plainComponentSerializer();
111-
}
112-
11397
/**
11498
* Get a serializer for {@link Component}s that will convert components to
11599
* a plain-text string.

paper-api/src/main/java/org/bukkit/UnsafeValues.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@
3838
public interface UnsafeValues {
3939
// Paper start
4040
net.kyori.adventure.text.flattener.ComponentFlattener componentFlattener();
41-
@Deprecated(forRemoval = true) net.kyori.adventure.text.serializer.plain.PlainComponentSerializer plainComponentSerializer();
4241
@Deprecated(forRemoval = true) net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer plainTextSerializer();
4342
@Deprecated(forRemoval = true) net.kyori.adventure.text.serializer.gson.GsonComponentSerializer gsonComponentSerializer();
4443
@Deprecated(forRemoval = true) net.kyori.adventure.text.serializer.gson.GsonComponentSerializer colorDownsamplingGsonComponentSerializer();

paper-api/src/main/java/org/bukkit/command/CommandSender.java

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
package org.bukkit.command;
22

3+
import java.util.Objects;
34
import java.util.UUID;
4-
import net.kyori.adventure.audience.MessageType;
5-
import net.kyori.adventure.identity.Identity;
5+
import net.kyori.adventure.chat.ChatType;
6+
import net.kyori.adventure.chat.SignedMessage;
67
import net.kyori.adventure.text.Component;
78
import org.bukkit.Server;
89
import org.bukkit.permissions.Permissible;
@@ -38,7 +39,7 @@ public interface CommandSender extends net.kyori.adventure.audience.Audience, Pe
3839
*
3940
* @param message Message to be displayed
4041
* @param sender The sender of this message
41-
* @see #sendMessage(net.kyori.adventure.identity.Identified, net.kyori.adventure.text.Component)
42+
* @see #sendMessage(net.kyori.adventure.text.Component)
4243
* @deprecated sender UUID is ignored
4344
*/
4445
@Deprecated // Paper
@@ -49,7 +50,7 @@ public interface CommandSender extends net.kyori.adventure.audience.Audience, Pe
4950
*
5051
* @param messages An array of messages to be displayed
5152
* @param sender The sender of this message
52-
* @see #sendMessage(net.kyori.adventure.identity.Identified, net.kyori.adventure.text.Component)
53+
* @see #sendMessage(net.kyori.adventure.text.Component)
5354
* @deprecated sender UUID is ignored
5455
*/
5556
@Deprecated // Paper
@@ -134,10 +135,20 @@ public void sendMessage(@Nullable UUID sender, @NotNull net.md_5.bungee.api.chat
134135
public net.kyori.adventure.text.@NotNull Component name();
135136

136137
@Override
137-
default void sendMessage(final net.kyori.adventure.identity.@NotNull Identity identity, final net.kyori.adventure.text.@NotNull Component message, final net.kyori.adventure.audience.@NotNull MessageType type) {
138+
default void sendMessage(final net.kyori.adventure.text.@NotNull Component message) {
138139
this.sendMessage(net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().serialize(message));
139140
}
140141

142+
@Override
143+
default void sendMessage(final @NotNull Component message, final ChatType.@NotNull Bound boundChatType) {
144+
this.sendMessage(message);
145+
}
146+
147+
@Override
148+
default void sendMessage(final @NotNull SignedMessage signedMessage, final ChatType.@NotNull Bound boundChatType) {
149+
this.sendMessage(Objects.requireNonNullElseGet(signedMessage.unsignedContent(), () -> Component.text(signedMessage.message())));
150+
}
151+
141152
/**
142153
* Sends a message with the MiniMessage format to the command sender.
143154
* <p>
@@ -179,7 +190,7 @@ default void sendPlainMessage(final @NotNull String message) {
179190
* the component will be sent as legacy text.</p>
180191
*
181192
* @param component the component to send
182-
* @deprecated use {@link #sendMessage(Identity, Component, MessageType)} instead
193+
* @deprecated use {@link #sendMessage(Component)} instead
183194
*/
184195
@Deprecated
185196
default void sendMessage(@NotNull net.md_5.bungee.api.chat.BaseComponent component) {
@@ -193,7 +204,7 @@ default void sendMessage(@NotNull net.md_5.bungee.api.chat.BaseComponent compone
193204
* the components will be sent as legacy text.</p>
194205
*
195206
* @param components the components to send
196-
* @deprecated use {@link #sendMessage(Identity, Component, MessageType)} instead
207+
* @deprecated use {@link #sendMessage(Component)} instead
197208
*/
198209
@Deprecated
199210
default void sendMessage(@NotNull net.md_5.bungee.api.chat.BaseComponent... components) {

paper-api/src/main/java/org/bukkit/command/ProxiedCommandSender.java

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11

22
package org.bukkit.command;
33

4+
import net.kyori.adventure.audience.ForwardingAudience;
5+
import net.kyori.adventure.chat.ChatType;
6+
import net.kyori.adventure.chat.SignedMessage;
7+
import net.kyori.adventure.text.Component;
48
import org.jetbrains.annotations.NotNull;
59

610
public interface ProxiedCommandSender extends CommandSender, net.kyori.adventure.audience.ForwardingAudience.Single { // Paper
@@ -23,8 +27,18 @@ public interface ProxiedCommandSender extends CommandSender, net.kyori.adventure
2327

2428
// Paper start
2529
@Override
26-
default void sendMessage(final net.kyori.adventure.identity.@NotNull Identity source, final net.kyori.adventure.text.@NotNull Component message, final net.kyori.adventure.audience.@NotNull MessageType type) {
27-
net.kyori.adventure.audience.ForwardingAudience.Single.super.sendMessage(source, message, type);
30+
default void sendMessage(final @NotNull Component message, final ChatType.@NotNull Bound boundChatType) {
31+
ForwardingAudience.Single.super.sendMessage(message, boundChatType);
32+
}
33+
34+
@Override
35+
default void sendMessage(final @NotNull Component message) {
36+
ForwardingAudience.Single.super.sendMessage(message);
37+
}
38+
39+
@Override
40+
default void sendMessage(final @NotNull SignedMessage signedMessage, final ChatType.@NotNull Bound boundChatType) {
41+
ForwardingAudience.Single.super.sendMessage(signedMessage, boundChatType);
2842
}
2943

3044
@NotNull

paper-api/src/main/java/org/bukkit/entity/Entity.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1086,7 +1086,7 @@ public class Spigot extends CommandSender.Spigot {
10861086
@NotNull
10871087
@Override
10881088
default net.kyori.adventure.text.event.HoverEvent<net.kyori.adventure.text.event.HoverEvent.ShowEntity> asHoverEvent(final @NotNull java.util.function.UnaryOperator<net.kyori.adventure.text.event.HoverEvent.ShowEntity> op) {
1089-
return net.kyori.adventure.text.event.HoverEvent.showEntity(op.apply(net.kyori.adventure.text.event.HoverEvent.ShowEntity.of(this.getType().getKey(), this.getUniqueId(), this.customName())));
1089+
return net.kyori.adventure.text.event.HoverEvent.showEntity(op.apply(net.kyori.adventure.text.event.HoverEvent.ShowEntity.showEntity(this.getType().getKey(), this.getUniqueId(), this.customName())));
10901090
}
10911091

10921092
/**

paper-api/src/main/java/org/bukkit/entity/Player.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3555,7 +3555,7 @@ default void openSign(Sign sign) {
35553555
// Paper start
35563556
@Override
35573557
default net.kyori.adventure.text.event.HoverEvent<net.kyori.adventure.text.event.HoverEvent.ShowEntity> asHoverEvent(final java.util.function.UnaryOperator<net.kyori.adventure.text.event.HoverEvent.ShowEntity> op) {
3558-
return net.kyori.adventure.text.event.HoverEvent.showEntity(op.apply(net.kyori.adventure.text.event.HoverEvent.ShowEntity.of(this.getType().getKey(), this.getUniqueId(), this.displayName())));
3558+
return net.kyori.adventure.text.event.HoverEvent.showEntity(op.apply(net.kyori.adventure.text.event.HoverEvent.ShowEntity.showEntity(this.getType().getKey(), this.getUniqueId(), this.displayName())));
35593559
}
35603560
// Paper end
35613561

0 commit comments

Comments
 (0)