2020-05-06 09:48:49 +00:00
|
|
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
2018-03-18 15:46:14 +00:00
|
|
|
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.
|
|
|
|
|
2021-03-16 07:19:45 +00:00
|
|
|
diff --git a/src/main/java/net/minecraft/server/network/LoginListener.java b/src/main/java/net/minecraft/server/network/LoginListener.java
|
2021-04-27 23:38:35 +00:00
|
|
|
index f95f5a8b30f42c8f5b6cee3ef6adb1f4e09832dc..31d404c5343c33b9b64724c5ac40d0c52ad5af66 100644
|
2021-03-16 07:19:45 +00:00
|
|
|
--- a/src/main/java/net/minecraft/server/network/LoginListener.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/network/LoginListener.java
|
2018-03-18 15:46:14 +00:00
|
|
|
@@ -1,5 +1,7 @@
|
2021-03-16 07:19:45 +00:00
|
|
|
package net.minecraft.server.network;
|
2018-03-18 15:46:14 +00:00
|
|
|
|
|
|
|
+import com.destroystokyo.paper.profile.CraftPlayerProfile;
|
|
|
|
+import com.destroystokyo.paper.profile.PlayerProfile;
|
|
|
|
import com.mojang.authlib.GameProfile;
|
|
|
|
import com.mojang.authlib.exceptions.AuthenticationUnavailableException;
|
2020-06-25 13:11:48 +00:00
|
|
|
import java.math.BigInteger;
|
2021-03-16 07:19:45 +00:00
|
|
|
@@ -38,6 +40,7 @@ import org.apache.logging.log4j.Logger;
|
2018-03-18 15:46:14 +00:00
|
|
|
// CraftBukkit start
|
2021-03-16 07:19:45 +00:00
|
|
|
import net.minecraft.network.chat.ChatComponentText;
|
2021-02-21 19:45:33 +00:00
|
|
|
import io.papermc.paper.adventure.PaperAdventure; // Paper
|
2018-03-18 15:46:14 +00:00
|
|
|
+import org.bukkit.Bukkit;
|
|
|
|
import org.bukkit.craftbukkit.util.Waitable;
|
|
|
|
import org.bukkit.event.player.AsyncPlayerPreLoginEvent;
|
|
|
|
import org.bukkit.event.player.PlayerPreLoginEvent;
|
2021-04-27 23:38:35 +00:00
|
|
|
@@ -316,8 +319,16 @@ public class LoginListener implements PacketLoginInListener {
|
2020-11-03 02:22:15 +00:00
|
|
|
java.util.UUID uniqueId = i.getId();
|
|
|
|
final org.bukkit.craftbukkit.CraftServer server = LoginListener.this.server.server;
|
2018-03-18 15:46:14 +00:00
|
|
|
|
2020-11-03 02:22:15 +00:00
|
|
|
- AsyncPlayerPreLoginEvent asyncEvent = new AsyncPlayerPreLoginEvent(playerName, address, uniqueId);
|
2018-03-18 15:46:14 +00:00
|
|
|
+ // Paper start
|
|
|
|
+ PlayerProfile profile = Bukkit.createProfile(uniqueId, playerName);
|
|
|
|
+ AsyncPlayerPreLoginEvent asyncEvent = new AsyncPlayerPreLoginEvent(playerName, address, uniqueId, profile);
|
2020-11-03 02:22:15 +00:00
|
|
|
server.getPluginManager().callEvent(asyncEvent);
|
2018-03-18 15:46:14 +00:00
|
|
|
+ profile = asyncEvent.getPlayerProfile();
|
|
|
|
+ profile.complete();
|
|
|
|
+ i = CraftPlayerProfile.asAuthlibCopy(profile);
|
|
|
|
+ playerName = i.getName();
|
|
|
|
+ uniqueId = i.getId();
|
|
|
|
+ // Paper end
|
|
|
|
|
2020-11-03 02:22:15 +00:00
|
|
|
if (PlayerPreLoginEvent.getHandlerList().getRegisteredListeners().length != 0) {
|
|
|
|
final PlayerPreLoginEvent event = new PlayerPreLoginEvent(playerName, address, uniqueId);
|