Removed Bukkit.getScheduler calls
This commit is contained in:
@@ -3,6 +3,7 @@ package com.willfp.ecoenchants;
|
||||
import com.willfp.eco.core.proxy.proxies.FastGetEnchantsProxy;
|
||||
import com.willfp.eco.util.ProxyUtils;
|
||||
import com.willfp.eco.util.command.AbstractCommand;
|
||||
import com.willfp.eco.util.drops.telekinesis.TelekinesisTests;
|
||||
import com.willfp.eco.util.integrations.IntegrationLoader;
|
||||
import com.willfp.eco.util.interfaces.EcoRunnable;
|
||||
import com.willfp.eco.util.packets.AbstractPacketAdapter;
|
||||
@@ -77,7 +78,7 @@ public class EcoEnchantsPlugin extends AbstractEcoPlugin {
|
||||
this.getLog().info(EcoEnchants.values().size() + " Enchantments Loaded:");
|
||||
this.getLog().info(EcoEnchants.values().stream().map(ecoEnchant -> ecoEnchant.getType().getColor() + ecoEnchant.getName()).collect(Collectors.joining(", ")));
|
||||
|
||||
this.getTelekineticTests().registerTest(player -> ProxyUtils.getProxy(FastGetEnchantsProxy.class).getLevelOnItem(player.getInventory().getItemInMainHand(), EcoEnchants.TELEKINESIS) > 0);
|
||||
Bukkit.getServicesManager().load(TelekinesisTests.class).registerTest(player -> ProxyUtils.getProxy(FastGetEnchantsProxy.class).getLevelOnItem(player.getInventory().getItemInMainHand(), EcoEnchants.TELEKINESIS) > 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -40,7 +40,7 @@ public class Cleave extends EcoEnchant {
|
||||
.forEach(entity -> {
|
||||
entity.setMetadata("cleaved", new FixedMetadataValue(this.plugin, true));
|
||||
((LivingEntity) entity).damage(damage, attacker);
|
||||
Bukkit.getScheduler().runTaskLater(this.plugin, () -> entity.removeMetadata("cleaved", this.plugin), 5);
|
||||
this.plugin.getScheduler().runLater(() -> entity.removeMetadata("cleaved", this.plugin), 5);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ public class Disappear extends EcoEnchant {
|
||||
|
||||
@Override
|
||||
public void onDamageWearingArmor(LivingEntity victim, int level, EntityDamageEvent event) {
|
||||
Bukkit.getScheduler().runTaskLater(this.plugin, () -> {
|
||||
this.plugin.getScheduler().runLater(() -> {
|
||||
if(victim.getHealth() > EcoEnchants.DISAPPEAR.getConfig().getInt(EcoEnchants.CONFIG_LOCATION + "threshold"))
|
||||
return;
|
||||
|
||||
|
||||
@@ -46,7 +46,7 @@ public class Frozen extends EcoEnchant {
|
||||
int divisor = this.getConfig().getInt(EcoEnchants.CONFIG_LOCATION + "points-per-level");
|
||||
final int level = (int) Math.ceil((double) points / divisor);
|
||||
|
||||
Bukkit.getScheduler().runTaskLater(this.plugin, () -> {
|
||||
this.plugin.getScheduler().runLater(() -> {
|
||||
victim.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, points * 5, level));
|
||||
victim.addPotionEffect(new PotionEffect(PotionEffectType.SLOW_DIGGING, points * 5, level));
|
||||
}, 1);
|
||||
|
||||
@@ -35,7 +35,7 @@ public class Incandescence extends EcoEnchant {
|
||||
return;
|
||||
if(this.getDisabledWorlds().contains(player.getWorld())) return;
|
||||
|
||||
Bukkit.getScheduler().runTaskLater(this.plugin, () -> {
|
||||
this.plugin.getScheduler().runLater(() -> {
|
||||
victim.setFireTicks(totalIncandescencePoints * this.getConfig().getInt(EcoEnchants.CONFIG_LOCATION + "ticks-per-point") + this.getConfig().getInt(EcoEnchants.CONFIG_LOCATION + "initial-ticks"));
|
||||
}, 1);
|
||||
}
|
||||
|
||||
@@ -4,7 +4,6 @@ import com.willfp.ecoenchants.enchantments.EcoEnchant;
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchants;
|
||||
import com.willfp.ecoenchants.enchantments.meta.EnchantmentType;
|
||||
import com.willfp.ecoenchants.enchantments.util.EnchantChecks;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
@@ -42,6 +41,6 @@ public class Launch extends EcoEnchant {
|
||||
double multiplier = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "multiplier");
|
||||
double boost = 1 + (multiplier * level);
|
||||
|
||||
Bukkit.getScheduler().runTask(this.plugin, () -> player.setVelocity(player.getVelocity().multiply(boost)));
|
||||
this.plugin.getScheduler().run(() -> player.setVelocity(player.getVelocity().multiply(boost)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -55,7 +55,7 @@ public class Lumberjack extends EcoEnchant {
|
||||
|
||||
ProxyUtils.getProxy(BlockBreakProxy.class).breakBlock(player, treeBlock);
|
||||
|
||||
Bukkit.getScheduler().runTaskLater(this.plugin, () -> treeBlock.removeMetadata("block-ignore", this.plugin),1);
|
||||
this.plugin.getScheduler().runLater(() -> treeBlock.removeMetadata("block-ignore", this.plugin),1);
|
||||
}
|
||||
|
||||
AnticheatManager.unexemptPlayer(player);
|
||||
|
||||
@@ -28,7 +28,7 @@ public class Marking extends EcoEnchant {
|
||||
|
||||
victim.setMetadata("marked", new FixedMetadataValue(this.plugin, true));
|
||||
|
||||
Bukkit.getScheduler().runTaskLater(this.plugin, () -> {
|
||||
this.plugin.getScheduler().runLater(() -> {
|
||||
victim.removeMetadata("marked", this.plugin);
|
||||
}, ticks);
|
||||
}
|
||||
|
||||
@@ -60,7 +60,7 @@ public class Shockwave extends EcoEnchant {
|
||||
.forEach((mob -> {
|
||||
((LivingEntity) mob).damage(finalDamage, player);
|
||||
mob.setMetadata("shockwaved", new FixedMetadataValue(this.plugin, true));
|
||||
Bukkit.getScheduler().runTaskLater(this.plugin, () -> {
|
||||
this.plugin.getScheduler().runLater(() -> {
|
||||
mob.removeMetadata("shockwaved", this.plugin);
|
||||
}, 10);
|
||||
}
|
||||
|
||||
@@ -5,7 +5,6 @@ import com.willfp.ecoenchants.enchantments.EcoEnchant;
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchants;
|
||||
import com.willfp.ecoenchants.enchantments.meta.EnchantmentType;
|
||||
import com.willfp.ecoenchants.enchantments.util.EnchantChecks;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.entity.AbstractArrow;
|
||||
import org.bukkit.entity.Arrow;
|
||||
@@ -29,7 +28,7 @@ public class Succession extends EcoEnchant {
|
||||
boolean fire = EnchantChecks.mainhand(shooter, Enchantment.ARROW_FIRE);
|
||||
|
||||
for (int i = 1; i <= number; i++) {
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(this.plugin, () -> {
|
||||
this.plugin.getScheduler().runLater(() -> {
|
||||
Arrow arrow1 = shooter.launchProjectile(Arrow.class, event.getProjectile().getVelocity());
|
||||
arrow1.setPickupStatus(AbstractArrow.PickupStatus.DISALLOWED);
|
||||
if(fire) arrow1.setFireTicks(Integer.MAX_VALUE);
|
||||
|
||||
@@ -24,7 +24,7 @@ public class Tornado extends EcoEnchant {
|
||||
|
||||
Vector toAdd = new Vector(0, yVelocity, 0);
|
||||
|
||||
Bukkit.getScheduler().runTaskLater(this.plugin, () -> {
|
||||
this.plugin.getScheduler().runLater(() -> {
|
||||
victim.setVelocity(victim.getVelocity().clone().add(toAdd));
|
||||
}, 1);
|
||||
}
|
||||
|
||||
@@ -55,7 +55,7 @@ public class Vein extends EcoEnchant {
|
||||
|
||||
ProxyUtils.getProxy(BlockBreakProxy.class).breakBlock(player, veinBlock);
|
||||
|
||||
Bukkit.getScheduler().runTaskLater(this.plugin, () -> veinBlock.removeMetadata("block-ignore", this.plugin), 1);
|
||||
this.plugin.getScheduler().runLater(() -> veinBlock.removeMetadata("block-ignore", this.plugin), 1);
|
||||
}
|
||||
|
||||
AnticheatManager.unexemptPlayer(player);
|
||||
|
||||
@@ -27,7 +27,7 @@ public class Weakening extends EcoEnchant {
|
||||
|
||||
victim.setMetadata("weak", new FixedMetadataValue(this.plugin, true));
|
||||
|
||||
Bukkit.getScheduler().runTaskLater(this.plugin, () -> {
|
||||
this.plugin.getScheduler().runLater(() -> {
|
||||
victim.removeMetadata("weak", this.plugin);
|
||||
}, ticks);
|
||||
}
|
||||
|
||||
@@ -6,7 +6,6 @@ import com.willfp.ecoenchants.enchantments.EcoEnchant;
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchants;
|
||||
import com.willfp.ecoenchants.enchantments.meta.EnchantmentType;
|
||||
import com.willfp.ecoenchants.enchantments.util.EnchantChecks;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.entity.Arrow;
|
||||
import org.bukkit.entity.Enderman;
|
||||
@@ -105,7 +104,7 @@ public class Aiming extends EcoEnchant {
|
||||
checksPerformed.addAndGet(1);
|
||||
if(checksPerformed.get() > checks) this.cancel();
|
||||
if(arrow.isDead() || arrow.isInBlock() || arrow.isOnGround()) this.cancel();
|
||||
Bukkit.getScheduler().runTask(this.plugin, runnable);
|
||||
this.plugin.getScheduler().run(runnable);
|
||||
}
|
||||
}.runTaskTimer(this.plugin, 3, period);
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ public class Carve extends EcoEnchant {
|
||||
.forEach(entity -> {
|
||||
entity.setMetadata("carved", new FixedMetadataValue(this.plugin, true));
|
||||
((LivingEntity) entity).damage(damage, attacker);
|
||||
Bukkit.getScheduler().runTaskLater(this.plugin, () -> entity.removeMetadata("carved", this.plugin), 20);
|
||||
this.plugin.getScheduler().runLater(() -> entity.removeMetadata("carved", this.plugin), 20);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -64,7 +64,7 @@ public class Soulbound extends EcoEnchant {
|
||||
event.getPlayer().getInventory().addItem(itemStack);
|
||||
}));
|
||||
|
||||
Bukkit.getScheduler().runTaskLater(this.plugin, () -> {
|
||||
this.plugin.getScheduler().runLater(() -> {
|
||||
soulboundItemsMap.remove(event.getPlayer());
|
||||
}, 1);
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ public class Ascend extends Spell {
|
||||
int ticks = this.getConfig().getInt(EcoEnchants.CONFIG_LOCATION + "ticks-per-level") * level;
|
||||
player.addPotionEffect(new PotionEffect(PotionEffectType.LEVITATION, ticks, this.getConfig().getInt(EcoEnchants.CONFIG_LOCATION + "power") - 1,false,false));
|
||||
player.setMetadata(IGNORE_FALL_KEY, new FixedMetadataValue(this.plugin, true));
|
||||
Bukkit.getScheduler().runTaskLater(this.plugin, () -> player.removeMetadata(IGNORE_FALL_KEY, this.plugin), ticks * 4L);
|
||||
this.plugin.getScheduler().runLater(() -> player.removeMetadata(IGNORE_FALL_KEY, this.plugin), ticks * 4L);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
|
||||
@@ -53,7 +53,7 @@ public abstract class Spell extends EcoEnchant {
|
||||
|
||||
if (runningSpell.contains(player.getUniqueId())) return;
|
||||
runningSpell.add(player.getUniqueId());
|
||||
Bukkit.getScheduler().runTaskLater(this.plugin, () -> runningSpell.remove(player.getUniqueId()), 5);
|
||||
this.plugin.getScheduler().runLater(() -> runningSpell.remove(player.getUniqueId()), 5);
|
||||
|
||||
if (leftClickItems.contains(player.getInventory().getItemInMainHand().getType())) {
|
||||
if (!(event.getAction().equals(Action.LEFT_CLICK_AIR) || event.getAction().equals(Action.LEFT_CLICK_BLOCK))) {
|
||||
|
||||
@@ -9,7 +9,6 @@ import com.willfp.eco.util.config.Configs;
|
||||
import com.willfp.eco.util.injection.PluginDependent;
|
||||
import com.willfp.eco.util.plugin.AbstractEcoPlugin;
|
||||
import com.willfp.eco.util.tuplets.Pair;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
@@ -69,9 +68,8 @@ public class AnvilListeners extends PluginDependent implements Listener {
|
||||
num += 1;
|
||||
noIncreaseXpMap.put(player.getUniqueId(), num);
|
||||
|
||||
Bukkit.getScheduler().runTaskLater(this.plugin, () -> {
|
||||
noIncreaseXpMap.remove(player.getUniqueId());
|
||||
}, 1);
|
||||
this.plugin.getScheduler().runLater(() -> noIncreaseXpMap.remove(player.getUniqueId()), 1);
|
||||
|
||||
// End pain
|
||||
|
||||
int preCost = event.getInventory().getRepairCost();
|
||||
|
||||
@@ -59,7 +59,7 @@ public class GrindstoneListeners extends PluginDependent implements Listener {
|
||||
|
||||
final ItemStack finalOut = newOut;
|
||||
|
||||
Bukkit.getScheduler().runTask(this.plugin, () -> {
|
||||
this.plugin.getScheduler().run(() -> {
|
||||
inventory.setItem(2, finalOut);
|
||||
});
|
||||
}, 1);
|
||||
|
||||
@@ -51,8 +51,8 @@ public class Alchemy extends EcoEnchant {
|
||||
|
||||
entity.removePotionEffect(effect.getType());
|
||||
|
||||
Bukkit.getScheduler().runTask(this.plugin, () -> newEffect.apply(entity));
|
||||
this.plugin.getScheduler().run(() -> newEffect.apply(entity));
|
||||
|
||||
Bukkit.getScheduler().runTaskLater(this.plugin, () -> entity.removeMetadata(newEffect.toString(), this.plugin), 1);
|
||||
this.plugin.getScheduler().runLater(() -> entity.removeMetadata(newEffect.toString(), this.plugin), 1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ public abstract class EffectsEnchantment extends EcoEnchant {
|
||||
public void onEquip(ArmorEquipEvent event) {
|
||||
final Player player = event.getPlayer();
|
||||
|
||||
Bukkit.getScheduler().runTaskLater(this.plugin, () -> {
|
||||
this.plugin.getScheduler().runLater(() -> {
|
||||
if (player.hasPotionEffect(this.getPotionEffect()) && player.getPotionEffect(this.getPotionEffect()).getDuration() >= 1639) {
|
||||
player.removePotionEffect(this.getPotionEffect());
|
||||
}
|
||||
|
||||
@@ -96,7 +96,7 @@ public class Precision extends EcoEnchant {
|
||||
checksPerformed.addAndGet(1);
|
||||
if(checksPerformed.get() > checks) this.cancel();
|
||||
if(trident.isDead() || trident.isInBlock() || trident.isOnGround()) this.cancel();
|
||||
Bukkit.getScheduler().runTask(this.plugin, runnable);
|
||||
this.plugin.getScheduler().run(runnable);
|
||||
}
|
||||
}.runTaskTimer(this.plugin, 3, period);
|
||||
}
|
||||
|
||||
@@ -84,7 +84,7 @@ public abstract class SummoningEnchantment extends EcoEnchant {
|
||||
entity.setHealth(health);
|
||||
entity.setMetadata("eco-target", new FixedMetadataValue(this.plugin, victim));
|
||||
|
||||
Bukkit.getScheduler().runTaskLater(this.plugin, entity::remove, ticksToLive);
|
||||
this.plugin.getScheduler().runLater(entity::remove, ticksToLive);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -27,8 +27,13 @@ public class EcoScheduler extends PluginDependent implements Scheduler {
|
||||
}
|
||||
|
||||
@Override
|
||||
public BukkitTask run(Callable callable) {
|
||||
return Bukkit.getServer().getScheduler().runTask(this.plugin, callable::call);
|
||||
public BukkitTask run(Runnable runnable) {
|
||||
return Bukkit.getServer().getScheduler().runTask(this.plugin, runnable::run);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BukkitTask runAsync(Callable callable) {
|
||||
return Bukkit.getServer().getScheduler().runTaskAsynchronously(this.plugin, callable::call);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -7,7 +7,8 @@ public interface Scheduler {
|
||||
BukkitTask runLater(Callable callable, long ticksLater);
|
||||
BukkitTask runTimer(Callable callable, long delay, long repeat);
|
||||
BukkitTask runAsyncTimer(Callable callable, long delay, long repeat);
|
||||
BukkitTask run(Callable callable);
|
||||
BukkitTask run(Runnable runnable);
|
||||
BukkitTask runAsync(Callable callable);
|
||||
int syncRepeating(Runnable runnable, long delay, long repeat);
|
||||
void cancelAll();
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.willfp.eco.util.drops.internal;
|
||||
|
||||
import com.willfp.eco.util.plugin.AbstractEcoPlugin;
|
||||
import com.willfp.eco.util.drops.telekinesis.TelekinesisUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
@@ -118,7 +118,7 @@ public class InternalDropQueue implements AbstractDropQueue {
|
||||
* Push the queue
|
||||
*/
|
||||
public void push() {
|
||||
if(!hasTelekinesis) hasTelekinesis = AbstractEcoPlugin.getInstance().getTelekineticTests().testPlayer(player);
|
||||
if(!hasTelekinesis) hasTelekinesis = TelekinesisUtils.testPlayer(player);
|
||||
|
||||
World world = loc.getWorld();
|
||||
assert world != null;
|
||||
|
||||
@@ -8,17 +8,19 @@ import org.bukkit.entity.Player;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
public class TelekineticTests extends PluginDependent {
|
||||
public class EcoTelekinesisTests extends PluginDependent implements TelekinesisTests {
|
||||
private final Set<ObjectBiCallable<Boolean, Player>> tests = new HashSet<>();
|
||||
|
||||
public TelekineticTests(AbstractEcoPlugin plugin) {
|
||||
public EcoTelekinesisTests(AbstractEcoPlugin plugin) {
|
||||
super(plugin);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerTest(ObjectBiCallable<Boolean, Player> test) {
|
||||
tests.add(test);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean testPlayer(Player player) {
|
||||
for (ObjectBiCallable<Boolean, Player> test : tests) {
|
||||
if(test.call(player)) return true;
|
||||
@@ -0,0 +1,9 @@
|
||||
package com.willfp.eco.util.drops.telekinesis;
|
||||
|
||||
import com.willfp.eco.util.lambda.ObjectBiCallable;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public interface TelekinesisTests {
|
||||
void registerTest(ObjectBiCallable<Boolean, Player> test);
|
||||
boolean testPlayer(Player player);
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.willfp.eco.util.drops.telekinesis;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class TelekinesisUtils {
|
||||
private static TelekinesisTests tests = Bukkit.getServicesManager().load(TelekinesisTests.class);
|
||||
|
||||
public static boolean testPlayer(Player player) {
|
||||
return tests.testPlayer(player);
|
||||
}
|
||||
|
||||
public static void update() {
|
||||
tests = Bukkit.getServicesManager().load(TelekinesisTests.class);
|
||||
}
|
||||
}
|
||||
@@ -13,7 +13,9 @@ import com.willfp.eco.util.command.AbstractCommand;
|
||||
import com.willfp.eco.util.config.Configs;
|
||||
import com.willfp.eco.util.drops.internal.DropManager;
|
||||
import com.willfp.eco.util.drops.internal.FastCollatedDropQueue;
|
||||
import com.willfp.eco.util.drops.telekinesis.TelekineticTests;
|
||||
import com.willfp.eco.util.drops.telekinesis.EcoTelekinesisTests;
|
||||
import com.willfp.eco.util.drops.telekinesis.TelekinesisTests;
|
||||
import com.willfp.eco.util.drops.telekinesis.TelekinesisUtils;
|
||||
import com.willfp.eco.util.events.armorequip.ArmorListener;
|
||||
import com.willfp.eco.util.events.armorequip.DispenserArmorListener;
|
||||
import com.willfp.eco.util.events.entitydeathbyentity.EntityDeathByEntityListeners;
|
||||
@@ -43,6 +45,7 @@ import org.bstats.bukkit.Metrics;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.plugin.ServicePriority;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -67,7 +70,6 @@ public abstract class AbstractEcoPlugin extends JavaPlugin {
|
||||
private final NamespacedKeyFactory namespacedKeyFactory;
|
||||
private final MetadataValueFactory metadataValueFactory;
|
||||
private final ExtensionLoader extensionLoader;
|
||||
private final TelekineticTests telekineticTests;
|
||||
|
||||
protected boolean outdated = false;
|
||||
|
||||
@@ -82,7 +84,12 @@ public abstract class AbstractEcoPlugin extends JavaPlugin {
|
||||
this.namespacedKeyFactory = new NamespacedKeyFactory(this);
|
||||
this.metadataValueFactory = new MetadataValueFactory(this);
|
||||
this.extensionLoader = new EcoExtensionLoader(this);
|
||||
this.telekineticTests = new TelekineticTests(this);
|
||||
|
||||
if (!Bukkit.getServicesManager().isProvidedFor(TelekinesisTests.class)) {
|
||||
Bukkit.getServicesManager().register(TelekinesisTests.class, new EcoTelekinesisTests(this), this, ServicePriority.Normal);
|
||||
}
|
||||
|
||||
TelekinesisUtils.update();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -239,10 +246,6 @@ public abstract class AbstractEcoPlugin extends JavaPlugin {
|
||||
|
||||
public abstract List<Listener> getListeners();
|
||||
|
||||
public final TelekineticTests getTelekineticTests() {
|
||||
return telekineticTests;
|
||||
}
|
||||
|
||||
public final Logger getLog() {
|
||||
return log;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package com.willfp.eco.util.updater;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import com.willfp.eco.util.plugin.AbstractEcoPlugin;
|
||||
import org.bukkit.util.Consumer;
|
||||
|
||||
import java.io.IOException;
|
||||
@@ -13,7 +12,7 @@ import java.util.Scanner;
|
||||
* Checks spigot if a plugin is out of date
|
||||
*/
|
||||
public class UpdateChecker {
|
||||
private final Plugin plugin;
|
||||
private final AbstractEcoPlugin plugin;
|
||||
private final int resourceId;
|
||||
|
||||
/**
|
||||
@@ -22,7 +21,7 @@ public class UpdateChecker {
|
||||
* @param plugin The plugin to check
|
||||
* @param resourceId The resource ID of the plugin
|
||||
*/
|
||||
public UpdateChecker(Plugin plugin, int resourceId) {
|
||||
public UpdateChecker(AbstractEcoPlugin plugin, int resourceId) {
|
||||
this.plugin = plugin;
|
||||
this.resourceId = resourceId;
|
||||
}
|
||||
@@ -33,7 +32,7 @@ public class UpdateChecker {
|
||||
* @param consumer The process to run after checking
|
||||
*/
|
||||
public void getVersion(final Consumer<? super String> consumer) {
|
||||
Bukkit.getScheduler().runTaskAsynchronously(this.plugin, () -> {
|
||||
this.plugin.getScheduler().runAsync(() -> {
|
||||
try (InputStream inputStream = new URL("https://api.spigotmc.org/legacy/update.php?resource=" + this.resourceId).openStream(); Scanner scanner = new Scanner(inputStream)) {
|
||||
if (scanner.hasNext()) {
|
||||
consumer.accept(scanner.next());
|
||||
|
||||
Reference in New Issue
Block a user