Want a better Minecraft server? Read about SpigotMC here!
Separate names with a comma.
Discussion in 'Spigot Plugin Development' started by SledgeR6, Jan 13, 2019.
How can I disable block breakage?
Thank you all.
You can listen to BlockBreakEvent and check if the broken Material is Bedrock, and cancel the event if that's the case.
you can use protocollib lib with blockdiggingevent, you can check my plugin called SoHard which is using protocollib
How do you expect bedrock to be broken? It probably depends on that.
I do not want the bedrock broken.
I'm rephrasing what @Escad said: How can bedrock be broken? There are different ways to prevent this, but they depend on what is breaking the bedrock thus you need to know what could break bedrock in order to prevent it from happening.
If it is done by players, you can use my solution. Otherwise you will have to find an appropriate solution yourself or describe what will destroy bedrock: Some explosion, mobs, Chuck Norris,... and we will try to help you.
Unless it's Chuck Norris. Then he's out of luck
Do you want the same behaviour like interacting in survival with bedrock? Like Gamemode Adventure where you cannot break any block?
Oh, OP's question clicks now.
You'd probably use the BlockBreakEvent and cancel it, like vallas suggested at first. If you don't even want it to get to that point, you might be able to cancel the PlayerInteractEvent if the action is Action.LEFT_CLICK_BLOCK. You should ignore the event if it's cancelled via the EventHandler annotation, though. There's also no guarantee that other plugins won't interfere with the cancelled event.
edit:// you could also just put your players in adventure mode if you don't want them breaking or interacting with anything at all.
Then this is probably your solution:
I'm not being lazy!!
no its not a good solution because
afted click to air and dont release, when you change your directiom where is looking a block th event does not fire, so my plugin has this bug
Would actually instead recommend BlockDamageEvent. To my knowledge, this is called when a player first damages the block. It may have subsequent calls for every crack in the block, though I may be wrong. Never used it, personally.
Thank you for correcting me. I'd have to do some testing then but I see @2008Choco has given a solution already. Good to know if I ever need this.