|
3 | 3 | import github.nighter.smartspawner.SmartSpawner; |
4 | 4 | import github.nighter.smartspawner.api.events.SpawnerPlaceEvent; |
5 | 5 | import github.nighter.smartspawner.extras.HopperHandler; |
| 6 | +import github.nighter.smartspawner.hooks.protections.CheckStackBlock; |
6 | 7 | import github.nighter.smartspawner.language.MessageService; |
7 | 8 | import github.nighter.smartspawner.nms.ParticleWrapper; |
8 | 9 | import github.nighter.smartspawner.spawner.limits.ChunkSpawnerLimiter; |
@@ -78,12 +79,15 @@ public void onBlockPlace(BlockPlaceEvent event) { |
78 | 79 | return; |
79 | 80 | } |
80 | 81 |
|
81 | | - if (!(meta instanceof BlockStateMeta)) { |
| 82 | + if (!(meta instanceof BlockStateMeta blockMeta)) { |
82 | 83 | event.setCancelled(true); |
83 | 84 | return; |
84 | 85 | } |
85 | 86 |
|
86 | | - BlockStateMeta blockMeta = (BlockStateMeta) meta; |
| 87 | + if (!CheckStackBlock.CanPlayerPlaceBlock(player, block.getLocation())) { |
| 88 | + event.setCancelled(true); |
| 89 | + return; |
| 90 | + } |
87 | 91 |
|
88 | 92 | boolean isVanillaSpawner = SpawnerTypeChecker.isVanillaSpawner(item); |
89 | 93 |
|
@@ -269,8 +273,7 @@ private void createSmartSpawner(Block block, Player player, EntityType entityTyp |
269 | 273 | String spawnerId = UUID.randomUUID().toString().substring(0, 8); |
270 | 274 |
|
271 | 275 | BlockState state = block.getState(); |
272 | | - if (state instanceof CreatureSpawner) { |
273 | | - CreatureSpawner spawner = (CreatureSpawner) state; |
| 276 | + if (state instanceof CreatureSpawner spawner) { |
274 | 277 | spawner.setSpawnedType(entityType); |
275 | 278 | spawner.update(true, false); |
276 | 279 | } |
|
0 commit comments