mirror of
https://github.com/StarWishsama/Slimefun4.git
synced 2024-09-20 11:45:51 +00:00
Armor Task is now asynchronous
This commit is contained in:
parent
9ac4e7eeea
commit
2e77d306e2
@ -45,14 +45,16 @@ public class ArmorTask implements Runnable {
|
||||
}
|
||||
|
||||
if (item != null && armorpiece.getItem().isPresent()) {
|
||||
for (PotionEffect effect: armorpiece.getItem().get().getEffects()) {
|
||||
p.removePotionEffect(effect.getType());
|
||||
p.addPotionEffect(effect);
|
||||
}
|
||||
Bukkit.getScheduler().runTask(SlimefunPlugin.instance, () -> {
|
||||
for (PotionEffect effect: armorpiece.getItem().get().getEffects()) {
|
||||
p.removePotionEffect(effect.getType());
|
||||
p.addPotionEffect(effect);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if (SlimefunManager.isItemSimiliar(p.getInventory().getHelmet(), SlimefunItems.SOLAR_HELMET, false) && Slimefun.hasUnlocked(p, SlimefunItem.getByID("SOLAR_HELMET"), true) && (p.getWorld().getTime() < 12300 || p.getWorld().getTime() > 23850 && p.getEyeLocation().getBlock().getLightFromSky() == 15)) {
|
||||
if (SlimefunManager.isItemSimiliar(p.getInventory().getHelmet(), SlimefunItems.SOLAR_HELMET, true) && Slimefun.hasUnlocked(p, SlimefunItem.getByID("SOLAR_HELMET"), true) && (p.getWorld().getTime() < 12300 || p.getWorld().getTime() > 23850 && p.getEyeLocation().getBlock().getLightFromSky() == 15)) {
|
||||
ItemEnergy.chargeInventory(p, Float.valueOf(String.valueOf(Slimefun.getItemValue("SOLAR_HELMET", "charge-amount"))));
|
||||
}
|
||||
|
||||
@ -69,15 +71,17 @@ public class ArmorTask implements Runnable {
|
||||
|
||||
// If the item is enabled in the world, then make radioactivity do its job
|
||||
if (Slimefun.isEnabled(p, radioactive, false)) {
|
||||
p.addPotionEffect(new PotionEffect(PotionEffectType.WITHER, 400, 3));
|
||||
p.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, 400, 3));
|
||||
p.addPotionEffect(new PotionEffect(PotionEffectType.CONFUSION, 400, 3));
|
||||
p.addPotionEffect(new PotionEffect(PotionEffectType.WEAKNESS, 400, 3));
|
||||
p.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, 400, 1));
|
||||
p.addPotionEffect(new PotionEffect(PotionEffectType.SLOW_DIGGING, 400, 1));
|
||||
p.setFireTicks(400);
|
||||
break;
|
||||
// Break the loop to save some calculations
|
||||
Bukkit.getScheduler().runTask(SlimefunPlugin.instance, () -> {
|
||||
p.addPotionEffect(new PotionEffect(PotionEffectType.WITHER, 400, 3));
|
||||
p.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, 400, 3));
|
||||
p.addPotionEffect(new PotionEffect(PotionEffectType.CONFUSION, 400, 3));
|
||||
p.addPotionEffect(new PotionEffect(PotionEffectType.WEAKNESS, 400, 3));
|
||||
p.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, 400, 1));
|
||||
p.addPotionEffect(new PotionEffect(PotionEffectType.SLOW_DIGGING, 400, 1));
|
||||
p.setFireTicks(400);
|
||||
});
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -264,7 +264,7 @@ public final class SlimefunPlugin extends JavaPlugin {
|
||||
|
||||
// Armor Update Task
|
||||
if (config.getBoolean("options.enable-armor-effects")) {
|
||||
getServer().getScheduler().runTaskTimer(this, new ArmorTask(), 0L, config.getInt("options.armor-update-interval") * 20L);
|
||||
getServer().getScheduler().runTaskTimerAsynchronously(this, new ArmorTask(), 0L, config.getInt("options.armor-update-interval") * 20L);
|
||||
}
|
||||
|
||||
ticker = new TickerTask();
|
||||
|
Loading…
Reference in New Issue
Block a user