Lots more Marker usage, for much better logging options (making my dev life so so so much easier)

This commit is contained in:
Pahimar 2015-11-19 15:24:40 -05:00
parent d848ffe9ad
commit 35841c20ae
19 changed files with 188 additions and 257 deletions

View File

@ -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<AlchemyArray> 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);
}

View File

@ -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());
}
}

View File

@ -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));
}

View File

@ -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));
}
}
}

View File

@ -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);
}
}

View File

@ -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<EnergyValueRegistry>, JsonDeserializer<EnergyValueRegistry>
{
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<WrappedStack, EnergyValue> preCalculationMappings;
private static Map<WrappedStack, EnergyValue> postCalculationMappings;
private boolean shouldRegenNextRestart = false;
private ImmutableSortedMap<WrappedStack, EnergyValue> stackMappings;
private ImmutableSortedMap<EnergyValue, List<WrappedStack>> valueMappings;
private SortedSet<WrappedStack> uncomputedStacks;
@ -75,13 +80,13 @@ public class EnergyValueRegistry implements JsonSerializer<EnergyValueRegistry>,
{
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<EnergyValueRegistry>,
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<EnergyValueRegistry>,
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<WrappedStack, EnergyValue> 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<WrappedStack, EnergyValue> 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<EnergyValueRegistry>,
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<EnergyValueRegistry>,
{
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<EnergyValueRegistry>,
}
// 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<WrappedStack, EnergyValue> 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<WrappedStack, EnergyValue> 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<EnergyValueRegistry>,
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<EnergyValueRegistry>,
return stacksInRange;
}
public void loadFromMap(Map<WrappedStack, EnergyValue> stackValueMap)
{
if (stackValueMap != null)
{
public void loadFromMap(Map<WrappedStack, EnergyValue> stackValueMap) {
if (stackValueMap != null) {
ImmutableSortedMap.Builder<WrappedStack, EnergyValue> stackMappingsBuilder = ImmutableSortedMap.naturalOrder();
stackMappingsBuilder.putAll(stackValueMap);
stackMappings = stackMappingsBuilder.build();
@ -660,10 +657,8 @@ public class EnergyValueRegistry implements JsonSerializer<EnergyValueRegistry>,
}
}
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<WrappedStack, EnergyValue> stackValueMap = new TreeMap<WrappedStack, EnergyValue>(stackMappings);
stackValueMap.put(wrappedStack, energyValue);
@ -675,57 +670,48 @@ public class EnergyValueRegistry implements JsonSerializer<EnergyValueRegistry>,
}
}
public boolean getShouldRegenNextRestart()
{
public boolean getShouldRegenNextRestart() {
return shouldRegenNextRestart;
}
public void setShouldRegenNextRestart(boolean shouldRegenNextRestart)
{
public void setShouldRegenNextRestart(boolean shouldRegenNextRestart) {
this.shouldRegenNextRestart = shouldRegenNextRestart;
}
public ImmutableSortedMap<WrappedStack, EnergyValue> getStackValueMap()
{
public ImmutableSortedMap<WrappedStack, EnergyValue> getStackValueMap() {
return stackMappings;
}
public ImmutableSortedMap<EnergyValue, List<WrappedStack>> getValueStackMap()
{
public ImmutableSortedMap<EnergyValue, List<WrappedStack>> 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<EnergyValueRegistry>,
Map<WrappedStack, EnergyValue> 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<EnergyValueRegistry>,
}
@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<WrappedStack, EnergyValue> stackValueMap = new TreeMap<WrappedStack, EnergyValue>();
Iterator<JsonElement> 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<EnergyValueRegistry>,
}
@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<EnergyValueRegistry>,
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);
}
}

View File

@ -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();
}
}

View File

@ -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());
}
}

View File

@ -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());
}
}

View File

@ -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<AbilityRegistry>, JsonDeserializer<AbilityRegistry>
{
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<AbilityRegistry>, 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<AbilityRegistry>, 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<AbilityRegistry>, 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<AbilityRegistry>, 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<AbilityRegistry>, 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));
}
}

View File

@ -71,11 +71,11 @@ public class MessageSetEnergyValue implements IMessage, IMessageHandler<MessageS
if (message.energyValueStackMapping != null && message.energyValueStackMapping.wrappedStack != null && message.energyValueStackMapping.energyValue != null)
{
EnergyValueRegistry.getInstance().setEnergyValue(message.energyValueStackMapping.wrappedStack, message.energyValueStackMapping.energyValue);
LogHelper.info(String.format("Client successfully received new EnergyValue '%s' for object '%s'", message.energyValueStackMapping.wrappedStack, message.energyValueStackMapping.energyValue));
LogHelper.info(EnergyValueRegistry.ENERGY_VALUE_MARKER, "Client successfully received new EnergyValue '{}' for object '{}'", message.energyValueStackMapping.wrappedStack, message.energyValueStackMapping.energyValue);
}
else
{
LogHelper.info("Client failed to receive new EnergyValue from server");
LogHelper.info(EnergyValueRegistry.ENERGY_VALUE_MARKER, "Client failed to receive new EnergyValue from server");
}
return null;

