Package net.blueva.arcade.api.setup
Class SetupContext<P,C,L>
java.lang.Object
net.blueva.arcade.api.setup.SetupContext<P,C,L>
- Type Parameters:
P- the player type (platform-specific)C- the command sender type (platform-specific)L- the location type (platform-specific)
Context passed to setup handlers when executing commands.
This context contains all information needed to handle a setup command, including the command sender, arena being configured, command arguments, and access to data and selection APIs for arena configuration.
-
Constructor Summary
ConstructorsConstructorDescriptionSetupContext(C sender, P player, int arenaId, String gameId, String[] args, int startIndex, SetupDataAPI<L> dataAPI, SetupSelectionAPI<P, L> selectionAPI, MessageAPI<P> messageAPI) Deprecated.SetupContext(C sender, P player, int arenaId, String gameId, String[] args, int startIndex, SetupDataAPI<L> dataAPI, SetupSelectionAPI<P, L> selectionAPI, MessageAPI<P> messageAPI, SchedulerAPI<?, L> schedulerAPI) Creates a new setup context. -
Method Summary
Modifier and TypeMethodDescriptionintGet arena ID being configured.getArg(int index) Get argument at specific index, or null if out of bounds.String[]getArgs()Get all command arguments.getData()Get data API for saving/loading game configuration.Get game ID being configured.getHandlerArg(int relativeIndex) Get handler-specific argument at relative index.intGet number of handler-specific arguments.Get player if sender is a player, null otherwise.SchedulerAPI<?, L> Get scheduler API for running world-thread tasks from setup handlers.Get selection API for getting player's position selections.Get command sender (player or console).intGet index where handler-specific arguments start.booleanhasHandlerArgs(int count) Check if handler has enough arguments.booleanisPlayer()Check if sender is a player.
-
Constructor Details
-
SetupContext
@Deprecated public SetupContext(C sender, P player, int arenaId, String gameId, String[] args, int startIndex, SetupDataAPI<L> dataAPI, SetupSelectionAPI<P, L> selectionAPI, MessageAPI<P> messageAPI) Deprecated.Use the constructor that accepts aSchedulerAPIparameter instead. -
SetupContext
public SetupContext(C sender, P player, int arenaId, String gameId, String[] args, int startIndex, SetupDataAPI<L> dataAPI, SetupSelectionAPI<P, L> selectionAPI, MessageAPI<P> messageAPI, SchedulerAPI<?, L> schedulerAPI) Creates a new setup context.- Parameters:
sender- the command sender (player or console)player- the player, ornullif the sender is the consolearenaId- the arena being configuredgameId- the game module being configuredargs- full command argumentsstartIndex- index where handler-specific arguments startdataAPI- data API for saving/loading game configurationselectionAPI- selection API for getting player position selectionsmessageAPI- message API for sending formatted messagesschedulerAPI- scheduler API for running world-thread tasks from setup handlers- Since:
- 3.2
-
-
Method Details
-
getSender
Get command sender (player or console). -
getPlayer
Get player if sender is a player, null otherwise. -
isPlayer
public boolean isPlayer()Check if sender is a player. -
getArenaId
public int getArenaId()Get arena ID being configured. -
getGameId
Get game ID being configured. -
getArgs
Get all command arguments. Example: [game, 1, race, spawn, add] for "/baa game 1 race spawn add" -
getStartIndex
public int getStartIndex()Get index where handler-specific arguments start. For "/baa game 1 race spawn add", if handler handles "spawn", startIndex = 4 -
getArg
Get argument at specific index, or null if out of bounds. -
getHandlerArg
Get handler-specific argument at relative index. getHandlerArg(0) returns first arg after the handler subcommand. Example: "/baa game 1 race spawn add" If handler handles "spawn", getHandlerArg(0) = "add" -
getHandlerArgCount
public int getHandlerArgCount()Get number of handler-specific arguments. -
hasHandlerArgs
public boolean hasHandlerArgs(int count) Check if handler has enough arguments. -
getData
Get data API for saving/loading game configuration. -
getSelection
Get selection API for getting player's position selections. -
getMessagesAPI
-
getSchedulerAPI
Get scheduler API for running world-thread tasks from setup handlers.This allows setup handlers to schedule tasks on the world thread without having to use
world.execute()directly.- Returns:
- the scheduler API, or
nullif not available - Since:
- 3.2
-
SchedulerAPIparameter instead.