Merge branch 'development'

This commit is contained in:
Brianna 2020-08-05 16:06:23 -05:00
commit 05f6cdeb9e
4 changed files with 19 additions and 6 deletions

View File

@ -2,7 +2,7 @@
<groupId>com.songoda</groupId> <groupId>com.songoda</groupId>
<artifactId>UltimateStacker</artifactId> <artifactId>UltimateStacker</artifactId>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<version>1.11.19</version> <version>1.11.20</version>
<build> <build>
<defaultGoal>clean install</defaultGoal> <defaultGoal>clean install</defaultGoal>
<finalName>UltimateStacker-${project.version}</finalName> <finalName>UltimateStacker-${project.version}</finalName>

View File

@ -42,6 +42,8 @@ public class SpawnerListeners implements Listener {
SpawnerStack spawnerStack = spawnerStackManager.getSpawner(event.getSpawner().getLocation()); SpawnerStack spawnerStack = spawnerStackManager.getSpawner(event.getSpawner().getLocation());
spawnerStack.initialize();
EntityStack stack = plugin.getEntityStackManager().addStack(event.getEntity().getUniqueId(), spawnerStack.calculateSpawnCount()); EntityStack stack = plugin.getEntityStackManager().addStack(event.getEntity().getUniqueId(), spawnerStack.calculateSpawnCount());
plugin.getStackingTask().attemptSplit(stack, (LivingEntity) event.getEntity()); plugin.getStackingTask().attemptSplit(stack, (LivingEntity) event.getEntity());

View File

@ -63,9 +63,9 @@ public class LootablesManager {
}; };
} }
EntityType killer = null; EntityType killer = null;
Entity killerEntity = null;
if (entity.getLastDamageCause() instanceof EntityDamageByEntityEvent) { if (entity.getLastDamageCause() instanceof EntityDamageByEntityEvent) {
Entity killerEntity = ((EntityDamageByEntityEvent) entity.getLastDamageCause()).getDamager(); killerEntity = ((EntityDamageByEntityEvent) entity.getLastDamageCause()).getDamager();
killer = killerEntity.getType();
if (killerEntity instanceof Projectile) { if (killerEntity instanceof Projectile) {
Projectile projectile = (Projectile) killerEntity; Projectile projectile = (Projectile) killerEntity;
if (projectile.getShooter() instanceof Entity) { if (projectile.getShooter() instanceof Entity) {
@ -75,7 +75,7 @@ public class LootablesManager {
} }
return lootManager.runLoot(modify, return lootManager.runLoot(modify,
entity.getFireTicks() > 0, entity.getFireTicks() > 0,
entity instanceof Creeper && ((Creeper) entity).isPowered(), killerEntity instanceof Creeper && ((Creeper) killerEntity).isPowered(),
entity.getKiller() != null ? entity.getKiller().getItemInHand() : null, entity.getKiller() != null ? entity.getKiller().getItemInHand() : null,
killer, killer,
loot, loot,

View File

@ -14,13 +14,14 @@ import java.util.Random;
public class SpawnerStack { public class SpawnerStack {
private int id; private int id;
private boolean initialized = false;
private final Location location; private final Location location;
private int amount = 1; private int amount;
public SpawnerStack(Location location, int amount) { public SpawnerStack(Location location, int amount) {
this.location = location; this.location = location;
setAmount(amount); this.amount = amount;
} }
public int getAmount() { public int getAmount() {
@ -31,7 +32,10 @@ public class SpawnerStack {
UltimateStacker plugin = UltimateStacker.getInstance(); UltimateStacker plugin = UltimateStacker.getInstance();
this.amount = amount; this.amount = amount;
plugin.getDataManager().updateSpawner(this); plugin.getDataManager().updateSpawner(this);
}
public void updateAmount() {
UltimateStacker plugin = UltimateStacker.getInstance();
Bukkit.getScheduler().runTaskLater(plugin, () -> { Bukkit.getScheduler().runTaskLater(plugin, () -> {
if (!(location.getBlock().getState() instanceof CreatureSpawner)) return; if (!(location.getBlock().getState() instanceof CreatureSpawner)) return;
int count = Settings.STACK_ENTITIES.getBoolean() int count = Settings.STACK_ENTITIES.getBoolean()
@ -85,6 +89,13 @@ public class SpawnerStack {
return location.getWorld(); return location.getWorld();
} }
public void initialize() {
if (!initialized) {
updateAmount();
this.initialized = true;
}
}
@Override @Override
public String toString() { public String toString() {
return "SpawnerStack:{" return "SpawnerStack:{"