Performance improvements

This commit is contained in:
Esophose 2019-07-14 20:42:51 -06:00
parent 9ccebdb29d
commit a088778467
3 changed files with 17 additions and 4 deletions

View File

@ -4,7 +4,7 @@ stages:
variables:
name: "EpicFarming"
path: "/builds/$CI_PROJECT_PATH"
version: "2.2.2"
version: "2.2.3"
build:
stage: build

View File

@ -180,10 +180,14 @@ public class EpicFarmingPlugin extends JavaPlugin implements EpicFarming {
// Start tasks
this.growthTask = GrowthTask.startTask(this);
HopperTask.startTask(this);
this.farmTask = FarmTask.startTask(this);
this.entityTask = EntityTask.startTask(this);
Bukkit.getScheduler().runTaskLater(this, () -> {
if (!Bukkit.getPluginManager().isPluginEnabled("EpicFarming"))
HopperTask.startTask(this);
}, 20L);
Bukkit.getScheduler().scheduleSyncRepeatingTask(this, this::saveToFile, 6000, 6000);
// Start Metrics

View File

@ -3,6 +3,7 @@ package com.songoda.epicfarming.tasks;
import com.songoda.epicfarming.EpicFarmingPlugin;
import com.songoda.epicfarming.api.farming.Farm;
import com.songoda.epicfarming.api.farming.FarmManager;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
@ -33,12 +34,20 @@ public class HopperTask extends BukkitRunnable {
@Override
public void run() {
for (Farm farm : manager.getFarms().values()) {
if (farm.getLocation() == null) {
Location farmLocation = farm.getLocation();
if (farmLocation == null || farmLocation.getWorld() == null) {
manager.removeFarm(farm.getLocation());
continue;
}
Block block = farm.getLocation().getBlock().getRelative(BlockFace.DOWN).getRelative(BlockFace.DOWN);
int x = farmLocation.getBlockX() >> 4;
int z = farmLocation.getBlockZ() >> 4;
if (!farmLocation.getWorld().isChunkLoaded(x, z)) {
continue;
}
Block block = farmLocation.getBlock().getRelative(BlockFace.DOWN).getRelative(BlockFace.DOWN);
if (block.getType() != Material.HOPPER)
continue;