diff options
author | chill <chill.gtnh@outlook.com> | 2023-06-03 00:31:50 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-06-03 00:31:50 +0200 |
commit | ae5b5f3e1dc6f960f94b0e352ceb08d3822e2e9e (patch) | |
tree | 35cbd4dbf7f411deec46b85d888884b36d8a8611 /src | |
parent | 2c92ff9f657845021ab071147e81de50e84d3fd8 (diff) | |
download | GT5-Unofficial-ae5b5f3e1dc6f960f94b0e352ceb08d3822e2e9e.tar.gz GT5-Unofficial-ae5b5f3e1dc6f960f94b0e352ceb08d3822e2e9e.tar.bz2 GT5-Unofficial-ae5b5f3e1dc6f960f94b0e352ceb08d3822e2e9e.zip |
Refactor GT-ERR-01 (#2045)
* refactor and reword GT-ERR-01
Add two functions at the bottom:
one contains the error message, the other one prints it.
This refactor puts the error at the end of the file, so you don't have to
scroll through a screen's worth of space when debugging this file.
* invert if condition for mRegisteredOres.contains
It is questionable to put the case that is considered "wrong" as the first one,
and do the most common result as "else".
The flipped "if" essentially says
"if condition then do the usual, otherwise handle the error."
Diffstat (limited to 'src')
-rw-r--r-- | src/main/java/gregtech/GT_Mod.java | 49 |
1 files changed, 19 insertions, 30 deletions
diff --git a/src/main/java/gregtech/GT_Mod.java b/src/main/java/gregtech/GT_Mod.java index 072856b6b4..d480913498 100644 --- a/src/main/java/gregtech/GT_Mod.java +++ b/src/main/java/gregtech/GT_Mod.java @@ -722,37 +722,11 @@ public class GT_Mod implements IGT_Mod { } } for (ItemStack tOutput : tStacks) { - if (gregtechproxy.mRegisteredOres.contains(tOutput)) { - GT_FML_LOGGER.error("GT-ERR-01: @ " + tOutput.getUnlocalizedName() + " " + tOutput.getDisplayName()); - GT_FML_LOGGER.error( - "A Recipe used an OreDict Item as Output directly, without copying it before!!! This is a typical CallByReference/CallByValue Error"); - GT_FML_LOGGER.error( - "Said Item will be renamed to make the invalid Recipe visible, so that you can report it properly."); - GT_FML_LOGGER - .error("Please check all Recipes outputting this Item, and report the Recipes to their Owner."); - GT_FML_LOGGER.error( - "The Owner of the ==>RECIPE<==, NOT the Owner of the Item, which has been mentioned above!!!"); - GT_FML_LOGGER.error( - "And ONLY Recipes which are ==>OUTPUTTING<== the Item, sorry but I don't want failed Bug Reports."); - GT_FML_LOGGER.error( - "GregTech just reports this Error to you, so you can report it to the Mod causing the Problem."); - GT_FML_LOGGER.error( - "Even though I make that Bug visible, I can not and will not fix that for you, that's for the causing Mod to fix."); - GT_FML_LOGGER.error("And speaking of failed Reports:"); - GT_FML_LOGGER.error( - "Both IC2 and GregTech CANNOT be the CAUSE of this Problem, so don't report it to either of them."); - GT_FML_LOGGER - .error("I REPEAT, BOTH, IC2 and GregTech CANNOT be the source of THIS BUG. NO MATTER WHAT."); - GT_FML_LOGGER.error( - "Asking in the IC2 Forums, which Mod is causing that, won't help anyone, since it is not possible to determine, which Mod it is."); - GT_FML_LOGGER.error( - "If it would be possible, then I would have had added the Mod which is causing it to the Message already. But it is not possible."); - GT_FML_LOGGER.error( - "Sorry, but this Error is serious enough to justify this Wall-O-Text and the partially allcapsed Language."); - GT_FML_LOGGER.error("Also it is a Ban Reason on the IC2-Forums to post this seriously."); - tOutput.setStackDisplayName("ERROR! PLEASE CHECK YOUR LOG FOR 'GT-ERR-01'!"); - } else { + if (!gregtechproxy.mRegisteredOres.contains(tOutput)) { GT_OreDictUnificator.setStack(tOutput); + } else { + logMultilineError(GT_FML_LOGGER, generateGTErr01Message(tOutput)); + tOutput.setStackDisplayName("ERROR! PLEASE CHECK YOUR LOG FOR 'GT-ERR-01'!"); } } GregTech_API.mServerStarted = true; @@ -839,4 +813,19 @@ public class GT_Mod implements IGT_Mod { t.printStackTrace(new PrintWriter(sw)); GT_FML_LOGGER.error(sw); } + + private static String[] generateGTErr01Message(ItemStack stack) { + // The message is presented on a per-line basis to make possible formatting in the future easier. + return new String[] { "GT-ERR-01 at " + stack.getUnlocalizedName() + " " + stack.getDisplayName(), + "A recipe used an OreDict item as output directly, without copying the item before that. This is a typical CallByReference/CallByValue error.", + "The said item will be renamed to make the invalid recipe visible.", + "Please check all recipes that output this item, and report them to the mod that introduced the recipes.", }; + } + + @SuppressWarnings("SameParameterValue") // The method is used with one logger, but that might change in the future. + private static void logMultilineError(Logger logger, String[] errorMessageLines) { + for (String errorMessage : errorMessageLines) { + logger.error(errorMessage); + } + } } |