Skip to content
This repository has been archived by the owner on Jan 18, 2024. It is now read-only.

Commit

Permalink
Merge branch '1.8.9' into 1.9.4-asm
Browse files Browse the repository at this point in the history
Conflicts:
	gradle.properties
	src/main/java/com/kamesuta/mc/signpic/asm/SignPictureTransformer.java
	src/main/java/com/kamesuta/mc/signpic/http/download/ModDownload.java
  • Loading branch information
Kamesuta committed Dec 18, 2016
2 parents 41123a9 + 349a649 commit 3d67f0d
Show file tree
Hide file tree
Showing 15 changed files with 65 additions and 65 deletions.
2 changes: 1 addition & 1 deletion src/main/java/com/kamesuta/mc/bnnwidget/StencilClip.java
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public static void init() {
ReflectionHelper.<BitSet, MinecraftForgeClient> getPrivateValue(MinecraftForgeClient.class, null, "stencilBits").set(0, 8);
}
} catch (final Throwable e) {
Log.info("Failed to enable stencil buffer", e);
Log.log.info("Failed to enable stencil buffer", e);
}
}
}
2 changes: 1 addition & 1 deletion src/main/java/com/kamesuta/mc/signpic/Client.java
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ public static void deleteMod(final File mod) {
if (!mod.delete()) {
mod.deleteOnExit();
final String msg = Reference.NAME+" was unable to delete file "+mod.getPath()+" the game will now try to delete it on exit. If this dialog appears again, delete it manually.";
Log.error(msg);
Log.log.error(msg);
if (!GraphicsEnvironment.isHeadless())
JOptionPane.showMessageDialog(null, msg, "An update error has occured", JOptionPane.ERROR_MESSAGE);
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/kamesuta/mc/signpic/ClientProxy.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ private File getDataDirectory() {
try {
return file.getCanonicalFile();
} catch (final IOException e) {
Log.debugerror("Could not canonize path!", e);
Log.dev.error("Could not canonize path!", e);
}
return file;
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/kamesuta/mc/signpic/CommonProxy.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

public class CommonProxy {
public void preInit(final FMLPreInitializationEvent event) {
Log.logger = event.getModLog();
Log.log = event.getModLog();
Config.instance = new Config(event.getSuggestedConfigurationFile());
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/kamesuta/mc/signpic/Debug.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public static void main(final String[] args) throws Exception {
// Reference.logger.info(String.format("R:%.04f G:%.04f B:%.04f A:%.04f", r, g, b, a));

final String src = "gyazo.com/114514e";
Log.info(replace(src));
Log.log.info(replace(src));
}

final static Pattern p = Pattern.compile("[^\\w]");
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/kamesuta/mc/signpic/Locations.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ private File getSignPicDir(final File defaultdir) {
if (!StringUtils.isEmpty(Config.instance.signpicDir.get())) {
if (dir.exists()&&dir.isDirectory()&&!dir.equals(defaultdir))
return dir;
Log.debugerror("invalid signpic dir location! use default dir.");
Log.dev.error("invalid signpic dir location! use default dir.");
}
return new File(defaultdir, "signpic");
}
Expand All @@ -53,7 +53,7 @@ private boolean securementDirectory(final File cachedir) {
i++;
} while (to.exists());
cachedir.renameTo(to);
Log.warn("non-directory conflicting file exists. renamed to "+to.getName());
Log.log.warn("non-directory conflicting file exists. renamed to "+to.getName());
return true;
}
cachedir.mkdir();
Expand Down
94 changes: 47 additions & 47 deletions src/main/java/com/kamesuta/mc/signpic/Log.java
Original file line number Diff line number Diff line change
@@ -1,77 +1,77 @@
package com.kamesuta.mc.signpic;

import javax.annotation.Nonnull;

import org.apache.commons.lang3.Validate;
import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.Marker;
import org.apache.logging.log4j.message.Message;
import org.apache.logging.log4j.spi.AbstractLogger;

import com.kamesuta.mc.signpic.gui.OverlayFrame;

public class Log {
public static Logger logger = LogManager.getLogger(Reference.MODID);
public static Logger log = LogManager.getLogger(Reference.MODID);
public static Logger dev = new DevLogger(log);

public static void error(final Object message) {
logger.error(message);
}
private static class DevLogger extends AbstractLogger {
private Logger logger;

public static void error(final Object message, final Throwable e) {
logger.error(message, e);
}
public DevLogger(@Nonnull final Logger logger) {
this.logger = logger;
}

public static void warn(final Object message) {
logger.warn(message);
}
private boolean isEnabled() {
Validate.notNull(Config.instance, "internal error: debug logger can be used after config loaded!");
return Config.instance.debugLog.get();
}

public static void warn(final Object message, final Throwable e) {
logger.warn(message, e);
}
@Override
protected boolean isEnabled(final Level level, final Marker marker, final Message data, final Throwable t) {
return isEnabled();
}

public static void info(final Object message) {
logger.info(message);
}
@Override
protected boolean isEnabled(final Level level, final Marker marker, final Object data, final Throwable t) {
return isEnabled();
}

public static void info(final Object message, final Throwable e) {
logger.info(message, e);
}
@Override
protected boolean isEnabled(final Level level, final Marker marker, final String data) {
return isEnabled();
}

public static void debugerror(final Object message) {
if (Config.instance.debugLog.get())
logger.error("[DEBUG] "+message);
}
@Override
protected boolean isEnabled(final Level level, final Marker marker, final String data, final Object... p1) {
return isEnabled();
}

public static void debugerror(final Object message, final Throwable e) {
if (Config.instance.debugLog.get())
logger.error("[DEBUG] "+message, e);
}

public static void debugwarn(final Object message) {
if (Config.instance.debugLog.get())
logger.warn("[DEBUG] "+message);
}

public static void debugwarn(final Object message, final Throwable e) {
if (Config.instance.debugLog.get())
logger.warn("[DEBUG] "+message, e);
}

public static void debuginfo(final Object message) {
if (Config.instance.debugLog.get())
logger.info("[DEBUG] "+message);
}
@Override
protected boolean isEnabled(final Level level, final Marker marker, final String data, final Throwable t) {
return isEnabled();
}

public static void debuginfo(final Object message, final Throwable e) {
if (Config.instance.debugLog.get())
logger.info("[DEBUG] "+message, e);
@Override
public void log(final Marker marker, final String fqcn, final Level level, final Message data, final Throwable t) {
if (isEnabled())
this.logger.log(level, marker, "[DEBUG] "+data.getFormattedMessage(), t);
}
}

@SuppressWarnings("deprecation")
public static void notice(final Object notice, final float duration) {
OverlayFrame.instance.pane.addNotice1(notice.toString(), duration);
debuginfo(notice);
if (dev!=null)
dev.info(notice);
}

@SuppressWarnings("deprecation")
public static void notice(final String notice, final Throwable e, final float duration) {
OverlayFrame.instance.pane.addNotice1(notice, duration);
debuginfo(notice, e);
if (dev!=null)
dev.info(notice, e);
}

public static void notice(final String notice) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public byte[] transform(final String name, final String transformedName, final b
return VisitorHelper.apply(bytes, name, new TransformProvider(ClassWriter.COMPUTE_FRAMES) {
@Override
public ClassVisitor createVisitor(final String name, final ClassVisitor cv) {
Log.info(String.format("Patching TileEntity.getRenderBoundingBox (class: %s)", name));
Log.log.info(String.format("Patching TileEntity.getRenderBoundingBox (class: %s)", name));
return new TileEntityVisitor(name, cv);
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ private E loadData() {
return data;
}
} catch (final Exception e) {
Log.warn("content meta data is broken. aborted. ["+this.location.getName()+"]");
Log.log.warn("content meta data is broken. aborted. ["+this.location.getName()+"]");
} finally {
IOUtils.closeQuietly(reader);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@ protected void close() {

@Override
protected void apply(final File f) {
Log.info(f.getAbsolutePath());
Log.log.info(f.getAbsolutePath());
}

@Override
protected void transfer(final Transferable transferable) {
Log.info(transferable);
Log.log.info(transferable);
}
};
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public static void init() {
guiEditSignTileEntity = field;
}
} catch (final SecurityException e) {
Log.error("Could not hook TileEntitySign field included in GuiEditSign", e);
Log.log.error("Could not hook TileEntitySign field included in GuiEditSign", e);
}
try {
final Field[] fields = GuiRepair.class.getDeclaredFields();
Expand All @@ -75,7 +75,7 @@ public static void init() {
}
}
} catch (final SecurityException e) {
Log.error("Could not hook GuiTextField or ContainerRepair field included in GuiRepair", e);
Log.log.error("Could not hook GuiTextField or ContainerRepair field included in GuiRepair", e);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ protected void afterWrite(final int n) throws IOException {
onDone(new CommunicateResponse(true, null));
return;
} catch (final Throwable e) {
Log.warn("Updater Downloading Error", e);
Log.log.warn("Updater Downloading Error", e);
final ITextComponent chat = new ChatBuilder().setChat(new TextComponentTranslation("signpic.versioning.error").setStyle(new Style().setColor(TextFormatting.RED))).build();
this.result = new ModDLResult(chat);
onDone(new CommunicateResponse(false, e));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public ImageMeta parse(final String src) {
b = parseMeta(src, key, value)&&b;
}
}
Log.debuginfo("signmeta={"+src+"}, unsupported="+!b);
Log.dev.info("signmeta={"+src+"}, unsupported="+!b);
this.hasInvalidMeta = this.hasInvalidMeta||!b;
return this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ public void onDone(final ICommunicateResponse res) {
if (checker.result!=null)
setSource(checker.result);
if (res.getError()!=null)
Log.warn("Could not check version information", res.getError());
Log.log.warn("Could not check version information", res.getError());
if (after!=null)
after.run();
}
Expand Down Expand Up @@ -179,7 +179,7 @@ public void runUpdate() {
try {
Desktop.getDesktop().open(Client.location.modDir.getCanonicalFile());
} catch (final IOException e) {
Log.error(e.getMessage(), e);
Log.log.error(e.getMessage(), e);
}
} else if (state.downloading) {
ChatBuilder.create("signpic.versioning.downloadingAlready").useTranslation().setStyle(new Style().setColor(TextFormatting.RED)).chatClient();
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/kamesuta/mc/signpic/state/State.java
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public State setErrorMessage(final Throwable throwable) {
} catch (final Throwable e) {
setMessage(I18n.format("signpic.advmsg.unknown", e));
}
Log.debugerror(getMessage(), throwable);
Log.dev.error(getMessage(), throwable);
}
return this;
}
Expand Down

0 comments on commit 3d67f0d

Please sign in to comment.