mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-12-19 15:09:18 +00:00
cleanup command framework and fix random locator fails
This commit is contained in:
@@ -71,7 +71,6 @@ import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
import java.util.zip.GZIPInputStream;
|
||||
import java.util.zip.GZIPOutputStream;
|
||||
|
||||
@@ -159,7 +158,7 @@ public class CommandDeveloper implements DecreeExecutor {
|
||||
@SneakyThrows
|
||||
@Decree(description = "Generate Iris structures for all loaded datapack structures")
|
||||
public void generateStructures(
|
||||
@Param(description = "The pack to add the generated structures to", aliases = "pack", defaultValue = "---", customHandler = NullableDimensionHandler.class)
|
||||
@Param(description = "The pack to add the generated structures to", aliases = "pack", defaultValue = "null", customHandler = NullableDimensionHandler.class)
|
||||
IrisDimension dimension,
|
||||
@Param(description = "Ignore existing structures", defaultValue = "false")
|
||||
boolean force
|
||||
|
||||
@@ -48,7 +48,7 @@ public class CommandJigsaw implements DecreeExecutor {
|
||||
IrisJigsawPiece piece
|
||||
) {
|
||||
File dest = piece.getLoadFile();
|
||||
new JigsawEditor(player(), piece, IrisData.loadAnyObject(piece.getObject()), dest);
|
||||
new JigsawEditor(player(), piece, IrisData.loadAnyObject(piece.getObject(), data()), dest);
|
||||
}
|
||||
|
||||
@Decree(description = "Place a jigsaw structure")
|
||||
@@ -78,7 +78,7 @@ public class CommandJigsaw implements DecreeExecutor {
|
||||
@Param(description = "The object to use for this piece", customHandler = ObjectHandler.class)
|
||||
String object
|
||||
) {
|
||||
IrisObject o = IrisData.loadAnyObject(object);
|
||||
IrisObject o = IrisData.loadAnyObject(object, data());
|
||||
|
||||
if (object == null) {
|
||||
sender().sendMessage(C.RED + "Failed to find existing object");
|
||||
|
||||
@@ -136,7 +136,7 @@ public class CommandObject implements DecreeExecutor {
|
||||
@Param(description = "The object to analyze", customHandler = ObjectHandler.class)
|
||||
String object
|
||||
) {
|
||||
IrisObject o = IrisData.loadAnyObject(object);
|
||||
IrisObject o = IrisData.loadAnyObject(object, data());
|
||||
sender().sendMessage("Object Size: " + o.getW() + " * " + o.getH() + " * " + o.getD() + "");
|
||||
sender().sendMessage("Blocks Used: " + NumberFormat.getIntegerInstance().format(o.getBlocks().size()));
|
||||
|
||||
@@ -201,7 +201,7 @@ public class CommandObject implements DecreeExecutor {
|
||||
|
||||
@Decree(description = "Shrink an object to its minimum size")
|
||||
public void shrink(@Param(description = "The object to shrink", customHandler = ObjectHandler.class) String object) {
|
||||
IrisObject o = IrisData.loadAnyObject(object);
|
||||
IrisObject o = IrisData.loadAnyObject(object, data());
|
||||
sender().sendMessage("Current Object Size: " + o.getW() + " * " + o.getH() + " * " + o.getD());
|
||||
o.shrinkwrap();
|
||||
sender().sendMessage("New Object Size: " + o.getW() + " * " + o.getH() + " * " + o.getD());
|
||||
@@ -325,7 +325,7 @@ public class CommandObject implements DecreeExecutor {
|
||||
// @Param(description = "The scale interpolator to use", defaultValue = "none")
|
||||
// IrisObjectPlacementScaleInterpolator interpolator
|
||||
) {
|
||||
IrisObject o = IrisData.loadAnyObject(object);
|
||||
IrisObject o = IrisData.loadAnyObject(object, data());
|
||||
double maxScale = Double.max(10 - o.getBlocks().size() / 10000d, 1);
|
||||
if (scale > maxScale) {
|
||||
sender().sendMessage(C.YELLOW + "Indicated scale exceeds maximum. Downscaled to maximum: " + maxScale);
|
||||
|
||||
@@ -171,9 +171,9 @@ public class CommandStudio implements DecreeExecutor {
|
||||
var loc = player().getLocation().clone();
|
||||
|
||||
J.a(() -> {
|
||||
DecreeContext.touch(sender);
|
||||
PlatformChunkGenerator plat = IrisToolbelt.access(world);
|
||||
Engine engine = plat.getEngine();
|
||||
DecreeContext.touch(sender);
|
||||
try (SyncExecutor executor = new SyncExecutor(20)) {
|
||||
int x = loc.getBlockX() >> 4;
|
||||
int z = loc.getBlockZ() >> 4;
|
||||
@@ -247,6 +247,8 @@ public class CommandStudio implements DecreeExecutor {
|
||||
} catch (Throwable e) {
|
||||
sender().sendMessage("Error while regenerating chunks");
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
DecreeContext.remove();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@ import com.volmit.iris.core.commands.CommandIris;
|
||||
import com.volmit.iris.core.tools.IrisToolbelt;
|
||||
import com.volmit.iris.engine.data.cache.AtomicCache;
|
||||
import com.volmit.iris.util.collection.KMap;
|
||||
import com.volmit.iris.util.decree.DecreeContext;
|
||||
import com.volmit.iris.util.decree.DecreeSystem;
|
||||
import com.volmit.iris.util.decree.virtual.VirtualDecreeCommand;
|
||||
import com.volmit.iris.util.format.C;
|
||||
@@ -44,7 +45,14 @@ public class CommandSVC implements IrisService, DecreeSystem {
|
||||
@Override
|
||||
public void onEnable() {
|
||||
Iris.instance.getCommand("iris").setExecutor(this);
|
||||
J.a(() -> getRoot().cacheAll());
|
||||
J.a(() -> {
|
||||
DecreeContext.touch(Iris.getSender());
|
||||
try {
|
||||
getRoot().cacheAll();
|
||||
} finally {
|
||||
DecreeContext.remove();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -863,7 +863,7 @@ public interface Engine extends DataProvider, Fallible, LootProvider, BlockUpdat
|
||||
default void gotoBiome(IrisBiome biome, Player player, boolean teleport) {
|
||||
Set<String> regionKeys = getDimension()
|
||||
.getAllRegions(this).stream()
|
||||
.filter((i) -> i.getAllBiomes(this).contains(biome))
|
||||
.filter((i) -> i.getAllBiomeIds().contains(biome.getLoadKey()))
|
||||
.map(IrisRegistrant::getLoadKey)
|
||||
.collect(Collectors.toSet());
|
||||
Locator<IrisBiome> lb = Locator.surfaceBiome(biome.getLoadKey());
|
||||
@@ -959,7 +959,7 @@ public interface Engine extends DataProvider, Fallible, LootProvider, BlockUpdat
|
||||
}
|
||||
|
||||
default void gotoRegion(IrisRegion r, Player player, boolean teleport) {
|
||||
if (!getDimension().getAllRegions(this).contains(r)) {
|
||||
if (!getDimension().getRegions().contains(r.getLoadKey())) {
|
||||
player.sendMessage(C.RED + r.getName() + " is not defined in the dimension!");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -18,29 +18,20 @@
|
||||
|
||||
package com.volmit.iris.util.decree;
|
||||
|
||||
import com.volmit.iris.util.collection.KMap;
|
||||
import com.volmit.iris.util.plugin.VolmitSender;
|
||||
import com.volmit.iris.util.scheduling.ChronoLatch;
|
||||
|
||||
public class DecreeContext {
|
||||
private static final ChronoLatch cl = new ChronoLatch(60000);
|
||||
private static final KMap<Thread, VolmitSender> context = new KMap<>();
|
||||
private static final ThreadLocal<VolmitSender> context = new ThreadLocal<>();
|
||||
|
||||
public static VolmitSender get() {
|
||||
return context.get(Thread.currentThread());
|
||||
return context.get();
|
||||
}
|
||||
|
||||
public static void touch(VolmitSender c) {
|
||||
synchronized (context) {
|
||||
context.put(Thread.currentThread(), c);
|
||||
context.set(c);
|
||||
}
|
||||
|
||||
if (cl.flip()) {
|
||||
for (Thread i : context.k()) {
|
||||
if (!i.isAlive()) {
|
||||
context.remove(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
public static void remove() {
|
||||
context.remove();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
package com.volmit.iris.util.decree;
|
||||
|
||||
import com.volmit.iris.core.loader.IrisData;
|
||||
import com.volmit.iris.core.tools.IrisToolbelt;
|
||||
import com.volmit.iris.engine.framework.Engine;
|
||||
import com.volmit.iris.engine.platform.PlatformChunkGenerator;
|
||||
@@ -34,6 +35,14 @@ public interface DecreeExecutor {
|
||||
return sender().player();
|
||||
}
|
||||
|
||||
default IrisData data() {
|
||||
var access = access();
|
||||
if (access != null) {
|
||||
return access.getData();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
default Engine engine() {
|
||||
if (sender().isPlayer() && IrisToolbelt.access(sender().player().getWorld()) != null) {
|
||||
PlatformChunkGenerator gen = IrisToolbelt.access(sender().player().getWorld());
|
||||
|
||||
@@ -23,7 +23,7 @@ import com.volmit.iris.util.decree.exceptions.DecreeParsingException;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
public interface DecreeParameterHandler<T> {
|
||||
public interface DecreeParameterHandler<T> extends DecreeExecutor {
|
||||
/**
|
||||
* Should return the possible values for this type
|
||||
*
|
||||
|
||||
@@ -133,23 +133,32 @@ public interface DecreeSystem extends CommandExecutor, TabCompleter {
|
||||
|
||||
default boolean call(VolmitSender sender, String[] args) {
|
||||
DecreeContext.touch(sender);
|
||||
return getRoot().invoke(sender, enhanceArgs(args));
|
||||
try {
|
||||
return getRoot().invoke(sender, enhanceArgs(args));
|
||||
} finally {
|
||||
DecreeContext.remove();
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
default List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String alias, @NotNull String[] args) {
|
||||
KList<String> enhanced = new KList<>(args);
|
||||
KList<String> v = getRoot().tabComplete(enhanced, enhanced.toString(" "));
|
||||
v.removeDuplicates();
|
||||
DecreeContext.touch(new VolmitSender(sender));
|
||||
try {
|
||||
KList<String> enhanced = new KList<>(args);
|
||||
KList<String> v = getRoot().tabComplete(enhanced, enhanced.toString(" "));
|
||||
v.removeDuplicates();
|
||||
|
||||
if (sender instanceof Player) {
|
||||
if (IrisSettings.get().getGeneral().isCommandSounds()) {
|
||||
((Player) sender).playSound(((Player) sender).getLocation(), Sound.BLOCK_AMETHYST_BLOCK_CHIME, 0.25f, RNG.r.f(0.125f, 1.95f));
|
||||
if (sender instanceof Player) {
|
||||
if (IrisSettings.get().getGeneral().isCommandSounds()) {
|
||||
((Player) sender).playSound(((Player) sender).getLocation(), Sound.BLOCK_AMETHYST_BLOCK_CHIME, 0.25f, RNG.r.f(0.125f, 1.95f));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return v;
|
||||
return v;
|
||||
} finally {
|
||||
DecreeContext.remove();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -18,63 +18,12 @@
|
||||
|
||||
package com.volmit.iris.util.decree.handlers;
|
||||
|
||||
import com.volmit.iris.Iris;
|
||||
import com.volmit.iris.core.loader.IrisData;
|
||||
import com.volmit.iris.engine.object.IrisBiome;
|
||||
import com.volmit.iris.util.collection.KList;
|
||||
import com.volmit.iris.util.collection.KMap;
|
||||
import com.volmit.iris.util.decree.DecreeParameterHandler;
|
||||
import com.volmit.iris.util.decree.exceptions.DecreeParsingException;
|
||||
import com.volmit.iris.util.decree.specialhandlers.RegistrantHandler;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class BiomeHandler implements DecreeParameterHandler<IrisBiome> {
|
||||
@Override
|
||||
public KList<IrisBiome> getPossibilities() {
|
||||
KMap<String, IrisBiome> p = new KMap<>();
|
||||
|
||||
//noinspection ConstantConditions
|
||||
for (File i : Iris.instance.getDataFolder("packs").listFiles()) {
|
||||
if (i.isDirectory()) {
|
||||
IrisData data = IrisData.get(i);
|
||||
for (IrisBiome j : data.getBiomeLoader().loadAll(data.getBiomeLoader().getPossibleKeys())) {
|
||||
p.putIfAbsent(j.getLoadKey(), j);
|
||||
}
|
||||
|
||||
data.close();
|
||||
}
|
||||
}
|
||||
|
||||
return p.v();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString(IrisBiome dim) {
|
||||
return dim.getLoadKey();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IrisBiome parse(String in, boolean force) throws DecreeParsingException {
|
||||
if (in.equals("null")) {
|
||||
return null;
|
||||
}
|
||||
KList<IrisBiome> options = getPossibilities(in);
|
||||
|
||||
if (options.isEmpty()) {
|
||||
throw new DecreeParsingException("Unable to find Biome \"" + in + "\"");
|
||||
}
|
||||
|
||||
try {
|
||||
return options.stream().filter((i) -> toString(i).equalsIgnoreCase(in)).collect(Collectors.toList()).get(0);
|
||||
} catch (Throwable e) {
|
||||
throw new DecreeParsingException("Unable to filter which Biome \"" + in + "\"");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supports(Class<?> type) {
|
||||
return type.equals(IrisBiome.class);
|
||||
public class BiomeHandler extends RegistrantHandler<IrisBiome> {
|
||||
public BiomeHandler() {
|
||||
super(IrisBiome.class, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -18,62 +18,12 @@
|
||||
|
||||
package com.volmit.iris.util.decree.handlers;
|
||||
|
||||
import com.volmit.iris.Iris;
|
||||
import com.volmit.iris.core.loader.IrisData;
|
||||
import com.volmit.iris.engine.object.IrisCave;
|
||||
import com.volmit.iris.util.collection.KList;
|
||||
import com.volmit.iris.util.collection.KMap;
|
||||
import com.volmit.iris.util.decree.DecreeParameterHandler;
|
||||
import com.volmit.iris.util.decree.exceptions.DecreeParsingException;
|
||||
import com.volmit.iris.util.decree.specialhandlers.RegistrantHandler;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class CaveHandler implements DecreeParameterHandler<IrisCave> {
|
||||
@Override
|
||||
public KList<IrisCave> getPossibilities() {
|
||||
KMap<String, IrisCave> p = new KMap<>();
|
||||
|
||||
//noinspection ConstantConditions
|
||||
for (File i : Iris.instance.getDataFolder("packs").listFiles()) {
|
||||
if (i.isDirectory()) {
|
||||
IrisData data = IrisData.get(i);
|
||||
for (IrisCave j : data.getCaveLoader().loadAll(data.getCaveLoader().getPossibleKeys())) {
|
||||
p.putIfAbsent(j.getLoadKey(), j);
|
||||
}
|
||||
|
||||
data.close();
|
||||
}
|
||||
}
|
||||
|
||||
return p.v();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString(IrisCave dim) {
|
||||
return dim.getLoadKey();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IrisCave parse(String in, boolean force) throws DecreeParsingException {
|
||||
if (in.equals("null")) {
|
||||
return null;
|
||||
}
|
||||
KList<IrisCave> options = getPossibilities(in);
|
||||
|
||||
if (options.isEmpty()) {
|
||||
throw new DecreeParsingException("Unable to find Cave \"" + in + "\"");
|
||||
}
|
||||
try {
|
||||
return options.stream().filter((i) -> toString(i).equalsIgnoreCase(in)).collect(Collectors.toList()).get(0);
|
||||
} catch (Throwable e) {
|
||||
throw new DecreeParsingException("Unable to filter which Cave\"" + in + "\"");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supports(Class<?> type) {
|
||||
return type.equals(IrisCave.class);
|
||||
public class CaveHandler extends RegistrantHandler<IrisCave> {
|
||||
public CaveHandler() {
|
||||
super(IrisCave.class, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -18,65 +18,22 @@
|
||||
|
||||
package com.volmit.iris.util.decree.handlers;
|
||||
|
||||
import com.volmit.iris.Iris;
|
||||
import com.volmit.iris.core.IrisSettings;
|
||||
import com.volmit.iris.core.loader.IrisData;
|
||||
import com.volmit.iris.engine.object.IrisDimension;
|
||||
import com.volmit.iris.util.collection.KList;
|
||||
import com.volmit.iris.util.collection.KMap;
|
||||
import com.volmit.iris.util.decree.DecreeParameterHandler;
|
||||
import com.volmit.iris.util.decree.exceptions.DecreeParsingException;
|
||||
import com.volmit.iris.util.decree.specialhandlers.RegistrantHandler;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class DimensionHandler implements DecreeParameterHandler<IrisDimension> {
|
||||
@Override
|
||||
public KList<IrisDimension> getPossibilities() {
|
||||
KMap<String, IrisDimension> p = new KMap<>();
|
||||
|
||||
//noinspection ConstantConditions
|
||||
for (File i : Iris.instance.getDataFolder("packs").listFiles()) {
|
||||
if (i.isDirectory()) {
|
||||
IrisData data = IrisData.get(i);
|
||||
for (IrisDimension j : data.getDimensionLoader().loadAll(data.getDimensionLoader().getPossibleKeys())) {
|
||||
p.putIfAbsent(j.getLoadKey(), j);
|
||||
}
|
||||
|
||||
data.close();
|
||||
}
|
||||
}
|
||||
|
||||
return p.v();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString(IrisDimension dim) {
|
||||
return dim.getLoadKey();
|
||||
public class DimensionHandler extends RegistrantHandler<IrisDimension> {
|
||||
public DimensionHandler() {
|
||||
super(IrisDimension.class, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IrisDimension parse(String in, boolean force) throws DecreeParsingException {
|
||||
|
||||
if (in.equalsIgnoreCase("default")) {
|
||||
return parse(IrisSettings.get().getGenerator().getDefaultWorldType());
|
||||
}
|
||||
|
||||
KList<IrisDimension> options = getPossibilities(in);
|
||||
|
||||
|
||||
if (options.isEmpty()) {
|
||||
throw new DecreeParsingException("Unable to find Dimension \"" + in + "\"");
|
||||
}
|
||||
try {
|
||||
return options.stream().filter((i) -> toString(i).equalsIgnoreCase(in)).toList().get(0);
|
||||
} catch (Throwable e) {
|
||||
throw new DecreeParsingException("Unable to filter which Dimension \"" + in + "\"");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supports(Class<?> type) {
|
||||
return type.equals(IrisDimension.class);
|
||||
return super.parse(in, force);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -18,84 +18,13 @@
|
||||
|
||||
package com.volmit.iris.util.decree.handlers;
|
||||
|
||||
import com.volmit.iris.Iris;
|
||||
import com.volmit.iris.core.loader.IrisData;
|
||||
import com.volmit.iris.engine.object.IrisEntity;
|
||||
import com.volmit.iris.util.collection.KList;
|
||||
import com.volmit.iris.util.collection.KMap;
|
||||
import com.volmit.iris.util.decree.DecreeParameterHandler;
|
||||
import com.volmit.iris.util.decree.exceptions.DecreeParsingException;
|
||||
import com.volmit.iris.util.decree.specialhandlers.RegistrantHandler;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.stream.Collectors;
|
||||
public class EntityHandler extends RegistrantHandler<IrisEntity> {
|
||||
|
||||
public class EntityHandler implements DecreeParameterHandler<IrisEntity> {
|
||||
|
||||
/**
|
||||
* Should return the possible values for this type
|
||||
*
|
||||
* @return Possibilities for this type.
|
||||
*/
|
||||
@Override
|
||||
public KList<IrisEntity> getPossibilities() {
|
||||
KMap<String, IrisEntity> p = new KMap<>();
|
||||
|
||||
//noinspection ConstantConditions
|
||||
for (File i : Iris.instance.getDataFolder("packs").listFiles()) {
|
||||
if (i.isDirectory()) {
|
||||
IrisData data = IrisData.get(i);
|
||||
for (IrisEntity j : data.getEntityLoader().loadAll(data.getEntityLoader().getPossibleKeys())) {
|
||||
p.putIfAbsent(j.getLoadKey(), j);
|
||||
}
|
||||
|
||||
data.close();
|
||||
}
|
||||
}
|
||||
|
||||
return p.v();
|
||||
}
|
||||
|
||||
/**
|
||||
* Converting the type back to a string (inverse of the {@link #parse(String) parse} method)
|
||||
*
|
||||
* @param entity The input of the designated type to convert to a String
|
||||
* @return The resulting string
|
||||
*/
|
||||
@Override
|
||||
public String toString(IrisEntity entity) {
|
||||
return entity.getLoadKey();
|
||||
}
|
||||
|
||||
/**
|
||||
* Should parse a String into the designated type
|
||||
*
|
||||
* @param in The string to parse
|
||||
* @return The value extracted from the string, of the designated type
|
||||
* @throws DecreeParsingException Thrown when the parsing fails (ex: "oop" translated to an integer throws this)
|
||||
*/
|
||||
@Override
|
||||
public IrisEntity parse(String in, boolean force) throws DecreeParsingException {
|
||||
KList<IrisEntity> options = getPossibilities(in);
|
||||
|
||||
if (options.isEmpty()) {
|
||||
throw new DecreeParsingException("Unable to find Entity \"" + in + "\"");
|
||||
}
|
||||
try {
|
||||
return options.stream().filter((i) -> toString(i).equalsIgnoreCase(in)).collect(Collectors.toList()).get(0);
|
||||
} catch (Throwable e) {
|
||||
throw new DecreeParsingException("Unable to filter which Entity \"" + in + "\"");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether a certain type is supported by this handler<br>
|
||||
*
|
||||
* @param type The type to check
|
||||
* @return True if supported, false if not
|
||||
*/
|
||||
@Override
|
||||
public boolean supports(Class<?> type) {
|
||||
return type.equals(IrisEntity.class);
|
||||
public EntityHandler() {
|
||||
super(IrisEntity.class, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -18,59 +18,12 @@
|
||||
|
||||
package com.volmit.iris.util.decree.handlers;
|
||||
|
||||
import com.volmit.iris.Iris;
|
||||
import com.volmit.iris.core.loader.IrisData;
|
||||
import com.volmit.iris.engine.object.IrisGenerator;
|
||||
import com.volmit.iris.util.collection.KList;
|
||||
import com.volmit.iris.util.collection.KMap;
|
||||
import com.volmit.iris.util.decree.DecreeParameterHandler;
|
||||
import com.volmit.iris.util.decree.exceptions.DecreeParsingException;
|
||||
import com.volmit.iris.util.decree.specialhandlers.RegistrantHandler;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class GeneratorHandler implements DecreeParameterHandler<IrisGenerator> {
|
||||
@Override
|
||||
public KList<IrisGenerator> getPossibilities() {
|
||||
KMap<String, IrisGenerator> p = new KMap<>();
|
||||
|
||||
//noinspection ConstantConditions
|
||||
for (File i : Iris.instance.getDataFolder("packs").listFiles()) {
|
||||
if (i.isDirectory()) {
|
||||
IrisData data = IrisData.get(i);
|
||||
for (IrisGenerator j : data.getGeneratorLoader().loadAll(data.getGeneratorLoader().getPossibleKeys())) {
|
||||
p.putIfAbsent(j.getLoadKey(), j);
|
||||
}
|
||||
|
||||
data.close();
|
||||
}
|
||||
}
|
||||
|
||||
return p.v();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString(IrisGenerator gen) {
|
||||
return gen.getLoadKey();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IrisGenerator parse(String in, boolean force) throws DecreeParsingException {
|
||||
KList<IrisGenerator> options = getPossibilities(in);
|
||||
|
||||
if (options.isEmpty()) {
|
||||
throw new DecreeParsingException("Unable to find Generator \"" + in + "\"");
|
||||
}
|
||||
try {
|
||||
return options.stream().filter((i) -> toString(i).equalsIgnoreCase(in)).collect(Collectors.toList()).get(0);
|
||||
} catch (Throwable e) {
|
||||
throw new DecreeParsingException("Unable to filter which Generator \"" + in + "\"");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supports(Class<?> type) {
|
||||
return type.equals(IrisGenerator.class);
|
||||
public class GeneratorHandler extends RegistrantHandler<IrisGenerator> {
|
||||
public GeneratorHandler() {
|
||||
super(IrisGenerator.class, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -18,62 +18,12 @@
|
||||
|
||||
package com.volmit.iris.util.decree.handlers;
|
||||
|
||||
import com.volmit.iris.Iris;
|
||||
import com.volmit.iris.core.loader.IrisData;
|
||||
import com.volmit.iris.engine.object.IrisJigsawPiece;
|
||||
import com.volmit.iris.util.collection.KList;
|
||||
import com.volmit.iris.util.collection.KMap;
|
||||
import com.volmit.iris.util.decree.DecreeParameterHandler;
|
||||
import com.volmit.iris.util.decree.exceptions.DecreeParsingException;
|
||||
import com.volmit.iris.util.decree.specialhandlers.RegistrantHandler;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class JigsawPieceHandler implements DecreeParameterHandler<IrisJigsawPiece> {
|
||||
@Override
|
||||
public KList<IrisJigsawPiece> getPossibilities() {
|
||||
KMap<String, IrisJigsawPiece> p = new KMap<>();
|
||||
|
||||
//noinspection ConstantConditions
|
||||
for (File i : Iris.instance.getDataFolder("packs").listFiles()) {
|
||||
if (i.isDirectory()) {
|
||||
IrisData data = IrisData.get(i);
|
||||
for (IrisJigsawPiece j : data.getJigsawPieceLoader().loadAll(data.getJigsawPieceLoader().getPossibleKeys())) {
|
||||
p.putIfAbsent(j.getLoadKey(), j);
|
||||
}
|
||||
|
||||
data.close();
|
||||
}
|
||||
}
|
||||
|
||||
return p.v();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString(IrisJigsawPiece dim) {
|
||||
return dim.getLoadKey();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IrisJigsawPiece parse(String in, boolean force) throws DecreeParsingException {
|
||||
if (in.equals("null")) {
|
||||
return null;
|
||||
}
|
||||
KList<IrisJigsawPiece> options = getPossibilities(in);
|
||||
|
||||
if (options.isEmpty()) {
|
||||
throw new DecreeParsingException("Unable to find Jigsaw Piece \"" + in + "\"");
|
||||
}
|
||||
try {
|
||||
return options.stream().filter((i) -> toString(i).equalsIgnoreCase(in)).collect(Collectors.toList()).get(0);
|
||||
} catch (Throwable e) {
|
||||
throw new DecreeParsingException("Unable to filter which Jigsaw Piece \"" + in + "\"");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supports(Class<?> type) {
|
||||
return type.equals(IrisJigsawPiece.class);
|
||||
public class JigsawPieceHandler extends RegistrantHandler<IrisJigsawPiece> {
|
||||
public JigsawPieceHandler() {
|
||||
super(IrisJigsawPiece.class, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -18,62 +18,12 @@
|
||||
|
||||
package com.volmit.iris.util.decree.handlers;
|
||||
|
||||
import com.volmit.iris.Iris;
|
||||
import com.volmit.iris.core.loader.IrisData;
|
||||
import com.volmit.iris.engine.object.IrisJigsawPool;
|
||||
import com.volmit.iris.util.collection.KList;
|
||||
import com.volmit.iris.util.collection.KMap;
|
||||
import com.volmit.iris.util.decree.DecreeParameterHandler;
|
||||
import com.volmit.iris.util.decree.exceptions.DecreeParsingException;
|
||||
import com.volmit.iris.util.decree.specialhandlers.RegistrantHandler;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class JigsawPoolHandler implements DecreeParameterHandler<IrisJigsawPool> {
|
||||
@Override
|
||||
public KList<IrisJigsawPool> getPossibilities() {
|
||||
KMap<String, IrisJigsawPool> p = new KMap<>();
|
||||
|
||||
//noinspection ConstantConditions
|
||||
for (File i : Iris.instance.getDataFolder("packs").listFiles()) {
|
||||
if (i.isDirectory()) {
|
||||
IrisData data = IrisData.get(i);
|
||||
for (IrisJigsawPool j : data.getJigsawPoolLoader().loadAll(data.getJigsawPoolLoader().getPossibleKeys())) {
|
||||
p.putIfAbsent(j.getLoadKey(), j);
|
||||
}
|
||||
|
||||
data.close();
|
||||
}
|
||||
}
|
||||
|
||||
return p.v();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString(IrisJigsawPool dim) {
|
||||
return dim.getLoadKey();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IrisJigsawPool parse(String in, boolean force) throws DecreeParsingException {
|
||||
if (in.equals("null")) {
|
||||
return null;
|
||||
}
|
||||
KList<IrisJigsawPool> options = getPossibilities(in);
|
||||
|
||||
if (options.isEmpty()) {
|
||||
throw new DecreeParsingException("Unable to find Jigsaw Pool \"" + in + "\"");
|
||||
}
|
||||
try {
|
||||
return options.stream().filter((i) -> toString(i).equalsIgnoreCase(in)).collect(Collectors.toList()).get(0);
|
||||
} catch (Throwable e) {
|
||||
throw new DecreeParsingException("Unable to filter which Jigsaw Pool \"" + in + "\"");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supports(Class<?> type) {
|
||||
return type.equals(IrisJigsawPool.class);
|
||||
public class JigsawPoolHandler extends RegistrantHandler<IrisJigsawPool> {
|
||||
public JigsawPoolHandler() {
|
||||
super(IrisJigsawPool.class, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -18,62 +18,12 @@
|
||||
|
||||
package com.volmit.iris.util.decree.handlers;
|
||||
|
||||
import com.volmit.iris.Iris;
|
||||
import com.volmit.iris.core.loader.IrisData;
|
||||
import com.volmit.iris.engine.object.IrisJigsawStructure;
|
||||
import com.volmit.iris.util.collection.KList;
|
||||
import com.volmit.iris.util.collection.KMap;
|
||||
import com.volmit.iris.util.decree.DecreeParameterHandler;
|
||||
import com.volmit.iris.util.decree.exceptions.DecreeParsingException;
|
||||
import com.volmit.iris.util.decree.specialhandlers.RegistrantHandler;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class JigsawStructureHandler implements DecreeParameterHandler<IrisJigsawStructure> {
|
||||
@Override
|
||||
public KList<IrisJigsawStructure> getPossibilities() {
|
||||
KMap<String, IrisJigsawStructure> p = new KMap<>();
|
||||
|
||||
//noinspection ConstantConditions
|
||||
for (File i : Iris.instance.getDataFolder("packs").listFiles()) {
|
||||
if (i.isDirectory()) {
|
||||
IrisData data = IrisData.get(i);
|
||||
for (IrisJigsawStructure j : data.getJigsawStructureLoader().loadAll(data.getJigsawStructureLoader().getPossibleKeys())) {
|
||||
p.putIfAbsent(j.getLoadKey(), j);
|
||||
}
|
||||
|
||||
data.close();
|
||||
}
|
||||
}
|
||||
|
||||
return p.v();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString(IrisJigsawStructure dim) {
|
||||
return dim.getLoadKey();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IrisJigsawStructure parse(String in, boolean force) throws DecreeParsingException {
|
||||
if (in.equals("null")) {
|
||||
return null;
|
||||
}
|
||||
KList<IrisJigsawStructure> options = getPossibilities(in);
|
||||
|
||||
if (options.isEmpty()) {
|
||||
throw new DecreeParsingException("Unable to find Jigsaw Structure \"" + in + "\"");
|
||||
}
|
||||
try {
|
||||
return options.stream().filter((i) -> toString(i).equalsIgnoreCase(in)).collect(Collectors.toList()).get(0);
|
||||
} catch (Throwable e) {
|
||||
throw new DecreeParsingException("Unable to filter which Jigsaw Structure \"" + in + "\"");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supports(Class<?> type) {
|
||||
return type.equals(IrisJigsawStructure.class);
|
||||
public class JigsawStructureHandler extends RegistrantHandler<IrisJigsawStructure> {
|
||||
public JigsawStructureHandler() {
|
||||
super(IrisJigsawStructure.class, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -18,62 +18,12 @@
|
||||
|
||||
package com.volmit.iris.util.decree.handlers;
|
||||
|
||||
import com.volmit.iris.Iris;
|
||||
import com.volmit.iris.core.loader.IrisData;
|
||||
import com.volmit.iris.engine.object.IrisRegion;
|
||||
import com.volmit.iris.util.collection.KList;
|
||||
import com.volmit.iris.util.collection.KMap;
|
||||
import com.volmit.iris.util.decree.DecreeParameterHandler;
|
||||
import com.volmit.iris.util.decree.exceptions.DecreeParsingException;
|
||||
import com.volmit.iris.util.decree.specialhandlers.RegistrantHandler;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class RegionHandler implements DecreeParameterHandler<IrisRegion> {
|
||||
@Override
|
||||
public KList<IrisRegion> getPossibilities() {
|
||||
KMap<String, IrisRegion> p = new KMap<>();
|
||||
|
||||
//noinspection ConstantConditions
|
||||
for (File i : Iris.instance.getDataFolder("packs").listFiles()) {
|
||||
if (i.isDirectory()) {
|
||||
IrisData data = IrisData.get(i);
|
||||
for (IrisRegion j : data.getRegionLoader().loadAll(data.getRegionLoader().getPossibleKeys())) {
|
||||
p.putIfAbsent(j.getLoadKey(), j);
|
||||
}
|
||||
|
||||
data.close();
|
||||
}
|
||||
}
|
||||
|
||||
return p.v();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString(IrisRegion dim) {
|
||||
return dim.getLoadKey();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IrisRegion parse(String in, boolean force) throws DecreeParsingException {
|
||||
if (in.equals("null")) {
|
||||
return null;
|
||||
}
|
||||
KList<IrisRegion> options = getPossibilities(in);
|
||||
|
||||
if (options.isEmpty()) {
|
||||
throw new DecreeParsingException("Unable to find Region \"" + in + "\"");
|
||||
}
|
||||
try {
|
||||
return options.stream().filter((i) -> toString(i).equalsIgnoreCase(in)).collect(Collectors.toList()).get(0);
|
||||
} catch (Throwable e) {
|
||||
throw new DecreeParsingException("Unable to filter which Region \"" + in + "\"");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supports(Class<?> type) {
|
||||
return type.equals(IrisRegion.class);
|
||||
public class RegionHandler extends RegistrantHandler<IrisRegion> {
|
||||
public RegionHandler() {
|
||||
super(IrisRegion.class, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -18,59 +18,12 @@
|
||||
|
||||
package com.volmit.iris.util.decree.handlers;
|
||||
|
||||
import com.volmit.iris.Iris;
|
||||
import com.volmit.iris.core.loader.IrisData;
|
||||
import com.volmit.iris.engine.object.IrisScript;
|
||||
import com.volmit.iris.util.collection.KList;
|
||||
import com.volmit.iris.util.collection.KMap;
|
||||
import com.volmit.iris.util.decree.DecreeParameterHandler;
|
||||
import com.volmit.iris.util.decree.exceptions.DecreeParsingException;
|
||||
import com.volmit.iris.util.decree.specialhandlers.RegistrantHandler;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class ScriptHandler implements DecreeParameterHandler<IrisScript> {
|
||||
@Override
|
||||
public KList<IrisScript> getPossibilities() {
|
||||
KMap<String, IrisScript> p = new KMap<>();
|
||||
|
||||
//noinspection ConstantConditions
|
||||
for (File i : Iris.instance.getDataFolder("packs").listFiles()) {
|
||||
if (i.isDirectory()) {
|
||||
IrisData data = IrisData.get(i);
|
||||
for (IrisScript j : data.getScriptLoader().loadAll(data.getScriptLoader().getPossibleKeys())) {
|
||||
p.putIfAbsent(j.getLoadKey(), j);
|
||||
}
|
||||
|
||||
data.close();
|
||||
}
|
||||
}
|
||||
|
||||
return p.v();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString(IrisScript script) {
|
||||
return script.getLoadKey();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IrisScript parse(String in, boolean force) throws DecreeParsingException {
|
||||
KList<IrisScript> options = getPossibilities(in);
|
||||
|
||||
if (options.isEmpty()) {
|
||||
throw new DecreeParsingException("Unable to find Script \"" + in + "\"");
|
||||
}
|
||||
try {
|
||||
return options.stream().filter((i) -> toString(i).equalsIgnoreCase(in)).collect(Collectors.toList()).get(0);
|
||||
} catch (Throwable e) {
|
||||
throw new DecreeParsingException("Unable to filter which Script \"" + in + "\"");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supports(Class<?> type) {
|
||||
return type.equals(IrisScript.class);
|
||||
public class ScriptHandler extends RegistrantHandler<IrisScript> {
|
||||
public ScriptHandler() {
|
||||
super(IrisScript.class, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -18,67 +18,21 @@
|
||||
|
||||
package com.volmit.iris.util.decree.specialhandlers;
|
||||
|
||||
import com.volmit.iris.Iris;
|
||||
import com.volmit.iris.core.IrisSettings;
|
||||
import com.volmit.iris.core.loader.IrisData;
|
||||
import com.volmit.iris.engine.object.IrisDimension;
|
||||
import com.volmit.iris.util.collection.KList;
|
||||
import com.volmit.iris.util.collection.KMap;
|
||||
import com.volmit.iris.util.decree.DecreeParameterHandler;
|
||||
import com.volmit.iris.util.decree.exceptions.DecreeParsingException;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class NullableDimensionHandler implements DecreeParameterHandler<IrisDimension> {
|
||||
@Override
|
||||
public KList<IrisDimension> getPossibilities() {
|
||||
KMap<String, IrisDimension> p = new KMap<>();
|
||||
|
||||
//noinspection ConstantConditions
|
||||
for (File i : Iris.instance.getDataFolder("packs").listFiles()) {
|
||||
if (i.isDirectory()) {
|
||||
IrisData data = IrisData.get(i);
|
||||
for (IrisDimension j : data.getDimensionLoader().loadAll(data.getDimensionLoader().getPossibleKeys())) {
|
||||
p.putIfAbsent(j.getLoadKey(), j);
|
||||
}
|
||||
|
||||
data.close();
|
||||
}
|
||||
}
|
||||
|
||||
return p.v();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString(IrisDimension dim) {
|
||||
return dim.getLoadKey();
|
||||
public class NullableDimensionHandler extends RegistrantHandler<IrisDimension> {
|
||||
public NullableDimensionHandler() {
|
||||
super(IrisDimension.class, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IrisDimension parse(String in, boolean force) throws DecreeParsingException {
|
||||
if (in.equalsIgnoreCase("---"))
|
||||
return null;
|
||||
|
||||
if (in.equalsIgnoreCase("default")) {
|
||||
return parse(IrisSettings.get().getGenerator().getDefaultWorldType());
|
||||
}
|
||||
|
||||
KList<IrisDimension> options = getPossibilities(in);
|
||||
|
||||
|
||||
if (options.isEmpty()) {
|
||||
throw new DecreeParsingException("Unable to find Dimension \"" + in + "\"");
|
||||
}
|
||||
try {
|
||||
return options.stream().filter((i) -> toString(i).equalsIgnoreCase(in)).toList().get(0);
|
||||
} catch (Throwable e) {
|
||||
throw new DecreeParsingException("Unable to filter which Dimension \"" + in + "\"");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supports(Class<?> type) {
|
||||
return type.equals(IrisDimension.class);
|
||||
return super.parse(in, force);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -31,11 +31,15 @@ public class ObjectHandler implements DecreeParameterHandler<String> {
|
||||
@Override
|
||||
public KList<String> getPossibilities() {
|
||||
KList<String> p = new KList<>();
|
||||
IrisData data = data();
|
||||
if (data != null) {
|
||||
return new KList<>(data.getObjectLoader().getPossibleKeys());
|
||||
}
|
||||
|
||||
//noinspection ConstantConditions
|
||||
for (File i : Iris.instance.getDataFolder("packs").listFiles()) {
|
||||
if (i.isDirectory()) {
|
||||
IrisData data = IrisData.get(i);
|
||||
data = IrisData.get(i);
|
||||
p.add(data.getObjectLoader().getPossibleKeys());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,73 @@
|
||||
package com.volmit.iris.util.decree.specialhandlers;
|
||||
|
||||
import com.volmit.iris.Iris;
|
||||
import com.volmit.iris.core.loader.IrisData;
|
||||
import com.volmit.iris.core.loader.IrisRegistrant;
|
||||
import com.volmit.iris.util.collection.KList;
|
||||
import com.volmit.iris.util.decree.DecreeParameterHandler;
|
||||
import com.volmit.iris.util.decree.exceptions.DecreeParsingException;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
public abstract class RegistrantHandler<T extends IrisRegistrant> implements DecreeParameterHandler<T> {
|
||||
private final Class<T> type;
|
||||
private final String name;
|
||||
private final boolean nullable;
|
||||
|
||||
public RegistrantHandler(Class<T> type, boolean nullable) {
|
||||
this.type = type;
|
||||
this.name = type.getSimpleName().replaceFirst("Iris", "");
|
||||
this.nullable = nullable;
|
||||
}
|
||||
|
||||
@Override
|
||||
public KList<T> getPossibilities() {
|
||||
KList<T> p = new KList<>();
|
||||
Set<String> known = new HashSet<>();
|
||||
IrisData data = data();
|
||||
if (data != null) {
|
||||
return data.getLoader(type).loadAll(data.getLoader(type).getPossibleKeys()).qadd(null);
|
||||
}
|
||||
|
||||
//noinspection ConstantConditions
|
||||
for (File i : Iris.instance.getDataFolder("packs").listFiles()) {
|
||||
if (i.isDirectory()) {
|
||||
data = IrisData.get(i);
|
||||
for (T j : data.getLoader(type).loadAll(data.getLoader(type).getPossibleKeys())) {
|
||||
if (known.add(j.getLoadKey()))
|
||||
p.add(j);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return p;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString(T t) {
|
||||
return t != null ? t.getLoadKey() : "null";
|
||||
}
|
||||
|
||||
@Override
|
||||
public T parse(String in, boolean force) throws DecreeParsingException {
|
||||
if (in.equals("null") && nullable) {
|
||||
return null;
|
||||
}
|
||||
KList<T> options = getPossibilities(in);
|
||||
if (options.isEmpty()) {
|
||||
throw new DecreeParsingException("Unable to find " + name + " \"" + in + "\"");
|
||||
}
|
||||
|
||||
return options.stream()
|
||||
.filter((i) -> toString(i).equalsIgnoreCase(in))
|
||||
.findFirst()
|
||||
.orElseThrow(() -> new DecreeParsingException("Unable to filter which " + name + " \"" + in + "\""));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supports(Class<?> type) {
|
||||
return type.equals(this.type);
|
||||
}
|
||||
}
|
||||
@@ -478,21 +478,27 @@ public class VirtualDecreeCommand {
|
||||
}
|
||||
|
||||
DecreeContext.touch(sender);
|
||||
Runnable rx = () -> {
|
||||
try {
|
||||
try {
|
||||
Runnable rx = () -> {
|
||||
DecreeContext.touch(sender);
|
||||
getNode().getMethod().setAccessible(true);
|
||||
getNode().getMethod().invoke(getNode().getInstance(), params);
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
throw new RuntimeException("Failed to execute <INSERT REAL NODE HERE>"); // TODO:
|
||||
}
|
||||
};
|
||||
try {
|
||||
getNode().getMethod().setAccessible(true);
|
||||
getNode().getMethod().invoke(getNode().getInstance(), params);
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
throw new RuntimeException("Failed to execute <INSERT REAL NODE HERE>"); // TODO:
|
||||
} finally {
|
||||
DecreeContext.remove();
|
||||
}
|
||||
};
|
||||
|
||||
if (getNode().isSync()) {
|
||||
J.s(rx);
|
||||
} else {
|
||||
rx.run();
|
||||
if (getNode().isSync()) {
|
||||
J.s(rx);
|
||||
} else {
|
||||
rx.run();
|
||||
}
|
||||
} finally {
|
||||
DecreeContext.remove();
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user