mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-23 05:36:46 +01:00
Because we need to care about the result, not the source.
Also adds a couple of null checks, just to be safe.
This commit is contained in:
parent
a8b5b438bf
commit
a01882aea5
@ -12,6 +12,7 @@ import org.bukkit.event.inventory.InventoryCloseEvent;
|
||||
import org.bukkit.event.inventory.InventoryOpenEvent;
|
||||
import org.bukkit.event.inventory.InventoryType;
|
||||
import org.bukkit.inventory.FurnaceInventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.skills.smelting.SmeltingManager;
|
||||
@ -58,8 +59,9 @@ public class InventoryListener implements Listener{
|
||||
public void onFurnaceBurnEvent(FurnaceBurnEvent event) {
|
||||
Block furnaceBlock = event.getBlock();
|
||||
FurnaceInventory inventory = ((Furnace)furnaceBlock.getState()).getInventory();
|
||||
ItemStack smelting = inventory.getSmelting();
|
||||
|
||||
if (plugin.furnaceIsTracked(furnaceBlock) && ItemChecks.isSmeltable(inventory.getSmelting())) {
|
||||
if (plugin.furnaceIsTracked(furnaceBlock) && smelting != null && ItemChecks.isSmeltable(smelting)) {
|
||||
SmeltingManager smeltingManager = new SmeltingManager(plugin.getFurnacePlayer(furnaceBlock));
|
||||
smeltingManager.fuelEfficiency(event);
|
||||
}
|
||||
@ -69,8 +71,9 @@ public class InventoryListener implements Listener{
|
||||
public void onFurnaceSmeltEvent(FurnaceSmeltEvent event) {
|
||||
Block furnaceBlock = event.getBlock();
|
||||
FurnaceInventory inventory = ((Furnace)furnaceBlock.getState()).getInventory();
|
||||
ItemStack smelting = inventory.getSmelting();
|
||||
|
||||
if (plugin.furnaceIsTracked(furnaceBlock) && ItemChecks.isSmeltable(inventory.getSmelting())) {
|
||||
if (plugin.furnaceIsTracked(furnaceBlock) && smelting != null && ItemChecks.isSmeltable(smelting)) {
|
||||
SmeltingManager smeltingManager = new SmeltingManager(plugin.getFurnacePlayer(furnaceBlock));
|
||||
smeltingManager.smeltProcessing(event);
|
||||
}
|
||||
@ -80,8 +83,9 @@ public class InventoryListener implements Listener{
|
||||
public void onFurnaceExtractEvent(FurnaceExtractEvent event) {
|
||||
Block furnaceBlock = event.getBlock();
|
||||
FurnaceInventory inventory = ((Furnace)furnaceBlock.getState()).getInventory();
|
||||
ItemStack result = inventory.getResult();
|
||||
|
||||
if (plugin.furnaceIsTracked(furnaceBlock) && inventory.getSmelting() != null && ItemChecks.isSmeltable(inventory.getSmelting())) {
|
||||
if (plugin.furnaceIsTracked(furnaceBlock) && result != null && ItemChecks.isSmelted(result)) {
|
||||
SmeltingManager smeltingManager = new SmeltingManager(plugin.getFurnacePlayer(furnaceBlock));
|
||||
smeltingManager.vanillaXPBoost(event);
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.gmail.nossr50.util;
|
||||
|
||||
import org.bukkit.DyeColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
@ -490,4 +491,26 @@ public class ItemChecks {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isSmelted(ItemStack itemStack) {
|
||||
switch (itemStack.getType()) {
|
||||
case COAL:
|
||||
case DIAMOND:
|
||||
case REDSTONE:
|
||||
case GOLD_INGOT:
|
||||
case IRON_INGOT:
|
||||
case EMERALD:
|
||||
return true;
|
||||
|
||||
case INK_SACK:
|
||||
if (itemStack.getData().getData() == DyeColor.BLUE.getDyeData()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user