mirror of
https://github.com/Minestom/Minestom.git
synced 2024-12-27 11:38:03 +01:00
Prevent placing block in adventure mode
This commit is contained in:
parent
8b515e8686
commit
3e532b24a8
@ -60,10 +60,17 @@ public class BlockPlacementListener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if item at hand is a block
|
final Material useMaterial = usedItem.getMaterial();
|
||||||
final Material material = usedItem.getMaterial();
|
|
||||||
if (material == Material.AIR) {
|
// Verify if the player can place the block
|
||||||
return;
|
{
|
||||||
|
if (useMaterial == Material.AIR) { // Can't place air
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (player.getGameMode().equals(GameMode.ADVENTURE)) { // Can't place in adventure mode
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the newly placed block position
|
// Get the newly placed block position
|
||||||
@ -79,9 +86,9 @@ public class BlockPlacementListener {
|
|||||||
// This will ensure that the player has the correct version of the chunk
|
// This will ensure that the player has the correct version of the chunk
|
||||||
boolean refreshChunk = false;
|
boolean refreshChunk = false;
|
||||||
|
|
||||||
if (material.isBlock()) {
|
if (useMaterial.isBlock()) {
|
||||||
if (!chunk.isReadOnly()) {
|
if (!chunk.isReadOnly()) {
|
||||||
final Block block = material.getBlock();
|
final Block block = useMaterial.getBlock();
|
||||||
final Set<Entity> entities = instance.getChunkEntities(chunk);
|
final Set<Entity> entities = instance.getChunkEntities(chunk);
|
||||||
// Check if the player is trying to place a block in an entity
|
// Check if the player is trying to place a block in an entity
|
||||||
boolean intersect = false;
|
boolean intersect = false;
|
||||||
|
Loading…
Reference in New Issue
Block a user