mirror of
https://github.com/songoda/EpicFarming.git
synced 2024-11-30 14:33:28 +01:00
Moved add item method to sync.
This commit is contained in:
parent
cc0f4df840
commit
29828da0be
@ -176,8 +176,9 @@ public class Farm {
|
||||
return Collections.unmodifiableList(items);
|
||||
}
|
||||
|
||||
// Should be used in sync.
|
||||
public void addItem(ItemStack toAdd) {
|
||||
for (ItemStack item : new ArrayList<>(getItems())) {
|
||||
for (ItemStack item : new ArrayList<>(items)) {
|
||||
if (item.getType() != toAdd.getType()
|
||||
|| item.getAmount() + toAdd.getAmount() > item.getMaxStackSize()) continue;
|
||||
item.setAmount(item.getAmount() + toAdd.getAmount());
|
||||
|
@ -220,9 +220,10 @@ public class ModuleAutoCollect extends Module {
|
||||
ItemStack seedStack = new ItemStack(cropTypeData.getSeedMaterial(), random.nextInt(3) + 1 + (useBoneMeal(farm) ? 1 : 0));
|
||||
|
||||
if (!farm.willFit(stack) || !farm.willFit(seedStack)) return false;
|
||||
Bukkit.getScheduler().runTask(plugin, () ->
|
||||
Methods.animate(farm.getLocation(), cropTypeData.getYieldMaterial()));
|
||||
Bukkit.getScheduler().runTask(plugin, () -> {
|
||||
Methods.animate(farm.getLocation(), cropTypeData.getYieldMaterial());
|
||||
farm.addItem(stack);
|
||||
});
|
||||
if (getCollectionType(farm) != CollectionType.NO_SEEDS)
|
||||
farm.addItem(seedStack);
|
||||
return true;
|
||||
|
Loading…
Reference in New Issue
Block a user