diff options
author | t00thpick1 <t00thpick1dirko@gmail.com> | 2014-02-07 20:30:34 -0500 |
---|---|---|
committer | Travis Watkins <amaranth@ubuntu.com> | 2014-02-08 03:11:46 -0600 |
commit | f2328f933ed1f01dccf49dd23701a7d537c8f0bc (patch) | |
tree | a0b7cd3fb0846a1f468720148daacc2276af8f5f | |
parent | f5689165ad8daa6a1fa94b95a1e58a4b84fc65a3 (diff) | |
download | bukkit-f2328f933ed1f01dccf49dd23701a7d537c8f0bc.tar bukkit-f2328f933ed1f01dccf49dd23701a7d537c8f0bc.tar.gz bukkit-f2328f933ed1f01dccf49dd23701a7d537c8f0bc.tar.lz bukkit-f2328f933ed1f01dccf49dd23701a7d537c8f0bc.tar.xz bukkit-f2328f933ed1f01dccf49dd23701a7d537c8f0bc.zip |
[Bleeding] Blacklist certain plugin names
-rw-r--r-- | src/main/java/org/bukkit/plugin/PluginDescriptionFile.java | 3 | ||||
-rw-r--r-- | src/main/java/org/bukkit/plugin/SimplePluginManager.java | 7 |
2 files changed, 8 insertions, 2 deletions
diff --git a/src/main/java/org/bukkit/plugin/PluginDescriptionFile.java b/src/main/java/org/bukkit/plugin/PluginDescriptionFile.java index 1d79e637..1b5d820f 100644 --- a/src/main/java/org/bukkit/plugin/PluginDescriptionFile.java +++ b/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/src/main/java/org/bukkit/plugin/SimplePluginManager.java b/src/main/java/org/bukkit/plugin/SimplePluginManager.java index 3c9611ba..787dcfe5 100644 --- a/src/main/java/org/bukkit/plugin/SimplePluginManager.java +++ b/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() { |