improved TNT exploit prevention
Now, canceled exploit attempts don't injure players or mobs as if the TNT had successfully exploded, and if it's the case of an existing TNT block which a redstone torch is attempted to be placed next to, it no longer drops a free TNT item. In that case, the existing TNT block is still destroyed itself, but... oh well, it's close enough to perfect.
This commit is contained in:
parent
2a9b475012
commit
8142e1c28f
@ -132,6 +132,7 @@ public class P extends MPlugin
|
||||
this.registerEvent(Event.Type.ENTITY_TARGET, this.entityListener, Event.Priority.Normal);
|
||||
this.registerEvent(Event.Type.PAINTING_BREAK, this.entityListener, Event.Priority.Normal);
|
||||
this.registerEvent(Event.Type.PAINTING_PLACE, this.entityListener, Event.Priority.Normal);
|
||||
this.registerEvent(Event.Type.EXPLOSION_PRIME, this.entityListener, Event.Priority.Normal);
|
||||
|
||||
// Block Events
|
||||
this.registerEvent(Event.Type.BLOCK_BREAK, this.blockListener, Event.Priority.Normal);
|
||||
|
@ -20,6 +20,7 @@ import org.bukkit.event.entity.EntityDeathEvent;
|
||||
import org.bukkit.event.entity.EntityExplodeEvent;
|
||||
import org.bukkit.event.entity.EntityListener;
|
||||
import org.bukkit.event.entity.EntityTargetEvent;
|
||||
import org.bukkit.event.entity.ExplosionPrimeEvent;
|
||||
import org.bukkit.event.painting.PaintingBreakByEntityEvent;
|
||||
import org.bukkit.event.painting.PaintingBreakEvent;
|
||||
import org.bukkit.event.painting.PaintingPlaceEvent;
|
||||
@ -94,14 +95,16 @@ public class FactionsEntityListener extends EntityListener
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEntityExplode(EntityExplodeEvent event)
|
||||
public void onExplosionPrime(ExplosionPrimeEvent event)
|
||||
{
|
||||
if (event.isCancelled()) return;
|
||||
if (! (event.getEntity() instanceof TNTPrimed)) return;
|
||||
if (exploitExplosions.isEmpty()) return;
|
||||
|
||||
if (event.getEntity() instanceof TNTPrimed && exploitExplosions.size() > 0)
|
||||
{ // make sure this isn't a TNT explosion exploit attempt
|
||||
int locX = event.getLocation().getBlockX();
|
||||
int locZ = event.getLocation().getBlockZ();
|
||||
// make sure this isn't a TNT explosion exploit attempt
|
||||
|
||||
int locX = event.getEntity().getLocation().getBlockX();
|
||||
int locZ = event.getEntity().getLocation().getBlockZ();
|
||||
|
||||
for (int i = exploitExplosions.size() - 1; i >= 0; i--)
|
||||
{
|
||||
@ -132,6 +135,11 @@ public class FactionsEntityListener extends EntityListener
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEntityExplode(EntityExplodeEvent event)
|
||||
{
|
||||
if ( event.isCancelled()) return;
|
||||
|
||||
for (Block block : event.blockList())
|
||||
{
|
||||
Faction faction = Board.getFactionAt(new FLocation(block));
|
||||
|
Loading…
Reference in New Issue
Block a user