Removed enderman death drop flag. 1.13 drops blocks anyway.

This commit is contained in:
tastybento 2018-08-25 12:27:21 -07:00
parent 9e2c2c7dbc
commit 06f7b754b7
3 changed files with 0 additions and 96 deletions

View File

@ -3,14 +3,10 @@
*/ */
package world.bentobox.bentobox.listeners.flags; package world.bentobox.bentobox.listeners.flags;
import org.bukkit.Material;
import org.bukkit.block.data.BlockData;
import org.bukkit.entity.Enderman; import org.bukkit.entity.Enderman;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
import org.bukkit.event.entity.EntityChangeBlockEvent; import org.bukkit.event.entity.EntityChangeBlockEvent;
import org.bukkit.event.entity.EntityDeathEvent;
import org.bukkit.inventory.ItemStack;
import world.bentobox.bentobox.api.flags.AbstractFlagListener; import world.bentobox.bentobox.api.flags.AbstractFlagListener;
import world.bentobox.bentobox.lists.Flags; import world.bentobox.bentobox.lists.Flags;
@ -36,25 +32,4 @@ public class EndermanListener extends AbstractFlagListener {
} }
} }
/**
* Drops the Enderman's block when he dies if he has one
*
* @param e - event
*/
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onEndermanDeath(final EntityDeathEvent e) {
if (!(e.getEntity() instanceof Enderman)
|| !getIWM().inWorld(e.getEntity().getLocation())
|| !Flags.ENDERMAN_DEATH_DROP.isSetForWorld(e.getEntity().getWorld())) {
return;
}
// Get the block the enderman is holding
Enderman ender = (Enderman) e.getEntity();
BlockData m = ender.getCarriedBlock();
if (m != null && !m.getMaterial().equals(Material.AIR)) {
// Drop the item
e.getEntity().getWorld().dropItemNaturally(e.getEntity().getLocation(), new ItemStack(m.getMaterial()));
}
}
} }

View File

@ -176,10 +176,6 @@ public class Flags {
.listener(new EndermanListener()) .listener(new EndermanListener())
.build(); .build();
public static final Flag ENDERMAN_DEATH_DROP = new FlagBuilder().id("ENDERMAN_DEATH_DROP").icon(Material.END_ROD)
.allowedByDefault(true).type(Type.WORLD_SETTING)
.build();
public static final Flag ENTER_EXIT_MESSAGES = new FlagBuilder().id("ENTER_EXIT_MESSAGES").icon(Material.DIRT).allowedByDefault(true).type(Type.WORLD_SETTING) public static final Flag ENTER_EXIT_MESSAGES = new FlagBuilder().id("ENTER_EXIT_MESSAGES").icon(Material.DIRT).allowedByDefault(true).type(Type.WORLD_SETTING)
.listener(new EnterExitListener()) .listener(new EnterExitListener())
.build(); .build();

View File

@ -9,7 +9,6 @@ import static org.mockito.Matchers.any;
import static org.mockito.Mockito.mock; import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when; import static org.mockito.Mockito.when;
import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.Map; import java.util.Map;
@ -26,7 +25,6 @@ import org.bukkit.block.data.BlockData;
import org.bukkit.entity.Enderman; import org.bukkit.entity.Enderman;
import org.bukkit.entity.Slime; import org.bukkit.entity.Slime;
import org.bukkit.event.entity.EntityChangeBlockEvent; import org.bukkit.event.entity.EntityChangeBlockEvent;
import org.bukkit.event.entity.EntityDeathEvent;
import org.bukkit.inventory.ItemFactory; import org.bukkit.inventory.ItemFactory;
import org.bukkit.inventory.meta.SkullMeta; import org.bukkit.inventory.meta.SkullMeta;
import org.bukkit.plugin.PluginManager; import org.bukkit.plugin.PluginManager;
@ -137,9 +135,6 @@ public class EndermanListenerTest {
when(Util.getWorld(Mockito.any())).thenReturn(mock(World.class)); when(Util.getWorld(Mockito.any())).thenReturn(mock(World.class));
// Not allowed to start // Not allowed to start
Flags.ENDERMAN_GRIEFING.setSetting(world, false); Flags.ENDERMAN_GRIEFING.setSetting(world, false);
// Allowed to start
Flags.ENDERMAN_DEATH_DROP.setSetting(world, true);
} }
@ -197,66 +192,4 @@ public class EndermanListenerTest {
assertTrue(e.isCancelled()); assertTrue(e.isCancelled());
} }
/**
* Test method for {@link world.bentobox.bentobox.listeners.flags.EndermanListener#onEndermanDeath(org.bukkit.event.entity.EntityDeathEvent)}.
*/
@Test
public void testOnNotEndermanDeath() {
EndermanListener listener = new EndermanListener();
EntityDeathEvent e = new EntityDeathEvent(slime, new ArrayList<>());
listener.onEndermanDeath(e);
Mockito.verify(world, Mockito.never()).dropItemNaturally(Mockito.any(), Mockito.any());
}
/**
* Test method for {@link world.bentobox.bentobox.listeners.flags.EndermanListener#onEndermanDeath(org.bukkit.event.entity.EntityDeathEvent)}.
*/
@Test
public void testOnEndermanDeathCarryAir() {
when(bd.getMaterial()).thenReturn(Material.AIR);
EndermanListener listener = new EndermanListener();
EntityDeathEvent e = new EntityDeathEvent(enderman, new ArrayList<>());
listener.onEndermanDeath(e);
Mockito.verify(world, Mockito.never()).dropItemNaturally(Mockito.any(), Mockito.any());
}
/**
* Test method for {@link world.bentobox.bentobox.listeners.flags.EndermanListener#onEndermanDeath(org.bukkit.event.entity.EntityDeathEvent)}.
*/
@Test
public void testOnEndermanDeathNotInWorld() {
when(iwm.inWorld(Mockito.any())).thenReturn(false);
EndermanListener listener = new EndermanListener();
EntityDeathEvent e = new EntityDeathEvent(enderman, new ArrayList<>());
listener.onEndermanDeath(e);
Mockito.verify(world, Mockito.never()).dropItemNaturally(Mockito.any(), Mockito.any());
}
/**
* Test method for {@link world.bentobox.bentobox.listeners.flags.EndermanListener#onEndermanDeath(org.bukkit.event.entity.EntityDeathEvent)}.
*/
@Test
public void testOnEndermanDeathNoFlag() {
Flags.ENDERMAN_DEATH_DROP.setSetting(world, false);
EndermanListener listener = new EndermanListener();
EntityDeathEvent e = new EntityDeathEvent(enderman, new ArrayList<>());
listener.onEndermanDeath(e);
Mockito.verify(world, Mockito.never()).dropItemNaturally(Mockito.any(), Mockito.any());
}
/**
* Test method for {@link world.bentobox.bentobox.listeners.flags.EndermanListener#onEndermanDeath(org.bukkit.event.entity.EntityDeathEvent)}.
*/
@Test
public void testOnEndermanDeath() {
EndermanListener listener = new EndermanListener();
EntityDeathEvent e = new EntityDeathEvent(enderman, new ArrayList<>());
listener.onEndermanDeath(e);
Mockito.verify(world).dropItemNaturally(Mockito.any(), Mockito.any());
}
} }