13
0
geforkt von Mirrors/Velocity

Add CommandSource#sendRichMessage and #sendPlainMessage (#1256)

Dieser Commit ist enthalten in:
Adrian 2024-02-27 12:08:53 -05:00 committet von GitHub
Ursprung 74c932e579
Commit d330236b09
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: B5690EEEBB952194

Datei anzeigen

@ -9,10 +9,52 @@ package com.velocitypowered.api.command;
import com.velocitypowered.api.permission.PermissionSubject;
import net.kyori.adventure.audience.Audience;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.minimessage.MiniMessage;
import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver;
import org.jetbrains.annotations.NotNull;
/**
* Represents something that can be used to run a {@link Command}.
*/
public interface CommandSource extends Audience, PermissionSubject {
/**
* Sends a message with the MiniMessage format to this source.
*
* @param message MiniMessage content
* @see <a href="https://docs.advntr.dev/minimessage/format.html">MiniMessage docs</a>
* for more information on the format.
**/
default void sendRichMessage(final @NotNull String message) {
this.sendMessage(MiniMessage.miniMessage().deserialize(message));
}
/**
* Sends a message with the MiniMessage format to this source.
*
* @param message MiniMessage content
* @param resolvers resolvers to use
* @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.
**/
default void sendRichMessage(
final @NotNull String message,
final @NotNull TagResolver @NotNull... resolvers
) {
this.sendMessage(MiniMessage.miniMessage().deserialize(message, resolvers));
}
/**
* Sends a plain message to this source.
*
* @param message plain message
* @apiNote This method will not apply any form of parse to the text provided,
* however, it is recommended not to use legacy color codes as this is a deprecated format
* and not recommended.
*/
default void sendPlainMessage(final @NotNull String message) {
this.sendMessage(Component.text(message));
}
}