diff options
Diffstat (limited to 'src/main')
9 files changed, 748 insertions, 38 deletions
diff --git a/src/main/java/pers/gwyog/gtneioreplugin/Config.java b/src/main/java/pers/gwyog/gtneioreplugin/Config.java new file mode 100644 index 0000000000..62a94de43b --- /dev/null +++ b/src/main/java/pers/gwyog/gtneioreplugin/Config.java @@ -0,0 +1,19 @@ +package pers.gwyog.gtneioreplugin; + +import java.io.File; + +import cpw.mods.fml.common.event.FMLPreInitializationEvent; +import net.minecraftforge.common.config.Configuration; + +public class Config { + public Configuration tConfig; + public Config(FMLPreInitializationEvent preinit,String cfgname) { + File tFile = new File(preinit.getModConfigurationDirectory(), cfgname); + tConfig = new Configuration(tFile); + tConfig.load(); + } + public void save () { + tConfig.save(); + } + +} diff --git a/src/main/java/pers/gwyog/gtneioreplugin/GTNEIOrePlugin.java b/src/main/java/pers/gwyog/gtneioreplugin/GTNEIOrePlugin.java index e0c28843bb..0ce4ed0b81 100644 --- a/src/main/java/pers/gwyog/gtneioreplugin/GTNEIOrePlugin.java +++ b/src/main/java/pers/gwyog/gtneioreplugin/GTNEIOrePlugin.java @@ -1,28 +1,45 @@ package pers.gwyog.gtneioreplugin; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; + import cpw.mods.fml.common.Mod; import cpw.mods.fml.common.Mod.EventHandler; -import cpw.mods.fml.common.event.FMLInitializationEvent; import cpw.mods.fml.common.event.FMLLoadCompleteEvent; +import cpw.mods.fml.common.event.FMLPreInitializationEvent; import cpw.mods.fml.relauncher.Side; +import net.minecraft.init.Items; import pers.gwyog.gtneioreplugin.util.GT5OreLayerHelper; import pers.gwyog.gtneioreplugin.util.GT5OreSmallHelper; +import pers.gwyog.gtneioreplugin.util.Oremix; @Mod(modid = GTNEIOrePlugin.MODID, name = GTNEIOrePlugin.NAME, version = GTNEIOrePlugin.VERSION, dependencies = "required-after:gregtech;required-after:NotEnoughItems") public class GTNEIOrePlugin { public static final String MODID = "gtneioreplugin"; public static final String NAME = "GT NEI Ore Plugin GT:NH Mod"; public static final String VERSION = "@version@"; + public static boolean csv; + public static String CSVname; + public static List<Oremix> OreVeins=new ArrayList(); + public static HashSet OreV=new HashSet(); @Mod.Instance(MODID) public static GTNEIOrePlugin instance; @EventHandler + public void preinit(FMLPreInitializationEvent event) { + Config c = new Config(event, this.MODID+".cfg"); + csv = c.tConfig.getBoolean("print csv","ALL", false, "princsv, you need apache commons collections to be injected in the minecraft jar."); + CSVname = c.tConfig.getString("CSV_name", "ALL", event.getModConfigurationDirectory()+"/GTNH-Oresheet.csv", "rename the oresheet here, it will appear in /config"); + } + + @EventHandler public void onLoadComplete(FMLLoadCompleteEvent event) { if (event.getSide() == Side.CLIENT) { new GT5OreLayerHelper(); new GT5OreSmallHelper(); + } } - } } diff --git a/src/main/java/pers/gwyog/gtneioreplugin/plugin/PluginBase.java b/src/main/java/pers/gwyog/gtneioreplugin/plugin/PluginBase.java index 11b1b925f2..cbca2a66c6 100644 --- a/src/main/java/pers/gwyog/gtneioreplugin/plugin/PluginBase.java +++ b/src/main/java/pers/gwyog/gtneioreplugin/plugin/PluginBase.java @@ -48,4 +48,5 @@ public class PluginBase extends TemplateRecipeHandler { public int getGuiWidth() { return 166; } + } diff --git a/src/main/java/pers/gwyog/gtneioreplugin/plugin/gregtech5/PluginGT5Base.java b/src/main/java/pers/gwyog/gtneioreplugin/plugin/gregtech5/PluginGT5Base.java index 242b27f23e..1d612d8c9c 100644 --- a/src/main/java/pers/gwyog/gtneioreplugin/plugin/gregtech5/PluginGT5Base.java +++ b/src/main/java/pers/gwyog/gtneioreplugin/plugin/gregtech5/PluginGT5Base.java @@ -1,14 +1,7 @@ package pers.gwyog.gtneioreplugin.plugin.gregtech5; -import java.awt.Rectangle; - -import codechicken.lib.gui.GuiDraw; -import codechicken.nei.recipe.TemplateRecipeHandler; -import codechicken.nei.recipe.TemplateRecipeHandler.RecipeTransferRect; import gregtech.api.enums.Materials; import gregtech.api.util.GT_LanguageManager; -import net.minecraft.client.resources.I18n; -import net.minecraft.util.EnumChatFormatting; import pers.gwyog.gtneioreplugin.plugin.PluginBase; public class PluginGT5Base extends PluginBase { @@ -23,7 +16,7 @@ public class PluginGT5Base extends PluginBase { return 5; } - public String getGTOreLocalizedName(short index) { + public static String getGTOreLocalizedName(short index) { if (!Materials.getLocalizedNameForItem(GT_LanguageManager.getTranslation(getGTOreUnlocalizedName(index)), index%1000).contains("Awakened")) return Materials.getLocalizedNameForItem(GT_LanguageManager.getTranslation(getGTOreUnlocalizedName(index)), index%1000); @@ -31,7 +24,7 @@ public class PluginGT5Base extends PluginBase { return "Aw. Draconium Ore"; } - public String getGTOreUnlocalizedName(short index) { + public static String getGTOreUnlocalizedName(short index) { return "gt.blockores." + index + ".name"; } diff --git a/src/main/java/pers/gwyog/gtneioreplugin/plugin/gregtech5/PluginGT5VeinStat.java b/src/main/java/pers/gwyog/gtneioreplugin/plugin/gregtech5/PluginGT5VeinStat.java index b6081fc9b0..ddb130eec3 100644 --- a/src/main/java/pers/gwyog/gtneioreplugin/plugin/gregtech5/PluginGT5VeinStat.java +++ b/src/main/java/pers/gwyog/gtneioreplugin/plugin/gregtech5/PluginGT5VeinStat.java @@ -1,31 +1,31 @@ package pers.gwyog.gtneioreplugin.plugin.gregtech5; -import java.awt.Rectangle; -import java.io.File; +import java.io.FileWriter; import java.io.IOException; +import java.io.StringWriter; +import java.io.Writer; import java.util.ArrayList; import java.util.HashSet; import java.util.List; import java.util.Set; +import com.opencsv.bean.ColumnPositionMappingStrategy; +import com.opencsv.bean.StatefulBeanToCsv; +import com.opencsv.bean.StatefulBeanToCsvBuilder; +import com.opencsv.exceptions.CsvDataTypeMismatchException; +import com.opencsv.exceptions.CsvRequiredFieldEmptyException; + import codechicken.lib.gui.GuiDraw; import codechicken.nei.PositionedStack; -import codechicken.nei.recipe.TemplateRecipeHandler; -import codechicken.nei.recipe.TemplateRecipeHandler.RecipeTransferRect; -import cpw.mods.fml.common.FMLLog; import gregtech.api.GregTech_API; -import gregtech.api.enums.Materials; -import gregtech.api.util.GT_LanguageManager; -import gregtech.common.GT_Worldgen_GT_Ore_Layer; -import net.minecraft.client.gui.Gui; import net.minecraft.client.resources.I18n; -import net.minecraft.init.Items; import net.minecraft.item.ItemStack; import net.minecraft.util.EnumChatFormatting; -import pers.gwyog.gtneioreplugin.util.DimensionHelper; +import pers.gwyog.gtneioreplugin.GTNEIOrePlugin; import pers.gwyog.gtneioreplugin.util.GT5CFGHelper; import pers.gwyog.gtneioreplugin.util.GT5OreLayerHelper; import pers.gwyog.gtneioreplugin.util.GT5OreLayerHelper.OreLayerWrapper; +import pers.gwyog.gtneioreplugin.util.Oremix; public class PluginGT5VeinStat extends PluginGT5Base { @@ -122,6 +122,8 @@ public class PluginGT5VeinStat extends PluginGT5Base { CachedVeinStatRecipe crecipe = (CachedVeinStatRecipe) this.arecipes.get(recipe); OreLayerWrapper oreLayer = GT5OreLayerHelper.mapOreLayerWrapper.get(crecipe.veinName); + String Dims = getDims(oreLayer); + if (getLocalizedVeinName(oreLayer).length>1) { GuiDraw.drawString(I18n.format("gtnop.gui.nei.veinName") + ": " + getLocalizedVeinName(oreLayer)[0], 2, 20, 0x404040, false); if (getLocalizedVeinName(oreLayer).length>2) { @@ -133,29 +135,40 @@ public class PluginGT5VeinStat extends PluginGT5Base { } else GuiDraw.drawString(I18n.format("gtnop.gui.nei.veinName") + ": " + getLocalizedVeinName(oreLayer)[0], 2, 20, 0x404040, false); + + GuiDraw.drawString(I18n.format("gtnop.gui.nei.primaryOre") + ": " + getGTOreLocalizedName(oreLayer.Meta[0]), 2, 50, 0x404040, false); + GuiDraw.drawString(I18n.format("gtnop.gui.nei.secondaryOre") + ": " + getGTOreLocalizedName(oreLayer.Meta[1]), 2, 60, 0x404040, false); + GuiDraw.drawString(I18n.format("gtnop.gui.nei.betweenOre") + ": " + getGTOreLocalizedName(oreLayer.Meta[2]), 2, 70, 0x404040, false); + GuiDraw.drawString(I18n.format("gtnop.gui.nei.sporadicOre") + ": " + getGTOreLocalizedName(oreLayer.Meta[3]), 2, 80, 0x404040, false); + GuiDraw.drawString(I18n.format("gtnop.gui.nei.genHeight") + ": " + oreLayer.worldGenHeightRange, 2, 90, 0x404040, false); + GuiDraw.drawString(I18n.format("gtnop.gui.nei.weightedChance") + ": " + Integer.toString(oreLayer.randomWeight), 100, 90, 0x404040, false); + GuiDraw.drawString(I18n.format("gtnop.gui.nei.worldNames") + ": ", 2, 100, 0x404040, false); - if (getDims(oreLayer).length()>36) { - GuiDraw.drawString(I18n.format("") + getDims(oreLayer).substring(0, 36), 2, 110, 0x404040, false); - if (getDims(oreLayer).length()>70) { - GuiDraw.drawString(I18n.format("") + getDims(oreLayer).substring(36, 70), 2, 120, 0x404040, false); - GuiDraw.drawString(I18n.format("") + getDims(oreLayer).substring(70, getDims(oreLayer).length()-1), 2, 130, 0x404040, false); + if (Dims.length()>36) { + GuiDraw.drawString(I18n.format("") + Dims.substring(0, 36), 2, 110, 0x404040, false); + if (Dims.length()>70) { + GuiDraw.drawString(I18n.format("") + Dims.substring(36, 70), 2, 120, 0x404040, false); + GuiDraw.drawString(I18n.format("") + Dims.substring(70, Dims.length()-1), 2, 130, 0x404040, false); } else - GuiDraw.drawString(I18n.format("") + getDims(oreLayer).substring(36, getDims(oreLayer).length()-1), 2, 120, 0x404040, false); + GuiDraw.drawString(I18n.format("") + Dims.substring(36, Dims.length()-1), 2, 120, 0x404040, false); } else - GuiDraw.drawString(I18n.format("") + getDims(oreLayer).substring(0, getDims(oreLayer).length()-1), 2, 110, 0x404040, false); + GuiDraw.drawString(I18n.format("") + Dims.substring(0, Dims.length()-1), 2, 110, 0x404040, false); + + //if (GT5OreLayerHelper.restrictBiomeSupport) GuiDraw.drawString(I18n.format("gtnop.gui.nei.restrictBiome") + ": " + getBiomeTranslated(oreLayer.restrictBiome), 2, 122, 0x404040, false); GuiDraw.drawStringR(EnumChatFormatting.BOLD + I18n.format("gtnop.gui.nei.seeAll"), getGuiWidth()-3, 5, 0x404040, false); + } - public String[] getLocalizedVeinName(OreLayerWrapper oreLayer) { + public static String[] getLocalizedVeinName(OreLayerWrapper oreLayer) { String unlocalizedName = oreLayer.veinName; if (unlocalizedName.startsWith("ore.mix.custom.")) @@ -164,7 +177,7 @@ public class PluginGT5VeinStat extends PluginGT5Base { return new String[] {I18n.format("gtnop." + unlocalizedName) + I18n.format("gtnop.ore.vein.name")}; } - public String coustomVeinRenamer(OreLayerWrapper oreLayer) { + public static String coustomVeinRenamer(OreLayerWrapper oreLayer) { Set<String> s = new HashSet<String>(); for (int i=0; i < 4; i++) s.add(getGTOreLocalizedName(oreLayer.Meta[i]).replaceAll(" ", "")); @@ -197,11 +210,11 @@ public class PluginGT5VeinStat extends PluginGT5Base { return weightedChance; }*/ - public String getDims(OreLayerWrapper oreLayer) { + public static String getDims(OreLayerWrapper oreLayer) { return GT5CFGHelper.GT5CFG(GregTech_API.sWorldgenFile.mConfig.getConfigFile(), oreLayer.veinName.replace("ore.mix.custom.", "").replace("ore.mix.", "")); } - public String[] get_Cnames(OreLayerWrapper oreLayer) { + public static String[] get_Cnames(OreLayerWrapper oreLayer) { String[] splt = coustomVeinRenamer(oreLayer).split("\\s"); /*HashSet<String> h = new HashSet<String>(); diff --git a/src/main/java/pers/gwyog/gtneioreplugin/util/GT5OreLayerHelper.java b/src/main/java/pers/gwyog/gtneioreplugin/util/GT5OreLayerHelper.java index 9c94bf0029..073147696c 100644 --- a/src/main/java/pers/gwyog/gtneioreplugin/util/GT5OreLayerHelper.java +++ b/src/main/java/pers/gwyog/gtneioreplugin/util/GT5OreLayerHelper.java @@ -1,18 +1,35 @@ package pers.gwyog.gtneioreplugin.util; +import java.io.BufferedReader; +import java.io.BufferedWriter; +import java.io.FileWriter; +import java.io.IOException; import java.lang.reflect.Field; +import java.nio.file.Files; +import java.nio.file.Paths; import java.util.ArrayList; import java.util.HashMap; +import java.util.Iterator; import java.util.List; import java.util.Map; +import java.util.function.BiConsumer; + +import com.opencsv.CSVReader; +import com.opencsv.CSVWriter; +import com.opencsv.bean.ColumnPositionMappingStrategy; +import com.opencsv.bean.CsvToBean; +import com.opencsv.bean.StatefulBeanToCsv; +import com.opencsv.bean.StatefulBeanToCsvBuilder; import cpw.mods.fml.common.Loader; import gregtech.GT_Mod; import gregtech.api.GregTech_API; +import gregtech.api.enums.Materials; import gregtech.common.GT_Worldgen_GT_Ore_Layer; import net.minecraft.client.resources.I18n; import net.minecraft.item.ItemStack; import pers.gwyog.gtneioreplugin.GTNEIOrePlugin; +import pers.gwyog.gtneioreplugin.plugin.gregtech5.PluginGT5VeinStat; public class GT5OreLayerHelper { @@ -27,14 +44,108 @@ public class GT5OreLayerHelper { DimIDs[i]=0; for (GT_Worldgen_GT_Ore_Layer tWorldGen: GT_Worldgen_GT_Ore_Layer.sList) mapOreLayerWrapper.put(tWorldGen.mWorldGenName, new OreLayerWrapper(tWorldGen)); + + if (GTNEIOrePlugin.csv) { + Iterator it = mapOreLayerWrapper.entrySet().iterator(); + while (it.hasNext()) { + Oremix oremix = new Oremix(); + + Map.Entry pair = (Map.Entry)it.next(); + String Dims = PluginGT5VeinStat.getDims((OreLayerWrapper)pair.getValue()); + OreLayerWrapper oreLayer = (OreLayerWrapper) pair.getValue(); + if (PluginGT5VeinStat.getLocalizedVeinName(oreLayer).length>2) + oremix.setOreName(PluginGT5VeinStat.getLocalizedVeinName(oreLayer)[0]+PluginGT5VeinStat.getLocalizedVeinName(oreLayer)[1]+PluginGT5VeinStat.getLocalizedVeinName(oreLayer)[2]); + else if (PluginGT5VeinStat.getLocalizedVeinName(oreLayer).length>1) + oremix.setOreName(PluginGT5VeinStat.getLocalizedVeinName(oreLayer)[0]+PluginGT5VeinStat.getLocalizedVeinName(oreLayer)[1]); + else + oremix.setOreName(PluginGT5VeinStat.getLocalizedVeinName(oreLayer)[0]); + + oremix.setPrimary(PluginGT5VeinStat.getGTOreLocalizedName(oreLayer.Meta[0])); + oremix.setSecondary(PluginGT5VeinStat.getGTOreLocalizedName(oreLayer.Meta[1])); + oremix.setInbetween(PluginGT5VeinStat.getGTOreLocalizedName(oreLayer.Meta[2])); + oremix.setAround(PluginGT5VeinStat.getGTOreLocalizedName(oreLayer.Meta[3])); + oremix.setSize(oreLayer.size); + oremix.setHeight(oreLayer.worldGenHeightRange); + oremix.setDensity(oreLayer.density); + oremix.setWeight(oreLayer.randomWeight); + oremix.setMix("\'"+Integer.toString(oreLayer.Meta[0])+"|"+Integer.toString(oreLayer.Meta[1])+"|"+Integer.toString(oreLayer.Meta[2])+"|"+Integer.toString(oreLayer.Meta[3])+"\'"); + oremix.as=Dims.contains("As"); + oremix.bc=Dims.contains("BC"); + oremix.be=Dims.contains("BE"); + oremix.bf=Dims.contains("BF"); + oremix.ca=Dims.contains("Ca"); + oremix.cb=Dims.contains("CA"); + oremix.ce=Dims.contains("Ce"); + oremix.dd=Dims.contains("DD"); + oremix.de=Dims.contains("De"); + oremix.ea=Dims.contains("EA"); + oremix.en=Dims.contains("En"); + oremix.eu=Dims.contains("Eu"); + oremix.ga=Dims.contains("Ga"); + oremix.ha=Dims.contains("Ha"); + oremix.io=Dims.contains("Io"); + oremix.kb=Dims.contains("KB"); + oremix.make=Dims.contains("MM"); + oremix.ma=Dims.contains("Ma"); + oremix.me=Dims.contains("Me"); + oremix.mi=Dims.contains("Mi"); + oremix.mo=Dims.contains("Mo"); + oremix.ob=Dims.contains("Ob"); + oremix.ph=Dims.contains("Ph"); + oremix.pl=Dims.contains("Pl"); + oremix.pr=Dims.contains("Pr"); + oremix.tcetie=Dims.contains("TE"); + oremix.tf=Dims.contains("TF"); + oremix.ti=Dims.contains("Ti"); + oremix.tr=Dims.contains("Tr"); + oremix.vb=Dims.contains("VB"); + oremix.ve=Dims.contains("Ve"); + oremix.setOverworld(Dims.contains("Ow")); + oremix.setNether(Dims.contains("Ne")); + oremix.setEnd(Dims.contains("EN")); + GTNEIOrePlugin.OreVeins.add(oremix); + + + System.out.println(pair.getKey() + " = " + pair.getValue()); + it.remove(); // avoids a ConcurrentModificationException + } + BufferedWriter one = null; + try { + one = Files.newBufferedWriter(Paths.get(GTNEIOrePlugin.CSVname)); + } catch (IOException e1) { + e1.printStackTrace(); + } + + ColumnPositionMappingStrategy strat = new ColumnPositionMappingStrategy(); + strat.setType(Oremix.class); + String[] columns = "ORENAME,PRIMARY,SECONDARY,INBETWEEN,AROUND,mix,TIER,HEIGHT,DENSITY,SIZE,WEIGHT,overworld,nether,end,ea,tf,mo,ma,ph,de,as,ce,eu,ga,ca,io,ve,me,en,ti,mi,ob,pr,tr,pl,kb,ha,make,dd,cb,vb,bc,be,bf,tcetie".split("\\,"); + strat.setColumnMapping(columns); + StatefulBeanToCsv<Oremix> beanToCsv = new StatefulBeanToCsvBuilder(one) + .withQuotechar(CSVWriter.NO_QUOTE_CHARACTER) + .withMappingStrategy(strat) + .build(); + List towrite = Combsort(GTNEIOrePlugin.OreVeins); + try { + one.write("Ore Name,Primary,Secondary,Inbetween,Around,ID,Tier,Height,Density,Size,Weight,Overworld,Nether,End,End Asteroids,Twilight Forest,Moon,Mars,Phobos,Deimos,Asteroids,Ceres,Europa,Ganymede,Callisto,Io,Venus,Mercury,Enceladus,Titan,Miranda,Oberon,Proteus,Triton,Pluto,Kuiper Belt,Haumea,Makemake,Deep Dark,Centauri Bb,Vega B,Barnard C,Barnard E,Barnard F,T Ceti E"); + one.newLine(); + beanToCsv.write(towrite); + } catch (Exception e) { + e.printStackTrace(); + } + try { + one.flush(); + one.close(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } } public class OreLayerWrapper { - public String veinName; + public String veinName,worldGenHeightRange, weightedIEChance; public short[] Meta = new short[4]; - public String worldGenHeightRange; - public String weightedIEChance; - public int randomWeight; + public short randomWeight, size, density; public List<Integer> Weight = new ArrayList<Integer>(); public OreLayerWrapper(GT_Worldgen_GT_Ore_Layer worldGen) { @@ -43,10 +154,36 @@ public class GT5OreLayerHelper { this.Meta[1] = worldGen.mSecondaryMeta; this.Meta[2] = worldGen.mBetweenMeta; this.Meta[3] = worldGen.mSporadicMeta; + this.size = worldGen.mSize; + this.density = worldGen.mDensity; this.worldGenHeightRange = worldGen.mMinY + "-" + worldGen.mMaxY; this.randomWeight = worldGen.mWeight; } } - + + public static <T> List<Oremix> Combsort(List<Oremix> liste) { + List<Oremix> liste2 = new ArrayList<Oremix>(liste.size()); + for (Oremix element : liste) { + liste2.add(element); + } + + int schritt = liste2.size(); + boolean vertauscht = false; + do { + vertauscht = false; + if (schritt > 1) { + schritt = (int) (schritt / 1.3); + } + for (int i = 0; i < liste2.size() - schritt; i++) { + if (liste2.get(i).getOreName().substring(0, 3).compareTo((liste2.get(i + schritt).getOreName().substring(0, 3))) > 0) { + T tmp = (T) liste2.get(i); + liste2.set(i, liste2.get(i + schritt)); + liste2.set(i + schritt, (Oremix) tmp); + vertauscht = true; + } + } + } while (vertauscht || schritt > 1); + return liste2; + } }
\ No newline at end of file diff --git a/src/main/java/pers/gwyog/gtneioreplugin/util/Oremix.java b/src/main/java/pers/gwyog/gtneioreplugin/util/Oremix.java new file mode 100644 index 0000000000..0835293f8d --- /dev/null +++ b/src/main/java/pers/gwyog/gtneioreplugin/util/Oremix.java @@ -0,0 +1,466 @@ +package pers.gwyog.gtneioreplugin.util; + +import com.opencsv.bean.CsvBindByName; +import com.opencsv.bean.CsvCustomBindByName; + +public class Oremix { + + @CsvCustomBindByName(column = "Ore Name", required = true, converter = Veinrenamer.class) + private String oreName; + @CsvBindByName(column = "Primary", required = false) + private String primary = ""; + @CsvBindByName(column = "Secondary", required = false) + private String secondary = ""; + @CsvBindByName(column = "Inbetween", required = false) + private String inbetween = ""; + @CsvBindByName(column = "Around", required = false) + private String around = ""; + @CsvBindByName(column = "ID ", required = false) + private String mix = ""; + @CsvBindByName(column = "Tier", required = false) + private String tier = ""; + @CsvBindByName(column = "Height", required = false) + private String height = ""; + @CsvBindByName(column = "Density", required = false) + private int density; + @CsvBindByName(column = "Size", required = false) + private int size; + @CsvBindByName(column = "Weight", required = false) + private int weight; + @CsvCustomBindByName(column = "Overworld", required = false, converter = XtoBool.class) + private boolean overworld; + @CsvCustomBindByName(column = "Nether", required = false, converter = XtoBool.class) + private boolean nether; + @CsvCustomBindByName(column = "End", required = false, converter = XtoBool.class) + private boolean end; + @CsvCustomBindByName(column = "Moon", required = false, converter = XtoBool.class) + public boolean mo; + public boolean isMo() { + return mo; + } + + public void setMo(boolean mo) { + this.mo = mo; + } + + public boolean isEa() { + return ea; + } + + public void setEa(boolean ea) { + this.ea = ea; + } + + public boolean isAs() { + return as; + } + + public void setAs(boolean as) { + this.as = as; + } + + public boolean isBc() { + return bc; + } + + public void setBc(boolean bc) { + this.bc = bc; + } + + public boolean isBe() { + return be; + } + + public void setBe(boolean be) { + this.be = be; + } + + public boolean isBf() { + return bf; + } + + public void setBf(boolean bf) { + this.bf = bf; + } + + public boolean isMa() { + return ma; + } + + public void setMa(boolean ma) { + this.ma = ma; + } + + public boolean isCa() { + return ca; + } + + public void setCa(boolean ca) { + this.ca = ca; + } + + public boolean isCb() { + return cb; + } + + public void setCb(boolean cb) { + this.cb = cb; + } + + public boolean isCe() { + return ce; + } + + public void setCe(boolean ce) { + this.ce = ce; + } + + public boolean isTf() { + return tf; + } + + public void setTf(boolean tf) { + this.tf = tf; + } + + public boolean isDd() { + return dd; + } + + public void setDd(boolean dd) { + this.dd = dd; + } + + public boolean isPh() { + return ph; + } + + public void setPh(boolean ph) { + this.ph = ph; + } + + public boolean isDe() { + return de; + } + + public void setDe(boolean de) { + this.de = de; + } + + public boolean isEu() { + return eu; + } + + public void setEu(boolean eu) { + this.eu = eu; + } + + public boolean isGa() { + return ga; + } + + public void setGa(boolean ga) { + this.ga = ga; + } + + public boolean isIo() { + return io; + } + + public void setIo(boolean io) { + this.io = io; + } + + public boolean isVe() { + return ve; + } + + public void setVe(boolean ve) { + this.ve = ve; + } + + public boolean isMe() { + return me; + } + + public void setMe(boolean me) { + this.me = me; + } + + public boolean isEn() { + return en; + } + + public void setEn(boolean en) { + this.en = en; + } + + public boolean isTi() { + return ti; + } + + public void setTi(boolean ti) { + this.ti = ti; + } + + public boolean isMi() { + return mi; + } + + public void setMi(boolean mi) { + this.mi = mi; + } + + public boolean isOb() { + return ob; + } + + public void setOb(boolean ob) { + this.ob = ob; + } + + public boolean isTr() { + return tr; + } + + public void setTr(boolean tr) { + this.tr = tr; + } + + public boolean isPr() { + return pr; + } + + public void setPr(boolean pr) { + this.pr = pr; + } + + public boolean isPl() { + return pl; + } + + public void setPl(boolean pl) { + this.pl = pl; + } + + public boolean isKb() { + return kb; + } + + public void setKb(boolean kb) { + this.kb = kb; + } + + public boolean isHa() { + return ha; + } + + public void setHa(boolean ha) { + this.ha = ha; + } + + public boolean isMake() { + return make; + } + + public void setMake(boolean make) { + this.make = make; + } + + public boolean isVb() { + return vb; + } + + public void setVb(boolean vb) { + this.vb = vb; + } + + public boolean isTcetie() { + return tcetie; + } + + public void setTcetie(boolean tcetie) { + this.tcetie = tcetie; + } + + @CsvCustomBindByName(column = "End Asteroids", required = false, converter = XtoBool.class) + public boolean ea; + @CsvCustomBindByName(column = "Astroids", required = false, converter = XtoBool.class) + public boolean as; + @CsvCustomBindByName(column = "Barnard C", required = false, converter = XtoBool.class) + public boolean bc; + @CsvCustomBindByName(column = "Barnard E", required = false, converter = XtoBool.class) + public boolean be; + @CsvCustomBindByName(column = "Barnard F", required = false, converter = XtoBool.class) + public boolean bf; + @CsvCustomBindByName(column = "Mars", required = false, converter = XtoBool.class) + public boolean ma; + @CsvCustomBindByName(column = "Callisto", required = false, converter = XtoBool.class) + public boolean ca; + @CsvCustomBindByName(column = "Centauri Bb", required = false, converter = XtoBool.class) + public boolean cb; + @CsvCustomBindByName(column = "Ceres", required = false, converter = XtoBool.class) + public boolean ce; + @CsvCustomBindByName(column = "Twilight Forest", required = false, converter = XtoBool.class) + public boolean tf; + @CsvCustomBindByName(column = "Deep Dark", required = false, converter = XtoBool.class) + public boolean dd; + @CsvCustomBindByName(column = "Phobos", required = false, converter = XtoBool.class) + public boolean ph; + @CsvCustomBindByName(column = "Deimos", required = false, converter = XtoBool.class) + public boolean de; + @CsvCustomBindByName(column = "Europa", required = false, converter = XtoBool.class) + public boolean eu; + @CsvCustomBindByName(column = "Ganymede", required = false, converter = XtoBool.class) + public boolean ga; + @CsvCustomBindByName(column = "Io", required = false, converter = XtoBool.class) + public boolean io; + @CsvCustomBindByName(column = "Venus", required = false, converter = XtoBool.class) + public boolean ve; + @CsvCustomBindByName(column = "Mercury", required = false, converter = XtoBool.class) + public boolean me; + @CsvCustomBindByName(column = "Enceladus", required = false, converter = XtoBool.class) + public boolean en; + @CsvCustomBindByName(column = "Titan", required = false, converter = XtoBool.class) + public boolean ti; + @CsvCustomBindByName(column = "Miranda", required = false, converter = XtoBool.class) + public boolean mi; + @CsvCustomBindByName(column = "Oberon", required = false, converter = XtoBool.class) + public boolean ob; + @CsvCustomBindByName(column = "Triton", required = false, converter = XtoBool.class) + public boolean tr; + @CsvCustomBindByName(column = "Proteus", required = false, converter = XtoBool.class) + public boolean pr; + @CsvCustomBindByName(column = "Pluto", required = false, converter = XtoBool.class) + public boolean pl; + @CsvCustomBindByName(column = "Kuiper Belt", required = false, converter = XtoBool.class) + public boolean kb; + @CsvCustomBindByName(column = "Haumea", required = false, converter = XtoBool.class) + public boolean ha; + @CsvCustomBindByName(column = "Makemake", required = false, converter = XtoBool.class) + public boolean make; + @CsvCustomBindByName(column = "Vega B", required = false, converter = XtoBool.class) + public boolean vb; + @CsvCustomBindByName(column = "T Ceti E", required = false, converter = XtoBool.class) + public boolean tcetie; + + + + + public Oremix() { + } + + public void setOreName(String s) { + this.oreName = s; + } + public void setPrimary(String s) { + this.primary = s; + } + public void setSecondary(String s) { + this.secondary = s; + } + public void setInbetween(String s) { + this.inbetween = s; + } + public void setAround(String s) { + this.around = s; + } + public void setMix(String s) { + this.mix = s; + } + public void setTier(String s) { + this.tier = s; + } + public void setHeight(String s) { + this.height = s; + } + public void setDensity(int i) { + this.density = i; + } + public void setSize(int i) { + this.size = i; + } + public void setWeight(int i) { + this.weight = i; + } + public void setOverworld(boolean s) { + this.overworld = s; + } + public void setNether(boolean s) { + this.nether = s; + } + public void setEnd(boolean s) { + this.end = s; + } + + public String getOreName() { + return this.oreName; + } + + public String getPrimary() { + return this.primary; + } + public String getSecondary() { + return this.secondary; + } + public String getInbetween() { + return this.inbetween; + } + public String getAround() { + return this.around; + } + public String getMix() { + return this.mix; + } + public String getTier() { + return this.tier; + } + public String getHeight() { + return this.height; + } + public int getDensity() { + return this.density; + } + public int getSize() { + return this.size; + } + public int getWeight() { + return this.weight; + } + public int getMinY() { + calculateminmax(); + return this.miny; + } + public int getMaxY() { + calculateminmax(); + return this.maxy; + } + public boolean getOverworld() { + return this.overworld; + } + public boolean getNether() { + return this.nether; + } + public boolean getEnd() { + return this.end; + } + + private int miny,maxy; + + private void calculateminmax() { + this.miny=Integer.parseInt(this.height.split("-")[0]); + this.maxy=Integer.parseInt(this.height.split("-")[1]); + } + + public void setMinY(int i) { + this.miny=i; + } + public void setMaxY(int i) { + this.maxy=i; + } + + public String getHeightcalced() { + return new String (this.miny+"-"+this.maxy); + } + +} diff --git a/src/main/java/pers/gwyog/gtneioreplugin/util/Veinrenamer.java b/src/main/java/pers/gwyog/gtneioreplugin/util/Veinrenamer.java new file mode 100644 index 0000000000..8c0ca7df58 --- /dev/null +++ b/src/main/java/pers/gwyog/gtneioreplugin/util/Veinrenamer.java @@ -0,0 +1,28 @@ +package pers.gwyog.gtneioreplugin.util; + +import com.opencsv.bean.AbstractBeanField; +import com.opencsv.exceptions.CsvConstraintViolationException; +import com.opencsv.exceptions.CsvDataTypeMismatchException; + +public class Veinrenamer<T> extends AbstractBeanField<T> { + + @Override + protected Object convert(String value) throws CsvDataTypeMismatchException, CsvConstraintViolationException { + String ret = null; + CharSequence s = "/"; + + if (value.contains(s)) { + ret = value.split("/")[1]; + ret =ret.replaceAll("&", ""); + ret =ret.replaceAll(" ", ""); + ret =ret.replaceAll("\\.", ""); + ret = ret.toLowerCase(); + } + else + ret=value; + ret =ret.replaceAll(" ", ""); + ret = ret.toLowerCase(); + return ret; + } + +} diff --git a/src/main/java/pers/gwyog/gtneioreplugin/util/XtoBool.java b/src/main/java/pers/gwyog/gtneioreplugin/util/XtoBool.java new file mode 100644 index 0000000000..7839221630 --- /dev/null +++ b/src/main/java/pers/gwyog/gtneioreplugin/util/XtoBool.java @@ -0,0 +1,36 @@ +package pers.gwyog.gtneioreplugin.util; + +import java.util.ResourceBundle; + +import org.apache.commons.beanutils.ConversionException; +import org.apache.commons.beanutils.Converter; +import org.apache.commons.beanutils.converters.BooleanConverter; + +import com.opencsv.bean.AbstractBeanField; +import com.opencsv.exceptions.CsvConstraintViolationException; +import com.opencsv.exceptions.CsvDataTypeMismatchException; + +public class XtoBool<T> extends AbstractBeanField<T> { + + @Override + protected Object convert(String value) throws CsvDataTypeMismatchException, CsvConstraintViolationException { + if (value.isEmpty()) { + return null; + } + String[] trueStrings = {"x","X"}; + String[] falseStrings = {""}; + Converter bc = new BooleanConverter(trueStrings, falseStrings); + try { + return bc.convert(Boolean.class, value.trim()); + } catch (ConversionException e) { + CsvDataTypeMismatchException csve = new CsvDataTypeMismatchException( + value, field.getType(), ResourceBundle + .getBundle("convertGermanToBoolean", errorLocale) + .getString("input.not.boolean")); + csve.initCause(e); + throw csve; + } + } + + +} |