mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2025-04-04 02:36:23 +02:00
Check if the furnace is actually a furnace - fixes ClassCastExceptions
caused by "virtual furnace" plugins.
This commit is contained in:
parent
5bf1e49e43
commit
659e982c47
@ -1,6 +1,7 @@
|
|||||||
package com.gmail.nossr50.listeners;
|
package com.gmail.nossr50.listeners;
|
||||||
|
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
|
import org.bukkit.block.BlockState;
|
||||||
import org.bukkit.block.Furnace;
|
import org.bukkit.block.Furnace;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
@ -69,15 +70,19 @@ public class InventoryListener implements Listener{
|
|||||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||||
public void onFurnaceBurnEvent(FurnaceBurnEvent event) {
|
public void onFurnaceBurnEvent(FurnaceBurnEvent event) {
|
||||||
Block furnaceBlock = event.getBlock();
|
Block furnaceBlock = event.getBlock();
|
||||||
FurnaceInventory inventory = ((Furnace)furnaceBlock.getState()).getInventory();
|
BlockState blockState = furnaceBlock.getState();
|
||||||
ItemStack smelting = inventory.getSmelting();
|
|
||||||
|
|
||||||
if (plugin.furnaceIsTracked(furnaceBlock) && smelting != null && ItemChecks.isSmeltable(smelting)) {
|
if (blockState instanceof Furnace) {
|
||||||
Player player = plugin.getFurnacePlayer(furnaceBlock);
|
FurnaceInventory inventory = ((Furnace) blockState).getInventory();
|
||||||
|
ItemStack smelting = inventory.getSmelting();
|
||||||
if (player != null) {
|
|
||||||
SmeltingManager smeltingManager = new SmeltingManager(player);
|
if (plugin.furnaceIsTracked(furnaceBlock) && smelting != null && ItemChecks.isSmeltable(smelting)) {
|
||||||
smeltingManager.fuelEfficiency(event);
|
Player player = plugin.getFurnacePlayer(furnaceBlock);
|
||||||
|
|
||||||
|
if (player != null) {
|
||||||
|
SmeltingManager smeltingManager = new SmeltingManager(player);
|
||||||
|
smeltingManager.fuelEfficiency(event);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -85,15 +90,19 @@ public class InventoryListener implements Listener{
|
|||||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||||
public void onFurnaceSmeltEvent(FurnaceSmeltEvent event) {
|
public void onFurnaceSmeltEvent(FurnaceSmeltEvent event) {
|
||||||
Block furnaceBlock = event.getBlock();
|
Block furnaceBlock = event.getBlock();
|
||||||
FurnaceInventory inventory = ((Furnace)furnaceBlock.getState()).getInventory();
|
BlockState blockState = furnaceBlock.getState();
|
||||||
ItemStack smelting = inventory.getSmelting();
|
|
||||||
|
|
||||||
if (plugin.furnaceIsTracked(furnaceBlock) && smelting != null && ItemChecks.isSmeltable(smelting)) {
|
if (blockState instanceof Furnace) {
|
||||||
Player player = plugin.getFurnacePlayer(furnaceBlock);
|
FurnaceInventory inventory = ((Furnace) blockState).getInventory();
|
||||||
|
ItemStack smelting = inventory.getSmelting();
|
||||||
if (player != null) {
|
|
||||||
SmeltingManager smeltingManager = new SmeltingManager(player);
|
if (plugin.furnaceIsTracked(furnaceBlock) && smelting != null && ItemChecks.isSmeltable(smelting)) {
|
||||||
smeltingManager.smeltProcessing(event);
|
Player player = plugin.getFurnacePlayer(furnaceBlock);
|
||||||
|
|
||||||
|
if (player != null) {
|
||||||
|
SmeltingManager smeltingManager = new SmeltingManager(player);
|
||||||
|
smeltingManager.smeltProcessing(event);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -101,12 +110,16 @@ public class InventoryListener implements Listener{
|
|||||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||||
public void onFurnaceExtractEvent(FurnaceExtractEvent event) {
|
public void onFurnaceExtractEvent(FurnaceExtractEvent event) {
|
||||||
Block furnaceBlock = event.getBlock();
|
Block furnaceBlock = event.getBlock();
|
||||||
FurnaceInventory inventory = ((Furnace)furnaceBlock.getState()).getInventory();
|
BlockState blockState = furnaceBlock.getState();
|
||||||
ItemStack result = inventory.getResult();
|
|
||||||
|
|
||||||
if (plugin.furnaceIsTracked(furnaceBlock) && result != null && ItemChecks.isSmelted(result)) {
|
if (blockState instanceof Furnace) {
|
||||||
SmeltingManager smeltingManager = new SmeltingManager(plugin.getFurnacePlayer(furnaceBlock));
|
FurnaceInventory inventory = ((Furnace) blockState).getInventory();
|
||||||
smeltingManager.vanillaXPBoost(event);
|
ItemStack result = inventory.getResult();
|
||||||
|
|
||||||
|
if (plugin.furnaceIsTracked(furnaceBlock) && result != null && ItemChecks.isSmelted(result)) {
|
||||||
|
SmeltingManager smeltingManager = new SmeltingManager(plugin.getFurnacePlayer(furnaceBlock));
|
||||||
|
smeltingManager.vanillaXPBoost(event);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user