From e99802ba33043329c86ca6c2bae5c32c1b920dc7 Mon Sep 17 00:00:00 2001 From: tastybento Date: Thu, 16 Sep 2021 17:38:06 -0700 Subject: [PATCH] Version 1.2.1 (#32) * Version 1.2.1 * Added null checks. * Added null checks. * Added tests for Settings. * Improve code smells * Updated .gitignore * Made fields local * JavaDoc fixes * Make fields final * Removed exception * Renamed plugin Pladdon * Enderpearls were moving islandd centers in other worlds https://github.com/BentoBoxWorld/Boxed/issues/31 --- .gitignore | 1 + pom.xml | 4 +- .../bentobox/boxed/AdvancementsManager.java | 2 +- src/main/java/world/bentobox/boxed/Boxed.java | 9 +- .../bentobox/boxed/PlaceholdersManager.java | 9 +- .../AbstractBoxedBiomeGenerator.java | 15 +- .../boxed/generators/BoxedChunkGenerator.java | 2 +- .../bentobox/boxed/generators/DeleteGen.java | 2 +- .../boxed/generators/NetherGenerator.java | 11 +- .../boxed/listeners/AdvancementListener.java | 101 +++-- .../boxed/listeners/EnderPearlListener.java | 10 +- .../boxed/objects/IslandAdvancements.java | 2 +- src/main/resources/plugin.yml | 2 +- .../world/bentobox/boxed/SettingsTest.java | 421 ++++++++++++++++++ 14 files changed, 511 insertions(+), 80 deletions(-) create mode 100644 src/test/java/world/bentobox/boxed/SettingsTest.java diff --git a/.gitignore b/.gitignore index b5ae580..a96c143 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ /.DS_Store /pom.xml.versionsBackup /bin/ +/boxed.iml diff --git a/pom.xml b/pom.xml index 361f1eb..f37665f 100644 --- a/pom.xml +++ b/pom.xml @@ -59,13 +59,13 @@ 2.0.9 1.17-R0.1-SNAPSHOT - 1.17.0 + 1.17.3 ${build.version}-SNAPSHOT -LOCAL - 1.2.0 + 1.2.1 BentoBoxWorld_Boxed bentobox-world diff --git a/src/main/java/world/bentobox/boxed/AdvancementsManager.java b/src/main/java/world/bentobox/boxed/AdvancementsManager.java index 2831580..eff74c6 100644 --- a/src/main/java/world/bentobox/boxed/AdvancementsManager.java +++ b/src/main/java/world/bentobox/boxed/AdvancementsManager.java @@ -37,7 +37,7 @@ public class AdvancementsManager { private int unknownAdvChange; /** - * @param addon + * @param addon addon */ public AdvancementsManager(Boxed addon) { this.addon = addon; diff --git a/src/main/java/world/bentobox/boxed/Boxed.java b/src/main/java/world/bentobox/boxed/Boxed.java index d67f847..4846824 100644 --- a/src/main/java/world/bentobox/boxed/Boxed.java +++ b/src/main/java/world/bentobox/boxed/Boxed.java @@ -49,11 +49,10 @@ public class Boxed extends GameModeAddon { // Settings private Settings settings; private ChunkGenerator chunkGenerator; - private Config configObject = new Config<>(this, Settings.class); + private final Config configObject = new Config<>(this, Settings.class); private AdvancementsManager advManager; private DeleteGen delChunks; private ChunkGenerator netherChunkGenerator; - private PlaceholdersManager phManager; @Override public void onLoad() { @@ -104,10 +103,10 @@ public class Boxed extends GameModeAddon { return; } // Check for recommended addons - if (!this.getPlugin().getAddonsManager().getAddonByName("Border").isPresent()) { + if (this.getPlugin().getAddonsManager().getAddonByName("Border").isEmpty()) { this.logWarning("Boxed normally requires the Border addon."); } - if (!this.getPlugin().getAddonsManager().getAddonByName("InvSwitcher").isPresent()) { + if (this.getPlugin().getAddonsManager().getAddonByName("InvSwitcher").isEmpty()) { this.logWarning("Boxed normally requires the InvSwitcher addon for per-world Advancements."); } // Advancements manager @@ -130,7 +129,7 @@ public class Boxed extends GameModeAddon { this.registerListener(new EnderPearlListener(this)); // Register placeholders - phManager = new PlaceholdersManager(this); + PlaceholdersManager phManager = new PlaceholdersManager(this); getPlugin().getPlaceholdersManager().registerPlaceholder(this,"visited_island_advancements", phManager::getCountByLocation); getPlugin().getPlaceholdersManager().registerPlaceholder(this,"island_advancements", phManager::getCount); diff --git a/src/main/java/world/bentobox/boxed/PlaceholdersManager.java b/src/main/java/world/bentobox/boxed/PlaceholdersManager.java index fed2ae9..c14eb47 100644 --- a/src/main/java/world/bentobox/boxed/PlaceholdersManager.java +++ b/src/main/java/world/bentobox/boxed/PlaceholdersManager.java @@ -33,9 +33,12 @@ public class PlaceholdersManager { * @return string of advancement count */ public String getCountByLocation(User user) { - if (user == null || user.getUniqueId() == null) return ""; - return addon.getIslands().getIslandAt(user.getLocation()) - .map(i -> String.valueOf(addon.getAdvManager().getIsland(i).getAdvancements().size())).orElse(""); + if (user != null && user.getUniqueId() != null && user.getLocation() != null) { + return addon.getIslands().getIslandAt(user.getLocation()) + .map(i -> String.valueOf(addon.getAdvManager().getIsland(i).getAdvancements().size())).orElse(""); + } else { + return ""; + } } diff --git a/src/main/java/world/bentobox/boxed/generators/AbstractBoxedBiomeGenerator.java b/src/main/java/world/bentobox/boxed/generators/AbstractBoxedBiomeGenerator.java index c71927a..b635f0b 100644 --- a/src/main/java/world/bentobox/boxed/generators/AbstractBoxedBiomeGenerator.java +++ b/src/main/java/world/bentobox/boxed/generators/AbstractBoxedBiomeGenerator.java @@ -36,11 +36,6 @@ abstract class AbstractBoxedBiomeGenerator implements BiomeGenerator { ENV_MAP = Collections.unmodifiableMap(e); } - private final SortedMap northEast; - private final SortedMap southEast; - private final SortedMap northWest; - private final SortedMap southWest; - protected final Map> quadrants; private final Boxed addon; @@ -50,7 +45,7 @@ abstract class AbstractBoxedBiomeGenerator implements BiomeGenerator { private final Biome defaultBiome; - public AbstractBoxedBiomeGenerator(Boxed boxed, Environment env, Biome defaultBiome) { + protected AbstractBoxedBiomeGenerator(Boxed boxed, Environment env, Biome defaultBiome) { this.addon = boxed; this.defaultBiome = defaultBiome; dist = addon.getSettings().getIslandDistance(); @@ -62,10 +57,10 @@ abstract class AbstractBoxedBiomeGenerator implements BiomeGenerator { addon.saveResource("biomes.yml", true); } YamlConfiguration config = YamlConfiguration.loadConfiguration(biomeFile); - northEast = loadQuad(config, ENV_MAP.get(env) + ".north-east"); - southEast = loadQuad(config, ENV_MAP.get(env) + ".south-east"); - northWest = loadQuad(config, ENV_MAP.get(env) + ".north-west"); - southWest = loadQuad(config, ENV_MAP.get(env) + ".south-west"); + SortedMap northEast = loadQuad(config, ENV_MAP.get(env) + ".north-east"); + SortedMap southEast = loadQuad(config, ENV_MAP.get(env) + ".south-east"); + SortedMap northWest = loadQuad(config, ENV_MAP.get(env) + ".north-west"); + SortedMap southWest = loadQuad(config, ENV_MAP.get(env) + ".south-west"); quadrants = new EnumMap<>(BlockFace.class); quadrants.put(BlockFace.NORTH_EAST, northEast); diff --git a/src/main/java/world/bentobox/boxed/generators/BoxedChunkGenerator.java b/src/main/java/world/bentobox/boxed/generators/BoxedChunkGenerator.java index c80a136..abe6509 100644 --- a/src/main/java/world/bentobox/boxed/generators/BoxedChunkGenerator.java +++ b/src/main/java/world/bentobox/boxed/generators/BoxedChunkGenerator.java @@ -15,7 +15,7 @@ public class BoxedChunkGenerator { private final WorldRef wordRef; private final Boxed addon; - private WorldRef wordRefNether; + private final WorldRef wordRefNether; public BoxedChunkGenerator(Boxed addon) { this.addon = addon; diff --git a/src/main/java/world/bentobox/boxed/generators/DeleteGen.java b/src/main/java/world/bentobox/boxed/generators/DeleteGen.java index befc845..bc60d68 100644 --- a/src/main/java/world/bentobox/boxed/generators/DeleteGen.java +++ b/src/main/java/world/bentobox/boxed/generators/DeleteGen.java @@ -19,7 +19,7 @@ public class DeleteGen extends ChunkGenerator { private final Map backMap; /** - * @param addon + * @param addon addon */ public DeleteGen(Boxed addon) { backMap = new HashMap<>(); diff --git a/src/main/java/world/bentobox/boxed/generators/NetherGenerator.java b/src/main/java/world/bentobox/boxed/generators/NetherGenerator.java index c140f68..a0c8e8a 100644 --- a/src/main/java/world/bentobox/boxed/generators/NetherGenerator.java +++ b/src/main/java/world/bentobox/boxed/generators/NetherGenerator.java @@ -27,7 +27,6 @@ public class NetherGenerator implements BaseNoiseGenerator { private final BiomeNoise defaultNoise = new BiomeNoise(10D, 0D, 2D); private final NoiseGenerator mainNoiseGenerator; private final Boxed addon; - private final YamlConfiguration config; private final Map biomeNoiseMap; @@ -40,7 +39,7 @@ public class NetherGenerator implements BaseNoiseGenerator { if (!biomeFile.exists()) { addon.saveResource("biomes.yml", true); } - config = YamlConfiguration.loadConfiguration(biomeFile); + YamlConfiguration config = YamlConfiguration.loadConfiguration(biomeFile); biomeNoiseMap = new EnumMap<>(Biome.class); if (config.isConfigurationSection(NETHER_BIOMES)) { for (String key : config.getConfigurationSection(NETHER_BIOMES).getKeys(false)) { @@ -53,14 +52,14 @@ public class NetherGenerator implements BaseNoiseGenerator { } } - class BiomeNoise { + static class BiomeNoise { double noiseScaleHorizontal = 10D; double height = 0D; double noiseScaleVertical = 2D; /** - * @param noiseScaleHorizontal - * @param height - * @param noiseScaleVertical + * @param noiseScaleHorizontal horizontal noise scale + * @param height height + * @param noiseScaleVertical vertical noise scale */ public BiomeNoise(double noiseScaleHorizontal, double height, double noiseScaleVertical) { this.noiseScaleHorizontal = noiseScaleHorizontal; diff --git a/src/main/java/world/bentobox/boxed/listeners/AdvancementListener.java b/src/main/java/world/bentobox/boxed/listeners/AdvancementListener.java index 2507c8f..1106bc7 100644 --- a/src/main/java/world/bentobox/boxed/listeners/AdvancementListener.java +++ b/src/main/java/world/bentobox/boxed/listeners/AdvancementListener.java @@ -3,6 +3,7 @@ package world.bentobox.boxed.listeners; import java.util.Arrays; import java.util.Iterator; import java.util.List; +import java.util.Objects; import java.util.Spliterator; import java.util.Spliterators; import java.util.stream.StreamSupport; @@ -42,14 +43,14 @@ import world.bentobox.boxed.Boxed; */ public class AdvancementListener implements Listener { - private Boxed addon; + private final Boxed addon; private final Advancement netherAdvancement; private final Advancement endAdvancement; private final Advancement netherRoot; private final Advancement endRoot; /** - * @param addon + * @param addon addon */ public AdvancementListener(Boxed addon) { this.addon = addon; @@ -77,20 +78,27 @@ public class AdvancementListener implements Listener { e.getAdvancement().getCriteria().forEach(c -> e.getPlayer().getAdvancementProgress(e.getAdvancement()).revokeCriteria(c)); User u = User.getInstance(e.getPlayer()); - u.notify("boxed.adv-disallowed", TextVariables.NAME, e.getPlayer().getName(), TextVariables.DESCRIPTION, this.keyToString(u, e.getAdvancement().getKey())); + if (u != null) { + u.notify("boxed.adv-disallowed", TextVariables.NAME, e.getPlayer().getName(), TextVariables.DESCRIPTION, this.keyToString(u, e.getAdvancement().getKey())); + } return; } int score = addon.getAdvManager().addAdvancement(e.getPlayer(), e.getAdvancement()); if (score != 0) { User user = User.getInstance(e.getPlayer()); - Bukkit.getScheduler().runTask(addon.getPlugin(), () -> tellTeam(user, e.getAdvancement().getKey(), score)); + if (user != null) { + Bukkit.getScheduler().runTask(addon.getPlugin(), () -> tellTeam(user, e.getAdvancement().getKey(), score)); + } } } } private void tellTeam(User user, NamespacedKey key, int score) { Island island = addon.getIslands().getIsland(addon.getOverWorld(), user); + if (island == null) { + return; + } island.getMemberSet(RanksManager.MEMBER_RANK).stream() .map(User::getInstance) .filter(User::isOnline) @@ -119,16 +127,16 @@ public class AdvancementListener implements Listener { int diff = addon.getAdvManager().checkIslandSize(island); if (diff > 0) { user.sendMessage("boxed.size-changed", TextVariables.NUMBER, String.valueOf(diff)); - user.getPlayer().playSound(user.getLocation(), Sound.ENTITY_PLAYER_LEVELUP, 1F, 2F); + user.getPlayer().playSound(Objects.requireNonNull(user.getLocation()), Sound.ENTITY_PLAYER_LEVELUP, 1F, 2F); } else if (diff < 0) { user.sendMessage("boxed.size-decreased", TextVariables.NUMBER, String.valueOf(Math.abs(diff))); - user.getPlayer().playSound(user.getLocation(), Sound.ENTITY_VILLAGER_DEATH, 1F, 2F); + user.getPlayer().playSound(Objects.requireNonNull(user.getLocation()), Sound.ENTITY_VILLAGER_DEATH, 1F, 2F); } } } private void informPlayer(User user, NamespacedKey key, int score) { - user.getPlayer().playSound(user.getLocation(), Sound.ENTITY_PLAYER_LEVELUP, 1F, 2F); + user.getPlayer().playSound(Objects.requireNonNull(user.getLocation()), Sound.ENTITY_PLAYER_LEVELUP, 1F, 2F); user.sendMessage("boxed.completed", TextVariables.NAME, keyToString(user, key)); user.sendMessage("boxed.size-changed", TextVariables.NUMBER, String.valueOf(score)); @@ -137,7 +145,7 @@ public class AdvancementListener implements Listener { private String keyToString(User user, NamespacedKey key) { String adv = user.getTranslationOrNothing("boxed.advancements." + key.toString()); if (adv.isEmpty()) { - adv = Util.prettifyText(key.getKey().substring(key.getKey().lastIndexOf("/") + 1, key.getKey().length())); + adv = Util.prettifyText(key.getKey().substring(key.getKey().lastIndexOf("/") + 1)); } return adv; } @@ -186,7 +194,7 @@ public class AdvancementListener implements Listener { @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) public void onTeamJoinTime(TeamJoinedEvent e) { User user = User.getInstance(e.getPlayerUUID()); - if (addon.getSettings().isOnJoinResetAdvancements() && user.isOnline() + if (user != null && addon.getSettings().isOnJoinResetAdvancements() && user.isOnline() && addon.getOverWorld().equals(Util.getWorld(user.getWorld()))) { // Clear and set advancements clearAndSetAdv(user, addon.getSettings().isOnJoinResetAdvancements(), addon.getSettings().getOnJoinGrantAdvancements()); @@ -198,7 +206,7 @@ public class AdvancementListener implements Listener { @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) public void onTeamLeaveTime(TeamLeaveEvent e) { User user = User.getInstance(e.getPlayerUUID()); - if (addon.getSettings().isOnJoinResetAdvancements() && user.isOnline() + if (user != null && addon.getSettings().isOnJoinResetAdvancements() && user.isOnline() && addon.getOverWorld().equals(Util.getWorld(user.getWorld()))) { // Clear and set advancements clearAndSetAdv(user, addon.getSettings().isOnLeaveResetAdvancements(), addon.getSettings().getOnLeaveGrantAdvancements()); @@ -208,7 +216,10 @@ public class AdvancementListener implements Listener { @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) public void onFirstTime(IslandNewIslandEvent e) { - clearAndSetAdv(User.getInstance(e.getPlayerUUID()), addon.getSettings().isOnJoinResetAdvancements(), addon.getSettings().getOnJoinGrantAdvancements()); + User user = User.getInstance(e.getPlayerUUID()); + if (user != null) { + clearAndSetAdv(user, addon.getSettings().isOnJoinResetAdvancements(), addon.getSettings().getOnJoinGrantAdvancements()); + } } @@ -241,42 +252,11 @@ public class AdvancementListener implements Listener { } } - @SuppressWarnings("deprecation") + private void clearAdv(User user) { // Clear stats // Statistics - Arrays.stream(Statistic.values()).forEach(s -> { - switch(s.getType()) { - case BLOCK: - for (Material m: Material.values()) { - if (m.isBlock() && !m.isLegacy()) { - user.getPlayer().setStatistic(s, m, 0); - } - } - break; - case ITEM: - for (Material m: Material.values()) { - if (m.isItem() && !m.isLegacy()) { - user.getPlayer().setStatistic(s, m, 0); - } - } - break; - case ENTITY: - for (EntityType en: EntityType.values()) { - if (en.isAlive()) { - user.getPlayer().setStatistic(s, en, 0); - } - } - break; - case UNTYPED: - user.getPlayer().setStatistic(s, 0); - break; - default: - break; - - } - - }); + Arrays.stream(Statistic.values()).forEach(s -> resetStats(user, s)); // Clear advancements Iterator it = Bukkit.advancementIterator(); while (it.hasNext()) { @@ -287,4 +267,37 @@ public class AdvancementListener implements Listener { } + @SuppressWarnings("deprecation") + private void resetStats(User user, Statistic s) { + switch(s.getType()) { + case BLOCK: + for (Material m: Material.values()) { + if (m.isBlock() && !m.isLegacy()) { + user.getPlayer().setStatistic(s, m, 0); + } + } + break; + case ITEM: + for (Material m: Material.values()) { + if (m.isItem() && !m.isLegacy()) { + user.getPlayer().setStatistic(s, m, 0); + } + } + break; + case ENTITY: + for (EntityType en: EntityType.values()) { + if (en.isAlive()) { + user.getPlayer().setStatistic(s, en, 0); + } + } + break; + case UNTYPED: + user.getPlayer().setStatistic(s, 0); + break; + default: + break; + + } + } + } diff --git a/src/main/java/world/bentobox/boxed/listeners/EnderPearlListener.java b/src/main/java/world/bentobox/boxed/listeners/EnderPearlListener.java index 66a69d8..b5d018b 100644 --- a/src/main/java/world/bentobox/boxed/listeners/EnderPearlListener.java +++ b/src/main/java/world/bentobox/boxed/listeners/EnderPearlListener.java @@ -26,7 +26,7 @@ public class EnderPearlListener implements Listener { private final Boxed addon; /** - * @param addon + * @param addon addon */ public EnderPearlListener(Boxed addon) { this.addon = addon; @@ -38,15 +38,15 @@ public class EnderPearlListener implements Listener { public void onEnderPearlLand(ProjectileHitEvent e) { if (!e.getEntityType().equals(EntityType.ENDER_PEARL) || e.getHitBlock() == null - || !addon.getPlugin().getIWM().inWorld(e.getHitBlock().getLocation())) { + || !addon.inWorld(e.getHitBlock().getLocation())) { return; } Location l = e.getHitBlock().getRelative(BlockFace.UP).getLocation(); EnderPearl ep = (EnderPearl)e.getEntity(); - if (ep.getShooter() instanceof Player) { - User u = User.getInstance((Player)ep.getShooter()); + if (ep.getShooter() instanceof Player player) { + User u = User.getInstance(player); addon.getIslands().getIslandAt(l).ifPresent(i -> { - // Check flag + // Check flag if (i.isAllowed(u, Boxed.MOVE_BOX) && addon.getIslands().isSafeLocation(l)) { // Reset home locations i.getMemberSet().forEach(uuid -> { diff --git a/src/main/java/world/bentobox/boxed/objects/IslandAdvancements.java b/src/main/java/world/bentobox/boxed/objects/IslandAdvancements.java index f9b0616..b1ad73f 100644 --- a/src/main/java/world/bentobox/boxed/objects/IslandAdvancements.java +++ b/src/main/java/world/bentobox/boxed/objects/IslandAdvancements.java @@ -22,7 +22,7 @@ public class IslandAdvancements implements DataObject { List advancements = new ArrayList<>(); /** - * @param uniqueId + * @param uniqueId unique ID */ public IslandAdvancements(String uniqueId) { this.uniqueId = uniqueId; diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index f0a3548..89b0023 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -1,4 +1,4 @@ -name: Boxed +name: Pladdon main: world.bentobox.boxed.BoxedPladdon version: ${version} api-version: 1.17 diff --git a/src/test/java/world/bentobox/boxed/SettingsTest.java b/src/test/java/world/bentobox/boxed/SettingsTest.java new file mode 100644 index 0000000..ff26151 --- /dev/null +++ b/src/test/java/world/bentobox/boxed/SettingsTest.java @@ -0,0 +1,421 @@ +package world.bentobox.boxed; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import java.util.Collections; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import org.bukkit.Difficulty; +import org.bukkit.GameMode; +import org.bukkit.entity.EntityType; +import org.junit.Before; +import org.junit.Test; + +/** + * @author tastybento + * + */ +public class SettingsTest { + + Settings s; + + @Before + public void setUp() { + s = new Settings(); + } + /** + * Test method for {@link world.bentobox.boxed.Settings#setFriendlyName(java.lang.String)}. + */ + @Test + public void testSetFriendlyName() { + s.setFriendlyName("name"); + assertEquals("name", s.getFriendlyName()); + } + + /** + * Test method for {@link world.bentobox.boxed.Settings#setWorldName(java.lang.String)}. + */ + @Test + public void testSetWorldName() { + s.setWorldName("name"); + assertEquals("name", s.getWorldName()); + } + + /** + * Test method for {@link world.bentobox.boxed.Settings#setDifficulty(org.bukkit.Difficulty)}. + */ + @Test + public void testSetDifficulty() { + s.setDifficulty(Difficulty.PEACEFUL); + assertEquals(Difficulty.PEACEFUL, s.getDifficulty()); + } + + /** + * Test method for {@link world.bentobox.boxed.Settings#setIslandDistance(int)}. + */ + @Test + public void testSetIslandDistance() { + s.setIslandDistance(123); + assertEquals(123, s.getIslandDistance()); + } + + /** + * Test method for {@link world.bentobox.boxed.Settings#setIslandProtectionRange(int)}. + */ + @Test + public void testSetIslandProtectionRange() { + s.setIslandProtectionRange(123); + assertEquals(123, s.getIslandProtectionRange()); + } + + /** + * Test method for {@link world.bentobox.boxed.Settings#setIslandStartX(int)}. + */ + @Test + public void testSetIslandStartX() { + s.setIslandStartX(123); + assertEquals(123, s.getIslandStartX()); + } + + /** + * Test method for {@link world.bentobox.boxed.Settings#setIslandStartZ(int)}. + */ + @Test + public void testSetIslandStartZ() { + s.setIslandStartZ(123); + assertEquals(123, s.getIslandStartZ()); + } + + /** + * Test method for {@link world.bentobox.boxed.Settings#setIslandHeight(int)}. + */ + @Test + public void testSetIslandHeight() { + s.setIslandHeight(123); + assertEquals(123, s.getIslandHeight()); + } + + /** + * Test method for {@link world.bentobox.boxed.Settings#setMaxIslands(int)}. + */ + @Test + public void testSetMaxIslands() { + s.setMaxIslands(123); + assertEquals(123, s.getMaxIslands()); + } + + /** + * Test method for {@link world.bentobox.boxed.Settings#setDefaultGameMode(org.bukkit.GameMode)}. + */ + @Test + public void testSetDefaultGameMode() { + s.setDefaultGameMode(GameMode.CREATIVE); + assertEquals(GameMode.CREATIVE, s.getDefaultGameMode()); + } + + /** + * Test method for {@link world.bentobox.boxed.Settings#setNetherGenerate(boolean)}. + */ + @Test + public void testSetNetherGenerate() { + s.setNetherGenerate(true); + assertTrue(s.isNetherGenerate()); + } + + /** + * Test method for {@link world.bentobox.boxed.Settings#setNetherSpawnRadius(int)}. + */ + @Test + public void testSetNetherSpawnRadius() { + s.setNetherSpawnRadius(123); + assertEquals(123, s.getNetherSpawnRadius()); + } + + /** + * Test method for {@link world.bentobox.boxed.Settings#setEndGenerate(boolean)}. + */ + @Test + public void testSetEndGenerate() { + s.setEndGenerate(true); + assertTrue(s.isEndGenerate()); + } + + /** + * Test method for {@link world.bentobox.boxed.Settings#setRemoveMobsWhitelist(java.util.Set)}. + */ + @Test + public void testSetRemoveMobsWhitelist() { + Set wl = Collections.emptySet(); + s.setRemoveMobsWhitelist(wl); + assertEquals(wl, s.getRemoveMobsWhitelist()); + } + + /** + * Test method for {@link world.bentobox.boxed.Settings#setWorldFlags(java.util.Map)}. + */ + @Test + public void testSetWorldFlags() { + Map worldFlags = Collections.emptyMap(); + s.setWorldFlags(worldFlags); + assertEquals(worldFlags, s.getWorldFlags()); + } + + /** + * Test method for {@link world.bentobox.boxed.Settings#setHiddenFlags(java.util.List)}. + */ + @Test + public void testSetVisibleSettings() { + List visibleSettings = Collections.emptyList(); + s.setHiddenFlags(visibleSettings); + assertEquals(visibleSettings, s.getHiddenFlags()); + } + + /** + * Test method for {@link world.bentobox.boxed.Settings#setVisitorBannedCommands(java.util.List)}. + */ + @Test + public void testSetVisitorBannedCommands() { + List visitorBannedCommands = Collections.emptyList(); + s.setVisitorBannedCommands(visitorBannedCommands); + assertEquals(visitorBannedCommands, s.getVisitorBannedCommands()); + } + + /** + * Test method for {@link world.bentobox.boxed.Settings#setMaxTeamSize(int)}. + */ + @Test + public void testSetMaxTeamSize() { + s.setMaxTeamSize(123); + assertEquals(123, s.getMaxTeamSize()); + } + + /** + * Test method for {@link world.bentobox.boxed.Settings#setMaxHomes(int)}. + */ + @Test + public void testSetMaxHomes() { + s.setMaxHomes(123); + assertEquals(123, s.getMaxHomes()); + } + + /** + * Test method for {@link world.bentobox.boxed.Settings#setResetLimit(int)}. + */ + @Test + public void testSetResetLimit() { + s.setResetLimit(123); + assertEquals(123, s.getResetLimit()); + } + + /** + * Test method for {@link world.bentobox.boxed.Settings#setLeaversLoseReset(boolean)}. + */ + @Test + public void testSetLeaversLoseReset() { + s.setLeaversLoseReset(true); + assertTrue(s.isLeaversLoseReset()); + } + + /** + * Test method for {@link world.bentobox.boxed.Settings#setKickedKeepInventory(boolean)}. + */ + @Test + public void testSetKickedKeepInventory() { + s.setKickedKeepInventory(true); + assertTrue(s.isKickedKeepInventory()); + } + + /** + * Test method for {@link world.bentobox.boxed.Settings#setOnJoinResetMoney(boolean)}. + */ + @Test + public void testSetOnJoinResetMoney() { + s.setOnJoinResetMoney(true); + assertTrue(s.isOnJoinResetMoney()); + } + + /** + * Test method for {@link world.bentobox.boxed.Settings#setOnJoinResetInventory(boolean)}. + */ + @Test + public void testSetOnJoinResetInventory() { + s.setOnJoinResetInventory(true); + assertTrue(s.isOnJoinResetInventory()); + } + + /** + * Test method for {@link world.bentobox.boxed.Settings#setOnJoinResetEnderChest(boolean)}. + */ + @Test + public void testSetOnJoinResetEnderChest() { + s.setOnJoinResetEnderChest(true); + assertTrue(s.isOnJoinResetEnderChest()); + } + + /** + * Test method for {@link world.bentobox.boxed.Settings#setOnLeaveResetMoney(boolean)}. + */ + @Test + public void testSetOnLeaveResetMoney() { + s.setOnLeaveResetMoney(true); + assertTrue(s.isOnLeaveResetMoney()); + } + + /** + * Test method for {@link world.bentobox.boxed.Settings#setOnLeaveResetInventory(boolean)}. + */ + @Test + public void testSetOnLeaveResetInventory() { + s.setOnLeaveResetInventory(true); + assertTrue(s.isOnLeaveResetInventory()); + } + + /** + * Test method for {@link world.bentobox.boxed.Settings#setOnLeaveResetEnderChest(boolean)}. + */ + @Test + public void testSetOnLeaveResetEnderChest() { + s.setOnLeaveResetEnderChest(true); + assertTrue(s.isOnLeaveResetEnderChest()); + } + + /** + * Test method for {@link world.bentobox.boxed.Settings#setDeathsCounted(boolean)}. + */ + @Test + public void testSetDeathsCounted() { + s.setDeathsCounted(true); + assertTrue(s.isDeathsCounted()); + } + + /** + * Test method for {@link world.bentobox.boxed.Settings#setDeathsMax(int)}. + */ + @Test + public void testSetDeathsMax() { + s.setDeathsMax(123); + assertEquals(123, s.getDeathsMax()); + } + + /** + * Test method for {@link world.bentobox.boxed.Settings#setTeamJoinDeathReset(boolean)}. + */ + @Test + public void testSetTeamJoinDeathReset() { + s.setTeamJoinDeathReset(true); + assertTrue(s.isTeamJoinDeathReset()); + } + + /** + * Test method for {@link world.bentobox.boxed.Settings#setGeoLimitSettings(java.util.List)}. + */ + @Test + public void testSetGeoLimitSettings() { + List geoLimitSettings = Collections.emptyList(); + s.setGeoLimitSettings(geoLimitSettings); + assertEquals(geoLimitSettings, s.getGeoLimitSettings()); + } + + /** + * Test method for {@link world.bentobox.boxed.Settings#setIvSettings(java.util.List)}. + */ + @Test + public void testSetIvSettings() { + List ivSettings = Collections.emptyList(); + s.setIvSettings(ivSettings); + assertEquals(ivSettings, s.getIvSettings()); + } + + /** + * Test method for {@link world.bentobox.boxed.Settings#setAllowSetHomeInNether(boolean)}. + */ + @Test + public void testSetAllowSetHomeInNether() { + s.setAllowSetHomeInNether(true); + assertTrue(s.isAllowSetHomeInNether()); + } + + /** + * Test method for {@link world.bentobox.boxed.Settings#setAllowSetHomeInTheEnd(boolean)}. + */ + @Test + public void testSetAllowSetHomeInTheEnd() { + s.setAllowSetHomeInTheEnd(true); + assertTrue(s.isAllowSetHomeInTheEnd()); + } + + /** + * Test method for {@link world.bentobox.boxed.Settings#setRequireConfirmationToSetHomeInNether(boolean)}. + */ + @Test + public void testSetRequireConfirmationToSetHomeInNether() { + s.setRequireConfirmationToSetHomeInNether(true); + assertTrue(s.isRequireConfirmationToSetHomeInNether()); + } + + /** + * Test method for {@link world.bentobox.boxed.Settings#setRequireConfirmationToSetHomeInTheEnd(boolean)}. + */ + @Test + public void testSetRequireConfirmationToSetHomeInTheEnd() { + s.setRequireConfirmationToSetHomeInTheEnd(true); + assertTrue(s.isRequireConfirmationToSetHomeInTheEnd()); + } + + /** + * Test method for {@link world.bentobox.boxed.Settings#setResetEpoch(long)}. + */ + @Test + public void testSetResetEpoch() { + s.setResetEpoch(123); + assertEquals(123, s.getResetEpoch()); + } + + /** + * Test method for {@link world.bentobox.boxed.Settings#getPermissionPrefix()}. + */ + @Test + public void testGetPermissionPrefix() { + assertEquals("boxed", s.getPermissionPrefix()); + } + + /** + * Test method for {@link world.bentobox.boxed.Settings#isWaterUnsafe()}. + */ + @Test + public void testIsWaterUnsafe() { + assertFalse(s.isWaterUnsafe()); + } + + /** + * Test method for {@link world.bentobox.boxed.Settings#setBanLimit(int)}. + */ + @Test + public void testSetBanLimit() { + s.setBanLimit(123); + assertEquals(123, s.getBanLimit()); + } + + /** + * Test method for {@link Settings#getPlayerCommandAliases()} Command()}. + */ + @Test + public void testGetIslandCommand() { + s.setPlayerCommandAliases("island"); + assertEquals("island", s.getPlayerCommandAliases()); + } + + /** + * Test method for {@link Settings#getAdminCommandAliases()}. + */ + @Test + public void testGetAdminCommand() { + s.setAdminCommandAliases("admin"); + assertEquals("admin", s.getAdminCommandAliases()); + } + +}