2020-05-06 11:48:49 +02:00
|
|
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
2018-03-18 16:46:14 +01: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.
|
|
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/LoginListener.java b/src/main/java/net/minecraft/server/LoginListener.java
|
2020-08-25 04:22:08 +02:00
|
|
|
index 05583872f118346f6d7e1cd0f2304966ab65b5d9..98fada9761dafe1784c7d579a01b6737d0e29ad5 100644
|
2018-03-18 16:46:14 +01:00
|
|
|
--- a/src/main/java/net/minecraft/server/LoginListener.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/LoginListener.java
|
|
|
|
@@ -1,5 +1,7 @@
|
|
|
|
package net.minecraft.server;
|
|
|
|
|
|
|
|
+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 15:11:48 +02:00
|
|
|
import java.math.BigInteger;
|
|
|
|
@@ -18,6 +20,7 @@ import org.apache.logging.log4j.LogManager;
|
2018-03-18 16:46:14 +01:00
|
|
|
import org.apache.logging.log4j.Logger;
|
|
|
|
|
|
|
|
// CraftBukkit start
|
|
|
|
+import org.bukkit.Bukkit;
|
|
|
|
import org.bukkit.craftbukkit.util.Waitable;
|
|
|
|
import org.bukkit.event.player.AsyncPlayerPreLoginEvent;
|
|
|
|
import org.bukkit.event.player.PlayerPreLoginEvent;
|
2020-06-25 15:11:48 +02:00
|
|
|
@@ -286,8 +289,16 @@ public class LoginListener implements PacketLoginInListener {
|
2018-03-18 16:46:14 +01:00
|
|
|
java.util.UUID uniqueId = i.getId();
|
|
|
|
final org.bukkit.craftbukkit.CraftServer server = LoginListener.this.server.server;
|
|
|
|
|
|
|
|
- AsyncPlayerPreLoginEvent asyncEvent = new AsyncPlayerPreLoginEvent(playerName, address, uniqueId);
|
|
|
|
+ // Paper start
|
|
|
|
+ PlayerProfile profile = Bukkit.createProfile(uniqueId, playerName);
|
|
|
|
+ AsyncPlayerPreLoginEvent asyncEvent = new AsyncPlayerPreLoginEvent(playerName, address, uniqueId, profile);
|
|
|
|
server.getPluginManager().callEvent(asyncEvent);
|
|
|
|
+ profile = asyncEvent.getPlayerProfile();
|
|
|
|
+ profile.complete();
|
|
|
|
+ i = CraftPlayerProfile.asAuthlibCopy(profile);
|
|
|
|
+ playerName = i.getName();
|
|
|
|
+ uniqueId = i.getId();
|
|
|
|
+ // Paper end
|
|
|
|
|
|
|
|
if (PlayerPreLoginEvent.getHandlerList().getRegisteredListeners().length != 0) {
|
|
|
|
final PlayerPreLoginEvent event = new PlayerPreLoginEvent(playerName, address, uniqueId);
|