mirror of
https://github.com/songoda/UltimateStacker.git
synced 2024-12-27 10:57:43 +01:00
Merge branch 'development'
This commit is contained in:
commit
a5fb739e96
2
pom.xml
2
pom.xml
@ -2,7 +2,7 @@
|
||||
<groupId>com.songoda</groupId>
|
||||
<artifactId>UltimateStacker</artifactId>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<version>2.0.2</version>
|
||||
<version>2.0.3</version>
|
||||
<build>
|
||||
<defaultGoal>clean install</defaultGoal>
|
||||
<finalName>UltimateStacker-${project.version}</finalName>
|
||||
|
@ -119,9 +119,9 @@ public class DataManager extends DataManagerAbstract {
|
||||
|
||||
public void createStackedEntity(EntityStack hostStack, StackedEntity stackedEntity) {
|
||||
this.queueAsync(() -> this.databaseConnector.connect(connection -> {
|
||||
if (hostStack.getHostUniqueId() == null) return;
|
||||
String createSerializedEntity = "INSERT INTO " + this.getTablePrefix() + "stacked_entities (uuid, host, serialized_entity) VALUES (?, ?, ?)";
|
||||
try (PreparedStatement statement = connection.prepareStatement(createSerializedEntity)) {
|
||||
if (hostStack.getHostUniqueId() == null) return;
|
||||
statement.setString(1, stackedEntity.getUniqueId().toString());
|
||||
statement.setInt(2, hostStack.getId());
|
||||
statement.setBytes(3, stackedEntity.getSerializedEntity());
|
||||
@ -132,10 +132,10 @@ public class DataManager extends DataManagerAbstract {
|
||||
|
||||
public void createStackedEntities(ColdEntityStack hostStack, List<StackedEntity> stackedEntities) {
|
||||
this.queueAsync(() -> this.databaseConnector.connect(connection -> {
|
||||
if (hostStack.getHostUniqueId() == null) return;
|
||||
String createSerializedEntity = "INSERT INTO " + this.getTablePrefix() + "stacked_entities (uuid, host, serialized_entity) VALUES (?, ?, ?)" +
|
||||
"ON CONFLICT(uuid) DO UPDATE SET host = ?, serialized_entity = ?";
|
||||
try (PreparedStatement statement = connection.prepareStatement(createSerializedEntity)) {
|
||||
if (hostStack.getHostUniqueId() == null) return;
|
||||
for (StackedEntity entity : stackedEntities) {
|
||||
statement.setString(1, entity.getUniqueId().toString());
|
||||
statement.setInt(2, hostStack.getId());
|
||||
@ -151,9 +151,9 @@ public class DataManager extends DataManagerAbstract {
|
||||
|
||||
public void updateHost(ColdEntityStack hostStack) {
|
||||
this.async(() -> this.databaseConnector.connect(connection -> {
|
||||
if (hostStack.getHostUniqueId() == null) return;
|
||||
String updateHost = "UPDATE " + this.getTablePrefix() + "host_entities SET uuid = ?, create_duplicates = ? WHERE id = ?";
|
||||
try (PreparedStatement statement = connection.prepareStatement(updateHost)) {
|
||||
if (hostStack.getHostUniqueId() == null) return;
|
||||
statement.setString(1, hostStack.getHostUniqueId().toString());
|
||||
statement.setInt(2, hostStack.getCreateDuplicates());
|
||||
statement.setInt(3, hostStack.getId());
|
||||
|
@ -66,10 +66,12 @@ public class LootablesManager {
|
||||
Entity killerEntity = null;
|
||||
if (entity.getLastDamageCause() instanceof EntityDamageByEntityEvent) {
|
||||
killerEntity = ((EntityDamageByEntityEvent) entity.getLastDamageCause()).getDamager();
|
||||
killer = killerEntity.getType();
|
||||
if (killerEntity instanceof Projectile) {
|
||||
Projectile projectile = (Projectile) killerEntity;
|
||||
if (projectile.getShooter() instanceof Entity) {
|
||||
killer = ((Entity) projectile.getShooter()).getType();
|
||||
killerEntity = ((Entity) projectile.getShooter());
|
||||
killer = killerEntity.getType();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -17,7 +17,6 @@ import org.bukkit.util.Vector;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ThreadLocalRandom;
|
||||
|
||||
public class EntityStack extends ColdEntityStack {
|
||||
@ -83,7 +82,6 @@ public class EntityStack extends ColdEntityStack {
|
||||
plugin.getEntityStackManager().removeStack(event.getEntity());
|
||||
plugin.getDataManager().deleteHost(this);
|
||||
|
||||
|
||||
Location killedLocation = killed.getLocation();
|
||||
List<Drop> preStackedDrops = new ArrayList<>();
|
||||
for (int i = 1; i < getAmount(); i++) {
|
||||
@ -98,14 +96,14 @@ public class EntityStack extends ColdEntityStack {
|
||||
drops = plugin.getLootablesManager().getDrops(killed);
|
||||
preStackedDrops.addAll(drops);
|
||||
}
|
||||
if (!preStackedDrops.isEmpty())
|
||||
|
||||
DropUtils.processStackedDrop(killed, preStackedDrops, event);
|
||||
|
||||
if (droppedExp > 0)
|
||||
killedLocation.getWorld().spawn(killedLocation, ExperienceOrb.class).setExperience(droppedExp * getAmount());
|
||||
|
||||
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) {
|
||||
|
@ -5,9 +5,9 @@ import com.songoda.core.compatibility.ServerVersion;
|
||||
import com.songoda.ultimatestacker.UltimateStacker;
|
||||
import com.songoda.ultimatestacker.settings.Settings;
|
||||
import com.songoda.ultimatestacker.stackable.Hologramable;
|
||||
import com.songoda.ultimatestacker.utils.Stackable;
|
||||
import com.songoda.ultimatestacker.utils.Methods;
|
||||
import com.songoda.ultimatestacker.utils.Reflection;
|
||||
import com.songoda.ultimatestacker.utils.Stackable;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
@ -85,6 +85,10 @@ public class SpawnerStack implements Stackable, Hologramable {
|
||||
|
||||
@Override
|
||||
public String getHologramName() {
|
||||
if (!(location.getBlock().getState() instanceof CreatureSpawner)) {
|
||||
plugin.getSpawnerStackManager().removeSpawner(location);
|
||||
return null;
|
||||
}
|
||||
CreatureSpawner creatureSpawner = (CreatureSpawner) location.getBlock().getState();
|
||||
return Methods.compileSpawnerName(creatureSpawner.getSpawnedType(), amount);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user