Skip to content

Commit

Permalink
feat: allow configuring currency-changer which returns more items tha…
Browse files Browse the repository at this point in the history
…n the player sells
  • Loading branch information
Misat11 committed Jan 27, 2024
1 parent cf18063 commit 59b6104
Showing 1 changed file with 13 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -415,17 +415,27 @@ private void handleBuy(ShopTransactionEvent event) {

if (mapReader.containsKey("currency-changer")) {
String changeItemToName = mapReader.getString("currency-changer");
ItemSpawnerType changeItemType;
if (changeItemToName == null) {
return;
}

changeItemType = Main.getSpawnerType(changeItemToName);
String[] split = changeItemToName.trim().split(" ", 2);
if (split.length == 2) {
try {
amount = Integer.parseInt(split[0]);
changeItemToName = split[1].trim();
if (changeItemToName.startsWith("of ")) {
changeItemToName = changeItemToName.substring(3).trim();
}
} catch (NumberFormatException ignored) {
}
}
ItemSpawnerType changeItemType = Main.getSpawnerType(changeItemToName);
if (changeItemType == null) {
return;
}

newItem = changeItemType.getStack();
newItem = changeItemType.getStack(amount);
}

if (clickType.isShiftClick() && newItem.getMaxStackSize() > 1) {
Expand Down

0 comments on commit 59b6104

Please sign in to comment.