mirror of
https://github.com/PikaMug/Quests.git
synced 2024-11-15 23:26:11 +01:00
Fix shift-click crafting recipe with result greater than 1, fixes #1235
This commit is contained in:
parent
f13e07f89b
commit
6e761857bc
@ -62,21 +62,16 @@ public class ItemListener implements Listener {
|
|||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
private ItemStack getCraftedItem(CraftItemEvent evt) {
|
private ItemStack getCraftedItem(CraftItemEvent evt) {
|
||||||
if (evt.isShiftClick()) {
|
if (evt.isShiftClick()) {
|
||||||
ItemStack result = evt.getRecipe().getResult();
|
ItemStack recipeResult = evt.getRecipe().getResult();
|
||||||
int numberOfItems = result.getAmount();
|
int resultAmt = recipeResult.getAmount(); // Bread = 1, Cookie = 8, etc.
|
||||||
int itemsChecked = 0;
|
|
||||||
|
|
||||||
|
int leastIngredient = 1;
|
||||||
for (ItemStack item : evt.getInventory().getMatrix()) {
|
for (ItemStack item : evt.getInventory().getMatrix()) {
|
||||||
if (item != null && !item.getType().equals(Material.AIR)) {
|
if (item != null && !item.getType().equals(Material.AIR)) {
|
||||||
if (itemsChecked == 0) {
|
leastIngredient = Math.min(leastIngredient * resultAmt, item.getAmount() * resultAmt);
|
||||||
numberOfItems = item.getAmount();
|
|
||||||
} else {
|
|
||||||
numberOfItems = Math.min(numberOfItems, item.getAmount());
|
|
||||||
itemsChecked++;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
return new ItemStack(recipeResult.getType(), leastIngredient, recipeResult.getDurability());
|
||||||
return new ItemStack(result.getType(), numberOfItems, result.getDurability());
|
|
||||||
}
|
}
|
||||||
return evt.getCurrentItem();
|
return evt.getCurrentItem();
|
||||||
}
|
}
|
||||||
|
@ -167,7 +167,7 @@ public class PlayerListener implements Listener {
|
|||||||
} catch (NoSuchMethodError err) {
|
} catch (NoSuchMethodError err) {
|
||||||
// Do nothing, getHand() not present pre-1.9
|
// Do nothing, getHand() not present pre-1.9
|
||||||
}
|
}
|
||||||
if (e == null || e.equals(EquipmentSlot.HAND)) { //If the event is fired by HAND (main hand)
|
if (e == null || e.equals(EquipmentSlot.HAND)) { // If the event is fired by HAND (main hand)
|
||||||
if (evt.hasBlock() && ItemUtil.isJournal(evt.getPlayer().getItemInHand())) {
|
if (evt.hasBlock() && ItemUtil.isJournal(evt.getPlayer().getItemInHand())) {
|
||||||
if (evt.getClickedBlock().getType().name().contains("PORTAL")
|
if (evt.getClickedBlock().getType().name().contains("PORTAL")
|
||||||
&& plugin.getSettings().canAllowPranks()) {
|
&& plugin.getSettings().canAllowPranks()) {
|
||||||
|
Loading…
Reference in New Issue
Block a user