mirror of
https://github.com/BentoBoxWorld/BentoBox.git
synced 2024-11-01 00:10:40 +01:00
Merge branch 'develop' of https://github.com/BentoBoxWorld/BentoBox.git into develop
This commit is contained in:
commit
59fd8d94b5
@ -51,7 +51,10 @@ public class HurtingListener extends FlagListener {
|
||||
public void onEntityDamage(final EntityDamageByEntityEvent e)
|
||||
{
|
||||
// Mobs being hurt
|
||||
if (Util.isPassiveEntity(e.getEntity()))
|
||||
if (Util.isTamableEntity(e.getEntity())) {
|
||||
this.respond(e, e.getDamager(), Flags.HURT_TAMED_ANIMALS);
|
||||
}
|
||||
else if (Util.isPassiveEntity(e.getEntity()))
|
||||
{
|
||||
this.respond(e, e.getDamager(), Flags.HURT_ANIMALS);
|
||||
}
|
||||
@ -92,7 +95,8 @@ public class HurtingListener extends FlagListener {
|
||||
return;
|
||||
}
|
||||
|
||||
if ((Util.isPassiveEntity(e.getCaught()) && checkIsland(e, e.getPlayer(), e.getCaught().getLocation(), Flags.HURT_ANIMALS))
|
||||
if ((Util.isTamableEntity(e.getCaught()) && checkIsland(e, e.getPlayer(), e.getCaught().getLocation(), Flags.HURT_TAMED_ANIMALS))
|
||||
|| (Util.isPassiveEntity(e.getCaught()) && checkIsland(e, e.getPlayer(), e.getCaught().getLocation(), Flags.HURT_ANIMALS))
|
||||
|| (Util.isHostileEntity(e.getCaught()) && checkIsland(e, e.getPlayer(), e.getCaught().getLocation(), Flags.HURT_MONSTERS))
|
||||
|| (e.getCaught() instanceof AbstractVillager && checkIsland(e, e.getPlayer(), e.getCaught().getLocation(), Flags.HURT_VILLAGERS))) {
|
||||
e.getHook().remove();
|
||||
@ -113,7 +117,11 @@ public class HurtingListener extends FlagListener {
|
||||
if (e.getRightClicked() instanceof Parrot
|
||||
&& (e.getHand().equals(EquipmentSlot.HAND) && e.getPlayer().getInventory().getItemInMainHand().getType().equals(Material.COOKIE))
|
||||
|| (e.getHand().equals(EquipmentSlot.OFF_HAND) && e.getPlayer().getInventory().getItemInOffHand().getType().equals(Material.COOKIE))) {
|
||||
checkIsland(e, e.getPlayer(), e.getRightClicked().getLocation(), Flags.HURT_ANIMALS);
|
||||
if (((Parrot) e.getRightClicked()).isTamed()) {
|
||||
checkIsland(e, e.getPlayer(), e.getRightClicked().getLocation(), Flags.HURT_TAMED_ANIMALS);
|
||||
} else {
|
||||
checkIsland(e, e.getPlayer(), e.getRightClicked().getLocation(), Flags.HURT_ANIMALS);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -139,6 +147,13 @@ public class HurtingListener extends FlagListener {
|
||||
}
|
||||
}
|
||||
|
||||
// Tamed animals being hurt
|
||||
if (Util.isTamableEntity(entity) && !checkIsland(e, attacker, entity.getLocation(), Flags.HURT_TAMED_ANIMALS)) {
|
||||
for (PotionEffect effect : e.getPotion().getEffects()) {
|
||||
entity.removePotionEffect(effect.getType());
|
||||
}
|
||||
}
|
||||
|
||||
// Mobs being hurt
|
||||
if (Util.isPassiveEntity(entity) && !checkIsland(e, attacker, entity.getLocation(), Flags.HURT_ANIMALS)) {
|
||||
for (PotionEffect effect : e.getPotion().getEffects()) {
|
||||
@ -189,6 +204,10 @@ public class HurtingListener extends FlagListener {
|
||||
if (Util.isHostileEntity(entity)) {
|
||||
checkIsland(e, attacker, entity.getLocation(), Flags.HURT_MONSTERS);
|
||||
}
|
||||
// Tamed animals being hurt
|
||||
if (Util.isTamableEntity(entity)) {
|
||||
checkIsland(e, attacker, entity.getLocation(), Flags.HURT_TAMED_ANIMALS);
|
||||
}
|
||||
// Mobs being hurt
|
||||
if (Util.isPassiveEntity(entity)) {
|
||||
checkIsland(e, attacker, entity.getLocation(), Flags.HURT_ANIMALS);
|
||||
|
@ -283,6 +283,7 @@ public final class Flags {
|
||||
public static final Flag HURT_ANIMALS = new Flag.Builder("HURT_ANIMALS", Material.STONE_SWORD).listener(new HurtingListener()).mode(Flag.Mode.ADVANCED).build();
|
||||
public static final Flag HURT_MONSTERS = new Flag.Builder("HURT_MONSTERS", Material.WOODEN_SWORD).mode(Flag.Mode.BASIC).build();
|
||||
public static final Flag HURT_VILLAGERS = new Flag.Builder("HURT_VILLAGERS", Material.GOLDEN_SWORD).mode(Flag.Mode.ADVANCED).build();
|
||||
public static final Flag HURT_TAMED_ANIMALS = new Flag.Builder("HURT_TAMABLE_ENTITIES", Material.DIAMOND_SWORD).mode(Flag.Mode.ADVANCED).build();
|
||||
|
||||
// Leashes
|
||||
public static final Flag LEASH = new Flag.Builder("LEASH", Material.LEAD).listener(new LeashListener()).build();
|
||||
|
@ -28,20 +28,7 @@ import org.bukkit.World.Environment;
|
||||
import org.bukkit.attribute.Attribute;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.entity.Allay;
|
||||
import org.bukkit.entity.Animals;
|
||||
import org.bukkit.entity.Bat;
|
||||
import org.bukkit.entity.EnderDragon;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Flying;
|
||||
import org.bukkit.entity.IronGolem;
|
||||
import org.bukkit.entity.Monster;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.PufferFish;
|
||||
import org.bukkit.entity.Shulker;
|
||||
import org.bukkit.entity.Slime;
|
||||
import org.bukkit.entity.Snowman;
|
||||
import org.bukkit.entity.WaterMob;
|
||||
import org.bukkit.entity.*;
|
||||
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
|
||||
import org.bukkit.util.Vector;
|
||||
import org.eclipse.jdt.annotation.NonNull;
|
||||
@ -370,6 +357,10 @@ public class Util {
|
||||
entity instanceof Allay;
|
||||
}
|
||||
|
||||
public static boolean isTamableEntity(Entity entity) {
|
||||
return entity instanceof Tameable && ((Tameable) entity).isTamed();
|
||||
}
|
||||
|
||||
/*
|
||||
* PaperLib methods for addons to call
|
||||
*/
|
||||
|
@ -1231,6 +1231,10 @@ protection:
|
||||
description: '&a Toggle hive harvesting.'
|
||||
name: Hive harvesting
|
||||
hint: Harvesting disabled
|
||||
HURT_TAMED_ANIMALS:
|
||||
description: Toggle hurting. Enabled means that tamed animals can take damage. Disabled means they are invincible.
|
||||
name: Hurt tamed animals
|
||||
hint: Tamed animal hurting disabled
|
||||
HURT_ANIMALS:
|
||||
description: Toggle hurting
|
||||
name: Hurt animals
|
||||
|
Loading…
Reference in New Issue
Block a user