diff --git a/.github/actions/build/action.yml b/.github/actions/build/action.yml index d80ea9f..d92c7df 100644 --- a/.github/actions/build/action.yml +++ b/.github/actions/build/action.yml @@ -3,14 +3,30 @@ name: Build description: Build project with Gradle and upload artifact inputs: - is-snapshot: - description: Whether this is a snapshot build - required: false - default: 'true' artifact-name: description: Artifact name for upload required: true +outputs: + mod_name: + description: Display name of the mod + value: ${{ steps.info.outputs.mod_name }} + edition: + description: Target mod loader edition + value: ${{ steps.info.outputs.edition }} + short_version: + description: Shortened version identifier + value: ${{ steps.info.outputs.short_version }} + loaders: + description: List of supported mod loaders + value: ${{ steps.info.outputs.loaders }} + game_versions: + description: List of compatible Minecraft game versions + value: ${{ steps.info.outputs.game_versions }} + java: + description: List of compatible Java versions + value: ${{ steps.info.outputs.java }} + runs: using: composite steps: @@ -22,9 +38,13 @@ runs: - name: Build with Gradle shell: pwsh - env: - IS_SNAPSHOT: ${{ inputs.is-snapshot }} - run: ./gradlew clean build --info --stacktrace + run: ./gradlew clean build --info --stacktrace -Pbuild_type=${{ github.event_name }} + + - name: Generate metadata JSONs + if: github.event_name != 'pull_request' + shell: pwsh + id: info + run: ./.github/scripts/Get-PublishInfo.ps1 -ArtifactDir 'Bootstrap/build/libs' -Type '${{ github.event_name }}' - uses: actions/upload-artifact@v7 with: diff --git a/.github/actions/publish-object-storage/action.yml b/.github/actions/publish-object-storage/action.yml new file mode 100644 index 0000000..27d2f99 --- /dev/null +++ b/.github/actions/publish-object-storage/action.yml @@ -0,0 +1,56 @@ +name: Publish to Object Storage +description: >- + Upload build artifacts to an S3-compatible object store (AWS S3, Cloudflare + R2, MinIO, etc.). Requires the AWS CLI to be pre-installed on the runner. + +inputs: + artifact-path: + description: Path to the directory containing build artifacts. + required: true + endpoint-url: + description: S3-compatible endpoint URL. + required: true + bucket: + description: S3 bucket name. + required: true + access-key-id: + description: S3-compatible access key ID. + required: true + secret-access-key: + description: S3-compatible secret access key. + required: true + region: + description: AWS region (use 'auto' for Cloudflare R2). + required: false + default: 'auto' + target-path: + description: Key prefix in the bucket (e.g., 'mods'). + required: false + default: '' + files: + description: Glob pattern for files to upload. + required: false + default: '*' + +runs: + using: composite + steps: + - name: Validate artifact path + shell: pwsh + run: | + $path = "${{ inputs.artifact-path }}" + if (-not (Test-Path -LiteralPath $path)) { + throw "Artifact path not found: $path" + } + + - name: Upload to object storage + shell: pwsh + env: + AWS_ACCESS_KEY_ID: ${{ inputs.access-key-id }} + AWS_SECRET_ACCESS_KEY: ${{ inputs.secret-access-key }} + AWS_DEFAULT_REGION: ${{ inputs.region }} + run: | + $ErrorActionPreference = "Stop" + Get-ChildItem -Path "${{ inputs.artifact-path }}" -Filter "${{ inputs.files }}" | ForEach-Object { + aws s3 cp "$_.FullName" "s3://${{ inputs.bucket }}/${{ inputs.target-path }}$($_.Name)" --endpoint-url "${{ inputs.endpoint-url }}" + } diff --git a/.github/actions/publish-release/action.yml b/.github/actions/publish-release/action.yml new file mode 100644 index 0000000..76090e2 --- /dev/null +++ b/.github/actions/publish-release/action.yml @@ -0,0 +1,56 @@ +name: Publish to GitHub Release +description: Upload build artifacts to a GitHub Release. Requires contents:write permission at the workflow level. + +inputs: + artifact-path: + description: Path to the directory containing build artifacts. + required: true + tag-name: + description: Git tag for the release. + required: true + token: + description: GitHub token with contents:write permission. + required: true + files: + description: Glob pattern(s) for files to upload (passed to gh release create). + required: false + default: '*' + notes-file: + description: Path to file containing release body text. + required: false + prerelease: + description: Mark as a pre-release (true/false). + required: false + default: 'false' + generate-notes: + description: Auto-generate release notes from merged commits (true/false). + required: false + default: 'false' + replace: + description: Delete existing release with the same tag before creating (true/false). + required: false + default: 'false' + +runs: + using: composite + steps: + - name: Validate artifact path + shell: pwsh + run: | + $path = "${{ inputs.artifact-path }}" + if (-not (Test-Path -LiteralPath $path)) { + throw "Artifact path not found: $path" + } + + - name: Create GitHub Release + shell: pwsh + env: + GH_TOKEN: ${{ inputs.token }} + run: | + $ErrorActionPreference = "Stop" + $tag = '${{ inputs.tag-name }}' + if('${{ inputs.replace }}' -eq 'true') { gh release delete "$tag" --yes --cleanup-tag } + + gh release create "$tag" '${{ inputs.artifact-path }}/${{ inputs.files }}' --title "CustomSkinLoader $tag" ` + $(if('${{ inputs.prerelease }}' -eq 'true') { '--prerelease' }) ` + $(if('${{ inputs.notes-file }}') { '--notes-file'; '${{ inputs.notes-file }}' } elseif ('${{ inputs.generate-notes }}' -eq 'true') { '--generate-notes' }) diff --git a/.github/actions/publish/action.yml b/.github/actions/publish/action.yml deleted file mode 100644 index c9a3a8c..0000000 --- a/.github/actions/publish/action.yml +++ /dev/null @@ -1,30 +0,0 @@ -# Composite action: upload jars to R2/COS, generate and upload JSON metadata -name: Publish -description: Upload built artifacts to object storage and publish JSON metadata - -inputs: - artifact-dir: - description: Directory containing built artifacts (relative to workspace) - required: true - type: - description: Release type - 'beta' or 'release' - required: true - -runs: - using: composite - steps: - # Generate JSON metadata, upload to R2/COS root, and output CDN URLs - - name: Generate and upload JSON metadata - id: publish-files - shell: pwsh - run: ./.github/scripts/Publish-Files.ps1 -ArtifactDir '${{ inputs.artifact-dir }}' -Type '${{ inputs.type }}' - - # Refresh Tencent Cloud CDN cache for the JSON files - - name: Refresh CDN - uses: linrongda/tencent-cdn-action@v2 - with: - secret-id: ${{ env.COS_SECRET_ID }} - secret-key: ${{ env.COS_SECRET_KEY }} - action: purgeUrls - paths: ${{ steps.publish-files.outputs.cdn-urls }} - continue-on-error: true diff --git a/.github/scripts/Get-PublishInfo.ps1 b/.github/scripts/Get-PublishInfo.ps1 index a798dae..cbff4ba 100644 --- a/.github/scripts/Get-PublishInfo.ps1 +++ b/.github/scripts/Get-PublishInfo.ps1 @@ -1,29 +1,68 @@ -param() +param( + [string]$ArtifactDir = '', + [string]$Type = '' +) $ErrorActionPreference = "Stop" -$props = Get-Content "gradle.properties" +# ---- Output build.info.json to GITHUB_OUTPUT ---- +$info = Get-Content "build.info.json" -Raw | ConvertFrom-Json -function Get-Prop($key) { - ($props | Select-String "^$key=") -replace "^.*=", "" | ForEach-Object { $_.Trim() } +$info.PSObject.Properties | ForEach-Object { + $name = $_.Name + $value = $_.Value + if ($value -is [array]) { + "$name< 15.0-s33 -# mod_version=15.0, IS_SNAPSHOT=false -> 15.0 -$version = ((Get-Content "gradle.properties" | Select-String "^mod_version=") -replace "^mod_version=", "").Trim() -$isSnapshot = if ($env:IS_SNAPSHOT) { $env:IS_SNAPSHOT -ne "false" } else { $true } -if ($isSnapshot) { - $shortVersion = "$version-s$env:GITHUB_RUN_NUMBER" -} else { - $shortVersion = "$version" -} - -# ---- Read MC major versions from gradle.properties ---- -$mcVersions = ((Get-Content "gradle.properties" | Select-String "^minecraft_major_versions=") -replace "^.*=", "").Trim() -$mcVersionList = $mcVersions -split "," | ForEach-Object { $_.Trim() } - -$baseUrl = "_BASE_URL_" - -# ---- Generate latest(-beta).json ---- -$latestJson = @{ - version = $shortVersion - downloads = @{ Universal = "$baseUrl/$jarKey" } - launchermeta = @{} -} | ConvertTo-Json -Depth 10 - -# ---- Generate detail(-beta).json ---- -$details = [ordered]@{} -foreach ($mcVer in $mcVersionList) { - $details[$mcVer] = @{ - Fabric = "$baseUrl/$jarKey" - Forge = "$baseUrl/$jarKey" - NeoForge = "$baseUrl/$jarKey" - Quilt = "$baseUrl/$jarKey" - } -} -$detailJson = @{ - version = $shortVersion - timestamp = [System.DateTimeOffset]::UtcNow.ToUnixTimeMilliseconds() - details = $details -} | ConvertTo-Json -Depth 10 - -# ---- Upload files to R2 ---- -$env:AWS_ACCESS_KEY_ID = $env:R2_SECRET_ID -$env:AWS_SECRET_ACCESS_KEY = $env:R2_SECRET_KEY -$env:AWS_DEFAULT_REGION = "auto" - -aws s3 cp "$ArtifactDir/$jarFilename" "s3://$env:R2_BUCKET/$jarKey" --endpoint-url $($env:R2_BASE_URL.TrimEnd('/')) -$latestJson -replace $baseUrl, "https://csl.3-3.dev" | Set-Content -Path "$ArtifactDir/latest$suffix.json" -NoNewline -$detailJson -replace $baseUrl, "https://csl.3-3.dev" | Set-Content -Path "$ArtifactDir/detail$suffix.json" -NoNewline -aws s3 cp "$ArtifactDir/latest$suffix.json" "s3://$env:R2_BUCKET/latest$suffix.json" --endpoint-url $($env:R2_BASE_URL.TrimEnd('/')) -aws s3 cp "$ArtifactDir/detail$suffix.json" "s3://$env:R2_BUCKET/detail$suffix.json" --endpoint-url $($env:R2_BASE_URL.TrimEnd('/')) - -# ---- Upload files to COS ---- -$cdnBase = "https://csl.littleservice.cn" -try { - pip install coscmd -q --disable-pip-version-check - coscmd config -a $env:COS_SECRET_ID -s $env:COS_SECRET_KEY -b $env:COS_BUCKET -r ap-shanghai - coscmd upload "$ArtifactDir/$jarFilename" "$jarKey" - $latestJson -replace $baseUrl, $cdnBase | Set-Content -Path "$ArtifactDir/latest$suffix.json" -NoNewline - $detailJson -replace $baseUrl, $cdnBase | Set-Content -Path "$ArtifactDir/detail$suffix.json" -NoNewline - coscmd upload "$ArtifactDir/latest$suffix.json" "latest$suffix.json" - coscmd upload "$ArtifactDir/detail$suffix.json" "detail$suffix.json" -} catch { - Write-Warning "COS JSON upload failed: $_" -} - -# ---- Output CDN URLs for subsequent refresh step ---- -"cdn-urls<", "(" + objectDesc(STRING) + objectDesc(STRING) + ")V"))); + modified |= this.requireModified("identifier.patch", this.makeMethodPublicNonFinal(context.findMethod(IDENTIFIER, "", "(" + objectDesc(STRING) + objectDesc(STRING) + ")V"))); } return modified; diff --git a/Bootstrap/Core/src/main/java/customskinloader/bootstrap/transformer/patch/SkinTexturePatch.java b/Bootstrap/Core/src/main/java/customskinloader/bootstrap/transformer/patch/SkinTexturePatch.java index b9b78d2..37a4c21 100644 --- a/Bootstrap/Core/src/main/java/customskinloader/bootstrap/transformer/patch/SkinTexturePatch.java +++ b/Bootstrap/Core/src/main/java/customskinloader/bootstrap/transformer/patch/SkinTexturePatch.java @@ -88,11 +88,11 @@ public final class SkinTexturePatch extends PatchSupport { private boolean replaceSkinTextureDownloaderProcessLegacySkin(ClassTransformationContext context) { boolean modified = false; // 24w46a ~ 25w37a (1.21.4 ~ 1.21.8) - modified |= this.applyIfMatches("[769,772],[0x400000DE,0x4000010C]", "skin-texture-downloader.process-legacy-skin.string", () -> replaceSkinTextureDownloaderProcessLegacySkin( + modified |= this.applyIfMatches("[769,772],[0x400000DE,0x4000010C]", "skin-texture-downloader.process-legacy-skin.v1", () -> replaceSkinTextureDownloaderProcessLegacySkin( context, context.findMethod(SKIN_TEXTURE_DOWNLOADER, "lambda$downloadAndRegisterSkin$0", "(" + objectDesc(PATH) + objectDesc(STRING) + "Z)" + objectDesc(NATIVE_IMAGE)) )); // 1.21.9-pre1+ (1.21.9+) - modified |= this.applyIfMatches("[773,800],[804,0x40000000],[0x4000010D,]", "skin-texture-downloader.process-legacy-skin.downloaded-texture", () -> replaceSkinTextureDownloaderProcessLegacySkin( + modified |= this.applyIfMatches("[773,800],[804,0x40000000],[0x4000010D,]", "skin-texture-downloader.process-legacy-skin.v2", () -> replaceSkinTextureDownloaderProcessLegacySkin( context, context.findMethod(SKIN_TEXTURE_DOWNLOADER, "lambda$downloadAndRegisterSkin$0", "(" + objectDesc(PATH) + objectDesc(CLIENT_ASSET_DOWNLOADED_TEXTURE) + "Z)" + objectDesc(NATIVE_IMAGE)) )); return modified; diff --git a/Bootstrap/FabricV1/src/main/java/customskinloader/bootstrap/fabric/v1/TransformerBootstrap.java b/Bootstrap/FabricV1/src/main/java/customskinloader/bootstrap/fabric/v1/TransformerBootstrap.java index 05c57b0..ed6b362 100644 --- a/Bootstrap/FabricV1/src/main/java/customskinloader/bootstrap/fabric/v1/TransformerBootstrap.java +++ b/Bootstrap/FabricV1/src/main/java/customskinloader/bootstrap/fabric/v1/TransformerBootstrap.java @@ -2,6 +2,7 @@ package customskinloader.bootstrap.fabric.v1; import java.lang.reflect.Field; import java.lang.reflect.Method; +import java.nio.file.Path; import java.util.ArrayList; import java.util.Iterator; import java.util.List; @@ -26,7 +27,7 @@ final class TransformerBootstrap { private static final Logger LOGGER = BootstrapLogger.LOGGER; private static final TransformerBootstrapSupport SUPPORT = new TransformerBootstrapSupport(TransformerBootstrap.class, "intermediary"); private static final Object LOCK = new Object(); - private static final List PENDING_MIXIN_TARGETS = new ArrayList(); + private static final List PENDING_MIXIN_TARGETS = new ArrayList<>(); private static final String DUMMY_MIXIN = "customskinloader.bootstrap.fabric.v1.mixin.DummyMixin"; private TransformerBootstrap() { @@ -45,7 +46,7 @@ final class TransformerBootstrap { private static void releaseRuntimeArtifacts() { try { - java.nio.file.Path commonJar = CommonJarInstaller.releaseCommonJar(FabricLoader.getInstance().getGameDir(), "intermediary"); + Path commonJar = CommonJarInstaller.releaseCommonJar(FabricLoader.getInstance().getGameDir(), "intermediary"); FabricLauncherBase.getLauncher().addToClassPath(commonJar, "customskinloader."); LOGGER.info("Added CustomSkinLoader Common jar to Fabric class path: " + BootstrapLogger.formatPath(commonJar)); } catch (Exception exception) { @@ -135,7 +136,7 @@ final class TransformerBootstrap { targetClassNames.add(targetInternalName); Map> mixinMapping = (Map>) getField(mixinConfig, "mixinMapping"); - List mappedMixins = mixinMapping.computeIfAbsent(targetBinaryName, k -> new ArrayList()); + List mappedMixins = mixinMapping.computeIfAbsent(targetBinaryName, k -> new ArrayList<>()); if (!mappedMixins.contains(mixinInfo)) { mappedMixins.add(mixinInfo); } diff --git a/Bootstrap/ForgeV2/src/main/java/customskinloader/bootstrap/forge/v2/BridgeModLocator.java b/Bootstrap/ForgeV2/src/main/java/customskinloader/bootstrap/forge/v2/CommonModLocator.java similarity index 81% rename from Bootstrap/ForgeV2/src/main/java/customskinloader/bootstrap/forge/v2/BridgeModLocator.java rename to Bootstrap/ForgeV2/src/main/java/customskinloader/bootstrap/forge/v2/CommonModLocator.java index 05a3f37..ebf25cb 100644 --- a/Bootstrap/ForgeV2/src/main/java/customskinloader/bootstrap/forge/v2/BridgeModLocator.java +++ b/Bootstrap/ForgeV2/src/main/java/customskinloader/bootstrap/forge/v2/CommonModLocator.java @@ -5,8 +5,8 @@ import net.minecraftforge.fml.loading.moddiscovery.ModsFolderLocator; import customskinloader.bootstrap.util.ModLocatorUtils; -public final class BridgeModLocator extends ModsFolderLocator { - public BridgeModLocator() { +public final class CommonModLocator extends ModsFolderLocator { + public CommonModLocator() { ModLocatorUtils.initialize(this, ModsFolderLocator.class, FMLPaths.GAMEDIR.get(), "srg"); } diff --git a/Bootstrap/ForgeV2/src/main/java/customskinloader/bootstrap/forge/v2/TransformerBootstrap.java b/Bootstrap/ForgeV2/src/main/java/customskinloader/bootstrap/forge/v2/TransformerBootstrap.java index e3fd63e..68db88b 100644 --- a/Bootstrap/ForgeV2/src/main/java/customskinloader/bootstrap/forge/v2/TransformerBootstrap.java +++ b/Bootstrap/ForgeV2/src/main/java/customskinloader/bootstrap/forge/v2/TransformerBootstrap.java @@ -74,12 +74,12 @@ final class TransformerBootstrap { // NeoForge public cpw.mods.modlauncher.api.TargetType getTargetType() { - return cpw.mods.modlauncher.api.TargetType.CLASS; + return cpw.mods.modlauncher.api.TargetType.CLASS; } @Override public String[] labels() { - return new String[]{"customskinloader:" + this.targetClassName.replace('/', '.')}; + return new String[] {"customskinloader:" + this.targetClassName.replace('/', '.')}; } } } diff --git a/Bootstrap/ForgeV2/src/main/resources/META-INF/services/net.minecraftforge.fml.loading.moddiscovery.IModLocator b/Bootstrap/ForgeV2/src/main/resources/META-INF/services/net.minecraftforge.fml.loading.moddiscovery.IModLocator index b6684d4..1b867e7 100644 --- a/Bootstrap/ForgeV2/src/main/resources/META-INF/services/net.minecraftforge.fml.loading.moddiscovery.IModLocator +++ b/Bootstrap/ForgeV2/src/main/resources/META-INF/services/net.minecraftforge.fml.loading.moddiscovery.IModLocator @@ -1 +1 @@ -customskinloader.bootstrap.forge.v2.BridgeModLocator +customskinloader.bootstrap.forge.v2.CommonModLocator diff --git a/Bootstrap/ForgeV2/src/main/resources/META-INF/services/net.minecraftforge.forgespi.locating.IModLocator b/Bootstrap/ForgeV2/src/main/resources/META-INF/services/net.minecraftforge.forgespi.locating.IModLocator index b6684d4..1b867e7 100644 --- a/Bootstrap/ForgeV2/src/main/resources/META-INF/services/net.minecraftforge.forgespi.locating.IModLocator +++ b/Bootstrap/ForgeV2/src/main/resources/META-INF/services/net.minecraftforge.forgespi.locating.IModLocator @@ -1 +1 @@ -customskinloader.bootstrap.forge.v2.BridgeModLocator +customskinloader.bootstrap.forge.v2.CommonModLocator diff --git a/Bootstrap/NeoForgeV1/src/main/java/customskinloader/bootstrap/neoforge/v1/BridgeModLocator.java b/Bootstrap/NeoForgeV1/src/main/java/customskinloader/bootstrap/neoforge/v1/CommonModLocator.java similarity index 80% rename from Bootstrap/NeoForgeV1/src/main/java/customskinloader/bootstrap/neoforge/v1/BridgeModLocator.java rename to Bootstrap/NeoForgeV1/src/main/java/customskinloader/bootstrap/neoforge/v1/CommonModLocator.java index 6dbdceb..372d014 100644 --- a/Bootstrap/NeoForgeV1/src/main/java/customskinloader/bootstrap/neoforge/v1/BridgeModLocator.java +++ b/Bootstrap/NeoForgeV1/src/main/java/customskinloader/bootstrap/neoforge/v1/CommonModLocator.java @@ -4,8 +4,8 @@ import customskinloader.bootstrap.util.ModLocatorUtils; import net.neoforged.fml.loading.FMLPaths; import net.neoforged.fml.loading.moddiscovery.ModsFolderLocator; -public final class BridgeModLocator extends ModsFolderLocator { - public BridgeModLocator() { +public final class CommonModLocator extends ModsFolderLocator { + public CommonModLocator() { ModLocatorUtils.initialize(this, ModsFolderLocator.class, FMLPaths.GAMEDIR.get(), "official"); } diff --git a/Bootstrap/NeoForgeV1/src/main/resources/META-INF/services/net.neoforged.neoforgespi.locating.IModLocator b/Bootstrap/NeoForgeV1/src/main/resources/META-INF/services/net.neoforged.neoforgespi.locating.IModLocator index 4e0bb1f..24bd008 100644 --- a/Bootstrap/NeoForgeV1/src/main/resources/META-INF/services/net.neoforged.neoforgespi.locating.IModLocator +++ b/Bootstrap/NeoForgeV1/src/main/resources/META-INF/services/net.neoforged.neoforgespi.locating.IModLocator @@ -1 +1 @@ -customskinloader.bootstrap.neoforge.v1.BridgeModLocator +customskinloader.bootstrap.neoforge.v1.CommonModLocator diff --git a/Bootstrap/NeoForgeV2/src/main/java/customskinloader/bootstrap/neoforge/v2/BridgeModLocator.java b/Bootstrap/NeoForgeV2/src/main/java/customskinloader/bootstrap/neoforge/v2/CommonModLocator.java similarity index 81% rename from Bootstrap/NeoForgeV2/src/main/java/customskinloader/bootstrap/neoforge/v2/BridgeModLocator.java rename to Bootstrap/NeoForgeV2/src/main/java/customskinloader/bootstrap/neoforge/v2/CommonModLocator.java index 7020cd7..4454336 100644 --- a/Bootstrap/NeoForgeV2/src/main/java/customskinloader/bootstrap/neoforge/v2/BridgeModLocator.java +++ b/Bootstrap/NeoForgeV2/src/main/java/customskinloader/bootstrap/neoforge/v2/CommonModLocator.java @@ -4,8 +4,8 @@ import customskinloader.bootstrap.util.ModLocatorUtils; import net.neoforged.fml.loading.FMLPaths; import net.neoforged.fml.loading.moddiscovery.locators.ModsFolderLocator; -public final class BridgeModLocator extends ModsFolderLocator { - public BridgeModLocator() { +public final class CommonModLocator extends ModsFolderLocator { + public CommonModLocator() { ModLocatorUtils.initialize(this, ModsFolderLocator.class, FMLPaths.GAMEDIR.get(), "official"); } diff --git a/Bootstrap/NeoForgeV2/src/main/resources/META-INF/services/net.neoforged.neoforgespi.locating.IModFileCandidateLocator b/Bootstrap/NeoForgeV2/src/main/resources/META-INF/services/net.neoforged.neoforgespi.locating.IModFileCandidateLocator index 41826ed..9642b17 100644 --- a/Bootstrap/NeoForgeV2/src/main/resources/META-INF/services/net.neoforged.neoforgespi.locating.IModFileCandidateLocator +++ b/Bootstrap/NeoForgeV2/src/main/resources/META-INF/services/net.neoforged.neoforgespi.locating.IModFileCandidateLocator @@ -1 +1 @@ -customskinloader.bootstrap.neoforge.v2.BridgeModLocator +customskinloader.bootstrap.neoforge.v2.CommonModLocator diff --git a/Common/src/main/java/customskinloader/loader/jsonapi/CustomSkinAPIPlus.java b/Common/src/main/java/customskinloader/loader/jsonapi/CustomSkinAPIPlus.java index 6c7f7d3..8a08780 100644 --- a/Common/src/main/java/customskinloader/loader/jsonapi/CustomSkinAPIPlus.java +++ b/Common/src/main/java/customskinloader/loader/jsonapi/CustomSkinAPIPlus.java @@ -47,7 +47,7 @@ public class CustomSkinAPIPlus extends CustomSkinAPI { @Override public String getName() { - return "CustomSKinAPIPlus"; + return "CustomSkinAPIPlus"; } public static class CustomSkinAPIPlusPayload{ diff --git a/Common/src/main/java/customskinloader/loader/jsonapi/MinecraftCapesAPI.java b/Common/src/main/java/customskinloader/loader/jsonapi/MinecraftCapesAPI.java index 2beffd0..adebf87 100644 --- a/Common/src/main/java/customskinloader/loader/jsonapi/MinecraftCapesAPI.java +++ b/Common/src/main/java/customskinloader/loader/jsonapi/MinecraftCapesAPI.java @@ -1,16 +1,14 @@ package customskinloader.loader.jsonapi; +import java.util.List; + import com.google.common.collect.Lists; import com.google.gson.Gson; - import com.google.gson.annotations.SerializedName; import customskinloader.loader.JsonAPILoader; import customskinloader.loader.MojangAPILoader; import customskinloader.plugin.ICustomSkinLoaderPlugin; import customskinloader.profile.UserProfile; -import customskinloader.utils.TextureUtil; - -import java.util.List; public class MinecraftCapesAPI implements JsonAPILoader.IJsonAPI { diff --git a/Common/src/main/java/customskinloader/loader/jsonapi/WynntilsAPI.java b/Common/src/main/java/customskinloader/loader/jsonapi/WynntilsAPI.java index 50d3804..819d5fd 100644 --- a/Common/src/main/java/customskinloader/loader/jsonapi/WynntilsAPI.java +++ b/Common/src/main/java/customskinloader/loader/jsonapi/WynntilsAPI.java @@ -1,5 +1,7 @@ package customskinloader.loader.jsonapi; +import java.util.List; + import com.google.common.collect.Lists; import com.google.gson.Gson; import customskinloader.CustomSkinLoader; @@ -10,8 +12,6 @@ import customskinloader.plugin.ICustomSkinLoaderPlugin; import customskinloader.profile.UserProfile; import customskinloader.utils.TextureUtil; -import java.util.List; - /** * Wynntils cape API * Home diff --git a/Common/src/main/java/customskinloader/profile/ProfileCache.java b/Common/src/main/java/customskinloader/profile/ProfileCache.java index 2b54238..3188b8e 100644 --- a/Common/src/main/java/customskinloader/profile/ProfileCache.java +++ b/Common/src/main/java/customskinloader/profile/ProfileCache.java @@ -73,18 +73,9 @@ public class ProfileCache { return; saveLocalProfile(username,profile); } - public void putLoader(String username, Function loader) { - this.profileLoaders.putIfAbsent(username, new ConcurrentLinkedDeque<>()); - this.profileLoaders.get(username).offerLast(loader); - } private CachedProfile getCachedProfile(String username){ - CachedProfile cp=cachedProfiles.get(username.toLowerCase()); - if(cp!=null) - return cp; - cp=new CachedProfile(); - cachedProfiles.put(username.toLowerCase(), cp); - return cp; + return cachedProfiles.computeIfAbsent(username.toLowerCase(), k -> new CachedProfile()); } private UserProfile loadLocalProfile(String username){ File localProfile=new File(PROFILE_CACHE_DIR,username.toLowerCase()+".json"); diff --git a/Common/src/main/java/customskinloader/utils/HttpRequestUtil.java b/Common/src/main/java/customskinloader/utils/HttpRequestUtil.java index 84519a5..ccf0cbe 100644 --- a/Common/src/main/java/customskinloader/utils/HttpRequestUtil.java +++ b/Common/src/main/java/customskinloader/utils/HttpRequestUtil.java @@ -142,8 +142,8 @@ public class HttpRequestUtil { CustomSkinLoader.logger.debug("Encoded URL: " + url); } HttpURLConnection c = (HttpURLConnection) (new URL(url)).openConnection(); - c.setReadTimeout(1000 * 5); - c.setConnectTimeout(1000 * 5); + c.setReadTimeout(1000 * 10); + c.setConnectTimeout(1000 * 10); c.setDoInput(true); c.setUseCaches(false); c.setInstanceFollowRedirects(true); @@ -202,8 +202,11 @@ public class HttpRequestUtil { } //Load Content - InputStream is = "gzip".equals(c.getContentEncoding()) ? new GZIPInputStream(c.getInputStream()) : c.getInputStream(); - byte[] bytes = IOUtils.toByteArray(is); + byte[] bytes; + try (InputStream is = "gzip".equals(c.getContentEncoding()) ? new GZIPInputStream(c.getInputStream()) : c.getInputStream()) { + bytes = IOUtils.toByteArray(is); + } + if (request.checkPNG && (bytes.length <= 4 || bytes[1] != (byte) 'P' || bytes[2] != (byte) 'N' || bytes[3] != (byte) 'G')) { CustomSkinLoader.logger.debug("Failed to request (Not Standard PNG)"); responce.success = false; diff --git a/build.gradle b/build.gradle index 9fdd1fe..83bebb6 100644 --- a/build.gradle +++ b/build.gradle @@ -1,27 +1,15 @@ +import groovy.json.JsonSlurper import org.apache.tools.ant.filters.ReplaceTokens import org.gradle.api.attributes.java.TargetJvmVersion -def requireBuildProperty = { String propertyName -> - def propertyValue = rootProject.findProperty(propertyName)?.toString()?.trim() - if (!propertyValue) { - throw new GradleException("Missing ${propertyName} in gradle.properties") - } - propertyValue -} +def info = new JsonSlurper().parse(file("build.info.json")) -def isTruthy = { String value -> - if (value == null) { - return true - } - - value.trim().toLowerCase(Locale.ROOT) == 'true' -} - -def releaseName = requireBuildProperty('mod_name') -def releaseGroup = requireBuildProperty('mod_group') -def releaseVersion = requireBuildProperty('mod_version') +def releaseGroup = info['mod_group'] +def releaseName = info['mod_name'] +def releaseVersion = info['mod_version'] +def releaseEdition = info['edition'] +def releaseIsSnapshot = build_type != 'release' def releaseBuildNumber = System.getenv('GITHUB_RUN_NUMBER')?.trim() ?: '0' -def releaseIsSnapshot = isTruthy(System.getenv('IS_SNAPSHOT')) def releaseFullVersion = (releaseIsSnapshot ? "${releaseVersion}-SNAPSHOT-${releaseBuildNumber}" : releaseVersion).toString() group = releaseGroup @@ -32,7 +20,7 @@ ext { modVersion = releaseVersion modBuildNumber = releaseBuildNumber modFullVersion = releaseFullVersion - releaseArchiveBaseName = "${releaseName}_Universal".toString() + releaseArchiveBaseName = "${releaseName}_${releaseEdition}".toString() } def macroValues = { diff --git a/build.info.json b/build.info.json new file mode 100644 index 0000000..65853d8 --- /dev/null +++ b/build.info.json @@ -0,0 +1,30 @@ +{ + "mod_group": "customskinloader", + "mod_name": "CustomSkinLoader", + "mod_version": "15.0", + "edition": "Universal", + + "loaders": [ + "fabric", "forge", "neoforge", "quilt" + ], + "game_versions": [ + "1.8", "1.8.8", "1.8.9", + "1.9", "1.9.4", + "1.10", "1.10.2", + "1.11", "1.11.2", + "1.12", "1.12.1", "1.12.2", + "1.13.2", + "1.14", "1.14.1", "1.14.2", "1.14.3", "1.14.4", + "1.15", "1.15.1", "1.15.2", + "1.16", "1.16.1", "1.16.2", "1.16.3", "1.16.4", "1.16.5", + "1.17", "1.17.1", + "1.18", "1.18.1", "1.18.2", + "1.19", "1.19.1", "1.19.2", "1.19.3", "1.19.4", + "1.20", "1.20.1", "1.20.2", "1.20.3", "1.20.4", "1.20.5", "1.20.6", + "1.21", "1.21.1", "1.21.2", "1.21.3", "1.21.4", "1.21.5", "1.21.6", "1.21.7", "1.21.8", "1.21.9", "1.21.10", "1.21.11", + "26.1", "26.1.1", "26.1.2", "26.2" + ], + "java": [ + 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 25 + ] +} diff --git a/gradle.properties b/gradle.properties index 634c145..3f460c3 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,16 +1,8 @@ -mod_name=CustomSkinLoader -mod_group=customskinloader -mod_version=15.0 -edition=Universal -minecraft_major_versions=1.8,1.9,1.10,1.11,1.12,1.13,1.14,1.15,1.16,1.17,1.18,1.19,1.20,1.21,26.1 +build_type=beta -minecraft_version=26.1.2 -fabric_v1_version=0.19.2 +minecraft_version=26.2 +fabric_v1_version=0.19.3 forge_v1_version=14.23.5.2864 forge_v2_version=36.2.42 neoforge_v1_version=20.6.13-beta -neoforge_v2_version=26.1.2.59-beta - -loaders=fabric,forge,neoforge,quilt -game_versions=1.8,1.8.8,1.8.9,1.9,1.9.4,1.10,1.10.2,1.11,1.11.2,1.12,1.12.1,1.12.2,1.13.2,1.14,1.14.1,1.14.2,1.14.3,1.14.4,1.15,1.15.1,1.15.2,1.16,1.16.1,1.16.2,1.16.3,1.16.4,1.16.5,1.17,1.17.1,1.18,1.18.1,1.18.2,1.19,1.19.1,1.19.2,1.19.3,1.19.4,1.20,1.20.1,1.20.2,1.20.3,1.20.4,1.20.5,1.20.6,1.21,1.21.1,1.21.2,1.21.3,1.21.4,1.21.5,1.21.6,1.21.7,1.21.8,1.21.9,1.21.10,1.21.11,26.1,26.1.1,26.1.2 -java=8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,25 +neoforge_v2_version=26.2.0.1-beta