mirror of
https://github.com/songoda/UltimateStacker.git
synced 2024-06-26 06:35:15 +02: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.UltimateStacker;
|
||||||
import com.songoda.ultimatestacker.utils.Reflection;
|
import com.songoda.ultimatestacker.utils.Reflection;
|
||||||
import com.songoda.ultimatestacker.utils.ServerVersion;
|
import com.songoda.ultimatestacker.utils.ServerVersion;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.block.CreatureSpawner;
|
import org.bukkit.block.CreatureSpawner;
|
||||||
|
|
||||||
|
@ -27,16 +28,18 @@ public class SpawnerStack {
|
||||||
public void setAmount(int amount) {
|
public void setAmount(int amount) {
|
||||||
this.amount = amount;
|
this.amount = amount;
|
||||||
|
|
||||||
int count = 4 * amount;
|
Bukkit.getScheduler().runTaskLater(UltimateStacker.getInstance(), () -> {
|
||||||
int maxNearby = amount > 6 ? amount + 3 : 6;
|
int count = 4 * amount;
|
||||||
CreatureSpawner creatureSpawner = (CreatureSpawner)location.getBlock().getState();
|
int maxNearby = amount > 6 ? amount + 3 : 6;
|
||||||
if (UltimateStacker.getInstance().isServerVersionAtLeast(ServerVersion.V1_12)) {
|
CreatureSpawner creatureSpawner = (CreatureSpawner) location.getBlock().getState();
|
||||||
creatureSpawner.setMaxNearbyEntities(maxNearby);
|
if (UltimateStacker.getInstance().isServerVersionAtLeast(ServerVersion.V1_12)) {
|
||||||
creatureSpawner.setSpawnCount(count);
|
creatureSpawner.setMaxNearbyEntities(maxNearby);
|
||||||
} else {
|
creatureSpawner.setSpawnCount(count);
|
||||||
Reflection.updateSpawner(creatureSpawner, count, maxNearby);
|
} else {
|
||||||
}
|
Reflection.updateSpawner(creatureSpawner, count, maxNearby);
|
||||||
creatureSpawner.update();
|
}
|
||||||
|
creatureSpawner.update();
|
||||||
|
}, 1L);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in New Issue
Block a user