mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-23 16:51:35 +01:00
Provide warnings for spaces in plugin names. Addresses BUKKIT-5419
By: Wesley Wolfe <weswolf@aol.com>
This commit is contained in:
parent
edd5dc6155
commit
bc562b3f5b
@ -166,6 +166,7 @@ import com.google.common.collect.ImmutableMap;
|
|||||||
*/
|
*/
|
||||||
public final class PluginDescriptionFile {
|
public final class PluginDescriptionFile {
|
||||||
private static final Yaml yaml = new Yaml(new SafeConstructor());
|
private static final Yaml yaml = new Yaml(new SafeConstructor());
|
||||||
|
String rawName = null;
|
||||||
private String name = null;
|
private String name = null;
|
||||||
private String main = null;
|
private String main = null;
|
||||||
private String classLoaderOf = null;
|
private String classLoaderOf = null;
|
||||||
@ -228,6 +229,7 @@ public final class PluginDescriptionFile {
|
|||||||
* <li>Case sensitive.
|
* <li>Case sensitive.
|
||||||
* <li>The is the token referenced in {@link #getDepend()}, {@link
|
* <li>The is the token referenced in {@link #getDepend()}, {@link
|
||||||
* #getSoftDepend()}, and {@link #getLoadBefore()}.
|
* #getSoftDepend()}, and {@link #getLoadBefore()}.
|
||||||
|
* <li>Using spaces in the plugin's name is deprecated.
|
||||||
* </ul>
|
* </ul>
|
||||||
* <p>
|
* <p>
|
||||||
* In the plugin.yml, this entry is named <code>name</code>.
|
* 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 {
|
private void loadMap(Map<?, ?> map) throws InvalidDescriptionException {
|
||||||
try {
|
try {
|
||||||
name = map.get("name").toString();
|
name = rawName = map.get("name").toString();
|
||||||
|
|
||||||
if (!name.matches("^[A-Za-z0-9 _.-]+$")) {
|
if (!name.matches("^[A-Za-z0-9 _.-]+$")) {
|
||||||
throw new InvalidDescriptionException("name '" + name + "' contains invalid characters.");
|
throw new InvalidDescriptionException("name '" + name + "' contains invalid characters.");
|
||||||
|
@ -135,13 +135,28 @@ public final class SimplePluginManager implements PluginManager {
|
|||||||
if (name.equalsIgnoreCase("bukkit") || name.equalsIgnoreCase("minecraft") || name.equalsIgnoreCase("mojang")) {
|
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");
|
server.getLogger().log(Level.SEVERE, "Could not load '" + file.getPath() + "' in folder '" + directory.getPath() + "': Restricted Name");
|
||||||
continue;
|
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) {
|
} catch (InvalidDescriptionException ex) {
|
||||||
server.getLogger().log(Level.SEVERE, "Could not load '" + file.getPath() + "' in folder '" + directory.getPath() + "'", ex);
|
server.getLogger().log(Level.SEVERE, "Could not load '" + file.getPath() + "' in folder '" + directory.getPath() + "'", ex);
|
||||||
continue;
|
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();
|
Collection<String> softDependencySet = description.getSoftDepend();
|
||||||
if (softDependencySet != null && !softDependencySet.isEmpty()) {
|
if (softDependencySet != null && !softDependencySet.isEmpty()) {
|
||||||
|
Loading…
Reference in New Issue
Block a user