diff options
author | miozune <miozune@gmail.com> | 2023-06-18 17:40:37 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-06-18 10:40:37 +0200 |
commit | aa3b5f43be8a58619b0bdc15a8a9e2309de8365e (patch) | |
tree | fc0d314224956a18d5b8471bb686f552d0b05709 /src/main/java/pers/gwyog | |
parent | 749ee1a1860b65ef516d97224aad964b68bfbe09 (diff) | |
download | GT5-Unofficial-aa3b5f43be8a58619b0bdc15a8a9e2309de8365e.tar.gz GT5-Unofficial-aa3b5f43be8a58619b0bdc15a8a9e2309de8365e.tar.bz2 GT5-Unofficial-aa3b5f43be8a58619b0bdc15a8a9e2309de8365e.zip |
Cleanup (#36)
* updateBuildScript
* Remove unused members in PluginGT5Base
* Remove GuiRecipeHelper
* Use enhanced switch
* Remove / suppress unused members
* Fix empty catch block
* Apply final where possible
* Use toArray(IntFunction)
* Fix redundant default parameters
* Use enhanced for
* Use addAll
* Fix explicit type argument
* Redundant throws
* SameParameterValue
* String concatenation in loop
* constant condition
* Redundant initializer
* Redundant new String()
* Redundant cast
* Instantiation of utility class
* Fix Javadoc
* Don't instantiate DecimalFormat every time
* Put curly brackets
* Rename: liste -> list
* Rename: vertauscht -> swapped
* Rename: schritt -> step
Diffstat (limited to 'src/main/java/pers/gwyog')
22 files changed, 240 insertions, 489 deletions
diff --git a/src/main/java/pers/gwyog/gtneioreplugin/Config.java b/src/main/java/pers/gwyog/gtneioreplugin/Config.java index e486ea9f1e..8501ebabb1 100644 --- a/src/main/java/pers/gwyog/gtneioreplugin/Config.java +++ b/src/main/java/pers/gwyog/gtneioreplugin/Config.java @@ -8,7 +8,7 @@ import cpw.mods.fml.common.event.FMLPreInitializationEvent; public class Config { - public Configuration tConfig; + public final Configuration tConfig; public Config(FMLPreInitializationEvent preinit, String cfgname) { File tFile = new File(preinit.getModConfigurationDirectory(), cfgname); diff --git a/src/main/java/pers/gwyog/gtneioreplugin/GTNEIOrePlugin.java b/src/main/java/pers/gwyog/gtneioreplugin/GTNEIOrePlugin.java index 6b0505e1a4..f16fa148e0 100644 --- a/src/main/java/pers/gwyog/gtneioreplugin/GTNEIOrePlugin.java +++ b/src/main/java/pers/gwyog/gtneioreplugin/GTNEIOrePlugin.java @@ -19,7 +19,6 @@ import pers.gwyog.gtneioreplugin.util.CSVMaker; import pers.gwyog.gtneioreplugin.util.GT5OreLayerHelper; import pers.gwyog.gtneioreplugin.util.GT5OreSmallHelper; import pers.gwyog.gtneioreplugin.util.GT5UndergroundFluidHelper; -import pers.gwyog.gtneioreplugin.util.GuiRecipeHelper; @Mod( modid = GTNEIOrePlugin.MODID, @@ -35,7 +34,6 @@ public class GTNEIOrePlugin { public static boolean csv = false; public static String CSVname; public static String CSVnameSmall; - public static boolean toolTips = true; public static int maxTooltipLines = 11; public static final CreativeTabs creativeTab = new CreativeTabs(MODID) { @@ -66,7 +64,6 @@ public class GTNEIOrePlugin { "ALL", event.getModConfigurationDirectory() + "/GTNH-Small-Ores-Sheet.csv", "rename the oresheet here, it will appear in /config"); - toolTips = c.tConfig.getBoolean("DimTooltip", "ALL", true, "Activates Dimension Tooltips"); maxTooltipLines = c.tConfig.getInt( "MaxToolTipLines", "ALL", @@ -86,11 +83,10 @@ public class GTNEIOrePlugin { @EventHandler public void onLoadComplete(FMLLoadCompleteEvent event) { - new GT5OreLayerHelper(); - new GT5OreSmallHelper(); - new GT5UndergroundFluidHelper(); + GT5OreLayerHelper.init(); + GT5OreSmallHelper.init(); + GT5UndergroundFluidHelper.init(); if (event.getSide() == Side.CLIENT) { - new GuiRecipeHelper(); if (csv) { new CSVMaker().run(); } diff --git a/src/main/java/pers/gwyog/gtneioreplugin/plugin/IMCForNEI.java b/src/main/java/pers/gwyog/gtneioreplugin/plugin/IMCForNEI.java index ea60054576..2c69b68a4a 100644 --- a/src/main/java/pers/gwyog/gtneioreplugin/plugin/IMCForNEI.java +++ b/src/main/java/pers/gwyog/gtneioreplugin/plugin/IMCForNEI.java @@ -48,6 +48,7 @@ public class IMCForNEI { FMLInterModComms.sendMessage("NotEnoughItems", "registerHandlerInfo", aNBT); } + @SuppressWarnings("SameParameterValue") private static void sendCatalyst(String name, String itemStack, int priority) { NBTTagCompound aNBT = new NBTTagCompound(); aNBT.setString("handlerID", name); @@ -56,6 +57,7 @@ public class IMCForNEI { FMLInterModComms.sendMessage("NotEnoughItems", "registerCatalystInfo", aNBT); } + @SuppressWarnings("SameParameterValue") private static void sendCatalyst(String name, String itemStack) { sendCatalyst(name, itemStack, 0); } diff --git a/src/main/java/pers/gwyog/gtneioreplugin/plugin/NEIPluginConfig.java b/src/main/java/pers/gwyog/gtneioreplugin/plugin/NEIPluginConfig.java index 17193b07fe..6996cba220 100644 --- a/src/main/java/pers/gwyog/gtneioreplugin/plugin/NEIPluginConfig.java +++ b/src/main/java/pers/gwyog/gtneioreplugin/plugin/NEIPluginConfig.java @@ -7,6 +7,7 @@ import pers.gwyog.gtneioreplugin.plugin.gregtech5.PluginGT5SmallOreStat; import pers.gwyog.gtneioreplugin.plugin.gregtech5.PluginGT5UndergroundFluid; import pers.gwyog.gtneioreplugin.plugin.gregtech5.PluginGT5VeinStat; +@SuppressWarnings("unused") public class NEIPluginConfig implements IConfigureNEI { @Override diff --git a/src/main/java/pers/gwyog/gtneioreplugin/plugin/block/BlockDimensionDisplay.java b/src/main/java/pers/gwyog/gtneioreplugin/plugin/block/BlockDimensionDisplay.java index 048ce84aff..9e5ab1885c 100644 --- a/src/main/java/pers/gwyog/gtneioreplugin/plugin/block/BlockDimensionDisplay.java +++ b/src/main/java/pers/gwyog/gtneioreplugin/plugin/block/BlockDimensionDisplay.java @@ -12,6 +12,7 @@ public class BlockDimensionDisplay extends Block { private final String dimension; + @SuppressWarnings("unused") public long getDimensionRocketTier() { return dimensionRocketTier; } @@ -30,18 +31,11 @@ public class BlockDimensionDisplay extends Block { @Override public IIcon getIcon(int side, int meta) { EnumFacing direction = EnumFacing.getFront(side); - switch (direction) { - case NORTH: - case SOUTH: - return iconRight; - case WEST: - case EAST: - return iconLeft; - case UP: - case DOWN: - default: - return iconTop; - } + return switch (direction) { + case NORTH, SOUTH -> iconRight; + case WEST, EAST -> iconLeft; + default -> iconTop; + }; } @Override 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 d086175849..646e6d2bc7 100644 --- a/src/main/java/pers/gwyog/gtneioreplugin/plugin/gregtech5/PluginGT5Base.java +++ b/src/main/java/pers/gwyog/gtneioreplugin/plugin/gregtech5/PluginGT5Base.java @@ -1,17 +1,12 @@ package pers.gwyog.gtneioreplugin.plugin.gregtech5; -import java.awt.Point; -import java.awt.Rectangle; - import net.minecraft.client.resources.I18n; import codechicken.lib.gui.GuiDraw; -import codechicken.nei.recipe.GuiRecipe; import gregtech.api.GregTech_API; import gregtech.api.enums.Materials; import gregtech.api.util.GT_LanguageManager; import pers.gwyog.gtneioreplugin.plugin.PluginBase; -import pers.gwyog.gtneioreplugin.util.GuiRecipeHelper; public abstract class PluginGT5Base extends PluginBase { @@ -48,32 +43,6 @@ public abstract class PluginGT5Base extends PluginBase { GuiDraw.drawString(I18n.format(lineKey) + ": " + value, x, y, 0x404040, false); } - /** - * The dimension names for a given recipe index - * - * @param recipe The recipe index being handled - * @return A CSV string of dimension name abbreviations - */ - protected abstract String getDimensionNames(int recipe); - - /** - * Produce a rectangle covering the area of displayed dimension names - * - * @param gui An instance of the currentscreen - * @param recipe The recipe index being handled - * @param dimNames Dimension names to produce a rectangle for - * @return Rectangle area of dimension names - */ - protected Rectangle getDimensionNamesRect(GuiRecipe<?> gui, int recipe, String dimNames) { - int dimNamesHeight = dimNames.length() > 70 ? 30 : (dimNames.length() > 36 ? 20 : 10); - Point offset = gui.getRecipePosition(recipe); - return new Rectangle( - GuiRecipeHelper.getGuiLeft(gui) + offset.x + 2, - GuiRecipeHelper.getGuiTop(gui) + offset.y + 110, - GuiRecipeHelper.getXSize(gui) - 9, - dimNamesHeight); - } - protected int getMaximumMaterialIndex(short meta, boolean smallOre) { int offset = smallOre ? 16000 : 0; if (!getGTOreLocalizedName((short) (meta + offset + 5000)) @@ -88,9 +57,8 @@ public abstract class PluginGT5Base extends PluginBase { /** * Draw the dimension header and the dimension names over up to 3 lines * - * @param dimNames A CSV string of dimension name abbreviations */ - protected void drawDimNames(String dimNames) { + protected void drawDimNames() { GuiDraw.drawString(I18n.format("gtnop.gui.nei.worldNames") + ": ", 2, 100, 0x404040, false); } } diff --git a/src/main/java/pers/gwyog/gtneioreplugin/plugin/gregtech5/PluginGT5SmallOreStat.java b/src/main/java/pers/gwyog/gtneioreplugin/plugin/gregtech5/PluginGT5SmallOreStat.java index 512f966629..76bd66d280 100644 --- a/src/main/java/pers/gwyog/gtneioreplugin/plugin/gregtech5/PluginGT5SmallOreStat.java +++ b/src/main/java/pers/gwyog/gtneioreplugin/plugin/gregtech5/PluginGT5SmallOreStat.java @@ -27,8 +27,7 @@ public class PluginGT5SmallOreStat extends PluginGT5Base { drawSmallOreName(oreSmall); drawSmallOreInfo(oreSmall); - String sDimNames = GT5OreSmallHelper.bufferedDims.get(oreSmall); - drawDimNames(sDimNames); + drawDimNames(); drawSeeAllRecipesLabel(); } @@ -128,18 +127,6 @@ public class PluginGT5SmallOreStat extends PluginGT5Base { return I18n.format("gtnop.gui.smallOreStat.name"); } - /** - * The dimension names for a given recipe identifier - * - * @param recipe identifier - * @return A CSV string of dimension name abbreviations - */ - @Override - protected String getDimensionNames(int recipe) { - OreSmallWrapper oreSmall = getSmallOre(recipe); - return GT5OreSmallHelper.bufferedDims.get(oreSmall); - } - private String[] getDimNameArrayFromVeinName(String veinName) { OreSmallWrapper oreSmall = GT5OreSmallHelper.mapOreSmallWrapper.get(veinName); String[] dims = DimensionHelper.parseDimNames(GT5OreSmallHelper.bufferedDims.get(oreSmall)); @@ -149,10 +136,10 @@ public class PluginGT5SmallOreStat extends PluginGT5Base { public class CachedOreSmallRecipe extends CachedRecipe { - public String oreGenName; - public PositionedStack positionedStackOreSmall; - public PositionedStack positionedStackMaterialDust; - public List<PositionedStack> positionedDropStackList; + public final String oreGenName; + public final PositionedStack positionedStackOreSmall; + public final PositionedStack positionedStackMaterialDust; + public final List<PositionedStack> positionedDropStackList; private final List<PositionedStack> dimensionDisplayItems = new ArrayList<>(); public CachedOreSmallRecipe(String oreGenName, List<ItemStack> stackList, List<ItemStack> materialDustStackList, diff --git a/src/main/java/pers/gwyog/gtneioreplugin/plugin/gregtech5/PluginGT5UndergroundFluid.java b/src/main/java/pers/gwyog/gtneioreplugin/plugin/gregtech5/PluginGT5UndergroundFluid.java index 17a8216b7e..8f7754bbde 100644 --- a/src/main/java/pers/gwyog/gtneioreplugin/plugin/gregtech5/PluginGT5UndergroundFluid.java +++ b/src/main/java/pers/gwyog/gtneioreplugin/plugin/gregtech5/PluginGT5UndergroundFluid.java @@ -24,6 +24,7 @@ public class PluginGT5UndergroundFluid extends PluginBase { private static final int lineSpace = 20; private static final int xDimensionDisplay = 30; private static final int halfItemLength = 16 / 2; + private static final DecimalFormat format = new DecimalFormat("0.#"); @Override public void loadCraftingRecipes(String outputId, Object... results) { @@ -100,12 +101,7 @@ public class PluginGT5UndergroundFluid extends PluginBase { int y = 50; CachedUndergroundFluidRecipe recipe = (CachedUndergroundFluidRecipe) this.arecipes.get(recipeIndex); for (int i = 0; i < recipe.dimensionDisplayItems.size(); i++) { - GuiDraw.drawStringC( - new DecimalFormat("0.#").format((double) recipe.chances.get(i) / 100) + "%", - xChance, - y, - black, - false); + GuiDraw.drawStringC(format.format((double) recipe.chances.get(i) / 100) + "%", xChance, y, black, false); GuiDraw.drawStringC( recipe.minAmounts.get(i).toString() + "-" + recipe.maxAmounts.get(i).toString(), xAmount, 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 556e32fcfe..98f168c2a7 100644 --- a/src/main/java/pers/gwyog/gtneioreplugin/plugin/gregtech5/PluginGT5VeinStat.java +++ b/src/main/java/pers/gwyog/gtneioreplugin/plugin/gregtech5/PluginGT5VeinStat.java @@ -80,8 +80,7 @@ public class PluginGT5VeinStat extends PluginGT5Base { drawVeinLayerNames(oreLayer); drawVeinInfo(oreLayer); - String sDimNames = GT5OreLayerHelper.bufferedDims.get(oreLayer); - drawDimNames(sDimNames); + drawDimNames(); drawSeeAllRecipesLabel(); } @@ -132,18 +131,6 @@ public class PluginGT5VeinStat extends PluginGT5Base { return I18n.format("gtnop.gui.veinStat.name"); } - /** - * The dimension names for a given recipe identifier - * - * @param recipe identifier - * @return A CSV string of dimension name abbreviations - */ - @Override - protected String getDimensionNames(int recipe) { - OreLayerWrapper oreLayer = getOreLayer(recipe); - return GT5OreLayerHelper.bufferedDims.get(oreLayer); - } - private String[] getDimNameArrayFromVeinName(String veinName) { OreLayerWrapper oreLayer = GT5OreLayerHelper.mapOreLayerWrapper.get(veinName); String[] dims = DimensionHelper.parseDimNames(GT5OreLayerHelper.bufferedDims.get(oreLayer)); @@ -153,11 +140,11 @@ public class PluginGT5VeinStat extends PluginGT5Base { public class CachedVeinStatRecipe extends CachedRecipe { - public String veinName; - public PositionedStack positionedStackPrimary; - public PositionedStack positionedStackSecondary; - public PositionedStack positionedStackBetween; - public PositionedStack positionedStackSporadic; + public final String veinName; + public final PositionedStack positionedStackPrimary; + public final PositionedStack positionedStackSecondary; + public final PositionedStack positionedStackBetween; + public final PositionedStack positionedStackSporadic; private final List<PositionedStack> dimensionDisplayItems = new ArrayList<>(); public CachedVeinStatRecipe(String veinName, List<ItemStack> stackListPrimary, diff --git a/src/main/java/pers/gwyog/gtneioreplugin/plugin/item/ItemDimensionDisplay.java b/src/main/java/pers/gwyog/gtneioreplugin/plugin/item/ItemDimensionDisplay.java index b999b8eab0..b8e9301f3b 100644 --- a/src/main/java/pers/gwyog/gtneioreplugin/plugin/item/ItemDimensionDisplay.java +++ b/src/main/java/pers/gwyog/gtneioreplugin/plugin/item/ItemDimensionDisplay.java @@ -2,8 +2,6 @@ package pers.gwyog.gtneioreplugin.plugin.item; import static pers.gwyog.gtneioreplugin.GTNEIOrePlugin.LOG; -import java.util.Objects; - import net.minecraft.block.Block; import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemStack; @@ -46,14 +44,6 @@ public class ItemDimensionDisplay extends ItemBlock { return null; } - public static boolean isDimensionEqual(ItemStack stack1, ItemStack stack2) { - if (!(stack1.getItem() instanceof ItemDimensionDisplay) - || !(stack2.getItem() instanceof ItemDimensionDisplay)) { - return false; - } - return Objects.equals(getDimension(stack1), getDimension(stack2)); - } - @Override public String getItemStackDisplayName(ItemStack stack) { String dimension = getDimension(stack); diff --git a/src/main/java/pers/gwyog/gtneioreplugin/plugin/renderer/ItemDimensionDisplayRenderer.java b/src/main/java/pers/gwyog/gtneioreplugin/plugin/renderer/ItemDimensionDisplayRenderer.java index a86482d17f..0c7617645c 100644 --- a/src/main/java/pers/gwyog/gtneioreplugin/plugin/renderer/ItemDimensionDisplayRenderer.java +++ b/src/main/java/pers/gwyog/gtneioreplugin/plugin/renderer/ItemDimensionDisplayRenderer.java @@ -60,56 +60,18 @@ public class ItemDimensionDisplayRenderer implements IItemRenderer { // See DimensionHelper.DimNameDisplayed for real names of these. public static long getPrefix(String dimName) { - switch (dimName) { - case "Ow": - case "Ne": - case "TF": - case "ED": - case "VA": - case "EA": - return 0L; - case "Mo": - return 1L; - case "De": - case "Ma": - case "Ph": - return 2L; - case "As": - case "Ca": - case "Ce": - case "Eu": - case "Ga": - case "Rb": - return 3L; - case "Io": - case "Me": - case "Ve": - return 4L; - case "En": - case "Mi": - case "Ob": - case "Ti": - case "Ra": - return 5L; - case "Pr": - case "Tr": - return 6L; - case "Ha": - case "KB": - case "MM": - case "Pl": - return 7L; - case "BC": - case "BE": - case "BF": - case "CB": - case "TE": - case "VB": - return 8L; - case "DD": - return 9L; - default: - return -1L; - } + return switch (dimName) { + case "Ow", "Ne", "TF", "ED", "VA", "EA" -> 0L; + case "Mo" -> 1L; + case "De", "Ma", "Ph" -> 2L; + case "As", "Ca", "Ce", "Eu", "Ga", "Rb" -> 3L; + case "Io", "Me", "Ve" -> 4L; + case "En", "Mi", "Ob", "Ti", "Ra" -> 5L; + case "Pr", "Tr" -> 6L; + case "Ha", "KB", "MM", "Pl" -> 7L; + case "BC", "BE", "BF", "CB", "TE", "VB" -> 8L; + case "DD" -> 9L; + default -> -1L; + }; } } diff --git a/src/main/java/pers/gwyog/gtneioreplugin/util/CSVMaker.java b/src/main/java/pers/gwyog/gtneioreplugin/util/CSVMaker.java index 96af04051e..d19a1fdff9 100644 --- a/src/main/java/pers/gwyog/gtneioreplugin/util/CSVMaker.java +++ b/src/main/java/pers/gwyog/gtneioreplugin/util/CSVMaker.java @@ -21,31 +21,29 @@ public class CSVMaker implements Runnable { public CSVMaker() {} - public static List<Oremix> Combsort(List<Oremix> liste) { + public static List<Oremix> Combsort(List<Oremix> list) { try { - List<Oremix> liste2 = new ArrayList<Oremix>(liste.size()); - for (Oremix element : liste) { - liste2.add(element); - } + List<Oremix> list2 = new ArrayList<>(list.size()); + list2.addAll(list); - int schritt = liste2.size(); - boolean vertauscht = false; + int step = list2.size(); + boolean swapped; do { - vertauscht = false; - if (schritt > 1) { - schritt = (int) (schritt / 1.3); + swapped = false; + if (step > 1) { + step = (int) (step / 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; + for (int i = 0; i < list2.size() - step; i++) { + if (list2.get(i).getOreName().substring(0, 3) + .compareTo((list2.get(i + step).getOreName().substring(0, 3))) > 0) { + Oremix tmp = list2.get(i); + list2.set(i, list2.get(i + step)); + list2.set(i + step, tmp); + swapped = true; } } - } while (vertauscht || schritt > 1); - return liste2; + } while (swapped || step > 1); + return list2; } catch (Exception e) { e.printStackTrace(); return null; diff --git a/src/main/java/pers/gwyog/gtneioreplugin/util/DimensionHelper.java b/src/main/java/pers/gwyog/gtneioreplugin/util/DimensionHelper.java index be95356118..02ad143dd4 100644 --- a/src/main/java/pers/gwyog/gtneioreplugin/util/DimensionHelper.java +++ b/src/main/java/pers/gwyog/gtneioreplugin/util/DimensionHelper.java @@ -5,13 +5,12 @@ import static pers.gwyog.gtneioreplugin.GTNEIOrePlugin.maxTooltipLines; import java.util.Arrays; import java.util.HashMap; import java.util.List; -import java.util.stream.Collectors; import net.minecraft.util.StatCollector; public class DimensionHelper { - public static String[] DimName = { + public static final String[] DimName = { // Non GC dimensions in progression order instead of alphabetical "Overworld", "Nether", "Twilight", "TheEnd", "Vanilla_EndAsteroids", "EndAsteroid", // T1 @@ -33,14 +32,14 @@ public class DimensionHelper { "GalaxySpace_BarnardC", "GalaxySpace_BarnardE", "GalaxySpace_BarnardF", "GalaxySpace_CentauriA", "GalaxySpace_TcetiE", "Underdark", "GalaxySpace_VegaB", }; - public static String[] DimNameTrimmed = Arrays.stream(DimName) + public static final String[] DimNameTrimmed = Arrays.stream(DimName) .map( n -> n.replaceAll("GalacticraftCore_", "").replaceAll("GalacticraftMars_", "") .replaceAll("GalaxySpace_", "").replaceAll("Vanilla_", "Vanilla ")) - .collect(Collectors.toList()).toArray(new String[0]); + .toArray(String[]::new); - public static String[] DimNameDisplayed = { // first 2 letters if one word else 1 letter of every word, except - // capital letter in + public static final String[] DimNameDisplayed = { // first 2 letters if one word else 1 letter of every word, except + // capital letter in // name, then 1rst + capital Moon = Mo, BarnardC = BC, EndAsteroid = EA // Non GC dimensions in progression order instead of alphabetical "Ow", // Overworld @@ -100,57 +99,18 @@ public class DimensionHelper { if (s.equals(DimNameDisplayed[i])) { String k = DimNameTrimmed[i]; s = StatCollector.translateToLocal("gtnop.world." + k); - switch (k) { - case "Moon": - s = "T1: " + s; - break; - case "Deimos": - case "Mars": - case "Phobos": - s = "T2: " + s; - break; - case "Asteroids": - case "Callisto": - case "Ceres": - case "Europa": - case "Ganymede": - case "Ross128b": - s = "T3: " + s; - break; - case "Io": - case "Mercury": - case "Venus": - s = "T4: " + s; - break; - case "Enceladus": - case "Miranda": - case "Oberon": - case "Titan": - case "Ross128ba": - s = "T5: " + s; - break; - case "Proteus": - case "Triton": - s = "T6: " + s; - break; - case "Haumea": - case "Kuiperbelt": - case "MakeMake": - case "Pluto": - s = "T7: " + s; - break; - case "BarnardC": - case "BarnardE": - case "BarnardF": - case "CentauriA": - case "TcetiE": - case "VegaB": - s = "T8: " + s; - break; - case "Underdark": - s = "T9: " + s; - break; - } + s = switch (k) { + case "Moon" -> "T1: " + s; + case "Deimos", "Mars", "Phobos" -> "T2: " + s; + case "Asteroids", "Callisto", "Ceres", "Europa", "Ganymede", "Ross128b" -> "T3: " + s; + case "Io", "Mercury", "Venus" -> "T4: " + s; + case "Enceladus", "Miranda", "Oberon", "Titan", "Ross128ba" -> "T5: " + s; + case "Proteus", "Triton" -> "T6: " + s; + case "Haumea", "Kuiperbelt", "MakeMake", "Pluto" -> "T7: " + s; + case "BarnardC", "BarnardE", "BarnardF", "CentauriA", "TcetiE", "VegaB" -> "T8: " + s; + case "Underdark" -> "T9: " + s; + default -> s; + }; dims[j] = s; } diff --git a/src/main/java/pers/gwyog/gtneioreplugin/util/GT5CFGHelper.java b/src/main/java/pers/gwyog/gtneioreplugin/util/GT5CFGHelper.java index e6aecb3d85..ebc9956af1 100644 --- a/src/main/java/pers/gwyog/gtneioreplugin/util/GT5CFGHelper.java +++ b/src/main/java/pers/gwyog/gtneioreplugin/util/GT5CFGHelper.java @@ -19,14 +19,14 @@ import pers.gwyog.gtneioreplugin.GTNEIOrePlugin; public class GT5CFGHelper { // Do NOT ever put a comma in this or it will break split calls later in the code. Bad, but it is what it is. - public static String oreVeinNotInAnyDim = "Not available in any Galactic Dim!"; + public static final String oreVeinNotInAnyDim = "Not available in any Galactic Dim!"; - private static File F = GregTech_API.sWorldgenFile.mConfig.getConfigFile(); + private static final 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; + List<String> raw = new ArrayList<>(); + List<String> rawbools = new ArrayList<>(); + String st; Configuration c = new Configuration(F); ConfigCategory configCategory = c.getCategory("worldgen." + Veinname); for (Property p : configCategory.getOrderedValues()) { @@ -34,33 +34,40 @@ public class GT5CFGHelper { 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); + if (!raw.isEmpty()) { + for (String s : raw) { + for (int j = 0; j < DimensionHelper.DimName.length; j++) { + if (s.contains(DimensionHelper.DimName[j])) { + rawbools.add(s); + } + } + } + } else GTNEIOrePlugin.LOG.info("Config entry not found for Vein: " + Veinname); - String ret = " "; + StringBuilder ret = new StringBuilder(" "); - HashSet<String> rawboolsset = new HashSet<String>(); + HashSet<String> rawboolsset = new HashSet<>(); if (!rawbools.isEmpty()) { - for (int i = 0; i < rawbools.size(); i++) { - st = rawbools.get(i).replace("B:", "").replace("_true", "").replace("_false", "").replaceAll(" ", "") + for (String rawbool : rawbools) { + st = rawbool.replace("B:", "").replace("_true", "").replace("_false", "").replaceAll(" ", "") .replaceAll("\"", ""); rawboolsset.add(st); } - rawbools = new ArrayList<String>(rawboolsset); + rawbools = new ArrayList<>(rawboolsset); for (int j = 0; j < DimensionHelper.DimName.length; j++) { - for (int i = 0; i < rawbools.size(); i++) { - st = rawbools.get(i); - if (st.contains(DimensionHelper.DimName[j])) - if (st.contains("=true")) ret = (ret + DimensionHelper.DimNameDisplayed[j] + ","); + for (String rawbool : rawbools) { + st = rawbool; + if (st.contains(DimensionHelper.DimName[j]) && st.contains("=true")) { + ret.append(DimensionHelper.DimNameDisplayed[j]).append(","); + } } } } - ret = ret.trim(); - if (ret.equals("") || ret.equals(" ")) ret = oreVeinNotInAnyDim; - return ret; + ret = new StringBuilder(ret.toString().trim()); + if (ret.toString().equals("") || ret.toString().equals(" ")) { + ret = new StringBuilder(oreVeinNotInAnyDim); + } + return ret.toString(); } public static String GT5CFG(String Veinname) { @@ -70,16 +77,18 @@ public class GT5CFGHelper { return "Error while Loading CFG"; } else try { int buffer = (int) (0.1 * Runtime.getRuntime().freeMemory()); - if (buffer > F.length()) buffer = (int) F.length(); + if (buffer > F.length()) { + buffer = (int) F.length(); + } // allocate 10% of free memory for read-in-buffer, if there is less than filesize memory available // 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>(); + String st; + List<String> raw = new ArrayList<>(); + List<String> rawbools = new ArrayList<>(); Boolean[] found = new Boolean[2]; found[0] = false; found[1] = false; @@ -90,16 +99,18 @@ public class GT5CFGHelper { st = reader.readLine(); // FMLLog.info("st: "+st); if (st != null && st.trim().equals("mix {")) { - while (!((st == null) || ((st != null) && found[0]))) { + while (!(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]))) { + while (!(st == null || found[0])) { st = reader.readLine(); - if ((!(st == null)) && st.trim().equals("}")) found[0] = true; + if ((!(st == null)) && st.trim().equals("}")) { + found[0] = true; + } // FMLLog.info("dritte"); // add everything below Veinname { undtil } to raw raw.add(st); @@ -109,20 +120,22 @@ public class GT5CFGHelper { } if (st != null && st.trim().equals("dimensions {")) { - while (!((st == null) || ((st != null) && found[1]))) { + while (!(st == null || found[1])) { // FMLLog.info("zweite"); st = reader.readLine(); if (st != null && (st.trim().equals("mix {"))) { - while (!((st == null) || ((st != null) && found[1]))) { + while (!(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]))) { + while (!(st == null || found[1])) { st = reader.readLine(); - if ((!(st == null)) && st.trim().equals("}")) found[1] = true; + if ((!(st == null)) && st.trim().equals("}")) { + found[1] = true; + } // FMLLog.info("vierte"); // add everything below Veinname { undtil } to raw raw.add(st); @@ -135,40 +148,49 @@ public class GT5CFGHelper { } 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)); + if (!raw.isEmpty()) { + for (String s : raw) { + // filter needed booleans from raw + /// FMLLog.info("raw contains"+raw.get(i)); + for (int j = 0; j < DimensionHelper.DimName.length; j++) { + if (s.contains(DimensionHelper.DimName[j])) { + rawbools.add(s); + } + } + // FMLLog.info("rawbools: "+rawbools.get(i)); + } + } else { + GTNEIOrePlugin.LOG.info("Config entry not found for Vein: " + Veinname); } - else GTNEIOrePlugin.LOG.info("Config entry not found for Vein: " + Veinname); - String ret = " "; + StringBuilder ret = new StringBuilder(" "); - HashSet<String> rawboolsset = new HashSet<String>(); + HashSet<String> rawboolsset = new HashSet<>(); if (!rawbools.isEmpty()) { // remove dublicates - for (int i = 0; i < rawbools.size(); i++) { - st = rawbools.get(i).replace("B:", "").replace("_true", "").replace("_false", "") - .replaceAll(" ", "").replaceAll("\"", ""); + for (String rawbool : rawbools) { + st = rawbool.replace("B:", "").replace("_true", "").replace("_false", "").replaceAll(" ", "") + .replaceAll("\"", ""); rawboolsset.add(st); } - rawbools = new ArrayList<String>(rawboolsset); + rawbools = new ArrayList<>(rawboolsset); // filter for dims set to true for (int j = 0; j < DimensionHelper.DimName.length; j++) { // FMLLog.info("RawBools:"+st); - for (int i = 0; i < rawbools.size(); i++) { - st = rawbools.get(i); - if (st.contains(DimensionHelper.DimName[j])) - if (st.contains("=true")) ret = (ret + DimensionHelper.DimNameDisplayed[j] + ","); + for (String rawbool : rawbools) { + st = rawbool; + if (st.contains(DimensionHelper.DimName[j]) && st.contains("=true")) { + ret.append(DimensionHelper.DimNameDisplayed[j]).append(","); + } } } } - ret = ret.trim(); + ret = new StringBuilder(ret.toString().trim()); // FMLLog.info("ret:"+ret); - if (ret.equals("") || ret.equals(" ")) ret = oreVeinNotInAnyDim; - return ret; + if (ret.toString().equals("") || ret.toString().equals(" ")) { + ret = new StringBuilder(oreVeinNotInAnyDim); + } + return ret.toString(); } 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 996bef161a..c2c4fa9800 100644 --- a/src/main/java/pers/gwyog/gtneioreplugin/util/GT5OreLayerHelper.java +++ b/src/main/java/pers/gwyog/gtneioreplugin/util/GT5OreLayerHelper.java @@ -36,13 +36,13 @@ public class GT5OreLayerHelper { } private static final int DIMENSION_COUNT = 33; - public static Integer[] weightPerWorld = new Integer[DIMENSION_COUNT]; - public static Integer[] DimIDs = new Integer[DIMENSION_COUNT]; - public static HashMap<String, OreLayerWrapper> mapOreLayerWrapper = new HashMap<>(); - public static HashMap<OreLayerWrapper, String> bufferedDims = new HashMap<>(); - public static HashMap<String, NormalOreDimensionWrapper> dimToOreWrapper = new HashMap<>(); + public static final Integer[] weightPerWorld = new Integer[DIMENSION_COUNT]; + public static final Integer[] DimIDs = new Integer[DIMENSION_COUNT]; + public static final HashMap<String, OreLayerWrapper> mapOreLayerWrapper = new HashMap<>(); + public static final HashMap<OreLayerWrapper, String> bufferedDims = new HashMap<>(); + public static final HashMap<String, NormalOreDimensionWrapper> dimToOreWrapper = new HashMap<>(); - public GT5OreLayerHelper() { + public static void init() { Arrays.fill(weightPerWorld, 0); Arrays.fill(DimIDs, 0); for (GT_Worldgen_GT_Ore_Layer tWorldGen : GT_Worldgen_GT_Ore_Layer.sList) @@ -82,10 +82,9 @@ public class GT5OreLayerHelper { public static class OreLayerWrapper { - public String veinName, worldGenHeightRange; - public short[] Meta = new short[4]; - public short randomWeight, size, density; - public List<Integer> Weight = new ArrayList<>(); + public final String veinName, worldGenHeightRange; + public final short[] Meta = new short[4]; + public final short randomWeight, size, density; public final Materials mPrimaryVeinMaterial; public final Materials mSecondaryMaterial; diff --git a/src/main/java/pers/gwyog/gtneioreplugin/util/GT5OreSmallHelper.java b/src/main/java/pers/gwyog/gtneioreplugin/util/GT5OreSmallHelper.java index 3d673a4db7..8a150967a0 100644 --- a/src/main/java/pers/gwyog/gtneioreplugin/util/GT5OreSmallHelper.java +++ b/src/main/java/pers/gwyog/gtneioreplugin/util/GT5OreSmallHelper.java @@ -20,13 +20,12 @@ public class GT5OreSmallHelper { private static final int SMALL_ORE_BASE_META = 16000; public static boolean restrictBiomeSupport = false; - public static boolean gcBasicSupport = false; - public static List<ItemStack> oreSmallList = new ArrayList<>(); - public static HashMap<String, OreSmallWrapper> mapOreSmallWrapper = new HashMap<>(); - public static HashMap<String, Short> mapOreDropUnlocalizedNameToOreMeta = new HashMap<>(); - public static HashMap<Short, List<ItemStack>> mapOreMetaToOreDrops = new HashMap<>(); - public static HashMap<OreSmallWrapper, String> bufferedDims = new HashMap<>(); - public static HashMap<String, SmallOreDimensionWrapper> dimToSmallOreWrapper = new HashMap<>(); + public static final List<ItemStack> oreSmallList = new ArrayList<>(); + public static final HashMap<String, OreSmallWrapper> mapOreSmallWrapper = new HashMap<>(); + public static final HashMap<String, Short> mapOreDropUnlocalizedNameToOreMeta = new HashMap<>(); + public static final HashMap<Short, List<ItemStack>> mapOreMetaToOreDrops = new HashMap<>(); + public static final HashMap<OreSmallWrapper, String> bufferedDims = new HashMap<>(); + public static final HashMap<String, SmallOreDimensionWrapper> dimToSmallOreWrapper = new HashMap<>(); public static class SmallOreDimensionWrapper { @@ -46,7 +45,7 @@ public class GT5OreSmallHelper { } } - public GT5OreSmallHelper() { + public static void init() { checkExtraSupport(); ItemStack stack; Materials material; @@ -148,17 +147,12 @@ public class GT5OreSmallHelper { Class<?> clazzGTOreSmall = null; try { clazzGTOreSmall = Class.forName("gregtech.common" + ".GT_Worldgen_GT_Ore_SmallPieces"); - } catch (ClassNotFoundException e) {} + } catch (ClassNotFoundException ignored) {} if (clazzGTOreSmall != null) { try { clazzGTOreSmall.getField("mRestrictBiome"); restrictBiomeSupport = true; - } catch (Exception e) {} - try { - clazzGTOreSmall.getField("mMoon"); - clazzGTOreSmall.getField("mMars"); - gcBasicSupport = true; - } catch (Exception e) {} + } catch (Exception ignored) {} } } @@ -169,12 +163,12 @@ public class GT5OreSmallHelper { public static class OreSmallWrapper { - public String oreGenName; - public short oreMeta; - public String worldGenHeightRange; - public short amountPerChunk; - public String restrictBiome; + public final String oreGenName; + public final short oreMeta; + public final String worldGenHeightRange; + public final short amountPerChunk; + @SuppressWarnings("unused") public Materials getOreMaterial() { return oreMaterial; } diff --git a/src/main/java/pers/gwyog/gtneioreplugin/util/GT5UndergroundFluidHelper.java b/src/main/java/pers/gwyog/gtneioreplugin/util/GT5UndergroundFluidHelper.java index 5b80d4010f..9b47c757d8 100644 --- a/src/main/java/pers/gwyog/gtneioreplugin/util/GT5UndergroundFluidHelper.java +++ b/src/main/java/pers/gwyog/gtneioreplugin/util/GT5UndergroundFluidHelper.java @@ -33,7 +33,7 @@ public class GT5UndergroundFluidHelper { private static final Map<String, List<UndergroundFluidWrapper>> fluidMap = new HashMap<>(); @SuppressWarnings("unchecked") - public GT5UndergroundFluidHelper() { + public static void init() { try { Field fieldDimensionList = GT_UO_DimensionList.class.getDeclaredField("fDimensionList"); fieldDimensionList.setAccessible(true); @@ -119,31 +119,25 @@ public class GT5UndergroundFluidHelper { } @SuppressWarnings("SwitchStatementWithTooFewBranches") - private String getDimensionFromID(int id) { - switch (id) { - case 0: - return "Ow"; - default: - return null; - } + private static String getDimensionFromID(int id) { + return switch (id) { + case 0 -> "Ow"; + default -> null; + }; } - private String getDimensionForEdgeCase(String rawDimension) { - switch (rawDimension) { - case "aCentauriBb": - return "CB"; - case "BarnardaC": - return "BC"; - case "BarnardaE": - return "BE"; - case "BarnardaF": - return "BF"; - case "TCetiE": - return "TE"; - default: + private static String getDimensionForEdgeCase(String rawDimension) { + return switch (rawDimension) { + case "aCentauriBb" -> "CB"; + case "BarnardaC" -> "BC"; + case "BarnardaE" -> "BE"; + case "BarnardaF" -> "BF"; + case "TCetiE" -> "TE"; + default -> { LOG.warn("Unknown dimension name while parsing: " + rawDimension); - return null; - } + yield null; + } + }; } public static class UndergroundFluidWrapper { diff --git a/src/main/java/pers/gwyog/gtneioreplugin/util/GuiRecipeHelper.java b/src/main/java/pers/gwyog/gtneioreplugin/util/GuiRecipeHelper.java deleted file mode 100644 index a16524ab28..0000000000 --- a/src/main/java/pers/gwyog/gtneioreplugin/util/GuiRecipeHelper.java +++ /dev/null @@ -1,97 +0,0 @@ -package pers.gwyog.gtneioreplugin.util; - -import java.lang.reflect.Field; - -import net.minecraft.client.Minecraft; - -import org.apache.logging.log4j.Level; - -import codechicken.nei.recipe.GuiRecipe; -import cpw.mods.fml.common.FMLLog; - -public class GuiRecipeHelper { - - private static final String INIT_ERROR = "pers.gwyog.gtneioreplugin.util.GuiRecipeHelper failed setting up reflection : "; - private static final int DEFAULT_XSIZE = 176; - - public static Field xSizeField; - public static Field guiLeftField; - public static Field guiTopField; - - /** - * Access the xSize field of a GuiRecipe instance, or use a fallback hardcoded value if that fails - * - * @param gui GuiRecipe object - * @return Integer value of the xSize field of that object - */ - public static int getXSize(GuiRecipe<?> gui) { - if (xSizeField != null) { - try { - return (int) xSizeField.get(gui); - } catch (IllegalAccessException e) { - // Fail silently, hoping that it it fails it will be during initialization - } - } - - // Fallback should work unless codechicken.nei.recipe.GuiRecipe implementation changes - return DEFAULT_XSIZE; - } - - /** - * Access the guiLeft field of a GuiRecipe instance, or use a fallback hardcoded value if that fails - * - * @param gui GuiRecipe object - * @return Integer value of the guiLeft field of that object - */ - public static int getGuiLeft(GuiRecipe<?> gui) { - if (guiLeftField != null) { - try { - return (int) guiLeftField.get(gui); - } catch (IllegalAccessException e) { - // Fail silently, hoping that it it fails it will be during initialization - } - } - - // Fallback should work unless codechicken.nei.recipe.GuiRecipe implementation changes - return (Minecraft.getMinecraft().currentScreen.width - DEFAULT_XSIZE) / 2; - } - - /** - * Access the guiTop field of a GuiRecipe instance, or use a fallback hardcoded value if that fails - * - * @param gui GuiRecipe object - * @return Integer value of the guiTop field of that object - */ - public static int getGuiTop(GuiRecipe<?> gui) { - if (guiTopField != null) { - try { - return (int) guiTopField.get(gui); - } catch (IllegalAccessException e) { - // Fail silently, hoping that it it fails it will be during initialization - } - } - - // Fallback should work unless codechicken.nei.recipe.GuiRecipe implementation changes - int height = Minecraft.getMinecraft().currentScreen.height; - int ySize = Math.min(Math.max(height - 68, 166), 370); - return (height - ySize) / 2 + 10; - } - - /** - * Initialize the GuiRecipe Field accessors through reflection - */ - public GuiRecipeHelper() { - @SuppressWarnings("rawtypes") - Class<GuiRecipe> guiRecipeClass = GuiRecipe.class; - try { - guiLeftField = guiRecipeClass.getField("guiLeft"); - guiLeftField.setAccessible(true); - guiTopField = guiRecipeClass.getField("guiTop"); - guiTopField.setAccessible(true); - xSizeField = guiRecipeClass.getField("xSize"); - xSizeField.setAccessible(true); - } catch (NoSuchFieldException | SecurityException e) { - FMLLog.log(Level.ERROR, INIT_ERROR + e.getMessage()); - } - } -} diff --git a/src/main/java/pers/gwyog/gtneioreplugin/util/Oremix.java b/src/main/java/pers/gwyog/gtneioreplugin/util/Oremix.java index 69941b6ba2..d17e020db7 100644 --- a/src/main/java/pers/gwyog/gtneioreplugin/util/Oremix.java +++ b/src/main/java/pers/gwyog/gtneioreplugin/util/Oremix.java @@ -3,141 +3,142 @@ package pers.gwyog.gtneioreplugin.util; import com.opencsv.bean.CsvBindByName; import com.opencsv.bean.CsvCustomBindByName; +@SuppressWarnings("unused") public class Oremix { - @CsvCustomBindByName(column = "Moon", required = false, converter = XtoBool.class) + @CsvCustomBindByName(column = "Moon", converter = XtoBool.class) public boolean mo; - @CsvCustomBindByName(column = "End Asteroids", required = false, converter = XtoBool.class) + @CsvCustomBindByName(column = "End Asteroids", converter = XtoBool.class) public boolean ea; - @CsvCustomBindByName(column = "AstroidBelt", required = false, converter = XtoBool.class) + @CsvCustomBindByName(column = "AstroidBelt", converter = XtoBool.class) public boolean as; - @CsvCustomBindByName(column = "Barnard C", required = false, converter = XtoBool.class) + @CsvCustomBindByName(column = "Barnard C", converter = XtoBool.class) public boolean bc; - @CsvCustomBindByName(column = "Barnard E", required = false, converter = XtoBool.class) + @CsvCustomBindByName(column = "Barnard E", converter = XtoBool.class) public boolean be; - @CsvCustomBindByName(column = "Barnard F", required = false, converter = XtoBool.class) + @CsvCustomBindByName(column = "Barnard F", converter = XtoBool.class) public boolean bf; - @CsvCustomBindByName(column = "Mars", required = false, converter = XtoBool.class) + @CsvCustomBindByName(column = "Mars", converter = XtoBool.class) public boolean ma; - @CsvCustomBindByName(column = "Callisto", required = false, converter = XtoBool.class) + @CsvCustomBindByName(column = "Callisto", converter = XtoBool.class) public boolean ca; - @CsvCustomBindByName(column = "Centauri Bb", required = false, converter = XtoBool.class) + @CsvCustomBindByName(column = "Centauri Bb", converter = XtoBool.class) public boolean cb; - @CsvCustomBindByName(column = "Ceres", required = false, converter = XtoBool.class) + @CsvCustomBindByName(column = "Ceres", converter = XtoBool.class) public boolean ce; - @CsvCustomBindByName(column = "Twilight Forest", required = false, converter = XtoBool.class) + @CsvCustomBindByName(column = "Twilight Forest", converter = XtoBool.class) public boolean tf; - @CsvCustomBindByName(column = "Deep Dark", required = false, converter = XtoBool.class) + @CsvCustomBindByName(column = "Deep Dark", converter = XtoBool.class) public boolean dd; - @CsvCustomBindByName(column = "Phobos", required = false, converter = XtoBool.class) + @CsvCustomBindByName(column = "Phobos", converter = XtoBool.class) public boolean ph; - @CsvCustomBindByName(column = "Deimos", required = false, converter = XtoBool.class) + @CsvCustomBindByName(column = "Deimos", converter = XtoBool.class) public boolean de; - @CsvCustomBindByName(column = "Europa", required = false, converter = XtoBool.class) + @CsvCustomBindByName(column = "Europa", converter = XtoBool.class) public boolean eu; - @CsvCustomBindByName(column = "Ganymede", required = false, converter = XtoBool.class) + @CsvCustomBindByName(column = "Ganymede", converter = XtoBool.class) public boolean ga; - @CsvCustomBindByName(column = "Io", required = false, converter = XtoBool.class) + @CsvCustomBindByName(column = "Io", converter = XtoBool.class) public boolean io; - @CsvCustomBindByName(column = "Venus", required = false, converter = XtoBool.class) + @CsvCustomBindByName(column = "Venus", converter = XtoBool.class) public boolean ve; - @CsvCustomBindByName(column = "Mercury", required = false, converter = XtoBool.class) + @CsvCustomBindByName(column = "Mercury", converter = XtoBool.class) public boolean me; - @CsvCustomBindByName(column = "Enceladus", required = false, converter = XtoBool.class) + @CsvCustomBindByName(column = "Enceladus", converter = XtoBool.class) public boolean en; - @CsvCustomBindByName(column = "Titan", required = false, converter = XtoBool.class) + @CsvCustomBindByName(column = "Titan", converter = XtoBool.class) public boolean ti; - @CsvCustomBindByName(column = "Miranda", required = false, converter = XtoBool.class) + @CsvCustomBindByName(column = "Miranda", converter = XtoBool.class) public boolean mi; - @CsvCustomBindByName(column = "Oberon", required = false, converter = XtoBool.class) + @CsvCustomBindByName(column = "Oberon", converter = XtoBool.class) public boolean ob; - @CsvCustomBindByName(column = "Triton", required = false, converter = XtoBool.class) + @CsvCustomBindByName(column = "Triton", converter = XtoBool.class) public boolean tr; - @CsvCustomBindByName(column = "Proteus", required = false, converter = XtoBool.class) + @CsvCustomBindByName(column = "Proteus", converter = XtoBool.class) public boolean pr; - @CsvCustomBindByName(column = "Pluto", required = false, converter = XtoBool.class) + @CsvCustomBindByName(column = "Pluto", converter = XtoBool.class) public boolean pl; - @CsvCustomBindByName(column = "Kuiper Belt", required = false, converter = XtoBool.class) + @CsvCustomBindByName(column = "Kuiper Belt", converter = XtoBool.class) public boolean kb; - @CsvCustomBindByName(column = "Haumea", required = false, converter = XtoBool.class) + @CsvCustomBindByName(column = "Haumea", converter = XtoBool.class) public boolean ha; - @CsvCustomBindByName(column = "Makemake", required = false, converter = XtoBool.class) + @CsvCustomBindByName(column = "Makemake", converter = XtoBool.class) public boolean make; - @CsvCustomBindByName(column = "Vega B", required = false, converter = XtoBool.class) + @CsvCustomBindByName(column = "Vega B", converter = XtoBool.class) public boolean vb; - @CsvCustomBindByName(column = "T Ceti E", required = false, converter = XtoBool.class) + @CsvCustomBindByName(column = "T Ceti E", converter = XtoBool.class) public boolean tcetie; @CsvCustomBindByName(column = "Ore Name", required = true, converter = Veinrenamer.class) private String oreName; - @CsvBindByName(column = "Primary", required = false) + @CsvBindByName(column = "Primary") private String primary = ""; - @CsvBindByName(column = "Secondary", required = false) + @CsvBindByName(column = "Secondary") private String secondary = ""; - @CsvBindByName(column = "Inbetween", required = false) + @CsvBindByName(column = "Inbetween") private String inbetween = ""; - @CsvBindByName(column = "Around", required = false) + @CsvBindByName(column = "Around") private String around = ""; - @CsvBindByName(column = "ID ", required = false) + @CsvBindByName(column = "ID ") private String mix = ""; - @CsvBindByName(column = "Tier", required = false) + @CsvBindByName(column = "Tier") private String tier = ""; - @CsvBindByName(column = "Height", required = false) + @CsvBindByName(column = "Height") private String height = ""; - @CsvBindByName(column = "Density", required = false) + @CsvBindByName(column = "Density") private int density; - @CsvBindByName(column = "Size", required = false) + @CsvBindByName(column = "Size") private int size; - @CsvBindByName(column = "Weight", required = false) + @CsvBindByName(column = "Weight") private int weight; - @CsvCustomBindByName(column = "Overworld", required = false, converter = XtoBool.class) + @CsvCustomBindByName(column = "Overworld", converter = XtoBool.class) private boolean overworld; - @CsvCustomBindByName(column = "Nether", required = false, converter = XtoBool.class) + @CsvCustomBindByName(column = "Nether", converter = XtoBool.class) private boolean nether; - @CsvCustomBindByName(column = "End", required = false, converter = XtoBool.class) + @CsvCustomBindByName(column = "End", converter = XtoBool.class) private boolean end; private int miny, maxy; @@ -528,6 +529,6 @@ public class Oremix { } public String getHeightcalced() { - return new String(this.miny + "-" + this.maxy); + return this.miny + "-" + this.maxy; } } diff --git a/src/main/java/pers/gwyog/gtneioreplugin/util/StringPaddingHack.java b/src/main/java/pers/gwyog/gtneioreplugin/util/StringPaddingHack.java index 59a55a82fa..0b1d391a08 100644 --- a/src/main/java/pers/gwyog/gtneioreplugin/util/StringPaddingHack.java +++ b/src/main/java/pers/gwyog/gtneioreplugin/util/StringPaddingHack.java @@ -65,13 +65,13 @@ public class StringPaddingHack { /** * Pads strings with spaces so that they are of equal length and adds to that the number of spaces specified and up * to 3 if minExtraSpaces is below 3. Added spaces might be bold. - * + * <p> * Relies on the quirk of bold space characters being 1 pixel wider than regular space characters in the default * font renderer. * * @param strings List of strings * @param minExtraSpaces The minimum number of extra spaces to add - * @return List of strings padded with spaces to an equal length + * @return Array of strings padded with spaces to an equal length */ public static String[] padStrings(String[] strings, int minExtraSpaces) { int[] widths = getStringWidths(strings); diff --git a/src/main/java/pers/gwyog/gtneioreplugin/util/Veinrenamer.java b/src/main/java/pers/gwyog/gtneioreplugin/util/Veinrenamer.java index e80d972b17..346573e2a9 100644 --- a/src/main/java/pers/gwyog/gtneioreplugin/util/Veinrenamer.java +++ b/src/main/java/pers/gwyog/gtneioreplugin/util/Veinrenamer.java @@ -1,14 +1,12 @@ 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; + protected Object convert(String value) { + String ret; CharSequence s = "/"; if (value.contains(s)) { diff --git a/src/main/java/pers/gwyog/gtneioreplugin/util/XtoBool.java b/src/main/java/pers/gwyog/gtneioreplugin/util/XtoBool.java index 59dd82fa8e..f3426d53dd 100644 --- a/src/main/java/pers/gwyog/gtneioreplugin/util/XtoBool.java +++ b/src/main/java/pers/gwyog/gtneioreplugin/util/XtoBool.java @@ -7,13 +7,12 @@ 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 { + protected Object convert(String value) throws CsvDataTypeMismatchException { if (value.isEmpty()) { return null; } |