mirror of
https://github.com/Suiranoil/SkinRestorer.git
synced 2026-01-16 04:42:12 +00:00
Compare commits
234 Commits
v2.2.0-1.2
...
1.20-multi
| Author | SHA1 | Date | |
|---|---|---|---|
|
748e9911c0
|
|||
|
63a8ff18b5
|
|||
|
41793a904f
|
|||
|
3c2269ca6e
|
|||
|
4cf35048b0
|
|||
|
965af68461
|
|||
|
8fba8a997e
|
|||
|
a0d8f3d518
|
|||
|
aa3cb3df09
|
|||
|
0524b5dab8
|
|||
|
301428147d
|
|||
|
2e655ce1f3
|
|||
|
7dcd1d4e81
|
|||
|
1aa606038e
|
|||
|
e832e02fd4
|
|||
|
ffd2a0dba7
|
|||
|
76e801c944
|
|||
|
da754aa830
|
|||
|
69a561f679
|
|||
|
b5bed1c441
|
|||
|
f36390a3d5
|
|||
|
9c9f02667c
|
|||
|
abcb37fc6b
|
|||
|
b3b524c53a
|
|||
|
e6b2dcb4eb
|
|||
|
5f8a868e5c
|
|||
|
fce13237f9
|
|||
|
c987d48738
|
|||
|
583205febc
|
|||
|
fb7a4d11e9
|
|||
|
1d8472e35c
|
|||
|
f604ac2c8b
|
|||
|
8d4c2e9f83
|
|||
|
84a06898a2
|
|||
|
11ecf88eb2
|
|||
|
9298cad91d
|
|||
|
acd1f888c0
|
|||
|
c192cdce7e
|
|||
|
d54cb48697
|
|||
|
6df0cf4fd2
|
|||
|
2cec50afae
|
|||
|
01a045541c
|
|||
|
5bab96e269
|
|||
|
a0b557be51
|
|||
|
7fad7de710
|
|||
|
ede68a9543
|
|||
|
cfd6dcd181
|
|||
|
06e5a2f5b7
|
|||
|
05ef681621
|
|||
|
daf0310072
|
|||
|
a3bd44af89
|
|||
|
8af1dd8f12
|
|||
|
1c7f97551d
|
|||
|
a8cc81e570
|
|||
|
6ce3484824
|
|||
|
b518305028
|
|||
|
1a9e9d9ab7
|
|||
|
23eec5d7ac
|
|||
|
b38a296efa
|
|||
|
d54e30749f
|
|||
|
e5134cdd71
|
|||
|
220f9c6ac3
|
|||
|
742b4cb4d0
|
|||
|
1bacee4b22
|
|||
|
4a87bd43ca
|
|||
|
96ea077004
|
|||
|
91eead3d1f
|
|||
|
2ea4d3f3e7
|
|||
|
e65501e620
|
|||
|
9063254e12
|
|||
|
6076325c87
|
|||
|
64aaf906b0
|
|||
|
fb644adbc3
|
|||
|
b4e76576c2
|
|||
|
556ecdc039
|
|||
|
1b8a6c2f5d
|
|||
|
4cc12e23dc
|
|||
|
28db1ee84c
|
|||
|
b2ec095dd0
|
|||
|
a308fba699
|
|||
|
119e91e222
|
|||
|
ba6dc5a1e5
|
|||
|
b0333b4b7f
|
|||
|
21f00231af
|
|||
|
6f5b291008
|
|||
|
df58fe8c89
|
|||
|
2325b3b35c
|
|||
|
ad6d64e8d4
|
|||
|
07b4887f60
|
|||
|
30d21c9424
|
|||
|
1c51796409
|
|||
|
f2280fef96
|
|||
|
984d220a22
|
|||
|
02613e40fd
|
|||
|
dc0d69f0f0
|
|||
|
53e0740e43
|
|||
|
1b6afd5d6e
|
|||
|
c1bfa5350e
|
|||
|
b1c562f45d
|
|||
|
aeab757b05
|
|||
|
ef247f1ad3
|
|||
|
1eff73e9b3
|
|||
|
7e05f1eec9
|
|||
|
81d05fe991
|
|||
|
757d46b231
|
|||
|
3b15f7b341
|
|||
|
38a2fd7214
|
|||
|
c07497cddb
|
|||
|
418397d3d2
|
|||
|
7af35cda9f
|
|||
|
3d92617e47
|
|||
|
f357e6c985
|
|||
|
e4c9e1b3cd
|
|||
|
3ef3318ed3
|
|||
|
56655bca36
|
|||
|
90ca995907
|
|||
|
0823ed6669
|
|||
|
3fff2eb920
|
|||
|
50a49b33a2
|
|||
|
8de7f3a16f
|
|||
|
5b384c32d6
|
|||
|
7fb647b3ba
|
|||
|
907566e12b
|
|||
|
8a730c7c61
|
|||
|
0feba3f4b2
|
|||
|
fcd76d9a87
|
|||
|
8119a08c80
|
|||
|
6c159d6aa2
|
|||
|
1a5f4ab2b0
|
|||
|
a2c4da3c6e
|
|||
|
04e781d36f
|
|||
|
4b30b8b53d
|
|||
|
0921cf70bf
|
|||
|
760ac65ab3
|
|||
|
2e7a9edc20
|
|||
|
8457e6f4ab
|
|||
|
66a9c1fbbf
|
|||
|
e3754cda90
|
|||
|
a458f3456c
|
|||
|
b297c6addb
|
|||
|
daedf692a1
|
|||
|
c2afd37fae
|
|||
|
e0b1de4ae2
|
|||
|
100282d527
|
|||
|
4b48227eea
|
|||
|
d351f7497c
|
|||
|
a2279bc66e
|
|||
|
33586d02a3
|
|||
|
5f6d1204fc
|
|||
|
4abcb3ba71
|
|||
|
a655e0c2ce
|
|||
|
a7298a1909
|
|||
|
e1a58f4246
|
|||
|
496c8d8078
|
|||
|
0070d3ab1c
|
|||
|
7ec929335b
|
|||
|
5da06ee325
|
|||
|
100c1d5974
|
|||
|
26d4a5ef51
|
|||
|
ced2801d1c
|
|||
|
41b6a5d030
|
|||
|
10534b01a7
|
|||
|
4a1ce7885c
|
|||
|
d471eb2e5f
|
|||
|
138350545a
|
|||
|
7ab9f722e8
|
|||
|
5c2a50fd98
|
|||
|
088ad089ed
|
|||
|
6fbc53e38b
|
|||
|
364ca540be
|
|||
|
cec5bac608
|
|||
|
d1c0317fa1
|
|||
|
2a3c3d0f54
|
|||
|
040d26cb33
|
|||
|
ef79818d5c
|
|||
|
0d4a0034b8
|
|||
|
c70f780ec2
|
|||
|
ecdfff5dc7
|
|||
|
16ffeea4f3
|
|||
|
694e5ebfef
|
|||
|
c8a4674e0c
|
|||
|
d374c80659
|
|||
|
d85942041b
|
|||
|
1cafc91935
|
|||
|
5d28269b94
|
|||
|
2293fc2399
|
|||
|
3971f2efbf
|
|||
|
516601a899
|
|||
|
2e3b2649b3
|
|||
|
07d620ae2f
|
|||
|
ad2177848c
|
|||
|
8136354af1
|
|||
|
fee25d2d04
|
|||
|
33926b15e1
|
|||
|
226d3f7bcb
|
|||
|
c81adc7320
|
|||
|
583e59f9d8
|
|||
|
8081e443b9
|
|||
|
61e1ada760
|
|||
|
|
d04a3beecf | ||
|
|
89b06fcfc7 | ||
|
|
d7fffdab1b | ||
|
|
9e175ddabb | ||
|
|
74a571b62c | ||
|
|
8ae29eae89 | ||
|
|
9f0fac4b2a | ||
|
|
e68aa90953 | ||
|
048860182d
|
|||
|
143e95d7f2
|
|||
|
34de47e13e
|
|||
|
08e7f1792b
|
|||
|
6a7f5f2096
|
|||
|
4d6d4faafd
|
|||
|
823b2ea3f6
|
|||
|
a63b6c3867
|
|||
|
dfe6d7af42
|
|||
|
2b8de22f70
|
|||
|
ebdbee480f
|
|||
|
e43ebdd11e
|
|||
|
33e5889657
|
|||
|
3b88b5f5d5
|
|||
|
18ec6e87f8
|
|||
|
4a3da6fd6c
|
|||
|
f6523c0d99
|
|||
|
4c803cb369
|
|||
|
f1ee3b4542
|
|||
|
14f51e9224
|
|||
|
bcb8cd930d
|
|||
|
8b26d81ae4
|
|||
|
1d1aa94644
|
|||
|
9c9907d0ba
|
|||
|
5ddde27915
|
|||
|
bfd8843b44
|
|||
|
cfdfee11b3
|
90
.github/ISSUE_TEMPLATE/bug_report.yaml
vendored
Normal file
90
.github/ISSUE_TEMPLATE/bug_report.yaml
vendored
Normal file
@@ -0,0 +1,90 @@
|
|||||||
|
name: Bug Report
|
||||||
|
description: Report a bug encountered with SkinRestorer
|
||||||
|
title: "[Bug]: "
|
||||||
|
labels: ["bug"]
|
||||||
|
body:
|
||||||
|
- type: markdown
|
||||||
|
attributes:
|
||||||
|
value: |
|
||||||
|
🐛 **Before submitting:**
|
||||||
|
- Ensure you're using the latest mod version
|
||||||
|
- Ensure this bug is reproducible consistently
|
||||||
|
- Check existing issues for duplicates
|
||||||
|
|
||||||
|
- type: input
|
||||||
|
id: mod-version
|
||||||
|
attributes:
|
||||||
|
label: SkinRestorer Version
|
||||||
|
description: Exact version of the mod
|
||||||
|
placeholder: e.g., 2.2.1
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
|
||||||
|
- type: input
|
||||||
|
id: minecraft-version
|
||||||
|
attributes:
|
||||||
|
label: Minecraft Version
|
||||||
|
description: Full Minecraft version
|
||||||
|
placeholder: e.g., 1.21.4
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
|
||||||
|
- type: input
|
||||||
|
id: loader-version
|
||||||
|
attributes:
|
||||||
|
label: Mod Loader & Version
|
||||||
|
description: Fabric/Quilt/Forge/NeoForge version
|
||||||
|
placeholder: e.g., Fabric 0.15.7
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
|
||||||
|
- type: input
|
||||||
|
id: java-version
|
||||||
|
attributes:
|
||||||
|
label: Java Version
|
||||||
|
placeholder: e.g. 17, 21
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
|
||||||
|
- type: textarea
|
||||||
|
id: description
|
||||||
|
attributes:
|
||||||
|
label: Bug Description
|
||||||
|
description: What happened vs what you expected to happen
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
|
||||||
|
- type: textarea
|
||||||
|
id: steps
|
||||||
|
attributes:
|
||||||
|
label: Reproduction Steps
|
||||||
|
description: Provide step-by-step instructions or a video showing how to reproduce the issue.
|
||||||
|
placeholder: |
|
||||||
|
1.
|
||||||
|
2.
|
||||||
|
3.
|
||||||
|
Or a video demonstrating the issue.
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
|
||||||
|
- type: textarea
|
||||||
|
id: logs
|
||||||
|
attributes:
|
||||||
|
label: Relevant Logs
|
||||||
|
description: |
|
||||||
|
Please provide any relevant logs, especially error logs from your server console or `latest.log` file.
|
||||||
|
**Important**: Paste the FULL log content. Use a service like [mclo.gs](https://mclo.gs/).
|
||||||
|
render: shell
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
|
||||||
|
- type: checkboxes
|
||||||
|
id: confirmations
|
||||||
|
attributes:
|
||||||
|
label: Confirmations
|
||||||
|
options:
|
||||||
|
- label: I've checked for existing issues
|
||||||
|
required: true
|
||||||
|
- label: This bug is reproducible consistently
|
||||||
|
required: true
|
||||||
|
- label: I've tested without other mods
|
||||||
1
.github/ISSUE_TEMPLATE/config.yml
vendored
Normal file
1
.github/ISSUE_TEMPLATE/config.yml
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
blank_issues_enabled: true
|
||||||
52
.github/ISSUE_TEMPLATE/feature_request.yaml
vendored
Normal file
52
.github/ISSUE_TEMPLATE/feature_request.yaml
vendored
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
name: Feature Request
|
||||||
|
description: Suggest a new feature for SkinRestorer
|
||||||
|
title: "[Feature Request]: "
|
||||||
|
labels: ["enhancement"]
|
||||||
|
body:
|
||||||
|
- type: markdown
|
||||||
|
attributes:
|
||||||
|
value: |
|
||||||
|
💡 **Before submitting:**
|
||||||
|
- Check existing feature requests for duplicates
|
||||||
|
- Be clear and concise
|
||||||
|
- Explain the *why* and the *how*
|
||||||
|
|
||||||
|
- type: textarea
|
||||||
|
id: description
|
||||||
|
attributes:
|
||||||
|
label: Feature Description
|
||||||
|
description: Detailed description of the feature
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
|
||||||
|
- type: textarea
|
||||||
|
id: motivation
|
||||||
|
attributes:
|
||||||
|
label: Motivation
|
||||||
|
description: Why is this feature needed? What problem does it solve?
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
|
||||||
|
- type: textarea
|
||||||
|
id: use-cases
|
||||||
|
attributes:
|
||||||
|
label: Use Cases
|
||||||
|
description: How would this feature be used and who would benefit?
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
|
||||||
|
- type: textarea
|
||||||
|
id: implementation-ideas
|
||||||
|
attributes:
|
||||||
|
label: Implementation Ideas (Optional)
|
||||||
|
description: Any thoughts on how it could be implemented?
|
||||||
|
validations:
|
||||||
|
required: false
|
||||||
|
|
||||||
|
- type: checkboxes
|
||||||
|
id: confirmations
|
||||||
|
attributes:
|
||||||
|
label: Confirmations
|
||||||
|
options:
|
||||||
|
- label: I've checked for existing feature requests
|
||||||
|
required: true
|
||||||
1
.gitignore
vendored
1
.gitignore
vendored
@@ -30,3 +30,4 @@ bin/
|
|||||||
|
|
||||||
.architectury-transformer/
|
.architectury-transformer/
|
||||||
run/
|
run/
|
||||||
|
scripts/
|
||||||
|
|||||||
62
CHANGELOG.md
62
CHANGELOG.md
@@ -4,7 +4,67 @@ All notable changes to this project will be documented in this file.
|
|||||||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
||||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||||
|
|
||||||
## [2.2.0] - 2024-11-28
|
## [2.5.0] - 2026-01-14
|
||||||
|
### Added
|
||||||
|
- Added collection skin provider (allows assigning random skins from a predefined set)
|
||||||
|
- Added `forceFirstJoinSkinFetch` config option to force skin fetch on first join even if player already has a skin
|
||||||
|
|
||||||
|
## [2.4.3] - 2025-07-25
|
||||||
|
### Fixed
|
||||||
|
- Fixed crash on client when loading player head skin (fixes [#63](https://github.com/Suiranoil/SkinRestorer/issues/63) and [#64](https://github.com/Suiranoil/SkinRestorer/issues/64))
|
||||||
|
- Fixed server freeze when loading player head skin
|
||||||
|
|
||||||
|
## [2.4.2] - 2025-07-13
|
||||||
|
### Fixed
|
||||||
|
- Fix crash when head profile name is null (fixes [#60](https://github.com/Suiranoil/SkinRestorer/issues/60) and [#61](https://github.com/Suiranoil/SkinRestorer/issues/61))
|
||||||
|
|
||||||
|
## [2.4.1] - 2025-07-09
|
||||||
|
### Changed
|
||||||
|
- Log full exception and argument when unable to fetch/set skin
|
||||||
|
### Fixed
|
||||||
|
- Fixed mojang provider using offline uuids when unable to fetch actual uuid resulting in `no profile with uuid` error
|
||||||
|
|
||||||
|
## [2.4.0] - 2025-07-05
|
||||||
|
### Fixed
|
||||||
|
- Added support for player heads
|
||||||
|
|
||||||
|
## [2.3.5] - 2025-06-21
|
||||||
|
### Fixed
|
||||||
|
- Fix mod not loading on client
|
||||||
|
|
||||||
|
## [2.3.4] - 2025-06-19
|
||||||
|
### Added
|
||||||
|
- Added support for minecraft 1.21.6
|
||||||
|
|
||||||
|
## [2.3.3] - 2025-06-01
|
||||||
|
### Fixed
|
||||||
|
- Fixed forge mixin crash (closes [#54](https://github.com/Suiranoil/SkinRestorer/issues/53))
|
||||||
|
### Removed
|
||||||
|
- Removed minecraft 1.19 support
|
||||||
|
|
||||||
|
## [2.3.2] - 2025-05-24
|
||||||
|
### Fixed
|
||||||
|
- Fixed mixin incompatibility with ModernFix (closes [#42](https://github.com/Suiranoil/SkinRestorer/issues/52))
|
||||||
|
|
||||||
|
## [2.3.1] - 2025-05-03
|
||||||
|
### Added
|
||||||
|
- Added support for minecraft 1.19-1.19.4
|
||||||
|
### Changed
|
||||||
|
- Use services and session server urls from environment
|
||||||
|
|
||||||
|
## [2.3.0] - 2025-03-27
|
||||||
|
### Added
|
||||||
|
- Added `skinApplyDelayOnJoin` config option (see [wiki](https://github.com/Suiranoil/SkinRestorer/wiki/Configuration#skinapplydelayonjoin))
|
||||||
|
### Changed
|
||||||
|
- Updated to 1.21.5
|
||||||
|
### Removed
|
||||||
|
- [NeoForge] Dropped support for NeoForge on Minecraft 1.20.5-1.20.6
|
||||||
|
|
||||||
|
## [2.2.1] - 2024-12-23
|
||||||
|
### Fixed
|
||||||
|
- Fixed game not closing because of mineskin working threads (closes [#41](https://github.com/Suiranoil/SkinRestorer/issues/41))
|
||||||
|
|
||||||
|
## [2.2.0] - 2024-12-02
|
||||||
### Added
|
### Added
|
||||||
- Added support for [SkinShuffle](https://modrinth.com/mod/skinshuffle) clients (requires FabricAPI on Fabric)
|
- Added support for [SkinShuffle](https://modrinth.com/mod/skinshuffle) clients (requires FabricAPI on Fabric)
|
||||||
(closes [#34](https://github.com/Suiranoil/SkinRestorer/issues/34))
|
(closes [#34](https://github.com/Suiranoil/SkinRestorer/issues/34))
|
||||||
|
|||||||
@@ -1,10 +1,3 @@
|
|||||||
### Added
|
### Added
|
||||||
- Added support for [SkinShuffle](https://modrinth.com/mod/skinshuffle) clients (requires FabricAPI on Fabric)
|
- Added collection skin provider (allows assigning random skins from a predefined set) (see [wiki](https://github.com/Suiranoil/SkinRestorer/wiki/Configuration#providerscollection))
|
||||||
(closes [#34](https://github.com/Suiranoil/SkinRestorer/issues/34))
|
- Added `forceFirstJoinSkinFetch` config option to force skin fetch on first join even if player already has a skin (see [wiki](https://github.com/Suiranoil/SkinRestorer/wiki/Configuration#forcefirstjoinskinfetch))
|
||||||
- Added `providers.mineskin.apiKey` config option (see [wiki](https://github.com/Suiranoil/SkinRestorer/wiki/Configuration#providersmineskin))
|
|
||||||
### Changed
|
|
||||||
- Migrated to MineSkin's new API V2
|
|
||||||
### Fixed
|
|
||||||
- Fixed `providers` config validation
|
|
||||||
### Removed
|
|
||||||
- Dropped support for NeoForge on Minecraft 1.20.2-1.20.4
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
# SkinRestorer
|
# SkinRestorer
|
||||||
|
|
||||||
<a href="https://modrinth.com/mod/skinrestorer"><img src="https://raw.githubusercontent.com/Suiranoil/badges/main/assets/minecraft/platform/modrinth/mini/badge.svg" alt="Modrinth" height="32"></a>
|
<a href="https://modrinth.com/mod/skinrestorer"><img src="https://raw.githubusercontent.com/Suiranoil/badges/main/assets/minecraft/platform/modrinth/mini/badge.svg" alt="Modrinth"></a>
|
||||||
<a href="https://www.curseforge.com/minecraft/mc-mods/skinrestorer"><img src="https://raw.githubusercontent.com/Suiranoil/badges/main/assets/minecraft/platform/curseforge/mini/badge.svg" alt="CurseForge" height="32"></a>
|
<a href="https://www.curseforge.com/minecraft/mc-mods/skinrestorer"><img src="https://raw.githubusercontent.com/Suiranoil/badges/main/assets/minecraft/platform/curseforge/mini/badge.svg" alt="CurseForge"></a>
|
||||||
|
|
||||||
A server-side mod for managing and restoring player skins.
|
A server-side mod for managing and restoring player skins.
|
||||||
|
|
||||||
@@ -33,7 +33,9 @@ the [commands wiki page](https://github.com/Suiranoil/SkinRestorer/wiki/Commands
|
|||||||
If you enjoy using **SkinRestorer** and would like to support its development, you can contribute through the following
|
If you enjoy using **SkinRestorer** and would like to support its development, you can contribute through the following
|
||||||
platforms:
|
platforms:
|
||||||
|
|
||||||
[](https://ko-fi.com/lionarius)
|
<a href="https://ko-fi.com/lionarius"><img src="https://raw.githubusercontent.com/Suiranoil/badges/main/assets/donation/kofi/mini/badge.svg" alt="Ko-fi" height="32"></a>
|
||||||
|
|
||||||
|
<a href="https://boosty.to/lionarius"><img src="https://raw.githubusercontent.com/Suiranoil/badges/main/assets/donation/boosty/mini/badge.svg" alt="Boosty" height="32"></a>
|
||||||
|
|
||||||
Bitcoin (BTC): `1Ndbwny8pxdnWXFgadp95fp97y5JqMJKTX`
|
Bitcoin (BTC): `1Ndbwny8pxdnWXFgadp95fp97y5JqMJKTX`
|
||||||
USDT (TRC20): `TGXn8wrqku5KLzwPWQAeH7wgnV4UzwHEae`
|
USDT (TRC20): `TGXn8wrqku5KLzwPWQAeH7wgnV4UzwHEae`
|
||||||
|
|||||||
10
build.gradle
10
build.gradle
@@ -1,15 +1,15 @@
|
|||||||
plugins {
|
plugins {
|
||||||
// see https://fabricmc.net/develop/ for new versions
|
// see https://fabricmc.net/develop/ for new versions
|
||||||
id 'fabric-loom' version '1.8-SNAPSHOT' apply false
|
id 'fabric-loom' version '1.10-SNAPSHOT' apply false
|
||||||
// see https://projects.neoforged.net/neoforged/neogradle for new versions
|
// see https://projects.neoforged.net/neoforged/moddevgradle for new versions
|
||||||
id 'net.neoforged.gradle.userdev' version '7.0.153' apply false
|
id 'net.neoforged.moddev' version '2.0.+' apply false
|
||||||
// see https://files.minecraftforge.net/net/minecraftforge/gradle/ForgeGradle/ for new versions
|
// see https://files.minecraftforge.net/net/minecraftforge/gradle/ForgeGradle/ for new versions
|
||||||
id 'net.minecraftforge.gradle' version '6.0.29' apply false
|
id 'net.minecraftforge.gradle' version '6.0.+' apply false
|
||||||
id 'org.parchmentmc.librarian.forgegradle' version '1.+' apply false
|
id 'org.parchmentmc.librarian.forgegradle' version '1.+' apply false
|
||||||
|
|
||||||
id 'org.spongepowered.mixin' version '0.7-SNAPSHOT' apply false
|
id 'org.spongepowered.mixin' version '0.7-SNAPSHOT' apply false
|
||||||
|
|
||||||
id 'me.modmuss50.mod-publish-plugin' version '0.8.1' apply false
|
id 'me.modmuss50.mod-publish-plugin' version '0.8.+' apply false
|
||||||
}
|
}
|
||||||
|
|
||||||
allprojects {
|
allprojects {
|
||||||
|
|||||||
@@ -83,7 +83,6 @@ processResources {
|
|||||||
'group' : project.group, //Else we target the task's group.
|
'group' : project.group, //Else we target the task's group.
|
||||||
'minecraft_version' : minecraft_version,
|
'minecraft_version' : minecraft_version,
|
||||||
'minecraft_version_range' : minecraft_version_range,
|
'minecraft_version_range' : minecraft_version_range,
|
||||||
'fabric_loader_version' : fabric_loader_version,
|
|
||||||
'mod_name' : mod_name,
|
'mod_name' : mod_name,
|
||||||
'mod_author' : mod_author,
|
'mod_author' : mod_author,
|
||||||
'mod_id' : mod_id,
|
'mod_id' : mod_id,
|
||||||
@@ -92,16 +91,20 @@ processResources {
|
|||||||
'mod_issues' : mod_issues,
|
'mod_issues' : mod_issues,
|
||||||
'license' : license,
|
'license' : license,
|
||||||
'description' : project.description,
|
'description' : project.description,
|
||||||
'forge_version' : forge_version,
|
|
||||||
'forge_loader_version_range' : forge_loader_version_range,
|
|
||||||
'neoforge_version' : neoforge_version,
|
|
||||||
'neoforge_loader_version_range': neoforge_loader_version_range,
|
|
||||||
'credits' : credits,
|
'credits' : credits,
|
||||||
'java_version' : java_version
|
'java_version' : java_version,
|
||||||
|
|
||||||
|
// Loader specific properties
|
||||||
|
'fabric_loader_version' : project.hasProperty('fabric_loader_version') ? fabric_loader_version : '',
|
||||||
|
'forge_version' : project.hasProperty('forge_version') ? forge_version : '',
|
||||||
|
'forge_loader_version_range' : project.hasProperty('forge_loader_version_range') ? forge_loader_version_range : '',
|
||||||
|
'neoforge_version' : project.hasProperty('neoforge_version') ? neoforge_version : '',
|
||||||
|
'neoforge_loader_version_range': project.hasProperty('neoforge_loader_version_range') ? neoforge_loader_version_range : ''
|
||||||
]
|
]
|
||||||
|
|
||||||
filesMatching(['pack.mcmeta', 'fabric.mod.json', 'META-INF/mods.toml', 'META-INF/neoforge.mods.toml', '*.mixins.json']) {
|
filesMatching(['pack.mcmeta', 'fabric.mod.json', 'META-INF/mods.toml', 'META-INF/neoforge.mods.toml', '*.mixins.json']) {
|
||||||
expand expandProps
|
expand expandProps
|
||||||
}
|
}
|
||||||
|
|
||||||
inputs.properties(expandProps)
|
inputs.properties(expandProps)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,12 +3,17 @@ plugins {
|
|||||||
}
|
}
|
||||||
|
|
||||||
publishMods {
|
publishMods {
|
||||||
if (project.name == 'fabric')
|
file = project.layout.buildDirectory.file("libs/${project.archivesBaseName}-${project.version}.jar").map { it.asFile }.getOrNull()
|
||||||
file = remapJar.archiveFile
|
|
||||||
else
|
|
||||||
file = tasks.named('jarJar').get().archiveFile
|
|
||||||
|
|
||||||
modLoaders.add(project.name)
|
modLoaders.add(project.name)
|
||||||
|
|
||||||
|
if (project.hasProperty('additional_modloaders') && !additional_modloaders.isEmpty())
|
||||||
|
{
|
||||||
|
def loaders = additional_modloaders.split(',')
|
||||||
|
for (loader in loaders)
|
||||||
|
modLoaders.add(loader)
|
||||||
|
}
|
||||||
|
|
||||||
type = STABLE
|
type = STABLE
|
||||||
version = project.version
|
version = project.version
|
||||||
displayName = "[${project.name.capitalize()}] ${mod_name} ${mod_version}"
|
displayName = "[${project.name.capitalize()}] ${mod_name} ${mod_version}"
|
||||||
@@ -23,8 +28,8 @@ publishMods {
|
|||||||
minecraftVersions.addAll(minecraft_version_list.split(','))
|
minecraftVersions.addAll(minecraft_version_list.split(','))
|
||||||
serverRequired = true
|
serverRequired = true
|
||||||
|
|
||||||
if (project.name == 'fabric')
|
if (project.hasProperty('optional_dependencies') && !optional_dependencies.isEmpty())
|
||||||
optional(fabric_optional_dependencies.split(','))
|
optional(optional_dependencies.split(','))
|
||||||
}
|
}
|
||||||
|
|
||||||
modrinth {
|
modrinth {
|
||||||
@@ -35,7 +40,7 @@ publishMods {
|
|||||||
|
|
||||||
minecraftVersions.addAll(minecraft_version_list.split(','))
|
minecraftVersions.addAll(minecraft_version_list.split(','))
|
||||||
|
|
||||||
if (project.name == 'fabric')
|
if (project.hasProperty('optional_dependencies') && !optional_dependencies.isEmpty())
|
||||||
optional(fabric_optional_dependencies.split(','))
|
optional(optional_dependencies.split(','))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,25 +1,25 @@
|
|||||||
package net.lionarius.skinrestorer;
|
package net.lionarius.skinrestorer;
|
||||||
|
|
||||||
|
import com.google.common.base.Throwables;
|
||||||
import com.mojang.authlib.GameProfile;
|
import com.mojang.authlib.GameProfile;
|
||||||
import com.mojang.brigadier.CommandDispatcher;
|
import com.mojang.brigadier.CommandDispatcher;
|
||||||
import net.lionarius.skinrestorer.command.SkinCommand;
|
import net.lionarius.skinrestorer.command.SkinCommand;
|
||||||
import net.lionarius.skinrestorer.config.Config;
|
import net.lionarius.skinrestorer.config.Config;
|
||||||
import net.lionarius.skinrestorer.config.provider.BuiltInProviderConfig;
|
import net.lionarius.skinrestorer.config.provider.BuiltInProviderConfig;
|
||||||
|
import net.lionarius.skinrestorer.exception.TransparentException;
|
||||||
import net.lionarius.skinrestorer.platform.Services;
|
import net.lionarius.skinrestorer.platform.Services;
|
||||||
import net.lionarius.skinrestorer.skin.SkinIO;
|
import net.lionarius.skinrestorer.skin.SkinIO;
|
||||||
import net.lionarius.skinrestorer.skin.SkinStorage;
|
import net.lionarius.skinrestorer.skin.SkinStorage;
|
||||||
import net.lionarius.skinrestorer.skin.SkinValue;
|
import net.lionarius.skinrestorer.skin.SkinValue;
|
||||||
import net.lionarius.skinrestorer.skin.provider.*;
|
import net.lionarius.skinrestorer.skin.provider.*;
|
||||||
import net.lionarius.skinrestorer.translation.Translation;
|
import net.lionarius.skinrestorer.translation.Translation;
|
||||||
import net.lionarius.skinrestorer.util.FileUtils;
|
import net.lionarius.skinrestorer.util.*;
|
||||||
import net.lionarius.skinrestorer.util.PlayerUtils;
|
|
||||||
import net.lionarius.skinrestorer.util.Result;
|
|
||||||
import net.lionarius.skinrestorer.util.WebUtils;
|
|
||||||
import net.minecraft.commands.CommandSourceStack;
|
import net.minecraft.commands.CommandSourceStack;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.server.MinecraftServer;
|
import net.minecraft.server.MinecraftServer;
|
||||||
import net.minecraft.server.level.ServerPlayer;
|
import net.minecraft.server.level.ServerPlayer;
|
||||||
import net.minecraft.world.level.storage.LevelResource;
|
import net.minecraft.world.level.storage.LevelResource;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
@@ -37,6 +37,8 @@ public final class SkinRestorer {
|
|||||||
private static SkinStorage skinStorage;
|
private static SkinStorage skinStorage;
|
||||||
private static Path configDir;
|
private static Path configDir;
|
||||||
private static Config config;
|
private static Config config;
|
||||||
|
private static TickedScheduler tickedScheduler;
|
||||||
|
private static MinecraftServer minecraftServer;
|
||||||
|
|
||||||
private SkinRestorer() {}
|
private SkinRestorer() {}
|
||||||
|
|
||||||
@@ -56,6 +58,14 @@ public final class SkinRestorer {
|
|||||||
return SkinRestorer.providersRegistry;
|
return SkinRestorer.providersRegistry;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static TickedScheduler getTickedScheduler() {
|
||||||
|
return SkinRestorer.tickedScheduler;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static @Nullable MinecraftServer getMinecraftServer() {
|
||||||
|
return SkinRestorer.minecraftServer;
|
||||||
|
}
|
||||||
|
|
||||||
public static Optional<SkinProvider> getProvider(String name) {
|
public static Optional<SkinProvider> getProvider(String name) {
|
||||||
return Optional.ofNullable(SkinRestorer.providersRegistry.get(name));
|
return Optional.ofNullable(SkinRestorer.providersRegistry.get(name));
|
||||||
}
|
}
|
||||||
@@ -78,6 +88,7 @@ public final class SkinRestorer {
|
|||||||
SkinRestorer.registerDefaultSkinProvider(MojangSkinProvider.PROVIDER_NAME, SkinProvider.MOJANG, SkinRestorer.getConfig().providersConfig().mojang());
|
SkinRestorer.registerDefaultSkinProvider(MojangSkinProvider.PROVIDER_NAME, SkinProvider.MOJANG, SkinRestorer.getConfig().providersConfig().mojang());
|
||||||
SkinRestorer.registerDefaultSkinProvider(ElyBySkinProvider.PROVIDER_NAME, SkinProvider.ELY_BY, SkinRestorer.getConfig().providersConfig().ely_by());
|
SkinRestorer.registerDefaultSkinProvider(ElyBySkinProvider.PROVIDER_NAME, SkinProvider.ELY_BY, SkinRestorer.getConfig().providersConfig().ely_by());
|
||||||
SkinRestorer.registerDefaultSkinProvider(MineskinSkinProvider.PROVIDER_NAME, SkinProvider.MINESKIN, SkinRestorer.getConfig().providersConfig().mineskin());
|
SkinRestorer.registerDefaultSkinProvider(MineskinSkinProvider.PROVIDER_NAME, SkinProvider.MINESKIN, SkinRestorer.getConfig().providersConfig().mineskin());
|
||||||
|
SkinRestorer.registerDefaultSkinProvider(CollectionSkinProvider.PROVIDER_NAME, SkinProvider.COLLECTION, SkinRestorer.getConfig().providersConfig().collection());
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void registerDefaultSkinProvider(String defaultName, SkinProvider provider, BuiltInProviderConfig config) {
|
private static void registerDefaultSkinProvider(String defaultName, SkinProvider provider, BuiltInProviderConfig config) {
|
||||||
@@ -96,6 +107,7 @@ public final class SkinRestorer {
|
|||||||
MojangSkinProvider.reload();
|
MojangSkinProvider.reload();
|
||||||
ElyBySkinProvider.reload();
|
ElyBySkinProvider.reload();
|
||||||
MineskinSkinProvider.reload();
|
MineskinSkinProvider.reload();
|
||||||
|
CollectionSkinProvider.reload();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Collection<ServerPlayer> applySkin(MinecraftServer server, Iterable<GameProfile> targets, SkinValue value, boolean save) {
|
public static Collection<ServerPlayer> applySkin(MinecraftServer server, Iterable<GameProfile> targets, SkinValue value, boolean save) {
|
||||||
@@ -119,6 +131,8 @@ public final class SkinRestorer {
|
|||||||
|
|
||||||
PlayerUtils.refreshPlayer(player);
|
PlayerUtils.refreshPlayer(player);
|
||||||
acceptedPlayers.add(player);
|
acceptedPlayers.add(player);
|
||||||
|
|
||||||
|
SkinRestorer.getTickedScheduler().cancel(player.getUUID());
|
||||||
}
|
}
|
||||||
|
|
||||||
return acceptedPlayers;
|
return acceptedPlayers;
|
||||||
@@ -143,7 +157,7 @@ public final class SkinRestorer {
|
|||||||
|
|
||||||
var skinResult = result.get();
|
var skinResult = result.get();
|
||||||
if (skinResult.isError())
|
if (skinResult.isError())
|
||||||
return Result.<Collection<ServerPlayer>, String>error(skinResult.getErrorValue().getMessage());
|
throw new TransparentException(Throwables.getRootCause(skinResult.getErrorValue()));
|
||||||
|
|
||||||
var skinValue = SkinValue.fromProviderContextWithValue(context, skinResult.getSuccessValue().orElse(null));
|
var skinValue = SkinValue.fromProviderContextWithValue(context, skinResult.getSuccessValue().orElse(null));
|
||||||
|
|
||||||
@@ -152,7 +166,7 @@ public final class SkinRestorer {
|
|||||||
return Result.<Collection<ServerPlayer>, String>success(acceptedPlayers);
|
return Result.<Collection<ServerPlayer>, String>success(acceptedPlayers);
|
||||||
}, server)
|
}, server)
|
||||||
.exceptionally(e -> {
|
.exceptionally(e -> {
|
||||||
SkinRestorer.LOGGER.error(e.toString());
|
SkinRestorer.LOGGER.error("Failed to set skin '{}:{}'", context.name(), context.argument(), e);
|
||||||
return Result.error(e.getMessage());
|
return Result.error(e.getMessage());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -165,6 +179,16 @@ public final class SkinRestorer {
|
|||||||
FileUtils.tryMigrateOldSkinDirectory(SkinRestorer.getConfigDir(), worldSkinDirectory);
|
FileUtils.tryMigrateOldSkinDirectory(SkinRestorer.getConfigDir(), worldSkinDirectory);
|
||||||
|
|
||||||
SkinRestorer.skinStorage = new SkinStorage(new SkinIO(worldSkinDirectory));
|
SkinRestorer.skinStorage = new SkinStorage(new SkinIO(worldSkinDirectory));
|
||||||
|
SkinRestorer.tickedScheduler = new TickedScheduler(server);
|
||||||
|
server.addTickable(SkinRestorer.tickedScheduler);
|
||||||
|
|
||||||
|
SkinRestorer.minecraftServer = server;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void onServerStopped(MinecraftServer server) {
|
||||||
|
SkinRestorer.skinStorage = null;
|
||||||
|
SkinRestorer.tickedScheduler = null;
|
||||||
|
SkinRestorer.minecraftServer = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void onCommandRegister(CommandDispatcher<CommandSourceStack> dispatcher) {
|
public static void onCommandRegister(CommandDispatcher<CommandSourceStack> dispatcher) {
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ public final class SkinCommand {
|
|||||||
private SkinCommand() {}
|
private SkinCommand() {}
|
||||||
|
|
||||||
public static void register(CommandDispatcher<CommandSourceStack> dispatcher) {
|
public static void register(CommandDispatcher<CommandSourceStack> dispatcher) {
|
||||||
LiteralArgumentBuilder<CommandSourceStack> base =
|
var base =
|
||||||
literal("skin")
|
literal("skin")
|
||||||
.then(buildSetSubcommand("clear", SkinValue.EMPTY::toProviderContext))
|
.then(buildSetSubcommand("clear", SkinValue.EMPTY::toProviderContext))
|
||||||
.then(literal("reset")
|
.then(literal("reset")
|
||||||
@@ -44,7 +44,7 @@ public final class SkinCommand {
|
|||||||
)))
|
)))
|
||||||
.then(literal("refresh").executes(context -> refreshSubcommand(context.getSource())));
|
.then(literal("refresh").executes(context -> refreshSubcommand(context.getSource())));
|
||||||
|
|
||||||
LiteralArgumentBuilder<CommandSourceStack> set = literal("set");
|
var set = literal("set");
|
||||||
|
|
||||||
var providers = SkinRestorer.getProvidersRegistry().getPublicProviders();
|
var providers = SkinRestorer.getProvidersRegistry().getPublicProviders();
|
||||||
for (var entry : providers)
|
for (var entry : providers)
|
||||||
@@ -92,7 +92,7 @@ public final class SkinCommand {
|
|||||||
Collection<GameProfile> targets,
|
Collection<GameProfile> targets,
|
||||||
boolean setByOperator
|
boolean setByOperator
|
||||||
) {
|
) {
|
||||||
Collection<ServerPlayer> updatedPlayers = new HashSet<>();
|
var updatedPlayers = new HashSet<ServerPlayer>();
|
||||||
for (var profile : targets) {
|
for (var profile : targets) {
|
||||||
SkinValue skin = null;
|
SkinValue skin = null;
|
||||||
if (SkinRestorer.getSkinStorage().hasSavedSkin(profile.getId()))
|
if (SkinRestorer.getSkinStorage().hasSavedSkin(profile.getId()))
|
||||||
@@ -199,7 +199,7 @@ public final class SkinCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static LiteralArgumentBuilder<CommandSourceStack> buildSetSubcommand(String name, SkinProvider provider) {
|
private static LiteralArgumentBuilder<CommandSourceStack> buildSetSubcommand(String name, SkinProvider provider) {
|
||||||
LiteralArgumentBuilder<CommandSourceStack> action = literal(name);
|
var action = literal(name);
|
||||||
|
|
||||||
if (provider.hasVariantSupport()) {
|
if (provider.hasVariantSupport()) {
|
||||||
for (SkinVariant variant : SkinVariant.values()) {
|
for (SkinVariant variant : SkinVariant.values()) {
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ public class SkinShuffleCompatibility {
|
|||||||
public static void handleSkinRefresh(MinecraftServer server, ServerPlayer player, SkinShuffleSkinRefreshPayload payload) {
|
public static void handleSkinRefresh(MinecraftServer server, ServerPlayer player, SkinShuffleSkinRefreshPayload payload) {
|
||||||
var property = payload.textureProperty();
|
var property = payload.textureProperty();
|
||||||
|
|
||||||
if (!property.name().equals(PlayerUtils.TEXTURES_KEY))
|
if (!property.getName().equals(PlayerUtils.TEXTURES_KEY))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!property.hasSignature())
|
if (!property.hasSignature())
|
||||||
|
|||||||
@@ -1,23 +1,10 @@
|
|||||||
package net.lionarius.skinrestorer.compat.skinshuffle;
|
package net.lionarius.skinrestorer.compat.skinshuffle;
|
||||||
|
|
||||||
import net.minecraft.network.FriendlyByteBuf;
|
|
||||||
import net.minecraft.network.protocol.common.custom.CustomPacketPayload;
|
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
|
|
||||||
public record SkinShuffleHandshakePayload() implements CustomPacketPayload {
|
public record SkinShuffleHandshakePayload() {
|
||||||
|
|
||||||
public static final SkinShuffleHandshakePayload INSTANCE = new SkinShuffleHandshakePayload();
|
public static final SkinShuffleHandshakePayload INSTANCE = new SkinShuffleHandshakePayload();
|
||||||
|
|
||||||
public static final ResourceLocation PACKET_ID = SkinShuffleCompatibility.resourceLocation("handshake");
|
public static final ResourceLocation PACKET_ID = SkinShuffleCompatibility.resourceLocation("handshake");
|
||||||
|
|
||||||
@Override
|
|
||||||
public void write(@NotNull FriendlyByteBuf buf) {
|
|
||||||
// NO-OP
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public @NotNull ResourceLocation id() {
|
|
||||||
return PACKET_ID;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,34 +2,22 @@ package net.lionarius.skinrestorer.compat.skinshuffle;
|
|||||||
|
|
||||||
import com.mojang.authlib.properties.Property;
|
import com.mojang.authlib.properties.Property;
|
||||||
import net.minecraft.network.FriendlyByteBuf;
|
import net.minecraft.network.FriendlyByteBuf;
|
||||||
import net.minecraft.network.protocol.common.custom.CustomPacketPayload;
|
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
|
|
||||||
public record SkinShuffleSkinRefreshV1Payload(
|
public record SkinShuffleSkinRefreshV1Payload(
|
||||||
Property textureProperty) implements CustomPacketPayload, SkinShuffleSkinRefreshPayload {
|
Property textureProperty) implements SkinShuffleSkinRefreshPayload {
|
||||||
|
|
||||||
public static final ResourceLocation PACKET_ID = SkinShuffleCompatibility.resourceLocation("refresh");
|
public static final ResourceLocation PACKET_ID = SkinShuffleCompatibility.resourceLocation("refresh");
|
||||||
|
|
||||||
public static void encode(FriendlyByteBuf buf, SkinShuffleSkinRefreshV1Payload value) {
|
public static void encode(FriendlyByteBuf buf, SkinShuffleSkinRefreshV1Payload value) {
|
||||||
var textureProperty = value.textureProperty();
|
var textureProperty = value.textureProperty();
|
||||||
|
|
||||||
buf.writeUtf(textureProperty.name());
|
buf.writeUtf(textureProperty.getName());
|
||||||
buf.writeUtf(textureProperty.value());
|
buf.writeUtf(textureProperty.getValue());
|
||||||
buf.writeNullable(textureProperty.signature(), FriendlyByteBuf::writeUtf);
|
buf.writeNullable(textureProperty.getSignature(), FriendlyByteBuf::writeUtf);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static SkinShuffleSkinRefreshV1Payload decode(FriendlyByteBuf buf) {
|
public static SkinShuffleSkinRefreshV1Payload decode(FriendlyByteBuf buf) {
|
||||||
return new SkinShuffleSkinRefreshV1Payload(new Property(buf.readUtf(), buf.readUtf(), buf.readNullable(FriendlyByteBuf::readUtf)));
|
return new SkinShuffleSkinRefreshV1Payload(new Property(buf.readUtf(), buf.readUtf(), buf.readNullable(FriendlyByteBuf::readUtf)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void write(@NotNull FriendlyByteBuf buf) {
|
|
||||||
encode(buf, this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public @NotNull ResourceLocation id() {
|
|
||||||
return PACKET_ID;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,12 +2,10 @@ package net.lionarius.skinrestorer.compat.skinshuffle;
|
|||||||
|
|
||||||
import com.mojang.authlib.properties.Property;
|
import com.mojang.authlib.properties.Property;
|
||||||
import net.minecraft.network.FriendlyByteBuf;
|
import net.minecraft.network.FriendlyByteBuf;
|
||||||
import net.minecraft.network.protocol.common.custom.CustomPacketPayload;
|
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
|
|
||||||
public record SkinShuffleSkinRefreshV2Payload(
|
public record SkinShuffleSkinRefreshV2Payload(
|
||||||
Property textureProperty) implements CustomPacketPayload, SkinShuffleSkinRefreshPayload {
|
Property textureProperty) implements SkinShuffleSkinRefreshPayload {
|
||||||
|
|
||||||
public static final ResourceLocation PACKET_ID = SkinShuffleCompatibility.resourceLocation("skin_refresh");
|
public static final ResourceLocation PACKET_ID = SkinShuffleCompatibility.resourceLocation("skin_refresh");
|
||||||
|
|
||||||
@@ -15,12 +13,12 @@ public record SkinShuffleSkinRefreshV2Payload(
|
|||||||
var textureProperty = value.textureProperty();
|
var textureProperty = value.textureProperty();
|
||||||
|
|
||||||
buf.writeBoolean(textureProperty.hasSignature());
|
buf.writeBoolean(textureProperty.hasSignature());
|
||||||
buf.writeUtf(textureProperty.name());
|
buf.writeUtf(textureProperty.getName());
|
||||||
buf.writeUtf(textureProperty.value());
|
buf.writeUtf(textureProperty.getValue());
|
||||||
if (textureProperty.hasSignature()) {
|
if (textureProperty.hasSignature()) {
|
||||||
assert textureProperty.signature() != null;
|
assert textureProperty.getSignature() != null;
|
||||||
|
|
||||||
buf.writeUtf(textureProperty.signature());
|
buf.writeUtf(textureProperty.getSignature());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -30,14 +28,4 @@ public record SkinShuffleSkinRefreshV2Payload(
|
|||||||
}
|
}
|
||||||
return new SkinShuffleSkinRefreshV2Payload(new Property(buf.readUtf(), buf.readUtf(), null));
|
return new SkinShuffleSkinRefreshV2Payload(new Property(buf.readUtf(), buf.readUtf(), null));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void write(@NotNull FriendlyByteBuf buf) {
|
|
||||||
encode(buf, this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public @NotNull ResourceLocation id() {
|
|
||||||
return PACKET_ID;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,8 +18,12 @@ public final class Config implements GsonPostProcessable {
|
|||||||
|
|
||||||
private boolean refreshSkinOnJoin = true;
|
private boolean refreshSkinOnJoin = true;
|
||||||
|
|
||||||
|
private int skinApplyDelayOnJoin = 0;
|
||||||
|
|
||||||
private boolean fetchSkinOnFirstJoin = true;
|
private boolean fetchSkinOnFirstJoin = true;
|
||||||
|
|
||||||
|
private boolean forceFirstJoinSkinFetch = false;
|
||||||
|
|
||||||
private FirstJoinSkinProvider firstJoinSkinProvider = FirstJoinSkinProvider.MOJANG;
|
private FirstJoinSkinProvider firstJoinSkinProvider = FirstJoinSkinProvider.MOJANG;
|
||||||
|
|
||||||
private String proxy = "";
|
private String proxy = "";
|
||||||
@@ -37,10 +41,18 @@ public final class Config implements GsonPostProcessable {
|
|||||||
return this.refreshSkinOnJoin;
|
return this.refreshSkinOnJoin;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int skinApplyDelayOnJoin() {
|
||||||
|
return this.skinApplyDelayOnJoin;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean fetchSkinOnFirstJoin() {
|
public boolean fetchSkinOnFirstJoin() {
|
||||||
return this.fetchSkinOnFirstJoin;
|
return this.fetchSkinOnFirstJoin;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean forceFirstJoinSkinFetch() {
|
||||||
|
return this.forceFirstJoinSkinFetch;
|
||||||
|
}
|
||||||
|
|
||||||
public FirstJoinSkinProvider firstJoinSkinProvider() {
|
public FirstJoinSkinProvider firstJoinSkinProvider() {
|
||||||
return this.firstJoinSkinProvider;
|
return this.firstJoinSkinProvider;
|
||||||
}
|
}
|
||||||
@@ -82,6 +94,11 @@ public final class Config implements GsonPostProcessable {
|
|||||||
this.language = "en_us";
|
this.language = "en_us";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this.skinApplyDelayOnJoin < 0) {
|
||||||
|
SkinRestorer.LOGGER.warn("SkinApplyDelayOnJoin config is less than 0, defaulting to 0");
|
||||||
|
this.skinApplyDelayOnJoin = 0;
|
||||||
|
}
|
||||||
|
|
||||||
if (this.firstJoinSkinProvider == null) {
|
if (this.firstJoinSkinProvider == null) {
|
||||||
SkinRestorer.LOGGER.warn("FirstJoinSkinProvider config is null, defaulting to MOJANG");
|
SkinRestorer.LOGGER.warn("FirstJoinSkinProvider config is null, defaulting to MOJANG");
|
||||||
this.firstJoinSkinProvider = FirstJoinSkinProvider.MOJANG;
|
this.firstJoinSkinProvider = FirstJoinSkinProvider.MOJANG;
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package net.lionarius.skinrestorer.config;
|
package net.lionarius.skinrestorer.config;
|
||||||
|
|
||||||
import com.google.gson.annotations.SerializedName;
|
import com.google.gson.annotations.SerializedName;
|
||||||
|
import net.lionarius.skinrestorer.skin.provider.CollectionSkinProvider;
|
||||||
import net.lionarius.skinrestorer.skin.provider.ElyBySkinProvider;
|
import net.lionarius.skinrestorer.skin.provider.ElyBySkinProvider;
|
||||||
import net.lionarius.skinrestorer.skin.provider.MojangSkinProvider;
|
import net.lionarius.skinrestorer.skin.provider.MojangSkinProvider;
|
||||||
|
|
||||||
@@ -8,7 +9,9 @@ public enum FirstJoinSkinProvider {
|
|||||||
@SerializedName(value = "MOJANG", alternate = {"mojang"})
|
@SerializedName(value = "MOJANG", alternate = {"mojang"})
|
||||||
MOJANG(MojangSkinProvider.PROVIDER_NAME),
|
MOJANG(MojangSkinProvider.PROVIDER_NAME),
|
||||||
@SerializedName(value = "ELY.BY", alternate = {"ely.by", "ELY_BY", "ely_by"})
|
@SerializedName(value = "ELY.BY", alternate = {"ely.by", "ELY_BY", "ely_by"})
|
||||||
ELY_BY(ElyBySkinProvider.PROVIDER_NAME);
|
ELY_BY(ElyBySkinProvider.PROVIDER_NAME),
|
||||||
|
@SerializedName(value = "COLLECTION", alternate = {"collection"})
|
||||||
|
COLLECTION(CollectionSkinProvider.PROVIDER_NAME);
|
||||||
|
|
||||||
private final String name;
|
private final String name;
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +1,47 @@
|
|||||||
package net.lionarius.skinrestorer.config.provider;
|
package net.lionarius.skinrestorer.config.provider;
|
||||||
|
|
||||||
public interface BuiltInProviderConfig {
|
import net.lionarius.skinrestorer.SkinRestorer;
|
||||||
|
import net.lionarius.skinrestorer.util.gson.GsonPostProcessable;
|
||||||
|
|
||||||
boolean enabled();
|
public abstract class BuiltInProviderConfig implements GsonPostProcessable {
|
||||||
|
protected boolean enabled;
|
||||||
String name();
|
protected String name;
|
||||||
|
protected CacheConfig cache;
|
||||||
CacheConfig cache();
|
|
||||||
|
|
||||||
|
public BuiltInProviderConfig(String name, CacheConfig cache) {
|
||||||
|
this(name, cache, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public BuiltInProviderConfig(String name, CacheConfig cache, boolean enabled) {
|
||||||
|
this.enabled = enabled;
|
||||||
|
this.name = name;
|
||||||
|
this.cache = cache;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean enabled() {
|
||||||
|
return enabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String name() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CacheConfig cache() {
|
||||||
|
return cache;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void validate(String defaultName, CacheConfig defaultCache) {
|
||||||
|
if (this.name == null || this.name.isEmpty()) {
|
||||||
|
SkinRestorer.LOGGER.warn("Provider name is null or empty, defaulting to '{}'", defaultName);
|
||||||
|
this.name = defaultName;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.cache == null) {
|
||||||
|
SkinRestorer.LOGGER.warn("Provider cache is null, using default");
|
||||||
|
this.cache = defaultCache;
|
||||||
|
} else {
|
||||||
|
this.cache.validate(defaultCache);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,20 +5,20 @@ import net.lionarius.skinrestorer.SkinRestorer;
|
|||||||
public final class CacheConfig {
|
public final class CacheConfig {
|
||||||
private boolean enabled;
|
private boolean enabled;
|
||||||
private long duration;
|
private long duration;
|
||||||
|
|
||||||
public CacheConfig(boolean enabled, long duration) {
|
public CacheConfig(boolean enabled, long duration) {
|
||||||
this.enabled = enabled;
|
this.enabled = enabled;
|
||||||
this.duration = duration;
|
this.duration = duration;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean enabled() {
|
public boolean enabled() {
|
||||||
return enabled;
|
return enabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
public long duration() {
|
public long duration() {
|
||||||
return duration;
|
return duration;
|
||||||
}
|
}
|
||||||
|
|
||||||
void validate(CacheConfig defaultValue) {
|
void validate(CacheConfig defaultValue) {
|
||||||
if (this.duration <= 0) {
|
if (this.duration <= 0) {
|
||||||
SkinRestorer.LOGGER.warn("Cache duration is less than or equal to zero, defaulting to {}", defaultValue.duration());
|
SkinRestorer.LOGGER.warn("Cache duration is less than or equal to zero, defaulting to {}", defaultValue.duration());
|
||||||
|
|||||||
@@ -1,46 +1,16 @@
|
|||||||
package net.lionarius.skinrestorer.config.provider;
|
package net.lionarius.skinrestorer.config.provider;
|
||||||
|
|
||||||
import net.lionarius.skinrestorer.SkinRestorer;
|
|
||||||
import net.lionarius.skinrestorer.skin.provider.ElyBySkinProvider;
|
import net.lionarius.skinrestorer.skin.provider.ElyBySkinProvider;
|
||||||
import net.lionarius.skinrestorer.util.gson.GsonPostProcessable;
|
|
||||||
|
|
||||||
public class ElyByProviderConfig implements BuiltInProviderConfig, GsonPostProcessable {
|
public final class ElyByProviderConfig extends BuiltInProviderConfig {
|
||||||
private static final CacheConfig DEFAULT_CACHE_VALUE = new CacheConfig(true, 60);
|
private static final CacheConfig DEFAULT_CACHE_VALUE = new CacheConfig(true, 60);
|
||||||
|
|
||||||
private boolean enabled;
|
|
||||||
private String name;
|
|
||||||
private CacheConfig cache;
|
|
||||||
|
|
||||||
public ElyByProviderConfig() {
|
public ElyByProviderConfig() {
|
||||||
this.enabled = true;
|
super(ElyBySkinProvider.PROVIDER_NAME, DEFAULT_CACHE_VALUE);
|
||||||
this.name = ElyBySkinProvider.PROVIDER_NAME;
|
|
||||||
this.cache = DEFAULT_CACHE_VALUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean enabled() {
|
|
||||||
return enabled;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String name() {
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public CacheConfig cache() {
|
|
||||||
return cache;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void gsonPostProcess() {
|
public void gsonPostProcess() {
|
||||||
if (this.name == null || this.name.isEmpty()) {
|
super.validate(ElyBySkinProvider.PROVIDER_NAME, DEFAULT_CACHE_VALUE);
|
||||||
SkinRestorer.LOGGER.warn("Ely.By provider name is null or empty, defaulting to '{}'", ElyBySkinProvider.PROVIDER_NAME);
|
|
||||||
this.name = ElyBySkinProvider.PROVIDER_NAME;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.cache == null) {
|
|
||||||
SkinRestorer.LOGGER.warn("Ely.By provider cache is null, using default");
|
|
||||||
this.cache = DEFAULT_CACHE_VALUE;
|
|
||||||
} else {
|
|
||||||
this.cache.validate(DEFAULT_CACHE_VALUE);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,52 +2,25 @@ package net.lionarius.skinrestorer.config.provider;
|
|||||||
|
|
||||||
import net.lionarius.skinrestorer.SkinRestorer;
|
import net.lionarius.skinrestorer.SkinRestorer;
|
||||||
import net.lionarius.skinrestorer.skin.provider.MineskinSkinProvider;
|
import net.lionarius.skinrestorer.skin.provider.MineskinSkinProvider;
|
||||||
import net.lionarius.skinrestorer.util.gson.GsonPostProcessable;
|
|
||||||
|
|
||||||
public class MineskinProviderConfig implements BuiltInProviderConfig, GsonPostProcessable {
|
public final class MineskinProviderConfig extends BuiltInProviderConfig {
|
||||||
private static final CacheConfig DEFAULT_CACHE_VALUE = new CacheConfig(true, 300);
|
private static final CacheConfig DEFAULT_CACHE_VALUE = new CacheConfig(true, 300);
|
||||||
|
|
||||||
private boolean enabled;
|
|
||||||
private String name;
|
|
||||||
private CacheConfig cache;
|
|
||||||
private String apiKey;
|
private String apiKey;
|
||||||
|
|
||||||
public MineskinProviderConfig() {
|
public MineskinProviderConfig() {
|
||||||
this.enabled = true;
|
super(MineskinSkinProvider.PROVIDER_NAME, DEFAULT_CACHE_VALUE);
|
||||||
this.name = MineskinSkinProvider.PROVIDER_NAME;
|
|
||||||
this.cache = DEFAULT_CACHE_VALUE;
|
|
||||||
this.apiKey = "";
|
this.apiKey = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean enabled() {
|
|
||||||
return enabled;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String name() {
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public CacheConfig cache() {
|
|
||||||
return cache;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String apiKey() {
|
public String apiKey() {
|
||||||
return apiKey;
|
return apiKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void gsonPostProcess() {
|
public void gsonPostProcess() {
|
||||||
if (this.name == null || this.name.isEmpty()) {
|
super.validate(MineskinSkinProvider.PROVIDER_NAME, DEFAULT_CACHE_VALUE);
|
||||||
SkinRestorer.LOGGER.warn("Mineskin provider name is null or empty, defaulting to '{}'", MineskinSkinProvider.PROVIDER_NAME);
|
|
||||||
this.name = MineskinSkinProvider.PROVIDER_NAME;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.cache == null) {
|
|
||||||
SkinRestorer.LOGGER.warn("Mineskin cache is null, using default");
|
|
||||||
this.cache = DEFAULT_CACHE_VALUE;
|
|
||||||
} else {
|
|
||||||
this.cache.validate(DEFAULT_CACHE_VALUE);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.apiKey == null) {
|
if (this.apiKey == null) {
|
||||||
SkinRestorer.LOGGER.warn("Mineskin API key is null, defaulting to an empty string");
|
SkinRestorer.LOGGER.warn("Mineskin API key is null, defaulting to an empty string");
|
||||||
|
|||||||
@@ -1,46 +1,16 @@
|
|||||||
package net.lionarius.skinrestorer.config.provider;
|
package net.lionarius.skinrestorer.config.provider;
|
||||||
|
|
||||||
import net.lionarius.skinrestorer.SkinRestorer;
|
|
||||||
import net.lionarius.skinrestorer.skin.provider.MojangSkinProvider;
|
import net.lionarius.skinrestorer.skin.provider.MojangSkinProvider;
|
||||||
import net.lionarius.skinrestorer.util.gson.GsonPostProcessable;
|
|
||||||
|
|
||||||
public class MojangProviderConfig implements BuiltInProviderConfig, GsonPostProcessable {
|
public final class MojangProviderConfig extends BuiltInProviderConfig {
|
||||||
private static final CacheConfig DEFAULT_CACHE_VALUE = new CacheConfig(true, 60);
|
private static final CacheConfig DEFAULT_CACHE_VALUE = new CacheConfig(true, 60);
|
||||||
|
|
||||||
private boolean enabled;
|
|
||||||
private String name;
|
|
||||||
private CacheConfig cache;
|
|
||||||
|
|
||||||
public MojangProviderConfig() {
|
public MojangProviderConfig() {
|
||||||
this.enabled = true;
|
super(MojangSkinProvider.PROVIDER_NAME, DEFAULT_CACHE_VALUE);
|
||||||
this.name = MojangSkinProvider.PROVIDER_NAME;
|
|
||||||
this.cache = DEFAULT_CACHE_VALUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean enabled() {
|
|
||||||
return enabled;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String name() {
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public CacheConfig cache() {
|
|
||||||
return cache;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void gsonPostProcess() {
|
public void gsonPostProcess() {
|
||||||
if (this.name == null || this.name.isEmpty()) {
|
super.validate(MojangSkinProvider.PROVIDER_NAME, DEFAULT_CACHE_VALUE);
|
||||||
SkinRestorer.LOGGER.warn("Mojang provider name is null or empty, defaulting to '{}'", MojangSkinProvider.PROVIDER_NAME);
|
|
||||||
this.name = MojangSkinProvider.PROVIDER_NAME;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.cache == null) {
|
|
||||||
SkinRestorer.LOGGER.warn("Mojang provider cache is null, using default");
|
|
||||||
this.cache = DEFAULT_CACHE_VALUE;
|
|
||||||
} else {
|
|
||||||
this.cache.validate(DEFAULT_CACHE_VALUE);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,52 +1,65 @@
|
|||||||
package net.lionarius.skinrestorer.config.provider;
|
package net.lionarius.skinrestorer.config.provider;
|
||||||
|
|
||||||
import net.lionarius.skinrestorer.SkinRestorer;
|
import net.lionarius.skinrestorer.SkinRestorer;
|
||||||
|
import net.lionarius.skinrestorer.config.provider.collection.CollectionProviderConfig;
|
||||||
import net.lionarius.skinrestorer.util.gson.GsonPostProcessable;
|
import net.lionarius.skinrestorer.util.gson.GsonPostProcessable;
|
||||||
|
|
||||||
public final class ProvidersConfig implements GsonPostProcessable {
|
public final class ProvidersConfig implements GsonPostProcessable {
|
||||||
public static final ProvidersConfig DEFAULT = new ProvidersConfig(
|
public static final ProvidersConfig DEFAULT = new ProvidersConfig(
|
||||||
new MojangProviderConfig(),
|
new MojangProviderConfig(),
|
||||||
new ElyByProviderConfig(),
|
new ElyByProviderConfig(),
|
||||||
new MineskinProviderConfig()
|
new MineskinProviderConfig(),
|
||||||
|
new CollectionProviderConfig()
|
||||||
);
|
);
|
||||||
|
|
||||||
private MojangProviderConfig mojang;
|
private MojangProviderConfig mojang;
|
||||||
private ElyByProviderConfig ely_by;
|
private ElyByProviderConfig ely_by;
|
||||||
private MineskinProviderConfig mineskin;
|
private MineskinProviderConfig mineskin;
|
||||||
|
private CollectionProviderConfig collection;
|
||||||
public ProvidersConfig(MojangProviderConfig mojang, ElyByProviderConfig ely_by, MineskinProviderConfig mineskin) {
|
|
||||||
|
public ProvidersConfig(MojangProviderConfig mojang, ElyByProviderConfig ely_by, MineskinProviderConfig mineskin, CollectionProviderConfig collection) {
|
||||||
this.mojang = mojang;
|
this.mojang = mojang;
|
||||||
this.ely_by = ely_by;
|
this.ely_by = ely_by;
|
||||||
this.mineskin = mineskin;
|
this.mineskin = mineskin;
|
||||||
|
this.collection = collection;
|
||||||
}
|
}
|
||||||
|
|
||||||
public MojangProviderConfig mojang() {
|
public MojangProviderConfig mojang() {
|
||||||
return this.mojang;
|
return this.mojang;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ElyByProviderConfig ely_by() {
|
public ElyByProviderConfig ely_by() {
|
||||||
return this.ely_by;
|
return this.ely_by;
|
||||||
}
|
}
|
||||||
|
|
||||||
public MineskinProviderConfig mineskin() {
|
public MineskinProviderConfig mineskin() {
|
||||||
return this.mineskin;
|
return this.mineskin;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public CollectionProviderConfig collection() {
|
||||||
|
return this.collection;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void gsonPostProcess() {
|
public void gsonPostProcess() {
|
||||||
if (this.mojang == null) {
|
if (this.mojang == null) {
|
||||||
SkinRestorer.LOGGER.warn("Mojang provider config is null, using default");
|
SkinRestorer.LOGGER.warn("Mojang provider config is null, using default");
|
||||||
this.mojang = ProvidersConfig.DEFAULT.mojang();
|
this.mojang = ProvidersConfig.DEFAULT.mojang();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.ely_by == null) {
|
if (this.ely_by == null) {
|
||||||
SkinRestorer.LOGGER.warn("Ely.By provider config is null, using default");
|
SkinRestorer.LOGGER.warn("Ely.By provider config is null, using default");
|
||||||
this.ely_by = ProvidersConfig.DEFAULT.ely_by();
|
this.ely_by = ProvidersConfig.DEFAULT.ely_by();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.mineskin == null) {
|
if (this.mineskin == null) {
|
||||||
SkinRestorer.LOGGER.warn("Mineskin provider config is null, using default");
|
SkinRestorer.LOGGER.warn("Mineskin provider config is null, using default");
|
||||||
this.mineskin = ProvidersConfig.DEFAULT.mineskin();
|
this.mineskin = ProvidersConfig.DEFAULT.mineskin();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this.collection == null) {
|
||||||
|
SkinRestorer.LOGGER.warn("Collection provider config is null, using default");
|
||||||
|
this.collection = ProvidersConfig.DEFAULT.collection();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,32 @@
|
|||||||
|
package net.lionarius.skinrestorer.config.provider.collection;
|
||||||
|
|
||||||
|
import com.google.gson.annotations.JsonAdapter;
|
||||||
|
import net.lionarius.skinrestorer.config.provider.BuiltInProviderConfig;
|
||||||
|
import net.lionarius.skinrestorer.config.provider.CacheConfig;
|
||||||
|
import net.lionarius.skinrestorer.skin.provider.CollectionSkinProvider;
|
||||||
|
import net.lionarius.skinrestorer.util.gson.GsonPostProcessable;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public final class CollectionProviderConfig extends BuiltInProviderConfig implements GsonPostProcessable {
|
||||||
|
private static final CacheConfig DEFAULT_CACHE_VALUE = new CacheConfig(true, 604800);
|
||||||
|
|
||||||
|
@JsonAdapter(CollectionSkinSourceListDeserializer.class)
|
||||||
|
private List<CollectionSkinSource> sources = new ArrayList<>();
|
||||||
|
|
||||||
|
public CollectionProviderConfig() {
|
||||||
|
super(CollectionSkinProvider.PROVIDER_NAME, DEFAULT_CACHE_VALUE, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<CollectionSkinSource> sources() {
|
||||||
|
return this.sources;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void gsonPostProcess() {
|
||||||
|
if (this.sources == null) {
|
||||||
|
this.sources = new ArrayList<>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,60 @@
|
|||||||
|
package net.lionarius.skinrestorer.config.provider.collection;
|
||||||
|
|
||||||
|
import net.lionarius.skinrestorer.SkinRestorer;
|
||||||
|
import net.lionarius.skinrestorer.skin.SkinVariant;
|
||||||
|
import net.lionarius.skinrestorer.util.gson.GsonPostProcessable;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
import java.net.URI;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Path;
|
||||||
|
|
||||||
|
public final class CollectionSkinFile implements CollectionSkinSource, GsonPostProcessable {
|
||||||
|
private String path = "";
|
||||||
|
private SkinVariant variant = SkinVariant.CLASSIC;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @Nullable URI uri() {
|
||||||
|
if (this.path.isEmpty())
|
||||||
|
return null;
|
||||||
|
|
||||||
|
try {
|
||||||
|
var filePath = SkinRestorer.getConfigDir().resolve(this.path);
|
||||||
|
|
||||||
|
if (!Files.exists(filePath)) {
|
||||||
|
SkinRestorer.LOGGER.warn("Skin file does not exist: {}", this.path);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!Files.isRegularFile(filePath)) {
|
||||||
|
SkinRestorer.LOGGER.warn("Skin path is not a file: {}", this.path);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!this.path.toLowerCase().endsWith(".png")) {
|
||||||
|
SkinRestorer.LOGGER.warn("Skin file is not a PNG file: {}", this.path);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return filePath.toUri();
|
||||||
|
} catch (Exception e) {
|
||||||
|
SkinRestorer.LOGGER.warn("Invalid file path: {}", this.path, e);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SkinVariant variant() {
|
||||||
|
return this.variant;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void gsonPostProcess() {
|
||||||
|
if (this.path == null) {
|
||||||
|
this.path = "";
|
||||||
|
}
|
||||||
|
if (this.variant == null) {
|
||||||
|
this.variant = SkinVariant.CLASSIC;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
package net.lionarius.skinrestorer.config.provider.collection;
|
||||||
|
|
||||||
|
import net.lionarius.skinrestorer.skin.SkinVariant;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
import java.net.URI;
|
||||||
|
|
||||||
|
public interface CollectionSkinSource {
|
||||||
|
@Nullable URI uri();
|
||||||
|
|
||||||
|
SkinVariant variant();
|
||||||
|
}
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
package net.lionarius.skinrestorer.config.provider.collection;
|
||||||
|
|
||||||
|
import com.google.gson.*;
|
||||||
|
|
||||||
|
import java.lang.reflect.Type;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class CollectionSkinSourceListDeserializer implements JsonSerializer<List<CollectionSkinSource>>, JsonDeserializer<List<CollectionSkinSource>> {
|
||||||
|
@Override
|
||||||
|
public JsonElement serialize(List<CollectionSkinSource> src, Type typeOfT, JsonSerializationContext context) {
|
||||||
|
return context.serialize(src, List.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<CollectionSkinSource> deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context)
|
||||||
|
throws JsonParseException {
|
||||||
|
List<CollectionSkinSource> sources = new ArrayList<>();
|
||||||
|
|
||||||
|
if (json.isJsonArray()) {
|
||||||
|
for (JsonElement element : json.getAsJsonArray()) {
|
||||||
|
if (element.isJsonObject()) {
|
||||||
|
JsonObject obj = element.getAsJsonObject();
|
||||||
|
if (obj.has("url")) {
|
||||||
|
sources.add(context.deserialize(obj, CollectionSkinUrl.class));
|
||||||
|
} else if (obj.has("path")) {
|
||||||
|
sources.add(context.deserialize(obj, CollectionSkinFile.class));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return sources;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,41 @@
|
|||||||
|
package net.lionarius.skinrestorer.config.provider.collection;
|
||||||
|
|
||||||
|
import net.lionarius.skinrestorer.SkinRestorer;
|
||||||
|
import net.lionarius.skinrestorer.skin.SkinVariant;
|
||||||
|
import net.lionarius.skinrestorer.util.gson.GsonPostProcessable;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
import java.net.URI;
|
||||||
|
|
||||||
|
public final class CollectionSkinUrl implements CollectionSkinSource, GsonPostProcessable {
|
||||||
|
private String url = "";
|
||||||
|
private SkinVariant variant = SkinVariant.CLASSIC;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @Nullable URI uri() {
|
||||||
|
try {
|
||||||
|
if (this.url.isEmpty())
|
||||||
|
return null;
|
||||||
|
|
||||||
|
return new URI(this.url);
|
||||||
|
} catch (Exception e) {
|
||||||
|
SkinRestorer.LOGGER.warn("Invalid URI: {}", this.url, e);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SkinVariant variant() {
|
||||||
|
return this.variant;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void gsonPostProcess() {
|
||||||
|
if (this.url == null) {
|
||||||
|
this.url = "";
|
||||||
|
}
|
||||||
|
if (this.variant == null) {
|
||||||
|
this.variant = SkinVariant.CLASSIC;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
package net.lionarius.skinrestorer.exception;
|
||||||
|
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
public class TransparentException extends RuntimeException {
|
||||||
|
public TransparentException(@NotNull Throwable cause) {
|
||||||
|
super(cause);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getMessage() {
|
||||||
|
return this.getCause().getMessage();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return this.getLocalizedMessage();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -32,8 +32,8 @@ public class Java11RequestHandler extends RequestHandler {
|
|||||||
private final Gson gson;
|
private final Gson gson;
|
||||||
private final HttpClient httpClient;
|
private final HttpClient httpClient;
|
||||||
|
|
||||||
public Java11RequestHandler(String userAgent, String apiKey, int timeout, Gson gson, InetSocketAddress proxy) {
|
public Java11RequestHandler(String baseUrl, String userAgent, String apiKey, int timeout, Gson gson, InetSocketAddress proxy) {
|
||||||
super(userAgent, apiKey, timeout, gson);
|
super(baseUrl, userAgent, apiKey, timeout, gson);
|
||||||
this.gson = gson;
|
this.gson = gson;
|
||||||
|
|
||||||
HttpClient.Builder clientBuilder = HttpClient.newBuilder()
|
HttpClient.Builder clientBuilder = HttpClient.newBuilder()
|
||||||
@@ -85,6 +85,7 @@ public class Java11RequestHandler extends RequestHandler {
|
|||||||
|
|
||||||
public <T, R extends MineSkinResponse<T>> R getJson(String url, Class<T> clazz, ResponseConstructor<T, R> constructor)
|
public <T, R extends MineSkinResponse<T>> R getJson(String url, Class<T> clazz, ResponseConstructor<T, R> constructor)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
|
url = this.baseUrl + url;
|
||||||
MineSkinClientImpl.LOGGER.fine("GET " + url);
|
MineSkinClientImpl.LOGGER.fine("GET " + url);
|
||||||
|
|
||||||
HttpRequest.Builder requestBuilder = HttpRequest.newBuilder()
|
HttpRequest.Builder requestBuilder = HttpRequest.newBuilder()
|
||||||
@@ -110,6 +111,7 @@ public class Java11RequestHandler extends RequestHandler {
|
|||||||
|
|
||||||
public <T, R extends MineSkinResponse<T>> R postJson(String url, JsonObject data, Class<T> clazz, ResponseConstructor<T, R> constructor)
|
public <T, R extends MineSkinResponse<T>> R postJson(String url, JsonObject data, Class<T> clazz, ResponseConstructor<T, R> constructor)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
|
url = this.baseUrl + url;
|
||||||
MineSkinClientImpl.LOGGER.fine("POST " + url);
|
MineSkinClientImpl.LOGGER.fine("POST " + url);
|
||||||
|
|
||||||
HttpRequest.Builder requestBuilder = HttpRequest.newBuilder()
|
HttpRequest.Builder requestBuilder = HttpRequest.newBuilder()
|
||||||
@@ -137,6 +139,7 @@ public class Java11RequestHandler extends RequestHandler {
|
|||||||
|
|
||||||
public <T, R extends MineSkinResponse<T>> R postFormDataFile(String url, String key, String filename, InputStream in, Map<String, String> data, Class<T> clazz, ResponseConstructor<T, R> constructor)
|
public <T, R extends MineSkinResponse<T>> R postFormDataFile(String url, String key, String filename, InputStream in, Map<String, String> data, Class<T> clazz, ResponseConstructor<T, R> constructor)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
|
url = this.baseUrl + url;
|
||||||
MineSkinClientImpl.LOGGER.fine("POST " + url);
|
MineSkinClientImpl.LOGGER.fine("POST " + url);
|
||||||
|
|
||||||
String boundary = "mineskin-" + System.currentTimeMillis();
|
String boundary = "mineskin-" + System.currentTimeMillis();
|
||||||
|
|||||||
@@ -9,5 +9,5 @@ import org.spongepowered.asm.mixin.gen.Accessor;
|
|||||||
public interface ChunkMapAccessor {
|
public interface ChunkMapAccessor {
|
||||||
|
|
||||||
@Accessor
|
@Accessor
|
||||||
Int2ObjectMap<Object> getEntityMap();
|
Int2ObjectMap<TrackedEntityAccessorInvoker> getEntityMap();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,14 @@
|
|||||||
|
package net.lionarius.skinrestorer.mixin;
|
||||||
|
|
||||||
|
import net.minecraft.server.players.GameProfileCache;
|
||||||
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
import org.spongepowered.asm.mixin.gen.Accessor;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
@Mixin(GameProfileCache.class)
|
||||||
|
public interface GameProfileCacheAccessor {
|
||||||
|
|
||||||
|
@Accessor
|
||||||
|
Map<String, GameProfileCache.GameProfileInfo> getProfilesByName();
|
||||||
|
}
|
||||||
@@ -4,11 +4,11 @@ import net.lionarius.skinrestorer.SkinRestorer;
|
|||||||
import net.minecraft.network.Connection;
|
import net.minecraft.network.Connection;
|
||||||
import net.minecraft.server.MinecraftServer;
|
import net.minecraft.server.MinecraftServer;
|
||||||
import net.minecraft.server.level.ServerPlayer;
|
import net.minecraft.server.level.ServerPlayer;
|
||||||
import net.minecraft.server.network.CommonListenerCookie;
|
|
||||||
import net.minecraft.server.players.PlayerList;
|
import net.minecraft.server.players.PlayerList;
|
||||||
import org.spongepowered.asm.mixin.Final;
|
import org.spongepowered.asm.mixin.Final;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
import org.spongepowered.asm.mixin.Shadow;
|
import org.spongepowered.asm.mixin.Shadow;
|
||||||
|
import org.spongepowered.asm.mixin.Unique;
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
import org.spongepowered.asm.mixin.injection.Inject;
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||||
@@ -38,7 +38,23 @@ public abstract class PlayerListMixin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Inject(method = "placeNewPlayer", at = @At("HEAD"))
|
@Inject(method = "placeNewPlayer", at = @At("HEAD"))
|
||||||
private void placeNewPlayer(Connection connection, ServerPlayer player, CommonListenerCookie cookie, CallbackInfo ci) {
|
private void placeNewPlayer(Connection connection, ServerPlayer player, CallbackInfo ci) {
|
||||||
|
var delay = SkinRestorer.getConfig().skinApplyDelayOnJoin();
|
||||||
|
|
||||||
|
if (delay <= 0) {
|
||||||
|
skinrestorer$tryApplySkin(server, player);
|
||||||
|
} else {
|
||||||
|
var uuid = player.getUUID();
|
||||||
|
SkinRestorer.getTickedScheduler().schedule(() -> {
|
||||||
|
var actualPlayer = server.getPlayerList().getPlayer(uuid);
|
||||||
|
if (actualPlayer != null)
|
||||||
|
skinrestorer$tryApplySkin(server, actualPlayer);
|
||||||
|
}, delay, uuid);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Unique
|
||||||
|
private static void skinrestorer$tryApplySkin(MinecraftServer server, ServerPlayer player) {
|
||||||
if (SkinRestorer.getSkinStorage().hasSavedSkin(player.getUUID()))
|
if (SkinRestorer.getSkinStorage().hasSavedSkin(player.getUUID()))
|
||||||
SkinRestorer.applySkin(server, Collections.singleton(player.getGameProfile()), SkinRestorer.getSkinStorage().getSkin(player.getUUID()));
|
SkinRestorer.applySkin(server, Collections.singleton(player.getGameProfile()), SkinRestorer.getSkinStorage().getSkin(player.getUUID()));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package net.lionarius.skinrestorer.mixin;
|
|||||||
|
|
||||||
import com.mojang.authlib.GameProfile;
|
import com.mojang.authlib.GameProfile;
|
||||||
import net.lionarius.skinrestorer.SkinRestorer;
|
import net.lionarius.skinrestorer.SkinRestorer;
|
||||||
|
import net.lionarius.skinrestorer.config.FirstJoinSkinProvider;
|
||||||
import net.lionarius.skinrestorer.skin.SkinValue;
|
import net.lionarius.skinrestorer.skin.SkinValue;
|
||||||
import net.lionarius.skinrestorer.skin.provider.SkinProviderContext;
|
import net.lionarius.skinrestorer.skin.provider.SkinProviderContext;
|
||||||
import net.lionarius.skinrestorer.util.PlayerUtils;
|
import net.lionarius.skinrestorer.util.PlayerUtils;
|
||||||
@@ -21,20 +22,24 @@ import java.util.concurrent.CompletableFuture;
|
|||||||
public abstract class ServerLoginPacketListenerImplMixin {
|
public abstract class ServerLoginPacketListenerImplMixin {
|
||||||
|
|
||||||
@Shadow @Nullable
|
@Shadow @Nullable
|
||||||
private GameProfile authenticatedProfile;
|
private GameProfile gameProfile;
|
||||||
|
|
||||||
|
@Shadow
|
||||||
|
protected abstract GameProfile createFakeProfile(GameProfile original);
|
||||||
|
|
||||||
@Unique
|
@Unique
|
||||||
private CompletableFuture<Void> skinrestorer$pendingSkin;
|
private CompletableFuture<Void> skinrestorer$pendingSkin;
|
||||||
|
|
||||||
@Inject(method = "verifyLoginAndFinishConnectionSetup", at = @At(value = "INVOKE",
|
@Inject(method = "handleAcceptedLogin", at = @At(value = "HEAD"), cancellable = true)
|
||||||
target = "Lnet/minecraft/server/players/PlayerList;canPlayerLogin(Ljava/net/SocketAddress;Lcom/mojang/authlib/GameProfile;)Lnet/minecraft/network/chat/Component;"),
|
|
||||||
cancellable = true)
|
|
||||||
public void waitForSkin(CallbackInfo ci) {
|
public void waitForSkin(CallbackInfo ci) {
|
||||||
if (skinrestorer$pendingSkin == null) {
|
if (skinrestorer$pendingSkin == null) {
|
||||||
skinrestorer$pendingSkin = CompletableFuture.supplyAsync(() -> {
|
skinrestorer$pendingSkin = CompletableFuture.supplyAsync(() -> {
|
||||||
final var profile = authenticatedProfile;
|
var profile = gameProfile;
|
||||||
|
|
||||||
assert profile != null;
|
assert profile != null;
|
||||||
|
|
||||||
|
if (!profile.isComplete())
|
||||||
|
profile = createFakeProfile(profile);
|
||||||
|
|
||||||
var originalSkin = PlayerUtils.getPlayerSkin(profile);
|
var originalSkin = PlayerUtils.getPlayerSkin(profile);
|
||||||
|
|
||||||
if (SkinRestorer.getSkinStorage().hasSavedSkin(profile.getId())) {
|
if (SkinRestorer.getSkinStorage().hasSavedSkin(profile.getId())) {
|
||||||
@@ -53,9 +58,15 @@ public abstract class ServerLoginPacketListenerImplMixin {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (originalSkin == null && SkinRestorer.getConfig().fetchSkinOnFirstJoin()) {
|
var config = SkinRestorer.getConfig();
|
||||||
|
var provider = config.firstJoinSkinProvider();
|
||||||
|
|
||||||
|
var shouldFetch = (originalSkin == null && config.fetchSkinOnFirstJoin()) ||
|
||||||
|
(originalSkin != null && config.forceFirstJoinSkinFetch() && provider != FirstJoinSkinProvider.MOJANG);
|
||||||
|
|
||||||
|
if (shouldFetch) {
|
||||||
var context = new SkinProviderContext(
|
var context = new SkinProviderContext(
|
||||||
SkinRestorer.getConfig().firstJoinSkinProvider().getName(),
|
provider.getName(),
|
||||||
profile.getName(),
|
profile.getName(),
|
||||||
null
|
null
|
||||||
);
|
);
|
||||||
@@ -82,7 +93,7 @@ public abstract class ServerLoginPacketListenerImplMixin {
|
|||||||
var value = SkinValue.fromProviderContextWithValue(context, result.getSuccessValue().orElse(null));
|
var value = SkinValue.fromProviderContextWithValue(context, result.getSuccessValue().orElse(null));
|
||||||
SkinRestorer.getSkinStorage().setSkin(profile.getId(), value);
|
SkinRestorer.getSkinStorage().setSkin(profile.getId(), value);
|
||||||
} else {
|
} else {
|
||||||
SkinRestorer.LOGGER.warn("Failed to fetch skin: {}", result.getErrorValue().getMessage());
|
SkinRestorer.LOGGER.warn("Failed to fetch skin '{}:{}'", context.name(), context.argument(), result.getErrorValue());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,58 @@
|
|||||||
|
package net.lionarius.skinrestorer.mixin;
|
||||||
|
|
||||||
|
import com.mojang.authlib.GameProfile;
|
||||||
|
import net.lionarius.skinrestorer.SkinRestorer;
|
||||||
|
import net.lionarius.skinrestorer.util.PlayerUtils;
|
||||||
|
import net.minecraft.server.players.GameProfileCache;
|
||||||
|
import net.minecraft.world.level.block.entity.SkullBlockEntity;
|
||||||
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
import org.spongepowered.asm.mixin.Shadow;
|
||||||
|
import org.spongepowered.asm.mixin.Unique;
|
||||||
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||||
|
|
||||||
|
import java.util.Locale;
|
||||||
|
import java.util.Optional;
|
||||||
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
|
@Mixin(SkullBlockEntity.class)
|
||||||
|
public abstract class SkullBlockEntityMixin {
|
||||||
|
|
||||||
|
@Shadow
|
||||||
|
private static GameProfileCache profileCache;
|
||||||
|
|
||||||
|
@Inject(method = "updateGameprofile", at = @At("HEAD"),
|
||||||
|
cancellable = true)
|
||||||
|
private static void fetchProfileByName(GameProfile profile, Consumer<GameProfile> profileConsumer, CallbackInfo ci) {
|
||||||
|
if (profileCache == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (profile == null || profile.isComplete() || profile.getName() == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
var profileOpt = Optional.<GameProfile>empty();
|
||||||
|
var gameProfileInfo = ((GameProfileCacheAccessor) profileCache).getProfilesByName().get(profile.getName().toLowerCase(Locale.ROOT));
|
||||||
|
|
||||||
|
if (gameProfileInfo != null)
|
||||||
|
profileOpt = Optional.of(gameProfileInfo.getProfile());
|
||||||
|
|
||||||
|
skinrestorer$replaceSkin(profileOpt, profileConsumer, ci);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Unique
|
||||||
|
private static void skinrestorer$replaceSkin(Optional<GameProfile> profileOpt, Consumer<GameProfile> profileConsumer, CallbackInfo ci) {
|
||||||
|
if (profileOpt.isEmpty())
|
||||||
|
return;
|
||||||
|
|
||||||
|
var profile = PlayerUtils.cloneGameProfile(profileOpt.get());
|
||||||
|
|
||||||
|
if (SkinRestorer.getSkinStorage().hasSavedSkin(profile.getId())) {
|
||||||
|
var skin = SkinRestorer.getSkinStorage().getSkin(profile.getId(), false);
|
||||||
|
PlayerUtils.applyRestoredSkin(profile, skin.value());
|
||||||
|
|
||||||
|
profileConsumer.accept(profile);
|
||||||
|
ci.cancel();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -8,11 +8,11 @@ import java.util.ServiceLoader;
|
|||||||
|
|
||||||
public final class Services {
|
public final class Services {
|
||||||
|
|
||||||
private Services() {}
|
|
||||||
|
|
||||||
public final static PlatformHelper PLATFORM = load(PlatformHelper.class);
|
public final static PlatformHelper PLATFORM = load(PlatformHelper.class);
|
||||||
public final static CompatibilityHelper COMPATIBILITY = load(CompatibilityHelper.class);
|
public final static CompatibilityHelper COMPATIBILITY = load(CompatibilityHelper.class);
|
||||||
|
|
||||||
|
private Services() {}
|
||||||
|
|
||||||
private static <T> T load(Class<T> clazz) {
|
private static <T> T load(Class<T> clazz) {
|
||||||
final T loadedService = ServiceLoader.load(clazz)
|
final T loadedService = ServiceLoader.load(clazz)
|
||||||
.findFirst()
|
.findFirst()
|
||||||
|
|||||||
@@ -27,9 +27,7 @@ public class SkinIO {
|
|||||||
|
|
||||||
public SkinValue loadSkin(UUID uuid) {
|
public SkinValue loadSkin(UUID uuid) {
|
||||||
try {
|
try {
|
||||||
var value = SkinIO.loadSkin(savePath.resolve(SkinIO.uuidToFilename(uuid)));
|
return SkinIO.loadSkin(savePath.resolve(SkinIO.uuidToFilename(uuid)));
|
||||||
Objects.requireNonNull(value.provider());
|
|
||||||
return value;
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
return SkinValue.EMPTY;
|
return SkinValue.EMPTY;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,15 +17,22 @@ public class SkinStorage {
|
|||||||
return this.skinMap.containsKey(uuid) || this.skinIO.skinExists(uuid);
|
return this.skinMap.containsKey(uuid) || this.skinIO.skinExists(uuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
public SkinValue getSkin(UUID uuid) {
|
public SkinValue getSkin(UUID uuid, boolean cache) {
|
||||||
if (!skinMap.containsKey(uuid)) {
|
if (!skinMap.containsKey(uuid)) {
|
||||||
var skin = skinIO.loadSkin(uuid);
|
var skin = skinIO.loadSkin(uuid);
|
||||||
|
if (!cache)
|
||||||
|
return skin;
|
||||||
|
|
||||||
setSkin(uuid, skin);
|
setSkin(uuid, skin);
|
||||||
}
|
}
|
||||||
|
|
||||||
return skinMap.get(uuid);
|
return skinMap.get(uuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public SkinValue getSkin(UUID uuid) {
|
||||||
|
return this.getSkin(uuid, true);
|
||||||
|
}
|
||||||
|
|
||||||
public void removeSkin(UUID uuid, boolean save) {
|
public void removeSkin(UUID uuid, boolean save) {
|
||||||
var skin = skinMap.remove(uuid);
|
var skin = skinMap.remove(uuid);
|
||||||
if (skin != null && save)
|
if (skin != null && save)
|
||||||
|
|||||||
@@ -3,11 +3,14 @@ package net.lionarius.skinrestorer.skin;
|
|||||||
import com.mojang.authlib.properties.Property;
|
import com.mojang.authlib.properties.Property;
|
||||||
import net.lionarius.skinrestorer.skin.provider.EmptySkinProvider;
|
import net.lionarius.skinrestorer.skin.provider.EmptySkinProvider;
|
||||||
import net.lionarius.skinrestorer.skin.provider.SkinProviderContext;
|
import net.lionarius.skinrestorer.skin.provider.SkinProviderContext;
|
||||||
|
import net.lionarius.skinrestorer.util.gson.GsonPostProcessable;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
public record SkinValue(@NotNull String provider, @Nullable String argument, @Nullable SkinVariant variant,
|
public record SkinValue(@NotNull String provider, @Nullable String argument, @Nullable SkinVariant variant,
|
||||||
@Nullable Property value, @Nullable Property originalValue) {
|
@Nullable Property value, @Nullable Property originalValue) implements GsonPostProcessable {
|
||||||
|
|
||||||
public static final SkinValue EMPTY = new SkinValue(EmptySkinProvider.PROVIDER_NAME, null, null, null);
|
public static final SkinValue EMPTY = new SkinValue(EmptySkinProvider.PROVIDER_NAME, null, null, null);
|
||||||
|
|
||||||
@@ -30,4 +33,9 @@ public record SkinValue(@NotNull String provider, @Nullable String argument, @Nu
|
|||||||
public SkinValue setOriginalValue(Property originalValue) {
|
public SkinValue setOriginalValue(Property originalValue) {
|
||||||
return new SkinValue(this.provider, this.argument, this.variant, this.value, originalValue);
|
return new SkinValue(this.provider, this.argument, this.variant, this.value, originalValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void gsonPostProcess() {
|
||||||
|
Objects.requireNonNull(this.provider);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,11 @@
|
|||||||
package net.lionarius.skinrestorer.skin;
|
package net.lionarius.skinrestorer.skin;
|
||||||
|
|
||||||
|
import com.google.gson.annotations.SerializedName;
|
||||||
|
|
||||||
public enum SkinVariant {
|
public enum SkinVariant {
|
||||||
|
@SerializedName(value = "classic", alternate = {"CLASSIC"})
|
||||||
CLASSIC("classic"),
|
CLASSIC("classic"),
|
||||||
|
@SerializedName(value = "slim", alternate = {"SLIM"})
|
||||||
SLIM("slim");
|
SLIM("slim");
|
||||||
|
|
||||||
private final String name;
|
private final String name;
|
||||||
|
|||||||
@@ -0,0 +1,91 @@
|
|||||||
|
package net.lionarius.skinrestorer.skin.provider;
|
||||||
|
|
||||||
|
import com.google.common.cache.CacheBuilder;
|
||||||
|
import com.google.common.cache.CacheLoader;
|
||||||
|
import com.google.common.cache.LoadingCache;
|
||||||
|
import com.google.common.util.concurrent.UncheckedExecutionException;
|
||||||
|
import com.mojang.authlib.properties.Property;
|
||||||
|
import it.unimi.dsi.fastutil.Pair;
|
||||||
|
import net.lionarius.skinrestorer.SkinRestorer;
|
||||||
|
import net.lionarius.skinrestorer.config.provider.collection.CollectionSkinSource;
|
||||||
|
import net.lionarius.skinrestorer.skin.SkinVariant;
|
||||||
|
import net.lionarius.skinrestorer.util.Result;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import java.net.URI;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
public final class CollectionSkinProvider implements SkinProvider {
|
||||||
|
|
||||||
|
public static final String PROVIDER_NAME = "collection";
|
||||||
|
|
||||||
|
private static LoadingCache<Integer, Optional<Property>> SKIN_CACHE;
|
||||||
|
|
||||||
|
private static List<Pair<URI, SkinVariant>> COLLECTION_SKINS;
|
||||||
|
|
||||||
|
public static void reload() {
|
||||||
|
COLLECTION_SKINS = loadCollectionSkins();
|
||||||
|
|
||||||
|
createCache();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static List<Pair<URI, SkinVariant>> loadCollectionSkins() {
|
||||||
|
List<Pair<URI, SkinVariant>> skins = new ArrayList<>();
|
||||||
|
|
||||||
|
var config = SkinRestorer.getConfig().providersConfig().collection();
|
||||||
|
|
||||||
|
for (CollectionSkinSource source : config.sources()) {
|
||||||
|
var uri = source.uri();
|
||||||
|
if (uri != null) {
|
||||||
|
skins.add(Pair.of(uri, source.variant()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return skins;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void createCache() {
|
||||||
|
var config = SkinRestorer.getConfig().providersConfig().collection();
|
||||||
|
var time = config.cache().enabled() ? config.cache().duration() : 0;
|
||||||
|
|
||||||
|
SKIN_CACHE = CacheBuilder.newBuilder()
|
||||||
|
.expireAfterWrite(time, TimeUnit.SECONDS)
|
||||||
|
.build(new CacheLoader<>() {
|
||||||
|
@Override
|
||||||
|
public @NotNull Optional<Property> load(@NotNull Integer key) throws Exception {
|
||||||
|
var skinEntry = COLLECTION_SKINS.get(key);
|
||||||
|
return MineskinSkinProvider.loadSkin(skinEntry.first(), skinEntry.second());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getArgumentName() {
|
||||||
|
return "seed";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean hasVariantSupport() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Result<Optional<Property>, Exception> fetchSkin(String argument, SkinVariant variant) {
|
||||||
|
if (COLLECTION_SKINS.isEmpty()) {
|
||||||
|
return Result.error(new IllegalStateException("No collection skins configured"));
|
||||||
|
}
|
||||||
|
|
||||||
|
var skinIndex = Math.abs(argument.hashCode()) % COLLECTION_SKINS.size();
|
||||||
|
|
||||||
|
try {
|
||||||
|
return Result.success(SKIN_CACHE.get(skinIndex));
|
||||||
|
} catch (UncheckedExecutionException e) {
|
||||||
|
return Result.error((Exception) e.getCause());
|
||||||
|
} catch (Exception e) {
|
||||||
|
return Result.error(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -102,6 +102,6 @@ public final class ElyBySkinProvider implements SkinProvider {
|
|||||||
if (response.statusCode() != 200)
|
if (response.statusCode() != 200)
|
||||||
throw new IllegalArgumentException("no profile with name " + username);
|
throw new IllegalArgumentException("no profile with name " + username);
|
||||||
|
|
||||||
return JsonUtils.fromJson(response.body(), MinecraftProfilePropertiesResponse.class).toProfile();
|
return PlayerUtils.toProfile(JsonUtils.fromJson(response.body(), MinecraftProfilePropertiesResponse.class));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,7 +22,8 @@ import org.mineskin.response.QueueResponse;
|
|||||||
|
|
||||||
import java.net.InetSocketAddress;
|
import java.net.InetSocketAddress;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.net.URISyntaxException;
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Path;
|
||||||
import java.time.Duration;
|
import java.time.Duration;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
@@ -31,19 +32,10 @@ public final class MineskinSkinProvider implements SkinProvider {
|
|||||||
|
|
||||||
public static final String PROVIDER_NAME = "web";
|
public static final String PROVIDER_NAME = "web";
|
||||||
|
|
||||||
private static final URI API_URI;
|
|
||||||
private static MineSkinClient MINESKIN_CLIENT;
|
private static MineSkinClient MINESKIN_CLIENT;
|
||||||
|
|
||||||
private static LoadingCache<Pair<URI, SkinVariant>, Optional<Property>> SKIN_CACHE;
|
private static LoadingCache<Pair<URI, SkinVariant>, Optional<Property>> SKIN_CACHE;
|
||||||
|
|
||||||
static {
|
|
||||||
try {
|
|
||||||
API_URI = new URI("https://api.mineskin.org");
|
|
||||||
} catch (URISyntaxException e) {
|
|
||||||
throw new IllegalArgumentException(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void reload() {
|
public static void reload() {
|
||||||
var config = SkinRestorer.getConfig();
|
var config = SkinRestorer.getConfig();
|
||||||
var configApiKey = config.providersConfig().mineskin().apiKey();
|
var configApiKey = config.providersConfig().mineskin().apiKey();
|
||||||
@@ -53,7 +45,8 @@ public final class MineskinSkinProvider implements SkinProvider {
|
|||||||
.userAgent(WebUtils.USER_AGENT)
|
.userAgent(WebUtils.USER_AGENT)
|
||||||
.gson(JsonUtils.GSON)
|
.gson(JsonUtils.GSON)
|
||||||
.timeout((int) Duration.ofSeconds(config.requestTimeout()).toMillis())
|
.timeout((int) Duration.ofSeconds(config.requestTimeout()).toMillis())
|
||||||
.requestHandler((userAgent, apiKey, timeout, gson) -> new Java11RequestHandler(
|
.requestHandler((baseUrl, userAgent, apiKey, timeout, gson) -> new Java11RequestHandler(
|
||||||
|
baseUrl,
|
||||||
userAgent,
|
userAgent,
|
||||||
apiKey,
|
apiKey,
|
||||||
timeout,
|
timeout,
|
||||||
@@ -103,13 +96,18 @@ public final class MineskinSkinProvider implements SkinProvider {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Optional<Property> loadSkin(URI uri, SkinVariant variant) throws Exception {
|
static Optional<Property> loadSkin(URI uri, SkinVariant variant) throws Exception {
|
||||||
var mineskinVariant = switch (variant) {
|
var mineskinVariant = switch (variant) {
|
||||||
case CLASSIC -> Variant.CLASSIC;
|
case CLASSIC -> Variant.CLASSIC;
|
||||||
case SLIM -> Variant.SLIM;
|
case SLIM -> Variant.SLIM;
|
||||||
};
|
};
|
||||||
|
|
||||||
var request = GenerateRequest.url(uri)
|
var request = "file".equals(uri.getScheme())
|
||||||
|
? GenerateRequest.upload(Files.newInputStream(Path.of(uri)))
|
||||||
|
.variant(mineskinVariant)
|
||||||
|
.name("skinrestorer-skin")
|
||||||
|
.visibility(Visibility.UNLISTED)
|
||||||
|
: GenerateRequest.url(uri)
|
||||||
.variant(mineskinVariant)
|
.variant(mineskinVariant)
|
||||||
.name("skinrestorer-skin")
|
.name("skinrestorer-skin")
|
||||||
.visibility(Visibility.UNLISTED);
|
.visibility(Visibility.UNLISTED);
|
||||||
|
|||||||
@@ -4,11 +4,12 @@ import com.google.common.cache.CacheBuilder;
|
|||||||
import com.google.common.cache.CacheLoader;
|
import com.google.common.cache.CacheLoader;
|
||||||
import com.google.common.cache.LoadingCache;
|
import com.google.common.cache.LoadingCache;
|
||||||
import com.google.common.util.concurrent.UncheckedExecutionException;
|
import com.google.common.util.concurrent.UncheckedExecutionException;
|
||||||
import com.mojang.authlib.GameProfile;
|
import com.mojang.authlib.*;
|
||||||
import com.mojang.authlib.properties.Property;
|
import com.mojang.authlib.properties.Property;
|
||||||
|
import com.mojang.authlib.yggdrasil.YggdrasilEnvironment;
|
||||||
import com.mojang.authlib.yggdrasil.response.MinecraftProfilePropertiesResponse;
|
import com.mojang.authlib.yggdrasil.response.MinecraftProfilePropertiesResponse;
|
||||||
import com.mojang.util.UndashedUuid;
|
|
||||||
import net.lionarius.skinrestorer.SkinRestorer;
|
import net.lionarius.skinrestorer.SkinRestorer;
|
||||||
|
import net.lionarius.skinrestorer.exception.TransparentException;
|
||||||
import net.lionarius.skinrestorer.skin.SkinVariant;
|
import net.lionarius.skinrestorer.skin.SkinVariant;
|
||||||
import net.lionarius.skinrestorer.util.*;
|
import net.lionarius.skinrestorer.util.*;
|
||||||
import net.minecraft.server.players.GameProfileCache;
|
import net.minecraft.server.players.GameProfileCache;
|
||||||
@@ -26,7 +27,8 @@ public final class MojangSkinProvider implements SkinProvider {
|
|||||||
|
|
||||||
public static final String PROVIDER_NAME = "mojang";
|
public static final String PROVIDER_NAME = "mojang";
|
||||||
|
|
||||||
private static final URI API_URI;
|
private static final Environment ENVIRONMENT;
|
||||||
|
private static final URI SERVICES_SERVER_URI;
|
||||||
private static final URI SESSION_SERVER_URI;
|
private static final URI SESSION_SERVER_URI;
|
||||||
|
|
||||||
public static final String PROFILE_CACHE_FILENAME = "mojang_profile_cache.json";
|
public static final String PROFILE_CACHE_FILENAME = "mojang_profile_cache.json";
|
||||||
@@ -36,19 +38,21 @@ public final class MojangSkinProvider implements SkinProvider {
|
|||||||
|
|
||||||
static {
|
static {
|
||||||
try {
|
try {
|
||||||
API_URI = new URI("https://api.mojang.com");
|
ENVIRONMENT = EnvironmentParser.getEnvironmentFromProperties().orElse(YggdrasilEnvironment.PROD.getEnvironment());
|
||||||
SESSION_SERVER_URI = new URI("https://sessionserver.mojang.com");
|
|
||||||
|
SERVICES_SERVER_URI = new URI(ENVIRONMENT.getServicesHost());
|
||||||
|
SESSION_SERVER_URI = new URI(ENVIRONMENT.getSessionHost());
|
||||||
} catch (URISyntaxException e) {
|
} catch (URISyntaxException e) {
|
||||||
throw new IllegalArgumentException(e);
|
throw new IllegalArgumentException(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
PROFILE_CACHE = new GameProfileCache((names, callback) -> {
|
PROFILE_CACHE = new GameProfileCache((names, agent, callback) -> {
|
||||||
for (var name : names) {
|
for (var name : names) {
|
||||||
try {
|
try {
|
||||||
var profile = MojangSkinProvider.getProfile(name);
|
var profile = MojangSkinProvider.getProfile(name);
|
||||||
callback.onProfileLookupSucceeded(profile);
|
callback.onProfileLookupSucceeded(profile);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
callback.onProfileLookupFailed(name, e);
|
throw new TransparentException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, SkinRestorer.getConfigDir().resolve(PROFILE_CACHE_FILENAME).toFile());
|
}, SkinRestorer.getConfigDir().resolve(PROFILE_CACHE_FILENAME).toFile());
|
||||||
@@ -113,8 +117,8 @@ public final class MojangSkinProvider implements SkinProvider {
|
|||||||
|
|
||||||
private static GameProfile getProfile(final String name) throws IOException {
|
private static GameProfile getProfile(final String name) throws IOException {
|
||||||
var request = HttpRequest.newBuilder()
|
var request = HttpRequest.newBuilder()
|
||||||
.uri(MojangSkinProvider.API_URI
|
.uri(MojangSkinProvider.SERVICES_SERVER_URI
|
||||||
.resolve("/users/profiles/minecraft/")
|
.resolve("/minecraft/profile/lookup/name/")
|
||||||
.resolve(name)
|
.resolve(name)
|
||||||
)
|
)
|
||||||
.GET()
|
.GET()
|
||||||
@@ -133,7 +137,7 @@ public final class MojangSkinProvider implements SkinProvider {
|
|||||||
var request = HttpRequest.newBuilder()
|
var request = HttpRequest.newBuilder()
|
||||||
.uri(MojangSkinProvider.SESSION_SERVER_URI
|
.uri(MojangSkinProvider.SESSION_SERVER_URI
|
||||||
.resolve("/session/minecraft/profile/")
|
.resolve("/session/minecraft/profile/")
|
||||||
.resolve(UndashedUuid.toString(uuid) + "?unsigned=false")
|
.resolve(uuid.toString() + "?unsigned=false")
|
||||||
)
|
)
|
||||||
.GET()
|
.GET()
|
||||||
.build();
|
.build();
|
||||||
@@ -144,6 +148,6 @@ public final class MojangSkinProvider implements SkinProvider {
|
|||||||
if (response.statusCode() != 200)
|
if (response.statusCode() != 200)
|
||||||
throw new IllegalArgumentException("no profile with uuid " + uuid);
|
throw new IllegalArgumentException("no profile with uuid " + uuid);
|
||||||
|
|
||||||
return JsonUtils.fromJson(response.body(), MinecraftProfilePropertiesResponse.class).toProfile();
|
return PlayerUtils.toProfile(JsonUtils.fromJson(response.body(), MinecraftProfilePropertiesResponse.class));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ public interface SkinProvider {
|
|||||||
MojangSkinProvider MOJANG = new MojangSkinProvider();
|
MojangSkinProvider MOJANG = new MojangSkinProvider();
|
||||||
ElyBySkinProvider ELY_BY = new ElyBySkinProvider();
|
ElyBySkinProvider ELY_BY = new ElyBySkinProvider();
|
||||||
MineskinSkinProvider MINESKIN = new MineskinSkinProvider();
|
MineskinSkinProvider MINESKIN = new MineskinSkinProvider();
|
||||||
|
CollectionSkinProvider COLLECTION = new CollectionSkinProvider();
|
||||||
SkinShuffleSkinProvider SKIN_SHUFFLE = new SkinShuffleSkinProvider();
|
SkinShuffleSkinProvider SKIN_SHUFFLE = new SkinShuffleSkinProvider();
|
||||||
|
|
||||||
Set<String> BUILTIN_PROVIDER_NAMES = ImmutableSet.of(
|
Set<String> BUILTIN_PROVIDER_NAMES = ImmutableSet.of(
|
||||||
@@ -20,6 +21,7 @@ public interface SkinProvider {
|
|||||||
MojangSkinProvider.PROVIDER_NAME,
|
MojangSkinProvider.PROVIDER_NAME,
|
||||||
ElyBySkinProvider.PROVIDER_NAME,
|
ElyBySkinProvider.PROVIDER_NAME,
|
||||||
MineskinSkinProvider.PROVIDER_NAME,
|
MineskinSkinProvider.PROVIDER_NAME,
|
||||||
|
CollectionSkinProvider.PROVIDER_NAME,
|
||||||
SkinShuffleSkinProvider.PROVIDER_NAME
|
SkinShuffleSkinProvider.PROVIDER_NAME
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ public final class JsonUtils {
|
|||||||
|
|
||||||
public static JsonObject skinPropertyToJson(Property property) {
|
public static JsonObject skinPropertyToJson(Property property) {
|
||||||
try {
|
try {
|
||||||
JsonObject json = GSON.fromJson(new String(Base64.getDecoder().decode(property.value()), StandardCharsets.UTF_8), JsonObject.class);
|
JsonObject json = GSON.fromJson(new String(Base64.getDecoder().decode(property.getValue()), StandardCharsets.UTF_8), JsonObject.class);
|
||||||
if (json != null)
|
if (json != null)
|
||||||
json.remove("timestamp");
|
json.remove("timestamp");
|
||||||
|
|
||||||
|
|||||||
@@ -6,13 +6,13 @@ import com.mojang.authlib.GameProfile;
|
|||||||
import com.mojang.authlib.properties.Property;
|
import com.mojang.authlib.properties.Property;
|
||||||
import com.mojang.authlib.yggdrasil.response.MinecraftProfilePropertiesResponse;
|
import com.mojang.authlib.yggdrasil.response.MinecraftProfilePropertiesResponse;
|
||||||
import net.lionarius.skinrestorer.mixin.ChunkMapAccessor;
|
import net.lionarius.skinrestorer.mixin.ChunkMapAccessor;
|
||||||
import net.lionarius.skinrestorer.mixin.TrackedEntityAccessorInvoker;
|
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.network.chat.Component;
|
||||||
import net.minecraft.network.protocol.game.*;
|
import net.minecraft.network.protocol.game.*;
|
||||||
import net.minecraft.server.level.ChunkMap;
|
import net.minecraft.server.level.ChunkMap;
|
||||||
import net.minecraft.server.level.ServerLevel;
|
import net.minecraft.server.level.ServerLevel;
|
||||||
import net.minecraft.server.level.ServerPlayer;
|
import net.minecraft.server.level.ServerPlayer;
|
||||||
import net.minecraft.server.players.PlayerList;
|
import net.minecraft.server.players.PlayerList;
|
||||||
|
import net.minecraft.world.level.biome.BiomeManager;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
@@ -50,14 +50,14 @@ public final class PlayerUtils {
|
|||||||
)
|
)
|
||||||
));
|
));
|
||||||
|
|
||||||
var trackedEntity = (TrackedEntityAccessorInvoker) ((ChunkMapAccessor) chunkMap).getEntityMap().get(player.getId());
|
var trackedEntity = ((ChunkMapAccessor) chunkMap).getEntityMap().get(player.getId());
|
||||||
if (trackedEntity != null) {
|
if (trackedEntity != null) {
|
||||||
var seenBy = Set.copyOf(trackedEntity.getSeenBy());
|
var seenBy = Set.copyOf(trackedEntity.getSeenBy());
|
||||||
for (var observerConnection : seenBy) {
|
for (var observerConnection : seenBy) {
|
||||||
var observer = observerConnection.getPlayer();
|
var observer = observerConnection.getPlayer();
|
||||||
trackedEntity.invokeRemovePlayer(observer);
|
trackedEntity.invokeRemovePlayer(observer);
|
||||||
|
|
||||||
var trackedObserverEntity = (TrackedEntityAccessorInvoker) ((ChunkMapAccessor) chunkMap).getEntityMap().get(observer.getId());
|
var trackedObserverEntity = ((ChunkMapAccessor) chunkMap).getEntityMap().get(observer.getId());
|
||||||
if (trackedObserverEntity != null) {
|
if (trackedObserverEntity != null) {
|
||||||
trackedObserverEntity.invokeRemovePlayer(player);
|
trackedObserverEntity.invokeRemovePlayer(player);
|
||||||
trackedObserverEntity.invokeUpdatePlayer(player);
|
trackedObserverEntity.invokeUpdatePlayer(player);
|
||||||
@@ -67,12 +67,20 @@ public final class PlayerUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!player.isDeadOrDying()) {
|
if (!player.isDeadOrDying()) {
|
||||||
player.connection.send(new ClientboundBundlePacket(
|
player.connection.send(
|
||||||
List.of(
|
new ClientboundRespawnPacket(
|
||||||
new ClientboundRespawnPacket(player.createCommonSpawnInfo(serverLevel), ClientboundRespawnPacket.KEEP_ALL_DATA),
|
player.level().dimensionTypeId(),
|
||||||
new ClientboundGameEventPacket(ClientboundGameEventPacket.LEVEL_CHUNKS_LOAD_START, 0)
|
player.level().dimension(),
|
||||||
|
BiomeManager.obfuscateSeed(player.serverLevel().getSeed()),
|
||||||
|
player.gameMode.getGameModeForPlayer(),
|
||||||
|
player.gameMode.getPreviousGameModeForPlayer(),
|
||||||
|
player.level().isDebug(),
|
||||||
|
player.serverLevel().isFlat(),
|
||||||
|
(byte) 3,
|
||||||
|
player.getLastDeathLocation(),
|
||||||
|
player.getPortalCooldown()
|
||||||
)
|
)
|
||||||
));
|
);
|
||||||
player.connection.teleport(player.getX(), player.getY(), player.getZ(), player.getYRot(), player.getXRot());
|
player.connection.teleport(player.getX(), player.getY(), player.getZ(), player.getYRot(), player.getXRot());
|
||||||
player.connection.send(new ClientboundSetEntityMotionPacket(player));
|
player.connection.send(new ClientboundSetEntityMotionPacket(player));
|
||||||
var vehicle = player.getVehicle();
|
var vehicle = player.getVehicle();
|
||||||
@@ -96,6 +104,13 @@ public final class PlayerUtils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static GameProfile cloneGameProfile(GameProfile profile) {
|
||||||
|
var newProfile = new GameProfile(profile.getId(), profile.getName());
|
||||||
|
newProfile.getProperties().putAll(profile.getProperties());
|
||||||
|
|
||||||
|
return newProfile;
|
||||||
|
}
|
||||||
|
|
||||||
public static Property getPlayerSkin(GameProfile profile) {
|
public static Property getPlayerSkin(GameProfile profile) {
|
||||||
return Iterables.getFirst(profile.getProperties().get(TEXTURES_KEY), null);
|
return Iterables.getFirst(profile.getProperties().get(TEXTURES_KEY), null);
|
||||||
}
|
}
|
||||||
@@ -127,8 +142,8 @@ public final class PlayerUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static GameProfile toProfile(MinecraftProfilePropertiesResponse response) {
|
public static GameProfile toProfile(MinecraftProfilePropertiesResponse response) {
|
||||||
final GameProfile profile = new GameProfile(response.id(), response.name());
|
final GameProfile profile = new GameProfile(response.getId(), response.getName());
|
||||||
profile.getProperties().putAll(response.properties());
|
profile.getProperties().putAll(response.getProperties());
|
||||||
return profile;
|
return profile;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,6 +19,18 @@ public class Result<S, E> {
|
|||||||
this.errorValue = errorValue;
|
this.errorValue = errorValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static <S, E> Result<S, E> success(@NotNull S successValue) {
|
||||||
|
return new Result<>(successValue, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static <S, E> Result<S, E> error(@NotNull E errorValue) {
|
||||||
|
return new Result<>(null, errorValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static <S, E> Result<Optional<S>, E> ofNullable(S successValue) {
|
||||||
|
return Result.success(Optional.ofNullable(successValue));
|
||||||
|
}
|
||||||
|
|
||||||
public S getSuccessValue() {
|
public S getSuccessValue() {
|
||||||
return successValue;
|
return successValue;
|
||||||
}
|
}
|
||||||
@@ -69,16 +81,4 @@ public class Result<S, E> {
|
|||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return Objects.hash(successValue, errorValue);
|
return Objects.hash(successValue, errorValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static <S, E> Result<S, E> success(@NotNull S successValue) {
|
|
||||||
return new Result<>(successValue, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static <S, E> Result<S, E> error(@NotNull E errorValue) {
|
|
||||||
return new Result<>(null, errorValue);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static <S, E> Result<Optional<S>, E> ofNullable(S successValue) {
|
|
||||||
return Result.success(Optional.ofNullable(successValue));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,60 @@
|
|||||||
|
package net.lionarius.skinrestorer.util;
|
||||||
|
|
||||||
|
import net.minecraft.server.MinecraftServer;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Queue;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
import java.util.concurrent.PriorityBlockingQueue;
|
||||||
|
|
||||||
|
public class TickedScheduler implements Runnable {
|
||||||
|
private final MinecraftServer server;
|
||||||
|
private final Queue<TickTask> queue = new PriorityBlockingQueue<>();
|
||||||
|
private final Map<Integer, Integer> idMap = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
|
public TickedScheduler(MinecraftServer server) {
|
||||||
|
this.server = server;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void schedule(Runnable task, int delay) {
|
||||||
|
this.schedule(task, delay, task);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void schedule(Runnable task, int delay, Object id) {
|
||||||
|
var taskId = id.hashCode();
|
||||||
|
var serverTick = this.server.getTickCount();
|
||||||
|
this.idMap.merge(taskId, serverTick, Integer::max);
|
||||||
|
this.queue.add(new TickTask(serverTick, serverTick + delay, taskId, task));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void cancel(Object id) {
|
||||||
|
var taskId = id.hashCode();
|
||||||
|
this.idMap.remove(taskId);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
TickTask nextTask;
|
||||||
|
while ((nextTask = this.queue.peek()) != null) {
|
||||||
|
if (nextTask.runOnTick() > this.server.getTickCount())
|
||||||
|
break;
|
||||||
|
|
||||||
|
var tickTask = this.queue.remove();
|
||||||
|
var lastTaskScheduledOnTick = this.idMap.get(tickTask.id());
|
||||||
|
|
||||||
|
if (lastTaskScheduledOnTick != null && lastTaskScheduledOnTick <= tickTask.scheduledOnTick()) {
|
||||||
|
this.idMap.remove(tickTask.id());
|
||||||
|
if (tickTask.task() != null)
|
||||||
|
tickTask.task().run();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private record TickTask(int scheduledOnTick, int runOnTick, int id, Runnable task) implements Comparable<TickTask> {
|
||||||
|
@Override
|
||||||
|
public int compareTo(@NotNull TickedScheduler.TickTask other) {
|
||||||
|
return Integer.compare(this.runOnTick, other.runOnTick);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -13,8 +13,6 @@ import java.time.temporal.ChronoUnit;
|
|||||||
|
|
||||||
public final class WebUtils {
|
public final class WebUtils {
|
||||||
|
|
||||||
private WebUtils() {}
|
|
||||||
|
|
||||||
public static final String USER_AGENT;
|
public static final String USER_AGENT;
|
||||||
|
|
||||||
private static HttpClient HTTP_CLIENT = null;
|
private static HttpClient HTTP_CLIENT = null;
|
||||||
@@ -23,6 +21,8 @@ public final class WebUtils {
|
|||||||
USER_AGENT = String.format("SkinRestorer/%d", System.currentTimeMillis() % 65535);
|
USER_AGENT = String.format("SkinRestorer/%d", System.currentTimeMillis() % 65535);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private WebUtils() {}
|
||||||
|
|
||||||
public static void recreateHttpClient() {
|
public static void recreateHttpClient() {
|
||||||
HTTP_CLIENT = WebUtils.buildClient();
|
HTTP_CLIENT = WebUtils.buildClient();
|
||||||
}
|
}
|
||||||
|
|||||||
1
common/src/main/resources/META-INF/accesstransformer.cfg
Normal file
1
common/src/main/resources/META-INF/accesstransformer.cfg
Normal file
@@ -0,0 +1 @@
|
|||||||
|
public net.minecraft.server.players.GameProfileCache$GameProfileInfo
|
||||||
3
common/src/main/resources/skinrestorer.accesswidener
Normal file
3
common/src/main/resources/skinrestorer.accesswidener
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
accessWidener v2 named
|
||||||
|
|
||||||
|
accessible class net/minecraft/server/players/GameProfileCache$GameProfileInfo
|
||||||
@@ -2,13 +2,16 @@
|
|||||||
"required": true,
|
"required": true,
|
||||||
"minVersion": "0.8",
|
"minVersion": "0.8",
|
||||||
"package": "net.lionarius.skinrestorer.mixin",
|
"package": "net.lionarius.skinrestorer.mixin",
|
||||||
"compatibilityLevel": "JAVA_8",
|
"compatibilityLevel": "JAVA_17",
|
||||||
|
"priority": 1100,
|
||||||
"refmap": "${mod_id}.refmap.json",
|
"refmap": "${mod_id}.refmap.json",
|
||||||
"mixins": [
|
"mixins": [
|
||||||
"ChunkMapAccessor",
|
"ChunkMapAccessor",
|
||||||
"PlayerListMixin",
|
"PlayerListMixin",
|
||||||
"ServerLoginPacketListenerImplMixin",
|
"ServerLoginPacketListenerImplMixin",
|
||||||
"TrackedEntityAccessorInvoker"
|
"TrackedEntityAccessorInvoker",
|
||||||
|
"SkullBlockEntityMixin",
|
||||||
|
"GameProfileCacheAccessor"
|
||||||
],
|
],
|
||||||
"injectors": {
|
"injectors": {
|
||||||
"defaultRequire": 1
|
"defaultRequire": 1
|
||||||
|
|||||||
6
fabric/gradle.properties
Normal file
6
fabric/gradle.properties
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
# Fabric, see https://fabricmc.net/develop/ for new versions
|
||||||
|
fabric_loader_version=0.15.0
|
||||||
|
fabric_api_version=0.83.0+1.20
|
||||||
|
|
||||||
|
optional_dependencies=fabric-api
|
||||||
|
additional_modloaders=quilt
|
||||||
@@ -11,8 +11,14 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
|||||||
public abstract class MinecraftServerMixin {
|
public abstract class MinecraftServerMixin {
|
||||||
|
|
||||||
@Inject(method = "runServer",
|
@Inject(method = "runServer",
|
||||||
at = @At(value = "INVOKE", target = "Lnet/minecraft/Util;getNanos()J", ordinal = 0))
|
at = @At(value = "INVOKE", target = "Lnet/minecraft/Util;getMillis()J", ordinal = 0))
|
||||||
private void onServerStarted(CallbackInfo ci) {
|
private void onServerStarted(CallbackInfo ci) {
|
||||||
SkinRestorer.Events.onServerStarted((MinecraftServer) (Object) this);
|
SkinRestorer.Events.onServerStarted((MinecraftServer) (Object) this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Inject(method = "runServer",
|
||||||
|
at = @At(value = "INVOKE", target = "Lnet/minecraft/server/MinecraftServer;onServerExit()V"))
|
||||||
|
private void onServerStopped(CallbackInfo ci) {
|
||||||
|
SkinRestorer.Events.onServerStopped((MinecraftServer) (Object) this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,6 +24,7 @@
|
|||||||
"${mod_id}.mixins.json",
|
"${mod_id}.mixins.json",
|
||||||
"${mod_id}.fabric.mixins.json"
|
"${mod_id}.fabric.mixins.json"
|
||||||
],
|
],
|
||||||
|
"accessWidener": "${mod_id}.accesswidener",
|
||||||
"depends": {
|
"depends": {
|
||||||
"fabricloader": ">=${fabric_loader_version}",
|
"fabricloader": ">=${fabric_loader_version}",
|
||||||
"minecraft": ">=${minecraft_version}",
|
"minecraft": ">=${minecraft_version}",
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
"required": true,
|
"required": true,
|
||||||
"minVersion": "0.8",
|
"minVersion": "0.8",
|
||||||
"package": "net.lionarius.skinrestorer.fabric.mixin",
|
"package": "net.lionarius.skinrestorer.fabric.mixin",
|
||||||
"compatibilityLevel": "JAVA_8",
|
"compatibilityLevel": "JAVA_17",
|
||||||
"refmap": "${mod_id}.refmap.json",
|
"refmap": "${mod_id}.refmap.json",
|
||||||
"mixins": [
|
"mixins": [
|
||||||
"CommandsMixin",
|
"CommandsMixin",
|
||||||
|
|||||||
@@ -26,21 +26,21 @@ tasks.named('jarJar') {
|
|||||||
}
|
}
|
||||||
|
|
||||||
minecraft {
|
minecraft {
|
||||||
mappings channel: 'parchment', version: "${parchment_version}-${parchment_minecraft}"
|
mappings channel: 'parchment', version: "${parchment_minecraft}-${parchment_version}-${minecraft_version}"
|
||||||
|
|
||||||
copyIdeResources = true //Calls processResources when in dev
|
copyIdeResources = true //Calls processResources when in dev
|
||||||
|
|
||||||
// Automatically enable forge AccessTransformers if the file exists
|
// Automatically enable forge AccessTransformers if the file exists
|
||||||
// This location is hardcoded in Forge and can not be changed.
|
// This location is hardcoded in Forge and can not be changed.
|
||||||
// https://github.com/MinecraftForge/MinecraftForge/blob/be1698bb1554f9c8fa2f58e32b9ab70bc4385e60/fmlloader/src/main/java/net/minecraftforge/fml/loading/moddiscovery/ModFile.java#L123
|
// https://github.com/MinecraftForge/MinecraftForge/blob/be1698bb1554f9c8fa2f58e32b9ab70bc4385e60/fmlloader/src/main/java/net/minecraftforge/fml/loading/moddiscovery/ModFile.java#L123
|
||||||
def at = project(':common').file('src/main/resources/META-INF/accesstransformer.cfg')
|
def at = project(":common").file('src/main/resources/META-INF/accesstransformer.cfg')
|
||||||
if (at.exists()) {
|
if (at.exists()) {
|
||||||
accessTransformer = at
|
accessTransformer = at
|
||||||
}
|
}
|
||||||
|
|
||||||
runs {
|
runs {
|
||||||
client {
|
client {
|
||||||
workingDirectory file('../run/client')
|
workingDirectory rootProject.file('run/client')
|
||||||
ideaModule "${rootProject.name}.${project.name}.main"
|
ideaModule "${rootProject.name}.${project.name}.main"
|
||||||
taskName 'Client'
|
taskName 'Client'
|
||||||
mods {
|
mods {
|
||||||
@@ -51,7 +51,7 @@ minecraft {
|
|||||||
}
|
}
|
||||||
|
|
||||||
server {
|
server {
|
||||||
workingDirectory file('../run/server')
|
workingDirectory rootProject.file('run/server')
|
||||||
ideaModule "${rootProject.name}.${project.name}.main"
|
ideaModule "${rootProject.name}.${project.name}.main"
|
||||||
taskName 'Server'
|
taskName 'Server'
|
||||||
mods {
|
mods {
|
||||||
@@ -88,3 +88,7 @@ sourceSets.each {
|
|||||||
it.output.resourcesDir = dir
|
it.output.resourcesDir = dir
|
||||||
it.java.destinationDirectory = dir
|
it.java.destinationDirectory = dir
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tasks.named('processResources') {
|
||||||
|
duplicatesStrategy = DuplicatesStrategy.INCLUDE
|
||||||
|
}
|
||||||
|
|||||||
5
forge/gradle.properties
Normal file
5
forge/gradle.properties
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
# Forge, see https://files.minecraftforge.net/net/minecraftforge/forge/ for new versions
|
||||||
|
forge_version=46.0.1
|
||||||
|
forge_loader_version_range=[46,)
|
||||||
|
# Forge sometimes skips minor minecraft versions (like 1.20.5)
|
||||||
|
forge_minecraft_version=1.20
|
||||||
@@ -4,6 +4,7 @@ import net.lionarius.skinrestorer.SkinRestorer;
|
|||||||
import net.lionarius.skinrestorer.compat.skinshuffle.SkinShuffleCompatibility;
|
import net.lionarius.skinrestorer.compat.skinshuffle.SkinShuffleCompatibility;
|
||||||
import net.minecraftforge.event.RegisterCommandsEvent;
|
import net.minecraftforge.event.RegisterCommandsEvent;
|
||||||
import net.minecraftforge.event.server.ServerStartedEvent;
|
import net.minecraftforge.event.server.ServerStartedEvent;
|
||||||
|
import net.minecraftforge.event.server.ServerStoppedEvent;
|
||||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||||
import net.minecraftforge.fml.common.Mod;
|
import net.minecraftforge.fml.common.Mod;
|
||||||
|
|
||||||
@@ -27,4 +28,9 @@ public final class SkinRestorerForge {
|
|||||||
public static void onServerStarted(ServerStartedEvent event) {
|
public static void onServerStarted(ServerStartedEvent event) {
|
||||||
SkinRestorer.Events.onServerStarted(event.getServer());
|
SkinRestorer.Events.onServerStarted(event.getServer());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SubscribeEvent
|
||||||
|
public static void onServerStopped(ServerStoppedEvent event) {
|
||||||
|
SkinRestorer.Events.onServerStopped(event.getServer());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,57 +1,66 @@
|
|||||||
package net.lionarius.skinrestorer.forge.compat.skinshuffle;
|
package net.lionarius.skinrestorer.forge.compat.skinshuffle;
|
||||||
|
|
||||||
import io.netty.buffer.Unpooled;
|
import io.netty.buffer.Unpooled;
|
||||||
import net.lionarius.skinrestorer.compat.skinshuffle.*;
|
|
||||||
import net.lionarius.skinrestorer.compat.skinshuffle.SkinShuffleCompatibility;
|
import net.lionarius.skinrestorer.compat.skinshuffle.SkinShuffleCompatibility;
|
||||||
|
import net.lionarius.skinrestorer.compat.skinshuffle.*;
|
||||||
import net.minecraft.network.Connection;
|
import net.minecraft.network.Connection;
|
||||||
import net.minecraft.network.FriendlyByteBuf;
|
import net.minecraft.network.FriendlyByteBuf;
|
||||||
import net.minecraftforge.event.network.CustomPayloadEvent;
|
import net.minecraft.network.protocol.game.ClientboundCustomPayloadPacket;
|
||||||
import net.minecraftforge.network.ChannelBuilder;
|
import net.minecraftforge.network.NetworkEvent;
|
||||||
import net.minecraftforge.network.EventNetworkChannel;
|
import net.minecraftforge.network.NetworkRegistry;
|
||||||
|
import net.minecraftforge.network.event.EventNetworkChannel;
|
||||||
|
|
||||||
public class SkinShufflePacketHandler {
|
public class SkinShufflePacketHandler {
|
||||||
|
|
||||||
|
private static final EventNetworkChannel HANDSHAKE_INSTANCE = NetworkRegistry.ChannelBuilder
|
||||||
|
.named(SkinShuffleHandshakePayload.PACKET_ID)
|
||||||
|
.clientAcceptedVersions(NetworkRegistry.acceptMissingOr(""))
|
||||||
|
.serverAcceptedVersions(NetworkRegistry.acceptMissingOr(""))
|
||||||
|
.networkProtocolVersion(() -> "")
|
||||||
|
.eventNetworkChannel();
|
||||||
|
|
||||||
|
private static final EventNetworkChannel SKIN_REFRESH_V1_INSTANCE = NetworkRegistry.ChannelBuilder
|
||||||
|
.named(SkinShuffleSkinRefreshV1Payload.PACKET_ID)
|
||||||
|
.clientAcceptedVersions(NetworkRegistry.acceptMissingOr(""))
|
||||||
|
.serverAcceptedVersions(NetworkRegistry.acceptMissingOr(""))
|
||||||
|
.networkProtocolVersion(() -> "")
|
||||||
|
.eventNetworkChannel();
|
||||||
|
|
||||||
|
private static final EventNetworkChannel SKIN_REFRESH_V2_INSTANCE = NetworkRegistry.ChannelBuilder
|
||||||
|
.named(SkinShuffleSkinRefreshV2Payload.PACKET_ID)
|
||||||
|
.clientAcceptedVersions(NetworkRegistry.acceptMissingOr(""))
|
||||||
|
.serverAcceptedVersions(NetworkRegistry.acceptMissingOr(""))
|
||||||
|
.networkProtocolVersion(() -> "")
|
||||||
|
.eventNetworkChannel();
|
||||||
|
|
||||||
|
protected static void initialize() {
|
||||||
|
SKIN_REFRESH_V1_INSTANCE.addListener(SkinShufflePacketHandler::skinRefreshV1Listener);
|
||||||
|
SKIN_REFRESH_V2_INSTANCE.addListener(SkinShufflePacketHandler::skinRefreshV2Listener);
|
||||||
|
}
|
||||||
|
|
||||||
private SkinShufflePacketHandler() {
|
private SkinShufflePacketHandler() {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final EventNetworkChannel HANDSHAKE_INSTANCE = ChannelBuilder
|
|
||||||
.named(SkinShuffleHandshakePayload.PACKET_ID)
|
|
||||||
.optional()
|
|
||||||
.eventNetworkChannel();
|
|
||||||
|
|
||||||
private static final EventNetworkChannel SKIN_REFRESH_V1_INSTANCE = ChannelBuilder
|
|
||||||
.named(SkinShuffleSkinRefreshV1Payload.PACKET_ID)
|
|
||||||
.optional()
|
|
||||||
.eventNetworkChannel()
|
|
||||||
.addListener(SkinShufflePacketHandler::skinRefreshV1Listener);
|
|
||||||
|
|
||||||
private static final EventNetworkChannel SKIN_REFRESH_V2_INSTANCE = ChannelBuilder
|
|
||||||
.named(SkinShuffleSkinRefreshV2Payload.PACKET_ID)
|
|
||||||
.optional()
|
|
||||||
.eventNetworkChannel()
|
|
||||||
.addListener(SkinShufflePacketHandler::skinRefreshV2Listener);
|
|
||||||
|
|
||||||
protected static void initialize() {
|
|
||||||
// NO-OP
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void sendHandshake(Connection connection) {
|
public static void sendHandshake(Connection connection) {
|
||||||
HANDSHAKE_INSTANCE.send(new FriendlyByteBuf(Unpooled.buffer(0, 0)), connection);
|
connection.send(new ClientboundCustomPayloadPacket(SkinShuffleHandshakePayload.PACKET_ID, new FriendlyByteBuf(Unpooled.buffer(0, 0))));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void skinRefreshV1Listener(CustomPayloadEvent event) {
|
private static void skinRefreshV1Listener(NetworkEvent.ClientCustomPayloadEvent event) {
|
||||||
var payload = SkinShuffleSkinRefreshV1Payload.decode(event.getPayload());
|
var payload = SkinShuffleSkinRefreshV1Payload.decode(event.getPayload());
|
||||||
handleSkinRefreshPacket(payload, event.getSource());
|
handleSkinRefreshPacket(payload, event.getSource().get());
|
||||||
|
event.getSource().get().setPacketHandled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void skinRefreshV2Listener(CustomPayloadEvent event) {
|
private static void skinRefreshV2Listener(NetworkEvent.ClientCustomPayloadEvent event) {
|
||||||
var payload = SkinShuffleSkinRefreshV2Payload.decode(event.getPayload());
|
var payload = SkinShuffleSkinRefreshV2Payload.decode(event.getPayload());
|
||||||
handleSkinRefreshPacket(payload, event.getSource());
|
handleSkinRefreshPacket(payload, event.getSource().get());
|
||||||
|
event.getSource().get().setPacketHandled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void handleSkinRefreshPacket(SkinShuffleSkinRefreshPayload payload, CustomPayloadEvent.Context context) {
|
private static void handleSkinRefreshPacket(SkinShuffleSkinRefreshPayload payload, NetworkEvent.Context context) {
|
||||||
var sender = context.getSender();
|
var sender = context.getSender();
|
||||||
|
|
||||||
if (!context.isServerSide() || sender == null)
|
if (!context.getDirection().getReceptionSide().isServer() || sender == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
SkinShuffleCompatibility.handleSkinRefresh(sender.getServer(), sender, payload);
|
SkinShuffleCompatibility.handleSkinRefresh(sender.getServer(), sender, payload);
|
||||||
|
|||||||
@@ -8,6 +8,6 @@ public final class ForgeCompatibilityHelper implements CompatibilityHelper {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void skinShuffle_sendHandshake(ServerPlayer player) {
|
public void skinShuffle_sendHandshake(ServerPlayer player) {
|
||||||
SkinShufflePacketHandler.sendHandshake(player.connection.getConnection());
|
SkinShufflePacketHandler.sendHandshake(player.connection.connection);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,12 +3,12 @@ group=net.lionarius
|
|||||||
java_version=17
|
java_version=17
|
||||||
|
|
||||||
# Common
|
# Common
|
||||||
minecraft_version=1.20.3
|
minecraft_version=1.20
|
||||||
minecraft_version_list=1.20.3,1.20.4
|
minecraft_version_list=1.20,1.20.1
|
||||||
minecraft_version_range=[1.20.3,1.20.4]
|
minecraft_version_range=[1.20, 1.20.1]
|
||||||
mod_id=skinrestorer
|
mod_id=skinrestorer
|
||||||
mod_name=SkinRestorer
|
mod_name=SkinRestorer
|
||||||
mod_version=2.2.0
|
mod_version=2.5.0
|
||||||
mod_author=Lionarius
|
mod_author=Lionarius
|
||||||
mod_homepage=https://modrinth.com/mod/skinrestorer
|
mod_homepage=https://modrinth.com/mod/skinrestorer
|
||||||
mod_sources=https://github.com/Suiranoil/SkinRestorer
|
mod_sources=https://github.com/Suiranoil/SkinRestorer
|
||||||
@@ -17,26 +17,12 @@ license=MIT
|
|||||||
credits=
|
credits=
|
||||||
description=A server-side mod for managing skins.
|
description=A server-side mod for managing skins.
|
||||||
|
|
||||||
mineskin_client_version=3.0.1-SNAPSHOT
|
# Dependencies
|
||||||
|
mineskin_client_version=3.2.1-SNAPSHOT
|
||||||
|
|
||||||
# ParchmentMC mappings, see https://parchmentmc.org/docs/getting-started#choose-a-version for new versions
|
# ParchmentMC mappings, see https://parchmentmc.org/docs/getting-started#choose-a-version for new versions
|
||||||
parchment_minecraft=1.20.3
|
parchment_minecraft=1.20.1
|
||||||
parchment_version=2023.12.31
|
parchment_version=2023.09.03
|
||||||
|
|
||||||
# Fabric, see https://fabricmc.net/develop/ for new versions
|
|
||||||
fabric_loader_version=0.15.0
|
|
||||||
fabric_api_version=0.91.1+1.20.3
|
|
||||||
fabric_optional_dependencies=fabric-api
|
|
||||||
|
|
||||||
# Forge, see https://files.minecraftforge.net/net/minecraftforge/forge/ for new versions
|
|
||||||
forge_version=49.0.1
|
|
||||||
forge_loader_version_range=[49,)
|
|
||||||
# Forge sometimes skips minor minecraft versions (like 1.20.5)
|
|
||||||
forge_minecraft_version=1.20.3
|
|
||||||
|
|
||||||
# NeoForge, see https://projects.neoforged.net/neoforged/neoforge for new versions
|
|
||||||
neoforge_version=20.3.1-beta
|
|
||||||
neoforge_loader_version_range=[1,)
|
|
||||||
|
|
||||||
# Publishing
|
# Publishing
|
||||||
curseforge_id=443823
|
curseforge_id=443823
|
||||||
@@ -45,3 +31,5 @@ modrinth_id=ghrZDhGW
|
|||||||
# Gradle
|
# Gradle
|
||||||
org.gradle.jvmargs=-Xmx3G
|
org.gradle.jvmargs=-Xmx3G
|
||||||
org.gradle.daemon=false
|
org.gradle.daemon=false
|
||||||
|
org.gradle.parallel=true
|
||||||
|
org.gradle.caching=true
|
||||||
|
|||||||
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Binary file not shown.
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
@@ -1,6 +1,6 @@
|
|||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10-bin.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14-bin.zip
|
||||||
networkTimeout=10000
|
networkTimeout=10000
|
||||||
validateDistributionUrl=true
|
validateDistributionUrl=true
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
|
|||||||
9
gradlew
vendored
9
gradlew
vendored
@@ -86,8 +86,7 @@ done
|
|||||||
# shellcheck disable=SC2034
|
# shellcheck disable=SC2034
|
||||||
APP_BASE_NAME=${0##*/}
|
APP_BASE_NAME=${0##*/}
|
||||||
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
|
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
|
||||||
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s
|
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit
|
||||||
' "$PWD" ) || exit
|
|
||||||
|
|
||||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||||
MAX_FD=maximum
|
MAX_FD=maximum
|
||||||
@@ -115,7 +114,7 @@ case "$( uname )" in #(
|
|||||||
NONSTOP* ) nonstop=true ;;
|
NONSTOP* ) nonstop=true ;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
CLASSPATH="\\\"\\\""
|
||||||
|
|
||||||
|
|
||||||
# Determine the Java command to use to start the JVM.
|
# Determine the Java command to use to start the JVM.
|
||||||
@@ -206,7 +205,7 @@ fi
|
|||||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||||
|
|
||||||
# Collect all arguments for the java command:
|
# Collect all arguments for the java command:
|
||||||
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
|
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
|
||||||
# and any embedded shellness will be escaped.
|
# and any embedded shellness will be escaped.
|
||||||
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
|
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
|
||||||
# treated as '${Hostname}' itself on the command line.
|
# treated as '${Hostname}' itself on the command line.
|
||||||
@@ -214,7 +213,7 @@ DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
|||||||
set -- \
|
set -- \
|
||||||
"-Dorg.gradle.appname=$APP_BASE_NAME" \
|
"-Dorg.gradle.appname=$APP_BASE_NAME" \
|
||||||
-classpath "$CLASSPATH" \
|
-classpath "$CLASSPATH" \
|
||||||
org.gradle.wrapper.GradleWrapperMain \
|
-jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \
|
||||||
"$@"
|
"$@"
|
||||||
|
|
||||||
# Stop when "xargs" is not available.
|
# Stop when "xargs" is not available.
|
||||||
|
|||||||
4
gradlew.bat
vendored
4
gradlew.bat
vendored
@@ -70,11 +70,11 @@ goto fail
|
|||||||
:execute
|
:execute
|
||||||
@rem Setup the command line
|
@rem Setup the command line
|
||||||
|
|
||||||
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
set CLASSPATH=
|
||||||
|
|
||||||
|
|
||||||
@rem Execute Gradle
|
@rem Execute Gradle
|
||||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
|
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %*
|
||||||
|
|
||||||
:end
|
:end
|
||||||
@rem End local scope for the variables with windows NT shell
|
@rem End local scope for the variables with windows NT shell
|
||||||
|
|||||||
@@ -3,56 +3,58 @@ plugins {
|
|||||||
id 'idea'
|
id 'idea'
|
||||||
id 'eclipse'
|
id 'eclipse'
|
||||||
|
|
||||||
id 'net.neoforged.gradle.userdev'
|
id 'net.neoforged.moddev'
|
||||||
|
|
||||||
id 'multiloader-publish'
|
id 'multiloader-publish'
|
||||||
}
|
}
|
||||||
|
|
||||||
// Automatically enable neoforge AccessTransformers if the file exists
|
neoForge {
|
||||||
def at = project(':common').file('src/main/resources/META-INF/accesstransformer.cfg')
|
version = neoforge_version
|
||||||
if (at.exists()) {
|
|
||||||
minecraft.accessTransformers.file(at)
|
// Automatically enable neoforge AccessTransformers if the file exists
|
||||||
}
|
def at = project(":common").file('src/main/resources/META-INF/accesstransformer.cfg')
|
||||||
|
if (at.exists()) {
|
||||||
jarJar.enable()
|
accessTransformers.from(at.absolutePath)
|
||||||
|
|
||||||
tasks.named('jar') {
|
|
||||||
archiveClassifier = 'thin'
|
|
||||||
}
|
|
||||||
|
|
||||||
tasks.named('jarJar') {
|
|
||||||
archiveClassifier = ''
|
|
||||||
}
|
|
||||||
|
|
||||||
jar.finalizedBy('jarJar')
|
|
||||||
|
|
||||||
dependencies {
|
|
||||||
implementation "net.neoforged:neoforge:${neoforge_version}"
|
|
||||||
|
|
||||||
implementation(jarJar(group: 'org.mineskin', name: 'java-client', version: mineskin_client_version)) {
|
|
||||||
jarJar.ranged(it, "[${mineskin_client_version},)")
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
subsystems {
|
|
||||||
parchment {
|
parchment {
|
||||||
minecraftVersion = parchment_minecraft
|
minecraftVersion = parchment_minecraft
|
||||||
mappingsVersion = parchment_version
|
mappingsVersion = parchment_version
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
runs {
|
runs {
|
||||||
configureEach {
|
configureEach {
|
||||||
modSource project.sourceSets.main
|
ideName = "NeoForge ${it.name.capitalize()} (${project.path})" // Unify the run config names with fabric
|
||||||
systemProperty 'neoforge.enabledGameTestNamespaces', project.mod_id
|
}
|
||||||
|
|
||||||
|
client {
|
||||||
|
client()
|
||||||
|
gameDirectory = rootProject.file('run/client')
|
||||||
|
}
|
||||||
|
|
||||||
|
server {
|
||||||
|
server()
|
||||||
|
programArgument '--nogui'
|
||||||
|
gameDirectory = rootProject.file('run/server')
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
client {
|
mods {
|
||||||
workingDirectory = file('../run/client')
|
"${mod_id}" {
|
||||||
}
|
sourceSet sourceSets.main
|
||||||
|
}
|
||||||
server {
|
|
||||||
programArgument '--nogui'
|
|
||||||
workingDirectory = file('../run/server')
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
implementation "net.neoforged:neoforge:${neoforge_version}"
|
||||||
|
|
||||||
|
jarJar(implementation('org.mineskin:java-client')) {
|
||||||
|
version {
|
||||||
|
strictly "[${mineskin_client_version},)"
|
||||||
|
prefer mineskin_client_version
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
additionalRuntimeClasspath "org.mineskin:java-client:${mineskin_client_version}"
|
||||||
|
}
|
||||||
|
|||||||
3
neoforge/gradle.properties
Normal file
3
neoforge/gradle.properties
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
# NeoForge, see https://projects.neoforged.net/neoforged/neoforge for new versions
|
||||||
|
neoforge_version=20.2.3-beta
|
||||||
|
neoforge_loader_version_range=[1,)
|
||||||
@@ -6,6 +6,7 @@ import net.neoforged.bus.api.SubscribeEvent;
|
|||||||
import net.neoforged.fml.common.Mod;
|
import net.neoforged.fml.common.Mod;
|
||||||
import net.neoforged.neoforge.event.RegisterCommandsEvent;
|
import net.neoforged.neoforge.event.RegisterCommandsEvent;
|
||||||
import net.neoforged.neoforge.event.server.ServerStartedEvent;
|
import net.neoforged.neoforge.event.server.ServerStartedEvent;
|
||||||
|
import net.neoforged.neoforge.event.server.ServerStoppedEvent;
|
||||||
|
|
||||||
@Mod(SkinRestorer.MOD_ID)
|
@Mod(SkinRestorer.MOD_ID)
|
||||||
@Mod.EventBusSubscriber(modid = SkinRestorer.MOD_ID)
|
@Mod.EventBusSubscriber(modid = SkinRestorer.MOD_ID)
|
||||||
@@ -27,4 +28,9 @@ public final class SkinRestorerNeoForge {
|
|||||||
public static void onServerStarted(ServerStartedEvent event) {
|
public static void onServerStarted(ServerStartedEvent event) {
|
||||||
SkinRestorer.Events.onServerStarted(event.getServer());
|
SkinRestorer.Events.onServerStarted(event.getServer());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SubscribeEvent
|
||||||
|
public static void onServerStopped(ServerStoppedEvent event) {
|
||||||
|
SkinRestorer.Events.onServerStopped(event.getServer());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -71,4 +71,5 @@ rootProject.name = 'skin-restorer'
|
|||||||
include('common')
|
include('common')
|
||||||
include('fabric')
|
include('fabric')
|
||||||
include('forge')
|
include('forge')
|
||||||
//include('neoforge')
|
// There is no NeoForge for versions <1.20.2
|
||||||
|
// include('neoforge')
|
||||||
|
|||||||
Reference in New Issue
Block a user