cleanup, core fix for legacy carrot/potato

This commit is contained in:
jascotty2 2019-10-20 16:14:49 -05:00
parent 840ff59cd6
commit 8ec97dca42
3 changed files with 13 additions and 15 deletions

View File

@ -20,7 +20,7 @@ public class FarmTask extends BukkitRunnable {
private static EpicFarming plugin; private static EpicFarming plugin;
public static FarmTask startTask(EpicFarming pl) { public static FarmTask startTask(EpicFarming pl) {
if (instance != null && !instance.isCancelled()) { if (instance != null) {
instance.cancel(); instance.cancel();
} }
instance = new FarmTask(); instance = new FarmTask();

View File

@ -8,8 +8,11 @@ import com.songoda.epicfarming.settings.Settings;
import com.songoda.epicfarming.utils.CropType; import com.songoda.epicfarming.utils.CropType;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.scheduler.BukkitRunnable; import org.bukkit.scheduler.BukkitRunnable;
import java.util.ArrayList;
import java.util.*; import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Random;
public class GrowthTask extends BukkitRunnable { public class GrowthTask extends BukkitRunnable {
@ -20,7 +23,7 @@ public class GrowthTask extends BukkitRunnable {
private static final Random random = new Random(); private static final Random random = new Random();
public static GrowthTask startTask(EpicFarming plugin) { public static GrowthTask startTask(EpicFarming plugin) {
if (instance != null && !instance.isCancelled()) { if (instance != null) {
instance.cancel(); instance.cancel();
} }
instance = new GrowthTask(); instance = new GrowthTask();
@ -33,15 +36,9 @@ public class GrowthTask extends BukkitRunnable {
List<Crop> toRemove = new ArrayList<>(); List<Crop> toRemove = new ArrayList<>();
for (Crop crop : liveCrops.values()) { for (Crop crop : liveCrops.values()) {
if (crop.getFarm().getFarmType() == FarmType.LIVESTOCK) continue; if (crop.getFarm().getFarmType() == FarmType.LIVESTOCK
Location cropLocation = crop.getLocation(); || !crop.getFarm().isInLoadedChunk())
int x = cropLocation.getBlockX() >> 4;
int z = cropLocation.getBlockZ() >> 4;
if (cropLocation.getWorld() == null || !cropLocation.getWorld().isChunkLoaded(x, z)) {
continue; continue;
}
if (!CropType.isGrowableCrop(crop.getLocation().getBlock().getType())) { if (!CropType.isGrowableCrop(crop.getLocation().getBlock().getType())) {
toRemove.add(crop); toRemove.add(crop);

View File

@ -24,11 +24,12 @@ public class HopperTask extends BukkitRunnable {
public static HopperTask startTask(EpicFarming plugin) { public static HopperTask startTask(EpicFarming plugin) {
if (instance == null) { if (instance != null) {
instance = new HopperTask(plugin); instance.cancel();
instance.runTaskTimer(plugin, 0, 8);
} }
instance = new HopperTask(plugin);
instance.runTaskTimer(plugin, 0, 8);
return instance; return instance;
} }