Skip to content

Commit

Permalink
Merge pull request #12 from SpigotMC/master
Browse files Browse the repository at this point in the history
[pull] master from SpigotMC:master
  • Loading branch information
pull[bot] authored Feb 11, 2025
2 parents c54b386 + 4dad940 commit 3c3ae24
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,21 @@
public class PluginMessage extends DefinedPacket
{

public static final String BUNGEE_CHANNEL_LEGACY = "BungeeCord";
public static final String BUNGEE_CHANNEL_MODERN = "bungeecord:main";
public static final Function<String, String> MODERNISE = new Function<String, String>()
{
@Override
public String apply(String tag)
{
// Transform as per Bukkit
if ( tag.equals( "BungeeCord" ) )
if ( tag.equals( PluginMessage.BUNGEE_CHANNEL_LEGACY ) )
{
return "bungeecord:main";
return PluginMessage.BUNGEE_CHANNEL_MODERN;
}
if ( tag.equals( "bungeecord:main" ) )
if ( tag.equals( PluginMessage.BUNGEE_CHANNEL_MODERN ) )
{
return "BungeeCord";
return PluginMessage.BUNGEE_CHANNEL_LEGACY;
}

// Code that gets to here is UNLIKELY to be viable on the Bukkit side of side things,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ public class PluginMessageTest
@Test
public void testModerniseChannel()
{
assertEquals( "bungeecord:main", PluginMessage.MODERNISE.apply( "BungeeCord" ) );
assertEquals( "BungeeCord", PluginMessage.MODERNISE.apply( "bungeecord:main" ) );
assertEquals( PluginMessage.BUNGEE_CHANNEL_MODERN, PluginMessage.MODERNISE.apply( PluginMessage.BUNGEE_CHANNEL_LEGACY ) );
assertEquals( PluginMessage.BUNGEE_CHANNEL_LEGACY, PluginMessage.MODERNISE.apply( PluginMessage.BUNGEE_CHANNEL_MODERN ) );
assertEquals( "legacy:foo", PluginMessage.MODERNISE.apply( "FoO" ) );
assertEquals( "foo:bar", PluginMessage.MODERNISE.apply( "foo:bar" ) );
}
Expand Down
2 changes: 1 addition & 1 deletion proxy/src/main/java/net/md_5/bungee/BungeeCord.java
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ public class BungeeCord extends ProxyServer

{
// TODO: Proper fallback when we interface the manager
registerChannel( "BungeeCord" );
registerChannel( PluginMessage.BUNGEE_CHANNEL_LEGACY );
}

public static BungeeCord getInstance()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ public void handle(PluginMessage pluginMessage) throws Exception
throw CancelSendSignal.INSTANCE;
}

if ( pluginMessage.getTag().equals( "BungeeCord" ) )
if ( pluginMessage.getTag().equals( PluginMessage.BUNGEE_CHANNEL_LEGACY ) )
{
ByteArrayDataOutput out = ByteStreams.newDataOutput();
String subChannel = in.readUTF();
Expand All @@ -359,7 +359,7 @@ public void handle(PluginMessage pluginMessage) throws Exception
out.write( data );
byte[] payload = out.toByteArray();

target.getServer().sendData( "BungeeCord", payload );
target.getServer().sendData( PluginMessage.BUNGEE_CHANNEL_LEGACY, payload );
}

// Null out stream, important as we don't want to send to ourselves
Expand Down Expand Up @@ -391,7 +391,7 @@ public void handle(PluginMessage pluginMessage) throws Exception
{
if ( server != this.server.getInfo() )
{
server.sendData( "BungeeCord", payload );
server.sendData( PluginMessage.BUNGEE_CHANNEL_LEGACY, payload );
}
}
break;
Expand All @@ -400,15 +400,15 @@ public void handle(PluginMessage pluginMessage) throws Exception
{
if ( server != this.server.getInfo() )
{
server.sendData( "BungeeCord", payload, false );
server.sendData( PluginMessage.BUNGEE_CHANNEL_LEGACY, payload, false );
}
}
break;
default:
ServerInfo server = bungee.getServerInfo( target );
if ( server != null )
{
server.sendData( "BungeeCord", payload );
server.sendData( PluginMessage.BUNGEE_CHANNEL_LEGACY, payload );
}
break;
}
Expand Down Expand Up @@ -636,7 +636,7 @@ public void handle(PluginMessage pluginMessage) throws Exception
byte[] b = out.toByteArray();
if ( b.length != 0 )
{
server.sendData( "BungeeCord", b );
server.sendData( PluginMessage.BUNGEE_CHANNEL_LEGACY, b );
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ public void handle(ClientSettings settings) throws Exception
@Override
public void handle(PluginMessage pluginMessage) throws Exception
{
if ( pluginMessage.getTag().equals( "BungeeCord" ) )
if ( pluginMessage.getTag().equals( PluginMessage.BUNGEE_CHANNEL_LEGACY ) || pluginMessage.getTag().equals( PluginMessage.BUNGEE_CHANNEL_MODERN ) )
{
throw CancelSendSignal.INSTANCE;
}
Expand Down

0 comments on commit 3c3ae24

Please sign in to comment.