mirror of
https://github.com/DRE2N/DungeonsXL.git
synced 2024-11-24 19:45:43 +01:00
Merge pull request #150 from wysohn/0.15
sign need to be handled when it's broken indirect way
This commit is contained in:
commit
c99f5f89cd
@ -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();
|
||||
|
Loading…
Reference in New Issue
Block a user