Package com.ultikits.ultitools
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
UltiTools plugin main class.
- Version:
- 6.0.7
- Author:
- wisdommen, qianmo
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate CommandExecutionManagerprivate final CommandManagerprivate ConfigManagerprivate DataStoreD-03: the ten current blocked commands, shipped as the operator-editable blocklist's default.D-15: the default editable-root set — plugin configs and historical logs.private DependenceManagersprivate ErrorReportCollectorprivate EventBusprivate FileOperationManagerprivate Languageprivate final ListenerManagerprivate LogStreamManagerprivate static final Loggerprivate PanelResponderRegistryThe 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 viagetPanelResponderRegistry()(generated byGetterabove) from bothPluginInitiationUtils#handleInboundMessage's dispatch andPluginManager's two module-unload sites.private PlayerEventManagerprivate PluginManagerprivate RemoteActionLogThe single accessorPluginInitiationUtils's capability gate and every WebSocket manager use to append action-log lines —getRemoteActionLog()(generated byGetterabove).private ServerMonitorManagerprivate ServerPropertiesManagerprivate static UltiToolsprivate URLClassLoaderprivate UpdateManagerprivate static final PatternFields inherited from interface com.ultikits.ultitools.interfaces.Localized
LANGUAGE_EXTENSIONS -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate booleancollectModuleJarUrls(File pluginDir) Scan a directory for module plugin JARs and collect the URLs of the ones that passSecurityPolicy.isValidModuleJar(File)— a JAR is validated before its URL is added, never after.static org.bukkit.configuration.file.YamlConfigurationgetEnv()Retrieves the YAML configuration object containing environment variables.private InputStreamgetFileResource(String filename) Retrieves the input stream for the specified file resource.static UltiToolsReturns the instance of the UltiTools.static ClassLoaderGet the JavaPlugin class loader.private URL[]Get URLs for module plugin JARs in the UltiTools/plugins directory.static intGets the version of UltiTools.Get server jar file URL.Internationalization method that translates the given string based on the current language.private voidprivate booleanprivate voidprivate voidprivate voidprivate voidprivate voidMigrates the framework's ownconfig.ymlin place, invoked fromonEnable()afterJavaPlugin.saveDefaultConfig()(called inonLoad()) and beforeinitWebSocketManagers().private static booleanmigrateCapabilitiesConfig(File configFile, Logger logger) The actual migration logic, taking explicit inputs rather than readingthis— the same test-seam shapeparsePluginVersion(String)already uses, so this is callable from a plain JUnit test with no live Bukkit server.private static booleanmigrateKeyIfAbsent(org.bukkit.configuration.file.YamlConfiguration config, String path, Object value, List<String> commentLines) SetspathtovaluewithcommentLinesonly when it is absent fromconfig— never overwrites a value the operator already set (04-CONTEXT D-01).voidvoidonEnable()voidonLoad()(package private) static intparsePluginVersion(String versionString) private voidvoidReloads the UltiTools plugins by calling the reload method in the PluginManager.private voidscheduleStartupMessages(boolean loginSuccess) Returns the supported language codes.Methods inherited from class org.bukkit.plugin.java.JavaPlugin
getClassLoader, getCommand, getConfig, getDataFolder, getDefaultBiomeProvider, getDefaultWorldGenerator, getDescription, getFile, getLifecycleManager, getLogger, getPlugin, getPluginLoader, getPluginMeta, getProvidingPlugin, getResource, getServer, getTextResource, init, init, isEnabled, isNaggable, onCommand, onTabComplete, registerCommand, registerCommand, registerCommand, registerCommand, reloadConfig, saveConfig, saveDefaultConfig, saveResource, setEnabled, setNaggable, toStringMethods inherited from class org.bukkit.plugin.PluginBase
equals, getName, hashCode, namespaceMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.bukkit.plugin.Plugin
getComponentLogger, getDataPath, getLog4JLogger, getSLF4JLogger
-
Field Details
-
VERSION_PATTERN
-
MODULE_SCAN_LOGGER
-
DEFAULT_COMMAND_BLOCKLIST
D-03: the ten current blocked commands, shipped as the operator-editable blocklist's default. -
COMMAND_BLOCKLIST_COMMENT
-
DEFAULT_EDITABLE_ROOTS
D-15: the default editable-root set — plugin configs and historical logs. -
EDITABLE_ROOTS_COMMENT
-
ACTION_LOG_SIZE_COMMENT
-
ACTION_LOG_FILES_COMMENT
-
ultiTools
-
listenerManager
-
commandManager
-
dependenceManagers
-
ultiToolsClassLoader
-
language
-
pluginManager
-
configManager
-
dataStore
-
serverMonitorManager
-
commandExecutionManager
-
fileOperationManager
-
logStreamManager
-
playerEventManager
-
serverPropertiesManager
-
updateManager
-
eventBus
-
errorReportCollector
-
remoteActionLog
The single accessorPluginInitiationUtils's capability gate and every WebSocket manager use to append action-log lines —getRemoteActionLog()(generated byGetterabove). -
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 viagetPanelResponderRegistry()(generated byGetterabove) from bothPluginInitiationUtils#handleInboundMessage's dispatch andPluginManager's two module-unload sites. Constructed unconditionally ininitWebSocketManagers()alongside the seven WebSocket managers — not gated by anyCapability, 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
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
-
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:
onLoadin interfaceorg.bukkit.plugin.Plugin- Overrides:
onLoadin classorg.bukkit.plugin.java.JavaPlugin
-
onEnable
public void onEnable()- Specified by:
onEnablein interfaceorg.bukkit.plugin.Plugin- Overrides:
onEnablein classorg.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 ownconfig.ymlin place, invoked fromonEnable()afterJavaPlugin.saveDefaultConfig()(called inonLoad()) and beforeinitWebSocketManagers(). ReloadsJavaPlugin.getConfig()when the file changed, so every manager constructed afterward sees the merged file. -
migrateCapabilitiesConfig
The actual migration logic, taking explicit inputs rather than readingthis— the same test-seam shapeparsePluginVersion(String)already uses, so this is callable from a plain JUnit test with no live Bukkit server. Never reaches forAbstractConfigEntity/@ConfigEntity— that mechanism is scoped to module-authored config POJOs and never adds a key to the framework's own existingconfig.yml. What transfers is the underlying Paper techniqueAbstractConfigEntity.init()uses: aYamlConfigurationwithoptions().parseComments(true)set beforeload()—load()reads the option itself — plusconfig.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- theconfig.ymlfile to migratelogger- where to log a load failure- Returns:
trueif the file was modified
-
migrateKeyIfAbsent
private static boolean migrateKeyIfAbsent(org.bukkit.configuration.file.YamlConfiguration config, String path, Object value, List<String> commentLines) SetspathtovaluewithcommentLinesonly when it is absent fromconfig— never overwrites a value the operator already set (04-CONTEXT D-01).- Returns:
trueif 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:
onDisablein interfaceorg.bukkit.plugin.Plugin- Overrides:
onDisablein classorg.bukkit.plugin.java.JavaPlugin
-
reloadPlugins
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
Returns the supported language codes. -
i18n
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
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
Get server jar file URL.- Returns:
- Server jar file URL
-
getModuleUrls
Get URLs for module plugin JARs in the UltiTools/plugins directory.- Returns:
- Array of URLs for module plugin JARs
-
collectModuleJarUrls
Scan a directory for module plugin JARs and collect the URLs of the ones that passSecurityPolicy.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
pluginDirisnullor does not exist
-
getJavaPluginClassLoader
Get the JavaPlugin class loader. This ensures all class loading operations use the correct parent class loader.- Returns:
- JavaPlugin class loader
-