mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2024-11-16 17:16:11 +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();
|
Bukkit.getServer().shutdown();
|
||||||
}
|
}
|
||||||
|
|
||||||
chunksStretched = new MinecraftVersion().isEqualOrLower(MinecraftVersion.NETHER);
|
chunksStretched = new MinecraftVersion().isEqualOrHigherThan(MinecraftVersion.NETHER);
|
||||||
|
|
||||||
platformAdapter = new NMSAdapter();
|
platformAdapter = new NMSAdapter();
|
||||||
|
|
||||||
|
@ -69,7 +69,7 @@ public class MinecraftVersion implements Comparable<MinecraftVersion> {
|
|||||||
* @param other The other version to compare against.
|
* @param other The other version to compare against.
|
||||||
* @return {@code true} if this version is higher or equal compared to the other version.
|
* @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;
|
return compareTo(other) >= 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -77,7 +77,7 @@ public class MinecraftVersion implements Comparable<MinecraftVersion> {
|
|||||||
* @param other The other version to compare against.
|
* @param other The other version to compare against.
|
||||||
* @return {@code true} if this version is lower or equal compared to the other version.
|
* @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;
|
return compareTo(other) <= 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -85,7 +85,7 @@ public class MinecraftVersion implements Comparable<MinecraftVersion> {
|
|||||||
* @param other The other version to compare against.
|
* @param other The other version to compare against.
|
||||||
* @return {@code true} if this version is higher than the other version.
|
* @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;
|
return compareTo(other) > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -93,7 +93,7 @@ public class MinecraftVersion implements Comparable<MinecraftVersion> {
|
|||||||
* @param other The other version to compare against.
|
* @param other The other version to compare against.
|
||||||
* @return {@code true} if this version is lower than to the other version.
|
* @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;
|
return compareTo(other) < 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -140,6 +140,11 @@ public class MinecraftVersion implements Comparable<MinecraftVersion> {
|
|||||||
return getRelease() == that.getRelease();
|
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},
|
* 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.
|
* where v1_16_R3 is the resolved version.
|
||||||
|
@ -282,12 +282,12 @@ public class BukkitServerInterface extends AbstractPlatform implements MultiUser
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getVersionMinY() {
|
public int getVersionMinY() {
|
||||||
return new MinecraftVersion().isEqualOrLower(MinecraftVersion.CAVES_18) ? -64 : 0;
|
return new MinecraftVersion().isEqualOrHigherThan(MinecraftVersion.CAVES_18) ? -64 : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getVersionMaxY() {
|
public int getVersionMaxY() {
|
||||||
return new MinecraftVersion().isEqualOrLower(MinecraftVersion.CAVES_18) ? 319 : 255;
|
return new MinecraftVersion().isEqualOrHigherThan(MinecraftVersion.CAVES_18) ? 319 : 255;
|
||||||
}
|
}
|
||||||
//FAWE end
|
//FAWE end
|
||||||
}
|
}
|
||||||
|
@ -20,14 +20,14 @@ public class MinecraftVersionTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testEqualOrHigher() {
|
public void testEqualOrHigher() {
|
||||||
assertTrue(latestVersion.isEqualOrHigher(new MinecraftVersion(1, 16, 3)));
|
assertTrue(latestVersion.isEqualOrHigherThan(new MinecraftVersion(1, 16, 3)));
|
||||||
assertTrue(latestVersion.isEqualOrHigher(new MinecraftVersion(1, 16, 2)));
|
assertTrue(latestVersion.isEqualOrHigherThan(new MinecraftVersion(1, 16, 2)));
|
||||||
assertFalse(latestVersion.isEqualOrHigher(new MinecraftVersion(1, 16, 4)));
|
assertFalse(latestVersion.isEqualOrHigherThan(new MinecraftVersion(1, 16, 4)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testEqualOrHigherWithoutRelease() {
|
public void testEqualOrHigherWithoutRelease() {
|
||||||
assertTrue(latestVersion.isEqualOrHigher(new MinecraftVersion(1, 16)));
|
assertTrue(latestVersion.isEqualOrHigherThan(new MinecraftVersion(1, 16)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -39,15 +39,15 @@ public class MinecraftVersionTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testEqualOrLower() {
|
public void testEqualOrLower() {
|
||||||
assertTrue(latestVersion.isEqualOrLower(new MinecraftVersion(1, 16, 3)));
|
assertTrue(latestVersion.isEqualOrLowerThan(new MinecraftVersion(1, 16, 3)));
|
||||||
assertTrue(latestVersion.isEqualOrLower(new MinecraftVersion(1, 16, 4)));
|
assertTrue(latestVersion.isEqualOrLowerThan(new MinecraftVersion(1, 16, 4)));
|
||||||
assertFalse(latestVersion.isEqualOrLower(new MinecraftVersion(1, 16, 2)));
|
assertFalse(latestVersion.isEqualOrLowerThan(new MinecraftVersion(1, 16, 2)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testForChunkStretched() {
|
public void testForChunkStretched() {
|
||||||
assertTrue(latestVersion.isEqualOrHigher(MinecraftVersion.NETHER));
|
assertTrue(latestVersion.isEqualOrHigherThan(MinecraftVersion.NETHER));
|
||||||
assertFalse(latestVersion.isLower(new MinecraftVersion(1, 14, 2)));
|
assertFalse(latestVersion.isLowerThan(new MinecraftVersion(1, 14, 2)));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user