Package one.tranic.t.base.command.source
Interface CommandSource<C,R>
- Type Parameters:
C- the underlying type representing the source (e.g., CommandSender)R- the player-specific type related to the platform (e.g., Player)
- All Known Implementing Classes:
SystemCommandSource
public interface CommandSource<C,R>
Represents a source implementation that abstracts interactions with various platforms.
-
Method Summary
Modifier and TypeMethodDescriptionintargSize()Retrieves the number of arguments associated with the source.asPlayer()Attempts to retrieve the source as aPlayer.voidClears all boss bars currently shown to the source.voidClears any currently displayed title for the associated entity or source.String[]getArgs()Retrieves the arguments associated with the source.@Nullable LocaleRetrieves the locale associated with this source, identifying the language and regional preferences set for the source.default OperatorRetrieves the operator associated with this source implementation.Retrieves the source entity that this implementation represents.booleanhasPermission(String permission) Checks if the entity associated with this source has the specified permission.voidhideBossBar(@NotNull net.kyori.adventure.bossbar.BossBar bossBar) Hides the specified boss bar from the associated source.booleanisPlayer()Determines if the entity represented by this source is a player.voidsendMessage(@NotNull net.kyori.adventure.text.Component message) Sends a message to the source.voidsendMessage(String message) Sends a message to the source.voidshowBossBar(@NotNull net.kyori.adventure.bossbar.BossBar bossBar) Displays the specified BossBar to the source.voidshowTitle(@NotNull net.kyori.adventure.title.Title title) Displays the specified title to the command source.
-
Method Details
-
getOperator
Retrieves the operator associated with this source implementation.The operator typically represents the entity that executes administrative or management tasks.
- Returns:
- the operator, defaulting to the system console operator.
-
getSource
C getSource()Retrieves the source entity that this implementation represents.- Returns:
- the source entity of type C
-
isPlayer
boolean isPlayer()Determines if the entity represented by this source is a player.- Returns:
- true if the source is a player, otherwise false
-
getArgs
String[] getArgs()Retrieves the arguments associated with the source. The arguments are typically used to provide additional information or parameters related to a command or action.- Returns:
- an array of strings representing the arguments associated with the source
-
argSize
int argSize()Retrieves the number of arguments associated with the source.- Returns:
- the number of arguments as an integer.
-
getLocale
Retrieves the locale associated with this source, identifying the language and regional preferences set for the source.- Returns:
- the locale representing the language and region preferences, or null
if the client is not connected to any server.
If the source is not a player, it returns the environment's default locale.
-
hasPermission
Checks if the entity associated with this source has the specified permission.- Parameters:
permission- the permission node to check for- Returns:
- true if the entity has the specified permission, otherwise false
-
sendMessage
Sends a message to the source.- Parameters:
message- the message to be sent
-
sendMessage
void sendMessage(@NotNull @NotNull net.kyori.adventure.text.Component message) Sends a message to the source.- Parameters:
message- the message to be sent; must not be null
-
showBossBar
void showBossBar(@NotNull @NotNull net.kyori.adventure.bossbar.BossBar bossBar) Displays the specified BossBar to the source. The BossBar provides visual feedback typically used to represent progress, health, or timed events in a graphical interface.- Parameters:
bossBar- the BossBar to be displayed; must not be null
-
hideBossBar
void hideBossBar(@NotNull @NotNull net.kyori.adventure.bossbar.BossBar bossBar) Hides the specified boss bar from the associated source.- Parameters:
bossBar- the boss bar to be hidden; must not be null
-
clearBossBars
void clearBossBars()Clears all boss bars currently shown to the source.This method removes all active boss bar instances displayed to the command source, ensuring a clean slate without any remaining visual indicators associated with boss bars.
-
showTitle
void showTitle(@NotNull @NotNull net.kyori.adventure.title.Title title) Displays the specified title to the command source.- Parameters:
title- the title to be shown; must not be null
-
clearTitle
void clearTitle()Clears any currently displayed title for the associated entity or source. This method is intended to remove any active on-screen title graphics, including subtitles, from the user's view. -
asPlayer
Attempts to retrieve the source as aPlayer. If the source does not represent a player, this method will returnnull.- Returns:
- a
Player<R>instance if the source is a player, ornullif the source is not a player.
-