Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: various changes to 1.20.5 branch #4240

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion .github/workflows/e2e-testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,12 @@ jobs:
javaVersion: '18'
- mcVersion: '1.19.4'
javaVersion: '19'
- mcVersion: 'latest'
- mcVersion: '1.20.4'
javaVersion: '20'
- mcVersion: '1.20.6'
javaVersion: '21'
#- mcVersion: 'latest'
# javaVersion: '21'

steps:
- name: Checkout repository
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ public boolean isMinecraftVersion(int minecraftVersion) {
* It is equivalent to the "minor" version
* <p>
* Example: {@literal "1.13"} returns {@literal 13}<br />
* Exampe: {@literal "1.13.2"} returns {@literal 13_2}
* Example: {@literal "1.13.2"} returns {@literal 13_2}
*
* @param minecraftVersion
* The {@link Integer} version to match
Expand Down Expand Up @@ -278,7 +278,17 @@ public boolean isBefore(@Nonnull MinecraftVersion version) {
* @return True if this version is before, False if this version is virtual or otherwise.
*/
public boolean isBefore(int minecraftVersion, int patchVersion) {
return !isVirtual() && (this.majorVersion < minecraftVersion && this.minorVersion < patchVersion);
// unit tests or whatever
if (isVirtual()) {
return false;
}

// major version mismatch
if (this.majorVersion != minecraftVersion) {
return this.majorVersion < minecraftVersion;
}

return this.minorVersion == -1 ? patchVersion > 0 : this.minorVersion < patchVersion;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -495,14 +495,14 @@ private static boolean equalsItemMeta(@Nonnull ItemMeta itemMeta, @Nonnull ItemM
return potionMeta.getBasePotionData().equals(sfPotionMeta.getBasePotionData());
} else if (current.isBefore(20, 5)) {
// getBasePotionType without null check for 1.20.3 and 1.20.4
return potionMeta.getBasePotionType().equals(sfPotionMeta.getBasePotionType());
return potionMeta.getBasePotionType() == sfPotionMeta.getBasePotionType();
}
// check if potionMetha has a basePotionType (acting a null check for getBasePotionType
// on 1.20.5+
if (potionMeta.hasBasePotionType() != sfPotionMeta.hasBasePotionType()) {
return false;
}
return potionMeta.getBasePotionType().equals(sfPotionMeta.getBasePotionType());
return potionMeta.getBasePotionType() == sfPotionMeta.getBasePotionType();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,24 @@ void testIsBefore() {
Assertions.assertFalse(MinecraftVersion.MINECRAFT_1_17.isBefore(MinecraftVersion.MINECRAFT_1_16));
}

@Test
@DisplayName("Test if Minecraft versions #isBefore behaves correctly for minor versions")
void testIsBeforeMinor() {
Assertions.assertFalse(MinecraftVersion.MINECRAFT_1_18.isBefore(16, 5));
Assertions.assertFalse(MinecraftVersion.MINECRAFT_1_18.isBefore(17, 1));
Assertions.assertFalse(MinecraftVersion.MINECRAFT_1_18.isBefore(18, 0));
Assertions.assertTrue(MinecraftVersion.MINECRAFT_1_18.isBefore(18, 1));

Assertions.assertFalse(MinecraftVersion.MINECRAFT_1_20.isBefore(20, 0));
Assertions.assertTrue(MinecraftVersion.MINECRAFT_1_20.isBefore(20, 2));
Assertions.assertTrue(MinecraftVersion.MINECRAFT_1_20.isBefore(20, 4));
Assertions.assertTrue(MinecraftVersion.MINECRAFT_1_20.isBefore(20, 5));

Assertions.assertFalse(MinecraftVersion.MINECRAFT_1_20_5.isBefore(20, 4));
Assertions.assertFalse(MinecraftVersion.MINECRAFT_1_20_5.isBefore(20, 5));
Assertions.assertTrue(MinecraftVersion.MINECRAFT_1_20_5.isBefore(20, 6));
}

@Test
@DisplayName("Test correct behaviour for MinecraftVersion.UNKNOWN.isBefore(...)")
void testIsBeforeUnknown() {
Expand Down