mirror of
https://github.com/BentoBoxWorld/BentoBox.git
synced 2024-11-28 05:35:44 +01:00
Fills in protections.
Shulker box done. Pots done. Pufferfish are considered Monsters, not animals because they can hurt visitors. Other fish protected. Bonemeal prevented (place blocks). Name tags done. https://github.com/BentoBoxWorld/bentobox/issues/336
This commit is contained in:
parent
c2e9490bb0
commit
2ca00969e7
@ -31,10 +31,17 @@ public class BlockInteractionListener extends FlagListener {
|
||||
|
||||
// Now check for in-hand items
|
||||
if (e.getItem() != null) {
|
||||
if (e.getItem().getType().name().contains("BOAT")) {
|
||||
checkIsland(e, e.getClickedBlock().getLocation(), Flags.PLACE_BLOCKS);
|
||||
return;
|
||||
}
|
||||
switch (e.getItem().getType()) {
|
||||
case ENDER_PEARL:
|
||||
checkIsland(e, e.getClickedBlock().getLocation(), Flags.ENDER_PEARL);
|
||||
break;
|
||||
case BONE_MEAL:
|
||||
checkIsland(e, e.getClickedBlock().getLocation(), Flags.PLACE_BLOCKS);
|
||||
break;
|
||||
case BAT_SPAWN_EGG:
|
||||
case BLAZE_SPAWN_EGG:
|
||||
case CAVE_SPIDER_SPAWN_EGG:
|
||||
@ -102,6 +109,11 @@ public class BlockInteractionListener extends FlagListener {
|
||||
* @param type - material type of clicked block
|
||||
*/
|
||||
private void checkClickedBlock(Event e, Location loc, Material type) {
|
||||
// Handle pots
|
||||
if (type.name().startsWith("POTTED")) {
|
||||
checkIsland(e, loc, Flags.CHEST);
|
||||
return;
|
||||
}
|
||||
switch (type) {
|
||||
case ANVIL:
|
||||
checkIsland(e, loc, Flags.ANVIL);
|
||||
@ -150,6 +162,8 @@ public class BlockInteractionListener extends FlagListener {
|
||||
case LIGHT_GRAY_SHULKER_BOX:
|
||||
case WHITE_SHULKER_BOX:
|
||||
case YELLOW_SHULKER_BOX:
|
||||
case SHULKER_BOX:
|
||||
case FLOWER_POT:
|
||||
case DISPENSER:
|
||||
case DROPPER:
|
||||
case HOPPER:
|
||||
|
@ -20,7 +20,10 @@ public class ChestDamageListener extends FlagListener {
|
||||
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
||||
public void onExplosion(final EntityExplodeEvent e) {
|
||||
if (getIWM().inWorld(e.getLocation()) && !Flags.CHEST_DAMAGE.isSetForWorld(e.getLocation().getWorld())) {
|
||||
e.blockList().removeIf(b -> b.getType().equals(Material.CHEST) || b.getType().equals(Material.TRAPPED_CHEST));
|
||||
e.blockList().removeIf(b -> b.getType().equals(Material.CHEST)
|
||||
|| b.getType().equals(Material.TRAPPED_CHEST)
|
||||
|| b.getType().name().contains("SHULKER_BOX")
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package world.bentobox.bentobox.listeners.flags;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Animals;
|
||||
import org.bukkit.entity.ArmorStand;
|
||||
import org.bukkit.entity.EntityType;
|
||||
@ -37,5 +38,9 @@ public class EntityInteractListener extends FlagListener {
|
||||
if (e.getRightClicked().getType().equals(EntityType.VILLAGER)) {
|
||||
checkIsland(e, e.getRightClicked().getLocation(), Flags.TRADING);
|
||||
}
|
||||
// Name tags
|
||||
if (e.getPlayer().getInventory().getItemInMainHand().getType().equals(Material.NAME_TAG)) {
|
||||
checkIsland(e, e.getRightClicked().getLocation(), Flags.PLACE_BLOCKS);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -6,12 +6,14 @@ import java.util.UUID;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Animals;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Fish;
|
||||
import org.bukkit.entity.IronGolem;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Monster;
|
||||
import org.bukkit.entity.Parrot;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Projectile;
|
||||
import org.bukkit.entity.PufferFish;
|
||||
import org.bukkit.entity.Slime;
|
||||
import org.bukkit.entity.Snowman;
|
||||
import org.bukkit.entity.Squid;
|
||||
@ -27,8 +29,8 @@ import org.bukkit.event.player.PlayerInteractEntityEvent;
|
||||
import org.bukkit.inventory.EquipmentSlot;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
|
||||
import world.bentobox.bentobox.api.flags.FlagListener;
|
||||
import world.bentobox.bentobox.api.flags.Flag;
|
||||
import world.bentobox.bentobox.api.flags.FlagListener;
|
||||
import world.bentobox.bentobox.api.user.User;
|
||||
import world.bentobox.bentobox.lists.Flags;
|
||||
|
||||
@ -49,11 +51,13 @@ public class HurtingListener extends FlagListener {
|
||||
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
||||
public void onEntityDamage(final EntityDamageByEntityEvent e) {
|
||||
// Mobs being hurt
|
||||
if (e.getEntity() instanceof Animals || e.getEntity() instanceof IronGolem || e.getEntity() instanceof Snowman) {
|
||||
if (e.getEntity() instanceof Animals || e.getEntity() instanceof IronGolem || e.getEntity() instanceof Snowman
|
||||
|| (e.getEntity() instanceof Fish && !(e.getEntity() instanceof PufferFish))) {
|
||||
respond(e, e.getDamager(), Flags.HURT_ANIMALS);
|
||||
} else if (e.getEntity() instanceof Villager) {
|
||||
respond(e, e.getDamager(), Flags.HURT_VILLAGERS);
|
||||
} else if (e.getEntity() instanceof Monster || e.getEntity() instanceof Squid || e.getEntity() instanceof Slime) {
|
||||
} else if (e.getEntity() instanceof Monster || e.getEntity() instanceof Squid
|
||||
|| e.getEntity() instanceof Slime || e.getEntity() instanceof PufferFish) {
|
||||
respond(e, e.getDamager(), Flags.HURT_MONSTERS);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user