Trying to do some hacky things!
This commit is contained in:
parent
b65ca5f7dd
commit
56bc8dc232
@ -18,8 +18,8 @@ import net.md_5.bungee.api.ServerPing;
|
|||||||
import net.md_5.bungee.api.event.ProxyPingEvent;
|
import net.md_5.bungee.api.event.ProxyPingEvent;
|
||||||
import net.md_5.bungee.connection.CustomMotd;
|
import net.md_5.bungee.connection.CustomMotd;
|
||||||
import net.md_5.bungee.connection.InitialHandler;
|
import net.md_5.bungee.connection.InitialHandler;
|
||||||
|
import net.md_5.bungee.protocol.packet.PingPacket;
|
||||||
import net.md_5.bungee.protocol.packet.StatusResponse;
|
import net.md_5.bungee.protocol.packet.StatusResponse;
|
||||||
import org.apache.commons.io.comparator.NameFileComparator;
|
|
||||||
|
|
||||||
public class Motd implements CustomMotd
|
public class Motd implements CustomMotd
|
||||||
{
|
{
|
||||||
@ -64,12 +64,22 @@ public class Motd implements CustomMotd
|
|||||||
|
|
||||||
initialHandler.unsafe().sendPacket(new StatusResponse(gson.toJson(ping)));
|
initialHandler.unsafe().sendPacket(new StatusResponse(gson.toJson(ping)));
|
||||||
_ticks++;
|
_ticks++;
|
||||||
|
|
||||||
|
if (_ticks > MAX_TICKS)
|
||||||
|
{
|
||||||
|
PingPacket packet = initialHandler.getPingPacket();
|
||||||
|
if (packet != null)
|
||||||
|
{
|
||||||
|
initialHandler.unsafe().sendPacket(packet);
|
||||||
|
initialHandler.setPingPacket(null);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_task.cancel(true);
|
|
||||||
if (initialHandler.getChannelWrapper().getHandle().isOpen())
|
if (initialHandler.getChannelWrapper().getHandle().isOpen())
|
||||||
initialHandler.getChannelWrapper().getHandle().close();
|
initialHandler.getChannelWrapper().getHandle().close();
|
||||||
|
_task.cancel(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, 0, 200, TimeUnit.MILLISECONDS);
|
}, 0, 200, TimeUnit.MILLISECONDS);
|
||||||
|
@ -1,17 +1,13 @@
|
|||||||
package mineplex.bungee.motd;
|
package mineplex.bungee.motd;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import net.md_5.bungee.api.event.PreLoginEvent;
|
|
||||||
import net.md_5.bungee.api.event.ProxyPingEvent;
|
|
||||||
import net.md_5.bungee.api.plugin.Listener;
|
import net.md_5.bungee.api.plugin.Listener;
|
||||||
import net.md_5.bungee.api.plugin.Plugin;
|
import net.md_5.bungee.api.plugin.Plugin;
|
||||||
import net.md_5.bungee.connection.CustomMotd;
|
import net.md_5.bungee.connection.CustomMotd;
|
||||||
import net.md_5.bungee.connection.CustomMotdFactory;
|
import net.md_5.bungee.connection.CustomMotdFactory;
|
||||||
import net.md_5.bungee.connection.InitialHandler;
|
import net.md_5.bungee.connection.InitialHandler;
|
||||||
import net.md_5.bungee.event.EventHandler;
|
|
||||||
|
|
||||||
public class MotdManager implements Listener, Runnable, CustomMotdFactory
|
public class MotdManager implements Listener, Runnable, CustomMotdFactory
|
||||||
{
|
{
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package net.md_5.bungee.connection;
|
package net.md_5.bungee.connection;
|
||||||
|
|
||||||
import net.md_5.bungee.api.event.ProxyPingEvent;
|
import net.md_5.bungee.api.event.ProxyPingEvent;
|
||||||
|
import net.md_5.bungee.protocol.packet.PingPacket;
|
||||||
|
|
||||||
public interface CustomMotd
|
public interface CustomMotd
|
||||||
{
|
{
|
||||||
|
@ -12,7 +12,6 @@ import java.beans.ConstructorProperties;
|
|||||||
import java.math.BigInteger;
|
import java.math.BigInteger;
|
||||||
import java.net.InetSocketAddress;
|
import java.net.InetSocketAddress;
|
||||||
import java.net.URLEncoder;
|
import java.net.URLEncoder;
|
||||||
import java.nio.channels.Channel;
|
|
||||||
import java.security.MessageDigest;
|
import java.security.MessageDigest;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -41,15 +40,12 @@ import net.md_5.bungee.api.config.ListenerInfo;
|
|||||||
import net.md_5.bungee.api.config.ServerInfo;
|
import net.md_5.bungee.api.config.ServerInfo;
|
||||||
import net.md_5.bungee.api.connection.PendingConnection;
|
import net.md_5.bungee.api.connection.PendingConnection;
|
||||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||||
import net.md_5.bungee.api.connection.Connection.Unsafe;
|
|
||||||
import net.md_5.bungee.api.event.LoginEvent;
|
import net.md_5.bungee.api.event.LoginEvent;
|
||||||
import net.md_5.bungee.api.event.PlayerHandshakeEvent;
|
import net.md_5.bungee.api.event.PlayerHandshakeEvent;
|
||||||
import net.md_5.bungee.api.event.PostLoginEvent;
|
import net.md_5.bungee.api.event.PostLoginEvent;
|
||||||
import net.md_5.bungee.api.event.PreLoginEvent;
|
import net.md_5.bungee.api.event.PreLoginEvent;
|
||||||
import net.md_5.bungee.api.event.ProxyPingEvent;
|
import net.md_5.bungee.api.event.ProxyPingEvent;
|
||||||
import net.md_5.bungee.chat.ComponentSerializer;
|
import net.md_5.bungee.chat.ComponentSerializer;
|
||||||
import net.md_5.bungee.connection.LoginResult;
|
|
||||||
import net.md_5.bungee.connection.UpstreamBridge;
|
|
||||||
import net.md_5.bungee.http.HttpClient;
|
import net.md_5.bungee.http.HttpClient;
|
||||||
import net.md_5.bungee.netty.ChannelWrapper;
|
import net.md_5.bungee.netty.ChannelWrapper;
|
||||||
import net.md_5.bungee.netty.HandlerBoss;
|
import net.md_5.bungee.netty.HandlerBoss;
|
||||||
@ -74,6 +70,7 @@ public class InitialHandler extends PacketHandler implements PendingConnection {
|
|||||||
|
|
||||||
private static CustomMotdFactory _customMotdFactory;
|
private static CustomMotdFactory _customMotdFactory;
|
||||||
|
|
||||||
|
private PingPacket _pingPacket;
|
||||||
private final ProxyServer bungee;
|
private final ProxyServer bungee;
|
||||||
private ChannelWrapper ch;
|
private ChannelWrapper ch;
|
||||||
private final ListenerInfo listener;
|
private final ListenerInfo listener;
|
||||||
@ -180,11 +177,22 @@ public class InitialHandler extends PacketHandler implements PendingConnection {
|
|||||||
this.thisState = InitialHandler.State.PING;
|
this.thisState = InitialHandler.State.PING;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void handle(PingPacket ping) throws Exception {
|
public void handle(final PingPacket ping) throws Exception {
|
||||||
if (thisState == State.PING) return; // MINEPLEX
|
|
||||||
Preconditions.checkState(this.thisState == InitialHandler.State.PING, "Not expecting PING");
|
_pingPacket = ping;
|
||||||
this.unsafe.sendPacket(ping);
|
// if (thisState == State.PING) return; // MINEPLEX
|
||||||
this.disconnect((String)"");
|
// Preconditions.checkState(this.thisState == InitialHandler.State.PING, "Not expecting PING");
|
||||||
|
// getChannelWrapper().getHandle().eventLoop().schedule(new Runnable()
|
||||||
|
// {
|
||||||
|
// @Override
|
||||||
|
// public void run()
|
||||||
|
// {
|
||||||
|
// unsafe.sendPacket(ping);
|
||||||
|
// }
|
||||||
|
// }, 6, TimeUnit.SECONDS);
|
||||||
|
//
|
||||||
|
// this.unsafe.sendPacket(ping);
|
||||||
|
// this.disconnect((String)"");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void handle(Handshake handshake) throws Exception {
|
public void handle(Handshake handshake) throws Exception {
|
||||||
@ -450,6 +458,16 @@ public class InitialHandler extends PacketHandler implements PendingConnection {
|
|||||||
return ch; //MINEPLEX
|
return ch; //MINEPLEX
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public PingPacket getPingPacket()
|
||||||
|
{
|
||||||
|
return _pingPacket; // MINEPLEX
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPingPacket(PingPacket packet)
|
||||||
|
{
|
||||||
|
_pingPacket = packet;
|
||||||
|
}
|
||||||
|
|
||||||
private static enum State {
|
private static enum State {
|
||||||
HANDSHAKE,
|
HANDSHAKE,
|
||||||
STATUS,
|
STATUS,
|
||||||
|
@ -43,6 +43,7 @@ public class PingHandler extends PacketHandler {
|
|||||||
public void handle(StatusResponse statusResponse) throws Exception {
|
public void handle(StatusResponse statusResponse) throws Exception {
|
||||||
Gson gson = this.protocol == 4?BungeeCord.getInstance().gsonLegacy:BungeeCord.getInstance().gson;
|
Gson gson = this.protocol == 4?BungeeCord.getInstance().gsonLegacy:BungeeCord.getInstance().gson;
|
||||||
this.callback.done(gson.fromJson(statusResponse.getResponse(), ServerPing.class), (Throwable)null);
|
this.callback.done(gson.fromJson(statusResponse.getResponse(), ServerPing.class), (Throwable)null);
|
||||||
|
System.out.println("handle");
|
||||||
// this.channel.close(); //MINEPLEX
|
// this.channel.close(); //MINEPLEX
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user