Fixed metadata storage. XP and double drop chance works on natural blocks.

This commit is contained in:
Will Coates 2014-08-07 21:41:41 +01:00
parent 7f919b9207
commit 41a276e7d9
4 changed files with 20 additions and 7 deletions

View File

@ -127,7 +127,7 @@ public class BlockListener implements Listener {
/* Check if the blocks placed should be monitored so they do not give out XP in the future */ /* Check if the blocks placed should be monitored so they do not give out XP in the future */
if (BlockUtils.shouldBeWatched(blockState)) { if (BlockUtils.shouldBeWatched(blockState)) {
mcMMO.getPlaceStore().setTrue(blockState); mcMMO.getPlaceStore().setTrue(blockState);
blockState.setMetadata("unnatural", new FixedMetadataValue(plugin, true)); blockState.setMetadata("mmo_bin", new FixedMetadataValue(plugin, true));
} }

View File

@ -4,7 +4,9 @@ import java.util.List;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.block.BlockState; import org.bukkit.block.BlockState;
import org.bukkit.metadata.MetadataValue;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.Config; import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.skills.SecondaryAbility; import com.gmail.nossr50.datatypes.skills.SecondaryAbility;
@ -27,8 +29,11 @@ public class ExcavationManager extends SkillManager {
* @param blockState The {@link BlockState} to check ability activation for * @param blockState The {@link BlockState} to check ability activation for
*/ */
public void excavationBlockCheck(BlockState blockState) { public void excavationBlockCheck(BlockState blockState) {
if (blockState.getMetadata("unnatural").size() != 0) for (MetadataValue value : blockState.getMetadata("unnatural"))
return; {
if (value.getOwningPlugin().equals(mcMMO.p) && value.asBoolean()==true)
return;
}
int xp = Excavation.getBlockXP(blockState); int xp = Excavation.getBlockXP(blockState);

View File

@ -9,6 +9,7 @@ import org.bukkit.block.BlockState;
import org.bukkit.enchantments.Enchantment; import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.entity.TNTPrimed; import org.bukkit.entity.TNTPrimed;
import org.bukkit.metadata.MetadataValue;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.Config; import com.gmail.nossr50.config.Config;
@ -56,8 +57,11 @@ public class MiningManager extends SkillManager {
* @param blockState The {@link BlockState} to check ability activation for * @param blockState The {@link BlockState} to check ability activation for
*/ */
public void miningBlockCheck(BlockState blockState) { public void miningBlockCheck(BlockState blockState) {
if (blockState.getMetadata("unnatural").size() != 0) for (MetadataValue value : blockState.getMetadata("mmo_bin"))
return; {
if (value.getOwningPlugin().equals(mcMMO.p) && value.asBoolean()==true)
return;
}
Player player = getPlayer(); Player player = getPlayer();

View File

@ -10,6 +10,7 @@ import org.bukkit.block.BlockState;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.material.Tree; import org.bukkit.material.Tree;
import org.bukkit.metadata.MetadataValue;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.datatypes.mods.CustomBlock; import com.gmail.nossr50.datatypes.mods.CustomBlock;
@ -51,8 +52,11 @@ public class WoodcuttingManager extends SkillManager {
* @param blockState Block being broken * @param blockState Block being broken
*/ */
public void woodcuttingBlockCheck(BlockState blockState) { public void woodcuttingBlockCheck(BlockState blockState) {
if (blockState.getMetadata("unnatural").size() != 0) for (MetadataValue value : blockState.getMetadata("unnatural"))
return; {
if (value.getOwningPlugin().equals(mcMMO.p) && value.asBoolean()==true)
return;
}
int xp = Woodcutting.getExperienceFromLog(blockState, ExperienceGainMethod.DEFAULT); int xp = Woodcutting.getExperienceFromLog(blockState, ExperienceGainMethod.DEFAULT);