Logger, Channel#newSucceededFuture

This commit is contained in:
creeper123123321 2018-08-21 13:54:39 -03:00
parent 5955a668b9
commit b1775b5e75
4 changed files with 85 additions and 2 deletions

View File

@ -3,6 +3,9 @@ package com.github.creeper123123321.viarift;
import com.github.creeper123123321.viarift.platform.VRInjector;
import com.github.creeper123123321.viarift.platform.VRLoader;
import com.github.creeper123123321.viarift.platform.VRPlatform;
import com.github.creeper123123321.viarift.util.JLoggerToLog4j;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.dimdev.riftloader.listener.InitializationListener;
import org.spongepowered.asm.launch.MixinBootstrap;
import org.spongepowered.asm.mixin.Mixins;
@ -11,6 +14,8 @@ import us.myles.ViaVersion.api.Via;
public class ViaRift implements InitializationListener {
public static int fakeServerVersion = 393; // TODO
public static final Logger LOGGER = LogManager.getLogger();
public static final java.util.logging.Logger JLOGGER = new JLoggerToLog4j(LOGGER);
@Override
public void onInitialization() {
MixinBootstrap.init();

View File

@ -1,5 +1,6 @@
package com.github.creeper123123321.viarift.platform;
import com.github.creeper123123321.viarift.ViaRift;
import com.github.creeper123123321.viarift.util.DelayedRunnable;
import com.github.creeper123123321.viarift.util.LoopRunnable;
import net.minecraft.client.Minecraft;
@ -19,7 +20,7 @@ import java.util.logging.Logger;
public class VRPlatform implements ViaPlatform {
@Override
public Logger getLogger() {
return Logger.getLogger("ViaRift");
return ViaRift.JLOGGER;
}
@Override

View File

@ -60,6 +60,6 @@ public class VRUserConnection extends UserConnection {
} catch (Exception e) {
e.printStackTrace();
}
return null;
return channel.newSucceededFuture();
}
}

View File

@ -0,0 +1,77 @@
package com.github.creeper123123321.viarift.util;
import java.util.logging.Level;
import java.util.logging.LogRecord;
import java.util.logging.Logger;
public class JLoggerToLog4j extends Logger {
private final org.apache.logging.log4j.Logger base;
public JLoggerToLog4j(org.apache.logging.log4j.Logger logger) {
super("logger", null);
this.base = logger;
}
public void log(LogRecord record) {
this.log(record.getLevel(), record.getMessage());
}
public void log(Level level, String msg) {
if (level == Level.FINE) {
this.base.debug(msg);
} else if (level == Level.WARNING) {
this.base.warn(msg);
} else if (level == Level.SEVERE) {
this.base.error(msg);
} else if (level == Level.INFO) {
this.base.info(msg);
} else {
this.base.trace(msg);
}
}
public void log(Level level, String msg, Object param1) {
if (level == Level.FINE) {
this.base.debug(msg, param1);
} else if (level == Level.WARNING) {
this.base.warn(msg, param1);
} else if (level == Level.SEVERE) {
this.base.error(msg, param1);
} else if (level == Level.INFO) {
this.base.info(msg, param1);
} else {
this.base.trace(msg, param1);
}
}
public void log(Level level, String msg, Object[] params) {
if (level == Level.FINE) {
this.base.debug(msg, params);
} else if (level == Level.WARNING) {
this.base.warn(msg, params);
} else if (level == Level.SEVERE) {
this.base.error(msg, params);
} else if (level == Level.INFO) {
this.base.info(msg, params);
} else {
this.base.trace(msg, params);
}
}
public void log(Level level, String msg, Throwable params) {
if (level == Level.FINE) {
this.base.debug(msg, params);
} else if (level == Level.WARNING) {
this.base.warn(msg, params);
} else if (level == Level.SEVERE) {
this.base.error(msg, params);
} else if (level == Level.INFO) {
this.base.info(msg, params);
} else {
this.base.trace(msg, params);
}
}
}