Class MessageFormatter
- java.lang.Object
-
- ca.stellardrift.permissionsex.minecraft.command.MessageFormatter
-
public class MessageFormatter extends Object
Message formatting parameters for the current engine instance.
-
-
Field Summary
Fields Modifier and Type Field Description static net.kyori.adventure.text.format.TextColorDEFAULT_HIGHLIGHT_COLORstatic net.kyori.adventure.text.format.TextColorDEFAULT_MESSAGE_COLORstatic net.kyori.adventure.text.ComponentEQUALS_SIGNstatic net.kyori.adventure.text.ComponentSLASH
-
Constructor Summary
Constructors Constructor Description MessageFormatter(MinecraftPermissionsEx<?> manager)Create a new formatter with default message and highlight colours.MessageFormatter(MinecraftPermissionsEx<?> manager, net.kyori.adventure.text.format.TextColor messageColor, net.kyori.adventure.text.format.TextColor highlightColor)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <C extends net.kyori.adventure.text.BuildableComponent<C,B>,B extends net.kyori.adventure.text.ComponentBuilder<C,B>>
net.kyori.adventure.text.Componentbutton(B builder, ButtonType type, @Nullable net.kyori.adventure.text.ComponentLike tooltip, String command, boolean execute)Create a clickable button that will execute a command or suggest a command to be executedprotected <I> @Nullable StringfriendlyName(ca.stellardrift.permissionsex.subject.SubjectRef<I> reference)<C extends net.kyori.adventure.text.BuildableComponent<C,B>,B extends net.kyori.adventure.text.ComponentBuilder<C,B>>
Bheader(B builder)net.kyori.adventure.text.format.Style.Builderheader(net.kyori.adventure.text.format.Style.Builder builder)net.kyori.adventure.text.format.TextColorhighlightColor()The color to be used for highlighted parts of messages.<C extends net.kyori.adventure.text.BuildableComponent<C,B>,B extends net.kyori.adventure.text.ComponentBuilder<C,B>>
Bhl(B builder)net.kyori.adventure.text.format.Style.Builderhl(net.kyori.adventure.text.format.Style.Builder builder)net.kyori.adventure.text.format.TextColorresponseColor()Get the colour to be used for standard command responses.net.kyori.adventure.text.Componentsubject(ca.stellardrift.permissionsex.subject.CalculatedSubject subject)<I> net.kyori.adventure.text.Componentsubject(ca.stellardrift.permissionsex.subject.SubjectRef<I> subject)Print the subject in a user-friendly manner.protected StringtransformCommand(String cmd)Given a command in standard format, correct it to refer to specifically the proxy format.
-
-
-
Field Detail
-
DEFAULT_MESSAGE_COLOR
public static final net.kyori.adventure.text.format.TextColor DEFAULT_MESSAGE_COLOR
-
DEFAULT_HIGHLIGHT_COLOR
public static final net.kyori.adventure.text.format.TextColor DEFAULT_HIGHLIGHT_COLOR
-
EQUALS_SIGN
public static final net.kyori.adventure.text.Component EQUALS_SIGN
-
SLASH
public static final net.kyori.adventure.text.Component SLASH
-
-
Constructor Detail
-
MessageFormatter
public MessageFormatter(MinecraftPermissionsEx<?> manager)
Create a new formatter with default message and highlight colours.- Parameters:
manager- the permissions manager
-
MessageFormatter
public MessageFormatter(MinecraftPermissionsEx<?> manager, net.kyori.adventure.text.format.TextColor messageColor, net.kyori.adventure.text.format.TextColor highlightColor)
-
-
Method Detail
-
responseColor
public final net.kyori.adventure.text.format.TextColor responseColor()
Get the colour to be used for standard command responses.- Returns:
- the response color
-
highlightColor
public final net.kyori.adventure.text.format.TextColor highlightColor()
The color to be used for highlighted parts of messages.- Returns:
- the highlight color
-
transformCommand
protected String transformCommand(String cmd)
Given a command in standard format, correct it to refer to specifically the proxy format.- Parameters:
cmd- the original command- Returns:
- the transformed command
-
friendlyName
protected <I> @Nullable String friendlyName(ca.stellardrift.permissionsex.subject.SubjectRef<I> reference)
-
subject
public final net.kyori.adventure.text.Component subject(ca.stellardrift.permissionsex.subject.CalculatedSubject subject)
-
subject
public <I> net.kyori.adventure.text.Component subject(ca.stellardrift.permissionsex.subject.SubjectRef<I> subject)
Print the subject in a user-friendly manner. May link to the subject info printout- Parameters:
subject- The subject to show- Returns:
- the formatted value
-
button
public <C extends net.kyori.adventure.text.BuildableComponent<C,B>,B extends net.kyori.adventure.text.ComponentBuilder<C,B>> net.kyori.adventure.text.Component button(B builder, ButtonType type, @Nullable net.kyori.adventure.text.ComponentLike tooltip, String command, boolean execute)
Create a clickable button that will execute a command or suggest a command to be executed- Parameters:
type- The style of button to presenttooltip- A tooltip to optionally show when hovering over a buttoncommand- The command to executeexecute- Whether the command provided will be executed or only added to the user's input- Returns:
- the formatted text
-
header
public final <C extends net.kyori.adventure.text.BuildableComponent<C,B>,B extends net.kyori.adventure.text.ComponentBuilder<C,B>> B header(B builder)
-
hl
public final <C extends net.kyori.adventure.text.BuildableComponent<C,B>,B extends net.kyori.adventure.text.ComponentBuilder<C,B>> B hl(B builder)
-
header
public final net.kyori.adventure.text.format.Style.Builder header(net.kyori.adventure.text.format.Style.Builder builder)
-
hl
public final net.kyori.adventure.text.format.Style.Builder hl(net.kyori.adventure.text.format.Style.Builder builder)
-
-