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.
This commit is contained in:
tastybento 2019-07-06 22:52:48 -07:00 committed by Florian CUNY
parent 6634a4e1f5
commit 8b79ce3b3e
7 changed files with 0 additions and 137 deletions

View File

@ -28,7 +28,6 @@ import world.bentobox.bentobox.listeners.BannedVisitorCommands;
import world.bentobox.bentobox.listeners.BlockEndDragon; import world.bentobox.bentobox.listeners.BlockEndDragon;
import world.bentobox.bentobox.listeners.DeathListener; import world.bentobox.bentobox.listeners.DeathListener;
import world.bentobox.bentobox.listeners.JoinLeaveListener; import world.bentobox.bentobox.listeners.JoinLeaveListener;
import world.bentobox.bentobox.listeners.NetherTreesListener;
import world.bentobox.bentobox.listeners.PanelListenerManager; import world.bentobox.bentobox.listeners.PanelListenerManager;
import world.bentobox.bentobox.listeners.PortalTeleportationListener; import world.bentobox.bentobox.listeners.PortalTeleportationListener;
import world.bentobox.bentobox.listeners.StandardSpawnProtectionListener; import world.bentobox.bentobox.listeners.StandardSpawnProtectionListener;
@ -232,8 +231,6 @@ public class BentoBox extends JavaPlugin {
manager.registerEvents(new StandardSpawnProtectionListener(this), this); manager.registerEvents(new StandardSpawnProtectionListener(this), this);
// Nether portals // Nether portals
manager.registerEvents(new PortalTeleportationListener(this), this); manager.registerEvents(new PortalTeleportationListener(this), this);
// Nether trees conversion
manager.registerEvents(new NetherTreesListener(this), this);
// End dragon blocking // End dragon blocking
manager.registerEvents(new BlockEndDragon(this), this); manager.registerEvents(new BlockEndDragon(this), this);
// Banned visitor commands // Banned visitor commands

View File

@ -171,11 +171,6 @@ public interface WorldSettings extends ConfigObject {
*/ */
boolean isNetherIslands(); boolean isNetherIslands();
/**
* @return the netherTrees
*/
boolean isNetherTrees();
/** /**
* @return the onJoinResetEnderChest * @return the onJoinResetEnderChest
*/ */

View File

@ -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);
}
}
}
}

View File

@ -416,16 +416,6 @@ public class IslandWorldManager {
return null; 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 * Whether the End Dragon can spawn or not in this world
* *

View File

@ -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);
}
}

View File

@ -402,22 +402,6 @@ public class IslandWorldManagerTest {
assertNull(iwm.getEndWorld(null)); 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)}. * Test method for {@link world.bentobox.bentobox.managers.IslandWorldManager#isDragonSpawn(org.bukkit.World)}.
*/ */

View File

@ -1,6 +1,3 @@
/**
*
*/
package world.bentobox.bentobox.managers; package world.bentobox.bentobox.managers;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
@ -32,7 +29,6 @@ import org.junit.After;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.Mockito; import org.mockito.Mockito;
import org.powermock.api.mockito.PowerMockito; import org.powermock.api.mockito.PowerMockito;
import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.core.classloader.annotations.PrepareForTest;