Merge branch 'development'

This commit is contained in:
Brianna 2020-08-31 11:10:02 -05:00
commit a5fb739e96
5 changed files with 15 additions and 11 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>2.0.2</version> <version>2.0.3</version>
<build> <build>
<defaultGoal>clean install</defaultGoal> <defaultGoal>clean install</defaultGoal>
<finalName>UltimateStacker-${project.version}</finalName> <finalName>UltimateStacker-${project.version}</finalName>

View File

@ -119,9 +119,9 @@ public class DataManager extends DataManagerAbstract {
public void createStackedEntity(EntityStack hostStack, StackedEntity stackedEntity) { public void createStackedEntity(EntityStack hostStack, StackedEntity stackedEntity) {
this.queueAsync(() -> this.databaseConnector.connect(connection -> { this.queueAsync(() -> this.databaseConnector.connect(connection -> {
if (hostStack.getHostUniqueId() == null) return;
String createSerializedEntity = "INSERT INTO " + this.getTablePrefix() + "stacked_entities (uuid, host, serialized_entity) VALUES (?, ?, ?)"; String createSerializedEntity = "INSERT INTO " + this.getTablePrefix() + "stacked_entities (uuid, host, serialized_entity) VALUES (?, ?, ?)";
try (PreparedStatement statement = connection.prepareStatement(createSerializedEntity)) { try (PreparedStatement statement = connection.prepareStatement(createSerializedEntity)) {
if (hostStack.getHostUniqueId() == null) return;
statement.setString(1, stackedEntity.getUniqueId().toString()); statement.setString(1, stackedEntity.getUniqueId().toString());
statement.setInt(2, hostStack.getId()); statement.setInt(2, hostStack.getId());
statement.setBytes(3, stackedEntity.getSerializedEntity()); statement.setBytes(3, stackedEntity.getSerializedEntity());
@ -132,10 +132,10 @@ public class DataManager extends DataManagerAbstract {
public void createStackedEntities(ColdEntityStack hostStack, List<StackedEntity> stackedEntities) { public void createStackedEntities(ColdEntityStack hostStack, List<StackedEntity> stackedEntities) {
this.queueAsync(() -> this.databaseConnector.connect(connection -> { this.queueAsync(() -> this.databaseConnector.connect(connection -> {
if (hostStack.getHostUniqueId() == null) return;
String createSerializedEntity = "INSERT INTO " + this.getTablePrefix() + "stacked_entities (uuid, host, serialized_entity) VALUES (?, ?, ?)" + String createSerializedEntity = "INSERT INTO " + this.getTablePrefix() + "stacked_entities (uuid, host, serialized_entity) VALUES (?, ?, ?)" +
"ON CONFLICT(uuid) DO UPDATE SET host = ?, serialized_entity = ?"; "ON CONFLICT(uuid) DO UPDATE SET host = ?, serialized_entity = ?";
try (PreparedStatement statement = connection.prepareStatement(createSerializedEntity)) { try (PreparedStatement statement = connection.prepareStatement(createSerializedEntity)) {
if (hostStack.getHostUniqueId() == null) return;
for (StackedEntity entity : stackedEntities) { for (StackedEntity entity : stackedEntities) {
statement.setString(1, entity.getUniqueId().toString()); statement.setString(1, entity.getUniqueId().toString());
statement.setInt(2, hostStack.getId()); statement.setInt(2, hostStack.getId());
@ -151,9 +151,9 @@ public class DataManager extends DataManagerAbstract {
public void updateHost(ColdEntityStack hostStack) { public void updateHost(ColdEntityStack hostStack) {
this.async(() -> this.databaseConnector.connect(connection -> { this.async(() -> this.databaseConnector.connect(connection -> {
if (hostStack.getHostUniqueId() == null) return;
String updateHost = "UPDATE " + this.getTablePrefix() + "host_entities SET uuid = ?, create_duplicates = ? WHERE id = ?"; String updateHost = "UPDATE " + this.getTablePrefix() + "host_entities SET uuid = ?, create_duplicates = ? WHERE id = ?";
try (PreparedStatement statement = connection.prepareStatement(updateHost)) { try (PreparedStatement statement = connection.prepareStatement(updateHost)) {
if (hostStack.getHostUniqueId() == null) return;
statement.setString(1, hostStack.getHostUniqueId().toString()); statement.setString(1, hostStack.getHostUniqueId().toString());
statement.setInt(2, hostStack.getCreateDuplicates()); statement.setInt(2, hostStack.getCreateDuplicates());
statement.setInt(3, hostStack.getId()); statement.setInt(3, hostStack.getId());

View File

@ -66,10 +66,12 @@ public class LootablesManager {
Entity killerEntity = null; Entity killerEntity = null;
if (entity.getLastDamageCause() instanceof EntityDamageByEntityEvent) { if (entity.getLastDamageCause() instanceof EntityDamageByEntityEvent) {
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) {
killer = ((Entity) projectile.getShooter()).getType(); killerEntity = ((Entity) projectile.getShooter());
killer = killerEntity.getType();
} }
} }
} }

View File

@ -17,7 +17,6 @@ import org.bukkit.util.Vector;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.UUID;
import java.util.concurrent.ThreadLocalRandom; import java.util.concurrent.ThreadLocalRandom;
public class EntityStack extends ColdEntityStack { public class EntityStack extends ColdEntityStack {
@ -83,7 +82,6 @@ public class EntityStack extends ColdEntityStack {
plugin.getEntityStackManager().removeStack(event.getEntity()); plugin.getEntityStackManager().removeStack(event.getEntity());
plugin.getDataManager().deleteHost(this); plugin.getDataManager().deleteHost(this);
Location killedLocation = killed.getLocation(); Location killedLocation = killed.getLocation();
List<Drop> preStackedDrops = new ArrayList<>(); List<Drop> preStackedDrops = new ArrayList<>();
for (int i = 1; i < getAmount(); i++) { for (int i = 1; i < getAmount(); i++) {
@ -98,14 +96,14 @@ public class EntityStack extends ColdEntityStack {
drops = plugin.getLootablesManager().getDrops(killed); drops = plugin.getLootablesManager().getDrops(killed);
preStackedDrops.addAll(drops); preStackedDrops.addAll(drops);
} }
if (!preStackedDrops.isEmpty())
DropUtils.processStackedDrop(killed, preStackedDrops, event); DropUtils.processStackedDrop(killed, preStackedDrops, event);
if (droppedExp > 0) if (droppedExp > 0)
killedLocation.getWorld().spawn(killedLocation, ExperienceOrb.class).setExperience(droppedExp * getAmount()); killedLocation.getWorld().spawn(killedLocation, ExperienceOrb.class).setExperience(droppedExp * getAmount());
if (killed.getKiller() == null) return; if (killed.getKiller() == null) return;
UltimateStacker.getInstance().addExp(killed.getKiller(), this); plugin.addExp(killed.getKiller(), this);
} }
private void handleSingleStackDeath(LivingEntity killed, List<Drop> drops, EntityDeathEvent event) { private void handleSingleStackDeath(LivingEntity killed, List<Drop> drops, EntityDeathEvent event) {

View File

@ -5,9 +5,9 @@ import com.songoda.core.compatibility.ServerVersion;
import com.songoda.ultimatestacker.UltimateStacker; import com.songoda.ultimatestacker.UltimateStacker;
import com.songoda.ultimatestacker.settings.Settings; import com.songoda.ultimatestacker.settings.Settings;
import com.songoda.ultimatestacker.stackable.Hologramable; import com.songoda.ultimatestacker.stackable.Hologramable;
import com.songoda.ultimatestacker.utils.Stackable;
import com.songoda.ultimatestacker.utils.Methods; import com.songoda.ultimatestacker.utils.Methods;
import com.songoda.ultimatestacker.utils.Reflection; import com.songoda.ultimatestacker.utils.Reflection;
import com.songoda.ultimatestacker.utils.Stackable;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.World; import org.bukkit.World;
@ -85,6 +85,10 @@ public class SpawnerStack implements Stackable, Hologramable {
@Override @Override
public String getHologramName() { public String getHologramName() {
if (!(location.getBlock().getState() instanceof CreatureSpawner)) {
plugin.getSpawnerStackManager().removeSpawner(location);
return null;
}
CreatureSpawner creatureSpawner = (CreatureSpawner) location.getBlock().getState(); CreatureSpawner creatureSpawner = (CreatureSpawner) location.getBlock().getState();
return Methods.compileSpawnerName(creatureSpawner.getSpawnedType(), amount); return Methods.compileSpawnerName(creatureSpawner.getSpawnedType(), amount);
} }