mirror of
https://github.com/songoda/UltimateStacker.git
synced 2025-01-13 11:01:42 +01:00
Newly placed spawners will now spawn the correct amounts.
This commit is contained in:
parent
70fbf7a3e5
commit
3801d8ecbd
@ -3,6 +3,7 @@ package com.songoda.ultimatestacker.spawner;
|
||||
import com.songoda.ultimatestacker.UltimateStacker;
|
||||
import com.songoda.ultimatestacker.utils.Reflection;
|
||||
import com.songoda.ultimatestacker.utils.ServerVersion;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.block.CreatureSpawner;
|
||||
|
||||
@ -27,16 +28,18 @@ public class SpawnerStack {
|
||||
public void setAmount(int amount) {
|
||||
this.amount = amount;
|
||||
|
||||
int count = 4 * amount;
|
||||
int maxNearby = amount > 6 ? amount + 3 : 6;
|
||||
CreatureSpawner creatureSpawner = (CreatureSpawner)location.getBlock().getState();
|
||||
if (UltimateStacker.getInstance().isServerVersionAtLeast(ServerVersion.V1_12)) {
|
||||
creatureSpawner.setMaxNearbyEntities(maxNearby);
|
||||
creatureSpawner.setSpawnCount(count);
|
||||
} else {
|
||||
Reflection.updateSpawner(creatureSpawner, count, maxNearby);
|
||||
}
|
||||
creatureSpawner.update();
|
||||
Bukkit.getScheduler().runTaskLater(UltimateStacker.getInstance(), () -> {
|
||||
int count = 4 * amount;
|
||||
int maxNearby = amount > 6 ? amount + 3 : 6;
|
||||
CreatureSpawner creatureSpawner = (CreatureSpawner) location.getBlock().getState();
|
||||
if (UltimateStacker.getInstance().isServerVersionAtLeast(ServerVersion.V1_12)) {
|
||||
creatureSpawner.setMaxNearbyEntities(maxNearby);
|
||||
creatureSpawner.setSpawnCount(count);
|
||||
} else {
|
||||
Reflection.updateSpawner(creatureSpawner, count, maxNearby);
|
||||
}
|
||||
creatureSpawner.update();
|
||||
}, 1L);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Loading…
Reference in New Issue
Block a user