Package me.croabeast.common.reflect
Class Craft.Server
java.lang.Object
me.croabeast.common.reflect.Craft.Server
- Enclosing class:
Craft
Contains server-related utility methods using reflection.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classProvides access to internal Minecraft server functions. -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionorg.bukkit.configuration.file.FileConfigurationLoads the commands configuration file into aFileConfiguration.Retrieves aFilebased on a provided file name from the server options.Retrieves the Bukkit server's configuration file.org.bukkit.command.SimpleCommandMapRetrieves the server'sSimpleCommandMapvia reflection.Retrieves the server's commands configuration file.Retrieves a map of known commands from the command map.voidInvokes the internal method to load the server icon.voidReloads the server's commands configuration file and updates command registrations.voidvoidsyncCommands(Collection<String> collection) Synchronizes the server commands with a given collection of command names.voidUpdates command information for all online players.
-
Field Details
-
INSTANCE
A singletonReflectorinstance wrapping the current Bukkit server.
-
-
Constructor Details
-
Server
public Server()
-
-
Method Details
-
loadServerIcon
public void loadServerIcon()Invokes the internal method to load the server icon. -
fileFrom
Retrieves aFilebased on a provided file name from the server options.- Parameters:
fileName- the name of the file to retrieve- Returns:
- the corresponding
File
-
getBukkit
Retrieves the Bukkit server's configuration file.- Returns:
- the configuration
File
-
getCommands
Retrieves the server's commands configuration file.- Returns:
- the commands configuration
File
-
createCommandsConfiguration
public org.bukkit.configuration.file.FileConfiguration createCommandsConfiguration()Loads the commands configuration file into aFileConfiguration.- Returns:
- the
FileConfigurationrepresenting the commands configuration
-
getCommandMap
public org.bukkit.command.SimpleCommandMap getCommandMap()Retrieves the server'sSimpleCommandMapvia reflection.- Returns:
- the server's command map
-
getKnownCommands
Retrieves a map of known commands from the command map.- Returns:
- a
Mapof command names toCommandobjects
-
updateCommands
public void updateCommands()Updates command information for all online players.For server versions 13.0 or higher, this method calls
updateCommands()on each player. -
syncCommands
Synchronizes the server commands with a given collection of command names.This method removes any commands from the command dispatcher that are not in the provided collection, and then updates the commands for all online players.
- Parameters:
collection- a collection of command names to synchronize
-
syncCommands
public void syncCommands() -
reloadCommandsFile
public void reloadCommandsFile()Reloads the server's commands configuration file and updates command registrations.For Paper servers (version >= 12), it invokes the method to reload command aliases. Otherwise, it removes and unregisters existing command aliases, reloads the configuration, updates internal settings, and re-registers commands.
-