mirror of
https://github.com/BentoBoxWorld/BentoBox.git
synced 2025-01-23 08:31:34 +01:00
Merge pull request #2561 from BentoBoxWorld/2546_Max_homes_limit_for_players_is_the_set_limit_minus_1
Fix for #2546. Default unnamed home was being counted in the number
This commit is contained in:
commit
8e3a6ab6e5
@ -54,7 +54,8 @@ public class IslandSethomeCommand extends ConfirmableCommand {
|
||||
// Check number of homes
|
||||
|
||||
int maxHomes = getIslands().getMaxHomes(island);
|
||||
if (getIslands().getNumberOfHomesIfAdded(island, String.join(" ", args)) > maxHomes) {
|
||||
// The + 1 is for the default home
|
||||
if (getIslands().getNumberOfHomesIfAdded(island, String.join(" ", args)) > maxHomes + 1) {
|
||||
user.sendMessage("commands.island.sethome.too-many-homes", TextVariables.NUMBER, String.valueOf(maxHomes));
|
||||
user.sendMessage("commands.island.sethome.homes-are");
|
||||
getIslands().getIslands(getWorld(), user).forEach(is ->
|
||||
|
@ -940,6 +940,7 @@ public class IslandsManager {
|
||||
*/
|
||||
@NonNull
|
||||
public Map<String, Location> getHomeLocations(@NonNull Island island) {
|
||||
island.getHomes().forEach((n, l) -> BentoBox.getInstance().logDebug(n));
|
||||
return island.getHomes();
|
||||
}
|
||||
|
||||
@ -956,6 +957,7 @@ public class IslandsManager {
|
||||
|
||||
/**
|
||||
* Get the number of homes on this island if this home were added
|
||||
* This includes the default home, which has no name
|
||||
*
|
||||
* @param island - island
|
||||
* @param name - name
|
||||
|
@ -201,11 +201,11 @@ public class IslandSethomeCommandTest {
|
||||
*/
|
||||
@Test
|
||||
public void testCanExecuteTooManyHomes() {
|
||||
when(im.getMaxHomes(island)).thenReturn(10);
|
||||
when(im.getMaxHomes(island)).thenReturn(9);
|
||||
when(im.getNumberOfHomesIfAdded(eq(island), anyString())).thenReturn(11);
|
||||
IslandSethomeCommand isc = new IslandSethomeCommand(ic);
|
||||
assertFalse(isc.canExecute(user, "island", Collections.emptyList()));
|
||||
verify(user).sendMessage("commands.island.sethome.too-many-homes", TextVariables.NUMBER, "10");
|
||||
verify(user).sendMessage("commands.island.sethome.too-many-homes", TextVariables.NUMBER, "9");
|
||||
verify(user).sendMessage("commands.island.sethome.homes-are");
|
||||
}
|
||||
|
||||
@ -251,7 +251,7 @@ public class IslandSethomeCommandTest {
|
||||
@Test
|
||||
public void testExecuteUserStringListOfStringMultiHomeTooMany() {
|
||||
when(im.getMaxHomes(island)).thenReturn(3);
|
||||
when(im.getNumberOfHomesIfAdded(eq(island), anyString())).thenReturn(4);
|
||||
when(im.getNumberOfHomesIfAdded(eq(island), anyString())).thenReturn(5);
|
||||
IslandSethomeCommand isc = new IslandSethomeCommand(ic);
|
||||
assertFalse(isc.canExecute(user, "island", Collections.singletonList("13")));
|
||||
verify(user).sendMessage(eq("commands.island.sethome.too-many-homes"), eq("[number]"), eq("3"));
|
||||
|
Loading…
Reference in New Issue
Block a user