Reformat code for item frames/armor stands protection

This commit is contained in:
utarwyn 2018-05-17 18:01:05 +02:00
parent 4a8721e453
commit 5fecc4979c
3 changed files with 19 additions and 19 deletions

View File

@ -438,7 +438,7 @@ public class Conf {
territoryDenyUseageMaterialsWhenOffline.add(Material.BUCKET); territoryDenyUseageMaterialsWhenOffline.add(Material.BUCKET);
territoryDenyUseageMaterialsWhenOffline.add(Material.WATER_BUCKET); territoryDenyUseageMaterialsWhenOffline.add(Material.WATER_BUCKET);
territoryDenyUseageMaterialsWhenOffline.add(Material.LAVA_BUCKET); territoryDenyUseageMaterialsWhenOffline.add(Material.LAVA_BUCKET);
territoryDenyUseageMaterialsWhenOffline.add(Material.ARMOR_STAND); territoryDenyUseageMaterialsWhenOffline.add(Material.ARMOR_STAND);
safeZoneNerfedCreatureTypes.add(EntityType.BLAZE); safeZoneNerfedCreatureTypes.add(EntityType.BLAZE);
safeZoneNerfedCreatureTypes.add(EntityType.CAVE_SPIDER); safeZoneNerfedCreatureTypes.add(EntityType.CAVE_SPIDER);

View File

@ -134,9 +134,9 @@ public class FactionsEntityListener implements Listener {
// Protect armor stands/item frames from being damaged in protected territories // Protect armor stands/item frames from being damaged in protected territories
if (damagee.getType() == EntityType.ITEM_FRAME || damagee.getType() == EntityType.ARMOR_STAND) { if (damagee.getType() == EntityType.ITEM_FRAME || damagee.getType() == EntityType.ARMOR_STAND) {
// Manage projectiles launched by players // Manage projectiles launched by players
if (damager instanceof Projectile && ((Projectile) damager).getShooter() instanceof Entity) { if (damager instanceof Projectile && ((Projectile) damager).getShooter() instanceof Entity) {
damager = (Entity) ((Projectile) damager).getShooter(); damager = (Entity) ((Projectile) damager).getShooter();
} }
// Run the check for a player // Run the check for a player
if (damager instanceof Player) { if (damager instanceof Player) {
@ -154,10 +154,10 @@ public class FactionsEntityListener implements Listener {
} }
} else { } else {
// we don't want to let mobs/arrows destroy item frames/armor stands // 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 // 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())) { if (!this.checkExplosionForBlock(damager, damagee.getLocation().getBlock())) {
event.setCancelled(true); event.setCancelled(true);
} }
} }
// we don't need to go after // we don't need to go after

View File

@ -675,19 +675,19 @@ public class FactionsPlayerListener implements Listener {
} }
// For disabling interactions with armor stands in another faction's territory // For disabling interactions with armor stands in another faction's territory
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onPlayerInteractAtEntity(PlayerInteractAtEntityEvent event) { public void onPlayerInteractAtEntity(PlayerInteractAtEntityEvent event) {
Entity entity = event.getRightClicked(); Entity entity = event.getRightClicked();
// only need to check for armor stand and item frames // only need to check for armor stand and item frames
if (entity.getType() != EntityType.ARMOR_STAND) { if (entity.getType() != EntityType.ARMOR_STAND) {
return; return;
} }
if (!FactionsBlockListener.playerCanBuildDestroyBlock(event.getPlayer(), entity.getLocation(), "use armor stands", false)) { if (!FactionsBlockListener.playerCanBuildDestroyBlock(event.getPlayer(), entity.getLocation(), "use armor stands", false)) {
event.setCancelled(true); event.setCancelled(true);
} }
} }
// for handling people who repeatedly spam attempts to open a door (or similar) in another faction's territory // 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<>(); private Map<String, InteractAttemptSpam> interactSpammers = new HashMap<>();