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
@@ -6,20 +6,28 @@ import org.bukkit.permissions.Permissible;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
public interface CommandSender extends Permissible {
public interface CommandSender extends net.kyori.adventure.audience.Audience, Permissible { // Paper
/**
* Sends this sender a message
*
* @param message Message to be displayed
* @see #sendMessage(net.kyori.adventure.text.Component)
* @see #sendPlainMessage(String)
* @see #sendRichMessage(String)
*/
@org.jetbrains.annotations.ApiStatus.Obsolete // Paper
public void sendMessage(@NotNull String message);
/**
* Sends this sender multiple messages
*
* @param messages An array of messages to be displayed
* @see #sendMessage(net.kyori.adventure.text.Component)
* @see #sendPlainMessage(String)
* @see #sendRichMessage(String)
*/
@org.jetbrains.annotations.ApiStatus.Obsolete // Paper
public void sendMessage(@NotNull String... messages);
/**
@@ -27,7 +35,10 @@ public interface CommandSender extends Permissible {
*
* @param message Message to be displayed
* @param sender The sender of this message
* @see #sendMessage(net.kyori.adventure.identity.Identified, net.kyori.adventure.text.Component)
* @deprecated sender UUID is ignored
*/
@Deprecated // Paper
public void sendMessage(@Nullable UUID sender, @NotNull String message);
/**
@@ -35,7 +46,10 @@ public interface CommandSender extends Permissible {
*
* @param messages An array of messages to be displayed
* @param sender The sender of this message
* @see #sendMessage(net.kyori.adventure.identity.Identified, net.kyori.adventure.text.Component)
* @deprecated sender UUID is ignored
*/
@Deprecated // Paper
public void sendMessage(@Nullable UUID sender, @NotNull String... messages);
/**
@@ -61,7 +75,9 @@ public interface CommandSender extends Permissible {
* Sends this sender a chat component.
*
* @param component the components to send
* @deprecated use {@code sendMessage} methods that accept {@link net.kyori.adventure.text.Component}
*/
@Deprecated // Paper
public void sendMessage(@NotNull net.md_5.bungee.api.chat.BaseComponent component) {
throw new UnsupportedOperationException("Not supported yet.");
}
@@ -70,7 +86,9 @@ public interface CommandSender extends Permissible {
* Sends an array of components as a single message to the sender.
*
* @param components the components to send
* @deprecated use {@code sendMessage} methods that accept {@link net.kyori.adventure.text.Component}
*/
@Deprecated // Paper
public void sendMessage(@NotNull net.md_5.bungee.api.chat.BaseComponent... components) {
throw new UnsupportedOperationException("Not supported yet.");
}
@@ -80,7 +98,9 @@ public interface CommandSender extends Permissible {
*
* @param component the components to send
* @param sender the sender of the message
* @deprecated use {@code sendMessage} methods that accept {@link net.kyori.adventure.text.Component}
*/
@Deprecated // Paper
public void sendMessage(@Nullable UUID sender, @NotNull net.md_5.bungee.api.chat.BaseComponent component) {
throw new UnsupportedOperationException("Not supported yet.");
}
@@ -90,7 +110,9 @@ public interface CommandSender extends Permissible {
*
* @param components the components to send
* @param sender the sender of the message
* @deprecated use {@code sendMessage} methods that accept {@link net.kyori.adventure.text.Component}
*/
@Deprecated // Paper
public void sendMessage(@Nullable UUID sender, @NotNull net.md_5.bungee.api.chat.BaseComponent... components) {
throw new UnsupportedOperationException("Not supported yet.");
}
@@ -99,4 +121,52 @@ public interface CommandSender extends Permissible {
@NotNull
Spigot spigot();
// Spigot end
// Paper start
/**
* Gets the name of this command sender
*
* @return Name of the sender
*/
public net.kyori.adventure.text.@NotNull Component name();
@Override
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) {
this.sendMessage(net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().serialize(message));
}
/**
* Sends a message with the MiniMessage format to the command sender.
* <p>
* See <a href="https://docs.advntr.dev/minimessage/">MiniMessage docs</a>
* for more information on the format.
*
* @param message MiniMessage content
*/
default void sendRichMessage(final @NotNull String message) {
this.sendMessage(net.kyori.adventure.text.minimessage.MiniMessage.miniMessage().deserialize(message));
}
/**
* Sends a message with the MiniMessage format to the command sender.
* <p>
* See <a href="https://docs.advntr.dev/minimessage/">MiniMessage docs</a> and <a href="https://docs.advntr.dev/minimessage/dynamic-replacements">MiniMessage Placeholders docs</a>
* for more information on the format.
*
* @param message MiniMessage content
* @param resolvers resolvers to use
*/
default void sendRichMessage(final @NotNull String message, final net.kyori.adventure.text.minimessage.tag.resolver.@NotNull TagResolver... resolvers) {
this.sendMessage(net.kyori.adventure.text.minimessage.MiniMessage.miniMessage().deserialize(message, resolvers));
}
/**
* Sends a plain message to the command sender.
*
* @param message plain message
*/
default void sendPlainMessage(final @NotNull String message) {
this.sendMessage(net.kyori.adventure.text.Component.text(message));
}
// Paper end
}