diff options
Diffstat (limited to 'src/main/java/pers/gwyog/gtneioreplugin/util')
8 files changed, 1036 insertions, 850 deletions
diff --git a/src/main/java/pers/gwyog/gtneioreplugin/util/CSVMaker.java b/src/main/java/pers/gwyog/gtneioreplugin/util/CSVMaker.java index 82a2f4f341..f12405a7ae 100644 --- a/src/main/java/pers/gwyog/gtneioreplugin/util/CSVMaker.java +++ b/src/main/java/pers/gwyog/gtneioreplugin/util/CSVMaker.java @@ -1,5 +1,13 @@ package pers.gwyog.gtneioreplugin.util; +import com.opencsv.CSVWriter; +import com.opencsv.bean.ColumnPositionMappingStrategy; +import com.opencsv.bean.StatefulBeanToCsv; +import com.opencsv.bean.StatefulBeanToCsvBuilder; +import pers.gwyog.gtneioreplugin.GTNEIOrePlugin; +import pers.gwyog.gtneioreplugin.plugin.gregtech5.PluginGT5VeinStat; +import pers.gwyog.gtneioreplugin.util.GT5OreLayerHelper.OreLayerWrapper; + import java.io.BufferedWriter; import java.nio.file.Files; import java.nio.file.Paths; @@ -8,60 +16,129 @@ import java.util.Iterator; import java.util.List; import java.util.Map; -import com.opencsv.CSVWriter; -import com.opencsv.bean.ColumnPositionMappingStrategy; -import com.opencsv.bean.StatefulBeanToCsv; -import com.opencsv.bean.StatefulBeanToCsvBuilder; +public class CSVMaker implements Runnable { -import pers.gwyog.gtneioreplugin.GTNEIOrePlugin; -import pers.gwyog.gtneioreplugin.plugin.gregtech5.PluginGT5VeinStat; -import pers.gwyog.gtneioreplugin.util.GT5OreLayerHelper.OreLayerWrapper; + public CSVMaker() { -public class CSVMaker implements Runnable { + } + + public static List<Oremix> Combsort(List<Oremix> liste) { + try { + List<Oremix> liste2 = new ArrayList<Oremix>(liste.size()); + for (Oremix element : liste) { + liste2.add(element); + } - public CSVMaker() { - - } - - public static <T> List<Oremix> Combsort(List<Oremix> liste) { - try { - 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; - }catch (Exception e) { - e.printStackTrace(); - return null; - } + 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) { + Oremix tmp = (Oremix) liste2.get(i); + liste2.set(i, liste2.get(i + schritt)); + liste2.set(i + schritt, (Oremix) tmp); + vertauscht = true; + } + } + } while (vertauscht || schritt > 1); + return liste2; + } catch (Exception e) { + e.printStackTrace(); + return null; + } } - - public void run() { - try { - Iterator it = GT5OreLayerHelper.mapOreLayerWrapper.entrySet().iterator(); - List<Oremix> OreVeins=new ArrayList(); - while (it.hasNext()) { - Oremix oremix = new Oremix(); - - Map.Entry pair = (Map.Entry)it.next(); - String Dims = PluginGT5VeinStat.getDims((OreLayerWrapper)pair.getValue()); + + public void runSmallOres() { + try { + Iterator it = GT5OreSmallHelper.mapOreSmallWrapper.entrySet().iterator(); + List<Oremix> OreVeins = new ArrayList(); + while (it.hasNext()) { + Oremix oremix = new Oremix(); + + Map.Entry pair = (Map.Entry) it.next(); + String Dims = GT5OreSmallHelper.bufferedDims.get(pair.getValue()); + GT5OreSmallHelper.OreSmallWrapper oreLayer = (GT5OreSmallHelper.OreSmallWrapper) pair.getValue(); + oremix.setOreName(oreLayer.oreGenName.split("\\.")[2]); + oremix.setHeight(oreLayer.worldGenHeightRange); + oremix.setDensity(oreLayer.amountPerChunk); + 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")); + OreVeins.add(oremix); + + System.out.println(pair.getKey() + " = " + pair.getValue()); + it.remove(); // avoids a ConcurrentModificationException + } + BufferedWriter one = Files.newBufferedWriter(Paths.get(GTNEIOrePlugin.CSVnameSmall)); + ColumnPositionMappingStrategy strat = new ColumnPositionMappingStrategy(); + strat.setType(Oremix.class); + String[] columns = "ORENAME,mix,DENSITY,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(OreVeins); + 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); + one.flush(); + one.close(); + } catch (Exception e) { + e.printStackTrace(); + } + } + + @Override + public void run() { + runVeins(); + runSmallOres(); + } + + public void runVeins() { + try { + Iterator it = GT5OreLayerHelper.mapOreLayerWrapper.entrySet().iterator(); + List<Oremix> OreVeins = new ArrayList(); + while (it.hasNext()) { + Oremix oremix = new Oremix(); + + Map.Entry pair = (Map.Entry) it.next(); + String Dims = GT5OreLayerHelper.bufferedDims.get(pair.getValue()); OreLayerWrapper oreLayer = (OreLayerWrapper) pair.getValue(); oremix.setOreName(oreLayer.veinName.split("\\.")[2]); oremix.setPrimary(PluginGT5VeinStat.getGTOreLocalizedName(oreLayer.Meta[0])); @@ -72,66 +149,65 @@ public class CSVMaker implements Runnable { 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.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")); OreVeins.add(oremix); - - + + System.out.println(pair.getKey() + " = " + pair.getValue()); it.remove(); // avoids a ConcurrentModificationException - } - BufferedWriter one = Files.newBufferedWriter(Paths.get(GTNEIOrePlugin.CSVname)); + } + BufferedWriter one = Files.newBufferedWriter(Paths.get(GTNEIOrePlugin.CSVname)); 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) + StatefulBeanToCsv<Oremix> beanToCsv = new StatefulBeanToCsvBuilder(one) .withQuotechar(CSVWriter.NO_QUOTE_CHARACTER) .withMappingStrategy(strat) .build(); - List towrite = Combsort(OreVeins); - 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); - one.flush(); - one.close(); - - }catch (Exception e) { - e.printStackTrace(); - } - } + List towrite = Combsort(OreVeins); + 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); + one.flush(); + one.close(); + } catch (Exception e) { + e.printStackTrace(); + } + } } diff --git a/src/main/java/pers/gwyog/gtneioreplugin/util/DimensionHelper.java b/src/main/java/pers/gwyog/gtneioreplugin/util/DimensionHelper.java index c0842bfbfa..1d4b0e0025 100644 --- a/src/main/java/pers/gwyog/gtneioreplugin/util/DimensionHelper.java +++ b/src/main/java/pers/gwyog/gtneioreplugin/util/DimensionHelper.java @@ -1,85 +1,114 @@ package pers.gwyog.gtneioreplugin.util; -import net.minecraft.world.World; -import net.minecraft.world.WorldProvider; -import net.minecraft.world.WorldServer; -import net.minecraftforge.common.DimensionManager; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; public class DimensionHelper { - - public static String[] DimName = - { - "EndAsteroid", - "GalacticraftCore_Moon", - "GalacticraftMars_Asteroids", - "GalacticraftMars_Mars", - "GalaxySpace_BarnardC", - "GalaxySpace_BarnardE", - "GalaxySpace_BarnardF", - "GalaxySpace_Callisto", - "GalaxySpace_CentauriA", - "GalaxySpace_Ceres", - "GalaxySpace_Deimos", - "GalaxySpace_Enceladus", - "GalaxySpace_Europa", - "GalaxySpace_Ganymede", - "GalaxySpace_Haumea", - "GalaxySpace_Io", - "GalaxySpace_Kuiperbelt", - "GalaxySpace_MakeMake", - "GalaxySpace_Mercury", - "GalaxySpace_Miranda", - "GalaxySpace_Oberon", - "GalaxySpace_Phobos", - "GalaxySpace_Pluto", - "GalaxySpace_Proteus", - "GalaxySpace_TcetiE", - "GalaxySpace_Titan", - "GalaxySpace_Triton", - "GalaxySpace_VegaB", - "GalaxySpace_Venus", - "Nether", - "Overworld", - "TheEnd", - "Vanilla_EndAsteroids", - "Twilight", - "Underdark"}; - - public static String[] DimNameDisplayed = - {// first 2 letters if one word else 1 letter of every word, execpt capital letter in name, then 1rst + capital Moon = Mo, BarnardC = BC, EndAsteroid = EA - "EA", - "Mo", - "As", - "Ma", - "BC", - "BE", - "BF", - "Ca", - "CA", - "Ce", - "De", - "En", - "Eu", - "Ga", - "Ha", - "Io", - "KB", - "MM", - "Me", - "Mi", - "Ob", - "Ph", - "Pl", - "Pr", - "TE", - "Ti", - "Tr", - "VB", - "Ve", - "Ne", - "Ow", - "EN",//End = EN bc En = Encalus - "VA", - "TF", - "DD"}; + + public static String[] DimName = + { + "EndAsteroid", + "GalacticraftCore_Moon", + "GalacticraftMars_Asteroids", + "GalacticraftMars_Mars", + "GalaxySpace_BarnardC", + "GalaxySpace_BarnardE", + "GalaxySpace_BarnardF", + "GalaxySpace_Callisto", + "GalaxySpace_CentauriA", + "GalaxySpace_Ceres", + "GalaxySpace_Deimos", + "GalaxySpace_Enceladus", + "GalaxySpace_Europa", + "GalaxySpace_Ganymede", + "GalaxySpace_Haumea", + "GalaxySpace_Io", + "GalaxySpace_Kuiperbelt", + "GalaxySpace_MakeMake", + "GalaxySpace_Mercury", + "GalaxySpace_Miranda", + "GalaxySpace_Oberon", + "GalaxySpace_Phobos", + "GalaxySpace_Pluto", + "GalaxySpace_Proteus", + "GalaxySpace_TcetiE", + "GalaxySpace_Titan", + "GalaxySpace_Triton", + "GalaxySpace_VegaB", + "GalaxySpace_Venus", + "Nether", + "Overworld", + "TheEnd", + "Vanilla_EndAsteroids", + "Twilight", + "Underdark" + }; + + public static String[] DimNameDisplayed = + {// first 2 letters if one word else 1 letter of every word, execpt capital letter in name, then 1rst + capital Moon = Mo, BarnardC = BC, EndAsteroid = EA + "EA", + "Mo", + "As", + "Ma", + "BC", + "BE", + "BF", + "Ca", + "CA", + "Ce", + "De", + "En", + "Eu", + "Ga", + "Ha", + "Io", + "KB", + "MM", + "Me", + "Mi", + "Ob", + "Ph", + "Pl", + "Pr", + "TE", + "Ti", + "Tr", + "VB", + "Ve", + "Ne", + "Ow", + "EN",//End = EN bc En = Encalus + "VA", + "TF", + "DD" + }; + + private static HashMap<String, List<String>> tooltipBuffer = new HashMap<>(); + + private static List<String> computeString(String line) { + String[] dims = line.split(","); + for (int j = 0; j < dims.length; j++) { + String s = dims[j]; + s = s.replaceAll(",", ""); + s = s.trim(); + for (int i = 0; i < DimNameDisplayed.length; i++) { + if (s.equals(DimNameDisplayed[i])) { + s = DimName[i].replaceAll("GalacticraftCore_", "").replaceAll("GalacticraftMars_", "").replaceAll("GalaxySpace_", "").replaceAll("Vanilla_", "Vanilla "); + if (s.equals("Twilight")) + s = "Twilight Forrest"; + else if (s.equals("Underdark")) + s = "Deep Dark"; + else if (s.equals("EndAsteroid")) + s = "Far End Asteroids"; + dims[j] = s; + } + } + } + return Arrays.asList(dims); + } + + public static List<String> convertCondensedStringToToolTip(String line) { + return tooltipBuffer.computeIfAbsent(line, (String tmp) -> computeString(line)); + } }
\ No newline at end of file diff --git a/src/main/java/pers/gwyog/gtneioreplugin/util/GT5CFGHelper.java b/src/main/java/pers/gwyog/gtneioreplugin/util/GT5CFGHelper.java index c616534d8d..00260020da 100644 --- a/src/main/java/pers/gwyog/gtneioreplugin/util/GT5CFGHelper.java +++ b/src/main/java/pers/gwyog/gtneioreplugin/util/GT5CFGHelper.java @@ -1,5 +1,12 @@ package pers.gwyog.gtneioreplugin.util; +import cpw.mods.fml.common.FMLLog; +import gregtech.api.GregTech_API; +import net.minecraftforge.common.config.ConfigCategory; +import net.minecraftforge.common.config.Configuration; +import net.minecraftforge.common.config.Property; +import pers.gwyog.gtneioreplugin.GTNEIOrePlugin; + import java.io.BufferedReader; import java.io.File; import java.io.FileReader; @@ -8,128 +15,170 @@ import java.util.ArrayList; import java.util.HashSet; import java.util.List; -import cpw.mods.fml.common.FMLLog; - public class GT5CFGHelper { - - public static String GT5CFG(File F, String Veinname) { - //FMLLog.info(Veinname); - if (F == null) { - FMLLog.bigWarning("GT_CFG_NOT_found[0]"); - return "Error while Loading CFG"; - } - else - try { - int buffer = (int) (0.1*Runtime.getRuntime().freeMemory()); - if (buffer > F.length()) - buffer = (int) F.length(); - //allocate 10% of free memory for read-in-buffer, if there is less than filesize memory aviable - //FMLLog.info("GT_CFG_found[0]"); - FileReader in = new FileReader(F); - //FMLLog.info("FileReader created"); - BufferedReader reader = new BufferedReader(in, buffer); - //FMLLog.info("BufferedReader" +Integer.toString(buffer)+"created"); - String st=null; - List<String> raw= new ArrayList<String>(); - List<String> rawbools = new ArrayList<String>(); - Boolean[] found = new Boolean[2]; - found[0] = false; - found[1] = false; - - do{ - //FMLLog.info("erste"); - //read until reached eof or mix { - st = reader.readLine(); - //FMLLog.info("st: "+st); - if (st != null && st.trim().equals("mix {")) { - while(!((st == null)||((st != null)&&found[0]))){ - //FMLLog.info("zweite"); - st = reader.readLine(); - //read until reached eof or Veinname { - //FMLLog.info("MIXst: "+st); - if (st != null && st.trim().equals(Veinname+" {")) { - //FMLLog.info("VEINNAMEst: "+st); - while (!((st == null)||((st != null) && found[0]))){ - st = reader.readLine(); - if ((!(st == null)) && st.trim().equals("}")) - found[0] = true; - //FMLLog.info("dritte"); - //add everything below Veinname { undtil } to raw - raw.add(st); - } - } - } - } - - if (st != null && st.trim().equals("dimensions {")) { - while(!((st == null)||((st != null)&&found[1]))){ - //FMLLog.info("zweite"); - st = reader.readLine(); - if (st != null && (st.trim().equals("mix {"))) { - while(!((st == null)||((st != null)&&found[1]))){ - //FMLLog.info("dritte"); - st = reader.readLine(); - //read until reached eof or Veinname { - //FMLLog.info("MIXst: "+st); - if (st != null && st.trim().equals(Veinname+" {")) { - //FMLLog.info("VEINNAMEst: "+st); - while (!((st == null)||((st != null)&&found[1]))){ - st = reader.readLine(); - if ((!(st == null)) && st.trim().equals("}")) - found[1] = true; - //FMLLog.info("vierte"); - //add everything below Veinname { undtil } to raw - raw.add(st); - } - } - } - } - } - } - }while(st != null); - reader.close();//not needed anymore - - if (!raw.isEmpty()) - for (int i=0; i < raw.size();i++) { - //filter needed booleans from raw - ///FMLLog.info("raw contains"+raw.get(i)); - for (int j=0; j < DimensionHelper.DimName.length;j++) - if(raw.get(i).contains(DimensionHelper.DimName[j])) - rawbools.add(raw.get(i)); - //FMLLog.info("rawbools: "+rawbools.get(i)); - } - else FMLLog.info("raw is empty"); - - String ret=" "; - - HashSet<String> rawboolsset = new HashSet<String>(); - if (!rawbools.isEmpty()) { - //remove dublicats - for (int i=0; i < rawbools.size();i++){ - st = rawbools.get(i).replace("B:", "").replace("_true", "").replace("_false", "").replaceAll(" ", "").replaceAll("\"", ""); - rawboolsset.add(st); - } - rawbools = new ArrayList<String>(rawboolsset); - //filter for dims set to true - for (int i=0; i < rawbools.size();i++) { - st = rawbools.get(i); - //FMLLog.info("RawBools:"+st); - for (int j=0; j < DimensionHelper.DimName.length;j++) { - if(st.contains(DimensionHelper.DimName[j])) - if(st.contains("=true")) - ret=(ret+DimensionHelper.DimNameDisplayed[j]+","); - } - } - } - ret = ret.trim(); - //FMLLog.info("ret:"+ret); - if(ret.equals("")||ret.equals(" ")) - ret ="Not aviable in any Galactic Dim!"; + + private static File F = GregTech_API.sWorldgenFile.mConfig.getConfigFile(); + + public static String GT5CFGSmallOres(String Veinname) { + List<String> raw = new ArrayList<String>(); + List<String> rawbools = new ArrayList<String>(); + String st = null; + Configuration c = new Configuration(F); + ConfigCategory configCategory = c.getCategory("worldgen." + Veinname); + for (Property p : configCategory.getOrderedValues()) { + if (p.isBooleanValue() && p.getBoolean()) { + raw.add(p.getName() + "=" + p.getBoolean()); + } + } + if (!raw.isEmpty()) + for (int i = 0; i < raw.size(); i++) { + for (int j = 0; j < DimensionHelper.DimName.length; j++) + if (raw.get(i).contains(DimensionHelper.DimName[j])) + rawbools.add(raw.get(i)); + } + else GTNEIOrePlugin.LOG.info("Config entry not found for Vein: " + Veinname); + + String ret = " "; + + HashSet<String> rawboolsset = new HashSet<String>(); + if (!rawbools.isEmpty()) { + for (int i = 0; i < rawbools.size(); i++) { + st = rawbools.get(i).replace("B:", "").replace("_true", "").replace("_false", "").replaceAll(" ", "").replaceAll("\"", ""); + rawboolsset.add(st); + } + rawbools = new ArrayList<String>(rawboolsset); + for (int i = 0; i < rawbools.size(); i++) { + st = rawbools.get(i); + for (int j = 0; j < DimensionHelper.DimName.length; j++) { + if (st.contains(DimensionHelper.DimName[j])) + if (st.contains("=true")) + ret = (ret + DimensionHelper.DimNameDisplayed[j] + ","); + } + } + } + ret = ret.trim(); + if (ret.equals("") || ret.equals(" ")) + ret = "Not aviable in any Galactic Dim!"; return ret; - } catch (IOException e) { - e.printStackTrace(); - return "Error while Loading CFG"; - } - } + } + + public static String GT5CFG(String Veinname) { + //FMLLog.info(Veinname); + if (F == null) { + FMLLog.bigWarning("GT_CFG_NOT_found[0]"); + return "Error while Loading CFG"; + } else + try { + int buffer = (int) (0.1 * Runtime.getRuntime().freeMemory()); + if (buffer > F.length()) + buffer = (int) F.length(); + //allocate 10% of free memory for read-in-buffer, if there is less than filesize memory aviable + //FMLLog.info("GT_CFG_found[0]"); + FileReader in = new FileReader(F); + //FMLLog.info("FileReader created"); + BufferedReader reader = new BufferedReader(in, buffer); + //FMLLog.info("BufferedReader" +Integer.toString(buffer)+"created"); + String st = null; + List<String> raw = new ArrayList<String>(); + List<String> rawbools = new ArrayList<String>(); + Boolean[] found = new Boolean[2]; + found[0] = false; + found[1] = false; + + do { + //FMLLog.info("erste"); + //read until reached eof or mix { + st = reader.readLine(); + //FMLLog.info("st: "+st); + if (st != null && st.trim().equals("mix {")) { + while (!((st == null) || ((st != null) && found[0]))) { + //FMLLog.info("zweite"); + st = reader.readLine(); + //read until reached eof or Veinname { + //FMLLog.info("MIXst: "+st); + if (st != null && st.trim().equals(Veinname + " {")) { + //FMLLog.info("VEINNAMEst: "+st); + while (!((st == null) || ((st != null) && found[0]))) { + st = reader.readLine(); + if ((!(st == null)) && st.trim().equals("}")) + found[0] = true; + //FMLLog.info("dritte"); + //add everything below Veinname { undtil } to raw + raw.add(st); + } + } + } + } + + if (st != null && st.trim().equals("dimensions {")) { + while (!((st == null) || ((st != null) && found[1]))) { + //FMLLog.info("zweite"); + st = reader.readLine(); + if (st != null && (st.trim().equals("mix {"))) { + while (!((st == null) || ((st != null) && found[1]))) { + //FMLLog.info("dritte"); + st = reader.readLine(); + //read until reached eof or Veinname { + //FMLLog.info("MIXst: "+st); + if (st != null && st.trim().equals(Veinname + " {")) { + //FMLLog.info("VEINNAMEst: "+st); + while (!((st == null) || ((st != null) && found[1]))) { + st = reader.readLine(); + if ((!(st == null)) && st.trim().equals("}")) + found[1] = true; + //FMLLog.info("vierte"); + //add everything below Veinname { undtil } to raw + raw.add(st); + } + } + } + } + } + } + } while (st != null); + reader.close();//not needed anymore + + if (!raw.isEmpty()) + for (int i = 0; i < raw.size(); i++) { + //filter needed booleans from raw + ///FMLLog.info("raw contains"+raw.get(i)); + for (int j = 0; j < DimensionHelper.DimName.length; j++) + if (raw.get(i).contains(DimensionHelper.DimName[j])) + rawbools.add(raw.get(i)); + //FMLLog.info("rawbools: "+rawbools.get(i)); + } + else GTNEIOrePlugin.LOG.info("Config entry not found for Vein: " + Veinname); + + String ret = " "; + + HashSet<String> rawboolsset = new HashSet<String>(); + if (!rawbools.isEmpty()) { + //remove dublicats + for (int i = 0; i < rawbools.size(); i++) { + st = rawbools.get(i).replace("B:", "").replace("_true", "").replace("_false", "").replaceAll(" ", "").replaceAll("\"", ""); + rawboolsset.add(st); + } + rawbools = new ArrayList<String>(rawboolsset); + //filter for dims set to true + for (int i = 0; i < rawbools.size(); i++) { + st = rawbools.get(i); + //FMLLog.info("RawBools:"+st); + for (int j = 0; j < DimensionHelper.DimName.length; j++) { + if (st.contains(DimensionHelper.DimName[j])) + if (st.contains("=true")) + ret = (ret + DimensionHelper.DimNameDisplayed[j] + ","); + } + } + } + ret = ret.trim(); + //FMLLog.info("ret:"+ret); + if (ret.equals("") || ret.equals(" ")) + ret = "Not aviable in any Galactic Dim!"; + return ret; + } catch (IOException e) { + e.printStackTrace(); + return "Error while Loading CFG"; + } + } } diff --git a/src/main/java/pers/gwyog/gtneioreplugin/util/GT5OreLayerHelper.java b/src/main/java/pers/gwyog/gtneioreplugin/util/GT5OreLayerHelper.java index 2b6e286174..9e8a608405 100644 --- a/src/main/java/pers/gwyog/gtneioreplugin/util/GT5OreLayerHelper.java +++ b/src/main/java/pers/gwyog/gtneioreplugin/util/GT5OreLayerHelper.java @@ -1,57 +1,41 @@ 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 gregtech.common.GT_Worldgen_GT_Ore_Layer; + 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 { - + public static Integer weightPerWorld[] = new Integer[33]; public static Integer DimIDs[] = new Integer[33]; public static HashMap<String, OreLayerWrapper> mapOreLayerWrapper = new HashMap<String, OreLayerWrapper>(); + public static HashMap<OreLayerWrapper, String> bufferedDims = new HashMap<>(); public GT5OreLayerHelper() { - for (int i=0; i < DimIDs.length;i++) - weightPerWorld[i]=0; - for (int i=0; i < DimIDs.length;i++) - DimIDs[i]=0; - for (GT_Worldgen_GT_Ore_Layer tWorldGen: GT_Worldgen_GT_Ore_Layer.sList) + for (int i = 0; i < DimIDs.length; i++) + weightPerWorld[i] = 0; + for (int i = 0; i < DimIDs.length; i++) + DimIDs[i] = 0; + for (GT_Worldgen_GT_Ore_Layer tWorldGen : GT_Worldgen_GT_Ore_Layer.sList) mapOreLayerWrapper.put(tWorldGen.mWorldGenName, new OreLayerWrapper(tWorldGen)); - } - + for (OreLayerWrapper layer : mapOreLayerWrapper.values()) { + bufferedDims.put(layer, getDims(layer)); + } + } + + public static String getDims(OreLayerWrapper oreLayer) { + return GT5CFGHelper.GT5CFG(oreLayer.veinName.replace("ore.mix.custom.", "").replace("ore.mix.", "")); + } + + public class OreLayerWrapper { - public String veinName, worldGenHeightRange, weightedIEChance; + public String veinName, worldGenHeightRange; public short[] Meta = new short[4]; public short randomWeight, size, density; public List<Integer> Weight = new ArrayList<Integer>(); - + public OreLayerWrapper(GT_Worldgen_GT_Ore_Layer worldGen) { this.veinName = worldGen.mWorldGenName; this.Meta[0] = worldGen.mPrimaryMeta; @@ -62,7 +46,7 @@ public class GT5OreLayerHelper { this.density = worldGen.mDensity; this.worldGenHeightRange = worldGen.mMinY + "-" + worldGen.mMaxY; this.randomWeight = worldGen.mWeight; - } } } +}
\ No newline at end of file diff --git a/src/main/java/pers/gwyog/gtneioreplugin/util/GT5OreSmallHelper.java b/src/main/java/pers/gwyog/gtneioreplugin/util/GT5OreSmallHelper.java index 18aca0e5d8..6dc155e9fd 100644 --- a/src/main/java/pers/gwyog/gtneioreplugin/util/GT5OreSmallHelper.java +++ b/src/main/java/pers/gwyog/gtneioreplugin/util/GT5OreSmallHelper.java @@ -1,19 +1,17 @@ package pers.gwyog.gtneioreplugin.util; -import java.lang.reflect.Field; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; - import gregtech.api.GregTech_API; import gregtech.api.enums.Materials; import gregtech.api.enums.OrePrefixes; import gregtech.api.util.GT_OreDictUnificator; import gregtech.api.world.GT_Worldgen; import gregtech.common.GT_Worldgen_GT_Ore_SmallPieces; -import net.minecraft.client.resources.I18n; import net.minecraft.item.ItemStack; -import pers.gwyog.gtneioreplugin.GTNEIOrePlugin; + +import java.lang.reflect.Field; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; public class GT5OreSmallHelper { public static boolean restrictBiomeSupport = false; @@ -21,8 +19,9 @@ public class GT5OreSmallHelper { public static List<ItemStack> oreSmallList = new ArrayList<ItemStack>(); public static HashMap<String, OreSmallWrapper> mapOreSmallWrapper = new HashMap<String, OreSmallWrapper>(); public static HashMap<String, Short> mapOreDropUnlocalizedNameToOreMeta = new HashMap<String, Short>(); - public static HashMap<Short, List<ItemStack>> mapOreMetaToOreDrops = new HashMap<Short, List<ItemStack>>(); - + public static HashMap<Short, List<ItemStack>> mapOreMetaToOreDrops = new HashMap<Short, List<ItemStack>>(); + public static HashMap<OreSmallWrapper, String> bufferedDims = new HashMap<>(); + public GT5OreSmallHelper() { checkExtraSupport(); ItemStack stack; @@ -30,68 +29,95 @@ public class GT5OreSmallHelper { short meta; for (GT_Worldgen worldGen : GregTech_API.sWorldgenList) if (worldGen.mWorldGenName.startsWith("ore.small.") && worldGen instanceof GT_Worldgen_GT_Ore_SmallPieces) { - GT_Worldgen_GT_Ore_SmallPieces worldGenSmallPieces = (GT_Worldgen_GT_Ore_SmallPieces)worldGen; + GT_Worldgen_GT_Ore_SmallPieces worldGenSmallPieces = (GT_Worldgen_GT_Ore_SmallPieces) worldGen; meta = worldGenSmallPieces.mMeta; - if (meta<0) - break; + if (meta < 0) + break; material = GregTech_API.sGeneratedMaterials[meta]; mapOreSmallWrapper.put(worldGen.mWorldGenName, new OreSmallWrapper(worldGenSmallPieces)); if (!mapOreMetaToOreDrops.keySet().contains(meta)) { List<ItemStack> stackList = new ArrayList<ItemStack>(); stack = GT_OreDictUnificator.get(OrePrefixes.gemExquisite, material, GT_OreDictUnificator.get(OrePrefixes.gem, material, 1L), 1L); - if (stack != null && !mapOreDropUnlocalizedNameToOreMeta.keySet().contains(stack.getUnlocalizedName())) {mapOreDropUnlocalizedNameToOreMeta.put(stack.getUnlocalizedName(), meta);stackList.add(stack);} + if (stack != null && !mapOreDropUnlocalizedNameToOreMeta.keySet().contains(stack.getUnlocalizedName())) { + mapOreDropUnlocalizedNameToOreMeta.put(stack.getUnlocalizedName(), meta); + stackList.add(stack); + } stack = GT_OreDictUnificator.get(OrePrefixes.gemFlawless, material, GT_OreDictUnificator.get(OrePrefixes.gem, material, 1L), 1L); - if (stack != null && !mapOreDropUnlocalizedNameToOreMeta.keySet().contains(stack.getUnlocalizedName())) {mapOreDropUnlocalizedNameToOreMeta.put(stack.getUnlocalizedName(), meta);stackList.add(stack);} + if (stack != null && !mapOreDropUnlocalizedNameToOreMeta.keySet().contains(stack.getUnlocalizedName())) { + mapOreDropUnlocalizedNameToOreMeta.put(stack.getUnlocalizedName(), meta); + stackList.add(stack); + } stack = GT_OreDictUnificator.get(OrePrefixes.gem, material, 1L); - if (stack != null && !mapOreDropUnlocalizedNameToOreMeta.keySet().contains(stack.getUnlocalizedName())) {mapOreDropUnlocalizedNameToOreMeta.put(stack.getUnlocalizedName(), meta);stackList.add(stack);} + if (stack != null && !mapOreDropUnlocalizedNameToOreMeta.keySet().contains(stack.getUnlocalizedName())) { + mapOreDropUnlocalizedNameToOreMeta.put(stack.getUnlocalizedName(), meta); + stackList.add(stack); + } stack = GT_OreDictUnificator.get(OrePrefixes.gemFlawed, material, GT_OreDictUnificator.get(OrePrefixes.crushed, material, 1L), 1L); - if (stack != null && !mapOreDropUnlocalizedNameToOreMeta.keySet().contains(stack.getUnlocalizedName())) {mapOreDropUnlocalizedNameToOreMeta.put(stack.getUnlocalizedName(), meta);stackList.add(stack);} + if (stack != null && !mapOreDropUnlocalizedNameToOreMeta.keySet().contains(stack.getUnlocalizedName())) { + mapOreDropUnlocalizedNameToOreMeta.put(stack.getUnlocalizedName(), meta); + stackList.add(stack); + } stack = GT_OreDictUnificator.get(OrePrefixes.crushed, material, 1L); - if (stack != null && !mapOreDropUnlocalizedNameToOreMeta.keySet().contains(stack.getUnlocalizedName())) {mapOreDropUnlocalizedNameToOreMeta.put(stack.getUnlocalizedName(), meta);stackList.add(stack);} + if (stack != null && !mapOreDropUnlocalizedNameToOreMeta.keySet().contains(stack.getUnlocalizedName())) { + mapOreDropUnlocalizedNameToOreMeta.put(stack.getUnlocalizedName(), meta); + stackList.add(stack); + } stack = GT_OreDictUnificator.get(OrePrefixes.gemChipped, material, GT_OreDictUnificator.get(OrePrefixes.dustImpure, material, 1L), 1L); - if (stack != null && !mapOreDropUnlocalizedNameToOreMeta.keySet().contains(stack.getUnlocalizedName())) {mapOreDropUnlocalizedNameToOreMeta.put(stack.getUnlocalizedName(), meta);stackList.add(stack);} + if (stack != null && !mapOreDropUnlocalizedNameToOreMeta.keySet().contains(stack.getUnlocalizedName())) { + mapOreDropUnlocalizedNameToOreMeta.put(stack.getUnlocalizedName(), meta); + stackList.add(stack); + } stack = GT_OreDictUnificator.get(OrePrefixes.dustImpure, material, 1L); - if (stack != null && !mapOreDropUnlocalizedNameToOreMeta.keySet().contains(stack.getUnlocalizedName())) {mapOreDropUnlocalizedNameToOreMeta.put(stack.getUnlocalizedName(), meta);stackList.add(stack);} - oreSmallList.add(new ItemStack(GregTech_API.sBlockOres1, 1, meta+16000)); + if (stack != null && !mapOreDropUnlocalizedNameToOreMeta.keySet().contains(stack.getUnlocalizedName())) { + mapOreDropUnlocalizedNameToOreMeta.put(stack.getUnlocalizedName(), meta); + stackList.add(stack); + } + oreSmallList.add(new ItemStack(GregTech_API.sBlockOres1, 1, meta + 16000)); mapOreMetaToOreDrops.put(meta, stackList); } } + for (OreSmallWrapper oreSmallWrapper : mapOreSmallWrapper.values()) { + bufferedDims.put(oreSmallWrapper, GT5CFGHelper.GT5CFGSmallOres(oreSmallWrapper.oreGenName)); + } } - + private static void checkExtraSupport() { - Class clazzGTOreSmall = null; + Class clazzGTOreSmall = null; + try { + clazzGTOreSmall = Class.forName("gregtech.common.GT_Worldgen_GT_Ore_SmallPieces"); + } catch (ClassNotFoundException e) { + } + if (clazzGTOreSmall != null) { try { - clazzGTOreSmall = Class.forName("gregtech.common.GT_Worldgen_GT_Ore_SmallPieces"); - } catch (ClassNotFoundException e) {} - if (clazzGTOreSmall != null) { - try { - Field fieldRestrictBiome = clazzGTOreSmall.getField("mRestrictBiome");; - restrictBiomeSupport = true; - } catch (Exception e) {} - try { - Field fieldGCMoon = clazzGTOreSmall.getField("mMoon"); - Field fieldGCMars = clazzGTOreSmall.getField("mMars"); - gcBasicSupport = true; - } catch (Exception e) {} - } + Field fieldRestrictBiome = clazzGTOreSmall.getField("mRestrictBiome"); + restrictBiomeSupport = true; + } catch (Exception e) { + } + try { + Field fieldGCMoon = clazzGTOreSmall.getField("mMoon"); + Field fieldGCMars = clazzGTOreSmall.getField("mMars"); + gcBasicSupport = true; + } catch (Exception e) { + } + } } - + public static Materials[] getDroppedDusts() { return new Materials[]{Materials.Stone, Materials.Netherrack, Materials.Endstone, Materials.GraniteBlack, Materials.GraniteRed, Materials.Marble, Materials.Basalt, Materials.Stone}; } - + public class OreSmallWrapper { public String oreGenName; public short oreMeta; public String worldGenHeightRange; public short amountPerChunk; public String restrictBiome; - + public OreSmallWrapper(GT_Worldgen_GT_Ore_SmallPieces worldGen) { this.oreGenName = worldGen.mWorldGenName; this.oreMeta = worldGen.mMeta; this.worldGenHeightRange = worldGen.mMinY + "-" + worldGen.mMaxY; this.amountPerChunk = worldGen.mAmount; - } } } +} diff --git a/src/main/java/pers/gwyog/gtneioreplugin/util/Oremix.java b/src/main/java/pers/gwyog/gtneioreplugin/util/Oremix.java index 1b1f44df67..559a11cca8 100644 --- a/src/main/java/pers/gwyog/gtneioreplugin/util/Oremix.java +++ b/src/main/java/pers/gwyog/gtneioreplugin/util/Oremix.java @@ -4,463 +4,487 @@ 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; - } + @CsvCustomBindByName(column = "Moon", required = false, converter = XtoBool.class) + public boolean mo; + @CsvCustomBindByName(column = "End Asteroids", required = false, converter = XtoBool.class) + public boolean ea; + @CsvCustomBindByName(column = "AstroidBelt", 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; + @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; + private int miny, maxy; + + public Oremix() { + } + + 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 boolean isDe() { - return de; - } + public void setDd(boolean dd) { + this.dd = dd; + } - public void setDe(boolean de) { - this.de = de; - } + public boolean isPh() { + return ph; + } - public boolean isEu() { - return eu; - } + public void setPh(boolean ph) { + this.ph = ph; + } - public void setEu(boolean eu) { - this.eu = eu; - } + public boolean isDe() { + return de; + } - public boolean isGa() { - return ga; - } + public void setDe(boolean de) { + this.de = de; + } - public void setGa(boolean ga) { - this.ga = ga; - } + public boolean isEu() { + return eu; + } - public boolean isIo() { - return io; - } + public void setEu(boolean eu) { + this.eu = eu; + } - public void setIo(boolean io) { - this.io = io; - } + public boolean isGa() { + return ga; + } - public boolean isVe() { - return ve; - } + public void setGa(boolean ga) { + this.ga = ga; + } - public void setVe(boolean ve) { - this.ve = ve; - } + public boolean isIo() { + return io; + } - public boolean isMe() { - return me; - } + public void setIo(boolean io) { + this.io = io; + } - public void setMe(boolean me) { - this.me = me; - } + 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; + } + + public String getOreName() { + return this.oreName; + } + + public void setOreName(String s) { + this.oreName = s; + } + + public String getPrimary() { + return this.primary; + } + + public void setPrimary(String s) { + this.primary = s; + } + + public String getSecondary() { + return this.secondary; + } + + public void setSecondary(String s) { + this.secondary = s; + } + + public String getInbetween() { + return this.inbetween; + } + + public void setInbetween(String s) { + this.inbetween = s; + } + + public String getAround() { + return this.around; + } + + public void setAround(String s) { + this.around = s; + } + + public String getMix() { + return this.mix; + } + + public void setMix(String s) { + this.mix = s; + } + + public String getTier() { + return this.tier; + } + + public void setTier(String s) { + this.tier = s; + } + + public String getHeight() { + return this.height; + } + + public void setHeight(String s) { + this.height = s; + } + + public int getDensity() { + return this.density; + } + + public void setDensity(int i) { + this.density = i; + } + + public int getSize() { + return this.size; + } + + public void setSize(int i) { + this.size = i; + } + + public int getWeight() { + return this.weight; + } + + public void setWeight(int i) { + this.weight = i; + } + + public int getMinY() { + calculateminmax(); + return this.miny; + } + + public void setMinY(int i) { + this.miny = i; + } + + public int getMaxY() { + calculateminmax(); + return this.maxy; + } + + public void setMaxY(int i) { + this.maxy = i; + } + + public boolean getOverworld() { + return this.overworld; + } + + public void setOverworld(boolean s) { + this.overworld = s; + } + + public boolean getNether() { + return this.nether; + } + + public void setNether(boolean s) { + this.nether = s; + } + + public boolean getEnd() { + return this.end; + } + + public void setEnd(boolean s) { + this.end = s; + } + + private void calculateminmax() { + this.miny = Integer.parseInt(this.height.split("-")[0]); + this.maxy = Integer.parseInt(this.height.split("-")[1]); + } + + public String getHeightcalced() { + return new String(this.miny + "-" + this.maxy); + } - 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 = "AstroidBelt", 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 index 8c0ca7df58..a721d88e82 100644 --- a/src/main/java/pers/gwyog/gtneioreplugin/util/Veinrenamer.java +++ b/src/main/java/pers/gwyog/gtneioreplugin/util/Veinrenamer.java @@ -6,23 +6,22 @@ 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 = "/"; + @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; - } + 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 index 7839221630..c27a480557 100644 --- a/src/main/java/pers/gwyog/gtneioreplugin/util/XtoBool.java +++ b/src/main/java/pers/gwyog/gtneioreplugin/util/XtoBool.java @@ -1,23 +1,22 @@ package pers.gwyog.gtneioreplugin.util; -import java.util.ResourceBundle; - +import com.opencsv.bean.AbstractBeanField; +import com.opencsv.exceptions.CsvConstraintViolationException; +import com.opencsv.exceptions.CsvDataTypeMismatchException; 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; +import java.util.ResourceBundle; public class XtoBool<T> extends AbstractBeanField<T> { - @Override - protected Object convert(String value) throws CsvDataTypeMismatchException, CsvConstraintViolationException { - if (value.isEmpty()) { + @Override + protected Object convert(String value) throws CsvDataTypeMismatchException, CsvConstraintViolationException { + if (value.isEmpty()) { return null; } - String[] trueStrings = {"x","X"}; + String[] trueStrings = {"x", "X"}; String[] falseStrings = {""}; Converter bc = new BooleanConverter(trueStrings, falseStrings); try { @@ -25,12 +24,12 @@ public class XtoBool<T> extends AbstractBeanField<T> { } catch (ConversionException e) { CsvDataTypeMismatchException csve = new CsvDataTypeMismatchException( value, field.getType(), ResourceBundle - .getBundle("convertGermanToBoolean", errorLocale) - .getString("input.not.boolean")); + .getBundle("convertGermanToBoolean", errorLocale) + .getString("input.not.boolean")); csve.initCause(e); throw csve; } } - + } |