Compare commits

...

10 Commits

Author SHA1 Message Date
Johannes Frohnmeyer 449a54bc64
chore: update to 1.20.5
ci/woodpecker/push/jfmod Pipeline was successful Details
ci/woodpecker/tag/jfmod Pipeline was successful Details
2024-04-25 19:46:53 +02:00
Johannes Frohnmeyer 25e99adc33
chore: update to 1.20.4
ci/woodpecker/push/jfmod Pipeline failed Details
2023-12-07 20:51:27 +01:00
Johannes Frohnmeyer 715504d4d5
fix: mix into proper class for client
ci/woodpecker/push/jfmod Pipeline was successful Details
2023-09-22 21:12:55 +02:00
Johannes Frohnmeyer 7af7faa24d
chore: update to 1.20.2
ci/woodpecker/push/jfmod Pipeline failed Details
2023-09-22 20:59:35 +02:00
Johannes Frohnmeyer 2fc3da9b78
chore: bump dependencies 2023-08-30 11:01:18 +02:00
Johannes Frohnmeyer 96ce0801ad
Bump to 1.20
ci/woodpecker/push/jfmod Pipeline was successful Details
ci/woodpecker/tag/jfmod Pipeline was successful Details
2023-06-09 17:49:54 +02:00
Johannes Frohnmeyer b46790d6a3
Bump to 1.19.4
ci/woodpecker/push/jfmod Pipeline failed Details
ci/woodpecker/tag/jfmod Pipeline was successful Details
2023-03-14 21:44:11 +01:00
Johannes Frohnmeyer ec5d2d4908
Use new config compiler
ci/woodpecker/push/jfmod Pipeline was successful Details
2022-12-29 14:28:23 +01:00
Johannes Frohnmeyer cf3bbdcd1b
Update to 1.19.3
ci/woodpecker/push/jfmod Pipeline was successful Details
ci/woodpecker/tag/jfmod Pipeline was successful Details
2022-12-07 22:43:11 +01:00
Johannes Frohnmeyer e831f8fe01
Update to new infrastructure
ci/woodpecker/manual/jfmod Pipeline was successful Details
2022-12-02 17:47:39 +01:00
14 changed files with 130 additions and 109 deletions

View File

@ -1,2 +0,0 @@
include:
- remote: 'https://jfmods.gitlab.io/scripts/jfmod.yml'

1
.woodpecker.yml Normal file
View File

@ -0,0 +1 @@
#link https://pages.frohnmeyer-wds.de/scripts/jfmod.yml

View File

@ -1,10 +0,0 @@
apply from: "https://jfmods.gitlab.io/scripts/gradle/v2.gradle"
dependencies {
modImplementation("io.gitlab.jfronny.libjf:libjf-web-v0:${project.libjf_version}")
modImplementation("io.gitlab.jfronny.libjf:libjf-config-core-v1:${project.libjf_version}")
// Dev env
modLocalRuntime("io.gitlab.jfronny.libjf:libjf-config-reflect-v1:${project.libjf_version}")
modLocalRuntime("com.terraformersmc:modmenu:4.0.6")
}

38
build.gradle.kts Normal file
View File

@ -0,0 +1,38 @@
plugins {
id("jfmod") version "1.6-SNAPSHOT"
}
allprojects { group = "io.gitlab.jfronny" }
base.archivesName = "dynres"
jfMod {
minecraftVersion = "1.20.5"
yarn("build.1")
loaderVersion = "0.15.10"
libJfVersion = "3.15.4"
fabricApiVersion = "0.97.6+1.20.5"
modrinth {
projectId = "dynres"
requiredDependencies.add("libjf")
optionalDependencies.add("modmenu")
}
curseforge {
projectId = "407012"
requiredDependencies.add("libjf")
optionalDependencies.add("modmenu")
}
}
dependencies {
modImplementation("io.gitlab.jfronny.libjf:libjf-web-v1")
modImplementation("io.gitlab.jfronny.libjf:libjf-config-core-v2")
// Dev env
modLocalRuntime("com.terraformersmc:modmenu:10.0.0-beta.1")
// for modmenu
modLocalRuntime("net.fabricmc.fabric-api:fabric-resource-loader-v0")
modLocalRuntime("net.fabricmc.fabric-api:fabric-screen-api-v1")
modLocalRuntime("net.fabricmc.fabric-api:fabric-key-binding-api-v1")
}

View File

@ -1,16 +0,0 @@
# check these on https://fabricmc.net/develop/
minecraft_version=1.19.2
yarn_mappings=build.8
loader_version=0.14.9
maven_group=io.gitlab.jfronny
archives_base_name=dynres
fabric_version=0.60.0+1.19.2
libjf_version=3.0.2
modrinth_id=dynres
modrinth_required_dependencies=libjf
modrinth_optional_dependencies=modmenu
curseforge_id=407012
curseforge_required_dependencies=libjf
curseforge_optional_dependencies=modmenu

9
settings.gradle.kts Normal file
View File

@ -0,0 +1,9 @@
pluginManagement {
repositories {
maven("https://maven.fabricmc.net/") // FabricMC
maven("https://maven.frohnmeyer-wds.de/artifacts") // scripts
gradlePluginPortal()
}
}
rootProject.name = "dynres"

View File

@ -0,0 +1,33 @@
package io.gitlab.jfronny.dynres.mixin;
import io.gitlab.jfronny.dynres.DynRes;
import net.minecraft.client.network.ClientCommonNetworkHandler;
import net.minecraft.network.packet.c2s.common.ResourcePackStatusC2SPacket;
import net.minecraft.network.packet.s2c.common.ResourcePackSendS2CPacket;
import org.jetbrains.annotations.Nullable;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.*;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import java.net.URL;
@Mixin(ClientCommonNetworkHandler.class)
public abstract class ClientCommonNetworkHandlerMixin {
@Shadow @Nullable protected static URL getParsedResourcePackUrl(String url) {
throw new RuntimeException("Mixin not applied");
}
@Inject(at = @At("HEAD"), method = "onResourcePackSend(Lnet/minecraft/network/packet/s2c/common/ResourcePackSendS2CPacket;)V")
public void logResourcePackStatus(ResourcePackSendS2CPacket status, CallbackInfo info) {
DynRes.LOGGER.info("[RECEIVE] ResourcePackUrl={0}", status.url());
DynRes.LOGGER.info("[RECEIVE] ResourcePackHash={0}", status.hash());
}
@Redirect(method = "onResourcePackSend(Lnet/minecraft/network/packet/s2c/common/ResourcePackSendS2CPacket;)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientCommonNetworkHandler;getParsedResourcePackUrl(Ljava/lang/String;)Ljava/net/URL;"))
public URL logResourcePackStatus(String url) {
URL res = getParsedResourcePackUrl(url);
DynRes.LOGGER.info("[CHECK] ResourcePackUrlValid={0}", res != null);
return res;
}
}

View File

@ -1,38 +0,0 @@
package io.gitlab.jfronny.dynres.mixin;
import io.gitlab.jfronny.dynres.*;
import net.minecraft.client.network.*;
import net.minecraft.network.packet.c2s.play.*;
import net.minecraft.network.packet.s2c.play.*;
import org.jetbrains.annotations.*;
import org.spongepowered.asm.mixin.*;
import org.spongepowered.asm.mixin.injection.*;
import org.spongepowered.asm.mixin.injection.callback.*;
import java.net.*;
@Mixin(ClientPlayNetworkHandler.class)
public abstract class ClientPlayNetworkHandlerMixin {
@Shadow @Nullable
private static URL resolveUrl(String url) {
throw new RuntimeException("Mixin not applied");
}
@Inject(at = @At("HEAD"), method = "sendResourcePackStatus(Lnet/minecraft/network/packet/c2s/play/ResourcePackStatusC2SPacket$Status;)V")
public void logSentResourcePackStatus(ResourcePackStatusC2SPacket.Status packStatus, CallbackInfo info) {
DynRes.LOGGER.info("[SEND] ResourcePackStatus=" + packStatus);
}
@Inject(at = @At("HEAD"), method = "onResourcePackSend(Lnet/minecraft/network/packet/s2c/play/ResourcePackSendS2CPacket;)V")
public void logResourcePackStatus(ResourcePackSendS2CPacket status, CallbackInfo info) {
DynRes.LOGGER.info("[RECEIVE] ResourcePackUrl=" + status.getURL());
DynRes.LOGGER.info("[RECEIVE] ResourcePackSha1=" + status.getSHA1());
}
@Redirect(method = "onResourcePackSend(Lnet/minecraft/network/packet/s2c/play/ResourcePackSendS2CPacket;)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayNetworkHandler;resolveUrl(Ljava/lang/String;)Ljava/net/URL;"))
public URL logResourcePackStatus(String url) {
URL res = resolveUrl(url);
DynRes.LOGGER.info("[CHECK] ResourcePackUrlValid=" + (res != null));
return res;
}
}

