3
0
Mirror von https://github.com/IntellectualSites/FastAsyncWorldEdit.git synchronisiert 2024-12-24 18:10:08 +01:00

More precise method names in MinecraftVersion

- Also ensure correct comparisons are made in FaweBukkit and BukkitServerInterface
 - Fixes #1504
Dieser Commit ist enthalten in:
dordsor21 2021-12-29 14:46:30 +00:00
Ursprung 5d4a2a4a0d
Commit bca3a1b04d
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 1E53E88969FFCF0B
4 geänderte Dateien mit 21 neuen und 16 gelöschten Zeilen

Datei anzeigen

@ -83,7 +83,7 @@ public class FaweBukkit implements IFawe, Listener {
Bukkit.getServer().shutdown();
}
chunksStretched = new MinecraftVersion().isEqualOrLower(MinecraftVersion.NETHER);
chunksStretched = new MinecraftVersion().isEqualOrHigherThan(MinecraftVersion.NETHER);
platformAdapter = new NMSAdapter();

Datei anzeigen

@ -69,7 +69,7 @@ public class MinecraftVersion implements Comparable<MinecraftVersion> {
* @param other The other version to compare against.
* @return {@code true} if this version is higher or equal compared to the other version.
*/
public boolean isEqualOrHigher(MinecraftVersion other) {
public boolean isEqualOrHigherThan(MinecraftVersion other) {
return compareTo(other) >= 0;
}
@ -77,7 +77,7 @@ public class MinecraftVersion implements Comparable<MinecraftVersion> {
* @param other The other version to compare against.
* @return {@code true} if this version is lower or equal compared to the other version.
*/
public boolean isEqualOrLower(MinecraftVersion other) {
public boolean isEqualOrLowerThan(MinecraftVersion other) {
return compareTo(other) <= 0;
}
@ -85,7 +85,7 @@ public class MinecraftVersion implements Comparable<MinecraftVersion> {
* @param other The other version to compare against.
* @return {@code true} if this version is higher than the other version.
*/
public boolean isHigher(MinecraftVersion other) {
public boolean isHigherThan(MinecraftVersion other) {
return compareTo(other) > 0;
}
@ -93,7 +93,7 @@ public class MinecraftVersion implements Comparable<MinecraftVersion> {
* @param other The other version to compare against.
* @return {@code true} if this version is lower than to the other version.
*/
public boolean isLower(MinecraftVersion other) {
public boolean isLowerThan(MinecraftVersion other) {
return compareTo(other) < 0;
}
@ -140,6 +140,11 @@ public class MinecraftVersion implements Comparable<MinecraftVersion> {
return getRelease() == that.getRelease();
}
@Override
public String toString() {
return major + "." + minor + "." + release;
}
/**
* Determines the server version based on the CraftBukkit package path, e.g. {@code org.bukkit.craftbukkit.v1_16_R3},
* where v1_16_R3 is the resolved version.

Datei anzeigen

@ -282,12 +282,12 @@ public class BukkitServerInterface extends AbstractPlatform implements MultiUser
@Override
public int getVersionMinY() {
return new MinecraftVersion().isEqualOrLower(MinecraftVersion.CAVES_18) ? -64 : 0;
return new MinecraftVersion().isEqualOrHigherThan(MinecraftVersion.CAVES_18) ? -64 : 0;
}
@Override
public int getVersionMaxY() {
return new MinecraftVersion().isEqualOrLower(MinecraftVersion.CAVES_18) ? 319 : 255;
return new MinecraftVersion().isEqualOrHigherThan(MinecraftVersion.CAVES_18) ? 319 : 255;
}
//FAWE end
}

Datei anzeigen

@ -20,14 +20,14 @@ public class MinecraftVersionTest {
@Test
public void testEqualOrHigher() {
assertTrue(latestVersion.isEqualOrHigher(new MinecraftVersion(1, 16, 3)));
assertTrue(latestVersion.isEqualOrHigher(new MinecraftVersion(1, 16, 2)));
assertFalse(latestVersion.isEqualOrHigher(new MinecraftVersion(1, 16, 4)));
assertTrue(latestVersion.isEqualOrHigherThan(new MinecraftVersion(1, 16, 3)));
assertTrue(latestVersion.isEqualOrHigherThan(new MinecraftVersion(1, 16, 2)));
assertFalse(latestVersion.isEqualOrHigherThan(new MinecraftVersion(1, 16, 4)));
}
@Test
public void testEqualOrHigherWithoutRelease() {
assertTrue(latestVersion.isEqualOrHigher(new MinecraftVersion(1, 16)));
assertTrue(latestVersion.isEqualOrHigherThan(new MinecraftVersion(1, 16)));
}
@Test
@ -39,15 +39,15 @@ public class MinecraftVersionTest {
@Test
public void testEqualOrLower() {
assertTrue(latestVersion.isEqualOrLower(new MinecraftVersion(1, 16, 3)));
assertTrue(latestVersion.isEqualOrLower(new MinecraftVersion(1, 16, 4)));
assertFalse(latestVersion.isEqualOrLower(new MinecraftVersion(1, 16, 2)));
assertTrue(latestVersion.isEqualOrLowerThan(new MinecraftVersion(1, 16, 3)));
assertTrue(latestVersion.isEqualOrLowerThan(new MinecraftVersion(1, 16, 4)));
assertFalse(latestVersion.isEqualOrLowerThan(new MinecraftVersion(1, 16, 2)));
}
@Test
public void testForChunkStretched() {
assertTrue(latestVersion.isEqualOrHigher(MinecraftVersion.NETHER));
assertFalse(latestVersion.isLower(new MinecraftVersion(1, 14, 2)));
assertTrue(latestVersion.isEqualOrHigherThan(MinecraftVersion.NETHER));
assertFalse(latestVersion.isLowerThan(new MinecraftVersion(1, 14, 2)));
}
}