From d5308bc75d218d6a15d16e24624816dd8d91afbd Mon Sep 17 00:00:00 2001 From: Brettflan Date: Thu, 17 Mar 2011 18:02:29 -0500 Subject: [PATCH] Added config option territoryBlockFireballs, defaults to false; if enabled, prevents destruction of blocks by Ghast fireballs inside faction territory... note that this only works in CB build 557 and higher, where fireball detection was added --- src/com/bukkit/mcteam/factions/Commands.java | 3 --- src/com/bukkit/mcteam/factions/entities/Conf.java | 2 ++ .../factions/listeners/FactionsEntityListener.java | 9 +++++++++ 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/com/bukkit/mcteam/factions/Commands.java b/src/com/bukkit/mcteam/factions/Commands.java index 3377ddd6..210ad0c7 100644 --- a/src/com/bukkit/mcteam/factions/Commands.java +++ b/src/com/bukkit/mcteam/factions/Commands.java @@ -361,9 +361,6 @@ public class Commands { } page -= 1; - - // TODO Doesn't the second sort bellow completely overwrite the first?? - // Sort by total followers first Collections.sort(FactionList, new Comparator(){ @Override diff --git a/src/com/bukkit/mcteam/factions/entities/Conf.java b/src/com/bukkit/mcteam/factions/entities/Conf.java index 410382f8..81bafaef 100644 --- a/src/com/bukkit/mcteam/factions/entities/Conf.java +++ b/src/com/bukkit/mcteam/factions/entities/Conf.java @@ -43,6 +43,8 @@ public class Conf { public static double territoryShieldFactor = 0.5; public static boolean territoryBlockCreepers = false; + public static boolean territoryBlockFireballs = false; + public static List territoryProtectedMaterials = new ArrayList(); // Command names / aliases diff --git a/src/com/bukkit/mcteam/factions/listeners/FactionsEntityListener.java b/src/com/bukkit/mcteam/factions/listeners/FactionsEntityListener.java index 48f11325..f521bff8 100644 --- a/src/com/bukkit/mcteam/factions/listeners/FactionsEntityListener.java +++ b/src/com/bukkit/mcteam/factions/listeners/FactionsEntityListener.java @@ -4,6 +4,7 @@ import java.text.MessageFormat; import org.bukkit.ChatColor; import org.bukkit.entity.Entity; +import org.bukkit.entity.Fireball; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.event.entity.EntityDamageByEntityEvent; @@ -75,6 +76,14 @@ public class FactionsEntityListener extends EntityListener { return; } } + else if (Conf.territoryBlockFireballs && event.getEntity() instanceof Fireball) + { // ghast fireball which might need prevention, if inside faction territory + if (Board.get(event.getLocation().getWorld()).getFactionIdAt(Coord.from(event.getLocation())) > 0) + { + event.setCancelled(true); + return; + } + } } public boolean canDamagerHurtDamagee(EntityDamageByEntityEvent sub) {