mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-12 17:07:55 -04:00
Merge branch 'entity-meta' into render
This commit is contained in:
commit
c065c01361
@ -13,6 +13,7 @@
|
||||
|
||||
package de.bixilon.minosoft.config;
|
||||
|
||||
import com.google.common.base.StandardSystemProperty;
|
||||
import de.bixilon.minosoft.util.OSUtil;
|
||||
|
||||
import java.io.File;
|
||||
@ -29,7 +30,7 @@ public class StaticConfiguration {
|
||||
static {
|
||||
// Sets Config.homeDir to the correct folder per OS
|
||||
String homeDir;
|
||||
homeDir = System.getProperty("user.home");
|
||||
homeDir = System.getProperty(StandardSystemProperty.USER_HOME.key());
|
||||
if (!homeDir.endsWith(File.separator)) {
|
||||
homeDir += "/";
|
||||
}
|
||||
|
@ -42,7 +42,7 @@ public class PacketPlayerPositionAndRotationSending implements ServerboundPacket
|
||||
public PacketPlayerPositionAndRotationSending(double x, double feetY, double z, float yaw, float pitch, boolean onGround) {
|
||||
this.x = x;
|
||||
this.feetY = feetY;
|
||||
this.headY = feetY - 1.62F;
|
||||
this.headY = feetY + 1.62F;
|
||||
this.z = z;
|
||||
this.yaw = yaw;
|
||||
this.pitch = pitch;
|
||||
|
@ -15,7 +15,7 @@ package de.bixilon.minosoft.protocol.protocol;
|
||||
|
||||
import javax.crypto.*;
|
||||
import javax.crypto.spec.IvParameterSpec;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.security.*;
|
||||
import java.security.spec.InvalidKeySpecException;
|
||||
import java.security.spec.X509EncodedKeySpec;
|
||||
@ -29,8 +29,8 @@ public class CryptManager {
|
||||
return key.generateKey();
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
e.printStackTrace();
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static KeyPair createNewKeyPair() {
|
||||
@ -40,17 +40,11 @@ public class CryptManager {
|
||||
return keyPair.generateKeyPair();
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
e.printStackTrace();
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static byte[] getServerHash(String serverId, PublicKey publicKey, SecretKey secretKey) {
|
||||
try {
|
||||
return digestOperation(serverId.getBytes("ISO_8859_1"), secretKey.getEncoded(), publicKey.getEncoded());
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
return digestOperation(serverId.getBytes(StandardCharsets.ISO_8859_1), secretKey.getEncoded(), publicKey.getEncoded());
|
||||
}
|
||||
|
||||
static byte[] digestOperation(byte[]... bytes) {
|
||||
@ -62,8 +56,8 @@ public class CryptManager {
|
||||
return disgest.digest();
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
e.printStackTrace();
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static PublicKey decodePublicKey(byte[] key) {
|
||||
@ -73,32 +67,32 @@ public class CryptManager {
|
||||
return keyFactory.generatePublic(keySpec);
|
||||
} catch (NoSuchAlgorithmException | InvalidKeySpecException e) {
|
||||
e.printStackTrace();
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static byte[] encryptData(Key key, byte[] data) {
|
||||
return cipherOperation(1, key, data);
|
||||
}
|
||||
|
||||
static byte[] cipherOperation(int p_75885_0_, Key key, byte[] data) {
|
||||
static byte[] cipherOperation(int opMode, Key key, byte[] data) {
|
||||
try {
|
||||
return createTheCipherInstance(p_75885_0_, key.getAlgorithm(), key).doFinal(data);
|
||||
return createTheCipherInstance(opMode, key.getAlgorithm(), key).doFinal(data);
|
||||
} catch (IllegalBlockSizeException | BadPaddingException e) {
|
||||
e.printStackTrace();
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
static Cipher createTheCipherInstance(int p_75886_0_, String transformation, Key key) {
|
||||
static Cipher createTheCipherInstance(int opMode, String transformation, Key key) {
|
||||
try {
|
||||
Cipher cipher = Cipher.getInstance(transformation);
|
||||
cipher.init(p_75886_0_, key);
|
||||
cipher.init(opMode, key);
|
||||
return cipher;
|
||||
} catch (InvalidKeyException | NoSuchAlgorithmException | NoSuchPaddingException e) {
|
||||
e.printStackTrace();
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static Cipher createNetCipherInstance(int opMode, Key key) {
|
||||
|
@ -65,7 +65,10 @@ public class PacketHandler {
|
||||
|
||||
// now we know the version, set it, if the config allows it
|
||||
Version version;
|
||||
int protocolId = connection.getDesiredVersionNumber();
|
||||
int protocolId = -1;
|
||||
if (connection.getDesiredVersionNumber() != -1) {
|
||||
protocolId = Versions.getVersionById(connection.getDesiredVersionNumber()).getProtocolId();
|
||||
}
|
||||
if (protocolId == -1) {
|
||||
protocolId = pkg.getResponse().getProtocolId();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user