From cbafa7110ac6e433ffd8547acce8570cd84cc1e6 Mon Sep 17 00:00:00 2001 From: bm01 Date: Thu, 10 May 2012 15:54:29 +0200 Subject: [PATCH] Fixed minor Green Terra bugs on Stone Brick --- Changelog.txt | 2 + .../gmail/nossr50/datatypes/AbilityType.java | 17 +++--- .../nossr50/listeners/BlockListener.java | 22 ++++---- .../nossr50/listeners/PlayerListener.java | 6 +- .../nossr50/skills/gathering/BlastMining.java | 2 +- .../nossr50/skills/gathering/Herbalism.java | 10 ++-- .../nossr50/skills/gathering/Mining.java | 2 +- .../nossr50/skills/gathering/WoodCutting.java | 10 ++-- .../com/gmail/nossr50/util/BlockChecks.java | 55 ++++++++++--------- .../java/com/gmail/nossr50/util/Skills.java | 2 +- 10 files changed, 65 insertions(+), 63 deletions(-) diff --git a/Changelog.txt b/Changelog.txt index abaca45e3..68692e365 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -20,6 +20,8 @@ Version 1.3.07 + Added config options for enabling/disabling specific double drops + Added automatic zip backup of flatfile database & config files + Added config options to enable/disable specific skills for PVP & PVE + = Fixed bug where Green Terra consumed seeds even on Mossy Stone Brick + = Fixed bug where the client didn't reflect the Stone Brick to Mossy Stone Brick change = Fixed bug where an arrow could bounce off entities on daze proc = Fixed bug where a player could gain Acrobatics experience while riding a cart = Fixed /party not working properly with 2 arguments diff --git a/src/main/java/com/gmail/nossr50/datatypes/AbilityType.java b/src/main/java/com/gmail/nossr50/datatypes/AbilityType.java index 4c7319436..2fe3f088c 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/AbilityType.java +++ b/src/main/java/com/gmail/nossr50/datatypes/AbilityType.java @@ -1,6 +1,7 @@ package com.gmail.nossr50.datatypes; import org.bukkit.Material; +import org.bukkit.block.Block; import org.bukkit.entity.Player; import com.gmail.nossr50.config.Config; @@ -166,28 +167,28 @@ public enum AbilityType { /** * Check if a block is affected by this ability. * - * @param material The block type to check + * @param Block the block to check * @return true if the block is affected by this ability, false otherwise */ - public boolean blockCheck(Material material) { + public boolean blockCheck(Block block) { switch (this) { case BERSERK: - return (BlockChecks.canBeGigaDrillBroken(material) || material.equals(Material.SNOW)); + return (BlockChecks.canBeGigaDrillBroken(block) || block.getType() == Material.SNOW); case GIGA_DRILL_BREAKER: - return BlockChecks.canBeGigaDrillBroken(material); + return BlockChecks.canBeGigaDrillBroken(block); case GREEN_TERRA: - return BlockChecks.makeMossy(material); + return BlockChecks.makeMossy(block); case LEAF_BLOWER: - return material.equals(Material.LEAVES); + return block.getType() == Material.LEAVES; case SUPER_BREAKER: - return BlockChecks.canBeSuperBroken(material); + return BlockChecks.canBeSuperBroken(block); case TREE_FELLER: - return material.equals(Material.LOG); + return block.getType() == Material.LOG; default: return false; diff --git a/src/main/java/com/gmail/nossr50/listeners/BlockListener.java b/src/main/java/com/gmail/nossr50/listeners/BlockListener.java index 94f517dfd..eaa4749e9 100644 --- a/src/main/java/com/gmail/nossr50/listeners/BlockListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/BlockListener.java @@ -146,16 +146,16 @@ public class BlockListener implements Listener { */ /* Green Terra */ - if (PP.getToolPreparationMode(ToolType.HOE) && Permissions.getInstance().greenTerra(player) && ((mat.equals(Material.CROPS) && block.getData() == CropState.RIPE.getData()) || BlockChecks.canBeGreenTerra(mat))) { + if (PP.getToolPreparationMode(ToolType.HOE) && Permissions.getInstance().greenTerra(player) && ((mat.equals(Material.CROPS) && block.getData() == CropState.RIPE.getData()) || BlockChecks.canBeGreenTerra(block))) { Skills.abilityCheck(player, SkillType.HERBALISM); } /* Triple drops */ - if (PP.getAbilityMode(AbilityType.GREEN_TERRA) && BlockChecks.canBeGreenTerra(mat)) { + if (PP.getAbilityMode(AbilityType.GREEN_TERRA) && BlockChecks.canBeGreenTerra(block)) { Herbalism.herbalismProcCheck(block, player, event, plugin); } - if (Permissions.getInstance().herbalism(player) && BlockChecks.canBeGreenTerra(mat)) { + if (Permissions.getInstance().herbalism(player) && BlockChecks.canBeGreenTerra(block)) { Herbalism.herbalismProcCheck(block, player, event, plugin); } @@ -163,7 +163,7 @@ public class BlockListener implements Listener { * MINING */ - if (Permissions.getInstance().mining(player) && BlockChecks.canBeSuperBroken(mat)) { + if (Permissions.getInstance().mining(player) && BlockChecks.canBeSuperBroken(block)) { if (Config.getInstance().getMiningRequiresTool() && ItemChecks.isPickaxe(inhand)) { Mining.miningBlockCheck(player, block); } @@ -193,7 +193,7 @@ public class BlockListener implements Listener { * EXCAVATION */ - if (BlockChecks.canBeGigaDrillBroken(mat) && Permissions.getInstance().excavation(player) && !mcMMO.placeStore.isTrue(block)) { + if (BlockChecks.canBeGigaDrillBroken(block) && Permissions.getInstance().excavation(player) && !mcMMO.placeStore.isTrue(block)) { if (Config.getInstance().getExcavationRequiresTool() && ItemChecks.isShovel(inhand)) { Excavation.excavationProcCheck(block, player); } @@ -226,20 +226,20 @@ public class BlockListener implements Listener { /* * ABILITY PREPARATION CHECKS */ - if (BlockChecks.abilityBlockCheck(mat)) { - if (PP.getToolPreparationMode(ToolType.HOE) && (BlockChecks.canBeGreenTerra(mat) || BlockChecks.makeMossy(mat))) { + if (BlockChecks.abilityBlockCheck(block)) { + if (PP.getToolPreparationMode(ToolType.HOE) && (BlockChecks.canBeGreenTerra(block) || BlockChecks.makeMossy(block))) { Skills.abilityCheck(player, SkillType.HERBALISM); } else if (PP.getToolPreparationMode(ToolType.AXE) && mat.equals(Material.LOG) && Permissions.getInstance().treeFeller(player)) { //TODO: Why are we checking the permissions here? Skills.abilityCheck(player, SkillType.WOODCUTTING); } - else if (PP.getToolPreparationMode(ToolType.PICKAXE) && BlockChecks.canBeSuperBroken(mat)) { + else if (PP.getToolPreparationMode(ToolType.PICKAXE) && BlockChecks.canBeSuperBroken(block)) { Skills.abilityCheck(player, SkillType.MINING); } - else if (PP.getToolPreparationMode(ToolType.SHOVEL) && BlockChecks.canBeGigaDrillBroken(mat)) { + else if (PP.getToolPreparationMode(ToolType.SHOVEL) && BlockChecks.canBeGigaDrillBroken(block)) { Skills.abilityCheck(player, SkillType.EXCAVATION); } - else if (PP.getToolPreparationMode(ToolType.FISTS) && (BlockChecks.canBeGigaDrillBroken(mat) || mat.equals(Material.SNOW))) { + else if (PP.getToolPreparationMode(ToolType.FISTS) && (BlockChecks.canBeGigaDrillBroken(block) || mat.equals(Material.SNOW))) { Skills.abilityCheck(player, SkillType.UNARMED); } } @@ -252,7 +252,7 @@ public class BlockListener implements Listener { /* * ABILITY TRIGGER CHECKS */ - if (PP.getAbilityMode(AbilityType.GREEN_TERRA) && Permissions.getInstance().greenTerra(player) && BlockChecks.makeMossy(mat)) { + if (PP.getAbilityMode(AbilityType.GREEN_TERRA) && Permissions.getInstance().greenTerra(player) && BlockChecks.makeMossy(block)) { Herbalism.greenTerra(player, block); } else if (PP.getAbilityMode(AbilityType.GIGA_DRILL_BREAKER) && Skills.triggerCheck(player, block, AbilityType.GIGA_DRILL_BREAKER)) { diff --git a/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java b/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java index 8197162b1..4c8e9f845 100644 --- a/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java @@ -208,7 +208,7 @@ public class PlayerListener implements Listener { } /* ACTIVATION CHECKS */ - if (Config.getInstance().getAbilitiesEnabled() && BlockChecks.abilityBlockCheck(mat)) { + if (Config.getInstance().getAbilitiesEnabled() && BlockChecks.abilityBlockCheck(block)) { if (!mat.equals(Material.DIRT) && !mat.equals(Material.GRASS) && !mat.equals(Material.SOIL)) { Skills.activationCheck(player, SkillType.HERBALISM); } @@ -222,12 +222,12 @@ public class PlayerListener implements Listener { } /* GREEN THUMB CHECK */ - if (Permissions.getInstance().greenThumbBlocks(player) && BlockChecks.makeMossy(mat) && is.getType().equals(Material.SEEDS)) { + if (Permissions.getInstance().greenThumbBlocks(player) && BlockChecks.makeMossy(block) && is.getType().equals(Material.SEEDS)) { Herbalism.greenThumbBlocks(is, player, block); } /* ITEM CHECKS */ - if (BlockChecks.abilityBlockCheck(mat)) { + if (BlockChecks.abilityBlockCheck(block)) { Item.itemChecks(player); } diff --git a/src/main/java/com/gmail/nossr50/skills/gathering/BlastMining.java b/src/main/java/com/gmail/nossr50/skills/gathering/BlastMining.java index 5eaff7324..99f4d6cb4 100644 --- a/src/main/java/com/gmail/nossr50/skills/gathering/BlastMining.java +++ b/src/main/java/com/gmail/nossr50/skills/gathering/BlastMining.java @@ -103,7 +103,7 @@ public class BlastMining { while (iterator.hasNext()) { Block temp = iterator.next(); - if (BlockChecks.isOre(temp.getType())) { + if (BlockChecks.isOre(temp)) { ores.add(temp); } else { diff --git a/src/main/java/com/gmail/nossr50/skills/gathering/Herbalism.java b/src/main/java/com/gmail/nossr50/skills/gathering/Herbalism.java index 0fb285e05..7381de143 100644 --- a/src/main/java/com/gmail/nossr50/skills/gathering/Herbalism.java +++ b/src/main/java/com/gmail/nossr50/skills/gathering/Herbalism.java @@ -42,7 +42,6 @@ public class Herbalism { } else if (hasSeeds && !block.getType().equals(Material.WHEAT)) { inventory.removeItem(new ItemStack(Material.SEEDS)); - player.updateInventory(); greenTerraConvert(player, block); } } @@ -51,13 +50,13 @@ public class Herbalism { Material type = block.getType(); if (Misc.blockBreakSimulate(block, player, false)) { - if (Config.getInstance().getHerbalismGreenThumbSmoothbrickToMossy() && type.equals(Material.SMOOTH_BRICK)) { - block.setData((byte) 0x1); //Set type of the brick to mossy + if (Config.getInstance().getHerbalismGreenThumbSmoothbrickToMossy() && type == Material.SMOOTH_BRICK && block.getData() == 0) { + block.setTypeIdAndData(block.getTypeId(), (byte) 1, false); //Set type of the brick to mossy, force the client update } - else if (Config.getInstance().getHerbalismGreenThumbDirtToGrass() && type.equals(Material.DIRT)) { + else if (Config.getInstance().getHerbalismGreenThumbDirtToGrass() && type == Material.DIRT) { block.setType(Material.GRASS); } - else if (Config.getInstance().getHerbalismGreenThumbCobbleToMossy() && type.equals(Material.COBBLESTONE)) { + else if (Config.getInstance().getHerbalismGreenThumbCobbleToMossy() && type == Material.COBBLESTONE) { block.setType(Material.MOSSY_COBBLESTONE); } } @@ -299,7 +298,6 @@ public class Herbalism { plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new GreenThumbTimer(block, PP), 1); inventory.removeItem(new ItemStack(Material.SEEDS)); - player.updateInventory(); } } diff --git a/src/main/java/com/gmail/nossr50/skills/gathering/Mining.java b/src/main/java/com/gmail/nossr50/skills/gathering/Mining.java index 524f93410..35bada281 100644 --- a/src/main/java/com/gmail/nossr50/skills/gathering/Mining.java +++ b/src/main/java/com/gmail/nossr50/skills/gathering/Mining.java @@ -218,7 +218,7 @@ public class Mining { miningXP(player, block); - if (BlockChecks.canBeSuperBroken(block.getType())) { + if (BlockChecks.canBeSuperBroken(block)) { final int MAX_BONUS_LEVEL = 1000; int skillLevel = Users.getProfile(player).getSkillLevel(SkillType.MINING); diff --git a/src/main/java/com/gmail/nossr50/skills/gathering/WoodCutting.java b/src/main/java/com/gmail/nossr50/skills/gathering/WoodCutting.java index 48d6e5329..e25a1680e 100644 --- a/src/main/java/com/gmail/nossr50/skills/gathering/WoodCutting.java +++ b/src/main/java/com/gmail/nossr50/skills/gathering/WoodCutting.java @@ -189,24 +189,24 @@ public class WoodCutting { Block yPositive = currentBlock.getRelative(0, 1, 0); if (!mcMMO.placeStore.isTrue(currentBlock)) { - if (!isTooAggressive(currentBlock, xPositive) && BlockChecks.treeFellerCompatible(xPositive.getType()) && !toBeFelled.contains(xPositive)) { + if (!isTooAggressive(currentBlock, xPositive) && BlockChecks.treeFellerCompatible(xPositive) && !toBeFelled.contains(xPositive)) { processTreeFelling(xPositive, toBeFelled); } - if (!isTooAggressive(currentBlock, xNegative) && BlockChecks.treeFellerCompatible(xNegative.getType()) && !toBeFelled.contains(xNegative)) { + if (!isTooAggressive(currentBlock, xNegative) && BlockChecks.treeFellerCompatible(xNegative) && !toBeFelled.contains(xNegative)) { processTreeFelling(xNegative, toBeFelled); } - if (!isTooAggressive(currentBlock, zPositive) && BlockChecks.treeFellerCompatible(zPositive.getType()) && !toBeFelled.contains(zPositive)) { + if (!isTooAggressive(currentBlock, zPositive) && BlockChecks.treeFellerCompatible(zPositive) && !toBeFelled.contains(zPositive)) { processTreeFelling(zPositive, toBeFelled); } - if (!isTooAggressive(currentBlock, zNegative) && BlockChecks.treeFellerCompatible(zNegative.getType()) && !toBeFelled.contains(zNegative)) { + if (!isTooAggressive(currentBlock, zNegative) && BlockChecks.treeFellerCompatible(zNegative) && !toBeFelled.contains(zNegative)) { processTreeFelling(zNegative, toBeFelled); } } - if (BlockChecks.treeFellerCompatible(yPositive.getType())) { + if (BlockChecks.treeFellerCompatible(yPositive)) { if(!mcMMO.placeStore.isTrue(currentBlock) && !toBeFelled.contains(yPositive)) { processTreeFelling(yPositive, toBeFelled); } diff --git a/src/main/java/com/gmail/nossr50/util/BlockChecks.java b/src/main/java/com/gmail/nossr50/util/BlockChecks.java index 4133591f2..202432060 100644 --- a/src/main/java/com/gmail/nossr50/util/BlockChecks.java +++ b/src/main/java/com/gmail/nossr50/util/BlockChecks.java @@ -1,6 +1,7 @@ package com.gmail.nossr50.util; import org.bukkit.Material; +import org.bukkit.block.Block; import com.gmail.nossr50.config.Config; @@ -9,7 +10,7 @@ public class BlockChecks { /** * Checks to see if a block type awards XP. * - * @param material The type of Block to check + * @param block Block to check * @return true if the block type awards XP, false otherwise */ public static boolean shouldBeWatched(Material material) { @@ -56,11 +57,11 @@ public class BlockChecks { /** * Check if a block should allow for the activation of abilities. * - * @param material The type of Block to check + * @param block Block to check * @return true if the block should allow ability activation, false otherwise */ - public static boolean abilityBlockCheck(Material material) { - switch (material) { + public static boolean abilityBlockCheck(Block block) { + switch (block.getType()) { case BED_BLOCK: case BREWING_STAND: case BOOKSHELF: @@ -81,12 +82,9 @@ public class BlockChecks { case WOODEN_DOOR: case WORKBENCH: return false; - - default: - break; } - if (Material.getMaterial(Config.getInstance().getRepairAnvilId()).equals(material)) { + if (block.getTypeId() == Config.getInstance().getRepairAnvilId()) { return false; } else { @@ -97,11 +95,11 @@ public class BlockChecks { /** * Check if a block type is an ore. * - * @param material The type of Block to check + * @param block Block to check * @return true if the Block is an ore, false otherwise */ - public static boolean isOre(Material material) { - switch (material) { + public static boolean isOre(Block block) { + switch (block.getType()) { case COAL_ORE: case DIAMOND_ORE: case GLOWING_REDSTONE_ORE: @@ -119,15 +117,18 @@ public class BlockChecks { /** * Check if a block can be made mossy. * - * @param material The type of Block to check + * @param block The block to check * @return true if the block can be made mossy, false otherwise */ - public static boolean makeMossy(Material type) { - switch (type) { + public static boolean makeMossy(Block block) { + switch (block.getType()) { case COBBLESTONE: case DIRT: - case SMOOTH_BRICK: return true; + case SMOOTH_BRICK: + if (block.getData() == 0) { + return true; + } default: return false; @@ -137,11 +138,11 @@ public class BlockChecks { /** * Check if a block is affected by Herbalism abilities. * - * @param type The type of Block to check + * @param block Block to check * @return true if the block is affected, false otherwise */ - public static boolean canBeGreenTerra(Material type){ - switch (type) { + public static boolean canBeGreenTerra(Block block){ + switch (block.getType()) { case BROWN_MUSHROOM: case CACTUS: case CROPS: @@ -164,11 +165,11 @@ public class BlockChecks { /** * Check to see if a block is broken by Super Breaker. * - * @param type The type of Block to check + * @param block Block to check * @return true if the block would be broken by Super Breaker, false otherwise */ - public static Boolean canBeSuperBroken(Material type) { - switch (type) { + public static Boolean canBeSuperBroken(Block block) { + switch (block.getType()) { case COAL_ORE: case DIAMOND_ORE: case ENDER_STONE: @@ -193,11 +194,11 @@ public class BlockChecks { /** * Check to see if a block can be broken by Giga Drill Breaker. * - * @param material The type of block to check - * @return + * @param block Block to check + * @return true if the block can be broken by Giga Drill Breaker, false otherwise */ - public static boolean canBeGigaDrillBroken(Material type) { - switch (type) { + public static boolean canBeGigaDrillBroken(Block block) { + switch (block.getType()) { case CLAY: case DIRT: case GRASS: @@ -218,8 +219,8 @@ public class BlockChecks { * @param block Block to check * @return true if the block is affected by Tree Feller, false otherwise */ - public static boolean treeFellerCompatible(Material type) { - switch (type) { + public static boolean treeFellerCompatible(Block block) { + switch (block.getType()) { case LOG: case LEAVES: case AIR: diff --git a/src/main/java/com/gmail/nossr50/util/Skills.java b/src/main/java/com/gmail/nossr50/util/Skills.java index 2591da1dc..64a9846e9 100644 --- a/src/main/java/com/gmail/nossr50/util/Skills.java +++ b/src/main/java/com/gmail/nossr50/util/Skills.java @@ -423,7 +423,7 @@ public class Skills { /* FALLS THROUGH */ case GREEN_TERRA: - if (!ability.blockCheck(block.getType())) { + if (!ability.blockCheck(block)) { activate = false; break; }