diff --git a/src/main/java/com/pahimar/ee3/array/AlchemyArrayRegistry.java b/src/main/java/com/pahimar/ee3/array/AlchemyArrayRegistry.java index c417f702..dbef679f 100644 --- a/src/main/java/com/pahimar/ee3/array/AlchemyArrayRegistry.java +++ b/src/main/java/com/pahimar/ee3/array/AlchemyArrayRegistry.java @@ -5,12 +5,15 @@ import com.pahimar.ee3.api.array.AlchemyArray; import com.pahimar.ee3.util.LoaderHelper; import com.pahimar.ee3.util.LogHelper; import cpw.mods.fml.common.Loader; +import org.apache.logging.log4j.Marker; +import org.apache.logging.log4j.MarkerManager; import java.util.SortedSet; import java.util.TreeSet; public class AlchemyArrayRegistry { + public static final Marker ALCHEMY_ARRAY_MARKER = MarkerManager.getMarker("EE3_ALCHEMY_ARRAY", LogHelper.MOD_MARKER); private static AlchemyArrayRegistry alchemyArrayRegistry = null; private SortedSet registeredAlchemyArrays; @@ -59,7 +62,7 @@ public class AlchemyArrayRegistry { if (!registeredAlchemyArrays.contains(alchemyArray)) { - LogHelper.trace(String.format("AbilityRegistry[%s]: Mod with ID '%s' added alchemy array %s", LoaderHelper.getLoaderState(), Loader.instance().activeModContainer().getModId(), alchemyArray)); + LogHelper.trace(ALCHEMY_ARRAY_MARKER, "[{}]: Mod with ID '{}' added alchemy array {}", LoaderHelper.getLoaderState(), Loader.instance().activeModContainer().getModId(), alchemyArray); return registeredAlchemyArrays.add(alchemyArray); } diff --git a/src/main/java/com/pahimar/ee3/command/CommandRunTest.java b/src/main/java/com/pahimar/ee3/command/CommandRunTest.java index 224142ea..7029e3b6 100644 --- a/src/main/java/com/pahimar/ee3/command/CommandRunTest.java +++ b/src/main/java/com/pahimar/ee3/command/CommandRunTest.java @@ -49,9 +49,9 @@ public class CommandRunTest extends CommandEE { testFound = true; EnergyValueMappingsTestSuite energyValueMappingsTestSuite = new EnergyValueMappingsTestSuite(testCaseFile); - LogHelper.info(String.format("BEGIN TEST (%s)", testCaseFile.getName())); + LogHelper.info(EnergyValueMappingsTestSuite.TEST_MARKER, "BEGIN TEST ({})", testCaseFile.getName()); energyValueMappingsTestSuite.runTestSuite(); - LogHelper.info(String.format("END TEST (%s)", testCaseFile.getName())); + LogHelper.info(EnergyValueMappingsTestSuite.TEST_MARKER, "END TEST ({})", testCaseFile.getName()); } } diff --git a/src/main/java/com/pahimar/ee3/command/CommandSyncEnergyValues.java b/src/main/java/com/pahimar/ee3/command/CommandSyncEnergyValues.java index fdd9f412..5feee502 100644 --- a/src/main/java/com/pahimar/ee3/command/CommandSyncEnergyValues.java +++ b/src/main/java/com/pahimar/ee3/command/CommandSyncEnergyValues.java @@ -67,7 +67,7 @@ public class CommandSyncEnergyValues extends CommandBase if (shouldSync) { - LogHelper.info(String.format("Syncing energy values with player '%s' at their request", commandSender.getCommandSenderName())); + LogHelper.info(EnergyValueRegistry.ENERGY_VALUE_MARKER, "Syncing energy values with player '{}' at their request", commandSender.getCommandSenderName()); PacketHandler.INSTANCE.sendTo(new MessageSyncEnergyValues(EnergyValueRegistry.getInstance()), (EntityPlayerMP) commandSender); commandSender.addChatMessage(new ChatComponentTranslation(Messages.Commands.SYNC_ENERGY_VALUES_SUCCESS)); } diff --git a/src/main/java/com/pahimar/ee3/exchange/CachedOreDictionary.java b/src/main/java/com/pahimar/ee3/exchange/CachedOreDictionary.java index bb4f4c6d..ef0bfdf9 100644 --- a/src/main/java/com/pahimar/ee3/exchange/CachedOreDictionary.java +++ b/src/main/java/com/pahimar/ee3/exchange/CachedOreDictionary.java @@ -94,7 +94,7 @@ public class CachedOreDictionary { for (String oreName : CachedOreDictionary.getInstance().getOreNames()) { - LogHelper.info(String.format("OreName: %s, ItemStacks: %s", oreName, CachedOreDictionary.getInstance().getItemStacksForOreName(oreName))); + LogHelper.info("OreName: {}, ItemStacks: {}", oreName, CachedOreDictionary.getInstance().getItemStacksForOreName(oreName)); } } } diff --git a/src/main/java/com/pahimar/ee3/exchange/DynamicEnergyValueInitThread.java b/src/main/java/com/pahimar/ee3/exchange/DynamicEnergyValueInitThread.java index 62e83610..2fe9e837 100644 --- a/src/main/java/com/pahimar/ee3/exchange/DynamicEnergyValueInitThread.java +++ b/src/main/java/com/pahimar/ee3/exchange/DynamicEnergyValueInitThread.java @@ -22,6 +22,6 @@ public class DynamicEnergyValueInitThread implements Runnable long startTime = System.currentTimeMillis(); EnergyValueRegistry.getInstance().init(); - LogHelper.info(String.format("DynamicEMC system initialized after %s ms", System.currentTimeMillis() - startTime)); + LogHelper.info(EnergyValueRegistry.ENERGY_VALUE_MARKER, "DynamicEMC system initialized after {} ms", System.currentTimeMillis() - startTime); } } diff --git a/src/main/java/com/pahimar/ee3/exchange/EnergyValueRegistry.java b/src/main/java/com/pahimar/ee3/exchange/EnergyValueRegistry.java index 51df1939..6cead7a7 100644 --- a/src/main/java/com/pahimar/ee3/exchange/EnergyValueRegistry.java +++ b/src/main/java/com/pahimar/ee3/exchange/EnergyValueRegistry.java @@ -19,6 +19,8 @@ import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.oredict.OreDictionary; +import org.apache.logging.log4j.Marker; +import org.apache.logging.log4j.MarkerManager; import java.io.File; import java.lang.reflect.Type; @@ -26,12 +28,15 @@ import java.util.*; public class EnergyValueRegistry implements JsonSerializer, JsonDeserializer { - private static final Gson JSON_SERIALIZER = (new GsonBuilder()).setPrettyPrinting().registerTypeAdapter(EnergyValueRegistry.class, new EnergyValueRegistry()).registerTypeAdapter(EnergyValueStackMapping.class, new EnergyValueStackMapping()).create(); + public static final Marker ENERGY_VALUE_MARKER = MarkerManager.getMarker("EE3_ENERGY_VALUE", LogHelper.MOD_MARKER); + private static final Marker PRE_CALC_MARKER = MarkerManager.getMarker("EE3_ENERGY_VALUE_PRE_CALC", ENERGY_VALUE_MARKER); + private static final Marker POST_CALC_MARKER = MarkerManager.getMarker("EE3_ENERGY_VALUE_POST_CALC", ENERGY_VALUE_MARKER); - private boolean shouldRegenNextRestart = false; + private static final Gson JSON_SERIALIZER = (new GsonBuilder()).setPrettyPrinting().registerTypeAdapter(EnergyValueRegistry.class, new EnergyValueRegistry()).registerTypeAdapter(EnergyValueStackMapping.class, new EnergyValueStackMapping()).create(); private static EnergyValueRegistry energyValueRegistry = null; private static Map preCalculationMappings; private static Map postCalculationMappings; + private boolean shouldRegenNextRestart = false; private ImmutableSortedMap stackMappings; private ImmutableSortedMap> valueMappings; private SortedSet uncomputedStacks; @@ -75,13 +80,13 @@ public class EnergyValueRegistry implements JsonSerializer, { if (factoredEnergyValue.compareTo(preCalculationMappings.get(factoredWrappedStack)) < 0) { - LogHelper.trace(String.format("EnergyValueRegistry[%s]: Mod with ID '%s' added a pre-assignment energy value of %s for object %s", LoaderHelper.getLoaderState(), Loader.instance().activeModContainer().getModId(), energyValue, wrappedStack)); + LogHelper.trace(PRE_CALC_MARKER, "[{}] Mod with ID '{}' set a pre-calculation energy value of {} for object {}", LoaderHelper.getLoaderState(), Loader.instance().activeModContainer().getModId(), energyValue, wrappedStack); preCalculationMappings.put(factoredWrappedStack, factoredEnergyValue); } } else { - LogHelper.trace(String.format("EnergyValueRegistry[%s]: Mod with ID '%s' added a pre-assignment energy value of %s for object %s", LoaderHelper.getLoaderState(), Loader.instance().activeModContainer().getModId(), energyValue, wrappedStack)); + LogHelper.trace(PRE_CALC_MARKER, "[{}] Mod with ID '{}' set a pre-calculation energy value of {} for object {}", LoaderHelper.getLoaderState(), Loader.instance().activeModContainer().getModId(), energyValue, wrappedStack); preCalculationMappings.put(factoredWrappedStack, factoredEnergyValue); } } @@ -109,7 +114,7 @@ public class EnergyValueRegistry implements JsonSerializer, WrappedStack factoredWrappedStack = WrappedStack.wrap(wrappedStack, 1); EnergyValue factoredEnergyValue = EnergyValueHelper.factorEnergyValue(energyValue, wrappedStack.getStackSize()); - LogHelper.trace(String.format("EnergyValueRegistry[%s]: Mod with ID '%s' added a post-assignment energy value of %s for object %s", LoaderHelper.getLoaderState(), Loader.instance().activeModContainer().getModId(), energyValue, wrappedStack)); + LogHelper.trace(POST_CALC_MARKER, "[{}] Mod with ID '{}' set a post-calculation energy value of {} for object {}", LoaderHelper.getLoaderState(), Loader.instance().activeModContainer().getModId(), energyValue, wrappedStack); postCalculationMappings.put(factoredWrappedStack, factoredEnergyValue); } } @@ -354,30 +359,28 @@ public class EnergyValueRegistry implements JsonSerializer, stackValueMap.putAll(preCalculationMappings); // TODO Logging // Add in all global pre-calculation values - LogHelper.trace(String.format("BEGIN Adding EnergyValue mappings from %s", Files.PRE_CALCULATION_ENERGY_VALUES)); + LogHelper.trace(ENERGY_VALUE_MARKER, "Adding EnergyValue mappings from {}", Files.Global.preCalcluationEnergyValueFile); Map globalPreCalculationValueMap = SerializationHelper.readEnergyValueStackMapFromJsonFile(Files.Global.preCalcluationEnergyValueFile); for (WrappedStack wrappedStack : globalPreCalculationValueMap.keySet()) { if (globalPreCalculationValueMap.get(wrappedStack) != null) { stackValueMap.put(wrappedStack, globalPreCalculationValueMap.get(wrappedStack)); - LogHelper.trace(String.format("Adding EnergyValue %s for %s", globalPreCalculationValueMap.get(wrappedStack), wrappedStack)); + LogHelper.trace(ENERGY_VALUE_MARKER, "Adding EnergyValue {} for {}", globalPreCalculationValueMap.get(wrappedStack), wrappedStack); } } - LogHelper.trace(String.format("END Adding EnergyValue mappings from %s", Files.PRE_CALCULATION_ENERGY_VALUES)); // Add in all instance pre-calculation values - LogHelper.trace(String.format("BEGIN Adding EnergyValue mappings from %s", Files.PRE_CALCULATION_ENERGY_VALUES)); + LogHelper.trace(ENERGY_VALUE_MARKER, "Adding EnergyValue mappings from {}", Files.PRE_CALCULATION_ENERGY_VALUES); Map instancePreAssignedValueMap = SerializationHelper.readEnergyValueStackMapFromJsonFile(Files.PRE_CALCULATION_ENERGY_VALUES); for (WrappedStack wrappedStack : instancePreAssignedValueMap.keySet()) { if (instancePreAssignedValueMap.get(wrappedStack) != null) { stackValueMap.put(wrappedStack, instancePreAssignedValueMap.get(wrappedStack)); - LogHelper.trace(String.format("Adding EnergyValue %s for %s", instancePreAssignedValueMap.get(wrappedStack), wrappedStack)); + LogHelper.trace(ENERGY_VALUE_MARKER, "Adding EnergyValue {} for {}", instancePreAssignedValueMap.get(wrappedStack), wrappedStack); } } - LogHelper.trace(String.format("END Adding EnergyValue mappings from %s", Files.PRE_CALCULATION_ENERGY_VALUES)); /* * Auto-assignment @@ -388,7 +391,7 @@ public class EnergyValueRegistry implements JsonSerializer, long passStartTime; int passComputedValueCount = 0; int totalComputedValueCount = 0; - LogHelper.info("Beginning dynamic value calculation"); + LogHelper.info(ENERGY_VALUE_MARKER, "Beginning dynamic value calculation"); boolean isFirstPass = true; while ((isFirstPass || passComputedValueCount > 0) && (passNumber < 16)) { @@ -423,22 +426,22 @@ public class EnergyValueRegistry implements JsonSerializer, { if (factoredExchangeEnergyValue.compareTo(stackValueMap.get(factoredKeyStack)) == -1) { - LogHelper.trace(String.format("")); // TODO Log message +// LogHelper.trace(String.format("")); TODO Log message stackValueMap.put(factoredKeyStack, factoredExchangeEnergyValue); } } else { - LogHelper.trace(String.format("")); // TODO Log message +// LogHelper.trace(String.format("")); TODO Log message stackValueMap.put(factoredKeyStack, factoredExchangeEnergyValue); passComputedValueCount++; totalComputedValueCount++; } } } - LogHelper.info(String.format("Pass %s: Calculated %s values for objects in %s ms", passNumber, passComputedValueCount, System.currentTimeMillis() - passStartTime)); + LogHelper.info(ENERGY_VALUE_MARKER, "Pass {}: Calculated {} values for objects in {} ms", passNumber, passComputedValueCount, System.currentTimeMillis() - passStartTime); } - LogHelper.info(String.format("Finished dynamic value calculation (calculated %s values for objects in %s ms)", totalComputedValueCount, System.currentTimeMillis() - computationStartTime)); + LogHelper.info(ENERGY_VALUE_MARKER, "Finished dynamic value calculation (calculated {} values for objects in {} ms)", totalComputedValueCount, System.currentTimeMillis() - computationStartTime); // Add in all mod specified post-calculation values // TODO Logging @@ -458,30 +461,28 @@ public class EnergyValueRegistry implements JsonSerializer, } // Add in all global post-calculation values - LogHelper.trace(String.format("Begin Adding EnergyValue mappings from %s", Files.POST_CALCULATION_ENERGY_VALUES)); + LogHelper.trace(ENERGY_VALUE_MARKER, "Adding EnergyValue mappings from {}", Files.Global.postCalcluationEnergyValueFile); Map globalPostCalculationValueMap = SerializationHelper.readEnergyValueStackMapFromJsonFile(Files.Global.postCalcluationEnergyValueFile); for (WrappedStack wrappedStack : globalPostCalculationValueMap.keySet()) { if (globalPostCalculationValueMap.get(wrappedStack) != null) { stackValueMap.put(wrappedStack, globalPostCalculationValueMap.get(wrappedStack)); - LogHelper.trace(String.format("Adding EnergyValue %s for %s", globalPostCalculationValueMap.get(wrappedStack), wrappedStack)); + LogHelper.trace(ENERGY_VALUE_MARKER, "Adding EnergyValue {} for {}", globalPostCalculationValueMap.get(wrappedStack), wrappedStack); } } - LogHelper.trace(String.format("END Adding EnergyValue mappings from %s", Files.PRE_CALCULATION_ENERGY_VALUES)); // Add in all instance post-calculation values - LogHelper.trace(String.format("Begin Adding EnergyValue mappings from %s", Files.POST_CALCULATION_ENERGY_VALUES)); + LogHelper.trace(ENERGY_VALUE_MARKER, "Adding EnergyValue mappings from {}", Files.POST_CALCULATION_ENERGY_VALUES); Map instancePostCalculationValueMap = SerializationHelper.readEnergyValueStackMapFromJsonFile(Files.POST_CALCULATION_ENERGY_VALUES); for (WrappedStack wrappedStack : instancePostCalculationValueMap.keySet()) { if (instancePostCalculationValueMap.get(wrappedStack) != null) { stackValueMap.put(wrappedStack, instancePostCalculationValueMap.get(wrappedStack)); - LogHelper.trace(String.format("Adding EnergyValue %s for %s", instancePreAssignedValueMap.get(wrappedStack), wrappedStack)); + LogHelper.trace(ENERGY_VALUE_MARKER, "Adding EnergyValue {} for {}", instancePreAssignedValueMap.get(wrappedStack), wrappedStack); } } - LogHelper.trace(String.format("End Adding EnergyValue mappings from %s", Files.POST_CALCULATION_ENERGY_VALUES)); /** * Finalize the stack to value map @@ -496,19 +497,17 @@ public class EnergyValueRegistry implements JsonSerializer, generateValueStackMappings(); // Serialize values to disk - LogHelper.info("Saving energy values to disk"); + LogHelper.info(ENERGY_VALUE_MARKER, "Saving energy values to disk"); save(); // TODO Make this make "sense" and also ensure it's added as an option to the debug command - LogHelper.info("BEGIN UNCOMPUTED OBJECT LIST"); for (WrappedStack wrappedStack : uncomputedStacks) { if (!hasEnergyValue(wrappedStack)) { - LogHelper.info(wrappedStack); + LogHelper.info(ENERGY_VALUE_MARKER, "Unable to compute a value for object '{}'", wrappedStack); } } - LogHelper.info("END UNCOMPUTED OBJECT LIST"); } private void generateValueStackMappings() @@ -645,10 +644,8 @@ public class EnergyValueRegistry implements JsonSerializer, return stacksInRange; } - public void loadFromMap(Map stackValueMap) - { - if (stackValueMap != null) - { + public void loadFromMap(Map stackValueMap) { + if (stackValueMap != null) { ImmutableSortedMap.Builder stackMappingsBuilder = ImmutableSortedMap.naturalOrder(); stackMappingsBuilder.putAll(stackValueMap); stackMappings = stackMappingsBuilder.build(); @@ -660,10 +657,8 @@ public class EnergyValueRegistry implements JsonSerializer, } } - public void setEnergyValue(WrappedStack wrappedStack, EnergyValue energyValue) - { - if (wrappedStack != null && energyValue != null && Float.compare(energyValue.getValue(), 0f) > 0) - { + public void setEnergyValue(WrappedStack wrappedStack, EnergyValue energyValue) { + if (wrappedStack != null && energyValue != null && Float.compare(energyValue.getValue(), 0f) > 0) { TreeMap stackValueMap = new TreeMap(stackMappings); stackValueMap.put(wrappedStack, energyValue); @@ -675,57 +670,48 @@ public class EnergyValueRegistry implements JsonSerializer, } } - public boolean getShouldRegenNextRestart() - { + public boolean getShouldRegenNextRestart() { return shouldRegenNextRestart; } - public void setShouldRegenNextRestart(boolean shouldRegenNextRestart) - { + public void setShouldRegenNextRestart(boolean shouldRegenNextRestart) { this.shouldRegenNextRestart = shouldRegenNextRestart; } - public ImmutableSortedMap getStackValueMap() - { + public ImmutableSortedMap getStackValueMap() { return stackMappings; } - public ImmutableSortedMap> getValueStackMap() - { + public ImmutableSortedMap> getValueStackMap() { return valueMappings; } - public void save() - { + public void save() { + File energyValuesDataDirectory = new File(FMLCommonHandler.instance().getMinecraftServerInstance().getEntityWorld().getSaveHandler().getWorldDirectory(), "data" + File.separator + Reference.LOWERCASE_MOD_ID + File.separator + "energyvalues"); energyValuesDataDirectory.mkdirs(); - if (shouldRegenNextRestart) - { + if (shouldRegenNextRestart) { File staticEnergyValuesJsonFile = new File(energyValuesDataDirectory, Files.STATIC_ENERGY_VALUES_JSON); File md5EnergyValuesJsonFile = new File(energyValuesDataDirectory, SerializationHelper.getModListMD5() + ".json"); // JSON - if (staticEnergyValuesJsonFile.exists()) - { + if (staticEnergyValuesJsonFile.exists()) { staticEnergyValuesJsonFile.delete(); } - if (md5EnergyValuesJsonFile.exists()) - { + if (md5EnergyValuesJsonFile.exists()) { md5EnergyValuesJsonFile.delete(); } shouldRegenNextRestart = false; - } - else - { + } else { SerializationHelper.compressEnergyValueStackMapToFile(new File(energyValuesDataDirectory, Files.STATIC_ENERGY_VALUES_JSON), energyValueRegistry.stackMappings); SerializationHelper.compressEnergyValueStackMapToFile(new File(energyValuesDataDirectory, SerializationHelper.getModListMD5() + ".json.gz"), energyValueRegistry.stackMappings); } } - public boolean loadEnergyValueRegistryFromFile() - { + public boolean loadEnergyValueRegistryFromFile() { + File energyValuesDataDirectory = new File(FMLCommonHandler.instance().getMinecraftServerInstance().getEntityWorld().getSaveHandler().getWorldDirectory(), "data" + File.separator + Reference.LOWERCASE_MOD_ID + File.separator + "energyvalues"); energyValuesDataDirectory.mkdirs(); @@ -734,44 +720,31 @@ public class EnergyValueRegistry implements JsonSerializer, Map stackValueMap = null; - if (!Settings.DynamicEnergyValueGeneration.regenerateEnergyValuesWhen.equalsIgnoreCase("Always")) - { - if (Settings.DynamicEnergyValueGeneration.regenerateEnergyValuesWhen.equalsIgnoreCase("When Mods Change")) - { - if (md5EnergyValuesFile.exists()) - { - LogHelper.info("Attempting to load energy values from file: " + md5EnergyValuesFile.getAbsolutePath()); + if (!Settings.DynamicEnergyValueGeneration.regenerateEnergyValuesWhen.equalsIgnoreCase("Always")) { + if (Settings.DynamicEnergyValueGeneration.regenerateEnergyValuesWhen.equalsIgnoreCase("When Mods Change")) { + if (md5EnergyValuesFile.exists()) { + LogHelper.info(ENERGY_VALUE_MARKER, "Attempting to load energy values from file: {}", md5EnergyValuesFile.getAbsolutePath()); stackValueMap = SerializationHelper.decompressEnergyValueStackMapFromFile(md5EnergyValuesFile); } - } - else if (Settings.DynamicEnergyValueGeneration.regenerateEnergyValuesWhen.equalsIgnoreCase("Never")) - { - if (staticEnergyValuesFile.exists()) - { - LogHelper.info("Attempting to load energy values from file: " + staticEnergyValuesFile.getAbsolutePath()); + } else if (Settings.DynamicEnergyValueGeneration.regenerateEnergyValuesWhen.equalsIgnoreCase("Never")) { + if (staticEnergyValuesFile.exists()) { + LogHelper.info(ENERGY_VALUE_MARKER, "Attempting to load energy values from file: {}", staticEnergyValuesFile.getAbsolutePath()); stackValueMap = SerializationHelper.decompressEnergyValueStackMapFromFile(staticEnergyValuesFile); - } - else if (md5EnergyValuesFile.exists()) - { - LogHelper.info("Attempting to load energy values from file: " + md5EnergyValuesFile.getAbsolutePath()); + } else if (md5EnergyValuesFile.exists()) { + LogHelper.info(ENERGY_VALUE_MARKER, "Attempting to load energy values from file: {}", md5EnergyValuesFile.getAbsolutePath()); stackValueMap = SerializationHelper.decompressEnergyValueStackMapFromFile(md5EnergyValuesFile); } } - if (stackValueMap != null) - { + if (stackValueMap != null) { loadFromMap(stackValueMap); - LogHelper.info("Successfully loaded energy values from file"); + LogHelper.info(ENERGY_VALUE_MARKER, "Successfully loaded energy values from file"); return true; - } - else - { - LogHelper.info("No energy value file to load values from, generating new values"); + } else { + LogHelper.info(ENERGY_VALUE_MARKER, "No energy value file to load values from, generating new values"); return false; } - } - else - { + } else { return false; } } @@ -782,21 +755,18 @@ public class EnergyValueRegistry implements JsonSerializer, } @Override - public EnergyValueRegistry deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException - { - if (json.isJsonArray()) - { + public EnergyValueRegistry deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException { + + if (json.isJsonArray()) { JsonArray jsonArray = (JsonArray) json; Map stackValueMap = new TreeMap(); Iterator iterator = jsonArray.iterator(); - while (iterator.hasNext()) - { + while (iterator.hasNext()) { JsonElement jsonElement = iterator.next(); EnergyValueStackMapping energyValueStackMapping = new EnergyValueStackMapping().deserialize(jsonElement, typeOfT, context); - if (energyValueStackMapping != null) - { + if (energyValueStackMapping != null) { stackValueMap.put(energyValueStackMapping.wrappedStack, energyValueStackMapping.energyValue); } } @@ -812,8 +782,8 @@ public class EnergyValueRegistry implements JsonSerializer, } @Override - public JsonElement serialize(EnergyValueRegistry energyValueRegistry, Type typeOfSrc, JsonSerializationContext context) - { + public JsonElement serialize(EnergyValueRegistry energyValueRegistry, Type typeOfSrc, JsonSerializationContext context) { + JsonArray jsonEnergyValueRegistry = new JsonArray(); for (WrappedStack wrappedStack : energyValueRegistry.stackMappings.keySet()) @@ -824,38 +794,29 @@ public class EnergyValueRegistry implements JsonSerializer, return jsonEnergyValueRegistry; } - public void dumpEnergyValueRegistryToLog() - { + public void dumpEnergyValueRegistryToLog() { + dumpEnergyValueRegistryToLog(EnergyValueRegistryProxy.Phase.ALL); } - public void dumpEnergyValueRegistryToLog(EnergyValueRegistryProxy.Phase phase) - { - LogHelper.info(String.format("BEGIN DUMPING %s ENERGY VALUE MAPPINGS", phase)); - if (phase == EnergyValueRegistryProxy.Phase.PRE_ASSIGNMENT || phase == EnergyValueRegistryProxy.Phase.PRE_CALCULATION) - { - for (WrappedStack wrappedStack : this.preCalculationMappings.keySet()) - { - LogHelper.info(String.format("- Object: %s, Value: %s", wrappedStack, EnergyValueRegistry.getInstance().getStackValueMap().get(wrappedStack))); + public void dumpEnergyValueRegistryToLog(EnergyValueRegistryProxy.Phase phase) { + + LogHelper.info(ENERGY_VALUE_MARKER, "BEGIN DUMPING {} ENERGY VALUE MAPPINGS", phase); + if (phase == EnergyValueRegistryProxy.Phase.PRE_ASSIGNMENT || phase == EnergyValueRegistryProxy.Phase.PRE_CALCULATION) { + for (WrappedStack wrappedStack : this.preCalculationMappings.keySet()) { + LogHelper.info(ENERGY_VALUE_MARKER, "Object: {}, Value: {}", wrappedStack, EnergyValueRegistry.getInstance().getStackValueMap().get(wrappedStack)); } - } - else if (phase == EnergyValueRegistryProxy.Phase.POST_ASSIGNMENT || phase == EnergyValueRegistryProxy.Phase.POST_CALCULATION) - { - if (this.postCalculationMappings != null) - { - for (WrappedStack wrappedStack : this.postCalculationMappings.keySet()) - { - LogHelper.info(String.format("- Object: %s, Value: %s", wrappedStack, EnergyValueRegistry.getInstance().getStackValueMap().get(wrappedStack))); + } else if (phase == EnergyValueRegistryProxy.Phase.POST_ASSIGNMENT || phase == EnergyValueRegistryProxy.Phase.POST_CALCULATION) { + if (this.postCalculationMappings != null) { + for (WrappedStack wrappedStack : this.postCalculationMappings.keySet()) { + LogHelper.info(ENERGY_VALUE_MARKER, "Object: {}, Value: {}", wrappedStack, EnergyValueRegistry.getInstance().getStackValueMap().get(wrappedStack)); } } - } - else if (phase == EnergyValueRegistryProxy.Phase.ALL) - { - for (WrappedStack wrappedStack : EnergyValueRegistry.getInstance().getStackValueMap().keySet()) - { - LogHelper.info(String.format("- Object: %s, Value: %s", wrappedStack, EnergyValueRegistry.getInstance().getStackValueMap().get(wrappedStack))); + } else if (phase == EnergyValueRegistryProxy.Phase.ALL) { + for (WrappedStack wrappedStack : EnergyValueRegistry.getInstance().getStackValueMap().keySet()) { + LogHelper.info(ENERGY_VALUE_MARKER, "Object: {}, Value: {}", wrappedStack, EnergyValueRegistry.getInstance().getStackValueMap().get(wrappedStack)); } } - LogHelper.info(String.format("END DUMPING %s ENERGY VALUE MAPPINGS", phase)); + LogHelper.info(ENERGY_VALUE_MARKER, "END DUMPING {} ENERGY VALUE MAPPINGS", phase); } } diff --git a/src/main/java/com/pahimar/ee3/handler/ConfigurationHandler.java b/src/main/java/com/pahimar/ee3/handler/ConfigurationHandler.java index 21e5d628..4f145fa5 100644 --- a/src/main/java/com/pahimar/ee3/handler/ConfigurationHandler.java +++ b/src/main/java/com/pahimar/ee3/handler/ConfigurationHandler.java @@ -11,41 +11,35 @@ import net.minecraftforge.common.config.Configuration; import java.io.File; -public class ConfigurationHandler -{ +public class ConfigurationHandler { + public static Configuration configuration; - private final static String CATEGORY_DEBUG = "general.Debug"; + public static void init(File configFile) { - public static void init(File configFile) - { - if (configuration == null) - { + if (configuration == null) { configuration = new Configuration(configFile, true); loadConfiguration(); } } - private static void loadConfiguration() - { + private static void loadConfiguration() { + // TODO Come back and do these constants in logical locations and names Settings.General.syncThreshold = configuration.getInt(Messages.Configuration.GENERAL_SYNC_THRESHOLD, Configuration.CATEGORY_GENERAL, 5, 0, Short.MAX_VALUE, StatCollector.translateToLocal(Messages.Configuration.GENERAL_SYNC_THRESHOLD_COMMENT), Messages.Configuration.GENERAL_SYNC_THRESHOLD_LABEL); Settings.Sounds.soundMode = ConfigurationHelper.getString(configuration, Messages.Configuration.SOUND_MODE, Configuration.CATEGORY_GENERAL, "All", StatCollector.translateToLocal(Messages.Configuration.SOUND_MODE_COMMENT), new String[]{"All", "Self", "None"}, Messages.Configuration.SOUND_MODE_LABEL); Settings.Abilities.onlyLoadFile = configuration.getBoolean(Messages.Configuration.ABILITIES_ONLY_LOAD_FILE, Configuration.CATEGORY_GENERAL, false, StatCollector.translateToLocal(Messages.Configuration.ABILITIES_ONLY_LOAD_FILE_COMMENT), Messages.Configuration.ABILITIES_ONLY_LOAD_FILE_LABEL); Settings.DynamicEnergyValueGeneration.regenerateEnergyValuesWhen = ConfigurationHelper.getString(configuration, Messages.Configuration.REGENERATE_ENERGYVALUES_WHEN, Configuration.CATEGORY_GENERAL, "Always", StatCollector.translateToLocal(Messages.Configuration.REGENERATE_ENERGYVALUES_WHEN_COMMENT), new String[]{"Never", "When Mods Change", "Always"}, Messages.Configuration.REGENERATE_ENERGYVALUES_WHEN_LABEL); - Settings.Debug.logTraceToInfo = configuration.getBoolean(Messages.Configuration.LOG_TRACE_TO_INFO, CATEGORY_DEBUG, false, StatCollector.translateToLocal(Messages.Configuration.LOG_TRACE_TO_INFO_COMMENT), Messages.Configuration.LOG_TRACE_TO_INFO_LABEL); - if (configuration.hasChanged()) - { + if (configuration.hasChanged()) { configuration.save(); } } @SubscribeEvent - public void onConfigurationChangedEvent(ConfigChangedEvent.OnConfigChangedEvent event) - { - if (event.modID.equalsIgnoreCase(Reference.MOD_ID)) - { + public void onConfigurationChangedEvent(ConfigChangedEvent.OnConfigChangedEvent event) { + + if (event.modID.equalsIgnoreCase(Reference.MOD_ID)) { loadConfiguration(); } } diff --git a/src/main/java/com/pahimar/ee3/item/ItemMiniumStone.java b/src/main/java/com/pahimar/ee3/item/ItemMiniumStone.java index fca6f638..eeaaea40 100644 --- a/src/main/java/com/pahimar/ee3/item/ItemMiniumStone.java +++ b/src/main/java/com/pahimar/ee3/item/ItemMiniumStone.java @@ -52,6 +52,6 @@ public class ItemMiniumStone extends ItemEE implements IKeyBound @Override public void doKeyBindingAction(EntityPlayer entityPlayer, ItemStack itemStack, Key key) { - LogHelper.info(String.format("%s %s %s", entityPlayer.toString(), itemStack.toString(), key.toString())); + LogHelper.info("{} {} {}", entityPlayer.toString(), itemStack.toString(), key.toString()); } } diff --git a/src/main/java/com/pahimar/ee3/item/ItemPhilosophersStone.java b/src/main/java/com/pahimar/ee3/item/ItemPhilosophersStone.java index 6e63c1d5..8035e865 100644 --- a/src/main/java/com/pahimar/ee3/item/ItemPhilosophersStone.java +++ b/src/main/java/com/pahimar/ee3/item/ItemPhilosophersStone.java @@ -46,6 +46,6 @@ public class ItemPhilosophersStone extends ItemEE implements IKeyBound, IOverlay @Override public void doKeyBindingAction(EntityPlayer entityPlayer, ItemStack itemStack, Key key) { - LogHelper.info(String.format("%s %s %s", entityPlayer.toString(), itemStack.toString(), key.toString())); + LogHelper.info("{} {} {}", entityPlayer.toString(), itemStack.toString(), key.toString()); } } diff --git a/src/main/java/com/pahimar/ee3/knowledge/AbilityRegistry.java b/src/main/java/com/pahimar/ee3/knowledge/AbilityRegistry.java index ce130a0c..12d62007 100644 --- a/src/main/java/com/pahimar/ee3/knowledge/AbilityRegistry.java +++ b/src/main/java/com/pahimar/ee3/knowledge/AbilityRegistry.java @@ -14,6 +14,8 @@ import com.pahimar.ee3.util.SerializationHelper; import cpw.mods.fml.common.Loader; import net.minecraft.item.ItemStack; import net.minecraftforge.common.MinecraftForge; +import org.apache.logging.log4j.Marker; +import org.apache.logging.log4j.MarkerManager; import java.io.*; import java.lang.reflect.Type; @@ -23,6 +25,12 @@ import java.util.TreeSet; public class AbilityRegistry implements JsonSerializer, JsonDeserializer { + public static final Marker ABILITY_MARKER = MarkerManager.getMarker("EE3_ABILITY", LogHelper.MOD_MARKER); + private static final Marker NOT_LEARABLE_MARKER = MarkerManager.getMarker("EE3_ABILITY_NOT_LEARNABLE", ABILITY_MARKER); + private static final Marker LEARABLE_MARKER = MarkerManager.getMarker("EE3_ABILITY_LEARNABLE", ABILITY_MARKER); + private static final Marker NOT_RECOVERABLE_MARKER = MarkerManager.getMarker("EE3_ABILITY_NOT_RECOVERABLE", ABILITY_MARKER); + private static final Marker RECOVERABLE_MARKER = MarkerManager.getMarker("EE3_ABILITY_RECOVERABLE", ABILITY_MARKER); + private static final Gson jsonSerializer = (new GsonBuilder()).setPrettyPrinting().registerTypeAdapter(AbilityRegistry.class, new AbilityRegistry()).create(); private static AbilityRegistry abilityRegistry = null; @@ -90,7 +98,7 @@ public class AbilityRegistry implements JsonSerializer, JsonDes if (notLearnableSet.remove(wrappedStack)) { hasBeenModified = true; - LogHelper.trace(String.format("AbilityRegistry[%s]: Mod with ID '%s' set object %s as LEARNABLE", LoaderHelper.getLoaderState(), Loader.instance().activeModContainer().getModId(), wrappedStack)); + LogHelper.trace(LEARABLE_MARKER, "[{}] Mod with ID '{}' set object {} as LEARNABLE", LoaderHelper.getLoaderState(), Loader.instance().activeModContainer().getModId(), wrappedStack); } } } @@ -107,7 +115,7 @@ public class AbilityRegistry implements JsonSerializer, JsonDes if (notLearnableSet.add(wrappedStack)) { hasBeenModified = true; - LogHelper.trace(String.format("AbilityRegistry[%s]: Mod with ID '%s' set object %s as NOT LEARNABLE", LoaderHelper.getLoaderState(), Loader.instance().activeModContainer().getModId(), wrappedStack)); + LogHelper.trace(NOT_LEARABLE_MARKER, "[{}] Mod with ID '{}' set object {} as NOT LEARNABLE", LoaderHelper.getLoaderState(), Loader.instance().activeModContainer().getModId(), wrappedStack); } } } @@ -140,7 +148,7 @@ public class AbilityRegistry implements JsonSerializer, JsonDes if (notRecoverableSet.remove(wrappedStack)) { hasBeenModified = true; - LogHelper.trace(String.format("AbilityRegistry[%s]: Mod with ID '%s' set object %s as RECOVERABLE", LoaderHelper.getLoaderState(), Loader.instance().activeModContainer().getModId(), wrappedStack)); + LogHelper.trace(RECOVERABLE_MARKER, "[{}] Mod with ID '{}' set object {} as RECOVERABLE", LoaderHelper.getLoaderState(), Loader.instance().activeModContainer().getModId(), wrappedStack); } } } @@ -157,7 +165,7 @@ public class AbilityRegistry implements JsonSerializer, JsonDes if (notRecoverableSet.add(wrappedStack)) { hasBeenModified = true; - LogHelper.trace(String.format("AbilityRegistry[%s]: Mod with ID '%s' set object %s as NOT RECOVERABLE", LoaderHelper.getLoaderState(), Loader.instance().activeModContainer().getModId(), wrappedStack)); + LogHelper.trace(NOT_RECOVERABLE_MARKER, "[{}] Mod with ID '{}' set object {} as NOT RECOVERABLE", LoaderHelper.getLoaderState(), Loader.instance().activeModContainer().getModId(), wrappedStack); } } } @@ -358,47 +366,30 @@ public class AbilityRegistry implements JsonSerializer, JsonDes public void dumpAbilityRegistryToLog(AbilityRegistryProxy.Abilities abilityType) { - LogHelper.info(String.format("BEGIN DUMPING %s ABILITY OBJECTS", abilityType)); - if (abilityType == AbilityRegistryProxy.Abilities.NOT_LEARNABLE) - { - if (this.notLearnableSet != null) - { - for (WrappedStack wrappedStack : this.notLearnableSet) - { - LogHelper.info(String.format("- Object: %s", wrappedStack)); + if (abilityType == AbilityRegistryProxy.Abilities.NOT_LEARNABLE) { + if (this.notLearnableSet != null) { + for (WrappedStack wrappedStack : this.notLearnableSet) { + LogHelper.info(NOT_LEARABLE_MARKER, "Not Learnable: {}", wrappedStack); } } - } - else if (abilityType == AbilityRegistryProxy.Abilities.NOT_RECOVERABLE) - { - if (this.notRecoverableSet != null) - { - for (WrappedStack wrappedStack : this.notRecoverableSet) - { - LogHelper.info(String.format("- Object: %s", wrappedStack)); + } else if (abilityType == AbilityRegistryProxy.Abilities.NOT_RECOVERABLE) { + if (this.notRecoverableSet != null) { + for (WrappedStack wrappedStack : this.notRecoverableSet) { + LogHelper.info(NOT_RECOVERABLE_MARKER, "Not Recoverable: {}", wrappedStack); } } - } - else if (abilityType == AbilityRegistryProxy.Abilities.ALL) - { - if (this.notLearnableSet != null) - { - LogHelper.info("NOT LEARNABLE OBJECTS"); - for (WrappedStack wrappedStack : this.notLearnableSet) - { - LogHelper.info(String.format("- Object: %s", wrappedStack)); + } else if (abilityType == AbilityRegistryProxy.Abilities.ALL) { + if (this.notLearnableSet != null) { + for (WrappedStack wrappedStack : this.notLearnableSet) { + LogHelper.info(NOT_LEARABLE_MARKER, "Not Learnable: {}", wrappedStack); } } - if (this.notRecoverableSet != null) - { - LogHelper.info("NOT RECOVERABLE OBJECTS"); - for (WrappedStack wrappedStack : this.notRecoverableSet) - { - LogHelper.info(String.format("- Object: %s", wrappedStack)); + if (this.notRecoverableSet != null) { + for (WrappedStack wrappedStack : this.notRecoverableSet) { + LogHelper.info(NOT_RECOVERABLE_MARKER, "Not Recoverable: {}", wrappedStack); } } } - LogHelper.info(String.format("END DUMPING %s ABILITY OBJECTS", abilityType)); } } diff --git a/src/main/java/com/pahimar/ee3/network/message/MessageSetEnergyValue.java b/src/main/java/com/pahimar/ee3/network/message/MessageSetEnergyValue.java index 280f832a..ca68810f 100644 --- a/src/main/java/com/pahimar/ee3/network/message/MessageSetEnergyValue.java +++ b/src/main/java/com/pahimar/ee3/network/message/MessageSetEnergyValue.java @@ -71,11 +71,11 @@ public class MessageSetEnergyValue implements IMessage, IMessageHandler> recipeMap; private ImmutableMultimap> immutableRecipeMap; - private RecipeRegistry() - { + private RecipeRegistry() { recipeMap = HashMultimap.create(); // TODO Switch this to a TreeMultimap } - public static RecipeRegistry getInstance() - { - if (recipeRegistry == null) - { + public static RecipeRegistry getInstance() { + + if (recipeRegistry == null) { recipeRegistry = new RecipeRegistry(); } return recipeRegistry; } - public void addRecipe(Object recipeOutput, List recipeInputList) - { + public void addRecipe(Object recipeOutput, List recipeInputList) { + // Wrap the recipe output WrappedStack wrappedRecipeOutput = WrappedStack.wrap(recipeOutput); - if (wrappedRecipeOutput == null) - { + if (wrappedRecipeOutput == null) { return; } List wrappedRecipeInputList = new ArrayList(); StringBuilder stringBuilder = new StringBuilder(); - for (Object recipeInputObject : recipeInputList) - { + for (Object recipeInputObject : recipeInputList) { WrappedStack wrappedInputObject = WrappedStack.wrap(recipeInputObject); - if (wrappedInputObject != null) - { + if (wrappedInputObject != null) { wrappedRecipeInputList.add(wrappedInputObject); stringBuilder.append(wrappedInputObject); stringBuilder.append(" "); - } - else - { + } else { return; } } // Add the recipe mapping only if we don't already have it - if (!recipeMap.get(wrappedRecipeOutput).contains(wrappedRecipeInputList)) - { - LogHelper.trace(String.format("RecipeRegistry[%s]: Mod with ID '%s' added recipe (Output: %s, Inputs: %s)", LoaderHelper.getLoaderState(), Loader.instance().activeModContainer().getModId(), wrappedRecipeOutput, stringBuilder.toString().trim())); + if (!recipeMap.get(wrappedRecipeOutput).contains(wrappedRecipeInputList)) { + LogHelper.trace(RECIPE_MARKER, "[{}] Mod with ID '{}' added recipe (Output: {}, Inputs: {})", LoaderHelper.getLoaderState(), Loader.instance().activeModContainer().getModId(), wrappedRecipeOutput, stringBuilder.toString().trim()); recipeMap.put(wrappedRecipeOutput, wrappedRecipeInputList); } } - public void registerVanillaRecipes() - { + public void registerVanillaRecipes() { RecipesVanilla.registerRecipes(); RecipesFluidContainers.registerRecipes(); RecipesPotions.registerRecipes(); } - public Multimap> getRecipeMappings() - { - if (immutableRecipeMap == null) - { + public Multimap> getRecipeMappings() { + + if (immutableRecipeMap == null) { immutableRecipeMap = ImmutableMultimap.copyOf(recipeRegistry.recipeMap); } return immutableRecipeMap; } - public void dumpRecipeRegistryToLog() - { - for (WrappedStack wrappedStack : getRecipeMappings().keySet()) - { + public void dumpRecipeRegistryToLog() { + + for (WrappedStack wrappedStack : getRecipeMappings().keySet()) { StringBuilder stringBuilder = new StringBuilder(); stringBuilder.append(String.format("Output: %s, Inputs: ", wrappedStack.toString())); - for (List listStacks : getRecipeMappings().get(wrappedStack)) - { - for (WrappedStack listStack : listStacks) - { + for (List listStacks : getRecipeMappings().get(wrappedStack)) { + for (WrappedStack listStack : listStacks) { stringBuilder.append(listStack.toString() + " "); } } - LogHelper.info(stringBuilder.toString()); + LogHelper.info(RECIPE_MARKER, stringBuilder.toString()); } } } \ No newline at end of file diff --git a/src/main/java/com/pahimar/ee3/reference/Messages.java b/src/main/java/com/pahimar/ee3/reference/Messages.java index 2f3a4efa..88dd18d9 100644 --- a/src/main/java/com/pahimar/ee3/reference/Messages.java +++ b/src/main/java/com/pahimar/ee3/reference/Messages.java @@ -1,7 +1,7 @@ package com.pahimar.ee3.reference; -public final class Messages -{ +public final class Messages { + public static final String OWNER_SET_TO_SELF = "misc.ee3:owner-set-to-self"; public static final String ENERGY_VALUE = "misc.ee3:energy-value"; @@ -9,15 +9,15 @@ public final class Messages public static final String NO_FINGERPRINT_MESSAGE = "The copy of Equivalent Exchange 3 that you are running is a development version of the mod, and as such may be unstable and/or incomplete."; public static final String INVALID_FINGERPRINT_MESSAGE = "The copy of Equivalent Exchange 3 that you are running has been modified from the original, and unpredictable things may happen. Please consider re-downloading the original version of the mod."; - public static final class Gui - { + public static final class Gui { + private static final String GUI_PREFIX = "container.ee3:"; public static final String NO_KNOWN_TRANSMUTATIONS = GUI_PREFIX + "alchemicalTome.noTransmutationsKnown"; } - public static final class Tooltips - { + public static final class Tooltips { + private static final String TOOLTIP_PREFIX = "tooltip.ee3:"; public static final String UPGRADES_CHESTS = TOOLTIP_PREFIX + "upgradesPrefix"; @@ -33,8 +33,8 @@ public final class Messages public static final String SORT_DESCENDING = TOOLTIP_PREFIX + "sortDescending"; } - public static final class Commands - { + public static final class Commands { + private static final String COMMAND_PREFIX = "commands.ee3."; public static final String BASE_COMMAND_USAGE = COMMAND_PREFIX + "usage"; @@ -106,8 +106,8 @@ public final class Messages public static final String RUN_TESTS_NOT_FOUND = COMMAND_PREFIX + Names.Commands.RUN_TEST + ".notfound"; } - public static final class Configuration - { + public static final class Configuration { + public static final String GENERAL_SYNC_THRESHOLD = "sync.threshold"; public static final String GENERAL_SYNC_THRESHOLD_LABEL = "general.sync.threshold.label"; public static final String GENERAL_SYNC_THRESHOLD_COMMENT = "general.sync.threshold.comment"; @@ -123,9 +123,5 @@ public final class Messages public static final String REGENERATE_ENERGYVALUES_WHEN = "energyvalues.regenerateEnergyValuesWhen"; public static final String REGENERATE_ENERGYVALUES_WHEN_LABEL = "general.energyvalues.regenerateEnergyValuesWhen.label"; public static final String REGENERATE_ENERGYVALUES_WHEN_COMMENT = "general.energyvalues.regenerateEnergyValuesWhen.comment"; - - public static final String LOG_TRACE_TO_INFO = "debug.logTraceToInfo"; - public static final String LOG_TRACE_TO_INFO_LABEL = "debug.logTraceToInfo.label"; - public static final String LOG_TRACE_TO_INFO_COMMENT = "debug.logTraceToInfo.comment"; } } diff --git a/src/main/java/com/pahimar/ee3/reference/Settings.java b/src/main/java/com/pahimar/ee3/reference/Settings.java index 471d98d9..b12a0b63 100644 --- a/src/main/java/com/pahimar/ee3/reference/Settings.java +++ b/src/main/java/com/pahimar/ee3/reference/Settings.java @@ -21,9 +21,4 @@ public class Settings { public static String regenerateEnergyValuesWhen; } - - public static class Debug - { - public static boolean logTraceToInfo; - } } diff --git a/src/main/java/com/pahimar/ee3/test/EnergyValueMappingsTestSuite.java b/src/main/java/com/pahimar/ee3/test/EnergyValueMappingsTestSuite.java index 0f24821c..77f9e461 100644 --- a/src/main/java/com/pahimar/ee3/test/EnergyValueMappingsTestSuite.java +++ b/src/main/java/com/pahimar/ee3/test/EnergyValueMappingsTestSuite.java @@ -5,6 +5,8 @@ import com.pahimar.ee3.api.exchange.EnergyValueRegistryProxy; import com.pahimar.ee3.exchange.WrappedStack; import com.pahimar.ee3.util.LogHelper; import com.pahimar.ee3.util.SerializationHelper; +import org.apache.logging.log4j.Marker; +import org.apache.logging.log4j.MarkerManager; import java.io.File; import java.util.ArrayList; @@ -12,8 +14,12 @@ import java.util.List; import java.util.Map; import java.util.TreeMap; -public class EnergyValueMappingsTestSuite -{ +public class EnergyValueMappingsTestSuite { + + public static final Marker TEST_MARKER = MarkerManager.getMarker("EE3_TEST", LogHelper.MOD_MARKER); + private static final Marker SUCCESS_MARKER = MarkerManager.getMarker("EE3_TEST_SUCCESS", TEST_MARKER); + private static final Marker FAILURE_MARKER = MarkerManager.getMarker("EE3_TEST_FAILURE", TEST_MARKER); + Map testSuiteValueMap; public EnergyValueMappingsTestSuite() @@ -124,12 +130,12 @@ public class EnergyValueMappingsTestSuite for (String successMessage : successMessages) { - LogHelper.info(successMessage); + LogHelper.info(SUCCESS_MARKER, successMessage); } for (String failureMessage : failureMessages) { - LogHelper.warn(failureMessage); + LogHelper.warn(FAILURE_MARKER, failureMessage); } } } diff --git a/src/main/java/com/pahimar/ee3/util/LogHelper.java b/src/main/java/com/pahimar/ee3/util/LogHelper.java index 02dde4a7..5a81e393 100644 --- a/src/main/java/com/pahimar/ee3/util/LogHelper.java +++ b/src/main/java/com/pahimar/ee3/util/LogHelper.java @@ -7,9 +7,6 @@ import org.apache.logging.log4j.message.Message; public class LogHelper { public static final Marker MOD_MARKER = MarkerManager.getMarker(Reference.MOD_ID); - public static final Marker ENERGY_VALUE_MARKER = MarkerManager.getMarker("ENERGY_VALUE", MOD_MARKER); - public static final Marker ABILITY_MARKER = MarkerManager.getMarker("ABILITY", MOD_MARKER); - public static final Marker RECIPE_MARKER = MarkerManager.getMarker("RECIPE", MOD_MARKER); private static Logger logger = LogManager.getLogger(Reference.MOD_ID); public static void log(Level level, Marker marker, Message message) { diff --git a/src/main/java/com/pahimar/ee3/util/SerializationHelper.java b/src/main/java/com/pahimar/ee3/util/SerializationHelper.java index 09020187..f8f253ea 100644 --- a/src/main/java/com/pahimar/ee3/util/SerializationHelper.java +++ b/src/main/java/com/pahimar/ee3/util/SerializationHelper.java @@ -125,12 +125,12 @@ public class SerializationHelper if (verboseLogging) { - LogHelper.info(String.format("Successfully saved %s to file: %s", nbtTaggable.getTagLabel(), file2.getAbsolutePath())); + LogHelper.info("Successfully saved {} to file: {}", nbtTaggable.getTagLabel(), file2.getAbsolutePath()); } } catch (Exception exception) { - LogHelper.warn(String.format("Failed to save %s to file: %s%s%s", nbtTaggable.getTagLabel(), directory.getAbsolutePath(), File.separator, fileName)); + LogHelper.warn("Failed to save {} to file: {}{}{}", nbtTaggable.getTagLabel(), directory.getAbsolutePath(), File.separator, fileName); exception.printStackTrace(); } } @@ -180,13 +180,13 @@ public class SerializationHelper if (verboseLogging) { - LogHelper.info(String.format("Successfully saved TransmutationKnowledge to file: %s", file2.getAbsolutePath())); + LogHelper.info("Successfully saved TransmutationKnowledge to file: {}", file2.getAbsolutePath()); } } catch (Exception exception) { exception.printStackTrace(); - LogHelper.error(String.format("Failed to save TransmutationKnowledge to file: %s%s", directory.getAbsolutePath(), fileName)); + LogHelper.error("Failed to save TransmutationKnowledge to file: {}{}", directory.getAbsolutePath(), fileName); } } }