This commit is contained in:
cyberpwn 2021-08-13 11:33:12 -04:00
parent c92e64afbd
commit 93e0773758
6 changed files with 314 additions and 19 deletions

View File

@ -19,27 +19,11 @@
package com.volmit.iris.core; package com.volmit.iris.core;
import com.volmit.iris.Iris; 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.engine.data.cache.AtomicCache;
import com.volmit.iris.util.collection.KList; 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.DecreeSystem;
import com.volmit.iris.util.decree.virtual.VirtualDecreeCommand; 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 { public class CommandManager implements DecreeSystem {
private final transient AtomicCache<VirtualDecreeCommand> commandCache = new AtomicCache<>(); private final transient AtomicCache<VirtualDecreeCommand> commandCache = new AtomicCache<>();
@ -53,7 +37,7 @@ public class CommandManager implements DecreeSystem {
public VirtualDecreeCommand getRoot() { public VirtualDecreeCommand getRoot() {
return commandCache.aquire(() -> { return commandCache.aquire(() -> {
try { try {
return VirtualDecreeCommand.createRoot(new DecreeIris()); return VirtualDecreeCommand.createRoot(new CMDIris());
} catch (Throwable e) { } catch (Throwable e) {
e.printStackTrace(); e.printStackTrace();
} }

View File

@ -23,8 +23,10 @@ import com.volmit.iris.util.decree.annotations.Decree;
import com.volmit.iris.util.decree.annotations.Param; import com.volmit.iris.util.decree.annotations.Param;
@Decree(name = "irisd", aliases = {"ird"}, description = "Basic Command") @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") @Decree(description = "Ping self", aliases = "p")
public void ping( public void ping(
@Param(name = "message",defaultValue = "Pong", aliases = {"msg", "m"}) @Param(name = "message",defaultValue = "Pong", aliases = {"msg", "m"})

View File

@ -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 <https://www.gnu.org/licenses/>.
*/
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 + "!");
}
}

View File

@ -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 <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.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<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 = 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<IrisBiome> 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);
}
}

View File

@ -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 <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.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<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 = 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<IrisDimension> 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);
}
}

View File

@ -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 <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.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<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 = 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<IrisRegion> 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);
}
}