Mirror von
https://github.com/PaperMC/Velocity.git
synchronisiert 2024-12-26 00:00:55 +01:00
Add CommandSource#sendRichMessage and #sendPlainMessage (#1256)
Dieser Commit ist enthalten in:
Ursprung
74c932e579
Commit
d330236b09
@ -9,10 +9,52 @@ package com.velocitypowered.api.command;
|
|||||||
|
|
||||||
import com.velocitypowered.api.permission.PermissionSubject;
|
import com.velocitypowered.api.permission.PermissionSubject;
|
||||||
import net.kyori.adventure.audience.Audience;
|
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}.
|
* Represents something that can be used to run a {@link Command}.
|
||||||
*/
|
*/
|
||||||
public interface CommandSource extends Audience, PermissionSubject {
|
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));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren