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:
Ursprung
9a86585f3e
Commit
6f1bf72ba8
@ -137,21 +137,26 @@ public class SetBlockPacketListener implements PacketHandler {
|
|||||||
List<org.bukkit.block.BlockState> blockStates = new ArrayList<>();
|
List<org.bukkit.block.BlockState> blockStates = new ArrayList<>();
|
||||||
World world = player.serverLevel().getWorld();
|
World world = player.serverLevel().getWorld();
|
||||||
for (Map.Entry<BlockPos, BlockState> entry : blocks.entrySet()) {
|
for (Map.Entry<BlockPos, BlockState> entry : blocks.entrySet()) {
|
||||||
blockStates.add(new AxiomPlacingCraftBlockState(world, entry.getKey(), entry.getValue()));
|
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()) {
|
||||||
if (blockStates.size() > 1) {
|
Cancellable event;
|
||||||
event = CraftEventFactory.callBlockMultiPlaceEvent(player.serverLevel(),
|
if (blockStates.size() > 1) {
|
||||||
player, hand, blockStates, blockHit.getBlockPos().getX(),
|
event = CraftEventFactory.callBlockMultiPlaceEvent(player.serverLevel(),
|
||||||
blockHit.getBlockPos().getY(), blockHit.getBlockPos().getZ());
|
player, hand, blockStates, blockHit.getBlockPos().getX(),
|
||||||
} else if (blockStates.size() == 1) {
|
blockHit.getBlockPos().getY(), blockHit.getBlockPos().getZ());
|
||||||
event = CraftEventFactory.callBlockPlaceEvent(player.serverLevel(),
|
} else {
|
||||||
player, hand, blockStates.get(0), blockHit.getBlockPos().getX(),
|
event = CraftEventFactory.callBlockPlaceEvent(player.serverLevel(),
|
||||||
blockHit.getBlockPos().getY(), blockHit.getBlockPos().getZ());
|
player, hand, blockStates.get(0), blockHit.getBlockPos().getX(),
|
||||||
}
|
blockHit.getBlockPos().getY(), blockHit.getBlockPos().getZ());
|
||||||
if (event != null && event.isCancelled()) {
|
}
|
||||||
return;
|
if (event.isCancelled()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren