mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2024-12-22 17:27:38 +00:00
More precise method names in MinecraftVersion
- Also ensure correct comparisons are made in FaweBukkit and BukkitServerInterface - Fixes #1504
This commit is contained in:
parent
5d4a2a4a0d
commit
bca3a1b04d
@ -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();
|
||||
|
||||
|
@ -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.
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -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)));
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user