mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-09 19:49:35 +01:00
[Bleeding] Blacklist certain plugin names
By: t00thpick1 <t00thpick1dirko@gmail.com>
This commit is contained in:
parent
4d3aba0a11
commit
e833c88a72
2 changed files with 8 additions and 2 deletions
|
@ -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) {
|
||||
|
|
|
@ -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() {
|
||||
|
|
Loading…
Reference in a new issue