Merge branch 'development'

This commit is contained in:
Brianna 2020-09-17 19:24:47 -05:00
commit 7fe56c86eb
5 changed files with 8 additions and 5 deletions

View File

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

View File

@ -10,6 +10,7 @@ import org.bukkit.World;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Item;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
@ -43,13 +44,13 @@ public class CommandRemoveAll extends AbstractCommand {
EntityStackManager stackManager = plugin.getEntityStackManager();
for (World world : Bukkit.getWorlds()) {
for (Entity entityO : world.getEntities()) {
if (entityO instanceof Player || !(entityO instanceof LivingEntity)) continue;
if (entityO instanceof Player) continue;
if (entityO.getType() != EntityType.DROPPED_ITEM && (stackManager.isStackedAndLoaded((LivingEntity)entityO) || all) && type.equalsIgnoreCase("entities")) {
if (entityO instanceof LivingEntity && (stackManager.isStackedAndLoaded((LivingEntity)entityO) || all) && type.equalsIgnoreCase("entities")) {
entityO.remove();
amountRemoved++;
} else if (entityO.getType() == EntityType.DROPPED_ITEM && type.equalsIgnoreCase("items")) {
if (entityO.isCustomNameVisible() && !entityO.getCustomName().contains(TextUtils.convertToInvisibleString("IS")) || all)
if (!UltimateStacker.hasCustomAmount((Item)entityO) && !all)
continue;
entityO.remove();
amountRemoved++;

View File

@ -109,7 +109,7 @@ public class DataManager extends DataManagerAbstract {
public void createHostEntity(ColdEntityStack stack) {
this.queueAsync(() -> this.databaseConnector.connect(connection -> {
if (stack.getHostUniqueId() == null) return;
if (stack == null || stack.getHostUniqueId() == null) return;
String createSerializedEntity = "INSERT INTO " + this.getTablePrefix() + "host_entities (uuid, create_duplicates) VALUES (?, ?)";
try (PreparedStatement statement = connection.prepareStatement(createSerializedEntity)) {
statement.setString(1, stack.getHostUniqueId().toString());

View File

@ -87,6 +87,7 @@ public class ColdEntityStack implements Stackable {
}
public LivingEntity takeOneAndSpawnEntity(Location location) {
if (stackedEntities.isEmpty()) return null;
NBTEntity nbtEntity = NmsManager.getNbt().newEntity();
nbtEntity.deSerialize(stackedEntities.getFirst().getSerializedEntity());
LivingEntity newEntity = (LivingEntity)nbtEntity.spawn(location);

View File

@ -321,6 +321,7 @@ public class StackingTask extends BukkitRunnable {
Bukkit.getScheduler().runTask(plugin, () -> {
for (int i = stackSize; i > 0; i -= maxEntityStackAmount) {
LivingEntity entity = stack.takeOneAndSpawnEntity(livingEntity.getLocation());
if (entity == null) continue;
EntityStack newStack = plugin.getEntityStackManager().addStack(entity);
newStack.moveEntitiesFromStack(stack, Math.min(i, maxEntityStackAmount) - 1);
newStack.updateStack();