From 7f919b92072aa73badc7c0c0c34dd8c560cdfab7 Mon Sep 17 00:00:00 2001 From: Will Coates Date: Thu, 7 Aug 2014 18:35:08 +0100 Subject: [PATCH] Added block metadata for storing 'unnatural' blocks. --- src/main/java/com/gmail/nossr50/listeners/BlockListener.java | 3 +++ .../com/gmail/nossr50/skills/excavation/ExcavationManager.java | 3 +++ .../java/com/gmail/nossr50/skills/mining/MiningManager.java | 3 +++ .../gmail/nossr50/skills/woodcutting/WoodcuttingManager.java | 3 +++ 4 files changed, 12 insertions(+) diff --git a/src/main/java/com/gmail/nossr50/listeners/BlockListener.java b/src/main/java/com/gmail/nossr50/listeners/BlockListener.java index 6380402a3..449dcdc3d 100644 --- a/src/main/java/com/gmail/nossr50/listeners/BlockListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/BlockListener.java @@ -21,6 +21,7 @@ import org.bukkit.event.block.BlockPistonExtendEvent; import org.bukkit.event.block.BlockPistonRetractEvent; import org.bukkit.event.block.BlockPlaceEvent; import org.bukkit.inventory.ItemStack; +import org.bukkit.metadata.FixedMetadataValue; import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.config.Config; @@ -126,7 +127,9 @@ public class BlockListener implements Listener { /* Check if the blocks placed should be monitored so they do not give out XP in the future */ if (BlockUtils.shouldBeWatched(blockState)) { mcMMO.getPlaceStore().setTrue(blockState); + blockState.setMetadata("unnatural", new FixedMetadataValue(plugin, true)); } + McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player); diff --git a/src/main/java/com/gmail/nossr50/skills/excavation/ExcavationManager.java b/src/main/java/com/gmail/nossr50/skills/excavation/ExcavationManager.java index ab4a4df3f..0c763a343 100644 --- a/src/main/java/com/gmail/nossr50/skills/excavation/ExcavationManager.java +++ b/src/main/java/com/gmail/nossr50/skills/excavation/ExcavationManager.java @@ -27,6 +27,9 @@ public class ExcavationManager extends SkillManager { * @param blockState The {@link BlockState} to check ability activation for */ public void excavationBlockCheck(BlockState blockState) { + if (blockState.getMetadata("unnatural").size() != 0) + return; + int xp = Excavation.getBlockXP(blockState); if (Permissions.secondaryAbilityEnabled(getPlayer(), SecondaryAbility.EXCAVATION_TREASURE_HUNTER)) { diff --git a/src/main/java/com/gmail/nossr50/skills/mining/MiningManager.java b/src/main/java/com/gmail/nossr50/skills/mining/MiningManager.java index 63d324218..ae736ad0c 100644 --- a/src/main/java/com/gmail/nossr50/skills/mining/MiningManager.java +++ b/src/main/java/com/gmail/nossr50/skills/mining/MiningManager.java @@ -56,6 +56,9 @@ public class MiningManager extends SkillManager { * @param blockState The {@link BlockState} to check ability activation for */ public void miningBlockCheck(BlockState blockState) { + if (blockState.getMetadata("unnatural").size() != 0) + return; + Player player = getPlayer(); applyXpGain(Mining.getBlockXp(blockState), XPGainReason.PVE); diff --git a/src/main/java/com/gmail/nossr50/skills/woodcutting/WoodcuttingManager.java b/src/main/java/com/gmail/nossr50/skills/woodcutting/WoodcuttingManager.java index 23c95c8a7..3d41a9c86 100644 --- a/src/main/java/com/gmail/nossr50/skills/woodcutting/WoodcuttingManager.java +++ b/src/main/java/com/gmail/nossr50/skills/woodcutting/WoodcuttingManager.java @@ -51,6 +51,9 @@ public class WoodcuttingManager extends SkillManager { * @param blockState Block being broken */ public void woodcuttingBlockCheck(BlockState blockState) { + if (blockState.getMetadata("unnatural").size() != 0) + return; + int xp = Woodcutting.getExperienceFromLog(blockState, ExperienceGainMethod.DEFAULT); switch (blockState.getType()) {