Skip to content

Commit d124cec

Browse files
committed
chore(api): Initial refactor (minus text package) to remove deprecations and use modern language features
1 parent 0b04a19 commit d124cec

File tree

61 files changed

+171
-1537
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+171
-1537
lines changed

api/src/main/java/net/kyori/adventure/audience/Audience.java

Lines changed: 2 additions & 185 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,6 @@
3838
import net.kyori.adventure.chat.ChatType;
3939
import net.kyori.adventure.chat.SignedMessage;
4040
import net.kyori.adventure.dialog.DialogLike;
41-
import net.kyori.adventure.identity.Identified;
42-
import net.kyori.adventure.identity.Identity;
4341
import net.kyori.adventure.inventory.Book;
4442
import net.kyori.adventure.pointer.Pointered;
4543
import net.kyori.adventure.resource.ResourcePackInfo;
@@ -52,7 +50,6 @@
5250
import net.kyori.adventure.text.ComponentLike;
5351
import net.kyori.adventure.title.Title;
5452
import net.kyori.adventure.title.TitlePart;
55-
import org.jetbrains.annotations.ApiStatus;
5653
import org.jetbrains.annotations.NotNull;
5754

5855
/**
@@ -200,8 +197,6 @@ default void forEachAudience(final @NotNull Consumer<? super Audience> action) {
200197
*
201198
* @param message a message
202199
* @see Component
203-
* @see #sendMessage(Identified, ComponentLike)
204-
* @see #sendMessage(Identity, ComponentLike)
205200
* @since 4.1.0
206201
*/
207202
@ForwardingAudienceOverrideNotRequired
@@ -214,180 +209,12 @@ default void sendMessage(final @NotNull ComponentLike message) {
214209
*
215210
* @param message a message
216211
* @see Component
217-
* @see #sendMessage(Identified, Component)
218-
* @see #sendMessage(Identity, Component)
219212
* @since 4.1.0
220213
*/
221-
@SuppressWarnings("deprecation")
222214
default void sendMessage(final @NotNull Component message) {
223-
this.sendMessage(message, MessageType.SYSTEM);
224-
}
225-
226-
/**
227-
* Sends a system chat message to this {@link Audience} ignoring the provided {@link MessageType}.
228-
*
229-
* @param message a message
230-
* @param type the type
231-
* @see Component
232-
* @see #sendMessage(Identified, ComponentLike, MessageType)
233-
* @see #sendMessage(Identity, ComponentLike, MessageType)
234-
* @since 4.1.0
235-
* @deprecated for removal since 4.12.0, {@link MessageType} is deprecated for removal, use {@link #sendMessage(ComponentLike)}
236-
*/
237-
@ApiStatus.ScheduledForRemoval(inVersion = "5.0.0")
238-
@Deprecated
239-
@ForwardingAudienceOverrideNotRequired
240-
default void sendMessage(final @NotNull ComponentLike message, final @NotNull MessageType type) {
241-
this.sendMessage(message.asComponent(), type);
242-
}
243-
244-
/**
245-
* Sends a system chat message to this {@link Audience} ignoring the provided {@link MessageType}.
246-
*
247-
* @param message a message
248-
* @param type the type
249-
* @see Component
250-
* @see #sendMessage(Identified, Component, MessageType)
251-
* @see #sendMessage(Identity, Component, MessageType)
252-
* @since 4.1.0
253-
* @deprecated for removal since 4.12.0, {@link MessageType} is deprecated for removal, use {@link #sendMessage(Component)} instead
254-
*/
255-
@ApiStatus.ScheduledForRemoval(inVersion = "5.0.0")
256-
@Deprecated
257-
@ForwardingAudienceOverrideNotRequired
258-
default void sendMessage(final @NotNull Component message, final @NotNull MessageType type) {
259-
this.sendMessage(Identity.nil(), message, type);
260215
}
261216
/* End: system messages */
262217

263-
/* Start: unsigned player messages */
264-
/**
265-
* Sends an unsigned player chat message from the given {@link Identified} to this {@link Audience} with the {@link ChatType#CHAT system} chat type.
266-
*
267-
* @param source the source of the message
268-
* @param message a message
269-
* @see Component
270-
* @since 4.0.0
271-
* @deprecated since 4.12.0, the client errors on and can reject identified messages without {@link SignedMessage} data, this may be unsupported in the future, use {@link #sendMessage(SignedMessage, ChatType.Bound)} instead
272-
*/
273-
@Deprecated
274-
@ForwardingAudienceOverrideNotRequired
275-
default void sendMessage(final @NotNull Identified source, final @NotNull ComponentLike message) {
276-
this.sendMessage(source, message.asComponent());
277-
}
278-
279-
/**
280-
* Sends an unsigned player chat message from the entity represented by the given {@link Identity} to this {@link Audience} with the {@link ChatType#CHAT system} chat type.
281-
*
282-
* @param source the identity of the source of the message
283-
* @param message a message
284-
* @see Component
285-
* @since 4.0.0
286-
* @deprecated since 4.12.0, the client errors on and can reject identified messages without {@link SignedMessage} data, this may be unsupported in the future, use {@link #sendMessage(SignedMessage, ChatType.Bound)} instead
287-
*/
288-
@Deprecated
289-
@ForwardingAudienceOverrideNotRequired
290-
default void sendMessage(final @NotNull Identity source, final @NotNull ComponentLike message) {
291-
this.sendMessage(source, message.asComponent());
292-
}
293-
294-
/**
295-
* Sends an unsigned player chat message from the given {@link Identified} to this {@link Audience} with the {@link ChatType#CHAT system} chat type.
296-
*
297-
* @param source the source of the message
298-
* @param message a message
299-
* @see Component
300-
* @since 4.0.0
301-
* @deprecated since 4.12.0, the client errors on receiving and can reject identified messages without {@link SignedMessage} data, this may be unsupported in the future, use {@link #sendMessage(SignedMessage, ChatType.Bound)} instead
302-
*/
303-
@Deprecated
304-
@ForwardingAudienceOverrideNotRequired
305-
default void sendMessage(final @NotNull Identified source, final @NotNull Component message) {
306-
this.sendMessage(source, message, MessageType.CHAT);
307-
}
308-
309-
/**
310-
* Sends an unsigned player chat message from the entity represented by the given {@link Identity} to this {@link Audience} with the {@link ChatType#CHAT system} chat type.
311-
*
312-
* @param source the identity of the source of the message
313-
* @param message a message
314-
* @see Component
315-
* @since 4.0.0
316-
* @deprecated since 4.12.0, the client errors on receiving and can reject identified messages without {@link SignedMessage} data, this may be unsupported in the future, use {@link #sendMessage(SignedMessage, ChatType.Bound)} instead
317-
*/
318-
@Deprecated
319-
@ForwardingAudienceOverrideNotRequired
320-
default void sendMessage(final @NotNull Identity source, final @NotNull Component message) {
321-
this.sendMessage(source, message, MessageType.CHAT);
322-
}
323-
324-
/**
325-
* Sends an unsigned player chat message from the given {@link Identified} to this {@link Audience} with the {@link ChatType} corresponding to the provided {@link MessageType}.
326-
*
327-
* @param source the source of the message
328-
* @param message a message
329-
* @param type the type
330-
* @see Component
331-
* @since 4.0.0
332-
* @deprecated for removal since 4.12.0, {@link MessageType} is deprecated for removal and the client errors on receiving and can reject identified messages without {@link SignedMessage} data, use {@link #sendMessage(SignedMessage, ChatType.Bound)} instead
333-
*/
334-
@ApiStatus.ScheduledForRemoval(inVersion = "5.0.0")
335-
@Deprecated
336-
@ForwardingAudienceOverrideNotRequired
337-
default void sendMessage(final @NotNull Identified source, final @NotNull ComponentLike message, final @NotNull MessageType type) {
338-
this.sendMessage(source, message.asComponent(), type);
339-
}
340-
341-
/**
342-
* Sends an unsigned player chat message from the entity represented by the given {@link Identity} to this {@link Audience}.
343-
*
344-
* @param source the identity of the source of the message
345-
* @param message a message
346-
* @param type the type
347-
* @see Component
348-
* @since 4.0.0
349-
* @deprecated for removal since 4.12.0, {@link MessageType} is deprecated for removal and the client errors on receiving and can reject identified messages without {@link SignedMessage} data, use {@link #sendMessage(SignedMessage, ChatType.Bound)} instead
350-
*/
351-
@ApiStatus.ScheduledForRemoval(inVersion = "5.0.0")
352-
@Deprecated
353-
@ForwardingAudienceOverrideNotRequired
354-
default void sendMessage(final @NotNull Identity source, final @NotNull ComponentLike message, final @NotNull MessageType type) {
355-
this.sendMessage(source, message.asComponent(), type);
356-
}
357-
358-
/**
359-
* Sends an unsigned player chat message from the given {@link Identified} to this {@link Audience} with the {@link ChatType} corresponding to the provided {@link MessageType}.
360-
*
361-
* @param source the source of the message
362-
* @param message a message
363-
* @param type the type
364-
* @see Component
365-
* @since 4.0.0
366-
* @deprecated for removal since 4.12.0, {@link MessageType} is deprecated for removal and the client errors on receiving and can reject identified messages without {@link SignedMessage} data, use {@link #sendMessage(SignedMessage, ChatType.Bound)} instead
367-
*/
368-
@ApiStatus.ScheduledForRemoval(inVersion = "5.0.0")
369-
@Deprecated
370-
default void sendMessage(final @NotNull Identified source, final @NotNull Component message, final @NotNull MessageType type) {
371-
this.sendMessage(source.identity(), message, type);
372-
}
373-
374-
/**
375-
* Sends a player chat message from the entity represented by the given {@link Identity} to this {@link Audience} with the {@link ChatType} corresponding to the provided {@link MessageType}.
376-
*
377-
* @param source the identity of the source of the message
378-
* @param message a message
379-
* @param type the type
380-
* @see Component
381-
* @since 4.0.0
382-
* @deprecated for removal since 4.12.0, {@link MessageType} is deprecated for removal and the client errors on receiving and can reject identified messages without {@link SignedMessage} data, use {@link #sendMessage(SignedMessage, ChatType.Bound)} instead
383-
*/
384-
@ApiStatus.ScheduledForRemoval(inVersion = "5.0.0")
385-
@Deprecated
386-
default void sendMessage(final @NotNull Identity source, final @NotNull Component message, final @NotNull MessageType type) {
387-
// implementation required
388-
}
389-
/* End: unsigned player messages */
390-
391218
/* Start: disguised player messages */
392219
/**
393220
* Sends a message to this {@link Audience} with the provided {@link ChatType.Bound bound chat type}.
@@ -397,9 +224,7 @@ default void sendMessage(final @NotNull Identity source, final @NotNull Componen
397224
* @since 4.12.0
398225
* @sinceMinecraft 1.19
399226
*/
400-
@SuppressWarnings("deprecation")
401227
default void sendMessage(final @NotNull Component message, final ChatType.@NotNull Bound boundChatType) {
402-
this.sendMessage(message, MessageType.CHAT);
403228
}
404229

405230
/**
@@ -425,14 +250,7 @@ default void sendMessage(final @NotNull ComponentLike message, final ChatType.@N
425250
* @since 4.12.0
426251
* @sinceMinecraft 1.19
427252
*/
428-
@SuppressWarnings("deprecation")
429253
default void sendMessage(final @NotNull SignedMessage signedMessage, final ChatType.@NotNull Bound boundChatType) {
430-
final Component content = signedMessage.unsignedContent() != null ? signedMessage.unsignedContent() : Component.text(signedMessage.message());
431-
if (signedMessage.isSystem()) {
432-
this.sendMessage(content);
433-
} else {
434-
this.sendMessage(signedMessage.identity(), content, MessageType.CHAT);
435-
}
436254
}
437255

438256
/**
@@ -581,7 +399,6 @@ default void showTitle(final @NotNull Title title) {
581399
* @param part the part
582400
* @param value the value
583401
* @param <T> the type of the value of the part
584-
* @throws IllegalArgumentException if a title part that is not in {@link TitlePart} is used
585402
* @since 4.9.0
586403
*/
587404
default <T> void sendTitlePart(final @NotNull TitlePart<T> part, final @NotNull T value) {
@@ -782,7 +599,7 @@ default void removeResourcePacks(final @NotNull ResourcePackRequestLike request)
782599
default void removeResourcePacks(final @NotNull ResourcePackRequest request) {
783600
final List<ResourcePackInfo> infos = request.packs();
784601
if (infos.size() == 1) {
785-
this.removeResourcePacks(infos.get(0).id());
602+
this.removeResourcePacks(infos.getFirst().id());
786603
} else if (infos.isEmpty()) {
787604
return;
788605
}
@@ -791,7 +608,7 @@ default void removeResourcePacks(final @NotNull ResourcePackRequest request) {
791608
for (int i = 0; i < otherReqs.length; i++) {
792609
otherReqs[i] = infos.get(i + 1).id();
793610
}
794-
this.removeResourcePacks(infos.get(0).id(), otherReqs);
611+
this.removeResourcePacks(infos.getFirst().id(), otherReqs);
795612
}
796613

797614
/**

api/src/main/java/net/kyori/adventure/audience/EmptyAudience.java

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,6 @@
2929
import java.util.function.Supplier;
3030
import net.kyori.adventure.chat.ChatType;
3131
import net.kyori.adventure.chat.SignedMessage;
32-
import net.kyori.adventure.identity.Identified;
33-
import net.kyori.adventure.identity.Identity;
3432
import net.kyori.adventure.inventory.Book;
3533
import net.kyori.adventure.pointer.Pointer;
3634
import net.kyori.adventure.resource.ResourcePackInfoLike;
@@ -78,16 +76,6 @@ public void sendMessage(final @NotNull ComponentLike message) {
7876
public void sendMessage(final @NotNull Component message) {
7977
}
8078

81-
@Override
82-
@Deprecated
83-
public void sendMessage(final @NotNull Identified source, final @NotNull Component message, final @NotNull MessageType type) {
84-
}
85-
86-
@Override
87-
@Deprecated
88-
public void sendMessage(final @NotNull Identity source, final @NotNull Component message, final @NotNull MessageType type) {
89-
}
90-
9179
@Override
9280
public void sendMessage(final @NotNull Component message, final ChatType.@NotNull Bound boundChatType) {
9381
}

api/src/main/java/net/kyori/adventure/audience/ForwardingAudience.java

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,6 @@
3535
import net.kyori.adventure.chat.ChatType;
3636
import net.kyori.adventure.chat.SignedMessage;
3737
import net.kyori.adventure.dialog.DialogLike;
38-
import net.kyori.adventure.identity.Identified;
39-
import net.kyori.adventure.identity.Identity;
4038
import net.kyori.adventure.inventory.Book;
4139
import net.kyori.adventure.pointer.Pointer;
4240
import net.kyori.adventure.pointer.Pointers;
@@ -120,18 +118,6 @@ default void deleteMessage(final SignedMessage.@NotNull Signature signature) {
120118
for (final Audience audience : this.audiences()) audience.deleteMessage(signature);
121119
}
122120

123-
@Override
124-
@Deprecated
125-
default void sendMessage(final @NotNull Identified source, final @NotNull Component message, final @NotNull MessageType type) {
126-
for (final Audience audience : this.audiences()) audience.sendMessage(source, message, type);
127-
}
128-
129-
@Override
130-
@Deprecated
131-
default void sendMessage(final @NotNull Identity source, final @NotNull Component message, final @NotNull MessageType type) {
132-
for (final Audience audience : this.audiences()) audience.sendMessage(source, message, type);
133-
}
134-
135121
@Override
136122
default void sendActionBar(final @NotNull Component message) {
137123
for (final Audience audience : this.audiences()) audience.sendActionBar(message);
@@ -253,7 +239,7 @@ interface Single extends ForwardingAudience {
253239
* @return {@link #audience()}
254240
* @deprecated this audience only supports forwarding to a single audience
255241
*/
256-
@Deprecated(/* forRemoval = false */)
242+
@Deprecated
257243
@Override
258244
default @NotNull Iterable<? extends Audience> audiences() {
259245
return Collections.singleton(this.audience());
@@ -313,18 +299,6 @@ default void deleteMessage(final SignedMessage.@NotNull Signature signature) {
313299
this.audience().deleteMessage(signature);
314300
}
315301

316-
@Override
317-
@Deprecated
318-
default void sendMessage(final @NotNull Identified source, final @NotNull Component message, final @NotNull MessageType type) {
319-
this.audience().sendMessage(source, message, type);
320-
}
321-
322-
@Override
323-
@Deprecated
324-
default void sendMessage(final @NotNull Identity source, final @NotNull Component message, final @NotNull MessageType type) {
325-
this.audience().sendMessage(source, message, type);
326-
}
327-
328302
@Override
329303
default void sendActionBar(final @NotNull Component message) {
330304
this.audience().sendActionBar(message);

0 commit comments

Comments
 (0)