mirror of
https://github.com/songoda/EpicFarming.git
synced 2025-03-01 19:01:12 +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);
|
return Collections.unmodifiableList(items);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Should be used in sync.
|
||||||
public void addItem(ItemStack toAdd) {
|
public void addItem(ItemStack toAdd) {
|
||||||
for (ItemStack item : new ArrayList<>(getItems())) {
|
for (ItemStack item : new ArrayList<>(items)) {
|
||||||
if (item.getType() != toAdd.getType()
|
if (item.getType() != toAdd.getType()
|
||||||
|| item.getAmount() + toAdd.getAmount() > item.getMaxStackSize()) continue;
|
|| item.getAmount() + toAdd.getAmount() > item.getMaxStackSize()) continue;
|
||||||
item.setAmount(item.getAmount() + toAdd.getAmount());
|
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));
|
ItemStack seedStack = new ItemStack(cropTypeData.getSeedMaterial(), random.nextInt(3) + 1 + (useBoneMeal(farm) ? 1 : 0));
|
||||||
|
|
||||||
if (!farm.willFit(stack) || !farm.willFit(seedStack)) return false;
|
if (!farm.willFit(stack) || !farm.willFit(seedStack)) return false;
|
||||||
Bukkit.getScheduler().runTask(plugin, () ->
|
Bukkit.getScheduler().runTask(plugin, () -> {
|
||||||
Methods.animate(farm.getLocation(), cropTypeData.getYieldMaterial()));
|
Methods.animate(farm.getLocation(), cropTypeData.getYieldMaterial());
|
||||||
farm.addItem(stack);
|
farm.addItem(stack);
|
||||||
|
});
|
||||||
if (getCollectionType(farm) != CollectionType.NO_SEEDS)
|
if (getCollectionType(farm) != CollectionType.NO_SEEDS)
|
||||||
farm.addItem(seedStack);
|
farm.addItem(seedStack);
|
||||||
return true;
|
return true;
|
||||||
|
Loading…
Reference in New Issue
Block a user