Skip to content

Commit

Permalink
Update 1.2.44
Browse files Browse the repository at this point in the history
  • Loading branch information
Fox2Code committed May 22, 2024
1 parent 7e8570b commit 06b2d65
Show file tree
Hide file tree
Showing 8 changed files with 144 additions and 18 deletions.
8 changes: 4 additions & 4 deletions common/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ dependencies {
// TODO: Don't forget to update DependencyHelper and ":dev" project
api 'org.ow2.asm:asm-util:9.7'
api 'org.ow2.asm:asm-commons:9.7'
api 'org.semver4j:semver4j:5.2.2'
api 'org.semver4j:semver4j:5.3.0'
// api 'org.spongepowered:mixin:0.8.5'
api 'net.fabricmc:sponge-mixin:0.13.2+mixin.0.8.5' // <- https://maven.fabricmc.net/net/fabricmc/sponge-mixin/
api 'io.github.llamalad7:mixinextras-common:0.3.5' // <- https://github.com/LlamaLad7/MixinExtras/releases
api 'com.github.bawnorton.mixinsquared:mixinsquared-common:0.1.2-beta.5' // <- https://github.com/Bawnorton/MixinSquared/releases
api 'net.fabricmc:sponge-mixin:0.13.4+mixin.0.8.5' // <- https://maven.fabricmc.net/net/fabricmc/sponge-mixin/
api 'io.github.llamalad7:mixinextras-common:0.3.6' // <- https://github.com/LlamaLad7/MixinExtras/releases
api 'com.github.bawnorton.mixinsquared:mixinsquared-common:0.1.2-beta.6' // <- https://github.com/Bawnorton/MixinSquared/releases
api 'it.unimi.dsi:fastutil-core:8.5.13'

// Mixin dependencies
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -238,11 +238,13 @@ private static JsonElement getElementJsonObject(JsonObject jsonObject, String pa
int tmpIndex;
while ((tmpIndex = path.indexOf('.', index)) != -1) {
String subKey = path.substring(index, tmpIndex);
if (!directJsonObject.has(subKey)) return null;
if (directJsonObject == null || !directJsonObject.has(subKey)) {
return null;
}
directJsonObject = directJsonObject.getAsJsonObject(subKey);
index = tmpIndex + 1;
}
return directJsonObject.get(path.substring(index));
return directJsonObject == null ? null : directJsonObject.get(path.substring(index));
}

private static void setElementJsonObject(JsonObject jsonObject, String path, JsonElement jsonElement) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,17 @@ public class DependencyHelper {
new Dependency("org.ow2.asm:asm-commons:9.7", MAVEN_CENTRAL, "org.objectweb.asm.commons.InstructionAdapter"),
new Dependency("org.ow2.asm:asm-util:9.7", MAVEN_CENTRAL, "org.objectweb.asm.util.CheckClassAdapter"),
GSON_DEPENDENCY, new Dependency("com.google.guava:guava:21.0", MAVEN_CENTRAL, "com.google.common.io.Files"),
new Dependency("org.semver4j:semver4j:5.2.2", MAVEN_CENTRAL, "org.semver4j.Semver"),
new Dependency("org.semver4j:semver4j:5.3.0", MAVEN_CENTRAL, "org.semver4j.Semver"),
new Dependency("org.apache.commons:commons-lang3:3.3.2", MAVEN_CENTRAL, "org.apache.commons.lang3.tuple.Pair"),
new Dependency("org.luaj:luaj-jse:3.0.1", MAVEN_CENTRAL, "org.luaj.vm2.Globals"),
new Dependency("it.unimi.dsi:fastutil-core:8.5.12", MAVEN_CENTRAL, "it.unimi.dsi.fastutil.Pair"),
new Dependency("it.unimi.dsi:fastutil-core:8.5.13", MAVEN_CENTRAL, "it.unimi.dsi.fastutil.Pair"),
// new Dependency("org.spongepowered:mixin:0.8.5", SPONGE_POWERED, "org.spongepowered.asm.mixin.Mixins"),
new Dependency("net.fabricmc:sponge-mixin:0.13.2+mixin.0.8.5", FABRIC_MC, "org.spongepowered.asm.mixin.Mixins"),
new Dependency("io.github.llamalad7:mixinextras-common:0.3.5",
new Dependency("net.fabricmc:sponge-mixin:0.13.4+mixin.0.8.5", FABRIC_MC, "org.spongepowered.asm.mixin.Mixins"),
new Dependency("io.github.llamalad7:mixinextras-common:0.3.6",
MAVEN_CENTRAL, "com.llamalad7.mixinextras.MixinExtrasBootstrap"),
new Dependency("com.github.bawnorton.mixinsquared:mixinsquared-common:0.1.2-beta.5",
new Dependency("com.github.bawnorton.mixinsquared:mixinsquared-common:0.1.2-beta.6",
JITPACK, "com.bawnorton.mixinsquared.MixinSquaredBootstrap",
"https://github.com/Bawnorton/MixinSquared/releases/download/0.1.2-beta.5/mixinsquared-common-0.1.2-beta.5.jar"),
"https://github.com/Bawnorton/MixinSquared/releases/download/0.1.2-beta.6/mixinsquared-common-0.1.2-beta.6.jar"),
jFallback, // jFallback have special handling in dev plugin
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import com.fox2code.foxloader.registry.CommandCompat;
import com.fox2code.foxloader.registry.RegisteredEntity;
import com.fox2code.foxloader.registry.RegisteredItemStack;
import com.fox2code.foxloader.utils.WatchdogTimer;
import com.fox2code.jfallback.JFallbackClassLoader;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
Expand Down Expand Up @@ -516,21 +517,25 @@ public static void runOnPostInit(Runnable runnable) {
static final AsyncItrLinkedList<LifecycleListener> listeners = new AsyncItrLinkedList<>();

public static class Internal {
public static Properties fallbackTranslations = new Properties();
public static final Properties fallbackTranslations = new Properties();
public static final WatchdogTimer watchdogTimer = new WatchdogTimer(true);

public static void notifyOnTick() {
watchdogTimer.heartbeat();
for (ModContainer modContainer : modContainers.values()) {
modContainer.notifyOnTick();
}
}

public static void notifyOnServerStart(NetworkPlayer.ConnectionType connectionType) {
watchdogTimer.megaHeartbeat();
for (LifecycleListener lifecycleListener : listeners) {
lifecycleListener.onServerStart(connectionType);
}
}

public static void notifyOnServerStop(NetworkPlayer.ConnectionType connectionType) {
watchdogTimer.megaHeartbeat();
for (LifecycleListener lifecycleListener : listeners) {
lifecycleListener.onServerStop(connectionType);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
package com.fox2code.foxloader.utils;

import java.lang.ref.WeakReference;
import java.util.Map;
import java.util.concurrent.CopyOnWriteArrayList;

final class WatchdogThread extends Thread {
private static final long T1_SECONDS = 1000L;
private static final long T1_9_SECONDS = 1900L;
private static WatchdogThread watchdogThread;
private final CopyOnWriteArrayList<WeakReference<WatchdogTimer>> watchdogTimers;
private long lastStackDump;

private WatchdogThread() {
this.setDaemon(true);
this.setPriority(Thread.MIN_PRIORITY);
this.setName("FoxLoader - Watchdog Thread");
this.watchdogTimers = new CopyOnWriteArrayList<>();
this.lastStackDump = System.currentTimeMillis();
Runtime.getRuntime().addShutdownHook(new Thread(
this::interrupt, "FoxLoader - Watchdog Shutdown Thread"));
}

@Override
public void run() {
try {
boolean exit = false;
while (!(exit || this.isInterrupted())) {
//noinspection BusyWait
Thread.sleep(T1_SECONDS);
boolean needDump = false;
for (WeakReference<WatchdogTimer> watchdogTimerRef : this.watchdogTimers) {
WatchdogTimer watchdogTimer = watchdogTimerRef.get();
if (watchdogTimer != null && watchdogTimer.isEnabled()) {
long computingFor = watchdogTimer.getComputingFor();
if (computingFor / T1_SECONDS == 10L) {
needDump = true;
if (watchdogTimer.isEssential()) {
exit = true;
}
} else if (computingFor / T1_SECONDS == 5L) {
needDump = true;
}
}
}
if (needDump) {
doCompleteThreadDump(exit);
}
}
} catch (InterruptedException ignored) {}
}

static void registerTimer(WatchdogTimer watchdogTimer) {
if (watchdogThread == null) {
watchdogThread = new WatchdogThread();
watchdogThread.start();
}
watchdogThread.watchdogTimers.add(new WeakReference<>(watchdogTimer));
}

private void doCompleteThreadDump(boolean andExit) {
if (System.currentTimeMillis() - this.lastStackDump < T1_9_SECONDS && !andExit) return;
this.lastStackDump = System.currentTimeMillis();
System.out.println((andExit ? "Fatal freeze" : "Freeze") + " detected, creating stack dump:");
System.out.println();
for (Map.Entry<Thread, StackTraceElement[]> stackTrace : Thread.getAllStackTraces().entrySet()) {
Thread thread = stackTrace.getKey();
System.out.println(thread.getName() + " (Priority: " +
thread.getPriority() + (thread.isDaemon() ? ", Daemon)" : ")"));
for (StackTraceElement stackTraceElement : stackTrace.getValue()) {
System.out.println(" " + stackTraceElement.toString());
}
System.out.println();
}
if (andExit) {
System.exit(1);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package com.fox2code.foxloader.utils;

public final class WatchdogTimer {
private final boolean essential;
private volatile long lastCheck;
private volatile long megaLastCheck;
private boolean enabled;

public WatchdogTimer(boolean essential) {
WatchdogThread.registerTimer(this);
this.essential = essential;
this.lastCheck = 0;
this.megaHeartbeat();
this.enabled = true;
}

public boolean isEssential() {
return this.essential;
}

long getComputingFor() {
return this.lastCheck == 0 ? 0 : System.currentTimeMillis() - Math.max(this.lastCheck, this.megaLastCheck);
}

public void heartbeat() {
this.lastCheck = System.currentTimeMillis();
}

public void megaHeartbeat() {
this.megaLastCheck = System.currentTimeMillis() + 10000L;
}

public boolean isEnabled() {
return this.enabled;
}

public void setEnabled(boolean enabled) {
this.enabled = enabled;
}
}
2 changes: 1 addition & 1 deletion dev/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ dependencies {
//compileOnly localGroovy()
api 'com.fox2code:JFallback:0.1.1'
api 'com.google.code.gson:gson:2.10.1'
api 'org.semver4j:semver4j:5.2.2'
api 'org.semver4j:semver4j:5.3.0'
api 'org.ow2.asm:asm-commons:9.7'
api 'org.ow2.asm:asm-util:9.7'
// Need LWJGL 2 for game decompilation.
Expand Down
8 changes: 4 additions & 4 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ org.gradle.parallel=true
org.gradle.jvmargs=-Xmx1024m -XX:-UseGCOverheadLimit -Dfile.encoding=UTF-8

# FoxLoader properties
foxloader.version=1.2.43
foxloader.version=1.2.44
foxloader.lastReIndevTransformerChanges=1.2.39
# https://www.jitpack.io/#com.fox2code/FoxLoader

Expand All @@ -18,8 +18,8 @@ reindev.version=2.8.1_5
reindev.version.allowFrom=2.8.1_4

#Spark properties
spark.dependency=maven.modrinth:spark:1.10.58-fabric
spark.version=1.10.58
spark.dependency=maven.modrinth:spark:1.10.65-fabric
spark.version=1.10.65

#VineFlower properties
vineflower.dependency=org.vineflower:vineflower:1.10.0
vineflower.dependency=org.vineflower:vineflower:1.10.1

0 comments on commit 06b2d65

Please sign in to comment.