Merge branch 'development'

This commit is contained in:
Brianna 2020-08-31 17:35:20 -05:00
commit ee8214ffcb
3 changed files with 19 additions and 4 deletions

View File

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

View File

@ -16,6 +16,7 @@ import org.bukkit.inventory.ItemStack;
import org.bukkit.util.Vector;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import java.util.concurrent.ThreadLocalRandom;
@ -41,6 +42,20 @@ public class EntityStack extends ColdEntityStack {
return stackedEntity;
}
@Override
public List<StackedEntity> takeEntities(int amount) {
List<StackedEntity> entities = super.takeEntities(amount);
if (this.stackedEntities.isEmpty())
destroy(true);
return entities;
}
@Override
public List<StackedEntity> takeAllEntities() {
destroy(true);
return super.takeAllEntities();
}
public void updateStack() {
if (createDuplicates != 0) {
List<StackedEntity> stackedEntities = new ArrayList<>();

View File

@ -189,16 +189,16 @@ public class StackingTask extends BukkitRunnable {
// If we are a stack lets merge our stack with the just found friend stack.
if (isStack) {
// Get the host entity.
StackedEntity host = stack.getHostAsStackedEntity();
// Get all the stacked entities in our stack and add them to a list.
List<StackedEntity> entities = stack.takeAllEntities();
// Add the host to this list.
entities.add(stack.getHostAsStackedEntity());
entities.add(host);
// Add the collected entities to the new stack.
friendStack.addEntitiesToStackSilently(entities);
// Update friend stack to display changes.
friendStack.updateStack();
// Destroy our stack.
stack.destroy();
// Push changes to the database.
plugin.getDataManager().createStackedEntities(friendStack, entities);
} else {