mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-29 12:27:59 +01:00
Fix Inconsistencies with Paper Plugin Names (#9098)
This commit is contained in:
parent
77aec31991
commit
d8b12ddb4c
@ -56,4 +56,5 @@ Kieran Wallbanks <kieran.wallbanks@gmail.com>
|
|||||||
Denery <dorofeevij@gmail.com>
|
Denery <dorofeevij@gmail.com>
|
||||||
Jakubk15 <jakubk15@protonmail.com>
|
Jakubk15 <jakubk15@protonmail.com>
|
||||||
Redned <redned235@gmail.com>
|
Redned <redned235@gmail.com>
|
||||||
|
Luke Chambers <consolelogluke@gmail.com>
|
||||||
```
|
```
|
||||||
|
@ -88,8 +88,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||||||
+ Bukkit.getLogger().warning(
|
+ Bukkit.getLogger().warning(
|
||||||
+ String.format("Nag author(s): '%s' of '%s' about their usage of System.out/err.print. "
|
+ String.format("Nag author(s): '%s' of '%s' about their usage of System.out/err.print. "
|
||||||
+ + "Please use your plugin's logger instead (JavaPlugin#getLogger).",
|
+ + "Please use your plugin's logger instead (JavaPlugin#getLogger).",
|
||||||
+ plugin.getDescription().getAuthors(),
|
+ plugin.getPluginMeta().getAuthors(),
|
||||||
+ plugin.getName())
|
+ plugin.getPluginMeta().getDisplayName())
|
||||||
+ );
|
+ );
|
||||||
+ } catch (final IllegalArgumentException | IllegalStateException e) {
|
+ } catch (final IllegalArgumentException | IllegalStateException e) {
|
||||||
+ // If anything happens, the calling class doesn't exist, there is no JavaPlugin that "owns" the calling class, etc
|
+ // If anything happens, the calling class doesn't exist, there is no JavaPlugin that "owns" the calling class, etc
|
||||||
|
@ -612,13 +612,13 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||||||
+ ComponentLogger logger, Path pluginSource) implements PluginProviderContext {
|
+ ComponentLogger logger, Path pluginSource) implements PluginProviderContext {
|
||||||
+
|
+
|
||||||
+ public static PluginProviderContextImpl of(PluginMeta config, ComponentLogger logger, Path pluginSource) {
|
+ 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);
|
+ return new PluginProviderContextImpl(config, dataFolder, logger, pluginSource);
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ public static PluginProviderContextImpl of(PluginProvider<?> provider, Path pluginFolder) {
|
+ 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());
|
+ return new PluginProviderContextImpl(provider.getMeta(), dataFolder, provider.getLogger(), provider.getSource());
|
||||||
+ }
|
+ }
|
||||||
@ -966,7 +966,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||||||
+ PluginMeta config = this.configuration;
|
+ PluginMeta config = this.configuration;
|
||||||
+ PluginDescriptionFile pluginDescriptionFile = new PluginDescriptionFile(
|
+ PluginDescriptionFile pluginDescriptionFile = new PluginDescriptionFile(
|
||||||
+ config.getName(),
|
+ config.getName(),
|
||||||
+ config.getName().replace('_', ' '),
|
+ config.getName(),
|
||||||
+ config.getProvidedPlugins(),
|
+ config.getProvidedPlugins(),
|
||||||
+ config.getMainClass(),
|
+ config.getMainClass(),
|
||||||
+ "", // Classloader load order api
|
+ "", // Classloader load order api
|
||||||
@ -4393,6 +4393,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||||||
@@ -0,0 +0,0 @@
|
@@ -0,0 +0,0 @@
|
||||||
+package io.papermc.paper.plugin.provider.configuration;
|
+package io.papermc.paper.plugin.provider.configuration;
|
||||||
+
|
+
|
||||||
|
+import com.google.common.base.Preconditions;
|
||||||
+import com.google.common.collect.ImmutableList;
|
+import com.google.common.collect.ImmutableList;
|
||||||
+import io.leangen.geantyref.TypeToken;
|
+import io.leangen.geantyref.TypeToken;
|
||||||
+import io.papermc.paper.configuration.constraint.Constraint;
|
+import io.papermc.paper.configuration.constraint.Constraint;
|
||||||
@ -4411,6 +4412,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||||||
+import org.bukkit.plugin.PluginLoadOrder;
|
+import org.bukkit.plugin.PluginLoadOrder;
|
||||||
+import org.jetbrains.annotations.NotNull;
|
+import org.jetbrains.annotations.NotNull;
|
||||||
+import org.jetbrains.annotations.Nullable;
|
+import org.jetbrains.annotations.Nullable;
|
||||||
|
+import org.jetbrains.annotations.TestOnly;
|
||||||
+import org.spongepowered.configurate.CommentedConfigurationNode;
|
+import org.spongepowered.configurate.CommentedConfigurationNode;
|
||||||
+import org.spongepowered.configurate.ConfigurateException;
|
+import org.spongepowered.configurate.ConfigurateException;
|
||||||
+import org.spongepowered.configurate.loader.HeaderMode;
|
+import org.spongepowered.configurate.loader.HeaderMode;
|
||||||
@ -4456,8 +4458,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||||||
+ @PluginConfigConstraints.PluginVersion
|
+ @PluginConfigConstraints.PluginVersion
|
||||||
+ private String apiVersion;
|
+ private String apiVersion;
|
||||||
+
|
+
|
||||||
+ private transient String displayName;
|
|
||||||
+
|
|
||||||
+ public PaperPluginMeta() {
|
+ public PaperPluginMeta() {
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
@ -4500,8 +4500,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||||||
+ .build();
|
+ .build();
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ pluginConfiguration.displayName = pluginConfiguration.name.replace('_', ' ') + " v" + pluginConfiguration.version;
|
|
||||||
+
|
|
||||||
+ return pluginConfiguration;
|
+ return pluginConfiguration;
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
@ -4510,6 +4508,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||||||
+ return this.name;
|
+ return this.name;
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
|
+ @TestOnly
|
||||||
|
+ public void setName(@NotNull String name) {
|
||||||
|
+ Preconditions.checkNotNull(name, "name");
|
||||||
|
+ this.name = name;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
+ @Override
|
+ @Override
|
||||||
+ public @NotNull String getMainClass() {
|
+ public @NotNull String getMainClass() {
|
||||||
+ return this.main;
|
+ return this.main;
|
||||||
@ -4520,9 +4524,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||||||
+ return this.version;
|
+ return this.version;
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ @Override
|
+ @TestOnly
|
||||||
+ public @NotNull String getDisplayName() {
|
+ public void setVersion(@NotNull String version) {
|
||||||
+ return this.displayName;
|
+ Preconditions.checkNotNull(version, "version");
|
||||||
|
+ this.version = version;
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ @Override
|
+ @Override
|
||||||
@ -7052,6 +7057,40 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||||||
+ assertThat(pm.getPermissions(), is(empty()));
|
+ 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
|
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
|
new file mode 100644
|
||||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000
|
||||||
|
@ -44,14 +44,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||||||
+ List<BukkitWorker> overdueWorkers = getScheduler().getActiveWorkers();
|
+ List<BukkitWorker> overdueWorkers = getScheduler().getActiveWorkers();
|
||||||
+ for (BukkitWorker worker : overdueWorkers) {
|
+ for (BukkitWorker worker : overdueWorkers) {
|
||||||
+ Plugin plugin = worker.getOwner();
|
+ Plugin plugin = worker.getOwner();
|
||||||
+ String author = "<NoAuthorGiven>";
|
|
||||||
+ if (plugin.getDescription().getAuthors().size() > 0) {
|
|
||||||
+ author = plugin.getDescription().getAuthors().get(0);
|
|
||||||
+ }
|
|
||||||
+ getLogger().log(Level.SEVERE, String.format(
|
+ getLogger().log(Level.SEVERE, String.format(
|
||||||
+ "Nag author: '%s' of '%s' about the following: %s",
|
+ "Nag author(s): '%s' of '%s' about the following: %s",
|
||||||
+ author,
|
+ plugin.getPluginMeta().getAuthors(),
|
||||||
+ plugin.getDescription().getName(),
|
+ plugin.getPluginMeta().getDisplayName(),
|
||||||
+ "This plugin is not properly shutting down its async tasks when it is being shut down. This task may throw errors during the final shutdown logs and might not complete before process dies."
|
+ "This plugin is not properly shutting down its async tasks when it is being shut down. This task may throw errors during the final shutdown logs and might not complete before process dies."
|
||||||
+ ));
|
+ ));
|
||||||
+ }
|
+ }
|
||||||
|
Loading…
Reference in New Issue
Block a user