From a95cea4a18f82f4b288f6fccd8fff2a36b50d747 Mon Sep 17 00:00:00 2001 From: DaleMC Date: Fri, 19 Jun 2026 17:20:37 +0200 Subject: [PATCH 1/3] Fix honey bottles not returning glass bottles when condensed --- .../essentials/commands/Commandcondense.java | 41 ++++++++++++++++--- 1 file changed, 36 insertions(+), 5 deletions(-) diff --git a/Essentials/src/main/java/com/earth2me/essentials/commands/Commandcondense.java b/Essentials/src/main/java/com/earth2me/essentials/commands/Commandcondense.java index 26f75d27d84..fd20eb7b9a0 100644 --- a/Essentials/src/main/java/com/earth2me/essentials/commands/Commandcondense.java +++ b/Essentials/src/main/java/com/earth2me/essentials/commands/Commandcondense.java @@ -89,17 +89,27 @@ private boolean condenseStack(final User user, final ItemStack stack, final bool amount += contents.getAmount(); } } - - final int output = (amount / input.getAmount()) * result.getAmount(); + + final int crafts = amount / input.getAmount(); + final int output = crafts * result.getAmount(); + amount -= amount % input.getAmount(); - + if (amount > 0) { input.setAmount(amount); result.setAmount(output); + final Trade remove = new Trade(input, ess); final Trade add = new Trade(result, ess); + remove.charge(user); add.pay(user, OverflowType.DROP); + + for (final ItemStack remainingItem : condenseType.getRemainingItems()) { + remainingItem.setAmount(remainingItem.getAmount() * crafts); + new Trade(remainingItem, ess).pay(user, OverflowType.DROP); + } + return true; } } @@ -120,7 +130,8 @@ private SimpleRecipe getCondenseType(final ItemStack stack) { if (recipeItems != null && (recipeItems.size() == 4 || recipeItems.size() == 9) && (recipeItems.size() > recipe.getResult().getAmount())) { final ItemStack input = stack.clone(); input.setAmount(recipeItems.size()); - final SimpleRecipe newRecipe = new SimpleRecipe(recipe.getResult(), input); + final List remainingItems = getRemainingItems(stack, recipeItems.size()); + final SimpleRecipe newRecipe = new SimpleRecipe(recipe.getResult(), input, remainingItems); bestRecipes.add(newRecipe); } } @@ -187,10 +198,12 @@ protected List getTabCompleteOptions(final Server server, final User use private static final class SimpleRecipe implements Recipe { private final ItemStack result; private final ItemStack input; + private final List remainingItems; - private SimpleRecipe(final ItemStack result, final ItemStack input) { + private SimpleRecipe(final ItemStack result, final ItemStack input, final List remainingItems) { this.result = result; this.input = input; + this.remainingItems = remainingItems; } @Override @@ -201,6 +214,24 @@ public ItemStack getResult() { public ItemStack getInput() { return input.clone(); } + + public List getRemainingItems() { + final List clonedItems = new ArrayList<>(); + + for (final ItemStack item : remainingItems) { + clonedItems.add(item.clone()); + } + + return clonedItems; + } + } + + private List getRemainingItems(final ItemStack input, final int inputAmount) { + if (input.getType() == Material.HONEY_BOTTLE) { + return Collections.singletonList(new ItemStack(Material.GLASS_BOTTLE, inputAmount)); + } + + return Collections.emptyList(); } private static class SimpleRecipeComparator implements Comparator { From c385ecbd82ed8c0d3aedbd70a8edad6c30d0dd0b Mon Sep 17 00:00:00 2001 From: DaleMC Date: Fri, 19 Jun 2026 19:19:45 +0200 Subject: [PATCH 2/3] Remove trailing spaces on blank lines --- .../essentials/commands/Commandcondense.java | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/Essentials/src/main/java/com/earth2me/essentials/commands/Commandcondense.java b/Essentials/src/main/java/com/earth2me/essentials/commands/Commandcondense.java index fd20eb7b9a0..6f21fd59ecf 100644 --- a/Essentials/src/main/java/com/earth2me/essentials/commands/Commandcondense.java +++ b/Essentials/src/main/java/com/earth2me/essentials/commands/Commandcondense.java @@ -92,24 +92,24 @@ private boolean condenseStack(final User user, final ItemStack stack, final bool final int crafts = amount / input.getAmount(); final int output = crafts * result.getAmount(); - + amount -= amount % input.getAmount(); - + if (amount > 0) { input.setAmount(amount); result.setAmount(output); - + final Trade remove = new Trade(input, ess); final Trade add = new Trade(result, ess); - + remove.charge(user); add.pay(user, OverflowType.DROP); - + for (final ItemStack remainingItem : condenseType.getRemainingItems()) { remainingItem.setAmount(remainingItem.getAmount() * crafts); new Trade(remainingItem, ess).pay(user, OverflowType.DROP); } - + return true; } } @@ -214,23 +214,23 @@ public ItemStack getResult() { public ItemStack getInput() { return input.clone(); } - + public List getRemainingItems() { final List clonedItems = new ArrayList<>(); - + for (final ItemStack item : remainingItems) { clonedItems.add(item.clone()); } - + return clonedItems; } } - + private List getRemainingItems(final ItemStack input, final int inputAmount) { if (input.getType() == Material.HONEY_BOTTLE) { return Collections.singletonList(new ItemStack(Material.GLASS_BOTTLE, inputAmount)); } - + return Collections.emptyList(); } @@ -243,4 +243,4 @@ public int compare(final SimpleRecipe o1, final SimpleRecipe o2) { return Integer.compare(o2.getInput().getAmount(), o1.getInput().getAmount()); } } -} +} \ No newline at end of file From f853f48fbc29310194c2c4b489bd7e11295c6f1c Mon Sep 17 00:00:00 2001 From: DaleMC Date: Fri, 19 Jun 2026 19:28:12 +0200 Subject: [PATCH 3/3] fix style --- .../java/com/earth2me/essentials/commands/Commandcondense.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Essentials/src/main/java/com/earth2me/essentials/commands/Commandcondense.java b/Essentials/src/main/java/com/earth2me/essentials/commands/Commandcondense.java index 6f21fd59ecf..2d57bca12e5 100644 --- a/Essentials/src/main/java/com/earth2me/essentials/commands/Commandcondense.java +++ b/Essentials/src/main/java/com/earth2me/essentials/commands/Commandcondense.java @@ -243,4 +243,4 @@ public int compare(final SimpleRecipe o1, final SimpleRecipe o2) { return Integer.compare(o2.getInput().getAmount(), o1.getInput().getAmount()); } } -} \ No newline at end of file +}