Skip to content

Commit ebaca20

Browse files
authored
Added getHostname to AsyncPlayerPreLoginEvent (#6656)
1 parent cb198ff commit ebaca20

File tree

2 files changed

+80
-0
lines changed

2 files changed

+80
-0
lines changed
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2+
From: MCMDEV <john-m.1@gmx.de>
3+
Date: Fri, 24 Sep 2021 17:59:23 +0200
4+
Subject: [PATCH] Added getHostname to AsyncPlayerPreLoginEvent
5+
6+
7+
diff --git a/src/main/java/org/bukkit/event/player/AsyncPlayerPreLoginEvent.java b/src/main/java/org/bukkit/event/player/AsyncPlayerPreLoginEvent.java
8+
index 694a81769076ea58aae9f14f076ab80c9952c957..356d1154b0732e2daf242d60fa715dba9f2dc9db 100644
9+
--- a/src/main/java/org/bukkit/event/player/AsyncPlayerPreLoginEvent.java
10+
+++ b/src/main/java/org/bukkit/event/player/AsyncPlayerPreLoginEvent.java
11+
@@ -22,6 +22,7 @@ public class AsyncPlayerPreLoginEvent extends Event {
12+
private final InetAddress ipAddress;
13+
private final InetAddress rawAddress; // Paper
14+
//private UUID uniqueId; // Paper - Not used anymore
15+
+ private final String hostname; // Paper
16+
17+
@Deprecated
18+
public AsyncPlayerPreLoginEvent(@NotNull final String name, @NotNull final InetAddress ipAddress) {
19+
@@ -66,7 +67,14 @@ public class AsyncPlayerPreLoginEvent extends Event {
20+
this(name, ipAddress, ipAddress, uniqueId, profile);
21+
}
22+
23+
+ @Deprecated // Paper - Add hostname
24+
public AsyncPlayerPreLoginEvent(@NotNull final String name, @NotNull final InetAddress ipAddress, @NotNull final InetAddress rawAddress, @NotNull final UUID uniqueId, @NotNull PlayerProfile profile) {
25+
+ // Paper start - Add hostname
26+
+ this(name, ipAddress, rawAddress, uniqueId, profile, "");
27+
+ }
28+
+
29+
+ public AsyncPlayerPreLoginEvent(@NotNull final String name, @NotNull final InetAddress ipAddress, @NotNull final InetAddress rawAddress, @NotNull final UUID uniqueId, @NotNull PlayerProfile profile, @NotNull String hostname) {
30+
+ // Paper end - Add hostname
31+
super(true);
32+
this.profile = profile;
33+
// Paper end
34+
@@ -76,6 +84,7 @@ public class AsyncPlayerPreLoginEvent extends Event {
35+
this.ipAddress = ipAddress;
36+
this.rawAddress = rawAddress; // Paper
37+
//this.uniqueId = uniqueId; // Paper - Not used anymore
38+
+ this.hostname = hostname; // Paper - Add hostname
39+
}
40+
41+
/**
42+
@@ -261,6 +270,19 @@ public class AsyncPlayerPreLoginEvent extends Event {
43+
return profile.getId(); // Paper
44+
}
45+
46+
+ // Paper start
47+
+ /**
48+
+ * Gets the hostname that the player used to connect to the server, or
49+
+ * blank if unknown
50+
+ *
51+
+ * @return The hostname
52+
+ */
53+
+ @NotNull
54+
+ public String getHostname() {
55+
+ return hostname;
56+
+ }
57+
+ // Paper end
58+
+
59+
@NotNull
60+
@Override
61+
public HandlerList getHandlers() {
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2+
From: MCMDEV <john-m.1@gmx.de>
3+
Date: Fri, 24 Sep 2021 17:59:21 +0200
4+
Subject: [PATCH] Added getHostname to AsyncPlayerPreLoginEvent
5+
6+
7+
diff --git a/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
8+
index 462d8c36166c63a4dc8fa74ac7f82859e6f4b83a..60ba196e17df34c3ae2a9883e5d28830a2243517 100644
9+
--- a/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
10+
+++ b/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
11+
@@ -391,7 +391,7 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener
12+
13+
// Paper start
14+
PlayerProfile profile = CraftPlayerProfile.asBukkitMirror(ServerLoginPacketListenerImpl.this.gameProfile);
15+
- AsyncPlayerPreLoginEvent asyncEvent = new AsyncPlayerPreLoginEvent(playerName, address, rawAddress, uniqueId, profile);
16+
+ AsyncPlayerPreLoginEvent asyncEvent = new AsyncPlayerPreLoginEvent(playerName, address, rawAddress, uniqueId, profile, ServerLoginPacketListenerImpl.this.hostname);
17+
server.getPluginManager().callEvent(asyncEvent);
18+
profile = asyncEvent.getPlayerProfile();
19+
profile.complete(true);

0 commit comments

Comments
 (0)