More code duplication removal.

This commit is contained in:
GJ
2013-06-12 15:56:42 -04:00
parent db637f0bc9
commit 3a78e1b487
4 changed files with 44 additions and 40 deletions

View File

@ -461,6 +461,10 @@ public class ItemUtils {
}
public static boolean isSmeltable(ItemStack item) {
if (item == null) {
return false;
}
switch (item.getType()) {
case COAL_ORE:
case DIAMOND_ORE:
@ -479,6 +483,10 @@ public class ItemUtils {
}
public static boolean isSmelted(ItemStack item) {
if (item == null) {
return false;
}
switch (item.getType()) {
case COAL:
case DIAMOND:

View File

@ -8,6 +8,7 @@ import org.bukkit.Chunk;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.BlockState;
import org.bukkit.block.Furnace;
import org.bukkit.entity.Entity;
import org.bukkit.entity.HumanEntity;
@ -230,7 +231,31 @@ public final class Misc {
public static Player getPlayerFromFurnace(Block furnaceBlock) {
List<MetadataValue> metadata = furnaceBlock.getMetadata(mcMMO.furnaceMetadataKey);
return metadata.isEmpty() ? null : mcMMO.p.getServer().getPlayerExact(metadata.get(0).asString());
if (metadata.isEmpty()) {
return null;
}
return mcMMO.p.getServer().getPlayerExact(metadata.get(0).asString());
}
public static ItemStack getSmeltingFromFurnace(Block furnaceBlock) {
BlockState furnaceState = furnaceBlock.getState();
if (!(furnaceState instanceof Furnace)) {
return null;
}
return ((Furnace) furnaceState).getInventory().getSmelting();
}
public static ItemStack getResultFromFurnace(Block furnaceBlock) {
BlockState furnaceState = furnaceBlock.getState();
if (!(furnaceState instanceof Furnace)) {
return null;
}
return ((Furnace) furnaceState).getInventory().getResult();
}
public static Random getRandom() {