From 0fc5694b6a08e07d7c31a512995239fe8ffd047e Mon Sep 17 00:00:00 2001 From: md_5 Date: Sat, 28 Oct 2017 17:08:05 +1100 Subject: [PATCH] Fix some compiler warnings --- .../src/main/java/net/md_5/bungee/BungeeCordLauncher.java | 3 ++- .../net/md_5/bungee/module/cmd/alert/CommandAlert.java | 3 ++- .../java/net/md_5/bungee/module/cmd/find/CommandFind.java | 7 ++++--- native/src/main/java/net/md_5/bungee/jni/NativeCode.java | 6 +++--- native/src/test/java/net/md_5/bungee/NativeCipherTest.java | 2 +- native/src/test/java/net/md_5/bungee/NativeZlibTest.java | 2 +- proxy/src/main/java/net/md_5/bungee/BungeeServerInfo.java | 2 +- proxy/src/main/java/net/md_5/bungee/EncryptionUtil.java | 2 +- .../java/net/md_5/bungee/compress/CompressFactory.java | 2 +- proxy/src/main/java/net/md_5/bungee/conf/YamlConfig.java | 6 +++--- .../main/java/net/md_5/bungee/module/ModuleManager.java | 4 ++-- 11 files changed, 21 insertions(+), 18 deletions(-) diff --git a/bootstrap/src/main/java/net/md_5/bungee/BungeeCordLauncher.java b/bootstrap/src/main/java/net/md_5/bungee/BungeeCordLauncher.java index 3c1bbe93..b6b2ceef 100644 --- a/bootstrap/src/main/java/net/md_5/bungee/BungeeCordLauncher.java +++ b/bootstrap/src/main/java/net/md_5/bungee/BungeeCordLauncher.java @@ -10,6 +10,7 @@ import joptsimple.OptionParser; import joptsimple.OptionSet; import net.md_5.bungee.api.ChatColor; import net.md_5.bungee.api.ProxyServer; +import net.md_5.bungee.api.chat.ComponentBuilder; import net.md_5.bungee.command.ConsoleCommandSender; public class BungeeCordLauncher @@ -61,7 +62,7 @@ public class BungeeCordLauncher { if ( !bungee.getPluginManager().dispatchCommand( ConsoleCommandSender.getInstance(), line ) ) { - bungee.getConsole().sendMessage( ChatColor.RED + "Command not found" ); + bungee.getConsole().sendMessage( new ComponentBuilder( "Command not found" ).color( ChatColor.RED ).create() ); } } } diff --git a/module/cmd-alert/src/main/java/net/md_5/bungee/module/cmd/alert/CommandAlert.java b/module/cmd-alert/src/main/java/net/md_5/bungee/module/cmd/alert/CommandAlert.java index e3bdbc4b..3618c12f 100644 --- a/module/cmd-alert/src/main/java/net/md_5/bungee/module/cmd/alert/CommandAlert.java +++ b/module/cmd-alert/src/main/java/net/md_5/bungee/module/cmd/alert/CommandAlert.java @@ -3,6 +3,7 @@ package net.md_5.bungee.module.cmd.alert; import net.md_5.bungee.api.ChatColor; import net.md_5.bungee.api.CommandSender; import net.md_5.bungee.api.ProxyServer; +import net.md_5.bungee.api.chat.TextComponent; import net.md_5.bungee.api.plugin.Command; public class CommandAlert extends Command @@ -39,7 +40,7 @@ public class CommandAlert extends Command String message = builder.substring( 0, builder.length() - 1 ); - ProxyServer.getInstance().broadcast( message ); + ProxyServer.getInstance().broadcast( TextComponent.fromLegacyText( message ) ); } } } diff --git a/module/cmd-find/src/main/java/net/md_5/bungee/module/cmd/find/CommandFind.java b/module/cmd-find/src/main/java/net/md_5/bungee/module/cmd/find/CommandFind.java index e6799643..9c5bcb81 100644 --- a/module/cmd-find/src/main/java/net/md_5/bungee/module/cmd/find/CommandFind.java +++ b/module/cmd-find/src/main/java/net/md_5/bungee/module/cmd/find/CommandFind.java @@ -3,6 +3,7 @@ package net.md_5.bungee.module.cmd.find; import net.md_5.bungee.api.ChatColor; import net.md_5.bungee.api.CommandSender; import net.md_5.bungee.api.ProxyServer; +import net.md_5.bungee.api.chat.ComponentBuilder; import net.md_5.bungee.api.connection.ProxiedPlayer; import net.md_5.bungee.command.PlayerCommand; @@ -19,16 +20,16 @@ public class CommandFind extends PlayerCommand { if ( args.length != 1 ) { - sender.sendMessage( ChatColor.RED + "Please follow this command by a user name" ); + sender.sendMessage( new ComponentBuilder( "Please follow this command by a user name" ).color( ChatColor.RED ).create() ); } else { ProxiedPlayer player = ProxyServer.getInstance().getPlayer( args[0] ); if ( player == null || player.getServer() == null ) { - sender.sendMessage( ChatColor.RED + "That user is not online" ); + sender.sendMessage( new ComponentBuilder( "That user is not online" ).color( ChatColor.RED ).create() ); } else { - sender.sendMessage( ChatColor.GREEN + args[0] + " is online at " + player.getServer().getInfo().getName() ); + sender.sendMessage( new ComponentBuilder( args[0] ).color( ChatColor.GREEN ).append( " is online at " ).append( player.getServer().getInfo().getName() ).create() ); } } } diff --git a/native/src/main/java/net/md_5/bungee/jni/NativeCode.java b/native/src/main/java/net/md_5/bungee/jni/NativeCode.java index ad5657dd..6c92c1f5 100644 --- a/native/src/main/java/net/md_5/bungee/jni/NativeCode.java +++ b/native/src/main/java/net/md_5/bungee/jni/NativeCode.java @@ -12,12 +12,12 @@ public final class NativeCode { private final String name; - private final Class javaImpl; - private final Class nativeImpl; + private final Class javaImpl; + private final Class nativeImpl; // private boolean loaded; - public NativeCode(String name, Class javaImpl, Class nativeImpl) + public NativeCode(String name, Class javaImpl, Class nativeImpl) { this.name = name; this.javaImpl = javaImpl; diff --git a/native/src/test/java/net/md_5/bungee/NativeCipherTest.java b/native/src/test/java/net/md_5/bungee/NativeCipherTest.java index aa32869d..62477065 100644 --- a/native/src/test/java/net/md_5/bungee/NativeCipherTest.java +++ b/native/src/test/java/net/md_5/bungee/NativeCipherTest.java @@ -26,7 +26,7 @@ public class NativeCipherTest private final SecretKey secret = new SecretKeySpec( new byte[ 16 ], "AES" ); private static final int BENCHMARK_COUNT = 4096; // - private static final NativeCode factory = new NativeCode( "native-cipher", JavaCipher.class, NativeCipher.class ); + private static final NativeCode factory = new NativeCode<>( "native-cipher", JavaCipher.class, NativeCipher.class ); @Test public void testNative() throws Exception diff --git a/native/src/test/java/net/md_5/bungee/NativeZlibTest.java b/native/src/test/java/net/md_5/bungee/NativeZlibTest.java index 50a23244..fde626b1 100644 --- a/native/src/test/java/net/md_5/bungee/NativeZlibTest.java +++ b/native/src/test/java/net/md_5/bungee/NativeZlibTest.java @@ -15,7 +15,7 @@ import org.junit.Test; public class NativeZlibTest { - private final NativeCode factory = new NativeCode( "native-compress", JavaZlib.class, NativeZlib.class ); + private final NativeCode factory = new NativeCode<>( "native-compress", JavaZlib.class, NativeZlib.class ); @Test public void doTest() throws DataFormatException diff --git a/proxy/src/main/java/net/md_5/bungee/BungeeServerInfo.java b/proxy/src/main/java/net/md_5/bungee/BungeeServerInfo.java index 1dd0aeba..89c8f48f 100644 --- a/proxy/src/main/java/net/md_5/bungee/BungeeServerInfo.java +++ b/proxy/src/main/java/net/md_5/bungee/BungeeServerInfo.java @@ -66,7 +66,7 @@ public class BungeeServerInfo implements ServerInfo @Override public Collection getPlayers() { - return Collections.unmodifiableCollection( new HashSet( players ) ); + return Collections.unmodifiableCollection( new HashSet<>( players ) ); } @Override diff --git a/proxy/src/main/java/net/md_5/bungee/EncryptionUtil.java b/proxy/src/main/java/net/md_5/bungee/EncryptionUtil.java index 871e4ad0..0b4732cd 100644 --- a/proxy/src/main/java/net/md_5/bungee/EncryptionUtil.java +++ b/proxy/src/main/java/net/md_5/bungee/EncryptionUtil.java @@ -31,7 +31,7 @@ public class EncryptionUtil public static final KeyPair keys; @Getter private static final SecretKey secret = new SecretKeySpec( new byte[ 16 ], "AES" ); - public static final NativeCode nativeFactory = new NativeCode( "native-cipher", JavaCipher.class, NativeCipher.class ); + public static final NativeCode nativeFactory = new NativeCode<>( "native-cipher", JavaCipher.class, NativeCipher.class ); static { diff --git a/proxy/src/main/java/net/md_5/bungee/compress/CompressFactory.java b/proxy/src/main/java/net/md_5/bungee/compress/CompressFactory.java index 32b2b3e6..1f2d5a70 100644 --- a/proxy/src/main/java/net/md_5/bungee/compress/CompressFactory.java +++ b/proxy/src/main/java/net/md_5/bungee/compress/CompressFactory.java @@ -8,5 +8,5 @@ import net.md_5.bungee.jni.zlib.NativeZlib; public class CompressFactory { - public static final NativeCode zlib = new NativeCode( "native-compress", JavaZlib.class, NativeZlib.class ); + public static final NativeCode zlib = new NativeCode<>( "native-compress", JavaZlib.class, NativeZlib.class ); } diff --git a/proxy/src/main/java/net/md_5/bungee/conf/YamlConfig.java b/proxy/src/main/java/net/md_5/bungee/conf/YamlConfig.java index a2b96815..408312fd 100644 --- a/proxy/src/main/java/net/md_5/bungee/conf/YamlConfig.java +++ b/proxy/src/main/java/net/md_5/bungee/conf/YamlConfig.java @@ -42,7 +42,7 @@ public class YamlConfig implements ConfigurationAdapter GLOBAL(), GLOBAL_PING(), SERVER(); } private final Yaml yaml; - private Map config; + private Map config; private final File file = new File( "config.yml" ); public YamlConfig() @@ -72,10 +72,10 @@ public class YamlConfig implements ConfigurationAdapter if ( config == null ) { - config = new CaseInsensitiveMap(); + config = new CaseInsensitiveMap<>(); } else { - config = new CaseInsensitiveMap( config ); + config = new CaseInsensitiveMap<>( config ); } } catch ( IOException ex ) { diff --git a/proxy/src/main/java/net/md_5/bungee/module/ModuleManager.java b/proxy/src/main/java/net/md_5/bungee/module/ModuleManager.java index 901fc5a3..10366c88 100644 --- a/proxy/src/main/java/net/md_5/bungee/module/ModuleManager.java +++ b/proxy/src/main/java/net/md_5/bungee/module/ModuleManager.java @@ -63,10 +63,10 @@ public class ModuleManager if ( config == null ) { - config = new CaseInsensitiveMap(); + config = new CaseInsensitiveMap<>(); } else { - config = new CaseInsensitiveMap( config ); + config = new CaseInsensitiveMap<>( config ); } // End yaml