Fix 'java.lang.reflect.InvocationTargetException' for RPlayer being initialised

This commit is contained in:
2025-06-28 13:32:50 +02:00
parent bc5e781810
commit d06faa5d18
2 changed files with 13 additions and 12 deletions
@@ -26,6 +26,7 @@ import de.steamwar.core.BountifulWrapper;
import de.steamwar.core.Core;
import de.steamwar.core.FlatteningWrapper;
import de.steamwar.core.ProtocolWrapper;
import de.steamwar.network.CoreNetworkHandler;
import de.steamwar.network.NetworkSender;
import de.steamwar.network.packets.common.PlayerSkinRequestPacket;
import lombok.Getter;
@@ -34,7 +35,6 @@ import org.bukkit.Location;
import org.bukkit.entity.EntityType;
import org.bukkit.inventory.ItemStack;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.UUID;
import java.util.function.Consumer;
@@ -75,15 +75,8 @@ public class RPlayer extends REntity {
server.addEntity(this);
}
public static final Map<UUID, Property> SKIN_DATA_PROMISES = new LinkedHashMap<UUID, Property>() {
@Override
protected boolean removeEldestEntry(Map.Entry<UUID, Property> eldest) {
return size() > 100;
}
};
private GameProfile getGameProfile() {
Property skinData = SKIN_DATA_PROMISES.computeIfAbsent(uuid, __ -> {
Property skinData = CoreNetworkHandler.SKIN_DATA_PROMISES.computeIfAbsent(uuid, __ -> {
NetworkSender.sendOrQueue(new PlayerSkinRequestPacket(uuid));
return new Property("textures", null, null);
});
@@ -21,7 +21,6 @@ package de.steamwar.network;
import com.mojang.authlib.properties.Property;
import de.steamwar.core.BountifulWrapper;
import de.steamwar.entity.RPlayer;
import de.steamwar.network.handlers.InventoryHandler;
import de.steamwar.network.packets.PacketHandler;
import de.steamwar.network.packets.common.PlayerSkinResponsePacket;
@@ -31,6 +30,8 @@ import de.steamwar.sql.SteamwarUser;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.UUID;
public class CoreNetworkHandler extends PacketHandler {
@@ -72,9 +73,16 @@ public class CoreNetworkHandler extends PacketHandler {
SteamwarUser.invalidate(packet.getPlayerId());
}
public static final Map<UUID, Property> SKIN_DATA_PROMISES = new LinkedHashMap<UUID, Property>() {
@Override
protected boolean removeEldestEntry(Map.Entry<UUID, Property> eldest) {
return size() > 100;
}
};
@Handler
public void handlePlayerSkinResponse(PlayerSkinResponsePacket packet) {
if (!RPlayer.SKIN_DATA_PROMISES.containsKey(packet.getUuid())) return;
RPlayer.SKIN_DATA_PROMISES.put(packet.getUuid(), new Property("textures", packet.getSkin(), packet.getSignature()));
if (!SKIN_DATA_PROMISES.containsKey(packet.getUuid())) return;
SKIN_DATA_PROMISES.put(packet.getUuid(), new Property("textures", packet.getSkin(), packet.getSignature()));
}
}