Mirror von
https://github.com/PaperMC/Paper.git
synchronisiert 2024-11-16 21:10:17 +01:00
[Bleeding] Implemented getting the hostname a player used to log in. Addresses BUKKIT-984
Dieser Commit ist enthalten in:
Ursprung
97669f8d90
Commit
a602d5c8c1
@ -22,6 +22,7 @@ public class NetLoginHandler extends NetHandler {
|
||||
private String g = null;
|
||||
private Packet1Login h = null;
|
||||
private String loginKey = Long.toString(random.nextLong(), 16); // CraftBukkit - Security fix
|
||||
public String hostname = ""; // CraftBukkit - add field
|
||||
|
||||
public NetLoginHandler(MinecraftServer minecraftserver, Socket socket, String s) {
|
||||
this.server = minecraftserver;
|
||||
@ -60,6 +61,12 @@ public class NetLoginHandler extends NetHandler {
|
||||
}
|
||||
|
||||
public void a(Packet2Handshake packet2handshake) {
|
||||
// CraftBukkit start
|
||||
int i = packet2handshake.a.indexOf(';');
|
||||
if (i == -1) {
|
||||
this.hostname = "";
|
||||
} else this.hostname = packet2handshake.a.substring(i + 1);
|
||||
// CraftBukkit end
|
||||
if (this.server.onlineMode) {
|
||||
this.loginKey = Long.toString(random.nextLong(), 16);
|
||||
this.networkManager.queue(new Packet2Handshake(this.loginKey));
|
||||
@ -92,7 +99,7 @@ public class NetLoginHandler extends NetHandler {
|
||||
}
|
||||
|
||||
public void b(Packet1Login packet1login) {
|
||||
EntityPlayer entityplayer = this.server.serverConfigurationManager.attemptLogin(this, packet1login.name);
|
||||
EntityPlayer entityplayer = this.server.serverConfigurationManager.attemptLogin(this, packet1login.name, this.hostname); // CraftBukkit - add hostname parameter
|
||||
|
||||
if (entityplayer != null) {
|
||||
this.server.serverConfigurationManager.b(entityplayer);
|
||||
|
@ -199,14 +199,14 @@ public class ServerConfigurationManager {
|
||||
return playerQuitEvent.getQuitMessage(); // CraftBukkit
|
||||
}
|
||||
|
||||
public EntityPlayer attemptLogin(NetLoginHandler netloginhandler, String s) {
|
||||
public EntityPlayer attemptLogin(NetLoginHandler netloginhandler, String s, String hostname) { // CraftBukkit - add hostname parameter
|
||||
// CraftBukkit start - note: this entire method needs to be changed
|
||||
// Instead of kicking then returning, we need to store the kick reason
|
||||
// in the event, check with plugins to see if it's ok, and THEN kick
|
||||
// depending on the outcome. Also change any reference to this.e.c to entity.world
|
||||
EntityPlayer entity = new EntityPlayer(this.server, this.server.getWorldServer(0), s, new ItemInWorldManager(this.server.getWorldServer(0)));
|
||||
Player player = (entity == null) ? null : (Player) entity.getBukkitEntity();
|
||||
PlayerLoginEvent event = new PlayerLoginEvent(player);
|
||||
Player player = (Player) entity.getBukkitEntity();
|
||||
PlayerLoginEvent event = new PlayerLoginEvent(player, hostname);
|
||||
|
||||
String s1 = netloginhandler.networkManager.getSocketAddress().toString();
|
||||
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren