diff --git a/src/main/java/world/bentobox/acidisland/AcidIsland.java b/src/main/java/world/bentobox/acidisland/AcidIsland.java index e254e4f..1f05cb0 100644 --- a/src/main/java/world/bentobox/acidisland/AcidIsland.java +++ b/src/main/java/world/bentobox/acidisland/AcidIsland.java @@ -27,6 +27,7 @@ public class AcidIsland extends GameModeAddon { private AISettings settings; private AcidTask acidTask; private @NonNull ChunkGenerator chunkGenerator; + private Config config = new Config<>(this, AISettings.class); private static final String NETHER = "_nether"; private static final String THE_END = "_the_end"; @@ -45,7 +46,7 @@ public class AcidIsland extends GameModeAddon { } private boolean loadSettings() { - settings = new Config<>(this, AISettings.class).loadConfigObject(); + settings = config.loadConfigObject(); if (settings == null) { // Woops this.logError("AcidIsland settings could not load! Addon disabled."); @@ -65,6 +66,11 @@ public class AcidIsland extends GameModeAddon { if (settings == null) { return; } + // Set default access to boats + Flags.BOAT.setDefaultSetting(islandWorld, true); + if (netherWorld != null) Flags.BOAT.setDefaultSetting(netherWorld, true); + if (endWorld != null) Flags.BOAT.setDefaultSetting(endWorld, true); + // Register listeners // Acid Effects registerListener(new AcidEffect(this)); @@ -92,6 +98,9 @@ public class AcidIsland extends GameModeAddon { getPlugin().log(string); } + /* (non-Javadoc) + * @see world.bentobox.bentobox.api.addons.GameModeAddon#createWorlds() + */ @Override public void createWorlds() { String worldName = settings.getWorldName().toLowerCase(); @@ -102,8 +111,6 @@ public class AcidIsland extends GameModeAddon { chunkGenerator = new ChunkGeneratorWorld(this); islandWorld = WorldCreator.name(worldName).type(WorldType.FLAT).environment(World.Environment.NORMAL).generator(chunkGenerator) .createWorld(); - // Set default access to boats - Flags.BOAT.setDefaultSetting(islandWorld, true); // Make the nether if it does not exist if (settings.isNetherGenerate()) { if (getServer().getWorld(worldName + NETHER) == null) { @@ -111,7 +118,7 @@ public class AcidIsland extends GameModeAddon { } if (!settings.isNetherIslands()) { netherWorld = WorldCreator.name(worldName + NETHER).type(WorldType.NORMAL).environment(World.Environment.NETHER).createWorld(); - Flags.BOAT.setDefaultSetting(netherWorld, true); + } else { netherWorld = WorldCreator.name(worldName + NETHER).type(WorldType.FLAT).generator(chunkGenerator) .environment(World.Environment.NETHER).createWorld(); @@ -124,7 +131,6 @@ public class AcidIsland extends GameModeAddon { } if (!settings.isEndIslands()) { endWorld = WorldCreator.name(worldName + THE_END).type(WorldType.NORMAL).environment(World.Environment.THE_END).createWorld(); - Flags.BOAT.setDefaultSetting(endWorld, true); } else { endWorld = WorldCreator.name(worldName + THE_END).type(WorldType.FLAT).generator(chunkGenerator) .environment(World.Environment.THE_END).createWorld(); @@ -152,7 +158,7 @@ public class AcidIsland extends GameModeAddon { @Override public void saveWorldSettings() { if (settings != null) { - new Config<>(this, AISettings.class).saveConfigObject(settings); + config.saveConfigObject(settings); } } diff --git a/src/test/java/world/bentobox/acidisland/commands/AiCommandTest.java b/src/test/java/world/bentobox/acidisland/commands/AiCommandTest.java index ad06149..96b3cbc 100644 --- a/src/test/java/world/bentobox/acidisland/commands/AiCommandTest.java +++ b/src/test/java/world/bentobox/acidisland/commands/AiCommandTest.java @@ -16,6 +16,8 @@ import java.util.UUID; import org.bukkit.Bukkit; import org.bukkit.entity.Player; +import org.bukkit.plugin.PluginManager; +import org.bukkit.scheduler.BukkitScheduler; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @@ -29,6 +31,7 @@ import org.powermock.reflect.Whitebox; import world.bentobox.acidisland.AISettings; import world.bentobox.acidisland.AcidIsland; import world.bentobox.bentobox.BentoBox; +import world.bentobox.bentobox.Settings; import world.bentobox.bentobox.api.localization.TextVariables; import world.bentobox.bentobox.api.user.User; import world.bentobox.bentobox.blueprints.dataobjects.BlueprintBundle; @@ -81,6 +84,9 @@ public class AiCommandTest { IslandWorldManager iwm = mock(IslandWorldManager.class); when(plugin.getIWM()).thenReturn(iwm); + // Settings + Settings s = mock(Settings.class); + when(plugin.getSettings()).thenReturn(s); // Player has island to begin with im = mock(IslandsManager.class); @@ -108,7 +114,13 @@ public class AiCommandTest { when(bun.isRequirePermission()).thenReturn(true); when(bpm.getBlueprintBundles(Mockito.any())).thenReturn(map); when(plugin.getBlueprintsManager()).thenReturn(bpm); + + // Bukkit PowerMockito.mockStatic(Bukkit.class); + PluginManager pim = mock(PluginManager.class); + when(Bukkit.getPluginManager()).thenReturn(pim); + BukkitScheduler sch = mock(BukkitScheduler.class); + when(Bukkit.getScheduler()).thenReturn(sch); }