Waterfall/BungeeCord-Patches/0015-Micro-optimizations.patch
Shane Freeder 65ec15e5cc
Updated Upstream (BungeeCord)
Upstream has released updates that appear to apply and compile correctly.
This update has not been tested by PaperMC and as with ANY update, please do your own testing

BungeeCord Changes:
eae9d45c Provide more information in connect errors
d2d157c1 #3246: Fix commands not working due to MinecraftForge changes
2022-02-06 05:54:54 +00:00

48 lines
2.5 KiB
Diff

From d2e4ef8cea2353c302776ba3bf29f4a2fcf32569 Mon Sep 17 00:00:00 2001
From: Tux <write@imaginarycode.com>
Date: Tue, 19 Jan 2016 15:13:29 -0700
Subject: [PATCH] Micro-optimizations
- PluginManager.dispatchCommand() avoids regex while splitting commands. Java 7 introduced an optimized String.split() that should be used instead (affects command dispatch).
- Don't attempt to format arguments when there are none provided
- Don't create a data input stream for every plugin message we get from servers
diff --git a/proxy/src/main/java/net/md_5/bungee/BungeeCord.java b/proxy/src/main/java/net/md_5/bungee/BungeeCord.java
index dddc14d8..7227f268 100644
--- a/proxy/src/main/java/net/md_5/bungee/BungeeCord.java
+++ b/proxy/src/main/java/net/md_5/bungee/BungeeCord.java
@@ -559,7 +559,9 @@ public class BungeeCord extends ProxyServer
String translation = "<translation '" + name + "' missing>";
try
{
- translation = MessageFormat.format( customBundle != null && customBundle.containsKey( name ) ? customBundle.getString( name ) : baseBundle.getString( name ), args );
+ final String string = customBundle != null && customBundle.containsKey( name ) ? customBundle.getString( name ) : baseBundle.getString( name );
+
+ translation = ( args.length == 0 ) ? string : MessageFormat.format( string, args );
} catch ( MissingResourceException ex )
{
}
diff --git a/proxy/src/main/java/net/md_5/bungee/connection/DownstreamBridge.java b/proxy/src/main/java/net/md_5/bungee/connection/DownstreamBridge.java
index c0cd8570..a047c8b7 100644
--- a/proxy/src/main/java/net/md_5/bungee/connection/DownstreamBridge.java
+++ b/proxy/src/main/java/net/md_5/bungee/connection/DownstreamBridge.java
@@ -258,7 +258,6 @@ public class DownstreamBridge extends PacketHandler
@SuppressWarnings("checkstyle:avoidnestedblocks")
public void handle(PluginMessage pluginMessage) throws Exception
{
- DataInput in = pluginMessage.getStream();
PluginMessageEvent event = new PluginMessageEvent( server, con, pluginMessage.getTag(), pluginMessage.getData().clone() );
if ( bungee.getPluginManager().callEvent( event ).isCancelled() )
@@ -285,6 +284,7 @@ public class DownstreamBridge extends PacketHandler
if ( pluginMessage.getTag().equals( "BungeeCord" ) )
{
+ DataInput in = pluginMessage.getStream();
ByteArrayDataOutput out = ByteStreams.newDataOutput();
String subChannel = in.readUTF();
--
2.35.1