mirror of
https://github.com/Suiranoil/SkinRestorer.git
synced 2026-01-16 04:42:12 +00:00
Compare commits
106 Commits
v2.0.1+1.2
...
v2.1.0+1.2
| Author | SHA1 | Date | |
|---|---|---|---|
|
f1ee3b4542
|
|||
|
14f51e9224
|
|||
|
026ceb2337
|
|||
|
c650aa1386
|
|||
|
4be7335d7c
|
|||
|
bec3c9d179
|
|||
|
d9b5d6c12b
|
|||
|
86a1d4de14
|
|||
|
adcb696e35
|
|||
|
b3ca228d02
|
|||
|
f43fa13044
|
|||
|
bcb8cd930d
|
|||
|
8b26d81ae4
|
|||
|
1d1aa94644
|
|||
|
3203435453
|
|||
|
8a9802f763
|
|||
|
7add58da44
|
|||
|
9bd8a53657
|
|||
|
4a40a52d24
|
|||
|
48976117cb
|
|||
|
7aa3316d0f
|
|||
|
7eedb79453
|
|||
|
93e9907e03
|
|||
|
de4e8a3178
|
|||
|
04faa2953f
|
|||
|
75b3abb847
|
|||
|
e7d8dfa6b6
|
|||
|
017478374d
|
|||
|
3360bc567b
|
|||
|
75889944e9
|
|||
|
8baad37227
|
|||
|
4280659c70
|
|||
|
2e7c42b619
|
|||
|
9873747dfb
|
|||
|
b209893511
|
|||
|
3a8a513180
|
|||
|
9e0c41482f
|
|||
|
449e286fba
|
|||
|
299a8b621f
|
|||
|
c536dd36e2
|
|||
|
5b45fcb25c
|
|||
|
b2ae60ac73
|
|||
|
b850086ad8
|
|||
|
6611077b93
|
|||
|
417ed7d695
|
|||
|
40cddfc2a7
|
|||
|
0d6ed15014
|
|||
|
182f0c4497
|
|||
|
3492f82214
|
|||
|
2f5edc7069
|
|||
|
29a8b406c1
|
|||
|
304c3b371d
|
|||
|
d286270bdc
|
|||
|
2bd9e55b53
|
|||
|
19677fe63b
|
|||
|
9c9907d0ba
|
|||
|
5ddde27915
|
|||
|
08b734bb27
|
|||
|
49290171e2
|
|||
|
abcc213ee0
|
|||
|
9e85e78398
|
|||
|
d4efe0a177
|
|||
|
7fcf515790
|
|||
|
4339753271
|
|||
|
251fdce7ff
|
|||
|
5a02ab83e8
|
|||
|
bfd8843b44
|
|||
|
cfdfee11b3
|
|||
|
5c31b5f881
|
|||
|
b72d0c1e85
|
|||
|
067cd5c731
|
|||
|
1eed415053
|
|||
|
42cef73318
|
|||
|
266d56ed93
|
|||
|
423ee4e694
|
|||
|
7cf5b8e1d6
|
|||
|
e9bdfaefca
|
|||
|
e1773d4d79
|
|||
|
84da16fae6
|
|||
|
ac9189ecdc
|
|||
|
7131cb76d0
|
|||
|
4943c7d8f6
|
|||
|
82baf0b63e
|
|||
|
c755417ebf
|
|||
|
6cf7d0c465
|
|||
|
20feec931f
|
|||
|
73ffc37f2d
|
|||
|
726f4ed7a8
|
|||
|
fbbc37e4b1
|
|||
|
19114de347
|
|||
|
455d0deddc
|
|||
|
0eaaf6a950
|
|||
|
7c8aba6f71
|
|||
|
99675bb5ee
|
|||
|
6ad656c388
|
|||
|
fece751f0f
|
|||
|
ab75eddc90
|
|||
|
f9aa3f664a
|
|||
|
9edbb21128
|
|||
|
4851687fc9
|
|||
|
7bceb0d5ed
|
|||
|
65957b61c5
|
|||
|
|
8c3d1fe831 | ||
|
|
1dc1789fa4 | ||
|
|
85a0fa760b | ||
|
|
0a00b40655 |
54
.github/workflows/build.yml
vendored
54
.github/workflows/build.yml
vendored
@@ -1,31 +1,39 @@
|
||||
name: build
|
||||
on: [ pull_request, push ]
|
||||
on:
|
||||
push:
|
||||
paths-ignore:
|
||||
- '.github/**'
|
||||
- '*.md'
|
||||
pull_request:
|
||||
paths-ignore:
|
||||
- '.github/**'
|
||||
- '*.md'
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/setup-java@v4
|
||||
with:
|
||||
distribution: temurin
|
||||
java-version: 21
|
||||
|
||||
- uses: actions/setup-java@v4
|
||||
with:
|
||||
distribution: temurin
|
||||
java-version: 21
|
||||
- name: Setup Gradle
|
||||
uses: gradle/actions/setup-gradle@v3
|
||||
with:
|
||||
cache-read-only: false
|
||||
|
||||
- name: Setup Gradle
|
||||
uses: gradle/actions/setup-gradle@v3
|
||||
with:
|
||||
cache-read-only: false
|
||||
- name: Change wrapper permissions
|
||||
run: chmod +x ./gradlew
|
||||
|
||||
- name: Change wrapper permissions
|
||||
run: chmod +x ./gradlew
|
||||
- name: Run build with Gradle Wrapper
|
||||
run: ./gradlew build
|
||||
|
||||
- name: Run build with Gradle Wrapper
|
||||
run: ./gradlew build
|
||||
|
||||
- name: Upload built JAR
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: skin-restorer-artifacts
|
||||
path: build/libs/merged
|
||||
- name: Upload built JARs
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: skin-restorer-artifacts
|
||||
path: ./*/build/libs/*.jar
|
||||
|
||||
39
.github/workflows/release.yml
vendored
Normal file
39
.github/workflows/release.yml
vendored
Normal file
@@ -0,0 +1,39 @@
|
||||
name: release
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- "v**"
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
release:
|
||||
environment: release
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- uses: actions/setup-java@v4
|
||||
with:
|
||||
distribution: temurin
|
||||
java-version: 21
|
||||
|
||||
- name: Setup Gradle
|
||||
uses: gradle/actions/setup-gradle@v3
|
||||
with:
|
||||
cache-read-only: false
|
||||
|
||||
- name: Change wrapper permissions
|
||||
run: chmod +x ./gradlew
|
||||
|
||||
- name: Publish to CurseForge, Modrinth
|
||||
run: ./gradlew build publishMods
|
||||
env:
|
||||
CURSEFORGE_API_KEY: ${{ secrets.CURSEFORGE_API_KEY }}
|
||||
MODRINTH_TOKEN: ${{ secrets.MODRINTH_TOKEN }}
|
||||
|
||||
- name: Upload built JARs
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: skin-restorer-artifacts
|
||||
path: ./*/build/libs/*.jar
|
||||
87
CHANGELOG.md
Normal file
87
CHANGELOG.md
Normal file
@@ -0,0 +1,87 @@
|
||||
# Changelog
|
||||
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/),
|
||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||
|
||||
## [2.1.0] - 2024-09-26
|
||||
### 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 old skin directory migration not working
|
||||
- Prevented overwriting existing skin files during migration
|
||||
|
||||
## [2.0.3] - 2024-08-20
|
||||
### Added
|
||||
- Added `firstJoinSkinProvider` config option (see [wiki](https://github.com/Suiranoil/SkinRestorer/wiki/Config#firstjoinskinprovider))
|
||||
### Fixed
|
||||
- Fixed ability to set config values to `null`
|
||||
|
||||
## [2.0.2] - 2024-08-04
|
||||
### Added
|
||||
- Backported to minecraft 1.20-1.20.2
|
||||
- [Forge] Added support for Forge
|
||||
### Changed
|
||||
- Changed minimum java version to 17 for minecraft 1.20-1.20.4
|
||||
|
||||
## [2.0.1] - 2024-07-16
|
||||
### Added
|
||||
- Added Traditional Chinese translation ([#24](https://github.com/Suiranoil/SkinRestorer/pull/24)) - *yichifauzi*, *notlin4*
|
||||
### Fixed
|
||||
- Fixed concurrent modification exception
|
||||
|
||||
## [2.0.0] - 2024-07-03
|
||||
### Added
|
||||
- Added support for NeoForge
|
||||
- Added support for singleplayer
|
||||
- Added ely.by skin provider
|
||||
- Added `/skin refresh` command to get up-to-date skin
|
||||
- Added `/skin reset` command to remove skin data
|
||||
- Added proper support for secure servers
|
||||
- Added support for permissions api
|
||||
- Added translations
|
||||
### Changed
|
||||
- Changed to save skin data per world
|
||||
### Fixed
|
||||
- Fixed entity flickering on skin reload
|
||||
- Fixed player being left in invalid state on skin reload if on death screen
|
||||
|
||||
## [1.2.6] - 2024-06-25
|
||||
### Added
|
||||
- Added support for command blocks
|
||||
### Changed
|
||||
- Changed to better skin refresh logic
|
||||
### Fixed
|
||||
- Fixed no permission level for /skin clear targets
|
||||
- Fixed loading world screen on skin change
|
||||
|
||||
## [1.2.4] - 2023-09-30
|
||||
### Fixed
|
||||
- Fixed player stops riding entity with skin change
|
||||
- Fixed armor and hand items not displaying with skin change
|
||||
|
||||
## [1.2.3] - 2023-06-10
|
||||
### Changed
|
||||
- Updated to 1.20-1.20.1
|
||||
|
||||
## [1.2.2] - 2022-12-21
|
||||
### Changed
|
||||
- Updated to 1.19.3
|
||||
|
||||
## [1.2.1] - 2022-11-24
|
||||
### Fixed
|
||||
- Fixed incorrect filepath resolvement on linux systems
|
||||
|
||||
## [1.2.0] - 2022-11-18
|
||||
### Added
|
||||
- Added support for fake players ([#4](https://github.com/Suiranoil/SkinRestorer/pull/4)) - *CaveNightingale*
|
||||
### Changed
|
||||
- Allow player to apply their skin changes immediately ([#4](https://github.com/Suiranoil/SkinRestorer/pull/4)) - _CaveNightingale_
|
||||
|
||||
## [1.0.4] - 2021-08-28
|
||||
### Fixed
|
||||
- Fixed "invalid player data" exception
|
||||
9
CHANGELOG_LATEST.md
Normal file
9
CHANGELOG_LATEST.md
Normal file
@@ -0,0 +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 old skin directory migration not working
|
||||
- Prevented overwriting existing skin files during migration
|
||||
66
README.md
66
README.md
@@ -1,58 +1,34 @@
|
||||
# SkinRestorer
|
||||
|
||||

|
||||

|
||||
[](https://www.curseforge.com/minecraft/mc-mods/skinrestorer)
|
||||
[](https://modrinth.com/mod/skinrestorer)
|
||||
<a href="https://modrinth.com/mod/skinrestorer"><img src="https://raw.githubusercontent.com/Suiranoil/badges/main/assets/minecraft/platform/modrinth/mini/badge.svg" alt="Modrinth" height="32"></a>
|
||||
<a href="https://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>
|
||||
|
||||
SkinRestorer is a **server-side** only mod for Fabric that allows players to use and change skins on servers running in
|
||||
offline/insecure mode.
|
||||
A server-side mod for managing and restoring player skins.
|
||||
|
||||
## Features
|
||||
## ✨ Features
|
||||
|
||||
- **Set Skins from Mojang Account**: Fetch and apply skins using a valid Minecraft account name.
|
||||
- **Set Skins from URL**: Apply skins from any image URL, supporting both classic (Steve) and slim (Alex) skin models.
|
||||
- **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 URL**: Fetch and apply skins from any image URL, supporting both classic (Steve) and slim (Alex) skin 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)).
|
||||
- **Singleplayer support**: Apply skins individually for each world.
|
||||
- **Permissions API support**
|
||||
|
||||
## Command Usage Guide
|
||||
## 📜 Command Usage Guide
|
||||
|
||||
### Set Mojang Skin
|
||||
For a detailed list of available commands and their usage, please visit the [commands wiki page](https://github.com/Suiranoil/SkinRestorer/wiki/Commands).
|
||||
|
||||
```
|
||||
/skin set mojang <username> [<targets>]
|
||||
```
|
||||
## ❌ Known Incompatibilities
|
||||
|
||||
- **Parameters:**
|
||||
- `<username>`: Minecraft account name to fetch the skin from.
|
||||
- `[<targets>]`: (Optional, server operators only) Player(s) to apply the skin to.
|
||||
- **[Arclight](https://github.com/IzzelAliz/Arclight) (<=1.20.1)**: Trials or older versions are not compatible due to mixin conflicts.
|
||||
As an alternative, consider using the [SkinsRestorer](https://www.spigotmc.org/resources/skinsrestorer.2124/) plugin.
|
||||
|
||||
### Set Web Skin
|
||||
## 🪙 Donation
|
||||
|
||||
```
|
||||
/skin set web (classic|slim) "<url>" [<targets>]
|
||||
```
|
||||
If you enjoy using **SkinRestorer** and would like to support its development, you can contribute through cryptocurrency donations.
|
||||
|
||||
- **Parameters:**
|
||||
- `(classic|slim)`: Type of the skin model (`classic` for Steve model, `slim` for Alex model).
|
||||
- `"<url>"`: URL pointing to the skin image file (ensure it follows Minecraft's skin size and format requirements).
|
||||
- `[<targets>]`: (Optional, server operators only) Player(s) to apply the skin to.
|
||||
Bitcoin (BTC): `1Ndbwny8pxdnWXFgadp95fp97y5JqMJKTX`\
|
||||
USDT (TRC20): `TGXn8wrqku5KLzwPWQAeH7wgnV4UzwHEae`\
|
||||
USDT (TON): `UQAQF18Xlmx-V1oZ90C2YOju5qI7q1LgrCP5QaIUhqIELmDS`
|
||||
|
||||
### Clear Skin
|
||||
|
||||
```
|
||||
/skin clear [<targets>]
|
||||
```
|
||||
|
||||
- **Parameters:**
|
||||
- `[<targets>]`: (Optional, server operators only) Player(s) to clear the skin for.
|
||||
|
||||
### Notes:
|
||||
|
||||
- If `targets` is not specified, the command will apply to the player executing the command.
|
||||
|
||||
### Examples:
|
||||
|
||||
```
|
||||
/skin set mojang Notch
|
||||
/skin set web classic "https://example.com/skin.png"
|
||||
/skin clear @a
|
||||
```
|
||||
Thank you for your generosity!
|
||||
|
||||
158
build.gradle
158
build.gradle
@@ -1,149 +1,13 @@
|
||||
plugins {
|
||||
id "dev.architectury.loom" version "1.6-SNAPSHOT" apply false
|
||||
id "architectury-plugin" version "3.4-SNAPSHOT"
|
||||
id "com.github.johnrengelman.shadow" version "8.1.1" apply false
|
||||
id "io.github.pacifistmc.forgix" version "1.2.9"
|
||||
id "me.shedaniel.unified-publishing" version "0.1.+"
|
||||
}
|
||||
|
||||
version = "${project.mod_version}+${project.minecraft_version}"
|
||||
ext.version_name = "${project.capitalized_name} ${project.mod_version}"
|
||||
ext.headTag = "git describe --tags --abbrev=0 HEAD".execute([], rootProject.projectDir).text.trim()
|
||||
ext.previousTag = "git describe --tags --abbrev=0 HEAD^".execute([], rootProject.projectDir).text.trim()
|
||||
|
||||
architectury {
|
||||
minecraft = project.minecraft_version
|
||||
}
|
||||
|
||||
forgix {
|
||||
group = "$project.maven_group.$project.mod_id"
|
||||
// forgix does not append .jar extension for some reason
|
||||
mergedJarName = "${project.archives_name}-${project.version}.jar"
|
||||
outputDir = "build/libs/merged"
|
||||
}
|
||||
|
||||
allprojects {
|
||||
apply plugin: "java"
|
||||
|
||||
version = rootProject.version
|
||||
group = project.maven_group
|
||||
}
|
||||
|
||||
subprojects {
|
||||
apply plugin: "dev.architectury.loom"
|
||||
apply plugin: "architectury-plugin"
|
||||
|
||||
loom {
|
||||
silentMojangMappingsLicense()
|
||||
}
|
||||
|
||||
base {
|
||||
archivesName = "$rootProject.archives_name-$project.name"
|
||||
}
|
||||
|
||||
build.finalizedBy(mergeJars)
|
||||
assemble.finalizedBy(mergeJars)
|
||||
|
||||
repositories {
|
||||
maven {
|
||||
name = "ParchmentMC"
|
||||
url = "https://maven.parchmentmc.org"
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
minecraft "net.minecraft:minecraft:$rootProject.minecraft_version"
|
||||
mappings loom.layered {
|
||||
officialMojangMappings()
|
||||
parchment("org.parchmentmc.data:parchment-$rootProject.parchment_minecraft_version:$rootProject.parchment_mappings@zip")
|
||||
}
|
||||
}
|
||||
|
||||
java {
|
||||
withSourcesJar()
|
||||
|
||||
sourceCompatibility = JavaVersion.VERSION_21
|
||||
targetCompatibility = JavaVersion.VERSION_21
|
||||
}
|
||||
|
||||
jar {
|
||||
from "$rootProject.projectDir/LICENSE"
|
||||
}
|
||||
|
||||
tasks.withType(JavaCompile).configureEach {
|
||||
it.options.encoding = "UTF-8"
|
||||
|
||||
it.options.release.set(21)
|
||||
}
|
||||
}
|
||||
|
||||
// Adapted from https://raw.githubusercontent.com/TerraformersMC/GradleScripts/2.7/ferry.gradle
|
||||
tasks.register("generateChangelog") {
|
||||
ext.changelog = ""
|
||||
|
||||
def lastTag = previousTag
|
||||
def currentTag = headTag
|
||||
|
||||
def changes = new StringBuilder()
|
||||
def commits = "git log --max-count=${project.changelog_max_commit_search} --pretty=format:\"%b\" $lastTag..$currentTag".execute()
|
||||
commits.in.eachLine { line -> // Loops over the lines the git log command returns
|
||||
def processedLine = line.toString()
|
||||
if (processedLine.startsWith("\"")) {
|
||||
processedLine = processedLine.substring(1)
|
||||
}
|
||||
if (processedLine.endsWith("\"")) {
|
||||
processedLine = processedLine.substring(0, processedLine.length() - 1)
|
||||
}
|
||||
if (processedLine.startsWith("- ")) {
|
||||
if (changes.length() == 0) {
|
||||
changes << processedLine
|
||||
} else {
|
||||
changes << "\n$processedLine"
|
||||
}
|
||||
}
|
||||
}
|
||||
commits.err.eachLine { line -> println line }
|
||||
commits.waitFor()
|
||||
|
||||
ext.changelog = changes.toString()
|
||||
if (ext.changelog.isEmpty()) {
|
||||
ext.changelog = "No Changelog Available"
|
||||
}
|
||||
}
|
||||
|
||||
tasks.register("assertNewVersion") {
|
||||
if (headTag == previousTag) {
|
||||
throw new GradleException("Current version $headTag is the same as previous. Please create a new version tag if you want to proceed.")
|
||||
}
|
||||
}
|
||||
|
||||
tasks.publishUnified.dependsOn("assertNewVersion", "build")
|
||||
|
||||
unifiedPublishing {
|
||||
project {
|
||||
displayName = version_name.toString()
|
||||
version = project.version
|
||||
changelog = generateChangelog.changelog
|
||||
releaseType = "release"
|
||||
gameVersions = List.of(project.game_versions.split(","))
|
||||
gameLoaders = List.of(project.mod_loaders.split(","))
|
||||
|
||||
mainPublication.set(file("build/libs/merged/${project.archives_name}-${project.version}.jar"))
|
||||
|
||||
var cfToken = System.getenv("CF_TOKEN")
|
||||
if (cfToken != null) {
|
||||
curseforge {
|
||||
token = cfToken
|
||||
id = project.curseforge_id
|
||||
}
|
||||
}
|
||||
|
||||
var mrToken = System.getenv("MODRINTH_TOKEN")
|
||||
if (mrToken != null) {
|
||||
modrinth {
|
||||
token = mrToken
|
||||
id = project.modrinth_id
|
||||
}
|
||||
}
|
||||
}
|
||||
// see https://fabricmc.net/develop/ for new versions
|
||||
id 'fabric-loom' version '1.7-SNAPSHOT' apply false
|
||||
// see https://projects.neoforged.net/neoforged/neogradle for new versions
|
||||
id 'net.neoforged.gradle.userdev' version '7.0.153' apply false
|
||||
// see https://files.minecraftforge.net/net/minecraftforge/gradle/ForgeGradle/ for new versions
|
||||
id 'net.minecraftforge.gradle' version '6.0.26' apply false
|
||||
id 'org.parchmentmc.librarian.forgegradle' version '1.+' apply false
|
||||
|
||||
id 'org.spongepowered.mixin' version '0.7-SNAPSHOT' apply false
|
||||
|
||||
id 'me.modmuss50.mod-publish-plugin' version '0.6.3' apply false
|
||||
}
|
||||
|
||||
3
buildSrc/build.gradle
Normal file
3
buildSrc/build.gradle
Normal file
@@ -0,0 +1,3 @@
|
||||
plugins {
|
||||
id 'groovy-gradle-plugin'
|
||||
}
|
||||
107
buildSrc/src/main/groovy/multiloader-common.gradle
Normal file
107
buildSrc/src/main/groovy/multiloader-common.gradle
Normal file
@@ -0,0 +1,107 @@
|
||||
plugins {
|
||||
id 'java-library'
|
||||
}
|
||||
|
||||
base {
|
||||
archivesName = "${mod_id}"
|
||||
version = "${mod_version}+${minecraft_version}-${project.name}"
|
||||
}
|
||||
|
||||
java {
|
||||
toolchain.languageVersion = JavaLanguageVersion.of(java_version)
|
||||
withSourcesJar()
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
maven {
|
||||
name = 'ParchmentMC'
|
||||
url = 'https://maven.parchmentmc.org'
|
||||
}
|
||||
maven {
|
||||
name = 'Fabric'
|
||||
url = 'https://maven.fabricmc.net'
|
||||
}
|
||||
maven {
|
||||
name = 'Forge'
|
||||
url = 'https://maven.minecraftforge.net'
|
||||
}
|
||||
maven {
|
||||
name = 'NeoForge'
|
||||
url = 'https://maven.neoforged.net/releases'
|
||||
}
|
||||
exclusiveContent {
|
||||
forRepository {
|
||||
maven {
|
||||
name = 'Sponge'
|
||||
url = 'https://repo.spongepowered.org/repository/maven-public'
|
||||
}
|
||||
}
|
||||
filter {
|
||||
includeGroupAndSubgroups('org.spongepowered')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Declare capabilities on the outgoing configurations.
|
||||
// Read more about capabilities here: https://docs.gradle.org/current/userguide/component_capabilities.html#sec:declaring-additional-capabilities-for-a-local-component
|
||||
['apiElements', 'runtimeElements', 'sourcesElements'].each { variant ->
|
||||
configurations."$variant".outgoing {
|
||||
capability("$group:${base.archivesName.get()}:$version")
|
||||
capability("$group:$mod_id-${project.name}:$version")
|
||||
capability("$group:$mod_id:$version")
|
||||
}
|
||||
}
|
||||
|
||||
sourcesJar {
|
||||
from(rootProject.file('LICENSE')) {
|
||||
rename { "${it}_${mod_name}" }
|
||||
}
|
||||
}
|
||||
|
||||
jar {
|
||||
from(rootProject.file('LICENSE')) {
|
||||
rename { "${it}_${mod_name}" }
|
||||
}
|
||||
|
||||
manifest {
|
||||
attributes([
|
||||
'Specification-Title' : mod_name,
|
||||
'Specification-Vendor' : mod_author,
|
||||
'Specification-Version' : project.jar.archiveVersion,
|
||||
'Implementation-Title' : project.name,
|
||||
'Implementation-Version': project.jar.archiveVersion,
|
||||
'Implementation-Vendor' : mod_author,
|
||||
'Built-On-Minecraft' : minecraft_version
|
||||
])
|
||||
}
|
||||
}
|
||||
|
||||
processResources {
|
||||
def expandProps = [
|
||||
'version' : version,
|
||||
'group' : project.group, //Else we target the task's group.
|
||||
'minecraft_version' : minecraft_version,
|
||||
'minecraft_version_range' : minecraft_version_range,
|
||||
'fabric_loader_version' : fabric_loader_version,
|
||||
'mod_name' : mod_name,
|
||||
'mod_author' : mod_author,
|
||||
'mod_id' : mod_id,
|
||||
'mod_homepage' : mod_homepage,
|
||||
'mod_sources' : mod_sources,
|
||||
'mod_issues' : mod_issues,
|
||||
'license' : license,
|
||||
'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,
|
||||
'java_version' : java_version
|
||||
]
|
||||
|
||||
filesMatching(['pack.mcmeta', 'fabric.mod.json', 'META-INF/mods.toml', 'META-INF/neoforge.mods.toml', '*.mixins.json']) {
|
||||
expand expandProps
|
||||
}
|
||||
inputs.properties(expandProps)
|
||||
}
|
||||
39
buildSrc/src/main/groovy/multiloader-loader.gradle
Normal file
39
buildSrc/src/main/groovy/multiloader-loader.gradle
Normal file
@@ -0,0 +1,39 @@
|
||||
plugins {
|
||||
id 'multiloader-common'
|
||||
}
|
||||
|
||||
configurations {
|
||||
commonJava{
|
||||
canBeResolved = true
|
||||
}
|
||||
commonResources{
|
||||
canBeResolved = true
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compileOnly(project(':common')) {
|
||||
capabilities {
|
||||
requireCapability "$group:$mod_id"
|
||||
}
|
||||
}
|
||||
commonJava project(path: ':common', configuration: 'commonJava')
|
||||
commonResources project(path: ':common', configuration: 'commonResources')
|
||||
}
|
||||
|
||||
tasks.named('compileJava', JavaCompile) {
|
||||
dependsOn(configurations.commonJava)
|
||||
source(configurations.commonJava)
|
||||
}
|
||||
|
||||
processResources {
|
||||
dependsOn(configurations.commonResources)
|
||||
from(configurations.commonResources)
|
||||
}
|
||||
|
||||
tasks.named('sourcesJar', Jar) {
|
||||
dependsOn(configurations.commonJava)
|
||||
from(configurations.commonJava)
|
||||
dependsOn(configurations.commonResources)
|
||||
from(configurations.commonResources)
|
||||
}
|
||||
35
buildSrc/src/main/groovy/multiloader-publish.gradle
Normal file
35
buildSrc/src/main/groovy/multiloader-publish.gradle
Normal file
@@ -0,0 +1,35 @@
|
||||
plugins {
|
||||
id "me.modmuss50.mod-publish-plugin"
|
||||
}
|
||||
|
||||
publishMods {
|
||||
if (project.name == 'fabric')
|
||||
file = remapJar.archiveFile
|
||||
else
|
||||
file = jar.archiveFile
|
||||
|
||||
modLoaders.add(project.name)
|
||||
type = STABLE
|
||||
version = project.version
|
||||
displayName = "[${project.name.capitalize()}] ${mod_name} ${mod_version}"
|
||||
changelog = rootProject.file('CHANGELOG_LATEST.md').text
|
||||
|
||||
curseforge {
|
||||
projectId = curseforge_id
|
||||
|
||||
dryRun = providers.environmentVariable("CURSEFORGE_API_KEY").getOrNull() == null
|
||||
accessToken = providers.environmentVariable("CURSEFORGE_API_KEY")
|
||||
|
||||
minecraftVersions.addAll(minecraft_version_list.split(','))
|
||||
serverRequired = true
|
||||
}
|
||||
|
||||
modrinth {
|
||||
projectId = modrinth_id
|
||||
|
||||
dryRun = providers.environmentVariable("MODRINTH_TOKEN").getOrNull() == null
|
||||
accessToken = providers.environmentVariable("MODRINTH_TOKEN")
|
||||
|
||||
minecraftVersions.addAll(minecraft_version_list.split(','))
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,41 @@
|
||||
architectury {
|
||||
common rootProject.enabled_platforms.split(",")
|
||||
plugins {
|
||||
id 'multiloader-common'
|
||||
|
||||
id 'fabric-loom'
|
||||
}
|
||||
|
||||
dependencies {
|
||||
// We depend on Fabric Loader here to use the Fabric @Environment annotations,
|
||||
// which get remapped to the correct annotations on each platform.
|
||||
// Do NOT use other classes from Fabric Loader.
|
||||
modImplementation "net.fabricmc:fabric-loader:$rootProject.fabric_loader_version"
|
||||
minecraft "com.mojang:minecraft:${minecraft_version}"
|
||||
mappings loom.layered {
|
||||
officialMojangMappings()
|
||||
parchment("org.parchmentmc.data:parchment-${parchment_minecraft}:${parchment_version}@zip")
|
||||
}
|
||||
compileOnly group: 'org.spongepowered', name: 'mixin', version: '0.8.5'
|
||||
}
|
||||
|
||||
loom {
|
||||
def aw = project.file("src/main/resources/${mod_id}.accesswidener")
|
||||
if (aw.exists()) {
|
||||
accessWidenerPath.set(aw)
|
||||
}
|
||||
|
||||
mixin {
|
||||
useLegacyMixinAp = false
|
||||
}
|
||||
}
|
||||
|
||||
configurations {
|
||||
commonJava {
|
||||
canBeResolved = false
|
||||
canBeConsumed = true
|
||||
}
|
||||
commonResources {
|
||||
canBeResolved = false
|
||||
canBeConsumed = true
|
||||
}
|
||||
}
|
||||
|
||||
artifacts {
|
||||
commonJava sourceSets.main.java.sourceDirectories.singleFile
|
||||
commonResources sourceSets.main.resources.sourceDirectories.singleFile
|
||||
}
|
||||
|
||||
1
common/gradle.properties
Normal file
1
common/gradle.properties
Normal file
@@ -0,0 +1 @@
|
||||
fabric.loom.dontRemap = true
|
||||
@@ -1,7 +1,9 @@
|
||||
package net.lionarius.skinrestorer;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import net.lionarius.skinrestorer.config.BuiltInProviderConfig;
|
||||
import net.lionarius.skinrestorer.config.Config;
|
||||
import net.lionarius.skinrestorer.platform.Services;
|
||||
import net.lionarius.skinrestorer.skin.SkinIO;
|
||||
import net.lionarius.skinrestorer.skin.SkinStorage;
|
||||
import net.lionarius.skinrestorer.skin.SkinValue;
|
||||
@@ -10,6 +12,7 @@ import net.lionarius.skinrestorer.translation.Translation;
|
||||
import net.lionarius.skinrestorer.util.FileUtils;
|
||||
import net.lionarius.skinrestorer.util.PlayerUtils;
|
||||
import net.lionarius.skinrestorer.util.Result;
|
||||
import net.lionarius.skinrestorer.util.WebUtils;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.level.storage.LevelResource;
|
||||
@@ -17,11 +20,11 @@ import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.nio.file.Path;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public final class SkinRestorer {
|
||||
public static final String MOD_ID = "skinrestorer";
|
||||
@@ -54,19 +57,28 @@ public final class SkinRestorer {
|
||||
return Optional.ofNullable(SkinRestorer.providersRegistry.get(name));
|
||||
}
|
||||
|
||||
public static void onInitialize(Path rootConfigDir) {
|
||||
SkinRestorer.configDir = rootConfigDir.resolve(SkinRestorer.MOD_ID);
|
||||
public static void onInitialize() {
|
||||
SkinRestorer.configDir = Services.PLATFORM.getConfigDirectory().resolve(SkinRestorer.MOD_ID);
|
||||
SkinRestorer.reloadConfig();
|
||||
|
||||
SkinRestorer.providersRegistry.register(EmptySkinProvider.PROVIDER_NAME, SkinProvider.EMPTY, false);
|
||||
SkinRestorer.providersRegistry.register(MojangSkinProvider.PROVIDER_NAME, SkinProvider.MOJANG);
|
||||
SkinRestorer.providersRegistry.register(ElyBySkinProvider.PROVIDER_NAME, SkinProvider.ELY_BY);
|
||||
SkinRestorer.providersRegistry.register(MineskinSkinProvider.PROVIDER_NAME, SkinProvider.MINESKIN);
|
||||
|
||||
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(MineskinSkinProvider.PROVIDER_NAME, SkinProvider.MINESKIN, SkinRestorer.getConfig().providersConfig().mineskin());
|
||||
}
|
||||
|
||||
private static void registerDefaultSkinProvider(String defaultName, SkinProvider provider, BuiltInProviderConfig config) {
|
||||
var isDefaultName = config.name().equals(defaultName);
|
||||
SkinRestorer.providersRegistry.register(defaultName, provider, config.enabled() && isDefaultName);
|
||||
|
||||
if (!isDefaultName && Arrays.stream(SkinProvider.BUILTIN_PROVIDER_NAMES).noneMatch(name -> name.equals(config.name())))
|
||||
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(worldSkinDirectory);
|
||||
FileUtils.tryMigrateOldSkinDirectory(SkinRestorer.getConfigDir(), worldSkinDirectory);
|
||||
|
||||
SkinRestorer.skinStorage = new SkinStorage(new SkinIO(worldSkinDirectory));
|
||||
}
|
||||
@@ -74,9 +86,14 @@ public final class SkinRestorer {
|
||||
public static void reloadConfig() {
|
||||
SkinRestorer.config = Config.load(SkinRestorer.getConfigDir());
|
||||
Translation.reloadTranslations();
|
||||
WebUtils.recreateHttpClient();
|
||||
|
||||
MojangSkinProvider.createCache();
|
||||
ElyBySkinProvider.createCache();
|
||||
MineskinSkinProvider.createCache();
|
||||
}
|
||||
|
||||
public static String resource(String name) {
|
||||
public static String assetPath(String name) {
|
||||
return String.format("/assets/%s/%s", SkinRestorer.MOD_ID, name);
|
||||
}
|
||||
|
||||
@@ -117,7 +134,7 @@ public final class SkinRestorer {
|
||||
boolean save
|
||||
) {
|
||||
return CompletableFuture.supplyAsync(
|
||||
() -> SkinRestorer.getProvider(context.name()).map(provider -> provider.getSkin(context.argument(), context.variant()))
|
||||
() -> SkinRestorer.getProvider(context.name()).map(provider -> provider.fetchSkin(context.argument(), context.variant()))
|
||||
)
|
||||
.thenApplyAsync(result -> {
|
||||
if (result.isEmpty())
|
||||
|
||||
@@ -13,8 +13,8 @@ import net.lionarius.skinrestorer.skin.SkinVariant;
|
||||
import net.lionarius.skinrestorer.skin.provider.MojangSkinProvider;
|
||||
import net.lionarius.skinrestorer.skin.provider.SkinProvider;
|
||||
import net.lionarius.skinrestorer.skin.provider.SkinProviderContext;
|
||||
import net.lionarius.skinrestorer.util.PlayerUtils;
|
||||
import net.lionarius.skinrestorer.translation.Translation;
|
||||
import net.lionarius.skinrestorer.util.PlayerUtils;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.commands.arguments.GameProfileArgument;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
@@ -49,8 +49,14 @@ public final class SkinCommand {
|
||||
var providers = SkinRestorer.getProvidersRegistry().getPublicProviders();
|
||||
for (var entry : providers)
|
||||
set.then(buildSetSubcommand(entry.first(), entry.second()));
|
||||
if (!providers.isEmpty())
|
||||
base.then(set);
|
||||
|
||||
base.then(set);
|
||||
base.then(
|
||||
literal("config")
|
||||
.requires(commandSourceStack -> commandSourceStack.hasPermission(4))
|
||||
.then(literal("reload").executes(SkinCommand::configReloadSubcommand))
|
||||
);
|
||||
|
||||
dispatcher.register(base);
|
||||
}
|
||||
@@ -160,6 +166,16 @@ public final class SkinCommand {
|
||||
return setSubcommand(src, Collections.singleton(src.getPlayer().getGameProfile()), context, false);
|
||||
}
|
||||
|
||||
private static int configReloadSubcommand(CommandContext<CommandSourceStack> context) {
|
||||
SkinRestorer.reloadConfig();
|
||||
|
||||
context.getSource().sendSuccess(() -> Translation.translatableWithFallback(
|
||||
Translation.COMMAND_SKIN_CONFIG_RELOADED_KEY
|
||||
), true);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
private static void sendResponse(CommandSourceStack src, Collection<ServerPlayer> updatedPlayers, boolean setByOperator) {
|
||||
if (updatedPlayers.isEmpty()) {
|
||||
src.sendSuccess(() -> Translation.translatableWithFallback(
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -5,6 +5,7 @@ import net.lionarius.skinrestorer.util.FileUtils;
|
||||
import net.lionarius.skinrestorer.util.JsonUtils;
|
||||
|
||||
import java.nio.file.Path;
|
||||
import java.util.Optional;
|
||||
|
||||
public final class Config {
|
||||
|
||||
@@ -13,28 +14,47 @@ public final class Config {
|
||||
|
||||
private String language = "en_us";
|
||||
|
||||
private boolean refreshSkinOnJoin = true;
|
||||
|
||||
private boolean fetchSkinOnFirstJoin = true;
|
||||
|
||||
private FirstJoinSkinProvider firstJoinSkinProvider = FirstJoinSkinProvider.MOJANG;
|
||||
|
||||
private String proxy = "";
|
||||
private transient Proxy parsedProxy = null;
|
||||
|
||||
private long requestTimeout = 10;
|
||||
|
||||
public String getLanguage() {
|
||||
private ProvidersConfig providers = ProvidersConfig.DEFAULT;
|
||||
|
||||
public String language() {
|
||||
return this.language;
|
||||
}
|
||||
|
||||
public boolean refreshSkinOnJoin() {
|
||||
return this.refreshSkinOnJoin;
|
||||
}
|
||||
|
||||
public boolean fetchSkinOnFirstJoin() {
|
||||
return this.fetchSkinOnFirstJoin;
|
||||
}
|
||||
|
||||
public String getProxy() {
|
||||
return this.proxy;
|
||||
public FirstJoinSkinProvider firstJoinSkinProvider() {
|
||||
return this.firstJoinSkinProvider;
|
||||
}
|
||||
|
||||
public long getRequestTimeout() {
|
||||
public Optional<Proxy> proxy() {
|
||||
return Optional.ofNullable(this.parsedProxy);
|
||||
}
|
||||
|
||||
public long requestTimeout() {
|
||||
return this.requestTimeout;
|
||||
}
|
||||
|
||||
public ProvidersConfig providersConfig() {
|
||||
return this.providers;
|
||||
}
|
||||
|
||||
public static Config load(Path path) {
|
||||
var configFile = path.resolve(Config.CONFIG_FILENAME);
|
||||
|
||||
@@ -48,8 +68,49 @@ public final class Config {
|
||||
if (config == null)
|
||||
config = new Config();
|
||||
|
||||
config.verifyAndFix();
|
||||
|
||||
FileUtils.writeFile(path.resolve(Config.CONFIG_FILENAME), JsonUtils.toJson(config));
|
||||
|
||||
return config;
|
||||
}
|
||||
|
||||
private void verifyAndFix() {
|
||||
if (this.language == null || this.language.isEmpty()) {
|
||||
SkinRestorer.LOGGER.warn("Language config is null or empty, defaulting to 'en_us'");
|
||||
this.language = "en_us";
|
||||
}
|
||||
|
||||
if (this.firstJoinSkinProvider == null) {
|
||||
SkinRestorer.LOGGER.warn("FirstJoinSkinProvider config is null, defaulting to MOJANG");
|
||||
this.firstJoinSkinProvider = FirstJoinSkinProvider.MOJANG;
|
||||
}
|
||||
|
||||
if (this.proxy == null) {
|
||||
SkinRestorer.LOGGER.warn("Proxy config is null, defaulting to an empty string");
|
||||
this.proxy = "";
|
||||
}
|
||||
|
||||
if (!this.proxy.isEmpty()) {
|
||||
try {
|
||||
this.parsedProxy = Proxy.parse(this.proxy);
|
||||
} catch (Exception e) {
|
||||
SkinRestorer.LOGGER.warn("Could not parse proxy config", e);
|
||||
this.parsedProxy = null;
|
||||
}
|
||||
}
|
||||
|
||||
if (this.requestTimeout <= 0) {
|
||||
SkinRestorer.LOGGER.warn("Request timeout config is less than or equal to 0, defaulting to 10");
|
||||
this.requestTimeout = 10;
|
||||
}
|
||||
|
||||
if (this.providers == null) {
|
||||
SkinRestorer.LOGGER.warn("Providers config is null, using default");
|
||||
this.providers = ProvidersConfig.DEFAULT;
|
||||
}
|
||||
|
||||
if (!this.providers.isValid())
|
||||
this.providers.fix();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
package net.lionarius.skinrestorer.config;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import net.lionarius.skinrestorer.skin.provider.ElyBySkinProvider;
|
||||
import net.lionarius.skinrestorer.skin.provider.MojangSkinProvider;
|
||||
|
||||
public enum FirstJoinSkinProvider {
|
||||
@SerializedName(value = "MOJANG", alternate = {"mojang"})
|
||||
MOJANG(MojangSkinProvider.PROVIDER_NAME),
|
||||
@SerializedName(value = "ELY.BY", alternate = {"ely.by", "ELY_BY", "ely_by"})
|
||||
ELY_BY(ElyBySkinProvider.PROVIDER_NAME);
|
||||
|
||||
private final String name;
|
||||
|
||||
FirstJoinSkinProvider(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package net.lionarius.skinrestorer.config;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public record Proxy(@NotNull String host, int port) {
|
||||
|
||||
public static Proxy parse(@NotNull String proxy) {
|
||||
var colonIndex = proxy.lastIndexOf(':');
|
||||
if (colonIndex == -1)
|
||||
throw new IllegalArgumentException("no port in hostname");
|
||||
|
||||
var port = Integer.parseInt(proxy.substring(colonIndex + 1));
|
||||
|
||||
if (port < 0 || port > 0xFFFF)
|
||||
throw new IllegalArgumentException("port out of range: " + port);
|
||||
|
||||
var host = proxy.substring(0, colonIndex);
|
||||
|
||||
return new Proxy(host, port);
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,6 @@ import net.lionarius.skinrestorer.SkinRestorer;
|
||||
import net.minecraft.network.Connection;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.server.network.CommonListenerCookie;
|
||||
import net.minecraft.server.players.PlayerList;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
@@ -38,7 +37,7 @@ public abstract class PlayerListMixin {
|
||||
}
|
||||
|
||||
@Inject(method = "placeNewPlayer", at = @At("HEAD"))
|
||||
private void placeNewPlayer(Connection connection, ServerPlayer player, CommonListenerCookie cookie, CallbackInfo ci) {
|
||||
private void placeNewPlayer(Connection connection, ServerPlayer player, CallbackInfo ci) {
|
||||
if (SkinRestorer.getSkinStorage().hasSavedSkin(player.getUUID()))
|
||||
SkinRestorer.applySkin(server, Collections.singleton(player.getGameProfile()), SkinRestorer.getSkinStorage().getSkin(player.getUUID()));
|
||||
}
|
||||
|
||||
@@ -3,14 +3,11 @@ package net.lionarius.skinrestorer.mixin;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import net.lionarius.skinrestorer.SkinRestorer;
|
||||
import net.lionarius.skinrestorer.skin.SkinValue;
|
||||
import net.lionarius.skinrestorer.skin.provider.MojangSkinProvider;
|
||||
import net.lionarius.skinrestorer.skin.provider.SkinProviderContext;
|
||||
import net.lionarius.skinrestorer.util.PlayerUtils;
|
||||
import net.lionarius.skinrestorer.util.Result;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.network.ServerLoginPacketListenerImpl;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
@@ -24,52 +21,68 @@ import java.util.concurrent.CompletableFuture;
|
||||
public abstract class ServerLoginPacketListenerImplMixin {
|
||||
|
||||
@Shadow @Nullable
|
||||
private GameProfile authenticatedProfile;
|
||||
@Shadow @Final
|
||||
MinecraftServer server;
|
||||
private GameProfile gameProfile;
|
||||
|
||||
@Unique
|
||||
private CompletableFuture<Void> skinrestorer_pendingSkin;
|
||||
private CompletableFuture<Void> skinrestorer$pendingSkin;
|
||||
|
||||
@Inject(method = "verifyLoginAndFinishConnectionSetup", at = @At(value = "INVOKE",
|
||||
@Inject(method = "handleAcceptedLogin", at = @At(value = "INVOKE",
|
||||
target = "Lnet/minecraft/server/players/PlayerList;canPlayerLogin(Ljava/net/SocketAddress;Lcom/mojang/authlib/GameProfile;)Lnet/minecraft/network/chat/Component;"),
|
||||
cancellable = true)
|
||||
public void waitForSkin(CallbackInfo ci) {
|
||||
if (skinrestorer_pendingSkin == null) {
|
||||
skinrestorer_pendingSkin = CompletableFuture.supplyAsync(() -> {
|
||||
assert authenticatedProfile != null;
|
||||
var originalSkin = PlayerUtils.getPlayerSkin(authenticatedProfile);
|
||||
if (skinrestorer$pendingSkin == null) {
|
||||
skinrestorer$pendingSkin = CompletableFuture.supplyAsync(() -> {
|
||||
final var profile = gameProfile;
|
||||
|
||||
if (SkinRestorer.getSkinStorage().hasSavedSkin(authenticatedProfile.getId())) {
|
||||
assert profile != null;
|
||||
var originalSkin = PlayerUtils.getPlayerSkin(profile);
|
||||
|
||||
if (SkinRestorer.getSkinStorage().hasSavedSkin(profile.getId())) {
|
||||
if (originalSkin != null) { // update to the latest official skin
|
||||
var value = SkinRestorer.getSkinStorage().getSkin(authenticatedProfile.getId());
|
||||
SkinRestorer.getSkinStorage().setSkin(authenticatedProfile.getId(), value.setOriginalValue(originalSkin));
|
||||
var value = SkinRestorer.getSkinStorage().getSkin(profile.getId());
|
||||
SkinRestorer.getSkinStorage().setSkin(profile.getId(), value.setOriginalValue(originalSkin));
|
||||
}
|
||||
|
||||
if (SkinRestorer.getConfig().refreshSkinOnJoin()) {
|
||||
var currentSkin = SkinRestorer.getSkinStorage().getSkin(profile.getId());
|
||||
var context = currentSkin.toProviderContext();
|
||||
|
||||
skinrestorer$fetchSkin(profile, context);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
if (originalSkin == null && SkinRestorer.getConfig().fetchSkinOnFirstJoin()) {
|
||||
SkinRestorer.LOGGER.debug("Fetching {}'s skin", authenticatedProfile.getName());
|
||||
|
||||
var context = new SkinProviderContext(MojangSkinProvider.PROVIDER_NAME, authenticatedProfile.getName(), null);
|
||||
var result = SkinRestorer.getProvider(context.name()).map(
|
||||
provider -> provider.getSkin(context.argument(), context.variant())
|
||||
).orElse(Result.ofNullable(null));
|
||||
|
||||
if (!result.isError()) {
|
||||
var value = SkinValue.fromProviderContextWithValue(context, result.getSuccessValue().orElse(null));
|
||||
SkinRestorer.getSkinStorage().setSkin(authenticatedProfile.getId(), value);
|
||||
} else {
|
||||
SkinRestorer.LOGGER.warn("failed to fetch skin on first join", result.getErrorValue());
|
||||
}
|
||||
var context = new SkinProviderContext(
|
||||
SkinRestorer.getConfig().firstJoinSkinProvider().getName(),
|
||||
profile.getName(),
|
||||
null
|
||||
);
|
||||
skinrestorer$fetchSkin(profile, context);
|
||||
}
|
||||
|
||||
return null;
|
||||
});
|
||||
}
|
||||
|
||||
if (!skinrestorer_pendingSkin.isDone())
|
||||
if (!skinrestorer$pendingSkin.isDone())
|
||||
ci.cancel();
|
||||
}
|
||||
|
||||
@Unique
|
||||
private static void skinrestorer$fetchSkin(GameProfile profile, SkinProviderContext context) {
|
||||
SkinRestorer.LOGGER.debug("fetching {}'s skin", profile.getName());
|
||||
|
||||
var result = SkinRestorer.getProvider(context.name()).map(
|
||||
provider -> provider.fetchSkin(context.argument(), context.variant())
|
||||
).orElseGet(() -> Result.error(new IllegalArgumentException("skin provider is not registered: " + context.name())));
|
||||
|
||||
if (!result.isError()) {
|
||||
var value = SkinValue.fromProviderContextWithValue(context, result.getSuccessValue().orElse(null));
|
||||
SkinRestorer.getSkinStorage().setSkin(profile.getId(), value);
|
||||
} else {
|
||||
SkinRestorer.LOGGER.warn("failed to fetch skin", result.getErrorValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ import org.spongepowered.asm.mixin.gen.Invoker;
|
||||
import java.util.Set;
|
||||
|
||||
@Mixin(targets = "net.minecraft.server.level.ChunkMap$TrackedEntity")
|
||||
public interface TrackedEntityMixin {
|
||||
public interface TrackedEntityAccessorInvoker {
|
||||
|
||||
@Accessor
|
||||
Set<ServerPlayerConnection> getSeenBy();
|
||||
@@ -0,0 +1,21 @@
|
||||
package net.lionarius.skinrestorer.platform;
|
||||
|
||||
import net.lionarius.skinrestorer.SkinRestorer;
|
||||
import net.lionarius.skinrestorer.platform.services.PlatformHelper;
|
||||
|
||||
import java.util.ServiceLoader;
|
||||
|
||||
public final class Services {
|
||||
|
||||
private Services() {}
|
||||
|
||||
public final static PlatformHelper PLATFORM = load(PlatformHelper.class);
|
||||
|
||||
private static <T> T load(Class<T> clazz) {
|
||||
final T loadedService = ServiceLoader.load(clazz)
|
||||
.findFirst()
|
||||
.orElseThrow(() -> new NullPointerException("Failed to load service for " + clazz.getName()));
|
||||
SkinRestorer.LOGGER.debug("Loaded {} for service {}", loadedService, clazz);
|
||||
return loadedService;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package net.lionarius.skinrestorer.platform.services;
|
||||
|
||||
import java.nio.file.Path;
|
||||
|
||||
public interface PlatformHelper {
|
||||
|
||||
String getPlatformName();
|
||||
|
||||
boolean isModLoaded(String modId);
|
||||
|
||||
Path getConfigDirectory();
|
||||
}
|
||||
@@ -1,32 +1,55 @@
|
||||
package net.lionarius.skinrestorer.skin.provider;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.common.cache.CacheBuilder;
|
||||
import com.google.common.cache.CacheLoader;
|
||||
import com.google.common.cache.LoadingCache;
|
||||
import com.google.common.util.concurrent.UncheckedExecutionException;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import com.mojang.authlib.properties.Property;
|
||||
import com.mojang.authlib.yggdrasil.response.MinecraftProfilePropertiesResponse;
|
||||
import net.lionarius.skinrestorer.SkinRestorer;
|
||||
import net.lionarius.skinrestorer.skin.SkinVariant;
|
||||
import net.lionarius.skinrestorer.util.JsonUtils;
|
||||
import net.lionarius.skinrestorer.util.PlayerUtils;
|
||||
import net.lionarius.skinrestorer.util.Result;
|
||||
import net.lionarius.skinrestorer.util.WebUtils;
|
||||
import net.lionarius.skinrestorer.util.*;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.net.http.HttpRequest;
|
||||
import java.util.Locale;
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public final class ElyBySkinProvider implements SkinProvider {
|
||||
|
||||
public static final String PROVIDER_NAME = "ely.by";
|
||||
|
||||
private static final URI API_URI;
|
||||
|
||||
private static LoadingCache<String, Optional<Property>> SKIN_CACHE;
|
||||
|
||||
static {
|
||||
try {
|
||||
API_URI = new URI("http://skinsystem.ely.by/");
|
||||
API_URI = new URI("http://skinsystem.ely.by");
|
||||
} catch (URISyntaxException e) {
|
||||
throw new IllegalArgumentException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public static void createCache() {
|
||||
var config = SkinRestorer.getConfig().providersConfig().ely_by();
|
||||
var time = config.cache().enabled() ? config.cache().duration() : 0;
|
||||
|
||||
SKIN_CACHE = CacheBuilder.newBuilder()
|
||||
.expireAfterWrite(time, TimeUnit.SECONDS)
|
||||
.build(new CacheLoader<>() {
|
||||
@Override
|
||||
public @NotNull Optional<Property> load(@NotNull String key) throws Exception {
|
||||
return ElyBySkinProvider.loadSkin(key);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getArgumentName() {
|
||||
return "username";
|
||||
@@ -38,23 +61,32 @@ public final class ElyBySkinProvider implements SkinProvider {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result<Optional<Property>, Exception> getSkin(String username, SkinVariant variant) {
|
||||
public Result<Optional<Property>, Exception> fetchSkin(String username, SkinVariant variant) {
|
||||
try {
|
||||
var profile = ElyBySkinProvider.getElyByProfile(username);
|
||||
if (!StringUtils.isValidPlayerName(username))
|
||||
throw new IllegalArgumentException("invalid username");
|
||||
|
||||
var properties = profile.getAsJsonArray("properties");
|
||||
var textures = PlayerUtils.findTexturesProperty(properties);
|
||||
var usernameLowerCase = username.toLowerCase(Locale.ROOT);
|
||||
|
||||
return Result.ofNullable(textures);
|
||||
return Result.success(SKIN_CACHE.get(usernameLowerCase));
|
||||
} catch (UncheckedExecutionException e) {
|
||||
return Result.error((Exception) e.getCause());
|
||||
} catch (Exception e) {
|
||||
return Result.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
private static JsonObject getElyByProfile(String username) throws IOException {
|
||||
private static Optional<Property> loadSkin(String username) throws Exception {
|
||||
var profile = ElyBySkinProvider.getElyByProfile(username);
|
||||
var textures = PlayerUtils.getPlayerSkin(profile);
|
||||
|
||||
return Optional.ofNullable(textures);
|
||||
}
|
||||
|
||||
private static GameProfile getElyByProfile(String username) throws IOException {
|
||||
var request = HttpRequest.newBuilder()
|
||||
.uri(ElyBySkinProvider.API_URI
|
||||
.resolve("textures/signed/")
|
||||
.resolve("/textures/signed/")
|
||||
.resolve(username + "?unsigned=false")
|
||||
)
|
||||
.GET()
|
||||
@@ -66,6 +98,6 @@ public final class ElyBySkinProvider implements SkinProvider {
|
||||
if (response.statusCode() != 200)
|
||||
throw new IllegalArgumentException("no profile with name " + username);
|
||||
|
||||
return JsonUtils.parseJson(response.body());
|
||||
return PlayerUtils.toProfile(JsonUtils.fromJson(response.body(), MinecraftProfilePropertiesResponse.class));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,11 +21,11 @@ public final class EmptySkinProvider implements SkinProvider {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result<Optional<Property>, Exception> getSkin(String argument, SkinVariant variant) {
|
||||
return this.getSkin();
|
||||
public Result<Optional<Property>, Exception> fetchSkin(String argument, SkinVariant variant) {
|
||||
return this.fetchSkin();
|
||||
}
|
||||
|
||||
public Result<Optional<Property>, Exception> getSkin() {
|
||||
public Result<Optional<Property>, Exception> fetchSkin() {
|
||||
return Result.ofNullable(null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,18 +1,26 @@
|
||||
package net.lionarius.skinrestorer.skin.provider;
|
||||
|
||||
import com.google.common.cache.CacheBuilder;
|
||||
import com.google.common.cache.CacheLoader;
|
||||
import com.google.common.cache.LoadingCache;
|
||||
import com.google.common.util.concurrent.UncheckedExecutionException;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.mojang.authlib.properties.Property;
|
||||
import it.unimi.dsi.fastutil.Pair;
|
||||
import net.lionarius.skinrestorer.SkinRestorer;
|
||||
import net.lionarius.skinrestorer.skin.SkinVariant;
|
||||
import net.lionarius.skinrestorer.util.JsonUtils;
|
||||
import net.lionarius.skinrestorer.util.PlayerUtils;
|
||||
import net.lionarius.skinrestorer.util.Result;
|
||||
import net.lionarius.skinrestorer.util.WebUtils;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.net.http.HttpRequest;
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public final class MineskinSkinProvider implements SkinProvider {
|
||||
|
||||
@@ -20,14 +28,30 @@ public final class MineskinSkinProvider implements SkinProvider {
|
||||
|
||||
private static final URI API_URI;
|
||||
|
||||
private static LoadingCache<Pair<URI, SkinVariant>, Optional<Property>> SKIN_CACHE;
|
||||
|
||||
static {
|
||||
try {
|
||||
API_URI = new URI("https://api.mineskin.org/");
|
||||
API_URI = new URI("https://api.mineskin.org");
|
||||
} catch (URISyntaxException e) {
|
||||
throw new IllegalArgumentException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public static void createCache() {
|
||||
var config = SkinRestorer.getConfig().providersConfig().mineskin();
|
||||
var time = config.cache().enabled() ? config.cache().duration() : 0;
|
||||
|
||||
SKIN_CACHE = CacheBuilder.newBuilder()
|
||||
.expireAfterWrite(time, TimeUnit.SECONDS)
|
||||
.build(new CacheLoader<>() {
|
||||
@Override
|
||||
public @NotNull Optional<Property> load(@NotNull Pair<URI, SkinVariant> key) throws Exception {
|
||||
return MineskinSkinProvider.loadSkin(key.first(), key.second());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getArgumentName() {
|
||||
return "url";
|
||||
@@ -39,23 +63,32 @@ public final class MineskinSkinProvider implements SkinProvider {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result<Optional<Property>, Exception> getSkin(String url, SkinVariant variant) {
|
||||
public Result<Optional<Property>, Exception> fetchSkin(String url, SkinVariant variant) {
|
||||
try {
|
||||
var result = MineskinSkinProvider.uploadToMineskin(url, variant);
|
||||
var texture = result.getAsJsonObject("data").getAsJsonObject("texture");
|
||||
var uri = new URI(url);
|
||||
|
||||
return Result.ofNullable(new Property(PlayerUtils.TEXTURES_KEY, texture.get("value").getAsString(), texture.get("signature").getAsString()));
|
||||
return Result.success(SKIN_CACHE.get(Pair.of(uri, variant)));
|
||||
} catch (UncheckedExecutionException e) {
|
||||
return Result.error((Exception) e.getCause());
|
||||
} catch (Exception e) {
|
||||
return Result.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
private static JsonObject uploadToMineskin(String url, SkinVariant variant) throws IOException {
|
||||
private static Optional<Property> loadSkin(URI uri, SkinVariant variant) throws Exception {
|
||||
var result = MineskinSkinProvider.uploadToMineskin(uri, variant);
|
||||
var texture = result.getAsJsonObject("data").getAsJsonObject("texture");
|
||||
var textures = new Property(PlayerUtils.TEXTURES_KEY, texture.get("value").getAsString(), texture.get("signature").getAsString());
|
||||
|
||||
return Optional.of(textures);
|
||||
}
|
||||
|
||||
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 request = HttpRequest.newBuilder()
|
||||
.uri(MineskinSkinProvider.API_URI.resolve("generate/url"))
|
||||
.uri(MineskinSkinProvider.API_URI.resolve("/generate/url"))
|
||||
.POST(HttpRequest.BodyPublishers.ofString(body))
|
||||
.header("Content-Type", "application/json")
|
||||
.build();
|
||||
|
||||
@@ -1,19 +1,25 @@
|
||||
package net.lionarius.skinrestorer.skin.provider;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.common.cache.CacheBuilder;
|
||||
import com.google.common.cache.CacheLoader;
|
||||
import com.google.common.cache.LoadingCache;
|
||||
import com.google.common.util.concurrent.UncheckedExecutionException;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import com.mojang.authlib.properties.Property;
|
||||
import com.mojang.authlib.yggdrasil.response.MinecraftProfilePropertiesResponse;
|
||||
import net.lionarius.skinrestorer.SkinRestorer;
|
||||
import net.lionarius.skinrestorer.skin.SkinVariant;
|
||||
import net.lionarius.skinrestorer.util.JsonUtils;
|
||||
import net.lionarius.skinrestorer.util.PlayerUtils;
|
||||
import net.lionarius.skinrestorer.util.Result;
|
||||
import net.lionarius.skinrestorer.util.WebUtils;
|
||||
import net.lionarius.skinrestorer.util.*;
|
||||
import net.minecraft.server.players.GameProfileCache;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.net.http.HttpRequest;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public final class MojangSkinProvider implements SkinProvider {
|
||||
|
||||
@@ -22,13 +28,45 @@ public final class MojangSkinProvider implements SkinProvider {
|
||||
private static final URI API_URI;
|
||||
private static final URI SESSION_SERVER_URI;
|
||||
|
||||
public static final String PROFILE_CACHE_FILENAME = "mojang_profile_cache.json";
|
||||
private static final GameProfileCache PROFILE_CACHE;
|
||||
|
||||
private static LoadingCache<UUID, Optional<Property>> SKIN_CACHE;
|
||||
|
||||
static {
|
||||
try {
|
||||
API_URI = new URI("https://api.mojang.com/");
|
||||
SESSION_SERVER_URI = new URI("https://sessionserver.mojang.com/");
|
||||
API_URI = new URI("https://api.mojang.com");
|
||||
SESSION_SERVER_URI = new URI("https://sessionserver.mojang.com");
|
||||
} catch (URISyntaxException e) {
|
||||
throw new IllegalArgumentException(e);
|
||||
}
|
||||
|
||||
PROFILE_CACHE = new GameProfileCache((names, agent, callback) -> {
|
||||
for (var name : names) {
|
||||
try {
|
||||
var profile = MojangSkinProvider.getProfile(name);
|
||||
callback.onProfileLookupSucceeded(profile);
|
||||
} catch (IOException e) {
|
||||
callback.onProfileLookupFailed(new GameProfile(null, name), e);
|
||||
}
|
||||
}
|
||||
}, SkinRestorer.getConfigDir().resolve(PROFILE_CACHE_FILENAME).toFile());
|
||||
|
||||
|
||||
}
|
||||
|
||||
public static void createCache() {
|
||||
var config = SkinRestorer.getConfig().providersConfig().mojang();
|
||||
var time = config.cache().enabled() ? config.cache().duration() : 0;
|
||||
|
||||
SKIN_CACHE = CacheBuilder.newBuilder()
|
||||
.expireAfterWrite(time, TimeUnit.SECONDS)
|
||||
.build(new CacheLoader<>() {
|
||||
@Override
|
||||
public @NotNull Optional<Property> load(@NotNull UUID key) throws Exception {
|
||||
return MojangSkinProvider.loadSkin(key);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static SkinProviderContext skinProviderContextFromProfile(GameProfile gameProfile) {
|
||||
@@ -46,24 +84,34 @@ public final class MojangSkinProvider implements SkinProvider {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result<Optional<Property>, Exception> getSkin(String username, SkinVariant variant) {
|
||||
public Result<Optional<Property>, Exception> fetchSkin(String username, SkinVariant variant) {
|
||||
try {
|
||||
var uuid = MojangSkinProvider.getUuid(username);
|
||||
var profile = MojangSkinProvider.getMojangProfile(uuid);
|
||||
if (!StringUtils.isValidPlayerName(username))
|
||||
throw new IllegalArgumentException("invalid username");
|
||||
|
||||
var properties = profile.getAsJsonArray("properties");
|
||||
var textures = PlayerUtils.findTexturesProperty(properties);
|
||||
var cachedProfile = MojangSkinProvider.PROFILE_CACHE.get(username);
|
||||
if (cachedProfile.isEmpty())
|
||||
throw new IllegalArgumentException("no profile found for " + username);
|
||||
|
||||
return Result.ofNullable(textures);
|
||||
return Result.success(SKIN_CACHE.get(cachedProfile.get().getId()));
|
||||
} catch (UncheckedExecutionException e) {
|
||||
return Result.error((Exception) e.getCause());
|
||||
} catch (Exception e) {
|
||||
return Result.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
private static String getUuid(final String name) throws IOException {
|
||||
private static Optional<Property> loadSkin(UUID uuid) throws Exception {
|
||||
var profile = MojangSkinProvider.getProfileWithProperties(uuid);
|
||||
var textures = PlayerUtils.getPlayerSkin(profile);
|
||||
|
||||
return Optional.ofNullable(textures);
|
||||
}
|
||||
|
||||
private static GameProfile getProfile(final String name) throws IOException {
|
||||
var request = HttpRequest.newBuilder()
|
||||
.uri(MojangSkinProvider.API_URI
|
||||
.resolve("users/profiles/minecraft/")
|
||||
.resolve("/users/profiles/minecraft/")
|
||||
.resolve(name)
|
||||
)
|
||||
.GET()
|
||||
@@ -75,18 +123,14 @@ public final class MojangSkinProvider implements SkinProvider {
|
||||
if (response.statusCode() != 200)
|
||||
throw new IllegalArgumentException("no profile with name " + name);
|
||||
|
||||
var profile = JsonUtils.parseJson(response.body());
|
||||
if (profile == null)
|
||||
return null;
|
||||
|
||||
return profile.get("id").getAsString();
|
||||
return JsonUtils.fromJson(response.body(), GameProfile.class);
|
||||
}
|
||||
|
||||
private static JsonObject getMojangProfile(String uuid) throws IOException {
|
||||
private static GameProfile getProfileWithProperties(UUID uuid) throws IOException {
|
||||
var request = HttpRequest.newBuilder()
|
||||
.uri(MojangSkinProvider.SESSION_SERVER_URI
|
||||
.resolve("session/minecraft/profile/")
|
||||
.resolve(uuid + "?unsigned=false")
|
||||
.resolve("/session/minecraft/profile/")
|
||||
.resolve(uuid.toString() + "?unsigned=false")
|
||||
)
|
||||
.GET()
|
||||
.build();
|
||||
@@ -97,6 +141,6 @@ public final class MojangSkinProvider implements SkinProvider {
|
||||
if (response.statusCode() != 200)
|
||||
throw new IllegalArgumentException("no profile with uuid " + uuid);
|
||||
|
||||
return JsonUtils.parseJson(response.body());
|
||||
return PlayerUtils.toProfile(JsonUtils.fromJson(response.body(), MinecraftProfilePropertiesResponse.class));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,9 +12,11 @@ public interface SkinProvider {
|
||||
ElyBySkinProvider ELY_BY = new ElyBySkinProvider();
|
||||
MineskinSkinProvider MINESKIN = new MineskinSkinProvider();
|
||||
|
||||
String[] BUILTIN_PROVIDER_NAMES = new String[]{EmptySkinProvider.PROVIDER_NAME, MojangSkinProvider.PROVIDER_NAME, ElyBySkinProvider.PROVIDER_NAME, MineskinSkinProvider.PROVIDER_NAME};
|
||||
|
||||
String getArgumentName();
|
||||
|
||||
boolean hasVariantSupport();
|
||||
|
||||
Result<Optional<Property>, Exception> getSkin(String argument, SkinVariant variant);
|
||||
Result<Optional<Property>, Exception> fetchSkin(String argument, SkinVariant variant);
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ public final class SkinProviderRegistry {
|
||||
|
||||
public void register(@NotNull String name, @NotNull SkinProvider provider, boolean isPublic) {
|
||||
if (this.registry.containsKey(name))
|
||||
throw new IllegalArgumentException("Skin provider with name " + name + " is already registered");
|
||||
return;
|
||||
|
||||
this.registry.put(name, new Entry(provider, isPublic));
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ public final class Translation {
|
||||
public static final String COMMAND_SKIN_FAILED_KEY = "skinrestorer.command.skin.failed";
|
||||
public static final String COMMAND_SKIN_OK_KEY = "skinrestorer.command.skin.ok";
|
||||
public static final String COMMAND_SKIN_LOADING_KEY = "skinrestorer.command.skin.loading";
|
||||
public static final String COMMAND_SKIN_CONFIG_RELOADED_KEY = "skinrestorer.command.skin.config_reloaded";
|
||||
|
||||
private static Map<String, String> translations;
|
||||
private static final Map<String, String> fallback;
|
||||
@@ -46,11 +47,11 @@ public final class Translation {
|
||||
}
|
||||
|
||||
public static void reloadTranslations() {
|
||||
translations = Translation.loadTranslationMap(SkinRestorer.getConfig().getLanguage());
|
||||
translations = Translation.loadTranslationMap(SkinRestorer.getConfig().language());
|
||||
}
|
||||
|
||||
private static ImmutableMap<String, String> loadTranslationMap(String lang) {
|
||||
var json = FileUtils.readResource(SkinRestorer.resource(String.format("lang/%s.json", lang)));
|
||||
var json = FileUtils.readResource(SkinRestorer.assetPath(String.format("lang/%s.json", lang)));
|
||||
|
||||
var type = new TypeToken<Map<String, String>>() {}.getType();
|
||||
Map<String, String> map = null;
|
||||
|
||||
@@ -3,6 +3,7 @@ package net.lionarius.skinrestorer.util;
|
||||
import net.lionarius.skinrestorer.SkinRestorer;
|
||||
import net.lionarius.skinrestorer.config.Config;
|
||||
import net.lionarius.skinrestorer.skin.SkinIO;
|
||||
import net.lionarius.skinrestorer.skin.provider.MojangSkinProvider;
|
||||
import net.lionarius.skinrestorer.translation.Translation;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
@@ -17,24 +18,28 @@ public final class FileUtils {
|
||||
|
||||
private FileUtils() {}
|
||||
|
||||
public static void tryMigrateOldSkinDirectory(Path newDirectory) {
|
||||
public static void tryMigrateOldSkinDirectory(Path oldDirectory, Path newDirectory) {
|
||||
try {
|
||||
var configDirectory = SkinRestorer.getConfigDir();
|
||||
try (var stream = Files.list(configDirectory)) {
|
||||
try (var stream = Files.list(oldDirectory)) {
|
||||
var files = stream.filter(file -> {
|
||||
var name = file.getFileName();
|
||||
var name = file.getFileName().toString();
|
||||
return Files.isRegularFile(file)
|
||||
&& !name.startsWith(Translation.LEGACY_TRANSLATION_FILENAME)
|
||||
&& !name.startsWith(Config.CONFIG_FILENAME)
|
||||
&& !name.startsWith(MojangSkinProvider.PROFILE_CACHE_FILENAME)
|
||||
&& name.endsWith(SkinIO.FILE_EXTENSION);
|
||||
}).toList();
|
||||
|
||||
if (!files.isEmpty() && !Files.exists(newDirectory))
|
||||
Files.createDirectories(newDirectory);
|
||||
|
||||
|
||||
for (var file : files)
|
||||
Files.move(file, newDirectory.resolve(file.getFileName()), StandardCopyOption.REPLACE_EXISTING);
|
||||
for (var file : files) {
|
||||
var newFile = newDirectory.resolve(file.getFileName());
|
||||
if (!Files.exists(newFile))
|
||||
Files.move(file, newFile, StandardCopyOption.ATOMIC_MOVE);
|
||||
else
|
||||
Files.delete(file);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
SkinRestorer.LOGGER.error("could not migrate skin directory", e);
|
||||
|
||||
@@ -1,16 +1,28 @@
|
||||
package net.lionarius.skinrestorer.util;
|
||||
|
||||
import com.google.gson.*;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import com.mojang.authlib.properties.Property;
|
||||
import com.mojang.authlib.properties.PropertyMap;
|
||||
import com.mojang.util.UUIDTypeAdapter;
|
||||
import net.lionarius.skinrestorer.SkinRestorer;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Base64;
|
||||
import java.util.UUID;
|
||||
|
||||
public final class JsonUtils {
|
||||
|
||||
private static final Gson GSON = new GsonBuilder().setPrettyPrinting().create();
|
||||
private static final Gson GSON = new GsonBuilder()
|
||||
.registerTypeAdapter(UUID.class, new UUIDTypeAdapter())
|
||||
.registerTypeAdapter(PropertyMap.class, new PropertyMap.Serializer())
|
||||
.registerTypeAdapter(GameProfile.class, new GameProfile.Serializer())
|
||||
.setPrettyPrinting()
|
||||
.create();
|
||||
|
||||
private JsonUtils() {}
|
||||
|
||||
@@ -31,12 +43,12 @@ public final class JsonUtils {
|
||||
}
|
||||
|
||||
public static JsonObject parseJson(String json) {
|
||||
return JsonParser.parseString(json).getAsJsonObject();
|
||||
return GSON.fromJson(json, JsonObject.class);
|
||||
}
|
||||
|
||||
public static JsonObject skinPropertyToJson(Property property) {
|
||||
try {
|
||||
JsonObject json = GSON.fromJson(new String(Base64.getDecoder().decode(property.value()), StandardCharsets.UTF_8), JsonObject.class);
|
||||
JsonObject json = GSON.fromJson(new String(Base64.getDecoder().decode(property.getValue()), StandardCharsets.UTF_8), JsonObject.class);
|
||||
if (json != null)
|
||||
json.remove("timestamp");
|
||||
|
||||
|
||||
@@ -1,17 +1,19 @@
|
||||
package net.lionarius.skinrestorer.util;
|
||||
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import com.mojang.authlib.properties.Property;
|
||||
import com.mojang.authlib.yggdrasil.response.MinecraftProfilePropertiesResponse;
|
||||
import net.lionarius.skinrestorer.mixin.ChunkMapAccessor;
|
||||
import net.lionarius.skinrestorer.mixin.TrackedEntityMixin;
|
||||
import net.lionarius.skinrestorer.mixin.TrackedEntityAccessorInvoker;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.protocol.game.*;
|
||||
import net.minecraft.server.level.ChunkMap;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.server.players.PlayerList;
|
||||
import net.minecraft.world.level.biome.BiomeManager;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
@@ -49,14 +51,14 @@ public final class PlayerUtils {
|
||||
)
|
||||
));
|
||||
|
||||
var trackedEntity = (TrackedEntityMixin) ((ChunkMapAccessor) chunkMap).getEntityMap().get(player.getId());
|
||||
var trackedEntity = (TrackedEntityAccessorInvoker) ((ChunkMapAccessor) chunkMap).getEntityMap().get(player.getId());
|
||||
if (trackedEntity != null) {
|
||||
var seenBy = Set.copyOf(trackedEntity.getSeenBy());
|
||||
for (var observerConnection : seenBy) {
|
||||
var observer = observerConnection.getPlayer();
|
||||
trackedEntity.invokeRemovePlayer(observer);
|
||||
|
||||
var trackedObserverEntity = (TrackedEntityMixin) ((ChunkMapAccessor) chunkMap).getEntityMap().get(observer.getId());
|
||||
var trackedObserverEntity = (TrackedEntityAccessorInvoker) ((ChunkMapAccessor) chunkMap).getEntityMap().get(observer.getId());
|
||||
if (trackedObserverEntity != null) {
|
||||
trackedObserverEntity.invokeRemovePlayer(player);
|
||||
trackedObserverEntity.invokeUpdatePlayer(player);
|
||||
@@ -66,12 +68,20 @@ public final class PlayerUtils {
|
||||
}
|
||||
|
||||
if (!player.isDeadOrDying()) {
|
||||
player.connection.send(new ClientboundBundlePacket(
|
||||
List.of(
|
||||
new ClientboundRespawnPacket(player.createCommonSpawnInfo(serverLevel), ClientboundRespawnPacket.KEEP_ALL_DATA),
|
||||
new ClientboundGameEventPacket(ClientboundGameEventPacket.LEVEL_CHUNKS_LOAD_START, 0)
|
||||
player.connection.send(
|
||||
new ClientboundRespawnPacket(
|
||||
player.level().dimensionTypeId(),
|
||||
player.level().dimension(),
|
||||
BiomeManager.obfuscateSeed(player.serverLevel().getSeed()),
|
||||
player.gameMode.getGameModeForPlayer(),
|
||||
player.gameMode.getPreviousGameModeForPlayer(),
|
||||
player.level().isDebug(),
|
||||
player.serverLevel().isFlat(),
|
||||
(byte) 3,
|
||||
player.getLastDeathLocation(),
|
||||
player.getPortalCooldown()
|
||||
)
|
||||
));
|
||||
);
|
||||
player.connection.teleport(player.getX(), player.getY(), player.getZ(), player.getYRot(), player.getXRot());
|
||||
player.connection.send(new ClientboundSetEntityMotionPacket(player));
|
||||
var vehicle = player.getVehicle();
|
||||
@@ -89,14 +99,14 @@ public final class PlayerUtils {
|
||||
}
|
||||
}
|
||||
|
||||
public static void sendActivePlayerEffects(ServerPlayer player) {
|
||||
private static void sendActivePlayerEffects(ServerPlayer player) {
|
||||
for (var effect : player.getActiveEffects()) {
|
||||
player.connection.send(new ClientboundUpdateMobEffectPacket(player.getId(), effect, false));
|
||||
player.connection.send(new ClientboundUpdateMobEffectPacket(player.getId(), effect));
|
||||
}
|
||||
}
|
||||
|
||||
public static Property getPlayerSkin(GameProfile profile) {
|
||||
return profile.getProperties().get(TEXTURES_KEY).stream().findFirst().orElse(null);
|
||||
return Iterables.getFirst(profile.getProperties().get(TEXTURES_KEY), null);
|
||||
}
|
||||
|
||||
public static void applyRestoredSkin(GameProfile profile, Property skin) {
|
||||
@@ -106,7 +116,6 @@ public final class PlayerUtils {
|
||||
profile.getProperties().put(TEXTURES_KEY, skin);
|
||||
}
|
||||
|
||||
|
||||
public static boolean areSkinPropertiesEquals(Property x, Property y) {
|
||||
if (x == y)
|
||||
return true;
|
||||
@@ -126,24 +135,9 @@ public final class PlayerUtils {
|
||||
return xJson.equals(yJson);
|
||||
}
|
||||
|
||||
public static Property findTexturesProperty(JsonArray properties) {
|
||||
Property textures = null;
|
||||
for (var property : properties) {
|
||||
var propertyObject = property.getAsJsonObject();
|
||||
if (propertyObject == null)
|
||||
continue;
|
||||
|
||||
try {
|
||||
textures = JsonUtils.fromJson(propertyObject, Property.class);
|
||||
break;
|
||||
} catch (Exception e) {
|
||||
// ignored
|
||||
}
|
||||
}
|
||||
|
||||
if (textures == null)
|
||||
throw new IllegalStateException("no textures in profile");
|
||||
|
||||
return textures;
|
||||
public static GameProfile toProfile(MinecraftProfilePropertiesResponse response) {
|
||||
final GameProfile profile = new GameProfile(response.getId(), response.getName());
|
||||
profile.getProperties().putAll(response.getProperties());
|
||||
return profile;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,4 +17,8 @@ public final class StringUtils {
|
||||
|
||||
return response.toString();
|
||||
}
|
||||
|
||||
public static boolean isValidPlayerName(String playerName) {
|
||||
return playerName.length() <= 16 && playerName.chars().filter(i -> i <= 32 || i >= 127).findAny().isEmpty();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,7 +10,6 @@ import java.net.http.HttpRequest;
|
||||
import java.net.http.HttpResponse;
|
||||
import java.time.Duration;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
import java.util.Date;
|
||||
|
||||
public final class WebUtils {
|
||||
|
||||
@@ -18,37 +17,32 @@ public final class WebUtils {
|
||||
|
||||
public static final String USER_AGENT;
|
||||
|
||||
private static HttpClient HTTP_CLIENT = null;
|
||||
|
||||
static {
|
||||
var date = new Date();
|
||||
USER_AGENT = String.format("SkinRestorer/%d", date.getTime() % 65535);
|
||||
|
||||
USER_AGENT = String.format("SkinRestorer/%d", System.currentTimeMillis() % 65535);
|
||||
}
|
||||
|
||||
public static void recreateHttpClient() {
|
||||
HTTP_CLIENT = WebUtils.buildClient();
|
||||
}
|
||||
|
||||
private static HttpClient buildClient() {
|
||||
var builder = HttpClient.newBuilder();
|
||||
var proxy = SkinRestorer.getConfig().getProxy();
|
||||
|
||||
var proxy = SkinRestorer.getConfig().proxy();
|
||||
proxy.ifPresent(value -> builder.proxy(ProxySelector.of(InetSocketAddress.createUnresolved(value.host(), value.port()))));
|
||||
|
||||
try {
|
||||
if (proxy != null) {
|
||||
var colonIndex = proxy.lastIndexOf(':');
|
||||
if (colonIndex != -1) {
|
||||
var host = proxy.substring(0, colonIndex);
|
||||
var port = Integer.parseInt(proxy.substring(colonIndex + 1));
|
||||
|
||||
builder.proxy(ProxySelector.of(InetSocketAddress.createUnresolved(host, port)));
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
SkinRestorer.LOGGER.error("failed to parse proxy", e);
|
||||
}
|
||||
try {
|
||||
builder.connectTimeout(Duration.of(SkinRestorer.getConfig().getRequestTimeout(), ChronoUnit.SECONDS));
|
||||
builder.connectTimeout(Duration.of(SkinRestorer.getConfig().requestTimeout(), ChronoUnit.SECONDS));
|
||||
} catch (IllegalArgumentException e) {
|
||||
SkinRestorer.LOGGER.error("failed to set request timeout", e);
|
||||
builder.connectTimeout(Duration.of(10, ChronoUnit.SECONDS));
|
||||
}
|
||||
|
||||
HTTP_CLIENT = builder.build();
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
private static final HttpClient HTTP_CLIENT;
|
||||
|
||||
public static HttpResponse<String> executeRequest(HttpRequest request) throws IOException {
|
||||
try {
|
||||
var modifiedRequest = HttpRequest.newBuilder(request, (name, value) -> true)
|
||||
@@ -68,30 +62,16 @@ public final class WebUtils {
|
||||
}
|
||||
|
||||
public static void throwOnClientErrors(HttpResponse<?> response) {
|
||||
String message = null;
|
||||
switch (response.statusCode()) {
|
||||
case 400:
|
||||
message = "bad request";
|
||||
break;
|
||||
case 401:
|
||||
message = "unauthorized";
|
||||
break;
|
||||
case 403:
|
||||
message = "forbidden";
|
||||
break;
|
||||
case 404:
|
||||
message = "not found";
|
||||
break;
|
||||
case 405:
|
||||
message = "method not allowed";
|
||||
break;
|
||||
case 408:
|
||||
message = "request timeout";
|
||||
break;
|
||||
case 429:
|
||||
message = "too many requests";
|
||||
break;
|
||||
}
|
||||
String message = switch (response.statusCode()) {
|
||||
case 400 -> "bad request";
|
||||
case 401 -> "unauthorized";
|
||||
case 403 -> "forbidden";
|
||||
case 404 -> "not found";
|
||||
case 405 -> "method not allowed";
|
||||
case 408 -> "request timeout";
|
||||
case 429 -> "too many requests";
|
||||
default -> null;
|
||||
};
|
||||
|
||||
if (message != null)
|
||||
throw new IllegalStateException(message);
|
||||
|
||||
@@ -3,5 +3,6 @@
|
||||
"skinrestorer.command.skin.no_changes": "Žádné změny skinu",
|
||||
"skinrestorer.command.skin.failed": "Nepodařilo se změnit skin: %s",
|
||||
"skinrestorer.command.skin.ok": "Skin změněn",
|
||||
"skinrestorer.command.skin.loading": "Načítání skinu..."
|
||||
"skinrestorer.command.skin.loading": "Načítání skinu...",
|
||||
"skinrestorer.command.skin.config_reloaded": "Konfigurace byla znovu načtena"
|
||||
}
|
||||
|
||||
@@ -3,5 +3,6 @@
|
||||
"skinrestorer.command.skin.no_changes": "Keine Skinänderungen",
|
||||
"skinrestorer.command.skin.failed": "Skin konnte nicht geändert werden: %s",
|
||||
"skinrestorer.command.skin.ok": "Skin geändert",
|
||||
"skinrestorer.command.skin.loading": "Skin wird geladen..."
|
||||
"skinrestorer.command.skin.loading": "Skin wird geladen...",
|
||||
"skinrestorer.command.skin.config_reloaded": "Konfiguration wurde neu geladen"
|
||||
}
|
||||
|
||||
@@ -3,5 +3,6 @@
|
||||
"skinrestorer.command.skin.no_changes": "No skin changes",
|
||||
"skinrestorer.command.skin.failed": "Failed to change skin: %s",
|
||||
"skinrestorer.command.skin.ok": "Skin changed",
|
||||
"skinrestorer.command.skin.loading": "Loading skin..."
|
||||
"skinrestorer.command.skin.loading": "Loading skin...",
|
||||
"skinrestorer.command.skin.config_reloaded": "Config has been reloaded"
|
||||
}
|
||||
|
||||
@@ -3,5 +3,6 @@
|
||||
"skinrestorer.command.skin.no_changes": "No hay cambios de skin",
|
||||
"skinrestorer.command.skin.failed": "Error al cambiar el skin: %s",
|
||||
"skinrestorer.command.skin.ok": "Skin cambiado",
|
||||
"skinrestorer.command.skin.loading": "Cargando skin..."
|
||||
"skinrestorer.command.skin.loading": "Cargando skin...",
|
||||
"skinrestorer.command.skin.config_reloaded": "La configuración se ha recargado"
|
||||
}
|
||||
|
||||
@@ -3,5 +3,6 @@
|
||||
"skinrestorer.command.skin.no_changes": "No hay cambios de skin",
|
||||
"skinrestorer.command.skin.failed": "Error al cambiar el skin: %s",
|
||||
"skinrestorer.command.skin.ok": "Skin cambiado",
|
||||
"skinrestorer.command.skin.loading": "Cargando skin..."
|
||||
"skinrestorer.command.skin.loading": "Cargando skin...",
|
||||
"skinrestorer.command.skin.config_reloaded": "La configuración se ha recargado"
|
||||
}
|
||||
|
||||
@@ -3,5 +3,6 @@
|
||||
"skinrestorer.command.skin.no_changes": "No hay cambios de skin",
|
||||
"skinrestorer.command.skin.failed": "Error al cambiar el skin: %s",
|
||||
"skinrestorer.command.skin.ok": "Skin cambiado",
|
||||
"skinrestorer.command.skin.loading": "Cargando skin..."
|
||||
"skinrestorer.command.skin.loading": "Cargando skin...",
|
||||
"skinrestorer.command.skin.config_reloaded": "La configuración se ha recargado"
|
||||
}
|
||||
|
||||
@@ -3,5 +3,6 @@
|
||||
"skinrestorer.command.skin.no_changes": "Walang pagbabago sa skin",
|
||||
"skinrestorer.command.skin.failed": "Nabigo sa pagbabago ng skin: %s",
|
||||
"skinrestorer.command.skin.ok": "Nabago ang skin",
|
||||
"skinrestorer.command.skin.loading": "Naglo-load ng skin..."
|
||||
"skinrestorer.command.skin.loading": "Naglo-load ng skin...",
|
||||
"skinrestorer.command.skin.config_reloaded": "Na-reload ang config"
|
||||
}
|
||||
|
||||
@@ -3,5 +3,6 @@
|
||||
"skinrestorer.command.skin.no_changes": "Aucun changement de skin",
|
||||
"skinrestorer.command.skin.failed": "Échec du changement de skin : %s",
|
||||
"skinrestorer.command.skin.ok": "Skin changé",
|
||||
"skinrestorer.command.skin.loading": "Chargement du skin..."
|
||||
"skinrestorer.command.skin.loading": "Chargement du skin...",
|
||||
"skinrestorer.command.skin.config_reloaded": "La configuration a été rechargée"
|
||||
}
|
||||
|
||||
@@ -3,5 +3,6 @@
|
||||
"skinrestorer.command.skin.no_changes": "Aucun changement de skin",
|
||||
"skinrestorer.command.skin.failed": "Échec du changement de skin : %s",
|
||||
"skinrestorer.command.skin.ok": "Skin changé",
|
||||
"skinrestorer.command.skin.loading": "Chargement du skin..."
|
||||
"skinrestorer.command.skin.loading": "Chargement du skin...",
|
||||
"skinrestorer.command.skin.config_reloaded": "La configuration a été rechargée"
|
||||
}
|
||||
|
||||
@@ -3,5 +3,6 @@
|
||||
"skinrestorer.command.skin.no_changes": "कोई त्वचा परिवर्तन नहीं",
|
||||
"skinrestorer.command.skin.failed": "त्वचा बदलने में विफल: %s",
|
||||
"skinrestorer.command.skin.ok": "त्वचा बदल दी गई",
|
||||
"skinrestorer.command.skin.loading": "त्वचा लोड हो रही है..."
|
||||
"skinrestorer.command.skin.loading": "त्वचा लोड हो रही है...",
|
||||
"skinrestorer.command.skin.config_reloaded": "कॉन्फ़िगरेशन फिर से लोड किया गया है"
|
||||
}
|
||||
|
||||
@@ -3,5 +3,6 @@
|
||||
"skinrestorer.command.skin.no_changes": "Nincsenek skin változások",
|
||||
"skinrestorer.command.skin.failed": "Skin változtatás sikertelen: %s",
|
||||
"skinrestorer.command.skin.ok": "Skin megváltoztatva",
|
||||
"skinrestorer.command.skin.loading": "Skin betöltése..."
|
||||
"skinrestorer.command.skin.loading": "Skin betöltése...",
|
||||
"skinrestorer.command.skin.config_reloaded": "A konfiguráció újratöltve"
|
||||
}
|
||||
|
||||
@@ -3,5 +3,6 @@
|
||||
"skinrestorer.command.skin.no_changes": "Tidak ada perubahan skin",
|
||||
"skinrestorer.command.skin.failed": "Gagal mengubah skin: %s",
|
||||
"skinrestorer.command.skin.ok": "Skin diubah",
|
||||
"skinrestorer.command.skin.loading": "Memuat skin..."
|
||||
"skinrestorer.command.skin.loading": "Memuat skin...",
|
||||
"skinrestorer.command.skin.config_reloaded": "Konfigurasi telah dimuat ulang"
|
||||
}
|
||||
|
||||
@@ -3,5 +3,6 @@
|
||||
"skinrestorer.command.skin.no_changes": "Nessuna modifica alla skin",
|
||||
"skinrestorer.command.skin.failed": "Impossibile cambiare la skin: %s",
|
||||
"skinrestorer.command.skin.ok": "Skin cambiata",
|
||||
"skinrestorer.command.skin.loading": "Caricamento della skin..."
|
||||
"skinrestorer.command.skin.loading": "Caricamento della skin...",
|
||||
"skinrestorer.command.skin.config_reloaded": "La configurazione è stata ricaricata"
|
||||
}
|
||||
|
||||
@@ -3,5 +3,6 @@
|
||||
"skinrestorer.command.skin.no_changes": "Brak zmian skina",
|
||||
"skinrestorer.command.skin.failed": "Nie udało się zmienić skina: %s",
|
||||
"skinrestorer.command.skin.ok": "Skin zmieniony",
|
||||
"skinrestorer.command.skin.loading": "Ładowanie skina..."
|
||||
"skinrestorer.command.skin.loading": "Ładowanie skina...",
|
||||
"skinrestorer.command.skin.config_reloaded": "Konfiguracja została przeładowana"
|
||||
}
|
||||
|
||||
@@ -3,5 +3,6 @@
|
||||
"skinrestorer.command.skin.no_changes": "Nenhuma alteração de skin",
|
||||
"skinrestorer.command.skin.failed": "Falha ao alterar a skin: %s",
|
||||
"skinrestorer.command.skin.ok": "Skin alterada",
|
||||
"skinrestorer.command.skin.loading": "Carregando skin..."
|
||||
"skinrestorer.command.skin.loading": "Carregando skin...",
|
||||
"skinrestorer.command.skin.config_reloaded": "Configuração recarregada"
|
||||
}
|
||||
|
||||
@@ -3,5 +3,6 @@
|
||||
"skinrestorer.command.skin.no_changes": "Nenhuma alteração de skin",
|
||||
"skinrestorer.command.skin.failed": "Falha ao alterar a skin: %s",
|
||||
"skinrestorer.command.skin.ok": "Skin alterada",
|
||||
"skinrestorer.command.skin.loading": "Carregando skin..."
|
||||
"skinrestorer.command.skin.loading": "Carregando skin...",
|
||||
"skinrestorer.command.skin.config_reloaded": "Configuração recarregada"
|
||||
}
|
||||
|
||||
@@ -3,5 +3,6 @@
|
||||
"skinrestorer.command.skin.no_changes": "Изменений скина нет",
|
||||
"skinrestorer.command.skin.failed": "Не удалось изменить скин: %s",
|
||||
"skinrestorer.command.skin.ok": "Скин изменён",
|
||||
"skinrestorer.command.skin.loading": "Загрузка скина..."
|
||||
"skinrestorer.command.skin.loading": "Загрузка скина...",
|
||||
"skinrestorer.command.skin.config_reloaded": "Конфигурация была перезагружена"
|
||||
}
|
||||
|
||||
@@ -3,5 +3,6 @@
|
||||
"skinrestorer.command.skin.no_changes": "Skin değişikliği yok",
|
||||
"skinrestorer.command.skin.failed": "Skin değiştirme başarısız: %s",
|
||||
"skinrestorer.command.skin.ok": "Skin değiştirildi",
|
||||
"skinrestorer.command.skin.loading": "Skin yükleniyor..."
|
||||
"skinrestorer.command.skin.loading": "Skin yükleniyor...",
|
||||
"skinrestorer.command.skin.config_reloaded": "Yapılandırma yeniden yüklendi"
|
||||
}
|
||||
|
||||
@@ -3,5 +3,6 @@
|
||||
"skinrestorer.command.skin.no_changes": "Змін скіна немає",
|
||||
"skinrestorer.command.skin.failed": "Не вдалося змінити скіна: %s",
|
||||
"skinrestorer.command.skin.ok": "Скін змінено",
|
||||
"skinrestorer.command.skin.loading": "Завантаження скіна..."
|
||||
"skinrestorer.command.skin.loading": "Завантаження скіна...",
|
||||
"skinrestorer.command.skin.config_reloaded": "Конфігурацію перезавантажено"
|
||||
}
|
||||
|
||||
@@ -3,5 +3,6 @@
|
||||
"skinrestorer.command.skin.no_changes": "Không có thay đổi skin",
|
||||
"skinrestorer.command.skin.failed": "Thay đổi skin thất bại: %s",
|
||||
"skinrestorer.command.skin.ok": "Đã thay đổi skin",
|
||||
"skinrestorer.command.skin.loading": "Đang tải skin..."
|
||||
"skinrestorer.command.skin.loading": "Đang tải skin...",
|
||||
"skinrestorer.command.skin.config_reloaded": "Cấu hình đã được tải lại"
|
||||
}
|
||||
|
||||
@@ -3,5 +3,6 @@
|
||||
"skinrestorer.command.skin.no_changes": "没有皮肤更改",
|
||||
"skinrestorer.command.skin.failed": "更改皮肤失败:%s",
|
||||
"skinrestorer.command.skin.ok": "皮肤已更改",
|
||||
"skinrestorer.command.skin.loading": "正在加载皮肤..."
|
||||
"skinrestorer.command.skin.loading": "正在加载皮肤...",
|
||||
"skinrestorer.command.skin.config_reloaded": "配置已重新加载"
|
||||
}
|
||||
|
||||
@@ -3,5 +3,6 @@
|
||||
"skinrestorer.command.skin.no_changes": "沒有外觀變更",
|
||||
"skinrestorer.command.skin.failed": "變更外觀失敗:%s",
|
||||
"skinrestorer.command.skin.ok": "已變更外觀",
|
||||
"skinrestorer.command.skin.loading": "正在載入外觀..."
|
||||
"skinrestorer.command.skin.loading": "正在載入外觀...",
|
||||
"skinrestorer.command.skin.config_reloaded": "配置已重新載入"
|
||||
}
|
||||
|
||||
6
common/src/main/resources/pack.mcmeta
Normal file
6
common/src/main/resources/pack.mcmeta
Normal file
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"pack": {
|
||||
"description": "${mod_id}",
|
||||
"pack_format": 8
|
||||
}
|
||||
}
|
||||
@@ -3,11 +3,12 @@
|
||||
"minVersion": "0.8",
|
||||
"package": "net.lionarius.skinrestorer.mixin",
|
||||
"compatibilityLevel": "JAVA_8",
|
||||
"refmap": "${mod_id}.refmap.json",
|
||||
"mixins": [
|
||||
"PlayerListMixin",
|
||||
"ServerLoginPacketListenerImplMixin",
|
||||
"ChunkMapAccessor",
|
||||
"TrackedEntityMixin"
|
||||
"TrackedEntityAccessorInvoker"
|
||||
],
|
||||
"injectors": {
|
||||
"defaultRequire": 1
|
||||
@@ -1,49 +1,42 @@
|
||||
plugins {
|
||||
id "com.github.johnrengelman.shadow"
|
||||
id 'multiloader-loader'
|
||||
|
||||
id 'fabric-loom'
|
||||
|
||||
id 'multiloader-publish'
|
||||
}
|
||||
|
||||
architectury {
|
||||
platformSetupLoomIde()
|
||||
fabric()
|
||||
}
|
||||
|
||||
configurations {
|
||||
common {
|
||||
canBeResolved = true
|
||||
canBeConsumed = false
|
||||
}
|
||||
compileClasspath.extendsFrom common
|
||||
runtimeClasspath.extendsFrom common
|
||||
developmentFabric.extendsFrom common
|
||||
|
||||
// Files in this configuration will be bundled into your mod using the Shadow plugin.
|
||||
// Don"t use the `shadow` configuration from the plugin itself as it"s meant for excluding files.
|
||||
shadowBundle {
|
||||
canBeResolved = true
|
||||
canBeConsumed = false
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
modImplementation "net.fabricmc:fabric-loader:$rootProject.fabric_loader_version"
|
||||
|
||||
common(project(path: ":common", configuration: "namedElements")) { transitive false }
|
||||
shadowBundle project(path: ":common", configuration: "transformProductionFabric")
|
||||
minecraft "com.mojang:minecraft:${minecraft_version}"
|
||||
mappings loom.layered {
|
||||
officialMojangMappings()
|
||||
parchment("org.parchmentmc.data:parchment-${parchment_minecraft}:${parchment_version}@zip")
|
||||
}
|
||||
modImplementation "net.fabricmc:fabric-loader:${fabric_loader_version}"
|
||||
}
|
||||
|
||||
processResources {
|
||||
inputs.property "version", project.version
|
||||
loom {
|
||||
def aw = project(':common').file("src/main/resources/${mod_id}.accesswidener")
|
||||
if (aw.exists()) {
|
||||
accessWidenerPath.set(aw)
|
||||
}
|
||||
|
||||
mixin {
|
||||
defaultRefmapName.set("${mod_id}.refmap.json")
|
||||
}
|
||||
|
||||
runs {
|
||||
client {
|
||||
client()
|
||||
setConfigName('Fabric Client')
|
||||
ideConfigGenerated(true)
|
||||
runDir('../run/client')
|
||||
}
|
||||
|
||||
filesMatching("fabric.mod.json") {
|
||||
expand version: project.version
|
||||
server {
|
||||
server()
|
||||
setConfigName('Fabric Server')
|
||||
ideConfigGenerated(true)
|
||||
runDir('../run/server')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
shadowJar {
|
||||
configurations = [project.configurations.shadowBundle]
|
||||
archiveClassifier = "dev-shadow"
|
||||
}
|
||||
|
||||
remapJar {
|
||||
input.set shadowJar.archiveFile
|
||||
}
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
package net.lionarius.skinrestorer.fabric;
|
||||
|
||||
import net.fabricmc.api.ModInitializer;
|
||||
import net.fabricmc.loader.api.FabricLoader;
|
||||
import net.lionarius.skinrestorer.SkinRestorer;
|
||||
|
||||
public final class SkinRestorerFabric implements ModInitializer {
|
||||
@Override
|
||||
public void onInitialize() {
|
||||
SkinRestorer.onInitialize(FabricLoader.getInstance().getConfigDir());
|
||||
SkinRestorer.onInitialize();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
public abstract class MinecraftServerMixin {
|
||||
|
||||
@Inject(method = "runServer",
|
||||
at = @At(value = "INVOKE", target = "Lnet/minecraft/Util;getNanos()J", ordinal = 0))
|
||||
at = @At(value = "INVOKE", target = "Lnet/minecraft/Util;getMillis()J", ordinal = 0))
|
||||
private void onServerStarted(CallbackInfo ci) {
|
||||
SkinRestorer.onServerStarted((MinecraftServer) (Object) this);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
package net.lionarius.skinrestorer.fabric.platform;
|
||||
|
||||
import net.fabricmc.loader.api.FabricLoader;
|
||||
import net.lionarius.skinrestorer.platform.services.PlatformHelper;
|
||||
|
||||
import java.nio.file.Path;
|
||||
|
||||
public final class FabricPlatformHelper implements PlatformHelper {
|
||||
@Override
|
||||
public String getPlatformName() {
|
||||
return "fabric";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isModLoaded(String modId) {
|
||||
return FabricLoader.getInstance().isModLoaded(modId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Path getConfigDirectory() {
|
||||
return FabricLoader.getInstance().getConfigDir();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
net.lionarius.skinrestorer.fabric.platform.FabricPlatformHelper
|
||||
@@ -1,19 +1,19 @@
|
||||
{
|
||||
"schemaVersion": 1,
|
||||
"id": "skinrestorer",
|
||||
"id": "${mod_id}",
|
||||
"version": "${version}",
|
||||
"name": "SkinRestorer",
|
||||
"description": "A server-side mod for restoring skins on offline servers.",
|
||||
"name": "${mod_name}",
|
||||
"description": "${description}",
|
||||
"authors": [
|
||||
"Lionarius"
|
||||
"${mod_author}"
|
||||
],
|
||||
"contact": {
|
||||
"homepage": "https://modrinth.com/mod/skinrestorer",
|
||||
"sources": "https://github.com/Suiranoil/SkinRestorer",
|
||||
"issues": "https://github.com/Suiranoil/SkinRestorer/issues"
|
||||
"homepage": "${mod_homepage}",
|
||||
"sources": "${mod_sources}",
|
||||
"issues": "${mod_issues}"
|
||||
},
|
||||
"icon": "assets/skinrestorer/icon.png",
|
||||
"license": "MIT",
|
||||
"icon": "assets/${mod_id}/icon.png",
|
||||
"license": "${license}",
|
||||
"environment": "*",
|
||||
"entrypoints": {
|
||||
"main": [
|
||||
@@ -21,11 +21,12 @@
|
||||
]
|
||||
},
|
||||
"mixins": [
|
||||
"skinrestorer-common.mixins.json",
|
||||
"skinrestorer-fabric.mixins.json"
|
||||
"${mod_id}.mixins.json",
|
||||
"${mod_id}.fabric.mixins.json"
|
||||
],
|
||||
"depends": {
|
||||
"fabricloader": ">=0.15.10",
|
||||
"minecraft": ">=1.20.5"
|
||||
"fabricloader": ">=${fabric_loader_version}",
|
||||
"minecraft": ">=${minecraft_version}",
|
||||
"java": ">=${java_version}"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
"minVersion": "0.8",
|
||||
"package": "net.lionarius.skinrestorer.fabric.mixin",
|
||||
"compatibilityLevel": "JAVA_8",
|
||||
"refmap": "${mod_id}.refmap.json",
|
||||
"mixins": [
|
||||
"CommandsMixin",
|
||||
"MinecraftServerMixin"
|
||||
76
forge/build.gradle
Normal file
76
forge/build.gradle
Normal file
@@ -0,0 +1,76 @@
|
||||
plugins {
|
||||
id 'multiloader-loader'
|
||||
id 'idea'
|
||||
id 'eclipse'
|
||||
|
||||
id 'net.minecraftforge.gradle'
|
||||
id 'org.parchmentmc.librarian.forgegradle'
|
||||
id 'org.spongepowered.mixin'
|
||||
|
||||
id 'multiloader-publish'
|
||||
}
|
||||
|
||||
mixin {
|
||||
add sourceSets.main, "${mod_id}.refmap.json"
|
||||
config "${mod_id}.mixins.json"
|
||||
}
|
||||
|
||||
minecraft {
|
||||
mappings channel: 'parchment', version: "${parchment_version}-${parchment_minecraft}"
|
||||
|
||||
copyIdeResources = true //Calls processResources when in dev
|
||||
|
||||
// Automatically enable forge AccessTransformers if the file exists
|
||||
// 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
|
||||
def at = project(':common').file('src/main/resources/META-INF/accesstransformer.cfg')
|
||||
if (at.exists()) {
|
||||
accessTransformer = at
|
||||
}
|
||||
|
||||
runs {
|
||||
client {
|
||||
workingDirectory file('../run/client')
|
||||
ideaModule "${rootProject.name}.${project.name}.main"
|
||||
taskName 'Client'
|
||||
mods {
|
||||
modClientRun {
|
||||
source sourceSets.main
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
server {
|
||||
workingDirectory file('../run/server')
|
||||
ideaModule "${rootProject.name}.${project.name}.main"
|
||||
taskName 'Server'
|
||||
mods {
|
||||
modServerRun {
|
||||
source sourceSets.main
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
minecraft "net.minecraftforge:forge:${forge_minecraft_version}-${forge_version}"
|
||||
|
||||
annotationProcessor('org.spongepowered:mixin:0.8.5-SNAPSHOT:processor')
|
||||
implementation('net.sf.jopt-simple:jopt-simple:5.0.4') { version { strictly '5.0.4' } }
|
||||
}
|
||||
|
||||
// for some reason mixin plugin does not add 'MixinConfigs' to MANIFEST.MF so we do it manually
|
||||
jar {
|
||||
manifest {
|
||||
attributes([
|
||||
'MixinConfigs': "${mod_id}.mixins.json"
|
||||
])
|
||||
}
|
||||
}
|
||||
|
||||
sourceSets.each {
|
||||
def dir = layout.buildDirectory.dir("sourcesSets/$it.name")
|
||||
it.output.resourcesDir = dir
|
||||
it.java.destinationDirectory = dir
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package net.lionarius.skinrestorer.forge;
|
||||
|
||||
import net.lionarius.skinrestorer.SkinRestorer;
|
||||
import net.lionarius.skinrestorer.command.SkinCommand;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.event.RegisterCommandsEvent;
|
||||
import net.minecraftforge.event.server.ServerStartedEvent;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
|
||||
@Mod(SkinRestorer.MOD_ID)
|
||||
@Mod.EventBusSubscriber(modid = SkinRestorer.MOD_ID)
|
||||
public final class SkinRestorerForge {
|
||||
|
||||
public SkinRestorerForge() {
|
||||
MinecraftForge.EVENT_BUS.register(SkinRestorerForge.class);
|
||||
|
||||
SkinRestorer.onInitialize();
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public static void onCommandRegister(RegisterCommandsEvent event) {
|
||||
SkinCommand.register(event.getDispatcher());
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public static void onServerStarted(ServerStartedEvent event) {
|
||||
SkinRestorer.onServerStarted(event.getServer());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package net.lionarius.skinrestorer.forge.platform;
|
||||
|
||||
import net.lionarius.skinrestorer.platform.services.PlatformHelper;
|
||||
import net.minecraftforge.fml.ModList;
|
||||
import net.minecraftforge.fml.loading.FMLPaths;
|
||||
|
||||
import java.nio.file.Path;
|
||||
|
||||
public final class ForgePlatformHelper implements PlatformHelper {
|
||||
@Override
|
||||
public String getPlatformName() {
|
||||
return "forge";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isModLoaded(String modId) {
|
||||
return ModList.get().isLoaded(modId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Path getConfigDirectory() {
|
||||
return FMLPaths.CONFIGDIR.get();
|
||||
}
|
||||
}
|
||||
27
forge/src/main/resources/META-INF/mods.toml
Normal file
27
forge/src/main/resources/META-INF/mods.toml
Normal file
@@ -0,0 +1,27 @@
|
||||
modLoader = "javafml"
|
||||
loaderVersion = "${forge_loader_version_range}"
|
||||
license = "${license}"
|
||||
issueTrackerURL = "${mod_issues}"
|
||||
|
||||
[[mods]]
|
||||
modId = "${mod_id}"
|
||||
version = "${version}"
|
||||
displayName = "${mod_name}"
|
||||
authors = "${mod_author}"
|
||||
logoFile = "assets/${mod_id}/icon.png"
|
||||
displayURL = "${mod_homepage}"
|
||||
description = '''${description}'''
|
||||
|
||||
[[dependencies.${mod_id}]]
|
||||
modId = "forge"
|
||||
mandatory = true
|
||||
versionRange = "[${forge_version},)"
|
||||
ordering = "NONE"
|
||||
side = "BOTH"
|
||||
|
||||
[[dependencies.${mod_id}]]
|
||||
modId = "minecraft"
|
||||
mandatory = true
|
||||
versionRange = "${minecraft_version_range}"
|
||||
ordering = "NONE"
|
||||
side = "BOTH"
|
||||
@@ -0,0 +1 @@
|
||||
net.lionarius.skinrestorer.forge.platform.ForgePlatformHelper
|
||||
@@ -1,33 +1,43 @@
|
||||
# Done to increase the memory available to gradle.
|
||||
org.gradle.jvmargs=-Xmx1G
|
||||
org.gradle.parallel=true
|
||||
# Project
|
||||
group=net.lionarius.skinrestorer
|
||||
java_version=17
|
||||
|
||||
# Mod Properties
|
||||
mod_version=2.0.1
|
||||
# Common
|
||||
minecraft_version=1.20
|
||||
minecraft_version_list=1.20,1.20.1
|
||||
minecraft_version_range=[1.20, 1.20.1]
|
||||
mod_id=skinrestorer
|
||||
minecraft_version=1.20.5
|
||||
enabled_platforms=fabric,neoforge
|
||||
maven_group=net.lionarius
|
||||
archives_name=skin-restorer
|
||||
capitalized_name=SkinRestorer
|
||||
mod_name=SkinRestorer
|
||||
mod_version=2.1.0
|
||||
mod_author=Lionarius
|
||||
mod_homepage=https://modrinth.com/mod/skinrestorer
|
||||
mod_sources=https://github.com/Suiranoil/SkinRestorer
|
||||
mod_issues=https://github.com/Suiranoil/SkinRestorer/issues
|
||||
license=MIT
|
||||
credits=
|
||||
description=A server-side mod for managing skins.
|
||||
|
||||
# Mappings
|
||||
#yarn_mappings=1.21+build.4
|
||||
#yarn_mappings_patch_neoforge_version=1.21+build.4
|
||||
parchment_minecraft_version=1.20.6
|
||||
parchment_mappings=2024.06.16
|
||||
# ParchmentMC mappings, see https://parchmentmc.org/docs/getting-started#choose-a-version for new versions
|
||||
parchment_minecraft=1.20.1
|
||||
parchment_version=2023.09.03
|
||||
|
||||
# Fabric
|
||||
fabric_loader_version=0.15.10
|
||||
# Fabric, see https://fabricmc.net/develop/ for new versions
|
||||
fabric_loader_version=0.15.0
|
||||
|
||||
# NeoForge
|
||||
neoforge_loader_version=20.5.0-beta
|
||||
# Forge, see https://files.minecraftforge.net/net/minecraftforge/forge/ for new versions
|
||||
forge_version=46.0.1
|
||||
forge_loader_version_range=[46,)
|
||||
# Forge sometimes skips minor minecraft versions (like 1.20.5)
|
||||
forge_minecraft_version=1.20
|
||||
|
||||
# Publish
|
||||
modrinth_id=ghrZDhGW
|
||||
# NeoForge, see https://projects.neoforged.net/neoforged/neoforge for new versions
|
||||
neoforge_version=20.2.3-beta
|
||||
neoforge_loader_version_range=[1,)
|
||||
|
||||
# Publishing
|
||||
curseforge_id=443823
|
||||
game_versions=1.20.5,1.20.6
|
||||
mod_loaders=fabric,neoforge
|
||||
modrinth_id=ghrZDhGW
|
||||
|
||||
# Changelog Options
|
||||
changelog_max_commit_search=200
|
||||
# Gradle
|
||||
org.gradle.jvmargs=-Xmx3G
|
||||
org.gradle.daemon=false
|
||||
|
||||
@@ -1,56 +1,42 @@
|
||||
plugins {
|
||||
id "com.github.johnrengelman.shadow"
|
||||
id 'multiloader-loader'
|
||||
id 'idea'
|
||||
id 'eclipse'
|
||||
|
||||
id 'net.neoforged.gradle.userdev'
|
||||
|
||||
id 'multiloader-publish'
|
||||
}
|
||||
|
||||
architectury {
|
||||
platformSetupLoomIde()
|
||||
neoForge()
|
||||
// Automatically enable neoforge AccessTransformers if the file exists
|
||||
def at = project(':common').file('src/main/resources/META-INF/accesstransformer.cfg')
|
||||
if (at.exists()) {
|
||||
minecraft.accessTransformers.file(at)
|
||||
}
|
||||
|
||||
configurations {
|
||||
common {
|
||||
canBeResolved = true
|
||||
canBeConsumed = false
|
||||
}
|
||||
compileClasspath.extendsFrom common
|
||||
runtimeClasspath.extendsFrom common
|
||||
developmentNeoForge.extendsFrom common
|
||||
|
||||
// Files in this configuration will be bundled into your mod using the Shadow plugin.
|
||||
// Don"t use the `shadow` configuration from the plugin itself as it"s meant for excluding files.
|
||||
shadowBundle {
|
||||
canBeResolved = true
|
||||
canBeConsumed = false
|
||||
subsystems {
|
||||
parchment {
|
||||
minecraftVersion = parchment_minecraft
|
||||
mappingsVersion = parchment_version
|
||||
}
|
||||
}
|
||||
|
||||
repositories {
|
||||
maven {
|
||||
name = "NeoForged"
|
||||
url = "https://maven.neoforged.net/releases"
|
||||
runs {
|
||||
configureEach {
|
||||
modSource project.sourceSets.main
|
||||
systemProperty 'neoforge.enabledGameTestNamespaces', project.mod_id
|
||||
}
|
||||
|
||||
client {
|
||||
workingDirectory = file('../run/client')
|
||||
}
|
||||
|
||||
server {
|
||||
programArgument '--nogui'
|
||||
workingDirectory = file('../run/server')
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
neoForge "net.neoforged:neoforge:$rootProject.neoforge_loader_version"
|
||||
|
||||
common(project(path: ":common", configuration: "namedElements")) { transitive false }
|
||||
shadowBundle project(path: ":common", configuration: "transformProductionNeoForge")
|
||||
}
|
||||
|
||||
processResources {
|
||||
inputs.property "version", project.version
|
||||
|
||||
filesMatching("META-INF/neoforge.mods.toml") {
|
||||
expand version: project.version
|
||||
}
|
||||
}
|
||||
|
||||
shadowJar {
|
||||
configurations = [project.configurations.shadowBundle]
|
||||
archiveClassifier = "dev-shadow"
|
||||
}
|
||||
|
||||
remapJar {
|
||||
input.set shadowJar.archiveFile
|
||||
implementation "net.neoforged:neoforge:${neoforge_version}"
|
||||
}
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
loom.platform = neoforge
|
||||
@@ -3,21 +3,19 @@ package net.lionarius.skinrestorer.neoforge;
|
||||
import net.lionarius.skinrestorer.SkinRestorer;
|
||||
import net.lionarius.skinrestorer.command.SkinCommand;
|
||||
import net.neoforged.bus.api.SubscribeEvent;
|
||||
import net.neoforged.fml.common.EventBusSubscriber;
|
||||
import net.neoforged.fml.common.Mod;
|
||||
import net.neoforged.fml.loading.FMLPaths;
|
||||
import net.neoforged.neoforge.common.NeoForge;
|
||||
import net.neoforged.neoforge.event.RegisterCommandsEvent;
|
||||
import net.neoforged.neoforge.event.server.ServerStartedEvent;
|
||||
|
||||
@Mod(SkinRestorer.MOD_ID)
|
||||
@EventBusSubscriber(modid = SkinRestorer.MOD_ID)
|
||||
@Mod.EventBusSubscriber(modid = SkinRestorer.MOD_ID)
|
||||
public final class SkinRestorerNeoForge {
|
||||
|
||||
public SkinRestorerNeoForge() {
|
||||
NeoForge.EVENT_BUS.register(SkinRestorerNeoForge.class);
|
||||
|
||||
SkinRestorer.onInitialize(FMLPaths.CONFIGDIR.get());
|
||||
SkinRestorer.onInitialize();
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
package net.lionarius.skinrestorer.neoforge.platform;
|
||||
|
||||
import net.lionarius.skinrestorer.platform.services.PlatformHelper;
|
||||
import net.neoforged.fml.ModList;
|
||||
import net.neoforged.fml.loading.FMLPaths;
|
||||
|
||||
import java.nio.file.Path;
|
||||
|
||||
public final class NeoForgePlatformHelper implements PlatformHelper {
|
||||
@Override
|
||||
public String getPlatformName() {
|
||||
return "neoforge";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isModLoaded(String modId) {
|
||||
return ModList.get().isLoaded(modId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Path getConfigDirectory() {
|
||||
return FMLPaths.CONFIGDIR.get();
|
||||
}
|
||||
}
|
||||
30
neoforge/src/main/resources/META-INF/mods.toml
Normal file
30
neoforge/src/main/resources/META-INF/mods.toml
Normal file
@@ -0,0 +1,30 @@
|
||||
modLoader = "javafml"
|
||||
loaderVersion = "${neoforge_loader_version_range}"
|
||||
license = "${license}"
|
||||
issueTrackerURL = "${mod_issues}"
|
||||
|
||||
[[mods]]
|
||||
modId = "${mod_id}"
|
||||
version = "${version}"
|
||||
displayName = "${mod_name}"
|
||||
authors = "${mod_author}"
|
||||
logoFile = "assets/${mod_id}/icon.png"
|
||||
displayURL = "${mod_homepage}"
|
||||
description = "${description}"
|
||||
|
||||
[[mixins]]
|
||||
config = "${mod_id}.mixins.json"
|
||||
|
||||
[[dependencies.${mod_id}]]
|
||||
modId = "neoforge"
|
||||
mandatory = true
|
||||
versionRange = "[${neoforge_version},)"
|
||||
ordering = "NONE"
|
||||
side = "BOTH"
|
||||
|
||||
[[dependencies.${mod_id}]]
|
||||
modId = "minecraft"
|
||||
mandatory = true
|
||||
versionRange = "${minecraft_version_range}"
|
||||
ordering = "NONE"
|
||||
side = "BOTH"
|
||||
@@ -1,32 +0,0 @@
|
||||
modLoader = "javafml"
|
||||
loaderVersion = "[2,)"
|
||||
issueTrackerURL = "https://github.com/Suiranoil/SkinRestorer/issues"
|
||||
license = "MIT"
|
||||
|
||||
[[mods]]
|
||||
modId = "skinrestorer"
|
||||
version = "${version}"
|
||||
displayName = "SkinRestorer"
|
||||
authors = "Lionarius"
|
||||
logoFile = "assets/skinrestorer/icon.png"
|
||||
displayURL = "https://modrinth.com/mod/skinrestorer"
|
||||
description = '''
|
||||
A server-side mod for restoring skins on offline servers.
|
||||
'''
|
||||
|
||||
[[dependencies.skinrestorer]]
|
||||
modId = "neoforge"
|
||||
type = "required"
|
||||
versionRange = "[20.5.0-beta,)"
|
||||
ordering = "NONE"
|
||||
side = "BOTH"
|
||||
|
||||
[[dependencies.skinrestorer]]
|
||||
modId = "minecraft"
|
||||
type = "required"
|
||||
versionRange = "[1.20.5,1.20.6]"
|
||||
ordering = "NONE"
|
||||
side = "BOTH"
|
||||
|
||||
[[mixins]]
|
||||
config = "skinrestorer-common.mixins.json"
|
||||
@@ -0,0 +1 @@
|
||||
net.lionarius.skinrestorer.neoforge.platform.NeoForgePlatformHelper
|
||||
@@ -1,24 +1,75 @@
|
||||
pluginManagement {
|
||||
repositories {
|
||||
maven {
|
||||
name = "Architectury"
|
||||
url = "https://maven.architectury.dev/"
|
||||
}
|
||||
maven {
|
||||
name = "Fabric"
|
||||
url = "https://maven.fabricmc.net/"
|
||||
}
|
||||
maven {
|
||||
name = "Forge"
|
||||
url = "https://files.minecraftforge.net/maven/"
|
||||
}
|
||||
mavenCentral()
|
||||
gradlePluginPortal()
|
||||
mavenCentral()
|
||||
exclusiveContent {
|
||||
forRepository {
|
||||
maven {
|
||||
name = 'Fabric'
|
||||
url = 'https://maven.fabricmc.net'
|
||||
}
|
||||
}
|
||||
filter {
|
||||
includeGroupAndSubgroups('net.fabricmc')
|
||||
includeGroupAndSubgroups('fabric-loom')
|
||||
}
|
||||
}
|
||||
exclusiveContent {
|
||||
forRepository {
|
||||
maven {
|
||||
name = 'Forge'
|
||||
url = 'https://maven.minecraftforge.net'
|
||||
}
|
||||
}
|
||||
filter {
|
||||
includeGroupAndSubgroups('net.minecraftforge')
|
||||
}
|
||||
}
|
||||
exclusiveContent {
|
||||
forRepository {
|
||||
maven {
|
||||
name = 'NeoForge'
|
||||
url = 'https://maven.neoforged.net/releases'
|
||||
}
|
||||
}
|
||||
filter {
|
||||
includeGroupAndSubgroups('net.neoforged')
|
||||
includeGroupAndSubgroups('codechicken')
|
||||
}
|
||||
}
|
||||
exclusiveContent {
|
||||
forRepository {
|
||||
maven {
|
||||
name = 'Sponge'
|
||||
url = 'https://repo.spongepowered.org/repository/maven-public'
|
||||
}
|
||||
}
|
||||
filter {
|
||||
includeGroupAndSubgroups('org.spongepowered')
|
||||
}
|
||||
}
|
||||
exclusiveContent {
|
||||
forRepository {
|
||||
maven {
|
||||
name = 'ParchmentMC'
|
||||
url = 'https://maven.parchmentmc.org'
|
||||
}
|
||||
}
|
||||
filter {
|
||||
includeGroupAndSubgroups('org.parchmentmc')
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
rootProject.name = "skin-restorer"
|
||||
plugins {
|
||||
id 'org.gradle.toolchains.foojay-resolver-convention' version '0.8.0'
|
||||
}
|
||||
|
||||
include "common"
|
||||
include "fabric"
|
||||
include "neoforge"
|
||||
// This should match the folder name of the project, or else IDEA may complain (see https://youtrack.jetbrains.com/issue/IDEA-317606)
|
||||
rootProject.name = 'skin-restorer'
|
||||
include('common')
|
||||
include('fabric')
|
||||
include('forge')
|
||||
// There is no NeoForge for versions <1.20.2
|
||||
// include('neoforge')
|
||||
|
||||
Reference in New Issue
Block a user