Skip to content

Commit

Permalink
fix: menu saving
Browse files Browse the repository at this point in the history
Trying to save a modified or new custom item via `/itemjoin menu` would incorrectly fail when an item `count` or command `cost` was not specified.
  • Loading branch information
RockinChaos committed Sep 14, 2024
1 parent 1475481 commit 3e26789
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/main/java/me/RockinChaos/itemjoin/item/ItemMap.java
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ private void setCommandCost() {
if (commandItem != null && !commandItem.isEmpty()) {
this.itemCost = commandItem;
}
this.cost = this.nodeLocation.getString("commands-cost");
this.setCommandCost(this.nodeLocation.getString("commands-cost"));
}

/**
Expand Down Expand Up @@ -747,7 +747,7 @@ public void removeFromAnimationHandler(final Player player) {
* @param count - The stack size to be set.
*/
public void setCount(final String count) {
this.count = count;
this.count = count == null || count.isEmpty() ? "1" : count;
}

/**
Expand Down Expand Up @@ -1935,7 +1935,7 @@ public String getRawCost() {
* @param cost - The Commands Cost to be set.
*/
public void setCommandCost(final String cost) {
this.cost = cost;
this.cost = cost == null || cost.isEmpty() ? "0" : cost;
}

/**
Expand Down Expand Up @@ -5891,7 +5891,7 @@ private void parseData_1(final FileConfiguration itemData) {
itemData.set("items." + this.configName + ".slot", this.CustomSlot);
}
}
if (this.getCount(null) > 1 || this.count.contains("%")) {
if (this.getCount(null) > 1 || (this.count != null && this.count.contains("%"))) {
itemData.set("items." + this.configName + ".count", this.count);
}
if (this.durability != null && this.durability > 0) {
Expand Down Expand Up @@ -6174,7 +6174,7 @@ private void parseData_3(final FileConfiguration itemData) {
if (this.itemCost != null && !this.itemCost.isEmpty()) {
itemData.set("items." + this.configName + ".commands-item", this.itemCost);
}
if (this.getCommandCost(null) > 0 || this.cost.contains("%")) {
if (this.getCommandCost(null) > 0 || (this.cost != null && this.cost.contains("%"))) {
itemData.set("items." + this.configName + ".commands-cost", this.cost);
}
if (this.commandsReceive != null && this.commandsReceive != 0) {
Expand Down

0 comments on commit 3e26789

Please sign in to comment.