Update for 1.18
This commit is contained in:
parent
ef69704922
commit
d317e23c42
@ -1,32 +1,2 @@
|
|||||||
image: gradle:jdk17
|
include:
|
||||||
|
- remote: 'https://jfmods.gitlab.io/scripts/jfmod.yml'
|
||||||
variables:
|
|
||||||
GRADLE_OPTS: "-Dorg.gradle.daemon=false"
|
|
||||||
|
|
||||||
before_script:
|
|
||||||
- export GRADLE_USER_HOME=`pwd`/.gradle
|
|
||||||
|
|
||||||
stages:
|
|
||||||
- build
|
|
||||||
- deploy
|
|
||||||
|
|
||||||
build_test:
|
|
||||||
stage: build
|
|
||||||
script:
|
|
||||||
- gradle --build-cache build
|
|
||||||
- cp build/libs/* ./
|
|
||||||
- mv *-dev.jar dev.zip
|
|
||||||
- mv *.jar latest.jar
|
|
||||||
- mv dev.zip latest-dev.jar
|
|
||||||
artifacts:
|
|
||||||
paths:
|
|
||||||
- build/libs
|
|
||||||
- latest.jar
|
|
||||||
- latest-dev.jar
|
|
||||||
|
|
||||||
deploy:
|
|
||||||
rules:
|
|
||||||
- if: $CI_COMMIT_TAG && '$CI_MERGE_REQUEST_SOURCE_BRANCH_NAME =~ /^master/'
|
|
||||||
stage: deploy
|
|
||||||
script:
|
|
||||||
- gradle --build-cache build curseforge modrinth
|
|
||||||
|
20
build.gradle
20
build.gradle
@ -1,22 +1,6 @@
|
|||||||
apply from: "https://gitlab.com/-/snippets/2121059/raw/master/jfbase.gradle"
|
apply from: "https://jfmods.gitlab.io/scripts/jfmod.gradle"
|
||||||
|
|
||||||
repositories {
|
|
||||||
maven {
|
|
||||||
name = 'TerraformersMC'
|
|
||||||
url = 'https://maven.terraformersmc.com/'
|
|
||||||
}
|
|
||||||
maven {
|
|
||||||
url "https://gitlab.com/api/v4/projects/25805200/packages/maven"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
//to change the versions see the gradle.properties file
|
|
||||||
minecraft "com.mojang:minecraft:${project.minecraft_version}"
|
|
||||||
mappings "net.fabricmc:yarn:${project.minecraft_version}+${project.yarn_mappings}:v2"
|
|
||||||
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"
|
|
||||||
|
|
||||||
// Fabric API. This is technically optional, but you probably want it anyway.
|
|
||||||
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
|
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
|
||||||
|
|
||||||
include modImplementation("io.gitlab.jfronny.libjf:libjf-web-v0:${project.jfapi_version}")
|
include modImplementation("io.gitlab.jfronny.libjf:libjf-web-v0:${project.jfapi_version}")
|
||||||
@ -24,5 +8,5 @@ dependencies {
|
|||||||
include("io.gitlab.jfronny.libjf:libjf-unsafe-v0:${project.jfapi_version}")
|
include("io.gitlab.jfronny.libjf:libjf-unsafe-v0:${project.jfapi_version}")
|
||||||
include("io.gitlab.jfronny.libjf:libjf-base:${project.jfapi_version}")
|
include("io.gitlab.jfronny.libjf:libjf-base:${project.jfapi_version}")
|
||||||
|
|
||||||
modImplementation "com.terraformersmc:modmenu:2.0.7"
|
modImplementation "com.terraformersmc:modmenu:3.0.0"
|
||||||
}
|
}
|
||||||
|
@ -2,20 +2,17 @@
|
|||||||
org.gradle.jvmargs=-Xmx1G
|
org.gradle.jvmargs=-Xmx1G
|
||||||
# Fabric Properties
|
# Fabric Properties
|
||||||
# check these on https://fabricmc.net/versions.html
|
# check these on https://fabricmc.net/versions.html
|
||||||
minecraft_version=1.17.1
|
minecraft_version=1.18
|
||||||
yarn_mappings=build.63
|
yarn_mappings=build.1
|
||||||
loader_version=0.12.5
|
loader_version=0.12.6
|
||||||
# Mod Properties
|
# Mod Properties
|
||||||
mod_version=1.1.2
|
|
||||||
maven_group=io.gitlab.jfronny
|
maven_group=io.gitlab.jfronny
|
||||||
archives_base_name=dynres
|
archives_base_name=dynres
|
||||||
#Dependencies
|
#Dependencies
|
||||||
fabric_version=0.42.1+1.17
|
fabric_version=0.43.1+1.18
|
||||||
jfapi_version=2.1.3-406390708
|
jfapi_version=2.2.0
|
||||||
|
|
||||||
modrinth_id=v3lfX2LD
|
modrinth_id=v3lfX2LD
|
||||||
modrinth_required_dependencies=dOW0jmMj
|
modrinth_optional_dependencies=JPP6w2U1
|
||||||
modrinth_optional_dependencies=wRE7Emzz
|
|
||||||
curseforge_id=407012
|
curseforge_id=407012
|
||||||
curseforge_required_dependencies=libjf
|
|
||||||
curseforge_optional_dependencies=modmenu
|
curseforge_optional_dependencies=modmenu
|
||||||
|
@ -4,30 +4,32 @@ import io.gitlab.jfronny.libjf.web.api.WebInit;
|
|||||||
import io.gitlab.jfronny.libjf.web.api.WebServer;
|
import io.gitlab.jfronny.libjf.web.api.WebServer;
|
||||||
import net.fabricmc.api.EnvType;
|
import net.fabricmc.api.EnvType;
|
||||||
import net.fabricmc.loader.api.FabricLoader;
|
import net.fabricmc.loader.api.FabricLoader;
|
||||||
import net.fabricmc.loader.impl.gui.FabricGuiEntry;
|
|
||||||
import org.apache.logging.log4j.LogManager;
|
import org.apache.logging.log4j.LogManager;
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.FileNotFoundException;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Path;
|
||||||
|
|
||||||
public class DynRes implements WebInit {
|
public class DynRes implements WebInit {
|
||||||
public static final org.apache.logging.log4j.Logger LOGGER = LogManager.getLogger("DynRes");
|
public static final org.apache.logging.log4j.Logger LOGGER = LogManager.getLogger("DynRes");
|
||||||
public static File resFile;
|
public static Path resFile;
|
||||||
public static String resourceLink = "";
|
public static String resourceLink = "";
|
||||||
|
|
||||||
static {
|
static {
|
||||||
resFile = new File(FabricLoader.getInstance().getGameDir().toFile(), Cfg.resourcesFile);
|
resFile = FabricLoader.getInstance().getGameDir().resolve(Cfg.resourcesFile);
|
||||||
if (!resFile.isFile()) {
|
if (!Files.exists(resFile)) {
|
||||||
FabricGuiEntry.displayCriticalError(new FileNotFoundException("The file " + resFile + " does not exist in the game directory but is required"), true);
|
if (FabricLoader.getInstance().getEnvironmentType() == EnvType.SERVER) {
|
||||||
|
LOGGER.error("The resource file specified in your config could not be found. YOU MUST SPECIFY A RESOURCE PACK FOR IT TO BE SERVED!", new Exception("File not found"));
|
||||||
|
}
|
||||||
|
resFile = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void register(WebServer api) {
|
public void register(WebServer api) {
|
||||||
if (FabricLoader.getInstance().getEnvironmentType() == EnvType.SERVER) {
|
if (FabricLoader.getInstance().getEnvironmentType() == EnvType.SERVER && resFile != null) {
|
||||||
try {
|
try {
|
||||||
resourceLink = api.registerFile("/resources.zip", resFile.toPath(), !Cfg.hashResources);
|
resourceLink = api.registerFile("/resources.zip", resFile, !Cfg.hashResources);
|
||||||
LOGGER.info("Initialized DynRes at " + resourceLink);
|
LOGGER.info("Initialized DynRes at " + resourceLink);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
@ -1,5 +0,0 @@
|
|||||||
package io.gitlab.jfronny.dynres;
|
|
||||||
|
|
||||||
public interface ServerPropertiesHandlerExt {
|
|
||||||
void applyChanges(boolean print);
|
|
||||||
}
|
|
@ -2,9 +2,7 @@ package io.gitlab.jfronny.dynres.mixin;
|
|||||||
|
|
||||||
import io.gitlab.jfronny.dynres.Cfg;
|
import io.gitlab.jfronny.dynres.Cfg;
|
||||||
import io.gitlab.jfronny.dynres.DynRes;
|
import io.gitlab.jfronny.dynres.DynRes;
|
||||||
import io.gitlab.jfronny.dynres.ServerPropertiesHandlerExt;
|
|
||||||
import io.gitlab.jfronny.libjf.web.api.WebServer;
|
import io.gitlab.jfronny.libjf.web.api.WebServer;
|
||||||
import io.gitlab.jfronny.libjf.web.impl.JfWeb;
|
|
||||||
import io.gitlab.jfronny.libjf.web.impl.util.WebPaths;
|
import io.gitlab.jfronny.libjf.web.impl.util.WebPaths;
|
||||||
import net.minecraft.server.dedicated.ServerPropertiesHandler;
|
import net.minecraft.server.dedicated.ServerPropertiesHandler;
|
||||||
import org.apache.commons.codec.digest.DigestUtils;
|
import org.apache.commons.codec.digest.DigestUtils;
|
||||||
@ -16,37 +14,31 @@ import org.spongepowered.asm.mixin.injection.At;
|
|||||||
import org.spongepowered.asm.mixin.injection.Inject;
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||||
|
|
||||||
import java.io.FileInputStream;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
|
||||||
@Mixin(ServerPropertiesHandler.class)
|
@Mixin(ServerPropertiesHandler.class)
|
||||||
public class ServerPropertiesHandlerMixin implements ServerPropertiesHandlerExt {
|
public class ServerPropertiesHandlerMixin {
|
||||||
@Mutable @Final @Shadow public String resourcePackHash;
|
@Mutable @Final @Shadow public String resourcePackHash;
|
||||||
@Mutable @Final @Shadow public String resourcePackSha1;
|
@Mutable @Final @Shadow public String resourcePackSha1;
|
||||||
@Mutable @Final @Shadow public String resourcePack;
|
@Mutable @Final @Shadow public String resourcePack;
|
||||||
|
|
||||||
@Inject(at = @At("RETURN"), method = "<init>(Ljava/util/Properties;)V")
|
@Inject(at = @At("RETURN"), method = "<init>(Ljava/util/Properties;)V")
|
||||||
public void init(CallbackInfo info) {
|
public void init(CallbackInfo info) {
|
||||||
applyChanges(true);
|
if (DynRes.resFile != null) {
|
||||||
}
|
resourcePack = WebPaths.concat(WebServer.getInstance().getServerRoot(), "resources.zip");
|
||||||
|
|
||||||
@Override
|
|
||||||
public void applyChanges(boolean print) {
|
|
||||||
resourcePack = WebPaths.concat(WebServer.getInstance().getServerRoot(), "resources.zip");
|
|
||||||
if (print)
|
|
||||||
DynRes.LOGGER.info("Pack link: " + resourcePack);
|
DynRes.LOGGER.info("Pack link: " + resourcePack);
|
||||||
resourcePackSha1 = "";
|
resourcePackSha1 = "";
|
||||||
if (Cfg.hashResources) {
|
if (Cfg.hashResources) {
|
||||||
try {
|
try (InputStream fs = Files.newInputStream(DynRes.resFile)) {
|
||||||
FileInputStream fs = new FileInputStream(DynRes.resFile);
|
resourcePackSha1 = DigestUtils.sha1Hex(fs);
|
||||||
resourcePackSha1 = DigestUtils.sha1Hex(fs);
|
|
||||||
if (print)
|
|
||||||
DynRes.LOGGER.info("Set hash to " + resourcePackSha1);
|
DynRes.LOGGER.info("Set hash to " + resourcePackSha1);
|
||||||
fs.close();
|
} catch (IOException e) {
|
||||||
} catch (IOException e) {
|
DynRes.LOGGER.error("Failed to get hash, continuing with empty", e);
|
||||||
DynRes.LOGGER.error("Failed to get hash, continuing with empty", e);
|
}
|
||||||
}
|
}
|
||||||
|
resourcePackHash = resourcePackSha1;
|
||||||
}
|
}
|
||||||
resourcePackHash = resourcePackSha1;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
"required": true,
|
"required": true,
|
||||||
"minVersion": "0.8",
|
"minVersion": "0.8",
|
||||||
"package": "io.gitlab.jfronny.dynres.mixin",
|
"package": "io.gitlab.jfronny.dynres.mixin",
|
||||||
"compatibilityLevel": "JAVA_8",
|
"compatibilityLevel": "JAVA_17",
|
||||||
"client": [
|
"client": [
|
||||||
"ClientPlayNetworkHandlerMixin",
|
"ClientPlayNetworkHandlerMixin",
|
||||||
"ServerInfoMixin"
|
"ServerInfoMixin"
|
||||||
|
Loading…
Reference in New Issue
Block a user