diff options
author | Wesley Wolfe <weswolf@aol.com> | 2014-02-15 11:37:33 -0600 |
---|---|---|
committer | Wesley Wolfe <weswolf@aol.com> | 2014-02-15 12:16:03 -0600 |
commit | a41b54d1fb3ac8fcc5adea46cf61fdeaee5befb8 (patch) | |
tree | 08c74bc7a5c8d1dea4d0327092505acf5fddf6eb /src/main | |
parent | 7b04f0a6cd217e638f2dfaf676b7e7cf4712181e (diff) | |
download | bukkit-a41b54d1fb3ac8fcc5adea46cf61fdeaee5befb8.tar bukkit-a41b54d1fb3ac8fcc5adea46cf61fdeaee5befb8.tar.gz bukkit-a41b54d1fb3ac8fcc5adea46cf61fdeaee5befb8.tar.lz bukkit-a41b54d1fb3ac8fcc5adea46cf61fdeaee5befb8.tar.xz bukkit-a41b54d1fb3ac8fcc5adea46cf61fdeaee5befb8.zip |
Provide warnings for spaces in plugin names. Addresses BUKKIT-5419
Diffstat (limited to 'src/main')
-rw-r--r-- | src/main/java/org/bukkit/plugin/PluginDescriptionFile.java | 4 | ||||
-rw-r--r-- | src/main/java/org/bukkit/plugin/SimplePluginManager.java | 17 |
2 files changed, 19 insertions, 2 deletions
diff --git a/src/main/java/org/bukkit/plugin/PluginDescriptionFile.java b/src/main/java/org/bukkit/plugin/PluginDescriptionFile.java index 18f31bff..96749147 100644 --- a/src/main/java/org/bukkit/plugin/PluginDescriptionFile.java +++ b/src/main/java/org/bukkit/plugin/PluginDescriptionFile.java @@ -166,6 +166,7 @@ import com.google.common.collect.ImmutableMap; */ public final class PluginDescriptionFile { private static final Yaml yaml = new Yaml(new SafeConstructor()); + String rawName = null; private String name = null; private String main = null; private String classLoaderOf = null; @@ -228,6 +229,7 @@ public final class PluginDescriptionFile { * <li>Case sensitive. * <li>The is the token referenced in {@link #getDepend()}, {@link * #getSoftDepend()}, and {@link #getLoadBefore()}. + * <li>Using spaces in the plugin's name is deprecated. * </ul> * <p> * In the plugin.yml, this entry is named <code>name</code>. @@ -799,7 +801,7 @@ public final class PluginDescriptionFile { private void loadMap(Map<?, ?> map) throws InvalidDescriptionException { try { - name = map.get("name").toString(); + name = rawName = map.get("name").toString(); if (!name.matches("^[A-Za-z0-9 _.-]+$")) { throw new InvalidDescriptionException("name '" + name + "' contains invalid characters."); diff --git a/src/main/java/org/bukkit/plugin/SimplePluginManager.java b/src/main/java/org/bukkit/plugin/SimplePluginManager.java index 7d8a281e..d2fe422c 100644 --- a/src/main/java/org/bukkit/plugin/SimplePluginManager.java +++ b/src/main/java/org/bukkit/plugin/SimplePluginManager.java @@ -135,13 +135,28 @@ public final class SimplePluginManager implements PluginManager { 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; + } else if (description.rawName.indexOf(' ') != -1) { + server.getLogger().warning(String.format( + "Plugin `%s' uses the space-character (0x20) in its name `%s' - this is discouraged", + description.getFullName(), + description.rawName + )); } } catch (InvalidDescriptionException ex) { server.getLogger().log(Level.SEVERE, "Could not load '" + file.getPath() + "' in folder '" + directory.getPath() + "'", ex); continue; } - plugins.put(description.getName(), file); + File replacedFile = plugins.put(description.getName(), file); + if (replacedFile != null) { + server.getLogger().severe(String.format( + "Ambiguous plugin name `%s' for files `%s' and `%s' in `%s'", + description.getName(), + file.getPath(), + replacedFile.getPath(), + directory.getPath() + )); + } Collection<String> softDependencySet = description.getSoftDepend(); if (softDependencySet != null && !softDependencySet.isEmpty()) { |