Fix Inconsistencies with Paper Plugin Names (#9098)
This commit is contained in:
parent
6d2121efde
commit
dd216c1f09
21 changed files with 101 additions and 65 deletions
|
@ -594,7 +594,7 @@ index 0000000000000000000000000000000000000000..89bf48fd581ee6580b91e2eb31dd532c
|
|||
+}
|
||||
diff --git a/src/main/java/io/papermc/paper/plugin/bootstrap/PluginProviderContextImpl.java b/src/main/java/io/papermc/paper/plugin/bootstrap/PluginProviderContextImpl.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..2e450a9fce66e63ec94ee3d2579265eda28a1c3f
|
||||
index 0000000000000000000000000000000000000000..deffde92350f7c74694c2aa69799de446a3c3e0a
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/io/papermc/paper/plugin/bootstrap/PluginProviderContextImpl.java
|
||||
@@ -0,0 +1,45 @@
|
||||
|
@ -612,13 +612,13 @@ index 0000000000000000000000000000000000000000..2e450a9fce66e63ec94ee3d2579265ed
|
|||
+ ComponentLogger logger, Path pluginSource) implements PluginProviderContext {
|
||||
+
|
||||
+ public static PluginProviderContextImpl of(PluginMeta config, ComponentLogger logger, Path pluginSource) {
|
||||
+ Path dataFolder = PluginInitializerManager.instance().pluginDirectoryPath().resolve(config.getDisplayName());
|
||||
+ Path dataFolder = PluginInitializerManager.instance().pluginDirectoryPath().resolve(config.getName());
|
||||
+
|
||||
+ return new PluginProviderContextImpl(config, dataFolder, logger, pluginSource);
|
||||
+ }
|
||||
+
|
||||
+ public static PluginProviderContextImpl of(PluginProvider<?> provider, Path pluginFolder) {
|
||||
+ Path dataFolder = pluginFolder.resolve(provider.getMeta().getDisplayName());
|
||||
+ Path dataFolder = pluginFolder.resolve(provider.getMeta().getName());
|
||||
+
|
||||
+ return new PluginProviderContextImpl(provider.getMeta(), dataFolder, provider.getLogger(), provider.getSource());
|
||||
+ }
|
||||
|
@ -813,7 +813,7 @@ index 0000000000000000000000000000000000000000..f9a2c55a354c877749db3f92956de802
|
|||
+}
|
||||
diff --git a/src/main/java/io/papermc/paper/plugin/entrypoint/classloader/PaperPluginClassLoader.java b/src/main/java/io/papermc/paper/plugin/entrypoint/classloader/PaperPluginClassLoader.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..79995ab1b624d7c7aaaa467a86255ad97385cf72
|
||||
index 0000000000000000000000000000000000000000..56fc3e0984861e8ddb597cad3c0a0e0aca9606e6
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/io/papermc/paper/plugin/entrypoint/classloader/PaperPluginClassLoader.java
|
||||
@@ -0,0 +1,207 @@
|
||||
|
@ -966,7 +966,7 @@ index 0000000000000000000000000000000000000000..79995ab1b624d7c7aaaa467a86255ad9
|
|||
+ PluginMeta config = this.configuration;
|
||||
+ PluginDescriptionFile pluginDescriptionFile = new PluginDescriptionFile(
|
||||
+ config.getName(),
|
||||
+ config.getName().replace('_', ' '),
|
||||
+ config.getName(),
|
||||
+ config.getProvidedPlugins(),
|
||||
+ config.getMainClass(),
|
||||
+ "", // Classloader load order api
|
||||
|
@ -4387,12 +4387,13 @@ index 0000000000000000000000000000000000000000..e3430f535e8e9c3b8b44bf2daece8c47
|
|||
+}
|
||||
diff --git a/src/main/java/io/papermc/paper/plugin/provider/configuration/PaperPluginMeta.java b/src/main/java/io/papermc/paper/plugin/provider/configuration/PaperPluginMeta.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..7605efe37ac4a63cb95c8c64c576e93c0e676cc0
|
||||
index 0000000000000000000000000000000000000000..95cc4dbe336e37f01d9f478068fd21a387754a91
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/io/papermc/paper/plugin/provider/configuration/PaperPluginMeta.java
|
||||
@@ -0,0 +1,227 @@
|
||||
@@ -0,0 +1,232 @@
|
||||
+package io.papermc.paper.plugin.provider.configuration;
|
||||
+
|
||||
+import com.google.common.base.Preconditions;
|
||||
+import com.google.common.collect.ImmutableList;
|
||||
+import io.leangen.geantyref.TypeToken;
|
||||
+import io.papermc.paper.configuration.constraint.Constraint;
|
||||
|
@ -4411,6 +4412,7 @@ index 0000000000000000000000000000000000000000..7605efe37ac4a63cb95c8c64c576e93c
|
|||
+import org.bukkit.plugin.PluginLoadOrder;
|
||||
+import org.jetbrains.annotations.NotNull;
|
||||
+import org.jetbrains.annotations.Nullable;
|
||||
+import org.jetbrains.annotations.TestOnly;
|
||||
+import org.spongepowered.configurate.CommentedConfigurationNode;
|
||||
+import org.spongepowered.configurate.ConfigurateException;
|
||||
+import org.spongepowered.configurate.loader.HeaderMode;
|
||||
|
@ -4456,8 +4458,6 @@ index 0000000000000000000000000000000000000000..7605efe37ac4a63cb95c8c64c576e93c
|
|||
+ @PluginConfigConstraints.PluginVersion
|
||||
+ private String apiVersion;
|
||||
+
|
||||
+ private transient String displayName;
|
||||
+
|
||||
+ public PaperPluginMeta() {
|
||||
+ }
|
||||
+
|
||||
|
@ -4500,8 +4500,6 @@ index 0000000000000000000000000000000000000000..7605efe37ac4a63cb95c8c64c576e93c
|
|||
+ .build();
|
||||
+ }
|
||||
+
|
||||
+ pluginConfiguration.displayName = pluginConfiguration.name.replace('_', ' ') + " v" + pluginConfiguration.version;
|
||||
+
|
||||
+ return pluginConfiguration;
|
||||
+ }
|
||||
+
|
||||
|
@ -4510,6 +4508,12 @@ index 0000000000000000000000000000000000000000..7605efe37ac4a63cb95c8c64c576e93c
|
|||
+ return this.name;
|
||||
+ }
|
||||
+
|
||||
+ @TestOnly
|
||||
+ public void setName(@NotNull String name) {
|
||||
+ Preconditions.checkNotNull(name, "name");
|
||||
+ this.name = name;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public @NotNull String getMainClass() {
|
||||
+ return this.main;
|
||||
|
@ -4520,9 +4524,10 @@ index 0000000000000000000000000000000000000000..7605efe37ac4a63cb95c8c64c576e93c
|
|||
+ return this.version;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public @NotNull String getDisplayName() {
|
||||
+ return this.displayName;
|
||||
+ @TestOnly
|
||||
+ public void setVersion(@NotNull String version) {
|
||||
+ Preconditions.checkNotNull(version, "version");
|
||||
+ this.version = version;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
|
@ -7052,6 +7057,40 @@ index 0000000000000000000000000000000000000000..726eba26470e62b0e94a91418512e242
|
|||
+ assertThat(pm.getPermissions(), is(empty()));
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/test/java/io/papermc/paper/plugin/PluginNamingTest.java b/src/test/java/io/papermc/paper/plugin/PluginNamingTest.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..860a2bc8200cf41b216a2e37cfbd2f5464d6542c
|
||||
--- /dev/null
|
||||
+++ b/src/test/java/io/papermc/paper/plugin/PluginNamingTest.java
|
||||
@@ -0,0 +1,28 @@
|
||||
+package io.papermc.paper.plugin;
|
||||
+
|
||||
+import io.papermc.paper.plugin.provider.configuration.PaperPluginMeta;
|
||||
+import org.junit.Assert;
|
||||
+import org.junit.Test;
|
||||
+
|
||||
+public class PluginNamingTest {
|
||||
+ private static final String TEST_NAME = "Test_Plugin";
|
||||
+ private static final String TEST_VERSION = "1.0";
|
||||
+
|
||||
+ private final PaperPluginMeta pluginMeta;
|
||||
+
|
||||
+ public PluginNamingTest() {
|
||||
+ this.pluginMeta = new PaperPluginMeta();
|
||||
+ this.pluginMeta.setName(TEST_NAME);
|
||||
+ this.pluginMeta.setVersion(TEST_VERSION);
|
||||
+ }
|
||||
+
|
||||
+ @Test
|
||||
+ public void testName() {
|
||||
+ Assert.assertEquals(TEST_NAME, this.pluginMeta.getName());
|
||||
+ }
|
||||
+
|
||||
+ @Test
|
||||
+ public void testDisplayName() {
|
||||
+ Assert.assertEquals(TEST_NAME + " v" + TEST_VERSION, this.pluginMeta.getDisplayName());
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/test/java/io/papermc/paper/plugin/SyntheticEventTest.java b/src/test/java/io/papermc/paper/plugin/SyntheticEventTest.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..51c08740edffd152c8e2b6d3676ff7f1ce6090c6
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue