Skip to content

Commit

Permalink
Tnt flag now prevents explosions from TntMinecarts.
Browse files Browse the repository at this point in the history
  • Loading branch information
jcdesimp committed Apr 19, 2014
1 parent d358c87 commit 7564798
Showing 1 changed file with 32 additions and 8 deletions.
40 changes: 32 additions & 8 deletions src/com/jcdesimp/landlord/landFlags/TntDamage.java
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,10 @@ public TntDamage() {
*/
@EventHandler(priority = EventPriority.HIGH)
public void tntExplode( EntityExplodeEvent event ){
if(!event.getEntityType().equals(EntityType.PRIMED_TNT)){
if(!(event.getEntityType().equals(EntityType.PRIMED_TNT))){
return;
}

TNTPrimed tnt = (TNTPrimed)event.getEntity();
OwnedLand land = OwnedLand.getApplicableLand(event.getLocation());
if(land == null){
Expand All @@ -98,13 +99,7 @@ public void tntExplode( EntityExplodeEvent event ){
Block block = it.next();
OwnedLand lnd = OwnedLand.getApplicableLand(block.getLocation());
if (lnd != null && !lnd.canEveryone(this) ) {
if(tnt.getSource()!=null){
Player p = (Player)tnt.getSource();
if(!lnd.hasPermTo(p, this)){
it.remove();
}

} else {
if (!(tnt.getSource() instanceof Player) || !lnd.hasPermTo((Player) tnt.getSource(), this)) {
it.remove();
}

Expand All @@ -114,6 +109,35 @@ public void tntExplode( EntityExplodeEvent event ){

}

@EventHandler(priority = EventPriority.HIGH)
public void tntMinecartExplode( EntityExplodeEvent event ){
if(!event.getEntityType().equals(EntityType.MINECART_TNT)){
return;
}

OwnedLand land = OwnedLand.getApplicableLand(event.getLocation());
if (land != null) {
if(!land.canEveryone(this)){
event.setCancelled(true);
return;
}

}

List<Block> destroyed = event.blockList();
Iterator<Block> it = destroyed.iterator();
while (it.hasNext()) {
Block block = it.next();
OwnedLand lnd = OwnedLand.getApplicableLand(block.getLocation());
if (lnd != null && !lnd.canEveryone(this)) {
it.remove();
}

}


}

@EventHandler(priority = EventPriority.HIGH)
public void igniteTnt(PlayerInteractEvent event){

Expand Down

0 comments on commit 7564798

Please sign in to comment.