View File

@ -11,6 +11,6 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
public class ServerInfoMixin {
@Inject(at = @At("RETURN"), method = "getResourcePackPolicy()Lnet/minecraft/client/network/ServerInfo$ResourcePackPolicy;")
public void getResPackState(CallbackInfoReturnable<ServerInfo.ResourcePackPolicy> info) {
DynRes.LOGGER.info("[RECEIVE] ResourcePackStatus=" + info.getReturnValue());
DynRes.LOGGER.info("[RECEIVE] ResourcePackStatus={0}", info.getReturnValue());
}
}

View File

@ -4,7 +4,7 @@
"package": "io.gitlab.jfronny.dynres.mixin",
"compatibilityLevel": "JAVA_17",
"client": [
"ClientPlayNetworkHandlerMixin",
"ClientCommonNetworkHandlerMixin",
"ServerInfoMixin"
],
"injectors": {

View File

@ -1,10 +1,14 @@
package io.gitlab.jfronny.dynres;
import io.gitlab.jfronny.libjf.config.api.v1.Entry;
import io.gitlab.jfronny.libjf.config.api.v1.JfConfig;
import io.gitlab.jfronny.libjf.config.api.v2.Entry;
import io.gitlab.jfronny.libjf.config.api.v2.JfConfig;
@JfConfig
@JfConfig(referencedConfigs = "libjf-web-v0")
public class Cfg {
@Entry public static String resourcesFile = "resources.zip";
@Entry public static boolean hashResources = false;
static {
JFC_Cfg.ensureInitialized();
}
}

View File

@ -1,18 +1,16 @@
package io.gitlab.jfronny.dynres;
import io.gitlab.jfronny.libjf.web.api.WebInit;
import io.gitlab.jfronny.libjf.web.api.WebServer;
import io.gitlab.jfronny.commons.logger.SystemLoggerPlus;
import io.gitlab.jfronny.libjf.web.api.v1.*;
import net.fabricmc.api.EnvType;
import net.fabricmc.loader.api.FabricLoader;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
public class DynRes implements WebInit {
public static final Logger LOGGER = LoggerFactory.getLogger("DynRes");
public class DynRes implements WebEntrypoint {
public static final SystemLoggerPlus LOGGER = SystemLoggerPlus.forName("DynRes");
public static Path packFile;
public static String packUrl = "";
@ -30,10 +28,10 @@ public class DynRes implements WebInit {
public void register(WebServer api) {
if (FabricLoader.getInstance().getEnvironmentType() == EnvType.SERVER && packFile != null) {
try {
packUrl = api.registerFile("/resources.zip", packFile, !Cfg.hashResources);
LOGGER.info("Initialized DynRes at " + packUrl);
packUrl = api.registerFile(PathSegment.of("resources.zip"), packFile, !Cfg.hashResources);
LOGGER.info("Initialized DynRes at {0}", packUrl);
} catch (IOException e) {
e.printStackTrace();
LOGGER.error("Could not register DynRes resource pack", e);
}
}
}

View File

@ -1,20 +1,26 @@
package io.gitlab.jfronny.dynres.mixin;
import io.gitlab.jfronny.dynres.*;
import io.gitlab.jfronny.libjf.web.api.*;
import io.gitlab.jfronny.libjf.web.impl.util.*;
import net.minecraft.server.*;
import net.minecraft.server.dedicated.*;
import net.minecraft.text.*;
import org.jetbrains.annotations.*;
import org.spongepowered.asm.mixin.*;
import org.spongepowered.asm.mixin.injection.*;
import org.spongepowered.asm.mixin.injection.callback.*;
import io.gitlab.jfronny.dynres.Cfg;
import io.gitlab.jfronny.dynres.DynRes;
import io.gitlab.jfronny.libjf.web.api.v1.WebServer;
import io.gitlab.jfronny.libjf.web.impl.util.WebPaths;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.dedicated.ServerPropertiesHandler;
import net.minecraft.text.Text;
import org.jetbrains.annotations.Nullable;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import java.io.*;
import java.nio.file.*;
import java.security.*;
import java.util.*;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.Optional;
import java.util.UUID;
@Mixin(ServerPropertiesHandler.class)
public abstract class ServerPropertiesHandlerMixin {
@ -23,8 +29,8 @@ public abstract class ServerPropertiesHandlerMixin {
throw new IllegalStateException("Mixin not applied");
}
@Inject(method = "getServerResourcePackProperties(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ZLjava/lang/String;)Ljava/util/Optional;", at = @At("HEAD"), cancellable = true)
private static void getServerResourcePackProperties(String url, String sha1, @Nullable String hash, boolean required, String prompt, CallbackInfoReturnable<Optional<MinecraftServer.ServerResourcePackProperties>> cir) {
@Inject(method = "getServerResourcePackProperties(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ZLjava/lang/String;)Ljava/util/Optional;", at = @At("HEAD"), cancellable = true)
private static void getServerResourcePackProperties(String id, String url, String sha1, String hash, boolean required, String prompt, CallbackInfoReturnable<Optional<MinecraftServer.ServerResourcePackProperties>> cir) {
if (DynRes.packFile != null) {
sha1 = "";
if (Cfg.hashResources) {
@ -34,13 +40,15 @@ public abstract class ServerPropertiesHandlerMixin {
result.append(Integer.toString((b & 0xff) + 0x100, 16).substring(1));
}
sha1 = result.toString();
DynRes.LOGGER.info("Set hash to " + sha1);
DynRes.LOGGER.info("Set hash to {0}", sha1);
} catch (IOException | NoSuchAlgorithmException e) {
DynRes.LOGGER.error("Failed to get hash, continuing with empty", e);
}
}
url = WebPaths.concat(WebServer.getInstance().getServerRoot(), "resources.zip");
cir.setReturnValue(Optional.of(new MinecraftServer.ServerResourcePackProperties(
WebPaths.concat(WebServer.getInstance().getServerRoot(), "resources.zip"),
UUID.nameUUIDFromBytes(url.getBytes(StandardCharsets.UTF_8)),
url,
sha1,
required,
parseResourcePackPrompt(prompt)

View File

@ -3,13 +3,13 @@
"id": "dynres",
"version": "${version}",
"name": "DynRes",
"description": "Host resourcepacks directly in-server",
"authors": [
"JFronny"
],
"description": "Host a resource pack directly on your server",
"authors": ["JFronny"],
"contact": {
"website": "https://jfronny.gitlab.io",
"repo": "https://www.gitlab.com/jfmods/DynRes"
"email": "projects.contact@frohnmeyer-wds.de",
"homepage": "https://jfronny.gitlab.io",
"issues": "https://git.frohnmeyer-wds.de/JfMods/DynRes/issues",
"sources": "https://git.frohnmeyer-wds.de/JfMods/DynRes"
},
"license": "MIT",
"icon": "assets/dynres/icon.png",
@ -17,7 +17,7 @@
"entrypoints": {
"libjf:web": ["io.gitlab.jfronny.dynres.DynRes"],
"client": ["io.gitlab.jfronny.dynres.DebugClient"],
"libjf:config": ["io.gitlab.jfronny.dynres.Cfg"]
"libjf:config": ["io.gitlab.jfronny.dynres.JFC_Cfg"]
},
"mixins": [
"dynres.mixins.json",
@ -29,15 +29,11 @@
"depends": {
"fabricloader": ">=0.12.0",
"minecraft": "*",
"fabric-api": "*",
"libjf-config-core-v1": ">=2.7.0"
},
"custom": {
"libjf": {
"web": true
},
"libjf:config": {
"referencedConfigs": ["libjf-web-v0"]
}
}
}