Skip to content

Commit

Permalink
Fix some potions not able to be serialized
Browse files Browse the repository at this point in the history
  • Loading branch information
JRoy committed May 13, 2024
1 parent 35c150d commit 26d4dcd
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -333,12 +333,13 @@ public boolean equals(Object o) {
final EssentialPotionData that = (EssentialPotionData) o;
return upgraded == that.upgraded &&
extended == that.extended &&
type == that.type;
// Use the getters here to ensure the fallbacks are being used
getType() == that.getType();
}

@Override
public int hashCode() {
return Objects.hash(type, upgraded, extended);
return Objects.hash(getType(), upgraded, extended);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,15 @@ public boolean isUpgraded(ItemStack stack) {
public PotionType getBasePotionType(ItemStack stack) {
final PotionMeta meta = (PotionMeta) stack.getItemMeta();
//noinspection DataFlowIssue
return meta.getBasePotionType();
PotionType type = meta.getBasePotionType();
//noinspection DataFlowIssue
final String name = type.name();
if (name.startsWith("LONG_")) {
type = PotionType.valueOf(name.substring(5));
} else if (name.startsWith("STRONG_")) {
type = PotionType.valueOf(name.substring(7));
}
return type;
}

@Override
Expand Down

0 comments on commit 26d4dcd

Please sign in to comment.