mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-25 14:46:46 +01:00
minor refactoring
This commit is contained in:
parent
eeecf18caf
commit
4fce053804
@ -156,7 +156,7 @@ public class AlchemyBrewTask extends CancellableRunnable {
|
|||||||
mcMMO.p.getServer().getPluginManager().callEvent(event);
|
mcMMO.p.getServer().getPluginManager().callEvent(event);
|
||||||
|
|
||||||
if (!event.isCancelled()) {
|
if (!event.isCancelled()) {
|
||||||
AlchemyPotionBrewer.finishBrewing(brewingStand, mmoPlayer.getPlayer(), false);
|
AlchemyPotionBrewer.finishBrewing(brewingStand, mmoPlayer, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
Alchemy.brewingStandMap.remove(brewingStand.getLocation());
|
Alchemy.brewingStandMap.remove(brewingStand.getLocation());
|
||||||
@ -165,7 +165,7 @@ public class AlchemyBrewTask extends CancellableRunnable {
|
|||||||
public void finishImmediately() {
|
public void finishImmediately() {
|
||||||
this.cancel();
|
this.cancel();
|
||||||
|
|
||||||
AlchemyPotionBrewer.finishBrewing(brewingStand, mmoPlayer.getPlayer(), true);
|
AlchemyPotionBrewer.finishBrewing(brewingStand, mmoPlayer, true);
|
||||||
Alchemy.brewingStandMap.remove(brewingStand.getLocation());
|
Alchemy.brewingStandMap.remove(brewingStand.getLocation());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -144,7 +144,7 @@ public final class AlchemyPotionBrewer {
|
|||||||
? 1 : mmoPlayer.getAlchemyManager().getTier());
|
? 1 : mmoPlayer.getAlchemyManager().getTier());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void finishBrewing(BlockState brewingStand, Player player, boolean forced) {
|
public static void finishBrewing(BlockState brewingStand, @Nullable McMMOPlayer mmoPlayer, boolean forced) {
|
||||||
// Check if the brewing stand block state is an actual brewing stand
|
// Check if the brewing stand block state is an actual brewing stand
|
||||||
if (!(brewingStand instanceof BrewingStand)) {
|
if (!(brewingStand instanceof BrewingStand)) {
|
||||||
return;
|
return;
|
||||||
@ -153,9 +153,15 @@ public final class AlchemyPotionBrewer {
|
|||||||
// Retrieve the inventory of the brewing stand and clone the current ingredient for safe manipulation
|
// Retrieve the inventory of the brewing stand and clone the current ingredient for safe manipulation
|
||||||
final BrewerInventory inventory = ((BrewingStand) brewingStand).getInventory();
|
final BrewerInventory inventory = ((BrewingStand) brewingStand).getInventory();
|
||||||
final ItemStack ingredient = inventory.getIngredient() == null ? null : inventory.getIngredient().clone();
|
final ItemStack ingredient = inventory.getIngredient() == null ? null : inventory.getIngredient().clone();
|
||||||
|
Player player = mmoPlayer != null ? mmoPlayer.getPlayer() : null;
|
||||||
|
|
||||||
|
if (ingredient == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Check if the brewing stand has a valid ingredient; if not, exit the method
|
// Check if the brewing stand has a valid ingredient; if not, exit the method
|
||||||
if (!hasIngredient(inventory, player)) {
|
if (player == null
|
||||||
|
|| !hasIngredient(inventory, player)) {
|
||||||
// debug
|
// debug
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user