1
0
mirror of https://github.com/Suiranoil/SkinRestorer.git synced 2026-01-16 04:42:12 +00:00

Compare commits

...

47 Commits

Author SHA1 Message Date
49290171e2 Merge branch 'refs/heads/1.21-multiloader' into 1.20.5-multiloader 2024-08-20 13:50:52 +03:00
abcc213ee0 bump version 2024-08-20 13:49:00 +03:00
9e85e78398 update changelog 2024-08-20 13:43:00 +03:00
d4efe0a177 update README.md 2024-08-20 13:41:48 +03:00
7fcf515790 verify and fix config 2024-08-20 13:14:39 +03:00
4339753271 add aliases for FirstJoinSkinProvider 2024-08-20 13:13:32 +03:00
251fdce7ff allow to configure skin provider for first join skin fetching 2024-08-20 12:41:44 +03:00
5a02ab83e8 Update README.md 2024-08-06 15:29:02 +03:00
b72d0c1e85 backport to 1.20.5-1.20.6 2024-08-04 02:36:26 +03:00
067cd5c731 fix incorrect modrinth token name 2024-08-04 02:36:12 +03:00
1eed415053 allow manual trigger for release workflow 2024-08-04 02:26:48 +03:00
42cef73318 fix release workflow 2024-08-04 02:20:41 +03:00
266d56ed93 dont run build workflow on tag push 2024-08-04 02:19:46 +03:00
423ee4e694 update changelog 2024-08-04 00:23:40 +03:00
7cf5b8e1d6 bump version 2024-08-04 00:22:42 +03:00
e9bdfaefca run release workflow on version tag push 2024-08-04 00:12:38 +03:00
e1773d4d79 add java dependency for fabric 2024-08-04 00:05:01 +03:00
84da16fae6 use System.currentTimeMillis() instead of Date.getTime() 2024-08-03 23:30:51 +03:00
ac9189ecdc remove publishing to github 2024-08-03 23:20:17 +03:00
7131cb76d0 add forge_minecraft_version property 2024-08-03 15:39:10 +03:00
4943c7d8f6 add links to new versions of loaders 2024-08-03 15:30:47 +03:00
82baf0b63e use neoforge gradle 2024-08-03 10:41:00 +03:00
c755417ebf update github actions 2024-08-01 18:48:28 +03:00
6cf7d0c465 use fabric loom in common project 2024-08-01 18:00:45 +03:00
20feec931f formatting 2024-08-01 16:13:23 +03:00
73ffc37f2d fix mixins not working on forge 2024-08-01 14:41:41 +03:00
726f4ed7a8 loosen fabric loader version to 0.15.0 2024-08-01 09:05:58 +03:00
fbbc37e4b1 add mod_homepage, mod_sources and mod_issues to properties 2024-07-31 21:33:19 +03:00
19114de347 fix wrong job id for release workflow 2024-07-31 20:41:47 +03:00
455d0deddc dont run build workflow when source is not changed 2024-07-31 20:38:21 +03:00
0eaaf6a950 fix mod release workflow 2024-07-31 20:29:32 +03:00
7c8aba6f71 add mod release workflow 2024-07-31 20:28:25 +03:00
99675bb5ee add mod publishing gradle task 2024-07-31 20:28:04 +03:00
6ad656c388 separate mod version from project version 2024-07-31 20:05:50 +03:00
fece751f0f add CHANGELOG.md 2024-07-31 20:03:38 +03:00
ab75eddc90 update github workflow 2024-07-31 17:43:38 +03:00
f9aa3f664a add pack.mcmeta 2024-07-31 17:13:14 +03:00
9edbb21128 use multiloader template 2024-07-31 16:30:19 +03:00
4851687fc9 bump version 2024-07-16 19:55:29 +03:00
7bceb0d5ed log "failed to fetch skin on first join" as warning 2024-07-16 19:53:27 +03:00
65957b61c5 fix concurrent modification 2024-07-16 19:51:45 +03:00
Suiranoil
8c3d1fe831 Merge pull request #24 from yichifauzi/1.21-architectury
- Added Traditional Chinese (zh_tw.json)

Co-authored-by: notlin4 <121224522+notlin4@users.noreply.github.com>
2024-07-03 22:44:12 +03:00
dirtTW
1dc1789fa4 Apply suggestions from code review
Co-authored-by: notlin4 <121224522+notlin4@users.noreply.github.com>
2024-07-03 17:24:33 +07:00
dirtTW
85a0fa760b Update zh_tw.json 2024-07-03 17:13:57 +07:00
dirtTW
0a00b40655 Added Traditional Chinese (zh_tw.json)
Added Traditional Chinese translations
2024-07-03 17:11:34 +07:00
f98808583d add function to send effects for backporting 2024-07-03 01:48:13 +03:00
21c98a4224 specify parchment minecraft version 2024-07-03 01:30:18 +03:00
33 changed files with 868 additions and 377 deletions

View File

@@ -1,31 +1,41 @@
name: build
on: [ pull_request, push ]
on:
push:
paths-ignore:
- '.github/**'
- '*.md'
tags-ignore:
- '*'
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
View 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

76
CHANGELOG.md Normal file
View File

@@ -0,0 +1,76 @@
# 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.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

4
CHANGELOG_LATEST.md Normal file
View File

@@ -0,0 +1,4 @@
### Added
- Added `firstJoinSkinProvider` config option (see [wiki](https://github.com/Suiranoil/SkinRestorer/wiki/Config#firstjoinskinprovider))
### Fixed
- Fixed ability to set config values to `null`

View File

@@ -1,55 +1,100 @@
# SkinRestorer
![a](https://cf.way2muchnoise.eu/versions/skinrestorer.svg)
![Enviroment](https://img.shields.io/badge/enviroment-server-orangered)
[![CurseForge Downloads](https://cf.way2muchnoise.eu/skinrestorer.svg)](https://www.curseforge.com/minecraft/mc-mods/skinrestorer)
[![Modrinth Downloads](https://img.shields.io/modrinth/dt/skinrestorer?logo=modrinth&label=&suffix=%20&style=flat&color=242629&labelColor=5ca424&logoColor=1c1c1c)](https://modrinth.com/mod/skinrestorer)
<a href="https://www.curseforge.com/minecraft/mc-mods/skinrestorer"><img src="https://raw.githubusercontent.com/Suiranoil/badges/main/assets/minecraft/platform/curseforge/mini/badge.svg" alt="CurseForge" height="32"></a>
<a href="https://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>
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/Config)).
- **Singleplayer support**: Apply skins individually for each world.
- **Permissions API support**
## Command Usage Guide
## 📜 Command Usage Guide
### Set Mojang Skin
### Set Mojang skin
Fetch and apply skins using a valid Minecraft username.
```
/skin set mojang <username> [<targets>]
```
- **Parameters:**
- `<username>`: Minecraft account name to fetch the skin from.
- **Parameters**
- `<username>`: Minecraft username to fetch the skin from.
- `[<targets>]`: (Optional, server operators only) Player(s) to apply the skin to.
### Set Web Skin
### Set Ely.by skin
Fetch and apply skins using a valid [Ely.by](https://ely.by/) username.
```
/skin set ely.by <username> [<targets>]
```
- **Parameters**
- `<username>`: Ely.by username to fetch the skin from.
- `[<targets>]`: (Optional, server operators only) Player(s) to apply the skin to.
### Set Web skin
Fetch and apply skins from any image URL, supporting both classic (Steve) and slim (Alex) skin models.
Uses [mineskin api](https://mineskin.org/) under the hood.
```
/skin set web (classic|slim) "<url>" [<targets>]
```
- **Parameters:**
- **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.
### Clear Skin
### Refresh skin
Refetch and reapply the currently applied skins.
```
/skin refresh [<targets>]
```
- **Parameters**
- `[<targets>]`: (Optional, server operators only) Player(s) to refresh the skin for.
### Clear skin
Remove the currently applied skins.
```
/skin clear [<targets>]
```
- **Parameters:**
- **Parameters**
- `[<targets>]`: (Optional, server operators only) Player(s) to clear the skin for.
### Notes:
### Reset skin
Reset to the default skin or remove any custom skin.
If [automatic skin fetching](https://github.com/Suiranoil/SkinRestorer/wiki/Config#fetchskinonfirstjoin) is enabled, a new skin will be fetched when the player rejoins the server.
```
/skin reset [<targets>]
```
- **Parameters**
- `[<targets>]`: (Optional, server operators only) Player(s) to reset the skin for.
### Notes
- If `targets` is not specified, the command will apply to the player executing the command.
### Examples:
### Examples
```
/skin set mojang Notch

View File

@@ -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.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
View File

@@ -0,0 +1,3 @@
plugins {
id 'groovy-gradle-plugin'
}

View File

@@ -0,0 +1,107 @@
plugins {
id 'java-library'
}
base {
archivesName = "${mod_id}-${project.name}"
version = "${mod_version}+${minecraft_version}"
}
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)
}

View 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)
}

View 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(','))
}
}

View File

@@ -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
View File

@@ -0,0 +1 @@
fabric.loom.dontRemap = true

View File

@@ -21,7 +21,6 @@ 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";

View File

@@ -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;

View File

@@ -15,6 +15,8 @@ public final class Config {
private boolean fetchSkinOnFirstJoin = true;
private FirstJoinSkinProvider firstJoinSkinProvider = FirstJoinSkinProvider.MOJANG;
private String proxy = "";
private long requestTimeout = 10;
@@ -27,6 +29,10 @@ public final class Config {
return this.fetchSkinOnFirstJoin;
}
public FirstJoinSkinProvider getFirstJoinSkinProvider() {
return this.firstJoinSkinProvider;
}
public String getProxy() {
return this.proxy;
}
@@ -48,8 +54,24 @@ 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())
this.language = "en_us";
if (this.firstJoinSkinProvider == null)
this.firstJoinSkinProvider = FirstJoinSkinProvider.MOJANG;
if (this.proxy == null)
this.proxy = "";
if (this.requestTimeout <= 0)
this.requestTimeout = 10;
}
}

View File

@@ -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;
}
}

View File

@@ -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;
@@ -25,8 +22,6 @@ public abstract class ServerLoginPacketListenerImplMixin {
@Shadow @Nullable
private GameProfile authenticatedProfile;
@Shadow @Final
MinecraftServer server;
@Unique
private CompletableFuture<Void> skinrestorer_pendingSkin;
@@ -52,7 +47,11 @@ public abstract class ServerLoginPacketListenerImplMixin {
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 context = new SkinProviderContext(
SkinRestorer.getConfig().getFirstJoinSkinProvider().getName(),
authenticatedProfile.getName(),
null
);
var result = SkinRestorer.getProvider(context.name()).map(
provider -> provider.getSkin(context.argument(), context.variant())
).orElse(Result.ofNullable(null));
@@ -61,7 +60,7 @@ public abstract class ServerLoginPacketListenerImplMixin {
var value = SkinValue.fromProviderContextWithValue(context, result.getSuccessValue().orElse(null));
SkinRestorer.getSkinStorage().setSkin(authenticatedProfile.getId(), value);
} else {
SkinRestorer.LOGGER.error("failed to fetch skin on first join", result.getErrorValue());
SkinRestorer.LOGGER.warn("failed to fetch skin on first join", result.getErrorValue());
}
}

View File

@@ -13,10 +13,7 @@ import net.minecraft.server.level.ServerLevel;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.server.players.PlayerList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
import java.util.*;
public final class PlayerUtils {
@@ -54,7 +51,8 @@ public final class PlayerUtils {
var trackedEntity = (TrackedEntityMixin) ((ChunkMapAccessor) chunkMap).getEntityMap().get(player.getId());
if (trackedEntity != null) {
for (var observerConnection : trackedEntity.getSeenBy()) {
var seenBy = Set.copyOf(trackedEntity.getSeenBy());
for (var observerConnection : seenBy) {
var observer = observerConnection.getPlayer();
trackedEntity.invokeRemovePlayer(observer);
@@ -87,7 +85,13 @@ public final class PlayerUtils {
playerList.sendPlayerPermissionLevel(player);
playerList.sendLevelInfo(player, serverLevel);
playerList.sendAllPlayerInfo(player);
playerList.sendActivePlayerEffects(player);
PlayerUtils.sendActivePlayerEffects(player);
}
}
public static void sendActivePlayerEffects(ServerPlayer player) {
for (var effect : player.getActiveEffects()) {
player.connection.send(new ClientboundUpdateMobEffectPacket(player.getId(), effect, false));
}
}

View File

@@ -19,8 +19,7 @@ public final class WebUtils {
public static final String USER_AGENT;
static {
var date = new Date();
USER_AGENT = String.format("SkinRestorer/%d", date.getTime() % 65535);
USER_AGENT = String.format("SkinRestorer/%d", System.currentTimeMillis() % 65535);
var builder = HttpClient.newBuilder();
var proxy = SkinRestorer.getConfig().getProxy();

View File

@@ -0,0 +1,7 @@
{
"skinrestorer.command.skin.affected_players": "已變更 %s 的外觀",
"skinrestorer.command.skin.no_changes": "沒有外觀變更",
"skinrestorer.command.skin.failed": "變更外觀失敗:%s",
"skinrestorer.command.skin.ok": "已變更外觀",
"skinrestorer.command.skin.loading": "正在載入外觀..."
}

View File

@@ -0,0 +1,6 @@
{
"pack": {
"description": "${mod_id}",
"pack_format": 8
}
}

View File

@@ -3,6 +3,7 @@
"minVersion": "0.8",
"package": "net.lionarius.skinrestorer.mixin",
"compatibilityLevel": "JAVA_8",
"refmap": "${mod_id}.refmap.json",
"mixins": [
"PlayerListMixin",
"ServerLoginPacketListenerImplMixin",

View File

@@ -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
}

View File

@@ -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.21"
"fabricloader": ">=${fabric_loader_version}",
"minecraft": ">=${minecraft_version}",
"java": ">=${java_version}"
}
}

View File

@@ -3,6 +3,7 @@
"minVersion": "0.8",
"package": "net.lionarius.skinrestorer.fabric.mixin",
"compatibilityLevel": "JAVA_8",
"refmap": "${mod_id}.refmap.json",
"mixins": [
"CommandsMixin",
"MinecraftServerMixin"

78
forge/build.gradle Normal file
View File

@@ -0,0 +1,78 @@
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
reobf = false // Forge 1.20.6+ uses official mappings at runtime, so we shouldn't reobf from official to SRG
// Automatically enable forge AccessTransformers if the file exists
// 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
}

View File

@@ -0,0 +1,31 @@
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;
import net.minecraftforge.fml.loading.FMLPaths;
@Mod(SkinRestorer.MOD_ID)
@Mod.EventBusSubscriber(modid = SkinRestorer.MOD_ID)
public final class SkinRestorerForge {
public SkinRestorerForge() {
MinecraftForge.EVENT_BUS.register(SkinRestorerForge.class);
SkinRestorer.onInitialize(FMLPaths.CONFIGDIR.get());
}
@SubscribeEvent
public static void onCommandRegister(RegisterCommandsEvent event) {
SkinCommand.register(event.getDispatcher());
}
@SubscribeEvent
public static void onServerStarted(ServerStartedEvent event) {
SkinRestorer.onServerStarted(event.getServer());
}
}

View 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"

View File

@@ -1,32 +1,46 @@
# Done to increase the memory available to gradle.
org.gradle.jvmargs=-Xmx1G
org.gradle.parallel=true
# Important Notes:
# Every field you add must be added to the root build.gradle expandProps map.
# Mod Properties
mod_version=2.0.0
# Project
group=net.lionarius.skinrestorer
java_version=21
# Common
minecraft_version=1.20.5
minecraft_version_list=1.20.5,1.20.6
minecraft_version_range=[1.20.5,1.20.6]
mod_id=skinrestorer
minecraft_version=1.21
enabled_platforms=fabric,neoforge
maven_group=net.lionarius
archives_name=skin-restorer
capitalized_name=SkinRestorer
mod_name=SkinRestorer
mod_version=2.0.3
mod_author=Lionarius
mod_homepage=https://www.curseforge.com/minecraft/mc-mods/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_mappings=2024.06.23
# ParchmentMC mappings, see https://parchmentmc.org/docs/getting-started#choose-a-version for new versions
parchment_minecraft=1.20.6
parchment_version=2024.06.16
# Fabric
fabric_loader_version=0.15.11
# Fabric, see https://fabricmc.net/develop/ for new versions
fabric_loader_version=0.15.0
# NeoForge
neoforge_loader_version=21.0.0-beta
# Forge, see https://files.minecraftforge.net/net/minecraftforge/forge/ for new versions
forge_version=50.0.0
forge_loader_version_range=[50,)
# Forge sometimes skips minor minecraft versions (like 1.20.5)
forge_minecraft_version=1.20.6
# Publish
modrinth_id=ghrZDhGW
# NeoForge, see https://projects.neoforged.net/neoforged/neoforge for new versions
neoforge_version=20.5.0-beta
neoforge_loader_version_range=[3,)
# Publishing
curseforge_id=443823
game_versions=1.21
mod_loaders=fabric,neoforge
modrinth_id=ghrZDhGW
# Changelog Options
changelog_max_commit_search=200
# Gradle
org.gradle.jvmargs=-Xmx3G
org.gradle.daemon=false

View File

@@ -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}"
}

View File

@@ -1 +0,0 @@
loom.platform = neoforge

View File

@@ -1,32 +1,30 @@
modLoader = "javafml"
loaderVersion = "[2,)"
issueTrackerURL = "https://github.com/Suiranoil/SkinRestorer/issues"
license = "MIT"
loaderVersion = "${neoforge_loader_version_range}"
license = "${license}"
issueTrackerURL = "${mod_issues}"
[[mods]]
modId = "skinrestorer"
modId = "${mod_id}"
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 = "[21.0.0-beta,)"
ordering = "NONE"
side = "BOTH"
[[dependencies.skinrestorer]]
modId = "minecraft"
type = "required"
versionRange = "[1.21,)"
ordering = "NONE"
side = "BOTH"
displayName = "${mod_name}"
authors = "${mod_author}"
logoFile = "assets/${mod_id}/icon.png"
displayURL = "${mod_homepage}"
description = "${description}"
[[mixins]]
config = "skinrestorer-common.mixins.json"
config = "${mod_id}.mixins.json"
[[dependencies.${mod_id}]]
modId = "neoforge"
type = "required"
versionRange = "[${neoforge_version},)"
ordering = "NONE"
side = "BOTH"
[[dependencies.${mod_id}]]
modId = "minecraft"
type = "required"
versionRange = "${minecraft_version_range}"
ordering = "NONE"
side = "BOTH"

View File

@@ -1,24 +1,74 @@
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')
include('neoforge')