Apply spawner data on spawn.
This commit is contained in:
parent
631ec84fb7
commit
ae1c0a9078
|
@ -42,6 +42,8 @@ public class SpawnerListeners implements Listener {
|
|||
|
||||
SpawnerStack spawnerStack = spawnerStackManager.getSpawner(event.getSpawner().getLocation());
|
||||
|
||||
spawnerStack.initialize();
|
||||
|
||||
EntityStack stack = plugin.getEntityStackManager().addStack(event.getEntity().getUniqueId(), spawnerStack.calculateSpawnCount());
|
||||
|
||||
plugin.getStackingTask().attemptSplit(stack, (LivingEntity) event.getEntity());
|
||||
|
|
|
@ -14,13 +14,14 @@ import java.util.Random;
|
|||
public class SpawnerStack {
|
||||
|
||||
private int id;
|
||||
private boolean initialized = false;
|
||||
|
||||
private final Location location;
|
||||
private int amount = 1;
|
||||
private int amount;
|
||||
|
||||
public SpawnerStack(Location location, int amount) {
|
||||
this.location = location;
|
||||
setAmount(amount);
|
||||
this.amount = amount;
|
||||
}
|
||||
|
||||
public int getAmount() {
|
||||
|
@ -31,7 +32,10 @@ public class SpawnerStack {
|
|||
UltimateStacker plugin = UltimateStacker.getInstance();
|
||||
this.amount = amount;
|
||||
plugin.getDataManager().updateSpawner(this);
|
||||
}
|
||||
|
||||
public void updateAmount() {
|
||||
UltimateStacker plugin = UltimateStacker.getInstance();
|
||||
Bukkit.getScheduler().runTaskLater(plugin, () -> {
|
||||
if (!(location.getBlock().getState() instanceof CreatureSpawner)) return;
|
||||
int count = Settings.STACK_ENTITIES.getBoolean()
|
||||
|
@ -85,6 +89,13 @@ public class SpawnerStack {
|
|||
return location.getWorld();
|
||||
}
|
||||
|
||||
public void initialize() {
|
||||
if (!initialized) {
|
||||
updateAmount();
|
||||
this.initialized = true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "SpawnerStack:{"
|
||||
|
|
Loading…
Reference in New Issue