Added option ("territoryBlockCreepers") to prevent creepers from destroying blocks if they explode inside faction owned territory, which defaults to disabled; if enabled, it prevents griefing by way of luring creepers into a faction's territory
note that creepers will still explode and hurt nearby players and mobs, they just won't destroy blocks
This commit is contained in:
parent
429e86fd4b
commit
1d26e18916
@ -42,6 +42,7 @@ public class Factions extends JavaPlugin {
|
|||||||
pm.registerEvent(Event.Type.PLAYER_QUIT, this.playerListener, Event.Priority.Normal, this);
|
pm.registerEvent(Event.Type.PLAYER_QUIT, this.playerListener, Event.Priority.Normal, this);
|
||||||
pm.registerEvent(Event.Type.ENTITY_DEATH, this.entityListener, Event.Priority.Normal, this);
|
pm.registerEvent(Event.Type.ENTITY_DEATH, this.entityListener, Event.Priority.Normal, this);
|
||||||
pm.registerEvent(Event.Type.ENTITY_DAMAGED, this.entityListener, Event.Priority.Normal, this);
|
pm.registerEvent(Event.Type.ENTITY_DAMAGED, this.entityListener, Event.Priority.Normal, this);
|
||||||
|
pm.registerEvent(Event.Type.ENTITY_EXPLODE, this.entityListener, Event.Priority.Normal, this);
|
||||||
pm.registerEvent(Event.Type.BLOCK_DAMAGED, this.blockListener, Event.Priority.Normal, this);
|
pm.registerEvent(Event.Type.BLOCK_DAMAGED, this.blockListener, Event.Priority.Normal, this);
|
||||||
pm.registerEvent(Event.Type.BLOCK_PLACED, this.blockListener, Event.Priority.Normal, this);
|
pm.registerEvent(Event.Type.BLOCK_PLACED, this.blockListener, Event.Priority.Normal, this);
|
||||||
pm.registerEvent(Event.Type.BLOCK_INTERACT, this.blockListener, Event.Priority.Normal, this);
|
pm.registerEvent(Event.Type.BLOCK_INTERACT, this.blockListener, Event.Priority.Normal, this);
|
||||||
|
@ -42,6 +42,7 @@ public class Conf {
|
|||||||
public static int mapWidth = 49;
|
public static int mapWidth = 49;
|
||||||
|
|
||||||
public static double territoryShieldFactor = 0.5;
|
public static double territoryShieldFactor = 0.5;
|
||||||
|
public static boolean territoryBlockCreepers = false;
|
||||||
public static List<Material> territoryProtectedMaterials = new ArrayList<Material>();
|
public static List<Material> territoryProtectedMaterials = new ArrayList<Material>();
|
||||||
|
|
||||||
// Command names / aliases
|
// Command names / aliases
|
||||||
|
@ -4,15 +4,19 @@ import java.text.DecimalFormat;
|
|||||||
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
|
import org.bukkit.entity.LivingEntity;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||||
import org.bukkit.event.entity.EntityDamageByProjectileEvent;
|
import org.bukkit.event.entity.EntityDamageByProjectileEvent;
|
||||||
import org.bukkit.event.entity.EntityDamageEvent;
|
import org.bukkit.event.entity.EntityDamageEvent;
|
||||||
import org.bukkit.event.entity.EntityDeathEvent;
|
import org.bukkit.event.entity.EntityDeathEvent;
|
||||||
|
import org.bukkit.event.entity.EntityExplodeEvent;
|
||||||
import org.bukkit.event.entity.EntityListener;
|
import org.bukkit.event.entity.EntityListener;
|
||||||
|
|
||||||
import com.bukkit.mcteam.factions.Factions;
|
import com.bukkit.mcteam.factions.Factions;
|
||||||
|
import com.bukkit.mcteam.factions.entities.Board;
|
||||||
import com.bukkit.mcteam.factions.entities.Conf;
|
import com.bukkit.mcteam.factions.entities.Conf;
|
||||||
|
import com.bukkit.mcteam.factions.entities.Coord;
|
||||||
import com.bukkit.mcteam.factions.entities.Follower;
|
import com.bukkit.mcteam.factions.entities.Follower;
|
||||||
import com.bukkit.mcteam.factions.struct.Relation;
|
import com.bukkit.mcteam.factions.struct.Relation;
|
||||||
|
|
||||||
@ -60,6 +64,19 @@ public class FactionsEntityListener extends EntityListener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onEntityExplode(EntityExplodeEvent event)
|
||||||
|
{
|
||||||
|
if (Conf.territoryBlockCreepers && event.getEntity() instanceof LivingEntity)
|
||||||
|
{ // creeper 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(Entity damager, Entity damagee, int damage) {
|
public boolean canDamagerHurtDamagee(Entity damager, Entity damagee, int damage) {
|
||||||
if ( ! (damager instanceof Player)) {
|
if ( ! (damager instanceof Player)) {
|
||||||
return true;
|
return true;
|
||||||
|
Loading…
Reference in New Issue
Block a user