fix for caching issue

This commit is contained in:
Brianna O'Keefe 2018-11-04 00:32:49 -05:00
parent be31a1ce5f
commit acd4f9e97a
4 changed files with 8 additions and 4 deletions

View File

@ -288,6 +288,10 @@ public class EFarm implements Farm {
cachedCrops.add(block); cachedCrops.add(block);
} }
public void removeCachedCrop(Block block) {
cachedCrops.remove(block);
}
@Override @Override
public List<Block> getCachedCrops() { public List<Block> getCachedCrops() {
return new ArrayList<>(cachedCrops); return new ArrayList<>(cachedCrops);

View File

@ -114,7 +114,7 @@ public class FarmTask extends BukkitRunnable {
} }
public List<Block> getCrops(Farm farm, boolean add) { public List<Block> getCrops(Farm farm, boolean add) {
if (System.currentTimeMillis() - ((EFarm)farm).getLastCached() > 30 * 1000) { if (System.currentTimeMillis() - ((EFarm)farm).getLastCached() > 30 * 1000 || !add) {
((EFarm)farm).setLastCached(System.currentTimeMillis()); ((EFarm)farm).setLastCached(System.currentTimeMillis());
Block block = farm.getLocation().getBlock(); Block block = farm.getLocation().getBlock();
int radius = farm.getLevel().getRadius(); int radius = farm.getLevel().getRadius();
@ -132,8 +132,8 @@ public class FarmTask extends BukkitRunnable {
((EFarm)farm).addCachedCrop(b2); ((EFarm)farm).addCachedCrop(b2);
continue; continue;
} }
((EFarm)farm).removeCachedCrop(b2);
plugin.getGrowthTask().removeCropByLocation(b2.getLocation()); plugin.getGrowthTask().removeCropByLocation(b2.getLocation());
} }
} }
} }

View File

@ -1,7 +1,7 @@
name: EpicFarming name: EpicFarming
description: EpicFarming description: EpicFarming
main: com.songoda.epicfarming.EpicFarmingPlugin main: com.songoda.epicfarming.EpicFarmingPlugin
version: 2.0.13 version: 2.0.14
depend: [Arconix] depend: [Arconix]
soft-depend: [Multiverse-Core] soft-depend: [Multiverse-Core]
author: Songoda author: Songoda

View File

@ -2,7 +2,7 @@
<groupId>com.songoda</groupId> <groupId>com.songoda</groupId>
<artifactId>EpicFarming</artifactId> <artifactId>EpicFarming</artifactId>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<version>2.0.13</version> <version>2.0.14</version>
<build> <build>
<defaultGoal>clean package</defaultGoal> <defaultGoal>clean package</defaultGoal>
<plugins> <plugins>