mirror of
https://github.com/songoda/EpicFarming.git
synced 2024-11-30 22:43:35 +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;
|
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();
|
||||||
|
@ -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);
|
||||||
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user