mirror of
https://github.com/Suiranoil/SkinRestorer.git
synced 2026-01-16 04:42:12 +00:00
Compare commits
19 Commits
9c9f02667c
...
1.19-multi
| Author | SHA1 | Date | |
|---|---|---|---|
|
42f9103f72
|
|||
|
e4b03a9989
|
|||
|
034d4863b7
|
|||
|
59ea3eb160
|
|||
|
4af85d2c6c
|
|||
|
c36eb4db8c
|
|||
|
768125d11d
|
|||
|
276c670902
|
|||
|
90e4e2c2c9
|
|||
|
1f265a0802
|
|||
|
e16fbffa5c
|
|||
|
b67ea1bb29
|
|||
|
eeb405dd96
|
|||
|
3509b2e63c
|
|||
|
f4ade5f29d
|
|||
|
1ed4c8fd17
|
|||
|
17e2d1a7c3
|
|||
|
4fb3972416
|
|||
|
cb0756902a
|
@@ -128,7 +128,7 @@ public final class SkinCommand {
|
||||
boolean save,
|
||||
boolean setByOperator
|
||||
) {
|
||||
src.sendSystemMessage(Translation.translatableWithFallback(Translation.COMMAND_SKIN_LOADING_KEY));
|
||||
src.sendSuccess(Translation.translatableWithFallback(Translation.COMMAND_SKIN_LOADING_KEY), false);
|
||||
|
||||
SkinRestorer.setSkinAsync(src.getServer(), targets, context, save).thenAccept(result -> {
|
||||
if (result.isError()) {
|
||||
@@ -169,7 +169,7 @@ public final class SkinCommand {
|
||||
private static int configReloadSubcommand(CommandContext<CommandSourceStack> context) {
|
||||
SkinRestorer.reloadConfig();
|
||||
|
||||
context.getSource().sendSuccess(() -> Translation.translatableWithFallback(
|
||||
context.getSource().sendSuccess(Translation.translatableWithFallback(
|
||||
Translation.COMMAND_SKIN_CONFIG_RELOADED_KEY
|
||||
), true);
|
||||
|
||||
@@ -178,7 +178,7 @@ public final class SkinCommand {
|
||||
|
||||
private static void sendResponse(CommandSourceStack src, Collection<ServerPlayer> updatedPlayers, boolean setByOperator) {
|
||||
if (updatedPlayers.isEmpty()) {
|
||||
src.sendSuccess(() -> Translation.translatableWithFallback(
|
||||
src.sendSuccess(Translation.translatableWithFallback(
|
||||
Translation.COMMAND_SKIN_NO_CHANGES_KEY
|
||||
), true);
|
||||
return;
|
||||
@@ -187,12 +187,12 @@ public final class SkinCommand {
|
||||
if (setByOperator) {
|
||||
var playersComponent = PlayerUtils.createPlayerListComponent(updatedPlayers);
|
||||
|
||||
src.sendSuccess(() -> Translation.translatableWithFallback(
|
||||
src.sendSuccess(Translation.translatableWithFallback(
|
||||
Translation.COMMAND_SKIN_AFFECTED_PLAYERS_KEY,
|
||||
playersComponent
|
||||
), true);
|
||||
} else {
|
||||
src.sendSuccess(() -> Translation.translatableWithFallback(
|
||||
src.sendSuccess(Translation.translatableWithFallback(
|
||||
Translation.COMMAND_SKIN_OK_KEY
|
||||
), true);
|
||||
}
|
||||
|
||||
@@ -1,55 +0,0 @@
|
||||
package net.lionarius.skinrestorer.compat.skinshuffle;
|
||||
|
||||
import net.lionarius.skinrestorer.SkinRestorer;
|
||||
import net.lionarius.skinrestorer.platform.Services;
|
||||
import net.lionarius.skinrestorer.skin.SkinValue;
|
||||
import net.lionarius.skinrestorer.skin.provider.SkinShuffleSkinProvider;
|
||||
import net.lionarius.skinrestorer.util.PlayerUtils;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
public class SkinShuffleCompatibility {
|
||||
|
||||
public static final String MOD_ID = "skinshuffle";
|
||||
|
||||
private static final boolean SHOULD_APPLY = !Services.PLATFORM.isModLoaded(SkinShuffleCompatibility.MOD_ID);
|
||||
|
||||
private SkinShuffleCompatibility() {}
|
||||
|
||||
public static boolean shouldApply() {
|
||||
return SkinShuffleCompatibility.SHOULD_APPLY;
|
||||
}
|
||||
|
||||
public static ResourceLocation resourceLocation(String name) {
|
||||
return new ResourceLocation(SkinShuffleCompatibility.MOD_ID, name);
|
||||
}
|
||||
|
||||
public static void onPlayerJoin(ServerPlayer player) {
|
||||
Services.COMPATIBILITY.skinShuffle_sendHandshake(player);
|
||||
}
|
||||
|
||||
public static void handleSkinRefresh(MinecraftServer server, ServerPlayer player, SkinShuffleSkinRefreshPayload payload) {
|
||||
var property = payload.textureProperty();
|
||||
|
||||
if (!property.getName().equals(PlayerUtils.TEXTURES_KEY))
|
||||
return;
|
||||
|
||||
if (!property.hasSignature())
|
||||
return;
|
||||
|
||||
server.execute(() -> {
|
||||
SkinRestorer.applySkin(
|
||||
server,
|
||||
Collections.singleton(player.getGameProfile()),
|
||||
new SkinValue(SkinShuffleSkinProvider.PROVIDER_NAME, null, null, property),
|
||||
!server.usesAuthentication()
|
||||
);
|
||||
|
||||
if (server.usesAuthentication() && SkinRestorer.getSkinStorage().hasSavedSkin(player.getUUID()))
|
||||
SkinRestorer.getSkinStorage().deleteSkin(player.getUUID());
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
package net.lionarius.skinrestorer.compat.skinshuffle;
|
||||
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
|
||||
public record SkinShuffleHandshakePayload() {
|
||||
|
||||
public static final SkinShuffleHandshakePayload INSTANCE = new SkinShuffleHandshakePayload();
|
||||
|
||||
public static final ResourceLocation PACKET_ID = SkinShuffleCompatibility.resourceLocation("handshake");
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
package net.lionarius.skinrestorer.compat.skinshuffle;
|
||||
|
||||
import com.mojang.authlib.properties.Property;
|
||||
|
||||
public interface SkinShuffleSkinRefreshPayload {
|
||||
Property textureProperty();
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
package net.lionarius.skinrestorer.compat.skinshuffle;
|
||||
|
||||
import com.mojang.authlib.properties.Property;
|
||||
import net.minecraft.network.FriendlyByteBuf;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
|
||||
public record SkinShuffleSkinRefreshV1Payload(
|
||||
Property textureProperty) implements SkinShuffleSkinRefreshPayload {
|
||||
|
||||
public static final ResourceLocation PACKET_ID = SkinShuffleCompatibility.resourceLocation("refresh");
|
||||
|
||||
public static void encode(FriendlyByteBuf buf, SkinShuffleSkinRefreshV1Payload value) {
|
||||
var textureProperty = value.textureProperty();
|
||||
|
||||
buf.writeUtf(textureProperty.getName());
|
||||
buf.writeUtf(textureProperty.getValue());
|
||||
buf.writeNullable(textureProperty.getSignature(), FriendlyByteBuf::writeUtf);
|
||||
}
|
||||
|
||||
public static SkinShuffleSkinRefreshV1Payload decode(FriendlyByteBuf buf) {
|
||||
return new SkinShuffleSkinRefreshV1Payload(new Property(buf.readUtf(), buf.readUtf(), buf.readNullable(FriendlyByteBuf::readUtf)));
|
||||
}
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
package net.lionarius.skinrestorer.compat.skinshuffle;
|
||||
|
||||
import com.mojang.authlib.properties.Property;
|
||||
import net.minecraft.network.FriendlyByteBuf;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
|
||||
public record SkinShuffleSkinRefreshV2Payload(
|
||||
Property textureProperty) implements SkinShuffleSkinRefreshPayload {
|
||||
|
||||
public static final ResourceLocation PACKET_ID = SkinShuffleCompatibility.resourceLocation("skin_refresh");
|
||||
|
||||
public static void encode(FriendlyByteBuf buf, SkinShuffleSkinRefreshV2Payload value) {
|
||||
var textureProperty = value.textureProperty();
|
||||
|
||||
buf.writeBoolean(textureProperty.hasSignature());
|
||||
buf.writeUtf(textureProperty.getName());
|
||||
buf.writeUtf(textureProperty.getValue());
|
||||
if (textureProperty.hasSignature()) {
|
||||
assert textureProperty.getSignature() != null;
|
||||
|
||||
buf.writeUtf(textureProperty.getSignature());
|
||||
}
|
||||
}
|
||||
|
||||
public static SkinShuffleSkinRefreshV2Payload decode(FriendlyByteBuf buf) {
|
||||
if (buf.readBoolean()) {
|
||||
return new SkinShuffleSkinRefreshV2Payload(new Property(buf.readUtf(), buf.readUtf(), buf.readUtf()));
|
||||
}
|
||||
return new SkinShuffleSkinRefreshV2Payload(new Property(buf.readUtf(), buf.readUtf(), null));
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,4 @@
|
||||
package net.lionarius.skinrestorer.platform.services;
|
||||
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
|
||||
public interface CompatibilityHelper {
|
||||
|
||||
void skinShuffle_sendHandshake(ServerPlayer player);
|
||||
}
|
||||
|
||||
@@ -9,11 +9,25 @@ 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) implements GsonPostProcessable {
|
||||
public final class SkinValue implements GsonPostProcessable {
|
||||
|
||||
public static final SkinValue EMPTY = new SkinValue(EmptySkinProvider.PROVIDER_NAME, null, null, null);
|
||||
|
||||
private @NotNull String provider;
|
||||
private @Nullable String argument;
|
||||
private @Nullable SkinVariant variant;
|
||||
private @Nullable Property value;
|
||||
private @Nullable Property originalValue;
|
||||
|
||||
public SkinValue(@NotNull String provider, @Nullable String argument, @Nullable SkinVariant variant,
|
||||
@Nullable Property value, @Nullable Property originalValue) {
|
||||
this.provider = provider;
|
||||
this.argument = argument;
|
||||
this.variant = variant;
|
||||
this.value = value;
|
||||
this.originalValue = originalValue;
|
||||
}
|
||||
|
||||
public SkinValue(String provider, String argument, SkinVariant variant, Property value) {
|
||||
this(provider, argument, variant, value, null);
|
||||
}
|
||||
@@ -38,4 +52,23 @@ public record SkinValue(@NotNull String provider, @Nullable String argument, @Nu
|
||||
public void gsonPostProcess() {
|
||||
Objects.requireNonNull(this.provider);
|
||||
}
|
||||
|
||||
public @NotNull String provider() {
|
||||
return provider;
|
||||
}
|
||||
|
||||
public @Nullable String argument() {
|
||||
return argument;
|
||||
}
|
||||
|
||||
public @Nullable SkinVariant variant() {
|
||||
return variant;}
|
||||
|
||||
public @Nullable Property value() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public @Nullable Property originalValue() {
|
||||
return originalValue;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,11 +39,11 @@ public final class Translation {
|
||||
}
|
||||
|
||||
public static MutableComponent translatableWithFallback(String key) {
|
||||
return Component.translatableWithFallback(key, Translation.get(key));
|
||||
return Component.translatable(Translation.get(key));
|
||||
}
|
||||
|
||||
public static MutableComponent translatableWithFallback(String key, Object... args) {
|
||||
return Component.translatableWithFallback(key, Translation.get(key), args);
|
||||
return Component.translatable(Translation.get(key), args);
|
||||
}
|
||||
|
||||
public static void reloadTranslations() {
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
package net.lionarius.skinrestorer.util;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.*;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import com.mojang.authlib.properties.Property;
|
||||
import com.mojang.authlib.properties.PropertyMap;
|
||||
@@ -22,7 +19,7 @@ public final class JsonUtils {
|
||||
.registerTypeAdapterFactory(new PostProcessingEnabler())
|
||||
.registerTypeAdapter(UUID.class, new UUIDTypeAdapter())
|
||||
.registerTypeAdapter(PropertyMap.class, new PropertyMap.Serializer())
|
||||
.registerTypeAdapter(GameProfile.class, new GameProfile.Serializer())
|
||||
.registerTypeAdapter(GameProfile.class, new GameProfileSerializer())
|
||||
.setPrettyPrinting()
|
||||
.create();
|
||||
|
||||
@@ -60,4 +57,26 @@ public final class JsonUtils {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private static class GameProfileSerializer implements JsonSerializer<GameProfile>, JsonDeserializer<GameProfile> {
|
||||
@Override
|
||||
public GameProfile deserialize(final JsonElement json, final Type typeOfT, final JsonDeserializationContext context) throws JsonParseException {
|
||||
final JsonObject object = (JsonObject) json;
|
||||
final UUID id = object.has("id") ? context.deserialize(object.get("id"), UUID.class) : null;
|
||||
final String name = object.has("name") ? object.getAsJsonPrimitive("name").getAsString() : null;
|
||||
return new GameProfile(id, name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public JsonElement serialize(final GameProfile src, final Type typeOfSrc, final JsonSerializationContext context) {
|
||||
final JsonObject result = new JsonObject();
|
||||
if (src.getId() != null) {
|
||||
result.add("id", context.serialize(src.getId()));
|
||||
}
|
||||
if (src.getName() != null) {
|
||||
result.addProperty("name", src.getName());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,16 +40,12 @@ public final class PlayerUtils {
|
||||
}
|
||||
|
||||
public static void refreshPlayer(ServerPlayer player) {
|
||||
ServerLevel serverLevel = player.serverLevel();
|
||||
ServerLevel serverLevel = player.getLevel();
|
||||
PlayerList playerList = serverLevel.getServer().getPlayerList();
|
||||
ChunkMap chunkMap = serverLevel.getChunkSource().chunkMap;
|
||||
|
||||
playerList.broadcastAll(new ClientboundBundlePacket(
|
||||
List.of(
|
||||
new ClientboundPlayerInfoRemovePacket(List.of(player.getUUID())),
|
||||
ClientboundPlayerInfoUpdatePacket.createPlayerInitializing(Collections.singleton(player))
|
||||
)
|
||||
));
|
||||
playerList.broadcastAll(new ClientboundPlayerInfoPacket(ClientboundPlayerInfoPacket.Action.REMOVE_PLAYER, player));
|
||||
playerList.broadcastAll(new ClientboundPlayerInfoPacket(ClientboundPlayerInfoPacket.Action.ADD_PLAYER, player));
|
||||
|
||||
var trackedEntity = (TrackedEntityAccessorInvoker) ((ChunkMapAccessor) chunkMap).getEntityMap().get(player.getId());
|
||||
if (trackedEntity != null) {
|
||||
@@ -70,16 +66,15 @@ public final class PlayerUtils {
|
||||
if (!player.isDeadOrDying()) {
|
||||
player.connection.send(
|
||||
new ClientboundRespawnPacket(
|
||||
player.level().dimensionTypeId(),
|
||||
player.level().dimension(),
|
||||
BiomeManager.obfuscateSeed(player.serverLevel().getSeed()),
|
||||
player.getLevel().dimensionTypeId(),
|
||||
player.getLevel().dimension(),
|
||||
BiomeManager.obfuscateSeed(player.getLevel().getSeed()),
|
||||
player.gameMode.getGameModeForPlayer(),
|
||||
player.gameMode.getPreviousGameModeForPlayer(),
|
||||
player.level().isDebug(),
|
||||
player.serverLevel().isFlat(),
|
||||
(byte) 3,
|
||||
player.getLastDeathLocation(),
|
||||
player.getPortalCooldown()
|
||||
player.getLevel().isDebug(),
|
||||
player.getLevel().isFlat(),
|
||||
true,
|
||||
player.getLastDeathLocation()
|
||||
)
|
||||
);
|
||||
player.connection.teleport(player.getX(), player.getY(), player.getZ(), player.getYRot(), player.getXRot());
|
||||
|
||||
@@ -14,8 +14,6 @@ dependencies {
|
||||
}
|
||||
modImplementation "net.fabricmc:fabric-loader:${fabric_loader_version}"
|
||||
|
||||
modCompileOnly "net.fabricmc.fabric-api:fabric-api:${fabric_api_version}"
|
||||
|
||||
include implementation("org.mineskin:java-client:${mineskin_client_version}")
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,2 @@
|
||||
# Fabric, see https://fabricmc.net/develop/ for new versions
|
||||
fabric_loader_version=0.15.0
|
||||
fabric_api_version=0.83.0+1.20
|
||||
|
||||
optional_dependencies=fabric-api
|
||||
|
||||
@@ -2,18 +2,11 @@ package net.lionarius.skinrestorer.fabric;
|
||||
|
||||
import net.fabricmc.api.ModInitializer;
|
||||
import net.lionarius.skinrestorer.SkinRestorer;
|
||||
import net.lionarius.skinrestorer.compat.skinshuffle.SkinShuffleCompatibility;
|
||||
import net.lionarius.skinrestorer.platform.Services;
|
||||
|
||||
public final class SkinRestorerFabric implements ModInitializer {
|
||||
|
||||
public static final boolean FABRIC_API_LOADED = Services.PLATFORM.isModLoaded("fabric-api");
|
||||
|
||||
@Override
|
||||
public void onInitialize() {
|
||||
SkinRestorer.onInitialize();
|
||||
|
||||
if (SkinShuffleCompatibility.shouldApply())
|
||||
net.lionarius.skinrestorer.fabric.compat.skinshuffle.SkinShuffleCompatibility.initialize();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,46 +0,0 @@
|
||||
package net.lionarius.skinrestorer.fabric.compat.skinshuffle;
|
||||
|
||||
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.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 {
|
||||
|
||||
private SkinShuffleCompatibility() {}
|
||||
|
||||
public static void initialize() {
|
||||
if (!SkinRestorerFabric.FABRIC_API_LOADED) {
|
||||
SkinRestorer.LOGGER.warn("fabric-api is not loaded, SkinShuffle compatibility will not be available");
|
||||
return;
|
||||
}
|
||||
|
||||
ServerPlayConnectionEvents.JOIN.register((handler, sender, server) -> net.lionarius.skinrestorer.compat.skinshuffle.SkinShuffleCompatibility.onPlayerJoin(handler.getPlayer()));
|
||||
|
||||
ServerPlayNetworking.registerGlobalReceiver(SkinShuffleSkinRefreshV1Payload.PACKET_ID, SkinShuffleCompatibility::handleSkinRefreshV1Packet);
|
||||
|
||||
ServerPlayNetworking.registerGlobalReceiver(SkinShuffleSkinRefreshV2Payload.PACKET_ID, SkinShuffleCompatibility::handleSkinRefreshV2Packet);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
@@ -1,14 +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;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
|
||||
public final class FabricCompatibilityHelper implements CompatibilityHelper {
|
||||
@Override
|
||||
public void skinShuffle_sendHandshake(ServerPlayer player) {
|
||||
ServerPlayNetworking.send(player, SkinShuffleHandshakePayload.PACKET_ID, PacketByteBufs.empty());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,8 +28,5 @@
|
||||
"fabricloader": ">=${fabric_loader_version}",
|
||||
"minecraft": ">=${minecraft_version}",
|
||||
"java": ">=${java_version}"
|
||||
},
|
||||
"suggests": {
|
||||
"fabric-api": "*"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# Forge, see https://files.minecraftforge.net/net/minecraftforge/forge/ for new versions
|
||||
forge_version=46.0.1
|
||||
forge_loader_version_range=[46,)
|
||||
forge_version=41.0.1
|
||||
forge_loader_version_range=[41,)
|
||||
# Forge sometimes skips minor minecraft versions (like 1.20.5)
|
||||
forge_minecraft_version=1.20
|
||||
forge_minecraft_version=1.19
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package net.lionarius.skinrestorer.forge;
|
||||
|
||||
import net.lionarius.skinrestorer.SkinRestorer;
|
||||
import net.lionarius.skinrestorer.compat.skinshuffle.SkinShuffleCompatibility;
|
||||
import net.minecraftforge.event.RegisterCommandsEvent;
|
||||
import net.minecraftforge.event.server.ServerStartedEvent;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
@@ -13,9 +12,6 @@ public final class SkinRestorerForge {
|
||||
|
||||
public SkinRestorerForge() {
|
||||
SkinRestorer.onInitialize();
|
||||
|
||||
if (SkinShuffleCompatibility.shouldApply())
|
||||
net.lionarius.skinrestorer.forge.compat.skinshuffle.SkinShuffleCompatibility.initialize();
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
package net.lionarius.skinrestorer.forge.compat.skinshuffle;
|
||||
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
|
||||
public final class SkinShuffleCompatibility {
|
||||
|
||||
private SkinShuffleCompatibility() {}
|
||||
|
||||
public static void initialize() {
|
||||
MinecraftForge.EVENT_BUS.register(SkinShuffleGameEventHandler.class);
|
||||
|
||||
SkinShufflePacketHandler.initialize();
|
||||
}
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
package net.lionarius.skinrestorer.forge.compat.skinshuffle;
|
||||
|
||||
import net.lionarius.skinrestorer.compat.skinshuffle.SkinShuffleCompatibility;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraftforge.event.entity.player.PlayerEvent;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
|
||||
public final class SkinShuffleGameEventHandler {
|
||||
|
||||
private SkinShuffleGameEventHandler() {}
|
||||
|
||||
@SubscribeEvent
|
||||
public static void onPlayerLoggedIn(PlayerEvent.PlayerLoggedInEvent event) {
|
||||
SkinShuffleCompatibility.onPlayerJoin((ServerPlayer) event.getEntity());
|
||||
}
|
||||
}
|
||||
@@ -1,67 +0,0 @@
|
||||
package net.lionarius.skinrestorer.forge.compat.skinshuffle;
|
||||
|
||||
import io.netty.buffer.Unpooled;
|
||||
import net.lionarius.skinrestorer.compat.skinshuffle.SkinShuffleCompatibility;
|
||||
import net.lionarius.skinrestorer.compat.skinshuffle.*;
|
||||
import net.minecraft.network.Connection;
|
||||
import net.minecraft.network.FriendlyByteBuf;
|
||||
import net.minecraft.network.protocol.game.ClientboundCustomPayloadPacket;
|
||||
import net.minecraftforge.network.NetworkEvent;
|
||||
import net.minecraftforge.network.NetworkRegistry;
|
||||
import net.minecraftforge.network.event.EventNetworkChannel;
|
||||
|
||||
public class SkinShufflePacketHandler {
|
||||
private SkinShufflePacketHandler() {
|
||||
}
|
||||
|
||||
private static final EventNetworkChannel HANDSHAKE_INSTANCE = NetworkRegistry.ChannelBuilder
|
||||
.named(SkinShuffleHandshakePayload.PACKET_ID)
|
||||
.clientAcceptedVersions(NetworkRegistry.acceptMissingOr(""))
|
||||
.serverAcceptedVersions(NetworkRegistry.acceptMissingOr(""))
|
||||
.networkProtocolVersion(() -> "")
|
||||
.eventNetworkChannel();
|
||||
|
||||
private static final EventNetworkChannel SKIN_REFRESH_V1_INSTANCE = NetworkRegistry.ChannelBuilder
|
||||
.named(SkinShuffleSkinRefreshV1Payload.PACKET_ID)
|
||||
.clientAcceptedVersions(NetworkRegistry.acceptMissingOr(""))
|
||||
.serverAcceptedVersions(NetworkRegistry.acceptMissingOr(""))
|
||||
.networkProtocolVersion(() -> "")
|
||||
.eventNetworkChannel();
|
||||
|
||||
private static final EventNetworkChannel SKIN_REFRESH_V2_INSTANCE = NetworkRegistry.ChannelBuilder
|
||||
.named(SkinShuffleSkinRefreshV2Payload.PACKET_ID)
|
||||
.clientAcceptedVersions(NetworkRegistry.acceptMissingOr(""))
|
||||
.serverAcceptedVersions(NetworkRegistry.acceptMissingOr(""))
|
||||
.networkProtocolVersion(() -> "")
|
||||
.eventNetworkChannel();
|
||||
|
||||
protected static void initialize() {
|
||||
SKIN_REFRESH_V1_INSTANCE.addListener(SkinShufflePacketHandler::skinRefreshV1Listener);
|
||||
SKIN_REFRESH_V2_INSTANCE.addListener(SkinShufflePacketHandler::skinRefreshV2Listener);
|
||||
}
|
||||
|
||||
public static void sendHandshake(Connection connection) {
|
||||
connection.send(new ClientboundCustomPayloadPacket(SkinShuffleHandshakePayload.PACKET_ID, new FriendlyByteBuf(Unpooled.buffer(0, 0))));
|
||||
}
|
||||
|
||||
private static void skinRefreshV1Listener(NetworkEvent.ClientCustomPayloadEvent event) {
|
||||
var payload = SkinShuffleSkinRefreshV1Payload.decode(event.getPayload());
|
||||
handleSkinRefreshPacket(payload, event.getSource().get());
|
||||
event.getSource().get().setPacketHandled(true);
|
||||
}
|
||||
|
||||
private static void skinRefreshV2Listener(NetworkEvent.ClientCustomPayloadEvent event) {
|
||||
var payload = SkinShuffleSkinRefreshV2Payload.decode(event.getPayload());
|
||||
handleSkinRefreshPacket(payload, event.getSource().get());
|
||||
event.getSource().get().setPacketHandled(true);
|
||||
}
|
||||
|
||||
private static void handleSkinRefreshPacket(SkinShuffleSkinRefreshPayload payload, NetworkEvent.Context context) {
|
||||
var sender = context.getSender();
|
||||
|
||||
if (!context.getDirection().getReceptionSide().isServer() || sender == null)
|
||||
return;
|
||||
|
||||
SkinShuffleCompatibility.handleSkinRefresh(sender.getServer(), sender, payload);
|
||||
}
|
||||
}
|
||||
@@ -1,13 +1,6 @@
|
||||
package net.lionarius.skinrestorer.forge.platform;
|
||||
|
||||
import net.lionarius.skinrestorer.forge.compat.skinshuffle.SkinShufflePacketHandler;
|
||||
import net.lionarius.skinrestorer.platform.services.CompatibilityHelper;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
|
||||
public final class ForgeCompatibilityHelper implements CompatibilityHelper {
|
||||
|
||||
@Override
|
||||
public void skinShuffle_sendHandshake(ServerPlayer player) {
|
||||
SkinShufflePacketHandler.sendHandshake(player.connection.connection);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,9 +3,9 @@ group=net.lionarius
|
||||
java_version=17
|
||||
|
||||
# Common
|
||||
minecraft_version=1.20
|
||||
minecraft_version_list=1.20,1.20.1
|
||||
minecraft_version_range=[1.20, 1.20.1]
|
||||
minecraft_version=1.19
|
||||
minecraft_version_list=1.19
|
||||
minecraft_version_range=[1.19,1.19.1)
|
||||
mod_id=skinrestorer
|
||||
mod_name=SkinRestorer
|
||||
mod_version=2.3.2
|
||||
@@ -21,8 +21,8 @@ description=A server-side mod for managing skins.
|
||||
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.1
|
||||
parchment_version=2023.09.03
|
||||
parchment_minecraft=1.19.2
|
||||
parchment_version=2022.11.27
|
||||
|
||||
# Publishing
|
||||
curseforge_id=443823
|
||||
|
||||
Reference in New Issue
Block a user