Merge branch 'development'

This commit is contained in:
Brianna 2020-05-10 14:36:22 -04:00
commit 823f5c7a0b
3 changed files with 27 additions and 23 deletions

View File

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

View File

@ -85,7 +85,8 @@ public class ModuleAutoCollect extends Module {
entity.getLocation().getWorld().playSound(entity.getLocation(), Sound.ENTITY_CHICKEN_EGG, 1, 2);
if (!isEnabled(farm)) {
ticksLived.remove(entity);
entity.getLocation().getWorld().dropItemNaturally(entity.getLocation(), new ItemStack(Material.EGG));
Bukkit.getScheduler().runTask(plugin, () ->
entity.getLocation().getWorld().dropItemNaturally(entity.getLocation(), new ItemStack(Material.EGG)));
} else {
doLivestockDrop(farm, new ItemStack(Material.EGG, 1));
}
@ -98,7 +99,8 @@ public class ModuleAutoCollect extends Module {
Wool woolColor = new Wool(((Sheep) entity).getColor());
ItemStack wool = woolColor.toItemStack((int) Math.round(1 + (Math.random() * 3)));
if (!isEnabled(farm)) {
entity.getLocation().getWorld().dropItemNaturally(entity.getLocation(), wool);
Bukkit.getScheduler().runTask(plugin, () ->
entity.getLocation().getWorld().dropItemNaturally(entity.getLocation(), wool));
} else {
doLivestockDrop(farm, wool);
}

View File

@ -37,31 +37,33 @@ public class FarmTask extends BukkitRunnable {
public static List<Block> getCrops(Farm farm, boolean add) {
if (((System.currentTimeMillis() - farm.getLastCached()) > (30 * 1000)) || !add) {
farm.setLastCached(System.currentTimeMillis());
if (add) farm.clearCache();
Block block = farm.getLocation().getBlock();
int radius = farm.getLevel().getRadius();
int bx = block.getX();
int by = block.getY();
int bz = block.getZ();
for (int fx = -radius; fx <= radius; fx++) {
for (int fy = -2; fy <= 1; fy++) {
for (int fz = -radius; fz <= radius; fz++) {
Block b2 = block.getWorld().getBlockAt(bx + fx, by + fy, bz + fz);
CompatibleMaterial mat = CompatibleMaterial.getMaterial(b2);
Bukkit.getScheduler().runTask(plugin, () -> {
farm.setLastCached(System.currentTimeMillis());
if (add) farm.clearCache();
Block block = farm.getLocation().getBlock();
int radius = farm.getLevel().getRadius();
int bx = block.getX();
int by = block.getY();
int bz = block.getZ();
for (int fx = -radius; fx <= radius; fx++) {
for (int fy = -2; fy <= 1; fy++) {
for (int fz = -radius; fz <= radius; fz++) {
Block b2 = block.getWorld().getBlockAt(bx + fx, by + fy, bz + fz);
CompatibleMaterial mat = CompatibleMaterial.getMaterial(b2);
if (mat == null || !mat.isCrop() || !CropType.isGrowableCrop(mat.getBlockMaterial()))
continue;
if (mat == null || !mat.isCrop() || !CropType.isGrowableCrop(mat.getBlockMaterial()))
continue;
if (add) {
farm.addCachedCrop(b2);
continue;
if (add) {
farm.addCachedCrop(b2);
continue;
}
farm.removeCachedCrop(b2);
plugin.getGrowthTask().removeCropByLocation(b2.getLocation());
}
farm.removeCachedCrop(b2);
plugin.getGrowthTask().removeCropByLocation(b2.getLocation());
}
}
}
});
}
return farm.getCachedCrops();
}