SteamWar/SpigotCore
Archiviert
13
0

Merge pull request 'Fix Invalid Schem Names' (#153) from is_punished into master
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful

Reviewed-on: #153
Reviewed-by: YoyoNow <jwsteam@nidido.de>
Dieser Commit ist enthalten in:
YoyoNow 2021-12-30 21:13:10 +01:00
Commit 0e3544f730
2 geänderte Dateien mit 31 neuen und 3 gelöschten Zeilen

Datei anzeigen

@ -228,10 +228,14 @@ public class SchematicSelector {
SWAnvilInv inv = new SWAnvilInv(player, Core.MESSAGE.parse("SCHEM_SELECTOR_CREATE_DIR_TITLE", player));
inv.setItem(Material.CHEST);
inv.setCallback(s -> {
if(injectable.onFolderCreate(this, s)) {
SchematicNode.createSchematicDirectory(user.getId(), s, parent==null?0:parent.getId());
openList(parent);
if(!SchematicNode.invalidSchemName(new String[] {s})) {
if(injectable.onFolderCreate(this, s)) {
SchematicNode.createSchematicDirectory(user.getId(), s, parent==null?0:parent.getId());
openList(parent);
}
return;
}
player.closeInventory();
});
inv.open();
}

Datei anzeigen

@ -604,4 +604,28 @@ public class SchematicNode {
list.remove("//copy");
return list;
}
private static final List<String> FORBIDDEN_NAMES = Collections.unmodifiableList(Arrays.asList("public"));
public static boolean invalidSchemName(String[] layers) {
for (String layer : layers) {
if (layer.isEmpty()) {
return true;
}
if (layer.contains("/") ||
layer.contains("\\") ||
layer.contains("<") ||
layer.contains(">") ||
layer.contains("^") ||
layer.contains("°") ||
layer.contains("'") ||
layer.contains("\"") ||
layer.contains(" ")) {
return true;
}
if(FORBIDDEN_NAMES.contains(layer.toLowerCase())) {
return true;
}
}
return false;
}
}