mirror of
https://github.com/ViaVersion/ViaFabric.git
synced 2024-11-21 11:35:16 +01:00
Add ViaRift name on thread, print exceptions
This commit is contained in:
parent
dec421ff61
commit
5ed38fbd5b
@ -30,6 +30,7 @@ import com.github.creeper123123321.viarift.platform.VRPlatform;
|
||||
import com.github.creeper123123321.viarift.util.JLoggerToLog4j;
|
||||
import io.netty.channel.DefaultEventLoop;
|
||||
import io.netty.channel.EventLoop;
|
||||
import net.minecraft.util.NamedThreadFactory;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.dimdev.riftloader.listener.InitializationListener;
|
||||
@ -38,11 +39,16 @@ import org.spongepowered.asm.mixin.Mixins;
|
||||
import us.myles.ViaVersion.ViaManager;
|
||||
import us.myles.ViaVersion.api.Via;
|
||||
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.concurrent.ThreadFactory;
|
||||
|
||||
public class ViaRift implements InitializationListener {
|
||||
public static int fakeServerVersion = -1;
|
||||
public static final Logger LOGGER = LogManager.getLogger();
|
||||
public static final java.util.logging.Logger JLOGGER = new JLoggerToLog4j(LOGGER);
|
||||
public static final EventLoop EVENT_LOOP = new DefaultEventLoop();
|
||||
public static final ThreadFactory THREAD_FACTORY = new NamedThreadFactory("ViaRift");
|
||||
public static final EventLoop EVENT_LOOP = new DefaultEventLoop(THREAD_FACTORY);
|
||||
@Override
|
||||
public void onInitialization() {
|
||||
MixinBootstrap.init();
|
||||
|
@ -68,24 +68,36 @@ public class VRPlatform implements ViaPlatform {
|
||||
|
||||
@Override
|
||||
public TaskId runAsync(Runnable runnable) {
|
||||
Thread t = new Thread(runnable, "ViaRift Async Task");
|
||||
Thread t = ViaRift.THREAD_FACTORY.newThread(runnable);
|
||||
t.start();
|
||||
return new ThreadTaskId(t);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TaskId runSync(Runnable runnable) {
|
||||
return new FutureTaskId(ViaRift.EVENT_LOOP.submit(runnable));
|
||||
return new FutureTaskId(ViaRift.EVENT_LOOP.submit(runnable).addListener(future -> {
|
||||
if (!future.isSuccess()) {
|
||||
future.cause().printStackTrace();
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
@Override
|
||||
public TaskId runSync(Runnable runnable, Long ticks) {
|
||||
return new FutureTaskId(ViaRift.EVENT_LOOP.schedule(runnable, ticks * 50, TimeUnit.SECONDS));
|
||||
return new FutureTaskId(ViaRift.EVENT_LOOP.schedule(runnable, ticks * 50, TimeUnit.SECONDS).addListener(future -> {
|
||||
if (!future.isSuccess()) {
|
||||
future.cause().printStackTrace();
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
@Override
|
||||
public TaskId runRepeatingSync(Runnable runnable, Long ticks) {
|
||||
return new FutureTaskId(ViaRift.EVENT_LOOP.scheduleAtFixedRate(runnable, 0, ticks * 50, TimeUnit.SECONDS));
|
||||
return new FutureTaskId(ViaRift.EVENT_LOOP.scheduleAtFixedRate(runnable, 0, ticks * 50, TimeUnit.SECONDS).addListener(future -> {
|
||||
if (!future.isSuccess()) {
|
||||
future.cause().printStackTrace();
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Loading…
Reference in New Issue
Block a user