From d2bbbb0fe75b3ddf176530f5bd636fb34f37a7b6 Mon Sep 17 00:00:00 2001 From: GJ Date: Thu, 5 Sep 2013 16:36:02 -0400 Subject: [PATCH] More deprecation fixes. --- .../nossr50/listeners/PlayerListener.java | 2 +- .../nossr50/skills/herbalism/Herbalism.java | 6 ++- .../skills/herbalism/HerbalismManager.java | 48 +++++++++++++------ .../gmail/nossr50/skills/repair/Repair.java | 3 +- .../com/gmail/nossr50/util/BlockUtils.java | 10 +++- .../com/gmail/nossr50/util/ChimaeraWing.java | 9 ++-- 6 files changed, 54 insertions(+), 24 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java b/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java index 7d7448b25..ef437ab62 100644 --- a/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java @@ -443,7 +443,7 @@ public class PlayerListener implements Listener { } /* BLAST MINING CHECK */ else if (miningManager.canDetonate()) { - if (blockID == Material.TNT.getId()) { + if (block.getType() == Material.TNT) { event.setCancelled(true); // Don't detonate the TNT if they're too close } else { diff --git a/src/main/java/com/gmail/nossr50/skills/herbalism/Herbalism.java b/src/main/java/com/gmail/nossr50/skills/herbalism/Herbalism.java index ffb433518..f5d5ad7f8 100644 --- a/src/main/java/com/gmail/nossr50/skills/herbalism/Herbalism.java +++ b/src/main/java/com/gmail/nossr50/skills/herbalism/Herbalism.java @@ -4,6 +4,7 @@ import org.bukkit.Material; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; import org.bukkit.block.BlockState; +import org.bukkit.material.SmoothBrick; import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.config.AdvancedConfig; @@ -37,10 +38,13 @@ public class Herbalism { protected static boolean convertGreenTerraBlocks(BlockState blockState) { switch (blockState.getType()) { case COBBLE_WALL: - case SMOOTH_BRICK: blockState.setRawData((byte) 0x1); return true; + case SMOOTH_BRICK: + ((SmoothBrick) blockState.getData()).setMaterial(Material.MOSSY_COBBLESTONE); + return true; + case DIRT: blockState.setType(Material.GRASS); return true; diff --git a/src/main/java/com/gmail/nossr50/skills/herbalism/HerbalismManager.java b/src/main/java/com/gmail/nossr50/skills/herbalism/HerbalismManager.java index b81037153..8ca06895d 100644 --- a/src/main/java/com/gmail/nossr50/skills/herbalism/HerbalismManager.java +++ b/src/main/java/com/gmail/nossr50/skills/herbalism/HerbalismManager.java @@ -12,6 +12,7 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.PlayerInventory; import org.bukkit.material.CocoaPlant; import org.bukkit.material.CocoaPlant.CocoaPlantSize; +import org.bukkit.material.Crops; import org.bukkit.material.NetherWarts; import com.gmail.nossr50.mcMMO; @@ -294,15 +295,41 @@ public class HerbalismManager extends SkillManager { } private boolean handleBlockState(BlockState blockState, boolean greenTerra) { + byte greenThumbStage = getGreenThumbStage(); + switch (blockState.getType()) { case CROPS: + Crops crops = (Crops) blockState.getData(); + + if (greenTerra) { + crops.setState(CropState.MEDIUM); + } + else { + switch (greenThumbStage) { + case 4: + crops.setState(CropState.SMALL); + break; + case 3: + crops.setState(CropState.VERY_SMALL); + break; + case 2: + crops.setState(CropState.GERMINATED); + break; + default: + crops.setState(CropState.SEEDED); + break; + } + } + + return true; + case CARROT: case POTATO: if (greenTerra) { - blockState.setRawData(CropState.MEDIUM.getData()); // 2 + blockState.setRawData(CropState.MEDIUM.getData()); } else { - blockState.setRawData(getGreenThumbStage()); + blockState.setRawData(greenThumbStage); } return true; @@ -310,21 +337,14 @@ public class HerbalismManager extends SkillManager { case NETHER_WARTS: NetherWarts warts = (NetherWarts) blockState.getData(); - if (greenTerra) { + if (greenTerra || greenThumbStage > 2) { warts.setState(NetherWartsState.STAGE_TWO); } + else if (greenThumbStage == 2) { + warts.setState(NetherWartsState.STAGE_ONE); + } else { - int greenThumbStage = getGreenThumbStage(); - - if (greenThumbStage > 2) { - warts.setState(NetherWartsState.STAGE_TWO); - } - else if (greenThumbStage == 2) { - warts.setState(NetherWartsState.STAGE_ONE); - } - else { - warts.setState(NetherWartsState.SEEDED); - } + warts.setState(NetherWartsState.SEEDED); } return true; diff --git a/src/main/java/com/gmail/nossr50/skills/repair/Repair.java b/src/main/java/com/gmail/nossr50/skills/repair/Repair.java index 967db1501..5f83b4495 100644 --- a/src/main/java/com/gmail/nossr50/skills/repair/Repair.java +++ b/src/main/java/com/gmail/nossr50/skills/repair/Repair.java @@ -3,6 +3,7 @@ package com.gmail.nossr50.skills.repair; import org.bukkit.Material; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.PlayerInventory; +import org.bukkit.material.MaterialData; import com.gmail.nossr50.config.AdvancedConfig; import com.gmail.nossr50.config.Config; @@ -102,7 +103,7 @@ public class Repair { continue; } - if (item.getTypeId() == itemId && item.getData().getData() == metadata) { + if (item.getData().equals(new MaterialData(itemId, metadata))) { return i; } } diff --git a/src/main/java/com/gmail/nossr50/util/BlockUtils.java b/src/main/java/com/gmail/nossr50/util/BlockUtils.java index c67e605bd..1001a1bbe 100644 --- a/src/main/java/com/gmail/nossr50/util/BlockUtils.java +++ b/src/main/java/com/gmail/nossr50/util/BlockUtils.java @@ -7,6 +7,8 @@ import org.bukkit.Material; import org.bukkit.NetherWartsState; import org.bukkit.block.BlockState; import org.bukkit.material.CocoaPlant; +import org.bukkit.material.Crops; +import org.bukkit.material.SmoothBrick; import org.bukkit.material.CocoaPlant.CocoaPlantSize; import org.bukkit.material.NetherWarts; @@ -103,6 +105,8 @@ public final class BlockUtils { return true; case SMOOTH_BRICK: + return ((SmoothBrick) blockState.getData()).getMaterial() == Material.STONE; + case COBBLE_WALL: return blockState.getRawData() == (byte) 0x0; @@ -132,10 +136,12 @@ public final class BlockUtils { return true; case CARROT: - case CROPS: case POTATO: return blockState.getRawData() == CropState.RIPE.getData(); + case CROPS: + return ((Crops) blockState.getData()).getState() == CropState.RIPE; + case NETHER_WARTS: return ((NetherWarts) blockState.getData()).getState() == NetherWartsState.RIPE; @@ -281,7 +287,7 @@ public final class BlockUtils { public static boolean affectedByBlockCracker(BlockState blockState) { switch (blockState.getType()) { case SMOOTH_BRICK: - return blockState.getRawData() == (byte) 0x0; + return ((SmoothBrick) blockState.getData()).getMaterial() == Material.STONE; default: return false; diff --git a/src/main/java/com/gmail/nossr50/util/ChimaeraWing.java b/src/main/java/com/gmail/nossr50/util/ChimaeraWing.java index 335735e73..f31f7ae30 100644 --- a/src/main/java/com/gmail/nossr50/util/ChimaeraWing.java +++ b/src/main/java/com/gmail/nossr50/util/ChimaeraWing.java @@ -142,8 +142,7 @@ public final class ChimaeraWing { } public static ItemStack getChimaeraWing(int amount) { - Material ingredient = Material.getMaterial(Config.getInstance().getChimaeraItemId()); - ItemStack itemStack = new ItemStack(ingredient, amount); + ItemStack itemStack = new ItemStack(Config.getInstance().getChimaeraItemId(), amount); ItemMeta itemMeta = itemStack.getItemMeta(); itemMeta.setDisplayName(ChatColor.GOLD + LocaleLoader.getString("Item.ChimaeraWing.Name")); @@ -164,8 +163,8 @@ public final class ChimaeraWing { amount = 9; } - ShapelessRecipe ChimaeraWing = new ShapelessRecipe(getChimaeraWing(1)); - ChimaeraWing.addIngredient(amount, ingredient); - return ChimaeraWing; + ShapelessRecipe chimeraWing = new ShapelessRecipe(getChimaeraWing(1)); + chimeraWing.addIngredient(amount, ingredient); + return chimeraWing; } }