mirror of
https://github.com/songoda/EpicFarming.git
synced 2024-11-05 18:39:49 +01:00
Performance improvements
This commit is contained in:
parent
9ccebdb29d
commit
a088778467
@ -4,7 +4,7 @@ stages:
|
||||
variables:
|
||||
name: "EpicFarming"
|
||||
path: "/builds/$CI_PROJECT_PATH"
|
||||
version: "2.2.2"
|
||||
version: "2.2.3"
|
||||
|
||||
build:
|
||||
stage: build
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user