Close #918 - use case insensitive lookup for Yaml locations

This commit is contained in:
md_5 2014-03-10 11:04:28 +11:00
parent 003a1973d4
commit 4a7f8015e5
6 changed files with 10 additions and 3 deletions

View File

@ -14,6 +14,7 @@ import java.util.logging.Level;
import net.md_5.bungee.api.ProxyServer; import net.md_5.bungee.api.ProxyServer;
import net.md_5.bungee.api.config.ServerInfo; import net.md_5.bungee.api.config.ServerInfo;
import net.md_5.bungee.api.connection.ProxiedPlayer; import net.md_5.bungee.api.connection.ProxiedPlayer;
import net.md_5.bungee.util.CaseInsensitiveMap;
import org.yaml.snakeyaml.Yaml; import org.yaml.snakeyaml.Yaml;
import org.yaml.snakeyaml.error.YAMLException; import org.yaml.snakeyaml.error.YAMLException;
@ -24,7 +25,7 @@ public class YamlReconnectHandler extends AbstractReconnectHandler
private final File file = new File( "locations.yml" ); private final File file = new File( "locations.yml" );
private final ReadWriteLock lock = new ReentrantReadWriteLock(); private final ReadWriteLock lock = new ReentrantReadWriteLock();
/*========================================================================*/ /*========================================================================*/
private Map<String, String> data; private CaseInsensitiveMap< String> data;
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public YamlReconnectHandler() public YamlReconnectHandler()
@ -34,7 +35,7 @@ public class YamlReconnectHandler extends AbstractReconnectHandler
file.createNewFile(); file.createNewFile();
try ( FileReader rd = new FileReader( file ) ) try ( FileReader rd = new FileReader( file ) )
{ {
data = yaml.loadAs( rd, Map.class ); data = new CaseInsensitiveMap<>( yaml.loadAs( rd, Map.class ) );
} }
} catch ( YAMLException ex ) } catch ( YAMLException ex )
{ {
@ -47,7 +48,7 @@ public class YamlReconnectHandler extends AbstractReconnectHandler
if ( data == null ) if ( data == null )
{ {
data = new HashMap<>(); data = new CaseInsensitiveMap<>();
} }
} }

View File

@ -6,6 +6,8 @@ import java.math.BigInteger;
import java.net.InetSocketAddress; import java.net.InetSocketAddress;
import java.net.URLEncoder; import java.net.URLEncoder;
import java.security.MessageDigest; import java.security.MessageDigest;
import java.util.Date;
import java.util.UUID;
import java.util.logging.Level; import java.util.logging.Level;
import javax.crypto.SecretKey; import javax.crypto.SecretKey;
import lombok.Getter; import lombok.Getter;
@ -305,6 +307,10 @@ public class InitialHandler extends PacketHandler implements PendingConnection
if ( obj != null ) if ( obj != null )
{ {
UUID = obj.getId(); UUID = obj.getId();
UUID = UUID.substring(0, 8) + "-" + UUID.substring(8, 12) + "-" + UUID.substring(12, 16) + "-" + UUID.substring(16, 20) + "-" + UUID.substring(20, 32);
java.util.UUID u = java.util.UUID.fromString( UUID );
System.out.println( u.version() );
System.out.println( new Date(u.clockSequence()) );
finish(); finish();
return; return;
} }