added handling of blueprints without unique ids, close #1842
This commit is contained in:
parent
6f1294ab27
commit
8f8529d408
2 changed files with 22 additions and 10 deletions
|
@ -166,19 +166,27 @@ public class BlueprintDatabase {
|
|||
for (File blueprintFile : directory.listFiles(filter)) {
|
||||
String fileName = blueprintFile.getName();
|
||||
|
||||
int cutIndex = fileName.lastIndexOf(BuildCraftBuilders.BPT_SEP_CHARACTER);
|
||||
|
||||
String prefix = fileName.substring(0, cutIndex);
|
||||
String suffix = fileName.substring(cutIndex + 1);
|
||||
|
||||
BlueprintId id = new BlueprintId();
|
||||
id.name = prefix;
|
||||
|
||||
if (suffix.contains(BPT_EXTENSION)) {
|
||||
id.uniqueId = BlueprintId.toBytes(suffix.replaceAll(BPT_EXTENSION, ""));
|
||||
int sepIndex = fileName.lastIndexOf(BuildCraftBuilders.BPT_SEP_CHARACTER);
|
||||
int dotIndex = fileName.lastIndexOf('.');
|
||||
|
||||
String extension = fileName.substring(dotIndex);
|
||||
|
||||
if (sepIndex > 0) {
|
||||
String prefix = fileName.substring(0, sepIndex);
|
||||
String suffix = fileName.substring(sepIndex + 1);
|
||||
|
||||
id.name = prefix;
|
||||
id.uniqueId = BlueprintId.toBytes(suffix.substring(0, suffix.length() - 4));
|
||||
} else {
|
||||
id.name = fileName.substring(0, dotIndex);
|
||||
id.uniqueId = new byte[0];
|
||||
}
|
||||
|
||||
if (extension.equals(BPT_EXTENSION)) {
|
||||
id.kind = Kind.Blueprint;
|
||||
} else {
|
||||
id.uniqueId = BlueprintId.toBytes(suffix.replaceAll(TPL_EXTENSION, ""));
|
||||
id.kind = Kind.Template;
|
||||
}
|
||||
|
||||
|
|
|
@ -78,8 +78,12 @@ public final class BlueprintId implements Comparable<BlueprintId> {
|
|||
|
||||
public String getCompleteId () {
|
||||
if (completeId == null) {
|
||||
if (uniqueId.length > 0) {
|
||||
completeId = name + BuildCraftBuilders.BPT_SEP_CHARACTER
|
||||
+ toString(uniqueId);
|
||||
} else {
|
||||
completeId = name;
|
||||
}
|
||||
}
|
||||
|
||||
return completeId;
|
||||
|
|
Loading…
Reference in a new issue