View File

@ -114,11 +114,11 @@ public class MessageSyncEnergyValues implements IMessage, IMessageHandler<Messag
}
EnergyValueRegistry.getInstance().loadFromMap(energyValueStackMap);
LogHelper.info("Client successfully received EnergyValues from server");
LogHelper.info(EnergyValueRegistry.ENERGY_VALUE_MARKER, "Client successfully received EnergyValues from server");
}
else
{
LogHelper.info("Client failed to receive EnergyValues from server - falling back to local EnergyValues");
LogHelper.info(EnergyValueRegistry.ENERGY_VALUE_MARKER, "Client failed to receive EnergyValues from server - falling back to local EnergyValues");
}
return null;

View File

@ -32,6 +32,12 @@ public class AludelRecipeManager
return aludelRegistry;
}
public static void registerRecipes() {
for (RecipeAludel recipeAludel : AludelRecipeManager.getInstance().getRecipes()) {
RecipeRegistryProxy.addRecipe(recipeAludel.getRecipeOutput(), recipeAludel.getRecipeInputsAsWrappedStacks());
}
}
public void addRecipe(ItemStack recipeOutput, ItemStack recipeInputStack, ItemStack recipeInputDust)
{
addRecipe(new RecipeAludel(recipeOutput, recipeInputStack, recipeInputDust));
@ -41,7 +47,7 @@ public class AludelRecipeManager
{
if (!aludelRecipes.contains(recipeAludel))
{
LogHelper.trace(String.format("AludelRecipeManager[%s]: Mod with ID '%s' added Aludel recipe '%s'", LoaderHelper.getLoaderState(), Loader.instance().activeModContainer().getModId(), recipeAludel));
LogHelper.trace(RecipeRegistry.RECIPE_MARKER, "[{}] Mod with ID '%s' added Aludel recipe '%s'", LoaderHelper.getLoaderState(), Loader.instance().activeModContainer().getModId(), recipeAludel);
aludelRecipes.add(recipeAludel);
}
}
@ -76,12 +82,4 @@ public class AludelRecipeManager
{
return ImmutableList.copyOf(aludelRecipes);
}
public static void registerRecipes()
{
for (RecipeAludel recipeAludel : AludelRecipeManager.getInstance().getRecipes())
{
RecipeRegistryProxy.addRecipe(recipeAludel.getRecipeOutput(), recipeAludel.getRecipeInputsAsWrappedStacks());
}
}
}

View File

@ -7,97 +7,87 @@ import com.pahimar.ee3.exchange.WrappedStack;
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.ArrayList;
import java.util.List;
public class RecipeRegistry
{
public class RecipeRegistry {
public static final Marker RECIPE_MARKER = MarkerManager.getMarker("EE3_RECIPE", LogHelper.MOD_MARKER);
private static RecipeRegistry recipeRegistry = null;
private Multimap<WrappedStack, List<WrappedStack>> recipeMap;
private ImmutableMultimap<WrappedStack, List<WrappedStack>> 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<WrappedStack> wrappedRecipeInputList = new ArrayList<WrappedStack>();
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<WrappedStack, List<WrappedStack>> getRecipeMappings()
{
if (immutableRecipeMap == null)
{
public Multimap<WrappedStack, List<WrappedStack>> 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<WrappedStack> listStacks : getRecipeMappings().get(wrappedStack))
{
for (WrappedStack listStack : listStacks)
{
for (List<WrappedStack> listStacks : getRecipeMappings().get(wrappedStack)) {
for (WrappedStack listStack : listStacks) {
stringBuilder.append(listStack.toString() + " ");
}
}
LogHelper.info(stringBuilder.toString());
LogHelper.info(RECIPE_MARKER, stringBuilder.toString());
}
}
}

View File

@ -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";
}
}

View File

@ -21,9 +21,4 @@ public class Settings
{
public static String regenerateEnergyValuesWhen;
}
public static class Debug
{
public static boolean logTraceToInfo;
}
}

View File

@ -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<WrappedStack, EnergyValue> 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);
}
}
}

View File

@ -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) {

View File

@ -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);
}
}
}