Fix Invalid Schem Names #153
@ -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();
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren