Class UltiTools

java.lang.Object
org.bukkit.plugin.PluginBase
org.bukkit.plugin.java.JavaPlugin
com.ultikits.ultitools.UltiTools
All Implemented Interfaces:
Localized, io.papermc.paper.plugin.lifecycle.event.LifecycleEventOwner, net.kyori.adventure.key.Namespaced, org.bukkit.command.CommandExecutor, org.bukkit.command.TabCompleter, org.bukkit.command.TabExecutor, org.bukkit.plugin.Plugin

public final class UltiTools extends org.bukkit.plugin.java.JavaPlugin implements Localized
UltiTools plugin main class.
Version:
6.0.7
Author:
wisdommen, qianmo
  • Field Details

    • VERSION_PATTERN

      private static final Pattern VERSION_PATTERN
    • MODULE_SCAN_LOGGER

      private static final Logger MODULE_SCAN_LOGGER
    • DEFAULT_COMMAND_BLOCKLIST

      private static final List<String> DEFAULT_COMMAND_BLOCKLIST
      D-03: the ten current blocked commands, shipped as the operator-editable blocklist's default.
    • COMMAND_BLOCKLIST_COMMENT

      private static final List<String> COMMAND_BLOCKLIST_COMMENT
    • DEFAULT_EDITABLE_ROOTS

      private static final List<String> DEFAULT_EDITABLE_ROOTS
      D-15: the default editable-root set — plugin configs and historical logs.
    • EDITABLE_ROOTS_COMMENT

      private static final List<String> EDITABLE_ROOTS_COMMENT
    • ACTION_LOG_SIZE_COMMENT

      private static final List<String> ACTION_LOG_SIZE_COMMENT
    • ACTION_LOG_FILES_COMMENT

      private static final List<String> ACTION_LOG_FILES_COMMENT
    • ultiTools

      private static UltiTools ultiTools
    • listenerManager

      private final ListenerManager listenerManager
    • commandManager

      private final CommandManager commandManager
    • dependenceManagers

      private DependenceManagers dependenceManagers
    • ultiToolsClassLoader

      private URLClassLoader ultiToolsClassLoader
    • language

      private Language language
    • pluginManager

      private PluginManager pluginManager
    • configManager

      private ConfigManager configManager
    • dataStore

      private DataStore dataStore
    • serverMonitorManager

      private ServerMonitorManager serverMonitorManager
    • commandExecutionManager

      private CommandExecutionManager commandExecutionManager
    • fileOperationManager

      private FileOperationManager fileOperationManager
    • logStreamManager

      private LogStreamManager logStreamManager
    • playerEventManager

      private PlayerEventManager playerEventManager
    • serverPropertiesManager

      private ServerPropertiesManager serverPropertiesManager
    • updateManager

      private UpdateManager updateManager
    • eventBus

      private EventBus eventBus
    • errorReportCollector

      private ErrorReportCollector errorReportCollector
    • remoteActionLog

      private RemoteActionLog remoteActionLog
      The single accessor PluginInitiationUtils's capability gate and every WebSocket manager use to append action-log lines — getRemoteActionLog() (generated by Getter above).
    • panelResponderRegistry

      private PanelResponderRegistry panelResponderRegistry
      The single-owner registry a module uses to claim a request/response responder for a panel message type the framework itself does not own (WIRE-16, D-26/D-27), reached via getPanelResponderRegistry() (generated by Getter above) from both PluginInitiationUtils#handleInboundMessage's dispatch and PluginManager's two module-unload sites. Constructed unconditionally in initWebSocketManagers() alongside the seven WebSocket managers — not gated by any Capability, since the registry itself holds no data and starts no collection; what flows through it is already gated at the dispatch table it sits behind.
  • Constructor Details

    • UltiTools

      public UltiTools()
  • Method Details

    • getInstance

      public static UltiTools getInstance()
      Returns the instance of the UltiTools.
      Returns:
      the instance of the UltiTools
    • getPluginVersion

      public static int getPluginVersion()
      Gets the version of UltiTools.
      Returns:
      the version of the UltiTools
    • parsePluginVersion

      static int parsePluginVersion(String versionString)
    • getEnv

      public static org.bukkit.configuration.file.YamlConfiguration getEnv()
      Retrieves the YAML configuration object containing environment variables.
      Returns:
      the YAML configuration object
    • onLoad

      public void onLoad()
      Specified by:
      onLoad in interface org.bukkit.plugin.Plugin
      Overrides:
      onLoad in class org.bukkit.plugin.java.JavaPlugin
    • onEnable

      public void onEnable()
      Specified by:
      onEnable in interface org.bukkit.plugin.Plugin
      Overrides:
      onEnable in class org.bukkit.plugin.java.JavaPlugin
    • initDependencies

      private boolean initDependencies()
    • initLanguage

      private void initLanguage()
    • initDataStore

      private void initDataStore()
    • initPluginModules

      private void initPluginModules()
    • migrateCapabilitiesConfig

      private void migrateCapabilitiesConfig()
      Migrates the framework's own config.yml in place, invoked from onEnable() after JavaPlugin.saveDefaultConfig() (called in onLoad()) and before initWebSocketManagers(). Reloads JavaPlugin.getConfig() when the file changed, so every manager constructed afterward sees the merged file.
    • migrateCapabilitiesConfig

      private static boolean migrateCapabilitiesConfig(File configFile, Logger logger)
      The actual migration logic, taking explicit inputs rather than reading this — the same test-seam shape parsePluginVersion(String) already uses, so this is callable from a plain JUnit test with no live Bukkit server. Never reaches for AbstractConfigEntity/@ConfigEntity — that mechanism is scoped to module-authored config POJOs and never adds a key to the framework's own existing config.yml. What transfers is the underlying Paper technique AbstractConfigEntity.init() uses: a YamlConfiguration with options().parseComments(true) set before load() — load() reads the option itself — plus config.setComments(path, ...) on the missing-key branch. Never modifies a value the operator already set and never removes or reorders existing content (04-CONTEXT D-01).
      Parameters:
      configFile - the config.yml file to migrate
      logger - where to log a load failure
      Returns:
      true if the file was modified
    • migrateKeyIfAbsent

      private static boolean migrateKeyIfAbsent(org.bukkit.configuration.file.YamlConfiguration config, String path, Object value, List<String> commentLines)
      Sets path to value with commentLines only when it is absent from config — never overwrites a value the operator already set (04-CONTEXT D-01).
      Returns:
      true if the key was absent and was written
    • initWebSocketManagers

      private void initWebSocketManagers()
    • attemptCloudLogin

      private boolean attemptCloudLogin()
    • initWebSocket

      private void initWebSocket()
    • registerCommands

      private void registerCommands()
    • scheduleStartupMessages

      private void scheduleStartupMessages(boolean loginSuccess)
    • onDisable

      public void onDisable()
      Specified by:
      onDisable in interface org.bukkit.plugin.Plugin
      Overrides:
      onDisable in class org.bukkit.plugin.java.JavaPlugin
    • reloadPlugins

      public void reloadPlugins() throws IOException
      Reloads the UltiTools plugins by calling the reload method in the PluginManager.
      Throws:
      IOException - if an I/O error occurs during the reloading process
    • supported

      public List<String> supported()
      Returns the supported language codes.
      Specified by:
      supported in interface Localized
      Returns:
      a list of supported language codes
      See Also:
    • i18n

      public String i18n(String str)
      Internationalization method that translates the given string based on the current language. If the string is not found in the dictionary, the original string is returned.
      Parameters:
      str - the string to be translated
      Returns:
      the translated string or the original string if not found in the dictionary
    • getFileResource

      private InputStream getFileResource(String filename)
      Retrieves the input stream for the specified file resource.
      Parameters:
      filename - the name of the file resource
      Returns:
      the input stream for the file resource, or null if an I/O error occurs
    • getServerJar

      public URL getServerJar()
      Get server jar file URL.
      Returns:
      Server jar file URL
    • getModuleUrls

      private URL[] getModuleUrls()
      Get URLs for module plugin JARs in the UltiTools/plugins directory.
      Returns:
      Array of URLs for module plugin JARs
    • collectModuleJarUrls

      static List<URL> collectModuleJarUrls(File pluginDir)
      Scan a directory for module plugin JARs and collect the URLs of the ones that pass SecurityPolicy.isValidModuleJar(File) — a JAR is validated before its URL is added, never after. A failing JAR is skipped and named in a WARNING; the scan continues and never throws (D-05: module-granularity skip, not a bootstrap abort).

      Package-private and static so it can be exercised directly by a test against a @TempDir, without standing up the whole plugin.

      Parameters:
      pluginDir - directory to scan for module JARs
      Returns:
      collected URLs of the JARs that passed validation, empty if pluginDir is null or does not exist
    • getJavaPluginClassLoader

      public static ClassLoader getJavaPluginClassLoader()
      Get the JavaPlugin class loader. This ensures all class loading operations use the correct parent class loader.
      Returns:
      JavaPlugin class loader