sign need to be handled when it's broken indirect way

This commit is contained in:
wysohn 2016-09-02 16:47:40 -07:00
parent 258e115a38
commit 872fa928d1

View File

@ -35,6 +35,7 @@ import io.github.dre2n.dungeonsxl.world.DGameWorld;
import io.github.dre2n.dungeonsxl.world.DInstanceWorld;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.block.Sign;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
@ -50,7 +51,7 @@ import org.bukkit.event.block.BlockSpreadEvent;
import org.bukkit.event.block.SignChangeEvent;
/**
* @author Frank Baumann, Milan Albrecht, Daniel Saukel
* @author Frank Baumann, Milan Albrecht, Daniel Saukel, Wooyoung Son
*/
public class BlockListener implements Listener {
@ -64,6 +65,28 @@ public class BlockListener implements Listener {
}
}
@EventHandler
public void onBreakWithSignOnIt(BlockBreakEvent event){
Block block = event.getBlock();
Player player = event.getPlayer();
Block blockAbove = block.getRelative(BlockFace.UP);
//get the above block and return if there is nothing
if(blockAbove == null)
return;
//return if above block is not a sign
if(blockAbove.getType() != Material.SIGN_POST && blockAbove.getType() != Material.WALL_SIGN)
return;
//let onBreak() method to handle the sign
BlockBreakEvent bbe = new BlockBreakEvent(blockAbove, player);
onBreak(bbe);
//follow the onBreak()
event.setCancelled(bbe.isCancelled());
}
@EventHandler(priority = EventPriority.HIGH)
public void onBreak(BlockBreakEvent event) {
Block block = event.getBlock();