mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-07-03 00:17:15 +00:00
get iris to load on folia, but it will not load worlds as this is currently not possible
This commit is contained in:
parent
ba6fac5422
commit
35b879f0df
@ -2,6 +2,7 @@ import com.volmit.nmstools.NMSToolsExtension
|
|||||||
import com.volmit.nmstools.NMSToolsPlugin
|
import com.volmit.nmstools.NMSToolsPlugin
|
||||||
import de.undercouch.gradle.tasks.download.Download
|
import de.undercouch.gradle.tasks.download.Download
|
||||||
import xyz.jpenilla.runpaper.task.RunServer
|
import xyz.jpenilla.runpaper.task.RunServer
|
||||||
|
import xyz.jpenilla.runtask.service.DownloadsAPIService
|
||||||
import kotlin.system.exitProcess
|
import kotlin.system.exitProcess
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -104,6 +105,20 @@ nmsBindings.forEach { key, value ->
|
|||||||
systemProperty("net.kyori.ansi.colorLevel", color)
|
systemProperty("net.kyori.ansi.colorLevel", color)
|
||||||
systemProperty("com.mojang.eula.agree", true)
|
systemProperty("com.mojang.eula.agree", true)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tasks.register<RunServer>("runFolia-$key") {
|
||||||
|
group = "servers"
|
||||||
|
downloadsApiService = DownloadsAPIService.folia(project)
|
||||||
|
minecraftVersion(value.split("-")[0])
|
||||||
|
minHeapSize = serverMinHeap
|
||||||
|
maxHeapSize = serverMaxHeap
|
||||||
|
pluginJars(tasks.jar.flatMap { it.archiveFile })
|
||||||
|
javaLauncher = javaToolchains.launcherFor { languageVersion = JavaLanguageVersion.of(jvmVersion.getOrDefault(key, 21))}
|
||||||
|
runDirectory.convention(layout.buildDirectory.dir("run/$key"))
|
||||||
|
systemProperty("disable.watchdog", "")
|
||||||
|
systemProperty("net.kyori.ansi.colorLevel", color)
|
||||||
|
systemProperty("com.mojang.eula.agree", true)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks {
|
tasks {
|
||||||
|
@ -63,6 +63,7 @@ import com.volmit.iris.util.plugin.VolmitPlugin;
|
|||||||
import com.volmit.iris.util.plugin.VolmitSender;
|
import com.volmit.iris.util.plugin.VolmitSender;
|
||||||
import com.volmit.iris.util.reflect.ShadeFix;
|
import com.volmit.iris.util.reflect.ShadeFix;
|
||||||
import com.volmit.iris.util.scheduling.J;
|
import com.volmit.iris.util.scheduling.J;
|
||||||
|
import com.volmit.iris.util.scheduling.Platform;
|
||||||
import com.volmit.iris.util.scheduling.Queue;
|
import com.volmit.iris.util.scheduling.Queue;
|
||||||
import com.volmit.iris.util.scheduling.ShurikenQueue;
|
import com.volmit.iris.util.scheduling.ShurikenQueue;
|
||||||
import com.volmit.iris.util.sentry.Attachments;
|
import com.volmit.iris.util.sentry.Attachments;
|
||||||
@ -98,6 +99,7 @@ import java.math.RoundingMode;
|
|||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.text.NumberFormat;
|
import java.text.NumberFormat;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
@ -115,6 +117,7 @@ public class Iris extends VolmitPlugin implements Listener {
|
|||||||
public static MythicMobsLink linkMythicMobs;
|
public static MythicMobsLink linkMythicMobs;
|
||||||
public static IrisCompat compat;
|
public static IrisCompat compat;
|
||||||
public static FileWatcher configWatcher;
|
public static FileWatcher configWatcher;
|
||||||
|
public static Platform scheduler;
|
||||||
private static VolmitSender sender;
|
private static VolmitSender sender;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
@ -333,15 +336,14 @@ public class Iris extends VolmitPlugin implements Listener {
|
|||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
public static void later(NastyRunnable object) {
|
public static void later(NastyRunnable object) {
|
||||||
try {
|
try {
|
||||||
Bukkit.getScheduler().scheduleAsyncDelayedTask(instance, () ->
|
scheduler.async().runDelayed(task -> {
|
||||||
{
|
|
||||||
try {
|
try {
|
||||||
object.run();
|
object.run();
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
Iris.reportError(e);
|
Iris.reportError(e);
|
||||||
}
|
}
|
||||||
}, RNG.r.i(100, 1200));
|
}, RNG.r.i(5, 60), TimeUnit.SECONDS);
|
||||||
} catch (IllegalPluginAccessException ignored) {
|
} catch (IllegalPluginAccessException ignored) {
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -459,6 +461,7 @@ public class Iris extends VolmitPlugin implements Listener {
|
|||||||
}
|
}
|
||||||
private void enable() {
|
private void enable() {
|
||||||
instance = this;
|
instance = this;
|
||||||
|
scheduler = Platform.create(this);
|
||||||
services = new KMap<>();
|
services = new KMap<>();
|
||||||
setupAudience();
|
setupAudience();
|
||||||
setupSentry();
|
setupSentry();
|
||||||
@ -580,7 +583,6 @@ public class Iris extends VolmitPlugin implements Listener {
|
|||||||
|
|
||||||
public void onDisable() {
|
public void onDisable() {
|
||||||
services.values().forEach(IrisService::onDisable);
|
services.values().forEach(IrisService::onDisable);
|
||||||
Bukkit.getScheduler().cancelTasks(this);
|
|
||||||
HandlerList.unregisterAll((Plugin) this);
|
HandlerList.unregisterAll((Plugin) this);
|
||||||
postShutdown.forEach(Runnable::run);
|
postShutdown.forEach(Runnable::run);
|
||||||
super.onDisable();
|
super.onDisable();
|
||||||
|
@ -49,7 +49,6 @@ import org.bukkit.configuration.file.FileConfiguration;
|
|||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.generator.ChunkGenerator;
|
import org.bukkit.generator.ChunkGenerator;
|
||||||
import org.bukkit.scheduler.BukkitRunnable;
|
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@ -157,13 +156,8 @@ public class CommandIris implements DecreeExecutor {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
new BukkitRunnable() {
|
Iris.scheduler.teleportAsync(target, world.getSpawnLocation()).thenRun(() ->
|
||||||
@Override
|
new VolmitSender(target).sendMessage(C.GREEN + "You have been teleported to " + world.getName() + "."));
|
||||||
public void run() {
|
|
||||||
target.teleport(world.getSpawnLocation());
|
|
||||||
new VolmitSender(target).sendMessage(C.GREEN + "You have been teleported to " + world.getName() + ".");
|
|
||||||
}
|
|
||||||
}.runTask(Iris.instance);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Decree(description = "Print version information")
|
@Decree(description = "Print version information")
|
||||||
|
@ -55,11 +55,11 @@ import com.volmit.iris.util.parallel.BurstExecutor;
|
|||||||
import com.volmit.iris.util.parallel.MultiBurst;
|
import com.volmit.iris.util.parallel.MultiBurst;
|
||||||
import com.volmit.iris.util.plugin.VolmitSender;
|
import com.volmit.iris.util.plugin.VolmitSender;
|
||||||
import com.volmit.iris.util.scheduling.J;
|
import com.volmit.iris.util.scheduling.J;
|
||||||
import com.volmit.iris.util.scheduling.O;
|
|
||||||
import com.volmit.iris.util.scheduling.PrecisionStopwatch;
|
import com.volmit.iris.util.scheduling.PrecisionStopwatch;
|
||||||
import com.volmit.iris.util.scheduling.jobs.QueueJob;
|
import com.volmit.iris.util.scheduling.jobs.QueueJob;
|
||||||
import io.papermc.lib.PaperLib;
|
import io.papermc.lib.PaperLib;
|
||||||
import org.bukkit.*;
|
import org.bukkit.*;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.inventory.InventoryType;
|
import org.bukkit.event.inventory.InventoryType;
|
||||||
import org.bukkit.inventory.Inventory;
|
import org.bukkit.inventory.Inventory;
|
||||||
import org.bukkit.util.BlockVector;
|
import org.bukkit.util.BlockVector;
|
||||||
@ -309,27 +309,25 @@ public class CommandStudio implements DecreeExecutor {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Player player = player();
|
||||||
|
var scheduler = Iris.scheduler.entity(player);
|
||||||
|
scheduler.run(() -> {
|
||||||
|
sender().sendMessage(C.GREEN + "Opening inventory now!");
|
||||||
|
player.openInventory(inv);
|
||||||
|
|
||||||
O<Integer> ta = new O<>();
|
scheduler.runAtFixedRate(refresh -> {
|
||||||
ta.set(-1);
|
if (!player.getOpenInventory().getType().equals(InventoryType.CHEST)) {
|
||||||
|
refresh.cancel();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
ta.set(Bukkit.getScheduler().scheduleSyncRepeatingTask(Iris.instance, () ->
|
if (!add) {
|
||||||
{
|
inv.clear();
|
||||||
if (!player().getOpenInventory().getType().equals(InventoryType.CHEST)) {
|
}
|
||||||
Bukkit.getScheduler().cancelTask(ta.get());
|
|
||||||
sender().sendMessage(C.GREEN + "Opened inventory!");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!add) {
|
engine().addItems(true, inv, new RNG(RNG.r.imax()), tables, InventorySlotType.STORAGE, player.getWorld(), player.getLocation().getBlockX(), player.getLocation().getBlockY(), player.getLocation().getBlockZ(), 1);
|
||||||
inv.clear();
|
}, null, 1, fast ? 5 : 35);
|
||||||
}
|
}, null);
|
||||||
|
|
||||||
engine().addItems(true, inv, new RNG(RNG.r.imax()), tables, InventorySlotType.STORAGE, player().getWorld(), player().getLocation().getBlockX(), player().getLocation().getBlockY(), player().getLocation().getBlockZ(), 1);
|
|
||||||
}, 0, fast ? 5 : 35));
|
|
||||||
|
|
||||||
sender().sendMessage(C.GREEN + "Opening inventory now!");
|
|
||||||
player().openInventory(inv);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -350,9 +348,7 @@ public class CommandStudio implements DecreeExecutor {
|
|||||||
var loc = player().getLocation();
|
var loc = player().getLocation();
|
||||||
int totalTasks = d * d;
|
int totalTasks = d * d;
|
||||||
AtomicInteger completedTasks = new AtomicInteger(0);
|
AtomicInteger completedTasks = new AtomicInteger(0);
|
||||||
int c = J.ar(() -> {
|
var c = J.ar(() -> sender.sendProgress((double) completedTasks.get() / totalTasks, "Finding structures"), 0);
|
||||||
sender.sendProgress((double) completedTasks.get() / totalTasks, "Finding structures");
|
|
||||||
}, 0);
|
|
||||||
|
|
||||||
new Spiraler(d, d, (x, z) -> executor.queue(() -> {
|
new Spiraler(d, d, (x, z) -> executor.queue(() -> {
|
||||||
var struct = engine.getStructureAt(x, z);
|
var struct = engine.getStructureAt(x, z);
|
||||||
@ -364,7 +360,7 @@ public class CommandStudio implements DecreeExecutor {
|
|||||||
|
|
||||||
executor.complete();
|
executor.complete();
|
||||||
multiBurst.close();
|
multiBurst.close();
|
||||||
J.car(c);
|
if (c != null) c.cancel();
|
||||||
|
|
||||||
for (var key : data.keySet()) {
|
for (var key : data.keySet()) {
|
||||||
var list = data.get(key);
|
var list = data.get(key);
|
||||||
|
@ -18,7 +18,9 @@
|
|||||||
|
|
||||||
package com.volmit.iris.core.edit;
|
package com.volmit.iris.core.edit;
|
||||||
|
|
||||||
|
import com.volmit.iris.Iris;
|
||||||
import com.volmit.iris.util.parallel.MultiBurst;
|
import com.volmit.iris.util.parallel.MultiBurst;
|
||||||
|
import com.volmit.iris.util.scheduling.AR;
|
||||||
import com.volmit.iris.util.scheduling.J;
|
import com.volmit.iris.util.scheduling.J;
|
||||||
import com.volmit.iris.util.scheduling.SR;
|
import com.volmit.iris.util.scheduling.SR;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
@ -79,7 +81,7 @@ public class BlockSignal {
|
|||||||
e.setTicksLived(1);
|
e.setTicksLived(1);
|
||||||
e.setVelocity(new Vector(0, 0, 0));
|
e.setVelocity(new Vector(0, 0, 0));
|
||||||
|
|
||||||
new SR(20) {
|
new AR(20) {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
if (e.isDead()) {
|
if (e.isDead()) {
|
||||||
@ -87,9 +89,10 @@ public class BlockSignal {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
e.setTicksLived(1);
|
Iris.scheduler.teleportAsync(e, tg.clone()).thenAccept(b -> {
|
||||||
e.teleport(tg.clone());
|
e.setTicksLived(1);
|
||||||
e.setVelocity(new Vector(0, 0, 0));
|
e.setVelocity(new Vector(0, 0, 0));
|
||||||
|
}).join();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -30,6 +30,7 @@ import com.volmit.iris.util.json.JSONObject;
|
|||||||
import com.volmit.iris.util.math.RNG;
|
import com.volmit.iris.util.math.RNG;
|
||||||
import com.volmit.iris.util.scheduling.ChronoLatch;
|
import com.volmit.iris.util.scheduling.ChronoLatch;
|
||||||
import com.volmit.iris.util.scheduling.J;
|
import com.volmit.iris.util.scheduling.J;
|
||||||
|
import com.volmit.iris.util.scheduling.Task;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.Particle;
|
import org.bukkit.Particle;
|
||||||
@ -55,7 +56,7 @@ public class JigsawEditor implements Listener {
|
|||||||
private final IrisJigsawPiece piece;
|
private final IrisJigsawPiece piece;
|
||||||
private final Location origin;
|
private final Location origin;
|
||||||
private final Cuboid cuboid;
|
private final Cuboid cuboid;
|
||||||
private final int ticker;
|
private final Task ticker;
|
||||||
private final KMap<IrisPosition, Runnable> falling = new KMap<>();
|
private final KMap<IrisPosition, Runnable> falling = new KMap<>();
|
||||||
private final ChronoLatch cl = new ChronoLatch(100);
|
private final ChronoLatch cl = new ChronoLatch(100);
|
||||||
private Location target;
|
private Location target;
|
||||||
@ -197,7 +198,7 @@ public class JigsawEditor implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void exit() {
|
public void exit() {
|
||||||
J.car(ticker);
|
if (ticker != null) ticker.cancel();
|
||||||
Iris.instance.unregisterListener(this);
|
Iris.instance.unregisterListener(this);
|
||||||
try {
|
try {
|
||||||
J.sfut(() -> {
|
J.sfut(() -> {
|
||||||
|
@ -22,7 +22,6 @@ import org.bukkit.World;
|
|||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.world.WorldUnloadEvent;
|
import org.bukkit.event.world.WorldUnloadEvent;
|
||||||
import org.bukkit.scheduler.BukkitRunnable;
|
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileWriter;
|
import java.io.FileWriter;
|
||||||
@ -235,16 +234,13 @@ public class DeepSearchPregenerator extends Thread implements Listener {
|
|||||||
}
|
}
|
||||||
save();
|
save();
|
||||||
jobs.remove(world.getName());
|
jobs.remove(world.getName());
|
||||||
new BukkitRunnable() {
|
J.a(() -> {
|
||||||
@Override
|
while (deepFile.exists()) {
|
||||||
public void run() {
|
deepFile.delete();
|
||||||
while (deepFile.exists()){
|
J.sleep(1000);
|
||||||
deepFile.delete();
|
|
||||||
J.sleep(1000);
|
|
||||||
}
|
|
||||||
Iris.info("DeepSearch: " + C.IRIS + world.getName() + C.BLUE + " File deleted and instance closed.");
|
|
||||||
}
|
}
|
||||||
}.runTaskLater(Iris.instance, 20L);
|
Iris.info("DeepSearch: " + C.IRIS + world.getName() + C.BLUE + " File deleted and instance closed.");
|
||||||
|
}, 10);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Iris.error("Failed to shutdown DeepSearch for " + world.getName());
|
Iris.error("Failed to shutdown DeepSearch for " + world.getName());
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
@ -19,7 +19,6 @@ import org.bukkit.World;
|
|||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.world.WorldUnloadEvent;
|
import org.bukkit.event.world.WorldUnloadEvent;
|
||||||
import org.bukkit.scheduler.BukkitRunnable;
|
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@ -238,16 +237,13 @@ public class LazyPregenerator extends Thread implements Listener {
|
|||||||
}
|
}
|
||||||
save();
|
save();
|
||||||
jobs.remove(world.getName());
|
jobs.remove(world.getName());
|
||||||
new BukkitRunnable() {
|
J.a(() -> {
|
||||||
@Override
|
while (lazyFile.exists()){
|
||||||
public void run() {
|
lazyFile.delete();
|
||||||
while (lazyFile.exists()){
|
J.sleep(1000);
|
||||||
lazyFile.delete();
|
|
||||||
J.sleep(1000);
|
|
||||||
}
|
|
||||||
Iris.info("LazyGen: " + C.IRIS + world.getName() + C.BLUE + " File deleted and instance closed.");
|
|
||||||
}
|
}
|
||||||
}.runTaskLater(Iris.instance, 20L);
|
Iris.info("LazyGen: " + C.IRIS + world.getName() + C.BLUE + " File deleted and instance closed.");
|
||||||
|
}, 20);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Iris.error("Failed to shutdown Lazygen for " + world.getName());
|
Iris.error("Failed to shutdown Lazygen for " + world.getName());
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
@ -26,7 +26,6 @@ import org.bukkit.World;
|
|||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.world.WorldUnloadEvent;
|
import org.bukkit.event.world.WorldUnloadEvent;
|
||||||
import org.bukkit.scheduler.BukkitRunnable;
|
|
||||||
import org.checkerframework.checker.units.qual.N;
|
import org.checkerframework.checker.units.qual.N;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
@ -302,16 +301,13 @@ public class TurboPregenerator extends Thread implements Listener {
|
|||||||
}
|
}
|
||||||
save();
|
save();
|
||||||
jobs.remove(world.getName());
|
jobs.remove(world.getName());
|
||||||
new BukkitRunnable() {
|
J.a(() -> {
|
||||||
@Override
|
while (turboFile.exists()) {
|
||||||
public void run() {
|
turboFile.delete();
|
||||||
while (turboFile.exists()) {
|
J.sleep(1000);
|
||||||
turboFile.delete();
|
|
||||||
J.sleep(1000);
|
|
||||||
}
|
|
||||||
Iris.info("turboGen: " + C.IRIS + world.getName() + C.BLUE + " File deleted and instance closed.");
|
|
||||||
}
|
}
|
||||||
}.runTaskLater(Iris.instance, 20L);
|
Iris.info("turboGen: " + C.IRIS + world.getName() + C.BLUE + " File deleted and instance closed.");
|
||||||
|
}, 20);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Iris.error("Failed to shutdown turbogen for " + world.getName());
|
Iris.error("Failed to shutdown turbogen for " + world.getName());
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
@ -38,7 +38,7 @@ public class EditSVC implements IrisService {
|
|||||||
@Override
|
@Override
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
this.editors = new KMap<>();
|
this.editors = new KMap<>();
|
||||||
Bukkit.getScheduler().scheduleSyncRepeatingTask(Iris.instance, this::update, 1000, 1000);
|
Iris.scheduler.global().runAtFixedRate(this::update, 1000, 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -71,21 +71,18 @@ public class ObjectSVC implements IrisService {
|
|||||||
*/
|
*/
|
||||||
private void revert(Map<Block, BlockData> blocks) {
|
private void revert(Map<Block, BlockData> blocks) {
|
||||||
Iterator<Map.Entry<Block, BlockData>> it = blocks.entrySet().iterator();
|
Iterator<Map.Entry<Block, BlockData>> it = blocks.entrySet().iterator();
|
||||||
Bukkit.getScheduler().runTask(Iris.instance, () -> {
|
var scheduler = Iris.scheduler.region();
|
||||||
int amount = 0;
|
for (int i = 0; i < 200 && it.hasNext(); i++) {
|
||||||
while (it.hasNext()) {
|
Map.Entry<Block, BlockData> entry = it.next();
|
||||||
Map.Entry<Block, BlockData> entry = it.next();
|
Block block = entry.getKey();
|
||||||
BlockData data = entry.getValue();
|
BlockData data = entry.getValue();
|
||||||
entry.getKey().setBlockData(data, false);
|
it.remove();
|
||||||
|
|
||||||
it.remove();
|
scheduler.run(block.getLocation(), () -> block.setBlockData(data, false));
|
||||||
|
}
|
||||||
|
|
||||||
amount++;
|
if (it.hasNext()) {
|
||||||
|
J.s(() -> revert(blocks), 1);
|
||||||
if (amount > 200) {
|
}
|
||||||
J.s(() -> revert(blocks), 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -11,6 +11,7 @@ import com.volmit.iris.util.plugin.VolmitSender;
|
|||||||
import com.volmit.iris.util.reflect.V;
|
import com.volmit.iris.util.reflect.V;
|
||||||
import com.volmit.iris.util.scheduling.J;
|
import com.volmit.iris.util.scheduling.J;
|
||||||
import com.volmit.iris.util.scheduling.PrecisionStopwatch;
|
import com.volmit.iris.util.scheduling.PrecisionStopwatch;
|
||||||
|
import com.volmit.iris.util.scheduling.Task;
|
||||||
import it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap;
|
import it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap;
|
||||||
import org.apache.commons.io.FileUtils;
|
import org.apache.commons.io.FileUtils;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
@ -58,7 +59,7 @@ public class IrisConverter {
|
|||||||
int objW = ((ShortTag) compound.get("Width")).getValue();
|
int objW = ((ShortTag) compound.get("Width")).getValue();
|
||||||
int objH = ((ShortTag) compound.get("Height")).getValue();
|
int objH = ((ShortTag) compound.get("Height")).getValue();
|
||||||
int objD = ((ShortTag) compound.get("Length")).getValue();
|
int objD = ((ShortTag) compound.get("Length")).getValue();
|
||||||
int i = -1;
|
Task i = null;
|
||||||
int mv = objW * objH * objD;
|
int mv = objW * objH * objD;
|
||||||
AtomicInteger v = new AtomicInteger(0);
|
AtomicInteger v = new AtomicInteger(0);
|
||||||
if (mv > 500_000) {
|
if (mv > 500_000) {
|
||||||
@ -66,9 +67,7 @@ public class IrisConverter {
|
|||||||
Iris.info(C.GRAY + "Converting.. "+ schem.getName() + " -> " + schem.getName().replace(".schem", ".iob"));
|
Iris.info(C.GRAY + "Converting.. "+ schem.getName() + " -> " + schem.getName().replace(".schem", ".iob"));
|
||||||
Iris.info(C.GRAY + "- It may take a while");
|
Iris.info(C.GRAY + "- It may take a while");
|
||||||
if (sender.isPlayer()) {
|
if (sender.isPlayer()) {
|
||||||
i = J.ar(() -> {
|
i = J.ar(() -> sender.sendProgress((double) v.get() / mv, "Converting"), 0);
|
||||||
sender.sendProgress((double) v.get() / mv, "Converting");
|
|
||||||
}, 0);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -97,7 +96,7 @@ public class IrisConverter {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (i != -1) J.car(i);
|
if (i != null) i.cancel();
|
||||||
try {
|
try {
|
||||||
object.shrinkwrap();
|
object.shrinkwrap();
|
||||||
object.write(new File(folder, schem.getName().replace(".schem", ".iob")));
|
object.write(new File(folder, schem.getName().replace(".schem", ".iob")));
|
||||||
|
@ -50,6 +50,7 @@ import com.volmit.iris.util.matter.MatterStructurePOI;
|
|||||||
import com.volmit.iris.util.scheduling.ChronoLatch;
|
import com.volmit.iris.util.scheduling.ChronoLatch;
|
||||||
import com.volmit.iris.util.scheduling.J;
|
import com.volmit.iris.util.scheduling.J;
|
||||||
import com.volmit.iris.util.scheduling.PrecisionStopwatch;
|
import com.volmit.iris.util.scheduling.PrecisionStopwatch;
|
||||||
|
import com.volmit.iris.util.scheduling.Task;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
import lombok.ToString;
|
import lombok.ToString;
|
||||||
@ -85,7 +86,7 @@ public class IrisEngine implements Engine {
|
|||||||
private final EngineMetrics metrics;
|
private final EngineMetrics metrics;
|
||||||
private final boolean studio;
|
private final boolean studio;
|
||||||
private final AtomicRollingSequence wallClock;
|
private final AtomicRollingSequence wallClock;
|
||||||
private final int art;
|
private final Task art;
|
||||||
private final AtomicCache<IrisEngineData> engineData = new AtomicCache<>();
|
private final AtomicCache<IrisEngineData> engineData = new AtomicCache<>();
|
||||||
private final AtomicBoolean cleaning;
|
private final AtomicBoolean cleaning;
|
||||||
private final ChronoLatch cleanLatch;
|
private final ChronoLatch cleanLatch;
|
||||||
@ -418,7 +419,7 @@ public class IrisEngine implements Engine {
|
|||||||
public void close() {
|
public void close() {
|
||||||
PregeneratorJob.shutdownInstance();
|
PregeneratorJob.shutdownInstance();
|
||||||
closed = true;
|
closed = true;
|
||||||
J.car(art);
|
art.cancel();
|
||||||
getWorldManager().close();
|
getWorldManager().close();
|
||||||
getTarget().close();
|
getTarget().close();
|
||||||
saveEngineData();
|
saveEngineData();
|
||||||
|
@ -24,6 +24,7 @@ import com.volmit.iris.util.collection.KList;
|
|||||||
import com.volmit.iris.util.format.C;
|
import com.volmit.iris.util.format.C;
|
||||||
import com.volmit.iris.util.math.Position2;
|
import com.volmit.iris.util.math.Position2;
|
||||||
import com.volmit.iris.util.plugin.VolmitSender;
|
import com.volmit.iris.util.plugin.VolmitSender;
|
||||||
|
import com.volmit.iris.util.scheduling.Task;
|
||||||
import org.bukkit.*;
|
import org.bukkit.*;
|
||||||
import org.bukkit.entity.EnderSignal;
|
import org.bukkit.entity.EnderSignal;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -41,18 +42,18 @@ import org.bukkit.inventory.EquipmentSlot;
|
|||||||
import java.util.concurrent.atomic.AtomicBoolean;
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
|
|
||||||
public abstract class EngineAssignedWorldManager extends EngineAssignedComponent implements EngineWorldManager, Listener {
|
public abstract class EngineAssignedWorldManager extends EngineAssignedComponent implements EngineWorldManager, Listener {
|
||||||
private final int taskId;
|
private final Task task;
|
||||||
protected AtomicBoolean ignoreTP = new AtomicBoolean(false);
|
protected AtomicBoolean ignoreTP = new AtomicBoolean(false);
|
||||||
|
|
||||||
public EngineAssignedWorldManager() {
|
public EngineAssignedWorldManager() {
|
||||||
super(null, null);
|
super(null, null);
|
||||||
taskId = -1;
|
task = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public EngineAssignedWorldManager(Engine engine) {
|
public EngineAssignedWorldManager(Engine engine) {
|
||||||
super(engine, "World");
|
super(engine, "World");
|
||||||
Iris.instance.registerListener(this);
|
Iris.instance.registerListener(this);
|
||||||
taskId = Bukkit.getScheduler().scheduleSyncRepeatingTask(Iris.instance, this::onTick, 0, 0);
|
task = Iris.scheduler.global().runAtFixedRate(this::onTick, 1, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
@ -129,6 +130,6 @@ public abstract class EngineAssignedWorldManager extends EngineAssignedComponent
|
|||||||
public void close() {
|
public void close() {
|
||||||
super.close();
|
super.close();
|
||||||
Iris.instance.unregisterListener(this);
|
Iris.instance.unregisterListener(this);
|
||||||
Bukkit.getScheduler().cancelTask(taskId);
|
if (task != null) task.cancel();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -65,6 +65,7 @@ public class IrisCommand {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var scheduler = Iris.scheduler.global();
|
||||||
for (String command : commands) {
|
for (String command : commands) {
|
||||||
command = (command.startsWith("/") ? command.replaceFirst("/", "") : command)
|
command = (command.startsWith("/") ? command.replaceFirst("/", "") : command)
|
||||||
.replaceAll("\\Q{x}\\E", String.valueOf(at.getBlockX()))
|
.replaceAll("\\Q{x}\\E", String.valueOf(at.getBlockX()))
|
||||||
@ -72,9 +73,9 @@ public class IrisCommand {
|
|||||||
.replaceAll("\\Q{z}\\E", String.valueOf(at.getBlockZ()));
|
.replaceAll("\\Q{z}\\E", String.valueOf(at.getBlockZ()));
|
||||||
final String finalCommand = command;
|
final String finalCommand = command;
|
||||||
if (repeat) {
|
if (repeat) {
|
||||||
Bukkit.getScheduler().scheduleSyncRepeatingTask(Iris.instance, () -> Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), finalCommand), delay, repeatDelay);
|
scheduler.runAtFixedRate(() -> Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), finalCommand), Math.max(delay, 1), Math.max(repeatDelay, 1));
|
||||||
} else {
|
} else {
|
||||||
Bukkit.getScheduler().scheduleSyncDelayedTask(Iris.instance, () -> Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), finalCommand), delay);
|
scheduler.runDelayed(() -> Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), finalCommand), Math.max(delay, 1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -337,9 +337,7 @@ public class IrisEntity extends IrisRegistrant {
|
|||||||
if (e instanceof Villager) {
|
if (e instanceof Villager) {
|
||||||
Villager villager = (Villager) e;
|
Villager villager = (Villager) e;
|
||||||
villager.setRemoveWhenFarAway(false);
|
villager.setRemoveWhenFarAway(false);
|
||||||
Bukkit.getScheduler().scheduleSyncDelayedTask(Iris.instance, () -> {
|
Iris.scheduler.entity(villager).run(() -> villager.setPersistent(true), null);
|
||||||
villager.setPersistent(true);
|
|
||||||
}, 1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (e instanceof Mob) {
|
if (e instanceof Mob) {
|
||||||
@ -377,10 +375,9 @@ public class IrisEntity extends IrisRegistrant {
|
|||||||
((LivingEntity) e).setCollidable(false);
|
((LivingEntity) e).setCollidable(false);
|
||||||
((LivingEntity) e).setNoDamageTicks(100000);
|
((LivingEntity) e).setNoDamageTicks(100000);
|
||||||
AtomicInteger t = new AtomicInteger(0);
|
AtomicInteger t = new AtomicInteger(0);
|
||||||
AtomicInteger v = new AtomicInteger(0);
|
Iris.scheduler.global().runAtFixedRate(task -> {
|
||||||
v.set(J.sr(() -> {
|
|
||||||
if (t.get() > 100) {
|
if (t.get() > 100) {
|
||||||
J.csr(v.get());
|
task.cancel();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -393,13 +390,13 @@ public class IrisEntity extends IrisRegistrant {
|
|||||||
e.getWorld().playSound(e.getLocation(), Sound.BLOCK_CHORUS_FLOWER_GROW, 0.8f, 0.1f);
|
e.getWorld().playSound(e.getLocation(), Sound.BLOCK_CHORUS_FLOWER_GROW, 0.8f, 0.1f);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
J.csr(v.get());
|
task.cancel();
|
||||||
((LivingEntity) e).setNoDamageTicks(0);
|
((LivingEntity) e).setNoDamageTicks(0);
|
||||||
((LivingEntity) e).setCollidable(true);
|
((LivingEntity) e).setCollidable(true);
|
||||||
((LivingEntity) e).setAI(true);
|
((LivingEntity) e).setAI(true);
|
||||||
e.setInvulnerable(false);
|
e.setInvulnerable(false);
|
||||||
}
|
}
|
||||||
}, 0));
|
}, 1, 1);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -18,10 +18,11 @@
|
|||||||
|
|
||||||
package com.volmit.iris.util.board;
|
package com.volmit.iris.util.board;
|
||||||
|
|
||||||
|
import com.volmit.iris.Iris;
|
||||||
|
import com.volmit.iris.util.scheduling.Task;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
import org.bukkit.scheduler.BukkitTask;
|
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@ -34,7 +35,7 @@ public class BoardManager {
|
|||||||
|
|
||||||
private final JavaPlugin plugin;
|
private final JavaPlugin plugin;
|
||||||
private final Map<UUID, Board> scoreboards;
|
private final Map<UUID, Board> scoreboards;
|
||||||
private final BukkitTask updateTask;
|
private final Task updateTask;
|
||||||
private BoardSettings boardSettings;
|
private BoardSettings boardSettings;
|
||||||
|
|
||||||
|
|
||||||
@ -42,7 +43,7 @@ public class BoardManager {
|
|||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
this.boardSettings = boardSettings;
|
this.boardSettings = boardSettings;
|
||||||
this.scoreboards = new ConcurrentHashMap<>();
|
this.scoreboards = new ConcurrentHashMap<>();
|
||||||
this.updateTask = new BoardUpdateTask(this).runTaskTimer(plugin, 2L, 20L);
|
this.updateTask = Iris.scheduler.global().runAtFixedRate(new BoardUpdateTask(this), 2L, 20L);
|
||||||
plugin.getServer().getOnlinePlayers().forEach(this::setup);
|
plugin.getServer().getOnlinePlayers().forEach(this::setup);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,7 +20,6 @@ package com.volmit.iris.util.board;
|
|||||||
|
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.scheduler.BukkitRunnable;
|
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.function.Predicate;
|
import java.util.function.Predicate;
|
||||||
@ -30,7 +29,7 @@ import java.util.function.Predicate;
|
|||||||
* @since 5/31/2018
|
* @since 5/31/2018
|
||||||
*/
|
*/
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
public class BoardUpdateTask extends BukkitRunnable {
|
public class BoardUpdateTask implements Runnable {
|
||||||
|
|
||||||
private static final Predicate<UUID> PLAYER_IS_ONLINE = uuid -> Bukkit.getPlayer(uuid) != null;
|
private static final Predicate<UUID> PLAYER_IS_ONLINE = uuid -> Bukkit.getPlayer(uuid) != null;
|
||||||
|
|
||||||
|
@ -245,7 +245,6 @@ public abstract class VolmitPlugin extends JavaPlugin implements Listener {
|
|||||||
@Override
|
@Override
|
||||||
public void onDisable() {
|
public void onDisable() {
|
||||||
stop();
|
stop();
|
||||||
Bukkit.getScheduler().cancelTasks(this);
|
|
||||||
unregisterListener(this);
|
unregisterListener(this);
|
||||||
unregisterAll();
|
unregisterAll();
|
||||||
}
|
}
|
||||||
|
@ -48,6 +48,7 @@ import java.util.Set;
|
|||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
import java.util.concurrent.ExecutionException;
|
import java.util.concurrent.ExecutionException;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.concurrent.atomic.AtomicBoolean;
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
import java.util.concurrent.atomic.AtomicReference;
|
import java.util.concurrent.atomic.AtomicReference;
|
||||||
@ -298,17 +299,16 @@ public class VolmitSender implements CommandSender {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public <T> void showWaiting(String passive, CompletableFuture<T> f) {
|
public <T> void showWaiting(String passive, CompletableFuture<T> f) {
|
||||||
AtomicInteger v = new AtomicInteger();
|
|
||||||
AtomicReference<T> g = new AtomicReference<>();
|
AtomicReference<T> g = new AtomicReference<>();
|
||||||
v.set(J.ar(() -> {
|
Iris.scheduler.async().runAtFixedRate(task -> {
|
||||||
if (f.isDone() && g.get() != null) {
|
if (f.isDone() && g.get() != null) {
|
||||||
J.car(v.get());
|
task.cancel();
|
||||||
sendAction(" ");
|
sendAction(" ");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
sendProgress(-1, passive);
|
sendProgress(-1, passive);
|
||||||
}, 0));
|
}, 0, 50, TimeUnit.MILLISECONDS);
|
||||||
J.a(() -> {
|
J.a(() -> {
|
||||||
try {
|
try {
|
||||||
g.set(f.get());
|
g.set(f.get());
|
||||||
|
@ -1,8 +1,10 @@
|
|||||||
package com.volmit.iris.util.profile;
|
package com.volmit.iris.util.profile;
|
||||||
|
|
||||||
|
import com.volmit.iris.Iris;
|
||||||
import com.volmit.iris.util.math.M;
|
import com.volmit.iris.util.math.M;
|
||||||
import com.volmit.iris.util.scheduling.J;
|
import com.volmit.iris.util.scheduling.J;
|
||||||
import com.volmit.iris.util.scheduling.Looper;
|
import com.volmit.iris.util.scheduling.Looper;
|
||||||
|
import com.volmit.iris.util.scheduling.Task;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
@ -12,7 +14,7 @@ public abstract class MsptTimings extends Looper {
|
|||||||
private final AtomicInteger currentTick = new AtomicInteger(0);
|
private final AtomicInteger currentTick = new AtomicInteger(0);
|
||||||
private int lastTick, lastMspt;
|
private int lastTick, lastMspt;
|
||||||
private long lastTime;
|
private long lastTime;
|
||||||
private int taskId = -1;
|
private Task task = null;
|
||||||
|
|
||||||
public MsptTimings() {
|
public MsptTimings() {
|
||||||
setName("MsptTimings");
|
setName("MsptTimings");
|
||||||
@ -52,18 +54,18 @@ public abstract class MsptTimings extends Looper {
|
|||||||
protected abstract void update(int mspt);
|
protected abstract void update(int mspt);
|
||||||
|
|
||||||
private boolean startTickTask() {
|
private boolean startTickTask() {
|
||||||
if (taskId != -1 && (Bukkit.getScheduler().isQueued(taskId) || Bukkit.getScheduler().isCurrentlyRunning(taskId)))
|
if (task != null && !task.cancelled())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
taskId = J.sr(() -> {
|
task = Iris.scheduler.global().runAtFixedRate(t -> {
|
||||||
if (isInterrupted()) {
|
if (isInterrupted()) {
|
||||||
J.csr(taskId);
|
t.cancel();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
currentTick.incrementAndGet();
|
currentTick.incrementAndGet();
|
||||||
}, 1);
|
}, 1, 1);
|
||||||
return taskId != -1;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class Simple extends MsptTimings {
|
private static class Simple extends MsptTimings {
|
||||||
|
@ -21,22 +21,18 @@ package com.volmit.iris.util.scheduling;
|
|||||||
import com.volmit.iris.util.plugin.CancellableTask;
|
import com.volmit.iris.util.plugin.CancellableTask;
|
||||||
|
|
||||||
public abstract class AR implements Runnable, CancellableTask {
|
public abstract class AR implements Runnable, CancellableTask {
|
||||||
private int id = 0;
|
private final Task task;
|
||||||
|
|
||||||
public AR() {
|
public AR() {
|
||||||
this(0);
|
this(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
public AR(int interval) {
|
public AR(int interval) {
|
||||||
id = J.ar(this, interval);
|
task = J.ar(this, interval);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void cancel() {
|
public void cancel() {
|
||||||
J.car(id);
|
task.cancel();
|
||||||
}
|
|
||||||
|
|
||||||
public int getId() {
|
|
||||||
return id;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -31,6 +31,7 @@ import org.bukkit.Bukkit;
|
|||||||
import java.util.concurrent.Callable;
|
import java.util.concurrent.Callable;
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
import java.util.concurrent.Future;
|
import java.util.concurrent.Future;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
@ -91,7 +92,7 @@ public class J {
|
|||||||
if (!Bukkit.getPluginManager().isPluginEnabled(Iris.instance)) {
|
if (!Bukkit.getPluginManager().isPluginEnabled(Iris.instance)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Bukkit.getScheduler().scheduleAsyncDelayedTask(Iris.instance, a);
|
Iris.scheduler.async().run(a);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static <T> Future<T> a(Callable<T> a) {
|
public static <T> Future<T> a(Callable<T> a) {
|
||||||
@ -224,33 +225,29 @@ public class J {
|
|||||||
if (!Bukkit.getPluginManager().isPluginEnabled(Iris.instance)) {
|
if (!Bukkit.getPluginManager().isPluginEnabled(Iris.instance)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Bukkit.getScheduler().scheduleSyncDelayedTask(Iris.instance, r);
|
Iris.scheduler.global().run(r);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static CompletableFuture sfut(Runnable r) {
|
public static CompletableFuture sfut(Runnable r) {
|
||||||
CompletableFuture f = new CompletableFuture();
|
|
||||||
|
|
||||||
if (!Bukkit.getPluginManager().isPluginEnabled(Iris.instance)) {
|
if (!Bukkit.getPluginManager().isPluginEnabled(Iris.instance)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
Bukkit.getScheduler().scheduleSyncDelayedTask(Iris.instance, () -> {
|
|
||||||
|
return Iris.scheduler.global().run(() -> {
|
||||||
r.run();
|
r.run();
|
||||||
f.complete(null);
|
return null;
|
||||||
});
|
}).result();
|
||||||
return f;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static CompletableFuture sfut(Runnable r, int delay) {
|
public static CompletableFuture sfut(Runnable r, int delay) {
|
||||||
CompletableFuture f = new CompletableFuture();
|
|
||||||
|
|
||||||
if (!Bukkit.getPluginManager().isPluginEnabled(Iris.instance)) {
|
if (!Bukkit.getPluginManager().isPluginEnabled(Iris.instance)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
Bukkit.getScheduler().scheduleSyncDelayedTask(Iris.instance, () -> {
|
|
||||||
|
return Iris.scheduler.global().runDelayed(() -> {
|
||||||
r.run();
|
r.run();
|
||||||
f.complete(null);
|
return null;
|
||||||
}, delay);
|
}, delay).result();
|
||||||
return f;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static CompletableFuture afut(Runnable r) {
|
public static CompletableFuture afut(Runnable r) {
|
||||||
@ -273,21 +270,12 @@ public class J {
|
|||||||
if (!Bukkit.getPluginManager().isPluginEnabled(Iris.instance)) {
|
if (!Bukkit.getPluginManager().isPluginEnabled(Iris.instance)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Bukkit.getScheduler().scheduleSyncDelayedTask(Iris.instance, r, delay);
|
Iris.scheduler.global().runDelayed(r, delay);
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
Iris.reportError(e);
|
Iris.reportError(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Cancel a sync repeating task
|
|
||||||
*
|
|
||||||
* @param id the task id
|
|
||||||
*/
|
|
||||||
public static void csr(int id) {
|
|
||||||
Bukkit.getScheduler().cancelTask(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Start a sync repeating task
|
* Start a sync repeating task
|
||||||
*
|
*
|
||||||
@ -295,34 +283,11 @@ public class J {
|
|||||||
* @param interval the interval
|
* @param interval the interval
|
||||||
* @return the task id
|
* @return the task id
|
||||||
*/
|
*/
|
||||||
public static int sr(Runnable r, int interval) {
|
public static Task sr(Runnable r, int interval) {
|
||||||
if (!Bukkit.getPluginManager().isPluginEnabled(Iris.instance)) {
|
if (!Bukkit.getPluginManager().isPluginEnabled(Iris.instance)) {
|
||||||
return -1;
|
return null;
|
||||||
}
|
}
|
||||||
return Bukkit.getScheduler().scheduleSyncRepeatingTask(Iris.instance, r, 0, interval);
|
return Iris.scheduler.global().runAtFixedRate(r, 1, Math.max(interval, 1));
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Start a sync repeating task for a limited amount of ticks
|
|
||||||
*
|
|
||||||
* @param r the runnable
|
|
||||||
* @param interval the interval in ticks
|
|
||||||
* @param intervals the maximum amount of intervals to run
|
|
||||||
*/
|
|
||||||
public static void sr(Runnable r, int interval, int intervals) {
|
|
||||||
FinalInteger fi = new FinalInteger(0);
|
|
||||||
|
|
||||||
new SR() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
fi.add(1);
|
|
||||||
r.run();
|
|
||||||
|
|
||||||
if (fi.get() >= intervals) {
|
|
||||||
cancel();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -331,22 +296,12 @@ public class J {
|
|||||||
* @param r the runnable
|
* @param r the runnable
|
||||||
* @param delay the delay to wait before running
|
* @param delay the delay to wait before running
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("deprecation")
|
|
||||||
public static void a(Runnable r, int delay) {
|
public static void a(Runnable r, int delay) {
|
||||||
if (Bukkit.getPluginManager().isPluginEnabled(Iris.instance)) {
|
if (Bukkit.getPluginManager().isPluginEnabled(Iris.instance)) {
|
||||||
Bukkit.getScheduler().scheduleAsyncDelayedTask(Iris.instance, r, delay);
|
Iris.scheduler.async().runDelayed(r, Math.max(delay * 50, 0), TimeUnit.MILLISECONDS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Cancel an async repeat task
|
|
||||||
*
|
|
||||||
* @param id the id
|
|
||||||
*/
|
|
||||||
public static void car(int id) {
|
|
||||||
Bukkit.getScheduler().cancelTask(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Start an async repeat task
|
* Start an async repeat task
|
||||||
*
|
*
|
||||||
@ -354,12 +309,11 @@ public class J {
|
|||||||
* @param interval the interval in ticks
|
* @param interval the interval in ticks
|
||||||
* @return the task id
|
* @return the task id
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("deprecation")
|
public static Task ar(Runnable r, int interval) {
|
||||||
public static int ar(Runnable r, int interval) {
|
|
||||||
if (!Bukkit.getPluginManager().isPluginEnabled(Iris.instance)) {
|
if (!Bukkit.getPluginManager().isPluginEnabled(Iris.instance)) {
|
||||||
return -1;
|
return null;
|
||||||
}
|
}
|
||||||
return Bukkit.getScheduler().scheduleAsyncRepeatingTask(Iris.instance, r, 0, interval);
|
return Iris.scheduler.async().runAtFixedRate(r, 0, Math.max(interval, 1) * 50, TimeUnit.MILLISECONDS);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -21,22 +21,20 @@ package com.volmit.iris.util.scheduling;
|
|||||||
import com.volmit.iris.util.plugin.CancellableTask;
|
import com.volmit.iris.util.plugin.CancellableTask;
|
||||||
|
|
||||||
public abstract class SR implements Runnable, CancellableTask {
|
public abstract class SR implements Runnable, CancellableTask {
|
||||||
private int id = 0;
|
private final Task id;
|
||||||
|
|
||||||
public SR() {
|
public SR() {
|
||||||
this(0);
|
this(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public SR(int interval) {
|
public SR(int interval) {
|
||||||
id = J.sr(this, interval);
|
this.id = J.sr(this, interval);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void cancel() {
|
public void cancel() {
|
||||||
J.csr(id);
|
if (id != null) {
|
||||||
}
|
id.cancel();
|
||||||
|
}
|
||||||
public int getId() {
|
|
||||||
return id;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -63,7 +63,7 @@ public interface Job {
|
|||||||
default void execute(VolmitSender sender, boolean silentMsg, Runnable whenComplete) {
|
default void execute(VolmitSender sender, boolean silentMsg, Runnable whenComplete) {
|
||||||
PrecisionStopwatch p = PrecisionStopwatch.start();
|
PrecisionStopwatch p = PrecisionStopwatch.start();
|
||||||
CompletableFuture<?> f = J.afut(this::execute);
|
CompletableFuture<?> f = J.afut(this::execute);
|
||||||
int c = J.ar(() -> {
|
var c = J.ar(() -> {
|
||||||
if (sender.isPlayer()) {
|
if (sender.isPlayer()) {
|
||||||
sender.sendProgress(getProgress(), getName());
|
sender.sendProgress(getProgress(), getName());
|
||||||
} else {
|
} else {
|
||||||
@ -71,7 +71,7 @@ public interface Job {
|
|||||||
}
|
}
|
||||||
}, sender.isPlayer() ? 0 : 20);
|
}, sender.isPlayer() ? 0 : 20);
|
||||||
f.whenComplete((fs, ff) -> {
|
f.whenComplete((fs, ff) -> {
|
||||||
J.car(c);
|
if (c != null) c.cancel();
|
||||||
if (!silentMsg) {
|
if (!silentMsg) {
|
||||||
sender.sendMessage(C.AQUA + "Completed " + getName() + " in " + Form.duration(p.getMilliseconds(), 1));
|
sender.sendMessage(C.AQUA + "Completed " + getName() + " in " + Form.duration(p.getMilliseconds(), 1));
|
||||||
}
|
}
|
||||||
|
@ -24,4 +24,5 @@ commands:
|
|||||||
iris:
|
iris:
|
||||||
aliases: [ ir, irs ]
|
aliases: [ ir, irs ]
|
||||||
api-version: '${apiVersion}'
|
api-version: '${apiVersion}'
|
||||||
hotload-dependencies: false
|
hotload-dependencies: false
|
||||||
|
folia-supported: true
|
Loading…
x
Reference in New Issue
Block a user