diff --git a/paper-api/src/main/java/org/bukkit/plugin/PluginDescriptionFile.java b/paper-api/src/main/java/org/bukkit/plugin/PluginDescriptionFile.java index 1d79e637be..1b5d820f2d 100644 --- a/paper-api/src/main/java/org/bukkit/plugin/PluginDescriptionFile.java +++ b/paper-api/src/main/java/org/bukkit/plugin/PluginDescriptionFile.java @@ -207,7 +207,7 @@ public final class PluginDescriptionFile { * @param mainClass Full location of the main class of this plugin */ public PluginDescriptionFile(final String pluginName, final String pluginVersion, final String mainClass) { - name = pluginName; + name = pluginName.replace(' ', '_'); version = pluginVersion; main = mainClass; } @@ -801,6 +801,7 @@ public final class PluginDescriptionFile { if (!name.matches("^[A-Za-z0-9 _.-]+$")) { throw new InvalidDescriptionException("name '" + name + "' contains invalid characters."); } + name = name.replace(' ', '_'); } catch (NullPointerException ex) { throw new InvalidDescriptionException(ex, "name is not defined"); } catch (ClassCastException ex) { diff --git a/paper-api/src/main/java/org/bukkit/plugin/SimplePluginManager.java b/paper-api/src/main/java/org/bukkit/plugin/SimplePluginManager.java index 3c9611ba41..787dcfe58d 100644 --- a/paper-api/src/main/java/org/bukkit/plugin/SimplePluginManager.java +++ b/paper-api/src/main/java/org/bukkit/plugin/SimplePluginManager.java @@ -131,6 +131,11 @@ public final class SimplePluginManager implements PluginManager { PluginDescriptionFile description = null; try { description = loader.getPluginDescription(file); + String name = description.getName(); + if (name.equalsIgnoreCase("bukkit") || name.equalsIgnoreCase("minecraft") || name.equalsIgnoreCase("mojang")) { + server.getLogger().log(Level.SEVERE, "Could not load '" + file.getPath() + "' in folder '" + directory.getPath() + "': Restricted Name"); + continue; + } } catch (InvalidDescriptionException ex) { server.getLogger().log(Level.SEVERE, "Could not load '" + file.getPath() + "' in folder '" + directory.getPath() + "'", ex); continue; @@ -337,7 +342,7 @@ public final class SimplePluginManager implements PluginManager { * @return Plugin if it exists, otherwise null */ public synchronized Plugin getPlugin(String name) { - return lookupNames.get(name); + return lookupNames.get(name.replace(' ', '_')); } public synchronized Plugin[] getPlugins() {