From 8b79ce3b3e9b5edbeb1ee4c7c91a7ee843295cdf Mon Sep 17 00:00:00 2001 From: tastybento Date: Sat, 6 Jul 2019 22:52:48 -0700 Subject: [PATCH] Removes nether trees (#822) https://github.com/BentoBoxWorld/BentoBox/issues/746 NOTE: The settings will need to be removed from the game mode addons too otherwise it will be confusing to admins. --- .../world/bentobox/bentobox/BentoBox.java | 3 -- .../api/configuration/WorldSettings.java | 5 -- .../listeners/NetherTreesListener.java | 50 ------------------- .../bentobox/managers/IslandWorldManager.java | 10 ---- .../listeners/NetherTreesListenerTest.java | 49 ------------------ .../managers/IslandWorldManagerTest.java | 16 ------ .../bentobox/managers/PlayersManagerTest.java | 4 -- 7 files changed, 137 deletions(-) delete mode 100644 src/main/java/world/bentobox/bentobox/listeners/NetherTreesListener.java delete mode 100644 src/test/java/world/bentobox/bentobox/listeners/NetherTreesListenerTest.java diff --git a/src/main/java/world/bentobox/bentobox/BentoBox.java b/src/main/java/world/bentobox/bentobox/BentoBox.java index 562a85753..bba3a2094 100644 --- a/src/main/java/world/bentobox/bentobox/BentoBox.java +++ b/src/main/java/world/bentobox/bentobox/BentoBox.java @@ -28,7 +28,6 @@ import world.bentobox.bentobox.listeners.BannedVisitorCommands; import world.bentobox.bentobox.listeners.BlockEndDragon; import world.bentobox.bentobox.listeners.DeathListener; import world.bentobox.bentobox.listeners.JoinLeaveListener; -import world.bentobox.bentobox.listeners.NetherTreesListener; import world.bentobox.bentobox.listeners.PanelListenerManager; import world.bentobox.bentobox.listeners.PortalTeleportationListener; import world.bentobox.bentobox.listeners.StandardSpawnProtectionListener; @@ -232,8 +231,6 @@ public class BentoBox extends JavaPlugin { manager.registerEvents(new StandardSpawnProtectionListener(this), this); // Nether portals manager.registerEvents(new PortalTeleportationListener(this), this); - // Nether trees conversion - manager.registerEvents(new NetherTreesListener(this), this); // End dragon blocking manager.registerEvents(new BlockEndDragon(this), this); // Banned visitor commands diff --git a/src/main/java/world/bentobox/bentobox/api/configuration/WorldSettings.java b/src/main/java/world/bentobox/bentobox/api/configuration/WorldSettings.java index 395cf093f..a44dda6c7 100644 --- a/src/main/java/world/bentobox/bentobox/api/configuration/WorldSettings.java +++ b/src/main/java/world/bentobox/bentobox/api/configuration/WorldSettings.java @@ -171,11 +171,6 @@ public interface WorldSettings extends ConfigObject { */ boolean isNetherIslands(); - /** - * @return the netherTrees - */ - boolean isNetherTrees(); - /** * @return the onJoinResetEnderChest */ diff --git a/src/main/java/world/bentobox/bentobox/listeners/NetherTreesListener.java b/src/main/java/world/bentobox/bentobox/listeners/NetherTreesListener.java deleted file mode 100644 index 1ad629cb9..000000000 --- a/src/main/java/world/bentobox/bentobox/listeners/NetherTreesListener.java +++ /dev/null @@ -1,50 +0,0 @@ -package world.bentobox.bentobox.listeners; - -import org.bukkit.Material; -import org.bukkit.Tag; -import org.bukkit.World; -import org.bukkit.block.BlockState; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.bukkit.event.Listener; -import org.bukkit.event.world.StructureGrowEvent; -import org.eclipse.jdt.annotation.NonNull; - -import world.bentobox.bentobox.BentoBox; -import world.bentobox.bentobox.api.configuration.WorldSettings; - -/** - * Handles conversion of trees in the Nether if {@link WorldSettings#isNetherTrees()} is {@code true}. - * - * @author tastybento - */ -public class NetherTreesListener implements Listener { - - private BentoBox plugin; - - public NetherTreesListener(@NonNull BentoBox plugin) { - this.plugin = plugin; - } - - /** - * Converts trees to gravel and glowstone. - * - * @param e event - */ - @EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) - public void onTreeGrow(StructureGrowEvent e) { - // Don't do anything if we're not in the right place. - if (!plugin.getIWM().isNetherTrees(e.getWorld()) || !e.getWorld().getEnvironment().equals(World.Environment.NETHER)) { - return; - } - - // Modify everything! - for (BlockState b : e.getBlocks()) { - if (Tag.LOGS.isTagged(b.getType())) { - b.setType(Material.GRAVEL); - } else if (Tag.LEAVES.isTagged(b.getType())) { - b.setType(Material.GLOWSTONE); - } - } - } -} diff --git a/src/main/java/world/bentobox/bentobox/managers/IslandWorldManager.java b/src/main/java/world/bentobox/bentobox/managers/IslandWorldManager.java index fdea04604..757ab7a64 100644 --- a/src/main/java/world/bentobox/bentobox/managers/IslandWorldManager.java +++ b/src/main/java/world/bentobox/bentobox/managers/IslandWorldManager.java @@ -416,16 +416,6 @@ public class IslandWorldManager { return null; } - /** - * Check if nether trees should be created in the nether or not - * - * @param world - world - * @return true or false - */ - public boolean isNetherTrees(@Nullable World world) { - return world != null && (gameModes.containsKey(world) && gameModes.get(world).getWorldSettings().isNetherTrees()); - } - /** * Whether the End Dragon can spawn or not in this world * diff --git a/src/test/java/world/bentobox/bentobox/listeners/NetherTreesListenerTest.java b/src/test/java/world/bentobox/bentobox/listeners/NetherTreesListenerTest.java deleted file mode 100644 index bdecbeb9d..000000000 --- a/src/test/java/world/bentobox/bentobox/listeners/NetherTreesListenerTest.java +++ /dev/null @@ -1,49 +0,0 @@ -package world.bentobox.bentobox.listeners; - -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -import org.junit.Before; -import org.junit.Ignore; -import org.junit.runner.RunWith; -import org.powermock.core.classloader.annotations.PrepareForTest; -import org.powermock.modules.junit4.PowerMockRunner; -import org.powermock.reflect.Whitebox; - -import world.bentobox.bentobox.BentoBox; -import world.bentobox.bentobox.managers.IslandWorldManager; - -/** - * Tests {@link NetherTreesListener}. - * - * @author Poslovitch - * @since 1.3.0 - */ -@Ignore -@RunWith(PowerMockRunner.class) -@PrepareForTest({BentoBox.class}) -public class NetherTreesListenerTest { - - /* Plugin */ - private BentoBox plugin; - - /* Island World Manager */ - private IslandWorldManager iwm; - - /* Listener */ - private NetherTreesListener listener; - - @Before - public void setUp() { - /* Plugin */ - plugin = mock(BentoBox.class); - Whitebox.setInternalState(BentoBox.class, "instance", plugin); - - /* Island World Manager */ - iwm = mock(IslandWorldManager.class); - when(plugin.getIWM()).thenReturn(iwm); - - /* Listener */ - listener = new NetherTreesListener(plugin); - } -} diff --git a/src/test/java/world/bentobox/bentobox/managers/IslandWorldManagerTest.java b/src/test/java/world/bentobox/bentobox/managers/IslandWorldManagerTest.java index 7ec4511eb..86a5682b9 100644 --- a/src/test/java/world/bentobox/bentobox/managers/IslandWorldManagerTest.java +++ b/src/test/java/world/bentobox/bentobox/managers/IslandWorldManagerTest.java @@ -402,22 +402,6 @@ public class IslandWorldManagerTest { assertNull(iwm.getEndWorld(null)); } - /** - * Test method for {@link world.bentobox.bentobox.managers.IslandWorldManager#isNetherTrees(org.bukkit.World)}. - */ - @Test - public void testIsNetherTrees() { - assertFalse(iwm.isNetherTrees(netherWorld)); - } - - /** - * Test method for {@link world.bentobox.bentobox.managers.IslandWorldManager#isNetherTrees(org.bukkit.World)}. - */ - @Test - public void testIsNetherTreesNull() { - assertFalse(iwm.isNetherTrees(null)); - } - /** * Test method for {@link world.bentobox.bentobox.managers.IslandWorldManager#isDragonSpawn(org.bukkit.World)}. */ diff --git a/src/test/java/world/bentobox/bentobox/managers/PlayersManagerTest.java b/src/test/java/world/bentobox/bentobox/managers/PlayersManagerTest.java index 99341c2af..518acd55e 100644 --- a/src/test/java/world/bentobox/bentobox/managers/PlayersManagerTest.java +++ b/src/test/java/world/bentobox/bentobox/managers/PlayersManagerTest.java @@ -1,6 +1,3 @@ -/** - * - */ package world.bentobox.bentobox.managers; import static org.junit.Assert.assertEquals; @@ -32,7 +29,6 @@ import org.junit.After; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; -import org.mockito.Mock; import org.mockito.Mockito; import org.powermock.api.mockito.PowerMockito; import org.powermock.core.classloader.annotations.PrepareForTest;