fix a crash, display commit at startup
All checks were successful
/ Build BaseBand (push) Successful in 2m43s
/ Build BaseBand Loader (push) Successful in 1m53s

This commit is contained in:
Daniella / Tove 2024-10-06 05:46:59 +02:00
parent d17dec15b2
commit ed5e463141
Signed by: TudbuT
GPG key ID: B3CF345217F202D3
4 changed files with 19 additions and 11 deletions

View file

@ -17,7 +17,6 @@ import de.com.baseband.client.util.net.WebServiceClient;
import de.com.baseband.client.util.render.NotificationRender;
import de.com.baseband.prod.LoadHandler;
import de.tudbut.tools.Lock;
import de.tudbut.tools.Tools;
import hint.Mobf;
import net.minecraft.client.Minecraft;
import net.minecraftforge.common.MinecraftForge;
@ -33,7 +32,7 @@ public class BaseBand {
public static final Logger LOGGER = LogManager.getLogger("BaseBand");
public static final SecureRandom RANDOM = new SecureRandom();
public static String buildString = Tools.firstNonNull(LoadHandler.data.getString("build-name"), "Greenland");
public static String buildString = LoadHandler.data.getString("build-name");
public static final EventBus EVENT_BUS = new EventBus(Throwable::printStackTrace);
public static final RemoteEventBus REMOTE_EVENT_BUS = new RemoteEventBus();
public static final StaticEventHandler STATIC_EVENT_HANDLER = new StaticEventHandler();

View file

@ -28,8 +28,10 @@ public class DevStub implements IFMLLoadingPlugin {
@Mod.EventHandler
public void onInit(FMLPostInitializationEvent event) {
LOGGER.info("Booting BaseBand Greenland...");
if(LoadHandler.data.map.get("username") != null)
throw new IllegalStateException();
LoadHandler.data.set("build-name", "Greenland");
LoadHandler.data.set("ip", "baseband.com.de");
LoadHandler.data.set("branch", "[dev]");
LoadHandler.data.set("allowed-branches", new TCNArray());

View file

@ -16,7 +16,7 @@ import java.util.Queue;
public class PacketCounter extends Feature {
long totUp = 0, totDown = 0;
Queue<PacketTimestamp> up = new LinkedList<>(), down = new LinkedList<>();
final Queue<PacketTimestamp> up = new LinkedList<>(), down = new LinkedList<>();
@Config("Abbreviate")
@Description("Abbreviates numbers with ...K and ...M once they get too large.")
@ -51,11 +51,13 @@ public class PacketCounter extends Feature {
}
private void processQueue(Queue<PacketTimestamp> queue) {
while (!queue.isEmpty()) {
if(queue.peek().passed())
queue.remove();
else
break;
synchronized (queue) {
while (!queue.isEmpty()) {
if (queue.peek().passed())
queue.remove();
else
break;
}
}
}
@ -68,11 +70,15 @@ public class PacketCounter extends Feature {
public void onPacket(PacketEvent event) {
if(event instanceof PacketEvent.Send) {
totUp ++;
up.add(new PacketTimestamp());
synchronized (up) {
up.add(new PacketTimestamp());
}
}
if(event instanceof PacketEvent.Receive) {
totDown ++;
down.add(new PacketTimestamp());
synchronized (down) {
down.add(new PacketTimestamp());
}
}
}

View file

@ -288,7 +288,7 @@ public class Loader implements Util {
LOGGER.warn("No new BaseBand chunk has been downloaded in 2 seconds. Consider restarting your game.");
}
else if(System.currentTimeMillis() - lastUpdate >= 500) {
LOGGER.info("Downloading at {}KB/s...", (int) ((bytes.get() / 1024f) * (System.currentTimeMillis() - lastUpdate) / 1000f));
//LOGGER.info("Downloading at {}KB/s...", (int) ((bytes.get() / 1024f) * (System.currentTimeMillis() - lastUpdate) / 1000f));
lastUpdate = System.currentTimeMillis();
bytes.set(0);
}
@ -308,6 +308,7 @@ public class Loader implements Util {
continueDownload.waitHere();
}
LOGGER.info("BaseBand downloaded: {} chunks.", data.size());
LOGGER.info("Booting BaseBand {} @ {}", clientData.getString("build-name"), new String(data.get("commit")).trim());
classLoader = new CustomClassLoader(data);
downloadUpdated.unlock();
classLoader.inject();