mirror of
https://github.com/xfl03/MCCustomSkinLoader.git
synced 2026-11-25 22:44:38 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
59a515ba61 | ||
|
|
1f3d19ac6e | ||
|
|
1fbe258365 | ||
|
|
d4cc4740d3 | ||
|
|
d0d71b8557 | ||
|
|
1a15951791 | ||
|
|
a195b42bc4 | ||
|
|
5d2f945d45 | ||
|
|
6bf959de49 | ||
|
|
2f26a07dc9 | ||
|
|
5764d81d6d | ||
|
|
8080aa7ab5 | ||
|
|
4d0ebcc1f7 | ||
|
|
1cb4cf40b0 | ||
|
|
a9b2484b3e | ||
|
|
8e63429293 | ||
|
|
aa68af31e5 | ||
|
|
bab30e4f0a | ||
|
|
571d61118d | ||
|
|
5d3326c333 | ||
|
|
b2095998e5 | ||
|
|
cdf2fbe644 | ||
|
|
fa0f820143 | ||
|
|
23f08a3a64 | ||
|
|
3e4b06f5d1 | ||
|
|
18d31bed8f | ||
|
|
64490f1d18 | ||
|
|
cd1922844c | ||
|
|
4185e5bb5f | ||
|
|
7fd5ff84ee | ||
|
|
d2772697f3 | ||
|
|
0ffa9ef137 | ||
|
|
f4b5954dad | ||
|
|
009895c018 | ||
|
|
c273dc396e | ||
|
|
6cb37301b6 | ||
|
|
e9e1955fad | ||
|
|
933f64b810 | ||
|
|
e839362f09 | ||
|
|
220bddbebb | ||
|
|
00c931d434 | ||
|
|
119892489f | ||
|
|
9a55a4c615 | ||
|
|
1ed98534c9 | ||
|
|
b8ca913848 | ||
|
|
d5ae6226ae | ||
|
|
f274278419 | ||
|
|
f6f043fc7c | ||
|
|
9571e367df | ||
|
|
48efe58d52 | ||
|
|
16520f72a4 | ||
|
|
fd08f65af3 | ||
|
|
83799da6ae | ||
|
|
54d24a2800 | ||
|
|
f2698b4ccf | ||
|
|
4a344ed653 | ||
|
|
7074c8509d | ||
|
|
10950a21ee | ||
|
|
9889e05a81 | ||
|
|
e65ab7a9ea | ||
|
|
a4f30a4bf1 | ||
|
|
68ac9f67df | ||
|
|
647532629e | ||
|
|
71befeb300 | ||
|
|
8db9bf3de6 | ||
|
|
0c9a4033c4 | ||
|
|
d8d955224d | ||
|
|
8c0cdfb7b5 | ||
|
|
919b69aaad | ||
|
|
4de06aae50 | ||
|
|
f3f80a1f00 | ||
|
|
f5b1989453 | ||
|
|
85923855d8 | ||
|
|
755f7647ed | ||
|
|
c2dad72690 | ||
|
|
c8e96c11cd | ||
|
|
32e3e2e5a2 | ||
|
|
b7b5e9d6c8 | ||
|
|
dfa7db1731 | ||
|
|
b645fd1665 | ||
|
|
28fc81cb9a | ||
|
|
bb0a47de4b | ||
|
|
d09b1d9807 | ||
|
|
c207bdfc0e | ||
|
|
69d35a69b7 | ||
|
|
d767f40d32 | ||
|
|
5329a27d1a | ||
|
|
ddefe00ac0 | ||
|
|
dd4b706827 | ||
|
|
84072c62f3 | ||
|
|
2d00e12f0a | ||
|
|
b2b56f5be5 | ||
|
|
43c8ceb21e | ||
|
|
a0ad239770 | ||
|
|
c8f0f7e283 | ||
|
|
bfbd6ee31a | ||
|
|
f8f3caad39 | ||
|
|
bd409ae169 | ||
|
|
82f0aad9ff | ||
|
|
f2fce38137 | ||
|
|
7d19f3114c | ||
|
|
d7a1e0f31f | ||
|
|
201210f567 | ||
|
|
26ed002689 | ||
|
|
7d7e5c9060 | ||
|
|
81bf422250 | ||
|
|
776e31e158 | ||
|
|
4a92223158 | ||
|
|
264aacc8c0 | ||
|
|
0b000731b5 | ||
|
|
f0012b58df | ||
|
|
013c22ae95 | ||
|
|
01d02a27b0 | ||
|
|
077551e161 | ||
|
|
bd642d0106 | ||
|
|
fbec7ce6bb | ||
|
|
ea1b25a38f | ||
|
|
62018a3e8b | ||
|
|
f38a8ddcef | ||
|
|
63251c9f5e |
No files matched your search
@@ -1,46 +0,0 @@
|
|||||||
# Java Gradle CircleCI 2.0 configuration file
|
|
||||||
version: 2
|
|
||||||
jobs:
|
|
||||||
build:
|
|
||||||
docker:
|
|
||||||
- image: circleci/openjdk@sha256:7be33522f6f0ca65c2e78b22b1ef3e6739038494c1de1b8fb6d96da400dccf53
|
|
||||||
|
|
||||||
working_directory: ~/repo
|
|
||||||
|
|
||||||
environment:
|
|
||||||
JVM_OPTS: -Xmx3200m
|
|
||||||
TERM: dumb
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- checkout
|
|
||||||
|
|
||||||
- restore_cache:
|
|
||||||
keys:
|
|
||||||
- gradle-cache
|
|
||||||
|
|
||||||
# Gradle Wrapper
|
|
||||||
# - run: sudo chmod +x gradlew
|
|
||||||
# - run: ./gradlew --version
|
|
||||||
# - run: ./gradlew clean build
|
|
||||||
|
|
||||||
# Gradle
|
|
||||||
- run: gradle --version
|
|
||||||
- run:
|
|
||||||
name: Build
|
|
||||||
command: |
|
|
||||||
export GIT_COMMIT_DESC=$(git log --format=%B -n 1 $CIRCLE_SHA1)
|
|
||||||
gradle clean build
|
|
||||||
- run:
|
|
||||||
name: Publish
|
|
||||||
command: |
|
|
||||||
export GIT_COMMIT_DESC=$(git log --format=%B -n 1 $CIRCLE_SHA1)
|
|
||||||
gradle upload --info
|
|
||||||
# - run: gradle publishGprPublicationToGitHubPackagesRepository
|
|
||||||
|
|
||||||
- store_artifacts:
|
|
||||||
path: ./build/libs
|
|
||||||
|
|
||||||
- save_cache:
|
|
||||||
paths:
|
|
||||||
- ~/.gradle
|
|
||||||
key: gradle-cache
|
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
blank_issues_enabled: false
|
||||||
|
contact_links:
|
||||||
|
- name: Telegram
|
||||||
|
url: https://t.me/customskinloader
|
||||||
|
about: Gugugu
|
||||||
|
- name: QQ
|
||||||
|
url: https://jq.qq.com/?_wv=1027&k=vF16R5tg
|
||||||
|
about: Gugugu
|
||||||
@@ -0,0 +1,126 @@
|
|||||||
|
name: Report Bug
|
||||||
|
description: Report a bug and help us improve CustomSkinLoader
|
||||||
|
labels: [ bug ]
|
||||||
|
title: "[Bug] "
|
||||||
|
body:
|
||||||
|
- type: markdown
|
||||||
|
attributes:
|
||||||
|
value: |
|
||||||
|
Here is the Report Bug issue for CustomSkinLoader
|
||||||
|
With a red asterisk for the mandatory items
|
||||||
|
Please keep the work order content neat and tidy, do not paste the contents of the log file directly onto the work order, it will look very messy and unattractive work orders
|
||||||
|
- type: textarea
|
||||||
|
id: description
|
||||||
|
attributes:
|
||||||
|
label: Describe the bug
|
||||||
|
description: |
|
||||||
|
A clear and concise description of what the issue is.
|
||||||
|
Provide as much information as possible, videos, crash reports, etc.
|
||||||
|
DO NOT PASTE A CRASH REPORT HERE!!!
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
- type: textarea
|
||||||
|
id: reproducing
|
||||||
|
attributes:
|
||||||
|
label: Steps to reproduce
|
||||||
|
description: How do you trigger this bug?
|
||||||
|
render: bash
|
||||||
|
value: |
|
||||||
|
1.
|
||||||
|
2.
|
||||||
|
3.
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
- type: input
|
||||||
|
id: crash-report
|
||||||
|
attributes:
|
||||||
|
label: Link to crash-report if applicable
|
||||||
|
description: |
|
||||||
|
The files are in the folder `<minecraft-directory>/crash-reports`
|
||||||
|
[Generate URL](https://mclo.gs)
|
||||||
|
placeholder: "Ex: https://mclo.gs/xxxxxx"
|
||||||
|
- type: input
|
||||||
|
id: csl-log
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
attributes:
|
||||||
|
label: Link to CustomSkinLoader.log if applicable
|
||||||
|
description: |
|
||||||
|
The path to the file is `<minecraft-directory>/CustomSkinLoader/CustomSkinLoader.log`.
|
||||||
|
[Generate URL](https://mclo.gs)
|
||||||
|
placeholder: "Ex: https://mclo.gs/xxxxxx"
|
||||||
|
- type: input
|
||||||
|
id: latest-log
|
||||||
|
attributes:
|
||||||
|
label: Link to latest.log if applicable
|
||||||
|
description: |
|
||||||
|
The path to the file is `<minecraft-directory>/logs/latest.log`.
|
||||||
|
[Generate URL](https://mclo.gs)
|
||||||
|
placeholder: "Ex: https://mclo.gs/xxxxxx"
|
||||||
|
- type: input
|
||||||
|
id: forge-log
|
||||||
|
attributes:
|
||||||
|
label: "[Only Forge User] Link to Forge Log if applicable"
|
||||||
|
description: |
|
||||||
|
The path to the file is `<minecraft-directory>/logs/debug.log` or `<minecraft-directory>/logs/fml-client-latest.log`.
|
||||||
|
if your mod loader isn't `Forge`, URL can set empty
|
||||||
|
[Generate URL](https://mclo.gs)
|
||||||
|
placeholder: "Ex: https://mclo.gs/xxxxxx"
|
||||||
|
- type: input
|
||||||
|
id: mod-version
|
||||||
|
attributes:
|
||||||
|
label: Mod Version
|
||||||
|
placeholder: "Ex: 14.16"
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
- type: input
|
||||||
|
id: mc-version
|
||||||
|
attributes:
|
||||||
|
label: Minecraft Version
|
||||||
|
placeholder: "Ex: 1.19.4"
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
- type: input
|
||||||
|
id: mc-launcher-version
|
||||||
|
attributes:
|
||||||
|
label: Minecraft Launcher Name and Version
|
||||||
|
placeholder: "Ex: HMCL v3.5.4.232"
|
||||||
|
description: |
|
||||||
|
If you don't know the version of the game, you can just fill in the name of the game launcher
|
||||||
|
- type: dropdown
|
||||||
|
id: loader-type
|
||||||
|
attributes:
|
||||||
|
label: Mod Loader
|
||||||
|
options:
|
||||||
|
- Quilt
|
||||||
|
- Fabric
|
||||||
|
- Forge
|
||||||
|
- <without mod loader>
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
- type: dropdown
|
||||||
|
id: operating-systems
|
||||||
|
attributes:
|
||||||
|
label: Operating System
|
||||||
|
options:
|
||||||
|
- Windows
|
||||||
|
- Linux
|
||||||
|
- macOS
|
||||||
|
- Other
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
- type: checkboxes
|
||||||
|
id: prerequisites
|
||||||
|
attributes:
|
||||||
|
label: Before submitting a bug report
|
||||||
|
options:
|
||||||
|
- label: |
|
||||||
|
This bug wasn't already reported (I have searched bug reports on GitHub).
|
||||||
|
required: true
|
||||||
|
- label: |
|
||||||
|
This is a valid bug (I am able to reproduce this on the latest dev build).
|
||||||
|
required: true
|
||||||
|
- label: |
|
||||||
|
This problem is triggered in the latest version of the mod (if not the latest please upgrade the mod first)
|
||||||
|
required: true
|
||||||
|
|
||||||
@@ -0,0 +1,127 @@
|
|||||||
|
name: 提交问题
|
||||||
|
description: 报告问题以帮助我们改进CustomSkinLoader
|
||||||
|
labels: [ bug ]
|
||||||
|
title: "[Bug] "
|
||||||
|
body:
|
||||||
|
- type: markdown
|
||||||
|
attributes:
|
||||||
|
value: |
|
||||||
|
你好,这里是 `CustomSkinLoader`
|
||||||
|
标注红色星号的为必填项
|
||||||
|
以及,保持工单干净整洁,不要直接将日志内容粘贴到工单上,比如粘贴到描述内是不行的
|
||||||
|
- type: textarea
|
||||||
|
id: description
|
||||||
|
attributes:
|
||||||
|
label: 描述问题
|
||||||
|
description: |
|
||||||
|
简单的描述问题, 并提供类似图片、视频,以更好的报告错误(如果可以)
|
||||||
|
!注意:请不要在这里放日志文件或崩溃报告文件的内容
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
- type: textarea
|
||||||
|
id: reproducing
|
||||||
|
attributes:
|
||||||
|
label: 复现步骤
|
||||||
|
description: 请问你是如何触发这个问题的
|
||||||
|
render: bash
|
||||||
|
value: |
|
||||||
|
1.
|
||||||
|
2.
|
||||||
|
3.
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
- type: input
|
||||||
|
id: crash-report
|
||||||
|
attributes:
|
||||||
|
label: 崩溃报告查看地址
|
||||||
|
description: |
|
||||||
|
在游戏目录下的 `crash-reports` 文件夹下,里面找最近的报告生成时间
|
||||||
|
客户端若无崩溃则直接填写 `客户端无崩溃`
|
||||||
|
[生成连接](https://mclo.gs)
|
||||||
|
placeholder: "示例: https://mclo.gs/xxxxxx"
|
||||||
|
- type: input
|
||||||
|
id: csl-log
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
attributes:
|
||||||
|
label: CustomSkinLoader.log 查看地址
|
||||||
|
description: |
|
||||||
|
文件路径:`<游戏路径>/CustomSkinLoader/CustomSkinLoader.log`.
|
||||||
|
[生成连接](https://mclo.gs)
|
||||||
|
placeholder: "示例: https://mclo.gs/xxxxxx"
|
||||||
|
- type: input
|
||||||
|
id: latest-log
|
||||||
|
attributes:
|
||||||
|
label: latest.log 查看地址
|
||||||
|
description: |
|
||||||
|
文件路径:`<游戏路径>/logs/latest.log`.
|
||||||
|
[生成连接](https://mclo.gs)
|
||||||
|
placeholder: "示例: https://mclo.gs/xxxxxx"
|
||||||
|
- type: input
|
||||||
|
id: forge-log
|
||||||
|
attributes:
|
||||||
|
label: "[仅Forge用户] Forge Log 查看地址"
|
||||||
|
description: |
|
||||||
|
文件路径:`<游戏路径>/logs/debug.log` 或者 `<游戏路径>/logs/fml-client-latest.log`.
|
||||||
|
若没有使用 `Forge` 加载器的,可以不填写
|
||||||
|
[生成连接](https://mclo.gs)
|
||||||
|
placeholder: "示例: https://mclo.gs/xxxxxx"
|
||||||
|
- type: input
|
||||||
|
id: mod-version
|
||||||
|
attributes:
|
||||||
|
label: 模组版本
|
||||||
|
placeholder: "示例: 14.16"
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
- type: input
|
||||||
|
id: mc-version
|
||||||
|
attributes:
|
||||||
|
label: Minecraft游戏版本
|
||||||
|
placeholder: "示例: 1.19.4"
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
- type: input
|
||||||
|
id: mc-launcher-version
|
||||||
|
attributes:
|
||||||
|
label: Minecraft启动器 名称 及 版本
|
||||||
|
placeholder: "示例: HMCL v3.5.4.232"
|
||||||
|
description: |
|
||||||
|
若不知道游戏版本 可以只填写游戏启动器的名称
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
- type: dropdown
|
||||||
|
id: loader-type
|
||||||
|
attributes:
|
||||||
|
label: 模组加载器
|
||||||
|
options:
|
||||||
|
- Quilt
|
||||||
|
- Fabric
|
||||||
|
- Forge
|
||||||
|
- 不使用加载器
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
- type: dropdown
|
||||||
|
id: operating-systems
|
||||||
|
attributes:
|
||||||
|
label: 操作系统
|
||||||
|
options:
|
||||||
|
- Windows
|
||||||
|
- Linux
|
||||||
|
- macOS
|
||||||
|
- 其他操作系统
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
- type: checkboxes
|
||||||
|
id: prerequisites
|
||||||
|
attributes:
|
||||||
|
label: 在提交错误报告之前,有没有做到...
|
||||||
|
options:
|
||||||
|
- label: |
|
||||||
|
先尝试搜索issues里面, 查看并确认打开或关闭的工单, 是否搜索不到
|
||||||
|
required: true
|
||||||
|
- label: |
|
||||||
|
确认你的模组版本是最新的开发版本,且文件下载正确,没有出现类似forge下载了fabric版的这类基础问题
|
||||||
|
required: true
|
||||||
|
- label: |
|
||||||
|
这个问题是在最新的mod版本触发(若不是最新的请先升级mod)
|
||||||
|
required: true
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
name: Suggestion
|
||||||
|
description: Suggest a new feature or change for CustomSkinLoader.
|
||||||
|
labels: [ enhancement ]
|
||||||
|
body:
|
||||||
|
- type: textarea
|
||||||
|
id: description
|
||||||
|
attributes:
|
||||||
|
label: Describe the feature
|
||||||
|
description: A clear and concise description of what the feature/change is.
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
- type: checkboxes
|
||||||
|
id: prerequisites
|
||||||
|
attributes:
|
||||||
|
label: Before submitting a suggestion
|
||||||
|
options:
|
||||||
|
- label: |
|
||||||
|
This feature doesn't already exist in the client. (I have checked every module and their settings on the **latest dev build**)
|
||||||
|
required: true
|
||||||
|
- label: |
|
||||||
|
This wasn't already suggested. (I have searched suggestions on GitHub and read the FAQ)
|
||||||
|
required: true
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
name: 反馈或建议
|
||||||
|
description: 给CustomSkinLoader这个模组提个建议
|
||||||
|
labels: [ enhancement ]
|
||||||
|
body:
|
||||||
|
- type: textarea
|
||||||
|
id: description
|
||||||
|
attributes:
|
||||||
|
label: 描述一下
|
||||||
|
description: 简单描述一下该功能/变化是什么。
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
- type: checkboxes
|
||||||
|
id: prerequisites
|
||||||
|
attributes:
|
||||||
|
label: 在提交反馈或建议之前,请先确认...
|
||||||
|
options:
|
||||||
|
- label: |
|
||||||
|
你要提交的反馈或者建议不存在于本模组的最新开发版下.
|
||||||
|
required: true
|
||||||
|
- label: |
|
||||||
|
以及在issues或者Wiki内搜索过, 并且无结果
|
||||||
|
required: true
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
name: Beta
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- '14-develop'
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build-beta:
|
||||||
|
name: Build Beta
|
||||||
|
uses: ./.github/workflows/common.yml
|
||||||
|
with:
|
||||||
|
type: Beta
|
||||||
|
publish-task: uploadBeta
|
||||||
|
secrets: inherit
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
name: Canary
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- '15-develop'
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build-canary:
|
||||||
|
name: Build Canary
|
||||||
|
uses: ./.github/workflows/common.yml
|
||||||
|
with:
|
||||||
|
type: Canary
|
||||||
|
publish-task: uploadCanary
|
||||||
|
secrets: inherit
|
||||||
@@ -0,0 +1,238 @@
|
|||||||
|
name: Common
|
||||||
|
on:
|
||||||
|
workflow_call:
|
||||||
|
inputs:
|
||||||
|
type:
|
||||||
|
required: true
|
||||||
|
type: string
|
||||||
|
publish-task:
|
||||||
|
required: false
|
||||||
|
type: string
|
||||||
|
is-snapshot:
|
||||||
|
required: false
|
||||||
|
type: boolean
|
||||||
|
default: true
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build-common:
|
||||||
|
name: Build
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
environment: Build
|
||||||
|
steps:
|
||||||
|
-
|
||||||
|
name: Checkout
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
-
|
||||||
|
name: Set up JDK
|
||||||
|
uses: actions/setup-java@v4
|
||||||
|
with:
|
||||||
|
distribution: 'temurin'
|
||||||
|
java-version: '8'
|
||||||
|
cache: 'gradle'
|
||||||
|
-
|
||||||
|
name: Build
|
||||||
|
env:
|
||||||
|
KEY_PASS: ${{ secrets.KEY_PASS }}
|
||||||
|
IS_SNAPSHOT: ${{ inputs.is-snapshot }}
|
||||||
|
run: |
|
||||||
|
echo Snapshot: $IS_SNAPSHOT
|
||||||
|
export GIT_COMMIT_DESC=$(git log --format=%B -n 1 $GITHUB_SHA)
|
||||||
|
./gradlew clean build --stacktrace
|
||||||
|
-
|
||||||
|
uses: actions/upload-artifact@v4
|
||||||
|
name: Publish to Github Artifact
|
||||||
|
with:
|
||||||
|
name: CustomSkinLoader-${{ inputs.type }}-${{ github.run_number }}
|
||||||
|
path: build/libs
|
||||||
|
|
||||||
|
Upload:
|
||||||
|
if: inputs.publish-task
|
||||||
|
needs: build-common
|
||||||
|
continue-on-error: true
|
||||||
|
environment: Build
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
website: [CurseForge_Modrinth]
|
||||||
|
modtype: [Fabric,ForgeV1,ForgeV2,ForgeV3]
|
||||||
|
include:
|
||||||
|
-
|
||||||
|
website: ObjectStorage
|
||||||
|
modtype: All
|
||||||
|
# -
|
||||||
|
# website: GitHub-Release
|
||||||
|
# modtype: All
|
||||||
|
-
|
||||||
|
website: GitHub-PreRelease
|
||||||
|
modtype: All
|
||||||
|
name: ${{ matrix.website }} (${{ matrix.modtype}})
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
-
|
||||||
|
name: Checkout Git Repository
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
-
|
||||||
|
uses: actions/download-artifact@v4
|
||||||
|
name: Download Artifact Zips
|
||||||
|
with:
|
||||||
|
path: build
|
||||||
|
-
|
||||||
|
name: Preparation Folder
|
||||||
|
run: |
|
||||||
|
rsync -avz "build/$(ls build|grep "CustomSkinLoader")/" build/libs/
|
||||||
|
ls -lh build
|
||||||
|
-
|
||||||
|
if: ${{ matrix.modtype != 'All' }}
|
||||||
|
name: Checking and setting the environment
|
||||||
|
id: cslenv
|
||||||
|
run: |
|
||||||
|
output="$(ls build/libs | grep -v "sources")"
|
||||||
|
|
||||||
|
case "${{ matrix.modtype }}" in
|
||||||
|
"ForgeV1")
|
||||||
|
modloader="Forge"
|
||||||
|
path=`echo "${{ matrix.modtype }}" | sed 's#V#/V#'`
|
||||||
|
;;
|
||||||
|
"ForgeV2" | "ForgeV3")
|
||||||
|
modloader=$(cat <<EOF
|
||||||
|
Forge
|
||||||
|
NeoForge
|
||||||
|
EOF
|
||||||
|
)
|
||||||
|
path=`echo "${{ matrix.modtype }}" | sed 's#V#/V#'`
|
||||||
|
;;
|
||||||
|
"Fabric")
|
||||||
|
modloader=$(cat <<EOF
|
||||||
|
Fabric
|
||||||
|
Quilt
|
||||||
|
EOF
|
||||||
|
)
|
||||||
|
path="${{ matrix.modtype }}"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "Unsupported modtype: ${{ matrix.modtype }}"
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
echo "path=$path" >> $GITHUB_OUTPUT
|
||||||
|
echo "modloader="$modloader"" >> $GITHUB_OUTPUT
|
||||||
|
echo "filename=$(echo "$output"|grep $(echo ${{ matrix.modtype }}|sed "s#-##") )" >> $GITHUB_OUTPUT
|
||||||
|
echo "version=$(grep "version=" build.properties | grep -v "#" | sed "s/version=//")" >> $GITHUB_OUTPUT
|
||||||
|
echo "edition=$(echo ${{ matrix.modtype }} | sed "s/-//")" >> $GITHUB_OUTPUT
|
||||||
|
echo "minecraft_vers<<EOF" >> $GITHUB_OUTPUT
|
||||||
|
grep "dependencies=" "$path"/build.properties | grep -v "#" | awk -F '|' '{print $2}' | sed 's#\;\\##' | sed "s/,/\n/g" >> $GITHUB_OUTPUT
|
||||||
|
echo "EOF" >> $GITHUB_OUTPUT
|
||||||
|
echo "java_vers<<EOF" >> $GITHUB_OUTPUT
|
||||||
|
grep "java_full_versions=" "$path"/build.properties | grep -v "#" | sed "s/java_full_versions=//" | sed "s/,/\n/g" >> $GITHUB_OUTPUT
|
||||||
|
echo "EOF" >> $GITHUB_OUTPUT
|
||||||
|
-
|
||||||
|
if: startsWith(matrix.website, 'GitHub-')
|
||||||
|
name: Settings more strings to Environment
|
||||||
|
id: cslenv-github
|
||||||
|
run: |
|
||||||
|
#展开
|
||||||
|
echo "buildtime=$(TZ=Asia/Shanghai date "+%Y.%m.%d %H:%M")" >> $GITHUB_OUTPUT
|
||||||
|
echo "pathlist="$(find build/libs -type f|grep -v "sources"|grep -v "json")"" >> $GITHUB_OUTPUT
|
||||||
|
-
|
||||||
|
if: ${{ matrix.website == 'GitHub-PreRelease' && startsWith(github.ref, 'refs/heads') }}
|
||||||
|
name: "[GitHub Pre-Release] Delete"
|
||||||
|
uses: 8Mi-Tech/delete-release-assets-action@main
|
||||||
|
with:
|
||||||
|
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
tag: CI-Build
|
||||||
|
deleteOnlyFromDrafts: false
|
||||||
|
-
|
||||||
|
if: ${{ matrix.website == 'GitHub-PreRelease' && startsWith(github.ref, 'refs/heads') }}
|
||||||
|
name: 【GitHub Pre-Release】 Set CI-Build Text
|
||||||
|
run: |
|
||||||
|
cat > build/ci-build.md << 'EOF'
|
||||||
|
Build Time / 构建时间 : ${{ steps.cslenv-github.outputs.buildtime }}
|
||||||
|
自动同步分支 ${{ github.ref_name }} 的代码,以保持最新
|
||||||
|
Synchronize ${{ github.ref_name }} branch code updates, keeping only the latest version
|
||||||
|
<br>
|
||||||
|
[如何使用 / How to uses?](https://github.com/xfl03/MCCustomSkinLoader/wiki/How-to-Use)
|
||||||
|
EOF
|
||||||
|
-
|
||||||
|
if: ${{ matrix.website == 'GitHub-PreRelease' && startsWith(github.ref, 'refs/heads') }}
|
||||||
|
name: "[GitHub Pre-Release] Upload Tag"
|
||||||
|
uses: richardsimko/update-tag@v1
|
||||||
|
with:
|
||||||
|
tag_name: CI-Build
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
-
|
||||||
|
if: ${{ matrix.website == 'GitHub-PreRelease' && startsWith(github.ref, 'refs/heads') }}
|
||||||
|
name: "[GitHub Pre-Release] Publish"
|
||||||
|
uses: softprops/action-gh-release@v2
|
||||||
|
with:
|
||||||
|
token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
name: CustomSkinLoader CI-Build
|
||||||
|
tag_name: CI-Build
|
||||||
|
prerelease: true
|
||||||
|
body_path: build/ci-build.md
|
||||||
|
files: build/libs/*
|
||||||
|
#files: "${{ steps.cslenv-github.outputs.pathlist }}"
|
||||||
|
-
|
||||||
|
if: ${{ matrix.website == 'GitHub-Release' && inputs.type == 'Release' }}
|
||||||
|
uses: softprops/action-gh-release@v1
|
||||||
|
name: "[GitHub Release] Publish"
|
||||||
|
with:
|
||||||
|
token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
name: CustomSkinLoader ${{ github.ref }}
|
||||||
|
tag_name: ${{ github.ref }}
|
||||||
|
#generate_release_notes: true
|
||||||
|
files: ${{ steps.cslenv-github.outputs.pathlist }}
|
||||||
|
-
|
||||||
|
if: ${{ matrix.website == 'ObjectStorage' }}
|
||||||
|
name: "[ObjectStorage] Force JDK 8"
|
||||||
|
uses: actions/setup-java@v4
|
||||||
|
with:
|
||||||
|
distribution: 'temurin'
|
||||||
|
java-version: '8'
|
||||||
|
cache: 'gradle'
|
||||||
|
-
|
||||||
|
if: ${{ matrix.website == 'ObjectStorage' }}
|
||||||
|
name: "[ObjectStorage] Publish"
|
||||||
|
env:
|
||||||
|
COS_BUCKET: ${{ secrets.COS_BUCKET }}
|
||||||
|
COS_SECRET_ID: ${{ secrets.COS_SECRET_ID }}
|
||||||
|
COS_SECRET_KEY: ${{ secrets.COS_SECRET_KEY }}
|
||||||
|
R2_BASE_URL: ${{ secrets.R2_BASE_URL }}
|
||||||
|
R2_BUCKET: ${{ secrets.R2_BUCKET }}
|
||||||
|
R2_SECRET_ID: ${{ secrets.R2_SECRET_ID }}
|
||||||
|
R2_SECRET_KEY: ${{ secrets.R2_SECRET_KEY }}
|
||||||
|
IS_SNAPSHOT: ${{ inputs.is-snapshot }}
|
||||||
|
run: |
|
||||||
|
export GIT_COMMIT_DESC=$(git log --format=%B -n 1 $GITHUB_SHA)
|
||||||
|
./gradlew ${{ inputs.publish-task }} --info --stacktrace
|
||||||
|
# ./gradlew publishGprPublicationToGitHubPackagesRepository
|
||||||
|
|
||||||
|
-
|
||||||
|
if: ${{ matrix.website == 'CurseForge_Modrinth' && inputs.type == 'Release' }}
|
||||||
|
name: "[CurseForge & Modrinth] Publish"
|
||||||
|
uses: Kir-Antipov/[email protected]
|
||||||
|
with:
|
||||||
|
modrinth-id: idMHQ4n2
|
||||||
|
modrinth-featured: true
|
||||||
|
modrinth-unfeature-mode: subset
|
||||||
|
modrinth-token: ${{ secrets.MODRINTH_TOKEN }}
|
||||||
|
|
||||||
|
curseforge-id: 286924
|
||||||
|
curseforge-token: ${{ secrets.CURSEFORGE_API_KEY }}
|
||||||
|
|
||||||
|
name: CustomSkinLoader_${{ steps.cslenv.outputs.edition }}_${{ steps.cslenv.outputs.version }}
|
||||||
|
version: ${{ steps.cslenv.outputs.version }}-${{ steps.cslenv.outputs.edition }}
|
||||||
|
version-type: release
|
||||||
|
loaders: ${{ steps.cslenv.outputs.modloader }}
|
||||||
|
game-versions: |
|
||||||
|
${{ steps.cslenv.outputs.minecraft_vers }}
|
||||||
|
game-version-filter: releases
|
||||||
|
java: |
|
||||||
|
${{ steps.cslenv.outputs.java_vers }}
|
||||||
|
|
||||||
|
retry-attempts: 2
|
||||||
|
retry-delay: 10000
|
||||||
|
fail-mode: fail
|
||||||
|
|
||||||
|
files: |
|
||||||
|
build/libs/${{ steps.cslenv.outputs.filename }}
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
name: Pull Request
|
||||||
|
on:
|
||||||
|
pull_request:
|
||||||
|
types:
|
||||||
|
- opened
|
||||||
|
- synchronize
|
||||||
|
- reopened
|
||||||
|
branches:
|
||||||
|
- '14-develop'
|
||||||
|
- '15-develop'
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build-pull-request:
|
||||||
|
name: Build Pull Request
|
||||||
|
uses: ./.github/workflows/common.yml
|
||||||
|
with:
|
||||||
|
type: PullRequest
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
name: Release
|
||||||
|
on:
|
||||||
|
release:
|
||||||
|
types: [released]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build-release:
|
||||||
|
name: Build Release
|
||||||
|
uses: ./.github/workflows/common.yml
|
||||||
|
with:
|
||||||
|
type: Release
|
||||||
|
publish-task: upload
|
||||||
|
is-snapshot: false
|
||||||
|
secrets: inherit
|
||||||
+32
-27
@@ -13,7 +13,7 @@ There are the available versions in different environments below:
|
|||||||
| | Forge | Fabric |
|
| | Forge | Fabric |
|
||||||
|:-----------------------:|:-----------------------------------------------------------------------------------------------------------------------:|:----------------------------------------------------------------------------------------------------------------------------:|
|
|:-----------------------:|:-----------------------------------------------------------------------------------------------------------------------:|:----------------------------------------------------------------------------------------------------------------------------:|
|
||||||
| Runtime Environment | forge-1.8-11.14.0.1237 ~ 1.13.2-25.0.22<br/> forge-1.13.2-25.0.42 ~ latest | fabric-loader-0.4.3+build.134 ~ latest<br/> Minecraft 18w43b ~ latest<br/> *fabric-api is not required* |
|
| Runtime Environment | forge-1.8-11.14.0.1237 ~ 1.13.2-25.0.22<br/> forge-1.13.2-25.0.42 ~ latest | fabric-loader-0.4.3+build.134 ~ latest<br/> Minecraft 18w43b ~ latest<br/> *fabric-api is not required* |
|
||||||
| Development Environment | ForgeGradle-2.1-SNAPSHOT ~ latest<br/> forge-1.8-11.14.3.1503 ~ 1.12.2-14.23.5.2855<br/> forge-1.13.2-25.0.198 ~ latest | fabric-loom-(?) ~ latest<br/> fabric-loader-0.12.0 ~ latest<br/> Minecraft 18w49a ~ latest<br/> *fabric-api is not required* |
|
| Development Environment | ForgeGradle-2.1-SNAPSHOT ~ latest<br/> forge-1.8-11.14.3.1503 ~ 1.12.2-14.23.5.2860<br/> forge-1.13.2-25.0.198 ~ latest | fabric-loom-(?) ~ latest<br/> fabric-loader-0.12.0 ~ latest<br/> Minecraft 18w49a ~ latest<br/> *fabric-api is not required* |
|
||||||
|
|
||||||
### Preliminary steps for testing local builds
|
### Preliminary steps for testing local builds
|
||||||
1. Create a new empty minecraft development environment.
|
1. Create a new empty minecraft development environment.
|
||||||
@@ -27,31 +27,43 @@ There are the available versions in different environments below:
|
|||||||
```
|
```
|
||||||
1. Create these folders in the new project directory, then copy the built jar and source jar into it:
|
1. Create these folders in the new project directory, then copy the built jar and source jar into it:
|
||||||
```
|
```
|
||||||
Forge 1.8 ~ 1.16.5: ./local-repo/mods/CustomSkinLoader_ForgeLegacy/${version}
|
Forge 1.8 ~ 1.16.5: ./local-repo/mods/CustomSkinLoader_ForgeV1/${version}
|
||||||
Forge 1.17.1 ~ latest: ./local-repo/mods/CustomSkinLoader_ForgeActive/${version}
|
Forge 1.17.1 ~ 1.20.4 / NeoForge 1.20.1: ./local-repo/mods/CustomSkinLoader_ForgeV2/${version}
|
||||||
Fabric: ./local-repo/mods/CustomSkinLoader_Fabric/${version}
|
Forge 1.20.6 ~ latest / NeoForge 1.20.2 ~ latest: ./local-repo/mods/CustomSkinLoader_ForgeV3/${version}
|
||||||
|
Fabric: ./local-repo/mods/CustomSkinLoader_Fabric/${version}
|
||||||
```
|
```
|
||||||
*`${version}` should be repalced with something like `14.14-SNAPSHOT-00` manually*
|
*`${version}` should be repalced with something like `15.0-SNAPSHOT-00` manually*
|
||||||
1. Create a pom file in the same folder:
|
1. Create a pom file in the same folder:
|
||||||
- Forge 1.8 ~ 1.16.5: `CustomSkinLoader_ForgeLegacy-${version}.pom`
|
- Forge 1.8 ~ 1.16.5: `CustomSkinLoader_ForgeV1-${version}.pom`
|
||||||
```xml
|
```xml
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>mods</groupId>
|
<groupId>mods</groupId>
|
||||||
<artifactId>CustomSkinLoader_ForgeLegacy</artifactId>
|
<artifactId>CustomSkinLoader_ForgeV1</artifactId>
|
||||||
<!-- `${version}` should be repalced with something like `14.14-SNAPSHOT-00` manually -->
|
<!-- `${version}` should be repalced with something like `15.0-SNAPSHOT-00` manually -->
|
||||||
<version>${version}</version>
|
<version>${version}</version>
|
||||||
</project>
|
</project>
|
||||||
```
|
```
|
||||||
- Forge 1.17.1 ~ latest: `CustomSkinLoader_ForgeActive-${version}.pom`
|
- Forge 1.17.1 ~ 1.20.4 / NeoForge 1.20.1: `CustomSkinLoader_ForgeV2-${version}.pom`
|
||||||
```xml
|
```xml
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>mods</groupId>
|
<groupId>mods</groupId>
|
||||||
<artifactId>CustomSkinLoader_ForgeActive</artifactId>
|
<artifactId>CustomSkinLoader_ForgeV2</artifactId>
|
||||||
<!-- `${version}` should be repalced with something like `14.14-SNAPSHOT-00` manually -->
|
<!-- `${version}` should be repalced with something like `15.0-SNAPSHOT-00` manually -->
|
||||||
|
<version>${version}</version>
|
||||||
|
</project>
|
||||||
|
```
|
||||||
|
- Forge 1.20.6 ~ latest / NeoForge 1.20.2 ~ latest: `CustomSkinLoader_ForgeV3-${version}.pom`
|
||||||
|
```xml
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<groupId>mods</groupId>
|
||||||
|
<artifactId>CustomSkinLoader_ForgeV3</artifactId>
|
||||||
|
<!-- `${version}` should be repalced with something like `15.0-SNAPSHOT-00` manually -->
|
||||||
<version>${version}</version>
|
<version>${version}</version>
|
||||||
</project>
|
</project>
|
||||||
```
|
```
|
||||||
@@ -62,7 +74,7 @@ There are the available versions in different environments below:
|
|||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>mods</groupId>
|
<groupId>mods</groupId>
|
||||||
<artifactId>CustomSkinLoader_Fabric</artifactId>
|
<artifactId>CustomSkinLoader_Fabric</artifactId>
|
||||||
<!-- `${version}` should be repalced with something like `14.14-SNAPSHOT-00` manually -->
|
<!-- `${version}` should be repalced with something like `15.0-SNAPSHOT-00` manually -->
|
||||||
<version>${version}</version>
|
<version>${version}</version>
|
||||||
</project>
|
</project>
|
||||||
```
|
```
|
||||||
@@ -71,25 +83,22 @@ There are the available versions in different environments below:
|
|||||||
1. Add below contents to `build.gradle`:
|
1. Add below contents to `build.gradle`:
|
||||||
```gradle
|
```gradle
|
||||||
dependencies {
|
dependencies {
|
||||||
deobfCompile "mods:CustomSkinLoader_ForgeLegacy:14.14-SNAPSHOT-00"
|
deobfCompile "mods:CustomSkinLoader_ForgeLegacy:15.0-SNAPSHOT-00"
|
||||||
}
|
}
|
||||||
|
|
||||||
minecraft {
|
minecraft {
|
||||||
clientRunArgs += ["--tweakClass", "customskinloader.forge.ForgeDevTweaker", "--username", "<Your username>"]
|
clientRunArgs += ["--tweakClass", "customskinloader.forge.ForgeDevTweaker", "--username", "<Your username>"]
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
1. Run `./gradlew setupDecompWorkspace eclipse` command.
|
1. Run `./gradlew setupDecompWorkspace` command.
|
||||||
1. Due to the run configurations which generated by ForgeGradle 2 has not been compatible with IntelliJ IDEA 2020 and above, we recommend to install [Eclipser](https://plugins.jetbrains.com/plugin/7153-eclipser) plugin. It can convert Eclipse run configurations to IDEA. (Right click to `*.launch` file in project folder, then select `Convert with Eclipser`, then a new IDEA run configuration will be created.)
|
|
||||||
1. For IDEA, open `Run/Debug Configurations` dialog, change classpath of module to the name contains `.main`.
|
|
||||||
1. Add `--tweakClass customskinloader.forge.ForgeDevTweaker --username <Your username>` to CLI arguments in `Run/Debug Configurations` dialog.
|
|
||||||
1. Then you can debug the mod in IDE or through `./gradlew runClient` command.
|
1. Then you can debug the mod in IDE or through `./gradlew runClient` command.
|
||||||
|
|
||||||
### For ForgeGradle 3.x ~ 5.x ( forge-1.12.2-14.23.5.2851 ~ latest )
|
### For ForgeGradle 3.x ~ latest ( forge-1.12.2-14.23.5.2851 ~ latest )
|
||||||
1. Add below contents to `build.gradle`:
|
1. Add below contents to `build.gradle`:
|
||||||
```gradle
|
```gradle
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation fg.deobf("mods:CustomSkinLoader_ForgeLegacy:14.14-SNAPSHOT-00") // Only required for MinecraftForge 1.8 ~ 1.16.5
|
implementation fg.deobf("mods:CustomSkinLoader_ForgeLegacy:15.0-SNAPSHOT-00") // Only required for MinecraftForge 1.8 ~ 1.16.5
|
||||||
implementation fg.deobf("mods:CustomSkinLoader_ForgeActive:14.14-SNAPSHOT-00") // Only required for MinecraftForge 1.17.1 ~ latest
|
implementation fg.deobf("mods:CustomSkinLoader_ForgeActive:15.0-SNAPSHOT-00") // Only required for MinecraftForge 1.17.1 ~ latest
|
||||||
}
|
}
|
||||||
|
|
||||||
minecraft {
|
minecraft {
|
||||||
@@ -107,15 +116,12 @@ There are the available versions in different environments below:
|
|||||||
1. Add below contents to `build.gradle`:
|
1. Add below contents to `build.gradle`:
|
||||||
```gradle
|
```gradle
|
||||||
dependencies {
|
dependencies {
|
||||||
modImplementation "mods:CustomSkinLoader_Fabric:14.14-SNAPSHOT-00"
|
modImplementation "mods:CustomSkinLoader_Fabric:15.0-SNAPSHOT-00"
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks.runClient {
|
loom.runs.client.programArgs "--username", "<Your username>"
|
||||||
args += ["--username", "<Your username>"]
|
|
||||||
}
|
|
||||||
```
|
```
|
||||||
1. Add `--username <Your username>` to CLI arguments in `Run/Debug Configurations` dialog.
|
1. Setup the development environment and run the game as usual.
|
||||||
1. Run the game in IDE or through `./gradlew runClient` command..
|
|
||||||
|
|
||||||
## Depend on release builds
|
## Depend on release builds
|
||||||
1. Check the latest version in https://littlesk.in/csl-latest .
|
1. Check the latest version in https://littlesk.in/csl-latest .
|
||||||
@@ -148,5 +154,4 @@ There are the available versions in different environments below:
|
|||||||
|
|
||||||
## Developing
|
## Developing
|
||||||
- CustomSkinLoader is based on forge-1.12.2-14.23.5.2768 currently, including Fabric edition. We use custom reobfuscation mappings such as [Fabric.tsrg](Fabric/Fabric.tsrg) and [mixin.tsrg](Fabric/mixin.tsrg) to generate different editions jar and Mixin reference jsons.
|
- CustomSkinLoader is based on forge-1.12.2-14.23.5.2768 currently, including Fabric edition. We use custom reobfuscation mappings such as [Fabric.tsrg](Fabric/Fabric.tsrg) and [mixin.tsrg](Fabric/mixin.tsrg) to generate different editions jar and Mixin reference jsons.
|
||||||
- The source codes are all in `${projectDir}/sources` and resource files are in `${projectDir}/resources` instead of `src/main/java` and `src/main/resources`.
|
|
||||||
- Do not add other required mods.
|
- Do not add other required mods.
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
// This subproject is only to provide dependency for other subprojects.
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
implementation project(':Dummy')
|
||||||
|
}
|
||||||
@@ -1,106 +0,0 @@
|
|||||||
package customskinloader;
|
|
||||||
|
|
||||||
import java.io.BufferedWriter;
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.FileOutputStream;
|
|
||||||
import java.io.OutputStreamWriter;
|
|
||||||
import java.io.PrintWriter;
|
|
||||||
import java.io.StringWriter;
|
|
||||||
import java.text.SimpleDateFormat;
|
|
||||||
import java.util.Date;
|
|
||||||
|
|
||||||
@SuppressWarnings("ResultOfMethodCallIgnored")
|
|
||||||
public class Logger {
|
|
||||||
private static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
||||||
public enum Level{
|
|
||||||
DEBUG("DEBUG",false),
|
|
||||||
INFO("INFO",true),
|
|
||||||
WARNING("WARNING",true);
|
|
||||||
|
|
||||||
|
|
||||||
String name;
|
|
||||||
boolean display;
|
|
||||||
Level(String name,boolean display){
|
|
||||||
this.name=name;
|
|
||||||
this.display=display;
|
|
||||||
}
|
|
||||||
public String getName(){
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
public boolean display(){
|
|
||||||
return display;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
private BufferedWriter writer=null;
|
|
||||||
public Logger(){
|
|
||||||
//Logger isn't created.
|
|
||||||
}
|
|
||||||
public Logger(String logFile) {
|
|
||||||
this(new File(logFile));
|
|
||||||
}
|
|
||||||
public Logger(File logFile){
|
|
||||||
try {
|
|
||||||
if(!logFile.getParentFile().exists()){
|
|
||||||
logFile.getParentFile().mkdirs();
|
|
||||||
}
|
|
||||||
if(!logFile.exists())
|
|
||||||
logFile.createNewFile();
|
|
||||||
|
|
||||||
writer = new BufferedWriter(new OutputStreamWriter(
|
|
||||||
new FileOutputStream(logFile), "UTF-8"));
|
|
||||||
|
|
||||||
System.out.println("Log Path: " + logFile.getAbsolutePath());
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public void close(){
|
|
||||||
if(writer!=null){
|
|
||||||
try {
|
|
||||||
writer.close();
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void log(Level level,String msg){
|
|
||||||
if(!level.display()&&writer==null)
|
|
||||||
return;
|
|
||||||
String sb = String.format("[%s %s] %s", Thread.currentThread().getName(), level.getName(), msg);
|
|
||||||
if(level.display())
|
|
||||||
System.out.println(sb);
|
|
||||||
if(writer==null)
|
|
||||||
return;
|
|
||||||
try {
|
|
||||||
String sb2 = String.format("[%s] %s\r\n", DATE_FORMAT.format(new Date()), sb);
|
|
||||||
writer.write(sb2);
|
|
||||||
writer.flush();
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public void debug(String msg){
|
|
||||||
log(Level.DEBUG,msg);
|
|
||||||
}
|
|
||||||
public void debug(String format, Object... objs) {
|
|
||||||
debug(String.format(format, objs));
|
|
||||||
}
|
|
||||||
public void info(String msg){
|
|
||||||
log(Level.INFO,msg);
|
|
||||||
}
|
|
||||||
public void info(String format, Object... objs){
|
|
||||||
info(String.format(format, objs));
|
|
||||||
}
|
|
||||||
public void warning(String msg){
|
|
||||||
log(Level.WARNING,msg);
|
|
||||||
}
|
|
||||||
public void warning(String format, Object... objs){
|
|
||||||
warning(String.format(format, objs));
|
|
||||||
}
|
|
||||||
public void warning(Throwable e){
|
|
||||||
StringWriter sw = new StringWriter();
|
|
||||||
e.printStackTrace(new PrintWriter(sw));
|
|
||||||
log(Level.WARNING,"Exception: "+sw.toString());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,151 +0,0 @@
|
|||||||
package customskinloader.fake;
|
|
||||||
|
|
||||||
import java.awt.image.BufferedImage;
|
|
||||||
import java.io.File;
|
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
|
||||||
|
|
||||||
import com.google.common.collect.Maps;
|
|
||||||
import com.google.common.hash.Hashing;
|
|
||||||
import com.mojang.authlib.GameProfile;
|
|
||||||
import com.mojang.authlib.minecraft.MinecraftProfileTexture;
|
|
||||||
import com.mojang.authlib.minecraft.MinecraftSessionService;
|
|
||||||
import customskinloader.CustomSkinLoader;
|
|
||||||
import customskinloader.fake.itf.FakeInterfaceManager;
|
|
||||||
import customskinloader.utils.HttpTextureUtil;
|
|
||||||
import net.minecraft.client.Minecraft;
|
|
||||||
import net.minecraft.client.renderer.IImageBuffer;
|
|
||||||
import net.minecraft.client.renderer.texture.SimpleTexture;
|
|
||||||
import net.minecraft.client.renderer.texture.TextureManager;
|
|
||||||
import net.minecraft.client.resources.DefaultPlayerSkin;
|
|
||||||
import net.minecraft.client.resources.SkinManager;
|
|
||||||
import net.minecraft.util.ResourceLocation;
|
|
||||||
|
|
||||||
public class FakeSkinManager {
|
|
||||||
private final TextureManager textureManager;
|
|
||||||
|
|
||||||
private final Map<ResourceLocation, MinecraftProfileTexture> modelCache = new ConcurrentHashMap<>();
|
|
||||||
|
|
||||||
public FakeSkinManager(TextureManager textureManagerInstance, File skinCacheDirectory, MinecraftSessionService sessionService) {
|
|
||||||
this.textureManager = textureManagerInstance;
|
|
||||||
HttpTextureUtil.defaultCacheDir = skinCacheDirectory;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ResourceLocation loadSkin(MinecraftProfileTexture profileTexture, MinecraftProfileTexture.Type textureType) {
|
|
||||||
return this.loadSkin(profileTexture, textureType, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
public ResourceLocation loadSkin(final MinecraftProfileTexture profileTexture, final MinecraftProfileTexture.Type textureType, final SkinManager.SkinAvailableCallback skinAvailableCallback) {
|
|
||||||
return this.loadSkin(profileTexture, HttpTextureUtil.toHttpTextureInfo(profileTexture.getUrl()), textureType, skinAvailableCallback);
|
|
||||||
}
|
|
||||||
|
|
||||||
private ResourceLocation loadSkin(final MinecraftProfileTexture profileTexture, final HttpTextureUtil.HttpTextureInfo info, final MinecraftProfileTexture.Type textureType, final SkinManager.SkinAvailableCallback skinAvailableCallback) {
|
|
||||||
final ResourceLocation resourcelocation = new ResourceLocation("skins/" + Hashing.sha1().hashUnencodedChars(info.hash).toString());
|
|
||||||
|
|
||||||
if (FakeInterfaceManager.TextureManager_getTexture(this.textureManager, resourcelocation, null) != null) {//Have already loaded
|
|
||||||
makeCallback(skinAvailableCallback, textureType, resourcelocation, modelCache.getOrDefault(resourcelocation, profileTexture));
|
|
||||||
} else {
|
|
||||||
SimpleTexture threaddownloadimagedata = FakeThreadDownloadImageData.createThreadDownloadImageData(info.cacheFile, info.url, DefaultPlayerSkin.getDefaultSkinLegacy(), new BaseBuffer(skinAvailableCallback, textureType, resourcelocation, profileTexture), textureType);
|
|
||||||
if (skinAvailableCallback instanceof FakeClientPlayer.LegacyBuffer)//Cache for client player
|
|
||||||
FakeClientPlayer.textureCache.put(resourcelocation, threaddownloadimagedata);
|
|
||||||
FakeInterfaceManager.TextureManager_loadTexture(this.textureManager, resourcelocation, threaddownloadimagedata);
|
|
||||||
}
|
|
||||||
return resourcelocation;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void loadProfileTextures(final GameProfile profile, final SkinManager.SkinAvailableCallback skinAvailableCallback, final boolean requireSecure) {
|
|
||||||
CustomSkinLoader.loadProfileTextures(() -> CustomSkinLoader.loadProfileLazily(profile, m -> {
|
|
||||||
final Map<MinecraftProfileTexture.Type, MinecraftProfileTexture> map = Maps.newHashMap();
|
|
||||||
map.putAll(m);
|
|
||||||
|
|
||||||
for (MinecraftProfileTexture.Type type : MinecraftProfileTexture.Type.values()) {
|
|
||||||
MinecraftProfileTexture profileTexture = map.get(type);
|
|
||||||
if (profileTexture != null) {
|
|
||||||
HttpTextureUtil.HttpTextureInfo info = HttpTextureUtil.toHttpTextureInfo(profileTexture.getUrl());
|
|
||||||
FakeThreadDownloadImageData.downloadTexture(info.cacheFile, info.url);
|
|
||||||
|
|
||||||
FakeInterfaceManager.Minecraft_addScheduledTask(Minecraft.getMinecraft(), () -> {
|
|
||||||
CustomSkinLoader.logger.debug("Loading type: " + type);
|
|
||||||
try {
|
|
||||||
this.loadSkin(profileTexture, info, type, skinAvailableCallback);
|
|
||||||
} catch (Throwable t) {
|
|
||||||
CustomSkinLoader.logger.warning(t);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
|
|
||||||
public Map<MinecraftProfileTexture.Type, MinecraftProfileTexture> loadSkinFromCache(GameProfile profile) {
|
|
||||||
Map<MinecraftProfileTexture.Type, MinecraftProfileTexture> map = CustomSkinLoader.loadProfileFromCache(profile);
|
|
||||||
for (Iterator<Map.Entry<MinecraftProfileTexture.Type, MinecraftProfileTexture>> it = map.entrySet().iterator(); it.hasNext(); ) {
|
|
||||||
Map.Entry<MinecraftProfileTexture.Type, MinecraftProfileTexture> entry = it.next();
|
|
||||||
MinecraftProfileTexture texture = entry.getValue();
|
|
||||||
if (shouldJudgeType(texture)) {
|
|
||||||
texture = this.modelCache.get(this.loadSkin(texture, entry.getKey()));
|
|
||||||
if (texture == null) { // remove texture if was not loaded before
|
|
||||||
it.remove();
|
|
||||||
} else {
|
|
||||||
map.put(entry.getKey(), texture);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return map;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void makeCallback(SkinManager.SkinAvailableCallback callback, MinecraftProfileTexture.Type type, ResourceLocation location, MinecraftProfileTexture texture) {
|
|
||||||
if (callback != null)
|
|
||||||
callback.skinAvailable(type, location, texture);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static boolean shouldJudgeType(MinecraftProfileTexture texture) {
|
|
||||||
return texture != null && "auto".equals(texture.getMetadata("model"));
|
|
||||||
}
|
|
||||||
|
|
||||||
private class BaseBuffer implements IImageBuffer {
|
|
||||||
private IImageBuffer buffer;
|
|
||||||
|
|
||||||
private SkinManager.SkinAvailableCallback callback;
|
|
||||||
private MinecraftProfileTexture.Type type;
|
|
||||||
private ResourceLocation location;
|
|
||||||
private MinecraftProfileTexture texture;
|
|
||||||
|
|
||||||
public BaseBuffer(SkinManager.SkinAvailableCallback callback, MinecraftProfileTexture.Type type, ResourceLocation location, MinecraftProfileTexture texture) {
|
|
||||||
switch (type) {
|
|
||||||
case SKIN: this.buffer = new FakeSkinBuffer(); break;
|
|
||||||
case CAPE: this.buffer = new FakeCapeBuffer(location); break;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.callback = callback;
|
|
||||||
this.type = type;
|
|
||||||
this.location = location;
|
|
||||||
this.texture = texture;
|
|
||||||
}
|
|
||||||
|
|
||||||
public net.minecraft.client.renderer.texture.NativeImage func_195786_a(net.minecraft.client.renderer.texture.NativeImage image) {
|
|
||||||
return buffer instanceof FakeSkinBuffer ? ((FakeSkinBuffer) buffer).func_195786_a(image) : image;
|
|
||||||
}
|
|
||||||
|
|
||||||
public BufferedImage parseUserSkin(BufferedImage image) {
|
|
||||||
return buffer instanceof FakeSkinBuffer ? ((FakeSkinBuffer) buffer).parseUserSkin(image) : image;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void skinAvailable() {
|
|
||||||
if (buffer != null) {
|
|
||||||
buffer.skinAvailable();
|
|
||||||
if (shouldJudgeType(texture) && buffer instanceof FakeSkinBuffer) {
|
|
||||||
//Auto judge skin type
|
|
||||||
Map<String, String> metadata = Maps.newHashMap();
|
|
||||||
String type = ((FakeSkinBuffer) buffer).judgeType();
|
|
||||||
metadata.put("model", type);
|
|
||||||
texture = new MinecraftProfileTexture(texture.getUrl(), metadata);
|
|
||||||
FakeSkinManager.this.modelCache.put(location, texture);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
FakeSkinManager.makeCallback(callback, type, location, texture);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,101 +0,0 @@
|
|||||||
package customskinloader.fake;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.util.EnumMap;
|
|
||||||
import java.util.function.Supplier;
|
|
||||||
|
|
||||||
import com.mojang.authlib.minecraft.MinecraftProfileTexture;
|
|
||||||
import customskinloader.CustomSkinLoader;
|
|
||||||
import customskinloader.utils.HttpRequestUtil;
|
|
||||||
import net.minecraft.client.renderer.IImageBuffer;
|
|
||||||
import net.minecraft.client.renderer.ThreadDownloadImageData;
|
|
||||||
import net.minecraft.client.renderer.texture.DownloadingTexture;
|
|
||||||
import net.minecraft.client.renderer.texture.SimpleTexture;
|
|
||||||
import net.minecraft.util.ResourceLocation;
|
|
||||||
|
|
||||||
public class FakeThreadDownloadImageData {
|
|
||||||
private static IThreadDownloadImageDataBuilder builder;
|
|
||||||
|
|
||||||
public static SimpleTexture createThreadDownloadImageData(File cacheFileIn, String imageUrlIn, ResourceLocation textureResourceLocationIn, IImageBuffer imageBufferIn, MinecraftProfileTexture.Type textureTypeIn) {
|
|
||||||
SimpleTexture texture = null;
|
|
||||||
if (FakeThreadDownloadImageData.builder == null) {
|
|
||||||
EnumMap<ThreadDownloadImageDataBuilder, Throwable> throwables = new EnumMap<>(ThreadDownloadImageDataBuilder.class);
|
|
||||||
for (ThreadDownloadImageDataBuilder builder : ThreadDownloadImageDataBuilder.values()) {
|
|
||||||
try {
|
|
||||||
FakeThreadDownloadImageData.builder = builder.get().get();
|
|
||||||
texture = FakeThreadDownloadImageData.builder.build(cacheFileIn, imageUrlIn, textureResourceLocationIn, imageBufferIn, textureTypeIn);
|
|
||||||
CustomSkinLoader.logger.info("ThreadDownloadImageData Class: %s", texture.getClass().getName());
|
|
||||||
break;
|
|
||||||
} catch (Throwable t) {
|
|
||||||
throwables.put(builder, t);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (texture == null) {
|
|
||||||
CustomSkinLoader.logger.warning("Unable to get ThreadDownloadImageData Class: ");
|
|
||||||
throwables.forEach((k, v) -> {
|
|
||||||
CustomSkinLoader.logger.warning("Caused by: (%s)", k.name());
|
|
||||||
CustomSkinLoader.logger.warning(v);
|
|
||||||
});
|
|
||||||
throw new RuntimeException("Unable to get ThreadDownloadImageData Class!");
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
texture = builder.build(cacheFileIn, imageUrlIn, textureResourceLocationIn, imageBufferIn, textureTypeIn);
|
|
||||||
}
|
|
||||||
return texture;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void downloadTexture(File cacheFile, String imageUrl) {
|
|
||||||
HttpRequestUtil.HttpRequest request = new HttpRequestUtil.HttpRequest(imageUrl).setLoadContent(false).setCacheTime(0).setCacheFile(cacheFile);
|
|
||||||
for (int i = 0; i <= CustomSkinLoader.config.retryTime; i++) {
|
|
||||||
if (i != 0) {
|
|
||||||
CustomSkinLoader.logger.debug("Retry to download texture %s (%s)", imageUrl, i);
|
|
||||||
}
|
|
||||||
if (HttpRequestUtil.makeHttpRequest(request).success) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private interface IThreadDownloadImageDataBuilder {
|
|
||||||
SimpleTexture build(File cacheFile, String imageUrl, ResourceLocation textureResourceLocation, IImageBuffer imageBuffer, MinecraftProfileTexture.Type textureType);
|
|
||||||
}
|
|
||||||
|
|
||||||
private enum ThreadDownloadImageDataBuilder {
|
|
||||||
// DO NOT replace new IThreadDownloadImageDataBuilder() with lambda.
|
|
||||||
V1(() -> new IThreadDownloadImageDataBuilder() { // Forge 1.8.x~1.12.x
|
|
||||||
@Override
|
|
||||||
public SimpleTexture build(File cacheFile, String imageUrl, ResourceLocation textureResourceLocation, IImageBuffer imageBuffer, MinecraftProfileTexture.Type textureType) {
|
|
||||||
return new ThreadDownloadImageData(cacheFile, imageUrl, textureResourceLocation, imageBuffer);
|
|
||||||
}
|
|
||||||
}),
|
|
||||||
V2(() -> new IThreadDownloadImageDataBuilder() { // Forge 1.13.x
|
|
||||||
@Override
|
|
||||||
public SimpleTexture build(File cacheFile, String imageUrl, ResourceLocation textureResourceLocation, IImageBuffer imageBuffer, MinecraftProfileTexture.Type textureType) {
|
|
||||||
return new net.minecraft.client.renderer.texture.ThreadDownloadImageData(cacheFile, imageUrl, textureResourceLocation, imageBuffer);
|
|
||||||
}
|
|
||||||
}),
|
|
||||||
V3(() -> new IThreadDownloadImageDataBuilder() { // Forge 1.14.x
|
|
||||||
@Override
|
|
||||||
public SimpleTexture build(File cacheFile, String imageUrl, ResourceLocation textureResourceLocation, IImageBuffer imageBuffer, MinecraftProfileTexture.Type textureType) {
|
|
||||||
return new DownloadingTexture(cacheFile, imageUrl, textureResourceLocation, imageBuffer);
|
|
||||||
}
|
|
||||||
}),
|
|
||||||
V4(() -> new IThreadDownloadImageDataBuilder() { // Forge 1.15.x~1.16.x
|
|
||||||
@Override
|
|
||||||
public SimpleTexture build(File cacheFile, String imageUrl, ResourceLocation textureResourceLocation, IImageBuffer imageBuffer, MinecraftProfileTexture.Type textureType) {
|
|
||||||
return new DownloadingTexture(cacheFile, imageUrl, textureResourceLocation, true, imageBuffer);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
private final Supplier<IThreadDownloadImageDataBuilder> builder;
|
|
||||||
|
|
||||||
ThreadDownloadImageDataBuilder(Supplier<IThreadDownloadImageDataBuilder> builder) {
|
|
||||||
this.builder = builder;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Supplier<IThreadDownloadImageDataBuilder> get() {
|
|
||||||
return this.builder;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,43 +0,0 @@
|
|||||||
package customskinloader.fake.itf;
|
|
||||||
|
|
||||||
import java.awt.image.BufferedImage;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStream;
|
|
||||||
import java.util.Optional;
|
|
||||||
|
|
||||||
import net.minecraft.client.Minecraft;
|
|
||||||
import net.minecraft.client.renderer.texture.Texture;
|
|
||||||
import net.minecraft.client.renderer.texture.TextureManager;
|
|
||||||
import net.minecraft.client.resources.IResource;
|
|
||||||
import net.minecraft.client.resources.IResourceManager;
|
|
||||||
import net.minecraft.util.ResourceLocation;
|
|
||||||
|
|
||||||
public class FakeInterfaceManager {
|
|
||||||
public static InputStream IResource_getInputStream(Object resource) {
|
|
||||||
return ((IFakeIResource.V2) resource).open();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Optional<IResource> IResourceManager_getResource(Object resourceManager, ResourceLocation location) throws IOException {
|
|
||||||
return ((IFakeIResourceManager) resourceManager).getResource(location);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static IResourceManager Minecraft_getResourceManager(Minecraft minecraft) {
|
|
||||||
return (IResourceManager) ((IFakeMinecraft) minecraft).func_195551_G();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void Minecraft_addScheduledTask(Minecraft minecraft, Runnable runnable) {
|
|
||||||
((IFakeMinecraft) minecraft).execute(runnable);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void TextureManager_loadTexture(TextureManager textureManager, ResourceLocation textureLocation, Object textureObj) {
|
|
||||||
((IFakeTextureManager.V2) textureManager).func_229263_a_(textureLocation, (Texture) textureObj);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Texture TextureManager_getTexture(TextureManager textureManager, ResourceLocation textureLocation, Object textureObj) {
|
|
||||||
return ((IFakeTextureManager.V1) textureManager).getTexture(textureLocation, (Texture) textureObj);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void ThreadDownloadImageData_resetNewBufferedImage(Object threadDownloadImageData, BufferedImage image) {
|
|
||||||
((IFakeThreadDownloadImageData) threadDownloadImageData).resetNewBufferedImage(image);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,28 +0,0 @@
|
|||||||
package customskinloader.fake.itf;
|
|
||||||
|
|
||||||
import net.minecraft.client.renderer.texture.ITextureObject;
|
|
||||||
import net.minecraft.client.renderer.texture.Texture;
|
|
||||||
import net.minecraft.client.renderer.texture.TextureManager;
|
|
||||||
import net.minecraft.util.ResourceLocation;
|
|
||||||
|
|
||||||
public interface IFakeTextureManager {
|
|
||||||
interface V1 {
|
|
||||||
default boolean func_229263_a_(ResourceLocation textureLocation, Texture textureObj) {
|
|
||||||
return ((TextureManager) this).loadTexture(textureLocation, (ITextureObject) textureObj);
|
|
||||||
}
|
|
||||||
|
|
||||||
default Texture func_229267_b_(ResourceLocation textureLocation) {
|
|
||||||
return (Texture) ((TextureManager) this).getTexture(textureLocation);
|
|
||||||
}
|
|
||||||
|
|
||||||
default Texture getTexture(ResourceLocation textureLocation, Texture textureObj) {
|
|
||||||
return func_229267_b_(textureLocation);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
interface V2 {
|
|
||||||
default void func_229263_a_(ResourceLocation textureLocation, Texture textureObj) {
|
|
||||||
((IFakeTextureManager.V1) this).func_229263_a_(textureLocation, textureObj);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
package customskinloader.fake.itf;
|
|
||||||
|
|
||||||
import java.awt.image.BufferedImage;
|
|
||||||
|
|
||||||
// This interface is only available before 1.12.2
|
|
||||||
public interface IFakeThreadDownloadImageData {
|
|
||||||
/**
|
|
||||||
* Reset {@link net.minecraft.client.renderer.ThreadDownloadImageData#bufferedImage} and
|
|
||||||
* {@link net.minecraft.client.renderer.ThreadDownloadImageData#textureUploaded} to false to refresh texture.
|
|
||||||
*/
|
|
||||||
void resetNewBufferedImage(BufferedImage image);
|
|
||||||
}
|
|
||||||
@@ -1,119 +0,0 @@
|
|||||||
package customskinloader.loader.jsonapi;
|
|
||||||
|
|
||||||
import java.util.LinkedHashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import com.google.common.collect.Lists;
|
|
||||||
import customskinloader.CustomSkinLoader;
|
|
||||||
import customskinloader.config.SkinSiteProfile;
|
|
||||||
import customskinloader.loader.JsonAPILoader;
|
|
||||||
import customskinloader.plugin.ICustomSkinLoaderPlugin;
|
|
||||||
import customskinloader.profile.ModelManager0;
|
|
||||||
import customskinloader.profile.UserProfile;
|
|
||||||
import customskinloader.utils.HttpTextureUtil;
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
|
||||||
|
|
||||||
public class CustomSkinAPI implements JsonAPILoader.IJsonAPI {
|
|
||||||
|
|
||||||
public static class LittleSkin extends JsonAPILoader.DefaultProfile {
|
|
||||||
public LittleSkin(JsonAPILoader loader) { super(loader); }
|
|
||||||
@Override public String getName() { return "LittleSkin"; }
|
|
||||||
@Override public int getPriority() { return 200; }
|
|
||||||
@Override public String getRoot() { return "https://littleskin.cn/csl/"; }
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class BlessingSkin extends JsonAPILoader.DefaultProfile {
|
|
||||||
public BlessingSkin(JsonAPILoader loader) { super(loader); }
|
|
||||||
@Override public String getName() { return "BlessingSkin"; }
|
|
||||||
@Override public int getPriority() { return 300; }
|
|
||||||
@Override public String getRoot() { return "https://skin.prinzeugen.net/"; }
|
|
||||||
}
|
|
||||||
|
|
||||||
// // OneSkin has been removed temporarily
|
|
||||||
// public static class OneSkin extends JsonAPILoader.DefaultProfile {
|
|
||||||
// public OneSkin(JsonAPILoader loader) { super(loader); }
|
|
||||||
// @Override public String getName() { return "OneSkin"; }
|
|
||||||
// @Override public int getPriority() { return 500; }
|
|
||||||
// @Override public String getRoot() { return "http://fleey.cn/skin/skin_user/skin_json.php/"; }
|
|
||||||
// }
|
|
||||||
|
|
||||||
private static final String TEXTURES="textures/";
|
|
||||||
private static final String SUFFIX=".json";
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<ICustomSkinLoaderPlugin.IDefaultProfile> getDefaultProfiles(JsonAPILoader loader) {
|
|
||||||
return Lists.newArrayList(new LittleSkin(loader), new BlessingSkin(loader));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toJsonUrl(String root, String username) {
|
|
||||||
return root + username + SUFFIX;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public UserProfile toUserProfile(String root, String json, boolean local) {
|
|
||||||
CustomSkinAPIProfile profile=CustomSkinLoader.GSON.fromJson(json, CustomSkinAPIProfile.class);
|
|
||||||
UserProfile p=new UserProfile();
|
|
||||||
|
|
||||||
if(StringUtils.isNotBlank(profile.skin)){
|
|
||||||
p.skinUrl=root+TEXTURES+profile.skin;
|
|
||||||
if(local)
|
|
||||||
p.skinUrl=HttpTextureUtil.getLocalFakeUrl(p.skinUrl);
|
|
||||||
}
|
|
||||||
if(StringUtils.isNotBlank(profile.cape)){
|
|
||||||
p.capeUrl=root+TEXTURES+profile.cape;
|
|
||||||
if(local)
|
|
||||||
p.capeUrl=HttpTextureUtil.getLocalFakeUrl(p.capeUrl);
|
|
||||||
}
|
|
||||||
if(StringUtils.isNotBlank(profile.elytra)){
|
|
||||||
p.elytraUrl=root+TEXTURES+profile.elytra;
|
|
||||||
if(local)
|
|
||||||
p.elytraUrl=HttpTextureUtil.getLocalFakeUrl(p.elytraUrl);
|
|
||||||
}
|
|
||||||
|
|
||||||
Map<String,String> textures=new LinkedHashMap<>();
|
|
||||||
if(profile.skins!=null)
|
|
||||||
textures.putAll(profile.skins);
|
|
||||||
if(profile.textures!=null)
|
|
||||||
textures.putAll(profile.textures);
|
|
||||||
if(textures.isEmpty())
|
|
||||||
return p;
|
|
||||||
|
|
||||||
boolean hasSkin=false;
|
|
||||||
for(String model:textures.keySet()){
|
|
||||||
ModelManager0.Model enumModel=ModelManager0.getEnumModel(model);
|
|
||||||
if(enumModel==null||StringUtils.isEmpty(textures.get(model)))
|
|
||||||
continue;
|
|
||||||
if(ModelManager0.isSkin(enumModel))
|
|
||||||
if(hasSkin)
|
|
||||||
continue;
|
|
||||||
else
|
|
||||||
hasSkin=true;
|
|
||||||
String url=root+TEXTURES+textures.get(model);
|
|
||||||
if(local)
|
|
||||||
url=HttpTextureUtil.getLocalFakeUrl(url);
|
|
||||||
p.put(enumModel, url);
|
|
||||||
}
|
|
||||||
|
|
||||||
return p;
|
|
||||||
}
|
|
||||||
private static class CustomSkinAPIProfile{
|
|
||||||
public String username;
|
|
||||||
public LinkedHashMap<String,String> textures;
|
|
||||||
|
|
||||||
public LinkedHashMap<String,String> skins;
|
|
||||||
|
|
||||||
public String skin;
|
|
||||||
public String cape;
|
|
||||||
public String elytra;
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public String getPayload(SkinSiteProfile ssp) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public String getName() {
|
|
||||||
return "CustomSkinAPI";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,93 +0,0 @@
|
|||||||
package customskinloader.loader.jsonapi;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import com.google.common.collect.Lists;
|
|
||||||
import customskinloader.CustomSkinLoader;
|
|
||||||
import customskinloader.config.SkinSiteProfile;
|
|
||||||
import customskinloader.loader.JsonAPILoader;
|
|
||||||
import customskinloader.plugin.ICustomSkinLoaderPlugin;
|
|
||||||
import customskinloader.profile.ModelManager0;
|
|
||||||
import customskinloader.profile.UserProfile;
|
|
||||||
import customskinloader.utils.HttpTextureUtil;
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
|
||||||
|
|
||||||
public class UniSkinAPI implements JsonAPILoader.IJsonAPI {
|
|
||||||
|
|
||||||
public static class SkinMe extends JsonAPILoader.DefaultProfile {
|
|
||||||
public SkinMe(JsonAPILoader loader) { super(loader); }
|
|
||||||
@Override public String getName() { return "SkinMe"; }
|
|
||||||
@Override public int getPriority() { return 500; }
|
|
||||||
@Override public String getRoot() { return "http://www.skinme.cc/uniskin/"; }
|
|
||||||
}
|
|
||||||
|
|
||||||
private static final String TEXTURES="textures/";
|
|
||||||
private static final String SUFFIX=".json";
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<ICustomSkinLoaderPlugin.IDefaultProfile> getDefaultProfiles(JsonAPILoader loader) {
|
|
||||||
return Lists.newArrayList(new SkinMe(loader));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toJsonUrl(String root, String username) {
|
|
||||||
return root + username + SUFFIX;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public UserProfile toUserProfile(String root, String json, boolean local) {
|
|
||||||
UniSkinAPIProfile profile=CustomSkinLoader.GSON.fromJson(json, UniSkinAPIProfile.class);
|
|
||||||
UserProfile p=new UserProfile();
|
|
||||||
|
|
||||||
if(StringUtils.isNotBlank(profile.cape)){
|
|
||||||
p.capeUrl=root+TEXTURES+profile.cape;
|
|
||||||
if(local)
|
|
||||||
p.capeUrl=HttpTextureUtil.getLocalFakeUrl(p.capeUrl);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(profile.skins==null||profile.skins.isEmpty())
|
|
||||||
return p;
|
|
||||||
if(profile.model_preference==null||profile.model_preference.isEmpty())
|
|
||||||
return p;
|
|
||||||
|
|
||||||
boolean hasSkin=false;
|
|
||||||
for(String model:profile.model_preference){
|
|
||||||
ModelManager0.Model enumModel=ModelManager0.getEnumModel(model);
|
|
||||||
if(enumModel==null||StringUtils.isEmpty(profile.skins.get(model)))
|
|
||||||
continue;
|
|
||||||
if(ModelManager0.isSkin(enumModel))
|
|
||||||
if(hasSkin)
|
|
||||||
continue;
|
|
||||||
else
|
|
||||||
hasSkin=true;
|
|
||||||
String url=root+TEXTURES+profile.skins.get(model);
|
|
||||||
if(local)
|
|
||||||
url=HttpTextureUtil.getLocalFakeUrl(url);
|
|
||||||
p.put(enumModel, url);
|
|
||||||
}
|
|
||||||
|
|
||||||
return p;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Json profile for UniSkinAPI
|
|
||||||
* Source Code: https://github.com/RecursiveG/UniSkinMod/blob/master/src/main/java/org/devinprogress/uniskinmod/UniSkinApiProfile.java#L18-L22
|
|
||||||
* @author RecursiveG
|
|
||||||
*/
|
|
||||||
private class UniSkinAPIProfile{
|
|
||||||
public String player_name;
|
|
||||||
public long last_update;
|
|
||||||
public List<String> model_preference;
|
|
||||||
public Map<String,String> skins;
|
|
||||||
|
|
||||||
public String cape;
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public String getPayload(SkinSiteProfile ssp) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public String getName() {
|
|
||||||
return "UniSkinAPI";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,160 +0,0 @@
|
|||||||
package customskinloader.profile;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.util.*;
|
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
|
||||||
|
|
||||||
import com.google.common.collect.Lists;
|
|
||||||
import org.apache.commons.codec.Charsets;
|
|
||||||
import org.apache.commons.codec.binary.Base64;
|
|
||||||
import org.apache.commons.io.FileUtils;
|
|
||||||
import org.apache.commons.io.FilenameUtils;
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
|
||||||
|
|
||||||
import com.google.common.collect.Iterables;
|
|
||||||
import com.google.common.collect.Maps;
|
|
||||||
import com.google.gson.Gson;
|
|
||||||
import com.google.gson.GsonBuilder;
|
|
||||||
import com.mojang.authlib.GameProfile;
|
|
||||||
import com.mojang.authlib.minecraft.MinecraftProfileTexture;
|
|
||||||
import com.mojang.authlib.minecraft.MinecraftProfileTexture.Type;
|
|
||||||
import com.mojang.authlib.properties.Property;
|
|
||||||
import com.mojang.util.UUIDTypeAdapter;
|
|
||||||
|
|
||||||
import customskinloader.CustomSkinLoader;
|
|
||||||
import customskinloader.utils.HttpRequestUtil;
|
|
||||||
import customskinloader.utils.HttpRequestUtil.HttpRequest;
|
|
||||||
import customskinloader.utils.HttpRequestUtil.HttpResponce;
|
|
||||||
import customskinloader.utils.HttpTextureUtil;
|
|
||||||
import customskinloader.utils.HttpUtil0;
|
|
||||||
|
|
||||||
public class DynamicSkullManager {
|
|
||||||
public static class SkullTexture{
|
|
||||||
public Map<Type,MinecraftProfileTexture> textures;
|
|
||||||
public String index;//Index File
|
|
||||||
public ArrayList<String> skins;
|
|
||||||
public int interval;
|
|
||||||
public boolean fromZero;
|
|
||||||
//For program
|
|
||||||
public long startTime;
|
|
||||||
public int period;
|
|
||||||
}
|
|
||||||
private Map<GameProfile, SkullTexture> dynamicTextures = new ConcurrentHashMap<>();
|
|
||||||
private Map<GameProfile, Map<Type, MinecraftProfileTexture>> staticTextures = new ConcurrentHashMap<>();
|
|
||||||
private List<GameProfile> loadingList=new ArrayList<GameProfile>();
|
|
||||||
|
|
||||||
private void parseGameProfile(GameProfile profile){
|
|
||||||
Property textureProperty = Iterables.getFirst(profile.getProperties().get("textures"), null);
|
|
||||||
if (textureProperty==null){
|
|
||||||
staticTextures.put(profile, Maps.<Type, MinecraftProfileTexture>newHashMap());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
String value=textureProperty.getValue();
|
|
||||||
if(StringUtils.isBlank(value)){
|
|
||||||
staticTextures.put(profile, Maps.<Type, MinecraftProfileTexture>newHashMap());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
@SuppressWarnings("deprecation") String json = new String(Base64.decodeBase64(value), Charsets.UTF_8);
|
|
||||||
Gson gson=new GsonBuilder().registerTypeAdapter(UUID.class,new UUIDTypeAdapter()).create();
|
|
||||||
SkullTexture result=gson.fromJson(json,SkullTexture.class);
|
|
||||||
if(result==null){
|
|
||||||
staticTextures.put(profile, Maps.<Type, MinecraftProfileTexture>newHashMap());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
staticTextures.put(profile, (result.textures==null || !result.textures.containsKey(Type.SKIN)) ?
|
|
||||||
Maps.<Type, MinecraftProfileTexture>newHashMap() : parseTextures(result.textures));
|
|
||||||
|
|
||||||
if(StringUtils.isNotEmpty(result.index)){
|
|
||||||
File indexFile=new File(CustomSkinLoader.DATA_DIR,result.index);
|
|
||||||
try{
|
|
||||||
String index=FileUtils.readFileToString(indexFile, "UTF-8");
|
|
||||||
if(StringUtils.isNotEmpty(index)){
|
|
||||||
String[] skins = CustomSkinLoader.GSON.fromJson(index, String[].class);
|
|
||||||
if(skins != null && skins.length != 0)
|
|
||||||
result.skins = Lists.newArrayList(skins);
|
|
||||||
}
|
|
||||||
}catch(Exception e){
|
|
||||||
CustomSkinLoader.logger.warning("Exception occurs while parsing index file: "+e.toString());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!CustomSkinLoader.config.enableDynamicSkull||result.skins==null||result.skins.isEmpty())
|
|
||||||
return;
|
|
||||||
|
|
||||||
CustomSkinLoader.logger.info("Try to load Dynamic Skull: "+json);
|
|
||||||
|
|
||||||
for(int i=0;i<result.skins.size();i++){//check and cache skins
|
|
||||||
String skin=result.skins.get(i);
|
|
||||||
if(HttpUtil0.isLocal(skin)){
|
|
||||||
//Local Skin
|
|
||||||
File skinFile=new File(CustomSkinLoader.DATA_DIR,skin);
|
|
||||||
if(skinFile.isFile()&&skinFile.length()>0){
|
|
||||||
//Skin found
|
|
||||||
String fakeUrl=HttpTextureUtil.getLocalFakeUrl(skin);
|
|
||||||
result.skins.set(i, fakeUrl);
|
|
||||||
}else{
|
|
||||||
//Could not find skin
|
|
||||||
result.skins.remove(i--);
|
|
||||||
}
|
|
||||||
}else{
|
|
||||||
//Online Skin
|
|
||||||
HttpResponce responce=HttpRequestUtil.makeHttpRequest(new HttpRequest(skin).setCacheFile(HttpTextureUtil.getCacheFile(FilenameUtils.getBaseName(skin))).setCacheTime(0).setLoadContent(false));
|
|
||||||
if(!responce.success){
|
|
||||||
//Could not load skin
|
|
||||||
result.skins.remove(i--);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(result.skins.isEmpty()){//Nothing loaded
|
|
||||||
CustomSkinLoader.logger.info("Failed: Nothing loaded.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
result.interval=Math.max(result.interval, 50);
|
|
||||||
if(result.fromZero)
|
|
||||||
result.startTime=System.currentTimeMillis();
|
|
||||||
result.period=result.interval*result.skins.size();
|
|
||||||
CustomSkinLoader.logger.info("Successfully loaded Dynamic Skull: "+new Gson().toJson(result));
|
|
||||||
dynamicTextures.put(profile, result);
|
|
||||||
staticTextures.remove(profile);
|
|
||||||
}
|
|
||||||
|
|
||||||
//Support local skin for skull
|
|
||||||
public Map<Type, MinecraftProfileTexture> parseTextures(Map<Type, MinecraftProfileTexture> textures) {
|
|
||||||
MinecraftProfileTexture skin=textures.get(Type.SKIN);
|
|
||||||
String skinUrl=skin.getUrl();
|
|
||||||
if(!HttpUtil0.isLocal(skinUrl))
|
|
||||||
return textures;
|
|
||||||
File skinFile=new File(CustomSkinLoader.DATA_DIR,skinUrl);
|
|
||||||
if(!skinFile.isFile())
|
|
||||||
return Maps.newHashMap();
|
|
||||||
textures.put(Type.SKIN, ModelManager0.getProfileTexture(HttpTextureUtil.getLocalFakeUrl(skinUrl), null));
|
|
||||||
return textures;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Map<Type,MinecraftProfileTexture> getTexture(final GameProfile profile){
|
|
||||||
if(staticTextures.get(profile)!=null)
|
|
||||||
return staticTextures.get(profile);
|
|
||||||
if(loadingList.contains(profile))
|
|
||||||
return Maps.newHashMap();
|
|
||||||
if(dynamicTextures.containsKey(profile)){
|
|
||||||
SkullTexture texture=dynamicTextures.get(profile);
|
|
||||||
long time=System.currentTimeMillis()-texture.startTime;
|
|
||||||
int index=(int)Math.floor((time%texture.period)/texture.interval);
|
|
||||||
Map<Type,MinecraftProfileTexture> map=Maps.newHashMap();
|
|
||||||
map.put(Type.SKIN, ModelManager0.getProfileTexture(texture.skins.get(index), null));
|
|
||||||
return map;
|
|
||||||
}
|
|
||||||
|
|
||||||
loadingList.add(profile);
|
|
||||||
Thread loadThread=new Thread(){
|
|
||||||
public void run(){
|
|
||||||
parseGameProfile(profile);//Load in thread
|
|
||||||
loadingList.remove(profile);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
loadThread.setName("Skull "+profile.hashCode());
|
|
||||||
loadThread.start();
|
|
||||||
return Maps.newHashMap();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,16 +0,0 @@
|
|||||||
package net.minecraft.client.renderer.texture;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
|
|
||||||
import net.minecraft.client.renderer.IImageBuffer;
|
|
||||||
import net.minecraft.util.ResourceLocation;
|
|
||||||
|
|
||||||
public class DownloadingTexture extends SimpleTexture {
|
|
||||||
public DownloadingTexture(File cacheFileIn, String imageUrlIn, ResourceLocation textureResourceLocation, IImageBuffer imageBufferIn) {
|
|
||||||
super(textureResourceLocation);
|
|
||||||
}
|
|
||||||
|
|
||||||
public DownloadingTexture(File cacheFileIn, String imageUrlIn, ResourceLocation textureResourceLocation, boolean legacySkinIn, Runnable processTaskIn) {
|
|
||||||
super(textureResourceLocation);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
package net.minecraft.client.renderer.texture;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
|
|
||||||
import net.minecraft.client.renderer.IImageBuffer;
|
|
||||||
import net.minecraft.util.ResourceLocation;
|
|
||||||
|
|
||||||
public class ThreadDownloadImageData extends SimpleTexture {
|
|
||||||
public ThreadDownloadImageData(File cacheFileIn, String imageUrlIn, ResourceLocation textureResourceLocation, IImageBuffer imageBufferIn) {
|
|
||||||
super(textureResourceLocation);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
+38
-30
@@ -4,13 +4,14 @@ import java.io.File;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.concurrent.ExecutorService;
|
import java.util.concurrent.ExecutorService;
|
||||||
import java.util.concurrent.Executors;
|
import java.util.concurrent.Executors;
|
||||||
|
import java.util.concurrent.LinkedBlockingDeque;
|
||||||
import java.util.concurrent.LinkedBlockingQueue;
|
import java.util.concurrent.LinkedBlockingQueue;
|
||||||
import java.util.concurrent.ThreadFactory;
|
import java.util.concurrent.ThreadFactory;
|
||||||
import java.util.concurrent.ThreadPoolExecutor;
|
import java.util.concurrent.ThreadPoolExecutor;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Function;
|
||||||
|
|
||||||
import com.google.common.collect.Maps;
|
import com.google.common.collect.ImmutableMap;
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
import com.google.gson.GsonBuilder;
|
import com.google.gson.GsonBuilder;
|
||||||
import com.mojang.authlib.GameProfile;
|
import com.mojang.authlib.GameProfile;
|
||||||
@@ -18,16 +19,20 @@ import com.mojang.authlib.minecraft.MinecraftProfileTexture;
|
|||||||
import customskinloader.config.Config;
|
import customskinloader.config.Config;
|
||||||
import customskinloader.config.SkinSiteProfile;
|
import customskinloader.config.SkinSiteProfile;
|
||||||
import customskinloader.loader.ProfileLoader;
|
import customskinloader.loader.ProfileLoader;
|
||||||
|
import customskinloader.log.LogManager;
|
||||||
|
import customskinloader.log.Logger;
|
||||||
import customskinloader.profile.DynamicSkullManager;
|
import customskinloader.profile.DynamicSkullManager;
|
||||||
import customskinloader.profile.ModelManager0;
|
import customskinloader.profile.ModelManager0;
|
||||||
import customskinloader.profile.ProfileCache;
|
import customskinloader.profile.ProfileCache;
|
||||||
import customskinloader.profile.UserProfile;
|
import customskinloader.profile.UserProfile;
|
||||||
|
import customskinloader.utils.LIFOBlockingQueue;
|
||||||
import customskinloader.utils.MinecraftUtil;
|
import customskinloader.utils.MinecraftUtil;
|
||||||
|
import customskinloader.utils.TextureUtil;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Custom skin loader mod for Minecraft.
|
* Custom skin loader mod for Minecraft.
|
||||||
*
|
*
|
||||||
* @author (C) Jeremy Lam [JLChnToZ] 2013-2014 & Alexander Xia [xfl03] 2014-2020
|
* @author Jeremy Lam [JLChnToZ] 2013-2014 & Alexander Xia [xfl03] 2014-2023
|
||||||
* @version @MOD_FULL_VERSION@
|
* @version @MOD_FULL_VERSION@
|
||||||
*/
|
*/
|
||||||
public class CustomSkinLoader {
|
public class CustomSkinLoader {
|
||||||
@@ -42,12 +47,12 @@ public class CustomSkinLoader {
|
|||||||
|
|
||||||
public static final Gson GSON = new GsonBuilder().setPrettyPrinting().create();
|
public static final Gson GSON = new GsonBuilder().setPrettyPrinting().create();
|
||||||
public static final Logger logger = initLogger();
|
public static final Logger logger = initLogger();
|
||||||
public static final Config config = Config.loadConfig0();
|
public static final Config config = initConfig();
|
||||||
|
|
||||||
private static final ProfileCache profileCache = new ProfileCache();
|
private static final ProfileCache profileCache = new ProfileCache();
|
||||||
private static final DynamicSkullManager dynamicSkullManager = new DynamicSkullManager();
|
private static final DynamicSkullManager dynamicSkullManager = new DynamicSkullManager();
|
||||||
|
|
||||||
private static final ExecutorService THREAD_POOL = new ThreadPoolExecutor(config.threadPoolSize, config.threadPoolSize, 1L, TimeUnit.MINUTES, new LinkedBlockingQueue<>());
|
public static final ExecutorService THREAD_POOL = new ThreadPoolExecutor(config.threadPoolSize, config.threadPoolSize, 1L, TimeUnit.MINUTES, new LIFOBlockingQueue<>(new LinkedBlockingDeque<>()));
|
||||||
|
|
||||||
//Correct thread name in thread pool
|
//Correct thread name in thread pool
|
||||||
private static final ThreadFactory defaultFactory = Executors.defaultThreadFactory();
|
private static final ThreadFactory defaultFactory = Executors.defaultThreadFactory();
|
||||||
@@ -68,30 +73,18 @@ public class CustomSkinLoader {
|
|||||||
THREAD_POOL.execute(runnable);
|
THREAD_POOL.execute(runnable);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void loadProfileLazily(GameProfile gameProfile, Consumer<Map<MinecraftProfileTexture.Type, MinecraftProfileTexture>> consumer) {
|
//For User Skin
|
||||||
String username = gameProfile.getName();
|
public static UserProfile loadProfile(GameProfile gameProfile) {
|
||||||
|
String username = TextureUtil.AuthlibField.GAME_PROFILE_NAME.get(gameProfile);
|
||||||
String credential = MinecraftUtil.getCredential(gameProfile);
|
String credential = MinecraftUtil.getCredential(gameProfile);
|
||||||
// Fix: http://hopper.minecraft.net/crashes/minecraft/MCX-2773713
|
// Fix: http://hopper.minecraft.net/crashes/minecraft/MCX-2773713
|
||||||
if (username == null) {
|
if (username == null) {
|
||||||
logger.warning("Could not load profile: username is null.");
|
logger.warning("Could not load profile: username is null.");
|
||||||
consumer.accept(Maps.newHashMap());
|
return new UserProfile();
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
String tempName = Thread.currentThread().getName();
|
String tempName = Thread.currentThread().getName();
|
||||||
Thread.currentThread().setName(username); // Change Thread Name
|
Thread.currentThread().setName(username); // Change Thread Name
|
||||||
if (profileCache.isLoading(credential)) {
|
|
||||||
profileCache.putLoader(credential, consumer);
|
|
||||||
Thread.currentThread().setName(tempName);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
consumer.accept(loadProfile(gameProfile));
|
|
||||||
Thread.currentThread().setName(tempName);
|
|
||||||
profileCache.getLastLoader(credential).ifPresent(c -> loadProfileLazily(gameProfile, c));
|
|
||||||
}
|
|
||||||
|
|
||||||
//For User Skin
|
|
||||||
public static Map<MinecraftProfileTexture.Type, MinecraftProfileTexture> loadProfile(GameProfile gameProfile) {
|
|
||||||
String credential = MinecraftUtil.getCredential(gameProfile);
|
|
||||||
UserProfile profile;
|
UserProfile profile;
|
||||||
if (profileCache.isReady(credential)) {
|
if (profileCache.isReady(credential)) {
|
||||||
logger.info("Cached profile will be used.");
|
logger.info("Cached profile will be used.");
|
||||||
@@ -108,12 +101,13 @@ public class CustomSkinLoader {
|
|||||||
profileCache.setLoading(credential, true);
|
profileCache.setLoading(credential, true);
|
||||||
profile = loadProfile0(gameProfile, false);
|
profile = loadProfile0(gameProfile, false);
|
||||||
}
|
}
|
||||||
return ModelManager0.fromUserProfile(profile);
|
Thread.currentThread().setName(tempName);
|
||||||
|
return profile == null ? new UserProfile() : profile;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Core
|
//Core
|
||||||
public static UserProfile loadProfile0(GameProfile gameProfile, boolean isSkull) {
|
public static UserProfile loadProfile0(GameProfile gameProfile, boolean isSkull) {
|
||||||
String username = gameProfile.getName();
|
String username = TextureUtil.AuthlibField.GAME_PROFILE_NAME.get(gameProfile);
|
||||||
String credential = MinecraftUtil.getCredential(gameProfile);
|
String credential = MinecraftUtil.getCredential(gameProfile);
|
||||||
|
|
||||||
profileCache.setLoading(credential, true);
|
profileCache.setLoading(credential, true);
|
||||||
@@ -175,7 +169,7 @@ public class CustomSkinLoader {
|
|||||||
|
|
||||||
if (config.enableLocalProfileCache) {
|
if (config.enableLocalProfileCache) {
|
||||||
UserProfile profile = profileCache.getLocalProfile(credential);
|
UserProfile profile = profileCache.getLocalProfile(credential);
|
||||||
if (profile == null) {
|
if (profile == null || profile.equals(UserProfile.NULL)) {
|
||||||
logger.info(username + "'s LocalProfile not found.");
|
logger.info(username + "'s LocalProfile not found.");
|
||||||
} else {
|
} else {
|
||||||
profileCache.updateCache(credential, profile, false);
|
profileCache.updateCache(credential, profile, false);
|
||||||
@@ -189,14 +183,15 @@ public class CustomSkinLoader {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public final static Map<MinecraftProfileTexture.Type, MinecraftProfileTexture> INCOMPLETED = ImmutableMap.of();
|
||||||
//For Skull
|
//For Skull
|
||||||
public static Map<MinecraftProfileTexture.Type, MinecraftProfileTexture> loadProfileFromCache(final GameProfile gameProfile) {
|
public static Map<MinecraftProfileTexture.Type, MinecraftProfileTexture> loadProfileFromCache(final GameProfile gameProfile) {
|
||||||
String username = gameProfile.getName();
|
String username = TextureUtil.AuthlibField.GAME_PROFILE_NAME.get(gameProfile);
|
||||||
String credential = MinecraftUtil.getCredential(gameProfile);
|
String credential = MinecraftUtil.getCredential(gameProfile);
|
||||||
|
|
||||||
//CustomSkinLoader needs username to load standard skin, if username not exist, only textures in NBT can be used
|
//CustomSkinLoader needs username to load standard skin, if username not exist, only textures in NBT can be used
|
||||||
//Authlib 3.11.50 makes empty username to "\u0020"
|
//Authlib 3.11.50 makes empty username to " "
|
||||||
if (username == null || username.isEmpty() || username.equals("\u0020") || credential == null) {
|
if (username == null || username.isEmpty() || username.equals(" ") || credential == null) {
|
||||||
return dynamicSkullManager.getTexture(gameProfile);
|
return dynamicSkullManager.getTexture(gameProfile);
|
||||||
}
|
}
|
||||||
if (config.forceUpdateSkull ? profileCache.isReady(credential) : profileCache.isExist(credential)) {
|
if (config.forceUpdateSkull ? profileCache.isReady(credential) : profileCache.isExist(credential)) {
|
||||||
@@ -217,11 +212,12 @@ public class CustomSkinLoader {
|
|||||||
threadPool.execute(loadThread);
|
threadPool.execute(loadThread);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return Maps.newHashMap();
|
return INCOMPLETED;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Logger initLogger() {
|
private static Logger initLogger() {
|
||||||
Logger logger = new Logger(LOG_FILE);
|
LogManager.setLogFile(LOG_FILE.toPath());
|
||||||
|
Logger logger = LogManager.getLogger("Core");
|
||||||
logger.info("CustomSkinLoader " + CustomSkinLoader_FULL_VERSION);
|
logger.info("CustomSkinLoader " + CustomSkinLoader_FULL_VERSION);
|
||||||
logger.info("DataDir: " + DATA_DIR.getAbsolutePath());
|
logger.info("DataDir: " + DATA_DIR.getAbsolutePath());
|
||||||
logger.info("Operating System: " + System.getProperty("os.name") + " (" + System.getProperty("os.arch") + ") version " + System.getProperty("os.version"));
|
logger.info("Operating System: " + System.getProperty("os.name") + " (" + System.getProperty("os.arch") + ") version " + System.getProperty("os.version"));
|
||||||
@@ -230,4 +226,16 @@ public class CustomSkinLoader {
|
|||||||
logger.info("Minecraft: " + MinecraftUtil.getMinecraftMainVersion());
|
logger.info("Minecraft: " + MinecraftUtil.getMinecraftMainVersion());
|
||||||
return logger;
|
return logger;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create <code>Config</code> object.
|
||||||
|
* To use <code>logger</code>, please make sure call this function after <code>initLogger</code>.
|
||||||
|
*
|
||||||
|
* @return <code>Config</code>
|
||||||
|
*/
|
||||||
|
private static Config initConfig() {
|
||||||
|
Config config = Config.loadConfig0();
|
||||||
|
logger.enableLogStdOut = config.enableLogStdOut;
|
||||||
|
return config;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
+76
-69
@@ -14,7 +14,6 @@ import customskinloader.plugin.ICustomSkinLoaderPlugin;
|
|||||||
import customskinloader.plugin.PluginLoader;
|
import customskinloader.plugin.PluginLoader;
|
||||||
import customskinloader.utils.HttpRequestUtil;
|
import customskinloader.utils.HttpRequestUtil;
|
||||||
import customskinloader.utils.HttpTextureUtil;
|
import customskinloader.utils.HttpTextureUtil;
|
||||||
import customskinloader.utils.HttpUtil0;
|
|
||||||
import customskinloader.utils.Version;
|
import customskinloader.utils.Version;
|
||||||
import org.apache.commons.io.FileUtils;
|
import org.apache.commons.io.FileUtils;
|
||||||
|
|
||||||
@@ -26,21 +25,27 @@ public class Config {
|
|||||||
public List<SkinSiteProfile> loadlist;
|
public List<SkinSiteProfile> loadlist;
|
||||||
|
|
||||||
//Function
|
//Function
|
||||||
public boolean enableDynamicSkull=true;
|
public boolean enableDynamicSkull = true;
|
||||||
public boolean enableTransparentSkin=true;
|
public boolean enableTransparentSkin = true;
|
||||||
public boolean forceIgnoreHttpsCertificate = false;
|
public boolean forceLoadAllTextures = true;
|
||||||
public boolean forceLoadAllTextures=false;
|
|
||||||
public boolean enableCape = true;
|
public boolean enableCape = true;
|
||||||
public int threadPoolSize = 3;
|
public int threadPoolSize = 8;
|
||||||
public int retryTime = 1;
|
/**
|
||||||
|
* Can logger write message to standard output(System.out).
|
||||||
|
* Because standard output won't write to latest.log after Forge 1.17,
|
||||||
|
* printing to standard output is meaningless,
|
||||||
|
* which makes this switch default value is <code>false</code>.
|
||||||
|
* @since 14.15
|
||||||
|
*/
|
||||||
|
public boolean enableLogStdOut = false;
|
||||||
|
|
||||||
//Profile Cache
|
//Profile Cache
|
||||||
public int cacheExpiry=30;
|
public int cacheExpiry = 30;
|
||||||
public boolean forceUpdateSkull = false;
|
public boolean forceUpdateSkull = false;
|
||||||
public boolean enableLocalProfileCache=false;
|
public boolean enableLocalProfileCache = false;
|
||||||
|
|
||||||
//Network Cache
|
//Network Cache
|
||||||
public boolean enableCacheAutoClean=false;
|
public boolean enableCacheAutoClean = false;
|
||||||
public boolean forceDisableCache = false;
|
public boolean forceDisableCache = false;
|
||||||
|
|
||||||
// Used by Gson to create an instance with default value.
|
// Used by Gson to create an instance with default value.
|
||||||
@@ -49,21 +54,21 @@ public class Config {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Init config
|
//Init config
|
||||||
public Config(List<SkinSiteProfile> loadlist){
|
public Config(List<SkinSiteProfile> loadlist) {
|
||||||
this.version=CustomSkinLoader.CustomSkinLoader_VERSION;
|
this.version = CustomSkinLoader.CustomSkinLoader_VERSION;
|
||||||
this.buildNumber=CustomSkinLoader.CustomSkinLoader_BUILD_NUMBER;
|
this.buildNumber = CustomSkinLoader.CustomSkinLoader_BUILD_NUMBER;
|
||||||
this.loadlist=loadlist;
|
this.loadlist = loadlist;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Config loadConfig0() {
|
public static Config loadConfig0() {
|
||||||
Config config=loadConfig();
|
Config config = loadConfig();
|
||||||
|
|
||||||
//LoadList null checker
|
//LoadList null checker
|
||||||
if(config.loadlist==null){
|
if (config.loadlist == null) {
|
||||||
config.loadlist=new ArrayList<SkinSiteProfile>();
|
config.loadlist = new ArrayList<>();
|
||||||
}else{
|
} else {
|
||||||
for(int i=0;i<config.loadlist.size();i++){
|
for (int i = 0; i < config.loadlist.size(); i++) {
|
||||||
if(config.loadlist.get(i)==null)
|
if (config.loadlist.get(i) == null)
|
||||||
config.loadlist.remove(i--);
|
config.loadlist.remove(i--);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -73,25 +78,23 @@ public class Config {
|
|||||||
config.updateLoadlist();
|
config.updateLoadlist();
|
||||||
config.initLocalFolder();
|
config.initLocalFolder();
|
||||||
config.threadPoolSize = Math.max(config.threadPoolSize, 1);
|
config.threadPoolSize = Math.max(config.threadPoolSize, 1);
|
||||||
config.retryTime = Math.max(config.retryTime, 0);
|
if (config.enableCacheAutoClean && !config.enableLocalProfileCache) {
|
||||||
if(config.forceIgnoreHttpsCertificate)
|
try {
|
||||||
HttpUtil0.ignoreHttpsCertificate();
|
|
||||||
if(config.enableCacheAutoClean && !config.enableLocalProfileCache){
|
|
||||||
try{
|
|
||||||
FileUtils.deleteDirectory(HttpRequestUtil.CACHE_DIR);
|
FileUtils.deleteDirectory(HttpRequestUtil.CACHE_DIR);
|
||||||
FileUtils.deleteDirectory(HttpTextureUtil.getCacheDir());
|
FileUtils.deleteDirectory(HttpTextureUtil.getCacheDir());
|
||||||
CustomSkinLoader.logger.info("Successfully cleaned cache.");
|
CustomSkinLoader.logger.info("Successfully cleaned cache.");
|
||||||
}catch(Exception e){
|
} catch (Exception e) {
|
||||||
CustomSkinLoader.logger.warning("Exception occurs while cleaning cache: "+e.toString());
|
CustomSkinLoader.logger.warning("Exception occurs while cleaning cache: " + e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Check config version
|
//Check config version
|
||||||
Version configVersion = Version.of(config.version);
|
Version configVersion = Version.of(config.version);
|
||||||
if (CustomSkinLoader.CustomSkinLoader_BUILD_NUMBER == 0 // Custom builds
|
if (CustomSkinLoader.CustomSkinLoader_BUILD_NUMBER == 0 // Custom builds
|
||||||
|| configVersion.compareTo(CustomSkinLoader.CustomSkinLoader_VERSION) < 0
|
|| configVersion.compareTo(CustomSkinLoader.CustomSkinLoader_VERSION) < 0
|
||||||
|| config.buildNumber < CustomSkinLoader.CustomSkinLoader_BUILD_NUMBER) {
|
|| config.buildNumber < CustomSkinLoader.CustomSkinLoader_BUILD_NUMBER) {
|
||||||
CustomSkinLoader.logger.info("Config File is out of date: " + config.version + ", build number: " + config.buildNumber);
|
CustomSkinLoader.logger.info("Config File is out of date: " + config.version +
|
||||||
|
", build number: " + config.buildNumber);
|
||||||
config.version = CustomSkinLoader.CustomSkinLoader_VERSION;
|
config.version = CustomSkinLoader.CustomSkinLoader_VERSION;
|
||||||
config.buildNumber = CustomSkinLoader.CustomSkinLoader_BUILD_NUMBER;
|
config.buildNumber = CustomSkinLoader.CustomSkinLoader_BUILD_NUMBER;
|
||||||
}
|
}
|
||||||
@@ -102,51 +105,53 @@ public class Config {
|
|||||||
try {
|
try {
|
||||||
Object value = field.get(config);
|
Object value = field.get(config);
|
||||||
CustomSkinLoader.logger.info(field.getName() + " : " + value);
|
CustomSkinLoader.logger.info(field.getName() + " : " + value);
|
||||||
} catch (Exception ignored) { }
|
} catch (Exception ignored) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return config;
|
return config;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Config loadConfig() {
|
private static Config loadConfig() {
|
||||||
CustomSkinLoader.logger.info("Config File: "+CustomSkinLoader.CONFIG_FILE.getAbsolutePath());
|
CustomSkinLoader.logger.info("Config File: " + CustomSkinLoader.CONFIG_FILE.getAbsolutePath());
|
||||||
if(!CustomSkinLoader.CONFIG_FILE.exists()){
|
if (!CustomSkinLoader.CONFIG_FILE.exists()) {
|
||||||
CustomSkinLoader.logger.info("Config file not found, use default instead.");
|
CustomSkinLoader.logger.info("Config file not found, use default instead.");
|
||||||
return initConfig();
|
return initConfig();
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
CustomSkinLoader.logger.info("Try to load config.");
|
CustomSkinLoader.logger.info("Try to load config.");
|
||||||
String json=FileUtils.readFileToString(CustomSkinLoader.CONFIG_FILE, "UTF-8");
|
String json = FileUtils.readFileToString(CustomSkinLoader.CONFIG_FILE, "UTF-8");
|
||||||
Config config=Objects.requireNonNull(CustomSkinLoader.GSON.fromJson(json, Config.class));
|
Config config = Objects.requireNonNull(CustomSkinLoader.GSON.fromJson(json, Config.class));
|
||||||
CustomSkinLoader.logger.info("Successfully load config.");
|
CustomSkinLoader.logger.info("Successfully load config.");
|
||||||
return config;
|
return config;
|
||||||
}catch (Exception e) {
|
} catch (Exception e) {
|
||||||
CustomSkinLoader.logger.info("Failed to load config, use default instead.("+e.toString()+")");
|
CustomSkinLoader.logger.info("Failed to load config, use default instead.(" + e + ")");
|
||||||
createBrokenFile(CustomSkinLoader.CONFIG_FILE);
|
createBrokenFile(CustomSkinLoader.CONFIG_FILE);
|
||||||
return initConfig();
|
return initConfig();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void loadExtraList(){
|
private void loadExtraList() {
|
||||||
File listAddition=new File(CustomSkinLoader.DATA_DIR,"ExtraList");
|
File listAddition = new File(CustomSkinLoader.DATA_DIR, "ExtraList");
|
||||||
if(!listAddition.isDirectory()){
|
if (!listAddition.isDirectory()) {
|
||||||
listAddition.mkdirs();
|
listAddition.mkdirs();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
List<SkinSiteProfile> adds=new ArrayList<SkinSiteProfile>();
|
List<SkinSiteProfile> adds = new ArrayList<>();
|
||||||
File[] files=listAddition.listFiles();
|
File[] files = listAddition.listFiles();
|
||||||
for(File file: files != null ? files : new File[0]){
|
for (File file : files != null ? files : new File[0]) {
|
||||||
if(!file.getName().toLowerCase().endsWith(".json")&&!file.getName().toLowerCase().endsWith(".txt"))
|
if (!file.getName().toLowerCase().endsWith(".json") && !file.getName().toLowerCase().endsWith(".txt"))
|
||||||
continue;
|
continue;
|
||||||
try {
|
try {
|
||||||
CustomSkinLoader.logger.info("Try to load Extra List.("+file.getName()+")");
|
CustomSkinLoader.logger.info("Try to load Extra List.(" + file.getName() + ")");
|
||||||
String json=FileUtils.readFileToString(file, "UTF-8");
|
String json = FileUtils.readFileToString(file, "UTF-8");
|
||||||
SkinSiteProfile ssp=CustomSkinLoader.GSON.fromJson(json, SkinSiteProfile.class);
|
SkinSiteProfile ssp = CustomSkinLoader.GSON.fromJson(json, SkinSiteProfile.class);
|
||||||
CustomSkinLoader.logger.info("Successfully load Extra List.");
|
CustomSkinLoader.logger.info("Successfully load Extra List.");
|
||||||
if (ssp.type != null) {
|
if (ssp.type != null) {
|
||||||
ProfileLoader.IProfileLoader loader = ProfileLoader.LOADERS.get(ssp.type.toLowerCase());
|
ProfileLoader.IProfileLoader loader = ProfileLoader.LOADERS.get(ssp.type.toLowerCase());
|
||||||
if (loader == null) {
|
if (loader == null) {
|
||||||
CustomSkinLoader.logger.info("Extra List will be ignored: Type '" + ssp.type + "' is not defined.");
|
CustomSkinLoader.logger.info("Extra List will be ignored: Type '" + ssp.type +
|
||||||
|
"' is not defined.");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
boolean duplicate = false;
|
boolean duplicate = false;
|
||||||
@@ -166,36 +171,37 @@ public class Config {
|
|||||||
}
|
}
|
||||||
file.delete();
|
file.delete();
|
||||||
} else {
|
} else {
|
||||||
CustomSkinLoader.logger.info("Extra List is invalid: Type is not defined.(" + file.getName() + ")");
|
CustomSkinLoader.logger.info("Extra List is invalid: Type is not defined.(" +
|
||||||
|
file.getName() + ")");
|
||||||
createBrokenFile(file);
|
createBrokenFile(file);
|
||||||
}
|
}
|
||||||
}catch (Exception e) {
|
} catch (Exception e) {
|
||||||
CustomSkinLoader.logger.info("Failed to load Extra List.("+e.toString()+")");
|
CustomSkinLoader.logger.info("Failed to load Extra List.(" + e + ")");
|
||||||
createBrokenFile(file);
|
createBrokenFile(file);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(adds.size()!=0){
|
if (adds.size() != 0) {
|
||||||
adds.addAll(this.loadlist);
|
adds.addAll(this.loadlist);
|
||||||
this.loadlist=adds;
|
this.loadlist = adds;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateLoadlist() {
|
private void updateLoadlist() {
|
||||||
PluginLoader.PLUGINS.stream()
|
PluginLoader.PLUGINS.stream()
|
||||||
.map(ICustomSkinLoaderPlugin::getDefaultProfiles)
|
.map(ICustomSkinLoaderPlugin::getDefaultProfiles)
|
||||||
.filter(Objects::nonNull)
|
.filter(Objects::nonNull)
|
||||||
.flatMap(Collection::stream)
|
.flatMap(Collection::stream)
|
||||||
.forEach(profile -> this.loadlist.stream()
|
.forEach(profile -> this.loadlist.stream()
|
||||||
.filter(ssp -> profile.getName().equals(ssp.name))
|
.filter(ssp -> profile.getName().equals(ssp.name))
|
||||||
.forEach(profile::updateSkinSiteProfile));
|
.forEach(profile::updateSkinSiteProfile));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initLocalFolder(){
|
private void initLocalFolder() {
|
||||||
for(SkinSiteProfile ssp:this.loadlist){
|
for (SkinSiteProfile ssp : this.loadlist) {
|
||||||
if(ssp.type==null)
|
if (ssp.type == null)
|
||||||
continue;
|
continue;
|
||||||
ProfileLoader.IProfileLoader loader=ProfileLoader.LOADERS.get(ssp.type.toLowerCase());
|
ProfileLoader.IProfileLoader loader = ProfileLoader.LOADERS.get(ssp.type.toLowerCase());
|
||||||
if(loader==null)
|
if (loader == null)
|
||||||
continue;
|
continue;
|
||||||
loader.init(ssp);
|
loader.init(ssp);
|
||||||
}
|
}
|
||||||
@@ -237,16 +243,17 @@ public class Config {
|
|||||||
writeConfig(config, false);
|
writeConfig(config, false);
|
||||||
return config;
|
return config;
|
||||||
}
|
}
|
||||||
private static void writeConfig(Config config, boolean update){
|
|
||||||
String json=CustomSkinLoader.GSON.toJson(config);
|
private static void writeConfig(Config config, boolean update) {
|
||||||
if(CustomSkinLoader.CONFIG_FILE.exists())
|
String json = CustomSkinLoader.GSON.toJson(config);
|
||||||
|
if (CustomSkinLoader.CONFIG_FILE.exists())
|
||||||
CustomSkinLoader.CONFIG_FILE.delete();
|
CustomSkinLoader.CONFIG_FILE.delete();
|
||||||
try {
|
try {
|
||||||
CustomSkinLoader.CONFIG_FILE.createNewFile();
|
CustomSkinLoader.CONFIG_FILE.createNewFile();
|
||||||
FileUtils.write(CustomSkinLoader.CONFIG_FILE, json, "UTF-8");
|
FileUtils.write(CustomSkinLoader.CONFIG_FILE, json, "UTF-8");
|
||||||
CustomSkinLoader.logger.info("Successfully "+(update?"update":"create")+" config.");
|
CustomSkinLoader.logger.info("Successfully " + (update ? "update" : "create") + " config.");
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
CustomSkinLoader.logger.info("Failed to "+(update?"update":"create")+" config.("+e.toString()+")");
|
CustomSkinLoader.logger.info("Failed to " + (update ? "update" : "create") + " config.(" + e + ")");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
File renamed without changes.
+91
-45
@@ -2,26 +2,27 @@ package customskinloader.fake;
|
|||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.util.NoSuchElementException;
|
|
||||||
import java.util.function.BiPredicate;
|
import java.util.function.BiPredicate;
|
||||||
import java.util.function.Predicate;
|
import java.util.function.Predicate;
|
||||||
|
|
||||||
|
import customskinloader.CustomSkinLoader;
|
||||||
import customskinloader.fake.itf.FakeInterfaceManager;
|
import customskinloader.fake.itf.FakeInterfaceManager;
|
||||||
import customskinloader.fake.texture.FakeBufferedImage;
|
|
||||||
import customskinloader.fake.texture.FakeImage;
|
import customskinloader.fake.texture.FakeImage;
|
||||||
import customskinloader.utils.MinecraftUtil;
|
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
|
|
||||||
public class FakeCapeBuffer extends FakeSkinBuffer {
|
public class FakeCapeBuffer extends FakeSkinBuffer {
|
||||||
private static final ResourceLocation TEXTURE_ELYTRA = new ResourceLocation("textures/entity/elytra.png");
|
private static final ResourceLocation TEXTURE_ELYTRA_V1 = new ResourceLocation("minecraft", "textures/entity/elytra.png");
|
||||||
|
private static final ResourceLocation TEXTURE_ELYTRA_V2 = new ResourceLocation("minecraft", "textures/entity/equipment/wings/elytra.png");
|
||||||
private static int loadedGlobal = 0;
|
private static int loadedGlobal = 0;
|
||||||
private static FakeImage elytraImage;
|
private static FakeImage elytraImage;
|
||||||
|
|
||||||
private static FakeImage loadElytra(FakeImage originalImage) {
|
private static FakeImage loadElytra(FakeImage originalImage) {
|
||||||
loadedGlobal++;
|
loadedGlobal++;
|
||||||
try {
|
try {
|
||||||
InputStream is = FakeInterfaceManager.IResource_getInputStream(FakeInterfaceManager.IResourceManager_getResource(FakeInterfaceManager.Minecraft_getResourceManager(Minecraft.getMinecraft()), TEXTURE_ELYTRA).get());
|
Object resourceManager = FakeInterfaceManager.Minecraft_getResourceManager(Minecraft.getMinecraft());
|
||||||
|
InputStream is = FakeInterfaceManager.IResource_getInputStream(FakeInterfaceManager.IResourceManager_getResource(resourceManager, TEXTURE_ELYTRA_V1)
|
||||||
|
.orElseGet(() -> FakeInterfaceManager.IResourceManager_getResource(resourceManager, TEXTURE_ELYTRA_V2).orElse(null)));
|
||||||
if (is != null) {
|
if (is != null) {
|
||||||
FakeImage image = originalImage.createImage(is);
|
FakeImage image = originalImage.createImage(is);
|
||||||
if (image.getWidth() % 64 != 0 || image.getHeight() % 32 != 0) { // wtf?
|
if (image.getWidth() % 64 != 0 || image.getHeight() % 32 != 0) { // wtf?
|
||||||
@@ -30,28 +31,33 @@ public class FakeCapeBuffer extends FakeSkinBuffer {
|
|||||||
image = resetImageFormat(image, 22, 0, 46, 22);
|
image = resetImageFormat(image, 22, 0, 46, 22);
|
||||||
return image;
|
return image;
|
||||||
}
|
}
|
||||||
} catch (IOException | NoSuchElementException ignored) { }
|
} catch (IOException e) {
|
||||||
|
CustomSkinLoader.logger.warning(e);
|
||||||
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private int loaded = 0;
|
private int loaded = 0;
|
||||||
private double ratioX = -1;
|
private double ratioX = -1;
|
||||||
private double ratioY = -1;
|
private double ratioY = -1;
|
||||||
private ResourceLocation location;
|
|
||||||
private String type = null;
|
private String type = null;
|
||||||
|
|
||||||
public FakeCapeBuffer(ResourceLocation location) {
|
|
||||||
this.location = location;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public FakeImage parseUserSkin(FakeImage image) {
|
public FakeImage parseUserSkin(FakeImage image) {
|
||||||
if (image == null) return null;
|
if (image == null) return null;
|
||||||
this.image = image;
|
if (isOptiFineCape(image)) {
|
||||||
|
//OptiFine cape should be converted to standard cape
|
||||||
|
this.image = convertOptiFineCape(image);
|
||||||
|
//OptiFine cape contains elytra texture
|
||||||
|
//this.type = "elytra";//But its elytra texture doesn't work
|
||||||
|
} else {
|
||||||
|
this.image = image;
|
||||||
|
}
|
||||||
|
|
||||||
// When resource packs were changed, the elytra image needs to be reloaded, and here will be entered again
|
// When resource packs were changed, the elytra image needs to be reloaded, and here will be entered again
|
||||||
|
// The first cape which find elytra texture is outdated will reload it
|
||||||
if (this.loaded == loadedGlobal) {
|
if (this.loaded == loadedGlobal) {
|
||||||
elytraImage = loadElytra(image);
|
elytraImage = loadElytra(this.image);
|
||||||
}
|
}
|
||||||
this.loaded = loadedGlobal;
|
this.loaded = loadedGlobal;
|
||||||
if (elytraImage != null) {
|
if (elytraImage != null) {
|
||||||
@@ -65,9 +71,6 @@ public class FakeCapeBuffer extends FakeSkinBuffer {
|
|||||||
if ("cape".equals(this.type)) {
|
if ("cape".equals(this.type)) {
|
||||||
this.image = resetImageFormat(this.image, 0, 0, 22, 17);
|
this.image = resetImageFormat(this.image, 0, 0, 22, 17);
|
||||||
this.attachElytra(elytraImage);
|
this.attachElytra(elytraImage);
|
||||||
if (this.image instanceof FakeBufferedImage) { // before 1.12.2
|
|
||||||
this.refreshTexture((FakeBufferedImage) this.image);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return this.image;
|
return this.image;
|
||||||
@@ -126,15 +129,16 @@ public class FakeCapeBuffer extends FakeSkinBuffer {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Traverse every elytra pixel
|
* Traverse every elytra pixel
|
||||||
* @param predicate the predicate with x and y
|
*
|
||||||
* @param returnValue if the condition flag equals the condition, then return this value
|
* @param predicate the predicate with x and y
|
||||||
|
* @param returnValue if the condition flag equals the condition, then return this value
|
||||||
* @param defaultReturnValue otherwise return this value
|
* @param defaultReturnValue otherwise return this value
|
||||||
*/
|
*/
|
||||||
private <R> R withElytraPixels(BiPredicate<Integer, Integer> predicate, R returnValue, R defaultReturnValue) {
|
private <R> R withElytraPixels(BiPredicate<Integer, Integer> predicate, R returnValue, R defaultReturnValue) {
|
||||||
int startX = (int) Math.ceil(22 * ratioX), endX = (int) Math.ceil(46 * ratioX);
|
int startX = (int) Math.ceil(22 * ratioX), endX = (int) Math.ceil(46 * ratioX);
|
||||||
int startY = (int) Math.ceil(0 * ratioY), endY = (int) Math.ceil(22 * ratioY);
|
int startY = (int) Math.ceil(0 * ratioY), endY = (int) Math.ceil(22 * ratioY);
|
||||||
int excludeX0 = (int) Math.ceil(24 * ratioX), excludeX1 = (int) Math.ceil(44 * ratioX);
|
int excludeX0 = (int) Math.ceil(24 * ratioX), excludeX1 = (int) Math.ceil(44 * ratioX);
|
||||||
int excludeY = (int) Math.ceil(2 * ratioY);
|
int excludeY = (int) Math.ceil(2 * ratioY);
|
||||||
for (int x = startX; x < endX; ++x) {
|
for (int x = startX; x < endX; ++x) {
|
||||||
for (int y = startY; y < endY; ++y) {
|
for (int y = startY; y < endY; ++y) {
|
||||||
if (y < excludeY && (x < excludeX0 || x >= excludeX1)) continue;
|
if (y < excludeY && (x < excludeX0 || x >= excludeX1)) continue;
|
||||||
@@ -146,16 +150,6 @@ public class FakeCapeBuffer extends FakeSkinBuffer {
|
|||||||
return defaultReturnValue;
|
return defaultReturnValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TextureID won't be regenerated when changing resource packs before 1.12.2
|
|
||||||
private void refreshTexture(FakeBufferedImage image) {
|
|
||||||
Object textureObj = MinecraftUtil.getTextureManager().getTexture(this.location);
|
|
||||||
if (textureObj != null) {
|
|
||||||
// NOTICE: OptiFine modified the upload process of the texture from ThreadDownloadImageData
|
|
||||||
// Therefore, it may not be correct to simply copy the vanilla behavior
|
|
||||||
FakeInterfaceManager.ThreadDownloadImageData_resetNewBufferedImage(textureObj, image.getImage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Some cape image doesn't support alpha channel, so reset image format to ARGB
|
// Some cape image doesn't support alpha channel, so reset image format to ARGB
|
||||||
private static FakeImage resetImageFormat(FakeImage image, int startX, int startY, int endX, int endY) {
|
private static FakeImage resetImageFormat(FakeImage image, int startX, int startY, int endX, int endY) {
|
||||||
if (image != null) {
|
if (image != null) {
|
||||||
@@ -167,24 +161,27 @@ public class FakeCapeBuffer extends FakeSkinBuffer {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Scale image
|
* Scale image
|
||||||
* @param image the image to scale.
|
*
|
||||||
|
* @param image the image to scale.
|
||||||
* @param closeOldImage whether close old image
|
* @param closeOldImage whether close old image
|
||||||
* @param scaleWidth width enlargement ratio
|
* @param scaleWidth width enlargement ratio
|
||||||
* @param scaleHeight height enlargement ratio
|
* @param scaleHeight height enlargement ratio
|
||||||
* @param ratioX the ratio of 64 of the old image width
|
* @param ratioX the ratio of 64 of the old image width
|
||||||
* @param ratioY the ratio of 32 of the old image height
|
* @param ratioY the ratio of 32 of the old image height
|
||||||
* @param width the width after scaling.
|
* @param width the width after scaling.
|
||||||
* @param height the height after scaling.
|
* @param height the height after scaling.
|
||||||
* @param startX the x where start to copy.
|
* @param startX the x where start to copy.
|
||||||
* @param startY the y where start to copy.
|
* @param startY the y where start to copy.
|
||||||
* @param endX the x where end to copy.
|
* @param endX the x where end to copy.
|
||||||
* @param endY the y where end to copy.
|
* @param endY the y where end to copy.
|
||||||
* @return the image after scaling.
|
* @return the image after scaling.
|
||||||
*/
|
*/
|
||||||
private static FakeImage scaleImage(FakeImage image, boolean closeOldImage, double scaleWidth, double scaleHeight, double ratioX, double ratioY, int width, int height, int startX, int startY, int endX, int endY) {
|
private static FakeImage scaleImage(FakeImage image, boolean closeOldImage, double scaleWidth, double scaleHeight, double ratioX, double ratioY, int width, int height, int startX, int startY, int endX, int endY) {
|
||||||
FakeImage newImage = image.createImage(width, height);
|
FakeImage newImage = image.createImage(width, height);
|
||||||
startX = (int) (startX * ratioX); endX = (int) (endX * ratioX);
|
startX = (int) (startX * ratioX);
|
||||||
startY = (int) (startY * ratioY); endY = (int) (endY * ratioY);
|
endX = (int) (endX * ratioX);
|
||||||
|
startY = (int) (startY * ratioY);
|
||||||
|
endY = (int) (endY * ratioY);
|
||||||
|
|
||||||
int x0 = (int) (startX * scaleWidth), x1 = (int) ((startX + 1) * scaleWidth), dx0 = x1 - x0;
|
int x0 = (int) (startX * scaleWidth), x1 = (int) ((startX + 1) * scaleWidth), dx0 = x1 - x0;
|
||||||
for (int x = startX; x < endX; ++x) {
|
for (int x = startX; x < endX; ++x) {
|
||||||
@@ -196,12 +193,61 @@ public class FakeCapeBuffer extends FakeSkinBuffer {
|
|||||||
newImage.setRGBA(x0 + dx, y0 + dy, rgba);
|
newImage.setRGBA(x0 + dx, y0 + dy, rgba);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
y0 = y1; y1 = (int) ((y + 2) * scaleHeight); dy0 = y1 - y0;
|
y0 = y1;
|
||||||
|
y1 = (int) ((y + 2) * scaleHeight);
|
||||||
|
dy0 = y1 - y0;
|
||||||
}
|
}
|
||||||
x0 = x1; x1 = (int) ((x + 2) * scaleWidth); dx0 = x1 - x0;
|
x0 = x1;
|
||||||
|
x1 = (int) ((x + 2) * scaleWidth);
|
||||||
|
dx0 = x1 - x0;
|
||||||
}
|
}
|
||||||
if (closeOldImage)
|
if (closeOldImage)
|
||||||
image.close();
|
image.close();
|
||||||
return newImage;
|
return newImage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Judge OptiFine cape.
|
||||||
|
* OptiFine cape is 46*22 or 92*44 pixels.
|
||||||
|
* <a href="https://optifine.net/capes/Notch.png">46*22 example</a>
|
||||||
|
* <a href="https://optifine.net/capes/OptiFineCape.png">92*44 example</a>
|
||||||
|
*
|
||||||
|
* @param image cape image
|
||||||
|
* @return true if is OptiFine cape
|
||||||
|
* @since 14.16
|
||||||
|
*/
|
||||||
|
private static boolean isOptiFineCape(FakeImage image) {
|
||||||
|
int ratio = image.getWidth() / 46;
|
||||||
|
return image.getHeight() == 22 * ratio && image.getWidth() == 46 * ratio;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert OptiFine cape to standard cape
|
||||||
|
*
|
||||||
|
* @param image OptiFine cape image
|
||||||
|
* @return standard cape image
|
||||||
|
* @since 14.16
|
||||||
|
*/
|
||||||
|
private static FakeImage convertOptiFineCape(FakeImage image) {
|
||||||
|
int ratio = image.getWidth() / 46;
|
||||||
|
FakeImage newImage = image.createImage(64 * ratio, 32 * ratio);
|
||||||
|
copyImageData(image, newImage);
|
||||||
|
return newImage;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Copy image data to another image
|
||||||
|
*
|
||||||
|
* @param from from image
|
||||||
|
* @param to to image
|
||||||
|
*/
|
||||||
|
private static void copyImageData(FakeImage from, FakeImage to) {
|
||||||
|
int width = Math.min(from.getWidth(), to.getWidth());
|
||||||
|
int height = Math.min(from.getHeight(), to.getHeight());
|
||||||
|
for (int x = 0; x < width; ++x) {
|
||||||
|
for (int y = 0; y < height; ++y) {
|
||||||
|
to.setRGBA(x, y, from.getRGBA(x, y));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
+12
-3
@@ -7,7 +7,6 @@ import com.google.common.collect.Maps;
|
|||||||
import com.mojang.authlib.GameProfile;
|
import com.mojang.authlib.GameProfile;
|
||||||
import com.mojang.authlib.minecraft.MinecraftProfileTexture;
|
import com.mojang.authlib.minecraft.MinecraftProfileTexture;
|
||||||
import com.mojang.authlib.minecraft.MinecraftProfileTexture.Type;
|
import com.mojang.authlib.minecraft.MinecraftProfileTexture.Type;
|
||||||
|
|
||||||
import customskinloader.CustomSkinLoader;
|
import customskinloader.CustomSkinLoader;
|
||||||
import customskinloader.utils.MinecraftUtil;
|
import customskinloader.utils.MinecraftUtil;
|
||||||
import net.minecraft.client.renderer.ThreadDownloadImageData;
|
import net.minecraft.client.renderer.ThreadDownloadImageData;
|
||||||
@@ -16,11 +15,21 @@ import net.minecraft.client.renderer.texture.SimpleTexture;
|
|||||||
import net.minecraft.client.renderer.texture.TextureManager;
|
import net.minecraft.client.renderer.texture.TextureManager;
|
||||||
import net.minecraft.client.resources.DefaultPlayerSkin;
|
import net.minecraft.client.resources.DefaultPlayerSkin;
|
||||||
import net.minecraft.client.resources.SkinManager;
|
import net.minecraft.client.resources.SkinManager;
|
||||||
import net.minecraft.client.resources.SkinManager.SkinAvailableCallback;
|
import net.minecraft.client.resources.SkinManager$SkinAvailableCallback;
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
import net.minecraft.util.StringUtils;
|
import net.minecraft.util.StringUtils;
|
||||||
|
|
||||||
public class FakeClientPlayer {
|
public class FakeClientPlayer {
|
||||||
|
/**
|
||||||
|
* Invoked from {@link SkinManager#loadSkin(MinecraftProfileTexture, MinecraftProfileTexture.Type, SkinManager$SkinAvailableCallback)}
|
||||||
|
*/
|
||||||
|
public static ThreadDownloadImageData putCache(ThreadDownloadImageData threaddownloadimagedata, SkinManager$SkinAvailableCallback skinAvailableCallback, ResourceLocation resourcelocation) {
|
||||||
|
if (skinAvailableCallback instanceof FakeClientPlayer.LegacyBuffer) {//Cache for client player
|
||||||
|
textureCache.put(resourcelocation, threaddownloadimagedata);
|
||||||
|
}
|
||||||
|
return threaddownloadimagedata;
|
||||||
|
}
|
||||||
|
|
||||||
//For Legacy Skin
|
//For Legacy Skin
|
||||||
public static ThreadDownloadImageData getDownloadImageSkin(ResourceLocation resourceLocationIn, String username) {
|
public static ThreadDownloadImageData getDownloadImageSkin(ResourceLocation resourceLocationIn, String username) {
|
||||||
//CustomSkinLoader.logger.debug("FakeClientPlayer/getDownloadImageSkin "+username);
|
//CustomSkinLoader.logger.debug("FakeClientPlayer/getDownloadImageSkin "+username);
|
||||||
@@ -59,7 +68,7 @@ public class FakeClientPlayer {
|
|||||||
|
|
||||||
public static Map<ResourceLocation, ITextureObject> textureCache = Maps.newHashMap();
|
public static Map<ResourceLocation, ITextureObject> textureCache = Maps.newHashMap();
|
||||||
|
|
||||||
public static class LegacyBuffer implements SkinAvailableCallback {
|
public static class LegacyBuffer implements SkinManager$SkinAvailableCallback {
|
||||||
ResourceLocation resourceLocationIn;
|
ResourceLocation resourceLocationIn;
|
||||||
boolean loaded = false;
|
boolean loaded = false;
|
||||||
|
|
||||||
@@ -0,0 +1,71 @@
|
|||||||
|
package customskinloader.fake;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
import java.util.concurrent.CountDownLatch;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
import com.mojang.authlib.minecraft.MinecraftProfileTexture;
|
||||||
|
import customskinloader.CustomSkinLoader;
|
||||||
|
import customskinloader.utils.HttpTextureUtil;
|
||||||
|
|
||||||
|
public class FakeMinecraftProfileTexture extends MinecraftProfileTexture {
|
||||||
|
private final static Map<String, String> MODEL_CACHE = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
|
private final HttpTextureUtil.HttpTextureInfo info;
|
||||||
|
private final Map<String, String> metadata;
|
||||||
|
private final CountDownLatch latch = new CountDownLatch(1);
|
||||||
|
|
||||||
|
public FakeMinecraftProfileTexture(String url, Map<String, String> metadata) {
|
||||||
|
super(url, metadata);
|
||||||
|
this.info = HttpTextureUtil.toHttpTextureInfo(url);
|
||||||
|
this.metadata = metadata;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getUrl() {
|
||||||
|
return this.info.url;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getMetadata(String key) {
|
||||||
|
return this.getMetadata(key, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getMetadata(String key, boolean lock) {
|
||||||
|
String value = super.getMetadata(key);
|
||||||
|
if ("model".equals(key) && "auto".equals(value)) {
|
||||||
|
String model = MODEL_CACHE.get(this.getHash());
|
||||||
|
if (model != null) {
|
||||||
|
return model;
|
||||||
|
} else {
|
||||||
|
try {
|
||||||
|
if (lock && this.latch.await(60L * CustomSkinLoader.config.loadlist.size(), TimeUnit.SECONDS)) {
|
||||||
|
return this.getMetadata(key, false);
|
||||||
|
}
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setModel(String model) {
|
||||||
|
if (this.metadata != null) {
|
||||||
|
MODEL_CACHE.put(this.getHash(), model);
|
||||||
|
this.metadata.put("model", model);
|
||||||
|
this.latch.countDown();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getHash() {
|
||||||
|
return this.info.hash == null ? super.getHash() : this.info.hash;
|
||||||
|
}
|
||||||
|
|
||||||
|
public File getCacheFile() {
|
||||||
|
return this.info.cacheFile;
|
||||||
|
}
|
||||||
|
}
|
||||||
+62
-26
@@ -1,6 +1,8 @@
|
|||||||
package customskinloader.fake;
|
package customskinloader.fake;
|
||||||
|
|
||||||
import java.awt.image.BufferedImage;
|
import java.awt.image.BufferedImage;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.nio.file.Path;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
import java.util.function.Predicate;
|
import java.util.function.Predicate;
|
||||||
|
|
||||||
@@ -9,18 +11,42 @@ import customskinloader.fake.texture.FakeBufferedImage;
|
|||||||
import customskinloader.fake.texture.FakeImage;
|
import customskinloader.fake.texture.FakeImage;
|
||||||
import customskinloader.fake.texture.FakeNativeImage;
|
import customskinloader.fake.texture.FakeNativeImage;
|
||||||
import net.minecraft.client.renderer.IImageBuffer;
|
import net.minecraft.client.renderer.IImageBuffer;
|
||||||
|
import net.minecraft.client.renderer.ThreadDownloadImageData;
|
||||||
import net.minecraft.client.renderer.texture.NativeImage;
|
import net.minecraft.client.renderer.texture.NativeImage;
|
||||||
|
import net.minecraft.client.renderer.texture.SkinTextureDownloader;
|
||||||
|
|
||||||
public class FakeSkinBuffer implements IImageBuffer {
|
public class FakeSkinBuffer implements IImageBuffer {
|
||||||
private int ratio = 1;
|
|
||||||
FakeImage image = null;
|
FakeImage image = null;
|
||||||
|
|
||||||
//parseUserSkin for 1.15+
|
/**
|
||||||
|
* 24w46a+
|
||||||
|
* Invoked from {@link SkinTextureDownloader#lambda$downloadAndRegisterSkin$0(Path, String, boolean)}
|
||||||
|
*/
|
||||||
|
public static NativeImage processLegacySkin(NativeImage image, String url) {
|
||||||
|
if (image == null)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
FakeImage img = parseUserSkin0(new FakeNativeImage(image));
|
||||||
|
if (img instanceof FakeNativeImage) {
|
||||||
|
return FakeNativeImage.Extended.create((FakeNativeImage) img);
|
||||||
|
}
|
||||||
|
|
||||||
|
CustomSkinLoader.logger.warning("Failed to parseUserSkin(downloadAndRegisterSkin).");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 19w38a ~ 24w45a
|
||||||
|
* Invoked from {@link ThreadDownloadImageData#loadTexture(InputStream)}
|
||||||
|
*/
|
||||||
public static NativeImage processLegacySkin(NativeImage image, Runnable processTask, Function<NativeImage, NativeImage> processLegacySkin) {
|
public static NativeImage processLegacySkin(NativeImage image, Runnable processTask, Function<NativeImage, NativeImage> processLegacySkin) {
|
||||||
if (processTask instanceof IImageBuffer) {
|
if (processTask instanceof IImageBuffer) {
|
||||||
return ((IImageBuffer) processTask).func_195786_a(image);
|
return ((IImageBuffer) processTask).func_195786_a(image);
|
||||||
|
} else if (processLegacySkin != null) {
|
||||||
|
return processLegacySkin.apply(image);
|
||||||
|
} else {
|
||||||
|
return image;
|
||||||
}
|
}
|
||||||
return processLegacySkin.apply(image);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//parseUserSkin for 1.13+
|
//parseUserSkin for 1.13+
|
||||||
@@ -50,8 +76,12 @@ public class FakeSkinBuffer implements IImageBuffer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public FakeImage parseUserSkin(FakeImage image) {
|
public FakeImage parseUserSkin(FakeImage image) {
|
||||||
|
return this.image = parseUserSkin0(image);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static FakeImage parseUserSkin0(FakeImage image) {
|
||||||
if (image == null) return null;
|
if (image == null) return null;
|
||||||
this.ratio = image.getWidth() / 64;
|
int ratio = image.getWidth() / 64;
|
||||||
|
|
||||||
if (image.getHeight() != image.getWidth()) {//Single Layer
|
if (image.getHeight() != image.getWidth()) {//Single Layer
|
||||||
//Create a new image and copy origin image data
|
//Create a new image and copy origin image data
|
||||||
@@ -77,27 +107,32 @@ public class FakeSkinBuffer implements IImageBuffer {
|
|||||||
image.copyArea(52 * ratio, 20 * ratio, -8 * ratio, 32 * ratio, 4 * ratio, 12 * ratio, true, false);//Back
|
image.copyArea(52 * ratio, 20 * ratio, -8 * ratio, 32 * ratio, 4 * ratio, 12 * ratio, true, false);//Back
|
||||||
}
|
}
|
||||||
|
|
||||||
this.image = image;
|
setAreaDueToConfig(image, 0 * ratio, 0 * ratio, 32 * ratio, 16 * ratio);//Head - 1
|
||||||
setAreaDueToConfig(0 * ratio, 0 * ratio, 32 * ratio, 16 * ratio);//Head - 1
|
setAreaTransparent(image, 32 * ratio, 0 * ratio, 64 * ratio, 16 * ratio);//Head - 2
|
||||||
setAreaTransparent(32 * ratio, 0 * ratio, 64 * ratio, 16 * ratio);//Head - 2
|
setAreaDueToConfig(image, 16 * ratio, 16 * ratio, 40 * ratio, 32 * ratio);//Body - 1
|
||||||
setAreaDueToConfig(16 * ratio, 16 * ratio, 40 * ratio, 32 * ratio);//Body - 1
|
setAreaTransparent(image, 16 * ratio, 32 * ratio, 40 * ratio, 48 * ratio);//Body - 2
|
||||||
setAreaTransparent(16 * ratio, 32 * ratio, 40 * ratio, 48 * ratio);//Body - 2
|
|
||||||
|
|
||||||
setAreaDueToConfig(40 * ratio, 16 * ratio, 56 * ratio, 32 * ratio);//Right Arm - 1
|
setAreaDueToConfig(image, 40 * ratio, 16 * ratio, 56 * ratio, 32 * ratio);//Right Arm - 1
|
||||||
setAreaTransparent(40 * ratio, 32 * ratio, 56 * ratio, 48 * ratio);//Right Arm - 2
|
setAreaTransparent(image, 40 * ratio, 32 * ratio, 56 * ratio, 48 * ratio);//Right Arm - 2
|
||||||
setAreaDueToConfig(0 * ratio, 16 * ratio, 16 * ratio, 32 * ratio);//Right Leg - 1
|
setAreaDueToConfig(image, 0 * ratio, 16 * ratio, 16 * ratio, 32 * ratio);//Right Leg - 1
|
||||||
setAreaTransparent(0 * ratio, 32 * ratio, 16 * ratio, 48 * ratio);//Right Leg - 2
|
setAreaTransparent(image, 0 * ratio, 32 * ratio, 16 * ratio, 48 * ratio);//Right Leg - 2
|
||||||
|
|
||||||
setAreaDueToConfig(32 * ratio, 48 * ratio, 48 * ratio, 64 * ratio);//Left Arm - 1
|
setAreaDueToConfig(image, 32 * ratio, 48 * ratio, 48 * ratio, 64 * ratio);//Left Arm - 1
|
||||||
setAreaTransparent(48 * ratio, 48 * ratio, 64 * ratio, 64 * ratio);//Left Arm - 2
|
setAreaTransparent(image, 48 * ratio, 48 * ratio, 64 * ratio, 64 * ratio);//Left Arm - 2
|
||||||
setAreaDueToConfig(16 * ratio, 48 * ratio, 32 * ratio, 64 * ratio);//Left Leg - 1
|
setAreaDueToConfig(image, 16 * ratio, 48 * ratio, 32 * ratio, 64 * ratio);//Left Leg - 1
|
||||||
setAreaTransparent(0 * ratio, 48 * ratio, 16 * ratio, 64 * ratio);//Left Leg - 2
|
setAreaTransparent(image, 0 * ratio, 48 * ratio, 16 * ratio, 64 * ratio);//Left Leg - 2
|
||||||
|
|
||||||
|
image.setRatio(ratio);
|
||||||
return image;
|
return image;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Judge if the color is transparent or same with background */
|
/** Judge if the color is transparent or same with background */
|
||||||
static final Function<Integer, Predicate<Integer>> EQU_BG = bgColor -> getA(bgColor) == 0 ? (c) -> getA(c) == 0 : (c) -> c.equals(bgColor);
|
static final Function<Integer, Predicate<Integer>> EQU_BG = bgColor -> getA(bgColor) == 0 ? (c) -> getA(c) == 0 : (c) -> c.equals(bgColor);
|
||||||
|
|
||||||
|
public String judgeType() {
|
||||||
|
return judgeType0(this.image);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Judge the type of skin
|
* Judge the type of skin
|
||||||
* Must be called after parseUserSkin
|
* Must be called after parseUserSkin
|
||||||
@@ -105,9 +140,10 @@ public class FakeSkinBuffer implements IImageBuffer {
|
|||||||
* @return type of skin (slim / default)
|
* @return type of skin (slim / default)
|
||||||
* @since 14.9
|
* @since 14.9
|
||||||
*/
|
*/
|
||||||
public String judgeType() {
|
public static String judgeType0(FakeImage image) {
|
||||||
if (this.image == null)
|
if (image == null)
|
||||||
return "default";
|
return "default";
|
||||||
|
int ratio = image.getRatio();
|
||||||
int bgColor = image.getRGBA(63 * ratio, 20 * ratio);
|
int bgColor = image.getRGBA(63 * ratio, 20 * ratio);
|
||||||
/*
|
/*
|
||||||
* If background is transparent, all the pixels in ((54, 20), (55, 31)) areas is transparent,
|
* If background is transparent, all the pixels in ((54, 20), (55, 31)) areas is transparent,
|
||||||
@@ -134,7 +170,7 @@ public class FakeSkinBuffer implements IImageBuffer {
|
|||||||
private static final int WHITE = getARGB(255, 255, 255, 255);
|
private static final int WHITE = getARGB(255, 255, 255, 255);
|
||||||
private static final int BLACK = getARGB(255, 0, 0, 0);
|
private static final int BLACK = getARGB(255, 0, 0, 0);
|
||||||
|
|
||||||
private boolean isFilled(int x0, int y0, int x1, int y1) {
|
private static boolean isFilled(FakeImage image, int x0, int y0, int x1, int y1) {
|
||||||
int data = image.getRGBA(x0, y0);
|
int data = image.getRGBA(x0, y0);
|
||||||
if (data != WHITE && data != BLACK)
|
if (data != WHITE && data != BLACK)
|
||||||
return false;
|
return false;
|
||||||
@@ -145,8 +181,8 @@ public class FakeSkinBuffer implements IImageBuffer {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setAreaTransparent(int x0, int y0, int x1, int y1) {
|
private static void setAreaTransparent(FakeImage image, int x0, int y0, int x1, int y1) {
|
||||||
if (!isFilled(x0, y0, x1, y1))
|
if (!isFilled(image, x0, y0, x1, y1))
|
||||||
return;
|
return;
|
||||||
for (int x = x0; x < x1; ++x)
|
for (int x = x0; x < x1; ++x)
|
||||||
for (int y = y0; y < y1; ++y)
|
for (int y = y0; y < y1; ++y)
|
||||||
@@ -159,17 +195,17 @@ public class FakeSkinBuffer implements IImageBuffer {
|
|||||||
* 11111111 00000000 00000000 00000000 */
|
* 11111111 00000000 00000000 00000000 */
|
||||||
private static final int B = -16777216;
|
private static final int B = -16777216;
|
||||||
|
|
||||||
private void setAreaOpaque(int x0, int y0, int x1, int y1) {
|
private static void setAreaOpaque(FakeImage image, int x0, int y0, int x1, int y1) {
|
||||||
for (int x = x0; x < x1; ++x)
|
for (int x = x0; x < x1; ++x)
|
||||||
for (int y = y0; y < y1; ++y)
|
for (int y = y0; y < y1; ++y)
|
||||||
image.setRGBA(x, y, image.getRGBA(x, y) | B);
|
image.setRGBA(x, y, image.getRGBA(x, y) | B);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setAreaDueToConfig(int x0, int y0, int x1, int y1) {
|
private static void setAreaDueToConfig(FakeImage image, int x0, int y0, int x1, int y1) {
|
||||||
if (customskinloader.CustomSkinLoader.config.enableTransparentSkin)
|
if (customskinloader.CustomSkinLoader.config.enableTransparentSkin)
|
||||||
setAreaTransparent(x0, y0, x1, y1);
|
setAreaTransparent(image, x0, y0, x1, y1);
|
||||||
else
|
else
|
||||||
setAreaOpaque(x0, y0, x1, y1);
|
setAreaOpaque(image, x0, y0, x1, y1);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void skinAvailable() {
|
public void skinAvailable() {
|
||||||
@@ -0,0 +1,245 @@
|
|||||||
|
package customskinloader.fake;
|
||||||
|
|
||||||
|
import java.awt.image.BufferedImage;
|
||||||
|
import java.io.File;
|
||||||
|
import java.nio.file.Path;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.UUID;
|
||||||
|
import java.util.concurrent.Executor;
|
||||||
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
|
import com.google.common.collect.ImmutableList;
|
||||||
|
import com.mojang.authlib.GameProfile;
|
||||||
|
import com.mojang.authlib.SignatureState;
|
||||||
|
import com.mojang.authlib.minecraft.MinecraftProfileTexture;
|
||||||
|
import com.mojang.authlib.minecraft.MinecraftProfileTextures;
|
||||||
|
import com.mojang.authlib.minecraft.MinecraftSessionService;
|
||||||
|
import com.mojang.authlib.properties.Property;
|
||||||
|
import customskinloader.CustomSkinLoader;
|
||||||
|
import customskinloader.fake.texture.FakeResourceLocation;
|
||||||
|
import customskinloader.profile.ModelManager0;
|
||||||
|
import customskinloader.utils.HttpTextureUtil;
|
||||||
|
import net.minecraft.client.renderer.IImageBuffer;
|
||||||
|
import net.minecraft.client.renderer.texture.NativeImage;
|
||||||
|
import net.minecraft.client.renderer.texture.TextureManager;
|
||||||
|
import net.minecraft.client.resources.SkinManager;
|
||||||
|
import net.minecraft.client.resources.SkinManager$1;
|
||||||
|
import net.minecraft.client.resources.SkinManager$CacheKey;
|
||||||
|
import net.minecraft.client.resources.SkinManager$SkinAvailableCallback;
|
||||||
|
import net.minecraft.client.resources.SkinManager$TextureCache;
|
||||||
|
import net.minecraft.server.Services;
|
||||||
|
import net.minecraft.util.ResourceLocation;
|
||||||
|
|
||||||
|
public class FakeSkinManager {
|
||||||
|
/**
|
||||||
|
* 1.20.1-
|
||||||
|
* Invoked from {@link SkinManager(TextureManager, File, MinecraftSessionService)}
|
||||||
|
*/
|
||||||
|
public static void setSkinCacheDir(File skinCacheDirectory) {
|
||||||
|
HttpTextureUtil.defaultCacheDir = skinCacheDirectory;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 23w31a ~ 23w45a
|
||||||
|
* Invoked from {@link SkinManager(TextureManager, Path, MinecraftSessionService, Executor)}
|
||||||
|
*
|
||||||
|
* 23w46a ~ 25w33a
|
||||||
|
* Invoked from {@link SkinManager(Path, MinecraftSessionService, Executor)}
|
||||||
|
*
|
||||||
|
* 25w34a+
|
||||||
|
* Invoked from {@link SkinManager(Path, Services, Executor)}
|
||||||
|
*/
|
||||||
|
public static void setSkinCacheDir(Path skinCacheDirectory) {
|
||||||
|
HttpTextureUtil.defaultCacheDir = skinCacheDirectory.toFile();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 23w42a ~ 25w33a
|
||||||
|
* Invoked from {@link SkinManager#getOrLoad(GameProfile)}
|
||||||
|
*
|
||||||
|
* 25w34a+
|
||||||
|
* Invoked from {@link SkinManager#get(GameProfile)}
|
||||||
|
*/
|
||||||
|
public static Property createProperty(Property property) {
|
||||||
|
return property == null ? new Property(null, null) : property;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 1.20.1-
|
||||||
|
* Invoked from {@link SkinManager#loadSkin(MinecraftProfileTexture, MinecraftProfileTexture.Type, SkinManager$SkinAvailableCallback)}
|
||||||
|
*
|
||||||
|
* 23w31a+
|
||||||
|
* Invoked from {@link SkinManager$TextureCache#registerTexture(MinecraftProfileTexture)}
|
||||||
|
*/
|
||||||
|
public static Object[] createThreadDownloadImageData(ImmutableList<Object> list, MinecraftProfileTexture profileTexture, MinecraftProfileTexture.Type textureType) {
|
||||||
|
Object[] params = list.toArray();
|
||||||
|
if (profileTexture instanceof FakeMinecraftProfileTexture) {
|
||||||
|
FakeMinecraftProfileTexture fakeProfileTexture = (FakeMinecraftProfileTexture) profileTexture;
|
||||||
|
File cacheFile = fakeProfileTexture.getCacheFile();
|
||||||
|
if (params.length == 4) {
|
||||||
|
if (params[3] instanceof Boolean) { // 24w46a+
|
||||||
|
if ((Boolean) params[3]) {
|
||||||
|
params[0] = FakeResourceLocation.create((ResourceLocation) params[0], fakeProfileTexture);
|
||||||
|
}
|
||||||
|
params[1] = cacheFile.toPath();
|
||||||
|
} else { // 19w37a-
|
||||||
|
params[0] = cacheFile;
|
||||||
|
params[3] = new BaseBuffer((Runnable) params[3], textureType, fakeProfileTexture);
|
||||||
|
}
|
||||||
|
} else if (params.length == 5) { // 19w38a ~ 24w45a
|
||||||
|
params[0] = cacheFile;
|
||||||
|
params[3] = true;
|
||||||
|
params[4] = new BaseBuffer((Runnable) params[4], textureType, fakeProfileTexture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return params;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 1.20.1-
|
||||||
|
* Invoked from {@link SkinManager#loadProfileTextures(GameProfile, SkinManager$SkinAvailableCallback, boolean)}
|
||||||
|
*/
|
||||||
|
public static void loadProfileTextures(Runnable runnable) {
|
||||||
|
CustomSkinLoader.loadProfileTextures(runnable);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 23w31a+
|
||||||
|
* Invoked from {@link SkinManager$1#load(SkinManager$CacheKey)}
|
||||||
|
*/
|
||||||
|
public static Executor loadProfileTextures(Executor executor) {
|
||||||
|
return CustomSkinLoader.THREAD_POOL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 1.20.1-
|
||||||
|
* Invoked from {@link SkinManager#func_210275_a(GameProfile, boolean, SkinManager$SkinAvailableCallback)}
|
||||||
|
*/
|
||||||
|
public static Map<MinecraftProfileTexture.Type, MinecraftProfileTexture> getUserProfile(MinecraftSessionService sessionService, GameProfile profile, boolean requireSecure) {
|
||||||
|
return ModelManager0.fromUserProfile(CustomSkinLoader.loadProfile(profile));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 1.20.1-
|
||||||
|
* Invoked from {@link SkinManager#func_210276_a(Map, SkinManager$SkinAvailableCallback)}
|
||||||
|
*/
|
||||||
|
public static void loadElytraTexture(SkinManager skinManager, Map<MinecraftProfileTexture.Type, MinecraftProfileTexture> map, SkinManager$SkinAvailableCallback skinAvailableCallback) {
|
||||||
|
for (int i = 2; i < MinecraftProfileTexture.Type.values().length; i++) {
|
||||||
|
MinecraftProfileTexture.Type type = MinecraftProfileTexture.Type.values()[i];
|
||||||
|
if (map.containsKey(type)) {
|
||||||
|
skinManager.loadSkin(map.get(type), type, skinAvailableCallback);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 1.20.1-
|
||||||
|
* Invoked from {@link SkinManager#loadSkinFromCache(GameProfile)}
|
||||||
|
*/
|
||||||
|
public static Map<MinecraftProfileTexture.Type, MinecraftProfileTexture> loadSkinFromCache(GameProfile profile) {
|
||||||
|
return CustomSkinLoader.loadProfileFromCache(profile);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 23w31a ~ 23w41a
|
||||||
|
* Invoked from {@link SkinManager$1#lambda$load$0(MinecraftSessionService, GameProfile)}
|
||||||
|
*/
|
||||||
|
public static Map<MinecraftProfileTexture.Type, MinecraftProfileTexture> loadSkinFromCache(MinecraftSessionService sessionService, GameProfile profile, boolean requireSecure) {
|
||||||
|
return getUserProfile(sessionService, profile, requireSecure);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 23w42a ~ 25w33a
|
||||||
|
* Invoked from {@link SkinManager$1#lambda$load$0(SkinManager$CacheKey, MinecraftSessionService)}
|
||||||
|
*
|
||||||
|
* 25w34a+
|
||||||
|
* Invoked from {@link SkinManager$1#lambda$load$0(SkinManager$CacheKey, Services)}
|
||||||
|
*/
|
||||||
|
public static Object loadSkinFromCache(MinecraftSessionService sessionService, Property property, SkinManager$CacheKey cacheKey) {
|
||||||
|
if (cacheKey instanceof FakeCacheKey) {
|
||||||
|
return FakeCacheKey.createMinecraftProfileTextures(loadSkinFromCache(sessionService, ((FakeCacheKey) cacheKey).profile(), false));
|
||||||
|
}
|
||||||
|
return sessionService.unpackTextures(property);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class BaseBuffer implements IImageBuffer {
|
||||||
|
private IImageBuffer buffer;
|
||||||
|
|
||||||
|
private final Runnable callback;
|
||||||
|
private final FakeMinecraftProfileTexture texture;
|
||||||
|
|
||||||
|
public BaseBuffer(Runnable callback, MinecraftProfileTexture.Type type, FakeMinecraftProfileTexture texture) {
|
||||||
|
this.callback = callback;
|
||||||
|
this.texture = texture;
|
||||||
|
|
||||||
|
switch (type) {
|
||||||
|
case SKIN: this.buffer = new FakeSkinBuffer(); break;
|
||||||
|
case CAPE: this.buffer = new FakeCapeBuffer(); break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public NativeImage func_195786_a(NativeImage image) {
|
||||||
|
return this.buffer instanceof FakeSkinBuffer ? this.buffer.func_195786_a(image) : image;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BufferedImage parseUserSkin(BufferedImage image) {
|
||||||
|
return this.buffer instanceof FakeSkinBuffer ? this.buffer.parseUserSkin(image) : image;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void skinAvailable() {
|
||||||
|
if (this.buffer != null) {
|
||||||
|
this.buffer.skinAvailable();
|
||||||
|
if (this.buffer instanceof FakeSkinBuffer) {
|
||||||
|
judgeType(this.texture, () -> ((FakeSkinBuffer) this.buffer).judgeType());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.callback != null) {
|
||||||
|
this.callback.run();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void judgeType(FakeMinecraftProfileTexture texture, Supplier<String> type) {
|
||||||
|
if (shouldJudgeType(texture)) {
|
||||||
|
//Auto judge skin type
|
||||||
|
texture.setModel(type.get());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static boolean shouldJudgeType(FakeMinecraftProfileTexture texture) {
|
||||||
|
return texture != null && "auto".equals(texture.getMetadata("model", false));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class FakeCacheKey extends SkinManager$CacheKey {
|
||||||
|
private final GameProfile profile;
|
||||||
|
|
||||||
|
public FakeCacheKey(UUID uuid, Property property, GameProfile profile) {
|
||||||
|
super(uuid, property);
|
||||||
|
this.profile = profile;
|
||||||
|
}
|
||||||
|
|
||||||
|
public GameProfile profile() {
|
||||||
|
return this.profile;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 23w42a ~ 25w33a
|
||||||
|
* Invoked from {@link SkinManager#getOrLoad(GameProfile)}
|
||||||
|
*
|
||||||
|
* 25w34a+
|
||||||
|
* Invoked from {@link SkinManager#get(GameProfile)}
|
||||||
|
*/
|
||||||
|
public static SkinManager$CacheKey createFakeCacheKey(UUID uuid, Property property, GameProfile profile) {
|
||||||
|
return new FakeCacheKey(uuid, property, profile);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Object createMinecraftProfileTextures(Map<MinecraftProfileTexture.Type, MinecraftProfileTexture> textures) {
|
||||||
|
return new MinecraftProfileTextures(textures.get(MinecraftProfileTexture.Type.SKIN), textures.get(MinecraftProfileTexture.Type.CAPE), textures.get(MinecraftProfileTexture.Type.ELYTRA), SignatureState.SIGNED);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
package customskinloader.fake.itf;
|
||||||
|
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
import net.minecraft.client.resources.IResource;
|
||||||
|
import net.minecraft.client.resources.IResourceManager;
|
||||||
|
import net.minecraft.util.ResourceLocation;
|
||||||
|
|
||||||
|
public class FakeInterfaceManager {
|
||||||
|
public static InputStream IResource_getInputStream(Object resource) {
|
||||||
|
return ((IFakeIResource.V2) resource).open();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Optional<IResource> IResourceManager_getResource(Object resourceManager, ResourceLocation location) {
|
||||||
|
return ((IFakeIResourceManager) resourceManager).getResource(location);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static IResourceManager Minecraft_getResourceManager(Object minecraft) {
|
||||||
|
return (IResourceManager) ((IFakeMinecraft) minecraft).func_195551_G();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int NativeImage_getPixel(Object nativeImage, int x, int y) {
|
||||||
|
return ((IFakeNativeImage) nativeImage).getPixel(x, y);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void NativeImage_setPixel(Object nativeImage, int x, int y, int color) {
|
||||||
|
((IFakeNativeImage) nativeImage).setPixel(x, y, color);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
package customskinloader.fake.itf;
|
||||||
|
|
||||||
|
import net.minecraft.client.renderer.IImageBuffer;
|
||||||
|
|
||||||
|
public interface IFakeIImageBuffer extends Runnable {
|
||||||
|
@Override
|
||||||
|
default void run() {
|
||||||
|
((IImageBuffer) this).skinAvailable();
|
||||||
|
}
|
||||||
|
}
|
||||||
+1
-1
@@ -4,7 +4,7 @@ import java.io.InputStream;
|
|||||||
|
|
||||||
import net.minecraft.client.resources.IResource;
|
import net.minecraft.client.resources.IResource;
|
||||||
|
|
||||||
/** {@link net.minecraft.client.resources.IResource} is no longer an interface since 22w14a */
|
/** {@link IResource} is no longer an interface since 22w14a */
|
||||||
public interface IFakeIResource {
|
public interface IFakeIResource {
|
||||||
// 1.13.2 ~ 22w13a
|
// 1.13.2 ~ 22w13a
|
||||||
interface V1 {
|
interface V1 {
|
||||||
+2
-3
@@ -1,6 +1,5 @@
|
|||||||
package customskinloader.fake.itf;
|
package customskinloader.fake.itf;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
import net.minecraft.client.resources.IResourceManager;
|
import net.minecraft.client.resources.IResourceManager;
|
||||||
@@ -9,12 +8,12 @@ import net.minecraft.util.ResourceLocation;
|
|||||||
|
|
||||||
public interface IFakeIResourceManager {
|
public interface IFakeIResourceManager {
|
||||||
// 1.13.2 ~ 22w13a
|
// 1.13.2 ~ 22w13a
|
||||||
default IResource func_199002_a(ResourceLocation location) throws IOException {
|
default IResource func_199002_a(ResourceLocation location) {
|
||||||
return (IResource) ((IResourceManager) this).getResource(location);
|
return (IResource) ((IResourceManager) this).getResource(location);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 22w14a+
|
// 22w14a+
|
||||||
default Optional getResource(ResourceLocation location) throws IOException {
|
default Optional getResource(ResourceLocation location) {
|
||||||
return Optional.ofNullable(this.func_199002_a(location));
|
return Optional.ofNullable(this.func_199002_a(location));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
-5
@@ -8,9 +8,4 @@ public interface IFakeMinecraft {
|
|||||||
default IResourceManager func_195551_G() {
|
default IResourceManager func_195551_G() {
|
||||||
return (IResourceManager) ((Minecraft) this).getResourceManager();
|
return (IResourceManager) ((Minecraft) this).getResourceManager();
|
||||||
}
|
}
|
||||||
|
|
||||||
// 1.14+
|
|
||||||
default void execute(Runnable runnable) {
|
|
||||||
((Minecraft) this).addScheduledTask(runnable);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
package customskinloader.fake.itf;
|
||||||
|
|
||||||
|
import net.minecraft.client.renderer.texture.NativeImage;
|
||||||
|
|
||||||
|
public interface IFakeNativeImage {
|
||||||
|
default int getPixel(int x, int y) {
|
||||||
|
return ((NativeImage) this).func_195709_a(x, y);
|
||||||
|
}
|
||||||
|
|
||||||
|
default void setPixel(int x, int y, int color) {
|
||||||
|
((NativeImage) this).func_195700_a(x, y, color);
|
||||||
|
}
|
||||||
|
}
|
||||||
+11
@@ -10,6 +10,7 @@ import javax.imageio.ImageIO;
|
|||||||
public class FakeBufferedImage implements FakeImage {
|
public class FakeBufferedImage implements FakeImage {
|
||||||
private BufferedImage image;
|
private BufferedImage image;
|
||||||
private Graphics graphics;
|
private Graphics graphics;
|
||||||
|
private int ratio;
|
||||||
|
|
||||||
public FakeBufferedImage(int width, int height) {
|
public FakeBufferedImage(int width, int height) {
|
||||||
this(new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB));
|
this(new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB));
|
||||||
@@ -33,6 +34,16 @@ public class FakeBufferedImage implements FakeImage {
|
|||||||
return new FakeBufferedImage(ImageIO.read(is));
|
return new FakeBufferedImage(ImageIO.read(is));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getRatio() {
|
||||||
|
return this.ratio;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setRatio(int ratio) {
|
||||||
|
this.ratio = ratio;
|
||||||
|
}
|
||||||
|
|
||||||
public int getWidth() {
|
public int getWidth() {
|
||||||
return image.getWidth();
|
return image.getWidth();
|
||||||
}
|
}
|
||||||
+4
@@ -8,6 +8,10 @@ public interface FakeImage {
|
|||||||
|
|
||||||
FakeImage createImage(InputStream is) throws IOException;
|
FakeImage createImage(InputStream is) throws IOException;
|
||||||
|
|
||||||
|
int getRatio();
|
||||||
|
|
||||||
|
void setRatio(int ratio);
|
||||||
|
|
||||||
int getWidth();
|
int getWidth();
|
||||||
|
|
||||||
int getHeight();
|
int getHeight();
|
||||||
+33
-2
@@ -2,10 +2,12 @@ package customskinloader.fake.texture;
|
|||||||
|
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
|
||||||
|
import customskinloader.fake.itf.FakeInterfaceManager;
|
||||||
import net.minecraft.client.renderer.texture.NativeImage;
|
import net.minecraft.client.renderer.texture.NativeImage;
|
||||||
|
|
||||||
public class FakeNativeImage implements FakeImage {
|
public class FakeNativeImage implements FakeImage {
|
||||||
private NativeImage image;
|
private NativeImage image;
|
||||||
|
private int ratio;
|
||||||
|
|
||||||
public FakeNativeImage(int width, int height) {
|
public FakeNativeImage(int width, int height) {
|
||||||
this(new NativeImage(width, height, true));
|
this(new NativeImage(width, height, true));
|
||||||
@@ -27,6 +29,16 @@ public class FakeNativeImage implements FakeImage {
|
|||||||
return new FakeNativeImage(NativeImage.func_195713_a(is));
|
return new FakeNativeImage(NativeImage.func_195713_a(is));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getRatio() {
|
||||||
|
return this.ratio;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setRatio(int ratio) {
|
||||||
|
this.ratio = ratio;
|
||||||
|
}
|
||||||
|
|
||||||
public int getWidth() {
|
public int getWidth() {
|
||||||
return image.func_195702_a();
|
return image.func_195702_a();
|
||||||
}
|
}
|
||||||
@@ -36,11 +48,11 @@ public class FakeNativeImage implements FakeImage {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public int getRGBA(int x, int y) {
|
public int getRGBA(int x, int y) {
|
||||||
return image.func_195709_a(x, y);
|
return FakeInterfaceManager.NativeImage_getPixel(image, x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setRGBA(int x, int y, int rgba) {
|
public void setRGBA(int x, int y, int rgba) {
|
||||||
image.func_195700_a(x, y, rgba);
|
FakeInterfaceManager.NativeImage_setPixel(image, x, y, rgba);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void copyImageData(FakeImage image) {
|
public void copyImageData(FakeImage image) {
|
||||||
@@ -57,5 +69,24 @@ public class FakeNativeImage implements FakeImage {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void close() {
|
public void close() {
|
||||||
|
image.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Extended extends NativeImage {
|
||||||
|
public static NativeImage create(FakeNativeImage fakeImage) {
|
||||||
|
return new FakeNativeImage.Extended(fakeImage);
|
||||||
|
}
|
||||||
|
|
||||||
|
private final FakeNativeImage fakeImage;
|
||||||
|
|
||||||
|
public Extended(FakeNativeImage fakeImage) {
|
||||||
|
super(fakeImage.getWidth(), fakeImage.getHeight(), true);
|
||||||
|
this.func_195703_a(fakeImage.getImage());
|
||||||
|
this.fakeImage = fakeImage;
|
||||||
|
}
|
||||||
|
|
||||||
|
public FakeNativeImage getFakeImage() {
|
||||||
|
return this.fakeImage;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
package customskinloader.fake.texture;
|
||||||
|
|
||||||
|
import customskinloader.fake.FakeMinecraftProfileTexture;
|
||||||
|
import net.minecraft.util.ResourceLocation;
|
||||||
|
|
||||||
|
public class FakeResourceLocation extends ResourceLocation {
|
||||||
|
public static FakeResourceLocation create(ResourceLocation location, FakeMinecraftProfileTexture texture) {
|
||||||
|
String[] s = location.toString().split(":", 2);
|
||||||
|
return new FakeResourceLocation(s[0], s[1], texture);
|
||||||
|
}
|
||||||
|
|
||||||
|
private final FakeMinecraftProfileTexture texture;
|
||||||
|
|
||||||
|
public FakeResourceLocation(String domain, String path, FakeMinecraftProfileTexture texture) {
|
||||||
|
super(domain, path);
|
||||||
|
this.texture = texture;
|
||||||
|
}
|
||||||
|
|
||||||
|
public FakeMinecraftProfileTexture getTexture() {
|
||||||
|
return this.texture;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,46 @@
|
|||||||
|
package customskinloader.fake.texture;
|
||||||
|
|
||||||
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
import java.util.function.Function;
|
||||||
|
|
||||||
|
import customskinloader.fake.FakeCapeBuffer;
|
||||||
|
import customskinloader.fake.FakeSkinBuffer;
|
||||||
|
import customskinloader.fake.FakeSkinManager;
|
||||||
|
import net.minecraft.client.Minecraft;
|
||||||
|
import net.minecraft.client.renderer.texture.NativeImage;
|
||||||
|
import net.minecraft.client.renderer.texture.SimpleTexture;
|
||||||
|
import net.minecraft.client.renderer.texture.TextureContents;
|
||||||
|
import net.minecraft.client.resources.IResourceManager;
|
||||||
|
import net.minecraft.util.ResourceLocation;
|
||||||
|
|
||||||
|
// 24w46a+
|
||||||
|
public class FakeThreadDownloadImageData extends SimpleTexture {
|
||||||
|
private FakeCapeBuffer buffer;
|
||||||
|
private FakeNativeImage image;
|
||||||
|
|
||||||
|
public static Function<NativeImage, CompletableFuture<?>> createTexture(Function<NativeImage, CompletableFuture<?>> function, ResourceLocation location, boolean bl) {
|
||||||
|
return bl ? _image -> {
|
||||||
|
if (location instanceof FakeResourceLocation && _image instanceof FakeNativeImage.Extended) {
|
||||||
|
FakeSkinManager.BaseBuffer.judgeType(((FakeResourceLocation) location).getTexture(), () -> FakeSkinBuffer.judgeType0(((FakeNativeImage.Extended) _image).getFakeImage()));
|
||||||
|
}
|
||||||
|
return function.apply(_image);
|
||||||
|
} : _image -> function.apply(_image).thenApply(_location -> {
|
||||||
|
Minecraft.getMinecraft().getTextureManager().registerAndLoad(location, new FakeThreadDownloadImageData(location, _image));
|
||||||
|
return _location;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public FakeThreadDownloadImageData(ResourceLocation location, NativeImage image) {
|
||||||
|
super(location);
|
||||||
|
this.buffer = new FakeCapeBuffer();
|
||||||
|
this.image = new FakeNativeImage(image);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TextureContents loadContents(IResourceManager resourceManager) {
|
||||||
|
this.image = (FakeNativeImage) this.buffer.parseUserSkin(this.image);
|
||||||
|
FakeNativeImage local = (FakeNativeImage) this.image.createImage(this.image.getWidth(), this.image.getHeight());
|
||||||
|
local.copyImageData(this.image);
|
||||||
|
return new TextureContents(local.getImage(), null);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,112 @@
|
|||||||
|
package customskinloader.loader;
|
||||||
|
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
import com.google.common.collect.Iterables;
|
||||||
|
import com.google.common.collect.Lists;
|
||||||
|
import com.google.common.collect.Maps;
|
||||||
|
import com.google.gson.Gson;
|
||||||
|
import com.google.gson.GsonBuilder;
|
||||||
|
import com.mojang.authlib.GameProfile;
|
||||||
|
import com.mojang.authlib.minecraft.MinecraftProfileTexture;
|
||||||
|
import com.mojang.authlib.properties.Property;
|
||||||
|
import com.mojang.authlib.properties.PropertyMap;
|
||||||
|
import com.mojang.authlib.yggdrasil.response.MinecraftTexturesPayload;
|
||||||
|
import com.mojang.util.UUIDTypeAdapter;
|
||||||
|
import customskinloader.CustomSkinLoader;
|
||||||
|
import customskinloader.config.SkinSiteProfile;
|
||||||
|
import customskinloader.plugin.ICustomSkinLoaderPlugin;
|
||||||
|
import customskinloader.profile.ModelManager0;
|
||||||
|
import customskinloader.profile.UserProfile;
|
||||||
|
import customskinloader.utils.TextureUtil;
|
||||||
|
import org.apache.commons.codec.binary.Base64;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
|
public class GameProfileLoader implements ICustomSkinLoaderPlugin, ProfileLoader.IProfileLoader {
|
||||||
|
@Override
|
||||||
|
public ProfileLoader.IProfileLoader getProfileLoader() {
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<IDefaultProfile> getDefaultProfiles() {
|
||||||
|
return Lists.newArrayList(new ServerGameProfile(this));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class ServerGameProfile implements ICustomSkinLoaderPlugin.IDefaultProfile {
|
||||||
|
protected final GameProfileLoader loader;
|
||||||
|
|
||||||
|
public ServerGameProfile(GameProfileLoader loader) {
|
||||||
|
this.loader = loader;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getName() {
|
||||||
|
return "GameProfile";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getPriority() {
|
||||||
|
return 50;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateSkinSiteProfile(SkinSiteProfile ssp) {
|
||||||
|
ssp.type = this.loader.getName();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public UserProfile loadProfile(SkinSiteProfile ssp, GameProfile gameProfile) throws Exception {
|
||||||
|
Map<MinecraftProfileTexture.Type, MinecraftProfileTexture> map = getTextures(gameProfile);
|
||||||
|
if (!map.isEmpty()) {
|
||||||
|
CustomSkinLoader.logger.info("Default profile will be used.");
|
||||||
|
return ModelManager0.toUserProfile(map);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean compare(SkinSiteProfile ssp0, SkinSiteProfile ssp1) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getName() {
|
||||||
|
return "GameProfile";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void init(SkinSiteProfile ssp) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final Gson GSON = new GsonBuilder().registerTypeAdapter(UUID.class, new UUIDTypeAdapter()).registerTypeAdapter(PropertyMap.class, new PropertyMap.Serializer()).create();
|
||||||
|
public static Map<MinecraftProfileTexture.Type, MinecraftProfileTexture> getTextures(GameProfile gameProfile) {
|
||||||
|
if (gameProfile == null) {
|
||||||
|
return Maps.newHashMap();
|
||||||
|
}
|
||||||
|
Property textureProperty = Iterables.getFirst(TextureUtil.AuthlibField.GAME_PROFILE_PROPERTIES.<PropertyMap>get(gameProfile).get("textures"), null);
|
||||||
|
if (textureProperty == null) {
|
||||||
|
return Maps.newHashMap();
|
||||||
|
}
|
||||||
|
String value = TextureUtil.AuthlibField.PROPERTY_VALUE.get(textureProperty);
|
||||||
|
if (StringUtils.isBlank(value)) {
|
||||||
|
return Maps.newHashMap();
|
||||||
|
}
|
||||||
|
String json = new String(Base64.decodeBase64(value), StandardCharsets.UTF_8);
|
||||||
|
MinecraftTexturesPayload result = GSON.fromJson(json, MinecraftTexturesPayload.class);
|
||||||
|
|
||||||
|
if (result == null) {
|
||||||
|
return Maps.newHashMap();
|
||||||
|
}
|
||||||
|
Map<MinecraftProfileTexture.Type, MinecraftProfileTexture> textures = TextureUtil.AuthlibField.MINECRAFT_TEXTURES_PAYLOAD_TEXTURES.get(result);
|
||||||
|
if (textures == null) {
|
||||||
|
return Maps.newHashMap();
|
||||||
|
}
|
||||||
|
return textures;
|
||||||
|
}
|
||||||
|
}
|
||||||
+33
-4
@@ -12,6 +12,7 @@ import customskinloader.plugin.ICustomSkinLoaderPlugin;
|
|||||||
import customskinloader.profile.UserProfile;
|
import customskinloader.profile.UserProfile;
|
||||||
import customskinloader.utils.HttpRequestUtil;
|
import customskinloader.utils.HttpRequestUtil;
|
||||||
import customskinloader.utils.HttpUtil0;
|
import customskinloader.utils.HttpUtil0;
|
||||||
|
import customskinloader.utils.TextureUtil;
|
||||||
import org.apache.commons.io.IOUtils;
|
import org.apache.commons.io.IOUtils;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
@@ -22,7 +23,21 @@ public class JsonAPILoader implements ICustomSkinLoaderPlugin, ProfileLoader.IPr
|
|||||||
|
|
||||||
String toJsonUrl(String root, String username);
|
String toJsonUrl(String root, String username);
|
||||||
|
|
||||||
String getPayload(SkinSiteProfile ssp);
|
default String getPayload(SkinSiteProfile ssp) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* get JSON API payload, which will make a POST request
|
||||||
|
*
|
||||||
|
* @param ssp skin site profile
|
||||||
|
* @param username username
|
||||||
|
* @return JSON payload
|
||||||
|
* @since 14.16
|
||||||
|
*/
|
||||||
|
default String getPayload(SkinSiteProfile ssp, String username) {
|
||||||
|
return getPayload(ssp);
|
||||||
|
}
|
||||||
|
|
||||||
UserProfile toUserProfile(String root, String json, boolean local);
|
UserProfile toUserProfile(String root, String json, boolean local);
|
||||||
|
|
||||||
@@ -72,7 +87,7 @@ public class JsonAPILoader implements ICustomSkinLoaderPlugin, ProfileLoader.IPr
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public UserProfile loadProfile(SkinSiteProfile ssp, GameProfile gameProfile) throws Exception {
|
public UserProfile loadProfile(SkinSiteProfile ssp, GameProfile gameProfile) throws Exception {
|
||||||
String username = gameProfile.getName();
|
String username = TextureUtil.AuthlibField.GAME_PROFILE_NAME.get(gameProfile);
|
||||||
if (StringUtils.isEmpty(ssp.root)) {
|
if (StringUtils.isEmpty(ssp.root)) {
|
||||||
CustomSkinLoader.logger.info("Root not defined.");
|
CustomSkinLoader.logger.info("Root not defined.");
|
||||||
return null;
|
return null;
|
||||||
@@ -93,8 +108,15 @@ public class JsonAPILoader implements ICustomSkinLoaderPlugin, ProfileLoader.IPr
|
|||||||
}
|
}
|
||||||
json = IOUtils.toString(Files.newInputStream(jsonFile.toPath()), StandardCharsets.UTF_8);
|
json = IOUtils.toString(Files.newInputStream(jsonFile.toPath()), StandardCharsets.UTF_8);
|
||||||
} else {
|
} else {
|
||||||
HttpRequestUtil.HttpResponce responce = HttpRequestUtil.makeHttpRequest(new HttpRequestUtil.HttpRequest(jsonUrl).setCacheTime(90).setUserAgent(ssp.userAgent).setPayload(this.jsonAPI.getPayload(ssp)));
|
try {
|
||||||
json = responce.content;
|
HttpRequestUtil.HttpResponce responce = HttpRequestUtil
|
||||||
|
.makeHttpRequest(new HttpRequestUtil.HttpRequest(jsonUrl).setCacheTime(90)
|
||||||
|
.setUserAgent(ssp.userAgent).setPayload(this.jsonAPI.getPayload(ssp, username)));
|
||||||
|
json = responce.content;
|
||||||
|
} catch (ProfileNotFoundException ignored) {
|
||||||
|
CustomSkinLoader.logger.info("Profile not found.");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (json == null || json.equals("")) {
|
if (json == null || json.equals("")) {
|
||||||
CustomSkinLoader.logger.info("Profile not found.");
|
CustomSkinLoader.logger.info("Profile not found.");
|
||||||
@@ -135,4 +157,11 @@ public class JsonAPILoader implements ICustomSkinLoaderPlugin, ProfileLoader.IPr
|
|||||||
f.mkdirs();
|
f.mkdirs();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* When getting payload, this exception can end skin loading
|
||||||
|
* @since 14.16
|
||||||
|
*/
|
||||||
|
public static class ProfileNotFoundException extends RuntimeException {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
+54
-18
@@ -1,11 +1,11 @@
|
|||||||
package customskinloader.loader;
|
package customskinloader.loader;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
|
import com.google.common.collect.Lists;
|
||||||
import com.mojang.authlib.GameProfile;
|
import com.mojang.authlib.GameProfile;
|
||||||
import customskinloader.CustomSkinLoader;
|
import customskinloader.CustomSkinLoader;
|
||||||
import customskinloader.config.SkinSiteProfile;
|
import customskinloader.config.SkinSiteProfile;
|
||||||
@@ -14,6 +14,7 @@ import customskinloader.profile.UserProfile;
|
|||||||
import customskinloader.utils.HttpRequestUtil;
|
import customskinloader.utils.HttpRequestUtil;
|
||||||
import customskinloader.utils.HttpTextureUtil;
|
import customskinloader.utils.HttpTextureUtil;
|
||||||
import customskinloader.utils.HttpUtil0;
|
import customskinloader.utils.HttpUtil0;
|
||||||
|
import customskinloader.utils.TextureUtil;
|
||||||
|
|
||||||
public class LegacyLoader implements ICustomSkinLoaderPlugin, ProfileLoader.IProfileLoader {
|
public class LegacyLoader implements ICustomSkinLoaderPlugin, ProfileLoader.IProfileLoader {
|
||||||
|
|
||||||
@@ -24,7 +25,12 @@ public class LegacyLoader implements ICustomSkinLoaderPlugin, ProfileLoader.IPro
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<IDefaultProfile> getDefaultProfiles() {
|
public List<IDefaultProfile> getDefaultProfiles() {
|
||||||
return Collections.singletonList(new LocalSkin(this));
|
return Lists.newArrayList(new LocalSkin(this),
|
||||||
|
getCapeProfile(this, "OptiFine", "https://optifine.net/capes/{USERNAME}.png", 810),
|
||||||
|
getCapeProfile(this, "CloakPlus", "http://161.35.130.99/capes/{USERNAME}.png", 840),
|
||||||
|
//getCapeProfile(this, "LabyMod", "https://dl.labymod.net/capes/{STANDARD_UUID}", 850),
|
||||||
|
getCapeProfile(this, "Cosmetica", "https://api.cosmetica.cc/get/cloak?username={USERNAME}&uuid={STANDARD_UUID}¬hirdparty", 860)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract static class DefaultProfile implements ICustomSkinLoaderPlugin.IDefaultProfile {
|
public abstract static class DefaultProfile implements ICustomSkinLoaderPlugin.IDefaultProfile {
|
||||||
@@ -75,7 +81,7 @@ public class LegacyLoader implements ICustomSkinLoaderPlugin, ProfileLoader.IPro
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getPriority() {
|
public int getPriority() {
|
||||||
return 600;
|
return 710;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -94,18 +100,48 @@ public class LegacyLoader implements ICustomSkinLoaderPlugin, ProfileLoader.IPro
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// // Minecrack could not load skin correctly
|
/**
|
||||||
// public static class Minecrack extends LegacyLoader.DefaultProfile {
|
* Get cape Profile¬
|
||||||
// public Minecrack(LegacyLoader loader) { super(loader); }
|
*
|
||||||
// @Override public String getName() { return "Minecrack"; }
|
* @since 14.16
|
||||||
// @Override public int getPriority() { return 600; }
|
*/
|
||||||
// @Override public String getSkinRoot() { return "http://minecrack.fr.nf/mc/skinsminecrackd/{USERNAME}.png"; }
|
public static LegacyLoader.DefaultProfile getCapeProfile(LegacyLoader loader, String name, String capeRoot, int priority) {
|
||||||
// @Override public String getCapeRoot() { return "http://minecrack.fr.nf/mc/cloaksminecrackd/{USERNAME}.png"; }
|
return new DefaultProfile(loader) {
|
||||||
// @Override public String getElytraRoot() { return null; }
|
@Override
|
||||||
// }
|
public String getSkinRoot() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getCapeRoot() {
|
||||||
|
return capeRoot;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getElytraRoot() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getPriority() {
|
||||||
|
return priority;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
public static final String USERNAME_PLACEHOLDER = "{USERNAME}";
|
public static final String USERNAME_PLACEHOLDER = "{USERNAME}";
|
||||||
public static final String UUID_PLACEHOLDER = "{UUID}";
|
public static final String UUID_PLACEHOLDER = "{UUID}";
|
||||||
|
/**
|
||||||
|
* Mojang UUID with -
|
||||||
|
*
|
||||||
|
* @since 14.16
|
||||||
|
*/
|
||||||
|
public static final String STANDARD_UUID_PLACEHOLDER = "{STANDARD_UUID}";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public UserProfile loadProfile(SkinSiteProfile ssp, GameProfile gameProfile) {
|
public UserProfile loadProfile(SkinSiteProfile ssp, GameProfile gameProfile) {
|
||||||
@@ -125,13 +161,12 @@ public class LegacyLoader implements ICustomSkinLoaderPlugin, ProfileLoader.IPro
|
|||||||
return profile;
|
return profile;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void getTextureUrl(
|
private void getTextureUrl(SkinSiteProfile ssp, GameProfile gameProfile, String baseUrl, Consumer<String> onSuccess) {
|
||||||
SkinSiteProfile ssp, GameProfile gameProfile, String baseUrl, Consumer<String> onSuccess) {
|
|
||||||
//Base URL is empty
|
//Base URL is empty
|
||||||
if (baseUrl == null || baseUrl.isEmpty()) {
|
if (baseUrl == null || baseUrl.isEmpty()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
String url = expandURL(baseUrl, gameProfile.getName());
|
String url = expandURL(baseUrl, TextureUtil.AuthlibField.GAME_PROFILE_NAME.get(gameProfile));
|
||||||
//No texture can be loaded
|
//No texture can be loaded
|
||||||
if (url == null) {
|
if (url == null) {
|
||||||
return;
|
return;
|
||||||
@@ -187,14 +222,15 @@ public class LegacyLoader implements ICustomSkinLoaderPlugin, ProfileLoader.IPro
|
|||||||
|
|
||||||
private String expandURL(String url, String username) {
|
private String expandURL(String url, String username) {
|
||||||
String t = url.replace(USERNAME_PLACEHOLDER, username);
|
String t = url.replace(USERNAME_PLACEHOLDER, username);
|
||||||
if (!t.contains(UUID_PLACEHOLDER)) {
|
if (!t.contains(UUID_PLACEHOLDER) && !t.contains(STANDARD_UUID_PLACEHOLDER)) {
|
||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
String uuid = MojangAPILoader.getMojangUuidByUsername(username);
|
String uuid = MojangAPILoader.getMojangUuidByUsername(username, true);
|
||||||
//If Mojang uuid not found, won't load the texture
|
//If Mojang uuid not found, won't load the texture
|
||||||
if (uuid == null) {
|
if (uuid == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return t.replace(UUID_PLACEHOLDER, uuid);
|
String styledUuid = uuid.replace("-", "");
|
||||||
|
return t.replace(UUID_PLACEHOLDER, styledUuid).replace(STANDARD_UUID_PLACEHOLDER, uuid);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+33
-67
@@ -1,31 +1,23 @@
|
|||||||
package customskinloader.loader;
|
package customskinloader.loader;
|
||||||
|
|
||||||
import java.nio.charset.StandardCharsets;
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
import com.google.common.collect.Iterables;
|
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
import com.google.common.collect.Maps;
|
|
||||||
import com.google.gson.Gson;
|
|
||||||
import com.google.gson.GsonBuilder;
|
|
||||||
import com.mojang.authlib.GameProfile;
|
import com.mojang.authlib.GameProfile;
|
||||||
import com.mojang.authlib.minecraft.MinecraftProfileTexture;
|
import com.mojang.authlib.minecraft.MinecraftProfileTexture;
|
||||||
import com.mojang.authlib.properties.Property;
|
|
||||||
import com.mojang.authlib.properties.PropertyMap;
|
import com.mojang.authlib.properties.PropertyMap;
|
||||||
import com.mojang.authlib.yggdrasil.response.MinecraftProfilePropertiesResponse;
|
import com.mojang.authlib.yggdrasil.response.MinecraftProfilePropertiesResponse;
|
||||||
import com.mojang.authlib.yggdrasil.response.MinecraftTexturesPayload;
|
|
||||||
import com.mojang.util.UUIDTypeAdapter;
|
|
||||||
import customskinloader.CustomSkinLoader;
|
import customskinloader.CustomSkinLoader;
|
||||||
import customskinloader.config.SkinSiteProfile;
|
import customskinloader.config.SkinSiteProfile;
|
||||||
import customskinloader.plugin.ICustomSkinLoaderPlugin;
|
import customskinloader.plugin.ICustomSkinLoaderPlugin;
|
||||||
import customskinloader.profile.ModelManager0;
|
import customskinloader.profile.ModelManager0;
|
||||||
import customskinloader.profile.UserProfile;
|
import customskinloader.profile.UserProfile;
|
||||||
import customskinloader.utils.HttpRequestUtil;
|
import customskinloader.utils.HttpRequestUtil;
|
||||||
import org.apache.commons.codec.Charsets;
|
import customskinloader.utils.TextureUtil;
|
||||||
import org.apache.commons.codec.binary.Base64;
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
public class MojangAPILoader implements ICustomSkinLoaderPlugin, ProfileLoader.IProfileLoader {
|
public class MojangAPILoader implements ICustomSkinLoaderPlugin, ProfileLoader.IProfileLoader {
|
||||||
@@ -87,112 +79,86 @@ public class MojangAPILoader implements ICustomSkinLoaderPlugin, ProfileLoader.I
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public UserProfile loadProfile(SkinSiteProfile ssp, GameProfile gameProfile) {
|
public UserProfile loadProfile(SkinSiteProfile ssp, GameProfile gameProfile) {
|
||||||
Map<MinecraftProfileTexture.Type, MinecraftProfileTexture> map = getTextures(gameProfile);
|
String username = TextureUtil.AuthlibField.GAME_PROFILE_NAME.get(gameProfile);
|
||||||
if (!map.isEmpty()) {
|
GameProfile newGameProfile = loadGameProfileCached(ssp.apiRoot, username);
|
||||||
CustomSkinLoader.logger.info("Default profile will be used.");
|
|
||||||
return ModelManager0.toUserProfile(map);
|
|
||||||
}
|
|
||||||
String username = gameProfile.getName();
|
|
||||||
GameProfile newGameProfile = loadGameProfile(ssp.apiRoot, username);
|
|
||||||
if (newGameProfile == null) {
|
if (newGameProfile == null) {
|
||||||
CustomSkinLoader.logger.info("Profile not found.(" + username + "'s profile not found.)");
|
CustomSkinLoader.logger.info("Profile not found.(" + username + "'s profile not found.)");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
newGameProfile = fillGameProfile(ssp.sessionRoot, newGameProfile);
|
newGameProfile = fillGameProfile(ssp.sessionRoot, newGameProfile);
|
||||||
map = getTextures(newGameProfile);
|
Map<MinecraftProfileTexture.Type, MinecraftProfileTexture> map = GameProfileLoader.getTextures(newGameProfile);
|
||||||
if (!map.isEmpty()) {
|
if (!map.isEmpty()) {
|
||||||
gameProfile.getProperties().putAll(newGameProfile.getProperties());
|
|
||||||
return ModelManager0.toUserProfile(map);
|
return ModelManager0.toUserProfile(map);
|
||||||
}
|
}
|
||||||
CustomSkinLoader.logger.info("Profile not found.(" + username + " doesn't have skin/cape.)");
|
CustomSkinLoader.logger.info("Profile not found.(" + username + " doesn't have skin/cape.)");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static final Map<String, GameProfile> gameProfileCache = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
|
public static GameProfile loadGameProfileCached(String apiRoot, String username) {
|
||||||
|
return gameProfileCache.computeIfAbsent(apiRoot + " " + username, ignored -> loadGameProfile(apiRoot, username));
|
||||||
|
}
|
||||||
|
|
||||||
//Username -> UUID
|
//Username -> UUID
|
||||||
public static GameProfile loadGameProfile(String apiRoot, String username) {
|
public static GameProfile loadGameProfile(String apiRoot, String username) {
|
||||||
//Doc (https://wiki.vg/Mojang_API#Playernames_-.3E_UUIDs)
|
//Doc (https://minecraft.wiki/w/Mojang_API#Query_player_UUIDs_in_batch)
|
||||||
Gson gson = new GsonBuilder().registerTypeAdapter(UUID.class, new UUIDTypeAdapter()).create();
|
HttpRequestUtil.HttpResponce responce = HttpRequestUtil.makeHttpRequest(new HttpRequestUtil.HttpRequest(apiRoot + "profiles/minecraft").setCacheTime(600).setPayload(GameProfileLoader.GSON.toJson(Collections.singletonList(username))));
|
||||||
|
|
||||||
HttpRequestUtil.HttpResponce responce = HttpRequestUtil.makeHttpRequest(
|
|
||||||
new HttpRequestUtil.HttpRequest(apiRoot + "profiles/minecraft")
|
|
||||||
.setCacheTime(600).setPayload(gson.toJson(Collections.singletonList(username)))
|
|
||||||
);
|
|
||||||
if (StringUtils.isEmpty(responce.content)) {
|
if (StringUtils.isEmpty(responce.content)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
GameProfile[] profiles = gson.fromJson(responce.content, GameProfile[].class);
|
MinecraftProfilePropertiesResponse[] profiles = GameProfileLoader.GSON.fromJson(responce.content, MinecraftProfilePropertiesResponse[].class);
|
||||||
if (profiles.length == 0) {
|
if (profiles.length == 0) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
GameProfile gameProfile = profiles[0];
|
GameProfile gameProfile = createGameProfile(profiles[0]);
|
||||||
|
|
||||||
if (gameProfile.getId() == null) {
|
UUID id = TextureUtil.AuthlibField.GAME_PROFILE_ID.get(gameProfile);
|
||||||
|
if (id == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return new GameProfile(gameProfile.getId(), gameProfile.getName());
|
return new GameProfile(id, TextureUtil.AuthlibField.GAME_PROFILE_NAME.get(gameProfile));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get Mojang UUID by username.
|
* Get Mojang UUID by username.
|
||||||
*
|
*
|
||||||
* @param username username to query
|
* @param username username to query
|
||||||
|
* @param standard if - in UUID
|
||||||
* @return UUID in Mojang API style string. Returns {@code null} if username not found in Mojang API.
|
* @return UUID in Mojang API style string. Returns {@code null} if username not found in Mojang API.
|
||||||
*/
|
*/
|
||||||
public static String getMojangUuidByUsername(String username) {
|
public static String getMojangUuidByUsername(String username, boolean standard) {
|
||||||
GameProfile profile = loadGameProfile(getMojangApiRoot(), username);
|
GameProfile profile = loadGameProfileCached(getMojangApiRoot(), username);
|
||||||
if (profile == null) {
|
if (profile == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return UUIDTypeAdapter.fromUUID(profile.getId());
|
UUID id = TextureUtil.AuthlibField.GAME_PROFILE_ID.get(profile);
|
||||||
|
return standard ? id.toString() : TextureUtil.fromUUID(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
//UUID -> Profile
|
//UUID -> Profile
|
||||||
public static GameProfile fillGameProfile(String sessionRoot, GameProfile profile) {
|
public static GameProfile fillGameProfile(String sessionRoot, GameProfile profile) {
|
||||||
//Doc (http://wiki.vg/Mojang_API#UUID_-.3E_Profile_.2B_Skin.2FCape)
|
//Doc (https://minecraft.wiki/w/Mojang_API#Query_player's_skin_and_cape)
|
||||||
HttpRequestUtil.HttpResponce responce = HttpRequestUtil.makeHttpRequest(
|
HttpRequestUtil.HttpResponce responce = HttpRequestUtil.makeHttpRequest(new HttpRequestUtil.HttpRequest(sessionRoot + "session/minecraft/profile/" + TextureUtil.fromUUID(TextureUtil.AuthlibField.GAME_PROFILE_ID.get(profile))).setCacheTime(90));
|
||||||
new HttpRequestUtil.HttpRequest(sessionRoot + "session/minecraft/profile/"
|
|
||||||
+ UUIDTypeAdapter.fromUUID(profile.getId())).setCacheTime(90));
|
|
||||||
if (StringUtils.isEmpty(responce.content)) {
|
if (StringUtils.isEmpty(responce.content)) {
|
||||||
return profile;
|
return profile;
|
||||||
}
|
}
|
||||||
|
return createGameProfile(GameProfileLoader.GSON.fromJson(responce.content, MinecraftProfilePropertiesResponse.class));
|
||||||
Gson gson = new GsonBuilder()
|
|
||||||
.registerTypeAdapter(UUID.class, new UUIDTypeAdapter())
|
|
||||||
.registerTypeAdapter(PropertyMap.class, new PropertyMap.Serializer())
|
|
||||||
.create();
|
|
||||||
MinecraftProfilePropertiesResponse propertiesResponce = gson.fromJson(responce.content, MinecraftProfilePropertiesResponse.class);
|
|
||||||
GameProfile newGameProfile = new GameProfile(propertiesResponce.getId(), propertiesResponce.getName());
|
|
||||||
newGameProfile.getProperties().putAll(propertiesResponce.getProperties());
|
|
||||||
|
|
||||||
return newGameProfile;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Map<MinecraftProfileTexture.Type, MinecraftProfileTexture> getTextures(GameProfile gameProfile) {
|
public static GameProfile createGameProfile(MinecraftProfilePropertiesResponse response) {
|
||||||
if (gameProfile == null) {
|
GameProfile profile = new GameProfile(TextureUtil.AuthlibField.MINECRAFT_PROFILE_PROPERTIES_RESPONSE_ID.get(response), TextureUtil.AuthlibField.MINECRAFT_PROFILE_PROPERTIES_RESPONSE_NAME.get(response));
|
||||||
return Maps.newHashMap();
|
PropertyMap map = TextureUtil.AuthlibField.MINECRAFT_PROFILE_PROPERTIES_RESPONSE_PROPERTIES.get(response);
|
||||||
|
if (map != null) {
|
||||||
|
TextureUtil.AuthlibField.PROPERTY_MAP_PROPERTIES.set(TextureUtil.AuthlibField.GAME_PROFILE_PROPERTIES.get(profile), TextureUtil.AuthlibField.PROPERTY_MAP_PROPERTIES.get(map));
|
||||||
}
|
}
|
||||||
Property textureProperty = Iterables.getFirst(gameProfile.getProperties().get("textures"), null);
|
return profile;
|
||||||
if (textureProperty == null) {
|
|
||||||
return Maps.newHashMap();
|
|
||||||
}
|
|
||||||
String value = textureProperty.getValue();
|
|
||||||
if (StringUtils.isBlank(value)) {
|
|
||||||
return Maps.newHashMap();
|
|
||||||
}
|
|
||||||
String json = new String(Base64.decodeBase64(value), StandardCharsets.UTF_8);
|
|
||||||
Gson gson = new GsonBuilder().registerTypeAdapter(UUID.class, new UUIDTypeAdapter()).create();
|
|
||||||
MinecraftTexturesPayload result = gson.fromJson(json, MinecraftTexturesPayload.class);
|
|
||||||
if (result == null || result.getTextures() == null) {
|
|
||||||
return Maps.newHashMap();
|
|
||||||
}
|
|
||||||
return result.getTextures();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean compare(SkinSiteProfile ssp0, SkinSiteProfile ssp1) {
|
public boolean compare(SkinSiteProfile ssp0, SkinSiteProfile ssp1) {
|
||||||
return (!StringUtils.isNoneEmpty(ssp0.apiRoot) || ssp0.apiRoot.equalsIgnoreCase(ssp1.apiRoot)) ||
|
return (!StringUtils.isNoneEmpty(ssp0.apiRoot) || ssp0.apiRoot.equalsIgnoreCase(ssp1.apiRoot)) || (!StringUtils.isNoneEmpty(ssp0.sessionRoot) || ssp0.sessionRoot.equalsIgnoreCase(ssp1.sessionRoot));
|
||||||
(!StringUtils.isNoneEmpty(ssp0.sessionRoot) || ssp0.sessionRoot.equalsIgnoreCase(ssp1.sessionRoot));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
File renamed without changes.
@@ -0,0 +1,144 @@
|
|||||||
|
package customskinloader.loader.jsonapi;
|
||||||
|
|
||||||
|
import java.util.LinkedHashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import com.google.common.collect.Lists;
|
||||||
|
import customskinloader.CustomSkinLoader;
|
||||||
|
import customskinloader.loader.JsonAPILoader;
|
||||||
|
import customskinloader.plugin.ICustomSkinLoaderPlugin;
|
||||||
|
import customskinloader.profile.ModelManager0;
|
||||||
|
import customskinloader.profile.UserProfile;
|
||||||
|
import customskinloader.utils.HttpTextureUtil;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
|
public class CustomSkinAPI implements JsonAPILoader.IJsonAPI {
|
||||||
|
|
||||||
|
public static class LittleSkin extends JsonAPILoader.DefaultProfile {
|
||||||
|
public LittleSkin(JsonAPILoader loader) {
|
||||||
|
super(loader);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getName() {
|
||||||
|
return "LittleSkin";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getPriority() {
|
||||||
|
return 200;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getRoot() {
|
||||||
|
return "https://littleskin.cn/csl/";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class BlessingSkin extends JsonAPILoader.DefaultProfile {
|
||||||
|
public BlessingSkin(JsonAPILoader loader) {
|
||||||
|
super(loader);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getName() {
|
||||||
|
return "BlessingSkin";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getPriority() {
|
||||||
|
return 300;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getRoot() {
|
||||||
|
return "https://skin.prinzeugen.net/";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// // OneSkin has been removed temporarily
|
||||||
|
// public static class OneSkin extends JsonAPILoader.DefaultProfile {
|
||||||
|
// public OneSkin(JsonAPILoader loader) { super(loader); }
|
||||||
|
// @Override public String getName() { return "OneSkin"; }
|
||||||
|
// @Override public int getPriority() { return 500; }
|
||||||
|
// @Override public String getRoot() { return "http://fleey.cn/skin/skin_user/skin_json.php/"; }
|
||||||
|
// }
|
||||||
|
|
||||||
|
private static final String TEXTURES = "textures/";
|
||||||
|
private static final String SUFFIX = ".json";
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<ICustomSkinLoaderPlugin.IDefaultProfile> getDefaultProfiles(JsonAPILoader loader) {
|
||||||
|
return Lists.newArrayList(new LittleSkin(loader), new BlessingSkin(loader));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toJsonUrl(String root, String username) {
|
||||||
|
return root + username + SUFFIX;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public UserProfile toUserProfile(String root, String json, boolean local) {
|
||||||
|
CustomSkinAPIProfile profile = CustomSkinLoader.GSON.fromJson(json, CustomSkinAPIProfile.class);
|
||||||
|
UserProfile p = new UserProfile();
|
||||||
|
|
||||||
|
if (StringUtils.isNotBlank(profile.skin)) {
|
||||||
|
p.skinUrl = root + TEXTURES + profile.skin;
|
||||||
|
if (local)
|
||||||
|
p.skinUrl = HttpTextureUtil.getLocalFakeUrl(p.skinUrl);
|
||||||
|
}
|
||||||
|
if (StringUtils.isNotBlank(profile.cape)) {
|
||||||
|
p.capeUrl = root + TEXTURES + profile.cape;
|
||||||
|
if (local)
|
||||||
|
p.capeUrl = HttpTextureUtil.getLocalFakeUrl(p.capeUrl);
|
||||||
|
}
|
||||||
|
if (StringUtils.isNotBlank(profile.elytra)) {
|
||||||
|
p.elytraUrl = root + TEXTURES + profile.elytra;
|
||||||
|
if (local)
|
||||||
|
p.elytraUrl = HttpTextureUtil.getLocalFakeUrl(p.elytraUrl);
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, String> textures = new LinkedHashMap<>();
|
||||||
|
if (profile.skins != null)
|
||||||
|
textures.putAll(profile.skins);
|
||||||
|
if (profile.textures != null)
|
||||||
|
textures.putAll(profile.textures);
|
||||||
|
if (textures.isEmpty())
|
||||||
|
return p;
|
||||||
|
|
||||||
|
boolean hasSkin = false;
|
||||||
|
for (String model : textures.keySet()) {
|
||||||
|
ModelManager0.Model enumModel = ModelManager0.getEnumModel(model);
|
||||||
|
if (enumModel == null || StringUtils.isEmpty(textures.get(model)))
|
||||||
|
continue;
|
||||||
|
if (ModelManager0.isSkin(enumModel))
|
||||||
|
if (hasSkin)
|
||||||
|
continue;
|
||||||
|
else
|
||||||
|
hasSkin = true;
|
||||||
|
String url = root + TEXTURES + textures.get(model);
|
||||||
|
if (local)
|
||||||
|
url = HttpTextureUtil.getLocalFakeUrl(url);
|
||||||
|
p.put(enumModel, url);
|
||||||
|
}
|
||||||
|
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static class CustomSkinAPIProfile {
|
||||||
|
public String username;
|
||||||
|
public LinkedHashMap<String, String> textures;
|
||||||
|
|
||||||
|
public LinkedHashMap<String, String> skins;
|
||||||
|
|
||||||
|
public String skin;
|
||||||
|
public String cape;
|
||||||
|
public String elytra;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getName() {
|
||||||
|
return "CustomSkinAPI";
|
||||||
|
}
|
||||||
|
}
|
||||||
File renamed without changes.
+38
-15
@@ -7,7 +7,6 @@ import com.google.common.collect.Lists;
|
|||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
import com.google.gson.reflect.TypeToken;
|
import com.google.gson.reflect.TypeToken;
|
||||||
import com.mojang.authlib.minecraft.MinecraftProfileTexture;
|
import com.mojang.authlib.minecraft.MinecraftProfileTexture;
|
||||||
import customskinloader.config.SkinSiteProfile;
|
|
||||||
import customskinloader.loader.JsonAPILoader;
|
import customskinloader.loader.JsonAPILoader;
|
||||||
import customskinloader.plugin.ICustomSkinLoaderPlugin;
|
import customskinloader.plugin.ICustomSkinLoaderPlugin;
|
||||||
import customskinloader.profile.ModelManager0;
|
import customskinloader.profile.ModelManager0;
|
||||||
@@ -16,17 +15,45 @@ import customskinloader.profile.UserProfile;
|
|||||||
public class ElyByAPI implements JsonAPILoader.IJsonAPI {
|
public class ElyByAPI implements JsonAPILoader.IJsonAPI {
|
||||||
|
|
||||||
public static class ElyBy extends JsonAPILoader.DefaultProfile {
|
public static class ElyBy extends JsonAPILoader.DefaultProfile {
|
||||||
public ElyBy(JsonAPILoader loader) { super(loader); }
|
public ElyBy(JsonAPILoader loader) {
|
||||||
@Override public String getName() { return "ElyBy"; }
|
super(loader);
|
||||||
@Override public int getPriority() { return 400; }
|
}
|
||||||
@Override public String getRoot() { return "http://skinsystem.ely.by/textures/"; }
|
|
||||||
|
@Override
|
||||||
|
public String getName() {
|
||||||
|
return "ElyBy";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getPriority() {
|
||||||
|
return 400;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getRoot() {
|
||||||
|
return "http://skinsystem.ely.by/textures/";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class TLauncher extends JsonAPILoader.DefaultProfile {
|
public static class TLauncher extends JsonAPILoader.DefaultProfile {
|
||||||
public TLauncher(JsonAPILoader loader) { super(loader); }
|
public TLauncher(JsonAPILoader loader) {
|
||||||
@Override public String getName() { return "TLauncher"; }
|
super(loader);
|
||||||
@Override public int getPriority() { return 550; }
|
}
|
||||||
@Override public String getRoot() { return "https://auth.tlauncher.org/skin/profile/texture/login/"; }
|
|
||||||
|
@Override
|
||||||
|
public String getName() {
|
||||||
|
return "TLauncher";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getPriority() {
|
||||||
|
return 550;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getRoot() {
|
||||||
|
return "https://auth.tlauncher.org/skin/profile/texture/login/";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -41,15 +68,11 @@ public class ElyByAPI implements JsonAPILoader.IJsonAPI {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public UserProfile toUserProfile(String root, String json, boolean local) {
|
public UserProfile toUserProfile(String root, String json, boolean local) {
|
||||||
Map<MinecraftProfileTexture.Type, MinecraftProfileTexture> result = new Gson().fromJson(json, new TypeToken<Map<MinecraftProfileTexture.Type, MinecraftProfileTexture>>() { }.getType());
|
Map<MinecraftProfileTexture.Type, MinecraftProfileTexture> result = new Gson().fromJson(json, new TypeToken<Map<MinecraftProfileTexture.Type, MinecraftProfileTexture>>() {
|
||||||
|
}.getType());
|
||||||
return ModelManager0.toUserProfile(result);
|
return ModelManager0.toUserProfile(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getPayload(SkinSiteProfile ssp) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return "ElyByAPI";
|
return "ElyByAPI";
|
||||||
+18
-10
@@ -6,7 +6,6 @@ import java.util.Map;
|
|||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
import com.mojang.authlib.minecraft.MinecraftProfileTexture;
|
import com.mojang.authlib.minecraft.MinecraftProfileTexture;
|
||||||
import customskinloader.config.SkinSiteProfile;
|
|
||||||
import customskinloader.loader.JsonAPILoader;
|
import customskinloader.loader.JsonAPILoader;
|
||||||
import customskinloader.plugin.ICustomSkinLoaderPlugin;
|
import customskinloader.plugin.ICustomSkinLoaderPlugin;
|
||||||
import customskinloader.profile.ModelManager0;
|
import customskinloader.profile.ModelManager0;
|
||||||
@@ -15,10 +14,24 @@ import customskinloader.profile.UserProfile;
|
|||||||
public class GlitchlessAPI implements JsonAPILoader.IJsonAPI {
|
public class GlitchlessAPI implements JsonAPILoader.IJsonAPI {
|
||||||
|
|
||||||
public static class GlitchlessGames extends JsonAPILoader.DefaultProfile {
|
public static class GlitchlessGames extends JsonAPILoader.DefaultProfile {
|
||||||
public GlitchlessGames(JsonAPILoader loader) { super(loader); }
|
public GlitchlessGames(JsonAPILoader loader) {
|
||||||
@Override public String getName() { return "GlitchlessGames"; }
|
super(loader);
|
||||||
@Override public int getPriority() { return 700; }
|
}
|
||||||
@Override public String getRoot() { return "https://games.glitchless.ru/api/minecraft/users/profiles/textures/?nickname="; }
|
|
||||||
|
@Override
|
||||||
|
public String getName() {
|
||||||
|
return "GlitchlessGames";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getPriority() {
|
||||||
|
return 700;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getRoot() {
|
||||||
|
return "https://games.glitchless.ru/api/minecraft/users/profiles/textures/?nickname=";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -40,11 +53,6 @@ public class GlitchlessAPI implements JsonAPILoader.IJsonAPI {
|
|||||||
return ModelManager0.toUserProfile(result.textures);
|
return ModelManager0.toUserProfile(result.textures);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getPayload(SkinSiteProfile ssp) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return "GlitchlessAPI";
|
return "GlitchlessAPI";
|
||||||
+5
-33
@@ -2,22 +2,14 @@ package customskinloader.loader.jsonapi;
|
|||||||
|
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
import com.mojang.authlib.minecraft.MinecraftProfileTexture;
|
|
||||||
import customskinloader.CustomSkinLoader;
|
|
||||||
import customskinloader.Logger;
|
|
||||||
import customskinloader.config.SkinSiteProfile;
|
|
||||||
import customskinloader.loader.JsonAPILoader;
|
import customskinloader.loader.JsonAPILoader;
|
||||||
import customskinloader.loader.MojangAPILoader;
|
import customskinloader.loader.MojangAPILoader;
|
||||||
import customskinloader.plugin.ICustomSkinLoaderPlugin;
|
import customskinloader.plugin.ICustomSkinLoaderPlugin;
|
||||||
import customskinloader.profile.ModelManager0;
|
|
||||||
import customskinloader.profile.UserProfile;
|
import customskinloader.profile.UserProfile;
|
||||||
import customskinloader.utils.HttpTextureUtil;
|
import customskinloader.utils.TextureUtil;
|
||||||
import org.apache.commons.codec.binary.Base64;
|
|
||||||
import org.apache.commons.io.FileUtils;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
public class MinecraftCapesAPI implements JsonAPILoader.IJsonAPI {
|
public class MinecraftCapesAPI implements JsonAPILoader.IJsonAPI {
|
||||||
|
|
||||||
@@ -38,7 +30,7 @@ public class MinecraftCapesAPI implements JsonAPILoader.IJsonAPI {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getRoot() {
|
public String getRoot() {
|
||||||
return "https://minecraftcapes.net/profile/";
|
return "https://api.minecraftcapes.net/profile/";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -49,7 +41,7 @@ public class MinecraftCapesAPI implements JsonAPILoader.IJsonAPI {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toJsonUrl(String root, String username) {
|
public String toJsonUrl(String root, String username) {
|
||||||
String uuid = MojangAPILoader.getMojangUuidByUsername(username);
|
String uuid = MojangAPILoader.getMojangUuidByUsername(username, false);
|
||||||
//If uuid cannot be found, we won't load profile in this API.
|
//If uuid cannot be found, we won't load profile in this API.
|
||||||
if (uuid == null) {
|
if (uuid == null) {
|
||||||
return null;
|
return null;
|
||||||
@@ -65,32 +57,12 @@ public class MinecraftCapesAPI implements JsonAPILoader.IJsonAPI {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
String capeBase64 = result.textures.cape;
|
|
||||||
byte[] capeBytes = Base64.decodeBase64(capeBase64);
|
|
||||||
String hash = HttpTextureUtil.getHash(capeBytes);
|
|
||||||
File cacheFile = HttpTextureUtil.getCacheFile(hash);
|
|
||||||
String fakeUrl = HttpTextureUtil.getBase64FakeUrl(hash);
|
|
||||||
|
|
||||||
//Save base64 image to cache file
|
|
||||||
try {
|
|
||||||
FileUtils.writeByteArrayToFile(cacheFile, capeBytes);
|
|
||||||
CustomSkinLoader.logger.info("Saved base64 image to " + cacheFile);
|
|
||||||
} catch (Exception e) {
|
|
||||||
CustomSkinLoader.logger.warning("Error parsing base64 image: " + capeBase64);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
UserProfile profile = new UserProfile();
|
UserProfile profile = new UserProfile();
|
||||||
profile.capeUrl = fakeUrl;
|
profile.capeUrl = TextureUtil.parseBase64Texture(result.textures.cape);
|
||||||
|
|
||||||
return profile;
|
return profile;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getPayload(SkinSiteProfile ssp) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return "MinecraftCapesAPI";
|
return "MinecraftCapesAPI";
|
||||||
@@ -0,0 +1,105 @@
|
|||||||
|
package customskinloader.loader.jsonapi;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import com.google.common.collect.Lists;
|
||||||
|
import customskinloader.CustomSkinLoader;
|
||||||
|
import customskinloader.loader.JsonAPILoader;
|
||||||
|
import customskinloader.plugin.ICustomSkinLoaderPlugin;
|
||||||
|
import customskinloader.profile.ModelManager0;
|
||||||
|
import customskinloader.profile.UserProfile;
|
||||||
|
import customskinloader.utils.HttpTextureUtil;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
|
public class UniSkinAPI implements JsonAPILoader.IJsonAPI {
|
||||||
|
|
||||||
|
public static class SkinMe extends JsonAPILoader.DefaultProfile {
|
||||||
|
public SkinMe(JsonAPILoader loader) {
|
||||||
|
super(loader);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getName() {
|
||||||
|
return "SkinMe";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getPriority() {
|
||||||
|
return 500;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getRoot() {
|
||||||
|
return "http://www.skinme.cc/uniskin/";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static final String TEXTURES = "textures/";
|
||||||
|
private static final String SUFFIX = ".json";
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<ICustomSkinLoaderPlugin.IDefaultProfile> getDefaultProfiles(JsonAPILoader loader) {
|
||||||
|
return Lists.newArrayList(new SkinMe(loader));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toJsonUrl(String root, String username) {
|
||||||
|
return root + username + SUFFIX;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public UserProfile toUserProfile(String root, String json, boolean local) {
|
||||||
|
UniSkinAPIProfile profile = CustomSkinLoader.GSON.fromJson(json, UniSkinAPIProfile.class);
|
||||||
|
UserProfile p = new UserProfile();
|
||||||
|
|
||||||
|
if (StringUtils.isNotBlank(profile.cape)) {
|
||||||
|
p.capeUrl = root + TEXTURES + profile.cape;
|
||||||
|
if (local)
|
||||||
|
p.capeUrl = HttpTextureUtil.getLocalFakeUrl(p.capeUrl);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (profile.skins == null || profile.skins.isEmpty())
|
||||||
|
return p;
|
||||||
|
if (profile.model_preference == null || profile.model_preference.isEmpty())
|
||||||
|
return p;
|
||||||
|
|
||||||
|
boolean hasSkin = false;
|
||||||
|
for (String model : profile.model_preference) {
|
||||||
|
ModelManager0.Model enumModel = ModelManager0.getEnumModel(model);
|
||||||
|
if (enumModel == null || StringUtils.isEmpty(profile.skins.get(model)))
|
||||||
|
continue;
|
||||||
|
if (ModelManager0.isSkin(enumModel))
|
||||||
|
if (hasSkin)
|
||||||
|
continue;
|
||||||
|
else
|
||||||
|
hasSkin = true;
|
||||||
|
String url = root + TEXTURES + profile.skins.get(model);
|
||||||
|
if (local)
|
||||||
|
url = HttpTextureUtil.getLocalFakeUrl(url);
|
||||||
|
p.put(enumModel, url);
|
||||||
|
}
|
||||||
|
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Json profile for UniSkinAPI
|
||||||
|
* <a href="https://github.com/RecursiveG/UniSkinMod/blob/master/src/main/java/org/devinprogress/uniskinmod/UniSkinApiProfile.java#L18-L22">Source Code</a>
|
||||||
|
*
|
||||||
|
* @author RecursiveG
|
||||||
|
*/
|
||||||
|
private static class UniSkinAPIProfile {
|
||||||
|
public String player_name;
|
||||||
|
public long last_update;
|
||||||
|
public List<String> model_preference;
|
||||||
|
public Map<String, String> skins;
|
||||||
|
|
||||||
|
public String cape;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getName() {
|
||||||
|
return "UniSkinAPI";
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,110 @@
|
|||||||
|
package customskinloader.loader.jsonapi;
|
||||||
|
|
||||||
|
import com.google.common.collect.Lists;
|
||||||
|
import com.google.gson.Gson;
|
||||||
|
import customskinloader.CustomSkinLoader;
|
||||||
|
import customskinloader.config.SkinSiteProfile;
|
||||||
|
import customskinloader.loader.JsonAPILoader;
|
||||||
|
import customskinloader.loader.MojangAPILoader;
|
||||||
|
import customskinloader.plugin.ICustomSkinLoaderPlugin;
|
||||||
|
import customskinloader.profile.UserProfile;
|
||||||
|
import customskinloader.utils.TextureUtil;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Wynntils cape API
|
||||||
|
* <a href="https://wynntils.com/">Home</a>
|
||||||
|
* Test player: Cael
|
||||||
|
*
|
||||||
|
* @since 14.16
|
||||||
|
*/
|
||||||
|
public class WynntilsAPI implements JsonAPILoader.IJsonAPI {
|
||||||
|
|
||||||
|
public static class Wynntils extends JsonAPILoader.DefaultProfile {
|
||||||
|
public Wynntils(JsonAPILoader loader) {
|
||||||
|
super(loader);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getName() {
|
||||||
|
return "Wynntils";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getPriority() {
|
||||||
|
return 820;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getRoot() {
|
||||||
|
return "https://athena.wynntils.com/user/getInfo";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<ICustomSkinLoaderPlugin.IDefaultProfile> getDefaultProfiles(JsonAPILoader loader) {
|
||||||
|
return Lists.newArrayList(new Wynntils(loader));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toJsonUrl(String root, String username) {
|
||||||
|
return root;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public UserProfile toUserProfile(String root, String json, boolean local) {
|
||||||
|
WynntilsApiResponse result = new Gson().fromJson(json, WynntilsApiResponse.class);
|
||||||
|
if (result.user == null || result.user.cosmetics == null || result.user.cosmetics.texture == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
UserProfile profile = new UserProfile();
|
||||||
|
String fakeUrl = TextureUtil.parseBase64Texture(result.user.cosmetics.texture);
|
||||||
|
if (result.user.cosmetics.hasCape) {
|
||||||
|
profile.capeUrl = fakeUrl;
|
||||||
|
} else if (result.user.cosmetics.hasElytra) {
|
||||||
|
profile.elytraUrl = fakeUrl;
|
||||||
|
} else {
|
||||||
|
CustomSkinLoader.logger.warning("Illegal response found in Wynntils");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return profile;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getPayload(SkinSiteProfile ssp, String username) {
|
||||||
|
WynntilsApiRequest req = new WynntilsApiRequest();
|
||||||
|
req.uuid = MojangAPILoader.getMojangUuidByUsername(username, true);
|
||||||
|
if (req.uuid == null) {
|
||||||
|
throw new JsonAPILoader.ProfileNotFoundException();
|
||||||
|
}
|
||||||
|
return new Gson().toJson(req);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getName() {
|
||||||
|
return "WynntilsAPI";
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class WynntilsApiRequest {
|
||||||
|
public String uuid;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class WynntilsApiResponse {
|
||||||
|
public User user;
|
||||||
|
|
||||||
|
public static class User {
|
||||||
|
public String accountType;
|
||||||
|
public Cosmetics cosmetics;
|
||||||
|
|
||||||
|
public static class Cosmetics {
|
||||||
|
public boolean hasCape;
|
||||||
|
public boolean hasElytra;
|
||||||
|
public boolean hasEars;
|
||||||
|
public String texture;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,44 @@
|
|||||||
|
package customskinloader.log;
|
||||||
|
|
||||||
|
import java.io.Writer;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Path;
|
||||||
|
import java.nio.file.StandardOpenOption;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @since 14.16
|
||||||
|
*/
|
||||||
|
public class LogManager {
|
||||||
|
private static Path logFile;
|
||||||
|
private static Writer logWriter;
|
||||||
|
private static final Map<String, Logger> loggers = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
|
public static void setLogFile(Path logFile) {
|
||||||
|
//Not updated
|
||||||
|
if (logFile == null || logFile.equals(LogManager.logFile)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
LogManager.logFile = logFile;
|
||||||
|
try {
|
||||||
|
//Close previous writer
|
||||||
|
if (logWriter != null) {
|
||||||
|
logWriter.close();
|
||||||
|
}
|
||||||
|
//Set new writer
|
||||||
|
Files.createDirectories(logFile.getParent());
|
||||||
|
logWriter = Files.newBufferedWriter(logFile, StandardCharsets.UTF_8, StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING);
|
||||||
|
loggers.forEach((k, v) -> v.setWriter(logWriter));
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Logger getLogger(String loggerName) {
|
||||||
|
return loggers.computeIfAbsent(loggerName,
|
||||||
|
it -> new Logger(logWriter, "CustomSkinLoader " + loggerName));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,185 @@
|
|||||||
|
package customskinloader.log;
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
import java.io.*;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* the Logger
|
||||||
|
* Moved from <code>customskinloader.Logger</code>
|
||||||
|
*
|
||||||
|
* @since 14.16
|
||||||
|
*/
|
||||||
|
@SuppressWarnings("ResultOfMethodCallIgnored")
|
||||||
|
public class Logger {
|
||||||
|
private static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A copy of <code>Config.enableLogStdOut</code>.
|
||||||
|
* Because <code>Config.loadConfig0()</code> will use <code>Logger.log()</code>,
|
||||||
|
* which means cannot access <code>CustomSkinLoader.config</code> here.
|
||||||
|
*
|
||||||
|
* @see customskinloader.config.Config#enableLogStdOut
|
||||||
|
* @since 14.15
|
||||||
|
*/
|
||||||
|
public boolean enableLogStdOut = false;
|
||||||
|
|
||||||
|
public enum Level {
|
||||||
|
DEBUG("DEBUG", false),
|
||||||
|
INFO("INFO", true),
|
||||||
|
WARNING("WARNING", true);
|
||||||
|
|
||||||
|
|
||||||
|
final String name;
|
||||||
|
final boolean display;
|
||||||
|
|
||||||
|
Level(String name, boolean display) {
|
||||||
|
this.name = name;
|
||||||
|
this.display = display;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean display() {
|
||||||
|
return display;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private Writer writer = null;
|
||||||
|
|
||||||
|
public void setWriter(Writer writer) {
|
||||||
|
this.writer = writer;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Logger() {
|
||||||
|
//Logger isn't created.
|
||||||
|
}
|
||||||
|
|
||||||
|
public Logger(String logFile) {
|
||||||
|
this(new File(logFile));
|
||||||
|
}
|
||||||
|
|
||||||
|
public Logger(File logFile) {
|
||||||
|
this(logFile, "Unknown");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create Logger with File
|
||||||
|
*
|
||||||
|
* @since 14.16
|
||||||
|
*/
|
||||||
|
public Logger(File logFile, String loggerName) {
|
||||||
|
this.loggerName = loggerName;
|
||||||
|
try {
|
||||||
|
if (!logFile.getParentFile().exists()) {
|
||||||
|
logFile.getParentFile().mkdirs();
|
||||||
|
}
|
||||||
|
if (!logFile.exists()) {
|
||||||
|
logFile.createNewFile();
|
||||||
|
}
|
||||||
|
|
||||||
|
writer = new BufferedWriter(new OutputStreamWriter(
|
||||||
|
Files.newOutputStream(logFile.toPath()), StandardCharsets.UTF_8));
|
||||||
|
|
||||||
|
System.out.println("Log Path: " + logFile.getAbsolutePath());
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create Logger with special Writer
|
||||||
|
*
|
||||||
|
* @since 14.16
|
||||||
|
*/
|
||||||
|
public Logger(@Nullable Writer writer, String loggerName) {
|
||||||
|
this.loggerName = loggerName;
|
||||||
|
this.writer = writer;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Logger name in log
|
||||||
|
*
|
||||||
|
* @since 14.16
|
||||||
|
*/
|
||||||
|
String loggerName;
|
||||||
|
|
||||||
|
public void close() {
|
||||||
|
if (writer != null) {
|
||||||
|
try {
|
||||||
|
writer.close();
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Judge if a level can be printed to standard output(System.out) with config.
|
||||||
|
*
|
||||||
|
* @param level log level
|
||||||
|
* @return true - print
|
||||||
|
*/
|
||||||
|
private boolean canPrintToStdOut(Level level) {
|
||||||
|
return level.display() && enableLogStdOut;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void log(Level level, String msg) {
|
||||||
|
//When it neither be printed to standard output nor write to file
|
||||||
|
if (!canPrintToStdOut(level) && writer == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Format, print and write
|
||||||
|
String sb = String.format("[%s] [%s/%s] [%s]: %s",
|
||||||
|
DATE_FORMAT.format(new Date()), Thread.currentThread().getName(), level.getName(), loggerName, msg);
|
||||||
|
if (canPrintToStdOut(level)) {
|
||||||
|
System.out.println(sb);
|
||||||
|
}
|
||||||
|
if (writer == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
String sb2 = String.format("%s\r\n", sb);
|
||||||
|
writer.write(sb2);//Writer.write has lock
|
||||||
|
writer.flush();
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void debug(String msg) {
|
||||||
|
log(Level.DEBUG, msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void debug(String format, Object... objs) {
|
||||||
|
debug(String.format(format, objs));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void info(String msg) {
|
||||||
|
log(Level.INFO, msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void info(String format, Object... objs) {
|
||||||
|
info(String.format(format, objs));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void warning(String msg) {
|
||||||
|
log(Level.WARNING, msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void warning(String format, Object... objs) {
|
||||||
|
warning(String.format(format, objs));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void warning(Throwable e) {
|
||||||
|
StringWriter sw = new StringWriter();
|
||||||
|
e.printStackTrace(new PrintWriter(sw));
|
||||||
|
log(Level.WARNING, "Exception: " + sw);
|
||||||
|
}
|
||||||
|
}
|
||||||
File renamed without changes.
+4
-1
@@ -9,6 +9,7 @@ import java.util.ServiceLoader;
|
|||||||
|
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
import customskinloader.CustomSkinLoader;
|
import customskinloader.CustomSkinLoader;
|
||||||
|
import customskinloader.loader.GameProfileLoader;
|
||||||
import customskinloader.loader.JsonAPILoader;
|
import customskinloader.loader.JsonAPILoader;
|
||||||
import customskinloader.loader.LegacyLoader;
|
import customskinloader.loader.LegacyLoader;
|
||||||
import customskinloader.loader.MojangAPILoader;
|
import customskinloader.loader.MojangAPILoader;
|
||||||
@@ -17,6 +18,7 @@ import org.apache.commons.io.FileUtils;
|
|||||||
|
|
||||||
public class PluginLoader {
|
public class PluginLoader {
|
||||||
public static final ICustomSkinLoaderPlugin[] DEFAULT_PLUGINS = new ICustomSkinLoaderPlugin[]{
|
public static final ICustomSkinLoaderPlugin[] DEFAULT_PLUGINS = new ICustomSkinLoaderPlugin[]{
|
||||||
|
new GameProfileLoader(),
|
||||||
new MojangAPILoader(),
|
new MojangAPILoader(),
|
||||||
new LegacyLoader(),
|
new LegacyLoader(),
|
||||||
new JsonAPILoader(new CustomSkinAPI()),
|
new JsonAPILoader(new CustomSkinAPI()),
|
||||||
@@ -24,7 +26,8 @@ public class PluginLoader {
|
|||||||
new JsonAPILoader(new UniSkinAPI()),
|
new JsonAPILoader(new UniSkinAPI()),
|
||||||
new JsonAPILoader(new ElyByAPI()),
|
new JsonAPILoader(new ElyByAPI()),
|
||||||
new JsonAPILoader(new GlitchlessAPI()),
|
new JsonAPILoader(new GlitchlessAPI()),
|
||||||
new JsonAPILoader(new MinecraftCapesAPI())
|
new JsonAPILoader(new MinecraftCapesAPI()),
|
||||||
|
new JsonAPILoader(new WynntilsAPI()),
|
||||||
};
|
};
|
||||||
public static final ArrayList<ICustomSkinLoaderPlugin> PLUGINS = loadPlugins();
|
public static final ArrayList<ICustomSkinLoaderPlugin> PLUGINS = loadPlugins();
|
||||||
|
|
||||||
@@ -0,0 +1,159 @@
|
|||||||
|
package customskinloader.profile;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.UUID;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
|
import com.google.common.collect.Iterables;
|
||||||
|
import com.google.common.collect.Lists;
|
||||||
|
import com.google.common.collect.Maps;
|
||||||
|
import com.google.gson.Gson;
|
||||||
|
import com.google.gson.GsonBuilder;
|
||||||
|
import com.mojang.authlib.GameProfile;
|
||||||
|
import com.mojang.authlib.minecraft.MinecraftProfileTexture;
|
||||||
|
import com.mojang.authlib.properties.Property;
|
||||||
|
import com.mojang.authlib.properties.PropertyMap;
|
||||||
|
import com.mojang.util.UUIDTypeAdapter;
|
||||||
|
import customskinloader.CustomSkinLoader;
|
||||||
|
import customskinloader.utils.HttpRequestUtil;
|
||||||
|
import customskinloader.utils.HttpTextureUtil;
|
||||||
|
import customskinloader.utils.HttpUtil0;
|
||||||
|
import customskinloader.utils.TextureUtil;
|
||||||
|
import org.apache.commons.codec.Charsets;
|
||||||
|
import org.apache.commons.codec.binary.Base64;
|
||||||
|
import org.apache.commons.io.FileUtils;
|
||||||
|
import org.apache.commons.io.FilenameUtils;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
|
public class DynamicSkullManager {
|
||||||
|
public static class SkullTexture {
|
||||||
|
public Map<MinecraftProfileTexture.Type, MinecraftProfileTexture> textures;
|
||||||
|
public String index;//Index File
|
||||||
|
public ArrayList<String> skins;
|
||||||
|
public int interval;
|
||||||
|
public boolean fromZero;
|
||||||
|
//For program
|
||||||
|
public long startTime;
|
||||||
|
public int period;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Map<GameProfile, SkullTexture> dynamicTextures = new ConcurrentHashMap<>();
|
||||||
|
private Map<GameProfile, Map<MinecraftProfileTexture.Type, MinecraftProfileTexture>> staticTextures = new ConcurrentHashMap<>();
|
||||||
|
private List<GameProfile> loadingList = Lists.newArrayList();
|
||||||
|
|
||||||
|
private void parseGameProfile(GameProfile profile) {
|
||||||
|
Property textureProperty = Iterables.getFirst(TextureUtil.AuthlibField.GAME_PROFILE_PROPERTIES.<PropertyMap>get(profile).get("textures"), null);
|
||||||
|
if (textureProperty == null) {
|
||||||
|
staticTextures.put(profile, Maps.newHashMap());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
String value = TextureUtil.AuthlibField.PROPERTY_VALUE.get(textureProperty);
|
||||||
|
if (StringUtils.isBlank(value)) {
|
||||||
|
staticTextures.put(profile, Maps.newHashMap());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
@SuppressWarnings("deprecation") String json = new String(Base64.decodeBase64(value), Charsets.UTF_8);
|
||||||
|
Gson gson = new GsonBuilder().registerTypeAdapter(UUID.class, new UUIDTypeAdapter()).create();
|
||||||
|
SkullTexture result = gson.fromJson(json, SkullTexture.class);
|
||||||
|
if (result == null) {
|
||||||
|
staticTextures.put(profile, Maps.newHashMap());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
staticTextures.put(profile, (result.textures == null || !result.textures.containsKey(MinecraftProfileTexture.Type.SKIN)) ? Maps.newHashMap() : parseTextures(result.textures));
|
||||||
|
|
||||||
|
if (StringUtils.isNotEmpty(result.index)) {
|
||||||
|
File indexFile = new File(CustomSkinLoader.DATA_DIR, result.index);
|
||||||
|
try {
|
||||||
|
String index = FileUtils.readFileToString(indexFile, "UTF-8");
|
||||||
|
if (StringUtils.isNotEmpty(index)) {
|
||||||
|
String[] skins = CustomSkinLoader.GSON.fromJson(index, String[].class);
|
||||||
|
if (skins != null && skins.length != 0)
|
||||||
|
result.skins = Lists.newArrayList(skins);
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
CustomSkinLoader.logger.warning("Exception occurs while parsing index file: " + e.toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!CustomSkinLoader.config.enableDynamicSkull || result.skins == null || result.skins.isEmpty())
|
||||||
|
return;
|
||||||
|
|
||||||
|
CustomSkinLoader.logger.info("Try to load Dynamic Skull: " + json);
|
||||||
|
|
||||||
|
for (int i = 0; i < result.skins.size(); i++) {//check and cache skins
|
||||||
|
String skin = result.skins.get(i);
|
||||||
|
if (HttpUtil0.isLocal(skin)) {
|
||||||
|
//Local Skin
|
||||||
|
File skinFile = new File(CustomSkinLoader.DATA_DIR, skin);
|
||||||
|
if (skinFile.isFile() && skinFile.length() > 0) {
|
||||||
|
//Skin found
|
||||||
|
String fakeUrl = HttpTextureUtil.getLocalFakeUrl(skin);
|
||||||
|
result.skins.set(i, fakeUrl);
|
||||||
|
} else {
|
||||||
|
//Could not find skin
|
||||||
|
result.skins.remove(i--);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
//Online Skin
|
||||||
|
HttpRequestUtil.HttpResponce responce = HttpRequestUtil.makeHttpRequest(new HttpRequestUtil.HttpRequest(skin).setCacheFile(HttpTextureUtil.getCacheFile(FilenameUtils.getBaseName(skin))).setCacheTime(0).setLoadContent(false));
|
||||||
|
if (!responce.success) {
|
||||||
|
//Could not load skin
|
||||||
|
result.skins.remove(i--);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (result.skins.isEmpty()) {//Nothing loaded
|
||||||
|
CustomSkinLoader.logger.info("Failed: Nothing loaded.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
result.interval = Math.max(result.interval, 50);
|
||||||
|
if (result.fromZero)
|
||||||
|
result.startTime = System.currentTimeMillis();
|
||||||
|
result.period = result.interval * result.skins.size();
|
||||||
|
CustomSkinLoader.logger.info("Successfully loaded Dynamic Skull: " + new Gson().toJson(result));
|
||||||
|
dynamicTextures.put(profile, result);
|
||||||
|
staticTextures.remove(profile);
|
||||||
|
}
|
||||||
|
|
||||||
|
//Support local skin for skull
|
||||||
|
public Map<MinecraftProfileTexture.Type, MinecraftProfileTexture> parseTextures(Map<MinecraftProfileTexture.Type, MinecraftProfileTexture> textures) {
|
||||||
|
MinecraftProfileTexture skin = textures.get(MinecraftProfileTexture.Type.SKIN);
|
||||||
|
String skinUrl = skin.getUrl();
|
||||||
|
if (!HttpUtil0.isLocal(skinUrl))
|
||||||
|
// Wrap MinecraftProfileTexture to FakeMinecraftProfileTexture
|
||||||
|
return ModelManager0.fromUserProfile(ModelManager0.toUserProfile(textures));
|
||||||
|
File skinFile = new File(CustomSkinLoader.DATA_DIR, skinUrl);
|
||||||
|
if (!skinFile.isFile())
|
||||||
|
return Maps.newHashMap();
|
||||||
|
textures.put(MinecraftProfileTexture.Type.SKIN, ModelManager0.getProfileTexture(HttpTextureUtil.getLocalFakeUrl(skinUrl), null));
|
||||||
|
return textures;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Map<MinecraftProfileTexture.Type, MinecraftProfileTexture> getTexture(final GameProfile profile) {
|
||||||
|
if (staticTextures.get(profile) != null)
|
||||||
|
return staticTextures.get(profile);
|
||||||
|
if (loadingList.contains(profile))
|
||||||
|
return CustomSkinLoader.INCOMPLETED;
|
||||||
|
if (dynamicTextures.containsKey(profile)) {
|
||||||
|
SkullTexture texture = dynamicTextures.get(profile);
|
||||||
|
long time = System.currentTimeMillis() - texture.startTime;
|
||||||
|
int index = (int) Math.floor((time % texture.period) / texture.interval);
|
||||||
|
Map<MinecraftProfileTexture.Type, MinecraftProfileTexture> map = Maps.newHashMap();
|
||||||
|
map.put(MinecraftProfileTexture.Type.SKIN, ModelManager0.getProfileTexture(texture.skins.get(index), null));
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
|
||||||
|
loadingList.add(profile);
|
||||||
|
Thread loadThread = new Thread(() -> {
|
||||||
|
parseGameProfile(profile);//Load in thread
|
||||||
|
loadingList.remove(profile);
|
||||||
|
});
|
||||||
|
loadThread.setName("Skull " + profile.hashCode());
|
||||||
|
loadThread.start();
|
||||||
|
return CustomSkinLoader.INCOMPLETED;
|
||||||
|
}
|
||||||
|
}
|
||||||
+14
-14
@@ -3,11 +3,11 @@ package customskinloader.profile;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
|
||||||
|
|
||||||
import com.google.common.collect.Maps;
|
import com.google.common.collect.Maps;
|
||||||
import com.mojang.authlib.minecraft.MinecraftProfileTexture;
|
import com.mojang.authlib.minecraft.MinecraftProfileTexture;
|
||||||
import com.mojang.authlib.minecraft.MinecraftProfileTexture.Type;
|
import customskinloader.CustomSkinLoader;
|
||||||
|
import customskinloader.fake.FakeMinecraftProfileTexture;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Model Manager for 1.8 and higher.
|
* Model Manager for 1.8 and higher.
|
||||||
@@ -25,10 +25,10 @@ public class ModelManager0 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static HashMap<String, Model> models = new HashMap<String, Model>();
|
private static HashMap<String, Model> models = new HashMap<String, Model>();
|
||||||
private static Type typeElytra = null;
|
private static MinecraftProfileTexture.Type typeElytra = null;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
for (Type type : Type.values()) {
|
for (MinecraftProfileTexture.Type type : MinecraftProfileTexture.Type.values()) {
|
||||||
if (type.ordinal() == 2)//ELYTRA
|
if (type.ordinal() == 2)//ELYTRA
|
||||||
typeElytra = type;
|
typeElytra = type;
|
||||||
}
|
}
|
||||||
@@ -76,17 +76,17 @@ public class ModelManager0 {
|
|||||||
* @return profile - UserProfile instance
|
* @return profile - UserProfile instance
|
||||||
* @since 13.1
|
* @since 13.1
|
||||||
*/
|
*/
|
||||||
public static UserProfile toUserProfile(Map<Type, MinecraftProfileTexture> profile) {
|
public static UserProfile toUserProfile(Map<MinecraftProfileTexture.Type, MinecraftProfileTexture> profile) {
|
||||||
UserProfile userProfile = new UserProfile();
|
UserProfile userProfile = new UserProfile();
|
||||||
if (profile == null)
|
if (profile == null)
|
||||||
return userProfile;
|
return userProfile;
|
||||||
MinecraftProfileTexture skin = profile.get(Type.SKIN);
|
MinecraftProfileTexture skin = profile.get(MinecraftProfileTexture.Type.SKIN);
|
||||||
userProfile.skinUrl = skin == null ? null : skin.getUrl();//Avoid NullPointerException
|
userProfile.skinUrl = skin == null ? null : skin.getUrl();//Avoid NullPointerException
|
||||||
userProfile.model = skin == null ? null : skin.getMetadata("model");
|
userProfile.model = skin == null ? null : skin.getMetadata("model");
|
||||||
if (StringUtils.isEmpty(userProfile.model))
|
if (StringUtils.isEmpty(userProfile.model))
|
||||||
userProfile.model = "default";
|
userProfile.model = "default";
|
||||||
|
|
||||||
MinecraftProfileTexture cape = profile.get(Type.CAPE);
|
MinecraftProfileTexture cape = profile.get(MinecraftProfileTexture.Type.CAPE);
|
||||||
userProfile.capeUrl = cape == null ? null : cape.getUrl();
|
userProfile.capeUrl = cape == null ? null : cape.getUrl();
|
||||||
return userProfile;
|
return userProfile;
|
||||||
}
|
}
|
||||||
@@ -98,20 +98,20 @@ public class ModelManager0 {
|
|||||||
* @return profile - hashMapProfile (HashMap<String,MinecraftProfileTexture>)
|
* @return profile - hashMapProfile (HashMap<String,MinecraftProfileTexture>)
|
||||||
* @since 13.1
|
* @since 13.1
|
||||||
*/
|
*/
|
||||||
public static Map<Type, MinecraftProfileTexture> fromUserProfile(UserProfile profile) {
|
public static Map<MinecraftProfileTexture.Type, MinecraftProfileTexture> fromUserProfile(UserProfile profile) {
|
||||||
Map<Type, MinecraftProfileTexture> map = Maps.newHashMap();
|
|
||||||
if (profile == null)
|
if (profile == null)
|
||||||
return map;
|
return CustomSkinLoader.INCOMPLETED;
|
||||||
|
Map<MinecraftProfileTexture.Type, MinecraftProfileTexture> map = Maps.newHashMap();
|
||||||
if (profile.skinUrl != null) {
|
if (profile.skinUrl != null) {
|
||||||
Map<String, String> metadata = null;
|
Map<String, String> metadata = null;
|
||||||
if ("slim".equals(profile.model) || "auto".equals(profile.model)) {
|
if ("slim".equals(profile.model) || "auto".equals(profile.model)) {
|
||||||
metadata = Maps.newHashMap();
|
metadata = Maps.newHashMap();
|
||||||
metadata.put("model", profile.model);
|
metadata.put("model", profile.model);
|
||||||
}
|
}
|
||||||
map.put(Type.SKIN, getProfileTexture(profile.skinUrl, metadata));
|
map.put(MinecraftProfileTexture.Type.SKIN, getProfileTexture(profile.skinUrl, metadata));
|
||||||
}
|
}
|
||||||
if (profile.capeUrl != null)
|
if (profile.capeUrl != null)
|
||||||
map.put(Type.CAPE, getProfileTexture(profile.capeUrl, null));
|
map.put(MinecraftProfileTexture.Type.CAPE, getProfileTexture(profile.capeUrl, null));
|
||||||
if (typeElytra != null && profile.elytraUrl != null)
|
if (typeElytra != null && profile.elytraUrl != null)
|
||||||
map.put(typeElytra, getProfileTexture(profile.elytraUrl, null));
|
map.put(typeElytra, getProfileTexture(profile.elytraUrl, null));
|
||||||
return map;
|
return map;
|
||||||
@@ -126,6 +126,6 @@ public class ModelManager0 {
|
|||||||
* @since 14.5
|
* @since 14.5
|
||||||
*/
|
*/
|
||||||
public static MinecraftProfileTexture getProfileTexture(String url, Map<String, String> metadata) {
|
public static MinecraftProfileTexture getProfileTexture(String url, Map<String, String> metadata) {
|
||||||
return new MinecraftProfileTexture(url, metadata);
|
return new FakeMinecraftProfileTexture(url, metadata);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+10
-12
@@ -3,12 +3,10 @@ package customskinloader.profile;
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.Deque;
|
import java.util.Deque;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Optional;
|
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.concurrent.ConcurrentLinkedDeque;
|
import java.util.concurrent.ConcurrentLinkedDeque;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Function;
|
||||||
|
|
||||||
import com.mojang.authlib.minecraft.MinecraftProfileTexture;
|
|
||||||
import customskinloader.CustomSkinLoader;
|
import customskinloader.CustomSkinLoader;
|
||||||
import customskinloader.utils.TimeUtil;
|
import customskinloader.utils.TimeUtil;
|
||||||
import org.apache.commons.io.FileUtils;
|
import org.apache.commons.io.FileUtils;
|
||||||
@@ -18,7 +16,7 @@ public class ProfileCache {
|
|||||||
|
|
||||||
private Map<String, CachedProfile> cachedProfiles = new ConcurrentHashMap<>();
|
private Map<String, CachedProfile> cachedProfiles = new ConcurrentHashMap<>();
|
||||||
private Map<String, UserProfile> localProfiles = new ConcurrentHashMap<>();
|
private Map<String, UserProfile> localProfiles = new ConcurrentHashMap<>();
|
||||||
private Map<String, Deque<Consumer<Map<MinecraftProfileTexture.Type, MinecraftProfileTexture>>>> profileLoaders = new ConcurrentHashMap<>();
|
private Map<String, Deque<Function<UserProfile, ?>>> profileLoaders = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
@SuppressWarnings("ResultOfMethodCallIgnored")
|
@SuppressWarnings("ResultOfMethodCallIgnored")
|
||||||
public ProfileCache(){
|
public ProfileCache(){
|
||||||
@@ -53,12 +51,12 @@ public class ProfileCache {
|
|||||||
return localProfiles.get(username.toLowerCase());
|
return localProfiles.get(username.toLowerCase());
|
||||||
return loadLocalProfile(username);
|
return loadLocalProfile(username);
|
||||||
}
|
}
|
||||||
public Optional<Consumer<Map<MinecraftProfileTexture.Type, MinecraftProfileTexture>>> getLastLoader(String username) {
|
public Function<UserProfile, ?> getLastLoader(String username) {
|
||||||
Deque<Consumer<Map<MinecraftProfileTexture.Type, MinecraftProfileTexture>>> deque = this.profileLoaders.get(username);
|
Deque<Function<UserProfile, ?>> deque = this.profileLoaders.get(username);
|
||||||
if (deque != null) {
|
if (deque != null) {
|
||||||
return Optional.ofNullable(deque.pollLast());
|
return deque.pollLast();
|
||||||
}
|
}
|
||||||
return Optional.empty();
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setLoading(String username,boolean loading){
|
public void setLoading(String username,boolean loading){
|
||||||
@@ -75,7 +73,7 @@ public class ProfileCache {
|
|||||||
return;
|
return;
|
||||||
saveLocalProfile(username,profile);
|
saveLocalProfile(username,profile);
|
||||||
}
|
}
|
||||||
public void putLoader(String username, Consumer<Map<MinecraftProfileTexture.Type, MinecraftProfileTexture>> loader) {
|
public void putLoader(String username, Function<UserProfile, ?> loader) {
|
||||||
this.profileLoaders.putIfAbsent(username, new ConcurrentLinkedDeque<>());
|
this.profileLoaders.putIfAbsent(username, new ConcurrentLinkedDeque<>());
|
||||||
this.profileLoaders.get(username).offerLast(loader);
|
this.profileLoaders.get(username).offerLast(loader);
|
||||||
}
|
}
|
||||||
@@ -91,7 +89,7 @@ public class ProfileCache {
|
|||||||
private UserProfile loadLocalProfile(String username){
|
private UserProfile loadLocalProfile(String username){
|
||||||
File localProfile=new File(PROFILE_CACHE_DIR,username.toLowerCase()+".json");
|
File localProfile=new File(PROFILE_CACHE_DIR,username.toLowerCase()+".json");
|
||||||
if(!localProfile.exists()){
|
if(!localProfile.exists()){
|
||||||
localProfiles.put(username.toLowerCase(), null);
|
localProfiles.put(username.toLowerCase(), UserProfile.NULL);
|
||||||
}
|
}
|
||||||
try{
|
try{
|
||||||
String json = FileUtils.readFileToString(localProfile, "UTF-8");
|
String json = FileUtils.readFileToString(localProfile, "UTF-8");
|
||||||
@@ -101,9 +99,9 @@ public class ProfileCache {
|
|||||||
return profile;
|
return profile;
|
||||||
}catch(Exception e){
|
}catch(Exception e){
|
||||||
CustomSkinLoader.logger.info("Failed to load LocalProfile.("+e.toString()+")");
|
CustomSkinLoader.logger.info("Failed to load LocalProfile.("+e.toString()+")");
|
||||||
localProfiles.put(username.toLowerCase(), null);
|
localProfiles.put(username.toLowerCase(), UserProfile.NULL);
|
||||||
}
|
}
|
||||||
return null;
|
return UserProfile.NULL;
|
||||||
}
|
}
|
||||||
@SuppressWarnings("ResultOfMethodCallIgnored")
|
@SuppressWarnings("ResultOfMethodCallIgnored")
|
||||||
private void saveLocalProfile(String username, UserProfile profile){
|
private void saveLocalProfile(String username, UserProfile profile){
|
||||||
+3
-3
@@ -2,14 +2,14 @@ package customskinloader.profile;
|
|||||||
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
import customskinloader.profile.ModelManager0.Model;
|
|
||||||
|
|
||||||
/**The instance to storage user's profile in memory temporarily.
|
/**The instance to storage user's profile in memory temporarily.
|
||||||
* In this manner, it could be easier to pass profile in program.
|
* In this manner, it could be easier to pass profile in program.
|
||||||
* @since 13.1
|
* @since 13.1
|
||||||
*/
|
*/
|
||||||
public class UserProfile {
|
public class UserProfile {
|
||||||
|
|
||||||
|
public final static UserProfile NULL = new UserProfile();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Direct url for skin.
|
* Direct url for skin.
|
||||||
* @since 13.1
|
* @since 13.1
|
||||||
@@ -35,7 +35,7 @@ public class UserProfile {
|
|||||||
*/
|
*/
|
||||||
public String elytraUrl=null;
|
public String elytraUrl=null;
|
||||||
|
|
||||||
public void put(Model model,String url){
|
public void put(ModelManager0.Model model,String url){
|
||||||
if(model==null||StringUtils.isEmpty(url))
|
if(model==null||StringUtils.isEmpty(url))
|
||||||
return;
|
return;
|
||||||
switch(model){
|
switch(model){
|
||||||
+1
@@ -161,6 +161,7 @@ public class HttpRequestUtil {
|
|||||||
}
|
}
|
||||||
if (StringUtils.isNotEmpty(request.payload)) {
|
if (StringUtils.isNotEmpty(request.payload)) {
|
||||||
CustomSkinLoader.logger.info("Payload: " + request.payload);
|
CustomSkinLoader.logger.info("Payload: " + request.payload);
|
||||||
|
c.setRequestMethod("POST");
|
||||||
c.setRequestProperty("Content-Type", "application/json");
|
c.setRequestProperty("Content-Type", "application/json");
|
||||||
c.setDoOutput(true);
|
c.setDoOutput(true);
|
||||||
OutputStream os = c.getOutputStream();
|
OutputStream os = c.getOutputStream();
|
||||||
File renamed without changes.
-34
@@ -4,14 +4,7 @@ import java.io.IOException;
|
|||||||
import java.net.InetAddress;
|
import java.net.InetAddress;
|
||||||
import java.net.Socket;
|
import java.net.Socket;
|
||||||
import java.net.UnknownHostException;
|
import java.net.UnknownHostException;
|
||||||
import java.security.cert.X509Certificate;
|
|
||||||
import javax.net.ssl.HostnameVerifier;
|
|
||||||
import javax.net.ssl.HttpsURLConnection;
|
|
||||||
import javax.net.ssl.SSLContext;
|
|
||||||
import javax.net.ssl.SSLSession;
|
|
||||||
import javax.net.ssl.SSLSocketFactory;
|
import javax.net.ssl.SSLSocketFactory;
|
||||||
import javax.net.ssl.TrustManager;
|
|
||||||
import javax.net.ssl.X509TrustManager;
|
|
||||||
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
@@ -20,33 +13,6 @@ public class HttpUtil0 {
|
|||||||
return url != null && !url.startsWith("http://") && !url.startsWith("https://");
|
return url != null && !url.startsWith("http://") && !url.startsWith("https://");
|
||||||
}
|
}
|
||||||
|
|
||||||
//From: http://blog.csdn.net/xiyushiyi/article/details/46685387
|
|
||||||
public static void ignoreHttpsCertificate(){
|
|
||||||
HostnameVerifier doNotVerify = new HostnameVerifier() {
|
|
||||||
|
|
||||||
public boolean verify(String hostname, SSLSession session) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
TrustManager[] trustAllCerts = new TrustManager[] {new X509TrustManager() {
|
|
||||||
public X509Certificate[] getAcceptedIssuers() {
|
|
||||||
return new X509Certificate[] {};
|
|
||||||
}
|
|
||||||
public void checkClientTrusted(X509Certificate[] chain, String authType){}
|
|
||||||
public void checkServerTrusted(X509Certificate[] chain, String authType){}
|
|
||||||
}};
|
|
||||||
|
|
||||||
try {
|
|
||||||
SSLContext sc = SSLContext.getInstance("TLS");
|
|
||||||
sc.init(null, trustAllCerts, new java.security.SecureRandom());
|
|
||||||
//HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory());
|
|
||||||
HttpsURLConnection.setDefaultSSLSocketFactory(new SSLSocketFactoryFacade());
|
|
||||||
HttpsURLConnection.setDefaultHostnameVerifier(doNotVerify);
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String parseAddress(String address) {
|
public static String parseAddress(String address) {
|
||||||
if(StringUtils.isEmpty(address))
|
if(StringUtils.isEmpty(address))
|
||||||
return null;
|
return null;
|
||||||
-1
@@ -1,7 +1,6 @@
|
|||||||
package customskinloader.utils;
|
package customskinloader.utils;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.net.MalformedURLException;
|
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.net.URLClassLoader;
|
import java.net.URLClassLoader;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
@@ -0,0 +1,50 @@
|
|||||||
|
package customskinloader.utils;
|
||||||
|
|
||||||
|
import java.util.concurrent.BlockingDeque;
|
||||||
|
import java.util.concurrent.BlockingQueue;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
import com.google.common.util.concurrent.ForwardingBlockingQueue;
|
||||||
|
|
||||||
|
public class LIFOBlockingQueue<E> extends ForwardingBlockingQueue<E> {
|
||||||
|
private final BlockingDeque<E> deque;
|
||||||
|
|
||||||
|
public LIFOBlockingQueue(BlockingDeque<E> deque) {
|
||||||
|
this.deque = deque;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected BlockingQueue<E> delegate() {
|
||||||
|
return deque;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean offer(E e) {
|
||||||
|
return deque.offerFirst(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void put(E e) throws InterruptedException {
|
||||||
|
deque.putFirst(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean offer(E e, long timeout, TimeUnit unit) throws InterruptedException {
|
||||||
|
return deque.offerFirst(e, timeout, unit);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public E take() throws InterruptedException {
|
||||||
|
return deque.takeFirst();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public E poll(long timeout, TimeUnit unit) throws InterruptedException {
|
||||||
|
return deque.pollFirst(timeout, unit);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public E peek() {
|
||||||
|
return deque.peekFirst();
|
||||||
|
}
|
||||||
|
}
|
||||||
+4
-13
@@ -1,27 +1,19 @@
|
|||||||
package customskinloader.utils;
|
package customskinloader.utils;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileReader;
|
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
import java.lang.invoke.MethodHandle;
|
import java.lang.invoke.MethodHandle;
|
||||||
import java.lang.invoke.MethodHandles;
|
import java.lang.invoke.MethodHandles;
|
||||||
import java.lang.reflect.Field;
|
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.net.URLDecoder;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.regex.Matcher;
|
|
||||||
import java.util.regex.Pattern;
|
|
||||||
|
|
||||||
import com.google.gson.Gson;
|
|
||||||
import com.google.gson.JsonObject;
|
import com.google.gson.JsonObject;
|
||||||
import com.google.gson.JsonParser;
|
import com.google.gson.JsonParser;
|
||||||
import com.mojang.authlib.GameProfile;
|
import com.mojang.authlib.GameProfile;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
|
import net.minecraft.client.multiplayer.ServerData;
|
||||||
import net.minecraft.client.renderer.texture.TextureManager;
|
import net.minecraft.client.renderer.texture.TextureManager;
|
||||||
import net.minecraft.client.resources.SkinManager;
|
import net.minecraft.client.resources.SkinManager;
|
||||||
import net.minecraft.realms.RealmsSharedConstants;
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Alexander Xia
|
* @author Alexander Xia
|
||||||
@@ -48,7 +40,7 @@ public class MinecraftUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//version.json can be found in 1.14+
|
//version.json can be found in 1.14+
|
||||||
URL versionFile = MinecraftUtil.class.getResource("/version.json");
|
URL versionFile = ClassLoader.getSystemClassLoader().getResource("version.json");
|
||||||
if (versionFile != null) {
|
if (versionFile != null) {
|
||||||
try (
|
try (
|
||||||
InputStream is = versionFile.openStream();
|
InputStream is = versionFile.openStream();
|
||||||
@@ -77,7 +69,7 @@ public class MinecraftUtil {
|
|||||||
|
|
||||||
// (domain|ip)(:port)
|
// (domain|ip)(:port)
|
||||||
public static String getServerAddress() {
|
public static String getServerAddress() {
|
||||||
net.minecraft.client.multiplayer.ServerData data = Minecraft.getMinecraft().getCurrentServerData();
|
ServerData data = Minecraft.getMinecraft().getCurrentServerData();
|
||||||
if (data == null)//Single Player
|
if (data == null)//Single Player
|
||||||
return null;
|
return null;
|
||||||
return data.serverIP;
|
return data.serverIP;
|
||||||
@@ -93,7 +85,6 @@ public class MinecraftUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static String getCredential(GameProfile profile) {
|
public static String getCredential(GameProfile profile) {
|
||||||
return (profile == null || profile.hashCode() == 0) ? null :
|
return profile == null ? null : String.format("%s-%s", TextureUtil.AuthlibField.GAME_PROFILE_NAME.get(profile), TextureUtil.AuthlibField.GAME_PROFILE_ID.get(profile));
|
||||||
(profile.getId() == null ? profile.getName() : String.format("%s-%s", profile.getName(), profile.getId()));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,86 @@
|
|||||||
|
package customskinloader.utils;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.lang.reflect.Field;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
import com.mojang.authlib.GameProfile;
|
||||||
|
import com.mojang.authlib.properties.Property;
|
||||||
|
import com.mojang.authlib.properties.PropertyMap;
|
||||||
|
import com.mojang.authlib.yggdrasil.response.MinecraftProfilePropertiesResponse;
|
||||||
|
import com.mojang.authlib.yggdrasil.response.MinecraftTexturesPayload;
|
||||||
|
import customskinloader.CustomSkinLoader;
|
||||||
|
import org.apache.commons.codec.binary.Base64;
|
||||||
|
import org.apache.commons.io.FileUtils;
|
||||||
|
|
||||||
|
public class TextureUtil {
|
||||||
|
/**
|
||||||
|
* Save and get fake url of base64 texture
|
||||||
|
*
|
||||||
|
* @param base64 texture in base64 string
|
||||||
|
* @return base64 fake url
|
||||||
|
* @since 14.16
|
||||||
|
*/
|
||||||
|
public static String parseBase64Texture(String base64) {
|
||||||
|
byte[] capeBytes = Base64.decodeBase64(base64);
|
||||||
|
String hash = HttpTextureUtil.getHash(capeBytes);
|
||||||
|
File cacheFile = HttpTextureUtil.getCacheFile(hash);
|
||||||
|
String fakeUrl = HttpTextureUtil.getBase64FakeUrl(hash);
|
||||||
|
|
||||||
|
//Save base64 image to cache file
|
||||||
|
try {
|
||||||
|
FileUtils.writeByteArrayToFile(cacheFile, capeBytes);
|
||||||
|
CustomSkinLoader.logger.info("Saved base64 image to " + cacheFile);
|
||||||
|
return fakeUrl;
|
||||||
|
} catch (Exception e) {
|
||||||
|
CustomSkinLoader.logger.warning("Error parsing base64 image: " + base64);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Some of the classes in Authlib used after Minecraft 23w31a were changed to record classes,
|
||||||
|
// resulting in changes to method names, so reflection is used here to be compatible with these changes.
|
||||||
|
public enum AuthlibField {
|
||||||
|
GAME_PROFILE_ID(GameProfile.class, "id"),
|
||||||
|
GAME_PROFILE_NAME(GameProfile.class, "name"),
|
||||||
|
GAME_PROFILE_PROPERTIES(GameProfile.class, "properties"),
|
||||||
|
PROPERTY_VALUE(Property.class, "value"),
|
||||||
|
PROPERTY_MAP_PROPERTIES(PropertyMap.class, "properties"),
|
||||||
|
MINECRAFT_PROFILE_PROPERTIES_RESPONSE_ID(MinecraftProfilePropertiesResponse.class, "id"),
|
||||||
|
MINECRAFT_PROFILE_PROPERTIES_RESPONSE_NAME(MinecraftProfilePropertiesResponse.class, "name"),
|
||||||
|
MINECRAFT_PROFILE_PROPERTIES_RESPONSE_PROPERTIES(MinecraftProfilePropertiesResponse.class, "properties"),
|
||||||
|
MINECRAFT_TEXTURES_PAYLOAD_TEXTURES(MinecraftTexturesPayload.class, "textures");
|
||||||
|
|
||||||
|
private final Field field;
|
||||||
|
|
||||||
|
AuthlibField(Class<?> clazz, String name) {
|
||||||
|
try {
|
||||||
|
this.field = clazz.getDeclaredField(name);
|
||||||
|
this.field.setAccessible(true);
|
||||||
|
} catch (Throwable t) {
|
||||||
|
throw new RuntimeException(t);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
public <R> R get(Object o) {
|
||||||
|
try {
|
||||||
|
return (R) this.field.get(o);
|
||||||
|
} catch (Throwable t) {
|
||||||
|
throw new RuntimeException(t);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void set(Object o, Object value) {
|
||||||
|
try {
|
||||||
|
this.field.set(o, value);
|
||||||
|
} catch (Throwable t) {
|
||||||
|
throw new RuntimeException(t);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String fromUUID(UUID value) {
|
||||||
|
return value.toString().replace("-", "");
|
||||||
|
}
|
||||||
|
}
|
||||||
File renamed without changes.
File renamed without changes.
+2
-6
@@ -2,17 +2,13 @@ package net.minecraft.client.renderer;
|
|||||||
|
|
||||||
import java.awt.image.BufferedImage;
|
import java.awt.image.BufferedImage;
|
||||||
|
|
||||||
|
import customskinloader.fake.itf.IFakeIImageBuffer;
|
||||||
import net.minecraft.client.renderer.texture.NativeImage;
|
import net.minecraft.client.renderer.texture.NativeImage;
|
||||||
|
|
||||||
public interface IImageBuffer extends Runnable {
|
public interface IImageBuffer extends IFakeIImageBuffer {
|
||||||
BufferedImage parseUserSkin(BufferedImage image);
|
BufferedImage parseUserSkin(BufferedImage image);
|
||||||
|
|
||||||
NativeImage func_195786_a(NativeImage image);
|
NativeImage func_195786_a(NativeImage image);
|
||||||
|
|
||||||
void skinAvailable();
|
void skinAvailable();
|
||||||
|
|
||||||
@Override
|
|
||||||
default void run() {
|
|
||||||
this.skinAvailable();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -2,9 +2,9 @@
|
|||||||
"name": "CustomSkinLoader",
|
"name": "CustomSkinLoader",
|
||||||
"version": "${modVersion}",
|
"version": "${modVersion}",
|
||||||
"fullVersion": "${modFullVersion}",
|
"fullVersion": "${modFullVersion}",
|
||||||
"mcVersion": "${mcVersion}",
|
"dependencies": {
|
||||||
"mcFullVersions": "${mcFullVersions}",
|
"${dependencies}"
|
||||||
"forgeVersion": "${forgeVersion}",
|
},
|
||||||
"gitVersion": "${gitVersion}",
|
"gitVersion": "${gitVersion}",
|
||||||
"buildUrl": "${buildUrl}",
|
"buildUrl": "${buildUrl}",
|
||||||
"buildTime": "${releaseTime}"
|
"buildTime": "${releaseTime}"
|
||||||
File renamed without changes.
Whitespace-only changes.
@@ -0,0 +1,7 @@
|
|||||||
|
// This subproject is only to provide dependency for other subprojects.
|
||||||
|
|
||||||
|
reobf {
|
||||||
|
jar {
|
||||||
|
mappings = file("Dummy.srg")
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
forge_mc_version=1.12.2
|
||||||
|
forge_version=14.23.5.2768
|
||||||
|
mappings_version=stable_39
|
||||||
|
# this subproject is only to provide dependency for other subprojects.
|
||||||
|
is_real_project=false
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
package com.google.errorprone.annotations;
|
||||||
|
|
||||||
|
public @interface CanIgnoreReturnValue {
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
package com.mojang.authlib;
|
||||||
|
|
||||||
|
public enum SignatureState {
|
||||||
|
SIGNED
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
package com.mojang.authlib.minecraft;
|
||||||
|
|
||||||
|
import com.mojang.authlib.SignatureState;
|
||||||
|
|
||||||
|
public class MinecraftProfileTextures {
|
||||||
|
public MinecraftProfileTextures(MinecraftProfileTexture skin, MinecraftProfileTexture cape, MinecraftProfileTexture elytra, SignatureState signatureState) {}
|
||||||
|
public MinecraftProfileTexture skin() { return null; }
|
||||||
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
package com.mojang.authlib.minecraft;
|
||||||
|
|
||||||
|
import com.mojang.authlib.properties.Property;
|
||||||
|
|
||||||
|
public interface MinecraftSessionService {
|
||||||
|
MinecraftProfileTextures unpackTextures(Property packedTextures);
|
||||||
|
}
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
package net.minecraft.client;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
|
||||||
|
import net.minecraft.client.multiplayer.ServerData;
|
||||||
|
import net.minecraft.client.renderer.texture.TextureManager;
|
||||||
|
import net.minecraft.client.resources.IResourceManager;
|
||||||
|
import net.minecraft.client.resources.SkinManager;
|
||||||
|
|
||||||
|
public class Minecraft {
|
||||||
|
public File gameDir;
|
||||||
|
public static Minecraft getMinecraft() { return null; }
|
||||||
|
public ServerData getCurrentServerData() { return null; }
|
||||||
|
public IResourceManager getResourceManager() { return null; }
|
||||||
|
public SkinManager getSkinManager() { return null; }
|
||||||
|
public TextureManager getTextureManager() { return null; }
|
||||||
|
}
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
package net.minecraft.client.gui;
|
||||||
|
|
||||||
|
public class GuiPlayerTabOverlay {
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
package net.minecraft.client.multiplayer;
|
||||||
|
|
||||||
|
public class ServerData {
|
||||||
|
public String serverIP;
|
||||||
|
}
|
||||||
File renamed without changes.
@@ -0,0 +1,10 @@
|
|||||||
|
package net.minecraft.client.renderer;
|
||||||
|
|
||||||
|
import java.io.InputStream;
|
||||||
|
|
||||||
|
import net.minecraft.client.renderer.texture.ITextureObject;
|
||||||
|
import net.minecraft.client.renderer.texture.NativeImage;
|
||||||
|
|
||||||
|
public class ThreadDownloadImageData implements ITextureObject {
|
||||||
|
public NativeImage loadTexture(InputStream stream) { return null; }
|
||||||
|
}
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
package net.minecraft.client.renderer.entity;
|
||||||
|
|
||||||
|
public class RenderPlayer {
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
package net.minecraft.client.renderer.entity.layers;
|
||||||
|
|
||||||
|
public class LayerCape {
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
package net.minecraft.client.renderer.texture;
|
||||||
|
|
||||||
|
public abstract class AbstractTexture {
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
package net.minecraft.client.renderer.texture;
|
||||||
|
|
||||||
|
public interface ITextureObject {
|
||||||
|
|
||||||
|
}
|
||||||
File renamed without changes.
@@ -0,0 +1,5 @@
|
|||||||
|
package net.minecraft.client.renderer.texture;
|
||||||
|
|
||||||
|
public abstract class ReloadableTexture extends AbstractTexture {
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
package net.minecraft.client.renderer.texture;
|
||||||
|
|
||||||
|
import net.minecraft.client.resources.IResourceManager;
|
||||||
|
import net.minecraft.util.ResourceLocation;
|
||||||
|
|
||||||
|
public class SimpleTexture extends ReloadableTexture implements ITextureObject {
|
||||||
|
public SimpleTexture(ResourceLocation location) {}
|
||||||
|
public TextureContents loadContents(IResourceManager resourceManager) { return null; }
|
||||||
|
}
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
package net.minecraft.client.renderer.texture;
|
||||||
|
|
||||||
|
import java.nio.file.Path;
|
||||||
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
|
||||||
|
import net.minecraft.util.ResourceLocation;
|
||||||
|
|
||||||
|
public class SkinTextureDownloader {
|
||||||
|
public static CompletableFuture<?> downloadAndRegisterSkin(ResourceLocation location, Path path, String string, boolean b) { return null; }
|
||||||
|
public static NativeImage processLegacySkin(NativeImage nativeImage, String url) { return null; }
|
||||||
|
public static NativeImage lambda$downloadAndRegisterSkin$0(Path path, String url, boolean b) { return null; }
|
||||||
|
}
|
||||||
File renamed without changes.
@@ -0,0 +1,7 @@
|
|||||||
|
package net.minecraft.client.renderer.texture;
|
||||||
|
|
||||||
|
import net.minecraft.client.resources.data.TextureMetadataSection;
|
||||||
|
|
||||||
|
public class TextureContents {
|
||||||
|
public TextureContents(NativeImage image, TextureMetadataSection metadata) {}
|
||||||
|
}
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
package net.minecraft.client.renderer.texture;
|
||||||
|
|
||||||
|
import net.minecraft.util.ResourceLocation;
|
||||||
|
|
||||||
|
public class TextureManager {
|
||||||
|
public ITextureObject getTexture(ResourceLocation location) { return null; }
|
||||||
|
public void loadTexture(ResourceLocation location, AbstractTexture texture) {}
|
||||||
|
public boolean loadTexture(ResourceLocation location, ITextureObject texture) { return false; }
|
||||||
|
public void registerAndLoad(ResourceLocation resourceLocation, ReloadableTexture reloadableTexture) {}
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
package net.minecraft.client.resources;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
import net.minecraft.util.ResourceLocation;
|
||||||
|
|
||||||
|
public class DefaultPlayerSkin {
|
||||||
|
public static ResourceLocation getDefaultSkin(UUID uuid) { return null; }
|
||||||
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
package net.minecraft.client.resources;
|
||||||
|
|
||||||
|
import java.io.InputStream;
|
||||||
|
|
||||||
|
public interface IResource {
|
||||||
|
InputStream getInputStream();
|
||||||
|
}
|
||||||
Loaded 100 of 264 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user