diff --git a/pom.xml b/pom.xml
index 961d5ca..effac0d 100644
--- a/pom.xml
+++ b/pom.xml
@@ -2,7 +2,7 @@
com.songoda
UltimateStacker
4.0.0
- 2.0.7
+ 2.0.8
clean install
UltimateStacker-${project.version}
diff --git a/src/main/java/com/songoda/ultimatestacker/commands/CommandRemoveAll.java b/src/main/java/com/songoda/ultimatestacker/commands/CommandRemoveAll.java
index 59c1bae..1edd082 100644
--- a/src/main/java/com/songoda/ultimatestacker/commands/CommandRemoveAll.java
+++ b/src/main/java/com/songoda/ultimatestacker/commands/CommandRemoveAll.java
@@ -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++;
diff --git a/src/main/java/com/songoda/ultimatestacker/database/DataManager.java b/src/main/java/com/songoda/ultimatestacker/database/DataManager.java
index 4693127..5a35604 100644
--- a/src/main/java/com/songoda/ultimatestacker/database/DataManager.java
+++ b/src/main/java/com/songoda/ultimatestacker/database/DataManager.java
@@ -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());
diff --git a/src/main/java/com/songoda/ultimatestacker/stackable/entity/ColdEntityStack.java b/src/main/java/com/songoda/ultimatestacker/stackable/entity/ColdEntityStack.java
index 97486f1..ea35108 100644
--- a/src/main/java/com/songoda/ultimatestacker/stackable/entity/ColdEntityStack.java
+++ b/src/main/java/com/songoda/ultimatestacker/stackable/entity/ColdEntityStack.java
@@ -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);
diff --git a/src/main/java/com/songoda/ultimatestacker/tasks/StackingTask.java b/src/main/java/com/songoda/ultimatestacker/tasks/StackingTask.java
index c844ef0..dfcd3c5 100644
--- a/src/main/java/com/songoda/ultimatestacker/tasks/StackingTask.java
+++ b/src/main/java/com/songoda/ultimatestacker/tasks/StackingTask.java
@@ -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();