forked from KNEMC/KLALB
KLALB2.3
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
package org.kne.cloud.network;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.Inet6Address;
|
||||
import java.net.Socket;
|
||||
|
||||
import org.kne.cloud.network.klalb.KLALBVirtualSocket;
|
||||
import org.kne.cloud.network.minecraft.KLALBJsonMotdInserter;
|
||||
import org.kne.cloud.network.minecraft.MinecraftSocketBridge;
|
||||
|
||||
public class DefaultMinecraftSocketBridgeFactory extends SocketBridgeFactory {
|
||||
private Inet6Address vaddr;
|
||||
private int vport;
|
||||
public DefaultMinecraftSocketBridgeFactory(Inet6Address vaddr, int vport) {
|
||||
super();
|
||||
this.vaddr = vaddr;
|
||||
this.vport = vport;
|
||||
}
|
||||
public Inet6Address getVaddr() {
|
||||
return vaddr;
|
||||
}
|
||||
public int getVport() {
|
||||
return vport;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SocketBridge createBridge(Socket a, Socket b) throws IOException {
|
||||
if(a instanceof KLALBVirtualSocket) {
|
||||
KLALBVirtualSocket klv=(KLALBVirtualSocket) a;
|
||||
klv.setCompress(1);
|
||||
}
|
||||
if(b instanceof KLALBVirtualSocket) {
|
||||
KLALBVirtualSocket klv=(KLALBVirtualSocket) b;
|
||||
klv.setCompress(1);
|
||||
}
|
||||
MinecraftSocketBridge msb=new MinecraftSocketBridge(a, b);
|
||||
msb.getBridgeBA().getTransformers().add(new KLALBJsonMotdInserter(()->{return vaddr;},()->{return vport;}));
|
||||
return msb;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user