Force the Blueprint name to be lowercased using English locale

This commit is contained in:
Florian CUNY 2019-10-05 22:22:25 +02:00
parent 94ff2ebf75
commit 27647da6f4
2 changed files with 5 additions and 5 deletions

View File

@ -56,8 +56,9 @@ public class Blueprint {
/** /**
* @param name the name to set * @param name the name to set
*/ */
public Blueprint setName(String name) { public Blueprint setName(@NonNull String name) {
this.name = name; // Force lowercase
this.name = name.toLowerCase(Locale.ENGLISH);
return this; return this;
} }
/** /**

View File

@ -508,7 +508,7 @@ public class BlueprintsManager {
} }
File bpf = getBlueprintsFolder(addon); File bpf = getBlueprintsFolder(addon);
// Get the filename // Get the filename
File fileName = new File(bpf, bp.getName().toLowerCase(Locale.ENGLISH) + BLUEPRINT_SUFFIX); File fileName = new File(bpf, bp.getName() + BLUEPRINT_SUFFIX);
// Delete the old file // Delete the old file
try { try {
Files.deleteIfExists(fileName.toPath()); Files.deleteIfExists(fileName.toPath());
@ -516,10 +516,9 @@ public class BlueprintsManager {
plugin.logError("Could not delete old Blueprint " + e.getLocalizedMessage()); plugin.logError("Could not delete old Blueprint " + e.getLocalizedMessage());
} }
// Set new name // Set new name
bp.setName(name); bp.setName(name.toLowerCase(Locale.ENGLISH));
// Save it // Save it
saveBlueprint(addon, bp); saveBlueprint(addon, bp);
} }
} }