More PlayerEvent fixes.

This commit is contained in:
MattBDev 2019-12-15 12:53:16 -05:00
parent ed8fa0a2a5
commit 478c761750

View File

@ -1924,23 +1924,15 @@ import java.util.regex.Pattern;
//todo rearrange the right click code. it is all over the place.
case RIGHT_CLICK_BLOCK: {
Material blockType = block.getType();
eventType = PlayerBlockEventType.INTERACT_BLOCK;
if (blockType.isInteractable() && player.isSneaking()) {
return; //this returns so the block place event is called
}
if (blockType.isInteractable()) {
eventType = PlayerBlockEventType.INTERACT_BLOCK;
}
blocktype1 = BukkitAdapter.asBlockType(block.getType());
if (eventType != null && !player.isSneaking()) {
if (!player.isSneaking()) {
break;
}
Material type = event.getMaterial();
if (type == Material.AIR) {
if (!player.isSneaking() && blockType.isInteractable()) {
eventType = PlayerBlockEventType.INTERACT_BLOCK;
break outer;
}
}
// in the following, lb needs to have the material of the item in hand i.e. type
if (type == Material.REDSTONE || type == Material.STRING
@ -2018,18 +2010,6 @@ import java.util.regex.Pattern;
return;
}
}
if (eventType == null) {
PlotSquared.log("Please report this to PlotSquared Developers: ");
PlotSquared.log("Action: " + event.getAction().toString());
PlotSquared.log("HasItem: " + event.hasItem());
PlotSquared.log("HasBlock: " + event.hasBlock());
PlotSquared.log("getItem: " + (event.hasItem() ? Objects.requireNonNull(event.getItem())
.toString() : "null"));
PlotSquared.log("getBlockFace: " + (event.getBlockFace() != null ? event.getBlockFace().toString() : "null"));
PlotSquared.log("isBlockInHand: " + (event.isBlockInHand()));
PlotSquared.log("getClickedBlock: " + (event.getClickedBlock() != null ? event.getClickedBlock().toString() : "null"));
return;
}
if (!EventUtil.manager.checkPlayerBlockEvent(pp, eventType, location, blocktype1, true)) {
event.setCancelled(true);
event.setUseInteractedBlock(Event.Result.DENY);