Try loading native cipher from java.library.path first
This commit is contained in:
parent
972b4c1fe5
commit
22084b2c75
@ -30,21 +30,32 @@ public class NativeCipher implements BungeeCipher
|
|||||||
{
|
{
|
||||||
if ( !loaded && isSupported() )
|
if ( !loaded && isSupported() )
|
||||||
{
|
{
|
||||||
try ( InputStream lib = BungeeCipher.class.getClassLoader().getResourceAsStream( "native-cipher.so" ) )
|
try
|
||||||
{
|
{
|
||||||
// Else we will create and copy it to a temp file
|
System.loadLibrary( "bungeecord-native-cipher" );
|
||||||
File temp = File.createTempFile( "bungeecord-native-cipher", ".so" );
|
|
||||||
temp.deleteOnExit();
|
|
||||||
|
|
||||||
try ( OutputStream outputStream = new FileOutputStream( temp ) )
|
|
||||||
{
|
|
||||||
ByteStreams.copy( lib, outputStream );
|
|
||||||
System.load( temp.getPath() );
|
|
||||||
}
|
|
||||||
loaded = true;
|
loaded = true;
|
||||||
} catch ( Throwable t )
|
} catch ( Throwable t )
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( !loaded )
|
||||||
|
{
|
||||||
|
try ( InputStream lib = BungeeCipher.class.getClassLoader().getResourceAsStream( "native-cipher.so" ) )
|
||||||
|
{
|
||||||
|
// Else we will create and copy it to a temp file
|
||||||
|
File temp = File.createTempFile( "bungeecord-native-cipher", ".so" );
|
||||||
|
temp.deleteOnExit();
|
||||||
|
|
||||||
|
try ( OutputStream outputStream = new FileOutputStream( temp ) )
|
||||||
|
{
|
||||||
|
ByteStreams.copy( lib, outputStream );
|
||||||
|
System.load( temp.getPath() );
|
||||||
|
}
|
||||||
|
loaded = true;
|
||||||
|
} catch ( Throwable t )
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return loaded;
|
return loaded;
|
||||||
|
Loading…
Reference in New Issue
Block a user