complete login system for now, misc fixes
This commit is contained in:
parent
06a14ae645
commit
a6c2695ccb
26 changed files with 460 additions and 210 deletions
|
@ -8,7 +8,7 @@ import common.packet.RPacketRequestEncrypt;
|
|||
import common.packet.RPacketResponse;
|
||||
import common.packet.RPacketServerConfig;
|
||||
|
||||
public interface IClientLoginHandler {
|
||||
public interface IClientLoginHandler extends NetHandler {
|
||||
void handleDisconnect(RPacketDisconnect packet);
|
||||
void handleLoginSuccess(RPacketLoginSuccess packet);
|
||||
void handleEnableCompression(RPacketEnableCompression packet);
|
||||
|
|
|
@ -72,7 +72,7 @@ import common.tileentity.IInteractionObject;
|
|||
import common.util.BlockPos;
|
||||
import common.world.World;
|
||||
|
||||
public interface IClientPlayer {
|
||||
public interface IClientPlayer extends NetHandler {
|
||||
void playSound(Sound sound);
|
||||
boolean isRenderViewEntity(Entity entity);
|
||||
void updatePlayerMoveState();
|
||||
|
|
|
@ -2,6 +2,6 @@ package common.network;
|
|||
|
||||
import common.packet.HPacketHandshake;
|
||||
|
||||
public interface IHandshakeHandler {
|
||||
public interface IHandshakeHandler extends NetHandler {
|
||||
void processHandshake(HPacketHandshake packet);
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@ import common.packet.LPacketPubkey;
|
|||
import common.packet.LPacketResponse;
|
||||
import common.packet.LPacketStartEncrypt;
|
||||
|
||||
public interface ILoginHandler {
|
||||
public interface ILoginHandler extends NetHandler {
|
||||
void processEncryption(LPacketStartEncrypt packet);
|
||||
void processPassword(LPacketPassword packet);
|
||||
void processPubkey(LPacketPubkey packet);
|
||||
|
|
|
@ -31,7 +31,7 @@ import common.util.CharValidator;
|
|||
import common.util.ChunkPos;
|
||||
import common.util.PortalType;
|
||||
|
||||
public interface IPlayer {
|
||||
public interface IPlayer extends NetHandler {
|
||||
public static class UserValidator implements CharValidator {
|
||||
public boolean valid(char ch) {
|
||||
return (ch >= 'a' && ch <= 'z') || (ch >= '0' && ch <= '9') || ch == '_' || ch == '-';
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
package common.network;
|
||||
|
||||
public abstract class NetHandler {
|
||||
private static final ThreadQuickExitException EXIT = new ThreadQuickExitException();
|
||||
|
||||
public interface NetHandler {
|
||||
public static final class ThreadQuickExitException extends RuntimeException {
|
||||
private static final ThreadQuickExitException EXIT = new ThreadQuickExitException();
|
||||
|
||||
private ThreadQuickExitException() {
|
||||
this.setStackTrace(new StackTraceElement[0]);
|
||||
}
|
||||
|
@ -14,9 +14,9 @@ public abstract class NetHandler {
|
|||
}
|
||||
}
|
||||
|
||||
public abstract void onDisconnect(String reason);
|
||||
void onDisconnect(String reason);
|
||||
|
||||
public void update() {
|
||||
default void update() {
|
||||
}
|
||||
|
||||
public static <T> void checkThread(final Packet<T> packet, final T handler, IThreadListener listener) throws ThreadQuickExitException {
|
||||
|
@ -26,13 +26,13 @@ public abstract class NetHandler {
|
|||
packet.processPacket(handler);
|
||||
}
|
||||
});
|
||||
throw EXIT;
|
||||
throw ThreadQuickExitException.EXIT;
|
||||
}
|
||||
}
|
||||
|
||||
public static <T> void checkThread(final Packet<T> packet, final T handler, IThreadListener listener, Object check) throws ThreadQuickExitException {
|
||||
if(check == null && listener.isMainThread())
|
||||
throw EXIT;
|
||||
throw ThreadQuickExitException.EXIT;
|
||||
checkThread(packet, handler, listener);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue