Cleanup sources

This commit is contained in:
cyberpwn
2021-08-16 18:53:01 -04:00
parent af602a414a
commit a462ab98e9
73 changed files with 1235 additions and 1508 deletions

View File

@@ -1,3 +1,21 @@
/*
* Iris is a World Generator for Minecraft Bukkit Servers
* Copyright (c) 2021 Arcane Arts (Volmit Software)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.volmit.iris.util.decree;
import com.volmit.iris.Iris;
@@ -5,19 +23,15 @@ import com.volmit.iris.util.collection.KMap;
import com.volmit.iris.util.plugin.VolmitSender;
public interface DecreeContextHandler<T> {
static KMap<Class<?>, DecreeContextHandler<?>> contextHandlers = buildContextHandlers();
KMap<Class<?>, DecreeContextHandler<?>> contextHandlers = buildContextHandlers();
static KMap<Class<?>, DecreeContextHandler<?>> buildContextHandlers() {
KMap<Class<?>, DecreeContextHandler<?>> contextHandlers = new KMap<>();
try
{
try {
Iris.initialize("com.volmit.iris.util.decree.context").forEach((i)
-> contextHandlers.put(((DecreeContextHandler<?>)i).getType(), (DecreeContextHandler<?>)i));
}
catch(Throwable e)
{
-> contextHandlers.put(((DecreeContextHandler<?>) i).getType(), (DecreeContextHandler<?>) i));
} catch (Throwable e) {
Iris.reportError(e);
e.printStackTrace();
}

View File

@@ -21,28 +21,23 @@ package com.volmit.iris.util.decree;
import com.volmit.iris.core.tools.IrisToolbelt;
import com.volmit.iris.engine.framework.Engine;
import com.volmit.iris.engine.platform.PlatformChunkGenerator;
import com.volmit.iris.util.format.C;
import com.volmit.iris.util.plugin.VolmitSender;
import org.bukkit.World;
import org.bukkit.entity.Player;
public interface DecreeExecutor {
default VolmitSender sender()
{
default VolmitSender sender() {
return DecreeContext.get();
}
default Player player()
{
default Player player() {
return sender().player();
}
default Engine engine()
{
if(sender().isPlayer() && IrisToolbelt.access(sender().player().getWorld()) != null)
{
default Engine engine() {
if (sender().isPlayer() && IrisToolbelt.access(sender().player().getWorld()) != null) {
PlatformChunkGenerator gen = IrisToolbelt.access(sender().player().getWorld());
if (gen != null){
if (gen != null) {
return gen.getEngine();
}
}
@@ -50,24 +45,21 @@ public interface DecreeExecutor {
return null;
}
default PlatformChunkGenerator access()
{
if(sender().isPlayer()) {
default PlatformChunkGenerator access() {
if (sender().isPlayer()) {
return IrisToolbelt.access(world());
}
return null;
}
default World world()
{
if (sender().isPlayer()){
default World world() {
if (sender().isPlayer()) {
return sender().player().getWorld();
}
return null;
}
default <T> T get(T v, T ifUndefined)
{
default <T> T get(T v, T ifUndefined) {
return v == null ? ifUndefined : v;
}
}

View File

@@ -25,7 +25,6 @@ import lombok.Data;
import java.lang.reflect.Method;
import java.lang.reflect.Parameter;
import java.util.Arrays;
@Data
public class DecreeNode {
@@ -37,20 +36,20 @@ public class DecreeNode {
this.instance = instance;
this.method = method;
this.decree = method.getDeclaredAnnotation(Decree.class);
if (decree == null){
if (decree == null) {
throw new RuntimeException("Cannot instantiate DecreeNode on method " + method.getName() + " in " + method.getDeclaringClass().getCanonicalName() + " not annotated by @Decree");
}
}
/**
* Get the parameters of this decree node
*
* @return The list of parameters if ALL are annotated by @{@link Param}, else null
*/
public KList<DecreeParameter> getParameters() {
KList<DecreeParameter> p = new KList<>();
for(Parameter i : method.getParameters())
{
for (Parameter i : method.getParameters()) {
p.add(new DecreeParameter(i));
}
@@ -72,10 +71,8 @@ public class DecreeNode {
public KList<String> getNames() {
KList<String> d = new KList<>();
for(String i : decree.aliases())
{
if(i.isEmpty())
{
for (String i : decree.aliases()) {
if (i.isEmpty()) {
continue;
}

View File

@@ -30,11 +30,12 @@ public enum DecreeOrigin {
/**
* Check if the origin is valid for a sender
*
* @param sender The sender to check
* @return True if valid for origin
*/
public boolean validFor(VolmitSender sender){
if (sender.isPlayer()){
public boolean validFor(VolmitSender sender) {
if (sender.isPlayer()) {
return this.equals(PLAYER) || this.equals(BOTH);
} else {
return this.equals(CONSOLE) || this.equals(BOTH);

View File

@@ -34,7 +34,7 @@ public class DecreeParameter {
public DecreeParameter(Parameter parameter) {
this.parameter = parameter;
this.param = parameter.getDeclaredAnnotation(Param.class);
if (param == null){
if (param == null) {
throw new RuntimeException("Cannot instantiate DecreeParameter on " + parameter.getName() + " in method " + parameter.getDeclaringExecutable().getName() + "(...) in class " + parameter.getDeclaringExecutable().getDeclaringClass().getCanonicalName() + " not annotated by @Param");
}
}
@@ -62,10 +62,8 @@ public class DecreeParameter {
public KList<String> getNames() {
KList<String> d = new KList<>();
for(String i : param.aliases())
{
if(i.isEmpty())
{
for (String i : param.aliases()) {
if (i.isEmpty()) {
continue;
}
@@ -90,8 +88,7 @@ public class DecreeParameter {
KList<?> ff = getHandler().getPossibilities();
ff = ff != null ? ff : new KList<>();
KList<String> f = ff.convert((i) -> getHandler().toStringForce(i));
if(f.isEmpty())
{
if (f.isEmpty()) {
f = new KList<>();
f.add(getHandler().getRandomDefault());
}

View File

@@ -21,19 +21,20 @@ package com.volmit.iris.util.decree;
import com.volmit.iris.util.collection.KList;
import com.volmit.iris.util.decree.exceptions.DecreeParsingException;
import com.volmit.iris.util.decree.exceptions.DecreeWhichException;
import org.jetbrains.annotations.NotNull;
import java.util.concurrent.atomic.AtomicReference;
public interface DecreeParameterHandler<T> {
/**
* Should return the possible values for this type
*
* @return Possibilities for this type.
*/
KList<T> getPossibilities();
/**
* Converting the type back to a string (inverse of the {@link #parse(String) parse} method)
*
* @param t The input of the designated type to convert to a String
* @return The resulting string
*/
@@ -41,25 +42,27 @@ public interface DecreeParameterHandler<T> {
/**
* Forces conversion to the designated type before converting to a string using {@link #toString(T t)}
*
* @param t The object to convert to string (that should be of this type)
* @return The resulting string.
*/
default String toStringForce(Object t)
{
return toString((T)t);
default String toStringForce(Object t) {
return toString((T) t);
}
/**
* 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)
* @throws DecreeWhichException Thrown when multiple results are possible
* @throws DecreeWhichException Thrown when multiple results are possible
*/
T parse(String in) throws DecreeParsingException, DecreeWhichException;
/**
* Returns whether a certain type is supported by this handler<br>
*
* @param type The type to check
* @return True if supported, false if not
*/
@@ -67,13 +70,12 @@ public interface DecreeParameterHandler<T> {
/**
* The possible entries for the inputted string (support for autocomplete on partial entries)
*
* @param input The inputted string to check against
* @return A {@link KList} of possibilities
*/
default KList<T> getPossibilities(String input)
{
if(input.trim().isEmpty())
{
default KList<T> getPossibilities(String input) {
if (input.trim().isEmpty()) {
KList<T> f = getPossibilities();
return f == null ? new KList<>() : f;
}
@@ -82,26 +84,23 @@ public interface DecreeParameterHandler<T> {
KList<T> possible = getPossibilities();
KList<T> matches = new KList<>();
if (possible == null || possible.isEmpty()){
if (possible == null || possible.isEmpty()) {
return matches;
}
if (input.isEmpty())
{
if (input.isEmpty()) {
return getPossibilities();
}
KList<String> converted = possible.convert(v -> toString(v).trim());
for(int i = 0; i < converted.size(); i++)
{
for (int i = 0; i < converted.size(); i++) {
String g = converted.get(i);
// if
// G == I or
// I in G or
// G in I
if(g.equalsIgnoreCase(input) || g.toLowerCase().contains(input.toLowerCase()) || input.toLowerCase().contains(g.toLowerCase()))
{
if (g.equalsIgnoreCase(input) || g.toLowerCase().contains(input.toLowerCase()) || input.toLowerCase().contains(g.toLowerCase())) {
matches.add(possible.get(i));
}
}
@@ -109,54 +108,36 @@ public interface DecreeParameterHandler<T> {
return matches;
}
default String getRandomDefault()
{
default String getRandomDefault() {
return "NOEXAMPLE";
}
default double getMultiplier(AtomicReference<String> g)
{
default double getMultiplier(AtomicReference<String> g) {
double multiplier = 1;
String in = g.get();
boolean valid = true;
while(valid) {
while (valid) {
boolean trim = false;
if (in.toLowerCase().endsWith("k"))
{
if (in.toLowerCase().endsWith("k")) {
multiplier *= 1000;
trim = true;
}
else if(in.toLowerCase().endsWith("m"))
{
} else if (in.toLowerCase().endsWith("m")) {
multiplier *= 1000000;
trim = true;
}
else if(in.toLowerCase().endsWith("h"))
{
} else if (in.toLowerCase().endsWith("h")) {
multiplier *= 100;
trim = true;
}
else if(in.toLowerCase().endsWith("c"))
{
} else if (in.toLowerCase().endsWith("c")) {
multiplier *= 16;
trim = true;
}
else if(in.toLowerCase().endsWith("r"))
{
} else if (in.toLowerCase().endsWith("r")) {
multiplier *= (16 * 32);
trim = true;
}
else {
} else {
valid = false;
}
if(trim)
{
if (trim) {
in = in.substring(0, in.length() - 1);
}
}

View File

@@ -38,12 +38,12 @@ public interface DecreeSystem extends CommandExecutor, TabCompleter {
/**
* The root class to start command searching from
*
* @return
*/
VirtualDecreeCommand getRoot();
default boolean call(VolmitSender sender, String[] args)
{
default boolean call(VolmitSender sender, String[] args) {
DecreeContext.touch(sender);
return getRoot().invoke(sender, enhanceArgs(args));
}
@@ -61,108 +61,77 @@ public interface DecreeSystem extends CommandExecutor, TabCompleter {
@Override
default boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
J.aBukkit(() -> {
if(!call(new VolmitSender(sender), args))
{
if (!call(new VolmitSender(sender), args)) {
sender.sendMessage(C.RED + "Unknown Iris Command");
}
});
return true;
}
static KList<String> enhanceArgs(String[] args)
{
static KList<String> enhanceArgs(String[] args) {
return enhanceArgs(args, true);
}
static KList<String> enhanceArgs(String[] args, boolean trim)
{
static KList<String> enhanceArgs(String[] args, boolean trim) {
KList<String> a = new KList<>();
if(args.length == 0)
{
if (args.length == 0) {
return a;
}
StringBuilder flat = new StringBuilder();
for(String i : args)
{
if(trim)
{
if(i.trim().isEmpty())
{
for (String i : args) {
if (trim) {
if (i.trim().isEmpty()) {
continue;
}
flat.append(" ").append(i.trim());
}
else
{
if(i.endsWith(" "))
{
} else {
if (i.endsWith(" ")) {
flat.append(" ").append(i.trim()).append(" ");
}
}
}
flat = new StringBuilder(flat.length() > 0 ? trim ? flat.toString().trim().length() > 0 ?flat.substring(1).trim() : flat.toString().trim() : flat.substring(1) : flat);
flat = new StringBuilder(flat.length() > 0 ? trim ? flat.toString().trim().length() > 0 ? flat.substring(1).trim() : flat.toString().trim() : flat.substring(1) : flat);
StringBuilder arg = new StringBuilder();
boolean quoting = false;
for(int x = 0; x < flat.length(); x++)
{
for (int x = 0; x < flat.length(); x++) {
char i = flat.charAt(x);
char j = x < flat.length() - 1 ? flat.charAt(x + 1) : i;
boolean hasNext = x < flat.length();
if(i == ' ' && !quoting)
{
if(!arg.toString().trim().isEmpty() && trim)
{
if (i == ' ' && !quoting) {
if (!arg.toString().trim().isEmpty() && trim) {
a.add(arg.toString().trim());
arg = new StringBuilder();
}
}
else if(i == '"')
{
if(!quoting && (arg.length() == 0))
{
} else if (i == '"') {
if (!quoting && (arg.length() == 0)) {
quoting = true;
}
else if(quoting)
{
} else if (quoting) {
quoting = false;
if(hasNext && j == ' ')
{
if(!arg.toString().trim().isEmpty() && trim)
{
if (hasNext && j == ' ') {
if (!arg.toString().trim().isEmpty() && trim) {
a.add(arg.toString().trim());
arg = new StringBuilder();
}
}
else if(!hasNext)
{
if(!arg.toString().trim().isEmpty() && trim)
{
} else if (!hasNext) {
if (!arg.toString().trim().isEmpty() && trim) {
a.add(arg.toString().trim());
arg = new StringBuilder();
}
}
}
}
else
{
} else {
arg.append(i);
}
}
if(!arg.toString().trim().isEmpty() && trim)
{
if (!arg.toString().trim().isEmpty() && trim) {
a.add(arg.toString().trim());
}
@@ -171,14 +140,13 @@ public interface DecreeSystem extends CommandExecutor, TabCompleter {
/**
* Get the handler for the specified type
*
* @param type The type to handle
* @return The corresponding {@link DecreeParameterHandler}, or null
*/
static DecreeParameterHandler<?> getHandler(Class<?> type) {
for(DecreeParameterHandler<?> i : handlers)
{
if(i.supports(type))
{
for (DecreeParameterHandler<?> i : handlers) {
if (i.supports(type)) {
return i;
}
}

View File

@@ -38,6 +38,7 @@ public @interface Decree {
/**
* Only allow if studio mode is enabled
*
* @return defaults to false
*/
boolean studio() default false;

View File

@@ -1,3 +1,21 @@
/*
* Iris is a World Generator for Minecraft Bukkit Servers
* Copyright (c) 2021 Arcane Arts (Volmit Software)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.volmit.iris.util.decree.context;
import com.volmit.iris.core.tools.IrisToolbelt;
@@ -6,14 +24,14 @@ import com.volmit.iris.util.decree.DecreeContextHandler;
import com.volmit.iris.util.plugin.VolmitSender;
public class BiomeContextHandler implements DecreeContextHandler<IrisBiome> {
public Class<IrisBiome> getType(){return IrisBiome.class;}
public Class<IrisBiome> getType() {
return IrisBiome.class;
}
public IrisBiome handle(VolmitSender sender)
{
if(sender.isPlayer()
public IrisBiome handle(VolmitSender sender) {
if (sender.isPlayer()
&& IrisToolbelt.isIrisWorld(sender.player().getWorld())
&& IrisToolbelt.access(sender.player().getWorld()).getEngine() != null)
{
&& IrisToolbelt.access(sender.player().getWorld()).getEngine() != null) {
return IrisToolbelt.access(sender.player().getWorld()).getEngine().getBiome(sender.player().getLocation());
}

View File

@@ -1,3 +1,21 @@
/*
* Iris is a World Generator for Minecraft Bukkit Servers
* Copyright (c) 2021 Arcane Arts (Volmit Software)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.volmit.iris.util.decree.context;
import com.volmit.iris.core.tools.IrisToolbelt;
@@ -6,14 +24,14 @@ import com.volmit.iris.util.decree.DecreeContextHandler;
import com.volmit.iris.util.plugin.VolmitSender;
public class DimensionContextHandler implements DecreeContextHandler<IrisDimension> {
public Class<IrisDimension> getType(){return IrisDimension.class;}
public Class<IrisDimension> getType() {
return IrisDimension.class;
}
public IrisDimension handle(VolmitSender sender)
{
if(sender.isPlayer()
public IrisDimension handle(VolmitSender sender) {
if (sender.isPlayer()
&& IrisToolbelt.isIrisWorld(sender.player().getWorld())
&& IrisToolbelt.access(sender.player().getWorld()).getEngine() != null)
{
&& IrisToolbelt.access(sender.player().getWorld()).getEngine() != null) {
return IrisToolbelt.access(sender.player().getWorld()).getEngine().getDimension();
}

View File

@@ -1,3 +1,21 @@
/*
* Iris is a World Generator for Minecraft Bukkit Servers
* Copyright (c) 2021 Arcane Arts (Volmit Software)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.volmit.iris.util.decree.context;
import com.volmit.iris.core.tools.IrisToolbelt;
@@ -14,10 +32,9 @@ public class GeneratorContextHandler implements DecreeContextHandler<IrisGenerat
@Override
public IrisGenerator handle(VolmitSender sender) {
if(sender.isPlayer()
if (sender.isPlayer()
&& IrisToolbelt.isIrisWorld(sender.player().getWorld())
&& IrisToolbelt.access(sender.player().getWorld()).getEngine() != null)
{
&& IrisToolbelt.access(sender.player().getWorld()).getEngine() != null) {
Engine engine = IrisToolbelt.access(sender.player().getWorld()).getEngine();
return engine.getData().getGeneratorLoader().load(engine.getBiome(sender.player().getLocation()).getGenerators().getRandom().getGenerator());
}

View File

@@ -1,3 +1,21 @@
/*
* Iris is a World Generator for Minecraft Bukkit Servers
* Copyright (c) 2021 Arcane Arts (Volmit Software)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.volmit.iris.util.decree.context;
import com.volmit.iris.core.tools.IrisToolbelt;
@@ -6,14 +24,14 @@ import com.volmit.iris.util.decree.DecreeContextHandler;
import com.volmit.iris.util.plugin.VolmitSender;
public class RegionContextHandler implements DecreeContextHandler<IrisRegion> {
public Class<IrisRegion> getType(){return IrisRegion.class;}
public Class<IrisRegion> getType() {
return IrisRegion.class;
}
public IrisRegion handle(VolmitSender sender)
{
if(sender.isPlayer()
public IrisRegion handle(VolmitSender sender) {
if (sender.isPlayer()
&& IrisToolbelt.isIrisWorld(sender.player().getWorld())
&& IrisToolbelt.access(sender.player().getWorld()).getEngine() != null)
{
&& IrisToolbelt.access(sender.player().getWorld()).getEngine() != null) {
return IrisToolbelt.access(sender.player().getWorld()).getEngine().getRegion(sender.player().getLocation());
}

View File

@@ -1,3 +1,21 @@
/*
* Iris is a World Generator for Minecraft Bukkit Servers
* Copyright (c) 2021 Arcane Arts (Volmit Software)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.volmit.iris.util.decree.context;
import com.volmit.iris.util.decree.DecreeContextHandler;
@@ -5,10 +23,11 @@ import com.volmit.iris.util.plugin.VolmitSender;
import org.bukkit.World;
public class WorldContextHandler implements DecreeContextHandler<World> {
public Class<World> getType(){return World.class;}
public Class<World> getType() {
return World.class;
}
public World handle(VolmitSender sender)
{
public World handle(VolmitSender sender) {
return sender.isPlayer() ? sender.player().getWorld() : null;
}
}

View File

@@ -21,7 +21,7 @@ package com.volmit.iris.util.decree.exceptions;
/**
* Thrown when a decree parameter is parsed, but parsing fails
*/
public class DecreeParsingException extends Exception{
public class DecreeParsingException extends Exception {
public DecreeParsingException(String message) {
super(message);
}

View File

@@ -18,13 +18,11 @@
package com.volmit.iris.util.decree.exceptions;
import com.volmit.iris.util.collection.KList;
/**
* Thrown when more than one option is available for a singular mapping<br>
* Like having a hashmap where one input maps to two outputs.
*/
public class DecreeWhichException extends Exception{
public class DecreeWhichException extends Exception {
public DecreeWhichException() {
super();
}

View File

@@ -21,13 +21,11 @@ package com.volmit.iris.util.decree.handlers;
import com.volmit.iris.Iris;
import com.volmit.iris.core.project.loader.IrisData;
import com.volmit.iris.engine.object.biome.IrisBiome;
import com.volmit.iris.engine.object.dimensional.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.exceptions.DecreeWhichException;
import com.volmit.iris.util.math.RNG;
import java.io.File;
@@ -37,12 +35,10 @@ public class BiomeHandler implements DecreeParameterHandler<IrisBiome> {
KMap<String, IrisBiome> p = new KMap<>();
//noinspection ConstantConditions
for(File i : Iris.instance.getDataFolder("packs").listFiles())
{
if(i.isDirectory()) {
for (File i : Iris.instance.getDataFolder("packs").listFiles()) {
if (i.isDirectory()) {
IrisData data = new IrisData(i, true);
for (IrisBiome j : data.getBiomeLoader().loadAll(data.getBiomeLoader().getPossibleKeys()))
{
for (IrisBiome j : data.getBiomeLoader().loadAll(data.getBiomeLoader().getPossibleKeys())) {
p.putIfAbsent(j.getLoadKey(), j);
}
@@ -60,27 +56,19 @@ public class BiomeHandler implements DecreeParameterHandler<IrisBiome> {
@Override
public IrisBiome parse(String in) throws DecreeParsingException, DecreeWhichException {
try
{
try {
KList<IrisBiome> options = getPossibilities(in);
if(options.isEmpty())
{
if (options.isEmpty()) {
throw new DecreeParsingException("Unable to find Biome \"" + in + "\"");
}
else if(options.size() > 1)
{
} else if (options.size() > 1) {
throw new DecreeWhichException();
}
return options.get(0);
}
catch(DecreeParsingException e){
} catch (DecreeParsingException e) {
throw e;
}
catch(Throwable e)
{
} catch (Throwable e) {
throw new DecreeParsingException("Unable to find Biome \"" + in + "\" because of an uncaught exception: " + e);
}
}
@@ -91,8 +79,7 @@ public class BiomeHandler implements DecreeParameterHandler<IrisBiome> {
}
@Override
public String getRandomDefault()
{
public String getRandomDefault() {
return "biome";
}
}

View File

@@ -30,7 +30,6 @@ import com.volmit.iris.util.plugin.VolmitSender;
import org.bukkit.FluidCollisionMode;
import org.bukkit.entity.Player;
import org.bukkit.util.BlockVector;
import org.bukkit.util.Vector;
public class BlockVectorHandler implements DecreeParameterHandler<BlockVector> {
@Override
@@ -38,8 +37,7 @@ public class BlockVectorHandler implements DecreeParameterHandler<BlockVector> {
KList<BlockVector> vx = new KList<>();
VolmitSender s = DecreeContext.get();
if(s.isPlayer())
{
if (s.isPlayer()) {
vx.add(s.player().getLocation().toVector().toBlockVector());
}
@@ -48,9 +46,8 @@ public class BlockVectorHandler implements DecreeParameterHandler<BlockVector> {
@Override
public String toString(BlockVector v) {
if(v.getY() == 0)
{
return Form.f(v.getBlockX(), 2)+ "," + Form.f(v.getBlockZ(), 2);
if (v.getY() == 0) {
return Form.f(v.getBlockX(), 2) + "," + Form.f(v.getBlockZ(), 2);
}
return Form.f(v.getBlockX(), 2) + "," + Form.f(v.getBlockY(), 2) + "," + Form.f(v.getBlockZ(), 2);
@@ -59,69 +56,43 @@ public class BlockVectorHandler implements DecreeParameterHandler<BlockVector> {
@Override
public BlockVector parse(String in) throws DecreeParsingException, DecreeWhichException {
try {
if (in.contains(","))
{
if (in.contains(",")) {
String[] comp = in.split("\\Q,\\E");
if(comp.length == 2)
{
if (comp.length == 2) {
return new BlockVector(Integer.parseInt(comp[0].trim()), 0, Integer.parseInt(comp[1].trim()));
}
else if(comp.length == 3)
{
} else if (comp.length == 3) {
return new BlockVector(Integer.parseInt(comp[0].trim()),
Integer.parseInt(comp[1].trim()),
Integer.parseInt(comp[2].trim()));
}
else
{
} else {
throw new DecreeParsingException("Could not parse components for vector. You have " + comp.length + " components. Expected 2 or 3.");
}
}
else if(in.equalsIgnoreCase("here") ||in.equalsIgnoreCase("me") ||in.equalsIgnoreCase("self"))
{
if(!DecreeContext.get().isPlayer())
{
} else if (in.equalsIgnoreCase("here") || in.equalsIgnoreCase("me") || in.equalsIgnoreCase("self")) {
if (!DecreeContext.get().isPlayer()) {
throw new DecreeParsingException("You cannot specify me,self,here as a console.");
}
return DecreeContext.get().player().getLocation().toVector().toBlockVector();
}
else if(in.equalsIgnoreCase("look") ||in.equalsIgnoreCase("cursor") ||in.equalsIgnoreCase("crosshair"))
{
if(!DecreeContext.get().isPlayer())
{
} else if (in.equalsIgnoreCase("look") || in.equalsIgnoreCase("cursor") || in.equalsIgnoreCase("crosshair")) {
if (!DecreeContext.get().isPlayer()) {
throw new DecreeParsingException("You cannot specify look,cursor,crosshair as a console.");
}
return DecreeContext.get().player().getTargetBlockExact(256, FluidCollisionMode.NEVER).getLocation().toVector().toBlockVector();
}
else if(in.trim().toLowerCase().startsWith("player:"))
{
} else if (in.trim().toLowerCase().startsWith("player:")) {
String v = in.trim().split("\\Q:\\E")[1];
KList<?> px = DecreeSystem.getHandler(Player.class).getPossibilities(v);
if(px != null && px.isNotEmpty())
{
return ((Player)px.get(0)).getLocation().toVector().toBlockVector();
}
else if(px == null || px.isEmpty())
{
if (px != null && px.isNotEmpty()) {
return ((Player) px.get(0)).getLocation().toVector().toBlockVector();
} else if (px == null || px.isEmpty()) {
throw new DecreeParsingException("Cannot find player: " + v);
}
}
}
catch(Throwable e)
{
} catch (Throwable e) {
throw new DecreeParsingException("Unable to get Vector for \"" + in + "\" because of an uncaught exception: " + e);
}
@@ -134,8 +105,7 @@ public class BlockVectorHandler implements DecreeParameterHandler<BlockVector> {
}
@Override
public String getRandomDefault()
{
public String getRandomDefault() {
return M.r(0.5) ? "0,0" : "0,0,0";
}
}

View File

@@ -22,7 +22,6 @@ import com.volmit.iris.util.collection.KList;
import com.volmit.iris.util.decree.DecreeParameterHandler;
import com.volmit.iris.util.decree.exceptions.DecreeParsingException;
import com.volmit.iris.util.math.M;
import com.volmit.iris.util.math.RNG;
public class BooleanHandler implements DecreeParameterHandler<Boolean> {
@Override
@@ -37,13 +36,9 @@ public class BooleanHandler implements DecreeParameterHandler<Boolean> {
@Override
public Boolean parse(String in) throws DecreeParsingException {
try
{
try {
return Boolean.parseBoolean(in);
}
catch(Throwable e)
{
} catch (Throwable e) {
throw new DecreeParsingException("Unable to parse boolean \"" + in + "\"");
}
}
@@ -54,8 +49,7 @@ public class BooleanHandler implements DecreeParameterHandler<Boolean> {
}
@Override
public String getRandomDefault()
{
public String getRandomDefault() {
return M.r(0.5) + "";
}
}

View File

@@ -36,13 +36,9 @@ public class ByteHandler implements DecreeParameterHandler<Byte> {
@Override
public Byte parse(String in) throws DecreeParsingException {
try
{
try {
return Byte.parseByte(in);
}
catch(Throwable e)
{
} catch (Throwable e) {
throw new DecreeParsingException("Unable to parse byte \"" + in + "\"");
}
}
@@ -53,8 +49,7 @@ public class ByteHandler implements DecreeParameterHandler<Byte> {
}
@Override
public String getRandomDefault()
{
public String getRandomDefault() {
return RNG.r.i(0, Byte.MAX_VALUE) + "";
}
}

View File

@@ -26,8 +26,6 @@ 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.exceptions.DecreeWhichException;
import org.bukkit.Bukkit;
import org.bukkit.World;
import java.io.File;
@@ -37,12 +35,10 @@ public class DimensionHandler implements DecreeParameterHandler<IrisDimension> {
KMap<String, IrisDimension> p = new KMap<>();
//noinspection ConstantConditions
for(File i : Iris.instance.getDataFolder("packs").listFiles())
{
if(i.isDirectory()) {
for (File i : Iris.instance.getDataFolder("packs").listFiles()) {
if (i.isDirectory()) {
IrisData data = new IrisData(i, true);
for (IrisDimension j : data.getDimensionLoader().loadAll(data.getDimensionLoader().getPossibleKeys()))
{
for (IrisDimension j : data.getDimensionLoader().loadAll(data.getDimensionLoader().getPossibleKeys())) {
p.putIfAbsent(j.getLoadKey(), j);
}
@@ -60,27 +56,19 @@ public class DimensionHandler implements DecreeParameterHandler<IrisDimension> {
@Override
public IrisDimension parse(String in) throws DecreeParsingException, DecreeWhichException {
try
{
try {
KList<IrisDimension> options = getPossibilities(in);
if(options.isEmpty())
{
if (options.isEmpty()) {
throw new DecreeParsingException("Unable to find Dimension \"" + in + "\"");
}
else if(options.size() > 1)
{
} else if (options.size() > 1) {
throw new DecreeWhichException();
}
return options.get(0);
}
catch(DecreeParsingException e){
} catch (DecreeParsingException e) {
throw e;
}
catch(Throwable e)
{
} catch (Throwable e) {
throw new DecreeParsingException("Unable to find Dimension \"" + in + "\" because of an uncaught exception: " + e);
}
}
@@ -91,8 +79,7 @@ public class DimensionHandler implements DecreeParameterHandler<IrisDimension> {
}
@Override
public String getRandomDefault()
{
public String getRandomDefault() {
return "dimension";
}
}

View File

@@ -34,15 +34,11 @@ public class DoubleHandler implements DecreeParameterHandler<Double> {
@Override
public Double parse(String in) throws DecreeParsingException {
try
{
try {
AtomicReference<String> r = new AtomicReference<>(in);
double m = getMultiplier(r);
return Double.parseDouble(r.get()) * m;
}
catch(Throwable e)
{
} catch (Throwable e) {
throw new DecreeParsingException("Unable to parse double \"" + in + "\"");
}
}
@@ -58,8 +54,7 @@ public class DoubleHandler implements DecreeParameterHandler<Double> {
}
@Override
public String getRandomDefault()
{
public String getRandomDefault() {
return Form.f(RNG.r.d(0, 99.99), 1) + "";
}
}

View File

@@ -1,8 +1,25 @@
/*
* Iris is a World Generator for Minecraft Bukkit Servers
* Copyright (c) 2021 Arcane Arts (Volmit Software)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.volmit.iris.util.decree.handlers;
import com.volmit.iris.Iris;
import com.volmit.iris.core.project.loader.IrisData;
import com.volmit.iris.engine.object.dimensional.IrisDimension;
import com.volmit.iris.engine.object.entity.IrisEntity;
import com.volmit.iris.util.collection.KList;
import com.volmit.iris.util.collection.KMap;
@@ -24,12 +41,10 @@ public class EntityHandler implements DecreeParameterHandler<IrisEntity> {
KMap<String, IrisEntity> p = new KMap<>();
//noinspection ConstantConditions
for(File i : Iris.instance.getDataFolder("packs").listFiles())
{
if(i.isDirectory()) {
for (File i : Iris.instance.getDataFolder("packs").listFiles()) {
if (i.isDirectory()) {
IrisData data = new IrisData(i, true);
for (IrisEntity j : data.getEntityLoader().loadAll(data.getEntityLoader().getPossibleKeys()))
{
for (IrisEntity j : data.getEntityLoader().loadAll(data.getEntityLoader().getPossibleKeys())) {
p.putIfAbsent(j.getLoadKey(), j);
}
@@ -61,27 +76,19 @@ public class EntityHandler implements DecreeParameterHandler<IrisEntity> {
*/
@Override
public IrisEntity parse(String in) throws DecreeParsingException, DecreeWhichException {
try
{
try {
KList<IrisEntity> options = getPossibilities(in);
if(options.isEmpty())
{
if (options.isEmpty()) {
throw new DecreeParsingException("Unable to find Entity \"" + in + "\"");
}
else if(options.size() > 1)
{
} else if (options.size() > 1) {
throw new DecreeWhichException();
}
return options.get(0);
}
catch(DecreeParsingException e){
} catch (DecreeParsingException e) {
throw e;
}
catch(Throwable e)
{
} catch (Throwable e) {
throw new DecreeParsingException("Unable to find Entity \"" + in + "\" because of an uncaught exception: " + e);
}
}
@@ -98,8 +105,7 @@ public class EntityHandler implements DecreeParameterHandler<IrisEntity> {
}
@Override
public String getRandomDefault()
{
public String getRandomDefault() {
return "entity";
}
}

View File

@@ -34,15 +34,11 @@ public class FloatHandler implements DecreeParameterHandler<Float> {
@Override
public Float parse(String in) throws DecreeParsingException {
try
{
try {
AtomicReference<String> r = new AtomicReference<>(in);
double m = getMultiplier(r);
return (float)(Float.parseFloat(r.get()) * m);
}
catch(Throwable e)
{
return (float) (Float.parseFloat(r.get()) * m);
} catch (Throwable e) {
throw new DecreeParsingException("Unable to parse float \"" + in + "\"");
}
}
@@ -58,8 +54,7 @@ public class FloatHandler implements DecreeParameterHandler<Float> {
}
@Override
public String getRandomDefault()
{
public String getRandomDefault() {
return Form.f(RNG.r.d(0, 99.99), 1) + "";
}
}

View File

@@ -1,3 +1,21 @@
/*
* Iris is a World Generator for Minecraft Bukkit Servers
* Copyright (c) 2021 Arcane Arts (Volmit Software)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.volmit.iris.util.decree.handlers;
import com.volmit.iris.Iris;
@@ -17,12 +35,10 @@ public class GeneratorHandler implements DecreeParameterHandler<IrisGenerator> {
KMap<String, IrisGenerator> p = new KMap<>();
//noinspection ConstantConditions
for(File i : Iris.instance.getDataFolder("packs").listFiles())
{
if(i.isDirectory()) {
for (File i : Iris.instance.getDataFolder("packs").listFiles()) {
if (i.isDirectory()) {
IrisData data = new IrisData(i, true);
for (IrisGenerator j : data.getGeneratorLoader().loadAll(data.getGeneratorLoader().getPossibleKeys()))
{
for (IrisGenerator j : data.getGeneratorLoader().loadAll(data.getGeneratorLoader().getPossibleKeys())) {
p.putIfAbsent(j.getLoadKey(), j);
}
@@ -40,27 +56,19 @@ public class GeneratorHandler implements DecreeParameterHandler<IrisGenerator> {
@Override
public IrisGenerator parse(String in) throws DecreeParsingException, DecreeWhichException {
try
{
try {
KList<IrisGenerator> options = getPossibilities(in);
if(options.isEmpty())
{
if (options.isEmpty()) {
throw new DecreeParsingException("Unable to find Generator \"" + in + "\"");
}
else if(options.size() > 1)
{
} else if (options.size() > 1) {
throw new DecreeWhichException();
}
return options.get(0);
}
catch(DecreeParsingException e){
} catch (DecreeParsingException e) {
throw e;
}
catch(Throwable e)
{
} catch (Throwable e) {
throw new DecreeParsingException("Unable to find Generator \"" + in + "\" because of an uncaught exception: " + e);
}
}
@@ -71,8 +79,7 @@ public class GeneratorHandler implements DecreeParameterHandler<IrisGenerator> {
}
@Override
public String getRandomDefault()
{
public String getRandomDefault() {
return "generator";
}
}

View File

@@ -21,10 +21,8 @@ package com.volmit.iris.util.decree.handlers;
import com.volmit.iris.util.collection.KList;
import com.volmit.iris.util.decree.DecreeParameterHandler;
import com.volmit.iris.util.decree.exceptions.DecreeParsingException;
import com.volmit.iris.util.format.Form;
import com.volmit.iris.util.math.RNG;
import java.util.Locale;
import java.util.concurrent.atomic.AtomicReference;
public class IntegerHandler implements DecreeParameterHandler<Integer> {
@@ -35,15 +33,11 @@ public class IntegerHandler implements DecreeParameterHandler<Integer> {
@Override
public Integer parse(String in) throws DecreeParsingException {
try
{
try {
AtomicReference<String> r = new AtomicReference<>(in);
double m = getMultiplier(r);
return (int)(Integer.valueOf(r.get()).doubleValue() * m);
}
catch(Throwable e)
{
return (int) (Integer.valueOf(r.get()).doubleValue() * m);
} catch (Throwable e) {
throw new DecreeParsingException("Unable to parse integer \"" + in + "\"");
}
}
@@ -59,8 +53,7 @@ public class IntegerHandler implements DecreeParameterHandler<Integer> {
}
@Override
public String getRandomDefault()
{
public String getRandomDefault() {
return RNG.r.i(0, 99) + "";
}
}

View File

@@ -33,15 +33,11 @@ public class LongHandler implements DecreeParameterHandler<Long> {
@Override
public Long parse(String in) throws DecreeParsingException {
try
{
try {
AtomicReference<String> r = new AtomicReference<>(in);
double m = getMultiplier(r);
return (long)(Long.valueOf(r.get()).doubleValue() * m);
}
catch(Throwable e)
{
return (long) (Long.valueOf(r.get()).doubleValue() * m);
} catch (Throwable e) {
throw new DecreeParsingException("Unable to parse long \"" + in + "\"");
}
}
@@ -57,8 +53,7 @@ public class LongHandler implements DecreeParameterHandler<Long> {
}
@Override
public String getRandomDefault()
{
public String getRandomDefault() {
return RNG.r.i(0, 99) + "";
}
}

View File

@@ -40,25 +40,17 @@ public class PlayerHandler implements DecreeParameterHandler<Player> {
@Override
public Player parse(String in) throws DecreeParsingException, DecreeWhichException {
try
{
try {
KList<Player> options = getPossibilities(in);
if(options.isEmpty())
{
if (options.isEmpty()) {
throw new DecreeParsingException("Unable to find Player \"" + in + "\"");
}
else if(options.size() > 1)
{
} else if (options.size() > 1) {
throw new DecreeWhichException();
}
return options.get(0);
}
catch(Throwable e)
{
} catch (Throwable e) {
throw new DecreeParsingException("Unable to find Player \"" + in + "\" because of an uncaught exception: " + e);
}
}
@@ -69,8 +61,7 @@ public class PlayerHandler implements DecreeParameterHandler<Player> {
}
@Override
public String getRandomDefault()
{
public String getRandomDefault() {
return "playername";
}
}

View File

@@ -35,12 +35,10 @@ public class RegionHandler implements DecreeParameterHandler<IrisRegion> {
KMap<String, IrisRegion> p = new KMap<>();
//noinspection ConstantConditions
for(File i : Iris.instance.getDataFolder("packs").listFiles())
{
if(i.isDirectory()) {
for (File i : Iris.instance.getDataFolder("packs").listFiles()) {
if (i.isDirectory()) {
IrisData data = new IrisData(i, true);
for (IrisRegion j : data.getRegionLoader().loadAll(data.getRegionLoader().getPossibleKeys()))
{
for (IrisRegion j : data.getRegionLoader().loadAll(data.getRegionLoader().getPossibleKeys())) {
p.putIfAbsent(j.getLoadKey(), j);
}
@@ -58,27 +56,19 @@ public class RegionHandler implements DecreeParameterHandler<IrisRegion> {
@Override
public IrisRegion parse(String in) throws DecreeParsingException, DecreeWhichException {
try
{
try {
KList<IrisRegion> options = getPossibilities(in);
if(options.isEmpty())
{
if (options.isEmpty()) {
throw new DecreeParsingException("Unable to find Region \"" + in + "\"");
}
else if(options.size() > 1)
{
} else if (options.size() > 1) {
throw new DecreeWhichException();
}
return options.get(0);
}
catch(DecreeParsingException e){
} catch (DecreeParsingException e) {
throw e;
}
catch(Throwable e)
{
} catch (Throwable e) {
throw new DecreeParsingException("Unable to find Region \"" + in + "\" because of an uncaught exception: " + e);
}
}
@@ -89,8 +79,7 @@ public class RegionHandler implements DecreeParameterHandler<IrisRegion> {
}
@Override
public String getRandomDefault()
{
public String getRandomDefault() {
return "region";
}
}

View File

@@ -1,3 +1,21 @@
/*
* Iris is a World Generator for Minecraft Bukkit Servers
* Copyright (c) 2021 Arcane Arts (Volmit Software)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.volmit.iris.util.decree.handlers;
import com.volmit.iris.Iris;
@@ -17,12 +35,10 @@ public class ScriptHandler implements DecreeParameterHandler<IrisScript> {
KMap<String, IrisScript> p = new KMap<>();
//noinspection ConstantConditions
for(File i : Iris.instance.getDataFolder("packs").listFiles())
{
if(i.isDirectory()) {
for (File i : Iris.instance.getDataFolder("packs").listFiles()) {
if (i.isDirectory()) {
IrisData data = new IrisData(i, true);
for (IrisScript j : data.getScriptLoader().loadAll(data.getScriptLoader().getPossibleKeys()))
{
for (IrisScript j : data.getScriptLoader().loadAll(data.getScriptLoader().getPossibleKeys())) {
p.putIfAbsent(j.getLoadKey(), j);
}
@@ -40,27 +56,19 @@ public class ScriptHandler implements DecreeParameterHandler<IrisScript> {
@Override
public IrisScript parse(String in) throws DecreeParsingException, DecreeWhichException {
try
{
try {
KList<IrisScript> options = getPossibilities(in);
if(options.isEmpty())
{
if (options.isEmpty()) {
throw new DecreeParsingException("Unable to find Script \"" + in + "\"");
}
else if(options.size() > 1)
{
} else if (options.size() > 1) {
throw new DecreeWhichException();
}
return options.get(0);
}
catch(DecreeParsingException e){
} catch (DecreeParsingException e) {
throw e;
}
catch(Throwable e)
{
} catch (Throwable e) {
throw new DecreeParsingException("Unable to find Script \"" + in + "\" because of an uncaught exception: " + e);
}
}
@@ -71,8 +79,7 @@ public class ScriptHandler implements DecreeParameterHandler<IrisScript> {
}
@Override
public String getRandomDefault()
{
public String getRandomDefault() {
return "script";
}
}

View File

@@ -33,15 +33,11 @@ public class ShortHandler implements DecreeParameterHandler<Short> {
@Override
public Short parse(String in) throws DecreeParsingException {
try
{
try {
AtomicReference<String> r = new AtomicReference<>(in);
double m = getMultiplier(r);
return (short)(Short.valueOf(r.get()).doubleValue() * m);
}
catch(Throwable e)
{
return (short) (Short.valueOf(r.get()).doubleValue() * m);
} catch (Throwable e) {
throw new DecreeParsingException("Unable to parse short \"" + in + "\"");
}
}
@@ -57,8 +53,7 @@ public class ShortHandler implements DecreeParameterHandler<Short> {
}
@Override
public String getRandomDefault()
{
public String getRandomDefault() {
return RNG.r.i(0, 99) + "";
}
}

View File

@@ -21,7 +21,6 @@ package com.volmit.iris.util.decree.handlers;
import com.volmit.iris.util.collection.KList;
import com.volmit.iris.util.decree.DecreeParameterHandler;
import com.volmit.iris.util.decree.exceptions.DecreeParsingException;
import com.volmit.iris.util.math.RNG;
/**
* Abstraction can sometimes breed stupidity
@@ -48,8 +47,7 @@ public class StringHandler implements DecreeParameterHandler<String> {
}
@Override
public String getRandomDefault()
{
public String getRandomDefault() {
return new KList<String>().qadd("text").qadd("string")
.qadd("blah").qadd("derp").qadd("yolo").getRandom();
}

View File

@@ -27,23 +27,18 @@ import com.volmit.iris.util.decree.exceptions.DecreeWhichException;
import com.volmit.iris.util.format.Form;
import com.volmit.iris.util.math.M;
import com.volmit.iris.util.plugin.VolmitSender;
import org.bukkit.Bukkit;
import org.bukkit.FluidCollisionMode;
import org.bukkit.World;
import org.bukkit.entity.Player;
import org.bukkit.util.BlockVector;
import org.bukkit.util.Vector;
import java.util.Locale;
public class VectorHandler implements DecreeParameterHandler<Vector> {
@Override
public KList<Vector> getPossibilities() {
KList<Vector> vx = new KList<>();
VolmitSender s = DecreeContext.get();
if(s.isPlayer())
{
if (s.isPlayer()) {
vx.add(s.player().getLocation().toVector());
}
@@ -52,9 +47,8 @@ public class VectorHandler implements DecreeParameterHandler<Vector> {
@Override
public String toString(Vector v) {
if(v.getY() == 0)
{
return Form.f(v.getX(), 2)+ "," + Form.f(v.getZ(), 2);
if (v.getY() == 0) {
return Form.f(v.getX(), 2) + "," + Form.f(v.getZ(), 2);
}
return Form.f(v.getX(), 2) + "," + Form.f(v.getY(), 2) + "," + Form.f(v.getZ(), 2);
@@ -63,69 +57,43 @@ public class VectorHandler implements DecreeParameterHandler<Vector> {
@Override
public Vector parse(String in) throws DecreeParsingException, DecreeWhichException {
try {
if (in.contains(","))
{
if (in.contains(",")) {
String[] comp = in.split("\\Q,\\E");
if(comp.length == 2)
{
if (comp.length == 2) {
return new BlockVector(Double.parseDouble(comp[0].trim()), 0, Double.parseDouble(comp[1].trim()));
}
else if(comp.length == 3)
{
} else if (comp.length == 3) {
return new BlockVector(Double.parseDouble(comp[0].trim()),
Double.parseDouble(comp[1].trim()),
Double.parseDouble(comp[2].trim()));
}
else
{
} else {
throw new DecreeParsingException("Could not parse components for vector. You have " + comp.length + " components. Expected 2 or 3.");
}
}
else if(in.equalsIgnoreCase("here") ||in.equalsIgnoreCase("me") ||in.equalsIgnoreCase("self"))
{
if(!DecreeContext.get().isPlayer())
{
} else if (in.equalsIgnoreCase("here") || in.equalsIgnoreCase("me") || in.equalsIgnoreCase("self")) {
if (!DecreeContext.get().isPlayer()) {
throw new DecreeParsingException("You cannot specify me,self,here as a console.");
}
return DecreeContext.get().player().getLocation().toVector();
}
else if(in.equalsIgnoreCase("look") ||in.equalsIgnoreCase("cursor") ||in.equalsIgnoreCase("crosshair"))
{
if(!DecreeContext.get().isPlayer())
{
} else if (in.equalsIgnoreCase("look") || in.equalsIgnoreCase("cursor") || in.equalsIgnoreCase("crosshair")) {
if (!DecreeContext.get().isPlayer()) {
throw new DecreeParsingException("You cannot specify look,cursor,crosshair as a console.");
}
return DecreeContext.get().player().getTargetBlockExact(256, FluidCollisionMode.NEVER).getLocation().toVector();
}
else if(in.trim().toLowerCase().startsWith("player:"))
{
} else if (in.trim().toLowerCase().startsWith("player:")) {
String v = in.trim().split("\\Q:\\E")[1];
KList<?> px = DecreeSystem.getHandler(Player.class).getPossibilities(v);
if(px != null && px.isNotEmpty())
{
return ((Player)px.get(0)).getLocation().toVector();
}
else if(px == null || px.isEmpty())
{
if (px != null && px.isNotEmpty()) {
return ((Player) px.get(0)).getLocation().toVector();
} else if (px == null || px.isEmpty()) {
throw new DecreeParsingException("Cannot find player: " + v);
}
}
}
catch(Throwable e)
{
} catch (Throwable e) {
throw new DecreeParsingException("Unable to get Vector for \"" + in + "\" because of an uncaught exception: " + e);
}
@@ -138,8 +106,7 @@ public class VectorHandler implements DecreeParameterHandler<Vector> {
}
@Override
public String getRandomDefault()
{
public String getRandomDefault() {
return M.r(0.5) ? "0,0" : "0,0,0";
}
}

View File

@@ -38,27 +38,19 @@ public class WorldHandler implements DecreeParameterHandler<World> {
@Override
public World parse(String in) throws DecreeParsingException, DecreeWhichException {
try
{
try {
KList<World> options = getPossibilities(in);
if(options.isEmpty())
{
if (options.isEmpty()) {
throw new DecreeParsingException("Unable to find World \"" + in + "\"");
}
else if(options.size() > 1)
{
} else if (options.size() > 1) {
throw new DecreeWhichException();
}
return options.get(0);
}
catch(DecreeParsingException e){
} catch (DecreeParsingException e) {
throw e;
}
catch(Throwable e)
{
} catch (Throwable e) {
throw new DecreeParsingException("Unable to find World \"" + in + "\" because of an uncaught exception: " + e);
}
}
@@ -69,8 +61,7 @@ public class WorldHandler implements DecreeParameterHandler<World> {
}
@Override
public String getRandomDefault()
{
public String getRandomDefault() {
return "world";
}
}

View File

@@ -22,7 +22,10 @@ import com.volmit.iris.Iris;
import com.volmit.iris.core.IrisSettings;
import com.volmit.iris.util.collection.KList;
import com.volmit.iris.util.collection.KMap;
import com.volmit.iris.util.decree.*;
import com.volmit.iris.util.decree.DecreeContext;
import com.volmit.iris.util.decree.DecreeContextHandler;
import com.volmit.iris.util.decree.DecreeNode;
import com.volmit.iris.util.decree.DecreeParameter;
import com.volmit.iris.util.decree.annotations.Decree;
import com.volmit.iris.util.decree.exceptions.DecreeParsingException;
import com.volmit.iris.util.decree.exceptions.DecreeWhichException;
@@ -31,15 +34,10 @@ import com.volmit.iris.util.format.Form;
import com.volmit.iris.util.plugin.VolmitSender;
import com.volmit.iris.util.scheduling.J;
import lombok.Data;
import lombok.Getter;
import org.apache.logging.log4j.core.impl.ThrowableFormatOptions;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.util.Arrays;
import java.util.Locale;
import java.util.Objects;
@Data
@@ -49,8 +47,7 @@ public class VirtualDecreeCommand {
private final KList<VirtualDecreeCommand> nodes;
private final DecreeNode node;
private VirtualDecreeCommand(Class<?> type, VirtualDecreeCommand parent, KList<VirtualDecreeCommand> nodes, DecreeNode node)
{
private VirtualDecreeCommand(Class<?> type, VirtualDecreeCommand parent, KList<VirtualDecreeCommand> nodes, DecreeNode node) {
this.parent = parent;
this.type = type;
this.nodes = nodes;
@@ -64,23 +61,19 @@ public class VirtualDecreeCommand {
public static VirtualDecreeCommand createRoot(VirtualDecreeCommand parent, Object v) throws Throwable {
VirtualDecreeCommand c = new VirtualDecreeCommand(v.getClass(), parent, new KList<>(), null);
for(Field i : v.getClass().getDeclaredFields())
{
if(Modifier.isStatic(i.getModifiers()) || Modifier.isFinal(i.getModifiers())|| Modifier.isTransient(i.getModifiers())|| Modifier.isVolatile(i.getModifiers()))
{
for (Field i : v.getClass().getDeclaredFields()) {
if (Modifier.isStatic(i.getModifiers()) || Modifier.isFinal(i.getModifiers()) || Modifier.isTransient(i.getModifiers()) || Modifier.isVolatile(i.getModifiers())) {
continue;
}
if(!i.getType().isAnnotationPresent(Decree.class))
{
if (!i.getType().isAnnotationPresent(Decree.class)) {
continue;
}
i.setAccessible(true);
Object childRoot = i.get(v);
if(childRoot == null)
{
if (childRoot == null) {
childRoot = i.getType().getConstructor().newInstance();
i.set(v, childRoot);
}
@@ -88,15 +81,12 @@ public class VirtualDecreeCommand {
c.getNodes().add(createRoot(c, childRoot));
}
for(Method i : v.getClass().getDeclaredMethods())
{
if(Modifier.isStatic(i.getModifiers()) || Modifier.isFinal(i.getModifiers()) || Modifier.isPrivate(i.getModifiers()))
{
for (Method i : v.getClass().getDeclaredMethods()) {
if (Modifier.isStatic(i.getModifiers()) || Modifier.isFinal(i.getModifiers()) || Modifier.isPrivate(i.getModifiers())) {
continue;
}
if(!i.isAnnotationPresent(Decree.class))
{
if (!i.isAnnotationPresent(Decree.class)) {
continue;
}
@@ -106,13 +96,11 @@ public class VirtualDecreeCommand {
return c;
}
public String getPath()
{
public String getPath() {
KList<String> n = new KList<>();
VirtualDecreeCommand cursor = this;
while(cursor.getParent() != null)
{
while (cursor.getParent() != null) {
cursor = cursor.getParent();
n.add(cursor.getName());
}
@@ -120,13 +108,11 @@ public class VirtualDecreeCommand {
return "/" + n.reverse().qadd(getName()).toString(" ");
}
public String getParentPath()
{
return getParent().getPath();
public String getParentPath() {
return getParent().getPath();
}
public String getName()
{
public String getName() {
return isNode() ? getNode().getName() : getType().getDeclaredAnnotation(Decree.class).name();
}
@@ -134,24 +120,19 @@ public class VirtualDecreeCommand {
return isNode() ? getNode().getDecree().studio() : getType().getDeclaredAnnotation(Decree.class).studio();
}
public String getDescription()
{
public String getDescription() {
return isNode() ? getNode().getDescription() : getType().getDeclaredAnnotation(Decree.class).description();
}
public KList<String> getNames()
{
if(isNode())
{
public KList<String> getNames() {
if (isNode()) {
return getNode().getNames();
}
KList<String> d = new KList<>();
Decree dc = getType().getDeclaredAnnotation(Decree.class);
for(String i : dc.aliases())
{
if(i.isEmpty())
{
for (String i : dc.aliases()) {
if (i.isEmpty()) {
continue;
}
@@ -164,56 +145,45 @@ public class VirtualDecreeCommand {
return d;
}
public boolean isNode()
{
public boolean isNode() {
return node != null;
}
public KList<String> tabComplete(KList<String> args, String raw)
{
public KList<String> tabComplete(KList<String> args, String raw) {
KList<Integer> skip = new KList<>();
KList<String> tabs = new KList<>();
invokeTabComplete(args, skip, tabs, raw);
return tabs;
}
private boolean invokeTabComplete(KList<String> args, KList<Integer> skip, KList<String> tabs, String raw)
{
if(isStudio() && !IrisSettings.get().isStudio())
{
private boolean invokeTabComplete(KList<String> args, KList<Integer> skip, KList<String> tabs, String raw) {
if (isStudio() && !IrisSettings.get().isStudio()) {
return false;
}
if(isNode())
{
if (isNode()) {
tab(args, tabs);
skip.add(hashCode());
return false;
}
if(args.isEmpty())
{
if (args.isEmpty()) {
tab(args, tabs);
return true;
}
String head = args.get(0);
if (args.size() > 1 || head.endsWith(" "))
{
if (args.size() > 1 || head.endsWith(" ")) {
VirtualDecreeCommand match = matchNode(head, skip);
if(match != null)
{
if (match != null) {
args.pop();
return match.invokeTabComplete(args, skip, tabs, raw);
}
skip.add(hashCode());
}
else
{
} else {
tab(args, tabs);
}
@@ -226,22 +196,18 @@ public class VirtualDecreeCommand {
Runnable la = () -> {
};
for(String a : args)
{
for (String a : args) {
la.run();
last = a;
la = () -> {
if(isNode())
{
if (isNode()) {
String sea = a.contains("=") ? a.split("\\Q=\\E")[0] : a;
sea = sea.trim();
searching: for(DecreeParameter i : getNode().getParameters())
{
for(String m : i.getNames())
{
if(m.equalsIgnoreCase(sea) || m.toLowerCase().contains(sea.toLowerCase()) || sea.toLowerCase().contains(m.toLowerCase()))
{
searching:
for (DecreeParameter i : getNode().getParameters()) {
for (String m : i.getNames()) {
if (m.equalsIgnoreCase(sea) || m.toLowerCase().contains(sea.toLowerCase()) || sea.toLowerCase().contains(m.toLowerCase())) {
ignore.add(i);
continue searching;
}
@@ -251,52 +217,37 @@ public class VirtualDecreeCommand {
};
}
if(last != null)
{
if (last != null) {
if (isNode()) {
for(DecreeParameter i : getNode().getParameters())
{
if(ignore.contains(i))
{
for (DecreeParameter i : getNode().getParameters()) {
if (ignore.contains(i)) {
continue;
}
int g = 0;
if(last.contains("="))
{
if (last.contains("=")) {
String[] vv = last.trim().split("\\Q=\\E");
String vx = vv.length == 2 ? vv[1] : "";
for(String f : i.getHandler().getPossibilities(vx).convert((v) -> i.getHandler().toStringForce(v)))
{
for (String f : i.getHandler().getPossibilities(vx).convert((v) -> i.getHandler().toStringForce(v))) {
g++;
tabs.add(i.getName() +"="+ f);
tabs.add(i.getName() + "=" + f);
}
} else {
for (String f : i.getHandler().getPossibilities("").convert((v) -> i.getHandler().toStringForce(v))) {
g++;
tabs.add(i.getName() + "=" + f);
}
}
else
{
for(String f : i.getHandler().getPossibilities("").convert((v) -> i.getHandler().toStringForce(v)))
{
g++;
tabs.add(i.getName() +"="+ f);
}
}
if(g == 0)
{
if (g == 0) {
tabs.add(i.getName() + "=");
}
}
}
else
{
for(VirtualDecreeCommand i : getNodes())
{
} else {
for (VirtualDecreeCommand i : getNodes()) {
String m = i.getName();
if(m.equalsIgnoreCase(last) || m.toLowerCase().contains(last.toLowerCase()) || last.toLowerCase().contains(m.toLowerCase()))
{
if (m.equalsIgnoreCase(last) || m.toLowerCase().contains(last.toLowerCase()) || last.toLowerCase().contains(m.toLowerCase())) {
tabs.addAll(i.getNames());
}
}
@@ -304,40 +255,30 @@ public class VirtualDecreeCommand {
}
}
private KMap<String, Object> map(VolmitSender sender, KList<String> in)
{
private KMap<String, Object> map(VolmitSender sender, KList<String> in) {
KMap<String, Object> data = new KMap<>();
for(int ix = 0; ix < in.size(); ix++)
{
for (int ix = 0; ix < in.size(); ix++) {
String i = in.get(ix);
if(i.contains("="))
{
if (i.contains("=")) {
String[] v = i.split("\\Q=\\E");
String key = v[0];
String value = v[1];
DecreeParameter param = null;
for(DecreeParameter j : getNode().getParameters())
{
for(String k : j.getNames())
{
if(k.equalsIgnoreCase(key))
{
for (DecreeParameter j : getNode().getParameters()) {
for (String k : j.getNames()) {
if (k.equalsIgnoreCase(key)) {
param = j;
break;
}
}
}
if(param == null)
{
for(DecreeParameter j : getNode().getParameters())
{
for(String k : j.getNames())
{
if(k.toLowerCase().contains(key.toLowerCase()) || key.toLowerCase().contains(k.toLowerCase()))
{
if (param == null) {
for (DecreeParameter j : getNode().getParameters()) {
for (String k : j.getNames()) {
if (k.toLowerCase().contains(key.toLowerCase()) || key.toLowerCase().contains(k.toLowerCase())) {
param = j;
break;
}
@@ -345,8 +286,7 @@ public class VirtualDecreeCommand {
}
}
if(param == null)
{
if (param == null) {
Iris.debug("Can't find parameter key for " + key + "=" + value + " in " + getPath());
sender.sendMessage(C.YELLOW + "Unknown Parameter: " + key);
continue;
@@ -367,12 +307,8 @@ public class VirtualDecreeCommand {
Iris.debug("Client chose " + update + " for " + key + "=" + value + " (old) in " + getPath());
in.set(ix--, update);
}
}
else
{
try
{
} else {
try {
DecreeParameter par = getNode().getParameters().get(ix);
try {
data.put(par.getName(), par.getHandler().parse(i));
@@ -387,11 +323,8 @@ public class VirtualDecreeCommand {
Iris.debug("Client chose " + update + " for " + par.getName() + "=" + i + " (old) in " + getPath());
in.set(ix--, update);
}
}
catch(IndexOutOfBoundsException e)
{
sender.sendMessage(C.YELLOW + "Unknown Parameter: " + i + " (" + Form.getNumberSuffixThStRd(ix+1) + " argument)");
} catch (IndexOutOfBoundsException e) {
sender.sendMessage(C.YELLOW + "Unknown Parameter: " + i + " (" + Form.getNumberSuffixThStRd(ix + 1) + " argument)");
}
}
}
@@ -399,25 +332,20 @@ public class VirtualDecreeCommand {
return data;
}
public boolean invoke(VolmitSender sender, KList<String> realArgs)
{
public boolean invoke(VolmitSender sender, KList<String> realArgs) {
return invoke(sender, realArgs, new KList<>());
}
public boolean invoke(VolmitSender sender, KList<String> args, KList<Integer> skip)
{
if(isStudio() && !IrisSettings.get().isStudio())
{
public boolean invoke(VolmitSender sender, KList<String> args, KList<Integer> skip) {
if (isStudio() && !IrisSettings.get().isStudio()) {
sender.sendMessage(C.RED + "To use Iris Studio Commands, please enable studio in Iris/settings.json (settings auto-reload)");
return false;
}
Iris.debug("@ " + getPath() + " with " + args.toString(", "));
if(isNode())
{
Iris.debug("Invoke " +getPath() + "(" + args.toString(",") + ") at ");
if(invokeNode(sender, map(sender, args)))
{
if (isNode()) {
Iris.debug("Invoke " + getPath() + "(" + args.toString(",") + ") at ");
if (invokeNode(sender, map(sender, args))) {
return true;
}
@@ -425,8 +353,7 @@ public class VirtualDecreeCommand {
return false;
}
if(args.isEmpty())
{
if (args.isEmpty()) {
sender.sendDecreeHelp(this);
return true;
@@ -435,8 +362,7 @@ public class VirtualDecreeCommand {
String head = args.get(0);
VirtualDecreeCommand match = matchNode(head, skip);
if(match != null)
{
if (match != null) {
args.pop();
return match.invoke(sender, args, skip);
}
@@ -447,25 +373,20 @@ public class VirtualDecreeCommand {
}
private boolean invokeNode(VolmitSender sender, KMap<String, Object> map) {
if(map == null)
{
if (map == null) {
return false;
}
Object[] params = new Object[getNode().getMethod().getParameterCount()];
int vm = 0;
for(DecreeParameter i : getNode().getParameters())
{
for (DecreeParameter i : getNode().getParameters()) {
Object value = map.get(i.getName());
try
{
if(value == null && i.hasDefault())
{
try {
if (value == null && i.hasDefault()) {
value = i.getDefaultValue();
}
}
catch (DecreeParsingException e) {
} catch (DecreeParsingException e) {
Iris.debug("Can't parse parameter value for " + i.getName() + "=" + i + " in " + getPath() + " using handler " + i.getHandler().getClass().getSimpleName());
sender.sendMessage(C.RED + "Cannot convert \"" + i + "\" into a " + i.getType().getSimpleName());
return false;
@@ -474,11 +395,9 @@ public class VirtualDecreeCommand {
KList<?> validOptions = i.getHandler().getPossibilities(i.getParam().defaultValue());
String update = null; // TODO: PICK ONE
Iris.debug("Client chose " + update + " for " + i.getName() + "=" + i + " (old) in " + getPath());
try
{
try {
value = i.getDefaultValue();
}
catch (DecreeParsingException x) {
} catch (DecreeParsingException x) {
x.printStackTrace();
Iris.debug("Can't parse parameter value for " + i.getName() + "=" + i + " in " + getPath() + " using handler " + i.getHandler().getClass().getSimpleName());
sender.sendMessage(C.RED + "Cannot convert \"" + i + "\" into a " + i.getType().getSimpleName());
@@ -488,33 +407,23 @@ public class VirtualDecreeCommand {
}
}
if(i.isContextual() && value == null)
{
if (i.isContextual() && value == null) {
DecreeContextHandler<?> ch = DecreeContextHandler.contextHandlers.get(i.getType());
if(ch != null)
{
if (ch != null) {
value = ch.handle(sender);
if(value != null)
{
if (value != null) {
Iris.debug("Null Parameter " + i.getName() + " derived a value of " + i.getHandler().toStringForce(value) + " from " + ch.getClass().getSimpleName());
}
else
{
} else {
Iris.debug("Null Parameter " + i.getName() + " could not derive a value from " + ch.getClass().getSimpleName());
}
}
else
{
} else {
Iris.debug("Null Parameter " + i.getName() + " is contextual but has no context handler for " + i.getType().getCanonicalName());
}
}
if(i.hasDefault() && value == null)
{
if (i.hasDefault() && value == null) {
try {
Iris.debug("Null Parameter " + i.getName() + " is using default value " + i.getParam().defaultValue());
value = i.getDefaultValue();
@@ -523,7 +432,7 @@ public class VirtualDecreeCommand {
}
}
if(i.isRequired() && value == null) {
if (i.isRequired() && value == null) {
sender.sendMessage("Missing: " + i.getName() + " (" + i.getType().getSimpleName() + ") as the " + Form.getNumberSuffixThStRd(vm + 1) + " argument.");
return false;
}
@@ -533,55 +442,41 @@ public class VirtualDecreeCommand {
}
Runnable rx = () -> {
try
{
try {
DecreeContext.touch(sender);
getNode().getMethod().setAccessible(true);
getNode().getMethod().invoke(getNode().getInstance(), params);
}
catch(Throwable e)
{
} catch (Throwable e) {
e.printStackTrace();
throw new RuntimeException("Failed to execute <INSERT REAL NODE HERE>"); // TODO:
}
};
if(getNode().isSync())
{
if (getNode().isSync()) {
J.s(rx);
}
else
{
} else {
rx.run();
}
return true;
}
public KList<VirtualDecreeCommand> matchAllNodes(String in)
{
public KList<VirtualDecreeCommand> matchAllNodes(String in) {
KList<VirtualDecreeCommand> g = new KList<>();
if(in.trim().isEmpty())
{
if (in.trim().isEmpty()) {
g.addAll(nodes);
return g;
}
for(VirtualDecreeCommand i : nodes)
{
if(i.matches(in))
{
for (VirtualDecreeCommand i : nodes) {
if (i.matches(in)) {
g.add(i);
}
}
for(VirtualDecreeCommand i : nodes)
{
if(i.deepMatches(in))
{
for (VirtualDecreeCommand i : nodes) {
if (i.deepMatches(in)) {
g.add(i);
}
}
@@ -590,35 +485,27 @@ public class VirtualDecreeCommand {
return g;
}
public VirtualDecreeCommand matchNode(String in, KList<Integer> skip)
{
if(in.trim().isEmpty())
{
public VirtualDecreeCommand matchNode(String in, KList<Integer> skip) {
if (in.trim().isEmpty()) {
return null;
}
for(VirtualDecreeCommand i : nodes)
{
if(skip.contains(i.hashCode()))
{
for (VirtualDecreeCommand i : nodes) {
if (skip.contains(i.hashCode())) {
continue;
}
if(i.matches(in))
{
if (i.matches(in)) {
return i;
}
}
for(VirtualDecreeCommand i : nodes)
{
if(skip.contains(i.hashCode()))
{
for (VirtualDecreeCommand i : nodes) {
if (skip.contains(i.hashCode())) {
continue;
}
if(i.deepMatches(in))
{
if (i.deepMatches(in)) {
return i;
}
}
@@ -626,14 +513,11 @@ public class VirtualDecreeCommand {
return null;
}
public boolean deepMatches(String in)
{
public boolean deepMatches(String in) {
KList<String> a = getNames();
for(String i : a)
{
if(i.toLowerCase().contains(in.toLowerCase()) || in.toLowerCase().contains(i.toLowerCase()))
{
for (String i : a) {
if (i.toLowerCase().contains(in.toLowerCase()) || in.toLowerCase().contains(i.toLowerCase())) {
return true;
}
}
@@ -642,26 +526,23 @@ public class VirtualDecreeCommand {
}
@Override
public int hashCode(){
public int hashCode() {
return Objects.hash(getName(), getDescription(), getType(), getPath());
}
@Override
public boolean equals(Object obj){
if (!(obj instanceof VirtualDecreeCommand)){
public boolean equals(Object obj) {
if (!(obj instanceof VirtualDecreeCommand)) {
return false;
}
return this.hashCode() == obj.hashCode();
}
public boolean matches(String in)
{
public boolean matches(String in) {
KList<String> a = getNames();
for(String i : a)
{
if(i.equalsIgnoreCase(in))
{
for (String i : a) {
if (i.equalsIgnoreCase(in)) {
return true;
}
}