mirror of
https://github.com/SpigotMC/BungeeCord.git
synced 2024-12-24 01:27:38 +01:00
Always use root locale for case conversions
This commit is contained in:
parent
27f926cfc7
commit
ed6b03d24a
@ -16,6 +16,7 @@ import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.Stack;
|
||||
@ -75,10 +76,10 @@ public class PluginManager
|
||||
*/
|
||||
public void registerCommand(Plugin plugin, Command command)
|
||||
{
|
||||
commandMap.put( command.getName().toLowerCase(), command );
|
||||
commandMap.put( command.getName().toLowerCase( Locale.ROOT ), command );
|
||||
for ( String alias : command.getAliases() )
|
||||
{
|
||||
commandMap.put( alias.toLowerCase(), command );
|
||||
commandMap.put( alias.toLowerCase( Locale.ROOT ), command );
|
||||
}
|
||||
commandsByPlugin.put( plugin, command );
|
||||
}
|
||||
@ -126,12 +127,12 @@ public class PluginManager
|
||||
{
|
||||
String[] split = commandLine.split( " ", -1 );
|
||||
// Check for chat that only contains " "
|
||||
if ( split.length == 0 )
|
||||
if ( split.length == 0 || split[0].isEmpty() )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
String commandName = split[0].toLowerCase();
|
||||
String commandName = split[0].toLowerCase( Locale.ROOT );
|
||||
if ( sender instanceof ProxiedPlayer && proxy.getDisabledCommands().contains( commandName ) )
|
||||
{
|
||||
return false;
|
||||
|
@ -3,6 +3,7 @@ package net.md_5.bungee.command;
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.base.Predicate;
|
||||
import com.google.common.collect.Iterables;
|
||||
import java.util.Locale;
|
||||
import net.md_5.bungee.api.CommandSender;
|
||||
import net.md_5.bungee.api.ProxyServer;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
@ -29,13 +30,13 @@ public abstract class PlayerCommand extends Command implements TabExecutor
|
||||
@Override
|
||||
public Iterable<String> onTabComplete(CommandSender sender, String[] args)
|
||||
{
|
||||
final String lastArg = ( args.length > 0 ) ? args[args.length - 1].toLowerCase() : "";
|
||||
final String lastArg = ( args.length > 0 ) ? args[args.length - 1].toLowerCase( Locale.ROOT ) : "";
|
||||
return Iterables.transform( Iterables.filter( ProxyServer.getInstance().getPlayers(), new Predicate<ProxiedPlayer>()
|
||||
{
|
||||
@Override
|
||||
public boolean apply(ProxiedPlayer player)
|
||||
{
|
||||
return player.getName().toLowerCase().startsWith( lastArg );
|
||||
return player.getName().toLowerCase( Locale.ROOT ).startsWith( lastArg );
|
||||
}
|
||||
} ), new Function<ProxiedPlayer, String>()
|
||||
{
|
||||
|
@ -1,6 +1,7 @@
|
||||
package net.md_5.bungee.util;
|
||||
|
||||
import gnu.trove.strategy.HashingStrategy;
|
||||
import java.util.Locale;
|
||||
|
||||
class CaseInsensitiveHashingStrategy implements HashingStrategy
|
||||
{
|
||||
@ -10,12 +11,12 @@ class CaseInsensitiveHashingStrategy implements HashingStrategy
|
||||
@Override
|
||||
public int computeHashCode(Object object)
|
||||
{
|
||||
return ( (String) object ).toLowerCase().hashCode();
|
||||
return ( (String) object ).toLowerCase( Locale.ROOT ).hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o1, Object o2)
|
||||
{
|
||||
return o1.equals( o2 ) || ( o1 instanceof String && o2 instanceof String && ( (String) o1 ).toLowerCase().equals( ( (String) o2 ).toLowerCase() ) );
|
||||
return o1.equals( o2 ) || ( o1 instanceof String && o2 instanceof String && ( (String) o1 ).toLowerCase( Locale.ROOT ).equals( ( (String) o2 ).toLowerCase( Locale.ROOT ) ) );
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package net.md_5.bungee.api;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.regex.Pattern;
|
||||
import lombok.Getter;
|
||||
|
@ -2,6 +2,7 @@ package net.md_5.bungee.module.cmd.send;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import java.util.HashSet;
|
||||
import java.util.Locale;
|
||||
import java.util.Set;
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
import net.md_5.bungee.api.CommandSender;
|
||||
@ -97,10 +98,10 @@ public class CommandSend extends Command implements TabExecutor
|
||||
Set<String> matches = new HashSet<>();
|
||||
if ( args.length == 1 )
|
||||
{
|
||||
String search = args[0].toLowerCase();
|
||||
String search = args[0].toLowerCase( Locale.ROOT );
|
||||
for ( ProxiedPlayer player : ProxyServer.getInstance().getPlayers() )
|
||||
{
|
||||
if ( player.getName().toLowerCase().startsWith( search ) )
|
||||
if ( player.getName().toLowerCase( Locale.ROOT ).startsWith( search ) )
|
||||
{
|
||||
matches.add( player.getName() );
|
||||
}
|
||||
@ -115,10 +116,10 @@ public class CommandSend extends Command implements TabExecutor
|
||||
}
|
||||
} else
|
||||
{
|
||||
String search = args[1].toLowerCase();
|
||||
String search = args[1].toLowerCase( Locale.ROOT );
|
||||
for ( String server : ProxyServer.getInstance().getServers().keySet() )
|
||||
{
|
||||
if ( server.toLowerCase().startsWith( search ) )
|
||||
if ( server.toLowerCase( Locale.ROOT ).startsWith( search ) )
|
||||
{
|
||||
matches.add( server );
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import com.google.common.base.Function;
|
||||
import com.google.common.base.Predicate;
|
||||
import com.google.common.collect.Iterables;
|
||||
import java.util.Collections;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
import net.md_5.bungee.api.CommandSender;
|
||||
@ -86,12 +87,12 @@ public class CommandServer extends Command implements TabExecutor
|
||||
{
|
||||
return ( args.length > 1 ) ? Collections.EMPTY_LIST : Iterables.transform( Iterables.filter( ProxyServer.getInstance().getServers().values(), new Predicate<ServerInfo>()
|
||||
{
|
||||
private final String lower = ( args.length == 0 ) ? "" : args[0].toLowerCase();
|
||||
private final String lower = ( args.length == 0 ) ? "" : args[0].toLowerCase( Locale.ROOT );
|
||||
|
||||
@Override
|
||||
public boolean apply(ServerInfo input)
|
||||
{
|
||||
return input.getName().toLowerCase().startsWith( lower ) && input.canAccess( sender );
|
||||
return input.getName().toLowerCase( Locale.ROOT ).startsWith( lower ) && input.canAccess( sender );
|
||||
}
|
||||
} ), new Function<ServerInfo, String>()
|
||||
{
|
||||
|
@ -724,7 +724,7 @@ public class BungeeCord extends ProxyServer
|
||||
@Override
|
||||
public boolean apply(ProxiedPlayer input)
|
||||
{
|
||||
return ( input == null ) ? false : input.getName().toLowerCase().startsWith( partialName.toLowerCase() );
|
||||
return ( input == null ) ? false : input.getName().toLowerCase( Locale.ROOT ).startsWith( partialName.toLowerCase( Locale.ROOT ) );
|
||||
}
|
||||
} ) );
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ package net.md_5.bungee;
|
||||
import com.google.common.base.Preconditions;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.ByteBufAllocator;
|
||||
import java.util.Locale;
|
||||
import java.util.Queue;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
@ -296,7 +297,7 @@ public class ServerConnector extends PacketHandler
|
||||
{
|
||||
ServerInfo def = user.updateAndGetNextServer( target );
|
||||
ServerKickEvent event = new ServerKickEvent( user, target, ComponentSerializer.parse( kick.getMessage() ), def, ServerKickEvent.State.CONNECTING );
|
||||
if ( event.getKickReason().toLowerCase().contains( "outdated" ) && def != null )
|
||||
if ( event.getKickReason().toLowerCase( Locale.ROOT ).contains( "outdated" ) && def != null )
|
||||
{
|
||||
// Pre cancel the event if we are going to try another server
|
||||
event.setCancelled( true );
|
||||
|
@ -15,6 +15,7 @@ import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.logging.Level;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
@ -243,7 +244,7 @@ public class YamlConfig implements ConfigurationAdapter
|
||||
InetSocketAddress address = Util.getAddr( host );
|
||||
Map<String, String> forced = new CaseInsensitiveMap<>( get( "forced_hosts", forcedDef, val ) );
|
||||
String tabListName = get( "tab_list", "GLOBAL_PING", val );
|
||||
DefaultTabList value = DefaultTabList.valueOf( tabListName.toUpperCase() );
|
||||
DefaultTabList value = DefaultTabList.valueOf( tabListName.toUpperCase( Locale.ROOT ) );
|
||||
if ( value == null )
|
||||
{
|
||||
value = DefaultTabList.GLOBAL_PING;
|
||||
|
Loading…
Reference in New Issue
Block a user