mirror of
https://github.com/GTMEGA/EndlessIDs.git
synced 2026-11-17 18:05:05 +00:00
61 lines
1.7 KiB
Java
61 lines
1.7 KiB
Java
package com.falsepattern.endlessids.patching;
|
|
|
|
import com.falsepattern.endlessids.EndlessIDs;
|
|
import com.falsepattern.endlessids.patching.patches.common.Futurepack;
|
|
import com.falsepattern.endlessids.patching.patches.common.Tropicraft;
|
|
import lombok.SneakyThrows;
|
|
import lombok.val;
|
|
|
|
import cpw.mods.fml.common.Loader;
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.List;
|
|
|
|
public class CommonManager {
|
|
protected final List<Patch> patches = new ArrayList<>();
|
|
|
|
public CommonManager() {
|
|
patches.add(new Tropicraft());
|
|
patches.add(new Futurepack());
|
|
}
|
|
|
|
@SneakyThrows
|
|
public final void construct() {
|
|
runPatches("construct", Patch::construct);
|
|
}
|
|
|
|
@SneakyThrows
|
|
public final void preInit() {
|
|
runPatches("preInit", Patch::preInit);
|
|
}
|
|
|
|
@SneakyThrows
|
|
public final void init() {
|
|
runPatches("init", Patch::init);
|
|
}
|
|
|
|
@SneakyThrows
|
|
public final void postInit() {
|
|
runPatches("postInit", Patch::postInit);
|
|
}
|
|
|
|
private void runPatches(String stageName, Stage stage) throws Exception {
|
|
for (val patch : patches) {
|
|
if (Loader.isModLoaded(patch.modid)) {
|
|
try {
|
|
if (stage.run(patch)) {
|
|
EndlessIDs.LOG.info("Applied patch " + patch.getClass().getSimpleName() + " stage " + stageName + " for " + patch.modid);
|
|
}
|
|
} catch (Exception e) {
|
|
EndlessIDs.LOG.fatal("Failed to apply patch " + patch.getClass().getSimpleName() + " stage " + stageName + " for " + patch.modid);
|
|
throw e;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
public interface Stage {
|
|
boolean run(Patch patch) throws Exception;
|
|
}
|
|
}
|