2011-02-05 19:15:04 +01:00
|
|
|
package net.minecraft.server;
|
|
|
|
|
|
|
|
import java.net.Socket;
|
|
|
|
import java.util.Random;
|
|
|
|
import java.util.logging.Logger;
|
|
|
|
|
|
|
|
public class NetLoginHandler extends NetHandler {
|
|
|
|
|
|
|
|
public static Logger a = Logger.getLogger("Minecraft");
|
|
|
|
private static Random d = new Random();
|
|
|
|
public NetworkManager b;
|
|
|
|
public boolean c = false;
|
|
|
|
private MinecraftServer e;
|
|
|
|
private int f = 0;
|
|
|
|
private String g = null;
|
|
|
|
private Packet1Login h = null;
|
|
|
|
private String i = "";
|
|
|
|
|
|
|
|
public NetLoginHandler(MinecraftServer minecraftserver, Socket socket, String s) {
|
|
|
|
this.e = minecraftserver;
|
|
|
|
this.b = new NetworkManager(socket, s, this);
|
|
|
|
this.b.d = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void a() {
|
|
|
|
if (this.h != null) {
|
|
|
|
this.b(this.h);
|
|
|
|
this.h = null;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (this.f++ == 600) {
|
|
|
|
this.a("Took too long to log in");
|
|
|
|
} else {
|
|
|
|
this.b.a();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public void a(String s) {
|
|
|
|
try {
|
|
|
|
a.info("Disconnecting " + this.b() + ": " + s);
|
|
|
|
this.b.a((Packet) (new Packet255KickDisconnect(s)));
|
|
|
|
this.b.c();
|
|
|
|
this.c = true;
|
|
|
|
} catch (Exception exception) {
|
|
|
|
exception.printStackTrace();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public void a(Packet2Handshake packet2handshake) {
|
|
|
|
if (this.e.l) {
|
|
|
|
this.i = Long.toHexString(d.nextLong());
|
|
|
|
this.b.a((Packet) (new Packet2Handshake(this.i)));
|
|
|
|
} else {
|
|
|
|
this.b.a((Packet) (new Packet2Handshake("-")));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public void a(Packet1Login packet1login) {
|
|
|
|
this.g = packet1login.b;
|
2011-03-31 22:40:00 +02:00
|
|
|
if (packet1login.a != 10) {
|
|
|
|
if (packet1login.a > 10) {
|
2011-02-05 19:15:04 +01:00
|
|
|
this.a("Outdated server!");
|
|
|
|
} else {
|
|
|
|
this.a("Outdated client!");
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (!this.e.l) {
|
|
|
|
this.b(packet1login);
|
|
|
|
} else {
|
|
|
|
(new ThreadLoginVerifier(this, packet1login)).start();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public void b(Packet1Login packet1login) {
|
|
|
|
EntityPlayer entityplayer = this.e.f.a(this, packet1login.b, packet1login.c);
|
|
|
|
|
|
|
|
if (entityplayer != null) {
|
|
|
|
a.info(this.b() + " logged in with entity id " + entityplayer.id);
|
|
|
|
NetServerHandler netserverhandler = new NetServerHandler(this.e, this.b, entityplayer);
|
|
|
|
|
2011-02-23 13:56:36 +01:00
|
|
|
// CraftBukkit start
|
2011-03-31 22:40:00 +02:00
|
|
|
ChunkCoordinates chunkcoordinates = entityplayer.world.m();
|
|
|
|
netserverhandler.b((Packet) (new Packet1Login("", "", entityplayer.id, entityplayer.world.k(), (byte) entityplayer.world.m.g)));
|
2011-02-23 03:37:56 +01:00
|
|
|
netserverhandler.b((Packet) (new Packet6SpawnPosition(chunkcoordinates.a, chunkcoordinates.b, chunkcoordinates.c)));
|
2011-03-26 12:31:48 +01:00
|
|
|
// this.e.f.a((Packet) (new Packet3Chat("\u00A7e" + entityplayer.name + " joined the game."))); // CraftBukkit - message moved to join event
|
2011-02-05 19:15:04 +01:00
|
|
|
this.e.f.a(entityplayer);
|
|
|
|
netserverhandler.a(entityplayer.locX, entityplayer.locY, entityplayer.locZ, entityplayer.yaw, entityplayer.pitch);
|
|
|
|
this.e.c.a(netserverhandler);
|
2011-03-31 22:40:00 +02:00
|
|
|
netserverhandler.b((Packet) (new Packet4UpdateTime(entityplayer.world.l())));
|
2011-02-23 13:56:36 +01:00
|
|
|
// CraftBukkit end
|
2011-02-05 19:15:04 +01:00
|
|
|
|
2011-03-31 22:40:00 +02:00
|
|
|
entityplayer.m();
|
2011-02-05 19:15:04 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
this.c = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void a(String s, Object[] aobject) {
|
|
|
|
a.info(this.b() + " lost connection");
|
|
|
|
this.c = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void a(Packet packet) {
|
|
|
|
this.a("Protocol error");
|
|
|
|
}
|
|
|
|
|
|
|
|
public String b() {
|
|
|
|
return this.g != null ? this.g + " [" + this.b.b().toString() + "]" : this.b.b().toString();
|
|
|
|
}
|
|
|
|
|
|
|
|
static String a(NetLoginHandler netloginhandler) {
|
|
|
|
return netloginhandler.i;
|
|
|
|
}
|
|
|
|
|
|
|
|
static Packet1Login a(NetLoginHandler netloginhandler, Packet1Login packet1login) {
|
|
|
|
return netloginhandler.h = packet1login;
|
|
|
|
}
|
|
|
|
}
|