diff --git a/src/main/java/com/volmit/iris/core/CommandManager.java b/src/main/java/com/volmit/iris/core/CommandManager.java index 5411c9873..d20688aff 100644 --- a/src/main/java/com/volmit/iris/core/CommandManager.java +++ b/src/main/java/com/volmit/iris/core/CommandManager.java @@ -19,27 +19,11 @@ package com.volmit.iris.core; import com.volmit.iris.Iris; -import com.volmit.iris.core.decrees.DecreeIris; +import com.volmit.iris.core.decrees.CMDIris; import com.volmit.iris.engine.data.cache.AtomicCache; import com.volmit.iris.util.collection.KList; -import com.volmit.iris.util.decree.DecreeCommand; import com.volmit.iris.util.decree.DecreeSystem; import com.volmit.iris.util.decree.virtual.VirtualDecreeCommand; -import com.volmit.iris.util.plugin.VolmitSender; -import com.volmit.iris.util.scheduling.J; -import org.bukkit.command.Command; -import org.bukkit.command.CommandSender; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.bukkit.event.Listener; -import org.bukkit.event.player.AsyncPlayerChatEvent; -import org.bukkit.event.player.PlayerCommandPreprocessEvent; -import org.bukkit.event.server.ServerCommandEvent; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -import java.io.Console; -import java.util.List; public class CommandManager implements DecreeSystem { private final transient AtomicCache commandCache = new AtomicCache<>(); @@ -53,7 +37,7 @@ public class CommandManager implements DecreeSystem { public VirtualDecreeCommand getRoot() { return commandCache.aquire(() -> { try { - return VirtualDecreeCommand.createRoot(new DecreeIris()); + return VirtualDecreeCommand.createRoot(new CMDIris()); } catch (Throwable e) { e.printStackTrace(); } diff --git a/src/main/java/com/volmit/iris/core/decrees/DecreeIris.java b/src/main/java/com/volmit/iris/core/decrees/CMDIris.java similarity index 94% rename from src/main/java/com/volmit/iris/core/decrees/DecreeIris.java rename to src/main/java/com/volmit/iris/core/decrees/CMDIris.java index da910648d..4c3cdda4b 100644 --- a/src/main/java/com/volmit/iris/core/decrees/DecreeIris.java +++ b/src/main/java/com/volmit/iris/core/decrees/CMDIris.java @@ -23,8 +23,10 @@ import com.volmit.iris.util.decree.annotations.Decree; import com.volmit.iris.util.decree.annotations.Param; @Decree(name = "irisd", aliases = {"ird"}, description = "Basic Command") -public class DecreeIris implements DecreeExecutor +public class CMDIris implements DecreeExecutor { + private CMDIrisStudio studio; + @Decree(description = "Ping self", aliases = "p") public void ping( @Param(name = "message",defaultValue = "Pong", aliases = {"msg", "m"}) diff --git a/src/main/java/com/volmit/iris/core/decrees/CMDIrisStudio.java b/src/main/java/com/volmit/iris/core/decrees/CMDIrisStudio.java new file mode 100644 index 000000000..41dc6c8e0 --- /dev/null +++ b/src/main/java/com/volmit/iris/core/decrees/CMDIrisStudio.java @@ -0,0 +1,36 @@ +/* + * 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 . + */ + +package com.volmit.iris.core.decrees; + +import com.volmit.iris.engine.object.dimensional.IrisDimension; +import com.volmit.iris.util.decree.DecreeExecutor; +import com.volmit.iris.util.decree.annotations.Decree; +import com.volmit.iris.util.decree.annotations.Param; + +@Decree(name = "studio", aliases = {"std", "s"}, description = "Studio Commands") +public class CMDIrisStudio implements DecreeExecutor +{ + @Decree(description = "Open a new studio world", aliases = "o") + public void open( + @Param(name = "dimension", defaultValue = "overworld", aliases = "dim") + IrisDimension dimension) + { + sender().sendMessage(message + "!"); + } +} diff --git a/src/main/java/com/volmit/iris/util/decree/handlers/BiomeHandler.java b/src/main/java/com/volmit/iris/util/decree/handlers/BiomeHandler.java new file mode 100644 index 000000000..e3af00151 --- /dev/null +++ b/src/main/java/com/volmit/iris/util/decree/handlers/BiomeHandler.java @@ -0,0 +1,91 @@ +/* + * 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 . + */ + +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 java.io.File; + +public class BiomeHandler implements DecreeParameterHandler { + @Override + public KList getPossibilities() { + KMap p = new KMap<>(); + + //noinspection ConstantConditions + 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())) + { + 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) throws DecreeParsingException, DecreeWhichException { + try + { + KList options = getPossibilities(in); + + if(options.isEmpty()) + { + throw new DecreeParsingException("Unable to find Biome \"" + in + "\""); + } + + else if(options.size() > 1) + { + throw new DecreeWhichException(); + } + + return options.get(0); + } + catch(DecreeParsingException e){ + throw e; + } + catch(Throwable e) + { + throw new DecreeParsingException("Unable to find Biome \"" + in + "\" because of an uncaught exception: " + e); + } + } + + @Override + public boolean supports(Class type) { + return type.equals(IrisBiome.class); + } +} diff --git a/src/main/java/com/volmit/iris/util/decree/handlers/DimensionHandler.java b/src/main/java/com/volmit/iris/util/decree/handlers/DimensionHandler.java new file mode 100644 index 000000000..567149292 --- /dev/null +++ b/src/main/java/com/volmit/iris/util/decree/handlers/DimensionHandler.java @@ -0,0 +1,92 @@ +/* + * 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 . + */ + +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.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 org.bukkit.Bukkit; +import org.bukkit.World; + +import java.io.File; + +public class DimensionHandler implements DecreeParameterHandler { + @Override + public KList getPossibilities() { + KMap p = new KMap<>(); + + //noinspection ConstantConditions + 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())) + { + p.putIfAbsent(j.getLoadKey(), j); + } + + data.close(); + } + } + + return p.v(); + } + + @Override + public String toString(IrisDimension dim) { + return dim.getLoadKey(); + } + + @Override + public IrisDimension parse(String in) throws DecreeParsingException, DecreeWhichException { + try + { + KList options = getPossibilities(in); + + if(options.isEmpty()) + { + throw new DecreeParsingException("Unable to find Dimension \"" + in + "\""); + } + + else if(options.size() > 1) + { + throw new DecreeWhichException(); + } + + return options.get(0); + } + catch(DecreeParsingException e){ + throw e; + } + catch(Throwable e) + { + throw new DecreeParsingException("Unable to find Dimension \"" + in + "\" because of an uncaught exception: " + e); + } + } + + @Override + public boolean supports(Class type) { + return type.equals(IrisDimension.class); + } +} diff --git a/src/main/java/com/volmit/iris/util/decree/handlers/RegionHandler.java b/src/main/java/com/volmit/iris/util/decree/handlers/RegionHandler.java new file mode 100644 index 000000000..452fbf957 --- /dev/null +++ b/src/main/java/com/volmit/iris/util/decree/handlers/RegionHandler.java @@ -0,0 +1,90 @@ +/* + * 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 . + */ + +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.regional.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.exceptions.DecreeWhichException; + +import java.io.File; + +public class RegionHandler implements DecreeParameterHandler { + @Override + public KList getPossibilities() { + KMap p = new KMap<>(); + + //noinspection ConstantConditions + 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())) + { + 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) throws DecreeParsingException, DecreeWhichException { + try + { + KList options = getPossibilities(in); + + if(options.isEmpty()) + { + throw new DecreeParsingException("Unable to find Region \"" + in + "\""); + } + + else if(options.size() > 1) + { + throw new DecreeWhichException(); + } + + return options.get(0); + } + catch(DecreeParsingException e){ + throw e; + } + catch(Throwable e) + { + throw new DecreeParsingException("Unable to find Region \"" + in + "\" because of an uncaught exception: " + e); + } + } + + @Override + public boolean supports(Class type) { + return type.equals(IrisRegion.class); + } +}