mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-25 14:46:46 +01:00
Fire brew event after outputs have changed
and before experience is granted. Part 2 of fixing #2041
This commit is contained in:
parent
37aebc1716
commit
b107a8dc7c
@ -1,5 +1,6 @@
|
||||
package com.gmail.nossr50.skills.alchemy;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Material;
|
||||
@ -17,8 +18,8 @@ import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.config.skills.alchemy.PotionConfig;
|
||||
import com.gmail.nossr50.datatypes.skills.SecondaryAbility;
|
||||
import com.gmail.nossr50.datatypes.skills.alchemy.AlchemyPotion;
|
||||
import com.gmail.nossr50.events.fake.FakeBrewEvent;
|
||||
import com.gmail.nossr50.datatypes.skills.alchemy.PotionStage;
|
||||
import com.gmail.nossr50.events.fake.FakeBrewEvent;
|
||||
import com.gmail.nossr50.runnables.player.PlayerUpdateInventoryTask;
|
||||
import com.gmail.nossr50.runnables.skills.AlchemyBrewCheckTask;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
@ -102,12 +103,7 @@ public final class AlchemyPotionBrewer {
|
||||
return;
|
||||
}
|
||||
|
||||
FakeBrewEvent event = new FakeBrewEvent(brewingStand.getBlock(), inventory);
|
||||
mcMMO.p.getServer().getPluginManager().callEvent(event);
|
||||
|
||||
if (event.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
List<AlchemyPotion> inputList = new ArrayList<AlchemyPotion>();
|
||||
|
||||
for (int i = 0; i < 3; i++) {
|
||||
ItemStack item = inventory.getItem(i);
|
||||
@ -119,15 +115,28 @@ public final class AlchemyPotionBrewer {
|
||||
AlchemyPotion input = PotionConfig.getInstance().getPotion(item.getDurability());
|
||||
AlchemyPotion output = PotionConfig.getInstance().getPotion(input.getChildDataValue(ingredient));
|
||||
|
||||
inputList.add(input);
|
||||
|
||||
if (output != null) {
|
||||
inventory.setItem(i, output.toItemStack(item.getAmount()).clone());
|
||||
}
|
||||
}
|
||||
|
||||
if (player != null) {
|
||||
FakeBrewEvent event = new FakeBrewEvent(brewingStand.getBlock(), inventory);
|
||||
mcMMO.p.getServer().getPluginManager().callEvent(event);
|
||||
|
||||
if (event.isCancelled() || inputList.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (AlchemyPotion input : inputList) {
|
||||
AlchemyPotion output = PotionConfig.getInstance().getPotion(input.getChildDataValue(ingredient));
|
||||
|
||||
if (output != null && player != null) {
|
||||
PotionStage potionStage = PotionStage.getPotionStage(input, output);
|
||||
UserManager.getPlayer(player).getAlchemyManager().handlePotionBrewSuccesses(potionStage, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!forced) {
|
||||
scheduleUpdate(inventory);
|
||||
|
Loading…
Reference in New Issue
Block a user