mirror of
https://github.com/songoda/EpicFarming.git
synced 2024-11-30 14:33:28 +01:00
cleanup, core fix for legacy carrot/potato
This commit is contained in:
parent
840ff59cd6
commit
8ec97dca42
@ -20,7 +20,7 @@ public class FarmTask extends BukkitRunnable {
|
||||
private static EpicFarming plugin;
|
||||
|
||||
public static FarmTask startTask(EpicFarming pl) {
|
||||
if (instance != null && !instance.isCancelled()) {
|
||||
if (instance != null) {
|
||||
instance.cancel();
|
||||
}
|
||||
instance = new FarmTask();
|
||||
|
@ -8,8 +8,11 @@ import com.songoda.epicfarming.settings.Settings;
|
||||
import com.songoda.epicfarming.utils.CropType;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
|
||||
public class GrowthTask extends BukkitRunnable {
|
||||
|
||||
@ -20,7 +23,7 @@ public class GrowthTask extends BukkitRunnable {
|
||||
private static final Random random = new Random();
|
||||
|
||||
public static GrowthTask startTask(EpicFarming plugin) {
|
||||
if (instance != null && !instance.isCancelled()) {
|
||||
if (instance != null) {
|
||||
instance.cancel();
|
||||
}
|
||||
instance = new GrowthTask();
|
||||
@ -33,15 +36,9 @@ public class GrowthTask extends BukkitRunnable {
|
||||
List<Crop> toRemove = new ArrayList<>();
|
||||
|
||||
for (Crop crop : liveCrops.values()) {
|
||||
if (crop.getFarm().getFarmType() == FarmType.LIVESTOCK) continue;
|
||||
Location cropLocation = crop.getLocation();
|
||||
|
||||
int x = cropLocation.getBlockX() >> 4;
|
||||
int z = cropLocation.getBlockZ() >> 4;
|
||||
|
||||
if (cropLocation.getWorld() == null || !cropLocation.getWorld().isChunkLoaded(x, z)) {
|
||||
if (crop.getFarm().getFarmType() == FarmType.LIVESTOCK
|
||||
|| !crop.getFarm().isInLoadedChunk())
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!CropType.isGrowableCrop(crop.getLocation().getBlock().getType())) {
|
||||
toRemove.add(crop);
|
||||
|
@ -24,11 +24,12 @@ public class HopperTask extends BukkitRunnable {
|
||||
|
||||
|
||||
public static HopperTask startTask(EpicFarming plugin) {
|
||||
if (instance == null) {
|
||||
instance = new HopperTask(plugin);
|
||||
instance.runTaskTimer(plugin, 0, 8);
|
||||
if (instance != null) {
|
||||
instance.cancel();
|
||||
}
|
||||
|
||||
instance = new HopperTask(plugin);
|
||||
instance.runTaskTimer(plugin, 0, 8);
|
||||
return instance;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user