mirror of
https://github.com/Suiranoil/SkinRestorer.git
synced 2026-01-16 04:42:12 +00:00
Compare commits
11 Commits
v2.0.2+1.2
...
v2.0.3+1.2
| Author | SHA1 | Date | |
|---|---|---|---|
|
9c9907d0ba
|
|||
|
abcc213ee0
|
|||
|
9e85e78398
|
|||
|
d4efe0a177
|
|||
|
7fcf515790
|
|||
|
4339753271
|
|||
|
251fdce7ff
|
|||
|
5a02ab83e8
|
|||
|
bfd8843b44
|
|||
|
cfdfee11b3
|
|||
|
5c31b5f881
|
@@ -4,6 +4,12 @@ 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
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
### 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
|
||||
- Added `firstJoinSkinProvider` config option (see [wiki](https://github.com/Suiranoil/SkinRestorer/wiki/Config#firstjoinskinprovider))
|
||||
### Fixed
|
||||
- Fixed ability to set config values to `null`
|
||||
|
||||
83
README.md
83
README.md
@@ -1,55 +1,100 @@
|
||||
# SkinRestorer
|
||||
|
||||

|
||||

|
||||
[](https://www.curseforge.com/minecraft/mc-mods/skinrestorer)
|
||||
[](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
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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,7 +3,6 @@ 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;
|
||||
@@ -22,40 +21,44 @@ import java.util.concurrent.CompletableFuture;
|
||||
public abstract class ServerLoginPacketListenerImplMixin {
|
||||
|
||||
@Shadow @Nullable
|
||||
private GameProfile authenticatedProfile;
|
||||
private GameProfile gameProfile;
|
||||
|
||||
@Unique
|
||||
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);
|
||||
assert gameProfile != null;
|
||||
var originalSkin = PlayerUtils.getPlayerSkin(gameProfile);
|
||||
|
||||
if (SkinRestorer.getSkinStorage().hasSavedSkin(authenticatedProfile.getId())) {
|
||||
if (SkinRestorer.getSkinStorage().hasSavedSkin(gameProfile.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(gameProfile.getId());
|
||||
SkinRestorer.getSkinStorage().setSkin(gameProfile.getId(), value.setOriginalValue(originalSkin));
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
if (originalSkin == null && SkinRestorer.getConfig().fetchSkinOnFirstJoin()) {
|
||||
SkinRestorer.LOGGER.debug("Fetching {}'s skin", authenticatedProfile.getName());
|
||||
SkinRestorer.LOGGER.debug("Fetching {}'s skin", gameProfile.getName());
|
||||
|
||||
var context = new SkinProviderContext(MojangSkinProvider.PROVIDER_NAME, authenticatedProfile.getName(), null);
|
||||
var context = new SkinProviderContext(
|
||||
SkinRestorer.getConfig().getFirstJoinSkinProvider().getName(),
|
||||
gameProfile.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);
|
||||
SkinRestorer.getSkinStorage().setSkin(gameProfile.getId(), value);
|
||||
} else {
|
||||
SkinRestorer.LOGGER.warn("failed to fetch skin on first join", result.getErrorValue());
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ public final class JsonUtils {
|
||||
|
||||
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");
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@ 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.*;
|
||||
|
||||
@@ -66,12 +67,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();
|
||||
@@ -91,7 +100,7 @@ public final class PlayerUtils {
|
||||
|
||||
public 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));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -20,8 +20,6 @@ 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
|
||||
|
||||
@@ -3,15 +3,15 @@
|
||||
|
||||
# Project
|
||||
group=net.lionarius.skinrestorer
|
||||
java_version=21
|
||||
java_version=17
|
||||
|
||||
# Common
|
||||
minecraft_version=1.20.5
|
||||
minecraft_version_list=1.20.5,1.20.6
|
||||
minecraft_version_range=[1.20.5,1.20.6]
|
||||
minecraft_version=1.20
|
||||
minecraft_version_list=1.20,1.20.1
|
||||
minecraft_version_range=[1.20, 1.20.1]
|
||||
mod_id=skinrestorer
|
||||
mod_name=SkinRestorer
|
||||
mod_version=2.0.2
|
||||
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
|
||||
@@ -21,21 +21,21 @@ credits=
|
||||
description=A server-side mod for managing skins.
|
||||
|
||||
# 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
|
||||
parchment_minecraft=1.20.1
|
||||
parchment_version=2023.09.03
|
||||
|
||||
# Fabric, see https://fabricmc.net/develop/ for new versions
|
||||
fabric_loader_version=0.15.0
|
||||
|
||||
# Forge, see https://files.minecraftforge.net/net/minecraftforge/forge/ for new versions
|
||||
forge_version=50.0.0
|
||||
forge_loader_version_range=[50,)
|
||||
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.6
|
||||
forge_minecraft_version=1.20
|
||||
|
||||
# NeoForge, see https://projects.neoforged.net/neoforged/neoforge for new versions
|
||||
neoforge_version=20.5.0-beta
|
||||
neoforge_loader_version_range=[3,)
|
||||
neoforge_version=20.2.3-beta
|
||||
neoforge_loader_version_range=[1,)
|
||||
|
||||
# Publishing
|
||||
curseforge_id=443823
|
||||
|
||||
@@ -3,7 +3,6 @@ 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;
|
||||
@@ -11,7 +10,7 @@ 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() {
|
||||
|
||||
@@ -17,14 +17,14 @@ config = "${mod_id}.mixins.json"
|
||||
|
||||
[[dependencies.${mod_id}]]
|
||||
modId = "neoforge"
|
||||
type = "required"
|
||||
mandatory = true
|
||||
versionRange = "[${neoforge_version},)"
|
||||
ordering = "NONE"
|
||||
side = "BOTH"
|
||||
|
||||
[[dependencies.${mod_id}]]
|
||||
modId = "minecraft"
|
||||
type = "required"
|
||||
mandatory = true
|
||||
versionRange = "${minecraft_version_range}"
|
||||
ordering = "NONE"
|
||||
side = "BOTH"
|
||||
@@ -71,4 +71,5 @@ rootProject.name = 'skin-restorer'
|
||||
include('common')
|
||||
include('fabric')
|
||||
include('forge')
|
||||
include('neoforge')
|
||||
// There is no NeoForge for versions <1.20.2
|
||||
// include('neoforge')
|
||||
|
||||
Reference in New Issue
Block a user