mirror of
https://github.com/Suiranoil/SkinRestorer.git
synced 2026-01-16 04:42:12 +00:00
Merge branch '1.19.4-multiloader' into 1.19.3-multiloader
This commit is contained in:
@@ -5,26 +5,17 @@ import net.minecraft.network.Connection;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
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;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
@Mixin(PlayerList.class)
|
||||
public abstract class PlayerListMixin {
|
||||
|
||||
@Shadow
|
||||
public abstract List<ServerPlayer> getPlayers();
|
||||
|
||||
@Shadow @Final
|
||||
private MinecraftServer server;
|
||||
|
||||
@Inject(method = "remove", at = @At("TAIL"))
|
||||
private void remove(ServerPlayer player, CallbackInfo ci) {
|
||||
SkinRestorer.Events.onPlayerDisconnect(player);
|
||||
@@ -32,13 +23,14 @@ public abstract class PlayerListMixin {
|
||||
|
||||
@Inject(method = "removeAll", at = @At("HEAD"))
|
||||
private void removeAll(CallbackInfo ci) {
|
||||
for (var player : getPlayers()) {
|
||||
for (var player : ((PlayerList) (Object) this).getPlayers()) {
|
||||
SkinRestorer.Events.onPlayerDisconnect(player);
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "placeNewPlayer", at = @At("HEAD"))
|
||||
private void placeNewPlayer(Connection connection, ServerPlayer player, CallbackInfo ci) {
|
||||
var server = ((PlayerList) (Object) this).getServer();
|
||||
var delay = SkinRestorer.getConfig().skinApplyDelayOnJoin();
|
||||
|
||||
if (delay <= 0) {
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
package net.lionarius.skinrestorer.mixin;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import net.minecraft.server.network.ServerLoginPacketListenerImpl;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.gen.Accessor;
|
||||
import org.spongepowered.asm.mixin.gen.Invoker;
|
||||
|
||||
@Mixin(ServerLoginPacketListenerImpl.class)
|
||||
public interface ServerLoginPacketListenerImplAccessorInvoker {
|
||||
|
||||
@Accessor
|
||||
GameProfile getGameProfile();
|
||||
|
||||
@Invoker
|
||||
GameProfile invokeCreateFakeProfile(GameProfile original);
|
||||
}
|
||||
@@ -20,24 +20,18 @@ import java.util.concurrent.CompletableFuture;
|
||||
@Mixin(ServerLoginPacketListenerImpl.class)
|
||||
public abstract class ServerLoginPacketListenerImplMixin {
|
||||
|
||||
@Shadow @Nullable
|
||||
private GameProfile gameProfile;
|
||||
|
||||
@Unique
|
||||
private CompletableFuture<Void> skinrestorer$pendingSkin;
|
||||
|
||||
@Shadow
|
||||
protected abstract GameProfile createFakeProfile(GameProfile original);
|
||||
|
||||
@Inject(method = "handleAcceptedLogin", at = @At(value = "HEAD"), cancellable = true)
|
||||
public void waitForSkin(CallbackInfo ci) {
|
||||
if (skinrestorer$pendingSkin == null) {
|
||||
skinrestorer$pendingSkin = CompletableFuture.supplyAsync(() -> {
|
||||
var profile = gameProfile;
|
||||
var profile = ((ServerLoginPacketListenerImplAccessorInvoker) this).getGameProfile();
|
||||
assert profile != null;
|
||||
|
||||
if (!profile.isComplete())
|
||||
profile = createFakeProfile(profile);
|
||||
profile = ((ServerLoginPacketListenerImplAccessorInvoker) this).invokeCreateFakeProfile(profile);
|
||||
|
||||
var originalSkin = PlayerUtils.getPlayerSkin(profile);
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
"mixins": [
|
||||
"ChunkMapAccessor",
|
||||
"PlayerListMixin",
|
||||
"ServerLoginPacketListenerImplAccessorInvoker",
|
||||
"ServerLoginPacketListenerImplMixin",
|
||||
"TrackedEntityAccessorInvoker"
|
||||
],
|
||||
|
||||
Reference in New Issue
Block a user