Paper/patches/server/0181-Ability-to-change-PlayerProfile-in-AsyncPreLoginEven.patch

30 lines
2.1 KiB
Diff
Raw Normal View History

2021-06-11 14:02:28 +02:00
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Sun, 18 Mar 2018 11:45:57 -0400
Subject: [PATCH] Ability to change PlayerProfile in AsyncPreLoginEvent
This will allow you to change the players name or skin on login.
diff --git a/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
2023-09-22 06:05:18 +02:00
index 1202a60cf955dbfbfc2135c06d3304f215b23c2c..41de3c342f1dae9fc6af1b4938a676d337bcf5fa 100644
2021-06-11 14:02:28 +02:00
--- a/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
+++ b/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
2023-09-21 23:04:51 +02:00
@@ -292,8 +292,16 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener,
java.util.UUID uniqueId = gameprofile.getId();
2021-06-11 14:02:28 +02:00
final org.bukkit.craftbukkit.CraftServer server = ServerLoginPacketListenerImpl.this.server.server;
- AsyncPlayerPreLoginEvent asyncEvent = new AsyncPlayerPreLoginEvent(playerName, address, uniqueId);
2022-03-01 06:43:03 +01:00
+ // Paper start
+ com.destroystokyo.paper.profile.PlayerProfile profile = org.bukkit.Bukkit.createProfile(uniqueId, playerName);
+ AsyncPlayerPreLoginEvent asyncEvent = new AsyncPlayerPreLoginEvent(playerName, address, uniqueId, profile);
2021-06-11 14:02:28 +02:00
server.getPluginManager().callEvent(asyncEvent);
2022-03-01 06:43:03 +01:00
+ profile = asyncEvent.getPlayerProfile();
+ profile.complete();
2023-09-22 06:05:18 +02:00
+ gameprofile = com.destroystokyo.paper.profile.CraftPlayerProfile.asAuthlibCopy(profile);
+ playerName = gameprofile.getName();
+ uniqueId = gameprofile.getId();
2022-03-01 06:43:03 +01:00
+ // Paper end
2021-06-11 14:02:28 +02:00
if (PlayerPreLoginEvent.getHandlerList().getRegisteredListeners().length != 0) {
final PlayerPreLoginEvent event = new PlayerPreLoginEvent(playerName, address, uniqueId);