mirror of
https://github.com/xfl03/MCCustomSkinLoader.git
synced 2026-11-25 04:04:25 +00:00
Compare commits
412
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
921374f24f | ||
|
|
d2d244c70e | ||
|
|
f201f344a2 | ||
|
|
76d6ed9a41 | ||
|
|
b807aa1fb1 | ||
|
|
d797ed378a | ||
|
|
c3f8f1eb8f | ||
|
|
226d953012 | ||
|
|
d1ab2fbf43 | ||
|
|
00a14010c6 | ||
|
|
a198e40fc7 | ||
|
|
5b820c537d | ||
|
|
6e1be02cf0 | ||
|
|
9abf9eb779 | ||
|
|
fbc95314ad | ||
|
|
d4576249ac | ||
|
|
dfe47f7c64 | ||
|
|
1199e10ca4 | ||
|
|
61287cf64c | ||
|
|
b16058340c | ||
|
|
ac09a51f48 | ||
|
|
3e5bd83b5c | ||
|
|
4ce00d07b5 | ||
|
|
6e9380be49 | ||
|
|
53050a63f5 | ||
|
|
34ac3ac4f2 | ||
|
|
f5b1989453 | ||
|
|
85923855d8 | ||
|
|
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 | ||
|
|
e94f4b0e99 | ||
|
|
5ee2eee382 | ||
|
|
3063de7ff0 | ||
|
|
583bf1fe6a | ||
|
|
a3de21497d | ||
|
|
51aec265be | ||
|
|
52caeb3bdc | ||
|
|
a3fa4e47c6 | ||
|
|
e1cde0afc7 | ||
|
|
3f379f3cbe | ||
|
|
f50640139a | ||
|
|
46b8635e10 | ||
|
|
02b24229f3 | ||
|
|
941b421d86 | ||
|
|
a67ed507ec | ||
|
|
851fa81f31 | ||
|
|
5bb16ededa | ||
|
|
1e5bfcd1e7 | ||
|
|
1b85fa8ff9 | ||
|
|
e1e5319bdb | ||
|
|
187be47e88 | ||
|
|
b2f8d2cc38 | ||
|
|
8b641e0227 | ||
|
|
c90cea3721 | ||
|
|
b0c11d11c6 | ||
|
|
c77ac58f6d | ||
|
|
16fadc56b4 | ||
|
|
fc6c43bac9 | ||
|
|
b6fc1610bc | ||
|
|
c7d04976e6 | ||
|
|
0eaf1960bf | ||
|
|
cff5846e7f | ||
|
|
c8fb6e216e | ||
|
|
a5d466e0a7 | ||
|
|
31fffa5d23 | ||
|
|
7e9f7fa498 | ||
|
|
f51b55be6e | ||
|
|
584c7b7518 | ||
|
|
51c8900562 | ||
|
|
ab7aebb753 | ||
|
|
dc5ecfb576 | ||
|
|
04899ff676 | ||
|
|
4df8ce38d6 | ||
|
|
3e001c4cdf | ||
|
|
d5dea652ff | ||
|
|
2a4226527d | ||
|
|
6c9494970f | ||
|
|
c84f506af1 | ||
|
|
a0e31ed883 | ||
|
|
8befcb32d8 | ||
|
|
fb50a3db6d | ||
|
|
4daacd18e8 | ||
|
|
98681e8251 | ||
|
|
ea5d890992 | ||
|
|
f5135872cc | ||
|
|
5d736dd4b5 | ||
|
|
1b2a4dc260 | ||
|
|
855131d1aa | ||
|
|
581a2dddea | ||
|
|
a1b52eb7ac | ||
|
|
0ed371fdc1 | ||
|
|
ee7e57cf78 | ||
|
|
90ed224dd8 | ||
|
|
a65445e989 | ||
|
|
da79597a16 | ||
|
|
9c6102a813 | ||
|
|
573c5e4a20 | ||
|
|
12441cc379 | ||
|
|
7df6336b56 | ||
|
|
2dd69e08da | ||
|
|
67fbcf5cec | ||
|
|
f898831276 | ||
|
|
83042f45bd | ||
|
|
dc6d135699 | ||
|
|
f42496e04c | ||
|
|
f003d57ddf | ||
|
|
b64700b9fb | ||
|
|
f64af50a07 | ||
|
|
a8c8edaf20 | ||
|
|
5ebee1f1e0 | ||
|
|
1eb8db550f | ||
|
|
52a232f982 | ||
|
|
eeebc30b58 | ||
|
|
46bccadca2 | ||
|
|
d7f207177c | ||
|
|
339e30247a | ||
|
|
ba8d86789d | ||
|
|
a9f19cfc8d | ||
|
|
8b1400ef0d | ||
|
|
82c2e80e76 | ||
|
|
8146773354 | ||
|
|
5ac6aa1865 | ||
|
|
dab8e3dd22 | ||
|
|
fdceb08a2c | ||
|
|
ad846f37a2 | ||
|
|
b8ce13606b | ||
|
|
2fbd3965e0 | ||
|
|
a714670b9a | ||
|
|
c5460624e3 | ||
|
|
9f63a770c3 | ||
|
|
4d234762d2 | ||
|
|
730b565c59 | ||
|
|
4d12d70bf0 | ||
|
|
42adcb5b27 | ||
|
|
77ddcc8bf5 | ||
|
|
d46adaac5e | ||
|
|
a6666b53a1 | ||
|
|
958860ecce | ||
|
|
6fab945eb1 | ||
|
|
e19b9d860f | ||
|
|
7adb0f9ef7 | ||
|
|
1bb130bb87 | ||
|
|
779e25f837 | ||
|
|
3a2d8f9caf | ||
|
|
0c91fb3975 | ||
|
|
290cbb63d8 | ||
|
|
100e661ac5 | ||
|
|
c490631f2c | ||
|
|
c519d09be4 | ||
|
|
e5a31ae49e | ||
|
|
68615ba724 | ||
|
|
10e57fe349 | ||
|
|
9f70ad0159 | ||
|
|
0d5538a110 | ||
|
|
27efbbfeb0 | ||
|
|
7fad8c602d | ||
|
|
29a0952bc4 | ||
|
|
b7107b7172 | ||
|
|
2adbc25f69 | ||
|
|
3bee9281ec | ||
|
|
917f9f650b | ||
|
|
edf6e241e4 | ||
|
|
d2c65f00c9 | ||
|
|
95ee345441 | ||
|
|
3ade4867d4 | ||
|
|
2d1951774d | ||
|
|
cc3616a074 | ||
|
|
42c48c5c2e | ||
|
|
030daf12a2 | ||
|
|
88763d64ef | ||
|
|
4f2b5edf84 | ||
|
|
cbe07b9003 | ||
|
|
b2867a0dbf | ||
|
|
65dacd8527 | ||
|
|
d2d425e96e | ||
|
|
0762e3e339 | ||
|
|
4cb1e348bb | ||
|
|
7bbfd19bfd | ||
|
|
be8b80bd55 | ||
|
|
47de6d3a89 | ||
|
|
f78a3b2565 | ||
|
|
016249c6ca | ||
|
|
860edd2e1a | ||
|
|
3e6e444857 | ||
|
|
d67b7c6296 | ||
|
|
94f6044c9a | ||
|
|
6b3531964e | ||
|
|
fbd06f147a | ||
|
|
e3020dad00 | ||
|
|
49fb976a2c | ||
|
|
78bc4b5f7e | ||
|
|
7a3dc4f9c2 | ||
|
|
2087f7bb94 | ||
|
|
e95edb16ac | ||
|
|
3b07b5ccca | ||
|
|
a3fb3cd770 | ||
|
|
b7b59c0b85 | ||
|
|
db6b54732e | ||
|
|
09e3b81552 | ||
|
|
2f494d295e | ||
|
|
e8e3a72ae7 | ||
|
|
ca8bd4e83d | ||
|
|
d789119c8f | ||
|
|
bfd1b41ecc | ||
|
|
5807acb34a | ||
|
|
f319d535ae | ||
|
|
f669d095b6 | ||
|
|
ca8b0ba185 | ||
|
|
7acef4d987 | ||
|
|
79404f659c | ||
|
|
85c86ff375 | ||
|
|
f4030701ee | ||
|
|
a36eca2a53 | ||
|
|
6ffdf2aafb | ||
|
|
fba9f7ca28 | ||
|
|
2d157e3d5b | ||
|
|
055aef17db | ||
|
|
622e834d26 | ||
|
|
469c8b62a9 | ||
|
|
1558ec819a | ||
|
|
883e7b45fc | ||
|
|
f30d3319b0 | ||
|
|
58276a7a0c | ||
|
|
883fb39380 | ||
|
|
1358a99f51 | ||
|
|
47ea01dc39 | ||
|
|
ee36f2f42a | ||
|
|
5868a39adb | ||
|
|
f7e000cb82 | ||
|
|
c40bb38e20 | ||
|
|
4449ccdd45 | ||
|
|
67e56957e7 | ||
|
|
ea432f2405 | ||
|
|
eee978fc83 | ||
|
|
9698d4098a | ||
|
|
3f779c9028 | ||
|
|
3945599fb4 | ||
|
|
b50e6a934f | ||
|
|
3dbf812f50 | ||
|
|
2bb8da3ff9 | ||
|
|
1371e7685e | ||
|
|
a49fea706d | ||
|
|
32547481e7 | ||
|
|
faff465ace | ||
|
|
e487ab1147 | ||
|
|
e26bc85f46 | ||
|
|
7dc2c45600 | ||
|
|
d6281881a5 | ||
|
|
7cdd582ed4 | ||
|
|
129b50a6c2 | ||
|
|
eaf9c5f48f | ||
|
|
b7e5c59ecf | ||
|
|
05e98d6eee | ||
|
|
f4b7393b44 | ||
|
|
898a4fe7d9 | ||
|
|
5cbfb87d08 | ||
|
|
8cdabb762d | ||
|
|
4369ddf43e | ||
|
|
8a1dca0dd4 | ||
|
|
b533d33f71 | ||
|
|
bfaa97ba04 | ||
|
|
c86790371d | ||
|
|
ed4bf8dbb3 | ||
|
|
b97f838d59 | ||
|
|
79440740ee | ||
|
|
481b0d9df9 | ||
|
|
cdd42d60e3 | ||
|
|
76bf0b5fdf | ||
|
|
f1c1f2f39a | ||
|
|
3c4b1cc4e2 | ||
|
|
e2258b1540 | ||
|
|
d286e419c5 | ||
|
|
28eb5eb376 | ||
|
|
4d34720d1c | ||
|
|
b9456d599f | ||
|
|
0233b7e077 | ||
|
|
a917e67871 | ||
|
|
ea49e7489a | ||
|
|
bcf5dc4cea | ||
|
|
7e522011e7 | ||
|
|
bdead01ef9 | ||
|
|
87a40fc3c7 | ||
|
|
0d60fb328a | ||
|
|
2f141bd565 | ||
|
|
a7f52365ca | ||
|
|
10ec669589 | ||
|
|
f09fe38831 | ||
|
|
953748f2ae | ||
|
|
e63858d561 | ||
|
|
b2d6532709 | ||
|
|
d2db775a17 | ||
|
|
7cf42be31c | ||
|
|
9a85d18f22 | ||
|
|
5d366d1d8c | ||
|
|
8257d6dfd0 | ||
|
|
1c973e633b | ||
|
|
933244a492 | ||
|
|
e719e9cd4e | ||
|
|
25c864b11b | ||
|
|
d60d9d4c36 | ||
|
|
a2698b5b95 | ||
|
|
b14be41789 | ||
|
|
cf4487f4d3 | ||
|
|
23f301c819 | ||
|
|
958023382d | ||
|
|
037ef06379 | ||
|
|
ad8c356c46 | ||
|
|
c9181c411f | ||
|
|
164632c7be | ||
|
|
7af9df3177 | ||
|
|
37960965b4 | ||
|
|
10c0536dbe | ||
|
|
aaf23aa88a | ||
|
|
8bbb9b1ee9 | ||
|
|
8c1cfa330e | ||
|
|
ff83d7f709 | ||
|
|
e05ee65d19 | ||
|
|
9a39e38ba1 | ||
|
|
7a7b9418d3 | ||
|
|
b08122913b | ||
|
|
bbc355365a | ||
|
|
8bccab4f0b | ||
|
|
1d88a98040 | ||
|
|
7314a08268 | ||
|
|
5c12463c94 | ||
|
|
b34a5b3343 | ||
|
|
7654dc583d | ||
|
|
4e78285bbe | ||
|
|
fe8c556e35 | ||
|
|
ffbe66193d | ||
|
|
fccacc6f98 | ||
|
|
e27c3ecd68 | ||
|
|
11d7d53684 | ||
|
|
fa97359eeb | ||
|
|
1540ecfa8d | ||
|
|
b27654dfe9 | ||
|
|
db10725c31 | ||
|
|
946d6901ea | ||
|
|
3054cc6a13 | ||
|
|
8f73eed29d | ||
|
|
a16c4a7b44 | ||
|
|
fcb24315e5 | ||
|
|
47f198b337 | ||
|
|
a38aa9687c | ||
|
|
0857a80ca8 | ||
|
|
704f3a4102 | ||
|
|
4ebce88594 | ||
|
|
8fa3a567ac | ||
|
|
5a29416ee9 | ||
|
|
4142609635 | ||
|
|
1dbfa30ba8 | ||
|
|
199c5d674e | ||
|
|
bebbbb0050 | ||
|
|
03388e3f85 | ||
|
|
103cd4548d | ||
|
|
87aa82647a | ||
|
|
adbde5334d | ||
|
|
6d44d738a8 | ||
|
|
5f0c3b419c | ||
|
|
4fe495d7fa | ||
|
|
ae4eaeb4ba | ||
|
|
f9a36acf8f | ||
|
|
c6ea90867e | ||
|
|
e584c112df | ||
|
|
f59e58a15a | ||
|
|
be06bbb2ab | ||
|
|
7cbc4ac79e | ||
|
|
ce4d0b550a | ||
|
|
17c6bfad5f |
No files matched your search
@@ -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,124 @@
|
||||
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
|
||||
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,125 @@
|
||||
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
|
||||
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,201 @@
|
||||
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@v3
|
||||
-
|
||||
name: Set up JDK
|
||||
uses: actions/setup-java@v3
|
||||
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@v3
|
||||
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,Forge-Active,Forge-Legacy]
|
||||
include:
|
||||
-
|
||||
website: TencentCOS
|
||||
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@v3
|
||||
-
|
||||
uses: actions/download-artifact@v3
|
||||
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")"
|
||||
if [[ "${{ matrix.modtype }}" == "Forge"* ]]; then
|
||||
modloader="Forge"
|
||||
path=$(echo ${{ matrix.modtype }} | sed "s#-#/#")
|
||||
else
|
||||
modloader=${{ matrix.modtype }}
|
||||
path=${{ matrix.modtype }}
|
||||
fi
|
||||
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
|
||||
echo "$(grep "minecraft_full_versions=" "$path"/build.properties | grep -v "#" | sed "s/minecraft_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@v1
|
||||
with:
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
name: CustomSkinLoader CI-Build
|
||||
tag_name: CI-Build
|
||||
prerelease: true
|
||||
body_path: build/ci-build.md
|
||||
files: build/libs/*
|
||||
#iles: "${{ 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 == 'TencentCOS' }}
|
||||
name: 【TencentCOS】 Publish
|
||||
env:
|
||||
COS_BUCKET: ${{ secrets.COS_BUCKET }}
|
||||
COS_SECRET_ID: ${{ secrets.COS_SECRET_ID }}
|
||||
COS_SECRET_KEY: ${{ secrets.COS_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 }}
|
||||
version-type: release
|
||||
loaders: ${{ steps.cslenv.outputs.modloader }}
|
||||
game-versions: |
|
||||
${{ steps.cslenv.outputs.minecraft_vers }}
|
||||
game-version-filter: releases
|
||||
java: 8 11 17
|
||||
|
||||
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
|
||||
+29
-5
@@ -1,12 +1,36 @@
|
||||
# Java
|
||||
*.class
|
||||
|
||||
# Mobile Tools for Java (J2ME)
|
||||
.mtj.tmp/
|
||||
|
||||
# Package Files #
|
||||
*.jar
|
||||
*.war
|
||||
*.ear
|
||||
|
||||
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
|
||||
hs_err_pid*
|
||||
|
||||
# VSCode
|
||||
.vscode/
|
||||
|
||||
# eclipse
|
||||
bin/
|
||||
*/.classpath
|
||||
.classpath
|
||||
*/.project
|
||||
.project
|
||||
.settings/
|
||||
*.launch
|
||||
|
||||
# gradle
|
||||
.gradle/
|
||||
build/
|
||||
logs/
|
||||
run/
|
||||
|
||||
# IDEA
|
||||
.idea/
|
||||
*.iml
|
||||
*.ipr
|
||||
*.iws
|
||||
out/
|
||||
|
||||
#mac OS
|
||||
.DS_Store
|
||||
@@ -1,357 +0,0 @@
|
||||
package idv.jlchntoz;
|
||||
|
||||
import net.minecraft.src.Minecraft;
|
||||
|
||||
import java.io.*;
|
||||
import java.math.BigInteger;
|
||||
import java.net.*;
|
||||
import java.nio.MappedByteBuffer;
|
||||
import java.nio.channels.FileChannel;
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.util.HashMap;
|
||||
import java.util.logging.*;
|
||||
import java.util.regex.*;
|
||||
|
||||
/**
|
||||
* Custom skin loader mod for Minecraft.
|
||||
*
|
||||
* @version 12th Revision 9th Subversion 2016.2.10
|
||||
*
|
||||
* @author (C) Jeremy Lam [JLChnToZ] 2013 & Alexander Xia [xfl03] 2014-2016
|
||||
*/
|
||||
public class CustomSkinLoader {
|
||||
public final static String VERSION="12.9";
|
||||
|
||||
public final static String DefaultSkinURL = "http://skins.minecraft.net/MinecraftSkins/*.png";
|
||||
public final static String DefaultCloakURL = "http://skins.minecraft.net/MinecraftCloaks/*.png";
|
||||
|
||||
private final static Pattern newResPattern = Pattern.compile("^http://textures.minecraft.net/texture/(.*?)?(Skin|Cloak)=(.*?)$"),
|
||||
newURLPattern = Pattern.compile("^http://skins.minecraft.net/Minecraft(Skin|Cloak)s/(.*?).png$"),
|
||||
oldURLPattern = Pattern.compile("^http://s3.amazonaws.com/Minecraft(Skin|Cloak)s/(.*?).png$"),
|
||||
optifineCapeURLPattern = Pattern.compile("^http://s.optifine.net/capes/(.*?).png$");
|
||||
|
||||
public final static File DATA_DIR=new File(Minecraft.getMinecraft().mcDataDir,"CustomSkinLoader"),
|
||||
CACHE_DIR=new File(DATA_DIR,"caches"),
|
||||
LOG_FILE=new File(DATA_DIR,"CustomSkinLoader.log"),
|
||||
SKIN_URL_FILE=new File(DATA_DIR,"skinurls.txt"),
|
||||
CAPE_URL_FILE=new File(DATA_DIR,"capeurls.txt");
|
||||
public final static MainLogger logger = getLogger(LOG_FILE);
|
||||
|
||||
public final static String[] DEFAULT_SKIN_URLS={
|
||||
"http://skins.minecraft.net/MinecraftSkins/*.png",
|
||||
"http://minecrack.fr.nf/mc/skinsminecrackd/*.png",
|
||||
"http://www.skinme.cc/MinecraftSkins/*.png"};
|
||||
public final static String[] DEFAULT_CAPE_URLS={
|
||||
"http://skins.minecraft.net/MinecraftCloaks/*.png",
|
||||
"http://s.optifine.net/capes/*.png",
|
||||
"http://minecrack.fr.nf/mc/cloaksminecrackd/*.png",
|
||||
"http://www.skinme.cc/MinecraftCloaks/*.png"};
|
||||
|
||||
private static String[] cloakURLs = null, skinURLs = null;
|
||||
private HttpURLConnection C = null;
|
||||
|
||||
//Entrance
|
||||
public InputStream getPlayerSkinStream(String path) {
|
||||
if(!DATA_DIR.exists())
|
||||
DATA_DIR.mkdir();
|
||||
if(!CACHE_DIR.exists())
|
||||
CACHE_DIR.mkdir();
|
||||
logger.info("Get a request: "+path);
|
||||
if(path.contains("NOCSL"))//Not to use CSL to load, prepared for json api
|
||||
return getStream(path, false);
|
||||
Matcher m = newURLPattern.matcher(path);
|
||||
if (!m.matches())//Is not new url
|
||||
{
|
||||
m = oldURLPattern.matcher(path);//May be old url
|
||||
}
|
||||
if (m.matches()) {
|
||||
if (m.group(1).contains("Skin")) // Skin
|
||||
return getPlayerSkinStream(false, m.group(2));
|
||||
else if (m.group(1).contains("Cloak")) // Cloak
|
||||
return getPlayerSkinStream(true, m.group(2));
|
||||
}else{
|
||||
m = newResPattern.matcher(path);
|
||||
if(m.matches()){
|
||||
if (m.group(2).contains("Skin")) // Skin
|
||||
return getPlayerSkinStream(false, m.group(3));
|
||||
else if (m.group(2).contains("Cloak")) // Cloak
|
||||
return getPlayerSkinStream(true, m.group(3));
|
||||
}else{
|
||||
m = optifineCapeURLPattern.matcher(path);
|
||||
if(m.matches()){//Optifine Cape
|
||||
logger.info("Ignore Optifine Cape.");
|
||||
return null;//Not Load This
|
||||
}
|
||||
}
|
||||
}
|
||||
return getStream(path, false); // Neither skin nor cloak...
|
||||
}
|
||||
|
||||
public InputStream getPlayerSkinStream(Boolean isCloak, String playerName) {
|
||||
if ((skinURLs == null|| skinURLs.length <= 0) && (cloakURLs == null || cloakURLs.length <= 0))
|
||||
refreshSkinURL(); // If the list is blank or null, try to load again.
|
||||
InputStream S=null;
|
||||
|
||||
for (String l : isCloak ? cloakURLs : skinURLs) {
|
||||
if(l==null||l.equalsIgnoreCase(""))
|
||||
continue;
|
||||
String loc = str_replace("*", playerName, l);
|
||||
logger.log(Level.INFO, "Try to load " + (isCloak ? "cloak" : "skin") + " in " + loc);
|
||||
S = getStream(loc, true);
|
||||
|
||||
if (S == null){
|
||||
logger.log(Level.INFO, "No " + (isCloak ? "cloak" : "skin") + " found in " + loc);
|
||||
}else{
|
||||
logger.info("Succeessfully load " + (isCloak ? "cloak" : "skin") + " in " + loc);
|
||||
return S;
|
||||
}
|
||||
}
|
||||
|
||||
logger.log(Level.INFO, "Try to load skin in default URL instead.");
|
||||
return getStream(str_replace("*", playerName, isCloak ? DefaultCloakURL : DefaultSkinURL), true);
|
||||
}
|
||||
|
||||
private InputStream getStream(String URL, Boolean CheckPNG) {
|
||||
boolean success=false;
|
||||
File cacheFile=new File(CACHE_DIR,MD5(URL));
|
||||
boolean alreadyCached=false;
|
||||
if(cacheFile.exists()&&cacheFile.length()>1){
|
||||
alreadyCached=true;
|
||||
logger.info("Cache File Found (LastModified: "+cacheFile.lastModified()+" , Size: "+cacheFile.length()+")");
|
||||
}
|
||||
try {
|
||||
URL U = new URL(URL);
|
||||
C = (HttpURLConnection) U.openConnection();
|
||||
C.setReadTimeout(15000);
|
||||
C.setDoInput(true);
|
||||
C.setDoOutput(false);
|
||||
C.connect();
|
||||
logger.info("Response Code: "+C.getResponseCode());
|
||||
int respcode = C.getResponseCode() / 100;
|
||||
if (respcode != 4 && respcode != 5) { // Successful to get skin.
|
||||
if(C.getContentLength()<=0){//Nothing got
|
||||
logger.info("Nothing got.");
|
||||
return null;
|
||||
}
|
||||
logger.info("Successfully Get Resource (LastModified: "+C.getLastModified()+" , ContentLength: "+C.getContentLength()+")");
|
||||
if(alreadyCached && C.getLastModified()==cacheFile.lastModified() && C.getContentLength()==cacheFile.length()){
|
||||
logger.info("Not Modified.");
|
||||
return getStreamFromCache(cacheFile);
|
||||
}
|
||||
InputStream IS=new BufferedInputStream(C.getInputStream());
|
||||
if (!CheckPNG){ // If no need to check PNG header, just skip it.
|
||||
success=true;
|
||||
saveToCache(IS,cacheFile);
|
||||
return IS;
|
||||
}
|
||||
//logger.info(C.getContentLength()+" "+IS.available());
|
||||
IS.mark(C.getContentLength()+10);
|
||||
byte[] ib = new byte[4];
|
||||
IS.read(ib);
|
||||
if (ib[1] == (byte) 'P' && ib[2] == (byte) 'N' && ib[3] == (byte) 'G') { // Check PNG Header if needed
|
||||
IS.reset();
|
||||
success=true;
|
||||
saveToCache(IS,cacheFile);
|
||||
return IS;
|
||||
}
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
success=false;
|
||||
logger.log(Level.WARNING, ex.getMessage());
|
||||
if(alreadyCached)
|
||||
return getStreamFromCache(cacheFile);
|
||||
}finally{
|
||||
if(!success)
|
||||
disconnect();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
private InputStream getStreamFromCache(File cacheFile) {
|
||||
try{
|
||||
logger.info("Try load local cache in " + cacheFile.getAbsolutePath());
|
||||
InputStream in = new FileInputStream(cacheFile);
|
||||
BufferedInputStream bis=new BufferedInputStream(in);
|
||||
if(bis.available()<=0){
|
||||
logger.info("Cannot load local cache in " + cacheFile.getAbsolutePath());
|
||||
return null;
|
||||
}else{
|
||||
logger.info("Successfully load cache in " + cacheFile.getAbsolutePath());
|
||||
return bis;
|
||||
}
|
||||
}catch(Exception e){
|
||||
logger.log(Level.WARNING, e.getMessage());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
private void saveToCache(InputStream is,File to){
|
||||
logger.info("Try save local cache to " + to.getAbsolutePath());
|
||||
FileOutputStream fs=null;
|
||||
int times=0;
|
||||
try{//Save to Local Skin File
|
||||
if(to.exists()){
|
||||
to.delete();
|
||||
}
|
||||
fs = new FileOutputStream(to);
|
||||
int byteRead = 0;
|
||||
byte[] buffer = new byte[1024];
|
||||
while (( byteRead = is.read(buffer)) != -1) {
|
||||
times+=byteRead;
|
||||
fs.write(buffer, 0, byteRead);
|
||||
if(times>=C.getContentLength()){
|
||||
//logger.info(times+" "+C.getContentLength());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(to.length()>1){
|
||||
to.setLastModified(C.getLastModified());
|
||||
logger.info("Cache saved to " + to.getAbsolutePath()+" (LastModified: "+to.lastModified()+" , Size: "+to.length()+")");
|
||||
}else{
|
||||
to.delete();
|
||||
logger.info("Cannot save local cache to " + to.getAbsolutePath());
|
||||
}
|
||||
}catch(Exception e){
|
||||
logger.warning(e.getMessage());
|
||||
}finally{
|
||||
try {
|
||||
if(fs!=null)
|
||||
fs.close();
|
||||
is.reset();
|
||||
} catch (IOException e) {
|
||||
logger.warning(e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void disconnect() {
|
||||
if (C != null)
|
||||
C.disconnect();
|
||||
}
|
||||
|
||||
private static void refreshSkinURL() {
|
||||
try {
|
||||
if(!SKIN_URL_FILE.exists()){
|
||||
logger.log(Level.INFO, "SKIN config not found, create a new one.");
|
||||
SKIN_URL_FILE.createNewFile();
|
||||
}
|
||||
if(!CAPE_URL_FILE.exists()){
|
||||
logger.log(Level.INFO, "CAPE config not found, create a new one.");
|
||||
CAPE_URL_FILE.createNewFile();
|
||||
}
|
||||
skinURLs = readAllLines(SKIN_URL_FILE);
|
||||
cloakURLs = readAllLines(CAPE_URL_FILE);
|
||||
} catch (Exception ex) {
|
||||
logger.log(Level.WARNING, ex.getMessage());
|
||||
} finally {
|
||||
if(skinURLs.length==0&&cloakURLs.length==0){
|
||||
logger.info("No skinURLs and cloak URLS found, try to init and use default settings.");
|
||||
initSkinURL();
|
||||
refreshSkinURL();
|
||||
}else{
|
||||
logger.log(Level.INFO, "Skin URLs Refreshed. Skin count = "
|
||||
+ skinURLs.length + ", Cloak count = " + cloakURLs.length);
|
||||
}
|
||||
}
|
||||
}
|
||||
private static void initSkinURL(){
|
||||
//Init URL List
|
||||
skinURLs=DEFAULT_SKIN_URLS;
|
||||
writeToFile(new File(DATA_DIR,"skinurls.txt"),parseArrayToText(skinURLs));
|
||||
cloakURLs=DEFAULT_CAPE_URLS;
|
||||
writeToFile(new File(DATA_DIR,"capeurls.txt"),parseArrayToText(cloakURLs));
|
||||
}
|
||||
|
||||
private static String[] readAllLines(File F) {
|
||||
try {
|
||||
logger.log(Level.INFO, "Config file: " + F.getAbsolutePath());
|
||||
if (F.length() <= 0) {
|
||||
logger.log(Level.INFO, "Config file is blank, skipped.");
|
||||
return new String[0];
|
||||
} else {
|
||||
byte[] b = new byte[(int) F.length()];
|
||||
BufferedInputStream S = new BufferedInputStream(
|
||||
new FileInputStream(F));
|
||||
S.read(b);
|
||||
S.close();
|
||||
logger.log(Level.INFO, "Config file loaded.");
|
||||
String[] re= str_replace("\r", "\n",
|
||||
str_replace("\r\n", "\n", new String(b))).split("\n");
|
||||
for(int i=0;i<re.length;i++){
|
||||
if(re[i].startsWith("#"))//Remove note
|
||||
re[i]=null;
|
||||
else{//Remove same URL
|
||||
for(int g=0;g<re.length;g++){
|
||||
if(i==g)
|
||||
continue;
|
||||
if(re[i].equalsIgnoreCase(re[g])){
|
||||
re[i]=null;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return re;
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
logger.log(Level.WARNING, ex.getMessage());
|
||||
return new String[0];
|
||||
}
|
||||
}
|
||||
|
||||
private static String str_replace(String search, String replace,
|
||||
String subject) {
|
||||
StringBuffer result = new StringBuffer(subject);
|
||||
int pos;
|
||||
while ((pos = result.indexOf(search)) != -1)
|
||||
result.replace(pos, pos + search.length(), replace);
|
||||
return result.toString();
|
||||
}
|
||||
private static String parseArrayToText(String[] data){
|
||||
StringBuilder temp=new StringBuilder();
|
||||
for(int i=0;i<data.length-1;i++)
|
||||
temp.append(data[i]).append("\r\n");
|
||||
temp.append(data[data.length-1]);
|
||||
return temp.toString();
|
||||
}
|
||||
private static boolean writeToFile(File file,String Data){
|
||||
System.out.print("Write to "+file.getAbsolutePath()+" ");
|
||||
FileWriter fw=null;
|
||||
try{
|
||||
fw = new FileWriter(file);
|
||||
fw.write(Data,0,Data.length());
|
||||
fw.flush();
|
||||
fw.close();
|
||||
}catch(Exception ex){
|
||||
ex.printStackTrace();
|
||||
System.out.println("failed.");
|
||||
return false;
|
||||
}
|
||||
System.out.println("succeed.");
|
||||
return true;
|
||||
}
|
||||
|
||||
public String MD5(String str){
|
||||
byte [] buf = str.getBytes();
|
||||
MessageDigest md5;
|
||||
try {
|
||||
md5 = MessageDigest.getInstance("MD5");
|
||||
md5.update(buf);
|
||||
byte [] tmp = md5.digest();
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (byte b:tmp) {
|
||||
sb.append(Integer.toHexString(b&0xff));
|
||||
}
|
||||
return sb.toString();
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
logger.warning(e.getMessage());
|
||||
}
|
||||
return "Fail";
|
||||
}
|
||||
|
||||
private static MainLogger getLogger(File logFile){
|
||||
MainLogger mainLogger = new MainLogger(logFile);
|
||||
mainLogger.info("CustomSkinLoader " + VERSION);
|
||||
return mainLogger;
|
||||
}
|
||||
}
|
||||
@@ -1,71 +0,0 @@
|
||||
package idv.jlchntoz;
|
||||
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class MainLogger {
|
||||
private static final int LOWEST_DISPLAY_LEVEL=Level.INFO.intValue();
|
||||
SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
private BufferedWriter writer;
|
||||
public MainLogger(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"));
|
||||
} 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.intValue()>=LOWEST_DISPLAY_LEVEL)
|
||||
System.out.println(msg);
|
||||
try {
|
||||
writer.write("[");
|
||||
writer.write(DATE_FORMAT.format(new Date()));
|
||||
writer.write(" ");
|
||||
writer.write(Thread.currentThread().getName());
|
||||
writer.write(" ");
|
||||
writer.write(level.getName());
|
||||
writer.write("] ");
|
||||
writer.write(msg);
|
||||
writer.write("\r\n");
|
||||
writer.flush();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
public void info(String msg){
|
||||
log(Level.INFO,msg);
|
||||
}
|
||||
public void warning(String msg){
|
||||
log(Level.WARNING,msg);
|
||||
}
|
||||
public void warning(Exception e){
|
||||
log(Level.WARNING,"Exception occurs while running: "+e.getMessage());
|
||||
StackTraceElement[] stes=e.getStackTrace();
|
||||
for(StackTraceElement ste : stes){
|
||||
log(Level.WARNING,ste.toString());
|
||||
}
|
||||
log(Level.WARNING,"");
|
||||
}
|
||||
}
|
||||
@@ -1,98 +0,0 @@
|
||||
package net.minecraft.src;
|
||||
|
||||
import java.awt.Graphics;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.awt.image.DataBufferInt;
|
||||
import java.awt.image.ImageObserver;
|
||||
|
||||
public class ImageBufferDownload implements IImageBuffer
|
||||
{
|
||||
private int[] imageData;
|
||||
private int imageWidth;
|
||||
private int imageHeight;
|
||||
|
||||
public BufferedImage parseUserSkin(BufferedImage par1BufferedImage)
|
||||
{
|
||||
if (par1BufferedImage == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.imageWidth = par1BufferedImage.getWidth();//Default: 64
|
||||
this.imageHeight = par1BufferedImage.getHeight();//Default: 32
|
||||
BufferedImage var2 = new BufferedImage(this.imageWidth, this.imageWidth / 2, 2);
|
||||
Graphics var3 = var2.getGraphics();
|
||||
if(imageWidth == imageHeight){
|
||||
var3.drawImage(par1BufferedImage, 0, 0, this.imageWidth, this.imageWidth / 2, 0, 0, this.imageWidth, this.imageWidth / 2, (ImageObserver)null);
|
||||
var3.drawImage(par1BufferedImage, 0, this.imageWidth / 4, this.imageWidth, this.imageWidth / 2, 0, this.imageWidth / 2 , this.imageWidth, this.imageWidth / 4 * 3, (ImageObserver)null);
|
||||
imageHeight/=2;
|
||||
}else{
|
||||
var3.drawImage(par1BufferedImage, 0, 0, (ImageObserver)null);
|
||||
}
|
||||
var3.dispose();
|
||||
this.imageData = ((DataBufferInt)var2.getRaster().getDataBuffer()).getData();
|
||||
//this.setAreaOpaque(0, 0, 32, 16);
|
||||
//this.setAreaTransparent(32, 0, 64, 32);
|
||||
//this.setAreaOpaque(0, 16, 64, 32);
|
||||
this.setAreaOpaque(0, 0, imageWidth / 2, imageHeight / 2);
|
||||
this.setAreaTransparent(imageWidth / 2, 0, imageWidth, imageHeight);
|
||||
this.setAreaOpaque(0, imageHeight / 2, imageWidth, imageHeight);
|
||||
return var2;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes the given area of the image transparent if it was previously completely opaque (used to remove the outer
|
||||
* layer of a skin around the head if it was saved all opaque; this would be redundant so it's assumed that the skin
|
||||
* maker is just using an image editor without an alpha channel)
|
||||
*/
|
||||
private void setAreaTransparent(int par1, int par2, int par3, int par4)
|
||||
{
|
||||
if (!this.hasTransparency(par1, par2, par3, par4))
|
||||
{
|
||||
for (int var5 = par1; var5 < par3; ++var5)
|
||||
{
|
||||
for (int var6 = par2; var6 < par4; ++var6)
|
||||
{
|
||||
this.imageData[var5 + var6 * this.imageWidth] &= 16777215;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes the given area of the image opaque
|
||||
*/
|
||||
private void setAreaOpaque(int par1, int par2, int par3, int par4)
|
||||
{
|
||||
for (int var5 = par1; var5 < par3; ++var5)
|
||||
{
|
||||
for (int var6 = par2; var6 < par4; ++var6)
|
||||
{
|
||||
this.imageData[var5 + var6 * this.imageWidth] |= -16777216;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the given area of the image contains transparent pixels
|
||||
*/
|
||||
private boolean hasTransparency(int par1, int par2, int par3, int par4)
|
||||
{
|
||||
for (int var5 = par1; var5 < par3; ++var5)
|
||||
{
|
||||
for (int var6 = par2; var6 < par4; ++var6)
|
||||
{
|
||||
int var7 = this.imageData[var5 + var6 * this.imageWidth];
|
||||
|
||||
if ((var7 >> 24 & 255) < 128)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -1,81 +0,0 @@
|
||||
package net.minecraft.src;
|
||||
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.IOException;
|
||||
|
||||
public class ThreadDownloadImageData extends AbstractTexture
|
||||
{
|
||||
private final String imageUrl;
|
||||
private final IImageBuffer imageBuffer;
|
||||
private BufferedImage bufferedImage;
|
||||
private Thread imageThread;
|
||||
private SimpleTexture imageLocation;
|
||||
private boolean textureUploaded;
|
||||
|
||||
public boolean enabled;//For Optifine
|
||||
|
||||
public ThreadDownloadImageData(String par1Str, ResourceLocation par2ResourceLocation, IImageBuffer par3IImageBuffer)
|
||||
{
|
||||
this.imageUrl = par1Str;
|
||||
this.imageBuffer = par3IImageBuffer;
|
||||
this.imageLocation = par2ResourceLocation != null ? new SimpleTexture(par2ResourceLocation) : null;
|
||||
}
|
||||
|
||||
public int getGlTextureId()
|
||||
{
|
||||
int var1 = super.getGlTextureId();
|
||||
|
||||
if (!this.textureUploaded && this.bufferedImage != null)
|
||||
{
|
||||
TextureUtil.uploadTextureImage(var1, this.bufferedImage);
|
||||
this.textureUploaded = true;
|
||||
}
|
||||
|
||||
return var1;
|
||||
}
|
||||
|
||||
public void getBufferedImage(BufferedImage par1BufferedImage)
|
||||
{
|
||||
this.bufferedImage = par1BufferedImage;
|
||||
}
|
||||
|
||||
public void loadTexture(ResourceManager par1ResourceManager) throws IOException
|
||||
{
|
||||
if (this.bufferedImage == null)
|
||||
{
|
||||
if (this.imageLocation != null)
|
||||
{
|
||||
this.imageLocation.loadTexture(par1ResourceManager);
|
||||
this.glTextureId = this.imageLocation.getGlTextureId();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
TextureUtil.uploadTextureImage(this.getGlTextureId(), this.bufferedImage);
|
||||
}
|
||||
|
||||
if (this.imageThread == null)
|
||||
{
|
||||
this.imageThread = new ThreadDownloadImageDataINNER1(this);
|
||||
this.imageThread.setDaemon(true);
|
||||
//this.imageThread.setName("Skin downloader: " + this.imageUrl);
|
||||
this.imageThread.start();
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isTextureUploaded()
|
||||
{
|
||||
this.getGlTextureId();
|
||||
return this.textureUploaded;
|
||||
}
|
||||
|
||||
static String getImageUrl(ThreadDownloadImageData par0ThreadDownloadImageData)
|
||||
{
|
||||
return par0ThreadDownloadImageData.imageUrl;
|
||||
}
|
||||
|
||||
static IImageBuffer getImageBuffer(ThreadDownloadImageData par0ThreadDownloadImageData)
|
||||
{
|
||||
return par0ThreadDownloadImageData.imageBuffer;
|
||||
}
|
||||
}
|
||||
@@ -1,63 +0,0 @@
|
||||
package net.minecraft.src;
|
||||
|
||||
import idv.jlchntoz.CustomSkinLoader;
|
||||
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.InputStream;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import javax.imageio.ImageIO;
|
||||
|
||||
class ThreadDownloadImageDataINNER1 extends Thread
|
||||
{
|
||||
final ThreadDownloadImageData theThreadDownloadImageData;
|
||||
|
||||
ThreadDownloadImageDataINNER1(ThreadDownloadImageData par1ThreadDownloadImageData)
|
||||
{
|
||||
this.theThreadDownloadImageData = par1ThreadDownloadImageData;
|
||||
}
|
||||
|
||||
public void run()
|
||||
{
|
||||
|
||||
//HttpURLConnection var1 = null;
|
||||
CustomSkinLoader loader=new CustomSkinLoader();
|
||||
try
|
||||
{
|
||||
/*
|
||||
var1 = (HttpURLConnection)(new URL(ThreadDownloadImageData.getImageUrl(this.theThreadDownloadImageData))).openConnection(Minecraft.getMinecraft().getProxy());
|
||||
var1.setDoInput(true);
|
||||
var1.setDoOutput(false);
|
||||
var1.connect();
|
||||
|
||||
if (var1.getResponseCode() / 100 != 2)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
BufferedImage var2 = ImageIO.read(var1.getInputStream());
|
||||
*/
|
||||
BufferedImage var2 = ImageIO.read(loader.getPlayerSkinStream(
|
||||
ThreadDownloadImageData.getImageUrl(this.theThreadDownloadImageData)));
|
||||
if (ThreadDownloadImageData.getImageBuffer(this.theThreadDownloadImageData) != null)
|
||||
{
|
||||
var2 = ThreadDownloadImageData.getImageBuffer(this.theThreadDownloadImageData).parseUserSkin(var2);
|
||||
}
|
||||
|
||||
this.theThreadDownloadImageData.getBufferedImage(var2);
|
||||
}
|
||||
catch (Exception var6)
|
||||
{
|
||||
var6.printStackTrace();
|
||||
}
|
||||
finally
|
||||
{
|
||||
/*
|
||||
if (var1 != null)
|
||||
{
|
||||
var1.disconnect();
|
||||
}*/
|
||||
loader.disconnect();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,359 +0,0 @@
|
||||
package idv.jlchntoz;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
|
||||
import java.io.*;
|
||||
import java.math.BigInteger;
|
||||
import java.net.*;
|
||||
import java.nio.MappedByteBuffer;
|
||||
import java.nio.channels.FileChannel;
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.util.HashMap;
|
||||
import java.util.logging.*;
|
||||
import java.util.regex.*;
|
||||
|
||||
/**
|
||||
* Custom skin loader mod for Minecraft.
|
||||
*
|
||||
* @version 12th Revision 8th Subversion 2016.2.3
|
||||
*
|
||||
* @author (C) Jeremy Lam [JLChnToZ] 2013 & Alexander Xia [xfl03] 2014-2016
|
||||
*/
|
||||
public class CustomSkinLoader {
|
||||
public final static String VERSION="12.8";
|
||||
|
||||
public final static String DefaultSkinURL = "http://skins.minecraft.net/MinecraftSkins/*.png";
|
||||
public final static String DefaultCloakURL = "http://skins.minecraft.net/MinecraftCloaks/*.png";
|
||||
|
||||
private final static Pattern newResPattern = Pattern.compile("^http://textures.minecraft.net/texture/(.*?)?(Skin|Cloak)=(.*?)$"),
|
||||
newURLPattern = Pattern.compile("^http://skins.minecraft.net/Minecraft(Skin|Cloak)s/(.*?).png$"),
|
||||
oldURLPattern = Pattern.compile("^http://s3.amazonaws.com/Minecraft(Skin|Cloak)s/(.*?).png$"),
|
||||
optifineCapeURLPattern = Pattern.compile("^http://s.optifine.net/capes/(.*?).png$");
|
||||
|
||||
public final static File DATA_DIR=new File(Minecraft.getMinecraft().mcDataDir,"CustomSkinLoader"),
|
||||
CACHE_DIR=new File(DATA_DIR,"caches"),
|
||||
LOG_FILE=new File(DATA_DIR,"CustomSkinLoader.log"),
|
||||
SKIN_URL_FILE=new File(DATA_DIR,"skinurls.txt"),
|
||||
CAPE_URL_FILE=new File(DATA_DIR,"capeurls.txt");
|
||||
public final static MainLogger logger = getLogger(LOG_FILE);
|
||||
|
||||
public final static String[] DEFAULT_SKIN_URLS={
|
||||
"http://skins.minecraft.net/MinecraftSkins/*.png",
|
||||
"http://minecrack.fr.nf/mc/skinsminecrackd/*.png",
|
||||
"http://www.skinme.cc/MinecraftSkins/*.png"};
|
||||
public final static String[] DEFAULT_CAPE_URLS={
|
||||
"http://skins.minecraft.net/MinecraftCloaks/*.png",
|
||||
"http://s.optifine.net/capes/*.png",
|
||||
"http://minecrack.fr.nf/mc/cloaksminecrackd/*.png",
|
||||
"http://www.skinme.cc/MinecraftCloaks/*.png"};
|
||||
|
||||
private static String[] cloakURLs = null, skinURLs = null;
|
||||
private HttpURLConnection C = null;
|
||||
|
||||
//Entrance
|
||||
public InputStream getPlayerSkinStream(String path) {
|
||||
if(!DATA_DIR.exists())
|
||||
DATA_DIR.mkdir();
|
||||
if(!CACHE_DIR.exists())
|
||||
CACHE_DIR.mkdir();
|
||||
logger.info("Get a request: "+path);
|
||||
if(path.contains("NOCSL"))//Not to use CSL to load, prepared for json api
|
||||
return getStream(path, false);
|
||||
Matcher m = newURLPattern.matcher(path);
|
||||
if (!m.matches())//Is not new url
|
||||
{
|
||||
m = oldURLPattern.matcher(path);//May be old url
|
||||
}
|
||||
if (m.matches()) {
|
||||
if (m.group(1).contains("Skin")) // Skin
|
||||
return getPlayerSkinStream(false, m.group(2));
|
||||
else if (m.group(1).contains("Cloak")) // Cloak
|
||||
return getPlayerSkinStream(true, m.group(2));
|
||||
}else{
|
||||
m = newResPattern.matcher(path);
|
||||
if(m.matches()){
|
||||
if (m.group(2).contains("Skin")) // Skin
|
||||
return getPlayerSkinStream(false, m.group(3));
|
||||
else if (m.group(2).contains("Cloak")) // Cloak
|
||||
return getPlayerSkinStream(true, m.group(3));
|
||||
}else{
|
||||
m = optifineCapeURLPattern.matcher(path);
|
||||
if(m.matches()){//Optifine Cape
|
||||
logger.info("Ignore Optifine Cape.");
|
||||
return null;//Not Load This
|
||||
}
|
||||
}
|
||||
}
|
||||
return getStream(path, false); // Neither skin nor cloak...
|
||||
}
|
||||
|
||||
public InputStream getPlayerSkinStream(Boolean isCloak, String playerName) {
|
||||
if (skinURLs == null || cloakURLs == null || skinURLs.length <= 0
|
||||
|| cloakURLs.length <= 0)
|
||||
refreshSkinURL(); // If the list is blank or null, try to load again.
|
||||
InputStream S=null;
|
||||
|
||||
for (String l : isCloak ? cloakURLs : skinURLs) {
|
||||
if(l==null||l.equalsIgnoreCase(""))
|
||||
continue;
|
||||
String loc = str_replace("*", playerName, l);
|
||||
logger.log(Level.INFO, "Try to load " + (isCloak ? "cloak" : "skin") + " in " + loc);
|
||||
S = getStream(loc, true);
|
||||
|
||||
if (S == null){
|
||||
logger.log(Level.INFO, "No " + (isCloak ? "cloak" : "skin") + " found in " + loc);
|
||||
}else{
|
||||
logger.info("Succeessfully load " + (isCloak ? "cloak" : "skin") + " in " + loc);
|
||||
return S;
|
||||
}
|
||||
}
|
||||
|
||||
logger.log(Level.INFO, "Try to load skin in default URL instead.");
|
||||
return getStream(str_replace("*", playerName, isCloak ? DefaultCloakURL : DefaultSkinURL), true);
|
||||
}
|
||||
|
||||
private InputStream getStream(String URL, Boolean CheckPNG) {
|
||||
boolean success=false;
|
||||
File cacheFile=new File(CACHE_DIR,MD5(URL));
|
||||
boolean alreadyCached=false;
|
||||
if(cacheFile.exists()&&cacheFile.length()>1){
|
||||
alreadyCached=true;
|
||||
logger.info("Cache File Found");
|
||||
}
|
||||
try {
|
||||
URL U = new URL(URL);
|
||||
C = (HttpURLConnection) U.openConnection();
|
||||
C.setReadTimeout(15000);
|
||||
C.setDoInput(true);
|
||||
C.setDoOutput(false);
|
||||
C.connect();
|
||||
logger.info("Response Code: "+C.getResponseCode());
|
||||
int respcode = C.getResponseCode() / 100;
|
||||
if (respcode != 4 && respcode != 5) { // Successful to get skin.
|
||||
if(alreadyCached && C.getLastModified()==cacheFile.lastModified()){
|
||||
logger.info("Not Modified!");
|
||||
return getStreamFromCache(cacheFile);
|
||||
}
|
||||
if(C.getContentLength()<=0){//Nothing to get
|
||||
return null;
|
||||
}
|
||||
InputStream IS=new BufferedInputStream(C.getInputStream());
|
||||
if (!CheckPNG){ // If no need to check PNG header, just skip it.
|
||||
success=true;
|
||||
saveToCache(IS,cacheFile);
|
||||
return IS;
|
||||
}
|
||||
//logger.info(C.getContentLength()+" "+IS.available());
|
||||
IS.mark(C.getContentLength()+10);
|
||||
byte[] ib = new byte[4];
|
||||
IS.read(ib);
|
||||
if (ib[1] == (byte) 'P' && ib[2] == (byte) 'N' && ib[3] == (byte) 'G') { // Check PNG Header if needed
|
||||
IS.reset();
|
||||
success=true;
|
||||
saveToCache(IS,cacheFile);
|
||||
return IS;
|
||||
}
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
success=false;
|
||||
logger.log(Level.WARNING, ex.getMessage());
|
||||
if(alreadyCached)
|
||||
return getStreamFromCache(cacheFile);
|
||||
}finally{
|
||||
if(!success)
|
||||
disconnect();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
private InputStream getStreamFromCache(File cacheFile) {
|
||||
try{
|
||||
logger.info("Try load local cache in " + cacheFile.getAbsolutePath());
|
||||
InputStream in = new FileInputStream(cacheFile);
|
||||
BufferedInputStream bis=new BufferedInputStream(in);
|
||||
if(bis.available()<=0){
|
||||
logger.info("Cannot load local cache in " + cacheFile.getAbsolutePath());
|
||||
return null;
|
||||
}else{
|
||||
logger.info("Successfully load cache in " + cacheFile.getAbsolutePath());
|
||||
return bis;
|
||||
}
|
||||
}catch(Exception e){
|
||||
logger.log(Level.WARNING, e.getMessage());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
private void saveToCache(InputStream is,File to){
|
||||
logger.info("Try save local cache to " + to.getAbsolutePath());
|
||||
FileOutputStream fs=null;
|
||||
int times=0;
|
||||
try{//Save to Local Skin File
|
||||
if(to.exists()){
|
||||
to.delete();
|
||||
}
|
||||
fs = new FileOutputStream(to);
|
||||
int byteRead = 0;
|
||||
byte[] buffer = new byte[1024];
|
||||
while (( byteRead = is.read(buffer)) != -1) {
|
||||
times+=byteRead;
|
||||
fs.write(buffer, 0, byteRead);
|
||||
if(times>=C.getContentLength()){
|
||||
//logger.info(times+" "+C.getContentLength());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(to.length()>1){
|
||||
logger.info("Successfully save cache to " + to.getAbsolutePath());
|
||||
}else{
|
||||
to.delete();
|
||||
logger.info("Cannot save local cache to " + to.getAbsolutePath());
|
||||
}
|
||||
}catch(Exception e){
|
||||
logger.warning(e.getMessage());
|
||||
}finally{
|
||||
try {
|
||||
if(fs!=null)
|
||||
fs.close();
|
||||
is.reset();
|
||||
logger.info("Cache size : "+is.available());
|
||||
} catch (IOException e) {
|
||||
logger.warning(e.getMessage());
|
||||
}
|
||||
if(to.exists()){
|
||||
to.setLastModified(C.getLastModified());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void disconnect() {
|
||||
if (C != null)
|
||||
C.disconnect();
|
||||
}
|
||||
|
||||
private static void refreshSkinURL() {
|
||||
try {
|
||||
if(!SKIN_URL_FILE.exists()){
|
||||
logger.log(Level.INFO, "SKIN config not found, create a new one.");
|
||||
SKIN_URL_FILE.createNewFile();
|
||||
}
|
||||
if(!CAPE_URL_FILE.exists()){
|
||||
logger.log(Level.INFO, "CAPE config not found, create a new one.");
|
||||
CAPE_URL_FILE.createNewFile();
|
||||
}
|
||||
skinURLs = readAllLines(SKIN_URL_FILE);
|
||||
cloakURLs = readAllLines(CAPE_URL_FILE);
|
||||
} catch (Exception ex) {
|
||||
logger.log(Level.WARNING, ex.getMessage());
|
||||
} finally {
|
||||
if(skinURLs.length==0&&cloakURLs.length==0){
|
||||
logger.info("No skinURLs and cloak URLS found, try to init and use default settings.");
|
||||
initSkinURL();
|
||||
refreshSkinURL();
|
||||
}else{
|
||||
logger.log(Level.INFO, "Skin URLs Refreshed. Skin count = "
|
||||
+ skinURLs.length + ", Cloak count = " + cloakURLs.length);
|
||||
}
|
||||
}
|
||||
}
|
||||
private static void initSkinURL(){
|
||||
//TODO Init URL List
|
||||
skinURLs=DEFAULT_SKIN_URLS;
|
||||
writeToFile(new File(DATA_DIR,"skinurls.txt"),parseArrayToText(skinURLs));
|
||||
cloakURLs=DEFAULT_CAPE_URLS;
|
||||
writeToFile(new File(DATA_DIR,"capeurls.txt"),parseArrayToText(cloakURLs));
|
||||
}
|
||||
|
||||
private static String[] readAllLines(File F) {
|
||||
try {
|
||||
logger.log(Level.INFO, "Config file: " + F.getAbsolutePath());
|
||||
if (F.length() <= 0) {
|
||||
logger.log(Level.INFO, "Config file is blank, skipped.");
|
||||
return new String[0];
|
||||
} else {
|
||||
byte[] b = new byte[(int) F.length()];
|
||||
BufferedInputStream S = new BufferedInputStream(
|
||||
new FileInputStream(F));
|
||||
S.read(b);
|
||||
S.close();
|
||||
logger.log(Level.INFO, "Config file loaded.");
|
||||
String[] re= str_replace("\r", "\n",
|
||||
str_replace("\r\n", "\n", new String(b))).split("\n");
|
||||
for(int i=0;i<re.length;i++){
|
||||
if(re[i].startsWith("#"))//Remove note
|
||||
re[i]=null;
|
||||
else{//Remove same URL
|
||||
for(int g=0;g<re.length;g++){
|
||||
if(i==g)
|
||||
continue;
|
||||
if(re[i].equalsIgnoreCase(re[g])){
|
||||
re[i]=null;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return re;
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
logger.log(Level.WARNING, ex.getMessage());
|
||||
return new String[0];
|
||||
}
|
||||
}
|
||||
|
||||
private static String str_replace(String search, String replace,
|
||||
String subject) {
|
||||
StringBuffer result = new StringBuffer(subject);
|
||||
int pos;
|
||||
while ((pos = result.indexOf(search)) != -1)
|
||||
result.replace(pos, pos + search.length(), replace);
|
||||
return result.toString();
|
||||
}
|
||||
private static String parseArrayToText(String[] data){
|
||||
StringBuilder temp=new StringBuilder();
|
||||
for(int i=0;i<data.length-1;i++)
|
||||
temp.append(data[i]).append("\r\n");
|
||||
temp.append(data[data.length-1]);
|
||||
return temp.toString();
|
||||
}
|
||||
private static boolean writeToFile(File file,String Data){
|
||||
System.out.print("Write to "+file.getAbsolutePath()+" ");
|
||||
FileWriter fw=null;
|
||||
try{
|
||||
fw = new FileWriter(file);
|
||||
fw.write(Data,0,Data.length());
|
||||
fw.flush();
|
||||
fw.close();
|
||||
}catch(Exception ex){
|
||||
ex.printStackTrace();
|
||||
System.out.println("failed.");
|
||||
return false;
|
||||
}
|
||||
System.out.println("succeed.");
|
||||
return true;
|
||||
}
|
||||
|
||||
public String MD5(String str){
|
||||
byte [] buf = str.getBytes();
|
||||
MessageDigest md5;
|
||||
try {
|
||||
md5 = MessageDigest.getInstance("MD5");
|
||||
md5.update(buf);
|
||||
byte [] tmp = md5.digest();
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (byte b:tmp) {
|
||||
sb.append(Integer.toHexString(b&0xff));
|
||||
}
|
||||
return sb.toString();
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
logger.warning(e.getMessage());
|
||||
}
|
||||
return "Fail";
|
||||
}
|
||||
|
||||
private static MainLogger getLogger(File logFile){
|
||||
MainLogger mainLogger = new MainLogger(logFile);
|
||||
mainLogger.info("CustomSkinLoader " + VERSION);
|
||||
return mainLogger;
|
||||
}
|
||||
}
|
||||
@@ -1,71 +0,0 @@
|
||||
package idv.jlchntoz;
|
||||
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class MainLogger {
|
||||
private static final int LOWEST_DISPLAY_LEVEL=Level.INFO.intValue();
|
||||
SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
private BufferedWriter writer;
|
||||
public MainLogger(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"));
|
||||
} 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.intValue()>=LOWEST_DISPLAY_LEVEL)
|
||||
System.out.println(msg);
|
||||
try {
|
||||
writer.write("[");
|
||||
writer.write(DATE_FORMAT.format(new Date()));
|
||||
writer.write(" ");
|
||||
writer.write(Thread.currentThread().getName());
|
||||
writer.write(" ");
|
||||
writer.write(level.getName());
|
||||
writer.write("] ");
|
||||
writer.write(msg);
|
||||
writer.write("\r\n");
|
||||
writer.flush();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
public void info(String msg){
|
||||
log(Level.INFO,msg);
|
||||
}
|
||||
public void warning(String msg){
|
||||
log(Level.WARNING,msg);
|
||||
}
|
||||
public void warning(Exception e){
|
||||
log(Level.WARNING,"Exception occurs while running: "+e.getMessage());
|
||||
StackTraceElement[] stes=e.getStackTrace();
|
||||
for(StackTraceElement ste : stes){
|
||||
log(Level.WARNING,ste.toString());
|
||||
}
|
||||
log(Level.WARNING,"");
|
||||
}
|
||||
}
|
||||
@@ -1,101 +0,0 @@
|
||||
package net.minecraft.client.renderer;
|
||||
|
||||
import java.awt.Graphics;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.awt.image.DataBufferInt;
|
||||
import java.awt.image.ImageObserver;
|
||||
|
||||
public class ImageBufferDownload implements IImageBuffer
|
||||
{
|
||||
private int[] imageData;
|
||||
private int imageWidth;
|
||||
private int imageHeight;
|
||||
private static final String __OBFID = "CL_00000956";
|
||||
|
||||
public BufferedImage parseUserSkin(BufferedImage p_78432_1_)
|
||||
{
|
||||
if (p_78432_1_ == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.imageWidth = p_78432_1_.getWidth();//Default: 64
|
||||
this.imageHeight = p_78432_1_.getHeight();//Default: 32
|
||||
BufferedImage var2 = new BufferedImage(this.imageWidth, this.imageWidth / 2, 2);
|
||||
Graphics var3 = var2.getGraphics();
|
||||
if(imageWidth == imageHeight){
|
||||
var3.drawImage(p_78432_1_, 0, 0, this.imageWidth, this.imageWidth / 2, 0, 0, this.imageWidth, this.imageWidth / 2, (ImageObserver)null);
|
||||
var3.drawImage(p_78432_1_, 0, this.imageWidth / 4, this.imageWidth, this.imageWidth / 2, 0, this.imageWidth / 2 , this.imageWidth, this.imageWidth / 4 * 3, (ImageObserver)null);
|
||||
imageHeight/=2;
|
||||
}else{
|
||||
var3.drawImage(p_78432_1_, 0, 0, (ImageObserver)null);
|
||||
}
|
||||
var3.dispose();
|
||||
this.imageData = ((DataBufferInt)var2.getRaster().getDataBuffer()).getData();
|
||||
//this.setAreaOpaque(0, 0, 32, 16);
|
||||
//this.setAreaTransparent(32, 0, 64, 32);
|
||||
//this.setAreaOpaque(0, 16, 64, 32);
|
||||
this.setAreaOpaque(0, 0, imageWidth / 2, imageHeight / 2);
|
||||
this.setAreaTransparent(imageWidth / 2, 0, imageWidth, imageHeight);
|
||||
this.setAreaOpaque(0, imageHeight / 2, imageWidth, imageHeight);
|
||||
return var2;
|
||||
}
|
||||
}
|
||||
|
||||
public void func_152634_a() {}
|
||||
|
||||
/**
|
||||
* Makes the given area of the image transparent if it was previously completely opaque (used to remove the outer
|
||||
* layer of a skin around the head if it was saved all opaque; this would be redundant so it's assumed that the skin
|
||||
* maker is just using an image editor without an alpha channel)
|
||||
*/
|
||||
private void setAreaTransparent(int p_78434_1_, int p_78434_2_, int p_78434_3_, int p_78434_4_)
|
||||
{
|
||||
if (!this.hasTransparency(p_78434_1_, p_78434_2_, p_78434_3_, p_78434_4_))
|
||||
{
|
||||
for (int var5 = p_78434_1_; var5 < p_78434_3_; ++var5)
|
||||
{
|
||||
for (int var6 = p_78434_2_; var6 < p_78434_4_; ++var6)
|
||||
{
|
||||
this.imageData[var5 + var6 * this.imageWidth] &= 16777215;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes the given area of the image opaque
|
||||
*/
|
||||
private void setAreaOpaque(int p_78433_1_, int p_78433_2_, int p_78433_3_, int p_78433_4_)
|
||||
{
|
||||
for (int var5 = p_78433_1_; var5 < p_78433_3_; ++var5)
|
||||
{
|
||||
for (int var6 = p_78433_2_; var6 < p_78433_4_; ++var6)
|
||||
{
|
||||
this.imageData[var5 + var6 * this.imageWidth] |= -16777216;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the given area of the image contains transparent pixels
|
||||
*/
|
||||
private boolean hasTransparency(int p_78435_1_, int p_78435_2_, int p_78435_3_, int p_78435_4_)
|
||||
{
|
||||
for (int var5 = p_78435_1_; var5 < p_78435_3_; ++var5)
|
||||
{
|
||||
for (int var6 = p_78435_2_; var6 < p_78435_4_; ++var6)
|
||||
{
|
||||
int var7 = this.imageData[var5 + var6 * this.imageWidth];
|
||||
|
||||
if ((var7 >> 24 & 255) < 128)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
-158
@@ -1,158 +0,0 @@
|
||||
package net.minecraft.client.renderer;
|
||||
|
||||
import idv.jlchntoz.CustomSkinLoader;
|
||||
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import javax.imageio.ImageIO;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.texture.SimpleTexture;
|
||||
import net.minecraft.client.renderer.texture.TextureUtil;
|
||||
import net.minecraft.client.resources.IResourceManager;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
public class ThreadDownloadImageData extends SimpleTexture
|
||||
{
|
||||
private static final Logger logger = LogManager.getLogger();
|
||||
private static final AtomicInteger field_147643_d = new AtomicInteger(0);
|
||||
private final File field_152434_e;
|
||||
private final String imageUrl;
|
||||
private final IImageBuffer imageBuffer;
|
||||
private BufferedImage bufferedImage;
|
||||
private Thread imageThread;
|
||||
private boolean textureUploaded;
|
||||
private static final String __OBFID = "CL_00001049";
|
||||
|
||||
//For Optifine
|
||||
public Boolean imageFound = null;
|
||||
public boolean pipeline = false;
|
||||
|
||||
public ThreadDownloadImageData(File p_i1049_1_, String p_i1049_2_, ResourceLocation p_i1049_3_, IImageBuffer p_i1049_4_)
|
||||
{
|
||||
super(p_i1049_3_);
|
||||
this.field_152434_e = p_i1049_1_;
|
||||
this.imageUrl = p_i1049_2_;
|
||||
this.imageBuffer = p_i1049_4_;
|
||||
}
|
||||
|
||||
private void func_147640_e()
|
||||
{
|
||||
if (!this.textureUploaded)
|
||||
{
|
||||
if (this.bufferedImage != null)
|
||||
{
|
||||
if (this.textureLocation != null)
|
||||
{
|
||||
this.func_147631_c();
|
||||
}
|
||||
|
||||
TextureUtil.uploadTextureImage(super.getGlTextureId(), this.bufferedImage);
|
||||
this.textureUploaded = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public int getGlTextureId()
|
||||
{
|
||||
this.func_147640_e();
|
||||
return super.getGlTextureId();
|
||||
}
|
||||
|
||||
public void func_147641_a(BufferedImage p_147641_1_)
|
||||
{
|
||||
this.bufferedImage = p_147641_1_;
|
||||
|
||||
if (this.imageBuffer != null)
|
||||
{
|
||||
this.imageBuffer.func_152634_a();
|
||||
}
|
||||
}
|
||||
|
||||
public void loadTexture(IResourceManager p_110551_1_) throws IOException
|
||||
{
|
||||
if (this.bufferedImage == null && this.textureLocation != null)
|
||||
{
|
||||
super.loadTexture(p_110551_1_);
|
||||
}
|
||||
|
||||
if (this.imageThread == null)
|
||||
{
|
||||
if (this.field_152434_e != null && this.field_152434_e.isFile())
|
||||
{
|
||||
logger.debug("Loading http texture from local cache ({})", new Object[] {this.field_152434_e});
|
||||
|
||||
try
|
||||
{
|
||||
this.bufferedImage = ImageIO.read(this.field_152434_e);
|
||||
|
||||
if (this.imageBuffer != null)
|
||||
{
|
||||
this.func_147641_a(this.imageBuffer.parseUserSkin(this.bufferedImage));
|
||||
}
|
||||
}
|
||||
catch (IOException var3)
|
||||
{
|
||||
logger.error("Couldn\'t load skin " + this.field_152434_e, var3);
|
||||
this.func_152433_a();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.func_152433_a();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void func_152433_a()
|
||||
{
|
||||
this.imageThread = new Thread("Texture Downloader #" + field_147643_d.incrementAndGet())
|
||||
{
|
||||
private static final String __OBFID = "CL_00001050";
|
||||
public void run()
|
||||
{
|
||||
ThreadDownloadImageData.logger.debug("Downloading http texture from {} to {}", new Object[] {ThreadDownloadImageData.this.imageUrl, ThreadDownloadImageData.this.field_152434_e});
|
||||
|
||||
try
|
||||
{
|
||||
CustomSkinLoader loader=new CustomSkinLoader();
|
||||
InputStream var9=loader.getPlayerSkinStream(ThreadDownloadImageData.this.imageUrl);
|
||||
|
||||
|
||||
BufferedImage var2;
|
||||
/*
|
||||
if (ThreadDownloadImageData.this.field_152434_e != null)
|
||||
{
|
||||
FileUtils.copyInputStreamToFile(var9, ThreadDownloadImageData.this.field_152434_e);
|
||||
var2 = ImageIO.read(ThreadDownloadImageData.this.field_152434_e);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
}*/
|
||||
var2 = ImageIO.read(var9);
|
||||
if (ThreadDownloadImageData.this.imageBuffer != null)
|
||||
{
|
||||
var2 = ThreadDownloadImageData.this.imageBuffer.parseUserSkin(var2);
|
||||
}
|
||||
|
||||
ThreadDownloadImageData.this.func_147641_a(var2);
|
||||
loader.disconnect();
|
||||
}
|
||||
catch (Exception var6)
|
||||
{
|
||||
ThreadDownloadImageData.logger.error("Couldn\'t download http texture", var6);
|
||||
}
|
||||
}
|
||||
};
|
||||
this.imageThread.setDaemon(true);
|
||||
this.imageThread.start();
|
||||
}
|
||||
}
|
||||
@@ -1,178 +0,0 @@
|
||||
package net.minecraft.client.resources;
|
||||
|
||||
import com.google.common.cache.CacheBuilder;
|
||||
import com.google.common.cache.CacheLoader;
|
||||
import com.google.common.cache.LoadingCache;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import com.mojang.authlib.minecraft.InsecureTextureException;
|
||||
import com.mojang.authlib.minecraft.MinecraftProfileTexture;
|
||||
import com.mojang.authlib.minecraft.MinecraftSessionService;
|
||||
import com.mojang.authlib.minecraft.MinecraftProfileTexture.Type;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.File;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.LinkedBlockingQueue;
|
||||
import java.util.concurrent.ThreadPoolExecutor;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.IImageBuffer;
|
||||
import net.minecraft.client.renderer.ImageBufferDownload;
|
||||
import net.minecraft.client.renderer.ThreadDownloadImageData;
|
||||
import net.minecraft.client.renderer.texture.ITextureObject;
|
||||
import net.minecraft.client.renderer.texture.TextureManager;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
public class SkinManager
|
||||
{
|
||||
public static final ResourceLocation field_152793_a = new ResourceLocation("textures/entity/steve.png");
|
||||
private static final ExecutorService field_152794_b = new ThreadPoolExecutor(0, 2, 1L, TimeUnit.MINUTES, new LinkedBlockingQueue());
|
||||
private final TextureManager field_152795_c;
|
||||
private final File field_152796_d;
|
||||
private final MinecraftSessionService field_152797_e;
|
||||
private final LoadingCache field_152798_f;
|
||||
private static final String __OBFID = "CL_00001830";
|
||||
|
||||
public SkinManager(TextureManager p_i1044_1_, File p_i1044_2_, MinecraftSessionService p_i1044_3_)
|
||||
{
|
||||
this.field_152795_c = p_i1044_1_;
|
||||
this.field_152796_d = p_i1044_2_;
|
||||
this.field_152797_e = p_i1044_3_;
|
||||
this.field_152798_f = CacheBuilder.newBuilder().expireAfterAccess(15L, TimeUnit.SECONDS).build(new CacheLoader()
|
||||
{
|
||||
private static final String __OBFID = "CL_00001829";
|
||||
public Map func_152786_a(GameProfile p_152786_1_)
|
||||
{
|
||||
return Minecraft.getMinecraft().func_152347_ac().getTextures(p_152786_1_, false);
|
||||
}
|
||||
public Object load(Object p_load_1_)
|
||||
{
|
||||
return this.func_152786_a((GameProfile)p_load_1_);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public ResourceLocation func_152792_a(MinecraftProfileTexture p_152792_1_, Type p_152792_2_)
|
||||
{
|
||||
return this.func_152789_a(p_152792_1_, p_152792_2_, (SkinManager.SkinAvailableCallback)null);
|
||||
}
|
||||
|
||||
public ResourceLocation func_152789_a(MinecraftProfileTexture p_152789_1_, final Type p_152789_2_, final SkinManager.SkinAvailableCallback p_152789_3_)
|
||||
{
|
||||
|
||||
final ResourceLocation var4 = new ResourceLocation(p_152789_2_.name()+"/" + p_152789_1_.getHash());
|
||||
//ITextureObject var5 = this.field_152795_c.getTexture(var4);
|
||||
/*
|
||||
if (var5 != null)
|
||||
{
|
||||
if (p_152789_3_ != null)
|
||||
{
|
||||
p_152789_3_.func_152121_a(p_152789_2_, var4);
|
||||
}
|
||||
}
|
||||
else
|
||||
{*/
|
||||
File var6 = new File(this.field_152796_d, p_152789_1_.getHash().substring(0, 2));
|
||||
File var7 = new File(var6, p_152789_1_.getHash());
|
||||
final ImageBufferDownload var8 = p_152789_2_ == Type.SKIN ? new ImageBufferDownload() : null;
|
||||
ThreadDownloadImageData var9 = new ThreadDownloadImageData(var7, p_152789_1_.getUrl(), field_152793_a, new IImageBuffer()
|
||||
{
|
||||
private static final String __OBFID = "CL_00001828";
|
||||
public BufferedImage parseUserSkin(BufferedImage p_78432_1_)
|
||||
{
|
||||
if (var8 != null)
|
||||
{
|
||||
p_78432_1_ = var8.parseUserSkin(p_78432_1_);
|
||||
}
|
||||
|
||||
return p_78432_1_;
|
||||
}
|
||||
public void func_152634_a()
|
||||
{
|
||||
if (var8 != null)
|
||||
{
|
||||
var8.func_152634_a();
|
||||
}
|
||||
|
||||
if (p_152789_3_ != null)
|
||||
{
|
||||
p_152789_3_.func_152121_a(p_152789_2_, var4);
|
||||
}
|
||||
}
|
||||
});
|
||||
this.field_152795_c.loadTexture(var4, var9);
|
||||
//}
|
||||
return var4;
|
||||
}
|
||||
|
||||
public void func_152790_a(final GameProfile p_152790_1_, final SkinManager.SkinAvailableCallback p_152790_2_, final boolean p_152790_3_)
|
||||
{
|
||||
field_152794_b.submit(new Runnable()
|
||||
{
|
||||
private static final String __OBFID = "CL_00001827";
|
||||
public void run()
|
||||
{
|
||||
final HashMap var1 = Maps.newHashMap();
|
||||
|
||||
try
|
||||
{
|
||||
var1.putAll(SkinManager.this.field_152797_e.getTextures(p_152790_1_, p_152790_3_));
|
||||
}
|
||||
catch (InsecureTextureException var3)
|
||||
{
|
||||
;
|
||||
}
|
||||
|
||||
if (var1.isEmpty() && p_152790_1_.getId().equals(Minecraft.getMinecraft().getSession().func_148256_e().getId()))
|
||||
{
|
||||
var1.putAll(SkinManager.this.field_152797_e.getTextures(SkinManager.this.field_152797_e.fillProfileProperties(p_152790_1_, false), false));
|
||||
}
|
||||
|
||||
//CustomSkinLoader Begin
|
||||
HashMap var2 = Maps.newHashMap();
|
||||
if (var1.containsKey(Type.SKIN)){
|
||||
var2.put(Type.SKIN, new MinecraftProfileTexture(((MinecraftProfileTexture)var1.get(Type.SKIN)).getUrl()+"?Skin="+p_152790_1_.getName()));
|
||||
}else{
|
||||
var2.put(Type.SKIN,new MinecraftProfileTexture( "http://skins.minecraft.net/MinecraftSkins/"+p_152790_1_.getName()+".png"));
|
||||
}
|
||||
if (var1.containsKey(Type.CAPE)){
|
||||
var2.put(Type.CAPE, new MinecraftProfileTexture(((MinecraftProfileTexture)var1.get(Type.CAPE)).getUrl()+"?Cloak="+p_152790_1_.getName()));
|
||||
}else{
|
||||
var2.put(Type.CAPE,new MinecraftProfileTexture( "http://skins.minecraft.net/MinecraftCloaks/"+p_152790_1_.getName()+".png"));
|
||||
}
|
||||
var1.clear();
|
||||
var1.putAll(var2);
|
||||
//CustomSkinLoader End
|
||||
|
||||
Minecraft.getMinecraft().func_152344_a(new Runnable()
|
||||
{
|
||||
private static final String __OBFID = "CL_00001826";
|
||||
public void run()
|
||||
{
|
||||
if (var1.containsKey(Type.SKIN))
|
||||
{
|
||||
SkinManager.this.func_152789_a((MinecraftProfileTexture)var1.get(Type.SKIN), Type.SKIN, p_152790_2_);
|
||||
}
|
||||
|
||||
if (var1.containsKey(Type.CAPE))
|
||||
{
|
||||
SkinManager.this.func_152789_a((MinecraftProfileTexture)var1.get(Type.CAPE), Type.CAPE, p_152790_2_);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public Map func_152788_a(GameProfile p_152788_1_)
|
||||
{
|
||||
return (Map)this.field_152798_f.getUnchecked(p_152788_1_);
|
||||
}
|
||||
|
||||
public interface SkinAvailableCallback
|
||||
{
|
||||
void func_152121_a(Type p_152121_1_, ResourceLocation p_152121_2_);
|
||||
}
|
||||
}
|
||||
@@ -1,357 +0,0 @@
|
||||
package idv.jlchntoz;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
|
||||
import java.io.*;
|
||||
import java.math.BigInteger;
|
||||
import java.net.*;
|
||||
import java.nio.MappedByteBuffer;
|
||||
import java.nio.channels.FileChannel;
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.util.HashMap;
|
||||
import java.util.logging.*;
|
||||
import java.util.regex.*;
|
||||
|
||||
/**
|
||||
* Custom skin loader mod for Minecraft.
|
||||
*
|
||||
* @version 12th Revision 9th Subversion 2016.2.10
|
||||
*
|
||||
* @author (C) Jeremy Lam [JLChnToZ] 2013 & Alexander Xia [xfl03] 2014-2016
|
||||
*/
|
||||
public class CustomSkinLoader {
|
||||
public final static String VERSION="12.9";
|
||||
|
||||
public final static String DefaultSkinURL = "http://skins.minecraft.net/MinecraftSkins/*.png";
|
||||
public final static String DefaultCloakURL = "http://skins.minecraft.net/MinecraftCloaks/*.png";
|
||||
|
||||
private final static Pattern newResPattern = Pattern.compile("^http://textures.minecraft.net/texture/(.*?)?(Skin|Cloak)=(.*?)$"),
|
||||
newURLPattern = Pattern.compile("^http://skins.minecraft.net/Minecraft(Skin|Cloak)s/(.*?).png$"),
|
||||
oldURLPattern = Pattern.compile("^http://s3.amazonaws.com/Minecraft(Skin|Cloak)s/(.*?).png$"),
|
||||
optifineCapeURLPattern = Pattern.compile("^http://s.optifine.net/capes/(.*?).png$");
|
||||
|
||||
public final static File DATA_DIR=new File(Minecraft.getMinecraft().mcDataDir,"CustomSkinLoader"),
|
||||
CACHE_DIR=new File(DATA_DIR,"caches"),
|
||||
LOG_FILE=new File(DATA_DIR,"CustomSkinLoader.log"),
|
||||
SKIN_URL_FILE=new File(DATA_DIR,"skinurls.txt"),
|
||||
CAPE_URL_FILE=new File(DATA_DIR,"capeurls.txt");
|
||||
public final static MainLogger logger = getLogger(LOG_FILE);
|
||||
|
||||
public final static String[] DEFAULT_SKIN_URLS={
|
||||
"http://skins.minecraft.net/MinecraftSkins/*.png",
|
||||
"http://minecrack.fr.nf/mc/skinsminecrackd/*.png",
|
||||
"http://www.skinme.cc/MinecraftSkins/*.png"};
|
||||
public final static String[] DEFAULT_CAPE_URLS={
|
||||
"http://skins.minecraft.net/MinecraftCloaks/*.png",
|
||||
"http://s.optifine.net/capes/*.png",
|
||||
"http://minecrack.fr.nf/mc/cloaksminecrackd/*.png",
|
||||
"http://www.skinme.cc/MinecraftCloaks/*.png"};
|
||||
|
||||
private static String[] cloakURLs = null, skinURLs = null;
|
||||
private HttpURLConnection C = null;
|
||||
|
||||
//Entrance
|
||||
public InputStream getPlayerSkinStream(String path) {
|
||||
if(!DATA_DIR.exists())
|
||||
DATA_DIR.mkdir();
|
||||
if(!CACHE_DIR.exists())
|
||||
CACHE_DIR.mkdir();
|
||||
logger.info("Get a request: "+path);
|
||||
if(path.contains("NOCSL"))//Not to use CSL to load, prepared for json api
|
||||
return getStream(path, false);
|
||||
Matcher m = newURLPattern.matcher(path);
|
||||
if (!m.matches())//Is not new url
|
||||
{
|
||||
m = oldURLPattern.matcher(path);//May be old url
|
||||
}
|
||||
if (m.matches()) {
|
||||
if (m.group(1).contains("Skin")) // Skin
|
||||
return getPlayerSkinStream(false, m.group(2));
|
||||
else if (m.group(1).contains("Cloak")) // Cloak
|
||||
return getPlayerSkinStream(true, m.group(2));
|
||||
}else{
|
||||
m = newResPattern.matcher(path);
|
||||
if(m.matches()){
|
||||
if (m.group(2).contains("Skin")) // Skin
|
||||
return getPlayerSkinStream(false, m.group(3));
|
||||
else if (m.group(2).contains("Cloak")) // Cloak
|
||||
return getPlayerSkinStream(true, m.group(3));
|
||||
}else{
|
||||
m = optifineCapeURLPattern.matcher(path);
|
||||
if(m.matches()){//Optifine Cape
|
||||
logger.info("Ignore Optifine Cape.");
|
||||
return null;//Not Load This
|
||||
}
|
||||
}
|
||||
}
|
||||
return getStream(path, false); // Neither skin nor cloak...
|
||||
}
|
||||
|
||||
public InputStream getPlayerSkinStream(Boolean isCloak, String playerName) {
|
||||
if ((skinURLs == null|| skinURLs.length <= 0) && (cloakURLs == null || cloakURLs.length <= 0))
|
||||
refreshSkinURL(); // If the list is blank or null, try to load again.
|
||||
InputStream S=null;
|
||||
|
||||
for (String l : isCloak ? cloakURLs : skinURLs) {
|
||||
if(l==null||l.equalsIgnoreCase(""))
|
||||
continue;
|
||||
String loc = str_replace("*", playerName, l);
|
||||
logger.log(Level.INFO, "Try to load " + (isCloak ? "cloak" : "skin") + " in " + loc);
|
||||
S = getStream(loc, true);
|
||||
|
||||
if (S == null){
|
||||
logger.log(Level.INFO, "No " + (isCloak ? "cloak" : "skin") + " found in " + loc);
|
||||
}else{
|
||||
logger.info("Succeessfully load " + (isCloak ? "cloak" : "skin") + " in " + loc);
|
||||
return S;
|
||||
}
|
||||
}
|
||||
|
||||
logger.log(Level.INFO, "Try to load skin in default URL instead.");
|
||||
return getStream(str_replace("*", playerName, isCloak ? DefaultCloakURL : DefaultSkinURL), true);
|
||||
}
|
||||
|
||||
private InputStream getStream(String URL, Boolean CheckPNG) {
|
||||
boolean success=false;
|
||||
File cacheFile=new File(CACHE_DIR,MD5(URL));
|
||||
boolean alreadyCached=false;
|
||||
if(cacheFile.exists()&&cacheFile.length()>1){
|
||||
alreadyCached=true;
|
||||
logger.info("Cache File Found (LastModified: "+cacheFile.lastModified()+" , Size: "+cacheFile.length()+")");
|
||||
}
|
||||
try {
|
||||
URL U = new URL(URL);
|
||||
C = (HttpURLConnection) U.openConnection();
|
||||
C.setReadTimeout(15000);
|
||||
C.setDoInput(true);
|
||||
C.setDoOutput(false);
|
||||
C.connect();
|
||||
logger.info("Response Code: "+C.getResponseCode());
|
||||
int respcode = C.getResponseCode() / 100;
|
||||
if (respcode != 4 && respcode != 5) { // Successful to get skin.
|
||||
if(C.getContentLength()<=0){//Nothing got
|
||||
logger.info("Nothing got.");
|
||||
return null;
|
||||
}
|
||||
logger.info("Successfully Get Resource (LastModified: "+C.getLastModified()+" , ContentLength: "+C.getContentLength()+")");
|
||||
if(alreadyCached && C.getLastModified()==cacheFile.lastModified() && C.getContentLength()==cacheFile.length()){
|
||||
logger.info("Not Modified.");
|
||||
return getStreamFromCache(cacheFile);
|
||||
}
|
||||
InputStream IS=new BufferedInputStream(C.getInputStream());
|
||||
if (!CheckPNG){ // If no need to check PNG header, just skip it.
|
||||
success=true;
|
||||
saveToCache(IS,cacheFile);
|
||||
return IS;
|
||||
}
|
||||
//logger.info(C.getContentLength()+" "+IS.available());
|
||||
IS.mark(C.getContentLength()+10);
|
||||
byte[] ib = new byte[4];
|
||||
IS.read(ib);
|
||||
if (ib[1] == (byte) 'P' && ib[2] == (byte) 'N' && ib[3] == (byte) 'G') { // Check PNG Header if needed
|
||||
IS.reset();
|
||||
success=true;
|
||||
saveToCache(IS,cacheFile);
|
||||
return IS;
|
||||
}
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
success=false;
|
||||
logger.log(Level.WARNING, ex.getMessage());
|
||||
if(alreadyCached)
|
||||
return getStreamFromCache(cacheFile);
|
||||
}finally{
|
||||
if(!success)
|
||||
disconnect();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
private InputStream getStreamFromCache(File cacheFile) {
|
||||
try{
|
||||
logger.info("Try load local cache in " + cacheFile.getAbsolutePath());
|
||||
InputStream in = new FileInputStream(cacheFile);
|
||||
BufferedInputStream bis=new BufferedInputStream(in);
|
||||
if(bis.available()<=0){
|
||||
logger.info("Cannot load local cache in " + cacheFile.getAbsolutePath());
|
||||
return null;
|
||||
}else{
|
||||
logger.info("Successfully load cache in " + cacheFile.getAbsolutePath());
|
||||
return bis;
|
||||
}
|
||||
}catch(Exception e){
|
||||
logger.log(Level.WARNING, e.getMessage());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
private void saveToCache(InputStream is,File to){
|
||||
logger.info("Try save local cache to " + to.getAbsolutePath());
|
||||
FileOutputStream fs=null;
|
||||
int times=0;
|
||||
try{//Save to Local Skin File
|
||||
if(to.exists()){
|
||||
to.delete();
|
||||
}
|
||||
fs = new FileOutputStream(to);
|
||||
int byteRead = 0;
|
||||
byte[] buffer = new byte[1024];
|
||||
while (( byteRead = is.read(buffer)) != -1) {
|
||||
times+=byteRead;
|
||||
fs.write(buffer, 0, byteRead);
|
||||
if(times>=C.getContentLength()){
|
||||
//logger.info(times+" "+C.getContentLength());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(to.length()>1){
|
||||
to.setLastModified(C.getLastModified());
|
||||
logger.info("Cache saved to " + to.getAbsolutePath()+" (LastModified: "+to.lastModified()+" , Size: "+to.length()+")");
|
||||
}else{
|
||||
to.delete();
|
||||
logger.info("Cannot save local cache to " + to.getAbsolutePath());
|
||||
}
|
||||
}catch(Exception e){
|
||||
logger.warning(e.getMessage());
|
||||
}finally{
|
||||
try {
|
||||
if(fs!=null)
|
||||
fs.close();
|
||||
is.reset();
|
||||
} catch (IOException e) {
|
||||
logger.warning(e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void disconnect() {
|
||||
if (C != null)
|
||||
C.disconnect();
|
||||
}
|
||||
|
||||
private static void refreshSkinURL() {
|
||||
try {
|
||||
if(!SKIN_URL_FILE.exists()){
|
||||
logger.log(Level.INFO, "SKIN config not found, create a new one.");
|
||||
SKIN_URL_FILE.createNewFile();
|
||||
}
|
||||
if(!CAPE_URL_FILE.exists()){
|
||||
logger.log(Level.INFO, "CAPE config not found, create a new one.");
|
||||
CAPE_URL_FILE.createNewFile();
|
||||
}
|
||||
skinURLs = readAllLines(SKIN_URL_FILE);
|
||||
cloakURLs = readAllLines(CAPE_URL_FILE);
|
||||
} catch (Exception ex) {
|
||||
logger.log(Level.WARNING, ex.getMessage());
|
||||
} finally {
|
||||
if(skinURLs.length==0&&cloakURLs.length==0){
|
||||
logger.info("No skinURLs and cloak URLS found, try to init and use default settings.");
|
||||
initSkinURL();
|
||||
refreshSkinURL();
|
||||
}else{
|
||||
logger.log(Level.INFO, "Skin URLs Refreshed. Skin count = "
|
||||
+ skinURLs.length + ", Cloak count = " + cloakURLs.length);
|
||||
}
|
||||
}
|
||||
}
|
||||
private static void initSkinURL(){
|
||||
//Init URL List
|
||||
skinURLs=DEFAULT_SKIN_URLS;
|
||||
writeToFile(new File(DATA_DIR,"skinurls.txt"),parseArrayToText(skinURLs));
|
||||
cloakURLs=DEFAULT_CAPE_URLS;
|
||||
writeToFile(new File(DATA_DIR,"capeurls.txt"),parseArrayToText(cloakURLs));
|
||||
}
|
||||
|
||||
private static String[] readAllLines(File F) {
|
||||
try {
|
||||
logger.log(Level.INFO, "Config file: " + F.getAbsolutePath());
|
||||
if (F.length() <= 0) {
|
||||
logger.log(Level.INFO, "Config file is blank, skipped.");
|
||||
return new String[0];
|
||||
} else {
|
||||
byte[] b = new byte[(int) F.length()];
|
||||
BufferedInputStream S = new BufferedInputStream(
|
||||
new FileInputStream(F));
|
||||
S.read(b);
|
||||
S.close();
|
||||
logger.log(Level.INFO, "Config file loaded.");
|
||||
String[] re= str_replace("\r", "\n",
|
||||
str_replace("\r\n", "\n", new String(b))).split("\n");
|
||||
for(int i=0;i<re.length;i++){
|
||||
if(re[i].startsWith("#"))//Remove note
|
||||
re[i]=null;
|
||||
else{//Remove same URL
|
||||
for(int g=0;g<re.length;g++){
|
||||
if(i==g)
|
||||
continue;
|
||||
if(re[i].equalsIgnoreCase(re[g])){
|
||||
re[i]=null;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return re;
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
logger.log(Level.WARNING, ex.getMessage());
|
||||
return new String[0];
|
||||
}
|
||||
}
|
||||
|
||||
private static String str_replace(String search, String replace,
|
||||
String subject) {
|
||||
StringBuffer result = new StringBuffer(subject);
|
||||
int pos;
|
||||
while ((pos = result.indexOf(search)) != -1)
|
||||
result.replace(pos, pos + search.length(), replace);
|
||||
return result.toString();
|
||||
}
|
||||
private static String parseArrayToText(String[] data){
|
||||
StringBuilder temp=new StringBuilder();
|
||||
for(int i=0;i<data.length-1;i++)
|
||||
temp.append(data[i]).append("\r\n");
|
||||
temp.append(data[data.length-1]);
|
||||
return temp.toString();
|
||||
}
|
||||
private static boolean writeToFile(File file,String Data){
|
||||
System.out.print("Write to "+file.getAbsolutePath()+" ");
|
||||
FileWriter fw=null;
|
||||
try{
|
||||
fw = new FileWriter(file);
|
||||
fw.write(Data,0,Data.length());
|
||||
fw.flush();
|
||||
fw.close();
|
||||
}catch(Exception ex){
|
||||
ex.printStackTrace();
|
||||
System.out.println("failed.");
|
||||
return false;
|
||||
}
|
||||
System.out.println("succeed.");
|
||||
return true;
|
||||
}
|
||||
|
||||
public String MD5(String str){
|
||||
byte [] buf = str.getBytes();
|
||||
MessageDigest md5;
|
||||
try {
|
||||
md5 = MessageDigest.getInstance("MD5");
|
||||
md5.update(buf);
|
||||
byte [] tmp = md5.digest();
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (byte b:tmp) {
|
||||
sb.append(Integer.toHexString(b&0xff));
|
||||
}
|
||||
return sb.toString();
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
logger.warning(e.getMessage());
|
||||
}
|
||||
return "Fail";
|
||||
}
|
||||
|
||||
private static MainLogger getLogger(File logFile){
|
||||
MainLogger mainLogger = new MainLogger(logFile);
|
||||
mainLogger.info("CustomSkinLoader " + VERSION);
|
||||
return mainLogger;
|
||||
}
|
||||
}
|
||||
@@ -1,71 +0,0 @@
|
||||
package idv.jlchntoz;
|
||||
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class MainLogger {
|
||||
private static final int LOWEST_DISPLAY_LEVEL=Level.INFO.intValue();
|
||||
SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
private BufferedWriter writer;
|
||||
public MainLogger(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"));
|
||||
} 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.intValue()>=LOWEST_DISPLAY_LEVEL)
|
||||
System.out.println(msg);
|
||||
try {
|
||||
writer.write("[");
|
||||
writer.write(DATE_FORMAT.format(new Date()));
|
||||
writer.write(" ");
|
||||
writer.write(Thread.currentThread().getName());
|
||||
writer.write(" ");
|
||||
writer.write(level.getName());
|
||||
writer.write("] ");
|
||||
writer.write(msg);
|
||||
writer.write("\r\n");
|
||||
writer.flush();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
public void info(String msg){
|
||||
log(Level.INFO,msg);
|
||||
}
|
||||
public void warning(String msg){
|
||||
log(Level.WARNING,msg);
|
||||
}
|
||||
public void warning(Exception e){
|
||||
log(Level.WARNING,"Exception occurs while running: "+e.getMessage());
|
||||
StackTraceElement[] stes=e.getStackTrace();
|
||||
for(StackTraceElement ste : stes){
|
||||
log(Level.WARNING,ste.toString());
|
||||
}
|
||||
log(Level.WARNING,"");
|
||||
}
|
||||
}
|
||||
@@ -1,99 +0,0 @@
|
||||
package net.minecraft.client.renderer;
|
||||
|
||||
import java.awt.Graphics;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.awt.image.DataBufferInt;
|
||||
import java.awt.image.ImageObserver;
|
||||
|
||||
public class ImageBufferDownload implements IImageBuffer
|
||||
{
|
||||
private int[] imageData;
|
||||
private int imageWidth;
|
||||
private int imageHeight;
|
||||
private static final String __OBFID = "CL_00000956";
|
||||
|
||||
public BufferedImage parseUserSkin(BufferedImage par1BufferedImage)
|
||||
{
|
||||
if (par1BufferedImage == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.imageWidth = par1BufferedImage.getWidth();//Default: 64
|
||||
this.imageHeight = par1BufferedImage.getHeight();//Default: 32
|
||||
BufferedImage var2 = new BufferedImage(this.imageWidth, this.imageWidth / 2, 2);
|
||||
Graphics var3 = var2.getGraphics();
|
||||
if(imageWidth == imageHeight){
|
||||
var3.drawImage(par1BufferedImage, 0, 0, this.imageWidth, this.imageWidth / 2, 0, 0, this.imageWidth, this.imageWidth / 2, (ImageObserver)null);
|
||||
var3.drawImage(par1BufferedImage, 0, this.imageWidth / 4, this.imageWidth, this.imageWidth / 2, 0, this.imageWidth / 2 , this.imageWidth, this.imageWidth / 4 * 3, (ImageObserver)null);
|
||||
imageHeight/=2;
|
||||
}else{
|
||||
var3.drawImage(par1BufferedImage, 0, 0, (ImageObserver)null);
|
||||
}
|
||||
var3.dispose();
|
||||
this.imageData = ((DataBufferInt)var2.getRaster().getDataBuffer()).getData();
|
||||
//this.setAreaOpaque(0, 0, 32, 16);
|
||||
//this.setAreaTransparent(32, 0, 64, 32);
|
||||
//this.setAreaOpaque(0, 16, 64, 32);
|
||||
this.setAreaOpaque(0, 0, imageWidth / 2, imageHeight / 2);
|
||||
this.setAreaTransparent(imageWidth / 2, 0, imageWidth, imageHeight);
|
||||
this.setAreaOpaque(0, imageHeight / 2, imageWidth, imageHeight);
|
||||
return var2;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes the given area of the image transparent if it was previously completely opaque (used to remove the outer
|
||||
* layer of a skin around the head if it was saved all opaque; this would be redundant so it's assumed that the skin
|
||||
* maker is just using an image editor without an alpha channel)
|
||||
*/
|
||||
private void setAreaTransparent(int par1, int par2, int par3, int par4)
|
||||
{
|
||||
if (!this.hasTransparency(par1, par2, par3, par4))
|
||||
{
|
||||
for (int var5 = par1; var5 < par3; ++var5)
|
||||
{
|
||||
for (int var6 = par2; var6 < par4; ++var6)
|
||||
{
|
||||
this.imageData[var5 + var6 * this.imageWidth] &= 16777215;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes the given area of the image opaque
|
||||
*/
|
||||
private void setAreaOpaque(int par1, int par2, int par3, int par4)
|
||||
{
|
||||
for (int var5 = par1; var5 < par3; ++var5)
|
||||
{
|
||||
for (int var6 = par2; var6 < par4; ++var6)
|
||||
{
|
||||
this.imageData[var5 + var6 * this.imageWidth] |= -16777216;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the given area of the image contains transparent pixels
|
||||
*/
|
||||
private boolean hasTransparency(int par1, int par2, int par3, int par4)
|
||||
{
|
||||
for (int var5 = par1; var5 < par3; ++var5)
|
||||
{
|
||||
for (int var6 = par2; var6 < par4; ++var6)
|
||||
{
|
||||
int var7 = this.imageData[var5 + var6 * this.imageWidth];
|
||||
|
||||
if ((var7 >> 24 & 255) < 128)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
-110
@@ -1,110 +0,0 @@
|
||||
package net.minecraft.client.renderer;
|
||||
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.IOException;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import javax.imageio.ImageIO;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.texture.SimpleTexture;
|
||||
import net.minecraft.client.renderer.texture.TextureUtil;
|
||||
import net.minecraft.client.resources.IResourceManager;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import idv.jlchntoz.CustomSkinLoader;
|
||||
|
||||
public class ThreadDownloadImageData extends SimpleTexture
|
||||
{
|
||||
private static final Logger logger = LogManager.getLogger();
|
||||
private static final AtomicInteger field_147643_d = new AtomicInteger(0);
|
||||
private final String imageUrl;
|
||||
private final IImageBuffer imageBuffer;
|
||||
private BufferedImage bufferedImage;
|
||||
private Thread imageThread;
|
||||
private boolean textureUploaded;
|
||||
private static final String __OBFID = "CL_00001049";
|
||||
public CustomSkinLoader customSkinLoader=new CustomSkinLoader();
|
||||
|
||||
public boolean enabled;//For Optifine
|
||||
|
||||
public ThreadDownloadImageData(String par1Str, ResourceLocation par2ResourceLocation, IImageBuffer par3IImageBuffer)
|
||||
{
|
||||
super(par2ResourceLocation);
|
||||
this.imageUrl = par1Str;
|
||||
this.imageBuffer = par3IImageBuffer;
|
||||
}
|
||||
|
||||
private void func_147640_e()
|
||||
{
|
||||
if (!this.textureUploaded)
|
||||
{
|
||||
if (this.bufferedImage != null)
|
||||
{
|
||||
if (this.textureLocation != null)
|
||||
{
|
||||
this.func_147631_c();
|
||||
}
|
||||
|
||||
TextureUtil.uploadTextureImage(super.getGlTextureId(), this.bufferedImage);
|
||||
this.textureUploaded = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public int getGlTextureId()
|
||||
{
|
||||
this.func_147640_e();
|
||||
return super.getGlTextureId();
|
||||
}
|
||||
|
||||
public void func_147641_a(BufferedImage p_147641_1_)
|
||||
{
|
||||
this.bufferedImage = p_147641_1_;
|
||||
}
|
||||
|
||||
public void loadTexture(IResourceManager par1ResourceManager) throws IOException
|
||||
{
|
||||
if (this.bufferedImage == null && this.textureLocation != null)
|
||||
{
|
||||
super.loadTexture(par1ResourceManager);
|
||||
}
|
||||
|
||||
if (this.imageThread == null)
|
||||
{
|
||||
this.imageThread = new Thread("Texture Downloader #" + field_147643_d.incrementAndGet())
|
||||
{
|
||||
private static final String __OBFID = "CL_00001050";
|
||||
public void run()
|
||||
{
|
||||
try
|
||||
{
|
||||
BufferedImage var2 = ImageIO.read(
|
||||
ThreadDownloadImageData.this.customSkinLoader.getPlayerSkinStream(
|
||||
ThreadDownloadImageData.this.imageUrl));
|
||||
if (ThreadDownloadImageData.this.imageBuffer != null){
|
||||
var2 = ThreadDownloadImageData.this.imageBuffer.parseUserSkin(var2);
|
||||
}
|
||||
ThreadDownloadImageData.this.func_147641_a(var2);
|
||||
customSkinLoader.disconnect();
|
||||
}catch (Exception var6){
|
||||
ThreadDownloadImageData.logger.error("Couldn\'t download http texture", var6);
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
this.imageThread.setDaemon(true);
|
||||
//this.imageThread.setName("Skin downloader: " + this.imageUrl);
|
||||
this.imageThread.start();
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isTextureUploaded()
|
||||
{
|
||||
this.func_147640_e();
|
||||
return this.textureUploaded;
|
||||
}
|
||||
}
|
||||
-382
@@ -1,382 +0,0 @@
|
||||
// Decompiled by Jad v1.5.8e2. Copyright 2001 Pavel Kouznetsov.
|
||||
// Jad home page: http://kpdus.tripod.com/jad.html
|
||||
// Decompiler options: packimports(3) fieldsfirst ansi space
|
||||
// Source File Name: SourceFile
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
public class bpi extends bpa
|
||||
{
|
||||
|
||||
private static final brq a = new brq("textures/entity/steve.png");
|
||||
private bih f;
|
||||
private bih g;
|
||||
private bih h;
|
||||
|
||||
public bpi()
|
||||
{
|
||||
super(new bih(0.0F), 0.5F);
|
||||
f = (bih)i;
|
||||
g = new bih(1.0F);
|
||||
h = new bih(0.5F);
|
||||
}
|
||||
|
||||
protected int a(bma bma1, int i, float f1)
|
||||
{
|
||||
abu abu1 = bma1.bm.d(3 - i);
|
||||
if (abu1 != null)
|
||||
{
|
||||
abs abs1 = abu1.b();
|
||||
if (abs1 instanceof zs)
|
||||
{
|
||||
zs zs1 = (zs)abs1;
|
||||
a(bop.a(zs1, i));
|
||||
bih bih1 = i != 2 ? g : h;
|
||||
bih1.c.j = i == 0;
|
||||
bih1.d.j = i == 0;
|
||||
bih1.e.j = i == 1 || i == 2;
|
||||
bih1.f.j = i == 1;
|
||||
bih1.g.j = i == 1;
|
||||
bih1.h.j = i == 2 || i == 3;
|
||||
bih1.i.j = i == 2 || i == 3;
|
||||
a(((bim) (bih1)));
|
||||
bih1.p = this.i.p;
|
||||
bih1.q = this.i.q;
|
||||
bih1.s = this.i.s;
|
||||
if (zs1.m_() == zu.a)
|
||||
{
|
||||
int j = zs1.b(abu1);
|
||||
float f2 = (float)(j >> 16 & 0xff) / 255F;
|
||||
float f3 = (float)(j >> 8 & 0xff) / 255F;
|
||||
float f4 = (float)(j & 0xff) / 255F;
|
||||
GL11.glColor3f(f2, f3, f4);
|
||||
return !abu1.y() ? 16 : 31;
|
||||
}
|
||||
GL11.glColor3f(1.0F, 1.0F, 1.0F);
|
||||
return !abu1.y() ? 1 : 15;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
protected void b(bma bma1, int i, float f1)
|
||||
{
|
||||
abu abu1 = bma1.bm.d(3 - i);
|
||||
if (abu1 != null)
|
||||
{
|
||||
abs abs1 = abu1.b();
|
||||
if (abs1 instanceof zs)
|
||||
{
|
||||
a(bop.a((zs)abs1, i, "overlay"));
|
||||
GL11.glColor3f(1.0F, 1.0F, 1.0F);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void a(bma bma1, double d, double d1, double d2,
|
||||
float f1, float f2)
|
||||
{
|
||||
GL11.glColor3f(1.0F, 1.0F, 1.0F);
|
||||
abu abu1 = bma1.bm.h();
|
||||
g.m = h.m = f.m = abu1 == null ? 0 : 1;
|
||||
if (abu1 != null && bma1.bw() > 0)
|
||||
{
|
||||
acz acz1 = abu1.o();
|
||||
if (acz1 == acz.d)
|
||||
g.m = h.m = f.m = 3;
|
||||
else
|
||||
if (acz1 == acz.e)
|
||||
g.o = h.o = f.o = true;
|
||||
}
|
||||
g.n = h.n = f.n = bma1.am();
|
||||
double d3 = d1 - (double)bma1.L;
|
||||
if (bma1.am() && !(bma1 instanceof bmd))
|
||||
d3 -= 0.125D;
|
||||
super.a(bma1, d, d3, d2, f1, f2);
|
||||
g.o = h.o = f.o = false;
|
||||
g.n = h.n = f.n = false;
|
||||
g.m = h.m = f.m = 0;
|
||||
}
|
||||
|
||||
protected brq a(bma bma1)
|
||||
{
|
||||
return bma1.t();
|
||||
}
|
||||
|
||||
protected void a(bma bma1, float f1)
|
||||
{
|
||||
GL11.glColor3f(1.0F, 1.0F, 1.0F);
|
||||
super.c(bma1, f1);
|
||||
super.e(bma1, f1);
|
||||
abu abu1 = bma1.bm.d(3);
|
||||
if (abu1 != null)
|
||||
{
|
||||
GL11.glPushMatrix();
|
||||
f.c.c(0.0625F);
|
||||
if (abu1.b() instanceof zy)
|
||||
{
|
||||
if (bmf.a(ahz.a(abu1.b()).b()))
|
||||
{
|
||||
float f2 = 0.625F;
|
||||
GL11.glTranslatef(0.0F, -0.25F, 0.0F);
|
||||
GL11.glRotatef(90F, 0.0F, 1.0F, 0.0F);
|
||||
GL11.glScalef(f2, -f2, -f2);
|
||||
}
|
||||
b.f.a(bma1, abu1, 0);
|
||||
} else
|
||||
if (abu1.b() == abv.bL)
|
||||
{
|
||||
float f3 = 1.0625F;
|
||||
GL11.glScalef(f3, -f3, -f3);
|
||||
String s = "";
|
||||
if (abu1.p() && abu1.q().b("SkullOwner", 8))
|
||||
s = abu1.q().j("SkullOwner");
|
||||
bnl.b.a(-0.5F, 0.0F, -0.5F, 1, 180F, abu1.k(), s);
|
||||
}
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
if (bma1.b_().equals("deadmau5") && bma1.r().a())
|
||||
{
|
||||
a(bma1.t());
|
||||
for (int i = 0; i < 2; i++)
|
||||
{
|
||||
float f4 = (bma1.A + (bma1.y - bma1.A) * f1) - (bma1.aN + (bma1.aM - bma1.aN) * f1);
|
||||
float f5 = bma1.B + (bma1.z - bma1.B) * f1;
|
||||
GL11.glPushMatrix();
|
||||
GL11.glRotatef(f4, 0.0F, 1.0F, 0.0F);
|
||||
GL11.glRotatef(f5, 1.0F, 0.0F, 0.0F);
|
||||
GL11.glTranslatef(0.375F * (float)(i * 2 - 1), 0.0F, 0.0F);
|
||||
GL11.glTranslatef(0.0F, -0.375F, 0.0F);
|
||||
GL11.glRotatef(-f5, 1.0F, 0.0F, 0.0F);
|
||||
GL11.glRotatef(-f4, 0.0F, 1.0F, 0.0F);
|
||||
float f6 = 1.333333F;
|
||||
GL11.glScalef(f6, f6, f6);
|
||||
f.b(0.0625F);
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
}
|
||||
boolean flag = bma1.s().a();
|
||||
if (flag && !bma1.ao() && !bma1.bS())
|
||||
{
|
||||
a(bma1.u());
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslatef(0.0F, 0.0F, 0.125F);
|
||||
double d = (bma1.bu + (bma1.bx - bma1.bu) * (double)f1) - (bma1.p + (bma1.s - bma1.p) * (double)f1);
|
||||
double d1 = (bma1.bv + (bma1.by - bma1.bv) * (double)f1) - (bma1.q + (bma1.t - bma1.q) * (double)f1);
|
||||
double d2 = (bma1.bw + (bma1.bz - bma1.bw) * (double)f1) - (bma1.r + (bma1.u - bma1.r) * (double)f1);
|
||||
float f16 = bma1.aN + (bma1.aM - bma1.aN) * f1;
|
||||
double d3 = oy.a((f16 * 3.141593F) / 180F);
|
||||
double d4 = -oy.b((f16 * 3.141593F) / 180F);
|
||||
float f18 = (float)d1 * 10F;
|
||||
if (f18 < -6F)
|
||||
f18 = -6F;
|
||||
if (f18 > 32F)
|
||||
f18 = 32F;
|
||||
float f19 = (float)(d * d3 + d2 * d4) * 100F;
|
||||
float f20 = (float)(d * d4 - d2 * d3) * 100F;
|
||||
if (f19 < 0.0F)
|
||||
f19 = 0.0F;
|
||||
float f21 = bma1.br + (bma1.bs - bma1.br) * f1;
|
||||
f18 += oy.a((bma1.O + (bma1.P - bma1.O) * f1) * 6F) * 32F * f21;
|
||||
if (bma1.am())
|
||||
f18 += 25F;
|
||||
GL11.glRotatef(6F + f19 / 2.0F + f18, 1.0F, 0.0F, 0.0F);
|
||||
GL11.glRotatef(f20 / 2.0F, 0.0F, 0.0F, 1.0F);
|
||||
GL11.glRotatef(-f20 / 2.0F, 0.0F, 1.0F, 0.0F);
|
||||
GL11.glRotatef(180F, 0.0F, 1.0F, 0.0F);
|
||||
f.c(0.0625F);
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
abu abu2 = bma1.bm.h();
|
||||
if (abu2 != null)
|
||||
{
|
||||
GL11.glPushMatrix();
|
||||
f.f.c(0.0625F);
|
||||
GL11.glTranslatef(-0.0625F, 0.4375F, 0.0625F);
|
||||
if (bma1.bK != null)
|
||||
abu2 = new abu(abv.y);
|
||||
acz acz1 = null;
|
||||
if (bma1.bw() > 0)
|
||||
acz1 = abu2.o();
|
||||
if ((abu2.b() instanceof zy) && bmf.a(ahz.a(abu2.b()).b()))
|
||||
{
|
||||
float f7 = 0.5F;
|
||||
GL11.glTranslatef(0.0F, 0.1875F, -0.3125F);
|
||||
f7 *= 0.75F;
|
||||
GL11.glRotatef(20F, 1.0F, 0.0F, 0.0F);
|
||||
GL11.glRotatef(45F, 0.0F, 1.0F, 0.0F);
|
||||
GL11.glScalef(-f7, -f7, f7);
|
||||
} else
|
||||
if (abu2.b() == abv.f)
|
||||
{
|
||||
float f8 = 0.625F;
|
||||
GL11.glTranslatef(0.0F, 0.125F, 0.3125F);
|
||||
GL11.glRotatef(-20F, 0.0F, 1.0F, 0.0F);
|
||||
GL11.glScalef(f8, -f8, f8);
|
||||
GL11.glRotatef(-100F, 1.0F, 0.0F, 0.0F);
|
||||
GL11.glRotatef(45F, 0.0F, 1.0F, 0.0F);
|
||||
} else
|
||||
if (abu2.b().f())
|
||||
{
|
||||
float f9 = 0.625F;
|
||||
if (abu2.b().g())
|
||||
{
|
||||
GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F);
|
||||
GL11.glTranslatef(0.0F, -0.125F, 0.0F);
|
||||
}
|
||||
if (bma1.bw() > 0 && acz1 == acz.d)
|
||||
{
|
||||
GL11.glTranslatef(0.05F, 0.0F, -0.1F);
|
||||
GL11.glRotatef(-50F, 0.0F, 1.0F, 0.0F);
|
||||
GL11.glRotatef(-10F, 1.0F, 0.0F, 0.0F);
|
||||
GL11.glRotatef(-60F, 0.0F, 0.0F, 1.0F);
|
||||
}
|
||||
GL11.glTranslatef(0.0F, 0.1875F, 0.0F);
|
||||
GL11.glScalef(f9, -f9, f9);
|
||||
GL11.glRotatef(-100F, 1.0F, 0.0F, 0.0F);
|
||||
GL11.glRotatef(45F, 0.0F, 1.0F, 0.0F);
|
||||
} else
|
||||
{
|
||||
float f10 = 0.375F;
|
||||
GL11.glTranslatef(0.25F, 0.1875F, -0.1875F);
|
||||
GL11.glScalef(f10, f10, f10);
|
||||
GL11.glRotatef(60F, 0.0F, 0.0F, 1.0F);
|
||||
GL11.glRotatef(-90F, 1.0F, 0.0F, 0.0F);
|
||||
GL11.glRotatef(20F, 0.0F, 0.0F, 1.0F);
|
||||
}
|
||||
if (abu2.b().b())
|
||||
{
|
||||
for (int j = 0; j <= 1; j++)
|
||||
{
|
||||
int l = abu2.b().a(abu2, j);
|
||||
float f12 = (float)(l >> 16 & 0xff) / 255F;
|
||||
float f14 = (float)(l >> 8 & 0xff) / 255F;
|
||||
float f17 = (float)(l & 0xff) / 255F;
|
||||
GL11.glColor4f(f12, f14, f17, 1.0F);
|
||||
b.f.a(bma1, abu2, j);
|
||||
}
|
||||
|
||||
} else
|
||||
{
|
||||
int k = abu2.b().a(abu2, 0);
|
||||
float f11 = (float)(k >> 16 & 0xff) / 255F;
|
||||
float f13 = (float)(k >> 8 & 0xff) / 255F;
|
||||
float f15 = (float)(k & 0xff) / 255F;
|
||||
GL11.glColor4f(f11, f13, f15, 1.0F);
|
||||
b.f.a(bma1, abu2, 0);
|
||||
}
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
}
|
||||
|
||||
protected void b(bma bma1, float f1)
|
||||
{
|
||||
float f2 = 0.9375F;
|
||||
GL11.glScalef(f2, f2, f2);
|
||||
}
|
||||
|
||||
protected void a(bma bma1, double d, double d1, double d2,
|
||||
String s, float f1, double d3)
|
||||
{
|
||||
if (d3 < 100D)
|
||||
{
|
||||
ayw ayw1 = bma1.bT();
|
||||
ayr ayr1 = ayw1.a(2);
|
||||
if (ayr1 != null)
|
||||
{
|
||||
ayt ayt1 = ayw1.a(bma1.b_(), ayr1);
|
||||
if (bma1.bl())
|
||||
a(((qr) (bma1)), (new StringBuilder()).append(ayt1.c()).append(" ").append(ayr1.d()).toString(), d, d1 - 1.5D, d2, 64);
|
||||
else
|
||||
a(((qr) (bma1)), (new StringBuilder()).append(ayt1.c()).append(" ").append(ayr1.d()).toString(), d, d1, d2, 64);
|
||||
d1 += (float)c().a * 1.15F * f1;
|
||||
}
|
||||
}
|
||||
super.a(bma1, d, d1, d2, s, f1, d3);
|
||||
}
|
||||
|
||||
public void a(xq xq)
|
||||
{
|
||||
float f1 = 1.0F;
|
||||
GL11.glColor3f(f1, f1, f1);
|
||||
f.p = 0.0F;
|
||||
f.a(0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0625F, xq);
|
||||
f.f.a(0.0625F);
|
||||
}
|
||||
|
||||
protected void a(bma bma1, double d, double d1, double d2)
|
||||
{
|
||||
if (bma1.Y() && bma1.bl())
|
||||
super.a(bma1, d + (double)bma1.bC, d1 + (double)bma1.cc, d2 + (double)bma1.bD);
|
||||
else
|
||||
super.a(bma1, d, d1, d2);
|
||||
}
|
||||
|
||||
protected void a(bma bma1, float f1, float f2, float f3)
|
||||
{
|
||||
if (bma1.Y() && bma1.bl())
|
||||
{
|
||||
GL11.glRotatef(bma1.bJ(), 0.0F, 1.0F, 0.0F);
|
||||
GL11.glRotatef(a(((rm) (bma1))), 0.0F, 0.0F, 1.0F);
|
||||
GL11.glRotatef(270F, 0.0F, 1.0F, 0.0F);
|
||||
} else
|
||||
{
|
||||
super.a(bma1, f1, f2, f3);
|
||||
}
|
||||
}
|
||||
|
||||
protected volatile void a(rm rm, double d, double d1, double d2,
|
||||
String s, float f1, double d3)
|
||||
{
|
||||
a((bma)rm, d, d1, d2, s, f1, d3);
|
||||
}
|
||||
|
||||
protected void a(rm rm, float f1)
|
||||
{
|
||||
b((bma)rm, f1);
|
||||
}
|
||||
|
||||
protected void c(rm rm, int i, float f1)
|
||||
{
|
||||
b((bma)rm, i, f1);
|
||||
}
|
||||
|
||||
protected volatile int a(rm rm, int i, float f1)
|
||||
{
|
||||
return a((bma)rm, i, f1);
|
||||
}
|
||||
|
||||
protected void c(rm rm, float f1)
|
||||
{
|
||||
a((bma)rm, f1);
|
||||
}
|
||||
|
||||
protected volatile void a(rm rm, float f1, float f2, float f3)
|
||||
{
|
||||
a((bma)rm, f1, f2, f3);
|
||||
}
|
||||
|
||||
protected volatile void a(rm rm, double d, double d1, double d2)
|
||||
{
|
||||
a((bma)rm, d, d1, d2);
|
||||
}
|
||||
|
||||
public volatile void a(rm rm, double d, double d1, double d2,
|
||||
float f1, float f2)
|
||||
{
|
||||
a((bma)rm, d, d1, d2, f1, f2);
|
||||
}
|
||||
|
||||
protected volatile brq a(qr qr)
|
||||
{
|
||||
return a((bma)qr);
|
||||
}
|
||||
|
||||
public volatile void a(qr qr, double d, double d1, double d2,
|
||||
float f1, float f2)
|
||||
{
|
||||
a((bma)qr, d, d1, d2, f1, f2);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,80 +0,0 @@
|
||||
// Decompiled by Jad v1.5.8e2. Copyright 2001 Pavel Kouznetsov.
|
||||
// Jad home page: http://kpdus.tripod.com/jad.html
|
||||
// Decompiler options: packimports(3) fieldsfirst ansi space
|
||||
// Source File Name: SourceFile
|
||||
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
public class bqk extends bqn
|
||||
{
|
||||
|
||||
private static final AtomicInteger d = new AtomicInteger(0);
|
||||
private final String e;
|
||||
private final bmq f;
|
||||
private BufferedImage g;
|
||||
private Thread h;
|
||||
private boolean i;
|
||||
|
||||
public bqk(String s, brq brq, bmq bmq)
|
||||
{
|
||||
super(brq);
|
||||
e = s;
|
||||
f = bmq;
|
||||
}
|
||||
|
||||
private void e()
|
||||
{
|
||||
if (i)
|
||||
return;
|
||||
if (g != null)
|
||||
{
|
||||
if (b != null)
|
||||
c();
|
||||
brb.a(super.b(), g);
|
||||
i = true;
|
||||
}
|
||||
}
|
||||
|
||||
public int b()
|
||||
{
|
||||
e();
|
||||
return super.b();
|
||||
}
|
||||
|
||||
public void a(BufferedImage bufferedimage)
|
||||
{
|
||||
g = bufferedimage;
|
||||
}
|
||||
|
||||
public void a(brr brr1)
|
||||
{
|
||||
if (g == null && b != null)
|
||||
super.a(brr1);
|
||||
if (h == null)
|
||||
{
|
||||
h = new bql(this, (new StringBuilder()).append("Texture Downloader #").append(d.incrementAndGet()).toString());
|
||||
h.setDaemon(true);
|
||||
h.setName((new StringBuilder()).append("Skin downloader: ").append(e).toString());
|
||||
h.start();
|
||||
}
|
||||
}
|
||||
|
||||
public boolean a()
|
||||
{
|
||||
e();
|
||||
return i;
|
||||
}
|
||||
|
||||
static String a(bqk bqk1)
|
||||
{
|
||||
return bqk1.e;
|
||||
}
|
||||
|
||||
static bmq b(bqk bqk1)
|
||||
{
|
||||
return bqk1.f;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,41 +0,0 @@
|
||||
// Decompiled by Jad v1.5.8e2. Copyright 2001 Pavel Kouznetsov.
|
||||
// Jad home page: http://kpdus.tripod.com/jad.html
|
||||
// Decompiler options: packimports(3) fieldsfirst ansi space
|
||||
// Source File Name: SourceFile
|
||||
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import javax.imageio.ImageIO;
|
||||
|
||||
import idv.jlchntoz.CustomSkinLoader;
|
||||
class bql extends Thread
|
||||
{
|
||||
|
||||
final bqk a;
|
||||
|
||||
bql(bqk bqk1, String s)
|
||||
{
|
||||
a = bqk1;
|
||||
}
|
||||
|
||||
public void run()
|
||||
{
|
||||
CustomSkinLoader Loader = new CustomSkinLoader();
|
||||
|
||||
try
|
||||
{
|
||||
BufferedImage var2 = ImageIO.read(Loader.getPlayerSkinStream(bqk.a(a)));
|
||||
|
||||
a.a(var2);
|
||||
}
|
||||
catch (Exception var6)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
@echo off
|
||||
title CustomSkinLoader 1.7.4 Builder
|
||||
echo Please Build with Minecraft 1.7.4 classes
|
||||
echo Building CustomSkinLoader.java[Main]
|
||||
cd idv/jlchntoz
|
||||
javac CustomSkinLoader.java
|
||||
cd ../..
|
||||
echo Building bmv.java[For HD Skin]
|
||||
javac bmv.java
|
||||
echo Building bqk.java[DownloadImage]
|
||||
javac bqk.java
|
||||
echo Building bql.java[ThreadDownloadImage]
|
||||
javac bql.java
|
||||
pause
|
||||
@@ -1,189 +0,0 @@
|
||||
package idv.jlchntoz;
|
||||
|
||||
import java.io.*;
|
||||
import java.net.*;
|
||||
import java.util.logging.*;
|
||||
import java.util.regex.*;
|
||||
|
||||
/**
|
||||
* Custom skin loader mod for Minecraft.
|
||||
*
|
||||
* @version 10th Revision 1st Subversion 2014.4.20
|
||||
* @author (C) Jeremy Lam [JLChnToZ] 2013 & Alexander Xia [xfl03] 2014
|
||||
*/
|
||||
public class CustomSkinLoader {
|
||||
public final static String DefaultSkinURL = "http://skins.minecraft.net/MinecraftSkins/*.png";
|
||||
public final static String DefaultCloakURL = "http://skins.minecraft.net/MinecraftCloaks/*.png";
|
||||
private final static Pattern newURLPattern = Pattern.compile("^http://skins.minecraft.net/Minecraft(Skin|Cloak)s/(.*?).png$"),
|
||||
oldURLPattern = Pattern.compile("^http://s3.amazonaws.com/Minecraft(Skin|Cloak)s/(.*?).png$");
|
||||
|
||||
private final static Logger logger = Logger
|
||||
.getLogger(CustomSkinLoader.class.getName());
|
||||
|
||||
private static String[] cloakURLs = null, skinURLs = null;
|
||||
|
||||
private HttpURLConnection C = null;
|
||||
|
||||
public InputStream getPlayerSkinStream(String path) {
|
||||
Matcher m = newURLPattern.matcher(path);
|
||||
if (!m.matches())//Is not new url
|
||||
{
|
||||
m = oldURLPattern.matcher(path);//If is old url
|
||||
}
|
||||
if (m.matches()) {
|
||||
if (m.group(1).contains("Skin")) // Skin
|
||||
return getPlayerSkinStream(false, m.group(2));
|
||||
else if (m.group(1).contains("Cloak")) // Cloak
|
||||
return getPlayerSkinStream(true, m.group(2));
|
||||
}
|
||||
return getStream(path, false); // Neither skin nor cloak...
|
||||
}
|
||||
|
||||
public InputStream getPlayerSkinStream(Boolean isCloak, String playerName) {
|
||||
if (skinURLs == null || cloakURLs == null || skinURLs.length <= 0
|
||||
|| cloakURLs.length <= 0)
|
||||
refreshSkinURL(); // If the list is blank or null, try to load
|
||||
// again.
|
||||
for (String l : isCloak ? cloakURLs : skinURLs) {
|
||||
if(l==null||l.equalsIgnoreCase(""))
|
||||
continue;
|
||||
String loc = str_replace("*", playerName, l);
|
||||
logger.log(Level.INFO, "Try to load " + (isCloak ? "cloak" : "skin") + " in " + loc);
|
||||
InputStream S = getStream(loc, true);
|
||||
if (S == null)
|
||||
logger.log(Level.INFO, "No " + (isCloak ? "cloak" : "skin")
|
||||
+ " found in " + loc);
|
||||
else
|
||||
return S;
|
||||
}
|
||||
logger.log(Level.INFO, "Try to load skin in default URL instead.");
|
||||
return getStream(str_replace("*", playerName, isCloak ? DefaultCloakURL : DefaultSkinURL), true);
|
||||
}
|
||||
|
||||
private InputStream getStream(String URL, Boolean CheckPNG) {
|
||||
try {
|
||||
URL U = new URL(URL);
|
||||
C = (HttpURLConnection) U.openConnection();
|
||||
C.setDoInput(true);
|
||||
C.setDoOutput(false);
|
||||
C.connect();
|
||||
int respcode = C.getResponseCode() / 100;
|
||||
if (respcode != 4 && respcode != 5) { // Successful (?) to get skin.
|
||||
BufferedInputStream IS = new BufferedInputStream(
|
||||
C.getInputStream());
|
||||
if (!CheckPNG) // If no need to check PNG header, just skip it.
|
||||
return IS;
|
||||
IS.mark(0);
|
||||
byte[] ib = new byte[4];
|
||||
IS.read(ib);
|
||||
if (ib[1] == (byte) 'P' && ib[2] == (byte) 'N'
|
||||
&& ib[3] == (byte) 'G') { // Check PNG Header if needed
|
||||
IS.reset();
|
||||
return IS;
|
||||
}
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
logger.log(Level.WARNING, ex.getMessage());
|
||||
} finally {
|
||||
disconnect();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void disconnect() {
|
||||
if (C != null)
|
||||
C.disconnect();
|
||||
}
|
||||
|
||||
private static void refreshSkinURL() {
|
||||
try {
|
||||
File mcdir = new File("");
|
||||
skinURLs = readAllLines(mcdir, "skinurls.txt");
|
||||
cloakURLs = readAllLines(mcdir, "capeurls.txt");
|
||||
} catch (Exception ex) {
|
||||
logger.log(Level.WARNING, ex.getMessage());
|
||||
} finally {
|
||||
logger.log(Level.INFO, "Skin URLs Refreshed. Skin count = "
|
||||
+ skinURLs.length + ", Cloak count = " + cloakURLs.length);
|
||||
}
|
||||
}
|
||||
|
||||
private static String[] readAllLines(File mcdir, String path) {
|
||||
try {
|
||||
File F = new File(mcdir, path);
|
||||
logger.log(Level.INFO, "Config file: " + F.getAbsolutePath());
|
||||
if (!F.exists()) {
|
||||
logger.log(Level.INFO, "Config file not found, create new one.");
|
||||
de(mcdir);
|
||||
return new String[0];
|
||||
} else if (F.length() <= 0) {
|
||||
logger.log(Level.INFO, "Config file is blank, skipped.");
|
||||
return new String[0];
|
||||
} else {
|
||||
byte[] b = new byte[(int) F.length()];
|
||||
BufferedInputStream S = new BufferedInputStream(
|
||||
new FileInputStream(F));
|
||||
S.read(b);
|
||||
S.close();
|
||||
logger.log(Level.INFO, "Config file loaded.");
|
||||
String[] re= str_replace("\r", "\n",
|
||||
str_replace("\r\n", "\n", new String(b))).split("\n");
|
||||
for(int i=0;i<re.length;i++){
|
||||
if(re[i].startsWith("#"))
|
||||
re[i]=null;
|
||||
else{
|
||||
for(int g=0;g<re.length;g++){
|
||||
if(i==g)
|
||||
continue;
|
||||
if(re[i].equalsIgnoreCase(re[g])){
|
||||
re[i]=null;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return re;
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
logger.log(Level.WARNING, ex.getMessage());
|
||||
return new String[0];
|
||||
}
|
||||
}
|
||||
|
||||
private static String str_replace(String search, String replace,
|
||||
String subject) {
|
||||
StringBuffer result = new StringBuffer(subject);
|
||||
int pos;
|
||||
while ((pos = result.indexOf(search)) != -1)
|
||||
result.replace(pos, pos + search.length(), replace);
|
||||
return result.toString();
|
||||
}
|
||||
public static void de(File mcdir){
|
||||
File a=new File(mcdir,"CustomSkinLoaderGUI.jar");
|
||||
if(!a.exists())
|
||||
downloadFile("https://raw.githubusercontent.com/JLChnToZ/MCCustomSkinLoader/GUI/CustomSkinLoaderGUI.jar",a.getAbsolutePath());
|
||||
try{
|
||||
Runtime.getRuntime().exec("java -jar \""+a.getAbsolutePath()+"\" f");
|
||||
}catch(Exception e){
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
public static boolean downloadFile(String remote,String local){
|
||||
try {
|
||||
int byteRead = 0;
|
||||
URL url = new URL(remote);
|
||||
URLConnection conn = url.openConnection();
|
||||
InputStream inStream = conn.getInputStream();
|
||||
FileOutputStream fs = new FileOutputStream(local);
|
||||
byte[] buffer = new byte[1204];
|
||||
while (( byteRead = inStream.read(buffer)) != -1) {
|
||||
fs.write(buffer, 0, byteRead);
|
||||
}
|
||||
fs.close();
|
||||
return new File(local).exists();
|
||||
}catch (Exception e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
-124
@@ -1,124 +0,0 @@
|
||||
// Decompiled by Jad v1.5.8e2. Copyright 2001 Pavel Kouznetsov.
|
||||
// Jad home page: http://kpdus.tripod.com/jad.html
|
||||
// Decompiler options: packimports(3) fieldsfirst ansi space
|
||||
// Source File Name: bnb.java
|
||||
|
||||
import java.awt.Graphics;
|
||||
import java.awt.image.*;
|
||||
|
||||
public class bnb
|
||||
implements bmw
|
||||
{
|
||||
|
||||
private int a[];
|
||||
private int w23;
|
||||
private int h23;
|
||||
|
||||
public bnb()
|
||||
{
|
||||
}
|
||||
|
||||
public BufferedImage a(BufferedImage bufferedimage)
|
||||
{
|
||||
if (bufferedimage == null)
|
||||
return null;
|
||||
w23 = bufferedimage.getWidth(null);
|
||||
h23 = bufferedimage.getHeight(null);
|
||||
BufferedImage bufferedimage1 = new BufferedImage(w23, h23, 2);
|
||||
Graphics g = bufferedimage1.getGraphics();
|
||||
g.drawImage(bufferedimage, 0, 0, null);
|
||||
g.dispose();
|
||||
a = ((DataBufferInt)bufferedimage1.getRaster().getDataBuffer()).getData();
|
||||
if (w23 == 128 && h23 == 64)
|
||||
{
|
||||
b(0, 0, 0, 0);
|
||||
a(32, 0, 128, 64);
|
||||
b(0, 16, 0, 0);
|
||||
} else
|
||||
if (w23 == 256 && h23 == 128)
|
||||
{
|
||||
b(0, 0, 0, 0);
|
||||
a(32, 0, 256, 128);
|
||||
b(0, 16, 0, 0);
|
||||
} else
|
||||
if (w23 == 512 && h23 == 256)
|
||||
{
|
||||
b(0, 0, 32, 16);
|
||||
a(32, 0, 512, 256);
|
||||
b(0, 16, 0, 0);
|
||||
} else
|
||||
{
|
||||
b(0, 0, 32, 16);
|
||||
a(32, 0, 64, 32);
|
||||
b(0, 16, 64, 32);
|
||||
}
|
||||
boolean flag = false;
|
||||
for (int i = 32; i < 64; i++)
|
||||
{
|
||||
for (int k = 0; k < 16; k++)
|
||||
{
|
||||
int i1 = a[i + k * 64];
|
||||
if ((i1 >> 24 & 0xff) < 128)
|
||||
flag = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (!flag)
|
||||
{
|
||||
for (int j = 32; j < 64; j++)
|
||||
{
|
||||
for (int l = 0; l < 16; l++)
|
||||
{
|
||||
int j1 = a[j + l * 64];
|
||||
boolean flag1;
|
||||
if ((j1 >> 24 & 0xff) < 128)
|
||||
flag1 = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
return bufferedimage1;
|
||||
}
|
||||
|
||||
private void a(int i, int j, int k, int l)
|
||||
{
|
||||
if (c(i, j, k, l))
|
||||
return;
|
||||
for (int i1 = i; i1 < k; i1++)
|
||||
{
|
||||
for (int j1 = j; j1 < l; j1++)
|
||||
a[i1 + j1 * w23] &= 0xffffff;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void b(int i, int j, int k, int l)
|
||||
{
|
||||
for (int i1 = i; i1 < k; i1++)
|
||||
{
|
||||
for (int j1 = j; j1 < l; j1++)
|
||||
a[i1 + j1 * w23] |= 0xff000000;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private boolean c(int i, int j, int k, int l)
|
||||
{
|
||||
for (int i1 = i; i1 < k; i1++)
|
||||
{
|
||||
for (int j1 = j; j1 < l; j1++)
|
||||
{
|
||||
int k1 = a[i1 + j1 * w23];
|
||||
if ((k1 >> 24 & 0xff) < 128)
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -1,82 +0,0 @@
|
||||
// Decompiled by Jad v1.5.8e2. Copyright 2001 Pavel Kouznetsov.
|
||||
// Jad home page: http://kpdus.tripod.com/jad.html
|
||||
// Decompiler options: packimports(3) fieldsfirst ansi space
|
||||
// Source File Name: SourceFile
|
||||
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
|
||||
public class bqq extends bqt
|
||||
{
|
||||
|
||||
private static final AtomicInteger d = new AtomicInteger(0);
|
||||
private final String e;
|
||||
private final bmw f;
|
||||
private BufferedImage g;
|
||||
private Thread h;
|
||||
private boolean i;
|
||||
|
||||
public bqq(String s, brw brw, bmw bmw)
|
||||
{
|
||||
super(brw);
|
||||
e = s;
|
||||
f = bmw;
|
||||
}
|
||||
|
||||
private void e()
|
||||
{
|
||||
if (i)
|
||||
return;
|
||||
if (g != null)
|
||||
{
|
||||
if (b != null)
|
||||
c();
|
||||
brh.a(super.b(), g);
|
||||
i = true;
|
||||
}
|
||||
}
|
||||
|
||||
public int b()
|
||||
{
|
||||
e();
|
||||
return super.b();
|
||||
}
|
||||
|
||||
public void a(BufferedImage bufferedimage)
|
||||
{
|
||||
g = bufferedimage;
|
||||
}
|
||||
|
||||
public void a(brx brx1)
|
||||
{
|
||||
if (g == null && b != null)
|
||||
super.a(brx1);
|
||||
if (h == null)
|
||||
{
|
||||
h = new bqr(this, (new StringBuilder()).append("Texture Downloader #").append(d.incrementAndGet()).toString());
|
||||
h.setDaemon(true);
|
||||
h.setName((new StringBuilder()).append("Skin downloader: ").append(e).toString());
|
||||
h.start();
|
||||
}
|
||||
}
|
||||
|
||||
public boolean a()
|
||||
{
|
||||
e();
|
||||
return i;
|
||||
}
|
||||
|
||||
public static String a(bqq bqq1)
|
||||
{
|
||||
return bqq1.e;
|
||||
}
|
||||
|
||||
static bmw b(bqq bqq1)
|
||||
{
|
||||
return bqq1.f;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -1,37 +0,0 @@
|
||||
// Decompiled by Jad v1.5.8e2. Copyright 2001 Pavel Kouznetsov.
|
||||
// Jad home page: http://kpdus.tripod.com/jad.html
|
||||
// Decompiler options: packimports(3) fieldsfirst ansi space
|
||||
// Source File Name: SourceFile
|
||||
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import javax.imageio.ImageIO;
|
||||
|
||||
import idv.jlchntoz.CustomSkinLoader;
|
||||
class bqr extends Thread
|
||||
{
|
||||
|
||||
final bqq a;
|
||||
|
||||
bqr(bqq bqq1, String s)
|
||||
{
|
||||
a = bqq1;
|
||||
}
|
||||
|
||||
public void run()
|
||||
{
|
||||
CustomSkinLoader Loader = new CustomSkinLoader();
|
||||
|
||||
try
|
||||
{
|
||||
BufferedImage var2 = ImageIO.read(Loader.getPlayerSkinStream(bqq.a(a)));
|
||||
|
||||
a.a(var2);
|
||||
}
|
||||
catch (Exception var6)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
@echo off
|
||||
title CustomSkinLoader 1.7.5 Builder
|
||||
echo Please Build with Minecraft 1.7.5 classes
|
||||
echo Building CustomSkinLoader.java[Main]
|
||||
cd idv/jlchntoz
|
||||
javac CustomSkinLoader.java
|
||||
cd ../..
|
||||
echo Building bnb.java[For HD Skin]
|
||||
javac bnb.java
|
||||
echo Building bqq.java[DownloadImage]
|
||||
javac bqq.java
|
||||
echo Building bqr.java[ThreadDownloadImage]
|
||||
javac bqr.java
|
||||
pause
|
||||
@@ -1,189 +0,0 @@
|
||||
package idv.jlchntoz;
|
||||
|
||||
import java.io.*;
|
||||
import java.net.*;
|
||||
import java.util.logging.*;
|
||||
import java.util.regex.*;
|
||||
|
||||
/**
|
||||
* Custom skin loader mod for Minecraft.
|
||||
*
|
||||
* @version 10th Revision 1st Subversion 2014.4.20
|
||||
* @author (C) Jeremy Lam [JLChnToZ] 2013 & Alexander Xia [xfl03] 2014
|
||||
*/
|
||||
public class CustomSkinLoader {
|
||||
public final static String DefaultSkinURL = "http://skins.minecraft.net/MinecraftSkins/*.png";
|
||||
public final static String DefaultCloakURL = "http://skins.minecraft.net/MinecraftCloaks/*.png";
|
||||
private final static Pattern newURLPattern = Pattern.compile("^http://skins.minecraft.net/Minecraft(Skin|Cloak)s/(.*?).png$"),
|
||||
oldURLPattern = Pattern.compile("^http://s3.amazonaws.com/Minecraft(Skin|Cloak)s/(.*?).png$");
|
||||
|
||||
private final static Logger logger = Logger
|
||||
.getLogger(CustomSkinLoader.class.getName());
|
||||
|
||||
private static String[] cloakURLs = null, skinURLs = null;
|
||||
|
||||
private HttpURLConnection C = null;
|
||||
|
||||
public InputStream getPlayerSkinStream(String path) {
|
||||
Matcher m = newURLPattern.matcher(path);
|
||||
if (!m.matches())//Is not new url
|
||||
{
|
||||
m = oldURLPattern.matcher(path);//If is old url
|
||||
}
|
||||
if (m.matches()) {
|
||||
if (m.group(1).contains("Skin")) // Skin
|
||||
return getPlayerSkinStream(false, m.group(2));
|
||||
else if (m.group(1).contains("Cloak")) // Cloak
|
||||
return getPlayerSkinStream(true, m.group(2));
|
||||
}
|
||||
return getStream(path, false); // Neither skin nor cloak...
|
||||
}
|
||||
|
||||
public InputStream getPlayerSkinStream(Boolean isCloak, String playerName) {
|
||||
if (skinURLs == null || cloakURLs == null || skinURLs.length <= 0
|
||||
|| cloakURLs.length <= 0)
|
||||
refreshSkinURL(); // If the list is blank or null, try to load
|
||||
// again.
|
||||
for (String l : isCloak ? cloakURLs : skinURLs) {
|
||||
if(l==null||l.equalsIgnoreCase(""))
|
||||
continue;
|
||||
String loc = str_replace("*", playerName, l);
|
||||
logger.log(Level.INFO, "Try to load " + (isCloak ? "cloak" : "skin") + " in " + loc);
|
||||
InputStream S = getStream(loc, true);
|
||||
if (S == null)
|
||||
logger.log(Level.INFO, "No " + (isCloak ? "cloak" : "skin")
|
||||
+ " found in " + loc);
|
||||
else
|
||||
return S;
|
||||
}
|
||||
logger.log(Level.INFO, "Try to load skin in default URL instead.");
|
||||
return getStream(str_replace("*", playerName, isCloak ? DefaultCloakURL : DefaultSkinURL), true);
|
||||
}
|
||||
|
||||
private InputStream getStream(String URL, Boolean CheckPNG) {
|
||||
try {
|
||||
URL U = new URL(URL);
|
||||
C = (HttpURLConnection) U.openConnection();
|
||||
C.setDoInput(true);
|
||||
C.setDoOutput(false);
|
||||
C.connect();
|
||||
int respcode = C.getResponseCode() / 100;
|
||||
if (respcode != 4 && respcode != 5) { // Successful (?) to get skin.
|
||||
BufferedInputStream IS = new BufferedInputStream(
|
||||
C.getInputStream());
|
||||
if (!CheckPNG) // If no need to check PNG header, just skip it.
|
||||
return IS;
|
||||
IS.mark(0);
|
||||
byte[] ib = new byte[4];
|
||||
IS.read(ib);
|
||||
if (ib[1] == (byte) 'P' && ib[2] == (byte) 'N'
|
||||
&& ib[3] == (byte) 'G') { // Check PNG Header if needed
|
||||
IS.reset();
|
||||
return IS;
|
||||
}
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
logger.log(Level.WARNING, ex.getMessage());
|
||||
} finally {
|
||||
disconnect();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void disconnect() {
|
||||
if (C != null)
|
||||
C.disconnect();
|
||||
}
|
||||
|
||||
private static void refreshSkinURL() {
|
||||
try {
|
||||
File mcdir = new File("");
|
||||
skinURLs = readAllLines(mcdir, "skinurls.txt");
|
||||
cloakURLs = readAllLines(mcdir, "capeurls.txt");
|
||||
} catch (Exception ex) {
|
||||
logger.log(Level.WARNING, ex.getMessage());
|
||||
} finally {
|
||||
logger.log(Level.INFO, "Skin URLs Refreshed. Skin count = "
|
||||
+ skinURLs.length + ", Cloak count = " + cloakURLs.length);
|
||||
}
|
||||
}
|
||||
|
||||
private static String[] readAllLines(File mcdir, String path) {
|
||||
try {
|
||||
File F = new File(mcdir, path);
|
||||
logger.log(Level.INFO, "Config file: " + F.getAbsolutePath());
|
||||
if (!F.exists()) {
|
||||
logger.log(Level.INFO, "Config file not found, create new one.");
|
||||
de(mcdir);
|
||||
return new String[0];
|
||||
} else if (F.length() <= 0) {
|
||||
logger.log(Level.INFO, "Config file is blank, skipped.");
|
||||
return new String[0];
|
||||
} else {
|
||||
byte[] b = new byte[(int) F.length()];
|
||||
BufferedInputStream S = new BufferedInputStream(
|
||||
new FileInputStream(F));
|
||||
S.read(b);
|
||||
S.close();
|
||||
logger.log(Level.INFO, "Config file loaded.");
|
||||
String[] re= str_replace("\r", "\n",
|
||||
str_replace("\r\n", "\n", new String(b))).split("\n");
|
||||
for(int i=0;i<re.length;i++){
|
||||
if(re[i].startsWith("#"))
|
||||
re[i]=null;
|
||||
else{
|
||||
for(int g=0;g<re.length;g++){
|
||||
if(i==g)
|
||||
continue;
|
||||
if(re[i].equalsIgnoreCase(re[g])){
|
||||
re[i]=null;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return re;
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
logger.log(Level.WARNING, ex.getMessage());
|
||||
return new String[0];
|
||||
}
|
||||
}
|
||||
|
||||
private static String str_replace(String search, String replace,
|
||||
String subject) {
|
||||
StringBuffer result = new StringBuffer(subject);
|
||||
int pos;
|
||||
while ((pos = result.indexOf(search)) != -1)
|
||||
result.replace(pos, pos + search.length(), replace);
|
||||
return result.toString();
|
||||
}
|
||||
public static void de(File mcdir){
|
||||
File a=new File(mcdir,"CustomSkinLoaderGUI.jar");
|
||||
if(!a.exists())
|
||||
downloadFile("https://raw.githubusercontent.com/JLChnToZ/MCCustomSkinLoader/GUI/CustomSkinLoaderGUI.jar",a.getAbsolutePath());
|
||||
try{
|
||||
Runtime.getRuntime().exec("java -jar \""+a.getAbsolutePath()+"\" f");
|
||||
}catch(Exception e){
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
public static boolean downloadFile(String remote,String local){
|
||||
try {
|
||||
int byteRead = 0;
|
||||
URL url = new URL(remote);
|
||||
URLConnection conn = url.openConnection();
|
||||
InputStream inStream = conn.getInputStream();
|
||||
FileOutputStream fs = new FileOutputStream(local);
|
||||
byte[] buffer = new byte[1204];
|
||||
while (( byteRead = inStream.read(buffer)) != -1) {
|
||||
fs.write(buffer, 0, byteRead);
|
||||
}
|
||||
fs.close();
|
||||
return new File(local).exists();
|
||||
}catch (Exception e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
-128
@@ -1,128 +0,0 @@
|
||||
// Decompiled by Jad v1.5.8e2. Copyright 2001 Pavel Kouznetsov.
|
||||
// Jad home page: http://kpdus.tripod.com/jad.html
|
||||
// Decompiler options: packimports(3) fieldsfirst ansi space
|
||||
// Source File Name: SourceFile
|
||||
|
||||
import java.awt.Graphics;
|
||||
import java.awt.image.*;
|
||||
|
||||
public class bom
|
||||
implements boh
|
||||
{
|
||||
|
||||
private int a[];
|
||||
private int w23;
|
||||
private int h23;
|
||||
|
||||
public bom()
|
||||
{
|
||||
}
|
||||
|
||||
public BufferedImage a(BufferedImage bufferedimage)
|
||||
{
|
||||
if (bufferedimage == null)
|
||||
return null;
|
||||
w23 = bufferedimage.getWidth(null);
|
||||
h23 = bufferedimage.getHeight(null);
|
||||
BufferedImage bufferedimage1 = new BufferedImage(w23, h23, 2);
|
||||
Graphics g = bufferedimage1.getGraphics();
|
||||
g.drawImage(bufferedimage, 0, 0, null);
|
||||
g.dispose();
|
||||
a = ((DataBufferInt)bufferedimage1.getRaster().getDataBuffer()).getData();
|
||||
if (w23 == 128 && h23 == 64)
|
||||
{
|
||||
b(0, 0, 0, 0);
|
||||
a(32, 0, 128, 64);
|
||||
b(0, 16, 0, 0);
|
||||
} else
|
||||
if (w23 == 256 && h23 == 128)
|
||||
{
|
||||
b(0, 0, 0, 0);
|
||||
a(32, 0, 256, 128);
|
||||
b(0, 16, 0, 0);
|
||||
} else
|
||||
if (w23 == 512 && h23 == 256)
|
||||
{
|
||||
b(0, 0, 32, 16);
|
||||
a(32, 0, 512, 256);
|
||||
b(0, 16, 0, 0);
|
||||
} else
|
||||
{
|
||||
b(0, 0, 32, 16);
|
||||
a(32, 0, 64, 32);
|
||||
b(0, 16, 64, 32);
|
||||
}
|
||||
boolean flag = false;
|
||||
for (int i = 32; i < 64; i++)
|
||||
{
|
||||
for (int k = 0; k < 16; k++)
|
||||
{
|
||||
int i1 = a[i + k * 64];
|
||||
if ((i1 >> 24 & 0xff) < 128)
|
||||
flag = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (!flag)
|
||||
{
|
||||
for (int j = 32; j < 64; j++)
|
||||
{
|
||||
for (int l = 0; l < 16; l++)
|
||||
{
|
||||
int j1 = a[j + l * 64];
|
||||
boolean flag1;
|
||||
if ((j1 >> 24 & 0xff) < 128)
|
||||
flag1 = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
return bufferedimage1;
|
||||
}
|
||||
|
||||
public void a()
|
||||
{
|
||||
}
|
||||
|
||||
private void a(int i, int j, int k, int l)
|
||||
{
|
||||
if (c(i, j, k, l))
|
||||
return;
|
||||
for (int i1 = i; i1 < k; i1++)
|
||||
{
|
||||
for (int j1 = j; j1 < l; j1++)
|
||||
a[i1 + j1 * w23] &= 0xffffff;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void b(int i, int j, int k, int l)
|
||||
{
|
||||
for (int i1 = i; i1 < k; i1++)
|
||||
{
|
||||
for (int j1 = j; j1 < l; j1++)
|
||||
a[i1 + j1 * w23] |= 0xff000000;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private boolean c(int i, int j, int k, int l)
|
||||
{
|
||||
for (int i1 = i; i1 < k; i1++)
|
||||
{
|
||||
for (int j1 = j; j1 < l; j1++)
|
||||
{
|
||||
int k1 = a[i1 + j1 * w23];
|
||||
if ((k1 >> 24 & 0xff) < 128)
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
-105
@@ -1,105 +0,0 @@
|
||||
// Decompiled by Jad v1.5.8e2. Copyright 2001 Pavel Kouznetsov.
|
||||
// Jad home page: http://kpdus.tripod.com/jad.html
|
||||
// Decompiler options: packimports(3) fieldsfirst ansi space
|
||||
// Source File Name: SourceFile
|
||||
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import javax.imageio.ImageIO;
|
||||
|
||||
|
||||
public class bsb extends bse
|
||||
{
|
||||
|
||||
private static final AtomicInteger d = new AtomicInteger(0);
|
||||
private final File e;
|
||||
private final String f;
|
||||
private final boh g;
|
||||
private BufferedImage h;
|
||||
private Thread i;
|
||||
private boolean j;
|
||||
|
||||
public bsb(File file, String s, bth bth, boh boh1)
|
||||
{
|
||||
super(bth);
|
||||
e = file;
|
||||
f = s;
|
||||
g = boh1;
|
||||
}
|
||||
|
||||
private void f()
|
||||
{
|
||||
if (j)
|
||||
return;
|
||||
if (h != null)
|
||||
{
|
||||
if (b != null)
|
||||
c();
|
||||
bss.a(super.b(), h);
|
||||
j = true;
|
||||
}
|
||||
}
|
||||
|
||||
public int b()
|
||||
{
|
||||
f();
|
||||
return super.b();
|
||||
}
|
||||
|
||||
public void a(BufferedImage bufferedimage)
|
||||
{
|
||||
h = bufferedimage;
|
||||
if (g != null)
|
||||
g.a();
|
||||
}
|
||||
|
||||
public void a(bti bti1)
|
||||
{
|
||||
if (h == null && b != null)
|
||||
super.a(bti1);
|
||||
if (i == null)
|
||||
if (e != null && e.isFile())
|
||||
{
|
||||
try
|
||||
{
|
||||
h = ImageIO.read(e);
|
||||
if (g != null)
|
||||
a(g.a(h));
|
||||
}
|
||||
catch (IOException ioexception)
|
||||
{
|
||||
a();
|
||||
}
|
||||
} else
|
||||
{
|
||||
a();
|
||||
}
|
||||
}
|
||||
|
||||
protected void a()
|
||||
{
|
||||
i = new bsc(this, (new StringBuilder()).append("Texture Downloader #").append(d.incrementAndGet()).toString());
|
||||
i.setDaemon(true);
|
||||
i.start();
|
||||
}
|
||||
|
||||
static String a(bsb bsb1)
|
||||
{
|
||||
return bsb1.f;
|
||||
}
|
||||
|
||||
static File b(bsb bsb1)
|
||||
{
|
||||
return bsb1.e;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static boh c(bsb bsb1)
|
||||
{
|
||||
return bsb1.g;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,37 +0,0 @@
|
||||
// Decompiled by Jad v1.5.8e2. Copyright 2001 Pavel Kouznetsov.
|
||||
// Jad home page: http://kpdus.tripod.com/jad.html
|
||||
// Decompiler options: packimports(3) fieldsfirst ansi space
|
||||
// Source File Name: SourceFile
|
||||
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import javax.imageio.ImageIO;
|
||||
|
||||
import idv.jlchntoz.CustomSkinLoader;
|
||||
class bsc extends Thread
|
||||
{
|
||||
|
||||
final bsb a;
|
||||
|
||||
bsc(bsb bsb1, String s)
|
||||
{
|
||||
a = bsb1;
|
||||
}
|
||||
|
||||
public void run()
|
||||
{
|
||||
CustomSkinLoader Loader = new CustomSkinLoader();
|
||||
|
||||
try
|
||||
{
|
||||
BufferedImage var2 = ImageIO.read(Loader.getPlayerSkinStream(bsb.a(a)));
|
||||
|
||||
a.a(var2);
|
||||
}
|
||||
catch (Exception var6)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
@echo off
|
||||
title CustomSkinLoader 1.7.6 Builder
|
||||
echo Please Build with Minecraft 1.7.6 classes
|
||||
echo Building CustomSkinLoader.java[Main]
|
||||
cd idv/jlchntoz
|
||||
javac CustomSkinLoader.java
|
||||
cd ../..
|
||||
echo Building bom.java[For HD Skin]
|
||||
javac bom.java
|
||||
echo Building bsb.java[DownloadImage]
|
||||
javac bsb.java
|
||||
echo Building bsc.java[ThreadDownloadImage]
|
||||
javac bsc.java
|
||||
pause
|
||||
@@ -1,189 +0,0 @@
|
||||
package idv.jlchntoz;
|
||||
|
||||
import java.io.*;
|
||||
import java.net.*;
|
||||
import java.util.logging.*;
|
||||
import java.util.regex.*;
|
||||
|
||||
/**
|
||||
* Custom skin loader mod for Minecraft.
|
||||
*
|
||||
* @version 10th Revision 1st Subversion 2014.4.20
|
||||
* @author (C) Jeremy Lam [JLChnToZ] 2013 & Alexander Xia [xfl03] 2014
|
||||
*/
|
||||
public class CustomSkinLoader {
|
||||
public final static String DefaultSkinURL = "http://skins.minecraft.net/MinecraftSkins/*.png";
|
||||
public final static String DefaultCloakURL = "http://skins.minecraft.net/MinecraftCloaks/*.png";
|
||||
private final static Pattern newURLPattern = Pattern.compile("^http://skins.minecraft.net/Minecraft(Skin|Cloak)s/(.*?).png$"),
|
||||
oldURLPattern = Pattern.compile("^http://s3.amazonaws.com/Minecraft(Skin|Cloak)s/(.*?).png$");
|
||||
|
||||
private final static Logger logger = Logger
|
||||
.getLogger(CustomSkinLoader.class.getName());
|
||||
|
||||
private static String[] cloakURLs = null, skinURLs = null;
|
||||
|
||||
private HttpURLConnection C = null;
|
||||
|
||||
public InputStream getPlayerSkinStream(String path) {
|
||||
Matcher m = newURLPattern.matcher(path);
|
||||
if (!m.matches())//Is not new url
|
||||
{
|
||||
m = oldURLPattern.matcher(path);//If is old url
|
||||
}
|
||||
if (m.matches()) {
|
||||
if (m.group(1).contains("Skin")) // Skin
|
||||
return getPlayerSkinStream(false, m.group(2));
|
||||
else if (m.group(1).contains("Cloak")) // Cloak
|
||||
return getPlayerSkinStream(true, m.group(2));
|
||||
}
|
||||
return getStream(path, false); // Neither skin nor cloak...
|
||||
}
|
||||
|
||||
public InputStream getPlayerSkinStream(Boolean isCloak, String playerName) {
|
||||
if (skinURLs == null || cloakURLs == null || skinURLs.length <= 0
|
||||
|| cloakURLs.length <= 0)
|
||||
refreshSkinURL(); // If the list is blank or null, try to load
|
||||
// again.
|
||||
for (String l : isCloak ? cloakURLs : skinURLs) {
|
||||
if(l==null||l.equalsIgnoreCase(""))
|
||||
continue;
|
||||
String loc = str_replace("*", playerName, l);
|
||||
logger.log(Level.INFO, "Try to load " + (isCloak ? "cloak" : "skin") + " in " + loc);
|
||||
InputStream S = getStream(loc, true);
|
||||
if (S == null)
|
||||
logger.log(Level.INFO, "No " + (isCloak ? "cloak" : "skin")
|
||||
+ " found in " + loc);
|
||||
else
|
||||
return S;
|
||||
}
|
||||
logger.log(Level.INFO, "Try to load skin in default URL instead.");
|
||||
return getStream(str_replace("*", playerName, isCloak ? DefaultCloakURL : DefaultSkinURL), true);
|
||||
}
|
||||
|
||||
private InputStream getStream(String URL, Boolean CheckPNG) {
|
||||
try {
|
||||
URL U = new URL(URL);
|
||||
C = (HttpURLConnection) U.openConnection();
|
||||
C.setDoInput(true);
|
||||
C.setDoOutput(false);
|
||||
C.connect();
|
||||
int respcode = C.getResponseCode() / 100;
|
||||
if (respcode != 4 && respcode != 5) { // Successful (?) to get skin.
|
||||
BufferedInputStream IS = new BufferedInputStream(
|
||||
C.getInputStream());
|
||||
if (!CheckPNG) // If no need to check PNG header, just skip it.
|
||||
return IS;
|
||||
IS.mark(0);
|
||||
byte[] ib = new byte[4];
|
||||
IS.read(ib);
|
||||
if (ib[1] == (byte) 'P' && ib[2] == (byte) 'N'
|
||||
&& ib[3] == (byte) 'G') { // Check PNG Header if needed
|
||||
IS.reset();
|
||||
return IS;
|
||||
}
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
logger.log(Level.WARNING, ex.getMessage());
|
||||
} finally {
|
||||
disconnect();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void disconnect() {
|
||||
if (C != null)
|
||||
C.disconnect();
|
||||
}
|
||||
|
||||
private static void refreshSkinURL() {
|
||||
try {
|
||||
File mcdir = new File("");
|
||||
skinURLs = readAllLines(mcdir, "skinurls.txt");
|
||||
cloakURLs = readAllLines(mcdir, "capeurls.txt");
|
||||
} catch (Exception ex) {
|
||||
logger.log(Level.WARNING, ex.getMessage());
|
||||
} finally {
|
||||
logger.log(Level.INFO, "Skin URLs Refreshed. Skin count = "
|
||||
+ skinURLs.length + ", Cloak count = " + cloakURLs.length);
|
||||
}
|
||||
}
|
||||
|
||||
private static String[] readAllLines(File mcdir, String path) {
|
||||
try {
|
||||
File F = new File(mcdir, path);
|
||||
logger.log(Level.INFO, "Config file: " + F.getAbsolutePath());
|
||||
if (!F.exists()) {
|
||||
logger.log(Level.INFO, "Config file not found, create new one.");
|
||||
de(mcdir);
|
||||
return new String[0];
|
||||
} else if (F.length() <= 0) {
|
||||
logger.log(Level.INFO, "Config file is blank, skipped.");
|
||||
return new String[0];
|
||||
} else {
|
||||
byte[] b = new byte[(int) F.length()];
|
||||
BufferedInputStream S = new BufferedInputStream(
|
||||
new FileInputStream(F));
|
||||
S.read(b);
|
||||
S.close();
|
||||
logger.log(Level.INFO, "Config file loaded.");
|
||||
String[] re= str_replace("\r", "\n",
|
||||
str_replace("\r\n", "\n", new String(b))).split("\n");
|
||||
for(int i=0;i<re.length;i++){
|
||||
if(re[i].startsWith("#"))
|
||||
re[i]=null;
|
||||
else{
|
||||
for(int g=0;g<re.length;g++){
|
||||
if(i==g)
|
||||
continue;
|
||||
if(re[i].equalsIgnoreCase(re[g])){
|
||||
re[i]=null;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return re;
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
logger.log(Level.WARNING, ex.getMessage());
|
||||
return new String[0];
|
||||
}
|
||||
}
|
||||
|
||||
private static String str_replace(String search, String replace,
|
||||
String subject) {
|
||||
StringBuffer result = new StringBuffer(subject);
|
||||
int pos;
|
||||
while ((pos = result.indexOf(search)) != -1)
|
||||
result.replace(pos, pos + search.length(), replace);
|
||||
return result.toString();
|
||||
}
|
||||
public static void de(File mcdir){
|
||||
File a=new File(mcdir,"CustomSkinLoaderGUI.jar");
|
||||
if(!a.exists())
|
||||
downloadFile("https://raw.githubusercontent.com/JLChnToZ/MCCustomSkinLoader/GUI/CustomSkinLoaderGUI.jar",a.getAbsolutePath());
|
||||
try{
|
||||
Runtime.getRuntime().exec("java -jar \""+a.getAbsolutePath()+"\" f");
|
||||
}catch(Exception e){
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
public static boolean downloadFile(String remote,String local){
|
||||
try {
|
||||
int byteRead = 0;
|
||||
URL url = new URL(remote);
|
||||
URLConnection conn = url.openConnection();
|
||||
InputStream inStream = conn.getInputStream();
|
||||
FileOutputStream fs = new FileOutputStream(local);
|
||||
byte[] buffer = new byte[1204];
|
||||
while (( byteRead = inStream.read(buffer)) != -1) {
|
||||
fs.write(buffer, 0, byteRead);
|
||||
}
|
||||
fs.close();
|
||||
return new File(local).exists();
|
||||
}catch (Exception e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
-128
@@ -1,128 +0,0 @@
|
||||
// Decompiled by Jad v1.5.8e2. Copyright 2001 Pavel Kouznetsov.
|
||||
// Jad home page: http://kpdus.tripod.com/jad.html
|
||||
// Decompiler options: packimports(3) fieldsfirst ansi space
|
||||
// Source File Name: SourceFile
|
||||
|
||||
import java.awt.Graphics;
|
||||
import java.awt.image.*;
|
||||
|
||||
public class bom
|
||||
implements boh
|
||||
{
|
||||
|
||||
private int a[];
|
||||
private int w23;
|
||||
private int h23;
|
||||
|
||||
public bom()
|
||||
{
|
||||
}
|
||||
|
||||
public BufferedImage a(BufferedImage bufferedimage)
|
||||
{
|
||||
if (bufferedimage == null)
|
||||
return null;
|
||||
w23 = bufferedimage.getWidth(null);
|
||||
h23 = bufferedimage.getHeight(null);
|
||||
BufferedImage bufferedimage1 = new BufferedImage(w23, h23, 2);
|
||||
Graphics g = bufferedimage1.getGraphics();
|
||||
g.drawImage(bufferedimage, 0, 0, null);
|
||||
g.dispose();
|
||||
a = ((DataBufferInt)bufferedimage1.getRaster().getDataBuffer()).getData();
|
||||
if (w23 == 128 && h23 == 64)
|
||||
{
|
||||
b(0, 0, 0, 0);
|
||||
a(32, 0, 128, 64);
|
||||
b(0, 16, 0, 0);
|
||||
} else
|
||||
if (w23 == 256 && h23 == 128)
|
||||
{
|
||||
b(0, 0, 0, 0);
|
||||
a(32, 0, 256, 128);
|
||||
b(0, 16, 0, 0);
|
||||
} else
|
||||
if (w23 == 512 && h23 == 256)
|
||||
{
|
||||
b(0, 0, 32, 16);
|
||||
a(32, 0, 512, 256);
|
||||
b(0, 16, 0, 0);
|
||||
} else
|
||||
{
|
||||
b(0, 0, 32, 16);
|
||||
a(32, 0, 64, 32);
|
||||
b(0, 16, 64, 32);
|
||||
}
|
||||
boolean flag = false;
|
||||
for (int i = 32; i < 64; i++)
|
||||
{
|
||||
for (int k = 0; k < 16; k++)
|
||||
{
|
||||
int i1 = a[i + k * 64];
|
||||
if ((i1 >> 24 & 0xff) < 128)
|
||||
flag = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (!flag)
|
||||
{
|
||||
for (int j = 32; j < 64; j++)
|
||||
{
|
||||
for (int l = 0; l < 16; l++)
|
||||
{
|
||||
int j1 = a[j + l * 64];
|
||||
boolean flag1;
|
||||
if ((j1 >> 24 & 0xff) < 128)
|
||||
flag1 = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
return bufferedimage1;
|
||||
}
|
||||
|
||||
public void a()
|
||||
{
|
||||
}
|
||||
|
||||
private void a(int i, int j, int k, int l)
|
||||
{
|
||||
if (c(i, j, k, l))
|
||||
return;
|
||||
for (int i1 = i; i1 < k; i1++)
|
||||
{
|
||||
for (int j1 = j; j1 < l; j1++)
|
||||
a[i1 + j1 * w23] &= 0xffffff;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void b(int i, int j, int k, int l)
|
||||
{
|
||||
for (int i1 = i; i1 < k; i1++)
|
||||
{
|
||||
for (int j1 = j; j1 < l; j1++)
|
||||
a[i1 + j1 * w23] |= 0xff000000;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private boolean c(int i, int j, int k, int l)
|
||||
{
|
||||
for (int i1 = i; i1 < k; i1++)
|
||||
{
|
||||
for (int j1 = j; j1 < l; j1++)
|
||||
{
|
||||
int k1 = a[i1 + j1 * w23];
|
||||
if ((k1 >> 24 & 0xff) < 128)
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
-105
@@ -1,105 +0,0 @@
|
||||
// Decompiled by Jad v1.5.8e2. Copyright 2001 Pavel Kouznetsov.
|
||||
// Jad home page: http://kpdus.tripod.com/jad.html
|
||||
// Decompiler options: packimports(3) fieldsfirst ansi space
|
||||
// Source File Name: SourceFile
|
||||
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import javax.imageio.ImageIO;
|
||||
|
||||
|
||||
public class bsb extends bse
|
||||
{
|
||||
|
||||
private static final AtomicInteger d = new AtomicInteger(0);
|
||||
private final File e;
|
||||
private final String f;
|
||||
private final boh g;
|
||||
private BufferedImage h;
|
||||
private Thread i;
|
||||
private boolean j;
|
||||
|
||||
public bsb(File file, String s, bth bth, boh boh1)
|
||||
{
|
||||
super(bth);
|
||||
e = file;
|
||||
f = s;
|
||||
g = boh1;
|
||||
}
|
||||
|
||||
private void f()
|
||||
{
|
||||
if (j)
|
||||
return;
|
||||
if (h != null)
|
||||
{
|
||||
if (b != null)
|
||||
c();
|
||||
bss.a(super.b(), h);
|
||||
j = true;
|
||||
}
|
||||
}
|
||||
|
||||
public int b()
|
||||
{
|
||||
f();
|
||||
return super.b();
|
||||
}
|
||||
|
||||
public void a(BufferedImage bufferedimage)
|
||||
{
|
||||
h = bufferedimage;
|
||||
if (g != null)
|
||||
g.a();
|
||||
}
|
||||
|
||||
public void a(bti bti1)
|
||||
{
|
||||
if (h == null && b != null)
|
||||
super.a(bti1);
|
||||
if (i == null)
|
||||
if (e != null && e.isFile())
|
||||
{
|
||||
try
|
||||
{
|
||||
h = ImageIO.read(e);
|
||||
if (g != null)
|
||||
a(g.a(h));
|
||||
}
|
||||
catch (IOException ioexception)
|
||||
{
|
||||
a();
|
||||
}
|
||||
} else
|
||||
{
|
||||
a();
|
||||
}
|
||||
}
|
||||
|
||||
protected void a()
|
||||
{
|
||||
i = new bsc(this, (new StringBuilder()).append("Texture Downloader #").append(d.incrementAndGet()).toString());
|
||||
i.setDaemon(true);
|
||||
i.start();
|
||||
}
|
||||
|
||||
static String a(bsb bsb1)
|
||||
{
|
||||
return bsb1.f;
|
||||
}
|
||||
|
||||
static File b(bsb bsb1)
|
||||
{
|
||||
return bsb1.e;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static boh c(bsb bsb1)
|
||||
{
|
||||
return bsb1.g;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,37 +0,0 @@
|
||||
// Decompiled by Jad v1.5.8e2. Copyright 2001 Pavel Kouznetsov.
|
||||
// Jad home page: http://kpdus.tripod.com/jad.html
|
||||
// Decompiler options: packimports(3) fieldsfirst ansi space
|
||||
// Source File Name: SourceFile
|
||||
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import javax.imageio.ImageIO;
|
||||
|
||||
import idv.jlchntoz.CustomSkinLoader;
|
||||
class bsc extends Thread
|
||||
{
|
||||
|
||||
final bsb a;
|
||||
|
||||
bsc(bsb bsb1, String s)
|
||||
{
|
||||
a = bsb1;
|
||||
}
|
||||
|
||||
public void run()
|
||||
{
|
||||
CustomSkinLoader Loader = new CustomSkinLoader();
|
||||
|
||||
try
|
||||
{
|
||||
BufferedImage var2 = ImageIO.read(Loader.getPlayerSkinStream(bsb.a(a)));
|
||||
|
||||
a.a(var2);
|
||||
}
|
||||
catch (Exception var6)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
@echo off
|
||||
title CustomSkinLoader 1.7.7 Builder
|
||||
echo Please Build with Minecraft 1.7.7 classes
|
||||
echo Building CustomSkinLoader.java[Main]
|
||||
cd idv/jlchntoz
|
||||
javac CustomSkinLoader.java
|
||||
cd ../..
|
||||
echo Building bom.java[For HD Skin]
|
||||
javac bom.java
|
||||
echo Building bsb.java[DownloadImage]
|
||||
javac bsb.java
|
||||
echo Building bsc.java[ThreadDownloadImage]
|
||||
javac bsc.java
|
||||
pause
|
||||
@@ -1,189 +0,0 @@
|
||||
package idv.jlchntoz;
|
||||
|
||||
import java.io.*;
|
||||
import java.net.*;
|
||||
import java.util.logging.*;
|
||||
import java.util.regex.*;
|
||||
|
||||
/**
|
||||
* Custom skin loader mod for Minecraft.
|
||||
*
|
||||
* @version 10th Revision 1st Subversion 2014.4.20
|
||||
* @author (C) Jeremy Lam [JLChnToZ] 2013 & Alexander Xia [xfl03] 2014
|
||||
*/
|
||||
public class CustomSkinLoader {
|
||||
public final static String DefaultSkinURL = "http://skins.minecraft.net/MinecraftSkins/*.png";
|
||||
public final static String DefaultCloakURL = "http://skins.minecraft.net/MinecraftCloaks/*.png";
|
||||
private final static Pattern newURLPattern = Pattern.compile("^http://skins.minecraft.net/Minecraft(Skin|Cloak)s/(.*?).png$"),
|
||||
oldURLPattern = Pattern.compile("^http://s3.amazonaws.com/Minecraft(Skin|Cloak)s/(.*?).png$");
|
||||
|
||||
private final static Logger logger = Logger
|
||||
.getLogger(CustomSkinLoader.class.getName());
|
||||
|
||||
private static String[] cloakURLs = null, skinURLs = null;
|
||||
|
||||
private HttpURLConnection C = null;
|
||||
|
||||
public InputStream getPlayerSkinStream(String path) {
|
||||
Matcher m = newURLPattern.matcher(path);
|
||||
if (!m.matches())//Is not new url
|
||||
{
|
||||
m = oldURLPattern.matcher(path);//If is old url
|
||||
}
|
||||
if (m.matches()) {
|
||||
if (m.group(1).contains("Skin")) // Skin
|
||||
return getPlayerSkinStream(false, m.group(2));
|
||||
else if (m.group(1).contains("Cloak")) // Cloak
|
||||
return getPlayerSkinStream(true, m.group(2));
|
||||
}
|
||||
return getStream(path, false); // Neither skin nor cloak...
|
||||
}
|
||||
|
||||
public InputStream getPlayerSkinStream(Boolean isCloak, String playerName) {
|
||||
if (skinURLs == null || cloakURLs == null || skinURLs.length <= 0
|
||||
|| cloakURLs.length <= 0)
|
||||
refreshSkinURL(); // If the list is blank or null, try to load
|
||||
// again.
|
||||
for (String l : isCloak ? cloakURLs : skinURLs) {
|
||||
if(l==null||l.equalsIgnoreCase(""))
|
||||
continue;
|
||||
String loc = str_replace("*", playerName, l);
|
||||
logger.log(Level.INFO, "Try to load " + (isCloak ? "cloak" : "skin") + " in " + loc);
|
||||
InputStream S = getStream(loc, true);
|
||||
if (S == null)
|
||||
logger.log(Level.INFO, "No " + (isCloak ? "cloak" : "skin")
|
||||
+ " found in " + loc);
|
||||
else
|
||||
return S;
|
||||
}
|
||||
logger.log(Level.INFO, "Try to load skin in default URL instead.");
|
||||
return getStream(str_replace("*", playerName, isCloak ? DefaultCloakURL : DefaultSkinURL), true);
|
||||
}
|
||||
|
||||
private InputStream getStream(String URL, Boolean CheckPNG) {
|
||||
try {
|
||||
URL U = new URL(URL);
|
||||
C = (HttpURLConnection) U.openConnection();
|
||||
C.setDoInput(true);
|
||||
C.setDoOutput(false);
|
||||
C.connect();
|
||||
int respcode = C.getResponseCode() / 100;
|
||||
if (respcode != 4 && respcode != 5) { // Successful (?) to get skin.
|
||||
BufferedInputStream IS = new BufferedInputStream(
|
||||
C.getInputStream());
|
||||
if (!CheckPNG) // If no need to check PNG header, just skip it.
|
||||
return IS;
|
||||
IS.mark(0);
|
||||
byte[] ib = new byte[4];
|
||||
IS.read(ib);
|
||||
if (ib[1] == (byte) 'P' && ib[2] == (byte) 'N'
|
||||
&& ib[3] == (byte) 'G') { // Check PNG Header if needed
|
||||
IS.reset();
|
||||
return IS;
|
||||
}
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
logger.log(Level.WARNING, ex.getMessage());
|
||||
} finally {
|
||||
disconnect();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void disconnect() {
|
||||
if (C != null)
|
||||
C.disconnect();
|
||||
}
|
||||
|
||||
private static void refreshSkinURL() {
|
||||
try {
|
||||
File mcdir = new File("");
|
||||
skinURLs = readAllLines(mcdir, "skinurls.txt");
|
||||
cloakURLs = readAllLines(mcdir, "capeurls.txt");
|
||||
} catch (Exception ex) {
|
||||
logger.log(Level.WARNING, ex.getMessage());
|
||||
} finally {
|
||||
logger.log(Level.INFO, "Skin URLs Refreshed. Skin count = "
|
||||
+ skinURLs.length + ", Cloak count = " + cloakURLs.length);
|
||||
}
|
||||
}
|
||||
|
||||
private static String[] readAllLines(File mcdir, String path) {
|
||||
try {
|
||||
File F = new File(mcdir, path);
|
||||
logger.log(Level.INFO, "Config file: " + F.getAbsolutePath());
|
||||
if (!F.exists()) {
|
||||
logger.log(Level.INFO, "Config file not found, create new one.");
|
||||
de(mcdir);
|
||||
return new String[0];
|
||||
} else if (F.length() <= 0) {
|
||||
logger.log(Level.INFO, "Config file is blank, skipped.");
|
||||
return new String[0];
|
||||
} else {
|
||||
byte[] b = new byte[(int) F.length()];
|
||||
BufferedInputStream S = new BufferedInputStream(
|
||||
new FileInputStream(F));
|
||||
S.read(b);
|
||||
S.close();
|
||||
logger.log(Level.INFO, "Config file loaded.");
|
||||
String[] re= str_replace("\r", "\n",
|
||||
str_replace("\r\n", "\n", new String(b))).split("\n");
|
||||
for(int i=0;i<re.length;i++){
|
||||
if(re[i].startsWith("#"))
|
||||
re[i]=null;
|
||||
else{
|
||||
for(int g=0;g<re.length;g++){
|
||||
if(i==g)
|
||||
continue;
|
||||
if(re[i].equalsIgnoreCase(re[g])){
|
||||
re[i]=null;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return re;
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
logger.log(Level.WARNING, ex.getMessage());
|
||||
return new String[0];
|
||||
}
|
||||
}
|
||||
|
||||
private static String str_replace(String search, String replace,
|
||||
String subject) {
|
||||
StringBuffer result = new StringBuffer(subject);
|
||||
int pos;
|
||||
while ((pos = result.indexOf(search)) != -1)
|
||||
result.replace(pos, pos + search.length(), replace);
|
||||
return result.toString();
|
||||
}
|
||||
public static void de(File mcdir){
|
||||
File a=new File(mcdir,"CustomSkinLoaderGUI.jar");
|
||||
if(!a.exists())
|
||||
downloadFile("https://raw.githubusercontent.com/JLChnToZ/MCCustomSkinLoader/GUI/CustomSkinLoaderGUI.jar",a.getAbsolutePath());
|
||||
try{
|
||||
Runtime.getRuntime().exec("java -jar \""+a.getAbsolutePath()+"\" f");
|
||||
}catch(Exception e){
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
public static boolean downloadFile(String remote,String local){
|
||||
try {
|
||||
int byteRead = 0;
|
||||
URL url = new URL(remote);
|
||||
URLConnection conn = url.openConnection();
|
||||
InputStream inStream = conn.getInputStream();
|
||||
FileOutputStream fs = new FileOutputStream(local);
|
||||
byte[] buffer = new byte[1204];
|
||||
while (( byteRead = inStream.read(buffer)) != -1) {
|
||||
fs.write(buffer, 0, byteRead);
|
||||
}
|
||||
fs.close();
|
||||
return new File(local).exists();
|
||||
}catch (Exception e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
-128
@@ -1,128 +0,0 @@
|
||||
// Decompiled by Jad v1.5.8e2. Copyright 2001 Pavel Kouznetsov.
|
||||
// Jad home page: http://kpdus.tripod.com/jad.html
|
||||
// Decompiler options: packimports(3) fieldsfirst ansi space
|
||||
// Source File Name: SourceFile
|
||||
|
||||
import java.awt.Graphics;
|
||||
import java.awt.image.*;
|
||||
|
||||
public class boo
|
||||
implements boj
|
||||
{
|
||||
|
||||
private int a[];
|
||||
private int b;
|
||||
private int c;
|
||||
|
||||
public boo()
|
||||
{
|
||||
}
|
||||
|
||||
public BufferedImage a(BufferedImage bufferedimage)
|
||||
{
|
||||
if (bufferedimage == null)
|
||||
return null;
|
||||
b = bufferedimage.getWidth(null);
|
||||
c = bufferedimage.getHeight(null);
|
||||
BufferedImage bufferedimage1 = new BufferedImage(b, c, 2);
|
||||
Graphics g = bufferedimage1.getGraphics();
|
||||
g.drawImage(bufferedimage, 0, 0, null);
|
||||
g.dispose();
|
||||
a = ((DataBufferInt)bufferedimage1.getRaster().getDataBuffer()).getData();
|
||||
if (b == 128 && c == 64)
|
||||
{
|
||||
b(0, 0, 0, 0);
|
||||
a(32, 0, 128, 64);
|
||||
b(0, 16, 0, 0);
|
||||
} else
|
||||
if (b == 256 && c == 128)
|
||||
{
|
||||
b(0, 0, 0, 0);
|
||||
a(32, 0, 256, 128);
|
||||
b(0, 16, 0, 0);
|
||||
} else
|
||||
if (b == 512 && c == 256)
|
||||
{
|
||||
b(0, 0, 32, 16);
|
||||
a(32, 0, 512, 256);
|
||||
b(0, 16, 0, 0);
|
||||
} else
|
||||
{
|
||||
b(0, 0, 32, 16);
|
||||
a(32, 0, 64, 32);
|
||||
b(0, 16, 64, 32);
|
||||
}
|
||||
boolean flag = false;
|
||||
for (int i = 32; i < 64; i++)
|
||||
{
|
||||
for (int k = 0; k < 16; k++)
|
||||
{
|
||||
int i1 = a[i + k * 64];
|
||||
if ((i1 >> 24 & 0xff) < 128)
|
||||
flag = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (!flag)
|
||||
{
|
||||
for (int j = 32; j < 64; j++)
|
||||
{
|
||||
for (int l = 0; l < 16; l++)
|
||||
{
|
||||
int j1 = a[j + l * 64];
|
||||
boolean flag1;
|
||||
if ((j1 >> 24 & 0xff) < 128)
|
||||
flag1 = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
return bufferedimage1;
|
||||
}
|
||||
|
||||
public void a()
|
||||
{
|
||||
}
|
||||
|
||||
private void a(int i, int j, int k, int l)
|
||||
{
|
||||
if (c(i, j, k, l))
|
||||
return;
|
||||
for (int i1 = i; i1 < k; i1++)
|
||||
{
|
||||
for (int j1 = j; j1 < l; j1++)
|
||||
a[i1 + j1 * b] &= 0xffffff;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void b(int i, int j, int k, int l)
|
||||
{
|
||||
for (int i1 = i; i1 < k; i1++)
|
||||
{
|
||||
for (int j1 = j; j1 < l; j1++)
|
||||
a[i1 + j1 * b] |= 0xff000000;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private boolean c(int i, int j, int k, int l)
|
||||
{
|
||||
for (int i1 = i; i1 < k; i1++)
|
||||
{
|
||||
for (int j1 = j; j1 < l; j1++)
|
||||
{
|
||||
int k1 = a[i1 + j1 * b];
|
||||
if ((k1 >> 24 & 0xff) < 128)
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
-106
@@ -1,106 +0,0 @@
|
||||
// Decompiled by Jad v1.5.8e2. Copyright 2001 Pavel Kouznetsov.
|
||||
// Jad home page: http://kpdus.tripod.com/jad.html
|
||||
// Decompiler options: packimports(3) fieldsfirst ansi space
|
||||
// Source File Name: SourceFile
|
||||
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import javax.imageio.ImageIO;
|
||||
|
||||
public class bsd extends bsg
|
||||
{
|
||||
|
||||
|
||||
private static final AtomicInteger d = new AtomicInteger(0);
|
||||
private final File e;
|
||||
private final String f;
|
||||
private final boj g;
|
||||
private BufferedImage h;
|
||||
private Thread i;
|
||||
private boolean j;
|
||||
|
||||
public bsd(File file, String s, btj btj, boj boj1)
|
||||
{
|
||||
super(btj);
|
||||
e = file;
|
||||
f = s;
|
||||
g = boj1;
|
||||
}
|
||||
|
||||
private void f()
|
||||
{
|
||||
if (j)
|
||||
return;
|
||||
if (h != null)
|
||||
{
|
||||
if (b != null)
|
||||
c();
|
||||
bsu.a(super.b(), h);
|
||||
j = true;
|
||||
}
|
||||
}
|
||||
|
||||
public int b()
|
||||
{
|
||||
f();
|
||||
return super.b();
|
||||
}
|
||||
|
||||
public void a(BufferedImage bufferedimage)
|
||||
{
|
||||
h = bufferedimage;
|
||||
if (g != null)
|
||||
g.a();
|
||||
}
|
||||
|
||||
public void a(btk btk1)
|
||||
{
|
||||
if (h == null && b != null)
|
||||
super.a(btk1);
|
||||
if (i == null)
|
||||
if (e != null && e.isFile())
|
||||
{
|
||||
|
||||
try
|
||||
{
|
||||
h = ImageIO.read(e);
|
||||
if (g != null)
|
||||
a(g.a(h));
|
||||
}
|
||||
catch (IOException ioexception)
|
||||
{
|
||||
|
||||
a();
|
||||
}
|
||||
} else
|
||||
{
|
||||
a();
|
||||
}
|
||||
}
|
||||
|
||||
protected void a()
|
||||
{
|
||||
i = new bse(this, (new StringBuilder()).append("Texture Downloader #").append(d.incrementAndGet()).toString());
|
||||
i.setDaemon(true);
|
||||
i.start();
|
||||
}
|
||||
|
||||
static String a(bsd bsd1)
|
||||
{
|
||||
return bsd1.f;
|
||||
}
|
||||
|
||||
static File b(bsd bsd1)
|
||||
{
|
||||
return bsd1.e;
|
||||
}
|
||||
|
||||
|
||||
static boj c(bsd bsd1)
|
||||
{
|
||||
return bsd1.g;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,38 +0,0 @@
|
||||
// Decompiled by Jad v1.5.8e2. Copyright 2001 Pavel Kouznetsov.
|
||||
// Jad home page: http://kpdus.tripod.com/jad.html
|
||||
// Decompiler options: packimports(3) fieldsfirst ansi space
|
||||
// Source File Name: SourceFile
|
||||
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import javax.imageio.ImageIO;
|
||||
|
||||
import idv.jlchntoz.CustomSkinLoader;
|
||||
|
||||
class bse extends Thread
|
||||
{
|
||||
|
||||
final bsd a;
|
||||
|
||||
bse(bsd bsd1, String s)
|
||||
{
|
||||
a = bsd1;
|
||||
}
|
||||
|
||||
public void run()
|
||||
{
|
||||
CustomSkinLoader Loader = new CustomSkinLoader();
|
||||
|
||||
try
|
||||
{
|
||||
BufferedImage var2 = ImageIO.read(Loader.getPlayerSkinStream(bsd.a(a)));
|
||||
|
||||
a.a(var2);
|
||||
}
|
||||
catch (Exception var6)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
@echo off
|
||||
title CustomSkinLoader 1.7.8 Builder
|
||||
echo Please Build with Minecraft 1.7.8 classes
|
||||
echo Building CustomSkinLoader.java[Main]
|
||||
cd idv/jlchntoz
|
||||
javac CustomSkinLoader.java
|
||||
cd ../..
|
||||
echo Building boo.java[For HD Skin]
|
||||
javac boo.java
|
||||
echo Building bsd.java[DownloadImage]
|
||||
javac bsd.java
|
||||
echo Building bse.java[ThreadDownloadImage]
|
||||
javac bse.java
|
||||
pause
|
||||
@@ -1,189 +0,0 @@
|
||||
package idv.jlchntoz;
|
||||
|
||||
import java.io.*;
|
||||
import java.net.*;
|
||||
import java.util.logging.*;
|
||||
import java.util.regex.*;
|
||||
|
||||
/**
|
||||
* Custom skin loader mod for Minecraft.
|
||||
*
|
||||
* @version 10th Revision 1st Subversion 2014.4.20
|
||||
* @author (C) Jeremy Lam [JLChnToZ] 2013 & Alexander Xia [xfl03] 2014
|
||||
*/
|
||||
public class CustomSkinLoader {
|
||||
public final static String DefaultSkinURL = "http://skins.minecraft.net/MinecraftSkins/*.png";
|
||||
public final static String DefaultCloakURL = "http://skins.minecraft.net/MinecraftCloaks/*.png";
|
||||
private final static Pattern newURLPattern = Pattern.compile("^http://skins.minecraft.net/Minecraft(Skin|Cloak)s/(.*?).png$"),
|
||||
oldURLPattern = Pattern.compile("^http://s3.amazonaws.com/Minecraft(Skin|Cloak)s/(.*?).png$");
|
||||
|
||||
private final static Logger logger = Logger
|
||||
.getLogger(CustomSkinLoader.class.getName());
|
||||
|
||||
private static String[] cloakURLs = null, skinURLs = null;
|
||||
|
||||
private HttpURLConnection C = null;
|
||||
|
||||
public InputStream getPlayerSkinStream(String path) {
|
||||
Matcher m = newURLPattern.matcher(path);
|
||||
if (!m.matches())//Is not new url
|
||||
{
|
||||
m = oldURLPattern.matcher(path);//If is old url
|
||||
}
|
||||
if (m.matches()) {
|
||||
if (m.group(1).contains("Skin")) // Skin
|
||||
return getPlayerSkinStream(false, m.group(2));
|
||||
else if (m.group(1).contains("Cloak")) // Cloak
|
||||
return getPlayerSkinStream(true, m.group(2));
|
||||
}
|
||||
return getStream(path, false); // Neither skin nor cloak...
|
||||
}
|
||||
|
||||
public InputStream getPlayerSkinStream(Boolean isCloak, String playerName) {
|
||||
if (skinURLs == null || cloakURLs == null || skinURLs.length <= 0
|
||||
|| cloakURLs.length <= 0)
|
||||
refreshSkinURL(); // If the list is blank or null, try to load
|
||||
// again.
|
||||
for (String l : isCloak ? cloakURLs : skinURLs) {
|
||||
if(l==null||l.equalsIgnoreCase(""))
|
||||
continue;
|
||||
String loc = str_replace("*", playerName, l);
|
||||
logger.log(Level.INFO, "Try to load " + (isCloak ? "cloak" : "skin") + " in " + loc);
|
||||
InputStream S = getStream(loc, true);
|
||||
if (S == null)
|
||||
logger.log(Level.INFO, "No " + (isCloak ? "cloak" : "skin")
|
||||
+ " found in " + loc);
|
||||
else
|
||||
return S;
|
||||
}
|
||||
logger.log(Level.INFO, "Try to load skin in default URL instead.");
|
||||
return getStream(str_replace("*", playerName, isCloak ? DefaultCloakURL : DefaultSkinURL), true);
|
||||
}
|
||||
|
||||
private InputStream getStream(String URL, Boolean CheckPNG) {
|
||||
try {
|
||||
URL U = new URL(URL);
|
||||
C = (HttpURLConnection) U.openConnection();
|
||||
C.setDoInput(true);
|
||||
C.setDoOutput(false);
|
||||
C.connect();
|
||||
int respcode = C.getResponseCode() / 100;
|
||||
if (respcode != 4 && respcode != 5) { // Successful (?) to get skin.
|
||||
BufferedInputStream IS = new BufferedInputStream(
|
||||
C.getInputStream());
|
||||
if (!CheckPNG) // If no need to check PNG header, just skip it.
|
||||
return IS;
|
||||
IS.mark(0);
|
||||
byte[] ib = new byte[4];
|
||||
IS.read(ib);
|
||||
if (ib[1] == (byte) 'P' && ib[2] == (byte) 'N'
|
||||
&& ib[3] == (byte) 'G') { // Check PNG Header if needed
|
||||
IS.reset();
|
||||
return IS;
|
||||
}
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
logger.log(Level.WARNING, ex.getMessage());
|
||||
} finally {
|
||||
disconnect();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void disconnect() {
|
||||
if (C != null)
|
||||
C.disconnect();
|
||||
}
|
||||
|
||||
private static void refreshSkinURL() {
|
||||
try {
|
||||
File mcdir = new File("");
|
||||
skinURLs = readAllLines(mcdir, "skinurls.txt");
|
||||
cloakURLs = readAllLines(mcdir, "capeurls.txt");
|
||||
} catch (Exception ex) {
|
||||
logger.log(Level.WARNING, ex.getMessage());
|
||||
} finally {
|
||||
logger.log(Level.INFO, "Skin URLs Refreshed. Skin count = "
|
||||
+ skinURLs.length + ", Cloak count = " + cloakURLs.length);
|
||||
}
|
||||
}
|
||||
|
||||
private static String[] readAllLines(File mcdir, String path) {
|
||||
try {
|
||||
File F = new File(mcdir, path);
|
||||
logger.log(Level.INFO, "Config file: " + F.getAbsolutePath());
|
||||
if (!F.exists()) {
|
||||
logger.log(Level.INFO, "Config file not found, create new one.");
|
||||
de(mcdir);
|
||||
return new String[0];
|
||||
} else if (F.length() <= 0) {
|
||||
logger.log(Level.INFO, "Config file is blank, skipped.");
|
||||
return new String[0];
|
||||
} else {
|
||||
byte[] b = new byte[(int) F.length()];
|
||||
BufferedInputStream S = new BufferedInputStream(
|
||||
new FileInputStream(F));
|
||||
S.read(b);
|
||||
S.close();
|
||||
logger.log(Level.INFO, "Config file loaded.");
|
||||
String[] re= str_replace("\r", "\n",
|
||||
str_replace("\r\n", "\n", new String(b))).split("\n");
|
||||
for(int i=0;i<re.length;i++){
|
||||
if(re[i].startsWith("#"))
|
||||
re[i]=null;
|
||||
else{
|
||||
for(int g=0;g<re.length;g++){
|
||||
if(i==g)
|
||||
continue;
|
||||
if(re[i].equalsIgnoreCase(re[g])){
|
||||
re[i]=null;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return re;
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
logger.log(Level.WARNING, ex.getMessage());
|
||||
return new String[0];
|
||||
}
|
||||
}
|
||||
|
||||
private static String str_replace(String search, String replace,
|
||||
String subject) {
|
||||
StringBuffer result = new StringBuffer(subject);
|
||||
int pos;
|
||||
while ((pos = result.indexOf(search)) != -1)
|
||||
result.replace(pos, pos + search.length(), replace);
|
||||
return result.toString();
|
||||
}
|
||||
public static void de(File mcdir){
|
||||
File a=new File(mcdir,"CustomSkinLoaderGUI.jar");
|
||||
if(!a.exists())
|
||||
downloadFile("https://raw.githubusercontent.com/JLChnToZ/MCCustomSkinLoader/GUI/CustomSkinLoaderGUI.jar",a.getAbsolutePath());
|
||||
try{
|
||||
Runtime.getRuntime().exec("java -jar \""+a.getAbsolutePath()+"\" f");
|
||||
}catch(Exception e){
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
public static boolean downloadFile(String remote,String local){
|
||||
try {
|
||||
int byteRead = 0;
|
||||
URL url = new URL(remote);
|
||||
URLConnection conn = url.openConnection();
|
||||
InputStream inStream = conn.getInputStream();
|
||||
FileOutputStream fs = new FileOutputStream(local);
|
||||
byte[] buffer = new byte[1204];
|
||||
while (( byteRead = inStream.read(buffer)) != -1) {
|
||||
fs.write(buffer, 0, byteRead);
|
||||
}
|
||||
fs.close();
|
||||
return new File(local).exists();
|
||||
}catch (Exception e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
-128
@@ -1,128 +0,0 @@
|
||||
// Decompiled by Jad v1.5.8e2. Copyright 2001 Pavel Kouznetsov.
|
||||
// Jad home page: http://kpdus.tripod.com/jad.html
|
||||
// Decompiler options: packimports(3) fieldsfirst ansi space
|
||||
// Source File Name: SourceFile
|
||||
|
||||
import java.awt.Graphics;
|
||||
import java.awt.image.*;
|
||||
|
||||
public class boo
|
||||
implements boj
|
||||
{
|
||||
|
||||
private int a[];
|
||||
private int b;
|
||||
private int c;
|
||||
|
||||
public boo()
|
||||
{
|
||||
}
|
||||
|
||||
public BufferedImage a(BufferedImage bufferedimage)
|
||||
{
|
||||
if (bufferedimage == null)
|
||||
return null;
|
||||
b = bufferedimage.getWidth(null);
|
||||
c = bufferedimage.getHeight(null);
|
||||
BufferedImage bufferedimage1 = new BufferedImage(b, c, 2);
|
||||
Graphics g = bufferedimage1.getGraphics();
|
||||
g.drawImage(bufferedimage, 0, 0, null);
|
||||
g.dispose();
|
||||
a = ((DataBufferInt)bufferedimage1.getRaster().getDataBuffer()).getData();
|
||||
if (b == 128 && c == 64)
|
||||
{
|
||||
b(0, 0, 0, 0);
|
||||
a(32, 0, 128, 64);
|
||||
b(0, 16, 0, 0);
|
||||
} else
|
||||
if (b == 256 && c == 128)
|
||||
{
|
||||
b(0, 0, 0, 0);
|
||||
a(32, 0, 256, 128);
|
||||
b(0, 16, 0, 0);
|
||||
} else
|
||||
if (b == 512 && c == 256)
|
||||
{
|
||||
b(0, 0, 32, 16);
|
||||
a(32, 0, 512, 256);
|
||||
b(0, 16, 0, 0);
|
||||
} else
|
||||
{
|
||||
b(0, 0, 32, 16);
|
||||
a(32, 0, 64, 32);
|
||||
b(0, 16, 64, 32);
|
||||
}
|
||||
boolean flag = false;
|
||||
for (int i = 32; i < 64; i++)
|
||||
{
|
||||
for (int k = 0; k < 16; k++)
|
||||
{
|
||||
int i1 = a[i + k * 64];
|
||||
if ((i1 >> 24 & 0xff) < 128)
|
||||
flag = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (!flag)
|
||||
{
|
||||
for (int j = 32; j < 64; j++)
|
||||
{
|
||||
for (int l = 0; l < 16; l++)
|
||||
{
|
||||
int j1 = a[j + l * 64];
|
||||
boolean flag1;
|
||||
if ((j1 >> 24 & 0xff) < 128)
|
||||
flag1 = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
return bufferedimage1;
|
||||
}
|
||||
|
||||
public void a()
|
||||
{
|
||||
}
|
||||
|
||||
private void a(int i, int j, int k, int l)
|
||||
{
|
||||
if (c(i, j, k, l))
|
||||
return;
|
||||
for (int i1 = i; i1 < k; i1++)
|
||||
{
|
||||
for (int j1 = j; j1 < l; j1++)
|
||||
a[i1 + j1 * b] &= 0xffffff;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void b(int i, int j, int k, int l)
|
||||
{
|
||||
for (int i1 = i; i1 < k; i1++)
|
||||
{
|
||||
for (int j1 = j; j1 < l; j1++)
|
||||
a[i1 + j1 * b] |= 0xff000000;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private boolean c(int i, int j, int k, int l)
|
||||
{
|
||||
for (int i1 = i; i1 < k; i1++)
|
||||
{
|
||||
for (int j1 = j; j1 < l; j1++)
|
||||
{
|
||||
int k1 = a[i1 + j1 * b];
|
||||
if ((k1 >> 24 & 0xff) < 128)
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
-106
@@ -1,106 +0,0 @@
|
||||
// Decompiled by Jad v1.5.8e2. Copyright 2001 Pavel Kouznetsov.
|
||||
// Jad home page: http://kpdus.tripod.com/jad.html
|
||||
// Decompiler options: packimports(3) fieldsfirst ansi space
|
||||
// Source File Name: SourceFile
|
||||
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import javax.imageio.ImageIO;
|
||||
|
||||
public class bsd extends bsg
|
||||
{
|
||||
|
||||
|
||||
private static final AtomicInteger d = new AtomicInteger(0);
|
||||
private final File e;
|
||||
private final String f;
|
||||
private final boj g;
|
||||
private BufferedImage h;
|
||||
private Thread i;
|
||||
private boolean j;
|
||||
|
||||
public bsd(File file, String s, btj btj, boj boj1)
|
||||
{
|
||||
super(btj);
|
||||
e = file;
|
||||
f = s;
|
||||
g = boj1;
|
||||
}
|
||||
|
||||
private void f()
|
||||
{
|
||||
if (j)
|
||||
return;
|
||||
if (h != null)
|
||||
{
|
||||
if (b != null)
|
||||
c();
|
||||
bsu.a(super.b(), h);
|
||||
j = true;
|
||||
}
|
||||
}
|
||||
|
||||
public int b()
|
||||
{
|
||||
f();
|
||||
return super.b();
|
||||
}
|
||||
|
||||
public void a(BufferedImage bufferedimage)
|
||||
{
|
||||
h = bufferedimage;
|
||||
if (g != null)
|
||||
g.a();
|
||||
}
|
||||
|
||||
public void a(btk btk1)
|
||||
{
|
||||
if (h == null && b != null)
|
||||
super.a(btk1);
|
||||
if (i == null)
|
||||
if (e != null && e.isFile())
|
||||
{
|
||||
|
||||
try
|
||||
{
|
||||
h = ImageIO.read(e);
|
||||
if (g != null)
|
||||
a(g.a(h));
|
||||
}
|
||||
catch (IOException ioexception)
|
||||
{
|
||||
|
||||
a();
|
||||
}
|
||||
} else
|
||||
{
|
||||
a();
|
||||
}
|
||||
}
|
||||
|
||||
protected void a()
|
||||
{
|
||||
i = new bse(this, (new StringBuilder()).append("Texture Downloader #").append(d.incrementAndGet()).toString());
|
||||
i.setDaemon(true);
|
||||
i.start();
|
||||
}
|
||||
|
||||
static String a(bsd bsd1)
|
||||
{
|
||||
return bsd1.f;
|
||||
}
|
||||
|
||||
static File b(bsd bsd1)
|
||||
{
|
||||
return bsd1.e;
|
||||
}
|
||||
|
||||
|
||||
static boj c(bsd bsd1)
|
||||
{
|
||||
return bsd1.g;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,38 +0,0 @@
|
||||
// Decompiled by Jad v1.5.8e2. Copyright 2001 Pavel Kouznetsov.
|
||||
// Jad home page: http://kpdus.tripod.com/jad.html
|
||||
// Decompiler options: packimports(3) fieldsfirst ansi space
|
||||
// Source File Name: SourceFile
|
||||
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import javax.imageio.ImageIO;
|
||||
|
||||
import idv.jlchntoz.CustomSkinLoader;
|
||||
|
||||
class bse extends Thread
|
||||
{
|
||||
|
||||
final bsd a;
|
||||
|
||||
bse(bsd bsd1, String s)
|
||||
{
|
||||
a = bsd1;
|
||||
}
|
||||
|
||||
public void run()
|
||||
{
|
||||
CustomSkinLoader Loader = new CustomSkinLoader();
|
||||
|
||||
try
|
||||
{
|
||||
BufferedImage var2 = ImageIO.read(Loader.getPlayerSkinStream(bsd.a(a)));
|
||||
|
||||
a.a(var2);
|
||||
}
|
||||
catch (Exception var6)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
@echo off
|
||||
title CustomSkinLoader 1.7.9 Builder
|
||||
echo Please Build with Minecraft 1.7.9 classes
|
||||
echo Building CustomSkinLoader.java[Main]
|
||||
cd idv/jlchntoz
|
||||
javac CustomSkinLoader.java
|
||||
cd ../..
|
||||
echo Building boo.java[For HD Skin]
|
||||
javac boo.java
|
||||
echo Building bsd.java[DownloadImage]
|
||||
javac bsd.java
|
||||
echo Building bse.java[ThreadDownloadImage]
|
||||
javac bse.java
|
||||
pause
|
||||
@@ -1,189 +0,0 @@
|
||||
package idv.jlchntoz;
|
||||
|
||||
import java.io.*;
|
||||
import java.net.*;
|
||||
import java.util.logging.*;
|
||||
import java.util.regex.*;
|
||||
|
||||
/**
|
||||
* Custom skin loader mod for Minecraft.
|
||||
*
|
||||
* @version 10th Revision 1st Subversion 2014.4.20
|
||||
* @author (C) Jeremy Lam [JLChnToZ] 2013 & Alexander Xia [xfl03] 2014
|
||||
*/
|
||||
public class CustomSkinLoader {
|
||||
public final static String DefaultSkinURL = "http://skins.minecraft.net/MinecraftSkins/*.png";
|
||||
public final static String DefaultCloakURL = "http://skins.minecraft.net/MinecraftCloaks/*.png";
|
||||
private final static Pattern newURLPattern = Pattern.compile("^http://skins.minecraft.net/Minecraft(Skin|Cloak)s/(.*?).png$"),
|
||||
oldURLPattern = Pattern.compile("^http://s3.amazonaws.com/Minecraft(Skin|Cloak)s/(.*?).png$");
|
||||
|
||||
private final static Logger logger = Logger
|
||||
.getLogger(CustomSkinLoader.class.getName());
|
||||
|
||||
private static String[] cloakURLs = null, skinURLs = null;
|
||||
|
||||
private HttpURLConnection C = null;
|
||||
|
||||
public InputStream getPlayerSkinStream(String path) {
|
||||
Matcher m = newURLPattern.matcher(path);
|
||||
if (!m.matches())//Is not new url
|
||||
{
|
||||
m = oldURLPattern.matcher(path);//If is old url
|
||||
}
|
||||
if (m.matches()) {
|
||||
if (m.group(1).contains("Skin")) // Skin
|
||||
return getPlayerSkinStream(false, m.group(2));
|
||||
else if (m.group(1).contains("Cloak")) // Cloak
|
||||
return getPlayerSkinStream(true, m.group(2));
|
||||
}
|
||||
return getStream(path, false); // Neither skin nor cloak...
|
||||
}
|
||||
|
||||
public InputStream getPlayerSkinStream(Boolean isCloak, String playerName) {
|
||||
if (skinURLs == null || cloakURLs == null || skinURLs.length <= 0
|
||||
|| cloakURLs.length <= 0)
|
||||
refreshSkinURL(); // If the list is blank or null, try to load
|
||||
// again.
|
||||
for (String l : isCloak ? cloakURLs : skinURLs) {
|
||||
if(l==null||l.equalsIgnoreCase(""))
|
||||
continue;
|
||||
String loc = str_replace("*", playerName, l);
|
||||
logger.log(Level.INFO, "Try to load " + (isCloak ? "cloak" : "skin") + " in " + loc);
|
||||
InputStream S = getStream(loc, true);
|
||||
if (S == null)
|
||||
logger.log(Level.INFO, "No " + (isCloak ? "cloak" : "skin")
|
||||
+ " found in " + loc);
|
||||
else
|
||||
return S;
|
||||
}
|
||||
logger.log(Level.INFO, "Try to load skin in default URL instead.");
|
||||
return getStream(str_replace("*", playerName, isCloak ? DefaultCloakURL : DefaultSkinURL), true);
|
||||
}
|
||||
|
||||
private InputStream getStream(String URL, Boolean CheckPNG) {
|
||||
try {
|
||||
URL U = new URL(URL);
|
||||
C = (HttpURLConnection) U.openConnection();
|
||||
C.setDoInput(true);
|
||||
C.setDoOutput(false);
|
||||
C.connect();
|
||||
int respcode = C.getResponseCode() / 100;
|
||||
if (respcode != 4 && respcode != 5) { // Successful (?) to get skin.
|
||||
BufferedInputStream IS = new BufferedInputStream(
|
||||
C.getInputStream());
|
||||
if (!CheckPNG) // If no need to check PNG header, just skip it.
|
||||
return IS;
|
||||
IS.mark(0);
|
||||
byte[] ib = new byte[4];
|
||||
IS.read(ib);
|
||||
if (ib[1] == (byte) 'P' && ib[2] == (byte) 'N'
|
||||
&& ib[3] == (byte) 'G') { // Check PNG Header if needed
|
||||
IS.reset();
|
||||
return IS;
|
||||
}
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
logger.log(Level.WARNING, ex.getMessage());
|
||||
} finally {
|
||||
disconnect();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void disconnect() {
|
||||
if (C != null)
|
||||
C.disconnect();
|
||||
}
|
||||
|
||||
private static void refreshSkinURL() {
|
||||
try {
|
||||
File mcdir = new File("");
|
||||
skinURLs = readAllLines(mcdir, "skinurls.txt");
|
||||
cloakURLs = readAllLines(mcdir, "capeurls.txt");
|
||||
} catch (Exception ex) {
|
||||
logger.log(Level.WARNING, ex.getMessage());
|
||||
} finally {
|
||||
logger.log(Level.INFO, "Skin URLs Refreshed. Skin count = "
|
||||
+ skinURLs.length + ", Cloak count = " + cloakURLs.length);
|
||||
}
|
||||
}
|
||||
|
||||
private static String[] readAllLines(File mcdir, String path) {
|
||||
try {
|
||||
File F = new File(mcdir, path);
|
||||
logger.log(Level.INFO, "Config file: " + F.getAbsolutePath());
|
||||
if (!F.exists()) {
|
||||
logger.log(Level.INFO, "Config file not found, create new one.");
|
||||
de(mcdir);
|
||||
return new String[0];
|
||||
} else if (F.length() <= 0) {
|
||||
logger.log(Level.INFO, "Config file is blank, skipped.");
|
||||
return new String[0];
|
||||
} else {
|
||||
byte[] b = new byte[(int) F.length()];
|
||||
BufferedInputStream S = new BufferedInputStream(
|
||||
new FileInputStream(F));
|
||||
S.read(b);
|
||||
S.close();
|
||||
logger.log(Level.INFO, "Config file loaded.");
|
||||
String[] re= str_replace("\r", "\n",
|
||||
str_replace("\r\n", "\n", new String(b))).split("\n");
|
||||
for(int i=0;i<re.length;i++){
|
||||
if(re[i].startsWith("#"))
|
||||
re[i]=null;
|
||||
else{
|
||||
for(int g=0;g<re.length;g++){
|
||||
if(i==g)
|
||||
continue;
|
||||
if(re[i].equalsIgnoreCase(re[g])){
|
||||
re[i]=null;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return re;
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
logger.log(Level.WARNING, ex.getMessage());
|
||||
return new String[0];
|
||||
}
|
||||
}
|
||||
|
||||
private static String str_replace(String search, String replace,
|
||||
String subject) {
|
||||
StringBuffer result = new StringBuffer(subject);
|
||||
int pos;
|
||||
while ((pos = result.indexOf(search)) != -1)
|
||||
result.replace(pos, pos + search.length(), replace);
|
||||
return result.toString();
|
||||
}
|
||||
public static void de(File mcdir){
|
||||
File a=new File(mcdir,"CustomSkinLoaderGUI.jar");
|
||||
if(!a.exists())
|
||||
downloadFile("https://raw.githubusercontent.com/JLChnToZ/MCCustomSkinLoader/GUI/CustomSkinLoaderGUI.jar",a.getAbsolutePath());
|
||||
try{
|
||||
Runtime.getRuntime().exec("java -jar \""+a.getAbsolutePath()+"\" f");
|
||||
}catch(Exception e){
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
public static boolean downloadFile(String remote,String local){
|
||||
try {
|
||||
int byteRead = 0;
|
||||
URL url = new URL(remote);
|
||||
URLConnection conn = url.openConnection();
|
||||
InputStream inStream = conn.getInputStream();
|
||||
FileOutputStream fs = new FileOutputStream(local);
|
||||
byte[] buffer = new byte[1204];
|
||||
while (( byteRead = inStream.read(buffer)) != -1) {
|
||||
fs.write(buffer, 0, byteRead);
|
||||
}
|
||||
fs.close();
|
||||
return new File(local).exists();
|
||||
}catch (Exception e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,357 +0,0 @@
|
||||
package idv.jlchntoz;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
|
||||
import java.io.*;
|
||||
import java.math.BigInteger;
|
||||
import java.net.*;
|
||||
import java.nio.MappedByteBuffer;
|
||||
import java.nio.channels.FileChannel;
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.util.HashMap;
|
||||
import java.util.logging.*;
|
||||
import java.util.regex.*;
|
||||
|
||||
/**
|
||||
* Custom skin loader mod for Minecraft.
|
||||
*
|
||||
* @version 12th Revision 9th Subversion 2016.2.10
|
||||
*
|
||||
* @author (C) Jeremy Lam [JLChnToZ] 2013 & Alexander Xia [xfl03] 2014-2016
|
||||
*/
|
||||
public class CustomSkinLoader {
|
||||
public final static String VERSION="12.9";
|
||||
|
||||
public final static String DefaultSkinURL = "http://skins.minecraft.net/MinecraftSkins/*.png";
|
||||
public final static String DefaultCloakURL = "http://skins.minecraft.net/MinecraftCloaks/*.png";
|
||||
|
||||
private final static Pattern newResPattern = Pattern.compile("^http://textures.minecraft.net/texture/(.*?)?(Skin|Cloak)=(.*?)$"),
|
||||
newURLPattern = Pattern.compile("^http://skins.minecraft.net/Minecraft(Skin|Cloak)s/(.*?).png$"),
|
||||
oldURLPattern = Pattern.compile("^http://s3.amazonaws.com/Minecraft(Skin|Cloak)s/(.*?).png$"),
|
||||
optifineCapeURLPattern = Pattern.compile("^http://s.optifine.net/capes/(.*?).png$");
|
||||
|
||||
public final static File DATA_DIR=new File(Minecraft.getMinecraft().mcDataDir,"CustomSkinLoader"),
|
||||
CACHE_DIR=new File(DATA_DIR,"caches"),
|
||||
LOG_FILE=new File(DATA_DIR,"CustomSkinLoader.log"),
|
||||
SKIN_URL_FILE=new File(DATA_DIR,"skinurls.txt"),
|
||||
CAPE_URL_FILE=new File(DATA_DIR,"capeurls.txt");
|
||||
public final static MainLogger logger = getLogger(LOG_FILE);
|
||||
|
||||
public final static String[] DEFAULT_SKIN_URLS={
|
||||
"http://skins.minecraft.net/MinecraftSkins/*.png",
|
||||
"http://minecrack.fr.nf/mc/skinsminecrackd/*.png",
|
||||
"http://www.skinme.cc/MinecraftSkins/*.png"};
|
||||
public final static String[] DEFAULT_CAPE_URLS={
|
||||
"http://skins.minecraft.net/MinecraftCloaks/*.png",
|
||||
"http://s.optifine.net/capes/*.png",
|
||||
"http://minecrack.fr.nf/mc/cloaksminecrackd/*.png",
|
||||
"http://www.skinme.cc/MinecraftCloaks/*.png"};
|
||||
|
||||
private static String[] cloakURLs = null, skinURLs = null;
|
||||
private HttpURLConnection C = null;
|
||||
|
||||
//Entrance
|
||||
public InputStream getPlayerSkinStream(String path) {
|
||||
if(!DATA_DIR.exists())
|
||||
DATA_DIR.mkdir();
|
||||
if(!CACHE_DIR.exists())
|
||||
CACHE_DIR.mkdir();
|
||||
logger.info("Get a request: "+path);
|
||||
if(path.contains("NOCSL"))//Not to use CSL to load, prepared for json api
|
||||
return getStream(path, false);
|
||||
Matcher m = newURLPattern.matcher(path);
|
||||
if (!m.matches())//Is not new url
|
||||
{
|
||||
m = oldURLPattern.matcher(path);//May be old url
|
||||
}
|
||||
if (m.matches()) {
|
||||
if (m.group(1).contains("Skin")) // Skin
|
||||
return getPlayerSkinStream(false, m.group(2));
|
||||
else if (m.group(1).contains("Cloak")) // Cloak
|
||||
return getPlayerSkinStream(true, m.group(2));
|
||||
}else{
|
||||
m = newResPattern.matcher(path);
|
||||
if(m.matches()){
|
||||
if (m.group(2).contains("Skin")) // Skin
|
||||
return getPlayerSkinStream(false, m.group(3));
|
||||
else if (m.group(2).contains("Cloak")) // Cloak
|
||||
return getPlayerSkinStream(true, m.group(3));
|
||||
}else{
|
||||
m = optifineCapeURLPattern.matcher(path);
|
||||
if(m.matches()){//Optifine Cape
|
||||
logger.info("Ignore Optifine Cape.");
|
||||
return null;//Not Load This
|
||||
}
|
||||
}
|
||||
}
|
||||
return getStream(path, false); // Neither skin nor cloak...
|
||||
}
|
||||
|
||||
public InputStream getPlayerSkinStream(Boolean isCloak, String playerName) {
|
||||
if ((skinURLs == null|| skinURLs.length <= 0) && (cloakURLs == null || cloakURLs.length <= 0))
|
||||
refreshSkinURL(); // If the list is blank or null, try to load again.
|
||||
InputStream S=null;
|
||||
|
||||
for (String l : isCloak ? cloakURLs : skinURLs) {
|
||||
if(l==null||l.equalsIgnoreCase(""))
|
||||
continue;
|
||||
String loc = str_replace("*", playerName, l);
|
||||
logger.log(Level.INFO, "Try to load " + (isCloak ? "cloak" : "skin") + " in " + loc);
|
||||
S = getStream(loc, true);
|
||||
|
||||
if (S == null){
|
||||
logger.log(Level.INFO, "No " + (isCloak ? "cloak" : "skin") + " found in " + loc);
|
||||
}else{
|
||||
logger.info("Succeessfully load " + (isCloak ? "cloak" : "skin") + " in " + loc);
|
||||
return S;
|
||||
}
|
||||
}
|
||||
|
||||
logger.log(Level.INFO, "Try to load skin in default URL instead.");
|
||||
return getStream(str_replace("*", playerName, isCloak ? DefaultCloakURL : DefaultSkinURL), true);
|
||||
}
|
||||
|
||||
private InputStream getStream(String URL, Boolean CheckPNG) {
|
||||
boolean success=false;
|
||||
File cacheFile=new File(CACHE_DIR,MD5(URL));
|
||||
boolean alreadyCached=false;
|
||||
if(cacheFile.exists()&&cacheFile.length()>1){
|
||||
alreadyCached=true;
|
||||
logger.info("Cache File Found (LastModified: "+cacheFile.lastModified()+" , Size: "+cacheFile.length()+")");
|
||||
}
|
||||
try {
|
||||
URL U = new URL(URL);
|
||||
C = (HttpURLConnection) U.openConnection();
|
||||
C.setReadTimeout(15000);
|
||||
C.setDoInput(true);
|
||||
C.setDoOutput(false);
|
||||
C.connect();
|
||||
logger.info("Response Code: "+C.getResponseCode());
|
||||
int respcode = C.getResponseCode() / 100;
|
||||
if (respcode != 4 && respcode != 5) { // Successful to get skin.
|
||||
if(C.getContentLength()<=0){//Nothing got
|
||||
logger.info("Nothing got.");
|
||||
return null;
|
||||
}
|
||||
logger.info("Successfully Get Resource (LastModified: "+C.getLastModified()+" , ContentLength: "+C.getContentLength()+")");
|
||||
if(alreadyCached && C.getLastModified()==cacheFile.lastModified() && C.getContentLength()==cacheFile.length()){
|
||||
logger.info("Not Modified.");
|
||||
return getStreamFromCache(cacheFile);
|
||||
}
|
||||
InputStream IS=new BufferedInputStream(C.getInputStream());
|
||||
if (!CheckPNG){ // If no need to check PNG header, just skip it.
|
||||
success=true;
|
||||
saveToCache(IS,cacheFile);
|
||||
return IS;
|
||||
}
|
||||
//logger.info(C.getContentLength()+" "+IS.available());
|
||||
IS.mark(C.getContentLength()+10);
|
||||
byte[] ib = new byte[4];
|
||||
IS.read(ib);
|
||||
if (ib[1] == (byte) 'P' && ib[2] == (byte) 'N' && ib[3] == (byte) 'G') { // Check PNG Header if needed
|
||||
IS.reset();
|
||||
success=true;
|
||||
saveToCache(IS,cacheFile);
|
||||
return IS;
|
||||
}
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
success=false;
|
||||
logger.log(Level.WARNING, ex.getMessage());
|
||||
if(alreadyCached)
|
||||
return getStreamFromCache(cacheFile);
|
||||
}finally{
|
||||
if(!success)
|
||||
disconnect();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
private InputStream getStreamFromCache(File cacheFile) {
|
||||
try{
|
||||
logger.info("Try load local cache in " + cacheFile.getAbsolutePath());
|
||||
InputStream in = new FileInputStream(cacheFile);
|
||||
BufferedInputStream bis=new BufferedInputStream(in);
|
||||
if(bis.available()<=0){
|
||||
logger.info("Cannot load local cache in " + cacheFile.getAbsolutePath());
|
||||
return null;
|
||||
}else{
|
||||
logger.info("Successfully load cache in " + cacheFile.getAbsolutePath());
|
||||
return bis;
|
||||
}
|
||||
}catch(Exception e){
|
||||
logger.log(Level.WARNING, e.getMessage());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
private void saveToCache(InputStream is,File to){
|
||||
logger.info("Try save local cache to " + to.getAbsolutePath());
|
||||
FileOutputStream fs=null;
|
||||
int times=0;
|
||||
try{//Save to Local Skin File
|
||||
if(to.exists()){
|
||||
to.delete();
|
||||
}
|
||||
fs = new FileOutputStream(to);
|
||||
int byteRead = 0;
|
||||
byte[] buffer = new byte[1024];
|
||||
while (( byteRead = is.read(buffer)) != -1) {
|
||||
times+=byteRead;
|
||||
fs.write(buffer, 0, byteRead);
|
||||
if(times>=C.getContentLength()){
|
||||
//logger.info(times+" "+C.getContentLength());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(to.length()>1){
|
||||
to.setLastModified(C.getLastModified());
|
||||
logger.info("Cache saved to " + to.getAbsolutePath()+" (LastModified: "+to.lastModified()+" , Size: "+to.length()+")");
|
||||
}else{
|
||||
to.delete();
|
||||
logger.info("Cannot save local cache to " + to.getAbsolutePath());
|
||||
}
|
||||
}catch(Exception e){
|
||||
logger.warning(e.getMessage());
|
||||
}finally{
|
||||
try {
|
||||
if(fs!=null)
|
||||
fs.close();
|
||||
is.reset();
|
||||
} catch (IOException e) {
|
||||
logger.warning(e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void disconnect() {
|
||||
if (C != null)
|
||||
C.disconnect();
|
||||
}
|
||||
|
||||
private static void refreshSkinURL() {
|
||||
try {
|
||||
if(!SKIN_URL_FILE.exists()){
|
||||
logger.log(Level.INFO, "SKIN config not found, create a new one.");
|
||||
SKIN_URL_FILE.createNewFile();
|
||||
}
|
||||
if(!CAPE_URL_FILE.exists()){
|
||||
logger.log(Level.INFO, "CAPE config not found, create a new one.");
|
||||
CAPE_URL_FILE.createNewFile();
|
||||
}
|
||||
skinURLs = readAllLines(SKIN_URL_FILE);
|
||||
cloakURLs = readAllLines(CAPE_URL_FILE);
|
||||
} catch (Exception ex) {
|
||||
logger.log(Level.WARNING, ex.getMessage());
|
||||
} finally {
|
||||
if(skinURLs.length==0&&cloakURLs.length==0){
|
||||
logger.info("No skinURLs and cloak URLS found, try to init and use default settings.");
|
||||
initSkinURL();
|
||||
refreshSkinURL();
|
||||
}else{
|
||||
logger.log(Level.INFO, "Skin URLs Refreshed. Skin count = "
|
||||
+ skinURLs.length + ", Cloak count = " + cloakURLs.length);
|
||||
}
|
||||
}
|
||||
}
|
||||
private static void initSkinURL(){
|
||||
//Init URL List
|
||||
skinURLs=DEFAULT_SKIN_URLS;
|
||||
writeToFile(new File(DATA_DIR,"skinurls.txt"),parseArrayToText(skinURLs));
|
||||
cloakURLs=DEFAULT_CAPE_URLS;
|
||||
writeToFile(new File(DATA_DIR,"capeurls.txt"),parseArrayToText(cloakURLs));
|
||||
}
|
||||
|
||||
private static String[] readAllLines(File F) {
|
||||
try {
|
||||
logger.log(Level.INFO, "Config file: " + F.getAbsolutePath());
|
||||
if (F.length() <= 0) {
|
||||
logger.log(Level.INFO, "Config file is blank, skipped.");
|
||||
return new String[0];
|
||||
} else {
|
||||
byte[] b = new byte[(int) F.length()];
|
||||
BufferedInputStream S = new BufferedInputStream(
|
||||
new FileInputStream(F));
|
||||
S.read(b);
|
||||
S.close();
|
||||
logger.log(Level.INFO, "Config file loaded.");
|
||||
String[] re= str_replace("\r", "\n",
|
||||
str_replace("\r\n", "\n", new String(b))).split("\n");
|
||||
for(int i=0;i<re.length;i++){
|
||||
if(re[i].startsWith("#"))//Remove note
|
||||
re[i]=null;
|
||||
else{//Remove same URL
|
||||
for(int g=0;g<re.length;g++){
|
||||
if(i==g)
|
||||
continue;
|
||||
if(re[i].equalsIgnoreCase(re[g])){
|
||||
re[i]=null;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return re;
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
logger.log(Level.WARNING, ex.getMessage());
|
||||
return new String[0];
|
||||
}
|
||||
}
|
||||
|
||||
private static String str_replace(String search, String replace,
|
||||
String subject) {
|
||||
StringBuffer result = new StringBuffer(subject);
|
||||
int pos;
|
||||
while ((pos = result.indexOf(search)) != -1)
|
||||
result.replace(pos, pos + search.length(), replace);
|
||||
return result.toString();
|
||||
}
|
||||
private static String parseArrayToText(String[] data){
|
||||
StringBuilder temp=new StringBuilder();
|
||||
for(int i=0;i<data.length-1;i++)
|
||||
temp.append(data[i]).append("\r\n");
|
||||
temp.append(data[data.length-1]);
|
||||
return temp.toString();
|
||||
}
|
||||
private static boolean writeToFile(File file,String Data){
|
||||
System.out.print("Write to "+file.getAbsolutePath()+" ");
|
||||
FileWriter fw=null;
|
||||
try{
|
||||
fw = new FileWriter(file);
|
||||
fw.write(Data,0,Data.length());
|
||||
fw.flush();
|
||||
fw.close();
|
||||
}catch(Exception ex){
|
||||
ex.printStackTrace();
|
||||
System.out.println("failed.");
|
||||
return false;
|
||||
}
|
||||
System.out.println("succeed.");
|
||||
return true;
|
||||
}
|
||||
|
||||
public String MD5(String str){
|
||||
byte [] buf = str.getBytes();
|
||||
MessageDigest md5;
|
||||
try {
|
||||
md5 = MessageDigest.getInstance("MD5");
|
||||
md5.update(buf);
|
||||
byte [] tmp = md5.digest();
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (byte b:tmp) {
|
||||
sb.append(Integer.toHexString(b&0xff));
|
||||
}
|
||||
return sb.toString();
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
logger.warning(e.getMessage());
|
||||
}
|
||||
return "Fail";
|
||||
}
|
||||
|
||||
private static MainLogger getLogger(File logFile){
|
||||
MainLogger mainLogger = new MainLogger(logFile);
|
||||
mainLogger.info("CustomSkinLoader " + VERSION);
|
||||
return mainLogger;
|
||||
}
|
||||
}
|
||||
@@ -1,71 +0,0 @@
|
||||
package idv.jlchntoz;
|
||||
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class MainLogger {
|
||||
private static final int LOWEST_DISPLAY_LEVEL=Level.INFO.intValue();
|
||||
SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
private BufferedWriter writer;
|
||||
public MainLogger(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"));
|
||||
} 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.intValue()>=LOWEST_DISPLAY_LEVEL)
|
||||
System.out.println(msg);
|
||||
try {
|
||||
writer.write("[");
|
||||
writer.write(DATE_FORMAT.format(new Date()));
|
||||
writer.write(" ");
|
||||
writer.write(Thread.currentThread().getName());
|
||||
writer.write(" ");
|
||||
writer.write(level.getName());
|
||||
writer.write("] ");
|
||||
writer.write(msg);
|
||||
writer.write("\r\n");
|
||||
writer.flush();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
public void info(String msg){
|
||||
log(Level.INFO,msg);
|
||||
}
|
||||
public void warning(String msg){
|
||||
log(Level.WARNING,msg);
|
||||
}
|
||||
public void warning(Exception e){
|
||||
log(Level.WARNING,"Exception occurs while running: "+e.getMessage());
|
||||
StackTraceElement[] stes=e.getStackTrace();
|
||||
for(StackTraceElement ste : stes){
|
||||
log(Level.WARNING,ste.toString());
|
||||
}
|
||||
log(Level.WARNING,"");
|
||||
}
|
||||
}
|
||||
@@ -1,116 +0,0 @@
|
||||
package net.minecraft.client.renderer;
|
||||
|
||||
import java.awt.Graphics;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.awt.image.DataBufferInt;
|
||||
import java.awt.image.ImageObserver;
|
||||
|
||||
public class ImageBufferDownload implements IImageBuffer
|
||||
{
|
||||
private int[] imageData;
|
||||
private int imageWidth;
|
||||
private int imageHeight;
|
||||
private static final String __OBFID = "CL_00000956";
|
||||
|
||||
public BufferedImage parseUserSkin(BufferedImage p_78432_1_)
|
||||
{
|
||||
if (p_78432_1_ == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
else
|
||||
{
|
||||
int ratio=p_78432_1_.getWidth()/64;
|
||||
this.imageWidth = 64 * ratio;
|
||||
this.imageHeight = 64 * ratio;
|
||||
BufferedImage var2 = new BufferedImage(this.imageWidth, this.imageHeight, 2);
|
||||
Graphics var3 = var2.getGraphics();
|
||||
var3.drawImage(p_78432_1_, 0, 0, (ImageObserver)null);
|
||||
|
||||
if (p_78432_1_.getHeight() == 32 * ratio)
|
||||
{
|
||||
var3.drawImage(var2, 24 * ratio, 48 * ratio, 20 * ratio, 52 * ratio, 4 * ratio, 16 * ratio, 8 * ratio, 20 * ratio, (ImageObserver)null);
|
||||
var3.drawImage(var2, 28 * ratio, 48 * ratio, 24 * ratio, 52 * ratio, 8 * ratio, 16 * ratio, 12 * ratio, 20 * ratio, (ImageObserver)null);
|
||||
var3.drawImage(var2, 20 * ratio, 52 * ratio, 16 * ratio, 64 * ratio, 8 * ratio, 20 * ratio, 12 * ratio, 32 * ratio, (ImageObserver)null);
|
||||
var3.drawImage(var2, 24 * ratio, 52 * ratio, 20 * ratio, 64 * ratio, 4 * ratio, 20 * ratio, 8 * ratio, 32 * ratio, (ImageObserver)null);
|
||||
var3.drawImage(var2, 28 * ratio, 52 * ratio, 24 * ratio, 64 * ratio, 0 * ratio, 20 * ratio, 4 * ratio, 32 * ratio, (ImageObserver)null);
|
||||
var3.drawImage(var2, 32 * ratio, 52 * ratio, 28 * ratio, 64 * ratio, 12 * ratio, 20 * ratio, 16 * ratio, 32 * ratio, (ImageObserver)null);
|
||||
var3.drawImage(var2, 40 * ratio, 48 * ratio, 36 * ratio, 52 * ratio, 44 * ratio, 16 * ratio, 48 * ratio, 20 * ratio, (ImageObserver)null);
|
||||
var3.drawImage(var2, 44 * ratio, 48 * ratio, 40 * ratio, 52 * ratio, 48 * ratio, 16 * ratio, 52 * ratio, 20 * ratio, (ImageObserver)null);
|
||||
var3.drawImage(var2, 36 * ratio, 52 * ratio, 32 * ratio, 64 * ratio, 48 * ratio, 20 * ratio, 52 * ratio, 32 * ratio, (ImageObserver)null);
|
||||
var3.drawImage(var2, 40 * ratio, 52 * ratio, 36 * ratio, 64 * ratio, 44 * ratio, 20 * ratio, 48 * ratio, 32 * ratio, (ImageObserver)null);
|
||||
var3.drawImage(var2, 44 * ratio, 52 * ratio, 40 * ratio, 64 * ratio, 40 * ratio, 20 * ratio, 44 * ratio, 32 * ratio, (ImageObserver)null);
|
||||
var3.drawImage(var2, 48 * ratio, 52 * ratio, 44 * ratio, 64 * ratio, 52 * ratio, 20 * ratio, 56 * ratio, 32 * ratio, (ImageObserver)null);
|
||||
}
|
||||
|
||||
var3.dispose();
|
||||
this.imageData = ((DataBufferInt)var2.getRaster().getDataBuffer()).getData();
|
||||
this.setAreaOpaque(0, 0, 32 * ratio, 16 * ratio);
|
||||
this.setAreaTransparent(32 * ratio, 0, 64 * ratio, 32 * ratio);
|
||||
this.setAreaOpaque(0, 16 * ratio, 64 * ratio, 32 * ratio);
|
||||
this.setAreaTransparent(0, 32 * ratio, 16 * ratio, 48 * ratio);
|
||||
this.setAreaTransparent(16 * ratio, 32 * ratio, 40 * ratio, 48 * ratio);
|
||||
this.setAreaTransparent(40 * ratio, 32 * ratio, 56 * ratio, 48 * ratio);
|
||||
this.setAreaTransparent(0, 48 * ratio, 16 * ratio, 64 * ratio);
|
||||
this.setAreaOpaque(16 * ratio, 48 * ratio, 48 * ratio, 64 * ratio);
|
||||
this.setAreaTransparent(48 * ratio, 48 * ratio, 64 * ratio, 64 * ratio);
|
||||
return var2;
|
||||
}
|
||||
}
|
||||
|
||||
public void func_152634_a() {}
|
||||
|
||||
/**
|
||||
* Makes the given area of the image transparent if it was previously completely opaque (used to remove the outer
|
||||
* layer of a skin around the head if it was saved all opaque; this would be redundant so it's assumed that the skin
|
||||
* maker is just using an image editor without an alpha channel)
|
||||
*/
|
||||
private void setAreaTransparent(int p_78434_1_, int p_78434_2_, int p_78434_3_, int p_78434_4_)
|
||||
{
|
||||
if (!this.hasTransparency(p_78434_1_, p_78434_2_, p_78434_3_, p_78434_4_))
|
||||
{
|
||||
for (int var5 = p_78434_1_; var5 < p_78434_3_; ++var5)
|
||||
{
|
||||
for (int var6 = p_78434_2_; var6 < p_78434_4_; ++var6)
|
||||
{
|
||||
this.imageData[var5 + var6 * this.imageWidth] &= 16777215;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes the given area of the image opaque
|
||||
*/
|
||||
private void setAreaOpaque(int p_78433_1_, int p_78433_2_, int p_78433_3_, int p_78433_4_)
|
||||
{
|
||||
for (int var5 = p_78433_1_; var5 < p_78433_3_; ++var5)
|
||||
{
|
||||
for (int var6 = p_78433_2_; var6 < p_78433_4_; ++var6)
|
||||
{
|
||||
this.imageData[var5 + var6 * this.imageWidth] |= -16777216;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the given area of the image contains transparent pixels
|
||||
*/
|
||||
private boolean hasTransparency(int p_78435_1_, int p_78435_2_, int p_78435_3_, int p_78435_4_)
|
||||
{
|
||||
for (int var5 = p_78435_1_; var5 < p_78435_3_; ++var5)
|
||||
{
|
||||
for (int var6 = p_78435_2_; var6 < p_78435_4_; ++var6)
|
||||
{
|
||||
int var7 = this.imageData[var5 + var6 * this.imageWidth];
|
||||
|
||||
if ((var7 >> 24 & 255) < 128)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -1,177 +0,0 @@
|
||||
package net.minecraft.client.renderer;
|
||||
|
||||
import idv.jlchntoz.CustomSkinLoader;
|
||||
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.File;
|
||||
import java.io.InputStream;
|
||||
import java.io.IOException;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import javax.imageio.ImageIO;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.texture.SimpleTexture;
|
||||
import net.minecraft.client.renderer.texture.TextureUtil;
|
||||
import net.minecraft.client.resources.IResourceManager;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
public class ThreadDownloadImageData extends SimpleTexture
|
||||
{
|
||||
private static final Logger logger = LogManager.getLogger();
|
||||
private static final AtomicInteger threadDownloadCounter = new AtomicInteger(0);
|
||||
private final File field_152434_e;
|
||||
private final String imageUrl;
|
||||
private final IImageBuffer imageBuffer;
|
||||
private BufferedImage bufferedImage;
|
||||
private Thread imageThread;
|
||||
private boolean textureUploaded;
|
||||
private static final String __OBFID = "CL_00001049";
|
||||
|
||||
//For Optifine
|
||||
public Boolean imageFound = null;
|
||||
public boolean pipeline = false;
|
||||
|
||||
public ThreadDownloadImageData(File p_i1049_1_, String p_i1049_2_, ResourceLocation p_i1049_3_, IImageBuffer p_i1049_4_)
|
||||
{
|
||||
super(p_i1049_3_);
|
||||
this.field_152434_e = p_i1049_1_;
|
||||
this.imageUrl = p_i1049_2_;
|
||||
this.imageBuffer = p_i1049_4_;
|
||||
}
|
||||
|
||||
private void checkTextureUploaded()
|
||||
{
|
||||
if (!this.textureUploaded)
|
||||
{
|
||||
if (this.bufferedImage != null)
|
||||
{
|
||||
if (this.textureLocation != null)
|
||||
{
|
||||
this.deleteGlTexture();
|
||||
}
|
||||
|
||||
TextureUtil.uploadTextureImage(super.getGlTextureId(), this.bufferedImage);
|
||||
this.textureUploaded = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public int getGlTextureId()
|
||||
{
|
||||
this.checkTextureUploaded();
|
||||
return super.getGlTextureId();
|
||||
}
|
||||
|
||||
public void setBufferedImage(BufferedImage p_147641_1_)
|
||||
{
|
||||
this.bufferedImage = p_147641_1_;
|
||||
|
||||
if (this.imageBuffer != null)
|
||||
{
|
||||
this.imageBuffer.func_152634_a();
|
||||
}
|
||||
}
|
||||
|
||||
public void loadTexture(IResourceManager p_110551_1_) throws IOException
|
||||
{
|
||||
if (this.bufferedImage == null && this.textureLocation != null)
|
||||
{
|
||||
super.loadTexture(p_110551_1_);
|
||||
}
|
||||
|
||||
if (this.imageThread == null)
|
||||
{
|
||||
if (this.field_152434_e != null && this.field_152434_e.isFile())
|
||||
{
|
||||
logger.debug("Loading http texture from local cache ({})", new Object[] {this.field_152434_e});
|
||||
|
||||
try
|
||||
{
|
||||
this.bufferedImage = ImageIO.read(this.field_152434_e);
|
||||
|
||||
if (this.imageBuffer != null)
|
||||
{
|
||||
this.setBufferedImage(this.imageBuffer.parseUserSkin(this.bufferedImage));
|
||||
}
|
||||
}
|
||||
catch (IOException var3)
|
||||
{
|
||||
logger.error("Couldn\'t load skin " + this.field_152434_e, var3);
|
||||
this.func_152433_a();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.func_152433_a();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void func_152433_a()
|
||||
{
|
||||
this.imageThread = new Thread("Texture Downloader #" + threadDownloadCounter.incrementAndGet())
|
||||
{
|
||||
private static final String __OBFID = "CL_00001050";
|
||||
public void run()
|
||||
{
|
||||
CustomSkinLoader loader=new CustomSkinLoader();
|
||||
//HttpURLConnection var1 = null;
|
||||
ThreadDownloadImageData.logger.info("Downloading http texture from {} to {}", new Object[] {ThreadDownloadImageData.this.imageUrl, ThreadDownloadImageData.this.field_152434_e});
|
||||
|
||||
try
|
||||
{
|
||||
/*
|
||||
var1 = (HttpURLConnection)(new URL(ThreadDownloadImageData.this.imageUrl)).openConnection(Minecraft.getMinecraft().getProxy());
|
||||
var1.setDoInput(true);
|
||||
var1.setDoOutput(false);
|
||||
var1.connect();
|
||||
|
||||
if (var1.getResponseCode() / 100 == 2)
|
||||
{*/
|
||||
BufferedImage var2;
|
||||
/*
|
||||
if (ThreadDownloadImageData.this.field_152434_e != null)
|
||||
{
|
||||
FileUtils.copyInputStreamToFile(var1.getInputStream(), ThreadDownloadImageData.this.field_152434_e);
|
||||
var2 = ImageIO.read(ThreadDownloadImageData.this.field_152434_e);
|
||||
}
|
||||
else
|
||||
{
|
||||
var2 = TextureUtil.func_177053_a(var1.getInputStream());
|
||||
}
|
||||
*/
|
||||
InputStream var9=loader.getPlayerSkinStream(ThreadDownloadImageData.this.imageUrl);
|
||||
var2 = TextureUtil.func_177053_a(var9);
|
||||
if (ThreadDownloadImageData.this.imageBuffer != null)
|
||||
{
|
||||
var2 = ThreadDownloadImageData.this.imageBuffer.parseUserSkin(var2);
|
||||
}
|
||||
|
||||
ThreadDownloadImageData.this.setBufferedImage(var2);
|
||||
return;
|
||||
//}
|
||||
}
|
||||
catch (Exception var6)
|
||||
{
|
||||
ThreadDownloadImageData.logger.error("Couldn\'t download http texture", var6);
|
||||
return;
|
||||
}
|
||||
finally
|
||||
{
|
||||
/*
|
||||
if (var1 != null)
|
||||
{
|
||||
var1.disconnect();
|
||||
}*/
|
||||
loader.disconnect();
|
||||
}
|
||||
}
|
||||
};
|
||||
this.imageThread.setDaemon(true);
|
||||
this.imageThread.start();
|
||||
}
|
||||
}
|
||||
@@ -1,192 +0,0 @@
|
||||
package net.minecraft.client.resources;
|
||||
|
||||
import com.google.common.cache.CacheBuilder;
|
||||
import com.google.common.cache.CacheLoader;
|
||||
import com.google.common.cache.LoadingCache;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import com.mojang.authlib.minecraft.InsecureTextureException;
|
||||
import com.mojang.authlib.minecraft.MinecraftProfileTexture;
|
||||
import com.mojang.authlib.minecraft.MinecraftSessionService;
|
||||
import com.mojang.authlib.minecraft.MinecraftProfileTexture.Type;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.File;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.LinkedBlockingQueue;
|
||||
import java.util.concurrent.ThreadPoolExecutor;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.IImageBuffer;
|
||||
import net.minecraft.client.renderer.ImageBufferDownload;
|
||||
import net.minecraft.client.renderer.ThreadDownloadImageData;
|
||||
import net.minecraft.client.renderer.texture.ITextureObject;
|
||||
import net.minecraft.client.renderer.texture.TextureManager;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
public class SkinManager
|
||||
{
|
||||
private static final ExecutorService THREAD_POOL = new ThreadPoolExecutor(0, 2, 1L, TimeUnit.MINUTES, new LinkedBlockingQueue());
|
||||
private final TextureManager textureManager;
|
||||
private final File skinCacheDir;
|
||||
private final MinecraftSessionService sessionService;
|
||||
private final LoadingCache skinCacheLoader;
|
||||
private static final String __OBFID = "CL_00001830";
|
||||
|
||||
public SkinManager(TextureManager textureManagerInstance, File skinCacheDirectory, MinecraftSessionService sessionService)
|
||||
{
|
||||
this.textureManager = textureManagerInstance;
|
||||
this.skinCacheDir = skinCacheDirectory;
|
||||
this.sessionService = sessionService;
|
||||
this.skinCacheLoader = CacheBuilder.newBuilder().expireAfterAccess(15L, TimeUnit.SECONDS).build(new CacheLoader()
|
||||
{
|
||||
private static final String __OBFID = "CL_00001829";
|
||||
public Map func_152786_a(GameProfile p_152786_1_)
|
||||
{
|
||||
return Minecraft.getMinecraft().getSessionService().getTextures(p_152786_1_, false);
|
||||
}
|
||||
public Object load(Object p_load_1_)
|
||||
{
|
||||
return this.func_152786_a((GameProfile)p_load_1_);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Used in the Skull renderer to fetch a skin. May download the skin if it's not in the cache
|
||||
*/
|
||||
public ResourceLocation loadSkin(MinecraftProfileTexture p_152792_1_, Type p_152792_2_)
|
||||
{
|
||||
return this.loadSkin(p_152792_1_, p_152792_2_, (SkinManager.SkinAvailableCallback)null);
|
||||
}
|
||||
|
||||
/**
|
||||
* May download the skin if its not in the cache, can be passed a SkinManager#SkinAvailableCallback for handling
|
||||
*/
|
||||
public ResourceLocation loadSkin(final MinecraftProfileTexture p_152789_1_, final Type p_152789_2_, final SkinManager.SkinAvailableCallback p_152789_3_)
|
||||
{
|
||||
//final ResourceLocation var4 = new ResourceLocation("skins/" + p_152789_1_.getHash());
|
||||
final ResourceLocation var4 = new ResourceLocation(p_152789_2_.name() + "/" + p_152789_1_.getHash());
|
||||
//ITextureObject var5 = this.textureManager.getTexture(var4);
|
||||
/*
|
||||
if (var5 != null)
|
||||
{
|
||||
if (p_152789_3_ != null)
|
||||
{
|
||||
p_152789_3_.func_180521_a(p_152789_2_, var4, p_152789_1_);
|
||||
}
|
||||
}
|
||||
else
|
||||
{*/
|
||||
File var6 = new File(this.skinCacheDir, p_152789_1_.getHash().substring(0, 2));
|
||||
File var7 = new File(var6, p_152789_1_.getHash());
|
||||
final ImageBufferDownload var8 = p_152789_2_ == Type.SKIN ? new ImageBufferDownload() : null;
|
||||
ThreadDownloadImageData var9 = new ThreadDownloadImageData(var7, p_152789_1_.getUrl(), DefaultPlayerSkin.func_177335_a(), new IImageBuffer()
|
||||
{
|
||||
private static final String __OBFID = "CL_00001828";
|
||||
public BufferedImage parseUserSkin(BufferedImage p_78432_1_)
|
||||
{
|
||||
if (var8 != null)
|
||||
{
|
||||
p_78432_1_ = var8.parseUserSkin(p_78432_1_);
|
||||
}
|
||||
|
||||
return p_78432_1_;
|
||||
}
|
||||
public void func_152634_a()
|
||||
{
|
||||
if (var8 != null)
|
||||
{
|
||||
var8.func_152634_a();
|
||||
}
|
||||
|
||||
if (p_152789_3_ != null)
|
||||
{
|
||||
p_152789_3_.func_180521_a(p_152789_2_, var4, p_152789_1_);
|
||||
}
|
||||
}
|
||||
});
|
||||
this.textureManager.loadTexture(var4, var9);
|
||||
//}
|
||||
|
||||
return var4;
|
||||
}
|
||||
|
||||
public void func_152790_a(final GameProfile p_152790_1_, final SkinManager.SkinAvailableCallback p_152790_2_, final boolean p_152790_3_)
|
||||
{
|
||||
THREAD_POOL.submit(new Runnable()
|
||||
{
|
||||
private static final String __OBFID = "CL_00001827";
|
||||
public void run()
|
||||
{
|
||||
final HashMap var1 = Maps.newHashMap();
|
||||
|
||||
try
|
||||
{
|
||||
var1.putAll(SkinManager.this.sessionService.getTextures(p_152790_1_, p_152790_3_));
|
||||
}
|
||||
catch (InsecureTextureException var3)
|
||||
{
|
||||
;
|
||||
}
|
||||
|
||||
if (var1.isEmpty() && p_152790_1_.getId().equals(Minecraft.getMinecraft().getSession().getProfile().getId()))
|
||||
{
|
||||
var1.putAll(SkinManager.this.sessionService.getTextures(SkinManager.this.sessionService.fillProfileProperties(p_152790_1_, false), false));
|
||||
}
|
||||
//CustomSkinLoader Begin
|
||||
HashMap var2 = Maps.newHashMap();
|
||||
if (var1.containsKey(Type.SKIN)){
|
||||
MinecraftProfileTexture var3=((MinecraftProfileTexture)var1.get(Type.SKIN));
|
||||
String var4=var3.getMetadata("model");
|
||||
HashMap var5 = null;
|
||||
if(var4!=null){
|
||||
var5 = Maps.newHashMap();
|
||||
var5.put("model", var4);
|
||||
}
|
||||
var2.put(Type.SKIN, new MinecraftProfileTexture(var3.getUrl()+"?Skin="+p_152790_1_.getName(),var5));
|
||||
}else{
|
||||
HashMap var5 = Maps.newHashMap();
|
||||
//var5.put("model", "slim");
|
||||
var2.put(Type.SKIN,new MinecraftProfileTexture( "http://skins.minecraft.net/MinecraftSkins/"+p_152790_1_.getName()+".png",var5));
|
||||
}
|
||||
if (var1.containsKey(Type.CAPE)){
|
||||
var2.put(Type.CAPE, new MinecraftProfileTexture(((MinecraftProfileTexture)var1.get(Type.CAPE)).getUrl()+"?Cloak="+p_152790_1_.getName(),null));
|
||||
}else{
|
||||
var2.put(Type.CAPE,new MinecraftProfileTexture( "http://skins.minecraft.net/MinecraftCloaks/"+p_152790_1_.getName()+".png",null));
|
||||
}
|
||||
var1.clear();
|
||||
var1.putAll(var2);
|
||||
//CustomSkinLoader End
|
||||
|
||||
Minecraft.getMinecraft().addScheduledTask(new Runnable()
|
||||
{
|
||||
private static final String __OBFID = "CL_00001826";
|
||||
public void run()
|
||||
{
|
||||
if (var1.containsKey(Type.SKIN))
|
||||
{
|
||||
SkinManager.this.loadSkin((MinecraftProfileTexture)var1.get(Type.SKIN), Type.SKIN, p_152790_2_);
|
||||
}
|
||||
|
||||
if (var1.containsKey(Type.CAPE))
|
||||
{
|
||||
SkinManager.this.loadSkin((MinecraftProfileTexture)var1.get(Type.CAPE), Type.CAPE, p_152790_2_);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public Map loadSkinFromCache(GameProfile p_152788_1_)
|
||||
{
|
||||
return (Map)this.skinCacheLoader.getUnchecked(p_152788_1_);
|
||||
}
|
||||
|
||||
public interface SkinAvailableCallback
|
||||
{
|
||||
void func_180521_a(Type p_180521_1_, ResourceLocation p_180521_2_, MinecraftProfileTexture p_180521_3_);
|
||||
}
|
||||
}
|
||||
@@ -1,357 +0,0 @@
|
||||
package idv.jlchntoz;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
|
||||
import java.io.*;
|
||||
import java.math.BigInteger;
|
||||
import java.net.*;
|
||||
import java.nio.MappedByteBuffer;
|
||||
import java.nio.channels.FileChannel;
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.util.HashMap;
|
||||
import java.util.logging.*;
|
||||
import java.util.regex.*;
|
||||
|
||||
/**
|
||||
* Custom skin loader mod for Minecraft.
|
||||
*
|
||||
* @version 12th Revision 9th Subversion 2016.2.10
|
||||
*
|
||||
* @author (C) Jeremy Lam [JLChnToZ] 2013 & Alexander Xia [xfl03] 2014-2016
|
||||
*/
|
||||
public class CustomSkinLoader {
|
||||
public final static String VERSION="12.9";
|
||||
|
||||
public final static String DefaultSkinURL = "http://skins.minecraft.net/MinecraftSkins/*.png";
|
||||
public final static String DefaultCloakURL = "http://skins.minecraft.net/MinecraftCloaks/*.png";
|
||||
|
||||
private final static Pattern newResPattern = Pattern.compile("^http://textures.minecraft.net/texture/(.*?)?(Skin|Cloak)=(.*?)$"),
|
||||
newURLPattern = Pattern.compile("^http://skins.minecraft.net/Minecraft(Skin|Cloak)s/(.*?).png$"),
|
||||
oldURLPattern = Pattern.compile("^http://s3.amazonaws.com/Minecraft(Skin|Cloak)s/(.*?).png$"),
|
||||
optifineCapeURLPattern = Pattern.compile("^http://s.optifine.net/capes/(.*?).png$");
|
||||
|
||||
public final static File DATA_DIR=new File(Minecraft.getMinecraft().mcDataDir,"CustomSkinLoader"),
|
||||
CACHE_DIR=new File(DATA_DIR,"caches"),
|
||||
LOG_FILE=new File(DATA_DIR,"CustomSkinLoader.log"),
|
||||
SKIN_URL_FILE=new File(DATA_DIR,"skinurls.txt"),
|
||||
CAPE_URL_FILE=new File(DATA_DIR,"capeurls.txt");
|
||||
public final static MainLogger logger = getLogger(LOG_FILE);
|
||||
|
||||
public final static String[] DEFAULT_SKIN_URLS={
|
||||
"http://skins.minecraft.net/MinecraftSkins/*.png",
|
||||
"http://minecrack.fr.nf/mc/skinsminecrackd/*.png",
|
||||
"http://www.skinme.cc/MinecraftSkins/*.png"};
|
||||
public final static String[] DEFAULT_CAPE_URLS={
|
||||
"http://skins.minecraft.net/MinecraftCloaks/*.png",
|
||||
"http://s.optifine.net/capes/*.png",
|
||||
"http://minecrack.fr.nf/mc/cloaksminecrackd/*.png",
|
||||
"http://www.skinme.cc/MinecraftCloaks/*.png"};
|
||||
|
||||
private static String[] cloakURLs = null, skinURLs = null;
|
||||
private HttpURLConnection C = null;
|
||||
|
||||
//Entrance
|
||||
public InputStream getPlayerSkinStream(String path) {
|
||||
if(!DATA_DIR.exists())
|
||||
DATA_DIR.mkdir();
|
||||
if(!CACHE_DIR.exists())
|
||||
CACHE_DIR.mkdir();
|
||||
logger.info("Get a request: "+path);
|
||||
if(path.contains("NOCSL"))//Not to use CSL to load, prepared for json api
|
||||
return getStream(path, false);
|
||||
Matcher m = newURLPattern.matcher(path);
|
||||
if (!m.matches())//Is not new url
|
||||
{
|
||||
m = oldURLPattern.matcher(path);//May be old url
|
||||
}
|
||||
if (m.matches()) {
|
||||
if (m.group(1).contains("Skin")) // Skin
|
||||
return getPlayerSkinStream(false, m.group(2));
|
||||
else if (m.group(1).contains("Cloak")) // Cloak
|
||||
return getPlayerSkinStream(true, m.group(2));
|
||||
}else{
|
||||
m = newResPattern.matcher(path);
|
||||
if(m.matches()){
|
||||
if (m.group(2).contains("Skin")) // Skin
|
||||
return getPlayerSkinStream(false, m.group(3));
|
||||
else if (m.group(2).contains("Cloak")) // Cloak
|
||||
return getPlayerSkinStream(true, m.group(3));
|
||||
}else{
|
||||
m = optifineCapeURLPattern.matcher(path);
|
||||
if(m.matches()){//Optifine Cape
|
||||
logger.info("Ignore Optifine Cape.");
|
||||
return null;//Not Load This
|
||||
}
|
||||
}
|
||||
}
|
||||
return getStream(path, false); // Neither skin nor cloak...
|
||||
}
|
||||
|
||||
public InputStream getPlayerSkinStream(Boolean isCloak, String playerName) {
|
||||
if ((skinURLs == null|| skinURLs.length <= 0) && (cloakURLs == null || cloakURLs.length <= 0))
|
||||
refreshSkinURL(); // If the list is blank or null, try to load again.
|
||||
InputStream S=null;
|
||||
|
||||
for (String l : isCloak ? cloakURLs : skinURLs) {
|
||||
if(l==null||l.equalsIgnoreCase(""))
|
||||
continue;
|
||||
String loc = str_replace("*", playerName, l);
|
||||
logger.log(Level.INFO, "Try to load " + (isCloak ? "cloak" : "skin") + " in " + loc);
|
||||
S = getStream(loc, true);
|
||||
|
||||
if (S == null){
|
||||
logger.log(Level.INFO, "No " + (isCloak ? "cloak" : "skin") + " found in " + loc);
|
||||
}else{
|
||||
logger.info("Succeessfully load " + (isCloak ? "cloak" : "skin") + " in " + loc);
|
||||
return S;
|
||||
}
|
||||
}
|
||||
|
||||
logger.log(Level.INFO, "Try to load skin in default URL instead.");
|
||||
return getStream(str_replace("*", playerName, isCloak ? DefaultCloakURL : DefaultSkinURL), true);
|
||||
}
|
||||
|
||||
private InputStream getStream(String URL, Boolean CheckPNG) {
|
||||
boolean success=false;
|
||||
File cacheFile=new File(CACHE_DIR,MD5(URL));
|
||||
boolean alreadyCached=false;
|
||||
if(cacheFile.exists()&&cacheFile.length()>1){
|
||||
alreadyCached=true;
|
||||
logger.info("Cache File Found (LastModified: "+cacheFile.lastModified()+" , Size: "+cacheFile.length()+")");
|
||||
}
|
||||
try {
|
||||
URL U = new URL(URL);
|
||||
C = (HttpURLConnection) U.openConnection();
|
||||
C.setReadTimeout(15000);
|
||||
C.setDoInput(true);
|
||||
C.setDoOutput(false);
|
||||
C.connect();
|
||||
logger.info("Response Code: "+C.getResponseCode());
|
||||
int respcode = C.getResponseCode() / 100;
|
||||
if (respcode != 4 && respcode != 5) { // Successful to get skin.
|
||||
if(C.getContentLength()<=0){//Nothing got
|
||||
logger.info("Nothing got.");
|
||||
return null;
|
||||
}
|
||||
logger.info("Successfully Get Resource (LastModified: "+C.getLastModified()+" , ContentLength: "+C.getContentLength()+")");
|
||||
if(alreadyCached && C.getLastModified()==cacheFile.lastModified() && C.getContentLength()==cacheFile.length()){
|
||||
logger.info("Not Modified.");
|
||||
return getStreamFromCache(cacheFile);
|
||||
}
|
||||
InputStream IS=new BufferedInputStream(C.getInputStream());
|
||||
if (!CheckPNG){ // If no need to check PNG header, just skip it.
|
||||
success=true;
|
||||
saveToCache(IS,cacheFile);
|
||||
return IS;
|
||||
}
|
||||
//logger.info(C.getContentLength()+" "+IS.available());
|
||||
IS.mark(C.getContentLength()+10);
|
||||
byte[] ib = new byte[4];
|
||||
IS.read(ib);
|
||||
if (ib[1] == (byte) 'P' && ib[2] == (byte) 'N' && ib[3] == (byte) 'G') { // Check PNG Header if needed
|
||||
IS.reset();
|
||||
success=true;
|
||||
saveToCache(IS,cacheFile);
|
||||
return IS;
|
||||
}
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
success=false;
|
||||
logger.log(Level.WARNING, ex.getMessage());
|
||||
if(alreadyCached)
|
||||
return getStreamFromCache(cacheFile);
|
||||
}finally{
|
||||
if(!success)
|
||||
disconnect();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
private InputStream getStreamFromCache(File cacheFile) {
|
||||
try{
|
||||
logger.info("Try load local cache in " + cacheFile.getAbsolutePath());
|
||||
InputStream in = new FileInputStream(cacheFile);
|
||||
BufferedInputStream bis=new BufferedInputStream(in);
|
||||
if(bis.available()<=0){
|
||||
logger.info("Cannot load local cache in " + cacheFile.getAbsolutePath());
|
||||
return null;
|
||||
}else{
|
||||
logger.info("Successfully load cache in " + cacheFile.getAbsolutePath());
|
||||
return bis;
|
||||
}
|
||||
}catch(Exception e){
|
||||
logger.log(Level.WARNING, e.getMessage());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
private void saveToCache(InputStream is,File to){
|
||||
logger.info("Try save local cache to " + to.getAbsolutePath());
|
||||
FileOutputStream fs=null;
|
||||
int times=0;
|
||||
try{//Save to Local Skin File
|
||||
if(to.exists()){
|
||||
to.delete();
|
||||
}
|
||||
fs = new FileOutputStream(to);
|
||||
int byteRead = 0;
|
||||
byte[] buffer = new byte[1024];
|
||||
while (( byteRead = is.read(buffer)) != -1) {
|
||||
times+=byteRead;
|
||||
fs.write(buffer, 0, byteRead);
|
||||
if(times>=C.getContentLength()){
|
||||
//logger.info(times+" "+C.getContentLength());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(to.length()>1){
|
||||
to.setLastModified(C.getLastModified());
|
||||
logger.info("Cache saved to " + to.getAbsolutePath()+" (LastModified: "+to.lastModified()+" , Size: "+to.length()+")");
|
||||
}else{
|
||||
to.delete();
|
||||
logger.info("Cannot save local cache to " + to.getAbsolutePath());
|
||||
}
|
||||
}catch(Exception e){
|
||||
logger.warning(e.getMessage());
|
||||
}finally{
|
||||
try {
|
||||
if(fs!=null)
|
||||
fs.close();
|
||||
is.reset();
|
||||
} catch (IOException e) {
|
||||
logger.warning(e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void disconnect() {
|
||||
if (C != null)
|
||||
C.disconnect();
|
||||
}
|
||||
|
||||
private static void refreshSkinURL() {
|
||||
try {
|
||||
if(!SKIN_URL_FILE.exists()){
|
||||
logger.log(Level.INFO, "SKIN config not found, create a new one.");
|
||||
SKIN_URL_FILE.createNewFile();
|
||||
}
|
||||
if(!CAPE_URL_FILE.exists()){
|
||||
logger.log(Level.INFO, "CAPE config not found, create a new one.");
|
||||
CAPE_URL_FILE.createNewFile();
|
||||
}
|
||||
skinURLs = readAllLines(SKIN_URL_FILE);
|
||||
cloakURLs = readAllLines(CAPE_URL_FILE);
|
||||
} catch (Exception ex) {
|
||||
logger.log(Level.WARNING, ex.getMessage());
|
||||
} finally {
|
||||
if(skinURLs.length==0&&cloakURLs.length==0){
|
||||
logger.info("No skinURLs and cloak URLS found, try to init and use default settings.");
|
||||
initSkinURL();
|
||||
refreshSkinURL();
|
||||
}else{
|
||||
logger.log(Level.INFO, "Skin URLs Refreshed. Skin count = "
|
||||
+ skinURLs.length + ", Cloak count = " + cloakURLs.length);
|
||||
}
|
||||
}
|
||||
}
|
||||
private static void initSkinURL(){
|
||||
//Init URL List
|
||||
skinURLs=DEFAULT_SKIN_URLS;
|
||||
writeToFile(new File(DATA_DIR,"skinurls.txt"),parseArrayToText(skinURLs));
|
||||
cloakURLs=DEFAULT_CAPE_URLS;
|
||||
writeToFile(new File(DATA_DIR,"capeurls.txt"),parseArrayToText(cloakURLs));
|
||||
}
|
||||
|
||||
private static String[] readAllLines(File F) {
|
||||
try {
|
||||
logger.log(Level.INFO, "Config file: " + F.getAbsolutePath());
|
||||
if (F.length() <= 0) {
|
||||
logger.log(Level.INFO, "Config file is blank, skipped.");
|
||||
return new String[0];
|
||||
} else {
|
||||
byte[] b = new byte[(int) F.length()];
|
||||
BufferedInputStream S = new BufferedInputStream(
|
||||
new FileInputStream(F));
|
||||
S.read(b);
|
||||
S.close();
|
||||
logger.log(Level.INFO, "Config file loaded.");
|
||||
String[] re= str_replace("\r", "\n",
|
||||
str_replace("\r\n", "\n", new String(b))).split("\n");
|
||||
for(int i=0;i<re.length;i++){
|
||||
if(re[i].startsWith("#"))//Remove note
|
||||
re[i]=null;
|
||||
else{//Remove same URL
|
||||
for(int g=0;g<re.length;g++){
|
||||
if(i==g)
|
||||
continue;
|
||||
if(re[i].equalsIgnoreCase(re[g])){
|
||||
re[i]=null;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return re;
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
logger.log(Level.WARNING, ex.getMessage());
|
||||
return new String[0];
|
||||
}
|
||||
}
|
||||
|
||||
private static String str_replace(String search, String replace,
|
||||
String subject) {
|
||||
StringBuffer result = new StringBuffer(subject);
|
||||
int pos;
|
||||
while ((pos = result.indexOf(search)) != -1)
|
||||
result.replace(pos, pos + search.length(), replace);
|
||||
return result.toString();
|
||||
}
|
||||
private static String parseArrayToText(String[] data){
|
||||
StringBuilder temp=new StringBuilder();
|
||||
for(int i=0;i<data.length-1;i++)
|
||||
temp.append(data[i]).append("\r\n");
|
||||
temp.append(data[data.length-1]);
|
||||
return temp.toString();
|
||||
}
|
||||
private static boolean writeToFile(File file,String Data){
|
||||
System.out.print("Write to "+file.getAbsolutePath()+" ");
|
||||
FileWriter fw=null;
|
||||
try{
|
||||
fw = new FileWriter(file);
|
||||
fw.write(Data,0,Data.length());
|
||||
fw.flush();
|
||||
fw.close();
|
||||
}catch(Exception ex){
|
||||
ex.printStackTrace();
|
||||
System.out.println("failed.");
|
||||
return false;
|
||||
}
|
||||
System.out.println("succeed.");
|
||||
return true;
|
||||
}
|
||||
|
||||
public String MD5(String str){
|
||||
byte [] buf = str.getBytes();
|
||||
MessageDigest md5;
|
||||
try {
|
||||
md5 = MessageDigest.getInstance("MD5");
|
||||
md5.update(buf);
|
||||
byte [] tmp = md5.digest();
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (byte b:tmp) {
|
||||
sb.append(Integer.toHexString(b&0xff));
|
||||
}
|
||||
return sb.toString();
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
logger.warning(e.getMessage());
|
||||
}
|
||||
return "Fail";
|
||||
}
|
||||
|
||||
private static MainLogger getLogger(File logFile){
|
||||
MainLogger mainLogger = new MainLogger(logFile);
|
||||
mainLogger.info("CustomSkinLoader " + VERSION);
|
||||
return mainLogger;
|
||||
}
|
||||
}
|
||||
@@ -1,71 +0,0 @@
|
||||
package idv.jlchntoz;
|
||||
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class MainLogger {
|
||||
private static final int LOWEST_DISPLAY_LEVEL=Level.INFO.intValue();
|
||||
SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
private BufferedWriter writer;
|
||||
public MainLogger(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"));
|
||||
} 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.intValue()>=LOWEST_DISPLAY_LEVEL)
|
||||
System.out.println(msg);
|
||||
try {
|
||||
writer.write("[");
|
||||
writer.write(DATE_FORMAT.format(new Date()));
|
||||
writer.write(" ");
|
||||
writer.write(Thread.currentThread().getName());
|
||||
writer.write(" ");
|
||||
writer.write(level.getName());
|
||||
writer.write("] ");
|
||||
writer.write(msg);
|
||||
writer.write("\r\n");
|
||||
writer.flush();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
public void info(String msg){
|
||||
log(Level.INFO,msg);
|
||||
}
|
||||
public void warning(String msg){
|
||||
log(Level.WARNING,msg);
|
||||
}
|
||||
public void warning(Exception e){
|
||||
log(Level.WARNING,"Exception occurs while running: "+e.getMessage());
|
||||
StackTraceElement[] stes=e.getStackTrace();
|
||||
for(StackTraceElement ste : stes){
|
||||
log(Level.WARNING,ste.toString());
|
||||
}
|
||||
log(Level.WARNING,"");
|
||||
}
|
||||
}
|
||||
@@ -1,117 +0,0 @@
|
||||
package net.minecraft.client.renderer;
|
||||
|
||||
import java.awt.Graphics;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.awt.image.DataBufferInt;
|
||||
import java.awt.image.ImageObserver;
|
||||
|
||||
public class ImageBufferDownload implements IImageBuffer
|
||||
{
|
||||
private int[] imageData;
|
||||
private int imageWidth;
|
||||
private int imageHeight;
|
||||
|
||||
public BufferedImage parseUserSkin(BufferedImage image)
|
||||
{
|
||||
if (image == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
else
|
||||
{
|
||||
int ratio=image.getWidth()/64;
|
||||
this.imageWidth = 64 * ratio;
|
||||
this.imageHeight = 64 * ratio;
|
||||
BufferedImage var2 = new BufferedImage(this.imageWidth, this.imageHeight, 2);
|
||||
Graphics var3 = var2.getGraphics();
|
||||
var3.drawImage(image, 0, 0, (ImageObserver)null);
|
||||
|
||||
if (image.getHeight() == 32 * ratio)
|
||||
{
|
||||
var3.drawImage(var2, 24 * ratio, 48 * ratio, 20 * ratio, 52 * ratio, 4 * ratio, 16 * ratio, 8 * ratio, 20 * ratio, (ImageObserver)null);
|
||||
var3.drawImage(var2, 28 * ratio, 48 * ratio, 24 * ratio, 52 * ratio, 8 * ratio, 16 * ratio, 12 * ratio, 20 * ratio, (ImageObserver)null);
|
||||
var3.drawImage(var2, 20 * ratio, 52 * ratio, 16 * ratio, 64 * ratio, 8 * ratio, 20 * ratio, 12 * ratio, 32 * ratio, (ImageObserver)null);
|
||||
var3.drawImage(var2, 24 * ratio, 52 * ratio, 20 * ratio, 64 * ratio, 4 * ratio, 20 * ratio, 8 * ratio, 32 * ratio, (ImageObserver)null);
|
||||
var3.drawImage(var2, 28 * ratio, 52 * ratio, 24 * ratio, 64 * ratio, 0 * ratio, 20 * ratio, 4 * ratio, 32 * ratio, (ImageObserver)null);
|
||||
var3.drawImage(var2, 32 * ratio, 52 * ratio, 28 * ratio, 64 * ratio, 12 * ratio, 20 * ratio, 16 * ratio, 32 * ratio, (ImageObserver)null);
|
||||
var3.drawImage(var2, 40 * ratio, 48 * ratio, 36 * ratio, 52 * ratio, 44 * ratio, 16 * ratio, 48 * ratio, 20 * ratio, (ImageObserver)null);
|
||||
var3.drawImage(var2, 44 * ratio, 48 * ratio, 40 * ratio, 52 * ratio, 48 * ratio, 16 * ratio, 52 * ratio, 20 * ratio, (ImageObserver)null);
|
||||
var3.drawImage(var2, 36 * ratio, 52 * ratio, 32 * ratio, 64 * ratio, 48 * ratio, 20 * ratio, 52 * ratio, 32 * ratio, (ImageObserver)null);
|
||||
var3.drawImage(var2, 40 * ratio, 52 * ratio, 36 * ratio, 64 * ratio, 44 * ratio, 20 * ratio, 48 * ratio, 32 * ratio, (ImageObserver)null);
|
||||
var3.drawImage(var2, 44 * ratio, 52 * ratio, 40 * ratio, 64 * ratio, 40 * ratio, 20 * ratio, 44 * ratio, 32 * ratio, (ImageObserver)null);
|
||||
var3.drawImage(var2, 48 * ratio, 52 * ratio, 44 * ratio, 64 * ratio, 52 * ratio, 20 * ratio, 56 * ratio, 32 * ratio, (ImageObserver)null);
|
||||
}
|
||||
|
||||
var3.dispose();
|
||||
this.imageData = ((DataBufferInt)var2.getRaster().getDataBuffer()).getData();
|
||||
this.setAreaOpaque(0, 0, 32 * ratio, 16 * ratio);
|
||||
this.setAreaTransparent(32 * ratio, 0, 64 * ratio, 32 * ratio);
|
||||
this.setAreaOpaque(0, 16 * ratio, 64 * ratio, 32 * ratio);
|
||||
this.setAreaTransparent(0, 32 * ratio, 16 * ratio, 48 * ratio);
|
||||
this.setAreaTransparent(16 * ratio, 32 * ratio, 40 * ratio, 48 * ratio);
|
||||
this.setAreaTransparent(40 * ratio, 32 * ratio, 56 * ratio, 48 * ratio);
|
||||
this.setAreaTransparent(0, 48 * ratio, 16 * ratio, 64 * ratio);
|
||||
this.setAreaOpaque(16 * ratio, 48 * ratio, 48 * ratio, 64 * ratio);
|
||||
this.setAreaTransparent(48 * ratio, 48 * ratio, 64 * ratio, 64 * ratio);
|
||||
return var2;
|
||||
}
|
||||
}
|
||||
|
||||
public void skinAvailable()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes the given area of the image transparent if it was previously completely opaque (used to remove the outer
|
||||
* layer of a skin around the head if it was saved all opaque; this would be redundant so it's assumed that the skin
|
||||
* maker is just using an image editor without an alpha channel)
|
||||
*/
|
||||
private void setAreaTransparent(int p_78434_1_, int p_78434_2_, int p_78434_3_, int p_78434_4_)
|
||||
{
|
||||
if (!this.hasTransparency(p_78434_1_, p_78434_2_, p_78434_3_, p_78434_4_))
|
||||
{
|
||||
for (int i = p_78434_1_; i < p_78434_3_; ++i)
|
||||
{
|
||||
for (int j = p_78434_2_; j < p_78434_4_; ++j)
|
||||
{
|
||||
this.imageData[i + j * this.imageWidth] &= 16777215;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes the given area of the image opaque
|
||||
*/
|
||||
private void setAreaOpaque(int p_78433_1_, int p_78433_2_, int p_78433_3_, int p_78433_4_)
|
||||
{
|
||||
for (int i = p_78433_1_; i < p_78433_3_; ++i)
|
||||
{
|
||||
for (int j = p_78433_2_; j < p_78433_4_; ++j)
|
||||
{
|
||||
this.imageData[i + j * this.imageWidth] |= -16777216;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the given area of the image contains transparent pixels
|
||||
*/
|
||||
private boolean hasTransparency(int p_78435_1_, int p_78435_2_, int p_78435_3_, int p_78435_4_)
|
||||
{
|
||||
for (int i = p_78435_1_; i < p_78435_3_; ++i)
|
||||
{
|
||||
for (int j = p_78435_2_; j < p_78435_4_; ++j)
|
||||
{
|
||||
int k = this.imageData[i + j * this.imageWidth];
|
||||
|
||||
if ((k >> 24 & 255) < 128)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
-148
@@ -1,148 +0,0 @@
|
||||
package net.minecraft.client.renderer;
|
||||
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import javax.imageio.ImageIO;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.texture.SimpleTexture;
|
||||
import net.minecraft.client.renderer.texture.TextureUtil;
|
||||
import net.minecraft.client.resources.IResourceManager;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import idv.jlchntoz.CustomSkinLoader;
|
||||
|
||||
public class ThreadDownloadImageData extends SimpleTexture
|
||||
{
|
||||
private static final Logger logger = LogManager.getLogger();
|
||||
private static final AtomicInteger threadDownloadCounter = new AtomicInteger(0);
|
||||
private final File cacheFile;
|
||||
private final String imageUrl;
|
||||
private final IImageBuffer imageBuffer;
|
||||
private BufferedImage bufferedImage;
|
||||
private Thread imageThread;
|
||||
private boolean textureUploaded;
|
||||
|
||||
//For Optifine
|
||||
public Boolean imageFound = null;
|
||||
public boolean pipeline = false;
|
||||
|
||||
public ThreadDownloadImageData(File cacheFileIn, String imageUrlIn, ResourceLocation textureResourceLocation, IImageBuffer imageBufferIn)
|
||||
{
|
||||
super(textureResourceLocation);
|
||||
this.cacheFile = cacheFileIn;
|
||||
this.imageUrl = imageUrlIn;
|
||||
this.imageBuffer = imageBufferIn;
|
||||
}
|
||||
|
||||
private void checkTextureUploaded()
|
||||
{
|
||||
if (!this.textureUploaded)
|
||||
{
|
||||
if (this.bufferedImage != null)
|
||||
{
|
||||
if (this.textureLocation != null)
|
||||
{
|
||||
this.deleteGlTexture();
|
||||
}
|
||||
|
||||
TextureUtil.uploadTextureImage(super.getGlTextureId(), this.bufferedImage);
|
||||
this.textureUploaded = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public int getGlTextureId()
|
||||
{
|
||||
this.checkTextureUploaded();
|
||||
return super.getGlTextureId();
|
||||
}
|
||||
|
||||
public void setBufferedImage(BufferedImage bufferedImageIn)
|
||||
{
|
||||
this.bufferedImage = bufferedImageIn;
|
||||
|
||||
if (this.imageBuffer != null)
|
||||
{
|
||||
this.imageBuffer.skinAvailable();
|
||||
}
|
||||
}
|
||||
|
||||
public void loadTexture(IResourceManager resourceManager) throws IOException
|
||||
{
|
||||
if (this.bufferedImage == null && this.textureLocation != null)
|
||||
{
|
||||
super.loadTexture(resourceManager);
|
||||
}
|
||||
|
||||
if (this.imageThread == null)
|
||||
{
|
||||
if (this.cacheFile != null && this.cacheFile.isFile())
|
||||
{
|
||||
logger.info("Loading http texture from local cache ({})", new Object[] {this.cacheFile});
|
||||
|
||||
try
|
||||
{
|
||||
this.bufferedImage = ImageIO.read(this.cacheFile);
|
||||
|
||||
if (this.imageBuffer != null)
|
||||
{
|
||||
this.setBufferedImage(this.imageBuffer.parseUserSkin(this.bufferedImage));
|
||||
}
|
||||
}
|
||||
catch (IOException ioexception)
|
||||
{
|
||||
logger.error((String)("Couldn\'t load skin " + this.cacheFile), (Throwable)ioexception);
|
||||
this.loadTextureFromServer();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.loadTextureFromServer();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void loadTextureFromServer()
|
||||
{
|
||||
this.imageThread = new Thread("Texture Downloader #" + threadDownloadCounter.incrementAndGet())
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
CustomSkinLoader loader=new CustomSkinLoader();
|
||||
ThreadDownloadImageData.logger.info("Downloading http texture from {} to {}", new Object[] {ThreadDownloadImageData.this.imageUrl, ThreadDownloadImageData.this.cacheFile});
|
||||
|
||||
try
|
||||
{
|
||||
BufferedImage bufferedimage;
|
||||
bufferedimage = TextureUtil.readBufferedImage(loader.getPlayerSkinStream(ThreadDownloadImageData.this.imageUrl));
|
||||
|
||||
if (ThreadDownloadImageData.this.imageBuffer != null)
|
||||
{
|
||||
bufferedimage = ThreadDownloadImageData.this.imageBuffer.parseUserSkin(bufferedimage);
|
||||
}
|
||||
|
||||
ThreadDownloadImageData.this.setBufferedImage(bufferedimage);
|
||||
return;
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
ThreadDownloadImageData.logger.error((String)"Couldn\'t download http texture", (Throwable)exception);
|
||||
return;
|
||||
}
|
||||
finally
|
||||
{
|
||||
loader.disconnect();
|
||||
}
|
||||
}
|
||||
};
|
||||
this.imageThread.setDaemon(true);
|
||||
this.imageThread.start();
|
||||
}
|
||||
}
|
||||
@@ -1,184 +0,0 @@
|
||||
package net.minecraft.client.resources;
|
||||
|
||||
import com.google.common.cache.CacheBuilder;
|
||||
import com.google.common.cache.CacheLoader;
|
||||
import com.google.common.cache.LoadingCache;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import com.mojang.authlib.minecraft.InsecureTextureException;
|
||||
import com.mojang.authlib.minecraft.MinecraftProfileTexture;
|
||||
import com.mojang.authlib.minecraft.MinecraftSessionService;
|
||||
import com.mojang.authlib.minecraft.MinecraftProfileTexture.Type;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.File;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.LinkedBlockingQueue;
|
||||
import java.util.concurrent.ThreadPoolExecutor;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.IImageBuffer;
|
||||
import net.minecraft.client.renderer.ImageBufferDownload;
|
||||
import net.minecraft.client.renderer.ThreadDownloadImageData;
|
||||
import net.minecraft.client.renderer.texture.ITextureObject;
|
||||
import net.minecraft.client.renderer.texture.TextureManager;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
public class SkinManager
|
||||
{
|
||||
private static final ExecutorService THREAD_POOL = new ThreadPoolExecutor(0, 2, 1L, TimeUnit.MINUTES, new LinkedBlockingQueue());
|
||||
private final TextureManager textureManager;
|
||||
private final File skinCacheDir;
|
||||
private final MinecraftSessionService sessionService;
|
||||
private final LoadingCache<GameProfile, Map<Type, MinecraftProfileTexture>> skinCacheLoader;
|
||||
|
||||
public SkinManager(TextureManager textureManagerInstance, File skinCacheDirectory, MinecraftSessionService sessionService)
|
||||
{
|
||||
this.textureManager = textureManagerInstance;
|
||||
this.skinCacheDir = skinCacheDirectory;
|
||||
this.sessionService = sessionService;
|
||||
this.skinCacheLoader = CacheBuilder.newBuilder().expireAfterAccess(15L, TimeUnit.SECONDS).<GameProfile, Map<Type, MinecraftProfileTexture>>build(new CacheLoader<GameProfile, Map<Type, MinecraftProfileTexture>>()
|
||||
{
|
||||
public Map<Type, MinecraftProfileTexture> load(GameProfile p_load_1_) throws Exception
|
||||
{
|
||||
return Minecraft.getMinecraft().getSessionService().getTextures(p_load_1_, false);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Used in the Skull renderer to fetch a skin. May download the skin if it's not in the cache
|
||||
*/
|
||||
public ResourceLocation loadSkin(MinecraftProfileTexture profileTexture, Type p_152792_2_)
|
||||
{
|
||||
return this.loadSkin(profileTexture, p_152792_2_, (SkinManager.SkinAvailableCallback)null);
|
||||
}
|
||||
|
||||
/**
|
||||
* May download the skin if its not in the cache, can be passed a SkinManager#SkinAvailableCallback for handling
|
||||
*/
|
||||
public ResourceLocation loadSkin(final MinecraftProfileTexture profileTexture, final Type p_152789_2_, final SkinManager.SkinAvailableCallback skinAvailableCallback)
|
||||
{
|
||||
final ResourceLocation resourcelocation = new ResourceLocation(p_152789_2_.name() + "/" + profileTexture.getHash());
|
||||
/*Remove cache
|
||||
ITextureObject itextureobject = this.textureManager.getTexture(resourcelocation);
|
||||
|
||||
if (itextureobject != null)
|
||||
{
|
||||
if (skinAvailableCallback != null)
|
||||
{
|
||||
skinAvailableCallback.skinAvailable(p_152789_2_, resourcelocation, profileTexture);
|
||||
}
|
||||
}
|
||||
else
|
||||
{*/
|
||||
File file1 = new File(this.skinCacheDir, profileTexture.getHash().length() > 2 ? profileTexture.getHash().substring(0, 2) : "xx");
|
||||
File file2 = new File(file1, profileTexture.getHash());
|
||||
final IImageBuffer iimagebuffer = p_152789_2_ == Type.SKIN ? new ImageBufferDownload() : null;
|
||||
ThreadDownloadImageData threaddownloadimagedata = new ThreadDownloadImageData(file2, profileTexture.getUrl(), DefaultPlayerSkin.getDefaultSkinLegacy(), new IImageBuffer()
|
||||
{
|
||||
public BufferedImage parseUserSkin(BufferedImage image)
|
||||
{
|
||||
if (iimagebuffer != null)
|
||||
{
|
||||
image = iimagebuffer.parseUserSkin(image);
|
||||
}
|
||||
|
||||
return image;
|
||||
}
|
||||
public void skinAvailable()
|
||||
{
|
||||
if (iimagebuffer != null)
|
||||
{
|
||||
iimagebuffer.skinAvailable();
|
||||
}
|
||||
|
||||
if (skinAvailableCallback != null)
|
||||
{
|
||||
skinAvailableCallback.skinAvailable(p_152789_2_, resourcelocation, profileTexture);
|
||||
}
|
||||
}
|
||||
});
|
||||
this.textureManager.loadTexture(resourcelocation, threaddownloadimagedata);
|
||||
//}
|
||||
|
||||
return resourcelocation;
|
||||
}
|
||||
|
||||
public void loadProfileTextures(final GameProfile profile, final SkinManager.SkinAvailableCallback skinAvailableCallback, final boolean requireSecure)
|
||||
{
|
||||
THREAD_POOL.submit(new Runnable()
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
final Map<Type, MinecraftProfileTexture> map = Maps.<Type, MinecraftProfileTexture>newHashMap();
|
||||
|
||||
try
|
||||
{
|
||||
map.putAll(SkinManager.this.sessionService.getTextures(profile, requireSecure));
|
||||
}
|
||||
catch (InsecureTextureException var3)
|
||||
{
|
||||
;
|
||||
}
|
||||
|
||||
if (map.isEmpty() && profile.getId().equals(Minecraft.getMinecraft().getSession().getProfile().getId()))
|
||||
{
|
||||
profile.getProperties().clear();
|
||||
profile.getProperties().putAll(Minecraft.getMinecraft().func_181037_M());
|
||||
map.putAll(SkinManager.this.sessionService.getTextures(profile, false));
|
||||
}
|
||||
//CustomSkinLoader Begin
|
||||
Map<Type, MinecraftProfileTexture> var2 = Maps.<Type, MinecraftProfileTexture>newHashMap();
|
||||
if (map.containsKey(Type.SKIN)){
|
||||
MinecraftProfileTexture var3=((MinecraftProfileTexture)map.get(Type.SKIN));
|
||||
String var4=var3.getMetadata("model");
|
||||
Map var5 = null;
|
||||
if(var4!=null){
|
||||
var5 = Maps.newHashMap();
|
||||
var5.put("model", var4);
|
||||
}
|
||||
var2.put(Type.SKIN, new MinecraftProfileTexture(var3.getUrl()+"?Skin="+profile.getName(),var5));
|
||||
}else{
|
||||
Map var5 = Maps.newHashMap();
|
||||
//var5.put("model", "slim");
|
||||
var2.put(Type.SKIN,new MinecraftProfileTexture( "http://skins.minecraft.net/MinecraftSkins/"+profile.getName()+".png",var5));
|
||||
}
|
||||
if (map.containsKey(Type.CAPE)){
|
||||
var2.put(Type.CAPE, new MinecraftProfileTexture(((MinecraftProfileTexture)map.get(Type.CAPE)).getUrl()+"?Cloak="+profile.getName(),null));
|
||||
}else{
|
||||
var2.put(Type.CAPE,new MinecraftProfileTexture( "http://skins.minecraft.net/MinecraftCloaks/"+profile.getName()+".png",null));
|
||||
}
|
||||
map.clear();
|
||||
map.putAll(var2);
|
||||
//CustomSkinLoader End
|
||||
|
||||
Minecraft.getMinecraft().addScheduledTask(new Runnable()
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
if (map.containsKey(Type.SKIN))
|
||||
{
|
||||
SkinManager.this.loadSkin((MinecraftProfileTexture)map.get(Type.SKIN), Type.SKIN, skinAvailableCallback);
|
||||
}
|
||||
|
||||
if (map.containsKey(Type.CAPE))
|
||||
{
|
||||
SkinManager.this.loadSkin((MinecraftProfileTexture)map.get(Type.CAPE), Type.CAPE, skinAvailableCallback);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public Map<Type, MinecraftProfileTexture> loadSkinFromCache(GameProfile profile)
|
||||
{
|
||||
return (Map)this.skinCacheLoader.getUnchecked(profile);
|
||||
}
|
||||
|
||||
public interface SkinAvailableCallback
|
||||
{
|
||||
void skinAvailable(Type p_180521_1_, ResourceLocation location, MinecraftProfileTexture profileTexture);
|
||||
}
|
||||
}
|
||||
+149
@@ -0,0 +1,149 @@
|
||||
# Development and Contribution
|
||||
|
||||
## Building
|
||||
1. Run `./gradlew setupDecompWorkspace clean build` command.
|
||||
1. The built jars are all in `${rootprojectDir}/build/libs` folder.
|
||||
|
||||
*NOTICE: The jar file with specific Minecraft version is for the vanilla edition without Forge and Fabric. The json files are launcher profiles which only work when building with our CI server.*
|
||||
|
||||
## Running and Testing
|
||||
For now, CustomSkinLoader is unable to run under self development environment, so it needs to add to another development environment as a library.
|
||||
There are the available versions in different environments below:
|
||||
|
||||
| | 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* |
|
||||
| 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
|
||||
1. Create a new empty minecraft development environment.
|
||||
1. Add below contents to `build.gradle`:
|
||||
```gradle
|
||||
repositories {
|
||||
maven {
|
||||
url = "file:/${projectDir}/local-repo"
|
||||
}
|
||||
}
|
||||
```
|
||||
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.17.1 ~ latest: ./local-repo/mods/CustomSkinLoader_ForgeActive/${version}
|
||||
Fabric: ./local-repo/mods/CustomSkinLoader_Fabric/${version}
|
||||
```
|
||||
*`${version}` should be repalced with something like `14.15-SNAPSHOT-00` manually*
|
||||
1. Create a pom file in the same folder:
|
||||
- Forge 1.8 ~ 1.16.5: `CustomSkinLoader_ForgeLegacy-${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_ForgeLegacy</artifactId>
|
||||
<!-- `${version}` should be repalced with something like `14.15-SNAPSHOT-00` manually -->
|
||||
<version>${version}</version>
|
||||
</project>
|
||||
```
|
||||
- Forge 1.17.1 ~ latest: `CustomSkinLoader_ForgeActive-${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_ForgeActive</artifactId>
|
||||
<!-- `${version}` should be repalced with something like `14.15-SNAPSHOT-00` manually -->
|
||||
<version>${version}</version>
|
||||
</project>
|
||||
```
|
||||
- Fabric: `CustomSkinLoader_Fabric-${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_Fabric</artifactId>
|
||||
<!-- `${version}` should be repalced with something like `14.15-SNAPSHOT-00` manually -->
|
||||
<version>${version}</version>
|
||||
</project>
|
||||
```
|
||||
|
||||
### For ForgeGradle 2.x ( forge-1.8-11.14.3.1503 ~ forge-1.12.2-14.23.5.2847 )
|
||||
1. Add below contents to `build.gradle`:
|
||||
```gradle
|
||||
dependencies {
|
||||
deobfCompile "mods:CustomSkinLoader_ForgeLegacy:14.15-SNAPSHOT-00"
|
||||
}
|
||||
|
||||
minecraft {
|
||||
clientRunArgs += ["--tweakClass", "customskinloader.forge.ForgeDevTweaker", "--username", "<Your username>"]
|
||||
}
|
||||
```
|
||||
1. Run `./gradlew setupDecompWorkspace` 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 )
|
||||
1. Add below contents to `build.gradle`:
|
||||
```gradle
|
||||
dependencies {
|
||||
implementation fg.deobf("mods:CustomSkinLoader_ForgeLegacy:14.15-SNAPSHOT-00") // Only required for MinecraftForge 1.8 ~ 1.16.5
|
||||
implementation fg.deobf("mods:CustomSkinLoader_ForgeActive:14.15-SNAPSHOT-00") // Only required for MinecraftForge 1.17.1 ~ latest
|
||||
}
|
||||
|
||||
minecraft {
|
||||
runs {
|
||||
client {
|
||||
args += ["--username", "<Your username>"]
|
||||
args += ["--tweakClass", "customskinloader.forge.ForgeDevTweaker"] // Only required for MinecraftForge 1.12.2
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
1. Setup the development environment and run the game as usual.
|
||||
|
||||
### For fabric-loom ( fabric-loader-0.12.0 ~ latest )
|
||||
1. Add below contents to `build.gradle`:
|
||||
```gradle
|
||||
dependencies {
|
||||
modImplementation "mods:CustomSkinLoader_Fabric:14.15-SNAPSHOT-00"
|
||||
}
|
||||
|
||||
tasks.runClient {
|
||||
args += ["--username", "<Your username>"]
|
||||
}
|
||||
```
|
||||
1. Add `--username <Your username>` to CLI arguments in `Run/Debug Configurations` dialog.
|
||||
1. Run the game in IDE or through `./gradlew runClient` command..
|
||||
|
||||
## Depend on release builds
|
||||
1. Check the latest version in https://littlesk.in/csl-latest .
|
||||
1. Add below contents to `build.gradle`:
|
||||
```gradle
|
||||
// Before Gradle 5.x
|
||||
repositories {
|
||||
ivy {
|
||||
url = "https://csl.littleservice.cn/"
|
||||
layout "pattern", {
|
||||
artifact "[organisation]/[artifact]-[revision](-[classifier])(.[ext])"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// After Gradle 6.x
|
||||
repositories {
|
||||
ivy {
|
||||
url = "https://csl.littleservice.cn/"
|
||||
metadataSources {
|
||||
artifact()
|
||||
}
|
||||
patternLayout {
|
||||
artifact "[organisation]/[artifact]-[revision](-[classifier])(.[ext])"
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
1. Follow the same steps in **Running and Testing**.
|
||||
|
||||
## 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.
|
||||
- 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.
|
||||
@@ -1,3 +0,0 @@
|
||||
Manifest-Version: 1.0
|
||||
TweakClass: idv.jlchntoz.tweaker.ForgeTweaker
|
||||
TweakOrder: -10
|
||||
@@ -1,99 +0,0 @@
|
||||
package idv.jlchntoz.tweaker;
|
||||
|
||||
import idv.jlchntoz.CustomSkinLoader;
|
||||
|
||||
import java.io.*;
|
||||
import java.net.*;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipFile;
|
||||
|
||||
import net.minecraft.launchwrapper.IClassTransformer;
|
||||
|
||||
public class ClassTransformer implements IClassTransformer {
|
||||
|
||||
private ZipFile zipFile = null;
|
||||
|
||||
public ClassTransformer() {
|
||||
ForgeTweaker.logger.info("ClassTransformer Begin");
|
||||
try {
|
||||
URLClassLoader ucl = (URLClassLoader)idv.jlchntoz.tweaker.ClassTransformer.class.getClassLoader();
|
||||
URL urls[] = ucl.getURLs();
|
||||
for (int i = 0; i < urls.length; i++) {
|
||||
URL url = urls[i];
|
||||
ZipFile tempZipFile = getZipFile(url);
|
||||
if (tempZipFile == null)
|
||||
continue;
|
||||
zipFile = tempZipFile;
|
||||
ForgeTweaker.logger.info("Jar File URL: " + url);
|
||||
break;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
if (zipFile == null) {
|
||||
ForgeTweaker.logger.info("Can not find needed JAR in the classpath.");
|
||||
}
|
||||
}
|
||||
|
||||
private static ZipFile getZipFile(URL url)
|
||||
{
|
||||
ZipFile zipFile0;
|
||||
try {
|
||||
URI uri = url.toURI();
|
||||
File file = new File(uri);
|
||||
zipFile0 = new ZipFile(file);
|
||||
if (zipFile0.getEntry("idv/jlchntoz/tweaker/ClassTransformer.class") != null){
|
||||
ForgeTweaker.logger.info("JAR Found!");
|
||||
return zipFile0;
|
||||
}
|
||||
zipFile0.close();
|
||||
} catch (Exception e) {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public byte[] transform(String name, String transformedName, byte bytes[]) {
|
||||
byte diBytes[] = getClass(name);
|
||||
if (diBytes != null) {
|
||||
ForgeTweaker.logger.info("Class '" + name + "' transformed.");
|
||||
return diBytes;
|
||||
}
|
||||
else
|
||||
return bytes;
|
||||
}
|
||||
|
||||
private byte[] getClass(String name) {
|
||||
if (zipFile == null)
|
||||
return null;
|
||||
String fullName = name + ".class";
|
||||
ZipEntry ze = zipFile.getEntry(fullName);
|
||||
if (ze == null)
|
||||
return null;
|
||||
try {
|
||||
InputStream in = zipFile.getInputStream(ze);
|
||||
byte[] bytes = readAll(in);
|
||||
if ((long)bytes.length == ze.getSize())
|
||||
return bytes;
|
||||
ForgeTweaker.logger.info("Failed: " + fullName + " " + bytes.length + " / " + ze.getSize());
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
public static byte[] readAll(InputStream is) throws IOException {
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
byte buffer[] = new byte[1024];
|
||||
do {
|
||||
int len = is.read(buffer);
|
||||
if (len >= 0) {
|
||||
baos.write(buffer, 0, len);
|
||||
} else {
|
||||
is.close();
|
||||
byte bytes[] = baos.toByteArray();
|
||||
return bytes;
|
||||
}
|
||||
} while (true);
|
||||
}
|
||||
}
|
||||
@@ -1,39 +0,0 @@
|
||||
package idv.jlchntoz.tweaker;
|
||||
|
||||
import idv.jlchntoz.MainLogger;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.launchwrapper.ITweaker;
|
||||
import net.minecraft.launchwrapper.LaunchClassLoader;
|
||||
|
||||
public class ForgeTweaker implements ITweaker {
|
||||
|
||||
private static final File TWEAKER_LOG_FILE = new File("CustomSkinLoader/Tweaker.log");
|
||||
public static MainLogger logger = new MainLogger(TWEAKER_LOG_FILE);
|
||||
|
||||
public ForgeTweaker() {
|
||||
logger.info("Using ForgeTweaker");
|
||||
}
|
||||
|
||||
public void acceptOptions(List args, File gameDir, File assetsDir, String profile) {
|
||||
logger.info("ForgeTweaker: acceptOptions");
|
||||
}
|
||||
|
||||
public void injectIntoClassLoader(LaunchClassLoader classLoader) {
|
||||
logger.info("ForgeTweaker: injectIntoClassLoader");
|
||||
classLoader.registerTransformer("idv.jlchntoz.tweaker.ClassTransformer");
|
||||
logger.info("ClassTransformer Registered");
|
||||
}
|
||||
|
||||
public String getLaunchTarget() {
|
||||
logger.info("ForgeTweaker: getLaunchTarget");
|
||||
return "net.minecraft.client.main.Main";
|
||||
}
|
||||
|
||||
public String[] getLaunchArguments() {
|
||||
logger.info("ForgeTweaker: getLaunchArguments");
|
||||
return new String[0];
|
||||
}
|
||||
}
|
||||
@@ -1,54 +0,0 @@
|
||||
package idv.jlchntoz.tweaker;
|
||||
|
||||
import idv.jlchntoz.MainLogger;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.launchwrapper.ITweaker;
|
||||
import net.minecraft.launchwrapper.LaunchClassLoader;
|
||||
|
||||
public class Tweaker implements ITweaker {
|
||||
|
||||
private List args;
|
||||
private String gameDir;
|
||||
private String assetsDir;
|
||||
private String profile;
|
||||
|
||||
private static final File TWEAKER_LOG_FILE = new File("CustomSkinLoader/Tweaker.log");
|
||||
public static MainLogger logger = new MainLogger(TWEAKER_LOG_FILE);
|
||||
|
||||
public Tweaker() {
|
||||
logger.info("Using Tweaker");
|
||||
}
|
||||
|
||||
public void acceptOptions(List args, File gameDir, File assetsDir, String profile) {
|
||||
logger.info("Tweaker: acceptOptions");
|
||||
this.args = new ArrayList(args);
|
||||
this.gameDir = gameDir.getAbsolutePath();
|
||||
this.assetsDir = assetsDir.getAbsolutePath();
|
||||
this.profile = profile;
|
||||
}
|
||||
|
||||
public void injectIntoClassLoader(LaunchClassLoader classLoader) {
|
||||
logger.info("Tweaker: injectIntoClassLoader");
|
||||
logger.info("Loaded as a library.");
|
||||
}
|
||||
|
||||
public String getLaunchTarget() {
|
||||
logger.info("Tweaker: getLaunchTarget");
|
||||
return "net.minecraft.client.main.Main";
|
||||
}
|
||||
|
||||
public String[] getLaunchArguments() {
|
||||
logger.info("Tweaker: getLaunchArguments");
|
||||
this.args.add("--gameDir");
|
||||
this.args.add(gameDir);
|
||||
this.args.add("--assetsDir");
|
||||
this.args.add(assetsDir);
|
||||
this.args.add("--version");
|
||||
this.args.add(profile);
|
||||
return (String[])args.toArray(new String[args.size()]);
|
||||
}
|
||||
}
|
||||
Binary file not shown.
@@ -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,11 @@
|
||||
{
|
||||
"name": "CustomSkinLoader",
|
||||
"version": "${modVersion}",
|
||||
"fullVersion": "${modFullVersion}",
|
||||
"mcVersion": "${mcVersion}",
|
||||
"mcFullVersions": "${mcFullVersions}",
|
||||
"forgeVersion": "${forgeVersion}",
|
||||
"gitVersion": "${gitVersion}",
|
||||
"buildUrl": "${buildUrl}",
|
||||
"buildTime": "${releaseTime}"
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
English(en)
|
||||
|
||||
LICENSE - Binary File
|
||||
You could not modify binary file.
|
||||
Feel free to use and share this mod and unmodified file in anyway like modpack.
|
||||
When using in modpack, you must put 'CustomSkinLoader' in mod list.
|
||||
You could not repost this mod to any website without permission.
|
||||
You could not earn money with this mod excluding modpack.
|
||||
|
||||
LICENSE - Source Code
|
||||
GPLv3: http://www.gnu.org/licenses/gpl.html
|
||||
When using the code, you should change the name of package to avoid others' misunderstanding.
|
||||
|
||||
OTHER - Useful Link
|
||||
Source Code: https://github.com/xfl03/MCCustomSkinLoader
|
||||
Release Page: http://www.mcbbs.net/thread-269807-1-1.html
|
||||
Build Server: https://ci.infstudio.net/job/CustomSkinLoader/
|
||||
|
||||
|
||||
中文简体(zh_cn)
|
||||
|
||||
许可 - 编译产物
|
||||
您不得对CustomSkinLoader的成品jar内部内容进行任何修改
|
||||
您可以在不经我许可的情况下,以任意方式传播这一mod以及jar文件(例如加入整合包)。
|
||||
在加入整合包时,请必须在帖子内mod列表中明确写上"万用皮肤补丁"或者"CustomSkinLoader"或者附上发布页面地址。
|
||||
您不得在未经许可的情况下,在国内外任何网站进行二次发布(包括皮肤站)。
|
||||
您不得以任何形式出售CustomSkinLoader或任何使用或参考CustomSkinLoader源代码的作品。
|
||||
|
||||
许可 - 源代码
|
||||
GPLv3: http://www.gnu.org/licenses/gpl.html
|
||||
为避免他人误解,您在使用代码时必须修改包名。
|
||||
|
||||
其他 - 有用的链接
|
||||
源代码: https://github.com/xfl03/MCCustomSkinLoader
|
||||
发布页面: http://www.mcbbs.net/thread-269807-1-1.html
|
||||
构建服务器: https://ci.infstudio.net/job/CustomSkinLoader/
|
||||
@@ -0,0 +1,254 @@
|
||||
package customskinloader;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.LinkedBlockingQueue;
|
||||
import java.util.concurrent.ThreadFactory;
|
||||
import java.util.concurrent.ThreadPoolExecutor;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
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 customskinloader.config.Config;
|
||||
import customskinloader.config.SkinSiteProfile;
|
||||
import customskinloader.loader.ProfileLoader;
|
||||
import customskinloader.log.LogManager;
|
||||
import customskinloader.log.Logger;
|
||||
import customskinloader.profile.DynamicSkullManager;
|
||||
import customskinloader.profile.ModelManager0;
|
||||
import customskinloader.profile.ProfileCache;
|
||||
import customskinloader.profile.UserProfile;
|
||||
import customskinloader.utils.MinecraftUtil;
|
||||
|
||||
/**
|
||||
* Custom skin loader mod for Minecraft.
|
||||
*
|
||||
* @author Jeremy Lam [JLChnToZ] 2013-2014 & Alexander Xia [xfl03] 2014-2023
|
||||
* @version @MOD_FULL_VERSION@
|
||||
*/
|
||||
public class CustomSkinLoader {
|
||||
public static final String CustomSkinLoader_VERSION = "@MOD_VERSION@";
|
||||
public static final String CustomSkinLoader_FULL_VERSION = "@MOD_FULL_VERSION@";
|
||||
public static final int CustomSkinLoader_BUILD_NUMBER = Integer.parseInt("@MOD_BUILD_NUMBER@");
|
||||
|
||||
public static final File
|
||||
DATA_DIR = new File(MinecraftUtil.getMinecraftDataDir(), "CustomSkinLoader"),
|
||||
LOG_FILE = new File(DATA_DIR, "CustomSkinLoader.log"),
|
||||
CONFIG_FILE = new File(DATA_DIR, "CustomSkinLoader.json");
|
||||
|
||||
public static final Gson GSON = new GsonBuilder().setPrettyPrinting().create();
|
||||
public static final Logger logger = initLogger();
|
||||
public static final Config config = initConfig();
|
||||
|
||||
private static final ProfileCache profileCache = new ProfileCache();
|
||||
private static final DynamicSkullManager dynamicSkullManager = new DynamicSkullManager();
|
||||
|
||||
private static final ExecutorService THREAD_POOL = new ThreadPoolExecutor(
|
||||
config.threadPoolSize, config.threadPoolSize, 1L, TimeUnit.MINUTES, new LinkedBlockingQueue<>());
|
||||
|
||||
//Correct thread name in thread pool
|
||||
private static final ThreadFactory defaultFactory = Executors.defaultThreadFactory();
|
||||
private static final ThreadFactory customFactory = r -> {
|
||||
Thread t = defaultFactory.newThread(r);
|
||||
if (r instanceof Thread) {
|
||||
t.setName(((Thread) r).getName());
|
||||
}
|
||||
return t;
|
||||
};
|
||||
//Thread pool will discard oldest task when queue reaches 333 tasks
|
||||
private static final ThreadPoolExecutor threadPool = new ThreadPoolExecutor(
|
||||
config.threadPoolSize, config.threadPoolSize, 1L, TimeUnit.MINUTES,
|
||||
new LinkedBlockingQueue<>(333), customFactory, new ThreadPoolExecutor.DiscardOldestPolicy()
|
||||
);
|
||||
|
||||
public static void loadProfileTextures(Runnable runnable) {
|
||||
THREAD_POOL.execute(runnable);
|
||||
}
|
||||
|
||||
public static void loadProfileLazily(
|
||||
GameProfile gameProfile, Consumer<Map<MinecraftProfileTexture.Type, MinecraftProfileTexture>> consumer) {
|
||||
String username = gameProfile.getName();
|
||||
String credential = MinecraftUtil.getCredential(gameProfile);
|
||||
// Fix: http://hopper.minecraft.net/crashes/minecraft/MCX-2773713
|
||||
if (username == null) {
|
||||
logger.warning("Could not load profile: username is null.");
|
||||
consumer.accept(Maps.newHashMap());
|
||||
return;
|
||||
}
|
||||
String tempName = Thread.currentThread().getName();
|
||||
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;
|
||||
if (profileCache.isReady(credential)) {
|
||||
logger.info("Cached profile will be used.");
|
||||
profile = profileCache.getProfile(credential);
|
||||
if (profile == null) {
|
||||
logger.warning("(Cached Profile is empty!) Expiry: " + profileCache.getExpiry(credential));
|
||||
if (profileCache.isExpired(credential)) { // force load
|
||||
profile = loadProfile0(gameProfile, false);
|
||||
}
|
||||
} else {
|
||||
logger.info(profile.toString(profileCache.getExpiry(credential)));
|
||||
}
|
||||
} else {
|
||||
profileCache.setLoading(credential, true);
|
||||
profile = loadProfile0(gameProfile, false);
|
||||
}
|
||||
return ModelManager0.fromUserProfile(profile);
|
||||
}
|
||||
|
||||
//Core
|
||||
public static UserProfile loadProfile0(GameProfile gameProfile, boolean isSkull) {
|
||||
String username = gameProfile.getName();
|
||||
String credential = MinecraftUtil.getCredential(gameProfile);
|
||||
|
||||
profileCache.setLoading(credential, true);
|
||||
logger.info("Loading " + username + "'s profile.");
|
||||
if (config.loadlist == null || config.loadlist.isEmpty()) {
|
||||
logger.info("LoadList is Empty.");
|
||||
return null;
|
||||
}
|
||||
|
||||
UserProfile profile0 = new UserProfile();
|
||||
for (int i = 0; i < config.loadlist.size(); i++) {
|
||||
SkinSiteProfile ssp = config.loadlist.get(i);
|
||||
logger.info((i + 1) + "/" + config.loadlist.size() + " Try to load profile from '" + ssp.name + "'.");
|
||||
if (ssp.type == null) {
|
||||
logger.info("The type of '" + ssp.name + "' is null.");
|
||||
continue;
|
||||
}
|
||||
ProfileLoader.IProfileLoader loader = ProfileLoader.LOADERS.get(ssp.type.toLowerCase());
|
||||
if (loader == null) {
|
||||
logger.info("Type '" + ssp.type + "' is not defined.");
|
||||
continue;
|
||||
}
|
||||
UserProfile profile = null;
|
||||
try {
|
||||
profile = loader.loadProfile(ssp, gameProfile);
|
||||
} catch (Exception e) {
|
||||
logger.warning("Exception occurs while loading.");
|
||||
logger.warning(e);
|
||||
if (e.getCause() != null) {
|
||||
logger.warning("Caused By:");
|
||||
logger.warning(e.getCause());
|
||||
}
|
||||
}
|
||||
if (profile == null) {
|
||||
continue;
|
||||
}
|
||||
profile0.mix(profile);
|
||||
if (isSkull && !profile0.hasSkinUrl()) {
|
||||
continue;
|
||||
}
|
||||
if (!config.forceLoadAllTextures) {
|
||||
break;
|
||||
}
|
||||
if (profile0.isFull()) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!profile0.isEmpty()) {
|
||||
logger.info(username + "'s profile loaded.");
|
||||
if (!config.enableCape) {
|
||||
profile0.capeUrl = null;
|
||||
}
|
||||
profileCache.updateCache(credential, profile0);
|
||||
profileCache.setLoading(credential, false);
|
||||
logger.info(profile0.toString(profileCache.getExpiry(credential)));
|
||||
return profile0;
|
||||
}
|
||||
logger.info(username + "'s profile not found in load list.");
|
||||
|
||||
if (config.enableLocalProfileCache) {
|
||||
UserProfile profile = profileCache.getLocalProfile(credential);
|
||||
if (profile == null) {
|
||||
logger.info(username + "'s LocalProfile not found.");
|
||||
} else {
|
||||
profileCache.updateCache(credential, profile, false);
|
||||
profileCache.setLoading(credential, false);
|
||||
logger.info(username + "'s LocalProfile will be used.");
|
||||
logger.info(profile.toString(profileCache.getExpiry(credential)));
|
||||
return profile;
|
||||
}
|
||||
}
|
||||
profileCache.setLoading(credential, false);
|
||||
return null;
|
||||
}
|
||||
|
||||
//For Skull
|
||||
public static Map<MinecraftProfileTexture.Type, MinecraftProfileTexture> loadProfileFromCache(
|
||||
final GameProfile gameProfile) {
|
||||
String username = gameProfile.getName();
|
||||
String credential = MinecraftUtil.getCredential(gameProfile);
|
||||
|
||||
//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 " "
|
||||
if (username == null || username.isEmpty() || username.equals(" ") || credential == null) {
|
||||
return dynamicSkullManager.getTexture(gameProfile);
|
||||
}
|
||||
if (config.forceUpdateSkull ? profileCache.isReady(credential) : profileCache.isExist(credential)) {
|
||||
UserProfile profile = profileCache.getProfile(credential);
|
||||
return ModelManager0.fromUserProfile(profile);
|
||||
}
|
||||
if (!profileCache.isLoading(credential)) {
|
||||
profileCache.setLoading(credential, true);
|
||||
Runnable loadThread = () -> {
|
||||
String tempName = Thread.currentThread().getName();
|
||||
Thread.currentThread().setName(username + "'s skull");
|
||||
loadProfile0(gameProfile, true);//Load in thread
|
||||
Thread.currentThread().setName(tempName);
|
||||
};
|
||||
if (config.forceUpdateSkull) {
|
||||
new Thread(loadThread).start();
|
||||
} else {
|
||||
threadPool.execute(loadThread);
|
||||
}
|
||||
}
|
||||
return Maps.newHashMap();
|
||||
}
|
||||
|
||||
private static Logger initLogger() {
|
||||
LogManager.setLogFile(LOG_FILE.toPath());
|
||||
Logger logger = LogManager.getLogger("Core");
|
||||
logger.info("CustomSkinLoader " + CustomSkinLoader_FULL_VERSION);
|
||||
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("Java Version: " + System.getProperty("java.version") +
|
||||
", " + System.getProperty("java.vendor"));
|
||||
logger.info("Java VM Version: " + System.getProperty("java.vm.name") +
|
||||
" (" + System.getProperty("java.vm.info") + "), " + System.getProperty("java.vm.vendor"));
|
||||
logger.info("Minecraft: " + MinecraftUtil.getMinecraftMainVersion());
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package customskinloader;
|
||||
|
||||
/**
|
||||
* @deprecated From 14.16, use <code>customskinloader.log.Logger</code> instead.
|
||||
*/
|
||||
@Deprecated
|
||||
public class Logger extends customskinloader.log.Logger {
|
||||
}
|
||||
@@ -0,0 +1,259 @@
|
||||
package customskinloader.config;
|
||||
|
||||
import java.io.File;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.*;
|
||||
|
||||
import customskinloader.CustomSkinLoader;
|
||||
import customskinloader.loader.ProfileLoader;
|
||||
import customskinloader.plugin.ICustomSkinLoaderPlugin;
|
||||
import customskinloader.plugin.PluginLoader;
|
||||
import customskinloader.utils.HttpRequestUtil;
|
||||
import customskinloader.utils.HttpTextureUtil;
|
||||
import customskinloader.utils.HttpUtil0;
|
||||
import customskinloader.utils.Version;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
|
||||
@SuppressWarnings("ResultOfMethodCallIgnored")
|
||||
public class Config {
|
||||
//Program
|
||||
public String version;
|
||||
public int buildNumber;
|
||||
public List<SkinSiteProfile> loadlist;
|
||||
|
||||
//Function
|
||||
public boolean enableDynamicSkull = true;
|
||||
public boolean enableTransparentSkin = true;
|
||||
public boolean forceIgnoreHttpsCertificate = false;
|
||||
public boolean forceLoadAllTextures = true;
|
||||
public boolean enableCape = true;
|
||||
public int threadPoolSize = 8;
|
||||
/**
|
||||
* 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
|
||||
public int cacheExpiry = 30;
|
||||
public boolean forceUpdateSkull = false;
|
||||
public boolean enableLocalProfileCache = false;
|
||||
|
||||
//Network Cache
|
||||
public boolean enableCacheAutoClean = false;
|
||||
public boolean forceDisableCache = false;
|
||||
|
||||
// Used by Gson to create an instance with default value.
|
||||
public Config() {
|
||||
this(new ArrayList<>());
|
||||
}
|
||||
|
||||
//Init config
|
||||
public Config(List<SkinSiteProfile> loadlist) {
|
||||
this.version = CustomSkinLoader.CustomSkinLoader_VERSION;
|
||||
this.buildNumber = CustomSkinLoader.CustomSkinLoader_BUILD_NUMBER;
|
||||
this.loadlist = loadlist;
|
||||
}
|
||||
|
||||
public static Config loadConfig0() {
|
||||
Config config = loadConfig();
|
||||
|
||||
//LoadList null checker
|
||||
if (config.loadlist == null) {
|
||||
config.loadlist = new ArrayList<>();
|
||||
} else {
|
||||
for (int i = 0; i < config.loadlist.size(); i++) {
|
||||
if (config.loadlist.get(i) == null)
|
||||
config.loadlist.remove(i--);
|
||||
}
|
||||
}
|
||||
|
||||
//Init program
|
||||
config.loadExtraList();
|
||||
config.updateLoadlist();
|
||||
config.initLocalFolder();
|
||||
config.threadPoolSize = Math.max(config.threadPoolSize, 1);
|
||||
if (config.forceIgnoreHttpsCertificate)
|
||||
HttpUtil0.ignoreHttpsCertificate();
|
||||
if (config.enableCacheAutoClean && !config.enableLocalProfileCache) {
|
||||
try {
|
||||
FileUtils.deleteDirectory(HttpRequestUtil.CACHE_DIR);
|
||||
FileUtils.deleteDirectory(HttpTextureUtil.getCacheDir());
|
||||
CustomSkinLoader.logger.info("Successfully cleaned cache.");
|
||||
} catch (Exception e) {
|
||||
CustomSkinLoader.logger.warning("Exception occurs while cleaning cache: " + e);
|
||||
}
|
||||
}
|
||||
|
||||
//Check config version
|
||||
Version configVersion = Version.of(config.version);
|
||||
if (CustomSkinLoader.CustomSkinLoader_BUILD_NUMBER == 0 // Custom builds
|
||||
|| configVersion.compareTo(CustomSkinLoader.CustomSkinLoader_VERSION) < 0
|
||||
|| config.buildNumber < CustomSkinLoader.CustomSkinLoader_BUILD_NUMBER) {
|
||||
CustomSkinLoader.logger.info("Config File is out of date: " + config.version +
|
||||
", build number: " + config.buildNumber);
|
||||
config.version = CustomSkinLoader.CustomSkinLoader_VERSION;
|
||||
config.buildNumber = CustomSkinLoader.CustomSkinLoader_BUILD_NUMBER;
|
||||
}
|
||||
writeConfig(config, true);
|
||||
|
||||
//Output config
|
||||
for (Field field : config.getClass().getDeclaredFields()) {
|
||||
try {
|
||||
Object value = field.get(config);
|
||||
CustomSkinLoader.logger.info(field.getName() + " : " + value);
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
}
|
||||
|
||||
return config;
|
||||
}
|
||||
|
||||
private static Config loadConfig() {
|
||||
CustomSkinLoader.logger.info("Config File: " + CustomSkinLoader.CONFIG_FILE.getAbsolutePath());
|
||||
if (!CustomSkinLoader.CONFIG_FILE.exists()) {
|
||||
CustomSkinLoader.logger.info("Config file not found, use default instead.");
|
||||
return initConfig();
|
||||
}
|
||||
try {
|
||||
CustomSkinLoader.logger.info("Try to load config.");
|
||||
String json = FileUtils.readFileToString(CustomSkinLoader.CONFIG_FILE, "UTF-8");
|
||||
Config config = Objects.requireNonNull(CustomSkinLoader.GSON.fromJson(json, Config.class));
|
||||
CustomSkinLoader.logger.info("Successfully load config.");
|
||||
return config;
|
||||
} catch (Exception e) {
|
||||
CustomSkinLoader.logger.info("Failed to load config, use default instead.(" + e + ")");
|
||||
createBrokenFile(CustomSkinLoader.CONFIG_FILE);
|
||||
return initConfig();
|
||||
}
|
||||
}
|
||||
|
||||
private void loadExtraList() {
|
||||
File listAddition = new File(CustomSkinLoader.DATA_DIR, "ExtraList");
|
||||
if (!listAddition.isDirectory()) {
|
||||
listAddition.mkdirs();
|
||||
return;
|
||||
}
|
||||
List<SkinSiteProfile> adds = new ArrayList<>();
|
||||
File[] files = listAddition.listFiles();
|
||||
for (File file : files != null ? files : new File[0]) {
|
||||
if (!file.getName().toLowerCase().endsWith(".json") && !file.getName().toLowerCase().endsWith(".txt"))
|
||||
continue;
|
||||
try {
|
||||
CustomSkinLoader.logger.info("Try to load Extra List.(" + file.getName() + ")");
|
||||
String json = FileUtils.readFileToString(file, "UTF-8");
|
||||
SkinSiteProfile ssp = CustomSkinLoader.GSON.fromJson(json, SkinSiteProfile.class);
|
||||
CustomSkinLoader.logger.info("Successfully load Extra List.");
|
||||
if (ssp.type != null) {
|
||||
ProfileLoader.IProfileLoader loader = ProfileLoader.LOADERS.get(ssp.type.toLowerCase());
|
||||
if (loader == null) {
|
||||
CustomSkinLoader.logger.info("Extra List will be ignored: Type '" + ssp.type +
|
||||
"' is not defined.");
|
||||
continue;
|
||||
}
|
||||
boolean duplicate = false;
|
||||
for (SkinSiteProfile ssp0 : this.loadlist) {
|
||||
if (!ssp0.type.equalsIgnoreCase(ssp.type))
|
||||
continue;
|
||||
if (loader.compare(ssp0, ssp)) {
|
||||
duplicate = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!duplicate) {
|
||||
adds.add(ssp);
|
||||
CustomSkinLoader.logger.info("Successfully apply Extra List.(" + ssp.name + ")");
|
||||
} else {
|
||||
CustomSkinLoader.logger.info("Extra List will be ignored: Duplicate.(" + ssp.name + ")");
|
||||
}
|
||||
file.delete();
|
||||
} else {
|
||||
CustomSkinLoader.logger.info("Extra List is invalid: Type is not defined.(" +
|
||||
file.getName() + ")");
|
||||
createBrokenFile(file);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
CustomSkinLoader.logger.info("Failed to load Extra List.(" + e + ")");
|
||||
createBrokenFile(file);
|
||||
}
|
||||
}
|
||||
if (adds.size() != 0) {
|
||||
adds.addAll(this.loadlist);
|
||||
this.loadlist = adds;
|
||||
}
|
||||
}
|
||||
|
||||
private void updateLoadlist() {
|
||||
PluginLoader.PLUGINS.stream()
|
||||
.map(ICustomSkinLoaderPlugin::getDefaultProfiles)
|
||||
.filter(Objects::nonNull)
|
||||
.flatMap(Collection::stream)
|
||||
.forEach(profile -> this.loadlist.stream()
|
||||
.filter(ssp -> profile.getName().equals(ssp.name))
|
||||
.forEach(profile::updateSkinSiteProfile));
|
||||
}
|
||||
|
||||
private void initLocalFolder() {
|
||||
for (SkinSiteProfile ssp : this.loadlist) {
|
||||
if (ssp.type == null)
|
||||
continue;
|
||||
ProfileLoader.IProfileLoader loader = ProfileLoader.LOADERS.get(ssp.type.toLowerCase());
|
||||
if (loader == null)
|
||||
continue;
|
||||
loader.init(ssp);
|
||||
}
|
||||
}
|
||||
|
||||
private static void createBrokenFile(File file) {
|
||||
try {
|
||||
File brokenFile = new File(file.getParentFile(), file.getName() + ".broken");
|
||||
if (brokenFile.exists()) {
|
||||
brokenFile.delete();
|
||||
}
|
||||
file.renameTo(brokenFile);
|
||||
} catch (Exception e) {
|
||||
CustomSkinLoader.logger.warning("Failed to create broken file. (" + file.getName() + ")");
|
||||
CustomSkinLoader.logger.warning(e);
|
||||
}
|
||||
}
|
||||
|
||||
// The config file does not exist or was broken.
|
||||
private static Config initConfig() {
|
||||
List<ICustomSkinLoaderPlugin.IDefaultProfile> profiles = new ArrayList<>();
|
||||
for (ICustomSkinLoaderPlugin plugin : PluginLoader.PLUGINS) {
|
||||
List<ICustomSkinLoaderPlugin.IDefaultProfile> defaultProfiles = plugin.getDefaultProfiles();
|
||||
if (defaultProfiles != null) {
|
||||
profiles.addAll(defaultProfiles);
|
||||
}
|
||||
}
|
||||
profiles.sort(Comparator.comparingInt(ICustomSkinLoaderPlugin.IDefaultProfile::getPriority));
|
||||
|
||||
List<SkinSiteProfile> loadlist = new ArrayList<>();
|
||||
for (ICustomSkinLoaderPlugin.IDefaultProfile profile : profiles) {
|
||||
SkinSiteProfile ssp = new SkinSiteProfile();
|
||||
ssp.name = profile.getName();
|
||||
profile.updateSkinSiteProfile(ssp);
|
||||
loadlist.add(ssp);
|
||||
}
|
||||
|
||||
Config config = new Config(loadlist);
|
||||
writeConfig(config, false);
|
||||
return config;
|
||||
}
|
||||
|
||||
private static void writeConfig(Config config, boolean update) {
|
||||
String json = CustomSkinLoader.GSON.toJson(config);
|
||||
if (CustomSkinLoader.CONFIG_FILE.exists())
|
||||
CustomSkinLoader.CONFIG_FILE.delete();
|
||||
try {
|
||||
CustomSkinLoader.CONFIG_FILE.createNewFile();
|
||||
FileUtils.write(CustomSkinLoader.CONFIG_FILE, json, "UTF-8");
|
||||
CustomSkinLoader.logger.info("Successfully " + (update ? "update" : "create") + " config.");
|
||||
} catch (Exception e) {
|
||||
CustomSkinLoader.logger.info("Failed to " + (update ? "update" : "create") + " config.(" + e + ")");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package customskinloader.config;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
public class SkinSiteProfile {
|
||||
//Common
|
||||
public String name;
|
||||
public String type;
|
||||
public String userAgent;
|
||||
|
||||
//Mojang API
|
||||
public String apiRoot;
|
||||
public String sessionRoot;
|
||||
|
||||
//Json API
|
||||
public String root;
|
||||
|
||||
//Legacy
|
||||
public Boolean checkPNG;//Not suitable for local skin
|
||||
public String skin;
|
||||
public String model;
|
||||
public String cape;
|
||||
public String elytra;
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder("{ ");
|
||||
Field[] fields = SkinSiteProfile.class.getDeclaredFields();
|
||||
boolean first = true;
|
||||
for (Field field : fields) {
|
||||
try {
|
||||
Object value = field.get(this);
|
||||
if (value == null) continue;
|
||||
if (first) {
|
||||
first = false;
|
||||
} else {
|
||||
sb.append(", ");
|
||||
}
|
||||
sb.append("\"").append(field.getName()).append("\": \"").append(value).append("\"");
|
||||
} catch (Exception ignored) { }
|
||||
}
|
||||
return sb.append(" }").toString();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,269 @@
|
||||
package customskinloader.fake;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.NoSuchElementException;
|
||||
import java.util.function.BiPredicate;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
import customskinloader.fake.itf.FakeInterfaceManager;
|
||||
import customskinloader.fake.texture.FakeBufferedImage;
|
||||
import customskinloader.fake.texture.FakeImage;
|
||||
import customskinloader.utils.MinecraftUtil;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
public class FakeCapeBuffer extends FakeSkinBuffer {
|
||||
private static final ResourceLocation TEXTURE_ELYTRA = new ResourceLocation("textures/entity/elytra.png");
|
||||
private static int loadedGlobal = 0;
|
||||
private static FakeImage elytraImage;
|
||||
|
||||
private static FakeImage loadElytra(FakeImage originalImage) {
|
||||
loadedGlobal++;
|
||||
try {
|
||||
InputStream is = FakeInterfaceManager.IResource_getInputStream(FakeInterfaceManager.IResourceManager_getResource(FakeInterfaceManager.Minecraft_getResourceManager(Minecraft.getMinecraft()), TEXTURE_ELYTRA).get());
|
||||
if (is != null) {
|
||||
FakeImage image = originalImage.createImage(is);
|
||||
if (image.getWidth() % 64 != 0 || image.getHeight() % 32 != 0) { // wtf?
|
||||
return elytraImage;
|
||||
}
|
||||
image = resetImageFormat(image, 22, 0, 46, 22);
|
||||
return image;
|
||||
}
|
||||
} catch (IOException | NoSuchElementException ignored) {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private int loaded = 0;
|
||||
private double ratioX = -1;
|
||||
private double ratioY = -1;
|
||||
private final ResourceLocation location;
|
||||
private String type = null;
|
||||
|
||||
public FakeCapeBuffer(ResourceLocation location) {
|
||||
this.location = location;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FakeImage parseUserSkin(FakeImage image) {
|
||||
if (image == null) return null;
|
||||
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
|
||||
// The first cape which find elytra texture is outdated will reload it
|
||||
if (this.loaded == loadedGlobal) {
|
||||
elytraImage = loadElytra(this.image);
|
||||
}
|
||||
this.loaded = loadedGlobal;
|
||||
if (elytraImage != null) {
|
||||
if (this.ratioX < 0)
|
||||
this.ratioX = this.image.getWidth() / 64.0D;
|
||||
if (this.ratioY < 0)
|
||||
this.ratioY = this.image.getHeight() / 32.0D;
|
||||
if (this.type == null)
|
||||
this.type = this.judgeType();
|
||||
|
||||
if ("cape".equals(this.type)) {
|
||||
this.image = resetImageFormat(this.image, 0, 0, 22, 17);
|
||||
this.attachElytra(elytraImage);
|
||||
if (this.image instanceof FakeBufferedImage) { // before 1.12.2
|
||||
this.refreshTexture((FakeBufferedImage) this.image);
|
||||
}
|
||||
}
|
||||
}
|
||||
return this.image;
|
||||
}
|
||||
|
||||
/**
|
||||
* Judge the cape type
|
||||
*
|
||||
* @return "elytra" if the cape contains elytra texture, otherwise "cape"
|
||||
*/
|
||||
@Override
|
||||
public String judgeType() {
|
||||
if (this.image != null && elytraImage != null) {
|
||||
// If all the pixels in ((22, 0), (45, 21)) is same as background, it means the cape doesn't contain elytra
|
||||
Predicate<Integer> predicate = EQU_BG.apply(this.image.getRGBA(this.image.getWidth() - 1, this.image.getHeight() - 1));
|
||||
return withElytraPixels((x, y) -> !predicate.test(this.image.getRGBA(x, y)), "elytra", "cape");
|
||||
}
|
||||
return "cape";
|
||||
}
|
||||
|
||||
private void attachElytra(FakeImage elytraImage) {
|
||||
if (this.image != null) {
|
||||
int capeW = this.image.getWidth(), capeH = this.image.getHeight();
|
||||
int elytraW = elytraImage.getWidth(), elytraH = elytraImage.getHeight();
|
||||
|
||||
// scale cape and elytra to the same size
|
||||
// cape part ((0, 0), (21, 16)) -> (22 * 17)
|
||||
if (capeW < elytraW) {
|
||||
this.image = scaleImage(this.image, true, elytraW / (double) capeW, 1, capeW / 64.0D, capeH / 32.0D, elytraW, capeH, 0, 0, 22, 17);
|
||||
capeW = elytraW;
|
||||
}
|
||||
if (capeH < elytraH) {
|
||||
this.image = scaleImage(this.image, true, 1, elytraH / (double) capeH, capeW / 64.0D, capeH / 32.0D, capeW, elytraH, 0, 0, 22, 17);
|
||||
capeH = elytraH;
|
||||
}
|
||||
// elytra part ((22, 0), (45, 21)) -> (24 * 22)
|
||||
if (elytraW < capeW) {
|
||||
elytraImage = scaleImage(elytraImage, false, capeW / (double) elytraW, 1, elytraW / 64.0D, elytraH / 32.0D, capeW, elytraH, 22, 0, 46, 22);
|
||||
elytraW = capeW;
|
||||
}
|
||||
if (elytraH < capeH) {
|
||||
elytraImage = scaleImage(elytraImage, false, 1, capeH / (double) elytraH, elytraW / 64.0D, elytraH / 32.0D, elytraW, capeH, 22, 0, 46, 22);
|
||||
elytraH = capeH;
|
||||
}
|
||||
this.ratioX = capeW / 64.0D;
|
||||
this.ratioY = capeH / 32.0D;
|
||||
|
||||
// Overwrite pixels from elytra to cape
|
||||
FakeImage finalElytraImage = elytraImage;
|
||||
withElytraPixels((x, y) -> {
|
||||
this.image.setRGBA(x, y, finalElytraImage.getRGBA(x, y));
|
||||
return false;
|
||||
}, null, null);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 defaultReturnValue otherwise return this value
|
||||
*/
|
||||
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 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 excludeY = (int) Math.ceil(2 * ratioY);
|
||||
for (int x = startX; x < endX; ++x) {
|
||||
for (int y = startY; y < endY; ++y) {
|
||||
if (y < excludeY && (x < excludeX0 || x >= excludeX1)) continue;
|
||||
if (predicate.test(x, y)) {
|
||||
return returnValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
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
|
||||
private static FakeImage resetImageFormat(FakeImage image, int startX, int startY, int endX, int endY) {
|
||||
if (image != null) {
|
||||
int width = image.getWidth(), height = image.getHeight();
|
||||
image = scaleImage(image, true, 1, 1, width / 64.0D, height / 32.0D, width, height, startX, startY, endX, endY);
|
||||
}
|
||||
return image;
|
||||
}
|
||||
|
||||
/**
|
||||
* Scale image
|
||||
*
|
||||
* @param image the image to scale.
|
||||
* @param closeOldImage whether close old image
|
||||
* @param scaleWidth width enlargement ratio
|
||||
* @param scaleHeight height enlargement ratio
|
||||
* @param ratioX the ratio of 64 of the old image width
|
||||
* @param ratioY the ratio of 32 of the old image height
|
||||
* @param width the width after scaling.
|
||||
* @param height the height after scaling.
|
||||
* @param startX the x where start to copy.
|
||||
* @param startY the y where start to copy.
|
||||
* @param endX the x where end to copy.
|
||||
* @param endY the y where end to copy.
|
||||
* @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) {
|
||||
FakeImage newImage = image.createImage(width, height);
|
||||
startX = (int) (startX * ratioX);
|
||||
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;
|
||||
for (int x = startX; x < endX; ++x) {
|
||||
int y0 = (int) (startY * scaleHeight), y1 = (int) ((startY + 1) * scaleHeight), dy0 = y1 - y0;
|
||||
for (int y = startY; y < endY; ++y) {
|
||||
int rgba = image.getRGBA(x, y);
|
||||
for (int dx = 0; dx < dx0; dx++) {
|
||||
for (int dy = 0; dy < dy0; dy++) {
|
||||
newImage.setRGBA(x0 + dx, y0 + dy, rgba);
|
||||
}
|
||||
}
|
||||
y0 = y1;
|
||||
y1 = (int) ((y + 2) * scaleHeight);
|
||||
dy0 = y1 - y0;
|
||||
}
|
||||
x0 = x1;
|
||||
x1 = (int) ((x + 2) * scaleWidth);
|
||||
dx0 = x1 - x0;
|
||||
}
|
||||
if (closeOldImage)
|
||||
image.close();
|
||||
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));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,99 @@
|
||||
package customskinloader.fake;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import com.mojang.authlib.minecraft.MinecraftProfileTexture;
|
||||
import com.mojang.authlib.minecraft.MinecraftProfileTexture.Type;
|
||||
|
||||
import customskinloader.CustomSkinLoader;
|
||||
import customskinloader.utils.MinecraftUtil;
|
||||
import net.minecraft.client.renderer.ThreadDownloadImageData;
|
||||
import net.minecraft.client.renderer.texture.ITextureObject;
|
||||
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.client.resources.SkinManager.SkinAvailableCallback;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.StringUtils;
|
||||
|
||||
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
|
||||
public static ThreadDownloadImageData getDownloadImageSkin(ResourceLocation resourceLocationIn, String username) {
|
||||
//CustomSkinLoader.logger.debug("FakeClientPlayer/getDownloadImageSkin "+username);
|
||||
TextureManager textman = MinecraftUtil.getTextureManager();
|
||||
ITextureObject ito = textman.getTexture(resourceLocationIn);
|
||||
|
||||
if (ito == null || !(ito instanceof ThreadDownloadImageData)) {
|
||||
//if Legacy Skin for username not loaded yet
|
||||
SkinManager skinman = MinecraftUtil.getSkinManager();
|
||||
UUID offlineUUID = getOfflineUUID(username);
|
||||
GameProfile offlineProfile = new GameProfile(offlineUUID, username);
|
||||
|
||||
//Load Default Skin
|
||||
ResourceLocation defaultSkin = DefaultPlayerSkin.getDefaultSkin(offlineUUID);
|
||||
ITextureObject defaultSkinObj = new SimpleTexture(defaultSkin);
|
||||
textman.loadTexture(resourceLocationIn, defaultSkinObj);
|
||||
|
||||
//Load Skin from SkinManager
|
||||
skinman.loadProfileTextures(offlineProfile, new LegacyBuffer(resourceLocationIn), false);
|
||||
}
|
||||
|
||||
if (ito instanceof ThreadDownloadImageData)
|
||||
return (ThreadDownloadImageData) ito;
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
public static ResourceLocation getLocationSkin(String username) {
|
||||
//CustomSkinLoader.logger.debug("FakeClientPlayer/getLocationSkin "+username);
|
||||
return new ResourceLocation("skins/legacy-" + StringUtils.stripControlCodes(username));
|
||||
}
|
||||
|
||||
public static UUID getOfflineUUID(String username) {
|
||||
return UUID.nameUUIDFromBytes(("OfflinePlayer:" + username).getBytes());
|
||||
}
|
||||
|
||||
public static Map<ResourceLocation, ITextureObject> textureCache = Maps.newHashMap();
|
||||
|
||||
public static class LegacyBuffer implements SkinAvailableCallback {
|
||||
ResourceLocation resourceLocationIn;
|
||||
boolean loaded = false;
|
||||
|
||||
public LegacyBuffer(ResourceLocation resourceLocationIn) {
|
||||
CustomSkinLoader.logger.debug("Loading Legacy Texture (" + resourceLocationIn + ")");
|
||||
this.resourceLocationIn = resourceLocationIn;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void skinAvailable(Type typeIn, ResourceLocation location, MinecraftProfileTexture profileTexture) {
|
||||
if (typeIn != Type.SKIN || loaded)
|
||||
return;
|
||||
|
||||
TextureManager textman = MinecraftUtil.getTextureManager();
|
||||
ITextureObject ito = textman.getTexture(location);
|
||||
if (ito == null)
|
||||
ito = textureCache.get(location);
|
||||
if (ito == null)
|
||||
return;
|
||||
|
||||
loaded = true;
|
||||
textman.loadTexture(resourceLocationIn, ito);
|
||||
CustomSkinLoader.logger.debug("Legacy Texture (" + resourceLocationIn + ") Loaded as " +
|
||||
ito.toString() + " (" + location + ")");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package customskinloader.fake;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
import com.mojang.authlib.minecraft.MinecraftProfileTexture;
|
||||
import customskinloader.utils.HttpTextureUtil;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
public class FakeMinecraftProfileTexture extends MinecraftProfileTexture {
|
||||
private HttpTextureUtil.HttpTextureInfo info;
|
||||
private ResourceLocation resourceLocation;
|
||||
|
||||
public FakeMinecraftProfileTexture(String url, Map<String, String> metadata) {
|
||||
super(url, metadata);
|
||||
this.info = HttpTextureUtil.toHttpTextureInfo(url);
|
||||
}
|
||||
|
||||
public void setResourceLocation(ResourceLocation resourceLocation) {
|
||||
this.resourceLocation = resourceLocation;
|
||||
}
|
||||
|
||||
public ResourceLocation getResourceLocation() {
|
||||
return this.resourceLocation;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUrl() {
|
||||
return this.info.url;
|
||||
}
|
||||
|
||||
public String getRawUrl() {
|
||||
return super.getUrl();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHash() {
|
||||
return this.info.hash == null ? super.getHash() : this.info.hash;
|
||||
}
|
||||
|
||||
public File getCacheFile() {
|
||||
return this.info.cacheFile;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,186 @@
|
||||
package customskinloader.fake;
|
||||
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.util.function.Function;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
import customskinloader.CustomSkinLoader;
|
||||
import customskinloader.fake.texture.FakeBufferedImage;
|
||||
import customskinloader.fake.texture.FakeImage;
|
||||
import customskinloader.fake.texture.FakeNativeImage;
|
||||
import net.minecraft.client.renderer.IImageBuffer;
|
||||
import net.minecraft.client.renderer.texture.NativeImage;
|
||||
|
||||
public class FakeSkinBuffer implements IImageBuffer {
|
||||
private int ratio = 1;
|
||||
FakeImage image = null;
|
||||
|
||||
//parseUserSkin for 1.15+
|
||||
public static NativeImage processLegacySkin(NativeImage image, Runnable processTask, Function<NativeImage, NativeImage> processLegacySkin) {
|
||||
if (processTask instanceof IImageBuffer) {
|
||||
return ((IImageBuffer) processTask).func_195786_a(image);
|
||||
}
|
||||
return processLegacySkin.apply(image);
|
||||
}
|
||||
|
||||
//parseUserSkin for 1.13+
|
||||
public NativeImage func_195786_a(NativeImage image) {
|
||||
if (image == null)
|
||||
return null;
|
||||
|
||||
FakeImage img = parseUserSkin(new FakeNativeImage(image));
|
||||
if (img instanceof FakeNativeImage)
|
||||
return ((FakeNativeImage) img).getImage();
|
||||
|
||||
CustomSkinLoader.logger.warning("Failed to parseUserSkin(func_195786_a).");
|
||||
return null;
|
||||
}
|
||||
|
||||
//parseUserSkin for 1.12.2-
|
||||
public BufferedImage parseUserSkin(BufferedImage image) {
|
||||
if (image == null)
|
||||
return null;
|
||||
|
||||
FakeImage img = parseUserSkin(new FakeBufferedImage(image));
|
||||
if (img instanceof FakeBufferedImage)
|
||||
return ((FakeBufferedImage) img).getImage();
|
||||
|
||||
CustomSkinLoader.logger.warning("Failed to parseUserSkin.");
|
||||
return null;
|
||||
}
|
||||
|
||||
public FakeImage parseUserSkin(FakeImage image) {
|
||||
if (image == null) return null;
|
||||
this.ratio = image.getWidth() / 64;
|
||||
|
||||
if (image.getHeight() != image.getWidth()) {//Single Layer
|
||||
//Create a new image and copy origin image data
|
||||
FakeImage img = image.createImage(64 * ratio, 64 * ratio);
|
||||
img.copyImageData(image);
|
||||
image.close();
|
||||
image = img;
|
||||
image.fillArea(0 * ratio, 32 * ratio, 64 * ratio, 32 * ratio);
|
||||
|
||||
//Right Leg -> Left Leg
|
||||
image.copyArea(4 * ratio, 16 * ratio, 16 * ratio, 32 * ratio, 4 * ratio, 4 * ratio, true, false);//Top
|
||||
image.copyArea(8 * ratio, 16 * ratio, 16 * ratio, 32 * ratio, 4 * ratio, 4 * ratio, true, false);//Bottom
|
||||
image.copyArea(0 * ratio, 20 * ratio, 24 * ratio, 32 * ratio, 4 * ratio, 12 * ratio, true, false);//Right
|
||||
image.copyArea(4 * ratio, 20 * ratio, 16 * ratio, 32 * ratio, 4 * ratio, 12 * ratio, true, false);//Front
|
||||
image.copyArea(8 * ratio, 20 * ratio, 8 * ratio, 32 * ratio, 4 * ratio, 12 * ratio, true, false);//Left
|
||||
image.copyArea(12 * ratio, 20 * ratio, 16 * ratio, 32 * ratio, 4 * ratio, 12 * ratio, true, false);//Back
|
||||
//Right Arm -> Left Arm
|
||||
image.copyArea(44 * ratio, 16 * ratio, -8 * ratio, 32 * ratio, 4 * ratio, 4 * ratio, true, false);//Top
|
||||
image.copyArea(48 * ratio, 16 * ratio, -8 * ratio, 32 * ratio, 4 * ratio, 4 * ratio, true, false);//Bottom
|
||||
image.copyArea(40 * ratio, 20 * ratio, 0 * ratio, 32 * ratio, 4 * ratio, 12 * ratio, true, false);//Right
|
||||
image.copyArea(44 * ratio, 20 * ratio, -8 * ratio, 32 * ratio, 4 * ratio, 12 * ratio, true, false);//Front
|
||||
image.copyArea(48 * ratio, 20 * ratio, -16 * ratio, 32 * ratio, 4 * ratio, 12 * ratio, true, false);//Left
|
||||
image.copyArea(52 * ratio, 20 * ratio, -8 * ratio, 32 * ratio, 4 * ratio, 12 * ratio, true, false);//Back
|
||||
}
|
||||
|
||||
this.image = image;
|
||||
setAreaDueToConfig(0 * ratio, 0 * ratio, 32 * ratio, 16 * ratio);//Head - 1
|
||||
setAreaTransparent(32 * ratio, 0 * ratio, 64 * ratio, 16 * ratio);//Head - 2
|
||||
setAreaDueToConfig(16 * ratio, 16 * ratio, 40 * ratio, 32 * ratio);//Body - 1
|
||||
setAreaTransparent(16 * ratio, 32 * ratio, 40 * ratio, 48 * ratio);//Body - 2
|
||||
|
||||
setAreaDueToConfig(40 * ratio, 16 * ratio, 56 * ratio, 32 * ratio);//Right Arm - 1
|
||||
setAreaTransparent(40 * ratio, 32 * ratio, 56 * ratio, 48 * ratio);//Right Arm - 2
|
||||
setAreaDueToConfig(0 * ratio, 16 * ratio, 16 * ratio, 32 * ratio);//Right Leg - 1
|
||||
setAreaTransparent(0 * ratio, 32 * ratio, 16 * ratio, 48 * ratio);//Right Leg - 2
|
||||
|
||||
setAreaDueToConfig(32 * ratio, 48 * ratio, 48 * ratio, 64 * ratio);//Left Arm - 1
|
||||
setAreaTransparent(48 * ratio, 48 * ratio, 64 * ratio, 64 * ratio);//Left Arm - 2
|
||||
setAreaDueToConfig(16 * ratio, 48 * ratio, 32 * ratio, 64 * ratio);//Left Leg - 1
|
||||
setAreaTransparent(0 * ratio, 48 * ratio, 16 * ratio, 64 * ratio);//Left Leg - 2
|
||||
return image;
|
||||
}
|
||||
|
||||
/** 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);
|
||||
|
||||
/**
|
||||
* Judge the type of skin
|
||||
* Must be called after parseUserSkin
|
||||
*
|
||||
* @return type of skin (slim / default)
|
||||
* @since 14.9
|
||||
*/
|
||||
public String judgeType() {
|
||||
if (this.image == null)
|
||||
return "default";
|
||||
int bgColor = image.getRGBA(63 * ratio, 20 * ratio);
|
||||
/*
|
||||
* If background is transparent, all the pixels in ((54, 20), (55, 31)) areas is transparent,
|
||||
* which means it is Alex model.
|
||||
* If background is opaque, all the pixels in ((54, 20), (55, 31)) areas is same with background,
|
||||
* which means it is Alex model.
|
||||
* Otherwise, it is Steve model.
|
||||
* */
|
||||
Predicate<Integer> predicate = EQU_BG.apply(bgColor);
|
||||
for (int x = 54 * ratio; x <= 55 * ratio; ++x) {
|
||||
for (int y = 20 * ratio; y <= 31 * ratio; ++y) {
|
||||
int color = image.getRGBA(x, y);
|
||||
if (!predicate.test(color)) {
|
||||
return "default";
|
||||
}
|
||||
}
|
||||
}
|
||||
return "slim";
|
||||
}
|
||||
|
||||
/* 2^24-1
|
||||
* 00000000 11111111 11111111 11111111 */
|
||||
private static final int A = 16777215;
|
||||
private static final int WHITE = getARGB(255, 255, 255, 255);
|
||||
private static final int BLACK = getARGB(255, 0, 0, 0);
|
||||
|
||||
private boolean isFilled(int x0, int y0, int x1, int y1) {
|
||||
int data = image.getRGBA(x0, y0);
|
||||
if (data != WHITE && data != BLACK)
|
||||
return false;
|
||||
for (int x = x0; x < x1; ++x)
|
||||
for (int y = y0; y < y1; ++y)
|
||||
if (image.getRGBA(x, y) != data)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
private void setAreaTransparent(int x0, int y0, int x1, int y1) {
|
||||
if (!isFilled(x0, y0, x1, y1))
|
||||
return;
|
||||
for (int x = x0; x < x1; ++x)
|
||||
for (int y = y0; y < y1; ++y)
|
||||
image.setRGBA(x, y, image.getRGBA(x, y) & A);
|
||||
}
|
||||
|
||||
/* -2^24
|
||||
* 00000001 00000000 00000000 00000000 ->
|
||||
* 11111110 11111111 11111111 11111111 ->
|
||||
* 11111111 00000000 00000000 00000000 */
|
||||
private static final int B = -16777216;
|
||||
|
||||
private void setAreaOpaque(int x0, int y0, int x1, int y1) {
|
||||
for (int x = x0; x < x1; ++x)
|
||||
for (int y = y0; y < y1; ++y)
|
||||
image.setRGBA(x, y, image.getRGBA(x, y) | B);
|
||||
}
|
||||
|
||||
private void setAreaDueToConfig(int x0, int y0, int x1, int y1) {
|
||||
if (customskinloader.CustomSkinLoader.config.enableTransparentSkin)
|
||||
setAreaTransparent(x0, y0, x1, y1);
|
||||
else
|
||||
setAreaOpaque(x0, y0, x1, y1);
|
||||
}
|
||||
|
||||
public void skinAvailable() {
|
||||
//A callback when skin loaded, nothing to do
|
||||
}
|
||||
|
||||
private static int getARGB(int a, int r, int g, int b) {
|
||||
return (a << 24) | (r << 16) | (g << 8) | b;
|
||||
}
|
||||
|
||||
private static int getA(int argb) {
|
||||
return (argb & B) >>> 24;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,179 @@
|
||||
package customskinloader.fake;
|
||||
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.File;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.common.collect.Multimap;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import com.mojang.authlib.minecraft.MinecraftProfileTexture;
|
||||
import com.mojang.authlib.minecraft.MinecraftSessionService;
|
||||
import customskinloader.CustomSkinLoader;
|
||||
import customskinloader.utils.HttpTextureUtil;
|
||||
import customskinloader.utils.MinecraftUtil;
|
||||
import net.minecraft.client.renderer.IImageBuffer;
|
||||
import net.minecraft.client.renderer.texture.TextureManager;
|
||||
import net.minecraft.client.resources.SkinManager;
|
||||
import net.minecraft.client.resources.SkinManager.SkinAvailableCallback;
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Invoked from {@link SkinManager#loadSkin(MinecraftProfileTexture, MinecraftProfileTexture.Type, SkinAvailableCallback)}
|
||||
*/
|
||||
public static ResourceLocation setResourceLocation(ResourceLocation resourceLocation, MinecraftProfileTexture profileTexture) {
|
||||
if (profileTexture instanceof FakeMinecraftProfileTexture) {
|
||||
((FakeMinecraftProfileTexture) profileTexture).setResourceLocation(resourceLocation);
|
||||
}
|
||||
return resourceLocation;
|
||||
}
|
||||
|
||||
/**
|
||||
* Invoked from {@link SkinManager#loadSkin(MinecraftProfileTexture, MinecraftProfileTexture.Type, SkinAvailableCallback)}
|
||||
* <p>
|
||||
* {@code skinAvailableCallback.skinAvailable(textureType, resourcelocation, profileTexture);} -> {@code skinAvailableCallback.skinAvailable(textureType, resourcelocation, this.fakeManager.getModelCache(profileTexture, resourcelocation));}
|
||||
* <p>
|
||||
*/
|
||||
public static MinecraftProfileTexture getModelCache(MinecraftProfileTexture profileTexture, FakeSkinManager fakeManager, ResourceLocation location) {
|
||||
return fakeManager.modelCache.getOrDefault(location, profileTexture);
|
||||
}
|
||||
|
||||
/**
|
||||
* Invoked from {@link SkinManager#loadSkin(MinecraftProfileTexture, MinecraftProfileTexture.Type, SkinAvailableCallback)}
|
||||
*/
|
||||
public static Object[] createThreadDownloadImageData(ImmutableList<Object> list, FakeSkinManager fakeManager, MinecraftProfileTexture profileTexture, MinecraftProfileTexture.Type textureType, SkinManager.SkinAvailableCallback skinAvailableCallback) {
|
||||
Object[] params = list.toArray();
|
||||
if (profileTexture instanceof FakeMinecraftProfileTexture && params.length > 1) {
|
||||
FakeMinecraftProfileTexture fakeProfileTexture = (FakeMinecraftProfileTexture) profileTexture;
|
||||
ResourceLocation resourcelocation = fakeProfileTexture.getResourceLocation();
|
||||
if (fakeProfileTexture.getResourceLocation() != null) {
|
||||
params[0] = fakeProfileTexture.getCacheFile();
|
||||
if (params[params.length - 2] instanceof Boolean) {
|
||||
params[params.length - 2] = true;
|
||||
}
|
||||
params[params.length - 1] = fakeManager.new BaseBuffer(skinAvailableCallback, textureType, resourcelocation, fakeProfileTexture);
|
||||
}
|
||||
}
|
||||
return params;
|
||||
}
|
||||
|
||||
|
||||
private final static String KEY = "CustomSkinLoaderInfo";
|
||||
/**
|
||||
* Invoked from {@link SkinManager#loadProfileTextures(GameProfile, SkinAvailableCallback, boolean)}
|
||||
*/
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
public static void loadProfileTextures(Runnable runnable, GameProfile profile) {
|
||||
CustomSkinLoader.loadProfileTextures(() -> CustomSkinLoader.loadProfileLazily(profile, m -> {
|
||||
// This is a hack.
|
||||
((Multimap) profile.getProperties()).put(KEY, m);
|
||||
runnable.run();
|
||||
}));
|
||||
}
|
||||
|
||||
/**
|
||||
* Invoked from {@link SkinManager#lambda$loadProfileTextures$1(GameProfile, boolean, SkinAvailableCallback)}
|
||||
*/
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
public static Map<MinecraftProfileTexture.Type, MinecraftProfileTexture> getUserProfile(MinecraftSessionService sessionService, GameProfile profile, boolean requireSecure) {
|
||||
// This is a hack.
|
||||
return (Map<MinecraftProfileTexture.Type, MinecraftProfileTexture>) ((Optional) profile.getProperties().removeAll(KEY).stream().findFirst()).orElse(Maps.newHashMap());
|
||||
}
|
||||
|
||||
/**
|
||||
* Invoked from {@link SkinManager#lambda$null$0(Map, 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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(MinecraftUtil.getSkinManager().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 FakeMinecraftProfileTexture texture;
|
||||
|
||||
public BaseBuffer(SkinManager.SkinAvailableCallback callback, MinecraftProfileTexture.Type type, ResourceLocation location, FakeMinecraftProfileTexture 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 FakeMinecraftProfileTexture(texture.getRawUrl(), metadata);
|
||||
FakeSkinManager.this.modelCache.put(location, texture);
|
||||
}
|
||||
}
|
||||
|
||||
FakeSkinManager.makeCallback(callback, type, location, texture);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
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.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 ThreadDownloadImageData_resetNewBufferedImage(Object threadDownloadImageData, BufferedImage image) {
|
||||
((IFakeThreadDownloadImageData) threadDownloadImageData).resetNewBufferedImage(image);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package customskinloader.fake.itf;
|
||||
|
||||
import java.io.InputStream;
|
||||
|
||||
import net.minecraft.client.resources.IResource;
|
||||
|
||||
/** {@link net.minecraft.client.resources.IResource} is no longer an interface since 22w14a */
|
||||
public interface IFakeIResource {
|
||||
// 1.13.2 ~ 22w13a
|
||||
interface V1 {
|
||||
default InputStream func_199027_b() {
|
||||
return ((IResource) this).getInputStream();
|
||||
}
|
||||
}
|
||||
|
||||
// 22w14a+
|
||||
interface V2 {
|
||||
default InputStream open() {
|
||||
return ((IFakeIResource.V1) this).func_199027_b();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package customskinloader.fake.itf;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Optional;
|
||||
|
||||
import net.minecraft.client.resources.IResourceManager;
|
||||
import net.minecraft.resources.IResource;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
public interface IFakeIResourceManager {
|
||||
// 1.13.2 ~ 22w13a
|
||||
default IResource func_199002_a(ResourceLocation location) throws IOException {
|
||||
return (IResource) ((IResourceManager) this).getResource(location);
|
||||
}
|
||||
|
||||
// 22w14a+
|
||||
default Optional getResource(ResourceLocation location) throws IOException {
|
||||
return Optional.ofNullable(this.func_199002_a(location));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package customskinloader.fake.itf;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.resources.IResourceManager;
|
||||
|
||||
public interface IFakeMinecraft {
|
||||
// 1.13.2+
|
||||
default IResourceManager func_195551_G() {
|
||||
return (IResourceManager) ((Minecraft) this).getResourceManager();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
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);
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
package customskinloader.fake.texture;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import javax.imageio.ImageIO;
|
||||
|
||||
public class FakeBufferedImage implements FakeImage {
|
||||
private BufferedImage image;
|
||||
private Graphics graphics;
|
||||
|
||||
public FakeBufferedImage(int width, int height) {
|
||||
this(new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB));
|
||||
}
|
||||
|
||||
public FakeBufferedImage(BufferedImage image) {
|
||||
this.image = image;
|
||||
graphics = image.getGraphics();
|
||||
}
|
||||
|
||||
public BufferedImage getImage() {
|
||||
graphics.dispose();
|
||||
return image;
|
||||
}
|
||||
|
||||
public FakeImage createImage(int width, int height) {
|
||||
return new FakeBufferedImage(width, height);
|
||||
}
|
||||
|
||||
public FakeImage createImage(InputStream is) throws IOException {
|
||||
return new FakeBufferedImage(ImageIO.read(is));
|
||||
}
|
||||
|
||||
public int getWidth() {
|
||||
return image.getWidth();
|
||||
}
|
||||
|
||||
public int getHeight() {
|
||||
return image.getHeight();
|
||||
}
|
||||
|
||||
public int getRGBA(int x, int y) {
|
||||
return image.getRGB(x, y);
|
||||
}
|
||||
|
||||
public void setRGBA(int x, int y, int rgba) {
|
||||
image.setRGB(x, y, rgba);
|
||||
}
|
||||
|
||||
public void copyImageData(FakeImage image) {
|
||||
if (!(image instanceof FakeBufferedImage)) return;
|
||||
BufferedImage img = ((FakeBufferedImage) image).getImage();
|
||||
graphics.drawImage(img, 0, 0, null);
|
||||
}
|
||||
|
||||
public void fillArea(int x0, int y0, int width, int height) {
|
||||
graphics.setColor(new Color(0, 0, 0, 0));
|
||||
graphics.fillRect(x0, y0, width, height);
|
||||
}
|
||||
|
||||
public void copyArea(int x0, int y0, int dx, int dy, int width, int height, boolean reversex, boolean reversey) {
|
||||
int x1 = x0 + width, x2 = x0 + dx, x3 = x2 + width;
|
||||
int y1 = y0 + height, y2 = y0 + dy, y3 = y2 + height;
|
||||
graphics.drawImage(image,
|
||||
reversex ? x3 : x2, reversey ? y3 : y2,
|
||||
reversex ? x2 : x3, reversey ? y2 : y3,
|
||||
x0, y0, x1, y1, null);
|
||||
}
|
||||
|
||||
public void close() {
|
||||
graphics.dispose();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package customskinloader.fake.texture;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
public interface FakeImage {
|
||||
FakeImage createImage(int width, int height);
|
||||
|
||||
FakeImage createImage(InputStream is) throws IOException;
|
||||
|
||||
int getWidth();
|
||||
|
||||
int getHeight();
|
||||
|
||||
int getRGBA(int x, int y);
|
||||
|
||||
void setRGBA(int x, int y, int rgba);
|
||||
|
||||
void copyImageData(FakeImage image);
|
||||
|
||||
void fillArea(int x0, int y0, int width, int height);
|
||||
|
||||
void copyArea(int x0, int y0, int dx, int dy, int width, int height, boolean reversex, boolean reversey);
|
||||
|
||||
void close();
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
package customskinloader.fake.texture;
|
||||
|
||||
import java.io.InputStream;
|
||||
|
||||
import net.minecraft.client.renderer.texture.NativeImage;
|
||||
|
||||
public class FakeNativeImage implements FakeImage {
|
||||
private NativeImage image;
|
||||
|
||||
public FakeNativeImage(int width, int height) {
|
||||
this(new NativeImage(width, height, true));
|
||||
}
|
||||
|
||||
public FakeNativeImage(NativeImage image) {
|
||||
this.image = image;
|
||||
}
|
||||
|
||||
public NativeImage getImage() {
|
||||
return image;
|
||||
}
|
||||
|
||||
public FakeImage createImage(int width, int height) {
|
||||
return new FakeNativeImage(width, height);
|
||||
}
|
||||
|
||||
public FakeImage createImage(InputStream is) {
|
||||
return new FakeNativeImage(NativeImage.func_195713_a(is));
|
||||
}
|
||||
|
||||
public int getWidth() {
|
||||
return image.func_195702_a();
|
||||
}
|
||||
|
||||
public int getHeight() {
|
||||
return image.func_195714_b();
|
||||
}
|
||||
|
||||
public int getRGBA(int x, int y) {
|
||||
return image.func_195709_a(x, y);
|
||||
}
|
||||
|
||||
public void setRGBA(int x, int y, int rgba) {
|
||||
image.func_195700_a(x, y, rgba);
|
||||
}
|
||||
|
||||
public void copyImageData(FakeImage image) {
|
||||
if (!(image instanceof FakeNativeImage)) return;
|
||||
this.image.func_195703_a(((FakeNativeImage) image).getImage());
|
||||
}
|
||||
|
||||
public void fillArea(int x0, int y0, int width, int height) {
|
||||
image.func_195715_a(x0, y0, width, height, 0);
|
||||
}
|
||||
|
||||
public void copyArea(int x0, int y0, int dx, int dy, int width, int height, boolean reversex, boolean reversey) {
|
||||
image.func_195699_a(x0, y0, dx, dy, width, height, reversex, reversey);
|
||||
}
|
||||
|
||||
public void close() {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,166 @@
|
||||
package customskinloader.loader;
|
||||
|
||||
import java.io.File;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.util.List;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import customskinloader.CustomSkinLoader;
|
||||
import customskinloader.config.SkinSiteProfile;
|
||||
import customskinloader.plugin.ICustomSkinLoaderPlugin;
|
||||
import customskinloader.profile.UserProfile;
|
||||
import customskinloader.utils.HttpRequestUtil;
|
||||
import customskinloader.utils.HttpUtil0;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
public class JsonAPILoader implements ICustomSkinLoaderPlugin, ProfileLoader.IProfileLoader {
|
||||
|
||||
public interface IJsonAPI {
|
||||
List<IDefaultProfile> getDefaultProfiles(JsonAPILoader loader);
|
||||
|
||||
String toJsonUrl(String root, String username);
|
||||
|
||||
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);
|
||||
|
||||
String getName();
|
||||
}
|
||||
|
||||
public static class ErrorProfile {
|
||||
public int errno;
|
||||
public String msg;
|
||||
}
|
||||
|
||||
private final IJsonAPI jsonAPI;
|
||||
|
||||
public JsonAPILoader(IJsonAPI jsonAPI) {
|
||||
this.jsonAPI = jsonAPI;
|
||||
}
|
||||
|
||||
// === ICustomSkinLoaderPlugin ===
|
||||
|
||||
@Override
|
||||
public ProfileLoader.IProfileLoader getProfileLoader() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<IDefaultProfile> getDefaultProfiles() {
|
||||
return this.jsonAPI.getDefaultProfiles(this);
|
||||
}
|
||||
|
||||
public abstract static class DefaultProfile implements ICustomSkinLoaderPlugin.IDefaultProfile {
|
||||
protected final JsonAPILoader loader;
|
||||
|
||||
public DefaultProfile(JsonAPILoader loader) {
|
||||
this.loader = loader;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateSkinSiteProfile(SkinSiteProfile ssp) {
|
||||
ssp.type = this.loader.getName();
|
||||
ssp.root = this.getRoot();
|
||||
}
|
||||
|
||||
public abstract String getRoot();
|
||||
}
|
||||
|
||||
// === IProfileLoader ===
|
||||
|
||||
@Override
|
||||
public UserProfile loadProfile(SkinSiteProfile ssp, GameProfile gameProfile) throws Exception {
|
||||
String username = gameProfile.getName();
|
||||
if (StringUtils.isEmpty(ssp.root)) {
|
||||
CustomSkinLoader.logger.info("Root not defined.");
|
||||
return null;
|
||||
}
|
||||
boolean local = HttpUtil0.isLocal(ssp.root);
|
||||
String jsonUrl = this.jsonAPI.toJsonUrl(ssp.root, username);
|
||||
//Some API like MinecraftCapesAPI won't load profile at sometime
|
||||
if (jsonUrl == null) {
|
||||
CustomSkinLoader.logger.info("Profile url not found.");
|
||||
return null;
|
||||
}
|
||||
String json;
|
||||
if (local) {
|
||||
File jsonFile = new File(CustomSkinLoader.DATA_DIR, jsonUrl);
|
||||
if (!jsonFile.exists()) {
|
||||
CustomSkinLoader.logger.info("Profile File not found.");
|
||||
return null;
|
||||
}
|
||||
json = IOUtils.toString(Files.newInputStream(jsonFile.toPath()), StandardCharsets.UTF_8);
|
||||
} else {
|
||||
try {
|
||||
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("")) {
|
||||
CustomSkinLoader.logger.info("Profile not found.");
|
||||
return null;
|
||||
}
|
||||
|
||||
ErrorProfile profile = CustomSkinLoader.GSON.fromJson(json, ErrorProfile.class);
|
||||
if (profile.errno != 0) {
|
||||
CustomSkinLoader.logger.info("Error " + profile.errno + ": " + profile.msg);
|
||||
return null;
|
||||
}
|
||||
|
||||
UserProfile p = this.jsonAPI.toUserProfile(ssp.root, json, local);
|
||||
if (p == null || p.isEmpty()) {
|
||||
CustomSkinLoader.logger.info("Both skin and cape not found.");
|
||||
return null;
|
||||
} else {
|
||||
return p;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean compare(SkinSiteProfile ssp0, SkinSiteProfile ssp1) {
|
||||
return !StringUtils.isNoneEmpty(ssp0.root) || ssp0.root.equalsIgnoreCase(ssp1.root);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return this.jsonAPI.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(SkinSiteProfile ssp) {
|
||||
if (HttpUtil0.isLocal(ssp.root)) {
|
||||
File f = new File(ssp.root);
|
||||
if (!f.exists())
|
||||
//noinspection ResultOfMethodCallIgnored
|
||||
f.mkdirs();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* When getting payload, this exception can end skin loading
|
||||
* @since 14.16
|
||||
*/
|
||||
public static class ProfileNotFoundException extends RuntimeException {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,236 @@
|
||||
package customskinloader.loader;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import customskinloader.CustomSkinLoader;
|
||||
import customskinloader.config.SkinSiteProfile;
|
||||
import customskinloader.plugin.ICustomSkinLoaderPlugin;
|
||||
import customskinloader.profile.UserProfile;
|
||||
import customskinloader.utils.HttpRequestUtil;
|
||||
import customskinloader.utils.HttpTextureUtil;
|
||||
import customskinloader.utils.HttpUtil0;
|
||||
|
||||
public class LegacyLoader implements ICustomSkinLoaderPlugin, ProfileLoader.IProfileLoader {
|
||||
|
||||
@Override
|
||||
public ProfileLoader.IProfileLoader getProfileLoader() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<IDefaultProfile> getDefaultProfiles() {
|
||||
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 {
|
||||
protected final LegacyLoader loader;
|
||||
|
||||
public DefaultProfile(LegacyLoader loader) {
|
||||
this.loader = loader;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateSkinSiteProfile(SkinSiteProfile ssp) {
|
||||
ssp.type = this.loader.getName();
|
||||
if (ssp.checkPNG == null) {
|
||||
ssp.checkPNG = false;
|
||||
}
|
||||
if (ssp.model == null) {
|
||||
ssp.model = "auto";
|
||||
}
|
||||
//Set texture url when it is empty
|
||||
//Remote texture url could be changed, it will be auto updated here
|
||||
if (ssp.skin == null || !HttpUtil0.isLocal(this.getSkinRoot())) {
|
||||
ssp.skin = this.getSkinRoot();
|
||||
}
|
||||
if (ssp.cape == null || !HttpUtil0.isLocal(this.getCapeRoot())) {
|
||||
ssp.cape = this.getCapeRoot();
|
||||
}
|
||||
if (ssp.elytra == null || !HttpUtil0.isLocal(this.getElytraRoot())) {
|
||||
ssp.elytra = this.getElytraRoot();
|
||||
}
|
||||
}
|
||||
|
||||
public abstract String getSkinRoot();
|
||||
|
||||
public abstract String getCapeRoot();
|
||||
|
||||
public abstract String getElytraRoot();
|
||||
}
|
||||
|
||||
public static class LocalSkin extends LegacyLoader.DefaultProfile {
|
||||
public LocalSkin(LegacyLoader loader) {
|
||||
super(loader);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "LocalSkin";
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPriority() {
|
||||
return 710;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSkinRoot() {
|
||||
return "LocalSkin/skins/{USERNAME}.png";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCapeRoot() {
|
||||
return "LocalSkin/capes/{USERNAME}.png";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getElytraRoot() {
|
||||
return "LocalSkin/elytras/{USERNAME}.png";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get cape Profile¬
|
||||
*
|
||||
* @since 14.16
|
||||
*/
|
||||
public static LegacyLoader.DefaultProfile getCapeProfile(LegacyLoader loader, String name, String capeRoot, int priority) {
|
||||
return new DefaultProfile(loader) {
|
||||
@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 UUID_PLACEHOLDER = "{UUID}";
|
||||
/**
|
||||
* Mojang UUID with -
|
||||
*
|
||||
* @since 14.16
|
||||
*/
|
||||
public static final String STANDARD_UUID_PLACEHOLDER = "{STANDARD_UUID}";
|
||||
|
||||
@Override
|
||||
public UserProfile loadProfile(SkinSiteProfile ssp, GameProfile gameProfile) {
|
||||
UserProfile profile = new UserProfile();
|
||||
//Try to load all textures
|
||||
getTextureUrl(ssp, gameProfile, ssp.skin, it -> {
|
||||
profile.skinUrl = it;
|
||||
profile.model = ssp.model;
|
||||
});
|
||||
getTextureUrl(ssp, gameProfile, ssp.cape, it -> profile.capeUrl = it);
|
||||
getTextureUrl(ssp, gameProfile, ssp.elytra, it -> profile.elytraUrl = it);
|
||||
|
||||
if (profile.isEmpty()) {
|
||||
CustomSkinLoader.logger.info("No texture could be found.");
|
||||
return null;
|
||||
}
|
||||
return profile;
|
||||
}
|
||||
|
||||
private void getTextureUrl(
|
||||
SkinSiteProfile ssp, GameProfile gameProfile, String baseUrl, Consumer<String> onSuccess) {
|
||||
//Base URL is empty
|
||||
if (baseUrl == null || baseUrl.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
String url = expandURL(baseUrl, gameProfile.getName());
|
||||
//No texture can be loaded
|
||||
if (url == null) {
|
||||
return;
|
||||
}
|
||||
//Local texture file logic
|
||||
if (HttpUtil0.isLocal(url)) {
|
||||
File file = new File(CustomSkinLoader.DATA_DIR, url);
|
||||
if (file.exists() && file.isFile()) {
|
||||
String fakeUrl = HttpTextureUtil.getLocalLegacyFakeUrl(url,
|
||||
HttpTextureUtil.getHash(url, file.length(), file.lastModified()));
|
||||
onSuccess.accept(fakeUrl);
|
||||
}
|
||||
return;
|
||||
}
|
||||
//Remote texture logic
|
||||
HttpRequestUtil.HttpResponce responce = HttpRequestUtil.makeHttpRequest(new HttpRequestUtil.HttpRequest(url)
|
||||
.setUserAgent(ssp.userAgent).setCheckPNG(ssp.checkPNG != null && ssp.checkPNG).setLoadContent(false));
|
||||
if (responce.success) {
|
||||
onSuccess.accept(HttpTextureUtil.getLegacyFakeUrl(url));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean compare(SkinSiteProfile ssp0, SkinSiteProfile ssp1) {
|
||||
return Objects.equals(ssp0.skin, ssp1.skin) && Objects.equals(ssp0.cape, ssp1.cape) &&
|
||||
Objects.equals(ssp0.elytra, ssp1.elytra);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "Legacy";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(SkinSiteProfile ssp) {
|
||||
initFolder(ssp.skin);
|
||||
initFolder(ssp.cape);
|
||||
initFolder(ssp.elytra);
|
||||
}
|
||||
|
||||
@SuppressWarnings("ResultOfMethodCallIgnored")
|
||||
private void initFolder(String target) {
|
||||
//Only local skin should init folder
|
||||
if (!HttpUtil0.isLocal(target)) {
|
||||
return;
|
||||
}
|
||||
String file = target.replace(USERNAME_PLACEHOLDER, "init");
|
||||
File folder = new File(CustomSkinLoader.DATA_DIR, file).getParentFile();
|
||||
if (folder != null && !folder.exists()) {
|
||||
folder.mkdirs();
|
||||
}
|
||||
}
|
||||
|
||||
private String expandURL(String url, String username) {
|
||||
String t = url.replace(USERNAME_PLACEHOLDER, username);
|
||||
if (!t.contains(UUID_PLACEHOLDER) && !t.contains(STANDARD_UUID_PLACEHOLDER)) {
|
||||
return t;
|
||||
}
|
||||
String uuid = MojangAPILoader.getMojangUuidByUsername(username, true);
|
||||
//If Mojang uuid not found, won't load the texture
|
||||
if (uuid == null) {
|
||||
return null;
|
||||
}
|
||||
String styledUuid = uuid.replace("-", "");
|
||||
return t.replace(UUID_PLACEHOLDER, styledUuid).replace(STANDARD_UUID_PLACEHOLDER, uuid);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,232 @@
|
||||
package customskinloader.loader;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Collections;
|
||||
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.authlib.yggdrasil.response.MinecraftProfilePropertiesResponse;
|
||||
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.HttpRequestUtil;
|
||||
import org.apache.commons.codec.binary.Base64;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
public class MojangAPILoader implements ICustomSkinLoaderPlugin, ProfileLoader.IProfileLoader {
|
||||
|
||||
@Override
|
||||
public ProfileLoader.IProfileLoader getProfileLoader() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<IDefaultProfile> getDefaultProfiles() {
|
||||
return Lists.newArrayList(new Mojang(this));
|
||||
}
|
||||
|
||||
public abstract static class DefaultProfile implements ICustomSkinLoaderPlugin.IDefaultProfile {
|
||||
protected final MojangAPILoader loader;
|
||||
|
||||
public DefaultProfile(MojangAPILoader loader) {
|
||||
this.loader = loader;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateSkinSiteProfile(SkinSiteProfile ssp) {
|
||||
ssp.type = this.loader.getName();
|
||||
ssp.apiRoot = this.getAPIRoot();
|
||||
ssp.sessionRoot = this.getSessionRoot();
|
||||
}
|
||||
|
||||
public abstract String getAPIRoot();
|
||||
|
||||
public abstract String getSessionRoot();
|
||||
}
|
||||
|
||||
public static class Mojang extends MojangAPILoader.DefaultProfile {
|
||||
public Mojang(MojangAPILoader loader) {
|
||||
super(loader);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "Mojang";
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPriority() {
|
||||
return 100;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAPIRoot() {
|
||||
return getMojangApiRoot();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSessionRoot() {
|
||||
return getMojangSessionRoot();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public UserProfile loadProfile(SkinSiteProfile ssp, GameProfile gameProfile) {
|
||||
Map<MinecraftProfileTexture.Type, MinecraftProfileTexture> map = getTextures(gameProfile);
|
||||
if (!map.isEmpty()) {
|
||||
CustomSkinLoader.logger.info("Default profile will be used.");
|
||||
return ModelManager0.toUserProfile(map);
|
||||
}
|
||||
String username = gameProfile.getName();
|
||||
GameProfile newGameProfile = loadGameProfileCached(ssp.apiRoot, username);
|
||||
if (newGameProfile == null) {
|
||||
CustomSkinLoader.logger.info("Profile not found.(" + username + "'s profile not found.)");
|
||||
return null;
|
||||
}
|
||||
newGameProfile = fillGameProfile(ssp.sessionRoot, newGameProfile);
|
||||
map = getTextures(newGameProfile);
|
||||
if (!map.isEmpty()) {
|
||||
gameProfile.getProperties().putAll(newGameProfile.getProperties());
|
||||
return ModelManager0.toUserProfile(map);
|
||||
}
|
||||
CustomSkinLoader.logger.info("Profile not found.(" + username + " doesn't have skin/cape.)");
|
||||
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
|
||||
public static GameProfile loadGameProfile(String apiRoot, String username) {
|
||||
//Doc (https://wiki.vg/Mojang_API#Playernames_-.3E_UUIDs)
|
||||
Gson gson = new GsonBuilder().registerTypeAdapter(UUID.class, new UUIDTypeAdapter()).create();
|
||||
|
||||
HttpRequestUtil.HttpResponce responce = HttpRequestUtil.makeHttpRequest(
|
||||
new HttpRequestUtil.HttpRequest(apiRoot + "profiles/minecraft")
|
||||
.setCacheTime(600).setPayload(gson.toJson(Collections.singletonList(username)))
|
||||
);
|
||||
if (StringUtils.isEmpty(responce.content)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
GameProfile[] profiles = gson.fromJson(responce.content, GameProfile[].class);
|
||||
if (profiles.length == 0) {
|
||||
return null;
|
||||
}
|
||||
GameProfile gameProfile = profiles[0];
|
||||
|
||||
if (gameProfile.getId() == null) {
|
||||
return null;
|
||||
}
|
||||
return new GameProfile(gameProfile.getId(), gameProfile.getName());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Mojang UUID by username.
|
||||
*
|
||||
* @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.
|
||||
*/
|
||||
public static String getMojangUuidByUsername(String username, boolean standard) {
|
||||
GameProfile profile = loadGameProfileCached(getMojangApiRoot(), username);
|
||||
if (profile == null) {
|
||||
return null;
|
||||
}
|
||||
UUID id = profile.getId();
|
||||
return standard ? id.toString() : UUIDTypeAdapter.fromUUID(id);
|
||||
}
|
||||
|
||||
//UUID -> Profile
|
||||
public static GameProfile fillGameProfile(String sessionRoot, GameProfile profile) {
|
||||
//Doc (http://wiki.vg/Mojang_API#UUID_-.3E_Profile_.2B_Skin.2FCape)
|
||||
HttpRequestUtil.HttpResponce responce = HttpRequestUtil.makeHttpRequest(
|
||||
new HttpRequestUtil.HttpRequest(sessionRoot + "session/minecraft/profile/"
|
||||
+ UUIDTypeAdapter.fromUUID(profile.getId())).setCacheTime(90));
|
||||
if (StringUtils.isEmpty(responce.content)) {
|
||||
return profile;
|
||||
}
|
||||
|
||||
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) {
|
||||
if (gameProfile == null) {
|
||||
return Maps.newHashMap();
|
||||
}
|
||||
Property textureProperty = Iterables.getFirst(gameProfile.getProperties().get("textures"), null);
|
||||
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
|
||||
public boolean compare(SkinSiteProfile ssp0, SkinSiteProfile ssp1) {
|
||||
return (!StringUtils.isNoneEmpty(ssp0.apiRoot) || ssp0.apiRoot.equalsIgnoreCase(ssp1.apiRoot)) ||
|
||||
(!StringUtils.isNoneEmpty(ssp0.sessionRoot) || ssp0.sessionRoot.equalsIgnoreCase(ssp1.sessionRoot));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "MojangAPI";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(SkinSiteProfile ssp) {
|
||||
//Init default api & session root for Mojang API
|
||||
if (ssp.apiRoot == null)
|
||||
ssp.apiRoot = getMojangApiRoot();
|
||||
if (ssp.sessionRoot == null)
|
||||
ssp.sessionRoot = getMojangSessionRoot();
|
||||
}
|
||||
|
||||
// Prevent authlib-injector (https://github.com/yushijinhun/authlib-injector) from modifying these strings
|
||||
private static final String MOJANG_API_ROOT = "https://api{DO_NOT_MODIFY}.mojang.com/";
|
||||
private static final String MOJANG_SESSION_ROOT = "https://sessionserver{DO_NOT_MODIFY}.mojang.com/";
|
||||
|
||||
public static String getMojangApiRoot() {
|
||||
return MOJANG_API_ROOT.replace("{DO_NOT_MODIFY}", "");
|
||||
}
|
||||
|
||||
public static String getMojangSessionRoot() {
|
||||
return MOJANG_SESSION_ROOT.replace("{DO_NOT_MODIFY}", "");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package customskinloader.loader;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import customskinloader.CustomSkinLoader;
|
||||
import customskinloader.config.SkinSiteProfile;
|
||||
import customskinloader.plugin.ICustomSkinLoaderPlugin;
|
||||
import customskinloader.plugin.PluginLoader;
|
||||
import customskinloader.profile.UserProfile;
|
||||
|
||||
public class ProfileLoader {
|
||||
public static final HashMap<String, IProfileLoader> LOADERS = initLoaders();
|
||||
|
||||
private static HashMap<String, IProfileLoader> initLoaders() {
|
||||
HashMap<String, ProfileLoader.IProfileLoader> profileLoaders = new HashMap<>();
|
||||
for (ICustomSkinLoaderPlugin plugin : PluginLoader.PLUGINS) {
|
||||
ProfileLoader.IProfileLoader profileLoader = plugin.getProfileLoader();
|
||||
if (profileLoader != null) {
|
||||
profileLoaders.put(profileLoader.getName().toLowerCase(), profileLoader);
|
||||
CustomSkinLoader.logger.info("Add a profile loader: " + profileLoader.getName());
|
||||
}
|
||||
}
|
||||
return profileLoaders;
|
||||
}
|
||||
|
||||
public interface IProfileLoader {
|
||||
UserProfile loadProfile(SkinSiteProfile ssp,GameProfile gameProfile) throws Exception;
|
||||
boolean compare(SkinSiteProfile ssp0,SkinSiteProfile ssp1);
|
||||
String getName();
|
||||
void init(SkinSiteProfile ssp);
|
||||
}
|
||||
}
|
||||
@@ -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";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
package customskinloader.loader.jsonapi;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.gson.Gson;
|
||||
import customskinloader.CustomSkinLoader;
|
||||
import customskinloader.config.SkinSiteProfile;
|
||||
import customskinloader.loader.JsonAPILoader;
|
||||
import customskinloader.plugin.ICustomSkinLoaderPlugin;
|
||||
import customskinloader.utils.MinecraftUtil;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
|
||||
public class CustomSkinAPIPlus extends CustomSkinAPI {
|
||||
|
||||
private static String clientID=null;
|
||||
public CustomSkinAPIPlus(){
|
||||
File clientIDFile=new File(CustomSkinLoader.DATA_DIR,"CustomSkinAPIPlus-ClientID");
|
||||
|
||||
if(clientIDFile.isFile())
|
||||
try{
|
||||
clientID=FileUtils.readFileToString(clientIDFile, "UTF-8");
|
||||
}catch(Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
if(clientID==null){
|
||||
clientID=UUID.randomUUID().toString();
|
||||
try {
|
||||
FileUtils.write(clientIDFile, clientID, "UTF-8");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ICustomSkinLoaderPlugin.IDefaultProfile> getDefaultProfiles(JsonAPILoader loader) {
|
||||
return Lists.newArrayList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPayload(SkinSiteProfile ssp) {
|
||||
return new Gson().toJson(new CustomSkinAPIPlusPayload());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "CustomSKinAPIPlus";
|
||||
}
|
||||
|
||||
public static class CustomSkinAPIPlusPayload{
|
||||
String gameVersion;//minecraft version
|
||||
String modVersion;//mod version
|
||||
String serverAddress;//ip:port
|
||||
String clientID;//Minecraft Client ID
|
||||
CustomSkinAPIPlusPayload(){
|
||||
gameVersion = MinecraftUtil.getMinecraftMainVersion();
|
||||
modVersion = CustomSkinLoader.CustomSkinLoader_VERSION;
|
||||
serverAddress = MinecraftUtil.isLanServer() ? null : MinecraftUtil.getStandardServerAddress();
|
||||
clientID = CustomSkinAPIPlus.clientID;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
package customskinloader.loader.jsonapi;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import com.mojang.authlib.minecraft.MinecraftProfileTexture;
|
||||
import customskinloader.loader.JsonAPILoader;
|
||||
import customskinloader.plugin.ICustomSkinLoaderPlugin;
|
||||
import customskinloader.profile.ModelManager0;
|
||||
import customskinloader.profile.UserProfile;
|
||||
|
||||
public class ElyByAPI implements JsonAPILoader.IJsonAPI {
|
||||
|
||||
public static class ElyBy extends JsonAPILoader.DefaultProfile {
|
||||
public ElyBy(JsonAPILoader loader) {
|
||||
super(loader);
|
||||
}
|
||||
|
||||
@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 TLauncher(JsonAPILoader loader) {
|
||||
super(loader);
|
||||
}
|
||||
|
||||
@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
|
||||
public List<ICustomSkinLoaderPlugin.IDefaultProfile> getDefaultProfiles(JsonAPILoader loader) {
|
||||
return Lists.newArrayList(new ElyBy(loader), new TLauncher(loader));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toJsonUrl(String root, String username) {
|
||||
return root + username;
|
||||
}
|
||||
|
||||
@Override
|
||||
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());
|
||||
return ModelManager0.toUserProfile(result);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "ElyByAPI";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
package customskinloader.loader.jsonapi;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.gson.Gson;
|
||||
import com.mojang.authlib.minecraft.MinecraftProfileTexture;
|
||||
import customskinloader.loader.JsonAPILoader;
|
||||
import customskinloader.plugin.ICustomSkinLoaderPlugin;
|
||||
import customskinloader.profile.ModelManager0;
|
||||
import customskinloader.profile.UserProfile;
|
||||
|
||||
public class GlitchlessAPI implements JsonAPILoader.IJsonAPI {
|
||||
|
||||
public static class GlitchlessGames extends JsonAPILoader.DefaultProfile {
|
||||
public GlitchlessGames(JsonAPILoader loader) {
|
||||
super(loader);
|
||||
}
|
||||
|
||||
@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
|
||||
public List<ICustomSkinLoaderPlugin.IDefaultProfile> getDefaultProfiles(JsonAPILoader loader) {
|
||||
return Lists.newArrayList(new GlitchlessGames(loader));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toJsonUrl(String root, String username) {
|
||||
return root + username;
|
||||
}
|
||||
|
||||
@Override
|
||||
public UserProfile toUserProfile(String root, String json, boolean local) {
|
||||
GlitchlessApiResponse result = new Gson().fromJson(json, GlitchlessApiResponse.class);
|
||||
if (!result.textures.containsKey(MinecraftProfileTexture.Type.SKIN))
|
||||
return null;
|
||||
|
||||
return ModelManager0.toUserProfile(result.textures);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "GlitchlessAPI";
|
||||
}
|
||||
|
||||
public static class GlitchlessApiResponse {
|
||||
protected Map<MinecraftProfileTexture.Type, MinecraftProfileTexture> textures;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
package customskinloader.loader.jsonapi;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.gson.Gson;
|
||||
|
||||
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;
|
||||
|
||||
public class MinecraftCapesAPI implements JsonAPILoader.IJsonAPI {
|
||||
|
||||
public static class MinecraftCapes extends JsonAPILoader.DefaultProfile {
|
||||
public MinecraftCapes(JsonAPILoader loader) {
|
||||
super(loader);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "MinecraftCapes";
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPriority() {
|
||||
return 800;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRoot() {
|
||||
return "https://minecraftcapes.net/profile/";
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ICustomSkinLoaderPlugin.IDefaultProfile> getDefaultProfiles(JsonAPILoader loader) {
|
||||
return Lists.newArrayList(new MinecraftCapes(loader));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toJsonUrl(String root, String username) {
|
||||
String uuid = MojangAPILoader.getMojangUuidByUsername(username, false);
|
||||
//If uuid cannot be found, we won't load profile in this API.
|
||||
if (uuid == null) {
|
||||
return null;
|
||||
}
|
||||
//API url is `${root}${uuid}`
|
||||
return root + uuid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public UserProfile toUserProfile(String root, String json, boolean local) {
|
||||
MinecraftCapesApiResponse result = new Gson().fromJson(json, MinecraftCapesApiResponse.class);
|
||||
if (result.textures == null || result.textures.cape == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
UserProfile profile = new UserProfile();
|
||||
profile.capeUrl = TextureUtil.parseBase64Texture(result.textures.cape);
|
||||
|
||||
return profile;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPayload(SkinSiteProfile ssp) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "MinecraftCapesAPI";
|
||||
}
|
||||
|
||||
public static class MinecraftCapesApiResponse {
|
||||
public boolean animatedCape;
|
||||
public boolean capeGlint;
|
||||
public boolean upsideDown;
|
||||
public MinecraftCapesApiTexture textures;
|
||||
|
||||
public static class MinecraftCapesApiTexture {
|
||||
public String cape;
|
||||
public String ears;
|
||||
}
|
||||
}
|
||||
}
|
||||
Loaded 100 of 239 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user