Moved logging methods to their own util class
parent
7bd232bafd
commit
a7887c4da2
|
@ -9,6 +9,7 @@ import net.einsteinsci.betterbeginnings.network.PacketNetherBrickOvenFuelLevel;
|
|||
import net.einsteinsci.betterbeginnings.network.ServerProxy;
|
||||
import net.einsteinsci.betterbeginnings.register.*;
|
||||
import net.einsteinsci.betterbeginnings.register.achievement.RegisterAchievements;
|
||||
import net.einsteinsci.betterbeginnings.util.LogUtil;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraftforge.common.AchievementPage;
|
||||
|
@ -51,31 +52,10 @@ public class ModMain
|
|||
public static ServerProxy proxy;
|
||||
public static SimpleNetworkWrapper network;
|
||||
|
||||
public static void logDebug(String text)
|
||||
{
|
||||
if (BBConfig.debugLogging)
|
||||
{
|
||||
log(Level.DEBUG, text);
|
||||
}
|
||||
}
|
||||
|
||||
public static void log(Level level, String text)
|
||||
{
|
||||
FMLLog.log(NAME, level, text);
|
||||
}
|
||||
|
||||
public static void logDebug(Level level, String text)
|
||||
{
|
||||
if (BBConfig.debugLogging)
|
||||
{
|
||||
log(level, text);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void preInit(FMLPreInitializationEvent e)
|
||||
{
|
||||
log("Starting pre-initialization...");
|
||||
LogUtil.logDebug("Starting pre-initialization...");
|
||||
|
||||
configFile = BBConfigFolderLoader.getConfigFile(e);
|
||||
configFile.load();
|
||||
|
@ -99,11 +79,6 @@ public class ModMain
|
|||
RegisterTileEntities.register();
|
||||
}
|
||||
|
||||
public static void log(String text)
|
||||
{
|
||||
log(Level.INFO, text);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void init(FMLInitializationEvent e)
|
||||
{
|
||||
|
@ -134,6 +109,6 @@ public class ModMain
|
|||
RegisterItems.tweakVanilla();
|
||||
Worldgen.addWorldgen();
|
||||
AchievementPage.registerAchievementPage(new AchievementPage(NAME, RegisterAchievements.getAchievements()));
|
||||
log("Finished post-initialization.");
|
||||
LogUtil.logDebug("Finished post-initialization.");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ package net.einsteinsci.betterbeginnings.client;
|
|||
|
||||
import net.einsteinsci.betterbeginnings.ModMain;
|
||||
import net.einsteinsci.betterbeginnings.tileentity.TileEntityInfusionRepair;
|
||||
import net.einsteinsci.betterbeginnings.util.LogUtil;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.client.renderer.entity.RenderManager;
|
||||
|
@ -31,7 +32,7 @@ public class InfusionRender extends TileEntitySpecialRenderer
|
|||
|
||||
if (renderManager == null)
|
||||
{
|
||||
ModMain.logDebug("InfusionRender.rendermanager is NULL!");
|
||||
LogUtil.logDebug("InfusionRender.rendermanager is NULL!");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -88,7 +89,7 @@ public class InfusionRender extends TileEntitySpecialRenderer
|
|||
|
||||
if (renderManager == null)
|
||||
{
|
||||
ModMain.logDebug("InfusionRender.rendermanager is NULL!");
|
||||
LogUtil.logDebug("InfusionRender.rendermanager is NULL!");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -180,7 +181,7 @@ public class InfusionRender extends TileEntitySpecialRenderer
|
|||
|
||||
if (renderManager == null)
|
||||
{
|
||||
ModMain.logDebug("InfusionRender.rendermanager is NULL!");
|
||||
LogUtil.logDebug("InfusionRender.rendermanager is NULL!");
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package net.einsteinsci.betterbeginnings.config;
|
||||
|
||||
import net.einsteinsci.betterbeginnings.ModMain;
|
||||
import net.einsteinsci.betterbeginnings.util.LogUtil;
|
||||
import net.einsteinsci.betterbeginnings.util.RegistryUtil;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.Item;
|
||||
|
@ -222,7 +223,7 @@ public class BBConfig
|
|||
Block b = RegistryUtil.getBlockFromRegistry(s);
|
||||
if (b == null)
|
||||
{
|
||||
ModMain.log(Level.ERROR, "No block found matching '" + s + "'.");
|
||||
LogUtil.log(Level.ERROR, "No block found matching '" + s + "'.");
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -240,7 +241,7 @@ public class BBConfig
|
|||
int equalsAt = entry.indexOf("=");
|
||||
if (colonAt == -1 || equalsAt == -1)
|
||||
{
|
||||
ModMain.log(Level.ERROR, "Invalid format: '" + entry + "'.");
|
||||
LogUtil.log(Level.ERROR, "Invalid format: '" + entry + "'.");
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -251,7 +252,7 @@ public class BBConfig
|
|||
|
||||
if (item == null)
|
||||
{
|
||||
ModMain.log(Level.ERROR, "No item found within '" + entry + "'.");
|
||||
LogUtil.log(Level.ERROR, "No item found within '" + entry + "'.");
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -264,7 +265,7 @@ public class BBConfig
|
|||
}
|
||||
catch (NumberFormatException e)
|
||||
{
|
||||
ModMain.log(Level.ERROR, "Invalid number: " + levelStr + " within " + entry);
|
||||
LogUtil.log(Level.ERROR, "Invalid number: " + levelStr + " within " + entry);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -278,7 +279,7 @@ public class BBConfig
|
|||
int equalsAt = entry.indexOf("=");
|
||||
if (colonAt == -1 || equalsAt == -1)
|
||||
{
|
||||
ModMain.log(Level.ERROR, "Invalid format: '" + entry + "'.");
|
||||
LogUtil.log(Level.ERROR, "Invalid format: '" + entry + "'.");
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -289,7 +290,7 @@ public class BBConfig
|
|||
|
||||
if (item == null)
|
||||
{
|
||||
ModMain.log(Level.ERROR, "No item found within '" + entry + "'.");
|
||||
LogUtil.log(Level.ERROR, "No item found within '" + entry + "'.");
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -302,7 +303,7 @@ public class BBConfig
|
|||
}
|
||||
catch (NumberFormatException e)
|
||||
{
|
||||
ModMain.log(Level.ERROR, "Invalid number: " + levelStr + " within " + entry);
|
||||
LogUtil.log(Level.ERROR, "Invalid number: " + levelStr + " within " + entry);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ import net.einsteinsci.betterbeginnings.ModMain;
|
|||
import net.einsteinsci.betterbeginnings.config.BBConfig;
|
||||
import net.einsteinsci.betterbeginnings.items.ItemKnife;
|
||||
import net.einsteinsci.betterbeginnings.util.ChatUtil;
|
||||
import net.einsteinsci.betterbeginnings.util.LogUtil;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
@ -40,7 +41,7 @@ public class BlockBreakHelper
|
|||
|
||||
if (BBConfig.alwaysBreakable.contains(block))
|
||||
{
|
||||
ModMain.logDebug("Skipped block-breaking for block '" + block.getUnlocalizedName() +
|
||||
LogUtil.logDebug("Skipped block-breaking for block '" + block.getUnlocalizedName() +
|
||||
"'. Block is marked as always breakable in config.");
|
||||
return;
|
||||
}
|
||||
|
@ -109,11 +110,11 @@ public class BlockBreakHelper
|
|||
}
|
||||
else if (neededToolClass.equalsIgnoreCase("pickaxe") && isConfigPickaxe)
|
||||
{
|
||||
ModMain.logDebug("Item accepted as pickaxe from config: " + heldItemStack.toString());
|
||||
LogUtil.logDebug("Item accepted as pickaxe from config: " + heldItemStack.toString());
|
||||
}
|
||||
else if (neededToolClass.equalsIgnoreCase("axe") && isConfigAxe)
|
||||
{
|
||||
ModMain.logDebug("Item accepted as axe from config: " + heldItemStack.toString());
|
||||
LogUtil.logDebug("Item accepted as axe from config: " + heldItemStack.toString());
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -142,9 +143,9 @@ public class BlockBreakHelper
|
|||
brokenOnce.put(player, null);
|
||||
}
|
||||
|
||||
ModMain.log(Level.INFO, "Block break failed for " + stackName + " on " + block.getUnlocalizedName());
|
||||
ModMain.log(Level.INFO, " Required tool class: " + neededToolClass + ", supplied: " + usedToolClass);
|
||||
ModMain.log(Level.INFO, " Minimum harvest level: " + neededHarvestLevel + ", supplied: " +
|
||||
LogUtil.log(Level.INFO, "Block break failed for " + stackName + " on " + block.getUnlocalizedName());
|
||||
LogUtil.log(Level.INFO, " Required tool class: " + neededToolClass + ", supplied: " + usedToolClass);
|
||||
LogUtil.log(Level.INFO, " Minimum harvest level: " + neededHarvestLevel + ", supplied: " +
|
||||
usedHarvestLevel);
|
||||
}
|
||||
else
|
||||
|
@ -155,9 +156,9 @@ public class BlockBreakHelper
|
|||
|
||||
if (cancel)
|
||||
{
|
||||
ModMain.log(Level.INFO, "Block break failed for " + stackName + " on " + block.getUnlocalizedName());
|
||||
ModMain.log(Level.INFO, " Required tool class: " + neededToolClass + ", supplied: " + usedToolClass);
|
||||
ModMain.log(Level.INFO, " Minimum harvest level: " + neededHarvestLevel + ", supplied: " +
|
||||
LogUtil.log(Level.INFO, "Block break failed for " + stackName + " on " + block.getUnlocalizedName());
|
||||
LogUtil.log(Level.INFO, " Required tool class: " + neededToolClass + ", supplied: " + usedToolClass);
|
||||
LogUtil.log(Level.INFO, " Minimum harvest level: " + neededHarvestLevel + ", supplied: " +
|
||||
usedHarvestLevel);
|
||||
|
||||
ChatUtil.sendModChatToPlayer(player, "Wrong tool!" /* I18n.format("blockbreak.wrongtool") */);
|
||||
|
|
|
@ -3,6 +3,7 @@ package net.einsteinsci.betterbeginnings.network;
|
|||
import net.einsteinsci.betterbeginnings.ModMain;
|
||||
import net.einsteinsci.betterbeginnings.client.InfusionRender;
|
||||
import net.einsteinsci.betterbeginnings.tileentity.TileEntityInfusionRepair;
|
||||
import net.einsteinsci.betterbeginnings.util.LogUtil;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraftforge.fml.client.registry.ClientRegistry;
|
||||
|
@ -38,7 +39,7 @@ public class ClientProxy extends ServerProxy
|
|||
return ctx.getServerHandler().playerEntity;
|
||||
}
|
||||
default:
|
||||
ModMain.log(Level.ERROR, "Invalid side in TestMsgHandler: " + ctx.side);
|
||||
LogUtil.log(Level.ERROR, "Invalid side in TestMsgHandler: " + ctx.side);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ package net.einsteinsci.betterbeginnings.network;
|
|||
|
||||
import net.einsteinsci.betterbeginnings.ModMain;
|
||||
import net.einsteinsci.betterbeginnings.gui.BBGuiHandler;
|
||||
import net.einsteinsci.betterbeginnings.util.LogUtil;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraftforge.fml.common.network.NetworkRegistry;
|
||||
import net.minecraftforge.fml.common.network.simpleimpl.MessageContext;
|
||||
|
@ -29,12 +30,12 @@ public class ServerProxy
|
|||
switch (ctx.side)
|
||||
{
|
||||
case CLIENT:
|
||||
ModMain.log(Level.ERROR, "Message for CLIENT received for dedicated server");
|
||||
LogUtil.log(Level.ERROR, "Message for CLIENT received for dedicated server");
|
||||
return null;
|
||||
case SERVER:
|
||||
return ctx.getServerHandler().playerEntity;
|
||||
default:
|
||||
ModMain.log(Level.ERROR, "Invalid side in PacketHandler: " + ctx.side);
|
||||
LogUtil.log(Level.ERROR, "Invalid side in PacketHandler: " + ctx.side);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@ import net.einsteinsci.betterbeginnings.event.DamageSourceDiffusion;
|
|||
import net.einsteinsci.betterbeginnings.items.*;
|
||||
import net.einsteinsci.betterbeginnings.util.ChatUtil;
|
||||
import net.einsteinsci.betterbeginnings.util.InfusionRepairUtil;
|
||||
import net.einsteinsci.betterbeginnings.util.LogUtil;
|
||||
import net.einsteinsci.betterbeginnings.util.NBTUtil;
|
||||
import net.minecraft.command.IEntitySelector;
|
||||
import net.minecraft.enchantment.Enchantment;
|
||||
|
@ -350,7 +351,7 @@ public class TileEntityInfusionRepair extends TileEntity implements IUpdatePlaye
|
|||
|
||||
if (stackTool == null)
|
||||
{
|
||||
ModMain.log(Level.ERROR, "Tool not found in diffusion!");
|
||||
LogUtil.log(Level.ERROR, "Tool not found in diffusion!");
|
||||
ChatUtil.sendModChatToServer(ChatUtil.DARK_RED + "ERROR! Tool not found in diffusion!");
|
||||
healthTaken = 0;
|
||||
return;
|
||||
|
@ -359,7 +360,7 @@ public class TileEntityInfusionRepair extends TileEntity implements IUpdatePlaye
|
|||
NBTTagList enchList = stackTool.getEnchantmentTagList();
|
||||
if (enchList == null)
|
||||
{
|
||||
ModMain.log(Level.ERROR, "Tool does not have enchantments!");
|
||||
LogUtil.log(Level.ERROR, "Tool does not have enchantments!");
|
||||
healthTaken = 0;
|
||||
return;
|
||||
}
|
||||
|
@ -405,6 +406,8 @@ public class TileEntityInfusionRepair extends TileEntity implements IUpdatePlaye
|
|||
}
|
||||
}
|
||||
|
||||
LogUtil.log(Level.INFO, "Enchantment diffusion complete.");
|
||||
|
||||
healthTaken = 0;
|
||||
|
||||
worldObj.markBlockForUpdate(pos);
|
||||
|
|
|
@ -0,0 +1,35 @@
|
|||
package net.einsteinsci.betterbeginnings.util;
|
||||
|
||||
import net.einsteinsci.betterbeginnings.ModMain;
|
||||
import net.einsteinsci.betterbeginnings.config.BBConfig;
|
||||
import net.minecraftforge.fml.common.FMLLog;
|
||||
import org.apache.logging.log4j.Level;
|
||||
|
||||
public class LogUtil
|
||||
{
|
||||
public static void logDebug(String text)
|
||||
{
|
||||
if (BBConfig.debugLogging)
|
||||
{
|
||||
log(Level.DEBUG, text);
|
||||
}
|
||||
}
|
||||
|
||||
public static void logDebug(Level level, String text)
|
||||
{
|
||||
if (BBConfig.debugLogging)
|
||||
{
|
||||
log(level, text);
|
||||
}
|
||||
}
|
||||
|
||||
public static void log(Level level, String text)
|
||||
{
|
||||
FMLLog.log(ModMain.NAME, level, text);
|
||||
}
|
||||
|
||||
public static void log(String text)
|
||||
{
|
||||
log(Level.INFO, text);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue