Skip to content

Commit

Permalink
Work around odd class casting with odder class casting.
Browse files Browse the repository at this point in the history
Despite the API guaranteeing a block for chests, they are not actually BlockStates.
Fixes WORLDGUARD-3607. Probably.
  • Loading branch information
wizjany committed Feb 20, 2016
1 parent ca4bb7a commit 93d454c
Showing 1 changed file with 8 additions and 3 deletions.
Expand Up @@ -44,7 +44,12 @@
import com.sk89q.worldguard.bukkit.util.Materials;
import com.sk89q.worldguard.protection.flags.DefaultFlag;
import org.bukkit.*;
import org.bukkit.block.*;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.block.BlockState;
import org.bukkit.block.Chest;
import org.bukkit.block.DoubleChest;
import org.bukkit.block.Hopper;
import org.bukkit.entity.*;
import org.bukkit.event.Cancellable;
import org.bukkit.event.Event;
Expand Down Expand Up @@ -907,8 +912,8 @@ private static <T extends Event & Cancellable> void handleInventoryHolderUse(T o
} else if (holder instanceof BlockState) {
Events.fireToCancel(originalEvent, new UseBlockEvent(originalEvent, cause, ((BlockState) holder).getBlock()));
} else if (holder instanceof DoubleChest) {
Events.fireToCancel(originalEvent, new UseBlockEvent(originalEvent, cause, ((BlockState) ((DoubleChest) holder).getLeftSide()).getBlock()));
Events.fireToCancel(originalEvent, new UseBlockEvent(originalEvent, cause, ((BlockState) ((DoubleChest) holder).getRightSide()).getBlock()));
Events.fireToCancel(originalEvent, new UseBlockEvent(originalEvent, cause, (((Chest) ((DoubleChest) holder).getLeftSide()).getBlock())));
Events.fireToCancel(originalEvent, new UseBlockEvent(originalEvent, cause, (((Chest) ((DoubleChest) holder).getRightSide()).getBlock())));
}
}

Expand Down

0 comments on commit 93d454c

Please sign in to comment.