1818 */
1919public class Platform {
2020
21+ private static final String FAKE_PLUGIN_NAME = "Fake" ;
22+
2123 protected Platform () {
2224 }
2325
@@ -33,7 +35,7 @@ public <ScalaPluginClassLoader extends ClassLoader & IScalaPluginClassLoader> by
3335 try {
3436 Server server = currentPluginClassLoader .getServer ();
3537 UnsafeValues unsafeValues = server .getUnsafe ();
36- String fakeDescription = "name: Fake" + System .lineSeparator () +
38+ String fakeDescription = "name: " + FAKE_PLUGIN_NAME + System .lineSeparator () +
3739 "version: 1.0" + System .lineSeparator () +
3840 "main: xyz.janboerman.scalaloader.FakePlugin" + System .lineSeparator ();
3941 ApiVersion apiVersion = currentPluginClassLoader .getApiVersion ();
@@ -103,7 +105,7 @@ public <ScalaPluginClassLoader extends ClassLoader & IScalaPluginClassLoader> by
103105 }
104106
105107 if (commodoreConvert != null ) {
106- String pluginName = pluginClassLoader . getPlugin (). getName ( );
108+ String pluginName = getPluginName ( pluginClassLoader );
107109 try {
108110 MethodHandle getOrCreateVersion = lookup .findStatic (API_VERSION_CLASS , "getOrCreateVersion" , MethodType .methodType (API_VERSION_CLASS , String .class ));
109111 Object apiVersion = getOrCreateVersion .invoke (pluginClassLoader .getApiVersion ().getVersionString ());
@@ -155,6 +157,14 @@ public <ScalaPluginClassLoader extends ClassLoader & IScalaPluginClassLoader> by
155157 }
156158 }
157159
160+ private static String getPluginName (IScalaPluginClassLoader classLoader ) {
161+ IScalaPlugin plugin = classLoader .getPlugin ();
162+ if (plugin == null ) {
163+ return FAKE_PLUGIN_NAME ;
164+ } else {
165+ return plugin .getName ();
166+ }
167+ }
158168 }
159169
160170 public static class GlowstonePlatform extends Platform {
0 commit comments