From 79a8f4bd933ecfd4fbfef2817aebaa18bd13c78d Mon Sep 17 00:00:00 2001 From: LeoDog896 Date: Tue, 23 Mar 2021 11:50:42 -0400 Subject: [PATCH] General style alignment --- .../server/extensions/DiscoveredExtension.java | 12 ++++++++++-- .../minestom/server/extensions/ExtensionManager.java | 6 +++--- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/main/java/net/minestom/server/extensions/DiscoveredExtension.java b/src/main/java/net/minestom/server/extensions/DiscoveredExtension.java index 28945fbfd..b77b688ed 100644 --- a/src/main/java/net/minestom/server/extensions/DiscoveredExtension.java +++ b/src/main/java/net/minestom/server/extensions/DiscoveredExtension.java @@ -95,6 +95,7 @@ public final class DiscoveredExtension { extension.name = extension.loadStatus.name(); return; } + if (!extension.name.matches(NAME_REGEX)) { LOGGER.error("Extension '{}' specified an invalid name.", extension.name); LOGGER.error("Extension '{}' will not be loaded.", extension.name); @@ -104,6 +105,7 @@ public final class DiscoveredExtension { extension.name = extension.loadStatus.name(); return; } + if (extension.entrypoint == null) { LOGGER.error("Extension '{}' did not specify an entry point (via 'entrypoint').", extension.name); LOGGER.error("Extension '{}' will not be loaded.", extension.name); @@ -113,6 +115,7 @@ public final class DiscoveredExtension { extension.entrypoint = extension.loadStatus.name(); return; } + // Handle defaults // If we reach this code, then the extension will most likely be loaded: if (extension.version == null) { @@ -120,19 +123,24 @@ public final class DiscoveredExtension { LOGGER.warn("Extension '{}' will continue to load but should specify a plugin version.", extension.name); extension.version = "Unspecified"; } + if (extension.mixinConfig == null) { extension.mixinConfig = ""; } + if (extension.authors == null) { extension.authors = new String[0]; } + if (extension.codeModifiers == null) { extension.codeModifiers = new String[0]; } + // No dependencies were specified if (extension.dependencies == null) { extension.dependencies = new String[0]; } + // No external dependencies were specified; if (extension.externalDependencies == null) { extension.externalDependencies = new ExternalDependencies(); @@ -177,11 +185,11 @@ public final class DiscoveredExtension { } } - static final class ExternalDependencies { + public static final class ExternalDependencies { Repository[] repositories = new Repository[0]; String[] artifacts = new String[0]; - static class Repository { + public static class Repository { String name = ""; String url = ""; } diff --git a/src/main/java/net/minestom/server/extensions/ExtensionManager.java b/src/main/java/net/minestom/server/extensions/ExtensionManager.java index 5a7eca484..ddf36b68a 100644 --- a/src/main/java/net/minestom/server/extensions/ExtensionManager.java +++ b/src/main/java/net/minestom/server/extensions/ExtensionManager.java @@ -735,7 +735,7 @@ public class ExtensionManager { */ public static void loadCodeModifiersEarly() { // allow users to disable early code modifier load - if("true".equalsIgnoreCase(System.getProperty(DISABLE_EARLY_LOAD_SYSTEM_KEY))) { + if ("true".equalsIgnoreCase(System.getProperty(DISABLE_EARLY_LOAD_SYSTEM_KEY))) { return; } LOGGER.info("Early load of code modifiers from extensions."); @@ -765,8 +765,8 @@ public class ExtensionManager { public void unloadAllExtensions() { // copy names, as the extensions map will be modified via the calls to unload Set extensionNames = new HashSet<>(extensions.keySet()); - for(String ext : extensionNames) { - if(extensions.containsKey(ext)) { // is still loaded? Because extensions can depend on one another, it might have already been unloaded + for (String ext : extensionNames) { + if (extensions.containsKey(ext)) { // is still loaded? Because extensions can depend on one another, it might have already been unloaded unloadExtension(ext); } }