mirror of
https://github.com/BentoBoxWorld/BentoBox.git
synced 2025-01-08 09:27:38 +01:00
Fixes item frame protection by flag. Also affects armor stands
https://github.com/BentoBoxWorld/BentoBox/issues/1023
This commit is contained in:
parent
21e75c645e
commit
d3e35a9ecb
@ -1,5 +1,6 @@
|
||||
package world.bentobox.bentobox.listeners.flags.protection;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.ArmorStand;
|
||||
@ -108,14 +109,25 @@ public class BreakBlocksListener extends FlagListener {
|
||||
}
|
||||
// Get the attacker
|
||||
if (e.getDamager() instanceof Player) {
|
||||
checkIsland(e, (Player)e.getDamager(), e.getEntity().getLocation(), Flags.BREAK_BLOCKS);
|
||||
// Check the break blocks flag
|
||||
notAllowed(e, (Player)e.getDamager(), e.getEntity().getLocation());
|
||||
} else if (e.getDamager() instanceof Projectile) {
|
||||
// Find out who fired the arrow
|
||||
Projectile p = (Projectile) e.getDamager();
|
||||
if (p.getShooter() instanceof Player && !checkIsland(e, (Player)p.getShooter(), e.getEntity().getLocation(), Flags.BREAK_BLOCKS)) {
|
||||
if (p.getShooter() instanceof Player && notAllowed(e, (Player)p.getShooter(), e.getEntity().getLocation())) {
|
||||
e.getEntity().setFireTicks(0);
|
||||
p.setFireTicks(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private boolean notAllowed(EntityDamageByEntityEvent e, Player player, Location location) {
|
||||
if (!checkIsland(e, player, location, Flags.BREAK_BLOCKS)) return true;
|
||||
if (e.getEntity() instanceof ItemFrame) {
|
||||
return !checkIsland(e, player, location, Flags.ITEM_FRAME);
|
||||
} else if (e.getEntity() instanceof ArmorStand) {
|
||||
return !checkIsland(e, player, location, Flags.ARMOR_STAND);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -39,7 +39,8 @@ public class PlaceBlocksListener extends FlagListener {
|
||||
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
||||
public void onPlayerHitItemFrame(PlayerInteractEntityEvent e) {
|
||||
if (e.getRightClicked().getType().equals(EntityType.ITEM_FRAME)) {
|
||||
checkIsland(e, e.getPlayer(), e.getRightClicked().getLocation(), Flags.PLACE_BLOCKS);
|
||||
if (!checkIsland(e, e.getPlayer(), e.getRightClicked().getLocation(), Flags.PLACE_BLOCKS)) return;
|
||||
checkIsland(e, e.getPlayer(), e.getRightClicked().getLocation(), Flags.ITEM_FRAME);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user