Commits

Wesley Wolfe authored a41b54d1fb3
Provide warnings for spaces in plugin names.

Addresses BUKKIT-5419
No tags

src/main/java/org/bukkit/plugin/PluginDescriptionFile.java

Modified
159 159 * default: true
160 160 * inferno.burningdeaths.others:
161 161 * description: Allows you to see how many times others have burned to death
162 162 * default: op
163 163 * children:
164 164 * inferno.burningdeaths: true
165 165 *</pre></blockquote>
166 166 */
167 167 public final class PluginDescriptionFile {
168 168 private static final Yaml yaml = new Yaml(new SafeConstructor());
169 + String rawName = null;
169 170 private String name = null;
170 171 private String main = null;
171 172 private String classLoaderOf = null;
172 173 private List<String> depend = ImmutableList.of();
173 174 private List<String> softDepend = ImmutableList.of();
174 175 private List<String> loadBefore = ImmutableList.of();
175 176 private String version = null;
176 177 private Map<String, Map<String, Object>> commands = null;
177 178 private String description = null;
178 179 private List<String> authors = null;
221 222 * plugin.yml to fail loading.
222 223 * <li>Used to determine the name of the plugin's data folder. Data
223 224 * folders are placed in the ./plugins/ directory by default, but this
224 225 * behavior should not be relied on. {@link Plugin#getDataFolder()}
225 226 * should be used to reference the data folder.
226 227 * <li>It is good practice to name your jar the same as this, for example
227 228 * 'MyPlugin.jar'.
228 229 * <li>Case sensitive.
229 230 * <li>The is the token referenced in {@link #getDepend()}, {@link
230 231 * #getSoftDepend()}, and {@link #getLoadBefore()}.
232 + * <li>Using spaces in the plugin's name is deprecated.
231 233 * </ul>
232 234 * <p>
233 235 * In the plugin.yml, this entry is named <code>name</code>.
234 236 * <p>
235 237 * Example:<blockquote><pre>name: MyPlugin</pre></blockquote>
236 238 *
237 239 * @return the name of the plugin
238 240 */
239 241 public String getName() {
240 242 return name;
792 794 * Saves this PluginDescriptionFile to the given writer
793 795 *
794 796 * @param writer Writer to output this file to
795 797 */
796 798 public void save(Writer writer) {
797 799 yaml.dump(saveMap(), writer);
798 800 }
799 801
800 802 private void loadMap(Map<?, ?> map) throws InvalidDescriptionException {
801 803 try {
802 - name = map.get("name").toString();
804 + name = rawName = map.get("name").toString();
803 805
804 806 if (!name.matches("^[A-Za-z0-9 _.-]+$")) {
805 807 throw new InvalidDescriptionException("name '" + name + "' contains invalid characters.");
806 808 }
807 809 name = name.replace(' ', '_');
808 810 } catch (NullPointerException ex) {
809 811 throw new InvalidDescriptionException(ex, "name is not defined");
810 812 } catch (ClassCastException ex) {
811 813 throw new InvalidDescriptionException(ex, "name is of wrong type");
812 814 }

Everything looks good. We'll let you know here if there's anything you should know about.

Add shortcut