Compare commits

...
444 Commits
Author SHA1 Message Date
ZekerZhayard 8e63429293 Fix IllegalAccessError. (#317) 2024-11-12 21:36:24 +08:00
8Mi_Yile aa68af31e5 [skip ci] 修复缺少括号引起的执行问题 (#316)
手生了 还把括号搞丢了 太草了
2024-11-12 12:33:00 +08:00
8Mi_Yile bab30e4f0a 修复版本号问题和Quilt标签 (#312)
* [skip ci] fix cannot get minecraft versions

* [skip ci] fix cannot auto add tag `Quilt`
2024-11-08 13:14:45 +08:00
ZekerZhayard 571d61118d Fix #314 (#315) 2024-11-08 08:33:39 +08:00
33 5d3326c333 feat: 14.21 2024-11-06 10:49:15 +08:00
ZekerZhayard b2095998e5 1.21.2 (#311) 2024-10-30 12:31:15 +08:00
ZekerZhayard cdf2fbe644 24w33a (#310) 2024-09-27 20:29:27 +08:00
xand fa0f820143 Bump Fabric and ForgeV3 (Forge & Neoforge) versions to 1.21.1 (#306)
* Bump Fabric and Forge/Neoforge compatibility to 1.21.1

* Bump version to 14.21

* Fix version in build.properties
2024-08-10 21:07:12 +08:00
8Mi_Yile 23f08a3a64 support upload add tag NeoForge (#298)
* Update common.yml

* Update common.yml

* Update common.yml

* Update common.yml

* Update common.yml
2024-08-10 20:50:16 +08:00
ZekerZhayard 3e4b06f5d1 Fix NullPointerException (#299) 2024-08-10 20:49:09 +08:00
33 18d31bed8f feat: 1.21 2024-07-03 00:14:19 +08:00
ZekerZhayard 64490f1d18 Support 1.21. (#297) 2024-07-02 22:43:35 +08:00
33 cd1922844c feat: bump version to 14.19.3 2023-12-21 22:57:00 +08:00
ZekerZhayard 4185e5bb5f Fix #286 (#287) 2023-12-21 22:28:03 +08:00
ZekerZhayard 7fd5ff84ee Fix #284 (#285) 2023-12-18 21:04:28 +08:00
33 d2772697f3 feat: remove forceIgnoreHttpsCertificate for security 2023-12-15 17:39:36 +08:00
ZekerZhayard 0ffa9ef137 23w42a (#281) 2023-12-12 00:04:05 +08:00
33 f4b5954dad feat: version 14.19 2023-12-12 00:03:41 +08:00
8Mi_Yile 009895c018 fix: issues: report-bug: CSL.log is requried (#280)
* Update report_bug.zh_CN.yml

* Update report_bug.en_US.yml
2023-12-06 19:12:30 +08:00
33 c273dc396e feat: fix upload 2023-11-01 13:39:37 +08:00
33 6cb37301b6 feat: add cloudflare r2 2023-11-01 12:12:56 +08:00
33 e9e1955fad feat: change version to 14.18.3 2023-10-19 15:28:59 +08:00
33 933f64b810 feat: fix method not found in 1.8-1.12.2 2023-10-19 15:28:08 +08:00
33 e839362f09 feat: fix build 2023-10-16 20:31:19 +08:00
ZekerZhayard 220bddbebb Fix #272 (#273) 2023-10-15 14:51:50 +08:00
33 00c931d434 feat: fix MinecraftCapes 2023-10-11 12:29:02 +08:00
33 119892489f feat: rename enum AuthlibField 2023-10-10 13:58:32 +08:00
ZekerZhayard 9a55a4c615 Adapting to Authlib changes (#269) 2023-10-10 13:54:23 +08:00
33 1ed98534c9 feat: version 14.18 2023-10-09 19:35:03 +08:00
ZekerZhayard b8ca913848 Support 1.20.2. (#266) 2023-09-28 20:49:25 +08:00
33 d5ae6226ae feat: update Java version in action 2023-07-14 01:06:39 +08:00
33 f274278419 feat: update README.md 2023-07-14 01:04:24 +08:00
33 f6f043fc7c feat: remove illegal EOF 2023-07-14 01:04:24 +08:00
33 9571e367df feat: tweak into multi line output 2023-07-14 01:04:24 +08:00
33 48efe58d52 feat: use multiple version in action 2023-07-14 01:04:24 +08:00
33 16520f72a4 feat: add multiple version in release 2023-07-14 01:04:24 +08:00
33 fd08f65af3 feat: cherry pick from 14-develop 2023-07-14 01:03:51 +08:00
33 83799da6ae feat: cheery pick from 14-develop 2023-07-14 01:01:10 +08:00
33 54d24a2800 fix: mod version in action 2023-07-14 00:59:31 +08:00
33 f2698b4ccf fix: GitHub pre-release in action 2023-07-14 00:59:31 +08:00
33 4a344ed653 fix: CurseForge and Modrinth upload 2023-07-14 00:59:31 +08:00
33 7074c8509d fix: CurseForge and Modrinth upload 2023-07-14 00:59:31 +08:00
33 10950a21ee fix: CurseForge upload 2023-07-14 00:59:31 +08:00
33 9889e05a81 feat: remove GitHub release action 2023-07-14 00:59:31 +08:00
8Mi_Yile e65ab7a9ea Update common.yml (#258) 2023-07-13 15:22:53 +08:00
33 a4f30a4bf1 fix: curseforge and modrinth release 2023-06-28 13:56:20 +08:00
33 68ac9f67df fix: use correct environment in upload task 2023-06-27 14:46:01 +08:00
33 647532629e fix: pull request won't run upload 2023-06-27 14:31:43 +08:00
33 71befeb300 fix: publish snapshot and canary to Tencent COS 2023-06-27 14:26:14 +08:00
8Mi_Yileandgithub-actions[bot] 8db9bf3de6 Add: common.yaml: CI Build Sync to Github Pre-Release (#256)
* Auto Sync From 8MiYile / MCCustomSkinLoader / 15-develop

* Auto Sync From 8MiYile / MCCustomSkinLoader / 15-develop

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2023-06-27 13:49:59 +08:00
8Mi_Yileandgithub-actions[bot] 0c9a4033c4 add: common.yml: use matrix to multi-process upload file (#252)
* Auto Sync From 8MiYile / MCCustomSkinLoader / 15-develop

* Auto Sync From 8MiYile / MCCustomSkinLoader / 15-develop

* Auto Sync From 8MiYile / MCCustomSkinLoader / 15-develop

* Auto Sync From 8MiYile / MCCustomSkinLoader / 15-develop

* Auto Sync From 8MiYile / MCCustomSkinLoader / 15-develop

* Auto Sync From 8MiYile / MCCustomSkinLoader / 15-develop

* Auto Sync From 8MiYile / MCCustomSkinLoader / 15-develop

* Auto Sync From 8MiYile / MCCustomSkinLoader / 15-develop

* Auto Sync From 8MiYile / MCCustomSkinLoader / 15-develop

* Auto Sync From 8MiYile / MCCustomSkinLoader / 15-develop

* Auto Sync From 8MiYile / MCCustomSkinLoader / 15-develop

* Auto Sync From 8MiYile / MCCustomSkinLoader / 15-develop

* Auto Sync From 8MiYile / MCCustomSkinLoader / 15-develop

* Auto Sync From 8MiYile / MCCustomSkinLoader / 15-develop

* Auto Sync From 8MiYile / MCCustomSkinLoader / 15-develop

* Auto Sync From 8MiYile / MCCustomSkinLoader / 15-develop

* Auto Sync From 8MiYile / MCCustomSkinLoader / 15-develop

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2023-05-12 11:14:27 +08:00
ZekerZhayard d8d955224d Fix crash when the URL of skull profiles is not valid. (#255)
* Fix crash when the URL of skull profiles is not valid.

* Fix crash when the URL of skull profiles is not valid.
2023-05-07 16:38:36 +08:00
ZekerZhayard 8c0cdfb7b5 Support Fabric 23w16a. (#253) 2023-04-23 20:13:11 +08:00
33 919b69aaad Fix: GitHub Action Release 2023-04-17 21:57:55 +08:00
8Mi_Yileandgithub-actions[bot] 4de06aae50 issues-template: add option / common.yml: add support github release (#251)
* Auto Sync From

* Auto Sync From8MiYile/15-develop.zip

* Auto Sync From 8MiYile / 15-develop

* Auto Sync From 8MiYile / 15-develop

* Auto Sync From 8MiYile / MCCustomSkinLoader / 15-develop

* Auto Sync From 8MiYile / MCCustomSkinLoader / 15-develop

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2023-04-17 21:45:32 +08:00
ZekerZhayard f3f80a1f00 Merge remote-tracking branch 'origin/14-develop' into 15-develop 2023-03-18 21:42:57 +08:00
ZekerZhayard f5b1989453 Fix: Skull textures not loading when using local skins. 2023-03-18 11:07:34 +08:00
ZekerZhayard 85923855d8 Support 1.19.4. Remove Vanilla 1.19.3. 2023-03-15 23:34:05 +08:00
ZekerZhayard 755f7647ed Remove: all vanilla editions 2023-01-29 22:52:21 +08:00
33 c2dad72690 Add: 15-develop 2023-01-29 16:03:22 +08:00
8Mi_Yile c8e96c11cd Add Github Issue Template's options in Report Bug (#242)
* Update report_bug.en_US.yml

* Update report_bug.zh_CN.yml

* Update report_bug.zh_CN.yml

* Update report_bug.en_US.yml

* Update report_bug.zh_CN.yml

* Update report_bug.en_US.yml

* Update report_bug.en_US.yml

* Update report_bug.zh_CN.yml

* Update report_bug.zh_CN.yml

* Update report_bug.zh_CN.yml

* Update report_bug.en_US.yml

* Update report_bug.zh_CN.yml
2023-01-28 12:42:38 +08:00
33 32e3e2e5a2 Add: GameProfile cache for Mojang API 2023-01-26 19:34:58 +08:00
33 b7b5e9d6c8 Add: LogManager 2023-01-26 18:51:38 +08:00
ZekerZhayard dfa7db1731 Fix: Modrinth release for Fabric edition 2023-01-26 16:26:08 +08:00
33 b645fd1665 Fix: Modrinth release 2023-01-26 15:39:37 +08:00
33 28fc81cb9a Fix: release build 2023-01-26 15:21:26 +08:00
33 bb0a47de4b Release: 14.15.2 2023-01-26 14:46:52 +08:00
33 d09b1d9807 Tweak: log file format 2023-01-24 18:43:17 +08:00
33 c207bdfc0e Fix: build action 2023-01-13 15:43:38 +08:00
33 69d35a69b7 Tweak: release build action 2023-01-13 15:22:29 +08:00
8Mi_Yile d767f40d32 添加 Issue Template (#238) 2023-01-13 15:12:40 +08:00
ZekerZhayard 5329a27d1a Fix: #199 2023-01-12 22:12:40 +08:00
33 ddefe00ac0 Add: more cape 2023-01-12 00:09:57 +08:00
33 dd4b706827 Add: support WynntilsAPI cape 2023-01-11 22:06:58 +08:00
33 84072c62f3 Add: support OptiFine cape 2023-01-11 18:51:44 +08:00
33 2d00e12f0a Update: README.md 2023-01-07 04:33:22 +08:00
33 b2b56f5be5 Add: GitHub Action for Pull Request 2023-01-07 01:24:12 +08:00
33 43c8ceb21e Add: show Quilt loader in CurseForge and Modrinth 2023-01-07 01:09:08 +08:00
33 a0ad239770 Release: 14.15.1 2023-01-07 00:26:22 +08:00
ZekerZhayard c8f0f7e283 Fix: loadSkin not being remapped 2023-01-07 00:20:17 +08:00
33 bfbd6ee31a Update: README.md 2023-01-05 15:28:27 +08:00
33 f8f3caad39 Fix: trigger release action by tag 2023-01-04 17:15:40 +08:00
33 bd409ae169 Tweak: trigger release action by tag 2023-01-04 17:11:43 +08:00
33 82f0aad9ff Release: 14.15 2023-01-04 16:37:33 +08:00
33 f2fce38137 Fix: pass secrets to reuse workflow 2023-01-04 16:27:28 +08:00
33 7d19f3114c Add: GitHub Action Test 2023-01-04 16:15:47 +08:00
33 d7a1e0f31f Update: certificate 2023-01-04 15:56:11 +08:00
33 201210f567 Fix: GitHub Action 2023-01-04 15:40:53 +08:00
33 26ed002689 Fix: GitHub Action 2023-01-04 15:39:55 +08:00
33 7d7e5c9060 Update: reuse GitHub Action workflow 2023-01-04 15:37:43 +08:00
33 81bf422250 Add: environment in GitHub Action 2023-01-04 15:12:17 +08:00
33 776e31e158 Fix: cos beta build upload 2023-01-04 14:50:30 +08:00
33 4a92223158 Fix: GitHub Action 2023-01-04 14:38:43 +08:00
33 264aacc8c0 Add: upload beta to cos 2023-01-04 14:34:46 +08:00
33 0b000731b5 Remove: Circle CI 2023-01-04 13:57:39 +08:00
33 f0012b58df Tweak: GitHub Action 2023-01-04 13:50:38 +08:00
33 013c22ae95 Add: GitHub Action 2023-01-04 13:43:08 +08:00
33 01d02a27b0 Update: circle ci version 2.1 2023-01-04 12:01:48 +08:00
33 077551e161 Tweak: only build release branch in circle ci 2023-01-04 12:01:48 +08:00
ZekerZhayard bd642d0106 Don't use ClassWriter.COMPUTE_FRAME anymore. (#234) 2023-01-02 14:21:51 +08:00
ZekerZhayard fbec7ce6bb Support 1.19.3. Remove Vanilla 1.19.2. (#231) 2022-12-12 02:26:22 +08:00
33 ea1b25a38f Tweak: add debug argument to Gradle 2022-12-07 21:24:51 +08:00
33 62018a3e8b Tweak: use Gradle Wrapper 2022-12-07 19:52:11 +08:00
ZekerZhayard f38a8ddcef Refactor SkinManager (#230) 2022-12-07 19:38:24 +08:00
33 63251c9f5e Add: a switch for printing to standard output 2022-11-24 21:42:45 +08:00
33 e94f4b0e99 Release: 14.14 2022-10-19 11:35:43 +08:00
33 5ee2eee382 Add: LICENSE 2022-08-27 10:42:38 +08:00
ZekerZhayard 3063de7ff0 Support 1.19.2. Remove Vanilla 1.19.1. (#220) 2022-08-17 10:47:26 +08:00
33 583bf1fe6a Tweak: calculate correct hash for base64 texture 2022-07-29 02:29:15 +08:00
33 a3de21497d Fix: MinecraftCapesAPI 2022-07-29 02:15:19 +08:00
33 51aec265be Tweak: LegacyLoader UUID fallback logic 2022-07-29 01:14:50 +08:00
33 52caeb3bdc Tweak: compatible with authlib 3.11.50 2022-07-29 00:07:04 +08:00
33 a3fa4e47c6 Fix: MinecraftCapesAPI load profile only with existing UUID 2022-07-29 00:05:51 +08:00
33 e1cde0afc7 Tweak: correct MinecraftCapesAPI name 2022-07-28 11:04:27 +08:00
33 3f379f3cbe Tweak: register MinecraftCapesAPI 2022-07-28 11:03:27 +08:00
33 f50640139a Add: MinecraftCapesAPI 2022-07-28 10:59:54 +08:00
ZekerZhayard 46b8635e10 Support 1.19.1. Remove Vanilla 1.19. (#218) 2022-07-28 09:24:44 +08:00
33 02b24229f3 Update: LittleSkin root url 2022-07-28 08:44:30 +08:00
33 941b421d86 Fix: CDN cache wasn't be updated correctly 2022-07-28 08:43:41 +08:00
33 a67ed507ec Fix: CurseForge metadata json 2022-07-27 20:32:55 +08:00
33 851fa81f31 Tweak: change log level in build 2022-07-27 19:47:12 +08:00
33 5bb16ededa Fix: CurseForge uploading 2022-07-27 19:31:32 +08:00
33 1e5bfcd1e7 Fix: Minecraft version getting logic 2022-07-27 17:23:50 +08:00
ZekerZhayard 1b85fa8ff9 Convert all build scripts to buildSrc. (#216) 2022-07-20 23:11:48 +08:00
33 e1e5319bdb Add: detail.json with detailed downloading information 2022-07-19 22:22:14 +08:00
33 187be47e88 Add: Custom Gradle Plugin in buildSrc 2022-07-19 20:40:53 +08:00
ZekerZhayard b2f8d2cc38 Support 1.19, Remove Vanilla 1.17.1 (#211) 2022-06-09 10:00:10 +08:00
ZekerZhayard 8b641e0227 Support Fabric 22w14a. (#208) 2022-04-14 19:52:11 +08:00
ZekerZhayard c90cea3721 Remove transformers of SkullTileEntity (#207)
* Bump to 14.14

* Remove transformers of SkullTileEntity
2022-04-01 13:56:20 +08:00
33 b0c11d11c6 Fix curseforge and modrinth release 2022-03-17 11:07:25 +08:00
33 c77ac58f6d Release CustomSkinLoader 14.13 2022-03-17 10:41:59 +08:00
ZekerZhayard 16fadc56b4 Support Forge/Fabric/Vanilla 1.18.2. Remove Vanilla 1.18.1. (#206) 2022-03-03 17:31:20 +08:00
33 fc6c43bac9 Fix standalone elytra url (#204) 2022-02-22 17:38:53 +08:00
ZekerZhayard b6fc1610bc Fix skull not loading if not need to judge type. (#201) 2022-01-24 13:58:06 +08:00
ZekerZhayard c7d04976e6 Fix skin type judgement from cache. (#200)
Signed-off-by: ZekerZhayard <[email protected]>
2022-01-09 21:58:59 +08:00
ZekerZhayard 0eaf1960bf Support Fabric/Forge/Vanilla 1.18.1. (#196)
* Support Fabric and Vanilla 1.18.

Signed-off-by: ZekerZhayard <[email protected]>

* Support Fabric and Vanilla 1.18.

Signed-off-by: ZekerZhayard <[email protected]>

* Support Fabric, Forge and Vanilla 1.18.1.

Signed-off-by: ZekerZhayard <[email protected]>
2021-12-11 16:27:36 +08:00
ZekerZhayard cff5846e7f Fix NPE if type is null. (#195)
* Fix NPE if type is null.

Signed-off-by: ZekerZhayard <[email protected]>

* Forge does not support Java 18 for now.

Signed-off-by: ZekerZhayard <[email protected]>
2021-11-28 02:17:38 +08:00
ZekerZhayard c8fb6e216e Finish loader names for Modrinth. (#193)
Signed-off-by: ZekerZhayard <[email protected]>
2021-11-12 19:14:07 +08:00
ZekerZhayard a5d466e0a7 Added support for automatic upload to CurseForge and Modrinth. (#190)
* Added support for automatic upload to CurseForge and Modrinth.

Signed-off-by: ZekerZhayard <[email protected]>

* Fix defining environment variable in circle ci.

Signed-off-by: ZekerZhayard <[email protected]>

* Fix defining environment variable in circle ci.

Signed-off-by: ZekerZhayard <[email protected]>

* Finish fixing defining environment.

Signed-off-by: ZekerZhayard <[email protected]>
2021-11-04 14:55:59 +08:00
Uriel 31fffa5d23 support tlauncher (#188)
* support tlauncher

* it works

* Update README.md

* simplify things

* undo wildcard

* facepalm

* update tlauncher info
2021-11-04 14:52:05 +08:00
ZekerZhayard 7e9f7fa498 Compatible with fabric-loader-0.12.x in development environment. (#189)
Signed-off-by: ZekerZhayard <[email protected]>
2021-10-16 01:41:54 +08:00
ZekerZhayard f51b55be6e Fix compatible with OptiFine 1.17.1. (#186) 2021-10-03 18:06:58 +08:00
ZekerZhayard 584c7b7518 Improve skin loading logic. (#180) 2021-09-24 11:19:06 +08:00
ZekerZhayard 51c8900562 Support Forge 1.17.1. (#177) 2021-07-25 15:48:50 +08:00
ZekerZhayard ab7aebb753 Support Vanilla and Fabric 1.17.1. Remove Vanilla 1.17. (#175) 2021-07-07 00:21:36 +08:00
ZekerZhayard dc5ecfb576 Support Vanilla and Fabric 1.17. Remove Vanilla 1.15.2. (#171)
* Support Fabric 1.17-rc2.

* Support Vanilla and Fabric 1.17. Remove Vanilla 1.15.2.
2021-06-09 14:55:20 +08:00
ZekerZhayard 04899ff676 Support Fabric 1.17-pre1. (#170) 2021-05-29 18:53:27 +08:00
ZekerZhayard 4df8ce38d6 Fix CustomSkinAPIPlus loading incorrectly. Fix unable to complete config with default value. (#168) 2021-05-25 12:55:42 +08:00
ZekerZhayard 3e001c4cdf Fix elytra can not be rendered when the cape doesn't contain elytra. (#160)
* Fix elytra can not be rendered when the cape doesn't contain elytra.

* Fix typo.

* Streamline IFakeThreadDownloadImageData.

* Fix wrong arguments.

* Add compatible with other custom player model mods, such as tr7zw/FirstPersonModel
2021-05-07 17:15:45 +08:00
ZekerZhayard d5dea652ff Induce users to download the pre-release version. (#164)
* Induce users to download the pre-release version.

* Add contact us.

* Some versions of forge-1.13.2 is not compatible because of the strong limitation of CoreMods-0.3.0.
2021-05-07 17:10:01 +08:00
ZekerZhayard 2a4226527d Prevent authlib-injector from modifying urls. (#159) 2021-05-01 22:46:02 +08:00
ZekerZhayard 6c9494970f Enhanced default skin loaders. (#157)
* Enhance ICustomSkinLoaderPlugin.

* Support auto update config file per snapshot. Fix crash with forge 1.14.2 ~ 1.15.2.

* ElyByAPI should check root now.

* Remove unnecessary packages, add some deprecated loaders.

* Reformat imports.

* Move forge stuffs to another commit.

* Fix config updating incorrectly.
2021-04-24 10:33:18 +08:00
ZekerZhayard c84f506af1 Fix crash with forge 1.14.2~1.16.2. Upgrade forge maven. (#158)
* Fix crash with forge 1.14.2~1.16.2. Upgrade forge maven.

* Update forge maven url.
2021-04-23 22:07:53 +08:00
ZekerZhayard a0e31ed883 Change Mixin priority to prevent potential Mixin conflict. (#154) 2021-04-22 11:03:06 +08:00
ZekerZhayard 8befcb32d8 No longer remove any elements in SkinManager. (#151) 2021-03-27 19:32:00 +08:00
ZekerZhayard fb50a3db6d Support Fabric 21w10a. (#148) 2021-03-13 19:47:18 +08:00
ZekerZhayard 4daacd18e8 Make it easier to build the development environment. (Phase 2) (#147)
* Make it easier to build the development environment. (Phase 2)

* Provide sources jar.

* Add development guide.

* Improve development guide.
2021-03-13 19:46:51 +08:00
ZekerZhayard 98681e8251 Remove updateGameProfile transformer. (#143)
* Add an option to control updateGameProfile transformer.

* Remove unnecessary FrameNodes
2021-02-08 11:37:04 +08:00
ZekerZhayard ea5d890992 Support 1.16.5. Remove 1.16.4 Vanilla. (#141) 2021-01-17 01:57:36 +08:00
ZekerZhayard f5135872cc Fix rendering transparent capes for Forge 1.15+. (#140) 2021-01-12 22:59:14 +08:00
ZekerZhayard 5d736dd4b5 Fix sign jar. (#137) 2021-01-04 15:29:34 +08:00
ZekerZhayard 1b2a4dc260 Make it easier to build the development environment. (#133)
* Fix the warning about removing duplicate source roots when open the project with Intellij IDEA.

* Add Gradle wrapper.

* CustomSkinLoader can be loaded in Forge development environment now.

* CustomSkinLoader can be loaded in Fabric development environment now.
2021-01-03 02:53:57 +08:00
ZekerZhayard 855131d1aa Fix DefaultFMLPlatform can't be loaded when other FML platform being used. (#132) 2020-12-20 01:02:07 +08:00
ZekerZhayard 581a2dddea Change the ordinal of FMLLoadingPlugin to fix the crash with BetterFps before Minecraft 1.10.2. (#131)
Clean up codes.
2020-12-15 21:17:10 +08:00
ZekerZhayard a1b52eb7ac Fix version.json parser, compatible with 20w45a. (#128) 2020-11-05 21:54:43 +08:00
Alexander Xia 0ed371fdc1 Remove GitHub maven temporarily 2020-11-05 18:08:26 +08:00
ZekerZhayard ee7e57cf78 Support 1.16.4. Remove 1.16.3 Vanilla. (#127) 2020-11-05 11:53:12 +08:00
ZekerZhayard 90ed224dd8 Fix ResourceLocation characters limitation for Minecraft 1.13+ (#126) 2020-11-05 11:52:49 +08:00
ZekerZhayard a65445e989 Make sure the mod being absent on the other network side does not cause the client to display the server as incompatible after forge-1.13.2-25.0.107. (#124) 2020-11-05 11:52:36 +08:00
ZekerZhayard da79597a16 Fix crash on launch with forge-1.16.3-34.1.27. (#122) 2020-10-27 21:52:29 +08:00
ZekerZhayard 9c6102a813 Fix incorrect method descriptions. (#119) 2020-09-29 21:19:15 +08:00
ZekerZhayard 573c5e4a20 Fabric and vanilla jars can be signed now. (#118) 2020-09-27 16:57:36 +08:00
ZekerZhayard 12441cc379 Fix rendering transparent skins and capes for 19w41a+. (#117)
* Support 1.16.3. Remove 1.16.2 Vanilla.

* Fix rendering transparent skins and capes for 19w41a+.
2020-09-20 21:12:14 +08:00
ZekerZhayard 7df6336b56 Support 1.16.3. Remove 1.16.2 Vanilla. (#116) 2020-09-11 22:55:26 +08:00
ZekerZhayard 2dd69e08da Fix InvalidMixinException before 1.15-snapshot. (#115) 2020-09-02 12:30:25 +08:00
ZekerZhayard 67fbcf5cec Fix crashes caused by incorrect stack frames. (#114) 2020-09-02 12:29:54 +08:00
ZekerZhayard f898831276 Prepare for compatibility with 1.7.10. (#113) 2020-08-29 17:20:44 +08:00
ZekerZhayard 83042f45bd Allow APortingCore to load CustomSkinLoader. (#112) 2020-08-24 11:52:23 +08:00
ZekerZhayard dc6d135699 Add the function to print the System and Java version to the log file. (#111) 2020-08-21 12:51:59 +08:00
Alexander Xia f42496e04c Tweak cache config 2020-08-16 22:18:25 +08:00
Alexander Xia f003d57ddf Tweak thread pool 2020-08-16 21:55:06 +08:00
Alexander Xia b64700b9fb Add forceDisableCache 2020-08-16 21:07:22 +08:00
ZekerZhayard f64af50a07 Improve downloading http textures. (#108) 2020-08-16 19:50:19 +08:00
Alexander XiaandZekerZhayard a8c8edaf20 Support 1.16.2 Fabric, Forge and Vanilla. Remove 1.16.1 Vanilla. (#107)
* Support 1.16.2 Fabric, Forge and Vanilla. Remove 1.16.1 Vanilla.

* Delete build.properties

* Create build.properties

Co-authored-by: ZekerZhayard <[email protected]>
2020-08-13 16:22:16 +08:00
Alexander Xia 5ebee1f1e0 Bump 14.12 2020-07-06 23:01:40 +08:00
Alexander Xia 1eb8db550f Fix custom launchwrapper 2020-07-06 22:57:31 +08:00
Alexander Xia 52a232f982 Update custom launchwrapper version 2020-07-06 22:54:49 +08:00
ZekerZhayard eeebc30b58 Apply custom launchwrapper. (#102) 2020-07-02 01:08:24 +08:00
Evan Goode 46bccadca2 Escape URLs, for usernames with spaces (#100) 2020-07-01 22:47:47 +08:00
ZekerZhayard d7f207177c Apply ModSystemTweaker when another tweaker being applied. (#101) 2020-07-01 22:47:40 +08:00
ZekerZhayard 339e30247a Add "launchermeta" to "latest.json". (#99) 2020-06-30 23:45:37 +08:00
ZekerZhayard ba8d86789d Support Vanilla 1.8.9, 1.12.2, 1.15.2, 1.16.1. (#98)
* Support Vanilla 1.8.9, 1.12.2, 1.15.2, 1.16.1.

* Move vanilla specific version folders to "Vanilla" folder.

* Fix launchwrapper dependency.

* Update profile.

* Move customskinloader.fabric.mixin to customskinloader.mixin
2020-06-29 01:33:53 +08:00
ZekerZhayard a9f19cfc8d Allow users to customize the size of thread pools. (#86)
* Increase compatible Java version to 8.

* Support Forge & Fabric 1.15.2

* Fix lag spike while loading player skull textures.

* Allow users to customize the size of thread pools.

* Use the old scheme about loading skulls to avoid blocking the thread pool when "enableUpdateSkull" is true.

* Fix merge.
2020-06-29 00:57:42 +08:00
ZekerZhayard 8b1400ef0d Support Forge 1.16.x. (#97)
* Support Forge 1.16.x.

* Add Minecraft versions.
2020-06-29 00:56:41 +08:00
Steven Qiu 82c2e80e76 Update LittleSkin's API Root (#96) 2020-06-23 21:16:20 +08:00
ZekerZhayard 8146773354 Fix legacy model auto judge for 1.15.x (#93) 2020-05-21 10:30:45 +08:00
Alexander Xia 5ac6aa1865 Fix legacy model auto judge
Thanks to @ZekerZhayard
2020-05-21 02:37:51 +08:00
Alexander Xia dab8e3dd22 Fix legacy model auto judge 2020-05-20 18:38:31 +08:00
ZekerZhayard fdceb08a2c Fix skull loading lag for Minecraft 1.13.2 or older version. (#91) 2020-05-15 22:51:04 +08:00
ZekerZhayard ad846f37a2 Support Fabric 20w17a. (#90) 2020-05-12 17:07:30 +08:00
ZekerZhayard b8ce13606b Fix SkullTileEntityTransformer. (#88) 2020-04-17 20:19:23 +08:00
Steven Qiu 2fbd3965e0 Update LittleSkin's API root (#87) 2020-04-17 11:21:54 +08:00
Alexander Xia a714670b9a Fix GitHub publish in pull request 2020-03-29 22:57:28 +08:00
Alexander Xia c5460624e3 Fix typo 2020-03-29 19:56:52 +08:00
Alexander Xia 9f63a770c3 Fix concurrent issue 2020-03-26 10:22:20 +08:00
ZekerZhayard 4d234762d2 Fix lag spike while loading player skull textures. (#84)
* Increase compatible Java version to 8.

* Support Forge & Fabric 1.15.2

* Fix lag spike while loading player skull textures.
2020-03-25 11:58:01 +08:00
Alexander Xia 730b565c59 Fix transform script 2020-03-25 10:54:31 +08:00
Alexander Xia 4d12d70bf0 Fix skull loading lag
#79
2020-03-25 10:17:28 +08:00
Alexander Xia 42adcb5b27 Add thread pool to load skull
#79
2020-03-24 11:46:11 +08:00
Alexander Xia 77ddcc8bf5 Add GitHub Packages 2020-03-11 17:26:28 +08:00
Alexander Xia d46adaac5e Tweak transformer to avoid repeated modification 2020-03-04 15:51:54 +08:00
Alexander Xia a6666b53a1 Fix UniSkinAPI elytra 2020-02-22 03:05:38 +08:00
ZekerZhayard 958860ecce Support Forge & Fabric 1.15.2 (#78)
* Increase compatible Java version to 8.

* Support Forge & Fabric 1.15.2
2020-01-24 16:56:26 +08:00
ZekerZhayard 6fab945eb1 Support Forge for Minecraft 1.15.x (#77) 2019-12-18 15:07:46 +08:00
ZekerZhayard e19b9d860f Support Fabric for Minecraft 1.15.x (#75)
* Support Fabric for Minecraft 1.15.x

* Remove unused imports
2019-12-11 18:53:57 +08:00
ZekerZhayard 7adb0f9ef7 Fix PlayerTab for 1.14+ in Fabric. (#72) 2019-12-10 12:52:55 +08:00
Alexander Xia 1bb130bb87 Add latest.json 2019-12-10 03:10:26 +08:00
Alexander Xia 779e25f837 Init CustomSkinLoader earlier 2019-12-09 23:47:29 +08:00
Alexander Xia 3a2d8f9caf Fix PlayerTab in 1.14+ again 2019-12-09 23:20:52 +08:00
Alexander Xia 0c91fb3975 Fix PlayerTab in 1.14+ 2019-12-09 23:10:27 +08:00
Alexander Xia 290cbb63d8 Support UUID in Legacy Loader
Update copyright statement
#65 #66
2019-10-03 15:30:46 +08:00
Alexander Xia 100e661ac5 Add 1.14.4 vanilla 2019-09-20 22:07:58 +08:00
Alexander Xia c490631f2c Fix spelling mistake 2019-09-20 16:33:04 +08:00
Alexander Xia c519d09be4 Fix content type which causes 415 2019-09-20 11:44:07 +08:00
Alexander Xia e5a31ae49e Add custom Yggdrasil api & sessionserver root 2019-09-18 22:50:04 +08:00
Alexander Xia 68615ba724 Add custom Yggdrasil root 2019-09-18 22:15:58 +08:00
Alexander Xia 10e57fe349 Bump 14.11 2019-08-27 17:55:49 +08:00
Alexander Xia 9f70ad0159 Update upload url 2019-06-25 15:24:14 +08:00
ZekerZhayard 0d5538a110 Support for forge 1.14.2 (#59)
* Support for forge 1.14.2

* Delete unnecessary code.
2019-06-25 14:38:40 +08:00
Alexander Xia 27efbbfeb0 Fix addScheduledTask method not found 2019-06-24 20:07:48 +08:00
Alexander Xia 7fad8c602d Add 1.14.2 forge suport 2019-06-24 19:52:02 +08:00
Alexander Xia 29a0952bc4 Fix compatibility with ModLauncher 1.1 (#57) 2019-06-15 17:37:48 +08:00
Alexander Xia b7107b7172 Remove 1.13.2 vanilla 2019-05-24 00:06:35 +08:00
Alexander Xia 2adbc25f69 Fix gradle upload 2019-05-23 23:47:33 +08:00
ZekerZhayard 3bee9281ec Fix remapJar (#55) 2019-05-23 23:35:56 +08:00
ZekerZhayard 917f9f650b Support Fabric for 1.14.1 (#53)
* Fix ClassCastException

* Support Fabric for 1.14.1

* Support Fabric for 1.14.1

* Use mapping file instead of hard code
2019-05-22 23:47:59 +08:00
LionZXY edf6e241e4 Add GlitchlessAPI (#51)
* Add GlitchlessAPI

* Fix build and move GlitchlessSkin to down
2019-05-10 16:20:39 +08:00
Alexander Xia d2c65f00c9 Remove meaningless log 2019-04-26 13:59:08 +08:00
Alexander Xia 95ee345441 Fix 1.14 skin load 2019-04-26 13:56:22 +08:00
Alexander Xia 3ade4867d4 Add 1.14 to settings.gradle 2019-04-26 10:36:20 +08:00
Alexander Xia 2d1951774d Add 1.14 support 2019-04-26 10:34:31 +08:00
ZekerZhayard cc3616a074 Add CSLPluginsLoader (#48)
* Add CSLPluginsLoader

* Remove plugin loader. Add some events.

* Use ServiceLoader to load plugins

* Remove PluginClassLoader.
2019-03-08 13:38:44 +08:00
xfl03 42c48c5c2e Bump 14.10a 2019-03-05 19:33:09 +08:00
xfl03 030daf12a2 Fix 1.8 forge support 2019-03-04 20:12:13 +08:00
xfl03 88763d64ef Bump 14.10 2019-03-03 12:20:28 +08:00
xfl03 4f2b5edf84 Fix incorrect response code judgement 2019-03-03 11:53:48 +08:00
xfl03 cbe07b9003 Fix http redirect to https 2019-03-03 11:34:54 +08:00
xfl03 b2867a0dbf Add support for 1.13.2 forge 2019-03-02 12:26:53 +08:00
xfl03 65dacd8527 Fix javascript cannot expand 2019-03-01 20:31:23 +08:00
xfl03 d2d425e96e Remove 1.13 & 1.13.1 in settings.gradle 2019-03-01 20:10:50 +08:00
xfl03 0762e3e339 Remove support for vanilla 1.13 & 1.13.1 2019-03-01 20:08:22 +08:00
xfl03 4cb1e348bb Try to support 1.13 forge 2019-03-01 14:59:02 +08:00
Alexander Xia 7bbfd19bfd Fix no content cache 2019-02-06 00:39:17 +08:00
Alexander Xia be8b80bd55 Tweak CircleCI Docker Image 2019-01-05 00:20:22 +08:00
Alexander Xia 47de6d3a89 Add workaround for #42 2019-01-05 00:12:42 +08:00
Alexander Xia f78a3b2565 Add disable cape feature 2018-11-26 15:16:07 +08:00
Alexander Xia 016249c6ca Fix version display again 2018-11-25 02:33:12 +08:00
Alexander Xia 860edd2e1a Fix version display 2018-11-25 02:13:55 +08:00
Alexander Xia 3e6e444857 Fix gradle script buid again 2018-11-25 02:08:54 +08:00
Alexander Xia d67b7c6296 Fix gradle script buid again 2018-11-25 02:04:36 +08:00
Alexander Xia 94f6044c9a Fix gradle script build error 2018-11-25 01:53:28 +08:00
Alexander Xia 6b3531964e Tweak version json name 2018-11-25 01:44:06 +08:00
Alexander Xia fbd06f147a Modify gradle script 2018-11-24 01:38:49 +08:00
Alexander Xia e3020dad00 Add Upload Version json to COS 2018-11-23 03:23:17 +08:00
Alexander Xia 49fb976a2c Fix COS upload path 2018-11-23 02:48:19 +08:00
Alexander Xia 78bc4b5f7e Try to upload file to COS 2018-11-23 02:43:30 +08:00
Alexander Xia 7a3dc4f9c2 Support for 1.13.2 2018-11-02 14:48:07 +08:00
Alexander Xia 2087f7bb94 Tweak: Change Profile.json mirror 2018-09-23 23:44:25 +08:00
Alexander Xia e95edb16ac Add: Vanilla Support for 1.13.1 2018-09-23 23:00:34 +08:00
Alexander Xia 3b07b5ccca Update config version checker
Update config output
Add enableCape in config
2018-09-02 15:57:08 +08:00
xfl03 a3fb3cd770 Fix Build 2018-08-26 07:16:37 +08:00
xfl03 b7b59c0b85 Support ModLauncher 2018-08-26 07:04:25 +08:00
Alexander Xia db6b54732e Update MCP map to stable 2018-08-22 03:42:50 +08:00
Alexander Xia 09e3b81552 Fix path for ForgePlugin.log 2018-08-20 19:23:47 +08:00
Alexander Xia 2f494d295e Update Forge Version 2018-08-13 05:15:32 +08:00
Alexander Xia e8e3a72ae7 Add Fingerprint Violation 2018-08-13 05:11:47 +08:00
Alexander Xia ca8bd4e83d Add Profile.json for vanilla edition
Remove CustomSkinAPIPlusPrivacy
Fix typo in ReadMe
Update mcp map
2018-08-11 07:34:13 +08:00
Alexander Xia d789119c8f Get Ready for Forge 1.13 2018-07-26 20:50:41 +08:00
Alexander Xia bfd1b41ecc Update ReadMe
Thanks for @HeartyYF
2018-07-26 13:19:33 +08:00
Alexander Xia 5807acb34a Bump 14.9 2018-07-25 21:16:59 +08:00
Alexander Xia f319d535ae Merge branch '1.13-dev' into csl-14 2018-07-25 21:08:10 +08:00
Alexander Xia f669d095b6 Add Support for 1.13!
Thanks for MinecraftForge/MCPConfig.
2018-07-25 21:06:16 +08:00
Alexander Xia ca8b0ba185 Add FakeImage 2018-07-25 15:55:03 +08:00
Alexander Xia 7acef4d987 Fix Support for Java9
Add ElyBy in default load list
2018-07-20 23:23:37 +08:00
Alexander Xia 79404f659c Merge pull request #36 from andylizi/pr-replace
Replace the unnecessary `replaceAll` calls with `replace`
2018-07-13 22:36:31 +08:00
andylizi 85c86ff375 Replace the unnecessary replaceAll calls with replace 2018-07-13 19:48:02 +08:00
Alexander Xia f4030701ee Fix Legacy Texture cannot refresh in cache 2018-07-12 15:18:13 +08:00
Alexander Xia a36eca2a53 Add ElyByAPI 2018-07-09 19:53:35 +08:00
Alexander Xia 6ffdf2aafb Fix Spectator Menu totally 2018-07-02 00:15:03 +08:00
Alexander Xia fba9f7ca28 Fix head in Spectator Menu 2018-07-01 23:25:57 +08:00
Alexander Xia 2d157e3d5b Fix head is not loaded first time open Spectator Menu 2018-07-01 23:15:06 +08:00
Alexander Xia 055aef17db Fix ForgePlugin log 2018-06-25 00:56:47 +08:00
Alexander Xia 622e834d26 Make Code Better 2018-06-25 00:34:32 +08:00
Alexander Xia 469c8b62a9 Fix Noname skull load 2018-06-24 23:07:51 +08:00
Alexander Xia 1558ec819a Fix Crash in Spectator Menu 2018-06-24 22:59:46 +08:00
Alexander Xia 883e7b45fc Add skin model auto judge 2018-05-18 21:06:28 +08:00
Alexander Xia f30d3319b0 Reuse Vanilla Code 2018-05-06 01:10:55 +08:00
Alexander Xia 58276a7a0c Reuse Vanilla Code 2018-05-06 01:09:48 +08:00
Alexander Xia 883fb39380 Update Gradle Script
Fix local jsonAPI bug
https://minecraft.curseforge.com/projects/customskinloader?comment=10
2018-05-05 23:07:20 +08:00
Alexander Xia 1358a99f51 Merge pull request #35 from tnqzh123/csl-14
Update LittleSkin's API root
2018-04-10 23:39:31 +08:00
LittleStudio-Little_Qiu 47ea01dc39 Update API root 2018-04-10 23:29:45 +08:00
LittleStudio-Little_Qiu ee36f2f42a Update README.md
change link
2018-04-10 23:28:27 +08:00
Alexander Xia 5868a39adb Bump 14.8 2018-03-13 16:48:31 +08:00
Alexander Xia f7e000cb82 Add Cache for MojangAPI 2018-02-12 15:02:12 +08:00
Alexander Xia c40bb38e20 Remove Tab 2018-02-12 12:20:28 +08:00
Alexander Xia 4449ccdd45 Fix Spectator and TabIcon for non-Forge 2018-02-11 15:36:40 +08:00
Alexander Xia 67e56957e7 Fix Spectator Menu 2018-02-11 12:44:41 +08:00
Alexander Xia ea432f2405 Add more debug log 2018-02-10 21:23:58 +08:00
Alexander Xia eee978fc83 Try to fix SpectatorMenu
Forge only
2018-02-10 20:21:26 +08:00
Alexander Xia 9698d4098a Add CurseForge Url 2018-02-07 19:36:02 +08:00
Alexander Xia 3f779c9028 Try CircleCI 2 2018-02-06 07:41:18 +08:00
Alexander Xia 3945599fb4 Try CircleCI 2018-02-06 06:03:54 +08:00
Alexander Xia b50e6a934f Use both UUID and Name as credential 2018-02-03 18:40:04 +08:00
Alexander Xia 3dbf812f50 Update readme 2017-08-13 22:06:47 +08:00
Alexander Xia 2bb8da3ff9 Using Forge Gradle 2.3 2017-08-13 21:11:29 +08:00
Alexander Xia 1371e7685e Bump 14.7
Remove vanilla edition before 1.12
2017-08-13 21:06:39 +08:00
Alexander Xia a49fea706d Support 1.12.1 2017-08-13 20:48:18 +08:00
xfl03 32547481e7 Add forceLoadAllTexture Function 2017-07-12 20:00:06 +08:00
xfl03 faff465ace Fix auto cache clean 2017-07-09 21:40:04 +08:00
xfl03 e487ab1147 Fix #27 2017-07-02 18:19:18 +08:00
xfl03 e26bc85f46 Fix Readme & Remove useless loader 2017-06-18 21:53:29 +08:00
xfl03 7dc2c45600 Fix PlayerTab 2017-06-18 21:31:25 +08:00
xfl03 d6281881a5 Update Skin Site 2017-06-11 17:14:39 +08:00
xfl03 7cdd582ed4 Try CircleCI 2017-06-11 15:02:01 +08:00
xfl03 129b50a6c2 Add 1.11.2 1.12 and Remove1.11 2017-06-11 13:05:21 +08:00
xfl03 eaf9c5f48f Update 2017-01-01 01:33:13 +08:00
xfl03 b7e5c59ecf Fix desc 2017-01-01 01:19:09 +08:00
xfl03 05e98d6eee Fix 2017-01-01 01:09:22 +08:00
xfl03 f4b7393b44 Rewrite ASM 2017-01-01 01:06:40 +08:00
xfl03 898a4fe7d9 May fix forge 2016-12-31 23:17:31 +08:00
xfl03 5cbfb87d08 Remove some debug output 2016-12-31 23:05:55 +08:00
xfl03 8cdabb762d Add debug output 2016-12-31 22:41:36 +08:00
xfl03 4369ddf43e Continue 2016-12-31 22:20:29 +08:00
xfl03 8a1dca0dd4 May fix forge 2016-12-31 21:54:28 +08:00
xfl03 b533d33f71 Update Build Script 2016-12-29 16:51:51 +08:00
xfl03 bfaa97ba04 May finished fake skin manager 2016-12-29 16:44:16 +08:00
xfl03 c86790371d Finished FakeSkinManager 2016-12-25 17:05:30 +08:00
xfl03 ed4bf8dbb3 Fix Transformer for forge 2016-12-04 15:19:08 +08:00
xfl03 b97f838d59 Forge Test 2016-12-04 14:57:25 +08:00
xfl03 79440740ee Forge Test 2016-12-04 14:50:36 +08:00
xfl03 481b0d9df9 Remove 1.7.10 2016-12-04 14:38:17 +08:00
xfl03 cdd42d60e3 Fix strange bug 2016-11-27 13:32:25 +08:00
xfl03 76bf0b5fdf Fix 2016-11-20 12:57:42 +08:00
xfl03 f1c1f2f39a BuildInfo Test 2016-11-20 12:49:08 +08:00
xfl03 3c4b1cc4e2 Fix 2016-11-20 12:25:57 +08:00
xfl03 e2258b1540 Fix 2016-11-20 12:18:50 +08:00
xfl03 d286e419c5 Bump 14.6 2016-11-20 11:27:33 +08:00
xfl03 28eb5eb376 Fix again 2016-11-19 20:37:34 +08:00
xfl03 4d34720d1c Fix 2016-11-19 20:35:53 +08:00
xfl03 b9456d599f Fix 1.10 2016-11-19 20:33:59 +08:00
xfl03 0233b7e077 1.11 Test 2016-11-19 20:31:01 +08:00
xfl03 a917e67871 Support Dynamic Skull Texture Index
Local Texture Supported for Static Skull
Fix network bug
Try to use some forge
2016-11-19 19:35:17 +08:00
xfl03 ea49e7489a Update CustomSkinAPIPlus 2016-11-12 19:33:01 +08:00
xfl03 bcf5dc4cea RFC-2396 URL encode
Remove unused imports
Added ElfSkin for test
2016-11-11 19:48:42 +08:00
xfl03 7e522011e7 Do more for cache 2016-11-06 13:36:26 +08:00
xfl03 bdead01ef9 Added Http Cache
Use new http request platform
2016-11-06 12:00:36 +08:00
xfl03 87a40fc3c7 Fix auto clean 2016-10-18 22:12:06 +08:00
xfl03 0d60fb328a Fix 1.8 2016-10-18 21:59:42 +08:00
xfl03 2f141bd565 Cache Auto Clean 2016-10-18 21:48:07 +08:00
xfl03 a7f52365ca Update Build Script 2016-10-01 13:51:48 +08:00
xfl03 10ec669589 Update build script 2016-10-01 13:46:30 +08:00
xfl03 f09fe38831 Bump 14.5 2016-10-01 13:28:04 +08:00
xfl03 953748f2ae Added Custom Error Message for JsonAPI 2016-09-25 15:13:46 +08:00
xfl03 e63858d561 Fix Dynamic Skull 2016-09-25 11:45:52 +08:00
xfl03 b2d6532709 Fix Dynamic Skull Bug 2016-09-25 11:08:55 +08:00
xfl03 d2db775a17 Update Blessing Skin Url 2016-09-25 10:31:59 +08:00
xfl03 7cf42be31c Auto create local skin folder 2016-09-24 20:47:08 +08:00
xfl03 9a85d18f22 Load Elytra Standalone 2016-09-24 19:08:01 +08:00
xfl03 5d366d1d8c Refix texture parsing bug 2016-09-14 21:50:28 +08:00
xfl03 8257d6dfd0 Fix mistake 2016-09-10 21:26:52 +08:00
xfl03 1c973e633b Gzip Encoding 2016-09-10 21:21:49 +08:00
xfl03 933244a492 Fix build script 2016-09-10 21:11:37 +08:00
xfl03 e719e9cd4e Custom Map 2016-09-10 21:08:07 +08:00
xfl03 25c864b11b Dynamic Skull Test 2016-09-10 21:00:53 +08:00
xfl03 d60d9d4c36 Fix regex 2016-08-29 10:43:40 +08:00
xfl03 a2698b5b95 Fix mistake 2016-08-29 09:22:48 +08:00
xfl03 b14be41789 Fix loading bug 2016-08-29 09:19:38 +08:00
xfl03 cf4487f4d3 Fix mistake 2016-08-28 21:00:57 +08:00
xfl03 23f301c819 Bump 14.4 2016-08-28 20:55:54 +08:00
xfl03 958023382d Default loader list 2016-08-28 19:40:18 +08:00
xfl03 037ef06379 Fix mistake 2016-08-28 19:25:54 +08:00
xfl03 ad8c356c46 Do the same thing for 1.7.10 2016-08-28 19:21:49 +08:00
xfl03 c9181c411f Try to fix skin texture parsing bug 2016-08-28 19:08:59 +08:00
Alexander Xia 164632c7be Update 1.7.10 build script 2016-08-23 21:07:48 +08:00
xfl03 7af9df3177 Try to build 1.7.10 2016-08-21 16:20:27 +08:00
xfl03 37960965b4 Added Extra List 2016-08-21 11:26:00 +08:00
xfl03 10c0536dbe Update README 2016-08-20 23:48:46 +08:00
xfl03 aaf23aa88a Remove Build 1.7.10 2016-08-20 22:13:03 +08:00
xfl03 8bbb9b1ee9 Fixed mistake 2016-08-20 21:11:10 +08:00
xfl03 8c1cfa330e Build all version with Gradle 2016-08-20 21:07:25 +08:00
xfl03 ff83d7f709 Fixed mistake 2016-08-20 20:17:19 +08:00
xfl03 e05ee65d19 Remove maven mirror 2016-08-20 19:39:13 +08:00
xfl03 9a39e38ba1 Build with Gradle 2016-08-20 19:36:44 +08:00
xfl03 7a7b9418d3 Update MCP Map 2016-08-14 01:23:51 +08:00
xfl03 b08122913b Use UTF-8 Charset 2016-08-14 00:12:45 +08:00
xfl03 bbc355365a Get ready for new JsonAPI 2016-08-09 17:23:27 +08:00
xfl03 8bccab4f0b Remove some useless code 2016-08-05 17:00:03 +08:00
xfl03 1d88a98040 Fixed ClassTransformer bug 2016-08-01 23:58:29 +08:00
xfl03 7314a08268 Update README for Revision 14 2016-07-31 22:26:20 +08:00
xfl03 5c12463c94 Revision 14
Local skin supported
Local profile cache supported
Better profile cache
Swifter official profile loading
Better skull loading
Fix legacy loading bug
Fix bug while using ClassTransformer
2016-07-31 22:00:46 +08:00
Alexander Xia b34a5b3343 Fix 1.10 HD texture rendering bug 2016-07-16 20:18:50 +08:00
Alexander Xia 7654dc583d Added custom useragent
Faster mod loading
Backup broken json
Added a new skin site
2016-07-04 14:10:44 +08:00
Alexander Xia 4e78285bbe Fixed mistake 2016-06-30 23:40:10 +08:00
Alexander Xia fe8c556e35 Fixed crash when skull without name and texture 2016-06-25 17:00:48 +08:00
Alexander Xia ffbe66193d Added 1.10 forge support 2016-06-24 20:29:55 +08:00
Alexander Xia fccacc6f98 Changed to stable mcp 2016-06-18 20:45:51 +08:00
Alexander Xia e27c3ecd68 Added 1.10 support 2016-06-09 01:12:08 +08:00
Alexander Xia 11d7d53684 Reformat +1 2016-06-06 13:53:45 +08:00
Alexander Xia fa97359eeb Reformat 2016-06-06 13:48:59 +08:00
Alexander Xia 1540ecfa8d Refix incorrect skull texture 2016-06-06 13:44:55 +08:00
Alexander Xia b27654dfe9 Fixed mistake in 1.8 2016-06-05 22:24:02 +08:00
Alexander Xia db10725c31 Added 1.9.4 forge support 2016-06-05 19:18:09 +08:00
Alexander Xia 946d6901ea Fix incorrect skull texture.
Closes #16
2016-06-05 17:57:26 +08:00
Alexander Xia 3054cc6a13 Added 1.9.4 support 2016-05-14 00:13:16 +08:00
Alexander Xia 8f73eed29d Fix data folder url decoding bug 2016-05-07 19:41:32 +08:00
Alexander Xia a16c4a7b44 Fixed data folder 2016-05-07 13:11:08 +08:00
Alexander Xia fcb24315e5 Fixed tweaker log 2016-05-02 01:01:18 +08:00
Alexander Xia 47f198b337 Fixed data folder bug 2016-04-30 22:12:26 +08:00
Alexander Xia a38aa9687c Fixed crash when skull texture not found [1.7.10] 2016-04-10 19:21:28 +08:00
Alexander Xia 0857a80ca8 Tweaked Skull Texture Load 2016-04-04 13:13:18 +08:00
Alexander Xia 704f3a4102 Added 1.9.2 Support 2016-04-04 00:35:12 +08:00
Alexander Xia 4ebce88594 Fixed crash when skull texture not found
Added switch for cache
2016-04-03 16:29:00 +08:00
Alexander Xia 8fa3a567ac Fixed mistake 2016-04-03 14:56:06 +08:00
Alexander Xia 5a29416ee9 Added Skull Support 2016-04-03 13:55:33 +08:00
Alexander Xia 4142609635 Added Config File Updater
Added Transparent Skin Support
Tweaked UniSkinAPI Log
Added Config for Skull and Transparent Skin
Added a new skin site
2016-04-03 13:01:06 +08:00
Alexander Xia 1dbfa30ba8 Added Skull Support[1.9]
Added Profile Cache
Fixed Default Profile Not Used
Close #6
2016-04-03 01:14:33 +08:00
Alexander Xia 199c5d674e 1.9 forge support 2016-03-19 22:21:23 +08:00
Alexander Xia bebbbb0050 Fix 1.8-1.8.9 texture binding mistake
Support new UniSkinApi
2016-03-13 00:17:11 +08:00
Alexander Xia 03388e3f85 Fix 1.9 bwn NullPointer 2016-03-12 19:14:53 +08:00
Alexander Xia 103cd4548d Fix a mistake 2016-03-05 11:10:39 +08:00
Alexander Xia 87aa82647a Make CSL 1.9 support java6 2016-03-05 10:59:18 +08:00
Alexander Xia adbde5334d Fix 1.7.10 authlib21 bug
Fix #6 in all versions
2016-03-05 10:37:10 +08:00
Alexander Xia 6d44d738a8 Fix #6 2016-03-05 10:27:13 +08:00
Alexander Xia 5f0c3b419c Support 1.9 2016-03-05 10:04:28 +08:00
Alexander Xia 4fe495d7fa Get ready for 1.9
1.9-pre4 HD Fix
2016-02-28 12:25:13 +08:00
Alexander Xia ae4eaeb4ba 1.9-pre4 Support 2016-02-28 12:04:54 +08:00
Alexander Xia f9a36acf8f New 1.8.8 Support 2016-02-27 21:43:46 +08:00
Alexander Xia c6ea90867e Fix CustomSkinAPI Bug 2016-02-27 18:37:37 +08:00
Alexander Xia e584c112df New 1.8 Support 2016-02-27 18:04:25 +08:00
Alexander Xia f59e58a15a Fix rename bug 2016-02-27 16:37:05 +08:00
Alexander Xia be06bbb2ab Fix Readme *3 2016-02-27 15:28:47 +08:00
Alexander Xia 7cbc4ac79e Fix readme *2 2016-02-27 15:27:58 +08:00
Alexander Xia ce4d0b550a Fix Readme 2016-02-27 15:26:56 +08:00
Alexander Xia 17c6bfad5f Remake CustomSkinLoader
Support 1.7.10 first
2016-02-27 15:22:35 +08:00
242 changed files with 11357 additions and 7225 deletions

No files matched your search

+8
View File
@@ -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
+126
View File
@@ -0,0 +1,126 @@
name: Report Bug
description: Report a bug and help us improve CustomSkinLoader
labels: [ bug ]
title: "[Bug] "
body:
- type: markdown
attributes:
value: |
Here is the Report Bug issue for CustomSkinLoader
With a red asterisk for the mandatory items
Please keep the work order content neat and tidy, do not paste the contents of the log file directly onto the work order, it will look very messy and unattractive work orders
- type: textarea
id: description
attributes:
label: Describe the bug
description: |
A clear and concise description of what the issue is.
Provide as much information as possible, videos, crash reports, etc.
DO NOT PASTE A CRASH REPORT HERE!!!
validations:
required: true
- type: textarea
id: reproducing
attributes:
label: Steps to reproduce
description: How do you trigger this bug?
render: bash
value: |
1.
2.
3.
validations:
required: true
- type: input
id: crash-report
attributes:
label: Link to crash-report if applicable
description: |
The files are in the folder `<minecraft-directory>/crash-reports`
[Generate URL](https://mclo.gs)
placeholder: "Ex: https://mclo.gs/xxxxxx"
- type: input
id: csl-log
validations:
required: true
attributes:
label: Link to CustomSkinLoader.log if applicable
description: |
The path to the file is `<minecraft-directory>/CustomSkinLoader/CustomSkinLoader.log`.
[Generate URL](https://mclo.gs)
placeholder: "Ex: https://mclo.gs/xxxxxx"
- type: input
id: latest-log
attributes:
label: Link to latest.log if applicable
description: |
The path to the file is `<minecraft-directory>/logs/latest.log`.
[Generate URL](https://mclo.gs)
placeholder: "Ex: https://mclo.gs/xxxxxx"
- type: input
id: forge-log
attributes:
label: "[Only Forge User] Link to Forge Log if applicable"
description: |
The path to the file is `<minecraft-directory>/logs/debug.log` or `<minecraft-directory>/logs/fml-client-latest.log`.
if your mod loader isn't `Forge`, URL can set empty
[Generate URL](https://mclo.gs)
placeholder: "Ex: https://mclo.gs/xxxxxx"
- type: input
id: mod-version
attributes:
label: Mod Version
placeholder: "Ex: 14.16"
validations:
required: true
- type: input
id: mc-version
attributes:
label: Minecraft Version
placeholder: "Ex: 1.19.4"
validations:
required: true
- type: input
id: mc-launcher-version
attributes:
label: Minecraft Launcher Name and Version
placeholder: "Ex: HMCL v3.5.4.232"
description: |
If you don't know the version of the game, you can just fill in the name of the game launcher
- type: dropdown
id: loader-type
attributes:
label: Mod Loader
options:
- Quilt
- Fabric
- Forge
- <without mod loader>
validations:
required: true
- type: dropdown
id: operating-systems
attributes:
label: Operating System
options:
- Windows
- Linux
- macOS
- Other
validations:
required: true
- type: checkboxes
id: prerequisites
attributes:
label: Before submitting a bug report
options:
- label: |
This bug wasn't already reported (I have searched bug reports on GitHub).
required: true
- label: |
This is a valid bug (I am able to reproduce this on the latest dev build).
required: true
- label: |
This problem is triggered in the latest version of the mod (if not the latest please upgrade the mod first)
required: true
+127
View File
@@ -0,0 +1,127 @@
name: 提交问题
description: 报告问题以帮助我们改进CustomSkinLoader
labels: [ bug ]
title: "[Bug] "
body:
- type: markdown
attributes:
value: |
你好,这里是 `CustomSkinLoader`
标注红色星号的为必填项
以及,保持工单干净整洁,不要直接将日志内容粘贴到工单上,比如粘贴到描述内是不行的
- type: textarea
id: description
attributes:
label: 描述问题
description: |
简单的描述问题, 并提供类似图片、视频,以更好的报告错误(如果可以)
!注意:请不要在这里放日志文件或崩溃报告文件的内容
validations:
required: true
- type: textarea
id: reproducing
attributes:
label: 复现步骤
description: 请问你是如何触发这个问题的
render: bash
value: |
1.
2.
3.
validations:
required: true
- type: input
id: crash-report
attributes:
label: 崩溃报告查看地址
description: |
在游戏目录下的 `crash-reports` 文件夹下,里面找最近的报告生成时间
客户端若无崩溃则直接填写 `客户端无崩溃`
[生成连接](https://mclo.gs)
placeholder: "示例: https://mclo.gs/xxxxxx"
- type: input
id: csl-log
validations:
required: true
attributes:
label: CustomSkinLoader.log 查看地址
description: |
文件路径:`<游戏路径>/CustomSkinLoader/CustomSkinLoader.log`.
[生成连接](https://mclo.gs)
placeholder: "示例: https://mclo.gs/xxxxxx"
- type: input
id: latest-log
attributes:
label: latest.log 查看地址
description: |
文件路径:`<游戏路径>/logs/latest.log`.
[生成连接](https://mclo.gs)
placeholder: "示例: https://mclo.gs/xxxxxx"
- type: input
id: forge-log
attributes:
label: "[仅Forge用户] Forge Log 查看地址"
description: |
文件路径:`<游戏路径>/logs/debug.log` 或者 `<游戏路径>/logs/fml-client-latest.log`.
若没有使用 `Forge` 加载器的,可以不填写
[生成连接](https://mclo.gs)
placeholder: "示例: https://mclo.gs/xxxxxx"
- type: input
id: mod-version
attributes:
label: 模组版本
placeholder: "示例: 14.16"
validations:
required: true
- type: input
id: mc-version
attributes:
label: Minecraft游戏版本
placeholder: "示例: 1.19.4"
validations:
required: true
- type: input
id: mc-launcher-version
attributes:
label: Minecraft启动器 名称 及 版本
placeholder: "示例: HMCL v3.5.4.232"
description: |
若不知道游戏版本 可以只填写游戏启动器的名称
validations:
required: true
- type: dropdown
id: loader-type
attributes:
label: 模组加载器
options:
- Quilt
- Fabric
- Forge
- 不使用加载器
validations:
required: true
- type: dropdown
id: operating-systems
attributes:
label: 操作系统
options:
- Windows
- Linux
- macOS
- 其他操作系统
validations:
required: true
- type: checkboxes
id: prerequisites
attributes:
label: 在提交错误报告之前,有没有做到...
options:
- label: |
先尝试搜索issues里面, 查看并确认打开或关闭的工单, 是否搜索不到
required: true
- label: |
确认你的模组版本是最新的开发版本,且文件下载正确,没有出现类似forge下载了fabric版的这类基础问题
required: true
- label: |
这个问题是在最新的mod版本触发(若不是最新的请先升级mod)
required: true
@@ -0,0 +1,22 @@
name: Suggestion
description: Suggest a new feature or change for CustomSkinLoader.
labels: [ enhancement ]
body:
- type: textarea
id: description
attributes:
label: Describe the feature
description: A clear and concise description of what the feature/change is.
validations:
required: true
- type: checkboxes
id: prerequisites
attributes:
label: Before submitting a suggestion
options:
- label: |
This feature doesn't already exist in the client. (I have checked every module and their settings on the **latest dev build**)
required: true
- label: |
This wasn't already suggested. (I have searched suggestions on GitHub and read the FAQ)
required: true
@@ -0,0 +1,22 @@
name: 反馈或建议
description: 给CustomSkinLoader这个模组提个建议
labels: [ enhancement ]
body:
- type: textarea
id: description
attributes:
label: 描述一下
description: 简单描述一下该功能/变化是什么。
validations:
required: true
- type: checkboxes
id: prerequisites
attributes:
label: 在提交反馈或建议之前,请先确认...
options:
- label: |
你要提交的反馈或者建议不存在于本模组的最新开发版下.
required: true
- label: |
以及在issues或者Wiki内搜索过, 并且无结果
required: true
+14
View File
@@ -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
+14
View File
@@ -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
+230
View File
@@ -0,0 +1,230 @@
name: Common
on:
workflow_call:
inputs:
type:
required: true
type: string
publish-task:
required: false
type: string
is-snapshot:
required: false
type: boolean
default: true
jobs:
build-common:
name: Build
runs-on: ubuntu-latest
environment: Build
steps:
-
name: Checkout
uses: actions/checkout@v4
-
name: Set up JDK
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '8'
cache: 'gradle'
-
name: Build
env:
KEY_PASS: ${{ secrets.KEY_PASS }}
IS_SNAPSHOT: ${{ inputs.is-snapshot }}
run: |
echo Snapshot: $IS_SNAPSHOT
export GIT_COMMIT_DESC=$(git log --format=%B -n 1 $GITHUB_SHA)
./gradlew clean build --stacktrace
-
uses: actions/upload-artifact@v4
name: Publish to Github Artifact
with:
name: CustomSkinLoader-${{ inputs.type }}-${{ github.run_number }}
path: build/libs
Upload:
if: inputs.publish-task
needs: build-common
continue-on-error: true
environment: Build
strategy:
matrix:
website: [CurseForge_Modrinth]
modtype: [Fabric,ForgeV1,ForgeV2,ForgeV3]
include:
-
website: ObjectStorage
modtype: All
# -
# website: GitHub-Release
# modtype: All
-
website: GitHub-PreRelease
modtype: All
name: ${{ matrix.website }} (${{ matrix.modtype}})
runs-on: ubuntu-latest
steps:
-
name: Checkout Git Repository
uses: actions/checkout@v4
-
uses: actions/download-artifact@v4
name: Download Artifact Zips
with:
path: build
-
name: Preparation Folder
run: |
rsync -avz "build/$(ls build|grep "CustomSkinLoader")/" build/libs/
ls -lh build
-
if: ${{ matrix.modtype != 'All' }}
name: Checking and setting the environment
id: cslenv
run: |
output="$(ls build/libs | grep -v "sources")"
case "${{ matrix.modtype }}" in
"ForgeV1")
modloader="Forge"
path=`echo "${{ matrix.modtype }}" | sed 's#V#/V#'`
;;
"ForgeV2" | "ForgeV3")
modloader=$(cat <<EOF
Forge
NeoForge
EOF
)
path=`echo "${{ matrix.modtype }}" | sed 's#V#/V#'`
;;
"Fabric")
modloader=$(cat <<EOF
Fabric
Quilt
EOF
)
path="${{ matrix.modtype }}"
;;
*)
echo "Unsupported modtype: ${{ matrix.modtype }}"
exit 1
;;
esac
echo "path=$path" >> $GITHUB_OUTPUT
echo "modloader="$modloader"" >> $GITHUB_OUTPUT
echo "filename=$(echo "$output"|grep $(echo ${{ matrix.modtype }}|sed "s#-##") )" >> $GITHUB_OUTPUT
echo "version=$(grep "version=" build.properties | grep -v "#" | sed "s/version=//")" >> $GITHUB_OUTPUT
echo "edition=$(echo ${{ matrix.modtype }} | sed "s/-//")" >> $GITHUB_OUTPUT
echo "minecraft_vers<<EOF" >> $GITHUB_OUTPUT
grep "dependencies=" "$path"/build.properties | grep -v "#" | awk -F '|' '{print $2}' | sed 's#\;\\##' | sed "s/,/\n/g" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
echo "java_vers<<EOF" >> $GITHUB_OUTPUT
grep "java_full_versions=" "$path"/build.properties | grep -v "#" | sed "s/java_full_versions=//" | sed "s/,/\n/g" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
-
if: startsWith(matrix.website, 'GitHub-')
name: Settings more strings to Environment
id: cslenv-github
run: |
#展开
echo "buildtime=$(TZ=Asia/Shanghai date "+%Y.%m.%d %H:%M")" >> $GITHUB_OUTPUT
echo "pathlist="$(find build/libs -type f|grep -v "sources"|grep -v "json")"" >> $GITHUB_OUTPUT
-
if: ${{ matrix.website == 'GitHub-PreRelease' && startsWith(github.ref, 'refs/heads') }}
name: "[GitHub Pre-Release] Delete"
uses: 8Mi-Tech/delete-release-assets-action@main
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
tag: CI-Build
deleteOnlyFromDrafts: false
-
if: ${{ matrix.website == 'GitHub-PreRelease' && startsWith(github.ref, 'refs/heads') }}
name: 【GitHub Pre-Release】 Set CI-Build Text
run: |
cat > build/ci-build.md << 'EOF'
Build Time / 构建时间 : ${{ steps.cslenv-github.outputs.buildtime }}
自动同步分支 ${{ github.ref_name }} 的代码,以保持最新
Synchronize ${{ github.ref_name }} branch code updates, keeping only the latest version
<br>
[如何使用 / How to uses?](https://github.com/xfl03/MCCustomSkinLoader/wiki/How-to-Use)
EOF
-
if: ${{ matrix.website == 'GitHub-PreRelease' && startsWith(github.ref, 'refs/heads') }}
name: "[GitHub Pre-Release] Upload Tag"
uses: richardsimko/update-tag@v1
with:
tag_name: CI-Build
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
-
if: ${{ matrix.website == 'GitHub-PreRelease' && startsWith(github.ref, 'refs/heads') }}
name: "[GitHub Pre-Release] Publish"
uses: softprops/action-gh-release@v2
with:
token: ${{ secrets.GITHUB_TOKEN }}
name: CustomSkinLoader CI-Build
tag_name: CI-Build
prerelease: true
body_path: build/ci-build.md
files: build/libs/*
#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 == 'ObjectStorage' }}
name: "[ObjectStorage] Publish"
env:
COS_BUCKET: ${{ secrets.COS_BUCKET }}
COS_SECRET_ID: ${{ secrets.COS_SECRET_ID }}
COS_SECRET_KEY: ${{ secrets.COS_SECRET_KEY }}
R2_BASE_URL: ${{ secrets.R2_BASE_URL }}
R2_BUCKET: ${{ secrets.R2_BUCKET }}
R2_SECRET_ID: ${{ secrets.R2_SECRET_ID }}
R2_SECRET_KEY: ${{ secrets.R2_SECRET_KEY }}
IS_SNAPSHOT: ${{ inputs.is-snapshot }}
run: |
export GIT_COMMIT_DESC=$(git log --format=%B -n 1 $GITHUB_SHA)
./gradlew ${{ inputs.publish-task }} --info --stacktrace
# ./gradlew publishGprPublicationToGitHubPackagesRepository
-
if: ${{ matrix.website == 'CurseForge_Modrinth' && inputs.type == 'Release' }}
name: "[CurseForge & Modrinth] Publish"
uses: Kir-Antipov/[email protected]
with:
modrinth-id: idMHQ4n2
modrinth-featured: true
modrinth-unfeature-mode: subset
modrinth-token: ${{ secrets.MODRINTH_TOKEN }}
curseforge-id: 286924
curseforge-token: ${{ secrets.CURSEFORGE_API_KEY }}
name: CustomSkinLoader_${{ steps.cslenv.outputs.edition }}_${{ steps.cslenv.outputs.version }}
version: ${{ steps.cslenv.outputs.version }}-${{ steps.cslenv.outputs.edition }}
version-type: release
loaders: ${{ steps.cslenv.outputs.modloader }}
game-versions: |
${{ steps.cslenv.outputs.minecraft_vers }}
game-version-filter: releases
java: |
${{ steps.cslenv.outputs.java_vers }}
retry-attempts: 2
retry-delay: 10000
fail-mode: fail
files: |
build/libs/${{ steps.cslenv.outputs.filename }}
+17
View File
@@ -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
+14
View File
@@ -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
View File
@@ -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;
}
}
@@ -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;
}
}
@@ -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
View File
@@ -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);
}
}
-80
View File
@@ -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;
}
}
-41
View File
@@ -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;
}
}
}
-14
View File
@@ -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
-189
View File
@@ -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
View File
@@ -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;
}
}
-82
View File
@@ -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;
}
}
-37
View File
@@ -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;
}
}
}
-14
View File
@@ -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
-189
View File
@@ -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
View File
@@ -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
View File
@@ -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;
}
}
-37
View File
@@ -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;
}
}
}
-14
View File
@@ -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
-189
View File
@@ -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
View File
@@ -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
View File
@@ -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;
}
}
-37
View File
@@ -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;
}
}
}
-14
View File
@@ -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
-189
View File
@@ -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
View File
@@ -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
View File
@@ -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;
}
}
-38
View File
@@ -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;
}
}
}
-14
View File
@@ -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
-189
View File
@@ -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
View File
@@ -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
View File
@@ -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;
}
}
-38
View File
@@ -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;
}
}
}
-14
View File
@@ -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
-189
View File
@@ -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;
}
}
@@ -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
View File
@@ -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 `15.0-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 `15.0-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 `15.0-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 `15.0-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:15.0-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:15.0-SNAPSHOT-00") // Only required for MinecraftForge 1.8 ~ 1.16.5
implementation fg.deobf("mods:CustomSkinLoader_ForgeActive:15.0-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:15.0-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.
-3
View File
@@ -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.
+5
View File
@@ -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,7 @@
package com.mojang.authlib;
public enum SignatureState {
UNSIGNED,
INVALID,
SIGNED
}
@@ -0,0 +1,9 @@
package com.mojang.authlib.minecraft;
import com.mojang.authlib.SignatureState;
public class MinecraftProfileTextures {
public MinecraftProfileTextures(MinecraftProfileTexture skin, MinecraftProfileTexture cape, MinecraftProfileTexture elytra, SignatureState signatureState) {
}
}
@@ -0,0 +1,251 @@
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.Function;
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();
public 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 Object loadProfileLazily(GameProfile gameProfile, Function<UserProfile, ?> function) {
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.");
return function.apply(new UserProfile());
}
String tempName = Thread.currentThread().getName();
Thread.currentThread().setName(username); // Change Thread Name
if (profileCache.isLoading(credential)) {
profileCache.putLoader(credential, function);
Thread.currentThread().setName(tempName);
return function.apply(new UserProfile());
}
Object result = function.apply(loadProfile(gameProfile));
Thread.currentThread().setName(tempName);
Function<UserProfile, ?> func = profileCache.getLastLoader(credential);
if (func != null) {
result = loadProfileLazily(gameProfile, func);
}
return result;
}
//For User Skin
public static UserProfile 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 profile == null ? new UserProfile() : 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,259 @@
package customskinloader.config;
import java.io.File;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Comparator;
import java.util.List;
import java.util.Objects;
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.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 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.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,249 @@
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.FakeImage;
import net.minecraft.client.Minecraft;
import net.minecraft.util.ResourceLocation;
public class FakeCapeBuffer extends FakeSkinBuffer {
private static final ResourceLocation TEXTURE_ELYTRA = new ResourceLocation("minecraft", "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 String type = null;
@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);
}
}
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;
}
// 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,54 @@
package customskinloader.fake;
import java.io.File;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import com.mojang.authlib.minecraft.MinecraftProfileTexture;
import customskinloader.utils.HttpTextureUtil;
public class FakeMinecraftProfileTexture extends MinecraftProfileTexture {
private final static Map<String, String> MODEL_CACHE = new ConcurrentHashMap<>();
private final HttpTextureUtil.HttpTextureInfo info;
private final Map<String, String> metadata;
public FakeMinecraftProfileTexture(String url, Map<String, String> metadata) {
super(url, metadata);
this.info = HttpTextureUtil.toHttpTextureInfo(url);
this.metadata = metadata;
}
@Override
public String getUrl() {
return this.info.url;
}
@Override
public String getMetadata(final String key) {
String value = super.getMetadata(key);
if ("model".equals(key) && "auto".equals(value)) {
String model = MODEL_CACHE.get(this.getHash());
if (model != null) {
return model;
}
}
return value;
}
public void setModel(String model) {
if (this.metadata != null) {
MODEL_CACHE.put(this.getHash(), model);
this.metadata.put("model", model);
}
}
@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,242 @@
package customskinloader.fake;
import java.awt.image.BufferedImage;
import java.io.File;
import java.nio.file.Path;
import java.util.Map;
import java.util.function.Supplier;
import com.google.common.cache.CacheLoader;
import com.google.common.cache.LoadingCache;
import com.google.common.collect.ImmutableList;
import com.mojang.authlib.GameProfile;
import com.mojang.authlib.SignatureState;
import com.mojang.authlib.minecraft.MinecraftProfileTexture;
import com.mojang.authlib.minecraft.MinecraftProfileTextures;
import com.mojang.authlib.minecraft.MinecraftSessionService;
import com.mojang.authlib.properties.Property;
import customskinloader.CustomSkinLoader;
import customskinloader.fake.itf.FakeInterfaceManager;
import customskinloader.loader.MojangAPILoader;
import customskinloader.profile.ModelManager0;
import customskinloader.profile.UserProfile;
import customskinloader.utils.HttpTextureUtil;
import customskinloader.utils.TextureUtil;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.IImageBuffer;
import net.minecraft.client.renderer.texture.NativeImage;
import net.minecraft.client.resources.SkinManager;
public class FakeSkinManager {
/**
* Invoked from {@link SkinManager(net.minecraft.client.renderer.texture.TextureManager, File, MinecraftSessionService)}
*/
public static void setSkinCacheDir(File skinCacheDirectory) {
HttpTextureUtil.defaultCacheDir = skinCacheDirectory;
}
/**
* Invoked from {@link SkinManager(net.minecraft.client.renderer.texture.TextureManager, Path, MinecraftSessionService, java.util.concurrent.Executor)}
*/
public static void setSkinCacheDir(Path skinCacheDirectory) {
HttpTextureUtil.defaultCacheDir = skinCacheDirectory.toFile();
}
private static CacheLoader<Object, ?> cacheLoader;
/**
* Invoked from {@link SkinManager(net.minecraft.client.renderer.texture.TextureManager, Path, MinecraftSessionService, java.util.concurrent.Executor)}
*/
public static CacheLoader<Object, ?> setCacheLoader(CacheLoader<Object, ?> loader) {
return cacheLoader = loader;
}
/**
* Invoked from {@link SkinManager#getOrLoad(GameProfile)}
*/
public static Property createProperty(Property property) {
return property == null ? new Property(null, null) : new Property(TextureUtil.AuthlibField.PROPERTY_NAME.get(property), TextureUtil.AuthlibField.PROPERTY_VALUE.get(property), TextureUtil.AuthlibField.PROPERTY_SIGNATURE.get(property));
}
/**
* Invoked from {@link SkinManager#getOrLoad(GameProfile)}
*/
public static Object loadCache(LoadingCache<?, ?> loadingCache, Object cacheKey, GameProfile profile) throws Exception {
return cacheLoader.load(FakeCacheKey.wrapCacheKey(cacheKey, profile));
}
/**
* Invoked from {@link SkinManager#loadSkin(MinecraftProfileTexture, MinecraftProfileTexture.Type, SkinManager.SkinAvailableCallback)}
*/
public static Object[] createThreadDownloadImageData(ImmutableList<Object> list, MinecraftProfileTexture profileTexture, MinecraftProfileTexture.Type textureType) {
Object[] params = list.toArray();
if (profileTexture instanceof FakeMinecraftProfileTexture && params.length > 1) {
FakeMinecraftProfileTexture fakeProfileTexture = (FakeMinecraftProfileTexture) profileTexture;
params[0] = fakeProfileTexture.getCacheFile();
if (params[params.length - 2] instanceof Boolean) {
params[params.length - 2] = true;
}
params[params.length - 1] = new BaseBuffer((Runnable) params[params.length - 1], textureType, fakeProfileTexture);
}
return params;
}
private final static String KEY = "CustomSkinLoaderInfo";
/**
* Invoked from {@link SkinManager#loadProfileTextures(GameProfile, SkinManager.SkinAvailableCallback, boolean)}
*/
public static void loadProfileTextures(Runnable runnable, GameProfile profile) {
CustomSkinLoader.loadProfileTextures(() -> CustomSkinLoader.loadProfileLazily(profile, p -> {
profile.getProperties().putAll(KEY, p.toProperties());
runnable.run();
return null;
}));
}
/**
* 23w31a+
* Invoked from net.minecraft.client.resources.SkinManager$1#load(net.minecraft.client.resources.SkinManager$CacheKey)
*/
public static Object[] loadProfileTextures(ImmutableList<Object> list, Object cacheKey) {
Object[] params = list.toArray();
GameProfile profile = FakeCacheKey.unwrapCacheKey(cacheKey);
if (!profile.getProperties().containsKey(SKULL_KEY)) {
final Supplier<?> supplier = (Supplier<?>) params[0];
params[0] = (Supplier<?>) () -> CustomSkinLoader.loadProfileLazily(profile, p -> {
profile.getProperties().putAll(KEY, p.toProperties());
FakeCacheKey.wrapCacheKey(cacheKey, profile);
return supplier.get();
});
params[1] = CustomSkinLoader.THREAD_POOL;
} else {
params[1] = Minecraft.getMinecraft();
}
return params;
}
/**
* Invoked from {@link SkinManager#lambda$loadProfileTextures$1(GameProfile, boolean, SkinAvailableCallback)}
*/
public static Map<MinecraftProfileTexture.Type, MinecraftProfileTexture> getUserProfile(MinecraftSessionService sessionService, GameProfile profile, boolean requireSecure) {
return ModelManager0.fromUserProfile(UserProfile.fromProperties(profile.getProperties().values()));
}
/**
* 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);
}
}
}
private final static String SKULL_KEY = "CSL$IsSkull";
/**
* 23w31a+
* Invoked from {@link SkinManager#getInsecureSkin(GameProfile)}
*/
public static void setSkullType(GameProfile profile) {
profile.getProperties().removeAll(SKULL_KEY);
profile.getProperties().put(SKULL_KEY, new Property(SKULL_KEY, "true"));
}
public static Map<MinecraftProfileTexture.Type, MinecraftProfileTexture> loadSkinFromCache(GameProfile profile) {
return CustomSkinLoader.loadProfileFromCache(profile);
}
/**
* 23w31a ~ 23w41a
* Invoked from net.minecraft.client.resources.SkinManager$1#lambda$load$0(GameProfile)
*/
public static Map<MinecraftProfileTexture.Type, MinecraftProfileTexture> loadSkinFromCache(MinecraftSessionService sessionService, GameProfile profile, boolean requireSecure) {
if (profile.getProperties().containsKey(SKULL_KEY)) {
profile.getProperties().removeAll(SKULL_KEY);
return CustomSkinLoader.loadProfileFromCache(profile);
} else {
return getUserProfile(sessionService, profile, requireSecure);
}
}
/**
* 23w42a+
* Invoked from net.minecraft.client.resources.SkinManager$1#lambda$load$0(SkinManager.CacheKey, MinecraftSessionService)
*/
public static Object loadSkinFromCache(MinecraftSessionService sessionService, Property property) {
return FakeCacheKey.createMinecraftProfileTextures(loadSkinFromCache(sessionService, FakeCacheKey.unwrapProperty(property), false));
}
private static boolean shouldJudgeType(MinecraftProfileTexture texture) {
return texture != null && "auto".equals(texture.getMetadata("model"));
}
private static class BaseBuffer implements IImageBuffer {
private IImageBuffer buffer;
private final Runnable callback;
private final FakeMinecraftProfileTexture texture;
public BaseBuffer(Runnable callback, MinecraftProfileTexture.Type type, FakeMinecraftProfileTexture texture) {
this.callback = callback;
this.texture = texture;
switch (type) {
case SKIN: this.buffer = new FakeSkinBuffer(); break;
case CAPE: this.buffer = new FakeCapeBuffer(); break;
}
}
@Override
public NativeImage func_195786_a(NativeImage image) {
return buffer instanceof FakeSkinBuffer ? ((FakeSkinBuffer) buffer).func_195786_a(image) : image;
}
@Override
public BufferedImage parseUserSkin(BufferedImage image) {
return buffer instanceof FakeSkinBuffer ? ((FakeSkinBuffer) buffer).parseUserSkin(image) : image;
}
@Override
public void skinAvailable() {
if (buffer != null) {
buffer.skinAvailable();
if (shouldJudgeType(texture) && buffer instanceof FakeSkinBuffer) {
//Auto judge skin type
String type = ((FakeSkinBuffer) buffer).judgeType();
texture.setModel(type);
}
}
if (this.callback != null) {
this.callback.run();
}
}
}
public static class FakeCacheKey {
public static Object wrapCacheKey(Object cacheKey, GameProfile profile) {
if (FakeInterfaceManager.SkinManagerCacheKey_profile(cacheKey) == null) { // 23w42a+
TextureUtil.AuthlibField.PROPERTY_SIGNATURE.set(FakeInterfaceManager.SkinManagerCacheKey_packedTextures(cacheKey), MojangAPILoader.GSON.toJson(profile, GameProfile.class));
}
return cacheKey;
}
public static GameProfile unwrapCacheKey(Object cacheKey) {
if (FakeInterfaceManager.SkinManagerCacheKey_profile(cacheKey) != null) {
return FakeInterfaceManager.SkinManagerCacheKey_profile(cacheKey); // 23w31a ~ 23w41a
} else {
return unwrapProperty(FakeInterfaceManager.SkinManagerCacheKey_packedTextures(cacheKey)); // 23w42a+
}
}
public static GameProfile unwrapProperty(Property property) {
return MojangAPILoader.GSON.fromJson((String) TextureUtil.AuthlibField.PROPERTY_SIGNATURE.get(property), GameProfile.class); // 23w42a+
}
public static Object createMinecraftProfileTextures(Map<MinecraftProfileTexture.Type, MinecraftProfileTexture> textures) {
return new MinecraftProfileTextures(textures.get(MinecraftProfileTexture.Type.SKIN), textures.get(MinecraftProfileTexture.Type.CAPE), textures.get(MinecraftProfileTexture.Type.ELYTRA), SignatureState.SIGNED);
}
}
}
@@ -0,0 +1,41 @@
package customskinloader.fake.itf;
import java.io.IOException;
import java.io.InputStream;
import java.util.Optional;
import com.mojang.authlib.GameProfile;
import com.mojang.authlib.properties.Property;
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(Object minecraft) {
return (IResourceManager) ((IFakeMinecraft) minecraft).func_195551_G();
}
public static int NativeImage_getPixel(Object nativeImage, int x, int y) {
return ((IFakeNativeImage) nativeImage).getPixel(x, y);
}
public static void NativeImage_setPixel(Object nativeImage, int x, int y, int color) {
((IFakeNativeImage) nativeImage).setPixel(x, y, color);
}
public static GameProfile SkinManagerCacheKey_profile(Object skinManagerCacheKey) {
return ((IFakeSkinManagerCacheKey) skinManagerCacheKey).profile();
}
public static Property SkinManagerCacheKey_packedTextures(Object skinManagerCacheKey) {
return ((IFakeSkinManagerCacheKey) skinManagerCacheKey).packedTextures();
}
}
@@ -0,0 +1,10 @@
package customskinloader.fake.itf;
import net.minecraft.client.renderer.IImageBuffer;
public interface IFakeIImageBuffer extends Runnable {
@Override
default void run() {
((IImageBuffer) this).skinAvailable();
}
}
@@ -0,0 +1,22 @@
package customskinloader.fake.itf;
import java.io.InputStream;
import net.minecraft.client.resources.IResource;
/** {@link 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,13 @@
package customskinloader.fake.itf;
import net.minecraft.client.renderer.texture.NativeImage;
public interface IFakeNativeImage {
default int getPixel(int x, int y) {
return ((NativeImage) this).func_195709_a(x, y);
}
default void setPixel(int x, int y, int color) {
((NativeImage) this).func_195700_a(x, y, color);
}
}
@@ -0,0 +1,12 @@
package customskinloader.fake.itf;
import com.mojang.authlib.GameProfile;
import com.mojang.authlib.properties.Property;
public interface IFakeSkinManagerCacheKey {
default GameProfile profile() {
return null;
}
Property packedTextures();
}
@@ -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,62 @@
package customskinloader.fake.texture;
import java.io.InputStream;
import customskinloader.fake.itf.FakeInterfaceManager;
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 FakeInterfaceManager.NativeImage_getPixel(image, x, y);
}
public void setRGBA(int x, int y, int rgba) {
FakeInterfaceManager.NativeImage_setPixel(image, 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}&nothirdparty", 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,221 @@
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 customskinloader.utils.TextureUtil;
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;
}
public static final Gson GSON = new GsonBuilder().registerTypeAdapter(UUID.class, new UUIDTypeAdapter()).registerTypeAdapter(PropertyMap.class, new PropertyMap.Serializer()).create();
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)
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() : TextureUtil.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/" + TextureUtil.fromUUID(profile.getId())).setCacheTime(90));
if (StringUtils.isEmpty(responce.content)) {
return profile;
}
MinecraftProfilePropertiesResponse propertiesResponce = GSON.fromJson(responce.content, MinecraftProfilePropertiesResponse.class);
GameProfile newGameProfile = new GameProfile(TextureUtil.AuthlibField.MINECRAFT_PROFILE_PROPERTIES_RESPONSE_ID.get(propertiesResponce), TextureUtil.AuthlibField.MINECRAFT_PROFILE_PROPERTIES_RESPONSE_NAME.get(propertiesResponce));
newGameProfile.getProperties().putAll(TextureUtil.AuthlibField.MINECRAFT_PROFILE_PROPERTIES_RESPONSE_PROPERTIES.get(propertiesResponce));
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 = TextureUtil.AuthlibField.PROPERTY_VALUE.get(textureProperty);
if (StringUtils.isBlank(value)) {
return Maps.newHashMap();
}
String json = new String(Base64.decodeBase64(value), StandardCharsets.UTF_8);
MinecraftTexturesPayload result = GSON.fromJson(json, MinecraftTexturesPayload.class);
if (result == null || TextureUtil.AuthlibField.MINECRAFT_TEXTURES_PAYLOAD_TEXTURES.get(result) == null) {
return Maps.newHashMap();
}
return TextureUtil.AuthlibField.MINECRAFT_TEXTURES_PAYLOAD_TEXTURES.get(result);
}
@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;
}
}
Loaded 100 of 242 files, more files were not shown because too many files have changed in this diff. Show more