mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-04-06 07:46:08 +00:00
Revert "Revert "Merge pull request #561 from CocoTheOwner/DecreeCommands""
This reverts commit a451189d83.
This commit is contained in:
@@ -47,13 +47,21 @@ public class DecreeNode {
|
||||
* @return The list of parameters if ALL are annotated by @{@link Param}, else null
|
||||
*/
|
||||
public KList<DecreeParameter> getParameters() {
|
||||
KList<DecreeParameter> p = new KList<>();
|
||||
KList<DecreeParameter> required = new KList<>();
|
||||
KList<DecreeParameter> optional = new KList<>();
|
||||
|
||||
for (Parameter i : method.getParameters()) {
|
||||
p.add(new DecreeParameter(i));
|
||||
DecreeParameter p = new DecreeParameter(i);
|
||||
if (p.isRequired()){
|
||||
required.add(p);
|
||||
} else {
|
||||
optional.add(p);
|
||||
}
|
||||
}
|
||||
|
||||
required.addAll(optional);
|
||||
|
||||
return p;
|
||||
return required;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
|
||||
@@ -56,6 +56,9 @@ public class BiomeHandler implements DecreeParameterHandler<IrisBiome> {
|
||||
|
||||
@Override
|
||||
public IrisBiome parse(String in) throws DecreeParsingException, DecreeWhichException {
|
||||
if (in.equals("null")) {
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
KList<IrisBiome> options = getPossibilities(in);
|
||||
|
||||
|
||||
@@ -37,6 +37,9 @@ public class BooleanHandler implements DecreeParameterHandler<Boolean> {
|
||||
@Override
|
||||
public Boolean parse(String in) throws DecreeParsingException {
|
||||
try {
|
||||
if (in.equals("null") || in.equals("other") || in.equals("flip")) {
|
||||
return null;
|
||||
}
|
||||
return Boolean.parseBoolean(in);
|
||||
} catch (Throwable e) {
|
||||
throw new DecreeParsingException("Unable to parse boolean \"" + in + "\"");
|
||||
|
||||
@@ -56,6 +56,9 @@ public class RegionHandler implements DecreeParameterHandler<IrisRegion> {
|
||||
|
||||
@Override
|
||||
public IrisRegion parse(String in) throws DecreeParsingException, DecreeWhichException {
|
||||
if (in.equals("null")) {
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
KList<IrisRegion> options = getPossibilities(in);
|
||||
|
||||
|
||||
@@ -43,14 +43,7 @@ public class VectorHandler implements DecreeParameterHandler<Vector> {
|
||||
|
||||
@Override
|
||||
public KList<Vector> getPossibilities() {
|
||||
KList<Vector> vx = new KList<>();
|
||||
VolmitSender s = DecreeContext.get();
|
||||
|
||||
if (s.isPlayer()) {
|
||||
vx.add(s.player().getLocation().toVector());
|
||||
}
|
||||
|
||||
return vx;
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -28,7 +28,13 @@ import org.bukkit.World;
|
||||
public class WorldHandler implements DecreeParameterHandler<World> {
|
||||
@Override
|
||||
public KList<World> getPossibilities() {
|
||||
return new KList<>(Bukkit.getWorlds());
|
||||
KList<World> options = new KList<>();
|
||||
for (World world : Bukkit.getWorlds()) {
|
||||
if (!world.getName().toLowerCase().startsWith("iris/")){
|
||||
options.add(world);
|
||||
}
|
||||
}
|
||||
return options;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user