Add placeholders. Put in defensive code against nulls.

This commit is contained in:
tastybento 2024-09-28 16:02:11 -07:00
parent 2784f197cb
commit 4a972a86ae
4 changed files with 78 additions and 1 deletions

View File

@ -27,6 +27,7 @@ import world.bentobox.bentobox.util.Util;
* </ul> * </ul>
* *
* @author tastybento * @author tastybento
* @since 2.6.0
*/ */
public class AdminMaxHomesCommand extends ConfirmableCommand { public class AdminMaxHomesCommand extends ConfirmableCommand {

View File

@ -157,6 +157,15 @@ public enum GameModePlaceholder {
* @since 1.5.0 * @since 1.5.0
*/ */
ISLAND_VISITORS_COUNT("island_visitors_count", (addon, user, island) -> island == null ? "" : String.valueOf(island.getVisitors().size())), ISLAND_VISITORS_COUNT("island_visitors_count", (addon, user, island) -> island == null ? "" : String.valueOf(island.getVisitors().size())),
/**
* Returns the amount of players that are at least MEMBER on the island the player is standing on.
* @since 2.6.0
*/
ISLAND_MAX_HOMES("island_max_homes",
(addon, user, island) -> island == null ? ""
: String.valueOf(
island.getMaxHomes() == null ? addon.getPlugin().getIWM().getMaxHomes(island.getWorld())
: island.getMaxHomes())),
/** /**
* Returns the amount of players banned from the island. * Returns the amount of players banned from the island.
* @since 1.5.0 * @since 1.5.0
@ -281,6 +290,16 @@ public enum GameModePlaceholder {
*/ */
VISITED_ISLAND_MEMBERS_COUNT("visited_island_members_count", (addon, user, island) -> VISITED_ISLAND_MEMBERS_COUNT("visited_island_members_count", (addon, user, island) ->
getVisitedIsland(addon, user).map(value -> String.valueOf(value.getMemberSet().size())).orElse("")), getVisitedIsland(addon, user).map(value -> String.valueOf(value.getMemberSet().size())).orElse("")),
/**
* Returns the amount of players that are at least MEMBER on the island the player is standing on.
* @since 2.6.0
*/
VISITED_ISLAND_MAX_HOMES("visited_island_max_homes",
(addon, user,
island) -> getVisitedIsland(addon, user).map(value -> String.valueOf(
island.getMaxHomes() == null ? addon.getPlugin().getIWM().getMaxHomes(island.getWorld())
: island.getMaxHomes()))
.orElse("")),
/** /**
* Returns the amount of players that are TRUSTED on the island the player is standing on. * Returns the amount of players that are TRUSTED on the island the player is standing on.
* @since 1.5.2 * @since 1.5.2

View File

@ -143,7 +143,9 @@ public class IslandInfo {
// Show team members // Show team members
showMembers(user); showMembers(user);
} }
user.sendMessage("commands.admin.info.max-homes", TextVariables.NUMBER, String.valueOf(island.getMaxHomes())); int maxHomes = island.getMaxHomes() == null ? plugin.getIWM().getMaxHomes(island.getWorld())
: island.getMaxHomes();
user.sendMessage("commands.admin.info.max-homes", TextVariables.NUMBER, String.valueOf(maxHomes));
Vector location = island.getProtectionCenter().toVector(); Vector location = island.getProtectionCenter().toVector();
user.sendMessage("commands.admin.info.island-center", TextVariables.XYZ, Util.xyz(location)); user.sendMessage("commands.admin.info.island-center", TextVariables.XYZ, Util.xyz(location));
user.sendMessage("commands.admin.info.protection-range", RANGE, String.valueOf(island.getProtectionRange())); user.sendMessage("commands.admin.info.protection-range", RANGE, String.valueOf(island.getProtectionRange()));

View File

@ -0,0 +1,55 @@
/**
*
*/
package world.bentobox.bentobox.api.commands.admin;
import static org.junit.Assert.*;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
/**
*
*/
public class DefaultAdminCommandTest {
/**
* @throws java.lang.Exception
*/
@Before
public void setUp() throws Exception {
}
/**
* @throws java.lang.Exception
*/
@After
public void tearDown() throws Exception {
}
/**
* Test method for {@link world.bentobox.bentobox.api.commands.admin.DefaultAdminCommand#DefaultAdminCommand(world.bentobox.bentobox.api.addons.GameModeAddon)}.
*/
@Test
public void testDefaultAdminCommand() {
fail("Not yet implemented");
}
/**
* Test method for {@link world.bentobox.bentobox.api.commands.admin.DefaultAdminCommand#setup()}.
*/
@Test
public void testSetup() {
fail("Not yet implemented");
}
/**
* Test method for {@link world.bentobox.bentobox.api.commands.admin.DefaultAdminCommand#execute(world.bentobox.bentobox.api.user.User, java.lang.String, java.util.List)}.
*/
@Test
public void testExecuteUserStringListOfString() {
fail("Not yet implemented");
}
}