3
0
Mirror von https://github.com/Moulberry/AxiomPaperPlugin.git synchronisiert 2024-11-17 13:50:05 +01:00

Don't fire block place event for non-replaceable blocks

Dieser Commit ist enthalten in:
Moulberry 2024-11-17 00:18:55 +08:00
Ursprung d2fea3fb4e
Commit 1a46f07e11

Datei anzeigen

@ -136,23 +136,28 @@ public class SetBlockPacketListener implements PacketHandler {
List<org.bukkit.block.BlockState> blockStates = new ArrayList<>();
World world = player.serverLevel().getWorld();
for (Map.Entry<BlockPos, BlockState> entry : blocks.entrySet()) {
BlockState existing = player.serverLevel().getBlockState(entry.getKey());
if (existing.canBeReplaced()) {
blockStates.add(new AxiomPlacingCraftBlockState(world, entry.getKey(), entry.getValue()));
}
}
Cancellable event = null;
if (!blockStates.isEmpty()) {
Cancellable event;
if (blockStates.size() > 1) {
event = CraftEventFactory.callBlockMultiPlaceEvent(player.serverLevel(),
player, hand, blockStates, blockHit.getBlockPos().getX(),
blockHit.getBlockPos().getY(), blockHit.getBlockPos().getZ());
} else if (blockStates.size() == 1) {
} else {
event = CraftEventFactory.callBlockPlaceEvent(player.serverLevel(),
player, hand, blockStates.get(0), blockHit.getBlockPos().getX(),
blockHit.getBlockPos().getY(), blockHit.getBlockPos().getZ());
}
if (event != null && event.isCancelled()) {
if (event.isCancelled()) {
return;
}
}
}
CraftWorld world = player.level().getWorld();