mirror of
https://github.com/BentoBoxWorld/BentoBox.git
synced 2024-11-27 13:15:28 +01:00
Fix island test and max ever range bug
This commit is contained in:
parent
09ab327551
commit
937e8bf614
@ -565,11 +565,11 @@ public class Island implements DataObject, MetaDataAble {
|
|||||||
* @return the maxEverProtectionRange or the protection range, whichever is larger
|
* @return the maxEverProtectionRange or the protection range, whichever is larger
|
||||||
*/
|
*/
|
||||||
public int getMaxEverProtectionRange() {
|
public int getMaxEverProtectionRange() {
|
||||||
if (maxEverProtectionRange > this.range) {
|
if (maxEverProtectionRange > this.getRange()) {
|
||||||
maxEverProtectionRange = this.range;
|
maxEverProtectionRange = this.getRange();
|
||||||
setChanged();
|
setChanged();
|
||||||
}
|
}
|
||||||
return Math.max(protectionRange, maxEverProtectionRange);
|
return Math.max(this.getProtectionRange(), maxEverProtectionRange);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -43,6 +43,7 @@ import world.bentobox.bentobox.api.logs.LogEntry;
|
|||||||
import world.bentobox.bentobox.api.metadata.MetaDataValue;
|
import world.bentobox.bentobox.api.metadata.MetaDataValue;
|
||||||
import world.bentobox.bentobox.api.user.User;
|
import world.bentobox.bentobox.api.user.User;
|
||||||
import world.bentobox.bentobox.lists.Flags;
|
import world.bentobox.bentobox.lists.Flags;
|
||||||
|
import world.bentobox.bentobox.managers.CommandsManager;
|
||||||
import world.bentobox.bentobox.managers.FlagsManager;
|
import world.bentobox.bentobox.managers.FlagsManager;
|
||||||
import world.bentobox.bentobox.managers.IslandWorldManager;
|
import world.bentobox.bentobox.managers.IslandWorldManager;
|
||||||
import world.bentobox.bentobox.managers.RanksManager;
|
import world.bentobox.bentobox.managers.RanksManager;
|
||||||
@ -56,6 +57,7 @@ import world.bentobox.bentobox.util.Pair;
|
|||||||
@PrepareForTest({Bukkit.class})
|
@PrepareForTest({Bukkit.class})
|
||||||
public class IslandTest {
|
public class IslandTest {
|
||||||
|
|
||||||
|
private static final int DISTANCE = 400;
|
||||||
private final UUID uuid = UUID.randomUUID();
|
private final UUID uuid = UUID.randomUUID();
|
||||||
private final UUID m = UUID.randomUUID();
|
private final UUID m = UUID.randomUUID();
|
||||||
private Island i;
|
private Island i;
|
||||||
@ -69,6 +71,8 @@ public class IslandTest {
|
|||||||
private World world;
|
private World world;
|
||||||
@Mock
|
@Mock
|
||||||
private User user;
|
private User user;
|
||||||
|
@Mock
|
||||||
|
private CommandsManager cm;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -81,7 +85,7 @@ public class IslandTest {
|
|||||||
|
|
||||||
// Max range
|
// Max range
|
||||||
when(plugin.getIWM()).thenReturn(iwm);
|
when(plugin.getIWM()).thenReturn(iwm);
|
||||||
when(iwm.getIslandDistance(any())).thenReturn(400);
|
when(iwm.getIslandDistance(any())).thenReturn(DISTANCE);
|
||||||
|
|
||||||
// Location
|
// Location
|
||||||
//when(location.getWorld()).thenReturn(world);
|
//when(location.getWorld()).thenReturn(world);
|
||||||
@ -99,6 +103,9 @@ public class IslandTest {
|
|||||||
// Flags
|
// Flags
|
||||||
when(plugin.getFlagsManager()).thenReturn(fm);
|
when(plugin.getFlagsManager()).thenReturn(fm);
|
||||||
|
|
||||||
|
// Commands manager
|
||||||
|
when(plugin.getCommandsManager()).thenReturn(cm);
|
||||||
|
|
||||||
i = new Island(new Island(location, uuid , 100));
|
i = new Island(new Island(location, uuid , 100));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -116,7 +123,7 @@ public class IslandTest {
|
|||||||
public void testIslandLocationUUIDInt() {
|
public void testIslandLocationUUIDInt() {
|
||||||
assertEquals("Location{world=null,x=0.0,y=0.0,z=0.0,pitch=0.0,yaw=0.0}", i.getCenter().toString());
|
assertEquals("Location{world=null,x=0.0,y=0.0,z=0.0,pitch=0.0,yaw=0.0}", i.getCenter().toString());
|
||||||
assertEquals(uuid, i.getOwner());
|
assertEquals(uuid, i.getOwner());
|
||||||
assertEquals(400, i.getRange());
|
assertEquals(DISTANCE, i.getRange());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -126,7 +133,7 @@ public class IslandTest {
|
|||||||
public void testIslandIsland() {
|
public void testIslandIsland() {
|
||||||
assertEquals("Location{world=null,x=0.0,y=0.0,z=0.0,pitch=0.0,yaw=0.0}", i.getCenter().toString());
|
assertEquals("Location{world=null,x=0.0,y=0.0,z=0.0,pitch=0.0,yaw=0.0}", i.getCenter().toString());
|
||||||
assertEquals(uuid, i.getOwner());
|
assertEquals(uuid, i.getOwner());
|
||||||
assertEquals(400, i.getRange());
|
assertEquals(DISTANCE, i.getRange());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -273,7 +280,7 @@ public class IslandTest {
|
|||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testGetMinX() {
|
public void testGetMinX() {
|
||||||
assertEquals(-400, i.getMinX());
|
assertEquals(-DISTANCE, i.getMinX());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -281,7 +288,7 @@ public class IslandTest {
|
|||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testGetMaxX() {
|
public void testGetMaxX() {
|
||||||
assertEquals(400, i.getMaxX());
|
assertEquals(DISTANCE, i.getMaxX());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -289,7 +296,7 @@ public class IslandTest {
|
|||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testGetMinZ() {
|
public void testGetMinZ() {
|
||||||
assertEquals(-400, i.getMinZ());
|
assertEquals(-DISTANCE, i.getMinZ());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -297,7 +304,7 @@ public class IslandTest {
|
|||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testGetMaxZ() {
|
public void testGetMaxZ() {
|
||||||
assertEquals(400, i.getMaxZ());
|
assertEquals(DISTANCE, i.getMaxZ());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -372,7 +379,7 @@ public class IslandTest {
|
|||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testGetRange() {
|
public void testGetRange() {
|
||||||
assertEquals(400, i.getRange());
|
assertEquals(DISTANCE, i.getRange());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -473,7 +480,7 @@ public class IslandTest {
|
|||||||
i.setWorld(world);
|
i.setWorld(world);
|
||||||
when(location.getWorld()).thenReturn(world);
|
when(location.getWorld()).thenReturn(world);
|
||||||
assertNotNull(i.getBoundingBox());
|
assertNotNull(i.getBoundingBox());
|
||||||
assertEquals("BoundingBox [minX=-400.0, minY=0.0, minZ=-400.0, maxX=400.0, maxY=0.0, maxZ=400.0]", i.getBoundingBox().toString());
|
assertEquals("BoundingBox [minX=-" + DISTANCE + ".0, minY=0.0, minZ=-" + DISTANCE + ".0, maxX=" + DISTANCE + ".0, maxY=0.0, maxZ=" + DISTANCE + ".0]", i.getBoundingBox().toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -665,8 +672,9 @@ public class IslandTest {
|
|||||||
assertEquals(50, i.getProtectionRange());
|
assertEquals(50, i.getProtectionRange());
|
||||||
i.setProtectionRange(100);
|
i.setProtectionRange(100);
|
||||||
assertEquals(100, i.getProtectionRange());
|
assertEquals(100, i.getProtectionRange());
|
||||||
|
// Over island range
|
||||||
i.setProtectionRange(1000);
|
i.setProtectionRange(1000);
|
||||||
assertEquals(1000, i.getProtectionRange());
|
assertEquals(DISTANCE, i.getProtectionRange());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -675,7 +683,7 @@ public class IslandTest {
|
|||||||
@Test
|
@Test
|
||||||
public void testUpdateMaxEverProtectionRange() {
|
public void testUpdateMaxEverProtectionRange() {
|
||||||
i.setProtectionRange(1000);
|
i.setProtectionRange(1000);
|
||||||
assertEquals(1000, i.getMaxEverProtectionRange());
|
assertEquals(DISTANCE, i.getMaxEverProtectionRange());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user