Fix ClassCastException with trying to use Woodcutting on Mushrooms.

This commit is contained in:
GJ 2013-02-23 15:03:39 -05:00
parent 8d16c06739
commit 301914d94b
2 changed files with 22 additions and 24 deletions

View File

@ -177,22 +177,14 @@ public final class TreeFeller {
Material material = blockState.getType(); Material material = blockState.getType();
switch (material) { if (material == Material.HUGE_MUSHROOM_1 || material == Material.HUGE_MUSHROOM_2) {
case HUGE_MUSHROOM_1:
case HUGE_MUSHROOM_2:
xp += Woodcutting.getExperienceFromLog(blockState, ExperienceGainMethod.TREE_FELLER); xp += Woodcutting.getExperienceFromLog(blockState, ExperienceGainMethod.TREE_FELLER);
for (ItemStack drop : blockState.getBlock().getDrops()) { for (ItemStack drop : blockState.getBlock().getDrops()) {
Misc.dropItem(blockState.getLocation(), drop); Misc.dropItem(blockState.getLocation(), drop);
} }
break;
default:
break;
} }
else if (ModChecks.isCustomLogBlock(blockState)) {
if (ModChecks.isCustomLogBlock(blockState)) {
Woodcutting.checkForDoubleDrop(player, blockState); Woodcutting.checkForDoubleDrop(player, blockState);
CustomBlock customBlock = ModChecks.getCustomBlock(blockState); CustomBlock customBlock = ModChecks.getCustomBlock(blockState);
@ -211,7 +203,7 @@ public final class TreeFeller {
else if (ModChecks.isCustomLeafBlock(blockState)) { else if (ModChecks.isCustomLeafBlock(blockState)) {
Misc.randomDropItem(blockState.getLocation(), ModChecks.getCustomBlock(blockState).getItemDrop(), 10); Misc.randomDropItem(blockState.getLocation(), ModChecks.getCustomBlock(blockState).getItemDrop(), 10);
} }
else {
Tree tree = (Tree) blockState.getData(); Tree tree = (Tree) blockState.getData();
switch (material) { switch (material) {
case LOG: case LOG:
@ -227,6 +219,7 @@ public final class TreeFeller {
default: default:
break; break;
} }
}
blockState.setRawData((byte) 0x0); blockState.setRawData((byte) 0x0);
blockState.setType(Material.AIR); blockState.setType(Material.AIR);

View File

@ -1,6 +1,7 @@
package com.gmail.nossr50.skills.woodcutting; package com.gmail.nossr50.skills.woodcutting;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Sound; import org.bukkit.Sound;
import org.bukkit.block.BlockState; import org.bukkit.block.BlockState;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -61,8 +62,12 @@ public final class Woodcutting {
int xp = getExperienceFromLog(blockState, ExperienceGainMethod.DEFAULT); int xp = getExperienceFromLog(blockState, ExperienceGainMethod.DEFAULT);
if (Permissions.doubleDrops(player, SkillType.WOODCUTTING)) { if (Permissions.doubleDrops(player, SkillType.WOODCUTTING)) {
Material blockType = blockState.getType();
if (blockType != Material.HUGE_MUSHROOM_1 && blockType != Material.HUGE_MUSHROOM_2) {
checkForDoubleDrop(player, blockState); checkForDoubleDrop(player, blockState);
} }
}
Users.getPlayer(player).beginXpGain(SkillType.WOODCUTTING, xp); Users.getPlayer(player).beginXpGain(SkillType.WOODCUTTING, xp);
} }