mirror of
https://github.com/songoda/UltimateStacker.git
synced 2024-11-14 22:25:22 +01:00
API improvements.
This commit is contained in:
parent
ea5e56f431
commit
b82c128910
@ -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