Smart123s
c8c4aa522d
Remove Floodgate 1.0 warning
...
Floodgate 2.0 has been released a long time ago.
2022-08-09 17:27:29 +02:00
Smart123s
649ce8cb1a
Revert "Workaround for Floodgate prefixes with ProtocolLlib"
...
This reverts commit 94979a3
This reverts commit e82e7c7
This reverts commit b92911b
This reverts commit 03850ae
This reverts commit 8859ebb
2022-08-09 17:27:28 +02:00
Smart123s
61f949cf97
Revert "Fix Floodgate detection for buggy ProtocolLib"
...
This reverts commit 9978fe69
2022-08-09 17:27:28 +02:00
Smart123s
8571feef6d
Reimplement skipped Floodgate tasks
...
Due to a bug in ProtocolLib, Floodgate will never execute some of its tasks if an async listener is registered.
Related: https://github.com/GeyserMC/Floodgate/issues/143
Skipped code: 5d5713ed9e/spigot/src/main/java/org/geysermc/floodgate/addon/data/SpigotDataHandler.java (L121-L175)
Fixes #786
Fixes #703
Fixes #689
Fixes #647
2022-08-09 17:27:27 +02:00
Smart123s
bf86042c52
Disable checkstyle line length for JavaDoc links
...
GitHub permalinks can easily get longer than 120 characters.
2022-08-09 16:54:11 +02:00
Smart123s
55e3531718
Extract channel from ProtocolLib event
2022-08-09 16:54:04 +02:00
games647
1694a7a4f3
Do not override driver setting if using the simplified version
2022-08-09 09:25:56 +02:00
dependabot[bot]
ba7613c32a
Bump slf4j-jdk14 from 2.0.0-alpha7 to 2.0.0-beta1 ( #874 )
...
Bumps [slf4j-jdk14](https://github.com/qos-ch/slf4j ) from 2.0.0-alpha7 to 2.0.0-beta1.
- [Release notes](https://github.com/qos-ch/slf4j/releases )
- [Commits](https://github.com/qos-ch/slf4j/compare/v_2.0.0-alpha7...v_2.0.0-beta1 )
---
updated-dependencies:
- dependency-name: org.slf4j:slf4j-jdk14
dependency-type: direct:production
update-type: version-update:semver-patch
...
Signed-off-by: dependabot[bot] <support@github.com >
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-08-08 10:17:58 +02:00
games647
3244a3ab64
Resolve the mysql driver if using the simplified version
2022-08-08 10:16:12 +02:00
games647
833177933a
Remove and fix storage driver check
2022-08-04 14:28:30 +02:00
games647
091b558826
Allow any newer SQLite version
2022-08-03 13:31:19 +02:00
games647
df5e6db183
Set SQLite setting using the correct data class
...
Fixes #870
2022-08-03 13:21:44 +02:00
games647
845d16dd04
Simplify storage driver setting
2022-08-02 10:40:00 +02:00
games647
6beaf194ce
Let the JDBC DriveManager pick the right driver for us
...
According to HikariCP, it's recommended to use the DataSource version
if available. For MySQL, it's not recommended, because of bugs in the
network timeout implementation. Therefore, we use here the jdbc url
version still, but let the driver be picked by the DriveManager.
Fixes #591
2022-08-02 10:38:53 +02:00
dependabot[bot]
62d7320a6e
Bump junit-jupiter from 5.8.2 to 5.9.0 ( #866 )
...
Bumps [junit-jupiter](https://github.com/junit-team/junit5 ) from 5.8.2 to 5.9.0.
- [Release notes](https://github.com/junit-team/junit5/releases )
- [Commits](https://github.com/junit-team/junit5/compare/r5.8.2...r5.9.0 )
---
updated-dependencies:
- dependency-name: org.junit.jupiter:junit-jupiter
dependency-type: direct:development
update-type: version-update:semver-minor
...
Signed-off-by: dependabot[bot] <support@github.com >
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-08-01 12:15:39 +02:00
dependabot[bot]
c1207d884d
Bump craftapi from 0.5.3 to 0.6 ( #867 )
...
Bumps [craftapi](https://github.com/games647/CraftAPI ) from 0.5.3 to 0.6.
- [Release notes](https://github.com/games647/CraftAPI/releases )
- [Commits](https://github.com/games647/CraftAPI/commits )
---
updated-dependencies:
- dependency-name: com.github.games647:craftapi
dependency-type: direct:production
update-type: version-update:semver-minor
...
Signed-off-by: dependabot[bot] <support@github.com >
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-08-01 12:15:25 +02:00
dependabot[bot]
4a8e903773
Bump gson from 2.9.0 to 2.9.1 ( #868 )
...
Bumps [gson](https://github.com/google/gson ) from 2.9.0 to 2.9.1.
- [Release notes](https://github.com/google/gson/releases )
- [Changelog](https://github.com/google/gson/blob/master/CHANGELOG.md )
- [Commits](https://github.com/google/gson/compare/gson-parent-2.9.0...gson-parent-2.9.1 )
---
updated-dependencies:
- dependency-name: com.google.code.gson:gson
dependency-type: direct:production
update-type: version-update:semver-patch
...
Signed-off-by: dependabot[bot] <support@github.com >
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-08-01 12:15:14 +02:00
dependabot[bot]
e53c4f89f0
Bump checkstyle from 10.3.1 to 10.3.2 ( #865 )
...
Bumps [checkstyle](https://github.com/checkstyle/checkstyle ) from 10.3.1 to 10.3.2.
- [Release notes](https://github.com/checkstyle/checkstyle/releases )
- [Commits](https://github.com/checkstyle/checkstyle/compare/checkstyle-10.3.1...checkstyle-10.3.2 )
---
updated-dependencies:
- dependency-name: com.puppycrawl.tools:checkstyle
dependency-type: direct:production
update-type: version-update:semver-patch
...
Signed-off-by: dependabot[bot] <support@github.com >
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-08-01 12:14:53 +02:00
games647
ed45fada59
Update 1.19.1 public key verification
2022-07-28 17:06:06 +02:00
games647
045f980f38
Forward client key even if verification is disabled
2022-07-28 16:26:35 +02:00
games647
25c8be65ed
Disable metadata checking if login packets are re-used on login
...
Some servers appear to re-use login packets. However, ProtocolLib
metadata sets the data based on the identity of the packet handle. This
makes the metadata available for fresh incoming packets too.
Related #855
2022-07-28 14:14:10 +02:00
games647
e3778c865c
Update dependencies
2022-07-28 13:02:58 +02:00
dependabot[bot]
4765d6d4ef
Bump geyser.version from 2.0.0-SNAPSHOT to 2.0.5-SNAPSHOT ( #842 )
...
Bumps `geyser.version` from 2.0.0-SNAPSHOT to 2.0.5-SNAPSHOT.
Updates `core` from 2.0.0-SNAPSHOT to 2.0.5-SNAPSHOT
- [Release notes](https://github.com/GeyserMC/Geyser/releases )
- [Commits](https://github.com/GeyserMC/Geyser/commits )
Updates `geyser-api` from 2.0.0-SNAPSHOT to 2.0.5-SNAPSHOT
---
updated-dependencies:
- dependency-name: org.geysermc:core
dependency-type: direct:production
update-type: version-update:semver-patch
- dependency-name: org.geysermc:geyser-api
dependency-type: direct:production
update-type: version-update:semver-patch
...
Signed-off-by: dependabot[bot] <support@github.com >
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-07-28 12:42:40 +02:00
games647
c886ccb9ef
Remove commented out code
2022-07-27 14:37:11 +02:00
games647
bbb615bb0f
Merge branch 'tcpshield'
2022-07-27 14:31:55 +02:00
games647
0e1774a175
Comment out potential debug code
2022-07-27 14:30:48 +02:00
games647
f50bef3eb2
Fix TCPShield compat by using raw address for sessions
...
TCPShield overwrites the IP address during connection. ProtocolLib
doesn't notice this change, because it uses the end-to-end connection
which is the proxy IP. This causes getAddress calls during Spigot play
state and ProtocolLib auth state not match and then have conflicting
session ids.
A solution is also to hold onto the temporary player object. However
since we don't get a notification for a disconnect, holding it will
prevent to get GCed until the timeout occurs (1 minute).
Fixes #595
2022-07-27 14:30:42 +02:00
games647
0e2e431d87
Use the address field for verify task
2022-07-27 14:30:04 +02:00
games647
1e732d62cb
Replace Field- and MethodUtils from breaking changes in ProtocolLib
2022-07-27 10:06:46 +02:00
games647
94979a3cf6
Fix reading username with 1.19 and Floodgate
...
Related #856
2022-07-27 09:34:36 +02:00
games647
564f713fce
Simplify version setting
2022-07-25 16:28:38 +02:00
games647
05708a256c
Perform check for available reflection during compile time
2022-07-25 13:02:30 +02:00
games647
1d45cad2ea
Add connection debug messages for #855
2022-07-25 10:30:48 +02:00
games647
e82e7c7856
Fix manual name change workaround for floodgate with 1.19
...
Fixes #854
2022-07-25 10:27:09 +02:00
games647
8df5b11276
Fix Java 8 API compatibility
2022-07-22 18:46:46 +02:00
games647
c090278f82
Reset Hikari to the Java 8 version
2022-07-22 13:31:43 +02:00
games647
23d30eee1a
Migrate to Java 8 (sponsored contribution)
...
Java >8 includes many helpful features and API additions. Current
phoronix benchmarks indicated a very similar performance. Furthermore,
the fact that Java 18 even works with 1.8.8 contributed to the
decision to move to Java 17 like vanilla Java in 1.19.
This also helps us to learn about the newer features added for our
personal interests. As this is a free project, this motivated us to make
this step.
Nevertheless, many server owners were frustrated about this decision.
Thanks to financial contribution, we revised this decision until Java 8
is end of life or no longer used actively used according to bstats.org
2022-07-22 13:26:52 +02:00
games647
bd65c792d0
Use correct generics
2022-07-22 13:26:39 +02:00
games647
79a83ce84d
Throw exception for utilities
2022-07-22 13:26:39 +02:00
games647
9fdbdeaf9a
Use Lombok to create a record-like struct
2022-07-22 13:26:39 +02:00
games647
dd2fca2ea1
Replace var with val to prevent conflicts with newer Java version
...
diff --git a/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/listener/protocollib/EncryptionUtil.java b/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/listener/protocollib/EncryptionUtil.java
index 81abad1..d148bc1 100644
--- a/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/listener/protocollib/EncryptionUtil.java
+++ b/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/listener/protocollib/EncryptionUtil.java
@@ -59,7 +59,7 @@ import javax.crypto.NoSuchPaddingException;
import javax.crypto.SecretKey;
import javax.crypto.spec.SecretKeySpec;
-import lombok.var;
+import lombok.val;
/**
* Encryption and decryption minecraft util for connection between servers
@@ -179,9 +179,9 @@ final class EncryptionUtil {
private static PublicKey loadMojangSessionKey()
throws IOException, NoSuchAlgorithmException, InvalidKeySpecException {
- var keyUrl = FastLoginBukkit.class.getClassLoader().getResource("yggdrasil_session_pubkey.der");
- var keyData = Resources.toByteArray(keyUrl);
- var keySpec = new X509EncodedKeySpec(keyData);
+ val keyUrl = FastLoginBukkit.class.getClassLoader().getResource("yggdrasil_session_pubkey.der");
+ val keyData = Resources.toByteArray(keyUrl);
+ val keySpec = new X509EncodedKeySpec(keyData);
return KeyFactory.getInstance("RSA").generatePublic(keySpec);
}
diff --git a/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/listener/protocollib/VerifyResponseTask.java b/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/listener/protocollib/VerifyResponseTask.java
index dc208ff..1363cb3 100644
--- a/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/listener/protocollib/VerifyResponseTask.java
+++ b/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/listener/protocollib/VerifyResponseTask.java
@@ -60,7 +60,7 @@ import java.util.UUID;
import javax.crypto.Cipher;
import javax.crypto.SecretKey;
-import lombok.var;
+import lombok.val;
import org.bukkit.entity.Player;
import static com.comphenix.protocol.PacketType.Login.Client.START;
@@ -269,7 +269,7 @@ public class VerifyResponseTask implements Runnable {
startPacket.getStrings().write(0, username);
EquivalentConverter<WrappedProfileKeyData> converter = BukkitConverters.getWrappedPublicKeyDataConverter();
- var wrappedKey = Optional.ofNullable(clientKey).map(key ->
+ val wrappedKey = Optional.ofNullable(clientKey).map(key ->
new WrappedProfileKeyData(clientKey.expiry(), clientKey.key(), clientKey.signature())
);
diff --git a/bukkit/src/test/java/com/github/games647/fastlogin/bukkit/FastLoginBukkitTest.java b/bukkit/src/test/java/com/github/games647/fastlogin/bukkit/FastLoginBukkitTest.java
index e4ce55a..9d6832e 100644
--- a/bukkit/src/test/java/com/github/games647/fastlogin/bukkit/FastLoginBukkitTest.java
+++ b/bukkit/src/test/java/com/github/games647/fastlogin/bukkit/FastLoginBukkitTest.java
@@ -30,7 +30,7 @@ import com.github.games647.fastlogin.core.CommonUtil;
import net.md_5.bungee.api.chat.TextComponent;
import net.md_5.bungee.chat.ComponentSerializer;
-import lombok.var;
+import lombok.val;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
@@ -39,12 +39,12 @@ class FastLoginBukkitTest {
@Test
void testRGB() {
- var message = "&x00002a00002b&lText";
- var msg = CommonUtil.translateColorCodes(message);
+ val message = "&x00002a00002b&lText";
+ val msg = CommonUtil.translateColorCodes(message);
assertEquals(msg, "§x00002a00002b§lText");
- var components = TextComponent.fromLegacyText(msg);
- var expected = "{\"bold\":true,\"color\":\"#00a00b\",\"text\":\"Text\"}";
+ val components = TextComponent.fromLegacyText(msg);
+ val expected = "{\"bold\":true,\"color\":\"#00a00b\",\"text\":\"Text\"}";
assertEquals(ComponentSerializer.toString(components), expected);
}
}
diff --git a/bukkit/src/test/java/com/github/games647/fastlogin/bukkit/listener/protocollib/Base64Adapter.java b/bukkit/src/test/java/com/github/games647/fastlogin/bukkit/listener/protocollib/Base64Adapter.java
index 29b2f3d..c2fb34d 100644
--- a/bukkit/src/test/java/com/github/games647/fastlogin/bukkit/listener/protocollib/Base64Adapter.java
+++ b/bukkit/src/test/java/com/github/games647/fastlogin/bukkit/listener/protocollib/Base64Adapter.java
@@ -32,13 +32,13 @@ import com.google.gson.stream.JsonWriter;
import java.io.IOException;
import java.util.Base64;
-import lombok.var;
+import lombok.val;
public class Base64Adapter extends TypeAdapter<byte[]> {
@Override
public void write(JsonWriter out, byte[] value) throws IOException {
- var encoded = Base64.getEncoder().encodeToString(value);
+ val encoded = Base64.getEncoder().encodeToString(value);
out.value(encoded);
}
diff --git a/bukkit/src/test/java/com/github/games647/fastlogin/bukkit/listener/protocollib/EncryptionUtilTest.java b/bukkit/src/test/java/com/github/games647/fastlogin/bukkit/listener/protocollib/EncryptionUtilTest.java
index df3888e..1bbe864 100644
--- a/bukkit/src/test/java/com/github/games647/fastlogin/bukkit/listener/protocollib/EncryptionUtilTest.java
+++ b/bukkit/src/test/java/com/github/games647/fastlogin/bukkit/listener/protocollib/EncryptionUtilTest.java
@@ -50,7 +50,7 @@ import javax.crypto.NoSuchPaddingException;
import javax.crypto.SecretKey;
import javax.crypto.spec.SecretKeySpec;
-import lombok.var;
+import lombok.val;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.ValueSource;
@@ -61,7 +61,7 @@ class EncryptionUtilTest {
@Test
void testVerifyToken() {
- var random = ThreadLocalRandom.current();
+ val random = ThreadLocalRandom.current();
byte[] token = EncryptionUtil.generateVerifyToken(random);
assertAll(
@@ -89,10 +89,10 @@ class EncryptionUtilTest {
@Test
void testExpiredClientKey() throws Exception {
- var clientKey = ResourceLoader.loadClientKey("client_keys/valid_public_key.json");
+ val clientKey = ResourceLoader.loadClientKey("client_keys/valid_public_key.json");
// Client expires at the exact second mentioned, so use it for verification
- var expiredTimestamp = clientKey.expiry();
+ val expiredTimestamp = clientKey.expiry();
assertFalse(EncryptionUtil.verifyClientKey(clientKey, expiredTimestamp));
}
@@ -106,7 +106,7 @@ class EncryptionUtilTest {
"client_keys/invalid_wrong_signature.json"
})
void testInvalidClientKey(String clientKeySource) throws Exception {
- var clientKey = ResourceLoader.loadClientKey(clientKeySource);
+ val clientKey = ResourceLoader.loadClientKey(clientKeySource);
Instant expireTimestamp = clientKey.expiry().minus(5, ChronoUnit.HOURS);
assertFalse(EncryptionUtil.verifyClientKey(clientKey, expireTimestamp));
@@ -114,8 +114,8 @@ class EncryptionUtilTest {
@Test
void testValidClientKey() throws Exception {
- var clientKey = ResourceLoader.loadClientKey("client_keys/valid_public_key.json");
- var verificationTimestamp = clientKey.expiry().minus(5, ChronoUnit.HOURS);
+ val clientKey = ResourceLoader.loadClientKey("client_keys/valid_public_key.json");
+ val verificationTimestamp = clientKey.expiry().minus(5, ChronoUnit.HOURS);
assertTrue(EncryptionUtil.verifyClientKey(clientKey, verificationTimestamp));
}
@@ -123,7 +123,7 @@ class EncryptionUtilTest {
@Test
void testDecryptSharedSecret() throws Exception {
KeyPair serverPair = EncryptionUtil.generateKeyPair();
- var serverPK = serverPair.getPublic();
+ val serverPK = serverPair.getPublic();
SecretKey secretKey = generateSharedKey();
byte[] encryptedSecret = encrypt(serverPK, secretKey.getEncoded());
@@ -135,7 +135,7 @@ class EncryptionUtilTest {
private static byte[] encrypt(PublicKey receiverKey, byte... message)
throws NoSuchAlgorithmException, NoSuchPaddingException, InvalidKeyException,
IllegalBlockSizeException, BadPaddingException {
- var encryptCipher = Cipher.getInstance(receiverKey.getAlgorithm());
+ val encryptCipher = Cipher.getInstance(receiverKey.getAlgorithm());
encryptCipher.init(Cipher.ENCRYPT_MODE, receiverKey);
return encryptCipher.doFinal(message);
}
@@ -151,9 +151,9 @@ class EncryptionUtilTest {
@Test
void testServerIdHash() throws Exception {
- var serverId = "";
- var sharedSecret = generateSharedKey();
- var serverPK = ResourceLoader.loadClientKey("client_keys/valid_public_key.json").key();
+ val serverId = "";
+ val sharedSecret = generateSharedKey();
+ val serverPK = ResourceLoader.loadClientKey("client_keys/valid_public_key.json").key();
String sessionHash = getServerHash(serverId, sharedSecret, serverPK);
assertEquals(EncryptionUtil.getServerIdHashString(serverId, sharedSecret, serverPK), sessionHash);
@@ -167,7 +167,7 @@ class EncryptionUtilTest {
// sha1.update(server's encoded public key from Encryption Request)
// hash := sha1.hexdigest() # String of hex characters
@SuppressWarnings("deprecation")
- var hasher = Hashing.sha1().newHasher();
+ val hasher = Hashing.sha1().newHasher();
hasher.putString(serverId, StandardCharsets.US_ASCII);
hasher.putBytes(sharedSecret.getEncoded());
hasher.putBytes(serverPK.getEncoded());
@@ -180,9 +180,9 @@ class EncryptionUtilTest {
@Test
void testServerIdHashWrongSecret() throws Exception {
- var serverId = "";
- var sharedSecret = generateSharedKey();
- var serverPK = ResourceLoader.loadClientKey("client_keys/valid_public_key.json").key();
+ val serverId = "";
+ val sharedSecret = generateSharedKey();
+ val serverPK = ResourceLoader.loadClientKey("client_keys/valid_public_key.json").key();
String sessionHash = getServerHash(serverId, sharedSecret, serverPK);
assertNotEquals(EncryptionUtil.getServerIdHashString("", generateSharedKey(), serverPK), sessionHash);
@@ -190,12 +190,12 @@ class EncryptionUtilTest {
@Test
void testServerIdHashWrongServerKey() {
- var serverId = "";
- var sharedSecret = generateSharedKey();
- var serverPK = EncryptionUtil.generateKeyPair().getPublic();
+ val serverId = "";
+ val sharedSecret = generateSharedKey();
+ val serverPK = EncryptionUtil.generateKeyPair().getPublic();
String sessionHash = getServerHash(serverId, sharedSecret, serverPK);
- var wrongPK = EncryptionUtil.generateKeyPair().getPublic();
+ val wrongPK = EncryptionUtil.generateKeyPair().getPublic();
assertNotEquals(EncryptionUtil.getServerIdHashString("", sharedSecret, wrongPK), sessionHash);
}
@@ -239,8 +239,8 @@ class EncryptionUtilTest {
@Test
void testNonce() throws Exception {
byte[] expected = {1, 2, 3, 4};
- var serverKey = EncryptionUtil.generateKeyPair();
- var encryptedNonce = encrypt(serverKey.getPublic(), expected);
+ val serverKey = EncryptionUtil.generateKeyPair();
+ val encryptedNonce = encrypt(serverKey.getPublic(), expected);
assertTrue(EncryptionUtil.verifyNonce(expected, serverKey.getPrivate(), encryptedNonce));
}
@@ -248,19 +248,19 @@ class EncryptionUtilTest {
@Test
void testNonceIncorrect() throws Exception {
byte[] expected = {1, 2, 3, 4};
- var serverKey = EncryptionUtil.generateKeyPair();
+ val serverKey = EncryptionUtil.generateKeyPair();
// flipped first character
- var encryptedNonce = encrypt(serverKey.getPublic(), new byte[]{0, 2, 3, 4});
+ val encryptedNonce = encrypt(serverKey.getPublic(), new byte[]{0, 2, 3, 4});
assertFalse(EncryptionUtil.verifyNonce(expected, serverKey.getPrivate(), encryptedNonce));
}
@Test
void testNonceFailedDecryption() throws Exception {
byte[] expected = {1, 2, 3, 4};
- var serverKey = EncryptionUtil.generateKeyPair();
+ val serverKey = EncryptionUtil.generateKeyPair();
// generate a new keypair that is different
- var encryptedNonce = encrypt(EncryptionUtil.generateKeyPair().getPublic(), expected);
+ val encryptedNonce = encrypt(EncryptionUtil.generateKeyPair().getPublic(), expected);
assertThrows(GeneralSecurityException.class,
() -> EncryptionUtil.verifyNonce(expected, serverKey.getPrivate(), encryptedNonce)
@@ -270,7 +270,7 @@ class EncryptionUtilTest {
@Test
void testNonceIncorrectEmpty() {
byte[] expected = {1, 2, 3, 4};
- var serverKey = EncryptionUtil.generateKeyPair();
+ val serverKey = EncryptionUtil.generateKeyPair();
byte[] encryptedNonce = {};
assertThrows(GeneralSecurityException.class,
diff --git a/bukkit/src/test/java/com/github/games647/fastlogin/bukkit/listener/protocollib/SignatureTestData.java b/bukkit/src/test/java/com/github/games647/fastlogin/bukkit/listener/protocollib/SignatureTestData.java
index 9a75fc5..01b734e 100644
--- a/bukkit/src/test/java/com/github/games647/fastlogin/bukkit/listener/protocollib/SignatureTestData.java
+++ b/bukkit/src/test/java/com/github/games647/fastlogin/bukkit/listener/protocollib/SignatureTestData.java
@@ -32,13 +32,13 @@ import com.google.gson.annotations.JsonAdapter;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
-import lombok.var;
+import lombok.val;
public class SignatureTestData {
public static SignatureTestData fromResource(String resourceName) throws IOException {
- var keyUrl = Resources.getResource(resourceName);
- var encodedSignature = Resources.toString(keyUrl, StandardCharsets.US_ASCII);
+ val keyUrl = Resources.getResource(resourceName);
+ val encodedSignature = Resources.toString(keyUrl, StandardCharsets.US_ASCII);
return new Gson().fromJson(encodedSignature, SignatureTestData.class);
}
diff --git a/bungee/src/main/java/com/github/games647/fastlogin/bungee/FastLoginBungee.java b/bungee/src/main/java/com/github/games647/fastlogin/bungee/FastLoginBungee.java
index 148282c..c83c14d 100644
--- a/bungee/src/main/java/com/github/games647/fastlogin/bungee/FastLoginBungee.java
+++ b/bungee/src/main/java/com/github/games647/fastlogin/bungee/FastLoginBungee.java
@@ -57,6 +57,7 @@ import net.md_5.bungee.api.chat.TextComponent;
import net.md_5.bungee.api.connection.PendingConnection;
import net.md_5.bungee.api.connection.ProxiedPlayer;
import net.md_5.bungee.api.connection.Server;
+import net.md_5.bungee.api.plugin.Listener;
import net.md_5.bungee.api.plugin.Plugin;
import net.md_5.bungee.api.plugin.PluginManager;
import net.md_5.bungee.api.scheduler.GroupedThreadFactory;
@@ -100,7 +101,7 @@ public class FastLoginBungee extends Plugin implements PlatformPlugin<CommandSen
//events
PluginManager pluginManager = getProxy().getPluginManager();
- ConnectListener connectListener = new ConnectListener(this, core.getAntiBot());
+ Listener connectListener = new ConnectListener(this, core.getAntiBot());
pluginManager.registerListener(this, connectListener);
pluginManager.registerListener(this, new PluginMessageListener(this));
2022-07-22 13:26:38 +02:00
games647
7e9da9fd7c
Migrate to Java 8 (sponsored contribution)
...
Java >8 includes many helpful features and API additions. Current
phoronix benchmarks indicated a very similar performance. Furthermore,
the fact that Java 18 even works with 1.8.8 contributed to the
decision to move to Java 17 like vanilla Java in 1.19.
This also helps us to learn about the newer features added for our
personal interests. As this is a free project, this motivated us to make
this step.
Nevertheless, many server owners were frustrated about this decision.
Thanks to financial contribution, we revised this decision until Java 8
is end of life or no longer used actively used according to bstats.org
diff --git a/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/listener/protocollib/EncryptionUtil.java b/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/listener/protocollib/EncryptionUtil.java
index 68095f6..81abad1 100644
--- a/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/listener/protocollib/EncryptionUtil.java
+++ b/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/listener/protocollib/EncryptionUtil.java
@@ -50,7 +50,7 @@ import java.time.Instant;
import java.util.Arrays;
import java.util.Base64;
import java.util.Base64.Encoder;
-import java.util.random.RandomGenerator;
+import java.util.Random;
import javax.crypto.BadPaddingException;
import javax.crypto.Cipher;
@@ -59,6 +59,8 @@ import javax.crypto.NoSuchPaddingException;
import javax.crypto.SecretKey;
import javax.crypto.spec.SecretKeySpec;
+import lombok.var;
+
/**
* Encryption and decryption minecraft util for connection between servers
* and paid Minecraft account clients.
@@ -112,7 +114,7 @@ final class EncryptionUtil {
* @param random random generator
* @return a token with 4 bytes long
*/
- public static byte[] generateVerifyToken(RandomGenerator random) {
+ public static byte[] generateVerifyToken(Random random) {
byte[] token = new byte[VERIFY_TOKEN_LENGTH];
random.nextBytes(token);
return token;
diff --git a/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/listener/protocollib/ProtocolLibListener.java b/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/listener/protocollib/ProtocolLibListener.java
index 2e21ccb..4ce14ff 100644
--- a/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/listener/protocollib/ProtocolLibListener.java
+++ b/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/listener/protocollib/ProtocolLibListener.java
@@ -56,6 +56,7 @@ import javax.crypto.BadPaddingException;
import javax.crypto.IllegalBlockSizeException;
import javax.crypto.NoSuchPaddingException;
+import lombok.var;
import org.bukkit.entity.Player;
import static com.comphenix.protocol.PacketType.Login.Client.ENCRYPTION_BEGIN;
@@ -171,7 +172,7 @@ public class ProtocolLibListener extends PacketAdapter {
Either<byte[], ?> either = packet.getSpecificModifier(Either.class).read(0);
if (clientPublicKey == null) {
Optional<byte[]> left = either.left();
- if (left.isEmpty()) {
+ if (!left.isPresent()) {
plugin.getLog().error("No verify token sent if requested without player signed key {}", sender);
return false;
}
@@ -179,7 +180,7 @@ public class ProtocolLibListener extends PacketAdapter {
return EncryptionUtil.verifyNonce(expectedToken, keyPair.getPrivate(), left.get());
} else {
Optional<?> optSignatureData = either.right();
- if (optSignatureData.isEmpty()) {
+ if (!optSignatureData.isPresent()) {
plugin.getLog().error("No signature given to sent player signing key {}", sender);
return false;
}
@@ -219,7 +220,7 @@ public class ProtocolLibListener extends PacketAdapter {
.optionRead(0);
var clientKey = profileKey.flatMap(opt -> opt).flatMap(this::verifyPublicKey);
- if (verifyClientKeys && clientKey.isEmpty()) {
+ if (verifyClientKeys && !clientKey.isPresent()) {
// missing or incorrect
// expired always not allowed
player.kickPlayer(plugin.getCore().getMessage("invalid-public-key"));
diff --git a/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/listener/protocollib/VerifyResponseTask.java b/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/listener/protocollib/VerifyResponseTask.java
index 829d764..dc208ff 100644
--- a/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/listener/protocollib/VerifyResponseTask.java
+++ b/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/listener/protocollib/VerifyResponseTask.java
@@ -60,6 +60,7 @@ import java.util.UUID;
import javax.crypto.Cipher;
import javax.crypto.SecretKey;
+import lombok.var;
import org.bukkit.entity.Player;
import static com.comphenix.protocol.PacketType.Login.Client.START;
diff --git a/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/listener/protocollib/packet/ClientPublicKey.java b/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/listener/protocollib/packet/ClientPublicKey.java
index e375e29..619d41d 100644
--- a/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/listener/protocollib/packet/ClientPublicKey.java
+++ b/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/listener/protocollib/packet/ClientPublicKey.java
@@ -27,8 +27,62 @@ package com.github.games647.fastlogin.bukkit.listener.protocollib.packet;
import java.security.PublicKey;
import java.time.Instant;
+import java.util.Arrays;
+import java.util.Objects;
+import java.util.StringJoiner;
-public record ClientPublicKey(Instant expiry, PublicKey key, byte[] signature) {
+public final class ClientPublicKey {
+ private final Instant expiry;
+ private final PublicKey key;
+ private final byte[] signature;
+
+ public ClientPublicKey(Instant expiry, PublicKey key, byte[] signature) {
+ this.expiry = expiry;
+ this.key = key;
+ this.signature = signature;
+ }
+
+ public Instant expiry() {
+ return expiry;
+ }
+
+ public PublicKey key() {
+ return key;
+ }
+
+ public byte[] signature() {
+ return signature;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (obj == this) {
+ return true;
+ }
+
+ if (obj == null || obj.getClass() != this.getClass()) {
+ return false;
+ }
+
+ ClientPublicKey that = (ClientPublicKey) obj;
+ return Objects.equals(this.expiry, that.expiry)
+ && Objects.equals(this.key, that.key)
+ && Arrays.equals(this.signature, that.signature);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(expiry, key, signature);
+ }
+
+ @Override
+ public String toString() {
+ return new StringJoiner(", ", ClientPublicKey.class.getSimpleName() + "[", "]")
+ .add("expiry=" + expiry)
+ .add("key=" + key)
+ .add("signature=" + Arrays.toString(signature))
+ .toString();
+ }
public boolean isExpired(Instant verifyTimestamp) {
return !verifyTimestamp.isBefore(expiry);
diff --git a/bukkit/src/test/java/com/github/games647/fastlogin/bukkit/FastLoginBukkitTest.java b/bukkit/src/test/java/com/github/games647/fastlogin/bukkit/FastLoginBukkitTest.java
index 07ff623..e4ce55a 100644
--- a/bukkit/src/test/java/com/github/games647/fastlogin/bukkit/FastLoginBukkitTest.java
+++ b/bukkit/src/test/java/com/github/games647/fastlogin/bukkit/FastLoginBukkitTest.java
@@ -30,6 +30,7 @@ import com.github.games647.fastlogin.core.CommonUtil;
import net.md_5.bungee.api.chat.TextComponent;
import net.md_5.bungee.chat.ComponentSerializer;
+import lombok.var;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
@@ -43,8 +44,7 @@ class FastLoginBukkitTest {
assertEquals(msg, "§x00002a00002b§lText");
var components = TextComponent.fromLegacyText(msg);
- var expected = """
- {"bold":true,"color":"#00a00b","text":"Text"}""";
+ var expected = "{\"bold\":true,\"color\":\"#00a00b\",\"text\":\"Text\"}";
assertEquals(ComponentSerializer.toString(components), expected);
}
}
diff --git a/bukkit/src/test/java/com/github/games647/fastlogin/bukkit/listener/protocollib/Base64Adapter.java b/bukkit/src/test/java/com/github/games647/fastlogin/bukkit/listener/protocollib/Base64Adapter.java
index c2a2d1a..29b2f3d 100644
--- a/bukkit/src/test/java/com/github/games647/fastlogin/bukkit/listener/protocollib/Base64Adapter.java
+++ b/bukkit/src/test/java/com/github/games647/fastlogin/bukkit/listener/protocollib/Base64Adapter.java
@@ -32,6 +32,8 @@ import com.google.gson.stream.JsonWriter;
import java.io.IOException;
import java.util.Base64;
+import lombok.var;
+
public class Base64Adapter extends TypeAdapter<byte[]> {
@Override
diff --git a/bukkit/src/test/java/com/github/games647/fastlogin/bukkit/listener/protocollib/EncryptionUtilTest.java b/bukkit/src/test/java/com/github/games647/fastlogin/bukkit/listener/protocollib/EncryptionUtilTest.java
index e1b8bea..df3888e 100644
--- a/bukkit/src/test/java/com/github/games647/fastlogin/bukkit/listener/protocollib/EncryptionUtilTest.java
+++ b/bukkit/src/test/java/com/github/games647/fastlogin/bukkit/listener/protocollib/EncryptionUtilTest.java
@@ -50,6 +50,7 @@ import javax.crypto.NoSuchPaddingException;
import javax.crypto.SecretKey;
import javax.crypto.spec.SecretKeySpec;
+import lombok.var;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.ValueSource;
diff --git a/bukkit/src/test/java/com/github/games647/fastlogin/bukkit/listener/protocollib/ResourceLoader.java b/bukkit/src/test/java/com/github/games647/fastlogin/bukkit/listener/protocollib/ResourceLoader.java
index 4361fe9..ac0991e 100644
--- a/bukkit/src/test/java/com/github/games647/fastlogin/bukkit/listener/protocollib/ResourceLoader.java
+++ b/bukkit/src/test/java/com/github/games647/fastlogin/bukkit/listener/protocollib/ResourceLoader.java
@@ -33,6 +33,7 @@ import com.google.gson.JsonObject;
import java.io.IOException;
import java.io.Reader;
import java.io.StringReader;
+import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.security.KeyFactory;
import java.security.NoSuchAlgorithmException;
@@ -57,19 +58,19 @@ public class ResourceLoader {
) {
PemObject pemObject = pemReader.readPemObject();
byte[] content = pemObject.getContent();
- var privateKeySpec = new PKCS8EncodedKeySpec(content);
+ PKCS8EncodedKeySpec privateKeySpec = new PKCS8EncodedKeySpec(content);
- var factory = KeyFactory.getInstance("RSA");
+ KeyFactory factory = KeyFactory.getInstance("RSA");
return (RSAPrivateKey) factory.generatePrivate(privateKeySpec);
}
}
protected static ClientPublicKey loadClientKey(String path)
throws NoSuchAlgorithmException, IOException, InvalidKeySpecException {
- var keyUrl = Resources.getResource(path);
+ URL keyUrl = Resources.getResource(path);
- var lines = Resources.toString(keyUrl, StandardCharsets.US_ASCII);
- var object = new Gson().fromJson(lines, JsonObject.class);
+ String lines = Resources.toString(keyUrl, StandardCharsets.US_ASCII);
+ JsonObject object = new Gson().fromJson(lines, JsonObject.class);
Instant expires = Instant.parse(object.getAsJsonPrimitive("expires_at").getAsString());
String key = object.getAsJsonPrimitive("key").getAsString();
@@ -87,9 +88,9 @@ public class ResourceLoader {
) {
PemObject pemObject = pemReader.readPemObject();
byte[] content = pemObject.getContent();
- var pubKeySpec = new X509EncodedKeySpec(content);
+ X509EncodedKeySpec pubKeySpec = new X509EncodedKeySpec(content);
- var factory = KeyFactory.getInstance("RSA");
+ KeyFactory factory = KeyFactory.getInstance("RSA");
return (RSAPublicKey) factory.generatePublic(pubKeySpec);
}
}
diff --git a/bukkit/src/test/java/com/github/games647/fastlogin/bukkit/listener/protocollib/SignatureTestData.java b/bukkit/src/test/java/com/github/games647/fastlogin/bukkit/listener/protocollib/SignatureTestData.java
index ee62e24..9a75fc5 100644
--- a/bukkit/src/test/java/com/github/games647/fastlogin/bukkit/listener/protocollib/SignatureTestData.java
+++ b/bukkit/src/test/java/com/github/games647/fastlogin/bukkit/listener/protocollib/SignatureTestData.java
@@ -32,6 +32,8 @@ import com.google.gson.annotations.JsonAdapter;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
+import lombok.var;
+
public class SignatureTestData {
public static SignatureTestData fromResource(String resourceName) throws IOException {
diff --git a/core/src/main/java/com/github/games647/fastlogin/core/CommonUtil.java b/core/src/main/java/com/github/games647/fastlogin/core/CommonUtil.java
index 324e240..89dc7ee 100644
--- a/core/src/main/java/com/github/games647/fastlogin/core/CommonUtil.java
+++ b/core/src/main/java/com/github/games647/fastlogin/core/CommonUtil.java
@@ -25,8 +25,7 @@
*/
package com.github.games647.fastlogin.core;
-import com.github.games647.craftapi.cache.SafeCacheBuilder;
-import com.google.common.cache.CacheLoader;
+import com.google.common.cache.CacheBuilder;
import java.lang.reflect.Constructor;
import java.util.concurrent.ConcurrentMap;
@@ -43,7 +42,7 @@ public final class CommonUtil {
private static final char TRANSLATED_CHAR = '§';
public static <K, V> ConcurrentMap<K, V> buildCache(int expireAfterWrite, int maxSize) {
- SafeCacheBuilder<Object, Object> builder = SafeCacheBuilder.newBuilder();
+ CacheBuilder<Object, Object> builder = CacheBuilder.newBuilder();
if (expireAfterWrite > 0) {
builder.expireAfterWrite(expireAfterWrite, TimeUnit.MINUTES);
@@ -53,9 +52,7 @@ public final class CommonUtil {
builder.maximumSize(maxSize);
}
- return builder.build(CacheLoader.from(() -> {
- throw new UnsupportedOperationException();
- }));
+ return (ConcurrentMap<K, V>) builder.build().asMap();
}
public static String translateColorCodes(String rawMessage) {
diff --git a/core/src/main/java/com/github/games647/fastlogin/core/StoredProfile.java b/core/src/main/java/com/github/games647/fastlogin/core/StoredProfile.java
index ee58bde..26492d3 100644
--- a/core/src/main/java/com/github/games647/fastlogin/core/StoredProfile.java
+++ b/core/src/main/java/com/github/games647/fastlogin/core/StoredProfile.java
@@ -118,10 +118,11 @@ public class StoredProfile extends Profile {
return true;
}
- if (!(o instanceof StoredProfile that)) {
+ if (!(o instanceof StoredProfile)) {
return false;
}
+ StoredProfile that = (StoredProfile) o;
if (!super.equals(o)) {
return false;
}
diff --git a/pom.xml b/pom.xml
index f2f3950..e1b26b0 100644
--- a/pom.xml
+++ b/pom.xml
@@ -48,7 +48,7 @@
<!-- Set default for non-git clones -->
<git.commit.id>Unknown</git.commit.id>
- <java.version>17</java.version>
+ <java.version>8</java.version>
<maven.compiler.source>${java.version}</maven.compiler.source>
<maven.compiler.target>${java.version}</maven.compiler.target>
@@ -189,5 +189,12 @@
<version>5.8.2</version>
<scope>test</scope>
</dependency>
+
+ <dependency>
+ <groupId>org.projectlombok</groupId>
+ <artifactId>lombok</artifactId>
+ <version>1.18.24</version>
+ <scope>provided</scope>
+ </dependency>
</dependencies>
</project>
2022-07-22 13:26:38 +02:00
games647
f513cffbaf
Migrate tests to use Junit5
2022-07-22 13:24:57 +02:00
games647
cdb3c50b87
Merge pull request #837 from games647/dependabot/maven/org.mariadb.jdbc-mariadb-java-client-3.0.6
...
Bump mariadb-java-client from 3.0.5 to 3.0.6
2022-07-17 16:56:31 +02:00
games647
e338a768ca
Use class loader for loading the session key
...
Related #849
2022-07-17 16:54:06 +02:00
games647
18a8d7a5dc
Replace Guava with Java joiner
2022-07-17 16:54:06 +02:00
games647
6cf1a79ae1
Reset ignore list of dependabot
2022-07-17 16:54:06 +02:00
games647
0e8b51e148
Minimize dependency jars
2022-07-17 16:54:06 +02:00
games647
ef34550a53
Merge pull request #848 from Smart123s/fix/duplicate/forwardccommand
...
Remove duplicate forwardCrackedCommand()
2022-07-15 08:56:45 +02:00
Smart123s
fe1d4944a8
Remove duplicate forwardCrackedCommand()
...
The forwardCrackedCommand() method is invoked before, the removed code, that does the exact same thing.
2022-07-14 17:11:25 +02:00