9
0
mirror of https://github.com/VolmitSoftware/Iris.git synced 2025-12-29 20:19:06 +00:00
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

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