Added check limits for Aiming

This commit is contained in:
Auxilor 2020-11-21 12:12:30 +00:00
parent e5aacc2ef8
commit e3c1345672
2 changed files with 11 additions and 2 deletions

View File

@ -18,6 +18,7 @@ import org.bukkit.util.Vector;
import java.util.Arrays;
import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;
@SuppressWarnings("unchecked")
public final class Aiming extends EcoEnchant {
@ -91,12 +92,18 @@ public final class Aiming extends EcoEnchant {
}
};
final int period = this.getConfig().getInt(EcoEnchants.CONFIG_LOCATION + "check-ticks");
final int checks = this.getConfig().getInt(EcoEnchants.CONFIG_LOCATION + "checks-per-level") * level;
AtomicInteger checksPerformed = new AtomicInteger(0);
new BukkitRunnable() {
@Override
public void run() {
checksPerformed.addAndGet(1);
if(checksPerformed.get() > checks) this.cancel();
if(arrow.isDead() || arrow.isInBlock() || arrow.isOnGround()) this.cancel();
Bukkit.getScheduler().runTask(EcoEnchantsPlugin.getInstance(), runnable);
}
}.runTaskTimer(EcoEnchantsPlugin.getInstance(), 3, 5);
}.runTaskTimer(EcoEnchantsPlugin.getInstance(), 3, period);
}
}

View File

@ -22,4 +22,6 @@ general-config:
config:
distance-per-level: 4 # Distance to scan per aiming level
scale-on-force: true # Scale distance based on bow pull
require-full-force: true # Require full bow pull (works with rapid) If true, then scale-on-force is irrelevant.
require-full-force: true # Require full bow pull (works with rapid) If true, then scale-on-force is irrelevant.
check-ticks: 10 # Ticks between rotations
checks-per-level: 2 # Amount of times to rotate arrow per level (prevents "floating")