mirror of
https://github.com/BentoBoxWorld/BentoBox.git
synced 2024-11-26 04:35:43 +01:00
Merge pull request #2321 from BentoBoxWorld/max_islands_per_island
Allow the maxhomes to apply per island.
This commit is contained in:
commit
6fccf80477
@ -53,7 +53,7 @@ public class IslandSethomeCommand extends ConfirmableCommand {
|
||||
|
||||
// Check number of homes
|
||||
|
||||
int maxHomes = getIslands().getIslands(getWorld(), user).stream().mapToInt(getIslands()::getMaxHomes).sum();
|
||||
int maxHomes = getIslands().getMaxHomes(island);
|
||||
if (getIslands().getNumberOfHomesIfAdded(island, String.join(" ", args)) > maxHomes) {
|
||||
user.sendMessage("commands.island.sethome.too-many-homes", TextVariables.NUMBER, String.valueOf(maxHomes));
|
||||
user.sendMessage("commands.island.sethome.homes-are");
|
||||
|
@ -37,6 +37,7 @@ import world.bentobox.bentobox.BentoBox;
|
||||
import world.bentobox.bentobox.Settings;
|
||||
import world.bentobox.bentobox.api.commands.CompositeCommand;
|
||||
import world.bentobox.bentobox.api.configuration.WorldSettings;
|
||||
import world.bentobox.bentobox.api.localization.TextVariables;
|
||||
import world.bentobox.bentobox.api.user.User;
|
||||
import world.bentobox.bentobox.database.objects.Island;
|
||||
import world.bentobox.bentobox.managers.CommandsManager;
|
||||
@ -195,6 +196,20 @@ public class IslandSethomeCommandTest {
|
||||
verify(user).sendMessage("commands.island.sethome.must-be-on-your-island");
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for
|
||||
* {@link world.bentobox.bentobox.api.commands.island.IslandSethomeCommand#canExecute(world.bentobox.bentobox.api.user.User, java.lang.String, java.util.List)}.
|
||||
*/
|
||||
@Test
|
||||
public void testCanExecuteTooManyHomes() {
|
||||
when(im.getMaxHomes(island)).thenReturn(10);
|
||||
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.homes-are");
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for
|
||||
* {@link world.bentobox.bentobox.api.commands.island.IslandSethomeCommand#canExecute(world.bentobox.bentobox.api.user.User, java.lang.String, java.util.List)}.
|
||||
|
Loading…
Reference in New Issue
Block a user