Fix item frame/armor stand protection
This commit is contained in:
parent
1df8faf488
commit
e1f0938f59
@ -131,6 +131,34 @@ public class FactionsEntityListener implements Listener {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Protect armor stands/item frames from being damaged in protected territories
|
||||
if (damagee.getType() == EntityType.ITEM_FRAME || damagee.getType() == EntityType.ARMOR_STAND) {
|
||||
// Run the check for a player
|
||||
if (damager instanceof Player) {
|
||||
// Generate the action message.
|
||||
String entityAction;
|
||||
|
||||
if (damagee.getType() == EntityType.ITEM_FRAME) {
|
||||
entityAction = "item frames";
|
||||
} else {
|
||||
entityAction = "armor stands";
|
||||
}
|
||||
|
||||
if (!FactionsBlockListener.playerCanBuildDestroyBlock((Player) damager, damagee.getLocation(), "destroy " + entityAction, false)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
} else {
|
||||
// we don't want to let mobs/arrows destroy item frames/armor stands
|
||||
// so we only have to run the check as if there had been an explosion at the damager location
|
||||
if (!this.checkExplosionForBlock(damager, damagee.getLocation().getBlock())) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
// we don't need to go after
|
||||
return;
|
||||
}
|
||||
|
||||
//this one should trigger if something other than a player takes damage
|
||||
if (damager instanceof Player) {
|
||||
// now itll only go here if the damage is dealt by a player
|
||||
|
@ -658,6 +658,36 @@ public class FactionsPlayerListener implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
// For disabling interactions with item frames in another faction's territory
|
||||
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
||||
public void onPlayerInteractEntity(PlayerInteractEntityEvent event) {
|
||||
// only need to check for item frames
|
||||
if (event.getRightClicked().getType() != EntityType.ITEM_FRAME) {
|
||||
return;
|
||||
}
|
||||
|
||||
Player player = event.getPlayer();
|
||||
Entity entity = event.getRightClicked();
|
||||
|
||||
if (!FactionsBlockListener.playerCanBuildDestroyBlock(player, entity.getLocation(), "use item frames", false)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
// For disabling interactions with armor stands in another faction's territory
|
||||
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
||||
public void onPlayerInteractAtEntity(PlayerInteractAtEntityEvent event) {
|
||||
Entity entity = event.getRightClicked();
|
||||
|
||||
// only need to check for armor stand and item frames
|
||||
if (entity.getType() != EntityType.ARMOR_STAND) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!FactionsBlockListener.playerCanBuildDestroyBlock(event.getPlayer(), entity.getLocation(), "use armor stands", false)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
// for handling people who repeatedly spam attempts to open a door (or similar) in another faction's territory
|
||||
private Map<String, InteractAttemptSpam> interactSpammers = new HashMap<>();
|
||||
|
Loading…
Reference in New Issue
Block a user