Compare commits
13 Commits
81b8f12603
...
b499e2f2a0
Author | SHA1 | Date |
---|---|---|
Outfluencer | b499e2f2a0 | |
Outfluencer | 6e1751733f | |
DerFrZocker | 6335af840b | |
Outfluencer | 6936d33310 | |
Outfluencer | d75b6adaf6 | |
Outfluencer | 949a1cd376 | |
Outfluencer | 356f8731bc | |
Outfluencer | ef7619cded | |
Outfluencer | ec0d6f8ab8 | |
Outfluencer | 590713ec77 | |
Outfluencer | fefd223e56 | |
Outfluencer | f4fc652354 | |
Outfluencer | a74665b6c8 |
|
@ -0,0 +1,47 @@
|
|||
package net.md_5.bungee.api.event;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Getter;
|
||||
import lombok.ToString;
|
||||
import net.md_5.bungee.api.connection.Connection;
|
||||
import net.md_5.bungee.api.plugin.Event;
|
||||
import net.md_5.bungee.protocol.Protocol;
|
||||
|
||||
/**
|
||||
* Called when the encode or decode protocol of a {@link Connection} is changed.
|
||||
*/
|
||||
@Getter
|
||||
@ToString(callSuper = false)
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@AllArgsConstructor
|
||||
public class ProtocolChangedEvent extends Event
|
||||
{
|
||||
|
||||
/**
|
||||
* The old protocol.
|
||||
*/
|
||||
private Protocol oldProtocol;
|
||||
|
||||
/**
|
||||
* The new protocol.
|
||||
*/
|
||||
private Protocol newProtocol;
|
||||
|
||||
/**
|
||||
* The connection whose protocol is being changed.
|
||||
*/
|
||||
private Connection connection;
|
||||
|
||||
/**
|
||||
* The direction of the changed protocol.
|
||||
* encode or decode
|
||||
*/
|
||||
private Direction direction;
|
||||
|
||||
public enum Direction
|
||||
{
|
||||
ENCODE,
|
||||
DECODE
|
||||
}
|
||||
}
|
|
@ -61,6 +61,11 @@ class LibraryLoader
|
|||
logger.log( Level.INFO, "Downloading {0}", event.getResource().getRepositoryUrl() + event.getResource().getResourceName() );
|
||||
}
|
||||
} );
|
||||
|
||||
// SPIGOT-7638: Add system properties,
|
||||
// since JdkVersionProfileActivator needs 'java.version' when a profile has the 'jdk' element
|
||||
// otherwise it will silently fail and not resolves the dependencies in the affected pom.
|
||||
session.setSystemProperties( System.getProperties() );
|
||||
session.setReadOnly();
|
||||
|
||||
this.repositories = repository.newResolutionRepositories( session, Arrays.asList( new RemoteRepository.Builder( "central", "default", "https://repo.maven.apache.org/maven2" ).build() ) );
|
||||
|
|
|
@ -36,6 +36,7 @@ import net.md_5.bungee.api.config.ServerInfo;
|
|||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
import net.md_5.bungee.api.connection.Server;
|
||||
import net.md_5.bungee.api.event.PluginMessageEvent;
|
||||
import net.md_5.bungee.api.event.ProtocolChangedEvent;
|
||||
import net.md_5.bungee.api.event.ServerConnectEvent;
|
||||
import net.md_5.bungee.api.event.ServerDisconnectEvent;
|
||||
import net.md_5.bungee.api.event.ServerKickEvent;
|
||||
|
@ -146,6 +147,12 @@ public class DownstreamBridge extends PacketHandler
|
|||
con.sendPacket( packet );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void protocolChanged(ChannelWrapper channel, Protocol oldProtocol, Protocol newProtocol, ProtocolChangedEvent.Direction direction)
|
||||
{
|
||||
bungee.getPluginManager().callEvent( new ProtocolChangedEvent( oldProtocol, newProtocol, server, direction ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handle(KeepAlive alive) throws Exception
|
||||
{
|
||||
|
|
|
@ -43,6 +43,7 @@ import net.md_5.bungee.api.event.LoginEvent;
|
|||
import net.md_5.bungee.api.event.PlayerHandshakeEvent;
|
||||
import net.md_5.bungee.api.event.PostLoginEvent;
|
||||
import net.md_5.bungee.api.event.PreLoginEvent;
|
||||
import net.md_5.bungee.api.event.ProtocolChangedEvent;
|
||||
import net.md_5.bungee.api.event.ProxyPingEvent;
|
||||
import net.md_5.bungee.api.event.ServerConnectEvent;
|
||||
import net.md_5.bungee.http.HttpClient;
|
||||
|
@ -181,6 +182,12 @@ public class InitialHandler extends PacketHandler implements PendingConnection
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void protocolChanged(ChannelWrapper channel, Protocol oldProtocol, Protocol newProtocol, ProtocolChangedEvent.Direction direction)
|
||||
{
|
||||
bungee.getPluginManager().callEvent( new ProtocolChangedEvent( oldProtocol, newProtocol, this, direction ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handle(PluginMessage pluginMessage) throws Exception
|
||||
{
|
||||
|
|
|
@ -19,6 +19,7 @@ import net.md_5.bungee.api.connection.ProxiedPlayer;
|
|||
import net.md_5.bungee.api.event.ChatEvent;
|
||||
import net.md_5.bungee.api.event.PlayerDisconnectEvent;
|
||||
import net.md_5.bungee.api.event.PluginMessageEvent;
|
||||
import net.md_5.bungee.api.event.ProtocolChangedEvent;
|
||||
import net.md_5.bungee.api.event.SettingsChangedEvent;
|
||||
import net.md_5.bungee.api.event.TabCompleteEvent;
|
||||
import net.md_5.bungee.entitymap.EntityMap;
|
||||
|
@ -155,6 +156,12 @@ public class UpstreamBridge extends PacketHandler
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void protocolChanged(ChannelWrapper channel, Protocol oldProtocol, Protocol newProtocol, ProtocolChangedEvent.Direction direction)
|
||||
{
|
||||
BungeeCord.getInstance().getPluginManager().callEvent( new ProtocolChangedEvent( oldProtocol, newProtocol, con, direction ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handle(KeepAlive alive) throws Exception
|
||||
{
|
||||
|
|
|
@ -9,6 +9,7 @@ import java.net.SocketAddress;
|
|||
import java.util.concurrent.TimeUnit;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import net.md_5.bungee.api.event.ProtocolChangedEvent;
|
||||
import net.md_5.bungee.compress.PacketCompressor;
|
||||
import net.md_5.bungee.compress.PacketDecompressor;
|
||||
import net.md_5.bungee.protocol.DefinedPacket;
|
||||
|
@ -43,7 +44,13 @@ public class ChannelWrapper
|
|||
|
||||
public void setDecodeProtocol(Protocol protocol)
|
||||
{
|
||||
Protocol oldProtocol = getDecodeProtocol();
|
||||
ch.pipeline().get( MinecraftDecoder.class ).setProtocol( protocol );
|
||||
HandlerBoss handlerBoss = ch.pipeline().get( HandlerBoss.class );
|
||||
if ( oldProtocol != protocol && handlerBoss != null )
|
||||
{
|
||||
handlerBoss.getHandler().protocolChanged( this, oldProtocol, protocol, ProtocolChangedEvent.Direction.DECODE );
|
||||
}
|
||||
}
|
||||
|
||||
public Protocol getEncodeProtocol()
|
||||
|
@ -54,7 +61,13 @@ public class ChannelWrapper
|
|||
|
||||
public void setEncodeProtocol(Protocol protocol)
|
||||
{
|
||||
Protocol oldProtocol = getEncodeProtocol();
|
||||
ch.pipeline().get( MinecraftEncoder.class ).setProtocol( protocol );
|
||||
HandlerBoss handlerBoss = ch.pipeline().get( HandlerBoss.class );
|
||||
if ( oldProtocol != protocol && handlerBoss != null )
|
||||
{
|
||||
handlerBoss.getHandler().protocolChanged( this, oldProtocol, protocol, ProtocolChangedEvent.Direction.ENCODE );
|
||||
}
|
||||
}
|
||||
|
||||
public void setProtocol(Protocol protocol)
|
||||
|
|
|
@ -10,6 +10,8 @@ import io.netty.handler.timeout.ReadTimeoutException;
|
|||
import java.io.IOException;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.util.logging.Level;
|
||||
import lombok.AccessLevel;
|
||||
import lombok.Getter;
|
||||
import net.md_5.bungee.api.ProxyServer;
|
||||
import net.md_5.bungee.connection.CancelSendSignal;
|
||||
import net.md_5.bungee.connection.InitialHandler;
|
||||
|
@ -29,6 +31,7 @@ public class HandlerBoss extends ChannelInboundHandlerAdapter
|
|||
{
|
||||
|
||||
private ChannelWrapper channel;
|
||||
@Getter(AccessLevel.PACKAGE)
|
||||
private PacketHandler handler;
|
||||
|
||||
public void setHandler(PacketHandler handler)
|
||||
|
@ -94,6 +97,9 @@ public class HandlerBoss extends ChannelInboundHandlerAdapter
|
|||
} );
|
||||
|
||||
channel.setRemoteAddress( newAddress );
|
||||
} else
|
||||
{
|
||||
channel.close();
|
||||
}
|
||||
} finally
|
||||
{
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
package net.md_5.bungee.netty;
|
||||
|
||||
import net.md_5.bungee.api.event.ProtocolChangedEvent;
|
||||
import net.md_5.bungee.protocol.PacketWrapper;
|
||||
import net.md_5.bungee.protocol.Protocol;
|
||||
|
||||
public abstract class PacketHandler extends net.md_5.bungee.protocol.AbstractPacketHandler
|
||||
{
|
||||
|
@ -32,4 +34,9 @@ public abstract class PacketHandler extends net.md_5.bungee.protocol.AbstractPac
|
|||
public void writabilityChanged(ChannelWrapper channel) throws Exception
|
||||
{
|
||||
}
|
||||
|
||||
public void protocolChanged(ChannelWrapper channel, Protocol oldProtocol, Protocol newProtocol, ProtocolChangedEvent.Direction direction)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue