mirror of
https://github.com/BentoBoxWorld/BentoBox.git
synced 2024-12-27 11:37:36 +01:00
Removed enderman death drop flag. 1.13 drops blocks anyway.
This commit is contained in:
parent
9e2c2c7dbc
commit
06f7b754b7
@ -3,14 +3,10 @@
|
||||
*/
|
||||
package world.bentobox.bentobox.listeners.flags;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
import org.bukkit.entity.Enderman;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
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.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()));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -176,10 +176,6 @@ public class Flags {
|
||||
.listener(new EndermanListener())
|
||||
.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)
|
||||
.listener(new EnterExitListener())
|
||||
.build();
|
||||
|
@ -9,7 +9,6 @@ import static org.mockito.Matchers.any;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
@ -26,7 +25,6 @@ import org.bukkit.block.data.BlockData;
|
||||
import org.bukkit.entity.Enderman;
|
||||
import org.bukkit.entity.Slime;
|
||||
import org.bukkit.event.entity.EntityChangeBlockEvent;
|
||||
import org.bukkit.event.entity.EntityDeathEvent;
|
||||
import org.bukkit.inventory.ItemFactory;
|
||||
import org.bukkit.inventory.meta.SkullMeta;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
@ -137,9 +135,6 @@ public class EndermanListenerTest {
|
||||
when(Util.getWorld(Mockito.any())).thenReturn(mock(World.class));
|
||||
// Not allowed to start
|
||||
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());
|
||||
}
|
||||
|
||||
/**
|
||||
* 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());
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user