v2.5.0: fixed custom item notes not properly assigning ID

This commit is contained in:
Evan Debenham
2024-07-05 12:22:28 -04:00
parent a0225ad4a3
commit 02728ae770
2 changed files with 9 additions and 2 deletions
@@ -365,7 +365,7 @@ public class Notes {
protected CustomType type; protected CustomType type;
protected int ID; protected int ID = -1;
protected Class itemClass; protected Class itemClass;
protected String title; protected String title;
@@ -393,6 +393,12 @@ public class Notes {
body = desc; body = desc;
} }
public void assignID(){
if (ID == -1) {
ID = nextCustomID++;
}
}
public int ID(){ public int ID(){
return ID; return ID;
} }
@@ -575,7 +581,7 @@ public class Notes {
} }
public static boolean add( CustomRecord rec ){ public static boolean add( CustomRecord rec ){
rec.ID = nextCustomID++; rec.assignID();
if (!records.contains(rec)){ if (!records.contains(rec)){
boolean result = records.add(rec); boolean result = records.add(rec);
Collections.sort(records, comparator); Collections.sort(records, comparator);
@@ -167,6 +167,7 @@ public class CustomNoteButton extends IconButton {
public void onSelect( Item item ) { public void onSelect( Item item ) {
if (item != null){ if (item != null){
Notes.CustomRecord custom = new Notes.CustomRecord(item, "", ""); Notes.CustomRecord custom = new Notes.CustomRecord(item, "", "");
custom.assignID();
if (item instanceof EquipableItem){ if (item instanceof EquipableItem){
((EquipableItem) item).customNoteID = custom.ID(); ((EquipableItem) item).customNoteID = custom.ID();
} }