mirror of
https://github.com/array-in-a-matrix/brainwine.git
synced 2025-04-02 11:11:58 -04:00
Minor JSON & instance related improvements
This commit is contained in:
parent
779462a8fa
commit
d0e2ca8126
1 changed files with 18 additions and 2 deletions
|
@ -12,7 +12,18 @@ import com.fasterxml.jackson.annotation.JsonValue;
|
|||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public class Item {
|
||||
|
||||
public static final Item AIR = new Item();
|
||||
public static final Item AIR = new Item() {
|
||||
|
||||
@Override
|
||||
public int getId() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "air";
|
||||
}
|
||||
};
|
||||
|
||||
@JsonProperty("code")
|
||||
private int id;
|
||||
|
@ -57,6 +68,11 @@ public class Item {
|
|||
return ItemRegistry.getItem(id);
|
||||
}
|
||||
|
||||
@JsonCreator
|
||||
private static Item fromName(String name) {
|
||||
return ItemRegistry.getItem(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return id;
|
||||
|
@ -72,11 +88,11 @@ public class Item {
|
|||
return item.getId() == id;
|
||||
}
|
||||
|
||||
@JsonValue
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
@JsonValue
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue