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

Compare commits

...

71 Commits

Author SHA1 Message Date
d471eb2e5f Merge branch '1.20.3-multiloader' into 1.20.2-multiloader 2025-03-27 18:34:36 +03:00
138350545a Merge branch '1.20.5-multiloader' into 1.20.3-multiloader 2025-03-27 18:33:47 +03:00
7ab9f722e8 Merge branch '1.21-multiloader' into 1.20.5-multiloader 2025-03-27 18:32:56 +03:00
5c2a50fd98 Merge branch '1.21.5-multiloader' into 1.21-multiloader 2025-03-27 18:31:05 +03:00
088ad089ed do not use google collections method to create queue 2025-03-27 18:28:50 +03:00
6fbc53e38b allow canceling tasks by id 2025-03-27 18:25:41 +03:00
364ca540be make TickedScheduler track task id and schedule time 2025-03-27 18:25:27 +03:00
cec5bac608 fix main thread blocking 2025-03-27 17:19:41 +03:00
2a3c3d0f54 Merge branch '1.20.3-multiloader' into 1.20.2-multiloader 2025-03-27 12:47:00 +03:00
040d26cb33 Merge branch '1.20.5-multiloader' into 1.20.3-multiloader 2025-03-27 12:46:54 +03:00
ef79818d5c Merge branch '1.21-multiloader' into 1.20.5-multiloader 2025-03-27 12:46:45 +03:00
0d4a0034b8 Merge branch '1.21.5-multiloader' into 1.21-multiloader 2025-03-27 12:46:37 +03:00
c70f780ec2 update CHANGELOG 2025-03-27 12:46:02 +03:00
ecdfff5dc7 bump version 2025-03-27 12:45:53 +03:00
16ffeea4f3 move uuid into else statement 2025-03-27 12:44:45 +03:00
c8a4674e0c Merge branch '1.20.3-multiloader' into 1.20.2-multiloader 2025-03-26 02:47:09 +03:00
d374c80659 Merge branch '1.20.5-multiloader' into 1.20.3-multiloader 2025-03-26 02:38:36 +03:00
d85942041b drop neoforge 1.20.5-6 support 2025-03-26 02:38:18 +03:00
1cafc91935 Merge branch '1.21-multiloader' into 1.20.5-multiloader
# Conflicts:
#	gradle.properties
2025-03-26 02:32:11 +03:00
5d28269b94 pin max 1.21 version 2025-03-26 02:31:16 +03:00
2293fc2399 Revert "update gradle.properties"
This reverts commit 2e3b2649b3.
2025-03-26 02:26:26 +03:00
3971f2efbf Revert "fix GameProfileRepository interface impl"
This reverts commit 516601a899.
2025-03-26 02:26:25 +03:00
516601a899 fix GameProfileRepository interface impl 2025-03-26 02:23:12 +03:00
2e3b2649b3 update gradle.properties 2025-03-26 02:23:12 +03:00
07d620ae2f use moddev gradle for neoforge 2025-03-26 02:23:11 +03:00
ad2177848c update gradle plugin versions 2025-03-26 02:23:11 +03:00
8136354af1 add skinApplyDelayOnJoin config option (fixes #47 with config) 2025-03-26 02:22:50 +03:00
fee25d2d04 gradle.properties formatting 2025-03-26 02:22:50 +03:00
33926b15e1 add ServerUtils for scheduling server tasks 2025-03-26 02:22:50 +03:00
226d3f7bcb refactor BuiltInProviderConfig to abstract class 2025-03-26 02:22:49 +03:00
c81adc7320 use var in SkinCommand 2025-03-26 02:22:49 +03:00
583e59f9d8 update fabric loom 2025-03-26 02:22:49 +03:00
8081e443b9 update gradle 2025-03-26 02:22:48 +03:00
61e1ada760 add 1.21.4 to supported versions 2025-03-26 02:22:48 +03:00
Suiranoil
d04a3beecf Update README.md 2025-03-05 01:14:47 +03:00
Suiranoil
89b06fcfc7 Update config.yml 2025-02-07 19:11:11 +03:00
Suiranoil
d7fffdab1b Update feature_request.yaml 2025-02-07 19:10:32 +03:00
Suiranoil
9e175ddabb Create feature_request.yaml 2025-02-07 19:09:56 +03:00
Suiranoil
74a571b62c Update bug_report.yaml 2025-02-07 19:05:37 +03:00
Suiranoil
8ae29eae89 Update bug_report.yaml 2025-02-07 19:03:47 +03:00
Suiranoil
9f0fac4b2a Create config.yml 2025-02-07 19:01:03 +03:00
Suiranoil
e68aa90953 Create bug_report.yaml 2025-02-07 18:59:40 +03:00
143e95d7f2 Merge branch '1.20.3-multiloader' into 1.20.2-multiloader 2024-12-23 11:59:42 +03:00
34de47e13e Merge branch '1.20.5-multiloader' into 1.20.3-multiloader 2024-12-23 11:59:36 +03:00
08e7f1792b Merge branch '1.21-multiloader' into 1.20.5-multiloader 2024-12-23 11:59:26 +03:00
6a7f5f2096 bump version 2024-12-23 11:56:02 +03:00
4d6d4faafd update CHANGELOG.md 2024-12-23 11:55:32 +03:00
823b2ea3f6 remove api url in mineskin provider 2024-12-17 09:03:33 +03:00
a63b6c3867 implement GsonPostProcessable for SkinValue 2024-12-11 07:05:53 +03:00
dfe6d7af42 fix date in changelog 2024-12-02 21:40:16 +03:00
ebdbee480f Merge branch '1.20.3-multiloader' into 1.20.2-multiloader 2024-12-02 21:06:14 +03:00
49b2a2fc1e Merge branch '1.20.5-multiloader' into 1.20.3-multiloader 2024-12-02 21:06:08 +03:00
33e5889657 Merge branch '1.20.3-multiloader' into 1.20.2-multiloader 2024-12-02 17:54:39 +03:00
348471b30d actually fix reobf on forge 2024-12-02 17:54:13 +03:00
18ec6e87f8 Merge branch '1.20.3-multiloader' into 1.20.2-multiloader 2024-12-02 12:11:16 +03:00
e52baaef4c Merge branch '1.20.5-multiloader' into 1.20.3-multiloader 2024-12-02 03:39:12 +03:00
4c803cb369 Merge branch '1.20.3-multiloader' into 1.20.2-multiloader 2024-11-30 03:53:15 +03:00
120a8b7e3d fix reobf on forge 2024-11-30 03:49:04 +03:00
cab2ab3239 fix fabric handshake send 2024-11-30 03:48:43 +03:00
95cc551df7 drop neoforge support 2024-11-30 03:48:01 +03:00
3b71911ba0 backport to 1.20.3 2024-11-30 03:03:31 +03:00
7d1d4966b0 Merge branch '1.20.5-multiloader' into 1.20.3-multiloader
# Conflicts:
#	gradle.properties
2024-11-29 11:54:10 +03:00
14f51e9224 Merge branch 'refs/heads/1.20.3-multiloader' into 1.20.2-multiloader 2024-09-25 20:49:17 +03:00
026ceb2337 Merge branch 'refs/heads/1.20.5-multiloader' into 1.20.3-multiloader 2024-09-25 20:49:09 +03:00
1d1aa94644 Merge branch 'refs/heads/1.20.3-multiloader' into 1.20.2-multiloader 2024-09-24 08:16:47 +03:00
3203435453 backport to 1.20.3 2024-09-24 08:12:20 +03:00
8a9802f763 Merge branch 'refs/heads/1.20.5-multiloader' into 1.20.3-multiloader 2024-09-24 08:10:50 +03:00
5ddde27915 Merge branch 'refs/heads/1.21-multiloader' into 1.20.2-multiloader 2024-08-20 13:51:47 +03:00
08b734bb27 Merge branch 'refs/heads/1.21-multiloader' into 1.20.3-multiloader 2024-08-20 13:51:30 +03:00
cfdfee11b3 backport to 1.20.2 2024-08-04 02:36:33 +03:00
5c31b5f881 backport to 1.20.3-1.20.4 2024-08-04 02:36:30 +03:00
42 changed files with 512 additions and 299 deletions

88
.github/ISSUE_TEMPLATE/bug_report.yaml vendored Normal file
View File

@@ -0,0 +1,88 @@
name: Bug Report
description: Report a bug encountered with SkinRestorer
title: "[Bug]: "
labels: ["bug"]
body:
- type: markdown
attributes:
value: |
🐛 **Before submitting:**
- Ensure you're using the latest mod version
- Ensure this bug is reproducible consistently
- Check existing issues for duplicates
- type: input
id: mod-version
attributes:
label: SkinRestorer Version
description: Exact version of the mod
placeholder: e.g., 2.2.1
validations:
required: true
- type: input
id: minecraft-version
attributes:
label: Minecraft Version
description: Full Minecraft version
placeholder: e.g., 1.21.4
validations:
required: true
- type: input
id: loader-version
attributes:
label: Mod Loader & Version
description: Fabric/Quilt/Forge/NeoForge version
placeholder: e.g., Fabric 0.15.7
validations:
required: true
- type: input
id: java-version
attributes:
label: Java Version
placeholder: e.g. 17, 21
validations:
required: true
- type: textarea
id: description
attributes:
label: Bug Description
description: What happened vs what you expected to happen
validations:
required: true
- type: textarea
id: steps
attributes:
label: Reproduction Steps
placeholder: |
1.
2.
3.
validations:
required: true
- type: textarea
id: logs
attributes:
label: Relevant Logs
description: |
Please provide any relevant logs, especially error logs from your server console or `latest.log` file.
**Important**: Paste the FULL log content. Use a service like [mclo.gs](https://mclo.gs/).
render: shell
validations:
required: true
- type: checkboxes
id: confirmations
attributes:
label: Confirmations
options:
- label: I've checked for existing issues
required: true
- label: This bug is reproducible consistently
required: true
- label: I've tested without other mods

1
.github/ISSUE_TEMPLATE/config.yml vendored Normal file
View File

@@ -0,0 +1 @@
blank_issues_enabled: true

View File

@@ -0,0 +1,52 @@
name: Feature Request
description: Suggest a new feature for SkinRestorer
title: "[Feature Request]: "
labels: ["enhancement"]
body:
- type: markdown
attributes:
value: |
💡 **Before submitting:**
- Check existing feature requests for duplicates
- Be clear and concise
- Explain the *why* and the *how*
- type: textarea
id: description
attributes:
label: Feature Description
description: Detailed description of the feature
validations:
required: true
- type: textarea
id: motivation
attributes:
label: Motivation
description: Why is this feature needed? What problem does it solve?
validations:
required: true
- type: textarea
id: use-cases
attributes:
label: Use Cases
description: How would this feature be used and who would benefit?
validations:
required: true
- type: textarea
id: implementation-ideas
attributes:
label: Implementation Ideas (Optional)
description: Any thoughts on how it could be implemented?
validations:
required: false
- type: checkboxes
id: confirmations
attributes:
label: Confirmations
options:
- label: I've checked for existing feature requests
required: true

View File

@@ -4,7 +4,19 @@ 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.2.0] - 2024-11-28
## [2.3.0] - 2025-03-27
### Added
- Added `skinApplyDelayOnJoin` config option (see [wiki](https://github.com/Suiranoil/SkinRestorer/wiki/Configuration#skinapplydelayonjoin))
### Changed
- Updated to 1.21.5
### Removed
- [NeoForge] Dropped support for NeoForge on Minecraft 1.20.5-1.20.6
## [2.2.1] - 2024-12-23
### Fixed
- Fixed game not closing because of mineskin working threads (closes [#41](https://github.com/Suiranoil/SkinRestorer/issues/41))
## [2.2.0] - 2024-12-02
### Added
- Added support for [SkinShuffle](https://modrinth.com/mod/skinshuffle) clients (requires FabricAPI on Fabric)
(closes [#34](https://github.com/Suiranoil/SkinRestorer/issues/34))

View File

@@ -1,10 +1,6 @@
### Added
- Added support for [SkinShuffle](https://modrinth.com/mod/skinshuffle) clients (requires FabricAPI on Fabric)
(closes [#34](https://github.com/Suiranoil/SkinRestorer/issues/34))
- Added `providers.mineskin.apiKey` config option (see [wiki](https://github.com/Suiranoil/SkinRestorer/wiki/Configuration#providersmineskin))
- Added `skinApplyDelayOnJoin` config option (see [wiki](https://github.com/Suiranoil/SkinRestorer/wiki/Configuration#skinapplydelayonjoin))
### Changed
- Migrated to MineSkin's new API V2
### Fixed
- Fixed `providers` config validation
- Updated to 1.21.5
### Removed
- Dropped support for NeoForge on Minecraft 1.20.2-1.20.4
- [NeoForge] Dropped support for NeoForge on Minecraft 1.20.5-1.20.6

View File

@@ -1,7 +1,7 @@
# 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>
<a href="https://modrinth.com/mod/skinrestorer"><img src="https://raw.githubusercontent.com/Suiranoil/badges/main/assets/minecraft/platform/modrinth/mini/badge.svg" alt="Modrinth"></a>
<a href="https://www.curseforge.com/minecraft/mc-mods/skinrestorer"><img src="https://raw.githubusercontent.com/Suiranoil/badges/main/assets/minecraft/platform/curseforge/mini/badge.svg" alt="CurseForge"></a>
A server-side mod for managing and restoring player skins.
@@ -33,7 +33,9 @@ the [commands wiki page](https://github.com/Suiranoil/SkinRestorer/wiki/Commands
If you enjoy using **SkinRestorer** and would like to support its development, you can contribute through the following
platforms:
[![Ko-fi](https://ko-fi.com/img/githubbutton_sm.svg)](https://ko-fi.com/lionarius)
<a href="https://ko-fi.com/lionarius"><img src="https://raw.githubusercontent.com/Suiranoil/badges/main/assets/donation/kofi/mini/badge.svg" alt="Ko-fi" height="32"></a>
<a href="https://boosty.to/lionarius"><img src="https://raw.githubusercontent.com/Suiranoil/badges/main/assets/donation/boosty/mini/badge.svg" alt="Boosty" height="32"></a>
Bitcoin (BTC): `1Ndbwny8pxdnWXFgadp95fp97y5JqMJKTX`
USDT (TRC20): `TGXn8wrqku5KLzwPWQAeH7wgnV4UzwHEae`

View File

@@ -1,15 +1,15 @@
plugins {
// see https://fabricmc.net/develop/ for new versions
id 'fabric-loom' version '1.8-SNAPSHOT' apply false
// see https://projects.neoforged.net/neoforged/neogradle for new versions
id 'net.neoforged.gradle.userdev' version '7.0.153' apply false
id 'fabric-loom' version '1.10-SNAPSHOT' apply false
// see https://projects.neoforged.net/neoforged/moddevgradle for new versions
id 'net.neoforged.moddev' version '2.0.80' apply false
// see https://files.minecraftforge.net/net/minecraftforge/gradle/ForgeGradle/ for new versions
id 'net.minecraftforge.gradle' version '6.0.29' apply false
id 'net.minecraftforge.gradle' version '6.0.35' 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.8.1' apply false
id 'me.modmuss50.mod-publish-plugin' version '0.8.4' apply false
}
allprojects {

View File

@@ -5,6 +5,8 @@ plugins {
publishMods {
if (project.name == 'fabric')
file = remapJar.archiveFile
else if (project.name == 'neoforge')
file = jar.archiveFile
else
file = tasks.named('jarJar').get().archiveFile

View File

@@ -11,10 +11,7 @@ import net.lionarius.skinrestorer.skin.SkinStorage;
import net.lionarius.skinrestorer.skin.SkinValue;
import net.lionarius.skinrestorer.skin.provider.*;
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.lionarius.skinrestorer.util.*;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.MinecraftServer;
@@ -37,6 +34,7 @@ public final class SkinRestorer {
private static SkinStorage skinStorage;
private static Path configDir;
private static Config config;
private static TickedScheduler tickedScheduler;
private SkinRestorer() {}
@@ -56,6 +54,10 @@ public final class SkinRestorer {
return SkinRestorer.providersRegistry;
}
public static TickedScheduler getTickedScheduler() {
return SkinRestorer.tickedScheduler;
}
public static Optional<SkinProvider> getProvider(String name) {
return Optional.ofNullable(SkinRestorer.providersRegistry.get(name));
}
@@ -119,6 +121,8 @@ public final class SkinRestorer {
PlayerUtils.refreshPlayer(player);
acceptedPlayers.add(player);
SkinRestorer.getTickedScheduler().cancel(player.getUUID());
}
return acceptedPlayers;
@@ -165,6 +169,8 @@ public final class SkinRestorer {
FileUtils.tryMigrateOldSkinDirectory(SkinRestorer.getConfigDir(), worldSkinDirectory);
SkinRestorer.skinStorage = new SkinStorage(new SkinIO(worldSkinDirectory));
SkinRestorer.tickedScheduler = new TickedScheduler(server);
server.addTickable(SkinRestorer.tickedScheduler);
}
public static void onCommandRegister(CommandDispatcher<CommandSourceStack> dispatcher) {

View File

@@ -34,7 +34,7 @@ public final class SkinCommand {
private SkinCommand() {}
public static void register(CommandDispatcher<CommandSourceStack> dispatcher) {
LiteralArgumentBuilder<CommandSourceStack> base =
var base =
literal("skin")
.then(buildSetSubcommand("clear", SkinValue.EMPTY::toProviderContext))
.then(literal("reset")
@@ -44,7 +44,7 @@ public final class SkinCommand {
)))
.then(literal("refresh").executes(context -> refreshSubcommand(context.getSource())));
LiteralArgumentBuilder<CommandSourceStack> set = literal("set");
var set = literal("set");
var providers = SkinRestorer.getProvidersRegistry().getPublicProviders();
for (var entry : providers)
@@ -92,7 +92,7 @@ public final class SkinCommand {
Collection<GameProfile> targets,
boolean setByOperator
) {
Collection<ServerPlayer> updatedPlayers = new HashSet<>();
var updatedPlayers = new HashSet<ServerPlayer>();
for (var profile : targets) {
SkinValue skin = null;
if (SkinRestorer.getSkinStorage().hasSavedSkin(profile.getId()))
@@ -199,7 +199,7 @@ public final class SkinCommand {
}
private static LiteralArgumentBuilder<CommandSourceStack> buildSetSubcommand(String name, SkinProvider provider) {
LiteralArgumentBuilder<CommandSourceStack> action = literal(name);
var action = literal(name);
if (provider.hasVariantSupport()) {
for (SkinVariant variant : SkinVariant.values()) {

View File

@@ -1,19 +1,23 @@
package net.lionarius.skinrestorer.compat.skinshuffle;
import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.network.codec.StreamCodec;
import net.minecraft.network.protocol.common.custom.CustomPacketPayload;
import net.minecraft.resources.ResourceLocation;
import org.jetbrains.annotations.NotNull;
public record SkinShuffleHandshakePayload() implements CustomPacketPayload {
public static final SkinShuffleHandshakePayload INSTANCE = new SkinShuffleHandshakePayload();
public static final CustomPacketPayload.Type<SkinShuffleHandshakePayload> PACKET_ID = new CustomPacketPayload.Type<>(SkinShuffleCompatibility.resourceLocation("handshake"));
public static final StreamCodec<FriendlyByteBuf, SkinShuffleHandshakePayload> PACKET_CODEC = StreamCodec.unit(INSTANCE);
public static final ResourceLocation PACKET_ID = SkinShuffleCompatibility.resourceLocation("handshake");
@Override
public void write(@NotNull FriendlyByteBuf buf) {
// NO-OP
}
@Override
public CustomPacketPayload.@NotNull Type<? extends CustomPacketPayload> type() {
public @NotNull ResourceLocation id() {
return PACKET_ID;
}
}

View File

@@ -2,18 +2,14 @@ package net.lionarius.skinrestorer.compat.skinshuffle;
import com.mojang.authlib.properties.Property;
import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.network.codec.StreamCodec;
import net.minecraft.network.protocol.common.custom.CustomPacketPayload;
import net.minecraft.resources.ResourceLocation;
import org.jetbrains.annotations.NotNull;
public record SkinShuffleSkinRefreshV1Payload(
Property textureProperty) implements CustomPacketPayload, SkinShuffleSkinRefreshPayload {
public static final CustomPacketPayload.Type<SkinShuffleSkinRefreshV1Payload> PACKET_ID = new CustomPacketPayload.Type<>(SkinShuffleCompatibility.resourceLocation("refresh"));
public static final StreamCodec<FriendlyByteBuf, SkinShuffleSkinRefreshV1Payload> PACKET_CODEC = StreamCodec.of(
SkinShuffleSkinRefreshV1Payload::encode,
SkinShuffleSkinRefreshV1Payload::decode
);
public static final ResourceLocation PACKET_ID = SkinShuffleCompatibility.resourceLocation("refresh");
public static void encode(FriendlyByteBuf buf, SkinShuffleSkinRefreshV1Payload value) {
var textureProperty = value.textureProperty();
@@ -22,13 +18,18 @@ public record SkinShuffleSkinRefreshV1Payload(
buf.writeUtf(textureProperty.value());
buf.writeNullable(textureProperty.signature(), FriendlyByteBuf::writeUtf);
}
public static SkinShuffleSkinRefreshV1Payload decode(FriendlyByteBuf buf) {
return new SkinShuffleSkinRefreshV1Payload(new Property(buf.readUtf(), buf.readUtf(), buf.readNullable(FriendlyByteBuf::readUtf)));
}
@Override
public @NotNull CustomPacketPayload.Type<? extends CustomPacketPayload> type() {
public void write(@NotNull FriendlyByteBuf buf) {
encode(buf, this);
}
@Override
public @NotNull ResourceLocation id() {
return PACKET_ID;
}
}

View File

@@ -2,18 +2,14 @@ package net.lionarius.skinrestorer.compat.skinshuffle;
import com.mojang.authlib.properties.Property;
import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.network.codec.StreamCodec;
import net.minecraft.network.protocol.common.custom.CustomPacketPayload;
import net.minecraft.resources.ResourceLocation;
import org.jetbrains.annotations.NotNull;
public record SkinShuffleSkinRefreshV2Payload(
Property textureProperty) implements CustomPacketPayload, SkinShuffleSkinRefreshPayload {
public static final CustomPacketPayload.Type<SkinShuffleSkinRefreshV2Payload> PACKET_ID = new CustomPacketPayload.Type<>(SkinShuffleCompatibility.resourceLocation("skin_refresh"));
public static final StreamCodec<FriendlyByteBuf, SkinShuffleSkinRefreshV2Payload> PACKET_CODEC = StreamCodec.of(
SkinShuffleSkinRefreshV2Payload::encode,
SkinShuffleSkinRefreshV2Payload::decode
);
public static final ResourceLocation PACKET_ID = SkinShuffleCompatibility.resourceLocation("skin_refresh");
public static void encode(FriendlyByteBuf buf, SkinShuffleSkinRefreshV2Payload value) {
var textureProperty = value.textureProperty();
@@ -36,7 +32,12 @@ public record SkinShuffleSkinRefreshV2Payload(
}
@Override
public @NotNull CustomPacketPayload.Type<? extends CustomPacketPayload> type() {
public void write(@NotNull FriendlyByteBuf buf) {
encode(buf, this);
}
@Override
public @NotNull ResourceLocation id() {
return PACKET_ID;
}
}

View File

@@ -18,6 +18,8 @@ public final class Config implements GsonPostProcessable {
private boolean refreshSkinOnJoin = true;
private int skinApplyDelayOnJoin = 0;
private boolean fetchSkinOnFirstJoin = true;
private FirstJoinSkinProvider firstJoinSkinProvider = FirstJoinSkinProvider.MOJANG;
@@ -37,6 +39,10 @@ public final class Config implements GsonPostProcessable {
return this.refreshSkinOnJoin;
}
public int skinApplyDelayOnJoin() {
return this.skinApplyDelayOnJoin;
}
public boolean fetchSkinOnFirstJoin() {
return this.fetchSkinOnFirstJoin;
}
@@ -82,6 +88,11 @@ public final class Config implements GsonPostProcessable {
this.language = "en_us";
}
if (this.skinApplyDelayOnJoin < 0) {
SkinRestorer.LOGGER.warn("SkinApplyDelayOnJoin config is less than 0, defaulting to 0");
this.skinApplyDelayOnJoin = 0;
}
if (this.firstJoinSkinProvider == null) {
SkinRestorer.LOGGER.warn("FirstJoinSkinProvider config is null, defaulting to MOJANG");
this.firstJoinSkinProvider = FirstJoinSkinProvider.MOJANG;

View File

@@ -1,10 +1,42 @@
package net.lionarius.skinrestorer.config.provider;
public interface BuiltInProviderConfig {
import net.lionarius.skinrestorer.SkinRestorer;
import net.lionarius.skinrestorer.util.gson.GsonPostProcessable;
boolean enabled();
String name();
CacheConfig cache();
public abstract class BuiltInProviderConfig implements GsonPostProcessable {
protected boolean enabled;
protected String name;
protected CacheConfig cache;
public BuiltInProviderConfig(String name, CacheConfig cache) {
this.enabled = true;
this.name = name;
this.cache = cache;
}
public boolean enabled() {
return enabled;
}
public String name() {
return name;
}
public CacheConfig cache() {
return cache;
}
protected void validate(String defaultName, CacheConfig defaultCache) {
if (this.name == null || this.name.isEmpty()) {
SkinRestorer.LOGGER.warn("Provider name is null or empty, defaulting to '{}'", defaultName);
this.name = defaultName;
}
if (this.cache == null) {
SkinRestorer.LOGGER.warn("Provider cache is null, using default");
this.cache = defaultCache;
} else {
this.cache.validate(defaultCache);
}
}
}

View File

@@ -1,46 +1,16 @@
package net.lionarius.skinrestorer.config.provider;
import net.lionarius.skinrestorer.SkinRestorer;
import net.lionarius.skinrestorer.skin.provider.ElyBySkinProvider;
import net.lionarius.skinrestorer.util.gson.GsonPostProcessable;
public class ElyByProviderConfig implements BuiltInProviderConfig, GsonPostProcessable {
public final class ElyByProviderConfig extends BuiltInProviderConfig {
private static final CacheConfig DEFAULT_CACHE_VALUE = new CacheConfig(true, 60);
private boolean enabled;
private String name;
private CacheConfig cache;
public ElyByProviderConfig() {
this.enabled = true;
this.name = ElyBySkinProvider.PROVIDER_NAME;
this.cache = DEFAULT_CACHE_VALUE;
}
public boolean enabled() {
return enabled;
}
public String name() {
return name;
}
public CacheConfig cache() {
return cache;
super(ElyBySkinProvider.PROVIDER_NAME, DEFAULT_CACHE_VALUE);
}
@Override
public void gsonPostProcess() {
if (this.name == null || this.name.isEmpty()) {
SkinRestorer.LOGGER.warn("Ely.By provider name is null or empty, defaulting to '{}'", ElyBySkinProvider.PROVIDER_NAME);
this.name = ElyBySkinProvider.PROVIDER_NAME;
}
if (this.cache == null) {
SkinRestorer.LOGGER.warn("Ely.By provider cache is null, using default");
this.cache = DEFAULT_CACHE_VALUE;
} else {
this.cache.validate(DEFAULT_CACHE_VALUE);
}
super.validate(ElyBySkinProvider.PROVIDER_NAME, DEFAULT_CACHE_VALUE);
}
}

View File

@@ -2,52 +2,25 @@ package net.lionarius.skinrestorer.config.provider;
import net.lionarius.skinrestorer.SkinRestorer;
import net.lionarius.skinrestorer.skin.provider.MineskinSkinProvider;
import net.lionarius.skinrestorer.util.gson.GsonPostProcessable;
public class MineskinProviderConfig implements BuiltInProviderConfig, GsonPostProcessable {
public final class MineskinProviderConfig extends BuiltInProviderConfig {
private static final CacheConfig DEFAULT_CACHE_VALUE = new CacheConfig(true, 300);
private boolean enabled;
private String name;
private CacheConfig cache;
private String apiKey;
public MineskinProviderConfig() {
this.enabled = true;
this.name = MineskinSkinProvider.PROVIDER_NAME;
this.cache = DEFAULT_CACHE_VALUE;
super(MineskinSkinProvider.PROVIDER_NAME, DEFAULT_CACHE_VALUE);
this.apiKey = "";
}
public boolean enabled() {
return enabled;
}
public String name() {
return name;
}
public CacheConfig cache() {
return cache;
}
public String apiKey() {
return apiKey;
}
@Override
public void gsonPostProcess() {
if (this.name == null || this.name.isEmpty()) {
SkinRestorer.LOGGER.warn("Mineskin provider name is null or empty, defaulting to '{}'", MineskinSkinProvider.PROVIDER_NAME);
this.name = MineskinSkinProvider.PROVIDER_NAME;
}
if (this.cache == null) {
SkinRestorer.LOGGER.warn("Mineskin cache is null, using default");
this.cache = DEFAULT_CACHE_VALUE;
} else {
this.cache.validate(DEFAULT_CACHE_VALUE);
}
super.validate(MineskinSkinProvider.PROVIDER_NAME, DEFAULT_CACHE_VALUE);
if (this.apiKey == null) {
SkinRestorer.LOGGER.warn("Mineskin API key is null, defaulting to an empty string");

View File

@@ -1,46 +1,16 @@
package net.lionarius.skinrestorer.config.provider;
import net.lionarius.skinrestorer.SkinRestorer;
import net.lionarius.skinrestorer.skin.provider.MojangSkinProvider;
import net.lionarius.skinrestorer.util.gson.GsonPostProcessable;
public class MojangProviderConfig implements BuiltInProviderConfig, GsonPostProcessable {
public final class MojangProviderConfig extends BuiltInProviderConfig {
private static final CacheConfig DEFAULT_CACHE_VALUE = new CacheConfig(true, 60);
private boolean enabled;
private String name;
private CacheConfig cache;
public MojangProviderConfig() {
this.enabled = true;
this.name = MojangSkinProvider.PROVIDER_NAME;
this.cache = DEFAULT_CACHE_VALUE;
}
public boolean enabled() {
return enabled;
}
public String name() {
return name;
}
public CacheConfig cache() {
return cache;
super(MojangSkinProvider.PROVIDER_NAME, DEFAULT_CACHE_VALUE);
}
@Override
public void gsonPostProcess() {
if (this.name == null || this.name.isEmpty()) {
SkinRestorer.LOGGER.warn("Mojang provider name is null or empty, defaulting to '{}'", MojangSkinProvider.PROVIDER_NAME);
this.name = MojangSkinProvider.PROVIDER_NAME;
}
if (this.cache == null) {
SkinRestorer.LOGGER.warn("Mojang provider cache is null, using default");
this.cache = DEFAULT_CACHE_VALUE;
} else {
this.cache.validate(DEFAULT_CACHE_VALUE);
}
super.validate(MojangSkinProvider.PROVIDER_NAME, DEFAULT_CACHE_VALUE);
}
}

View File

@@ -9,6 +9,7 @@ import net.minecraft.server.players.PlayerList;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@@ -39,6 +40,22 @@ public abstract class PlayerListMixin {
@Inject(method = "placeNewPlayer", at = @At("HEAD"))
private void placeNewPlayer(Connection connection, ServerPlayer player, CommonListenerCookie cookie, CallbackInfo ci) {
var delay = SkinRestorer.getConfig().skinApplyDelayOnJoin();
if (delay <= 0) {
skinrestorer$tryApplySkin(server, player);
} else {
var uuid = player.getUUID();
SkinRestorer.getTickedScheduler().schedule(() -> {
var actualPlayer = server.getPlayerList().getPlayer(uuid);
if (actualPlayer != null)
skinrestorer$tryApplySkin(server, actualPlayer);
}, delay, uuid);
}
}
@Unique
private static void skinrestorer$tryApplySkin(MinecraftServer server, ServerPlayer player) {
if (SkinRestorer.getSkinStorage().hasSavedSkin(player.getUUID()))
SkinRestorer.applySkin(server, Collections.singleton(player.getGameProfile()), SkinRestorer.getSkinStorage().getSkin(player.getUUID()));
}

View File

@@ -27,9 +27,7 @@ public class SkinIO {
public SkinValue loadSkin(UUID uuid) {
try {
var value = SkinIO.loadSkin(savePath.resolve(SkinIO.uuidToFilename(uuid)));
Objects.requireNonNull(value.provider());
return value;
return SkinIO.loadSkin(savePath.resolve(SkinIO.uuidToFilename(uuid)));
} catch (Exception e) {
return SkinValue.EMPTY;
}

View File

@@ -3,11 +3,14 @@ package net.lionarius.skinrestorer.skin;
import com.mojang.authlib.properties.Property;
import net.lionarius.skinrestorer.skin.provider.EmptySkinProvider;
import net.lionarius.skinrestorer.skin.provider.SkinProviderContext;
import net.lionarius.skinrestorer.util.gson.GsonPostProcessable;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.Objects;
public record SkinValue(@NotNull String provider, @Nullable String argument, @Nullable SkinVariant variant,
@Nullable Property value, @Nullable Property originalValue) {
@Nullable Property value, @Nullable Property originalValue) implements GsonPostProcessable {
public static final SkinValue EMPTY = new SkinValue(EmptySkinProvider.PROVIDER_NAME, null, null, null);
@@ -30,4 +33,9 @@ public record SkinValue(@NotNull String provider, @Nullable String argument, @Nu
public SkinValue setOriginalValue(Property originalValue) {
return new SkinValue(this.provider, this.argument, this.variant, this.value, originalValue);
}
@Override
public void gsonPostProcess() {
Objects.requireNonNull(this.provider);
}
}

View File

@@ -9,11 +9,7 @@ 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.minecraft.util.StringUtil;
import net.lionarius.skinrestorer.util.*;
import org.jetbrains.annotations.NotNull;
import java.io.IOException;
@@ -71,7 +67,7 @@ public final class ElyBySkinProvider implements SkinProvider {
@Override
public Result<Optional<Property>, Exception> fetchSkin(String username, SkinVariant variant) {
try {
if (!StringUtil.isValidPlayerName(username))
if (!StringUtils.isValidPlayerName(username))
throw new IllegalArgumentException("invalid username");
var usernameLowerCase = username.toLowerCase(Locale.ROOT);

View File

@@ -22,7 +22,6 @@ import org.mineskin.response.QueueResponse;
import java.net.InetSocketAddress;
import java.net.URI;
import java.net.URISyntaxException;
import java.time.Duration;
import java.util.Optional;
import java.util.concurrent.TimeUnit;
@@ -31,19 +30,10 @@ public final class MineskinSkinProvider implements SkinProvider {
public static final String PROVIDER_NAME = "web";
private static final URI API_URI;
private static MineSkinClient MINESKIN_CLIENT;
private static LoadingCache<Pair<URI, SkinVariant>, Optional<Property>> SKIN_CACHE;
static {
try {
API_URI = new URI("https://api.mineskin.org");
} catch (URISyntaxException e) {
throw new IllegalArgumentException(e);
}
}
public static void reload() {
var config = SkinRestorer.getConfig();
var configApiKey = config.providersConfig().mineskin().apiKey();

View File

@@ -10,12 +10,8 @@ import com.mojang.authlib.yggdrasil.response.MinecraftProfilePropertiesResponse;
import com.mojang.util.UndashedUuid;
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 net.minecraft.util.StringUtil;
import org.jetbrains.annotations.NotNull;
import java.io.IOException;
@@ -93,7 +89,7 @@ public final class MojangSkinProvider implements SkinProvider {
@Override
public Result<Optional<Property>, Exception> fetchSkin(String username, SkinVariant variant) {
try {
if (!StringUtil.isValidPlayerName(username))
if (!StringUtils.isValidPlayerName(username))
throw new IllegalArgumentException("invalid username");
var cachedProfile = MojangSkinProvider.PROFILE_CACHE.get(username);

View File

@@ -67,12 +67,7 @@ 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.createCommonSpawnInfo(serverLevel), ClientboundRespawnPacket.KEEP_ALL_DATA));
player.connection.teleport(player.getX(), player.getY(), player.getZ(), player.getYRot(), player.getXRot());
player.connection.send(new ClientboundSetEntityMotionPacket(player));
var vehicle = player.getVehicle();
@@ -92,7 +87,7 @@ public final class PlayerUtils {
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));
}
}

View File

@@ -0,0 +1,60 @@
package net.lionarius.skinrestorer.util;
import net.minecraft.server.MinecraftServer;
import org.jetbrains.annotations.NotNull;
import java.util.Map;
import java.util.Queue;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.PriorityBlockingQueue;
public class TickedScheduler implements Runnable {
private final MinecraftServer server;
private final Queue<TickTask> queue = new PriorityBlockingQueue<>();
private final Map<Integer, Integer> idMap = new ConcurrentHashMap<>();
public TickedScheduler(MinecraftServer server) {
this.server = server;
}
public void schedule(Runnable task, int delay) {
this.schedule(task, delay, task);
}
public void schedule(Runnable task, int delay, Object id) {
var taskId = id.hashCode();
var serverTick = this.server.getTickCount();
this.idMap.merge(taskId, serverTick, Integer::max);
this.queue.add(new TickTask(serverTick, serverTick + delay, taskId, task));
}
public void cancel(Object id) {
var taskId = id.hashCode();
this.idMap.remove(taskId);
}
@Override
public void run() {
TickTask nextTask;
while ((nextTask = this.queue.peek()) != null) {
if (nextTask.runOnTick() > this.server.getTickCount())
break;
var tickTask = this.queue.remove();
var lastTaskScheduledOnTick = this.idMap.get(tickTask.id());
if (lastTaskScheduledOnTick != null && lastTaskScheduledOnTick <= tickTask.scheduledOnTick()) {
this.idMap.remove(tickTask.id());
if (tickTask.task() != null)
tickTask.task().run();
}
}
}
private record TickTask(int scheduledOnTick, int runOnTick, int id, Runnable task) implements Comparable<TickTask> {
@Override
public int compareTo(@NotNull TickedScheduler.TickTask other) {
return Integer.compare(this.runOnTick, other.runOnTick);
}
}
}

View File

@@ -1,14 +1,17 @@
package net.lionarius.skinrestorer.fabric.compat.skinshuffle;
import net.fabricmc.fabric.api.networking.v1.PayloadTypeRegistry;
import net.fabricmc.fabric.api.networking.v1.PacketSender;
import net.fabricmc.fabric.api.networking.v1.ServerPlayConnectionEvents;
import net.fabricmc.fabric.api.networking.v1.ServerPlayNetworking;
import net.lionarius.skinrestorer.SkinRestorer;
import net.lionarius.skinrestorer.compat.skinshuffle.SkinShuffleHandshakePayload;
import net.lionarius.skinrestorer.compat.skinshuffle.SkinShuffleSkinRefreshPayload;
import net.lionarius.skinrestorer.compat.skinshuffle.SkinShuffleSkinRefreshV1Payload;
import net.lionarius.skinrestorer.compat.skinshuffle.SkinShuffleSkinRefreshV2Payload;
import net.lionarius.skinrestorer.fabric.SkinRestorerFabric;
import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.server.network.ServerGamePacketListenerImpl;
public final class SkinShuffleCompatibility {
@@ -20,18 +23,24 @@ public final class SkinShuffleCompatibility {
return;
}
PayloadTypeRegistry.playS2C().register(SkinShuffleHandshakePayload.PACKET_ID, SkinShuffleHandshakePayload.PACKET_CODEC);
PayloadTypeRegistry.playC2S().register(SkinShuffleSkinRefreshV1Payload.PACKET_ID, SkinShuffleSkinRefreshV1Payload.PACKET_CODEC);
PayloadTypeRegistry.playC2S().register(SkinShuffleSkinRefreshV2Payload.PACKET_ID, SkinShuffleSkinRefreshV2Payload.PACKET_CODEC);
ServerPlayConnectionEvents.JOIN.register((handler, sender, server) -> net.lionarius.skinrestorer.compat.skinshuffle.SkinShuffleCompatibility.onPlayerJoin(handler.getPlayer()));
ServerPlayNetworking.registerGlobalReceiver(SkinShuffleSkinRefreshV1Payload.PACKET_ID, SkinShuffleCompatibility::handleSkinRefreshPacket);
ServerPlayNetworking.registerGlobalReceiver(SkinShuffleSkinRefreshV1Payload.PACKET_ID, SkinShuffleCompatibility::handleSkinRefreshV1Packet);
ServerPlayNetworking.registerGlobalReceiver(SkinShuffleSkinRefreshV2Payload.PACKET_ID, SkinShuffleCompatibility::handleSkinRefreshPacket);
ServerPlayNetworking.registerGlobalReceiver(SkinShuffleSkinRefreshV2Payload.PACKET_ID, SkinShuffleCompatibility::handleSkinRefreshV2Packet);
}
private static void handleSkinRefreshPacket(SkinShuffleSkinRefreshPayload payload, ServerPlayNetworking.Context context) {
net.lionarius.skinrestorer.compat.skinshuffle.SkinShuffleCompatibility.handleSkinRefresh(context.player().getServer(), context.player(), payload);
private static void handleSkinRefreshV1Packet(MinecraftServer server, ServerPlayer player, ServerGamePacketListenerImpl listener, FriendlyByteBuf buf, PacketSender sender) {
var payload = SkinShuffleSkinRefreshV1Payload.decode(buf);
SkinShuffleCompatibility.handleSkinRefreshPacket(payload, server, player);
}
private static void handleSkinRefreshV2Packet(MinecraftServer server, ServerPlayer player, ServerGamePacketListenerImpl listener, FriendlyByteBuf buf, PacketSender sender) {
var payload = SkinShuffleSkinRefreshV2Payload.decode(buf);
SkinShuffleCompatibility.handleSkinRefreshPacket(payload, server, player);
}
private static void handleSkinRefreshPacket(SkinShuffleSkinRefreshPayload payload, MinecraftServer server, ServerPlayer player) {
net.lionarius.skinrestorer.compat.skinshuffle.SkinShuffleCompatibility.handleSkinRefresh(server, player, payload);
}
}

View File

@@ -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.Events.onServerStarted((MinecraftServer) (Object) this);
}

View File

@@ -1,5 +1,6 @@
package net.lionarius.skinrestorer.fabric.platform;
import net.fabricmc.fabric.api.networking.v1.PacketByteBufs;
import net.fabricmc.fabric.api.networking.v1.ServerPlayNetworking;
import net.lionarius.skinrestorer.compat.skinshuffle.SkinShuffleHandshakePayload;
import net.lionarius.skinrestorer.platform.services.CompatibilityHelper;
@@ -8,6 +9,6 @@ import net.minecraft.server.level.ServerPlayer;
public final class FabricCompatibilityHelper implements CompatibilityHelper {
@Override
public void skinShuffle_sendHandshake(ServerPlayer player) {
ServerPlayNetworking.send(player, SkinShuffleHandshakePayload.INSTANCE);
ServerPlayNetworking.send(player, SkinShuffleHandshakePayload.PACKET_ID, PacketByteBufs.empty());
}
}

View File

@@ -17,19 +17,19 @@ mixin {
jarJar.enable()
tasks.named('jar') {
archiveClassifier = 'thin'
}
tasks.named('jarJar') {
archiveClassifier = ''
}
jar.finalizedBy('jarJar')
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
@@ -40,7 +40,7 @@ minecraft {
runs {
client {
workingDirectory file('../run/client')
workingDirectory rootProject.file('run/client')
ideaModule "${rootProject.name}.${project.name}.main"
taskName 'Client'
mods {
@@ -51,7 +51,7 @@ minecraft {
}
server {
workingDirectory file('../run/server')
workingDirectory rootProject.file('run/server')
ideaModule "${rootProject.name}.${project.name}.main"
taskName 'Server'
mods {

View File

@@ -14,18 +14,18 @@ public class SkinShufflePacketHandler {
}
private static final EventNetworkChannel HANDSHAKE_INSTANCE = ChannelBuilder
.named(SkinShuffleHandshakePayload.PACKET_ID.id())
.named(SkinShuffleHandshakePayload.PACKET_ID)
.optional()
.eventNetworkChannel();
private static final EventNetworkChannel SKIN_REFRESH_V1_INSTANCE = ChannelBuilder
.named(SkinShuffleSkinRefreshV1Payload.PACKET_ID.id())
.named(SkinShuffleSkinRefreshV1Payload.PACKET_ID)
.optional()
.eventNetworkChannel()
.addListener(SkinShufflePacketHandler::skinRefreshV1Listener);
private static final EventNetworkChannel SKIN_REFRESH_V2_INSTANCE = ChannelBuilder
.named(SkinShuffleSkinRefreshV2Payload.PACKET_ID.id())
.named(SkinShuffleSkinRefreshV2Payload.PACKET_ID)
.optional()
.eventNetworkChannel()
.addListener(SkinShufflePacketHandler::skinRefreshV2Listener);
@@ -39,12 +39,12 @@ public class SkinShufflePacketHandler {
}
private static void skinRefreshV1Listener(CustomPayloadEvent event) {
var payload = SkinShuffleSkinRefreshV1Payload.PACKET_CODEC.decode(event.getPayload());
var payload = SkinShuffleSkinRefreshV1Payload.decode(event.getPayload());
handleSkinRefreshPacket(payload, event.getSource());
}
private static void skinRefreshV2Listener(CustomPayloadEvent event) {
var payload = SkinShuffleSkinRefreshV2Payload.PACKET_CODEC.decode(event.getPayload());
var payload = SkinShuffleSkinRefreshV2Payload.decode(event.getPayload());
handleSkinRefreshPacket(payload, event.getSource());
}

View File

@@ -1,14 +1,14 @@
# Project
group=net.lionarius
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.2
minecraft_version_list=1.20.2
minecraft_version_range=1.20.2
mod_id=skinrestorer
mod_name=SkinRestorer
mod_version=2.2.0
mod_version=2.3.0
mod_author=Lionarius
mod_homepage=https://modrinth.com/mod/skinrestorer
mod_sources=https://github.com/Suiranoil/SkinRestorer
@@ -17,26 +17,27 @@ license=MIT
credits=
description=A server-side mod for managing skins.
# Dependencies
mineskin_client_version=3.0.1-SNAPSHOT
# 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.2
parchment_version=2023.12.10
# Fabric, see https://fabricmc.net/develop/ for new versions
fabric_loader_version=0.15.0
fabric_api_version=0.97.5+1.20.5
fabric_api_version=0.91.1+1.20.3
fabric_optional_dependencies=fabric-api
# Forge, see https://files.minecraftforge.net/net/minecraftforge/forge/ for new versions
forge_version=50.0.0
forge_loader_version_range=[50,)
forge_version=48.0.0
forge_loader_version_range=[48,)
# Forge sometimes skips minor minecraft versions (like 1.20.5)
forge_minecraft_version=1.20.6
forge_minecraft_version=1.20.2
# 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

View File

@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.12.1-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME

3
gradlew vendored
View File

@@ -86,8 +86,7 @@ done
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s
' "$PWD" ) || exit
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum

View File

@@ -3,56 +3,58 @@ plugins {
id 'idea'
id 'eclipse'
id 'net.neoforged.gradle.userdev'
id 'net.neoforged.moddev'
id 'multiloader-publish'
}
// 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)
}
jarJar.enable()
tasks.named('jar') {
archiveClassifier = 'thin'
}
tasks.named('jarJar') {
archiveClassifier = ''
}
jar.finalizedBy('jarJar')
dependencies {
implementation "net.neoforged:neoforge:${neoforge_version}"
implementation(jarJar(group: 'org.mineskin', name: 'java-client', version: mineskin_client_version)) {
jarJar.ranged(it, "[${mineskin_client_version},)")
neoForge {
version = neoforge_version
// 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)
}
}
subsystems {
parchment {
minecraftVersion = parchment_minecraft
mappingsVersion = parchment_version
}
}
runs {
configureEach {
modSource project.sourceSets.main
systemProperty 'neoforge.enabledGameTestNamespaces', project.mod_id
runs {
configureEach {
ideName = "NeoForge ${it.name.capitalize()} (${project.path})" // Unify the run config names with fabric
}
client {
client()
gameDirectory = rootProject.file('run/client')
}
server {
server()
programArgument '--nogui'
gameDirectory = rootProject.file('run/server')
}
}
client {
workingDirectory = file('../run/client')
}
server {
programArgument '--nogui'
workingDirectory = file('../run/server')
mods {
"${mod_id}" {
sourceSet sourceSets.main
}
}
}
dependencies {
implementation "net.neoforged:neoforge:${neoforge_version}"
jarJar(implementation('org.mineskin:java-client')) {
version {
strictly "[${mineskin_client_version},)"
prefer mineskin_client_version
}
}
additionalRuntimeClasspath "org.mineskin:java-client:${mineskin_client_version}"
}

View File

@@ -3,13 +3,12 @@ package net.lionarius.skinrestorer.neoforge;
import net.lionarius.skinrestorer.SkinRestorer;
import net.lionarius.skinrestorer.compat.skinshuffle.SkinShuffleCompatibility;
import net.neoforged.bus.api.SubscribeEvent;
import net.neoforged.fml.common.EventBusSubscriber;
import net.neoforged.fml.common.Mod;
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() {

View File

@@ -1,7 +1,5 @@
package net.lionarius.skinrestorer.neoforge.compat.skinshuffle;
import net.lionarius.skinrestorer.SkinRestorer;
import net.neoforged.fml.ModList;
import net.neoforged.neoforge.common.NeoForge;
public final class SkinShuffleCompatibility {
@@ -11,7 +9,6 @@ public final class SkinShuffleCompatibility {
public static void initialize() {
NeoForge.EVENT_BUS.register(SkinShuffleGameEventHandler.class);
final var mod = ModList.get().getModContainerById(SkinRestorer.MOD_ID).get();
mod.getEventBus().register(SkinShuffleModEventHandler.class);
SkinShufflePacketHandler.initialize();
}
}

View File

@@ -1,31 +0,0 @@
package net.lionarius.skinrestorer.neoforge.compat.skinshuffle;
import net.lionarius.skinrestorer.compat.skinshuffle.SkinShuffleCompatibility;
import net.lionarius.skinrestorer.compat.skinshuffle.*;
import net.minecraft.server.level.ServerPlayer;
import net.neoforged.bus.api.SubscribeEvent;
import net.neoforged.neoforge.network.event.RegisterPayloadHandlersEvent;
import net.neoforged.neoforge.network.handling.IPayloadContext;
import net.neoforged.neoforge.network.registration.HandlerThread;
public final class SkinShuffleModEventHandler {
private SkinShuffleModEventHandler() {}
@SubscribeEvent
public static void onRegisterPayloadHandlers(RegisterPayloadHandlersEvent event) {
final var registrar = event.registrar("1").optional().executesOn(HandlerThread.NETWORK);
registrar
.playToClient(SkinShuffleHandshakePayload.PACKET_ID, SkinShuffleHandshakePayload.PACKET_CODEC,
(payload, context) -> {})
.playToServer(SkinShuffleSkinRefreshV1Payload.PACKET_ID, SkinShuffleSkinRefreshV1Payload.PACKET_CODEC,
SkinShuffleModEventHandler::handleSkinRefreshPacket)
.playToServer(SkinShuffleSkinRefreshV2Payload.PACKET_ID, SkinShuffleSkinRefreshV2Payload.PACKET_CODEC,
SkinShuffleModEventHandler::handleSkinRefreshPacket);
}
private static void handleSkinRefreshPacket(SkinShuffleSkinRefreshPayload payload, IPayloadContext context) {
var player = (ServerPlayer) context.player();
SkinShuffleCompatibility.handleSkinRefresh(player.getServer(), player, payload);
}
}

View File

@@ -0,0 +1,55 @@
package net.lionarius.skinrestorer.neoforge.compat.skinshuffle;
import net.lionarius.skinrestorer.compat.skinshuffle.SkinShuffleCompatibility;
import net.lionarius.skinrestorer.compat.skinshuffle.*;
import net.neoforged.neoforge.network.NetworkConstants;
import net.neoforged.neoforge.network.NetworkEvent;
import net.neoforged.neoforge.network.NetworkRegistry;
import net.neoforged.neoforge.network.event.EventNetworkChannel;
public final class SkinShufflePacketHandler {
private SkinShufflePacketHandler() {
}
// there is no need for handshake channel but register it to not allow other mods to use it
private static final EventNetworkChannel HANDSHAKE_INSTANCE = NetworkRegistry.ChannelBuilder
.named(SkinShuffleHandshakePayload.PACKET_ID)
.serverAcceptedVersions(NetworkRegistry.acceptMissingOr("1"))
.clientAcceptedVersions(NetworkRegistry.acceptMissingOr("1"))
.networkProtocolVersion(() -> NetworkConstants.NETVERSION)
.eventNetworkChannel();
private static final EventNetworkChannel SKIN_REFRESH_V1_INSTANCE = NetworkRegistry.ChannelBuilder
.named(SkinShuffleSkinRefreshV1Payload.PACKET_ID)
.serverAcceptedVersions(NetworkRegistry.acceptMissingOr("1"))
.clientAcceptedVersions(NetworkRegistry.acceptMissingOr("1"))
.networkProtocolVersion(() -> NetworkConstants.NETVERSION)
.eventNetworkChannel();
private static final EventNetworkChannel SKIN_REFRESH_V2_INSTANCE = NetworkRegistry.ChannelBuilder
.named(SkinShuffleSkinRefreshV2Payload.PACKET_ID)
.serverAcceptedVersions(NetworkRegistry.acceptMissingOr("1"))
.clientAcceptedVersions(NetworkRegistry.acceptMissingOr("1"))
.networkProtocolVersion(() -> NetworkConstants.NETVERSION)
.eventNetworkChannel();
static void initialize() {
SKIN_REFRESH_V1_INSTANCE.addListener(SkinShufflePacketHandler::skinRefreshV1Listener);
SKIN_REFRESH_V2_INSTANCE.addListener(SkinShufflePacketHandler::skinRefreshV2Listener);
}
private static void skinRefreshV1Listener(NetworkEvent.ServerCustomPayloadEvent event) {
var payload = SkinShuffleSkinRefreshV1Payload.decode(event.getPayload());
handleSkinRefreshPacket(payload, event.getSource());
}
private static void skinRefreshV2Listener(NetworkEvent.ServerCustomPayloadEvent event) {
var payload = SkinShuffleSkinRefreshV2Payload.decode(event.getPayload());
handleSkinRefreshPacket(payload, event.getSource());
}
private static void handleSkinRefreshPacket(SkinShuffleSkinRefreshPayload payload, NetworkEvent.Context context) {
var player = context.getSender();
SkinShuffleCompatibility.handleSkinRefresh(player.getServer(), player, payload);
}
}

View File

@@ -10,6 +10,6 @@ public final class NeoForgeCompatibilityHelper implements CompatibilityHelper {
@Override
public void skinShuffle_sendHandshake(ServerPlayer player) {
// we can't use the packet distributor here because neoforge doesn't support sending packets to non-neoforge players
player.connection.getConnection().send(new ClientboundCustomPayloadPacket(SkinShuffleHandshakePayload.INSTANCE));
player.connection.connection.send(new ClientboundCustomPayloadPacket(SkinShuffleHandshakePayload.INSTANCE));
}
}

View File

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

View File

@@ -71,4 +71,4 @@ rootProject.name = 'skin-restorer'
include('common')
include('fabric')
include('forge')
include('neoforge')
//include('neoforge')