mirror of
https://github.com/songoda/UltimateStacker.git
synced 2025-02-28 17:21:02 +01:00
Merge branch 'development'
This commit is contained in:
commit
ee8214ffcb
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.3</version>
|
||||
<version>2.0.4</version>
|
||||
<build>
|
||||
<defaultGoal>clean install</defaultGoal>
|
||||
<finalName>UltimateStacker-${project.version}</finalName>
|
||||
|
@ -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<>();
|
||||
|
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user