mirror of
https://github.com/Suiranoil/SkinRestorer.git
synced 2026-01-16 04:42:12 +00:00
Compare commits
9 Commits
c987d48738
...
v2.1.0+1.2
| Author | SHA1 | Date | |
|---|---|---|---|
|
026ceb2337
|
|||
|
c650aa1386
|
|||
|
3203435453
|
|||
|
8a9802f763
|
|||
|
7add58da44
|
|||
|
08b734bb27
|
|||
|
49290171e2
|
|||
|
5c31b5f881
|
|||
|
b72d0c1e85
|
90
.github/ISSUE_TEMPLATE/bug_report.yaml
vendored
90
.github/ISSUE_TEMPLATE/bug_report.yaml
vendored
@@ -1,90 +0,0 @@
|
|||||||
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
1
.github/ISSUE_TEMPLATE/config.yml
vendored
@@ -1 +0,0 @@
|
|||||||
blank_issues_enabled: true
|
|
||||||
52
.github/ISSUE_TEMPLATE/feature_request.yaml
vendored
52
.github/ISSUE_TEMPLATE/feature_request.yaml
vendored
@@ -1,52 +0,0 @@
|
|||||||
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
|
|
||||||
3
.github/workflows/release.yml
vendored
3
.github/workflows/release.yml
vendored
@@ -1,5 +1,8 @@
|
|||||||
name: release
|
name: release
|
||||||
on:
|
on:
|
||||||
|
push:
|
||||||
|
tags:
|
||||||
|
- "v**"
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
|
|||||||
1
.gitignore
vendored
1
.gitignore
vendored
@@ -30,4 +30,3 @@ bin/
|
|||||||
|
|
||||||
.architectury-transformer/
|
.architectury-transformer/
|
||||||
run/
|
run/
|
||||||
scripts/
|
|
||||||
|
|||||||
67
CHANGELOG.md
67
CHANGELOG.md
@@ -4,73 +4,6 @@ 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.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 support for [SkinShuffle](https://modrinth.com/mod/skinshuffle) clients (requires FabricAPI on Fabric)
|
|
||||||
(closes [#34](https://github.com/Suiranoil/SkinRestorer/issues/34))
|
|
||||||
- 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
|
|
||||||
|
|
||||||
## [2.1.0] - 2024-09-26
|
## [2.1.0] - 2024-09-26
|
||||||
### Added
|
### Added
|
||||||
- Added `config reload` command for dynamic configuration updates
|
- Added `config reload` command for dynamic configuration updates
|
||||||
|
|||||||
@@ -1,3 +1,9 @@
|
|||||||
|
### Added
|
||||||
|
- Added `config reload` command for dynamic configuration updates
|
||||||
|
- Added `refreshSkinOnJoin` config option (see [wiki](https://github.com/Suiranoil/SkinRestorer/wiki/Configuration#refreshskinonjoin))
|
||||||
|
- Implemented caching for skin providers
|
||||||
|
- Added provider configurations (see [wiki](https://github.com/Suiranoil/SkinRestorer/wiki/Configuration#providers))
|
||||||
|
- Added username and url validation for requests
|
||||||
### Fixed
|
### 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 old skin directory migration not working
|
||||||
- Fixed server freeze when loading player head skin
|
- Prevented overwriting existing skin files during migration
|
||||||
|
|||||||
28
README.md
28
README.md
@@ -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"></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" 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 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 server-side mod for managing and restoring player skins.
|
A server-side mod for managing and restoring player skins.
|
||||||
|
|
||||||
@@ -9,36 +9,26 @@ A server-side mod for managing and restoring player skins.
|
|||||||
|
|
||||||
- **Set skins from Mojang Account**: Fetch and apply skins using a valid Minecraft username.
|
- **Set skins from Mojang Account**: Fetch and apply skins using a valid Minecraft username.
|
||||||
- **Set skins from Ely.by**: Fetch and apply skins using a valid [Ely.by](https://ely.by/) username.
|
- **Set skins from Ely.by**: Fetch and apply skins using a valid [Ely.by](https://ely.by/) username.
|
||||||
- **Set skins from URL**: Fetch and apply skins from any image URL, supporting both classic (Steve) and slim (Alex) skin
|
- **Set skins from URL**: Fetch and apply skins from any image URL, supporting both classic (Steve) and slim (Alex) skin models.
|
||||||
models.
|
- **Automatic skin fetching**: Automatically fetch skin from Mojang/Ely.by when a player joins the server running in offline/insecure mode ([configurable](https://github.com/Suiranoil/SkinRestorer/wiki/Configuration)).
|
||||||
- **Automatic skin fetching**: Automatically fetch skin from Mojang/Ely.by when a player joins the server running in
|
|
||||||
offline/insecure mode ([configurable](https://github.com/Suiranoil/SkinRestorer/wiki/Configuration)).
|
|
||||||
- **Singleplayer support**: Apply skins individually for each world.
|
- **Singleplayer support**: Apply skins individually for each world.
|
||||||
- **Permissions API support**
|
- **Permissions API support**
|
||||||
- **SkinShuffle support**: Allow players with [SkinShuffle](https://modrinth.com/mod/skinshuffle) installed to apply skins using GUI.
|
|
||||||
|
|
||||||
## 📜 Command Usage Guide
|
## 📜 Command Usage Guide
|
||||||
|
|
||||||
For a detailed list of available commands and their usage, please visit
|
For a detailed list of available commands and their usage, please visit the [commands wiki page](https://github.com/Suiranoil/SkinRestorer/wiki/Commands).
|
||||||
the [commands wiki page](https://github.com/Suiranoil/SkinRestorer/wiki/Commands).
|
|
||||||
|
|
||||||
## ❌ Known Incompatibilities
|
## ❌ Known Incompatibilities
|
||||||
|
|
||||||
- **[Arclight](https://github.com/IzzelAliz/Arclight) (<=1.20.1)**: Trials or older versions are not compatible due to
|
- **[Arclight](https://github.com/IzzelAliz/Arclight) (<=1.20.1)**: Trials or older versions are not compatible due to mixin conflicts.
|
||||||
mixin conflicts.
|
|
||||||
As an alternative, consider using the [SkinsRestorer](https://www.spigotmc.org/resources/skinsrestorer.2124/) plugin.
|
As an alternative, consider using the [SkinsRestorer](https://www.spigotmc.org/resources/skinsrestorer.2124/) plugin.
|
||||||
|
|
||||||
## 🪙 Donation
|
## 🪙 Donation
|
||||||
|
|
||||||
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 cryptocurrency donations.
|
||||||
platforms:
|
|
||||||
|
|
||||||
<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>
|
Bitcoin (BTC): `1Ndbwny8pxdnWXFgadp95fp97y5JqMJKTX`\
|
||||||
|
USDT (TRC20): `TGXn8wrqku5KLzwPWQAeH7wgnV4UzwHEae`\
|
||||||
<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`
|
|
||||||
USDT (TRC20): `TGXn8wrqku5KLzwPWQAeH7wgnV4UzwHEae`
|
|
||||||
USDT (TON): `UQAQF18Xlmx-V1oZ90C2YOju5qI7q1LgrCP5QaIUhqIELmDS`
|
USDT (TON): `UQAQF18Xlmx-V1oZ90C2YOju5qI7q1LgrCP5QaIUhqIELmDS`
|
||||||
|
|
||||||
Thank you for your generosity!
|
Thank you for your generosity!
|
||||||
|
|||||||
26
build.gradle
26
build.gradle
@@ -1,29 +1,13 @@
|
|||||||
plugins {
|
plugins {
|
||||||
// see https://fabricmc.net/develop/ for new versions
|
// see https://fabricmc.net/develop/ for new versions
|
||||||
id 'fabric-loom' version '1.10-SNAPSHOT' apply false
|
id 'fabric-loom' version '1.7-SNAPSHOT' apply false
|
||||||
// see https://projects.neoforged.net/neoforged/moddevgradle for new versions
|
// see https://projects.neoforged.net/neoforged/neogradle for new versions
|
||||||
id 'net.neoforged.moddev' version '2.0.+' apply false
|
id 'net.neoforged.gradle.userdev' version '7.0.153' 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.+' apply false
|
id 'net.minecraftforge.gradle' version '6.0.26' 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.+' apply false
|
id 'me.modmuss50.mod-publish-plugin' version '0.6.3' apply false
|
||||||
}
|
|
||||||
|
|
||||||
allprojects {
|
|
||||||
repositories {
|
|
||||||
exclusiveContent {
|
|
||||||
forRepository {
|
|
||||||
maven {
|
|
||||||
name = 'lionarius-repository'
|
|
||||||
url = 'https://reposilite.lionarius.ru/releases'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
filter {
|
|
||||||
includeGroupAndSubgroups('org.mineskin')
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -83,6 +83,7 @@ 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,
|
||||||
@@ -91,20 +92,16 @@ 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,10 +3,10 @@ plugins {
|
|||||||
}
|
}
|
||||||
|
|
||||||
configurations {
|
configurations {
|
||||||
commonJava {
|
commonJava{
|
||||||
canBeResolved = true
|
canBeResolved = true
|
||||||
}
|
}
|
||||||
commonResources {
|
commonResources{
|
||||||
canBeResolved = true
|
canBeResolved = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,17 +3,12 @@ plugins {
|
|||||||
}
|
}
|
||||||
|
|
||||||
publishMods {
|
publishMods {
|
||||||
file = project.layout.buildDirectory.file("libs/${project.archivesBaseName}-${project.version}.jar").map { it.asFile }.getOrNull()
|
if (project.name == 'fabric')
|
||||||
|
file = remapJar.archiveFile
|
||||||
|
else
|
||||||
|
file = jar.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}"
|
||||||
@@ -27,9 +22,6 @@ publishMods {
|
|||||||
|
|
||||||
minecraftVersions.addAll(minecraft_version_list.split(','))
|
minecraftVersions.addAll(minecraft_version_list.split(','))
|
||||||
serverRequired = true
|
serverRequired = true
|
||||||
|
|
||||||
if (project.hasProperty('optional_dependencies') && !optional_dependencies.isEmpty())
|
|
||||||
optional(optional_dependencies.split(','))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
modrinth {
|
modrinth {
|
||||||
@@ -39,8 +31,5 @@ publishMods {
|
|||||||
accessToken = providers.environmentVariable("MODRINTH_TOKEN")
|
accessToken = providers.environmentVariable("MODRINTH_TOKEN")
|
||||||
|
|
||||||
minecraftVersions.addAll(minecraft_version_list.split(','))
|
minecraftVersions.addAll(minecraft_version_list.split(','))
|
||||||
|
|
||||||
if (project.hasProperty('optional_dependencies') && !optional_dependencies.isEmpty())
|
|
||||||
optional(optional_dependencies.split(','))
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
plugins {
|
plugins {
|
||||||
id 'multiloader-common'
|
id 'multiloader-common'
|
||||||
|
|
||||||
id 'fabric-loom'
|
id 'fabric-loom'
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -11,8 +11,6 @@ dependencies {
|
|||||||
parchment("org.parchmentmc.data:parchment-${parchment_minecraft}:${parchment_version}@zip")
|
parchment("org.parchmentmc.data:parchment-${parchment_minecraft}:${parchment_version}@zip")
|
||||||
}
|
}
|
||||||
compileOnly group: 'org.spongepowered', name: 'mixin', version: '0.8.5'
|
compileOnly group: 'org.spongepowered', name: 'mixin', version: '0.8.5'
|
||||||
|
|
||||||
implementation("org.mineskin:java-client:${mineskin_client_version}")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
loom {
|
loom {
|
||||||
@@ -20,7 +18,7 @@ loom {
|
|||||||
if (aw.exists()) {
|
if (aw.exists()) {
|
||||||
accessWidenerPath.set(aw)
|
accessWidenerPath.set(aw)
|
||||||
}
|
}
|
||||||
|
|
||||||
mixin {
|
mixin {
|
||||||
useLegacyMixinAp = false
|
useLegacyMixinAp = false
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
fabric.loom.dontRemap=true
|
fabric.loom.dontRemap = true
|
||||||
|
|||||||
@@ -1,29 +1,26 @@
|
|||||||
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 net.lionarius.skinrestorer.config.BuiltInProviderConfig;
|
||||||
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.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.*;
|
import net.lionarius.skinrestorer.util.FileUtils;
|
||||||
import net.minecraft.commands.CommandSourceStack;
|
import net.lionarius.skinrestorer.util.PlayerUtils;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.lionarius.skinrestorer.util.Result;
|
||||||
|
import net.lionarius.skinrestorer.util.WebUtils;
|
||||||
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;
|
||||||
|
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
@@ -37,8 +34,6 @@ 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() {}
|
||||||
|
|
||||||
@@ -58,32 +53,15 @@ 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));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ResourceLocation resourceLocation(String name) {
|
|
||||||
return ResourceLocation.fromNamespaceAndPath(SkinRestorer.MOD_ID, name);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String assetPath(String name) {
|
|
||||||
return String.format("/assets/%s/%s", SkinRestorer.MOD_ID, name);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void onInitialize() {
|
public static void onInitialize() {
|
||||||
SkinRestorer.configDir = Services.PLATFORM.getConfigDirectory().resolve(SkinRestorer.MOD_ID);
|
SkinRestorer.configDir = Services.PLATFORM.getConfigDirectory().resolve(SkinRestorer.MOD_ID);
|
||||||
SkinRestorer.reloadConfig();
|
SkinRestorer.reloadConfig();
|
||||||
|
|
||||||
SkinRestorer.providersRegistry.register(EmptySkinProvider.PROVIDER_NAME, SkinProvider.EMPTY, false);
|
SkinRestorer.providersRegistry.register(EmptySkinProvider.PROVIDER_NAME, SkinProvider.EMPTY, false);
|
||||||
SkinRestorer.providersRegistry.register(SkinShuffleSkinProvider.PROVIDER_NAME, SkinProvider.SKIN_SHUFFLE, false);
|
|
||||||
|
|
||||||
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());
|
||||||
@@ -94,18 +72,29 @@ public final class SkinRestorer {
|
|||||||
var isDefaultName = config.name().equals(defaultName);
|
var isDefaultName = config.name().equals(defaultName);
|
||||||
SkinRestorer.providersRegistry.register(defaultName, provider, config.enabled() && isDefaultName);
|
SkinRestorer.providersRegistry.register(defaultName, provider, config.enabled() && isDefaultName);
|
||||||
|
|
||||||
if (!isDefaultName && !SkinProvider.BUILTIN_PROVIDER_NAMES.contains(config.name()))
|
if (!isDefaultName && Arrays.stream(SkinProvider.BUILTIN_PROVIDER_NAMES).noneMatch(name -> name.equals(config.name())))
|
||||||
SkinRestorer.providersRegistry.register(config.name(), provider, config.enabled());
|
SkinRestorer.providersRegistry.register(config.name(), provider, config.enabled());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void onServerStarted(MinecraftServer server) {
|
||||||
|
Path worldSkinDirectory = server.getWorldPath(LevelResource.ROOT).resolve(SkinRestorer.MOD_ID);
|
||||||
|
FileUtils.tryMigrateOldSkinDirectory(SkinRestorer.getConfigDir(), worldSkinDirectory);
|
||||||
|
|
||||||
|
SkinRestorer.skinStorage = new SkinStorage(new SkinIO(worldSkinDirectory));
|
||||||
|
}
|
||||||
|
|
||||||
public static void reloadConfig() {
|
public static void reloadConfig() {
|
||||||
SkinRestorer.config = Config.load(SkinRestorer.getConfigDir());
|
SkinRestorer.config = Config.load(SkinRestorer.getConfigDir());
|
||||||
Translation.reloadTranslations();
|
Translation.reloadTranslations();
|
||||||
WebUtils.recreateHttpClient();
|
WebUtils.recreateHttpClient();
|
||||||
|
|
||||||
MojangSkinProvider.reload();
|
MojangSkinProvider.createCache();
|
||||||
ElyBySkinProvider.reload();
|
ElyBySkinProvider.createCache();
|
||||||
MineskinSkinProvider.reload();
|
MineskinSkinProvider.createCache();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String assetPath(String name) {
|
||||||
|
return String.format("/assets/%s/%s", SkinRestorer.MOD_ID, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
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) {
|
||||||
@@ -115,12 +104,12 @@ public final class SkinRestorer {
|
|||||||
if (!SkinRestorer.getSkinStorage().hasSavedSkin(profile.getId()))
|
if (!SkinRestorer.getSkinStorage().hasSavedSkin(profile.getId()))
|
||||||
value = value.setOriginalValue(PlayerUtils.getPlayerSkin(profile));
|
value = value.setOriginalValue(PlayerUtils.getPlayerSkin(profile));
|
||||||
|
|
||||||
if (PlayerUtils.areSkinPropertiesEquals(value.value(), PlayerUtils.getPlayerSkin(profile)))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (save)
|
if (save)
|
||||||
SkinRestorer.getSkinStorage().setSkin(profile.getId(), value);
|
SkinRestorer.getSkinStorage().setSkin(profile.getId(), value);
|
||||||
|
|
||||||
|
if (PlayerUtils.areSkinPropertiesEquals(value.value(), PlayerUtils.getPlayerSkin(profile)))
|
||||||
|
continue;
|
||||||
|
|
||||||
PlayerUtils.applyRestoredSkin(profile, value.value());
|
PlayerUtils.applyRestoredSkin(profile, value.value());
|
||||||
|
|
||||||
var player = server.getPlayerList().getPlayer(profile.getId());
|
var player = server.getPlayerList().getPlayer(profile.getId());
|
||||||
@@ -129,8 +118,6 @@ 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;
|
||||||
@@ -155,7 +142,7 @@ public final class SkinRestorer {
|
|||||||
|
|
||||||
var skinResult = result.get();
|
var skinResult = result.get();
|
||||||
if (skinResult.isError())
|
if (skinResult.isError())
|
||||||
throw new TransparentException(Throwables.getRootCause(skinResult.getErrorValue()));
|
return Result.<Collection<ServerPlayer>, String>error(skinResult.getErrorValue().getMessage());
|
||||||
|
|
||||||
var skinValue = SkinValue.fromProviderContextWithValue(context, skinResult.getSuccessValue().orElse(null));
|
var skinValue = SkinValue.fromProviderContextWithValue(context, skinResult.getSuccessValue().orElse(null));
|
||||||
|
|
||||||
@@ -164,37 +151,8 @@ 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("Failed to set skin '{}:{}'", context.name(), context.argument(), e);
|
SkinRestorer.LOGGER.error(e.toString());
|
||||||
return Result.error(e.getMessage());
|
return Result.error(e.getMessage());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Events {
|
|
||||||
private Events() {}
|
|
||||||
|
|
||||||
public static void onServerStarted(MinecraftServer server) {
|
|
||||||
Path worldSkinDirectory = server.getWorldPath(LevelResource.ROOT).resolve(SkinRestorer.MOD_ID);
|
|
||||||
FileUtils.tryMigrateOldSkinDirectory(SkinRestorer.getConfigDir(), 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) {
|
|
||||||
SkinCommand.register(dispatcher);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void onPlayerDisconnect(ServerPlayer player) {
|
|
||||||
SkinRestorer.getSkinStorage().removeSkin(player.getUUID());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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) {
|
||||||
var base =
|
LiteralArgumentBuilder<CommandSourceStack> 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())));
|
||||||
|
|
||||||
var set = literal("set");
|
LiteralArgumentBuilder<CommandSourceStack> 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
|
||||||
) {
|
) {
|
||||||
var updatedPlayers = new HashSet<ServerPlayer>();
|
Collection<ServerPlayer> updatedPlayers = new HashSet<>();
|
||||||
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) {
|
||||||
var action = literal(name);
|
LiteralArgumentBuilder<CommandSourceStack> action = literal(name);
|
||||||
|
|
||||||
if (provider.hasVariantSupport()) {
|
if (provider.hasVariantSupport()) {
|
||||||
for (SkinVariant variant : SkinVariant.values()) {
|
for (SkinVariant variant : SkinVariant.values()) {
|
||||||
|
|||||||
@@ -1,55 +0,0 @@
|
|||||||
package net.lionarius.skinrestorer.compat.skinshuffle;
|
|
||||||
|
|
||||||
import net.lionarius.skinrestorer.SkinRestorer;
|
|
||||||
import net.lionarius.skinrestorer.platform.Services;
|
|
||||||
import net.lionarius.skinrestorer.skin.SkinValue;
|
|
||||||
import net.lionarius.skinrestorer.skin.provider.SkinShuffleSkinProvider;
|
|
||||||
import net.lionarius.skinrestorer.util.PlayerUtils;
|
|
||||||
import net.minecraft.resources.ResourceLocation;
|
|
||||||
import net.minecraft.server.MinecraftServer;
|
|
||||||
import net.minecraft.server.level.ServerPlayer;
|
|
||||||
|
|
||||||
import java.util.Collections;
|
|
||||||
|
|
||||||
public class SkinShuffleCompatibility {
|
|
||||||
|
|
||||||
public static final String MOD_ID = "skinshuffle";
|
|
||||||
|
|
||||||
private static final boolean SHOULD_APPLY = !Services.PLATFORM.isModLoaded(SkinShuffleCompatibility.MOD_ID);
|
|
||||||
|
|
||||||
private SkinShuffleCompatibility() {}
|
|
||||||
|
|
||||||
public static boolean shouldApply() {
|
|
||||||
return SkinShuffleCompatibility.SHOULD_APPLY;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static ResourceLocation resourceLocation(String name) {
|
|
||||||
return ResourceLocation.fromNamespaceAndPath(SkinShuffleCompatibility.MOD_ID, name);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void onPlayerJoin(ServerPlayer player) {
|
|
||||||
Services.COMPATIBILITY.skinShuffle_sendHandshake(player);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void handleSkinRefresh(MinecraftServer server, ServerPlayer player, SkinShuffleSkinRefreshPayload payload) {
|
|
||||||
var property = payload.textureProperty();
|
|
||||||
|
|
||||||
if (!property.name().equals(PlayerUtils.TEXTURES_KEY))
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (!property.hasSignature())
|
|
||||||
return;
|
|
||||||
|
|
||||||
server.execute(() -> {
|
|
||||||
SkinRestorer.applySkin(
|
|
||||||
server,
|
|
||||||
Collections.singleton(player.getGameProfile()),
|
|
||||||
new SkinValue(SkinShuffleSkinProvider.PROVIDER_NAME, null, null, property),
|
|
||||||
!server.usesAuthentication()
|
|
||||||
);
|
|
||||||
|
|
||||||
if (server.usesAuthentication() && SkinRestorer.getSkinStorage().hasSavedSkin(player.getUUID()))
|
|
||||||
SkinRestorer.getSkinStorage().deleteSkin(player.getUUID());
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,19 +0,0 @@
|
|||||||
package net.lionarius.skinrestorer.compat.skinshuffle;
|
|
||||||
|
|
||||||
import net.minecraft.network.FriendlyByteBuf;
|
|
||||||
import net.minecraft.network.codec.StreamCodec;
|
|
||||||
import net.minecraft.network.protocol.common.custom.CustomPacketPayload;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
|
|
||||||
public record SkinShuffleHandshakePayload() implements CustomPacketPayload {
|
|
||||||
|
|
||||||
public static final SkinShuffleHandshakePayload INSTANCE = new SkinShuffleHandshakePayload();
|
|
||||||
|
|
||||||
public static final CustomPacketPayload.Type<SkinShuffleHandshakePayload> PACKET_ID = new CustomPacketPayload.Type<>(SkinShuffleCompatibility.resourceLocation("handshake"));
|
|
||||||
public static final StreamCodec<FriendlyByteBuf, SkinShuffleHandshakePayload> PACKET_CODEC = StreamCodec.unit(INSTANCE);
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public CustomPacketPayload.@NotNull Type<? extends CustomPacketPayload> type() {
|
|
||||||
return PACKET_ID;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
package net.lionarius.skinrestorer.compat.skinshuffle;
|
|
||||||
|
|
||||||
import com.mojang.authlib.properties.Property;
|
|
||||||
|
|
||||||
public interface SkinShuffleSkinRefreshPayload {
|
|
||||||
Property textureProperty();
|
|
||||||
}
|
|
||||||
@@ -1,34 +0,0 @@
|
|||||||
package net.lionarius.skinrestorer.compat.skinshuffle;
|
|
||||||
|
|
||||||
import com.mojang.authlib.properties.Property;
|
|
||||||
import net.minecraft.network.FriendlyByteBuf;
|
|
||||||
import net.minecraft.network.codec.StreamCodec;
|
|
||||||
import net.minecraft.network.protocol.common.custom.CustomPacketPayload;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
|
|
||||||
public record SkinShuffleSkinRefreshV1Payload(
|
|
||||||
Property textureProperty) implements CustomPacketPayload, SkinShuffleSkinRefreshPayload {
|
|
||||||
|
|
||||||
public static final CustomPacketPayload.Type<SkinShuffleSkinRefreshV1Payload> PACKET_ID = new CustomPacketPayload.Type<>(SkinShuffleCompatibility.resourceLocation("refresh"));
|
|
||||||
public static final StreamCodec<FriendlyByteBuf, SkinShuffleSkinRefreshV1Payload> PACKET_CODEC = StreamCodec.of(
|
|
||||||
SkinShuffleSkinRefreshV1Payload::encode,
|
|
||||||
SkinShuffleSkinRefreshV1Payload::decode
|
|
||||||
);
|
|
||||||
|
|
||||||
public static void encode(FriendlyByteBuf buf, SkinShuffleSkinRefreshV1Payload value) {
|
|
||||||
var textureProperty = value.textureProperty();
|
|
||||||
|
|
||||||
buf.writeUtf(textureProperty.name());
|
|
||||||
buf.writeUtf(textureProperty.value());
|
|
||||||
buf.writeNullable(textureProperty.signature(), FriendlyByteBuf::writeUtf);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static SkinShuffleSkinRefreshV1Payload decode(FriendlyByteBuf buf) {
|
|
||||||
return new SkinShuffleSkinRefreshV1Payload(new Property(buf.readUtf(), buf.readUtf(), buf.readNullable(FriendlyByteBuf::readUtf)));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public @NotNull CustomPacketPayload.Type<? extends CustomPacketPayload> type() {
|
|
||||||
return PACKET_ID;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,42 +0,0 @@
|
|||||||
package net.lionarius.skinrestorer.compat.skinshuffle;
|
|
||||||
|
|
||||||
import com.mojang.authlib.properties.Property;
|
|
||||||
import net.minecraft.network.FriendlyByteBuf;
|
|
||||||
import net.minecraft.network.codec.StreamCodec;
|
|
||||||
import net.minecraft.network.protocol.common.custom.CustomPacketPayload;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
|
|
||||||
public record SkinShuffleSkinRefreshV2Payload(
|
|
||||||
Property textureProperty) implements CustomPacketPayload, SkinShuffleSkinRefreshPayload {
|
|
||||||
|
|
||||||
public static final CustomPacketPayload.Type<SkinShuffleSkinRefreshV2Payload> PACKET_ID = new CustomPacketPayload.Type<>(SkinShuffleCompatibility.resourceLocation("skin_refresh"));
|
|
||||||
public static final StreamCodec<FriendlyByteBuf, SkinShuffleSkinRefreshV2Payload> PACKET_CODEC = StreamCodec.of(
|
|
||||||
SkinShuffleSkinRefreshV2Payload::encode,
|
|
||||||
SkinShuffleSkinRefreshV2Payload::decode
|
|
||||||
);
|
|
||||||
|
|
||||||
public static void encode(FriendlyByteBuf buf, SkinShuffleSkinRefreshV2Payload value) {
|
|
||||||
var textureProperty = value.textureProperty();
|
|
||||||
|
|
||||||
buf.writeBoolean(textureProperty.hasSignature());
|
|
||||||
buf.writeUtf(textureProperty.name());
|
|
||||||
buf.writeUtf(textureProperty.value());
|
|
||||||
if (textureProperty.hasSignature()) {
|
|
||||||
assert textureProperty.signature() != null;
|
|
||||||
|
|
||||||
buf.writeUtf(textureProperty.signature());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static SkinShuffleSkinRefreshV2Payload decode(FriendlyByteBuf buf) {
|
|
||||||
if (buf.readBoolean()) {
|
|
||||||
return new SkinShuffleSkinRefreshV2Payload(new Property(buf.readUtf(), buf.readUtf(), buf.readUtf()));
|
|
||||||
}
|
|
||||||
return new SkinShuffleSkinRefreshV2Payload(new Property(buf.readUtf(), buf.readUtf(), null));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public @NotNull CustomPacketPayload.Type<? extends CustomPacketPayload> type() {
|
|
||||||
return PACKET_ID;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
package net.lionarius.skinrestorer.config;
|
||||||
|
|
||||||
|
public record BuiltInProviderConfig(boolean enabled, String name, CacheConfig cache) {
|
||||||
|
public boolean isValid() {
|
||||||
|
return this.name != null && this.cache != null && !this.name.isEmpty() && this.cache.isValid();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
package net.lionarius.skinrestorer.config;
|
||||||
|
|
||||||
|
public record CacheConfig(boolean enabled, long duration) {
|
||||||
|
public boolean isValid() {
|
||||||
|
return this.duration > 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,15 +1,13 @@
|
|||||||
package net.lionarius.skinrestorer.config;
|
package net.lionarius.skinrestorer.config;
|
||||||
|
|
||||||
import net.lionarius.skinrestorer.SkinRestorer;
|
import net.lionarius.skinrestorer.SkinRestorer;
|
||||||
import net.lionarius.skinrestorer.config.provider.ProvidersConfig;
|
|
||||||
import net.lionarius.skinrestorer.util.FileUtils;
|
import net.lionarius.skinrestorer.util.FileUtils;
|
||||||
import net.lionarius.skinrestorer.util.JsonUtils;
|
import net.lionarius.skinrestorer.util.JsonUtils;
|
||||||
import net.lionarius.skinrestorer.util.gson.GsonPostProcessable;
|
|
||||||
|
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
public final class Config implements GsonPostProcessable {
|
public final class Config {
|
||||||
|
|
||||||
public static final String CONFIG_FILENAME = "config.json";
|
public static final String CONFIG_FILENAME = "config.json";
|
||||||
|
|
||||||
@@ -18,8 +16,6 @@ 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 FirstJoinSkinProvider firstJoinSkinProvider = FirstJoinSkinProvider.MOJANG;
|
private FirstJoinSkinProvider firstJoinSkinProvider = FirstJoinSkinProvider.MOJANG;
|
||||||
@@ -39,10 +35,6 @@ 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;
|
||||||
}
|
}
|
||||||
@@ -76,23 +68,19 @@ public final class Config implements GsonPostProcessable {
|
|||||||
if (config == null)
|
if (config == null)
|
||||||
config = new Config();
|
config = new Config();
|
||||||
|
|
||||||
|
config.verifyAndFix();
|
||||||
|
|
||||||
FileUtils.writeFile(path.resolve(Config.CONFIG_FILENAME), JsonUtils.toJson(config));
|
FileUtils.writeFile(path.resolve(Config.CONFIG_FILENAME), JsonUtils.toJson(config));
|
||||||
|
|
||||||
return config;
|
return config;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
private void verifyAndFix() {
|
||||||
public void gsonPostProcess() {
|
|
||||||
if (this.language == null || this.language.isEmpty()) {
|
if (this.language == null || this.language.isEmpty()) {
|
||||||
SkinRestorer.LOGGER.warn("Language config is null or empty, defaulting to 'en_us'");
|
SkinRestorer.LOGGER.warn("Language config is null or empty, defaulting to 'en_us'");
|
||||||
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;
|
||||||
@@ -107,7 +95,7 @@ public final class Config implements GsonPostProcessable {
|
|||||||
try {
|
try {
|
||||||
this.parsedProxy = Proxy.parse(this.proxy);
|
this.parsedProxy = Proxy.parse(this.proxy);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
SkinRestorer.LOGGER.warn("Could not parse proxy config: {}", e.getMessage());
|
SkinRestorer.LOGGER.warn("Could not parse proxy config", e);
|
||||||
this.parsedProxy = null;
|
this.parsedProxy = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -121,5 +109,8 @@ public final class Config implements GsonPostProcessable {
|
|||||||
SkinRestorer.LOGGER.warn("Providers config is null, using default");
|
SkinRestorer.LOGGER.warn("Providers config is null, using default");
|
||||||
this.providers = ProvidersConfig.DEFAULT;
|
this.providers = ProvidersConfig.DEFAULT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!this.providers.isValid())
|
||||||
|
this.providers.fix();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,65 @@
|
|||||||
|
package net.lionarius.skinrestorer.config;
|
||||||
|
|
||||||
|
import net.lionarius.skinrestorer.SkinRestorer;
|
||||||
|
import net.lionarius.skinrestorer.skin.provider.ElyBySkinProvider;
|
||||||
|
import net.lionarius.skinrestorer.skin.provider.MineskinSkinProvider;
|
||||||
|
import net.lionarius.skinrestorer.skin.provider.MojangSkinProvider;
|
||||||
|
|
||||||
|
public final class ProvidersConfig {
|
||||||
|
public static final ProvidersConfig DEFAULT = new ProvidersConfig(
|
||||||
|
new BuiltInProviderConfig(true, MojangSkinProvider.PROVIDER_NAME, new CacheConfig(true, 60)),
|
||||||
|
new BuiltInProviderConfig(true, ElyBySkinProvider.PROVIDER_NAME, new CacheConfig(true, 60)),
|
||||||
|
new BuiltInProviderConfig(true, MineskinSkinProvider.PROVIDER_NAME, new CacheConfig(true, 300))
|
||||||
|
);
|
||||||
|
|
||||||
|
private BuiltInProviderConfig mojang;
|
||||||
|
private BuiltInProviderConfig ely_by;
|
||||||
|
private BuiltInProviderConfig mineskin;
|
||||||
|
|
||||||
|
public ProvidersConfig(BuiltInProviderConfig mojang, BuiltInProviderConfig ely_by, BuiltInProviderConfig mineskin) {
|
||||||
|
this.mojang = mojang;
|
||||||
|
this.ely_by = ely_by;
|
||||||
|
this.mineskin = mineskin;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isValid() {
|
||||||
|
if (this == ProvidersConfig.DEFAULT)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
return this.mojang == null || !this.mojang.isValid()
|
||||||
|
|| this.ely_by == null || !this.ely_by.isValid()
|
||||||
|
|| this.mineskin == null || !this.mineskin.isValid();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void fix() {
|
||||||
|
if (this == ProvidersConfig.DEFAULT)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (this.mojang == null || !this.mojang.isValid()) {
|
||||||
|
SkinRestorer.LOGGER.warn("Mojang provider config is invalid, using default");
|
||||||
|
this.mojang = ProvidersConfig.DEFAULT.mojang();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.ely_by == null || !this.ely_by.isValid()) {
|
||||||
|
SkinRestorer.LOGGER.warn("Ely.By provider config is invalid, using default");
|
||||||
|
this.ely_by = ProvidersConfig.DEFAULT.ely_by();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.mineskin == null || !this.mineskin.isValid()) {
|
||||||
|
SkinRestorer.LOGGER.warn("Mineskin provider config is invalid, using default");
|
||||||
|
this.mineskin = ProvidersConfig.DEFAULT.mineskin();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public BuiltInProviderConfig mojang() {
|
||||||
|
return this.mojang;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BuiltInProviderConfig ely_by() {
|
||||||
|
return this.ely_by;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BuiltInProviderConfig mineskin() {
|
||||||
|
return this.mineskin;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,42 +0,0 @@
|
|||||||
package net.lionarius.skinrestorer.config.provider;
|
|
||||||
|
|
||||||
import net.lionarius.skinrestorer.SkinRestorer;
|
|
||||||
import net.lionarius.skinrestorer.util.gson.GsonPostProcessable;
|
|
||||||
|
|
||||||
public abstract class BuiltInProviderConfig implements GsonPostProcessable {
|
|
||||||
protected boolean enabled;
|
|
||||||
protected String name;
|
|
||||||
protected CacheConfig cache;
|
|
||||||
|
|
||||||
public BuiltInProviderConfig(String name, CacheConfig cache) {
|
|
||||||
this.enabled = true;
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,28 +0,0 @@
|
|||||||
package net.lionarius.skinrestorer.config.provider;
|
|
||||||
|
|
||||||
import net.lionarius.skinrestorer.SkinRestorer;
|
|
||||||
|
|
||||||
public final class CacheConfig {
|
|
||||||
private boolean enabled;
|
|
||||||
private long duration;
|
|
||||||
|
|
||||||
public CacheConfig(boolean enabled, long duration) {
|
|
||||||
this.enabled = enabled;
|
|
||||||
this.duration = duration;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean enabled() {
|
|
||||||
return enabled;
|
|
||||||
}
|
|
||||||
|
|
||||||
public long duration() {
|
|
||||||
return duration;
|
|
||||||
}
|
|
||||||
|
|
||||||
void validate(CacheConfig defaultValue) {
|
|
||||||
if (this.duration <= 0) {
|
|
||||||
SkinRestorer.LOGGER.warn("Cache duration is less than or equal to zero, defaulting to {}", defaultValue.duration());
|
|
||||||
this.duration = defaultValue.duration();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,16 +0,0 @@
|
|||||||
package net.lionarius.skinrestorer.config.provider;
|
|
||||||
|
|
||||||
import net.lionarius.skinrestorer.skin.provider.ElyBySkinProvider;
|
|
||||||
|
|
||||||
public final class ElyByProviderConfig extends BuiltInProviderConfig {
|
|
||||||
private static final CacheConfig DEFAULT_CACHE_VALUE = new CacheConfig(true, 60);
|
|
||||||
|
|
||||||
public ElyByProviderConfig() {
|
|
||||||
super(ElyBySkinProvider.PROVIDER_NAME, DEFAULT_CACHE_VALUE);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void gsonPostProcess() {
|
|
||||||
super.validate(ElyBySkinProvider.PROVIDER_NAME, DEFAULT_CACHE_VALUE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,30 +0,0 @@
|
|||||||
package net.lionarius.skinrestorer.config.provider;
|
|
||||||
|
|
||||||
import net.lionarius.skinrestorer.SkinRestorer;
|
|
||||||
import net.lionarius.skinrestorer.skin.provider.MineskinSkinProvider;
|
|
||||||
|
|
||||||
public final class MineskinProviderConfig extends BuiltInProviderConfig {
|
|
||||||
private static final CacheConfig DEFAULT_CACHE_VALUE = new CacheConfig(true, 300);
|
|
||||||
|
|
||||||
private String apiKey;
|
|
||||||
|
|
||||||
public MineskinProviderConfig() {
|
|
||||||
super(MineskinSkinProvider.PROVIDER_NAME, DEFAULT_CACHE_VALUE);
|
|
||||||
|
|
||||||
this.apiKey = "";
|
|
||||||
}
|
|
||||||
|
|
||||||
public String apiKey() {
|
|
||||||
return apiKey;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void gsonPostProcess() {
|
|
||||||
super.validate(MineskinSkinProvider.PROVIDER_NAME, DEFAULT_CACHE_VALUE);
|
|
||||||
|
|
||||||
if (this.apiKey == null) {
|
|
||||||
SkinRestorer.LOGGER.warn("Mineskin API key is null, defaulting to an empty string");
|
|
||||||
this.apiKey = "";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,16 +0,0 @@
|
|||||||
package net.lionarius.skinrestorer.config.provider;
|
|
||||||
|
|
||||||
import net.lionarius.skinrestorer.skin.provider.MojangSkinProvider;
|
|
||||||
|
|
||||||
public final class MojangProviderConfig extends BuiltInProviderConfig {
|
|
||||||
private static final CacheConfig DEFAULT_CACHE_VALUE = new CacheConfig(true, 60);
|
|
||||||
|
|
||||||
public MojangProviderConfig() {
|
|
||||||
super(MojangSkinProvider.PROVIDER_NAME, DEFAULT_CACHE_VALUE);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void gsonPostProcess() {
|
|
||||||
super.validate(MojangSkinProvider.PROVIDER_NAME, DEFAULT_CACHE_VALUE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,52 +0,0 @@
|
|||||||
package net.lionarius.skinrestorer.config.provider;
|
|
||||||
|
|
||||||
import net.lionarius.skinrestorer.SkinRestorer;
|
|
||||||
import net.lionarius.skinrestorer.util.gson.GsonPostProcessable;
|
|
||||||
|
|
||||||
public final class ProvidersConfig implements GsonPostProcessable {
|
|
||||||
public static final ProvidersConfig DEFAULT = new ProvidersConfig(
|
|
||||||
new MojangProviderConfig(),
|
|
||||||
new ElyByProviderConfig(),
|
|
||||||
new MineskinProviderConfig()
|
|
||||||
);
|
|
||||||
|
|
||||||
private MojangProviderConfig mojang;
|
|
||||||
private ElyByProviderConfig ely_by;
|
|
||||||
private MineskinProviderConfig mineskin;
|
|
||||||
|
|
||||||
public ProvidersConfig(MojangProviderConfig mojang, ElyByProviderConfig ely_by, MineskinProviderConfig mineskin) {
|
|
||||||
this.mojang = mojang;
|
|
||||||
this.ely_by = ely_by;
|
|
||||||
this.mineskin = mineskin;
|
|
||||||
}
|
|
||||||
|
|
||||||
public MojangProviderConfig mojang() {
|
|
||||||
return this.mojang;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ElyByProviderConfig ely_by() {
|
|
||||||
return this.ely_by;
|
|
||||||
}
|
|
||||||
|
|
||||||
public MineskinProviderConfig mineskin() {
|
|
||||||
return this.mineskin;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void gsonPostProcess() {
|
|
||||||
if (this.mojang == null) {
|
|
||||||
SkinRestorer.LOGGER.warn("Mojang provider config is null, using default");
|
|
||||||
this.mojang = ProvidersConfig.DEFAULT.mojang();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.ely_by == null) {
|
|
||||||
SkinRestorer.LOGGER.warn("Ely.By provider config is null, using default");
|
|
||||||
this.ely_by = ProvidersConfig.DEFAULT.ely_by();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.mineskin == null) {
|
|
||||||
SkinRestorer.LOGGER.warn("Mineskin provider config is null, using default");
|
|
||||||
this.mineskin = ProvidersConfig.DEFAULT.mineskin();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,19 +0,0 @@
|
|||||||
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();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,190 +0,0 @@
|
|||||||
package net.lionarius.skinrestorer.mineskin;
|
|
||||||
|
|
||||||
import com.google.gson.Gson;
|
|
||||||
import com.google.gson.JsonObject;
|
|
||||||
import com.google.gson.JsonParseException;
|
|
||||||
import org.mineskin.MineSkinClientImpl;
|
|
||||||
import org.mineskin.data.CodeAndMessage;
|
|
||||||
import org.mineskin.exception.MineSkinRequestException;
|
|
||||||
import org.mineskin.exception.MineskinException;
|
|
||||||
import org.mineskin.request.RequestHandler;
|
|
||||||
import org.mineskin.response.MineSkinResponse;
|
|
||||||
import org.mineskin.response.ResponseConstructor;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStream;
|
|
||||||
import java.net.InetSocketAddress;
|
|
||||||
import java.net.ProxySelector;
|
|
||||||
import java.net.URI;
|
|
||||||
import java.net.http.HttpClient;
|
|
||||||
import java.net.http.HttpRequest;
|
|
||||||
import java.net.http.HttpRequest.BodyPublishers;
|
|
||||||
import java.net.http.HttpResponse;
|
|
||||||
import java.net.http.HttpResponse.BodyHandlers;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.logging.Level;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
// copy-pasted from https://github.com/InventivetalentDev/MineskinClient/blob/master/java11/src/main/java/org/mineskin/Java11RequestHandler.java
|
|
||||||
// with some modifications to support proxy
|
|
||||||
public class Java11RequestHandler extends RequestHandler {
|
|
||||||
|
|
||||||
private final Gson gson;
|
|
||||||
private final HttpClient httpClient;
|
|
||||||
|
|
||||||
public Java11RequestHandler(String baseUrl, String userAgent, String apiKey, int timeout, Gson gson, InetSocketAddress proxy) {
|
|
||||||
super(baseUrl, userAgent, apiKey, timeout, gson);
|
|
||||||
this.gson = gson;
|
|
||||||
|
|
||||||
HttpClient.Builder clientBuilder = HttpClient.newBuilder()
|
|
||||||
.connectTimeout(java.time.Duration.ofMillis(timeout));
|
|
||||||
|
|
||||||
if (userAgent != null) {
|
|
||||||
clientBuilder.followRedirects(HttpClient.Redirect.NORMAL);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (proxy != null) {
|
|
||||||
clientBuilder.proxy(ProxySelector.of(proxy));
|
|
||||||
}
|
|
||||||
|
|
||||||
this.httpClient = clientBuilder.build();
|
|
||||||
}
|
|
||||||
|
|
||||||
private <T, R extends MineSkinResponse<T>> R wrapResponse(HttpResponse<String> response, Class<T> clazz, ResponseConstructor<T, R> constructor)
|
|
||||||
throws IOException {
|
|
||||||
String rawBody = response.body();
|
|
||||||
try {
|
|
||||||
JsonObject jsonBody = gson.fromJson(rawBody, JsonObject.class);
|
|
||||||
R wrapped = constructor.construct(
|
|
||||||
response.statusCode(),
|
|
||||||
lowercaseHeaders(response.headers().map()),
|
|
||||||
jsonBody,
|
|
||||||
gson, clazz
|
|
||||||
);
|
|
||||||
if (!wrapped.isSuccess()) {
|
|
||||||
throw new MineSkinRequestException(
|
|
||||||
wrapped.getFirstError().map(CodeAndMessage::code).orElse("request_failed"),
|
|
||||||
wrapped.getFirstError().map(CodeAndMessage::message).orElse("Request Failed"),
|
|
||||||
wrapped
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return wrapped;
|
|
||||||
} catch (JsonParseException e) {
|
|
||||||
MineSkinClientImpl.LOGGER.log(Level.WARNING, "Failed to parse response body: " + rawBody, e);
|
|
||||||
throw new MineskinException("Failed to parse response", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private Map<String, String> lowercaseHeaders(Map<String, java.util.List<String>> headers) {
|
|
||||||
return headers.entrySet().stream()
|
|
||||||
.collect(Collectors.toMap(
|
|
||||||
entry -> entry.getKey().toLowerCase(),
|
|
||||||
entry -> String.join(", ", entry.getValue())
|
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
||||||
public <T, R extends MineSkinResponse<T>> R getJson(String url, Class<T> clazz, ResponseConstructor<T, R> constructor)
|
|
||||||
throws IOException {
|
|
||||||
url = this.baseUrl + url;
|
|
||||||
MineSkinClientImpl.LOGGER.fine("GET " + url);
|
|
||||||
|
|
||||||
HttpRequest.Builder requestBuilder = HttpRequest.newBuilder()
|
|
||||||
.uri(URI.create(url))
|
|
||||||
.GET()
|
|
||||||
.header("User-Agent", this.userAgent);
|
|
||||||
HttpRequest request;
|
|
||||||
if (apiKey != null) {
|
|
||||||
request = requestBuilder
|
|
||||||
.header("Authorization", "Bearer " + apiKey)
|
|
||||||
.header("Accept", "application/json").build();
|
|
||||||
} else {
|
|
||||||
request = requestBuilder.build();
|
|
||||||
}
|
|
||||||
HttpResponse<String> response;
|
|
||||||
try {
|
|
||||||
response = this.httpClient.send(request, BodyHandlers.ofString());
|
|
||||||
} catch (InterruptedException e) {
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
|
||||||
return wrapResponse(response, clazz, constructor);
|
|
||||||
}
|
|
||||||
|
|
||||||
public <T, R extends MineSkinResponse<T>> R postJson(String url, JsonObject data, Class<T> clazz, ResponseConstructor<T, R> constructor)
|
|
||||||
throws IOException {
|
|
||||||
url = this.baseUrl + url;
|
|
||||||
MineSkinClientImpl.LOGGER.fine("POST " + url);
|
|
||||||
|
|
||||||
HttpRequest.Builder requestBuilder = HttpRequest.newBuilder()
|
|
||||||
.uri(URI.create(url))
|
|
||||||
.POST(BodyPublishers.ofString(gson.toJson(data)))
|
|
||||||
.header("Content-Type", "application/json")
|
|
||||||
.header("User-Agent", this.userAgent);
|
|
||||||
HttpRequest request;
|
|
||||||
if (apiKey != null) {
|
|
||||||
request = requestBuilder
|
|
||||||
.header("Authorization", "Bearer " + apiKey)
|
|
||||||
.header("Accept", "application/json").build();
|
|
||||||
} else {
|
|
||||||
request = requestBuilder.build();
|
|
||||||
}
|
|
||||||
|
|
||||||
HttpResponse<String> response;
|
|
||||||
try {
|
|
||||||
response = this.httpClient.send(request, BodyHandlers.ofString());
|
|
||||||
} catch (InterruptedException e) {
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
|
||||||
return wrapResponse(response, clazz, 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 {
|
|
||||||
url = this.baseUrl + url;
|
|
||||||
MineSkinClientImpl.LOGGER.fine("POST " + url);
|
|
||||||
|
|
||||||
String boundary = "mineskin-" + System.currentTimeMillis();
|
|
||||||
StringBuilder bodyBuilder = new StringBuilder();
|
|
||||||
|
|
||||||
// add form fields
|
|
||||||
for (Map.Entry<String, String> entry : data.entrySet()) {
|
|
||||||
bodyBuilder.append("--").append(boundary).append("\r\n")
|
|
||||||
.append("Content-Disposition: form-data; name=\"").append(entry.getKey()).append("\"\r\n\r\n")
|
|
||||||
.append(entry.getValue()).append("\r\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
// add file
|
|
||||||
byte[] fileContent = in.readAllBytes();
|
|
||||||
bodyBuilder.append("--").append(boundary).append("\r\n")
|
|
||||||
.append("Content-Disposition: form-data; name=\"").append(key)
|
|
||||||
.append("\"; filename=\"").append(filename).append("\"\r\n")
|
|
||||||
.append("Content-Type: image/png\r\n\r\n");
|
|
||||||
byte[] bodyStart = bodyBuilder.toString().getBytes();
|
|
||||||
byte[] boundaryEnd = ("\r\n--" + boundary + "--\r\n").getBytes();
|
|
||||||
byte[] bodyString = new byte[bodyStart.length + fileContent.length + boundaryEnd.length];
|
|
||||||
System.arraycopy(bodyStart, 0, bodyString, 0, bodyStart.length);
|
|
||||||
System.arraycopy(fileContent, 0, bodyString, bodyStart.length, fileContent.length);
|
|
||||||
System.arraycopy(boundaryEnd, 0, bodyString, bodyStart.length + fileContent.length, boundaryEnd.length);
|
|
||||||
|
|
||||||
HttpRequest.Builder requestBuilder = HttpRequest.newBuilder()
|
|
||||||
.uri(URI.create(url))
|
|
||||||
.POST(HttpRequest.BodyPublishers.ofByteArray(bodyString))
|
|
||||||
.header("Content-Type", "multipart/form-data; boundary=" + boundary)
|
|
||||||
.header("User-Agent", this.userAgent);
|
|
||||||
HttpRequest request;
|
|
||||||
if (apiKey != null) {
|
|
||||||
request = requestBuilder
|
|
||||||
.header("Authorization", "Bearer " + apiKey)
|
|
||||||
.header("Accept", "application/json").build();
|
|
||||||
} else {
|
|
||||||
request = requestBuilder.build();
|
|
||||||
}
|
|
||||||
|
|
||||||
HttpResponse<String> response;
|
|
||||||
try {
|
|
||||||
response = this.httpClient.send(request, BodyHandlers.ofString());
|
|
||||||
} catch (InterruptedException e) {
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
|
||||||
return wrapResponse(response, clazz, constructor);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -9,5 +9,5 @@ import org.spongepowered.asm.mixin.gen.Accessor;
|
|||||||
public interface ChunkMapAccessor {
|
public interface ChunkMapAccessor {
|
||||||
|
|
||||||
@Accessor
|
@Accessor
|
||||||
Int2ObjectMap<TrackedEntityAccessorInvoker> getEntityMap();
|
Int2ObjectMap<Object> getEntityMap();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,14 +0,0 @@
|
|||||||
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();
|
|
||||||
}
|
|
||||||
@@ -9,7 +9,6 @@ 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;
|
||||||
@@ -28,34 +27,18 @@ public abstract class PlayerListMixin {
|
|||||||
|
|
||||||
@Inject(method = "remove", at = @At("TAIL"))
|
@Inject(method = "remove", at = @At("TAIL"))
|
||||||
private void remove(ServerPlayer player, CallbackInfo ci) {
|
private void remove(ServerPlayer player, CallbackInfo ci) {
|
||||||
SkinRestorer.Events.onPlayerDisconnect(player);
|
SkinRestorer.getSkinStorage().removeSkin(player.getUUID());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Inject(method = "removeAll", at = @At("HEAD"))
|
@Inject(method = "removeAll", at = @At("HEAD"))
|
||||||
private void removeAll(CallbackInfo ci) {
|
private void removeAll(CallbackInfo ci) {
|
||||||
for (var player : getPlayers()) {
|
for (ServerPlayer player : getPlayers()) {
|
||||||
SkinRestorer.Events.onPlayerDisconnect(player);
|
SkinRestorer.getSkinStorage().removeSkin(player.getUUID());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@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, CommonListenerCookie cookie, 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()));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -72,17 +72,17 @@ public abstract class ServerLoginPacketListenerImplMixin {
|
|||||||
|
|
||||||
@Unique
|
@Unique
|
||||||
private static void skinrestorer$fetchSkin(GameProfile profile, SkinProviderContext context) {
|
private static void skinrestorer$fetchSkin(GameProfile profile, SkinProviderContext context) {
|
||||||
SkinRestorer.LOGGER.debug("Fetching {}'s skin", profile.getName());
|
SkinRestorer.LOGGER.debug("fetching {}'s skin", profile.getName());
|
||||||
|
|
||||||
var result = SkinRestorer.getProvider(context.name()).map(
|
var result = SkinRestorer.getProvider(context.name()).map(
|
||||||
provider -> provider.fetchSkin(context.argument(), context.variant())
|
provider -> provider.fetchSkin(context.argument(), context.variant())
|
||||||
).orElseGet(() -> Result.error(new IllegalArgumentException("Skin provider is not registered: " + context.name())));
|
).orElseGet(() -> Result.error(new IllegalArgumentException("skin provider is not registered: " + context.name())));
|
||||||
|
|
||||||
if (!result.isError()) {
|
if (!result.isError()) {
|
||||||
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 '{}:{}'", context.name(), context.argument(), result.getErrorValue());
|
SkinRestorer.LOGGER.warn("failed to fetch skin", result.getErrorValue());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,69 +0,0 @@
|
|||||||
package net.lionarius.skinrestorer.mixin;
|
|
||||||
|
|
||||||
import com.mojang.authlib.GameProfile;
|
|
||||||
import net.lionarius.skinrestorer.SkinRestorer;
|
|
||||||
import net.lionarius.skinrestorer.util.PlayerUtils;
|
|
||||||
import net.minecraft.Util;
|
|
||||||
import net.minecraft.server.Services;
|
|
||||||
import net.minecraft.world.level.block.entity.SkullBlockEntity;
|
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
|
||||||
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.CallbackInfoReturnable;
|
|
||||||
|
|
||||||
import java.util.Locale;
|
|
||||||
import java.util.Optional;
|
|
||||||
import java.util.UUID;
|
|
||||||
import java.util.concurrent.CompletableFuture;
|
|
||||||
import java.util.function.BooleanSupplier;
|
|
||||||
|
|
||||||
@Mixin(SkullBlockEntity.class)
|
|
||||||
public abstract class SkullBlockEntityMixin {
|
|
||||||
|
|
||||||
@Inject(method = "fetchProfileByName", at = @At("HEAD"),
|
|
||||||
cancellable = true)
|
|
||||||
private static void fetchProfileByName(String name, Services services, CallbackInfoReturnable<CompletableFuture<Optional<GameProfile>>> cir) {
|
|
||||||
if (name == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
var profileOpt = Optional.<GameProfile>empty();
|
|
||||||
var gameProfileInfo = ((GameProfileCacheAccessor) services.profileCache()).getProfilesByName().get(name.toLowerCase(Locale.ROOT));
|
|
||||||
|
|
||||||
if (gameProfileInfo != null)
|
|
||||||
profileOpt = Optional.of(gameProfileInfo.getProfile());
|
|
||||||
|
|
||||||
skinrestorer$replaceSkin(profileOpt, cir);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Inject(method = "fetchProfileById", at = @At("HEAD"),
|
|
||||||
cancellable = true)
|
|
||||||
private static void fetchProfileById(UUID id, Services services, BooleanSupplier cacheUninitialized, CallbackInfoReturnable<CompletableFuture<Optional<GameProfile>>> cir) {
|
|
||||||
if (id == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
var profileOpt = services.profileCache().get(id);
|
|
||||||
|
|
||||||
skinrestorer$replaceSkin(profileOpt, cir);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Unique
|
|
||||||
private static void skinrestorer$replaceSkin(Optional<GameProfile> profileOpt, CallbackInfoReturnable<CompletableFuture<Optional<GameProfile>>> cir) {
|
|
||||||
if (SkinRestorer.getMinecraftServer() == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (profileOpt.isEmpty())
|
|
||||||
return;
|
|
||||||
|
|
||||||
var profile = PlayerUtils.cloneGameProfile(profileOpt.get());
|
|
||||||
|
|
||||||
if (SkinRestorer.getSkinStorage().hasSavedSkin(profile.getId())) {
|
|
||||||
cir.setReturnValue(CompletableFuture.supplyAsync(() -> {
|
|
||||||
var skin = SkinRestorer.getSkinStorage().getSkin(profile.getId(), false);
|
|
||||||
PlayerUtils.applyRestoredSkin(profile, skin.value());
|
|
||||||
|
|
||||||
return Optional.of(profile);
|
|
||||||
}, Util.backgroundExecutor().forName("getProfile")));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,17 +1,15 @@
|
|||||||
package net.lionarius.skinrestorer.platform;
|
package net.lionarius.skinrestorer.platform;
|
||||||
|
|
||||||
import net.lionarius.skinrestorer.SkinRestorer;
|
import net.lionarius.skinrestorer.SkinRestorer;
|
||||||
import net.lionarius.skinrestorer.platform.services.CompatibilityHelper;
|
|
||||||
import net.lionarius.skinrestorer.platform.services.PlatformHelper;
|
import net.lionarius.skinrestorer.platform.services.PlatformHelper;
|
||||||
|
|
||||||
import java.util.ServiceLoader;
|
import java.util.ServiceLoader;
|
||||||
|
|
||||||
public final class Services {
|
public final class Services {
|
||||||
|
|
||||||
public final static PlatformHelper PLATFORM = load(PlatformHelper.class);
|
|
||||||
public final static CompatibilityHelper COMPATIBILITY = load(CompatibilityHelper.class);
|
|
||||||
|
|
||||||
private Services() {}
|
private Services() {}
|
||||||
|
|
||||||
|
public final static PlatformHelper PLATFORM = load(PlatformHelper.class);
|
||||||
|
|
||||||
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)
|
||||||
|
|||||||
@@ -1,8 +0,0 @@
|
|||||||
package net.lionarius.skinrestorer.platform.services;
|
|
||||||
|
|
||||||
import net.minecraft.server.level.ServerPlayer;
|
|
||||||
|
|
||||||
public interface CompatibilityHelper {
|
|
||||||
|
|
||||||
void skinShuffle_sendHandshake(ServerPlayer player);
|
|
||||||
}
|
|
||||||
@@ -27,7 +27,9 @@ public class SkinIO {
|
|||||||
|
|
||||||
public SkinValue loadSkin(UUID uuid) {
|
public SkinValue loadSkin(UUID uuid) {
|
||||||
try {
|
try {
|
||||||
return SkinIO.loadSkin(savePath.resolve(SkinIO.uuidToFilename(uuid)));
|
var value = 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,22 +17,15 @@ 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, boolean cache) {
|
public SkinValue getSkin(UUID uuid) {
|
||||||
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,14 +3,11 @@ 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) implements GsonPostProcessable {
|
@Nullable Property value, @Nullable Property originalValue) {
|
||||||
|
|
||||||
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);
|
||||||
|
|
||||||
@@ -33,9 +30,4 @@ 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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,11 +9,7 @@ import com.mojang.authlib.properties.Property;
|
|||||||
import com.mojang.authlib.yggdrasil.response.MinecraftProfilePropertiesResponse;
|
import com.mojang.authlib.yggdrasil.response.MinecraftProfilePropertiesResponse;
|
||||||
import net.lionarius.skinrestorer.SkinRestorer;
|
import net.lionarius.skinrestorer.SkinRestorer;
|
||||||
import net.lionarius.skinrestorer.skin.SkinVariant;
|
import net.lionarius.skinrestorer.skin.SkinVariant;
|
||||||
import net.lionarius.skinrestorer.util.JsonUtils;
|
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.util.StringUtil;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@@ -40,11 +36,7 @@ public final class ElyBySkinProvider implements SkinProvider {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void reload() {
|
public static void createCache() {
|
||||||
createCache();
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void createCache() {
|
|
||||||
var config = SkinRestorer.getConfig().providersConfig().ely_by();
|
var config = SkinRestorer.getConfig().providersConfig().ely_by();
|
||||||
var time = config.cache().enabled() ? config.cache().duration() : 0;
|
var time = config.cache().enabled() ? config.cache().duration() : 0;
|
||||||
|
|
||||||
@@ -71,7 +63,7 @@ public final class ElyBySkinProvider implements SkinProvider {
|
|||||||
@Override
|
@Override
|
||||||
public Result<Optional<Property>, Exception> fetchSkin(String username, SkinVariant variant) {
|
public Result<Optional<Property>, Exception> fetchSkin(String username, SkinVariant variant) {
|
||||||
try {
|
try {
|
||||||
if (!StringUtil.isValidPlayerName(username))
|
if (!StringUtils.isValidPlayerName(username))
|
||||||
throw new IllegalArgumentException("invalid username");
|
throw new IllegalArgumentException("invalid username");
|
||||||
|
|
||||||
var usernameLowerCase = username.toLowerCase(Locale.ROOT);
|
var usernameLowerCase = username.toLowerCase(Locale.ROOT);
|
||||||
|
|||||||
@@ -4,25 +4,21 @@ 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.google.gson.JsonObject;
|
||||||
import com.mojang.authlib.properties.Property;
|
import com.mojang.authlib.properties.Property;
|
||||||
import it.unimi.dsi.fastutil.Pair;
|
import it.unimi.dsi.fastutil.Pair;
|
||||||
import net.lionarius.skinrestorer.SkinRestorer;
|
import net.lionarius.skinrestorer.SkinRestorer;
|
||||||
import net.lionarius.skinrestorer.mineskin.Java11RequestHandler;
|
|
||||||
import net.lionarius.skinrestorer.skin.SkinVariant;
|
import net.lionarius.skinrestorer.skin.SkinVariant;
|
||||||
import net.lionarius.skinrestorer.util.JsonUtils;
|
import net.lionarius.skinrestorer.util.JsonUtils;
|
||||||
import net.lionarius.skinrestorer.util.PlayerUtils;
|
import net.lionarius.skinrestorer.util.PlayerUtils;
|
||||||
import net.lionarius.skinrestorer.util.Result;
|
import net.lionarius.skinrestorer.util.Result;
|
||||||
import net.lionarius.skinrestorer.util.WebUtils;
|
import net.lionarius.skinrestorer.util.WebUtils;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.mineskin.MineSkinClient;
|
|
||||||
import org.mineskin.data.Variant;
|
|
||||||
import org.mineskin.data.Visibility;
|
|
||||||
import org.mineskin.request.GenerateRequest;
|
|
||||||
import org.mineskin.response.QueueResponse;
|
|
||||||
|
|
||||||
import java.net.InetSocketAddress;
|
import java.io.IOException;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.time.Duration;
|
import java.net.URISyntaxException;
|
||||||
|
import java.net.http.HttpRequest;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
@@ -30,34 +26,19 @@ public final class MineskinSkinProvider implements SkinProvider {
|
|||||||
|
|
||||||
public static final String PROVIDER_NAME = "web";
|
public static final String PROVIDER_NAME = "web";
|
||||||
|
|
||||||
private static MineSkinClient MINESKIN_CLIENT;
|
private static final URI API_URI;
|
||||||
|
|
||||||
private static LoadingCache<Pair<URI, SkinVariant>, Optional<Property>> SKIN_CACHE;
|
private static LoadingCache<Pair<URI, SkinVariant>, Optional<Property>> SKIN_CACHE;
|
||||||
|
|
||||||
public static void reload() {
|
static {
|
||||||
var config = SkinRestorer.getConfig();
|
try {
|
||||||
var configApiKey = config.providersConfig().mineskin().apiKey();
|
API_URI = new URI("https://api.mineskin.org");
|
||||||
|
} catch (URISyntaxException e) {
|
||||||
MINESKIN_CLIENT = MineSkinClient
|
throw new IllegalArgumentException(e);
|
||||||
.builder()
|
}
|
||||||
.userAgent(WebUtils.USER_AGENT)
|
|
||||||
.gson(JsonUtils.GSON)
|
|
||||||
.timeout((int) Duration.ofSeconds(config.requestTimeout()).toMillis())
|
|
||||||
.requestHandler((baseUrl, userAgent, apiKey, timeout, gson) -> new Java11RequestHandler(
|
|
||||||
baseUrl,
|
|
||||||
userAgent,
|
|
||||||
apiKey,
|
|
||||||
timeout,
|
|
||||||
gson,
|
|
||||||
SkinRestorer.getConfig().proxy().map(proxy -> new InetSocketAddress(proxy.host(), proxy.port())).orElse(null)
|
|
||||||
))
|
|
||||||
.apiKey(configApiKey.isEmpty() ? null : configApiKey)
|
|
||||||
.build();
|
|
||||||
|
|
||||||
createCache();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void createCache() {
|
public static void createCache() {
|
||||||
var config = SkinRestorer.getConfig().providersConfig().mineskin();
|
var config = SkinRestorer.getConfig().providersConfig().mineskin();
|
||||||
var time = config.cache().enabled() ? config.cache().duration() : 0;
|
var time = config.cache().enabled() ? config.cache().duration() : 0;
|
||||||
|
|
||||||
@@ -95,26 +76,29 @@ public final class MineskinSkinProvider implements SkinProvider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static Optional<Property> loadSkin(URI uri, SkinVariant variant) throws Exception {
|
private static Optional<Property> loadSkin(URI uri, SkinVariant variant) throws Exception {
|
||||||
var mineskinVariant = switch (variant) {
|
var result = MineskinSkinProvider.uploadToMineskin(uri, variant);
|
||||||
case CLASSIC -> Variant.CLASSIC;
|
var texture = result.getAsJsonObject("data").getAsJsonObject("texture");
|
||||||
case SLIM -> Variant.SLIM;
|
var textures = new Property(PlayerUtils.TEXTURES_KEY, texture.get("value").getAsString(), texture.get("signature").getAsString());
|
||||||
};
|
|
||||||
|
|
||||||
var request = GenerateRequest.url(uri)
|
return Optional.of(textures);
|
||||||
.variant(mineskinVariant)
|
}
|
||||||
.name("skinrestorer-skin")
|
|
||||||
.visibility(Visibility.UNLISTED);
|
private static JsonObject uploadToMineskin(URI url, SkinVariant variant) throws IOException {
|
||||||
|
var body = ("{\"variant\":\"%s\",\"name\":\"%s\",\"visibility\":%d,\"url\":\"%s\"}")
|
||||||
|
.formatted(variant.toString(), "none", 0, url);
|
||||||
|
|
||||||
var skin = MINESKIN_CLIENT.queue().submit(request)
|
var request = HttpRequest.newBuilder()
|
||||||
.thenApply(QueueResponse::getJob)
|
.uri(MineskinSkinProvider.API_URI.resolve("/generate/url"))
|
||||||
.thenCompose(jobInfo -> jobInfo.waitForCompletion(MINESKIN_CLIENT))
|
.POST(HttpRequest.BodyPublishers.ofString(body))
|
||||||
.thenCompose(jobReference -> jobReference.getOrLoadSkin(MINESKIN_CLIENT))
|
.header("Content-Type", "application/json")
|
||||||
.join();
|
.build();
|
||||||
|
|
||||||
return Optional.of(new Property(
|
var response = WebUtils.executeRequest(request);
|
||||||
PlayerUtils.TEXTURES_KEY,
|
WebUtils.throwOnClientErrors(response);
|
||||||
skin.texture().data().value(),
|
|
||||||
skin.texture().data().signature()
|
if (response.statusCode() != 200)
|
||||||
));
|
throw new IllegalArgumentException("could not get mineskin skin");
|
||||||
|
|
||||||
|
return JsonUtils.parseJson(response.body());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,20 +4,14 @@ 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.*;
|
import com.mojang.authlib.GameProfile;
|
||||||
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 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.JsonUtils;
|
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.server.players.GameProfileCache;
|
import net.minecraft.server.players.GameProfileCache;
|
||||||
import net.minecraft.util.StringUtil;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@@ -32,8 +26,7 @@ public final class MojangSkinProvider implements SkinProvider {
|
|||||||
|
|
||||||
public static final String PROVIDER_NAME = "mojang";
|
public static final String PROVIDER_NAME = "mojang";
|
||||||
|
|
||||||
private static final Environment ENVIRONMENT;
|
private static final URI API_URI;
|
||||||
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";
|
||||||
@@ -43,44 +36,27 @@ public final class MojangSkinProvider implements SkinProvider {
|
|||||||
|
|
||||||
static {
|
static {
|
||||||
try {
|
try {
|
||||||
ENVIRONMENT = EnvironmentParser.getEnvironmentFromProperties().orElse(YggdrasilEnvironment.PROD.getEnvironment());
|
API_URI = new URI("https://api.mojang.com");
|
||||||
|
SESSION_SERVER_URI = new URI("https://sessionserver.mojang.com");
|
||||||
SERVICES_SERVER_URI = new URI(ENVIRONMENT.servicesHost());
|
|
||||||
SESSION_SERVER_URI = new URI(ENVIRONMENT.sessionHost());
|
|
||||||
} catch (URISyntaxException e) {
|
} catch (URISyntaxException e) {
|
||||||
throw new IllegalArgumentException(e);
|
throw new IllegalArgumentException(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
PROFILE_CACHE = new GameProfileCache(new GameProfileRepository() {
|
PROFILE_CACHE = new GameProfileCache((names, callback) -> {
|
||||||
@Override
|
for (var name : names) {
|
||||||
public void findProfilesByNames(String[] names, ProfileLookupCallback callback) {
|
|
||||||
for (var name : names) {
|
|
||||||
try {
|
|
||||||
var profile = MojangSkinProvider.getProfile(name);
|
|
||||||
callback.onProfileLookupSucceeded(profile);
|
|
||||||
} catch (IOException e) {
|
|
||||||
throw new TransparentException(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Optional<GameProfile> findProfileByName(String name) {
|
|
||||||
try {
|
try {
|
||||||
var profile = MojangSkinProvider.getProfile(name);
|
var profile = MojangSkinProvider.getProfile(name);
|
||||||
return Optional.of(profile);
|
callback.onProfileLookupSucceeded(profile);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new TransparentException(e);
|
callback.onProfileLookupFailed(name, e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, SkinRestorer.getConfigDir().resolve(PROFILE_CACHE_FILENAME).toFile());
|
}, SkinRestorer.getConfigDir().resolve(PROFILE_CACHE_FILENAME).toFile());
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void reload() {
|
public static void createCache() {
|
||||||
createCache();
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void createCache() {
|
|
||||||
var config = SkinRestorer.getConfig().providersConfig().mojang();
|
var config = SkinRestorer.getConfig().providersConfig().mojang();
|
||||||
var time = config.cache().enabled() ? config.cache().duration() : 0;
|
var time = config.cache().enabled() ? config.cache().duration() : 0;
|
||||||
|
|
||||||
@@ -111,7 +87,7 @@ public final class MojangSkinProvider implements SkinProvider {
|
|||||||
@Override
|
@Override
|
||||||
public Result<Optional<Property>, Exception> fetchSkin(String username, SkinVariant variant) {
|
public Result<Optional<Property>, Exception> fetchSkin(String username, SkinVariant variant) {
|
||||||
try {
|
try {
|
||||||
if (!StringUtil.isValidPlayerName(username))
|
if (!StringUtils.isValidPlayerName(username))
|
||||||
throw new IllegalArgumentException("invalid username");
|
throw new IllegalArgumentException("invalid username");
|
||||||
|
|
||||||
var cachedProfile = MojangSkinProvider.PROFILE_CACHE.get(username);
|
var cachedProfile = MojangSkinProvider.PROFILE_CACHE.get(username);
|
||||||
@@ -135,8 +111,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.SERVICES_SERVER_URI
|
.uri(MojangSkinProvider.API_URI
|
||||||
.resolve("/minecraft/profile/lookup/name/")
|
.resolve("/users/profiles/minecraft/")
|
||||||
.resolve(name)
|
.resolve(name)
|
||||||
)
|
)
|
||||||
.GET()
|
.GET()
|
||||||
|
|||||||
@@ -1,27 +1,18 @@
|
|||||||
package net.lionarius.skinrestorer.skin.provider;
|
package net.lionarius.skinrestorer.skin.provider;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableSet;
|
|
||||||
import com.mojang.authlib.properties.Property;
|
import com.mojang.authlib.properties.Property;
|
||||||
import net.lionarius.skinrestorer.skin.SkinVariant;
|
import net.lionarius.skinrestorer.skin.SkinVariant;
|
||||||
import net.lionarius.skinrestorer.util.Result;
|
import net.lionarius.skinrestorer.util.Result;
|
||||||
|
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
public interface SkinProvider {
|
public interface SkinProvider {
|
||||||
EmptySkinProvider EMPTY = new EmptySkinProvider();
|
EmptySkinProvider EMPTY = new EmptySkinProvider();
|
||||||
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();
|
||||||
SkinShuffleSkinProvider SKIN_SHUFFLE = new SkinShuffleSkinProvider();
|
|
||||||
|
|
||||||
Set<String> BUILTIN_PROVIDER_NAMES = ImmutableSet.of(
|
String[] BUILTIN_PROVIDER_NAMES = new String[]{EmptySkinProvider.PROVIDER_NAME, MojangSkinProvider.PROVIDER_NAME, ElyBySkinProvider.PROVIDER_NAME, MineskinSkinProvider.PROVIDER_NAME};
|
||||||
EmptySkinProvider.PROVIDER_NAME,
|
|
||||||
MojangSkinProvider.PROVIDER_NAME,
|
|
||||||
ElyBySkinProvider.PROVIDER_NAME,
|
|
||||||
MineskinSkinProvider.PROVIDER_NAME,
|
|
||||||
SkinShuffleSkinProvider.PROVIDER_NAME
|
|
||||||
);
|
|
||||||
|
|
||||||
String getArgumentName();
|
String getArgumentName();
|
||||||
|
|
||||||
|
|||||||
@@ -1,27 +0,0 @@
|
|||||||
package net.lionarius.skinrestorer.skin.provider;
|
|
||||||
|
|
||||||
import com.mojang.authlib.properties.Property;
|
|
||||||
import net.lionarius.skinrestorer.skin.SkinVariant;
|
|
||||||
import net.lionarius.skinrestorer.util.Result;
|
|
||||||
|
|
||||||
import java.util.Optional;
|
|
||||||
|
|
||||||
public final class SkinShuffleSkinProvider implements SkinProvider {
|
|
||||||
|
|
||||||
public static final String PROVIDER_NAME = "skinshuffle";
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getArgumentName() {
|
|
||||||
return "unsupported";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean hasVariantSupport() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Result<Optional<Property>, Exception> fetchSkin(String argument, SkinVariant variant) {
|
|
||||||
return Result.error(new UnsupportedOperationException("SkinShuffle Provider does not support fetching skins"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -42,7 +42,7 @@ public final class FileUtils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
SkinRestorer.LOGGER.error("Could not migrate skin directory", e);
|
SkinRestorer.LOGGER.error("could not migrate skin directory", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -55,7 +55,7 @@ public final class FileUtils {
|
|||||||
return StringUtils.readString(reader);
|
return StringUtils.readString(reader);
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
SkinRestorer.LOGGER.error("Failed to read resource", e);
|
SkinRestorer.LOGGER.error("failed to read resource", e);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -67,7 +67,7 @@ public final class FileUtils {
|
|||||||
|
|
||||||
return Files.readString(file);
|
return Files.readString(file);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
SkinRestorer.LOGGER.error("Failed to read file", e);
|
SkinRestorer.LOGGER.error("failed to read file", e);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -83,7 +83,7 @@ public final class FileUtils {
|
|||||||
|
|
||||||
Files.writeString(file, content);
|
Files.writeString(file, content);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
SkinRestorer.LOGGER.error("Failed to write file", e);
|
SkinRestorer.LOGGER.error("failed to write file", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -92,7 +92,7 @@ public final class FileUtils {
|
|||||||
if (Files.exists(file))
|
if (Files.exists(file))
|
||||||
Files.delete(file);
|
Files.delete(file);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
SkinRestorer.LOGGER.error("Failed to delete file", e);
|
SkinRestorer.LOGGER.error("failed to delete file", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ import com.mojang.authlib.properties.Property;
|
|||||||
import com.mojang.authlib.properties.PropertyMap;
|
import com.mojang.authlib.properties.PropertyMap;
|
||||||
import com.mojang.util.UUIDTypeAdapter;
|
import com.mojang.util.UUIDTypeAdapter;
|
||||||
import net.lionarius.skinrestorer.SkinRestorer;
|
import net.lionarius.skinrestorer.SkinRestorer;
|
||||||
import net.lionarius.skinrestorer.util.gson.PostProcessingEnabler;
|
|
||||||
|
|
||||||
import java.lang.reflect.Type;
|
import java.lang.reflect.Type;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
@@ -18,8 +17,7 @@ import java.util.UUID;
|
|||||||
|
|
||||||
public final class JsonUtils {
|
public final class JsonUtils {
|
||||||
|
|
||||||
public static final Gson GSON = new GsonBuilder()
|
private static final Gson GSON = new GsonBuilder()
|
||||||
.registerTypeAdapterFactory(new PostProcessingEnabler())
|
|
||||||
.registerTypeAdapter(UUID.class, new UUIDTypeAdapter())
|
.registerTypeAdapter(UUID.class, new UUIDTypeAdapter())
|
||||||
.registerTypeAdapter(PropertyMap.class, new PropertyMap.Serializer())
|
.registerTypeAdapter(PropertyMap.class, new PropertyMap.Serializer())
|
||||||
.registerTypeAdapter(GameProfile.class, new GameProfile.Serializer())
|
.registerTypeAdapter(GameProfile.class, new GameProfile.Serializer())
|
||||||
@@ -56,7 +54,7 @@ public final class JsonUtils {
|
|||||||
|
|
||||||
return json;
|
return json;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
SkinRestorer.LOGGER.error("Could not parse skin property", e);
|
SkinRestorer.LOGGER.error(e.toString());
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -50,14 +50,14 @@ public final class PlayerUtils {
|
|||||||
)
|
)
|
||||||
));
|
));
|
||||||
|
|
||||||
var trackedEntity = ((ChunkMapAccessor) chunkMap).getEntityMap().get(player.getId());
|
var trackedEntity = (TrackedEntityAccessorInvoker) ((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 = ((ChunkMapAccessor) chunkMap).getEntityMap().get(observer.getId());
|
var trackedObserverEntity = (TrackedEntityAccessorInvoker) ((ChunkMapAccessor) chunkMap).getEntityMap().get(observer.getId());
|
||||||
if (trackedObserverEntity != null) {
|
if (trackedObserverEntity != null) {
|
||||||
trackedObserverEntity.invokeRemovePlayer(player);
|
trackedObserverEntity.invokeRemovePlayer(player);
|
||||||
trackedObserverEntity.invokeUpdatePlayer(player);
|
trackedObserverEntity.invokeUpdatePlayer(player);
|
||||||
@@ -86,23 +86,16 @@ public final class PlayerUtils {
|
|||||||
playerList.sendPlayerPermissionLevel(player);
|
playerList.sendPlayerPermissionLevel(player);
|
||||||
playerList.sendLevelInfo(player, serverLevel);
|
playerList.sendLevelInfo(player, serverLevel);
|
||||||
playerList.sendAllPlayerInfo(player);
|
playerList.sendAllPlayerInfo(player);
|
||||||
playerList.sendActivePlayerEffects(player);
|
PlayerUtils.sendActivePlayerEffects(player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void sendActivePlayerEffects(ServerPlayer player) {
|
private static void sendActivePlayerEffects(ServerPlayer player) {
|
||||||
for (var effect : player.getActiveEffects()) {
|
for (var effect : player.getActiveEffects()) {
|
||||||
player.connection.send(new ClientboundUpdateMobEffectPacket(player.getId(), effect, false));
|
player.connection.send(new ClientboundUpdateMobEffectPacket(player.getId(), effect));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,18 +19,6 @@ 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;
|
||||||
}
|
}
|
||||||
@@ -81,4 +69,16 @@ 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));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,60 +0,0 @@
|
|||||||
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,6 +13,8 @@ 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;
|
||||||
@@ -21,8 +23,6 @@ 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();
|
||||||
}
|
}
|
||||||
@@ -36,7 +36,7 @@ public final class WebUtils {
|
|||||||
try {
|
try {
|
||||||
builder.connectTimeout(Duration.of(SkinRestorer.getConfig().requestTimeout(), ChronoUnit.SECONDS));
|
builder.connectTimeout(Duration.of(SkinRestorer.getConfig().requestTimeout(), ChronoUnit.SECONDS));
|
||||||
} catch (IllegalArgumentException e) {
|
} catch (IllegalArgumentException e) {
|
||||||
SkinRestorer.LOGGER.error("Failed to set request timeout", e);
|
SkinRestorer.LOGGER.error("failed to set request timeout", e);
|
||||||
builder.connectTimeout(Duration.of(10, ChronoUnit.SECONDS));
|
builder.connectTimeout(Duration.of(10, ChronoUnit.SECONDS));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +0,0 @@
|
|||||||
package net.lionarius.skinrestorer.util.gson;
|
|
||||||
|
|
||||||
public interface GsonPostProcessable {
|
|
||||||
void gsonPostProcess();
|
|
||||||
}
|
|
||||||
@@ -1,34 +0,0 @@
|
|||||||
package net.lionarius.skinrestorer.util.gson;
|
|
||||||
|
|
||||||
import com.google.gson.Gson;
|
|
||||||
import com.google.gson.TypeAdapter;
|
|
||||||
import com.google.gson.TypeAdapterFactory;
|
|
||||||
import com.google.gson.reflect.TypeToken;
|
|
||||||
import com.google.gson.stream.JsonReader;
|
|
||||||
import com.google.gson.stream.JsonWriter;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
public class PostProcessingEnabler implements TypeAdapterFactory {
|
|
||||||
@Override
|
|
||||||
public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> type) {
|
|
||||||
var adapter = gson.getDelegateAdapter(this, type);
|
|
||||||
|
|
||||||
return new TypeAdapter<>() {
|
|
||||||
@Override
|
|
||||||
public void write(JsonWriter out, T value) throws IOException {
|
|
||||||
adapter.write(out, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public T read(JsonReader in) throws IOException {
|
|
||||||
var value = adapter.read(in);
|
|
||||||
|
|
||||||
if (value instanceof GsonPostProcessable postProcessable)
|
|
||||||
postProcessable.gsonPostProcess();
|
|
||||||
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
public net.minecraft.server.players.GameProfileCache$GameProfileInfo
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
accessWidener v2 named
|
|
||||||
|
|
||||||
accessible class net/minecraft/server/players/GameProfileCache$GameProfileInfo
|
|
||||||
@@ -2,16 +2,13 @@
|
|||||||
"required": true,
|
"required": true,
|
||||||
"minVersion": "0.8",
|
"minVersion": "0.8",
|
||||||
"package": "net.lionarius.skinrestorer.mixin",
|
"package": "net.lionarius.skinrestorer.mixin",
|
||||||
"compatibilityLevel": "JAVA_17",
|
"compatibilityLevel": "JAVA_8",
|
||||||
"priority": 1100,
|
|
||||||
"refmap": "${mod_id}.refmap.json",
|
"refmap": "${mod_id}.refmap.json",
|
||||||
"mixins": [
|
"mixins": [
|
||||||
"ChunkMapAccessor",
|
|
||||||
"PlayerListMixin",
|
"PlayerListMixin",
|
||||||
"ServerLoginPacketListenerImplMixin",
|
"ServerLoginPacketListenerImplMixin",
|
||||||
"TrackedEntityAccessorInvoker",
|
"ChunkMapAccessor",
|
||||||
"SkullBlockEntityMixin",
|
"TrackedEntityAccessorInvoker"
|
||||||
"GameProfileCacheAccessor"
|
|
||||||
],
|
],
|
||||||
"injectors": {
|
"injectors": {
|
||||||
"defaultRequire": 1
|
"defaultRequire": 1
|
||||||
|
|||||||
@@ -1,11 +1,10 @@
|
|||||||
plugins {
|
plugins {
|
||||||
id 'multiloader-loader'
|
id 'multiloader-loader'
|
||||||
|
|
||||||
id 'fabric-loom'
|
id 'fabric-loom'
|
||||||
|
|
||||||
id 'multiloader-publish'
|
id 'multiloader-publish'
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
minecraft "com.mojang:minecraft:${minecraft_version}"
|
minecraft "com.mojang:minecraft:${minecraft_version}"
|
||||||
mappings loom.layered {
|
mappings loom.layered {
|
||||||
@@ -13,10 +12,6 @@ dependencies {
|
|||||||
parchment("org.parchmentmc.data:parchment-${parchment_minecraft}:${parchment_version}@zip")
|
parchment("org.parchmentmc.data:parchment-${parchment_minecraft}:${parchment_version}@zip")
|
||||||
}
|
}
|
||||||
modImplementation "net.fabricmc:fabric-loader:${fabric_loader_version}"
|
modImplementation "net.fabricmc:fabric-loader:${fabric_loader_version}"
|
||||||
|
|
||||||
modCompileOnly "net.fabricmc.fabric-api:fabric-api:${fabric_api_version}"
|
|
||||||
|
|
||||||
include implementation("org.mineskin:java-client:${mineskin_client_version}")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
loom {
|
loom {
|
||||||
@@ -24,11 +19,11 @@ loom {
|
|||||||
if (aw.exists()) {
|
if (aw.exists()) {
|
||||||
accessWidenerPath.set(aw)
|
accessWidenerPath.set(aw)
|
||||||
}
|
}
|
||||||
|
|
||||||
mixin {
|
mixin {
|
||||||
defaultRefmapName.set("${mod_id}.refmap.json")
|
defaultRefmapName.set("${mod_id}.refmap.json")
|
||||||
}
|
}
|
||||||
|
|
||||||
runs {
|
runs {
|
||||||
client {
|
client {
|
||||||
client()
|
client()
|
||||||
|
|||||||
@@ -1,6 +0,0 @@
|
|||||||
# Fabric, see https://fabricmc.net/develop/ for new versions
|
|
||||||
fabric_loader_version=0.15.0
|
|
||||||
fabric_api_version=0.119.5+1.21.5
|
|
||||||
|
|
||||||
optional_dependencies=fabric-api
|
|
||||||
additional_modloaders=quilt
|
|
||||||
@@ -2,18 +2,10 @@ package net.lionarius.skinrestorer.fabric;
|
|||||||
|
|
||||||
import net.fabricmc.api.ModInitializer;
|
import net.fabricmc.api.ModInitializer;
|
||||||
import net.lionarius.skinrestorer.SkinRestorer;
|
import net.lionarius.skinrestorer.SkinRestorer;
|
||||||
import net.lionarius.skinrestorer.compat.skinshuffle.SkinShuffleCompatibility;
|
|
||||||
import net.lionarius.skinrestorer.platform.Services;
|
|
||||||
|
|
||||||
public final class SkinRestorerFabric implements ModInitializer {
|
public final class SkinRestorerFabric implements ModInitializer {
|
||||||
|
|
||||||
public static final boolean FABRIC_API_LOADED = Services.PLATFORM.isModLoaded("fabric-api");
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onInitialize() {
|
public void onInitialize() {
|
||||||
SkinRestorer.onInitialize();
|
SkinRestorer.onInitialize();
|
||||||
|
|
||||||
if (SkinShuffleCompatibility.shouldApply())
|
|
||||||
net.lionarius.skinrestorer.fabric.compat.skinshuffle.SkinShuffleCompatibility.initialize();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,37 +0,0 @@
|
|||||||
package net.lionarius.skinrestorer.fabric.compat.skinshuffle;
|
|
||||||
|
|
||||||
import net.fabricmc.fabric.api.networking.v1.PayloadTypeRegistry;
|
|
||||||
import net.fabricmc.fabric.api.networking.v1.ServerPlayConnectionEvents;
|
|
||||||
import net.fabricmc.fabric.api.networking.v1.ServerPlayNetworking;
|
|
||||||
import net.lionarius.skinrestorer.SkinRestorer;
|
|
||||||
import net.lionarius.skinrestorer.compat.skinshuffle.SkinShuffleHandshakePayload;
|
|
||||||
import net.lionarius.skinrestorer.compat.skinshuffle.SkinShuffleSkinRefreshPayload;
|
|
||||||
import net.lionarius.skinrestorer.compat.skinshuffle.SkinShuffleSkinRefreshV1Payload;
|
|
||||||
import net.lionarius.skinrestorer.compat.skinshuffle.SkinShuffleSkinRefreshV2Payload;
|
|
||||||
import net.lionarius.skinrestorer.fabric.SkinRestorerFabric;
|
|
||||||
|
|
||||||
public final class SkinShuffleCompatibility {
|
|
||||||
|
|
||||||
private SkinShuffleCompatibility() {}
|
|
||||||
|
|
||||||
public static void initialize() {
|
|
||||||
if (!SkinRestorerFabric.FABRIC_API_LOADED) {
|
|
||||||
SkinRestorer.LOGGER.warn("fabric-api is not loaded, SkinShuffle compatibility will not be available");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
PayloadTypeRegistry.playS2C().register(SkinShuffleHandshakePayload.PACKET_ID, SkinShuffleHandshakePayload.PACKET_CODEC);
|
|
||||||
PayloadTypeRegistry.playC2S().register(SkinShuffleSkinRefreshV1Payload.PACKET_ID, SkinShuffleSkinRefreshV1Payload.PACKET_CODEC);
|
|
||||||
PayloadTypeRegistry.playC2S().register(SkinShuffleSkinRefreshV2Payload.PACKET_ID, SkinShuffleSkinRefreshV2Payload.PACKET_CODEC);
|
|
||||||
|
|
||||||
ServerPlayConnectionEvents.JOIN.register((handler, sender, server) -> net.lionarius.skinrestorer.compat.skinshuffle.SkinShuffleCompatibility.onPlayerJoin(handler.getPlayer()));
|
|
||||||
|
|
||||||
ServerPlayNetworking.registerGlobalReceiver(SkinShuffleSkinRefreshV1Payload.PACKET_ID, SkinShuffleCompatibility::handleSkinRefreshPacket);
|
|
||||||
|
|
||||||
ServerPlayNetworking.registerGlobalReceiver(SkinShuffleSkinRefreshV2Payload.PACKET_ID, SkinShuffleCompatibility::handleSkinRefreshPacket);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void handleSkinRefreshPacket(SkinShuffleSkinRefreshPayload payload, ServerPlayNetworking.Context context) {
|
|
||||||
net.lionarius.skinrestorer.compat.skinshuffle.SkinShuffleCompatibility.handleSkinRefresh(context.player().getServer(), context.player(), payload);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
package net.lionarius.skinrestorer.fabric.mixin;
|
package net.lionarius.skinrestorer.fabric.mixin;
|
||||||
|
|
||||||
import com.mojang.brigadier.CommandDispatcher;
|
import com.mojang.brigadier.CommandDispatcher;
|
||||||
import net.lionarius.skinrestorer.SkinRestorer;
|
import net.lionarius.skinrestorer.command.SkinCommand;
|
||||||
import net.minecraft.commands.CommandBuildContext;
|
import net.minecraft.commands.CommandBuildContext;
|
||||||
import net.minecraft.commands.CommandSourceStack;
|
import net.minecraft.commands.CommandSourceStack;
|
||||||
import net.minecraft.commands.Commands;
|
import net.minecraft.commands.Commands;
|
||||||
@@ -21,6 +21,6 @@ public abstract class CommandsMixin {
|
|||||||
@Inject(method = "<init>", at = @At(value = "INVOKE",
|
@Inject(method = "<init>", at = @At(value = "INVOKE",
|
||||||
target = "Lnet/minecraft/server/commands/AdvancementCommands;register(Lcom/mojang/brigadier/CommandDispatcher;)V"))
|
target = "Lnet/minecraft/server/commands/AdvancementCommands;register(Lcom/mojang/brigadier/CommandDispatcher;)V"))
|
||||||
private void init(Commands.CommandSelection environment, CommandBuildContext commandRegistryAccess, CallbackInfo ci) {
|
private void init(Commands.CommandSelection environment, CommandBuildContext commandRegistryAccess, CallbackInfo ci) {
|
||||||
SkinRestorer.Events.onCommandRegister(dispatcher);
|
SkinCommand.register(dispatcher);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,12 +13,6 @@ 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;getNanos()J", ordinal = 0))
|
||||||
private void onServerStarted(CallbackInfo ci) {
|
private void onServerStarted(CallbackInfo ci) {
|
||||||
SkinRestorer.Events.onServerStarted((MinecraftServer) (Object) this);
|
SkinRestorer.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);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,13 +0,0 @@
|
|||||||
package net.lionarius.skinrestorer.fabric.platform;
|
|
||||||
|
|
||||||
import net.fabricmc.fabric.api.networking.v1.ServerPlayNetworking;
|
|
||||||
import net.lionarius.skinrestorer.compat.skinshuffle.SkinShuffleHandshakePayload;
|
|
||||||
import net.lionarius.skinrestorer.platform.services.CompatibilityHelper;
|
|
||||||
import net.minecraft.server.level.ServerPlayer;
|
|
||||||
|
|
||||||
public final class FabricCompatibilityHelper implements CompatibilityHelper {
|
|
||||||
@Override
|
|
||||||
public void skinShuffle_sendHandshake(ServerPlayer player) {
|
|
||||||
ServerPlayNetworking.send(player, SkinShuffleHandshakePayload.INSTANCE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
net.lionarius.skinrestorer.fabric.platform.FabricCompatibilityHelper
|
|
||||||
@@ -24,13 +24,9 @@
|
|||||||
"${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}",
|
||||||
"java": ">=${java_version}"
|
"java": ">=${java_version}"
|
||||||
},
|
|
||||||
"suggests": {
|
|
||||||
"fabric-api": "*"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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_17",
|
"compatibilityLevel": "JAVA_8",
|
||||||
"refmap": "${mod_id}.refmap.json",
|
"refmap": "${mod_id}.refmap.json",
|
||||||
"mixins": [
|
"mixins": [
|
||||||
"CommandsMixin",
|
"CommandsMixin",
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ plugins {
|
|||||||
id 'multiloader-loader'
|
id 'multiloader-loader'
|
||||||
id 'idea'
|
id 'idea'
|
||||||
id 'eclipse'
|
id 'eclipse'
|
||||||
|
|
||||||
id 'net.minecraftforge.gradle'
|
id 'net.minecraftforge.gradle'
|
||||||
id 'org.parchmentmc.librarian.forgegradle'
|
id 'org.parchmentmc.librarian.forgegradle'
|
||||||
id 'org.spongepowered.mixin'
|
id 'org.spongepowered.mixin'
|
||||||
@@ -15,32 +15,22 @@ mixin {
|
|||||||
config "${mod_id}.mixins.json"
|
config "${mod_id}.mixins.json"
|
||||||
}
|
}
|
||||||
|
|
||||||
jarJar.enable()
|
|
||||||
|
|
||||||
tasks.named('jarJar') {
|
|
||||||
archiveClassifier = ''
|
|
||||||
}
|
|
||||||
|
|
||||||
jar.finalizedBy('jarJar')
|
|
||||||
|
|
||||||
minecraft {
|
minecraft {
|
||||||
mappings channel: 'parchment', version: "${parchment_minecraft}-${parchment_version}-${minecraft_version}"
|
mappings channel: 'parchment', version: "${parchment_version}-${parchment_minecraft}"
|
||||||
|
|
||||||
copyIdeResources = true //Calls processResources when in dev
|
copyIdeResources = true //Calls processResources when in dev
|
||||||
|
|
||||||
reobf = false // Forge 1.20.6+ uses official mappings at runtime, so we shouldn't reobf from official to SRG
|
|
||||||
|
|
||||||
// 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 rootProject.file('run/client')
|
workingDirectory file('../run/client')
|
||||||
ideaModule "${rootProject.name}.${project.name}.main"
|
ideaModule "${rootProject.name}.${project.name}.main"
|
||||||
taskName 'Client'
|
taskName 'Client'
|
||||||
mods {
|
mods {
|
||||||
@@ -51,7 +41,7 @@ minecraft {
|
|||||||
}
|
}
|
||||||
|
|
||||||
server {
|
server {
|
||||||
workingDirectory rootProject.file('run/server')
|
workingDirectory file('../run/server')
|
||||||
ideaModule "${rootProject.name}.${project.name}.main"
|
ideaModule "${rootProject.name}.${project.name}.main"
|
||||||
taskName 'Server'
|
taskName 'Server'
|
||||||
mods {
|
mods {
|
||||||
@@ -68,10 +58,6 @@ dependencies {
|
|||||||
|
|
||||||
annotationProcessor('org.spongepowered:mixin:0.8.5-SNAPSHOT:processor')
|
annotationProcessor('org.spongepowered:mixin:0.8.5-SNAPSHOT:processor')
|
||||||
implementation('net.sf.jopt-simple:jopt-simple:5.0.4') { version { strictly '5.0.4' } }
|
implementation('net.sf.jopt-simple:jopt-simple:5.0.4') { version { strictly '5.0.4' } }
|
||||||
|
|
||||||
minecraftLibrary(jarJar(group: 'org.mineskin', name: 'java-client', version: mineskin_client_version)) {
|
|
||||||
jarJar.ranged(it, "[${mineskin_client_version},)")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// for some reason mixin plugin does not add 'MixinConfigs' to MANIFEST.MF so we do it manually
|
// for some reason mixin plugin does not add 'MixinConfigs' to MANIFEST.MF so we do it manually
|
||||||
@@ -88,7 +74,3 @@ sourceSets.each {
|
|||||||
it.output.resourcesDir = dir
|
it.output.resourcesDir = dir
|
||||||
it.java.destinationDirectory = dir
|
it.java.destinationDirectory = dir
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks.named('processResources') {
|
|
||||||
duplicatesStrategy = DuplicatesStrategy.INCLUDE
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,5 +0,0 @@
|
|||||||
# Forge, see https://files.minecraftforge.net/net/minecraftforge/forge/ for new versions
|
|
||||||
forge_version=55.0.0
|
|
||||||
forge_loader_version_range=[55,)
|
|
||||||
# Forge sometimes skips minor minecraft versions (like 1.20.5)
|
|
||||||
forge_minecraft_version=1.21.5
|
|
||||||
@@ -1,10 +1,10 @@
|
|||||||
package net.lionarius.skinrestorer.forge;
|
package net.lionarius.skinrestorer.forge;
|
||||||
|
|
||||||
import net.lionarius.skinrestorer.SkinRestorer;
|
import net.lionarius.skinrestorer.SkinRestorer;
|
||||||
import net.lionarius.skinrestorer.compat.skinshuffle.SkinShuffleCompatibility;
|
import net.lionarius.skinrestorer.command.SkinCommand;
|
||||||
|
import net.minecraftforge.common.MinecraftForge;
|
||||||
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;
|
||||||
|
|
||||||
@@ -13,24 +13,18 @@ import net.minecraftforge.fml.common.Mod;
|
|||||||
public final class SkinRestorerForge {
|
public final class SkinRestorerForge {
|
||||||
|
|
||||||
public SkinRestorerForge() {
|
public SkinRestorerForge() {
|
||||||
SkinRestorer.onInitialize();
|
MinecraftForge.EVENT_BUS.register(SkinRestorerForge.class);
|
||||||
|
|
||||||
if (SkinShuffleCompatibility.shouldApply())
|
SkinRestorer.onInitialize();
|
||||||
net.lionarius.skinrestorer.forge.compat.skinshuffle.SkinShuffleCompatibility.initialize();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public static void onCommandRegister(RegisterCommandsEvent event) {
|
public static void onCommandRegister(RegisterCommandsEvent event) {
|
||||||
SkinRestorer.Events.onCommandRegister(event.getDispatcher());
|
SkinCommand.register(event.getDispatcher());
|
||||||
}
|
}
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public static void onServerStarted(ServerStartedEvent event) {
|
public static void onServerStarted(ServerStartedEvent event) {
|
||||||
SkinRestorer.Events.onServerStarted(event.getServer());
|
SkinRestorer.onServerStarted(event.getServer());
|
||||||
}
|
|
||||||
|
|
||||||
@SubscribeEvent
|
|
||||||
public static void onServerStopped(ServerStoppedEvent event) {
|
|
||||||
SkinRestorer.Events.onServerStopped(event.getServer());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,14 +0,0 @@
|
|||||||
package net.lionarius.skinrestorer.forge.compat.skinshuffle;
|
|
||||||
|
|
||||||
import net.minecraftforge.common.MinecraftForge;
|
|
||||||
|
|
||||||
public final class SkinShuffleCompatibility {
|
|
||||||
|
|
||||||
private SkinShuffleCompatibility() {}
|
|
||||||
|
|
||||||
public static void initialize() {
|
|
||||||
MinecraftForge.EVENT_BUS.register(SkinShuffleGameEventHandler.class);
|
|
||||||
|
|
||||||
SkinShufflePacketHandler.initialize();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,16 +0,0 @@
|
|||||||
package net.lionarius.skinrestorer.forge.compat.skinshuffle;
|
|
||||||
|
|
||||||
import net.lionarius.skinrestorer.compat.skinshuffle.SkinShuffleCompatibility;
|
|
||||||
import net.minecraft.server.level.ServerPlayer;
|
|
||||||
import net.minecraftforge.event.entity.player.PlayerEvent;
|
|
||||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
|
||||||
|
|
||||||
public final class SkinShuffleGameEventHandler {
|
|
||||||
|
|
||||||
private SkinShuffleGameEventHandler() {}
|
|
||||||
|
|
||||||
@SubscribeEvent
|
|
||||||
public static void onPlayerLoggedIn(PlayerEvent.PlayerLoggedInEvent event) {
|
|
||||||
SkinShuffleCompatibility.onPlayerJoin((ServerPlayer) event.getEntity());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,45 +0,0 @@
|
|||||||
package net.lionarius.skinrestorer.forge.compat.skinshuffle;
|
|
||||||
|
|
||||||
import net.lionarius.skinrestorer.SkinRestorer;
|
|
||||||
import net.lionarius.skinrestorer.compat.skinshuffle.*;
|
|
||||||
import net.lionarius.skinrestorer.compat.skinshuffle.SkinShuffleCompatibility;
|
|
||||||
import net.minecraft.network.Connection;
|
|
||||||
import net.minecraft.network.protocol.common.custom.CustomPacketPayload;
|
|
||||||
import net.minecraftforge.event.network.CustomPayloadEvent;
|
|
||||||
import net.minecraftforge.network.Channel;
|
|
||||||
import net.minecraftforge.network.ChannelBuilder;
|
|
||||||
|
|
||||||
public class SkinShufflePacketHandler {
|
|
||||||
private static final Channel<CustomPacketPayload> INSTANCE = ChannelBuilder
|
|
||||||
.named(SkinRestorer.resourceLocation("skin_shuffle_compat"))
|
|
||||||
.optional()
|
|
||||||
.payloadChannel()
|
|
||||||
.any()
|
|
||||||
.clientbound()
|
|
||||||
.add(SkinShuffleHandshakePayload.PACKET_ID, SkinShuffleHandshakePayload.PACKET_CODEC, (payload, context) -> {
|
|
||||||
})
|
|
||||||
.serverbound()
|
|
||||||
.add(SkinShuffleSkinRefreshV1Payload.PACKET_ID, SkinShuffleSkinRefreshV1Payload.PACKET_CODEC, SkinShufflePacketHandler::handleSkinRefreshPacket)
|
|
||||||
.add(SkinShuffleSkinRefreshV2Payload.PACKET_ID, SkinShuffleSkinRefreshV2Payload.PACKET_CODEC, SkinShufflePacketHandler::handleSkinRefreshPacket)
|
|
||||||
.build();
|
|
||||||
|
|
||||||
private SkinShufflePacketHandler() {
|
|
||||||
}
|
|
||||||
|
|
||||||
protected static void initialize() {
|
|
||||||
// NO-OP
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void sendHandshake(Connection connection) {
|
|
||||||
INSTANCE.send(SkinShuffleHandshakePayload.INSTANCE, connection);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void handleSkinRefreshPacket(SkinShuffleSkinRefreshPayload payload, CustomPayloadEvent.Context context) {
|
|
||||||
var sender = context.getSender();
|
|
||||||
|
|
||||||
if (!context.isServerSide() || sender == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
SkinShuffleCompatibility.handleSkinRefresh(sender.getServer(), sender, payload);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
package net.lionarius.skinrestorer.forge.platform;
|
|
||||||
|
|
||||||
import net.lionarius.skinrestorer.forge.compat.skinshuffle.SkinShufflePacketHandler;
|
|
||||||
import net.lionarius.skinrestorer.platform.services.CompatibilityHelper;
|
|
||||||
import net.minecraft.server.level.ServerPlayer;
|
|
||||||
|
|
||||||
public final class ForgeCompatibilityHelper implements CompatibilityHelper {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void skinShuffle_sendHandshake(ServerPlayer player) {
|
|
||||||
SkinShufflePacketHandler.sendHandshake(player.connection.getConnection());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
net.lionarius.skinrestorer.forge.platform.ForgeCompatibilityHelper
|
|
||||||
@@ -1,14 +1,14 @@
|
|||||||
# Project
|
# Project
|
||||||
group=net.lionarius
|
group=net.lionarius.skinrestorer
|
||||||
java_version=21
|
java_version=17
|
||||||
|
|
||||||
# Common
|
# Common
|
||||||
minecraft_version=1.21.5
|
minecraft_version=1.20.3
|
||||||
minecraft_version_list=1.21.5
|
minecraft_version_list=1.20.3,1.20.4
|
||||||
minecraft_version_range=[1.21.5, 1.21.6)
|
minecraft_version_range=[1.20.3,1.20.4]
|
||||||
mod_id=skinrestorer
|
mod_id=skinrestorer
|
||||||
mod_name=SkinRestorer
|
mod_name=SkinRestorer
|
||||||
mod_version=2.4.3
|
mod_version=2.1.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,12 +17,22 @@ license=MIT
|
|||||||
credits=
|
credits=
|
||||||
description=A server-side mod for managing skins.
|
description=A server-side mod for managing skins.
|
||||||
|
|
||||||
# Dependencies
|
|
||||||
mineskin_client_version=3.0.6-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.21.5
|
parchment_minecraft=1.20.3
|
||||||
parchment_version=2025.06.15
|
parchment_version=2023.12.31
|
||||||
|
|
||||||
|
# Fabric, see https://fabricmc.net/develop/ for new versions
|
||||||
|
fabric_loader_version=0.15.0
|
||||||
|
|
||||||
|
# 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
|
||||||
@@ -31,5 +41,3 @@ 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.14-bin.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip
|
||||||
networkTimeout=10000
|
networkTimeout=10000
|
||||||
validateDistributionUrl=true
|
validateDistributionUrl=true
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
|
|||||||
10
gradlew
vendored
10
gradlew
vendored
@@ -15,8 +15,6 @@
|
|||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
#
|
#
|
||||||
# SPDX-License-Identifier: Apache-2.0
|
|
||||||
#
|
|
||||||
|
|
||||||
##############################################################################
|
##############################################################################
|
||||||
#
|
#
|
||||||
@@ -86,7 +84,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\n' "$PWD" ) || exit
|
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || 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
|
||||||
@@ -114,7 +112,7 @@ case "$( uname )" in #(
|
|||||||
NONSTOP* ) nonstop=true ;;
|
NONSTOP* ) nonstop=true ;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
CLASSPATH="\\\"\\\""
|
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||||
|
|
||||||
|
|
||||||
# Determine the Java command to use to start the JVM.
|
# Determine the Java command to use to start the JVM.
|
||||||
@@ -205,7 +203,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, and optsEnvironmentVar are not allowed to contain shell fragments,
|
# * DEFAULT_JVM_OPTS, JAVA_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.
|
||||||
@@ -213,7 +211,7 @@ DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
|||||||
set -- \
|
set -- \
|
||||||
"-Dorg.gradle.appname=$APP_BASE_NAME" \
|
"-Dorg.gradle.appname=$APP_BASE_NAME" \
|
||||||
-classpath "$CLASSPATH" \
|
-classpath "$CLASSPATH" \
|
||||||
-jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \
|
org.gradle.wrapper.GradleWrapperMain \
|
||||||
"$@"
|
"$@"
|
||||||
|
|
||||||
# Stop when "xargs" is not available.
|
# Stop when "xargs" is not available.
|
||||||
|
|||||||
6
gradlew.bat
vendored
6
gradlew.bat
vendored
@@ -13,8 +13,6 @@
|
|||||||
@rem See the License for the specific language governing permissions and
|
@rem See the License for the specific language governing permissions and
|
||||||
@rem limitations under the License.
|
@rem limitations under the License.
|
||||||
@rem
|
@rem
|
||||||
@rem SPDX-License-Identifier: Apache-2.0
|
|
||||||
@rem
|
|
||||||
|
|
||||||
@if "%DEBUG%"=="" @echo off
|
@if "%DEBUG%"=="" @echo off
|
||||||
@rem ##########################################################################
|
@rem ##########################################################################
|
||||||
@@ -70,11 +68,11 @@ goto fail
|
|||||||
:execute
|
:execute
|
||||||
@rem Setup the command line
|
@rem Setup the command line
|
||||||
|
|
||||||
set CLASSPATH=
|
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||||
|
|
||||||
|
|
||||||
@rem Execute Gradle
|
@rem Execute Gradle
|
||||||
"%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" %*
|
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
|
||||||
|
|
||||||
: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,58 +3,40 @@ plugins {
|
|||||||
id 'idea'
|
id 'idea'
|
||||||
id 'eclipse'
|
id 'eclipse'
|
||||||
|
|
||||||
id 'net.neoforged.moddev'
|
id 'net.neoforged.gradle.userdev'
|
||||||
|
|
||||||
id 'multiloader-publish'
|
id 'multiloader-publish'
|
||||||
}
|
}
|
||||||
|
|
||||||
neoForge {
|
// Automatically enable neoforge AccessTransformers if the file exists
|
||||||
version = neoforge_version
|
def at = project(':common').file('src/main/resources/META-INF/accesstransformer.cfg')
|
||||||
|
if (at.exists()) {
|
||||||
// Automatically enable neoforge AccessTransformers if the file exists
|
minecraft.accessTransformers.file(at)
|
||||||
def at = project(":common").file('src/main/resources/META-INF/accesstransformer.cfg')
|
}
|
||||||
if (at.exists()) {
|
|
||||||
accessTransformers.from(at.absolutePath)
|
|
||||||
}
|
|
||||||
|
|
||||||
|
subsystems {
|
||||||
parchment {
|
parchment {
|
||||||
minecraftVersion = parchment_minecraft
|
minecraftVersion = parchment_minecraft
|
||||||
mappingsVersion = parchment_version
|
mappingsVersion = parchment_version
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
runs {
|
runs {
|
||||||
configureEach {
|
configureEach {
|
||||||
ideName = "NeoForge ${it.name.capitalize()} (${project.path})" // Unify the run config names with fabric
|
modSource project.sourceSets.main
|
||||||
}
|
systemProperty 'neoforge.enabledGameTestNamespaces', project.mod_id
|
||||||
|
|
||||||
client {
|
|
||||||
client()
|
|
||||||
gameDirectory = rootProject.file('run/client')
|
|
||||||
}
|
|
||||||
|
|
||||||
server {
|
|
||||||
server()
|
|
||||||
programArgument '--nogui'
|
|
||||||
gameDirectory = rootProject.file('run/server')
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
mods {
|
client {
|
||||||
"${mod_id}" {
|
workingDirectory = file('../run/client')
|
||||||
sourceSet sourceSets.main
|
}
|
||||||
}
|
|
||||||
|
server {
|
||||||
|
programArgument '--nogui'
|
||||||
|
workingDirectory = file('../run/server')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation "net.neoforged:neoforge:${neoforge_version}"
|
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}"
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +0,0 @@
|
|||||||
# NeoForge, see https://projects.neoforged.net/neoforged/neoforge for new versions
|
|
||||||
neoforge_version=21.5.0-beta
|
|
||||||
neoforge_loader_version_range=[4,)
|
|
||||||
@@ -1,37 +1,30 @@
|
|||||||
package net.lionarius.skinrestorer.neoforge;
|
package net.lionarius.skinrestorer.neoforge;
|
||||||
|
|
||||||
import net.lionarius.skinrestorer.SkinRestorer;
|
import net.lionarius.skinrestorer.SkinRestorer;
|
||||||
import net.lionarius.skinrestorer.compat.skinshuffle.SkinShuffleCompatibility;
|
import net.lionarius.skinrestorer.command.SkinCommand;
|
||||||
import net.neoforged.bus.api.SubscribeEvent;
|
import net.neoforged.bus.api.SubscribeEvent;
|
||||||
import net.neoforged.fml.common.EventBusSubscriber;
|
|
||||||
import net.neoforged.fml.common.Mod;
|
import net.neoforged.fml.common.Mod;
|
||||||
|
import net.neoforged.neoforge.common.NeoForge;
|
||||||
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)
|
||||||
@EventBusSubscriber(modid = SkinRestorer.MOD_ID)
|
@Mod.EventBusSubscriber(modid = SkinRestorer.MOD_ID)
|
||||||
public final class SkinRestorerNeoForge {
|
public final class SkinRestorerNeoForge {
|
||||||
|
|
||||||
public SkinRestorerNeoForge() {
|
public SkinRestorerNeoForge() {
|
||||||
SkinRestorer.onInitialize();
|
NeoForge.EVENT_BUS.register(SkinRestorerNeoForge.class);
|
||||||
|
|
||||||
if (SkinShuffleCompatibility.shouldApply())
|
SkinRestorer.onInitialize();
|
||||||
net.lionarius.skinrestorer.neoforge.compat.skinshuffle.SkinShuffleCompatibility.initialize();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public static void onCommandRegister(RegisterCommandsEvent event) {
|
public static void onCommandRegister(RegisterCommandsEvent event) {
|
||||||
SkinRestorer.Events.onCommandRegister(event.getDispatcher());
|
SkinCommand.register(event.getDispatcher());
|
||||||
}
|
}
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public static void onServerStarted(ServerStartedEvent event) {
|
public static void onServerStarted(ServerStartedEvent event) {
|
||||||
SkinRestorer.Events.onServerStarted(event.getServer());
|
SkinRestorer.onServerStarted(event.getServer());
|
||||||
}
|
|
||||||
|
|
||||||
@SubscribeEvent
|
|
||||||
public static void onServerStopped(ServerStoppedEvent event) {
|
|
||||||
SkinRestorer.Events.onServerStopped(event.getServer());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,17 +0,0 @@
|
|||||||
package net.lionarius.skinrestorer.neoforge.compat.skinshuffle;
|
|
||||||
|
|
||||||
import net.lionarius.skinrestorer.SkinRestorer;
|
|
||||||
import net.neoforged.fml.ModList;
|
|
||||||
import net.neoforged.neoforge.common.NeoForge;
|
|
||||||
|
|
||||||
public final class SkinShuffleCompatibility {
|
|
||||||
|
|
||||||
private SkinShuffleCompatibility() {}
|
|
||||||
|
|
||||||
public static void initialize() {
|
|
||||||
NeoForge.EVENT_BUS.register(SkinShuffleGameEventHandler.class);
|
|
||||||
|
|
||||||
final var mod = ModList.get().getModContainerById(SkinRestorer.MOD_ID).get();
|
|
||||||
mod.getEventBus().register(SkinShuffleModEventHandler.class);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,16 +0,0 @@
|
|||||||
package net.lionarius.skinrestorer.neoforge.compat.skinshuffle;
|
|
||||||
|
|
||||||
import net.lionarius.skinrestorer.compat.skinshuffle.SkinShuffleCompatibility;
|
|
||||||
import net.minecraft.server.level.ServerPlayer;
|
|
||||||
import net.neoforged.bus.api.SubscribeEvent;
|
|
||||||
import net.neoforged.neoforge.event.entity.player.PlayerEvent;
|
|
||||||
|
|
||||||
public final class SkinShuffleGameEventHandler {
|
|
||||||
|
|
||||||
private SkinShuffleGameEventHandler() {}
|
|
||||||
|
|
||||||
@SubscribeEvent
|
|
||||||
public static void onPlayerLoggedIn(PlayerEvent.PlayerLoggedInEvent event) {
|
|
||||||
SkinShuffleCompatibility.onPlayerJoin((ServerPlayer) event.getEntity());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,31 +0,0 @@
|
|||||||
package net.lionarius.skinrestorer.neoforge.compat.skinshuffle;
|
|
||||||
|
|
||||||
import net.lionarius.skinrestorer.compat.skinshuffle.*;
|
|
||||||
import net.lionarius.skinrestorer.compat.skinshuffle.SkinShuffleCompatibility;
|
|
||||||
import net.minecraft.server.level.ServerPlayer;
|
|
||||||
import net.neoforged.bus.api.SubscribeEvent;
|
|
||||||
import net.neoforged.neoforge.network.event.RegisterPayloadHandlersEvent;
|
|
||||||
import net.neoforged.neoforge.network.handling.IPayloadContext;
|
|
||||||
import net.neoforged.neoforge.network.registration.HandlerThread;
|
|
||||||
|
|
||||||
public final class SkinShuffleModEventHandler {
|
|
||||||
private SkinShuffleModEventHandler() {}
|
|
||||||
|
|
||||||
@SubscribeEvent
|
|
||||||
public static void onRegisterPayloadHandlers(RegisterPayloadHandlersEvent event) {
|
|
||||||
final var registrar = event.registrar("1").optional().executesOn(HandlerThread.NETWORK);
|
|
||||||
|
|
||||||
registrar
|
|
||||||
.playToClient(SkinShuffleHandshakePayload.PACKET_ID, SkinShuffleHandshakePayload.PACKET_CODEC,
|
|
||||||
(payload, context) -> {})
|
|
||||||
.playToServer(SkinShuffleSkinRefreshV1Payload.PACKET_ID, SkinShuffleSkinRefreshV1Payload.PACKET_CODEC,
|
|
||||||
SkinShuffleModEventHandler::handleSkinRefreshPacket)
|
|
||||||
.playToServer(SkinShuffleSkinRefreshV2Payload.PACKET_ID, SkinShuffleSkinRefreshV2Payload.PACKET_CODEC,
|
|
||||||
SkinShuffleModEventHandler::handleSkinRefreshPacket);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void handleSkinRefreshPacket(SkinShuffleSkinRefreshPayload payload, IPayloadContext context) {
|
|
||||||
var player = (ServerPlayer) context.player();
|
|
||||||
SkinShuffleCompatibility.handleSkinRefresh(player.getServer(), player, payload);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
package net.lionarius.skinrestorer.neoforge.platform;
|
|
||||||
|
|
||||||
import net.lionarius.skinrestorer.compat.skinshuffle.SkinShuffleHandshakePayload;
|
|
||||||
import net.lionarius.skinrestorer.platform.services.CompatibilityHelper;
|
|
||||||
import net.minecraft.network.protocol.common.ClientboundCustomPayloadPacket;
|
|
||||||
import net.minecraft.server.level.ServerPlayer;
|
|
||||||
|
|
||||||
public final class NeoForgeCompatibilityHelper implements CompatibilityHelper {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void skinShuffle_sendHandshake(ServerPlayer player) {
|
|
||||||
// we can't use the packet distributor here because neoforge doesn't support sending packets to non-neoforge players
|
|
||||||
player.connection.getConnection().send(new ClientboundCustomPayloadPacket(SkinShuffleHandshakePayload.INSTANCE));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -17,14 +17,14 @@ config = "${mod_id}.mixins.json"
|
|||||||
|
|
||||||
[[dependencies.${mod_id}]]
|
[[dependencies.${mod_id}]]
|
||||||
modId = "neoforge"
|
modId = "neoforge"
|
||||||
type = "required"
|
mandatory = true
|
||||||
versionRange = "[${neoforge_version},)"
|
versionRange = "[${neoforge_version},)"
|
||||||
ordering = "NONE"
|
ordering = "NONE"
|
||||||
side = "BOTH"
|
side = "BOTH"
|
||||||
|
|
||||||
[[dependencies.${mod_id}]]
|
[[dependencies.${mod_id}]]
|
||||||
modId = "minecraft"
|
modId = "minecraft"
|
||||||
type = "required"
|
mandatory = true
|
||||||
versionRange = "${minecraft_version_range}"
|
versionRange = "${minecraft_version_range}"
|
||||||
ordering = "NONE"
|
ordering = "NONE"
|
||||||
side = "BOTH"
|
side = "BOTH"
|
||||||
@@ -1 +0,0 @@
|
|||||||
net.lionarius.skinrestorer.neoforge.platform.NeoForgeCompatibilityHelper
|
|
||||||
Reference in New Issue
Block a user