mirror of
https://github.com/PaperMC/Paper.git
synced 2025-08-01 04:32:11 -07:00
Fix Inconsistencies with Paper Plugin Names (#9098)
This commit is contained in:
@@ -612,13 +612,13 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
+ 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());
|
||||
+ }
|
||||
@@ -966,7 +966,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
+ PluginMeta config = this.configuration;
|
||||
+ PluginDescriptionFile pluginDescriptionFile = new PluginDescriptionFile(
|
||||
+ config.getName(),
|
||||
+ config.getName().replace('_', ' '),
|
||||
+ config.getName(),
|
||||
+ config.getProvidedPlugins(),
|
||||
+ config.getMainClass(),
|
||||
+ "", // Classloader load order api
|
||||
@@ -4393,6 +4393,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
@@ -0,0 +0,0 @@
|
||||
+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..00000000000000000000000000000000
|
||||
+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..00000000000000000000000000000000
|
||||
+ @PluginConfigConstraints.PluginVersion
|
||||
+ private String apiVersion;
|
||||
+
|
||||
+ private transient String displayName;
|
||||
+
|
||||
+ public PaperPluginMeta() {
|
||||
+ }
|
||||
+
|
||||
@@ -4500,8 +4500,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
+ .build();
|
||||
+ }
|
||||
+
|
||||
+ pluginConfiguration.displayName = pluginConfiguration.name.replace('_', ' ') + " v" + pluginConfiguration.version;
|
||||
+
|
||||
+ return pluginConfiguration;
|
||||
+ }
|
||||
+
|
||||
@@ -4510,6 +4508,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
+ 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..00000000000000000000000000000000
|
||||
+ 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..00000000000000000000000000000000
|
||||
+ 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..0000000000000000000000000000000000000000
|
||||
--- /dev/null
|
||||
+++ b/src/test/java/io/papermc/paper/plugin/PluginNamingTest.java
|
||||
@@ -0,0 +0,0 @@
|
||||
+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..0000000000000000000000000000000000000000
|
||||
|
Reference in New Issue
Block a user