mirror of
https://github.com/GeyserMC/MCProtocolLib.git
synced 2024-12-04 21:01:02 -05:00
9e38c61927
These were just replaced with functions that call the session and packet.
58 lines
1.6 KiB
Java
58 lines
1.6 KiB
Java
package com.github.steveice10.packetlib.test;
|
|
|
|
import com.github.steveice10.packetlib.Server;
|
|
import com.github.steveice10.packetlib.Session;
|
|
import com.github.steveice10.packetlib.crypt.AESEncryption;
|
|
import com.github.steveice10.packetlib.crypt.PacketEncryption;
|
|
import com.github.steveice10.packetlib.packet.DefaultPacketHeader;
|
|
import com.github.steveice10.packetlib.packet.PacketHeader;
|
|
import com.github.steveice10.packetlib.packet.PacketProtocol;
|
|
|
|
import javax.crypto.SecretKey;
|
|
import java.security.GeneralSecurityException;
|
|
|
|
public class TestProtocol extends PacketProtocol {
|
|
private final PacketHeader header = new DefaultPacketHeader();
|
|
private AESEncryption encrypt;
|
|
|
|
@SuppressWarnings("unused")
|
|
public TestProtocol() {
|
|
}
|
|
|
|
public TestProtocol(SecretKey key) {
|
|
this.setSecretKey(key);
|
|
}
|
|
|
|
public void setSecretKey(SecretKey key) {
|
|
this.register(0, PingPacket.class, PingPacket::new);
|
|
try {
|
|
this.encrypt = new AESEncryption(key);
|
|
} catch(GeneralSecurityException e) {
|
|
e.printStackTrace();
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public String getSRVRecordPrefix() {
|
|
return "_test";
|
|
}
|
|
|
|
@Override
|
|
public PacketHeader getPacketHeader() {
|
|
return this.header;
|
|
}
|
|
|
|
public PacketEncryption getEncryption() {
|
|
return this.encrypt;
|
|
}
|
|
|
|
@Override
|
|
public void newClientSession(Session session) {
|
|
session.addListener(new ClientSessionListener());
|
|
}
|
|
|
|
@Override
|
|
public void newServerSession(Server server, Session session) {
|
|
session.addListener(new ServerSessionListener());
|
|
}
|
|
}
|