@@ -15,25 +15,25 @@
|
||||
+ private static final HashMap<InetAddress, Long> throttleTracker = new HashMap<InetAddress, Long>();
|
||||
+ private static int throttleCounter = 0;
|
||||
+ // CraftBukkit end
|
||||
private static final IChatBaseComponent a = new ChatComponentText("Ignoring status request");
|
||||
private final MinecraftServer b;
|
||||
private final NetworkManager c;
|
||||
private static final IChatBaseComponent IGNORE_STATUS_REASON = new ChatComponentText("Ignoring status request");
|
||||
private final MinecraftServer server;
|
||||
private final NetworkManager connection;
|
||||
@@ -27,6 +36,40 @@
|
||||
switch (packethandshakinginsetprotocol.b()) {
|
||||
case LOGIN:
|
||||
this.c.setProtocol(EnumProtocol.LOGIN);
|
||||
this.connection.setProtocol(EnumProtocol.LOGIN);
|
||||
+ // CraftBukkit start - Connection throttle
|
||||
+ try {
|
||||
+ long currentTime = System.currentTimeMillis();
|
||||
+ long connectionThrottle = this.b.server.getConnectionThrottle();
|
||||
+ InetAddress address = ((java.net.InetSocketAddress) this.c.getSocketAddress()).getAddress();
|
||||
+ long connectionThrottle = this.server.server.getConnectionThrottle();
|
||||
+ InetAddress address = ((java.net.InetSocketAddress) this.connection.getSocketAddress()).getAddress();
|
||||
+
|
||||
+ synchronized (throttleTracker) {
|
||||
+ if (throttleTracker.containsKey(address) && !"127.0.0.1".equals(address.getHostAddress()) && currentTime - throttleTracker.get(address) < connectionThrottle) {
|
||||
+ throttleTracker.put(address, currentTime);
|
||||
+ ChatMessage chatmessage = new ChatMessage("Connection throttled! Please wait before reconnecting.");
|
||||
+ this.c.sendPacket(new PacketLoginOutDisconnect(chatmessage));
|
||||
+ this.c.close(chatmessage);
|
||||
+ this.connection.sendPacket(new PacketLoginOutDisconnect(chatmessage));
|
||||
+ this.connection.close(chatmessage);
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
@@ -60,10 +60,10 @@
|
||||
ChatMessage chatmessage;
|
||||
|
||||
@@ -40,6 +83,7 @@
|
||||
this.c.close(chatmessage);
|
||||
this.connection.close(chatmessage);
|
||||
} else {
|
||||
this.c.setPacketListener(new LoginListener(this.b, this.c));
|
||||
+ ((LoginListener) this.c.j()).hostname = packethandshakinginsetprotocol.hostname + ":" + packethandshakinginsetprotocol.port; // CraftBukkit - set hostname
|
||||
this.connection.setPacketListener(new LoginListener(this.server, this.connection));
|
||||
+ ((LoginListener) this.connection.j()).hostname = packethandshakinginsetprotocol.hostName + ":" + packethandshakinginsetprotocol.port; // CraftBukkit - set hostname
|
||||
}
|
||||
break;
|
||||
case STATUS:
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
--- a/net/minecraft/server/network/LegacyPingHandler.java
|
||||
+++ b/net/minecraft/server/network/LegacyPingHandler.java
|
||||
@@ -35,11 +35,12 @@
|
||||
MinecraftServer minecraftserver = this.b.d();
|
||||
@@ -36,11 +36,12 @@
|
||||
MinecraftServer minecraftserver = this.serverConnectionListener.d();
|
||||
int i = bytebuf.readableBytes();
|
||||
String s;
|
||||
+ org.bukkit.event.server.ServerListPingEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callServerListPingEvent(minecraftserver.server, inetsocketaddress.getAddress(), minecraftserver.getMotd(), minecraftserver.getPlayerCount(), minecraftserver.getMaxPlayers()); // CraftBukkit
|
||||
@@ -14,7 +14,7 @@
|
||||
this.a(channelhandlercontext, this.a(s));
|
||||
break;
|
||||
case 1:
|
||||
@@ -48,7 +49,7 @@
|
||||
@@ -49,7 +50,7 @@
|
||||
}
|
||||
|
||||
LegacyPingHandler.LOGGER.debug("Ping: (1.4-1.5.x) from {}:{}", inetsocketaddress.getAddress(), inetsocketaddress.getPort());
|
||||
@@ -23,7 +23,7 @@
|
||||
this.a(channelhandlercontext, this.a(s));
|
||||
break;
|
||||
default:
|
||||
@@ -67,7 +68,7 @@
|
||||
@@ -68,7 +69,7 @@
|
||||
}
|
||||
|
||||
LegacyPingHandler.LOGGER.debug("Ping: (1.6) from {}:{}", inetsocketaddress.getAddress(), inetsocketaddress.getPort());
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/server/network/LoginListener.java
|
||||
+++ b/net/minecraft/server/network/LoginListener.java
|
||||
@@ -35,6 +35,13 @@
|
||||
@@ -36,6 +36,13 @@
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
@@ -13,16 +13,16 @@
|
||||
+
|
||||
public class LoginListener implements PacketLoginInListener {
|
||||
|
||||
private static final AtomicInteger b = new AtomicInteger(0);
|
||||
@@ -49,6 +56,7 @@
|
||||
private final String j;
|
||||
private SecretKey loginKey;
|
||||
private EntityPlayer l;
|
||||
private static final AtomicInteger UNIQUE_THREAD_ID = new AtomicInteger(0);
|
||||
@@ -52,6 +59,7 @@
|
||||
private final String serverId;
|
||||
@Nullable
|
||||
private EntityPlayer delayedAcceptPlayer;
|
||||
+ public String hostname = ""; // CraftBukkit - add field
|
||||
|
||||
public LoginListener(MinecraftServer minecraftserver, NetworkManager networkmanager) {
|
||||
this.g = LoginListener.EnumProtocolState.HELLO;
|
||||
@@ -77,6 +85,20 @@
|
||||
this.state = LoginListener.EnumProtocolState.HELLO;
|
||||
@@ -80,6 +88,20 @@
|
||||
|
||||
}
|
||||
|
||||
@@ -32,8 +32,8 @@
|
||||
+ try {
|
||||
+ IChatBaseComponent ichatbasecomponent = new ChatComponentText(s);
|
||||
+ LoginListener.LOGGER.info("Disconnecting {}: {}", this.d(), s);
|
||||
+ this.networkManager.sendPacket(new PacketLoginOutDisconnect(ichatbasecomponent));
|
||||
+ this.networkManager.close(ichatbasecomponent);
|
||||
+ this.connection.sendPacket(new PacketLoginOutDisconnect(ichatbasecomponent));
|
||||
+ this.connection.close(ichatbasecomponent);
|
||||
+ } catch (Exception exception) {
|
||||
+ LoginListener.LOGGER.error("Error whilst disconnecting player", exception);
|
||||
+ }
|
||||
@@ -42,14 +42,14 @@
|
||||
+
|
||||
@Override
|
||||
public NetworkManager a() {
|
||||
return this.networkManager;
|
||||
@@ -98,10 +120,12 @@
|
||||
this.i = this.a(this.i);
|
||||
return this.connection;
|
||||
@@ -101,10 +123,12 @@
|
||||
this.gameProfile = this.a(this.gameProfile);
|
||||
}
|
||||
|
||||
- IChatBaseComponent ichatbasecomponent = this.server.getPlayerList().attemptLogin(this.networkManager.getSocketAddress(), this.i);
|
||||
- IChatBaseComponent ichatbasecomponent = this.server.getPlayerList().attemptLogin(this.connection.getSocketAddress(), this.gameProfile);
|
||||
+ // CraftBukkit start - fire PlayerLoginEvent
|
||||
+ EntityPlayer s = this.server.getPlayerList().attemptLogin(this, this.i, hostname);
|
||||
+ EntityPlayer s = this.server.getPlayerList().attemptLogin(this, this.gameProfile, hostname);
|
||||
|
||||
- if (ichatbasecomponent != null) {
|
||||
- this.disconnect(ichatbasecomponent);
|
||||
@@ -57,32 +57,29 @@
|
||||
+ // this.disconnect(ichatbasecomponent);
|
||||
+ // CraftBukkit end
|
||||
} else {
|
||||
this.g = LoginListener.EnumProtocolState.ACCEPTED;
|
||||
if (this.server.ax() >= 0 && !this.networkManager.isLocal()) {
|
||||
@@ -115,9 +139,9 @@
|
||||
this.state = LoginListener.EnumProtocolState.ACCEPTED;
|
||||
if (this.server.aw() >= 0 && !this.connection.isLocal()) {
|
||||
@@ -117,7 +141,7 @@
|
||||
EntityPlayer entityplayer = this.server.getPlayerList().getPlayer(this.gameProfile.getId());
|
||||
|
||||
if (entityplayer != null) {
|
||||
this.g = LoginListener.EnumProtocolState.DELAY_ACCEPT;
|
||||
- this.l = this.server.getPlayerList().processLogin(this.i);
|
||||
+ this.l = this.server.getPlayerList().processLogin(this.i, s); // CraftBukkit - add player reference
|
||||
} else {
|
||||
- this.server.getPlayerList().a(this.networkManager, this.server.getPlayerList().processLogin(this.i));
|
||||
+ this.server.getPlayerList().a(this.networkManager, this.server.getPlayerList().processLogin(this.i, s)); // CraftBukkit - add player reference
|
||||
}
|
||||
}
|
||||
try {
|
||||
- EntityPlayer entityplayer1 = this.server.getPlayerList().processLogin(this.gameProfile);
|
||||
+ EntityPlayer entityplayer1 = this.server.getPlayerList().processLogin(this.gameProfile, s); // CraftBukkit - add player reference
|
||||
|
||||
@@ -175,6 +199,43 @@
|
||||
if (entityplayer != null) {
|
||||
this.state = LoginListener.EnumProtocolState.DELAY_ACCEPT;
|
||||
@@ -191,6 +215,43 @@
|
||||
try {
|
||||
LoginListener.this.i = LoginListener.this.server.getMinecraftSessionService().hasJoinedServer(new GameProfile((UUID) null, gameprofile.getName()), s, this.a());
|
||||
if (LoginListener.this.i != null) {
|
||||
LoginListener.this.gameProfile = LoginListener.this.server.getMinecraftSessionService().hasJoinedServer(new GameProfile((UUID) null, gameprofile.getName()), s, this.a());
|
||||
if (LoginListener.this.gameProfile != null) {
|
||||
+ // CraftBukkit start - fire PlayerPreLoginEvent
|
||||
+ if (!networkManager.isConnected()) {
|
||||
+ if (!connection.isConnected()) {
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ String playerName = i.getName();
|
||||
+ java.net.InetAddress address = ((java.net.InetSocketAddress) networkManager.getSocketAddress()).getAddress();
|
||||
+ java.util.UUID uniqueId = i.getId();
|
||||
+ String playerName = gameProfile.getName();
|
||||
+ java.net.InetAddress address = ((java.net.InetSocketAddress) connection.getSocketAddress()).getAddress();
|
||||
+ java.util.UUID uniqueId = gameProfile.getId();
|
||||
+ final org.bukkit.craftbukkit.CraftServer server = LoginListener.this.server.server;
|
||||
+
|
||||
+ AsyncPlayerPreLoginEvent asyncEvent = new AsyncPlayerPreLoginEvent(playerName, address, uniqueId);
|
||||
@@ -112,10 +109,10 @@
|
||||
+ }
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
LoginListener.LOGGER.info("UUID of player {} is {}", LoginListener.this.i.getName(), LoginListener.this.i.getId());
|
||||
LoginListener.this.g = LoginListener.EnumProtocolState.READY_TO_ACCEPT;
|
||||
LoginListener.LOGGER.info("UUID of player {} is {}", LoginListener.this.gameProfile.getName(), LoginListener.this.gameProfile.getId());
|
||||
LoginListener.this.state = LoginListener.EnumProtocolState.READY_TO_ACCEPT;
|
||||
} else if (LoginListener.this.server.isEmbeddedServer()) {
|
||||
@@ -194,6 +255,11 @@
|
||||
@@ -210,6 +271,11 @@
|
||||
LoginListener.this.disconnect(new ChatMessage("multiplayer.disconnect.authservers_down"));
|
||||
LoginListener.LOGGER.error("Couldn't verify username because servers are unavailable");
|
||||
}
|
||||
|
||||
@@ -18,21 +18,21 @@
|
||||
+
|
||||
public class PacketStatusListener implements PacketStatusInListener {
|
||||
|
||||
private static final IChatBaseComponent a = new ChatMessage("multiplayer.status.request_handled");
|
||||
private static final IChatBaseComponent DISCONNECT_REASON = new ChatMessage("multiplayer.status.request_handled");
|
||||
@@ -36,8 +48,96 @@
|
||||
this.networkManager.close(PacketStatusListener.a);
|
||||
this.connection.close(PacketStatusListener.DISCONNECT_REASON);
|
||||
} else {
|
||||
this.d = true;
|
||||
- this.networkManager.sendPacket(new PacketStatusOutServerInfo(this.minecraftServer.getServerPing()));
|
||||
this.hasRequestedStatus = true;
|
||||
- this.connection.sendPacket(new PacketStatusOutServerInfo(this.server.getServerPing()));
|
||||
+ // CraftBukkit start
|
||||
+ // this.networkManager.sendPacket(new PacketStatusOutServerInfo(this.minecraftServer.getServerPing()));
|
||||
+ final Object[] players = minecraftServer.getPlayerList().players.toArray();
|
||||
+ final Object[] players = server.getPlayerList().players.toArray();
|
||||
+ class ServerListPingEvent extends org.bukkit.event.server.ServerListPingEvent {
|
||||
+
|
||||
+ CraftIconCache icon = minecraftServer.server.getServerIcon();
|
||||
+ CraftIconCache icon = server.server.getServerIcon();
|
||||
+
|
||||
+ ServerListPingEvent() {
|
||||
+ super(((InetSocketAddress) networkManager.getSocketAddress()).getAddress(), minecraftServer.getMotd(), minecraftServer.getPlayerList().getMaxPlayers());
|
||||
+ super(((InetSocketAddress) connection.getSocketAddress()).getAddress(), server.getMotd(), server.getPlayerList().getMaxPlayers());
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
@@ -92,7 +92,7 @@
|
||||
+ }
|
||||
+
|
||||
+ ServerListPingEvent event = new ServerListPingEvent();
|
||||
+ this.minecraftServer.server.getPluginManager().callEvent(event);
|
||||
+ this.server.server.getPluginManager().callEvent(event);
|
||||
+
|
||||
+ java.util.List<GameProfile> profiles = new java.util.ArrayList<GameProfile>(players.length);
|
||||
+ for (Object player : players) {
|
||||
@@ -109,9 +109,9 @@
|
||||
+ ping.setMOTD(CraftChatMessage.fromString(event.getMotd(), true)[0]);
|
||||
+ ping.setPlayerSample(playerSample);
|
||||
+ int version = SharedConstants.getGameVersion().getProtocolVersion();
|
||||
+ ping.setServerInfo(new ServerPing.ServerData(minecraftServer.getServerModName() + " " + minecraftServer.getVersion(), version));
|
||||
+ ping.setServerInfo(new ServerPing.ServerData(server.getServerModName() + " " + server.getVersion(), version));
|
||||
+
|
||||
+ this.networkManager.sendPacket(new PacketStatusOutServerInfo(ping));
|
||||
+ this.connection.sendPacket(new PacketStatusOutServerInfo(ping));
|
||||
}
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,13 +1,13 @@
|
||||
--- a/net/minecraft/server/network/ServerConnection.java
|
||||
+++ b/net/minecraft/server/network/ServerConnection.java
|
||||
@@ -87,14 +87,24 @@
|
||||
int j = ServerConnection.this.e.k();
|
||||
@@ -96,14 +96,24 @@
|
||||
int j = ServerConnection.this.server.l();
|
||||
Object object = j > 0 ? new NetworkManagerServer(j) : new NetworkManager(EnumProtocolDirection.SERVERBOUND);
|
||||
|
||||
- ServerConnection.this.connectedChannels.add(object);
|
||||
+ ServerConnection.this.connectedChannels.add((NetworkManager) object); // CraftBukkit - decompile error
|
||||
- ServerConnection.this.connections.add(object);
|
||||
+ ServerConnection.this.connections.add((NetworkManager) object); // CraftBukkit - decompile error
|
||||
channel.pipeline().addLast("packet_handler", (ChannelHandler) object);
|
||||
((NetworkManager) object).setPacketListener(new HandshakeListener(ServerConnection.this.e, (NetworkManager) object));
|
||||
((NetworkManager) object).setPacketListener(new HandshakeListener(ServerConnection.this.server, (NetworkManager) object));
|
||||
}
|
||||
- }).group((EventLoopGroup) lazyinitvar.a()).localAddress(inetaddress, i)).bind().syncUninterruptibly());
|
||||
+ }).group((EventLoopGroup) lazyinitvar.a()).localAddress(inetaddress, i)).option(ChannelOption.AUTO_READ, false).bind().syncUninterruptibly()); // CraftBukkit
|
||||
@@ -16,14 +16,14 @@
|
||||
|
||||
+ // CraftBukkit start
|
||||
+ public void acceptConnections() {
|
||||
+ synchronized (this.listeningChannels) {
|
||||
+ for (ChannelFuture future : this.listeningChannels) {
|
||||
+ synchronized (this.channels) {
|
||||
+ for (ChannelFuture future : this.channels) {
|
||||
+ future.channel().config().setAutoRead(true);
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
public void b() {
|
||||
this.c = false;
|
||||
Iterator iterator = this.listeningChannels.iterator();
|
||||
public SocketAddress a() {
|
||||
List list = this.channels;
|
||||
ChannelFuture channelfuture;
|
||||
|
||||
Reference in New Issue
Block a user