Close #918 - use case insensitive lookup for Yaml locations
This commit is contained in:
@@ -6,6 +6,8 @@ import java.math.BigInteger;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.URLEncoder;
|
||||
import java.security.MessageDigest;
|
||||
import java.util.Date;
|
||||
import java.util.UUID;
|
||||
import java.util.logging.Level;
|
||||
import javax.crypto.SecretKey;
|
||||
import lombok.Getter;
|
||||
@@ -305,6 +307,10 @@ public class InitialHandler extends PacketHandler implements PendingConnection
|
||||
if ( obj != null )
|
||||
{
|
||||
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();
|
||||
return;
|
||||
}
|
||||
|
@@ -1,21 +0,0 @@
|
||||
package net.md_5.bungee.util;
|
||||
|
||||
import gnu.trove.strategy.HashingStrategy;
|
||||
|
||||
class CaseInsensitiveHashingStrategy implements HashingStrategy
|
||||
{
|
||||
|
||||
static final CaseInsensitiveHashingStrategy INSTANCE = new CaseInsensitiveHashingStrategy();
|
||||
|
||||
@Override
|
||||
public int computeHashCode(Object object)
|
||||
{
|
||||
return ( (String) object ).toLowerCase().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() ) );
|
||||
}
|
||||
}
|
@@ -1,18 +0,0 @@
|
||||
package net.md_5.bungee.util;
|
||||
|
||||
import gnu.trove.map.hash.TCustomHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class CaseInsensitiveMap<V> extends TCustomHashMap<String, V>
|
||||
{
|
||||
|
||||
public CaseInsensitiveMap()
|
||||
{
|
||||
super( CaseInsensitiveHashingStrategy.INSTANCE );
|
||||
}
|
||||
|
||||
public CaseInsensitiveMap(Map<? extends String, ? extends V> map)
|
||||
{
|
||||
super( CaseInsensitiveHashingStrategy.INSTANCE, map );
|
||||
}
|
||||
}
|
@@ -1,18 +0,0 @@
|
||||
package net.md_5.bungee.util;
|
||||
|
||||
import gnu.trove.set.hash.TCustomHashSet;
|
||||
import java.util.Collection;
|
||||
|
||||
public class CaseInsensitiveSet extends TCustomHashSet<String>
|
||||
{
|
||||
|
||||
public CaseInsensitiveSet()
|
||||
{
|
||||
super( CaseInsensitiveHashingStrategy.INSTANCE );
|
||||
}
|
||||
|
||||
public CaseInsensitiveSet(Collection<? extends String> collection)
|
||||
{
|
||||
super( CaseInsensitiveHashingStrategy.INSTANCE, collection );
|
||||
}
|
||||
}
|
@@ -1,34 +0,0 @@
|
||||
package net.md_5.bungee.util;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.Assert;
|
||||
|
||||
public class CaseInsensitiveTest
|
||||
{
|
||||
|
||||
@Test
|
||||
public void testMaps()
|
||||
{
|
||||
Object obj = new Object();
|
||||
CaseInsensitiveMap<Object> map = new CaseInsensitiveMap<>();
|
||||
|
||||
map.put( "FOO", obj );
|
||||
Assert.assertTrue( map.contains( "foo" ) ); // Assert that contains is case insensitive
|
||||
Assert.assertTrue( map.entrySet().iterator().next().getKey().equals( "FOO" ) ); // Assert that case is preserved
|
||||
|
||||
// Assert that remove is case insensitive
|
||||
map.remove( "FoO" );
|
||||
Assert.assertFalse( map.contains( "foo" ) );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSets()
|
||||
{
|
||||
CaseInsensitiveSet set = new CaseInsensitiveSet();
|
||||
|
||||
set.add( "FOO" );
|
||||
Assert.assertTrue( set.contains( "foo" ) ); // Assert that contains is case insensitive
|
||||
set.remove( "FoO" );
|
||||
Assert.assertFalse( set.contains( "foo" ) ); // Assert that remove is case insensitive
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user