Class Craft.Server

java.lang.Object
me.croabeast.common.reflect.Craft.Server
Enclosing class:
Craft

public static class Craft.Server extends Object
Contains server-related utility methods using reflection.
  • Field Details

    • INSTANCE

      public final Reflector INSTANCE
      A singleton Reflector instance 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

      public File fileFrom(String fileName)
      Retrieves a File based on a provided file name from the server options.
      Parameters:
      fileName - the name of the file to retrieve
      Returns:
      the corresponding File
    • getBukkit

      public File getBukkit()
      Retrieves the Bukkit server's configuration file.
      Returns:
      the configuration File
    • getCommands

      public 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 a FileConfiguration.
      Returns:
      the FileConfiguration representing the commands configuration
    • getCommandMap

      public org.bukkit.command.SimpleCommandMap getCommandMap()
      Retrieves the server's SimpleCommandMap via reflection.
      Returns:
      the server's command map
    • getKnownCommands

      public Map<String,org.bukkit.command.Command> getKnownCommands()
      Retrieves a map of known commands from the command map.
      Returns:
      a Map of command names to Command objects
    • 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

      public void syncCommands(Collection<String> collection)
      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.