Commit 815b01b7 authored by Linus K.'s avatar Linus K.
Browse files

Ignore area when started farming

parent 0ff59d8f
Pipeline #120 passed with stage
in 41 seconds
......@@ -25,7 +25,11 @@ class AutoFarmerListener: Listener {
const val BLOCK_FARM_PLANT_DELAY_TICKS = 5L
fun isIgnoreInteract(location: Location) = IGNORE_INTERACTS.any { it.key == location && it.value >= System.currentTimeMillis() }
fun isIgnoreInteract(location: Location) = IGNORE_INTERACTS
.filter { it.key.world == location.world }
.filter { it.key.distance(location) <= 5.0 }
.filter { it.value >= System.currentTimeMillis() }
.any()
fun initScheduler(plugin: Plugin) {
Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, {
......@@ -145,7 +149,7 @@ class AutoFarmerListener: Listener {
if(isIgnoreInteract(clickedBlock.location)) return
if(!e.player.inventory.itemInMainHand.type.toString().endsWith("_HOE") && !e.player.inventory.itemInOffHand.type.toString().endsWith("_HOE"))
return
if(isRipe(clickedBlock)) {
IGNORE_INTERACTS[clickedBlock.location] = System.currentTimeMillis() + IGNORE_DURATION_MILLIS
farmFrom(clickedBlock)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment