mirror of
https://github.com/PaperMC/Waterfall.git
synced 2024-11-05 01:59:37 +01:00
48 lines
2.5 KiB
Diff
48 lines
2.5 KiB
Diff
From 441f1f77ca0f9efb08ded45ebbd15fa0d51cc33d 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 49c97cd9..19b897c0 100644
|
|
--- a/proxy/src/main/java/net/md_5/bungee/BungeeCord.java
|
|
+++ b/proxy/src/main/java/net/md_5/bungee/BungeeCord.java
|
|
@@ -515,7 +515,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 1693f42b..b54e7b9b 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
|
|
@@ -233,7 +233,6 @@ public class DownstreamBridge extends PacketHandler
|
|
@Override
|
|
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() )
|
|
@@ -260,6 +259,7 @@ public class DownstreamBridge extends PacketHandler
|
|
|
|
if ( pluginMessage.getTag().equals( "BungeeCord" ) )
|
|
{
|
|
+ DataInput in = pluginMessage.getStream();
|
|
ByteArrayDataOutput out = ByteStreams.newDataOutput();
|
|
String subChannel = in.readUTF();
|
|
|
|
--
|
|
2.20.1
|
|
|