mirror of
https://github.com/Suiranoil/SkinRestorer.git
synced 2026-01-16 04:42:12 +00:00
formatting
This commit is contained in:
@@ -22,7 +22,7 @@ public record SkinShuffleSkinRefreshV1Payload(
|
|||||||
buf.writeUtf(textureProperty.value());
|
buf.writeUtf(textureProperty.value());
|
||||||
buf.writeNullable(textureProperty.signature(), FriendlyByteBuf::writeUtf);
|
buf.writeNullable(textureProperty.signature(), FriendlyByteBuf::writeUtf);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static SkinShuffleSkinRefreshV1Payload decode(FriendlyByteBuf buf) {
|
public static SkinShuffleSkinRefreshV1Payload decode(FriendlyByteBuf buf) {
|
||||||
return new SkinShuffleSkinRefreshV1Payload(new Property(buf.readUtf(), buf.readUtf(), buf.readNullable(FriendlyByteBuf::readUtf)));
|
return new SkinShuffleSkinRefreshV1Payload(new Property(buf.readUtf(), buf.readUtf(), buf.readNullable(FriendlyByteBuf::readUtf)));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ public record SkinShuffleSkinRefreshV2Payload(
|
|||||||
SkinShuffleSkinRefreshV2Payload::encode,
|
SkinShuffleSkinRefreshV2Payload::encode,
|
||||||
SkinShuffleSkinRefreshV2Payload::decode
|
SkinShuffleSkinRefreshV2Payload::decode
|
||||||
);
|
);
|
||||||
|
|
||||||
public static void encode(FriendlyByteBuf buf, SkinShuffleSkinRefreshV2Payload value) {
|
public static void encode(FriendlyByteBuf buf, SkinShuffleSkinRefreshV2Payload value) {
|
||||||
var textureProperty = value.textureProperty();
|
var textureProperty = value.textureProperty();
|
||||||
|
|
||||||
@@ -27,7 +27,7 @@ public record SkinShuffleSkinRefreshV2Payload(
|
|||||||
buf.writeUtf(textureProperty.signature());
|
buf.writeUtf(textureProperty.signature());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static SkinShuffleSkinRefreshV2Payload decode(FriendlyByteBuf buf) {
|
public static SkinShuffleSkinRefreshV2Payload decode(FriendlyByteBuf buf) {
|
||||||
if (buf.readBoolean()) {
|
if (buf.readBoolean()) {
|
||||||
return new SkinShuffleSkinRefreshV2Payload(new Property(buf.readUtf(), buf.readUtf(), buf.readUtf()));
|
return new SkinShuffleSkinRefreshV2Payload(new Property(buf.readUtf(), buf.readUtf(), buf.readUtf()));
|
||||||
|
|||||||
@@ -5,20 +5,20 @@ import net.lionarius.skinrestorer.SkinRestorer;
|
|||||||
public final class CacheConfig {
|
public final class CacheConfig {
|
||||||
private boolean enabled;
|
private boolean enabled;
|
||||||
private long duration;
|
private long duration;
|
||||||
|
|
||||||
public CacheConfig(boolean enabled, long duration) {
|
public CacheConfig(boolean enabled, long duration) {
|
||||||
this.enabled = enabled;
|
this.enabled = enabled;
|
||||||
this.duration = duration;
|
this.duration = duration;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean enabled() {
|
public boolean enabled() {
|
||||||
return enabled;
|
return enabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
public long duration() {
|
public long duration() {
|
||||||
return duration;
|
return duration;
|
||||||
}
|
}
|
||||||
|
|
||||||
void validate(CacheConfig defaultValue) {
|
void validate(CacheConfig defaultValue) {
|
||||||
if (this.duration <= 0) {
|
if (this.duration <= 0) {
|
||||||
SkinRestorer.LOGGER.warn("Cache duration is less than or equal to zero, defaulting to {}", defaultValue.duration());
|
SkinRestorer.LOGGER.warn("Cache duration is less than or equal to zero, defaulting to {}", defaultValue.duration());
|
||||||
|
|||||||
@@ -9,41 +9,41 @@ public final class ProvidersConfig implements GsonPostProcessable {
|
|||||||
new ElyByProviderConfig(),
|
new ElyByProviderConfig(),
|
||||||
new MineskinProviderConfig()
|
new MineskinProviderConfig()
|
||||||
);
|
);
|
||||||
|
|
||||||
private MojangProviderConfig mojang;
|
private MojangProviderConfig mojang;
|
||||||
private ElyByProviderConfig ely_by;
|
private ElyByProviderConfig ely_by;
|
||||||
private MineskinProviderConfig mineskin;
|
private MineskinProviderConfig mineskin;
|
||||||
|
|
||||||
public ProvidersConfig(MojangProviderConfig mojang, ElyByProviderConfig ely_by, MineskinProviderConfig mineskin) {
|
public ProvidersConfig(MojangProviderConfig mojang, ElyByProviderConfig ely_by, MineskinProviderConfig mineskin) {
|
||||||
this.mojang = mojang;
|
this.mojang = mojang;
|
||||||
this.ely_by = ely_by;
|
this.ely_by = ely_by;
|
||||||
this.mineskin = mineskin;
|
this.mineskin = mineskin;
|
||||||
}
|
}
|
||||||
|
|
||||||
public MojangProviderConfig mojang() {
|
public MojangProviderConfig mojang() {
|
||||||
return this.mojang;
|
return this.mojang;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ElyByProviderConfig ely_by() {
|
public ElyByProviderConfig ely_by() {
|
||||||
return this.ely_by;
|
return this.ely_by;
|
||||||
}
|
}
|
||||||
|
|
||||||
public MineskinProviderConfig mineskin() {
|
public MineskinProviderConfig mineskin() {
|
||||||
return this.mineskin;
|
return this.mineskin;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void gsonPostProcess() {
|
public void gsonPostProcess() {
|
||||||
if (this.mojang == null) {
|
if (this.mojang == null) {
|
||||||
SkinRestorer.LOGGER.warn("Mojang provider config is null, using default");
|
SkinRestorer.LOGGER.warn("Mojang provider config is null, using default");
|
||||||
this.mojang = ProvidersConfig.DEFAULT.mojang();
|
this.mojang = ProvidersConfig.DEFAULT.mojang();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.ely_by == null) {
|
if (this.ely_by == null) {
|
||||||
SkinRestorer.LOGGER.warn("Ely.By provider config is null, using default");
|
SkinRestorer.LOGGER.warn("Ely.By provider config is null, using default");
|
||||||
this.ely_by = ProvidersConfig.DEFAULT.ely_by();
|
this.ely_by = ProvidersConfig.DEFAULT.ely_by();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.mineskin == null) {
|
if (this.mineskin == null) {
|
||||||
SkinRestorer.LOGGER.warn("Mineskin provider config is null, using default");
|
SkinRestorer.LOGGER.warn("Mineskin provider config is null, using default");
|
||||||
this.mineskin = ProvidersConfig.DEFAULT.mineskin();
|
this.mineskin = ProvidersConfig.DEFAULT.mineskin();
|
||||||
|
|||||||
@@ -8,11 +8,11 @@ import java.util.ServiceLoader;
|
|||||||
|
|
||||||
public final class Services {
|
public final class Services {
|
||||||
|
|
||||||
private Services() {}
|
|
||||||
|
|
||||||
public final static PlatformHelper PLATFORM = load(PlatformHelper.class);
|
public final static PlatformHelper PLATFORM = load(PlatformHelper.class);
|
||||||
public final static CompatibilityHelper COMPATIBILITY = load(CompatibilityHelper.class);
|
public final static CompatibilityHelper COMPATIBILITY = load(CompatibilityHelper.class);
|
||||||
|
|
||||||
|
private Services() {}
|
||||||
|
|
||||||
private static <T> T load(Class<T> clazz) {
|
private static <T> T load(Class<T> clazz) {
|
||||||
final T loadedService = ServiceLoader.load(clazz)
|
final T loadedService = ServiceLoader.load(clazz)
|
||||||
.findFirst()
|
.findFirst()
|
||||||
|
|||||||
@@ -19,6 +19,18 @@ public class Result<S, E> {
|
|||||||
this.errorValue = errorValue;
|
this.errorValue = errorValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static <S, E> Result<S, E> success(@NotNull S successValue) {
|
||||||
|
return new Result<>(successValue, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static <S, E> Result<S, E> error(@NotNull E errorValue) {
|
||||||
|
return new Result<>(null, errorValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static <S, E> Result<Optional<S>, E> ofNullable(S successValue) {
|
||||||
|
return Result.success(Optional.ofNullable(successValue));
|
||||||
|
}
|
||||||
|
|
||||||
public S getSuccessValue() {
|
public S getSuccessValue() {
|
||||||
return successValue;
|
return successValue;
|
||||||
}
|
}
|
||||||
@@ -69,16 +81,4 @@ public class Result<S, E> {
|
|||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return Objects.hash(successValue, errorValue);
|
return Objects.hash(successValue, errorValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static <S, E> Result<S, E> success(@NotNull S successValue) {
|
|
||||||
return new Result<>(successValue, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static <S, E> Result<S, E> error(@NotNull E errorValue) {
|
|
||||||
return new Result<>(null, errorValue);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static <S, E> Result<Optional<S>, E> ofNullable(S successValue) {
|
|
||||||
return Result.success(Optional.ofNullable(successValue));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,8 +13,6 @@ import java.time.temporal.ChronoUnit;
|
|||||||
|
|
||||||
public final class WebUtils {
|
public final class WebUtils {
|
||||||
|
|
||||||
private WebUtils() {}
|
|
||||||
|
|
||||||
public static final String USER_AGENT;
|
public static final String USER_AGENT;
|
||||||
|
|
||||||
private static HttpClient HTTP_CLIENT = null;
|
private static HttpClient HTTP_CLIENT = null;
|
||||||
@@ -23,6 +21,8 @@ public final class WebUtils {
|
|||||||
USER_AGENT = String.format("SkinRestorer/%d", System.currentTimeMillis() % 65535);
|
USER_AGENT = String.format("SkinRestorer/%d", System.currentTimeMillis() % 65535);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private WebUtils() {}
|
||||||
|
|
||||||
public static void recreateHttpClient() {
|
public static void recreateHttpClient() {
|
||||||
HTTP_CLIENT = WebUtils.buildClient();
|
HTTP_CLIENT = WebUtils.buildClient();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
package net.lionarius.skinrestorer.forge.compat.skinshuffle;
|
package net.lionarius.skinrestorer.forge.compat.skinshuffle;
|
||||||
|
|
||||||
import net.lionarius.skinrestorer.SkinRestorer;
|
import net.lionarius.skinrestorer.SkinRestorer;
|
||||||
import net.lionarius.skinrestorer.compat.skinshuffle.SkinShuffleCompatibility;
|
|
||||||
import net.lionarius.skinrestorer.compat.skinshuffle.*;
|
import net.lionarius.skinrestorer.compat.skinshuffle.*;
|
||||||
|
import net.lionarius.skinrestorer.compat.skinshuffle.SkinShuffleCompatibility;
|
||||||
import net.minecraft.network.Connection;
|
import net.minecraft.network.Connection;
|
||||||
import net.minecraft.network.protocol.common.custom.CustomPacketPayload;
|
import net.minecraft.network.protocol.common.custom.CustomPacketPayload;
|
||||||
import net.minecraftforge.event.network.CustomPayloadEvent;
|
import net.minecraftforge.event.network.CustomPayloadEvent;
|
||||||
@@ -10,9 +10,6 @@ import net.minecraftforge.network.Channel;
|
|||||||
import net.minecraftforge.network.ChannelBuilder;
|
import net.minecraftforge.network.ChannelBuilder;
|
||||||
|
|
||||||
public class SkinShufflePacketHandler {
|
public class SkinShufflePacketHandler {
|
||||||
private SkinShufflePacketHandler() {
|
|
||||||
}
|
|
||||||
|
|
||||||
private static final Channel<CustomPacketPayload> INSTANCE = ChannelBuilder
|
private static final Channel<CustomPacketPayload> INSTANCE = ChannelBuilder
|
||||||
.named(SkinRestorer.resourceLocation("skin_shuffle_compat"))
|
.named(SkinRestorer.resourceLocation("skin_shuffle_compat"))
|
||||||
.optional()
|
.optional()
|
||||||
@@ -26,6 +23,9 @@ public class SkinShufflePacketHandler {
|
|||||||
.add(SkinShuffleSkinRefreshV2Payload.PACKET_ID, SkinShuffleSkinRefreshV2Payload.PACKET_CODEC, SkinShufflePacketHandler::handleSkinRefreshPacket)
|
.add(SkinShuffleSkinRefreshV2Payload.PACKET_ID, SkinShuffleSkinRefreshV2Payload.PACKET_CODEC, SkinShufflePacketHandler::handleSkinRefreshPacket)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
|
private SkinShufflePacketHandler() {
|
||||||
|
}
|
||||||
|
|
||||||
protected static void initialize() {
|
protected static void initialize() {
|
||||||
// NO-OP
|
// NO-OP
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package net.lionarius.skinrestorer.neoforge.compat.skinshuffle;
|
package net.lionarius.skinrestorer.neoforge.compat.skinshuffle;
|
||||||
|
|
||||||
import net.lionarius.skinrestorer.compat.skinshuffle.SkinShuffleCompatibility;
|
|
||||||
import net.lionarius.skinrestorer.compat.skinshuffle.*;
|
import net.lionarius.skinrestorer.compat.skinshuffle.*;
|
||||||
|
import net.lionarius.skinrestorer.compat.skinshuffle.SkinShuffleCompatibility;
|
||||||
import net.minecraft.server.level.ServerPlayer;
|
import net.minecraft.server.level.ServerPlayer;
|
||||||
import net.neoforged.bus.api.SubscribeEvent;
|
import net.neoforged.bus.api.SubscribeEvent;
|
||||||
import net.neoforged.neoforge.network.event.RegisterPayloadHandlersEvent;
|
import net.neoforged.neoforge.network.event.RegisterPayloadHandlersEvent;
|
||||||
|
|||||||
Reference in New Issue
Block a user