Java Code Examples for org.bukkit.entity.EntityType#PRIMED_TNT

The following examples show how to use org.bukkit.entity.EntityType#PRIMED_TNT . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TntTracker.java    From CardinalPGM with MIT License 5 votes vote down vote up
@EventHandler
public void onExplosionPrime(ExplosionPrimeEvent event) {
    if (event.getEntity().getType() == EntityType.PRIMED_TNT) {
        Location location = event.getEntity().getLocation();
        if (tntPlaced.containsKey(location.getBlockX() + "," + location.getBlockY() + "," + location.getBlockZ())) {
            UUID player = tntPlaced.get(location.getBlockX() + "," + location.getBlockY() + "," + location.getBlockZ());
            event.getEntity().setMetadata("source", new FixedMetadataValue(GameHandler.getGameHandler().getPlugin(), player));
            tntPlaced.remove(location.getBlockX() + "," + location.getBlockY() + "," + location.getBlockZ());
        }
    }
}
 
Example 2
Source File: TntTracker.java    From CardinalPGM with MIT License 5 votes vote down vote up
@EventHandler
public void onEntityExplode(EntityExplodeEvent event) {
    if (event.getEntity() != null) {
        if (event.getEntity().getType() == EntityType.PRIMED_TNT) {
            for (Block block : event.blockList()) {
                if (block.getType() == Material.TNT && getWhoPlaced(event.getEntity()) != null) {
                    Location location = block.getLocation();
                    tntPlaced.put(location.getBlockX() + "," + location.getBlockY() + "," + location.getBlockZ(), getWhoPlaced(event.getEntity()));
                }
            }
        }
    }
}
 
Example 3
Source File: TntTracker.java    From CardinalPGM with MIT License 5 votes vote down vote up
@EventHandler
public void onEntityDispense(BlockDispenseEntityEvent event){
    if (event.getBlock().getType() == Material.DISPENSER){
        if (event.getEntity().getType() == EntityType.PRIMED_TNT) {
            Location location = event.getBlock().getLocation();
            if (dispenserPlaced.containsKey(location.getBlockX() + "," + location.getBlockY() + "," + location.getBlockZ())) {
                UUID player = dispenserPlaced.get(location.getBlockX() + "," + location.getBlockY() + "," + location.getBlockZ());
                event.getEntity().setMetadata("source", new FixedMetadataValue(GameHandler.getGameHandler().getPlugin(), player));
            }
        }
    }
}
 
Example 4
Source File: CraftTNTPrimed.java    From Kettle with GNU General Public License v3.0 4 votes vote down vote up
public EntityType getType() {
    return EntityType.PRIMED_TNT;
}
 
Example 5
Source File: ChunkEventHelper.java    From ClaimChunk with MIT License 4 votes vote down vote up
public static void handleExplosionIfConfig(@Nonnull EntityExplodeEvent e) {
    if (e.isCancelled()) return;

    final ChunkHandler CHUNK_HANLDE = ClaimChunk.getInstance().getChunkHandler();

    final EntityType TYPE = e.getEntityType();
    final Chunk CHUNK = e.getLocation().getChunk();

    // If the explosion is within a claimed chunk, it will cancel the whole
    // event.
    boolean inClaimedChunk = CHUNK_HANLDE.isClaimed(CHUNK);
    boolean hardCancel = inClaimedChunk || blockUnclaimedChunk(CHUNK.getWorld().getName());

    // If the event is TNT/Mincart TNT related, it should be cancelled
    boolean isTnt = TYPE == EntityType.PRIMED_TNT || TYPE == EntityType.MINECART_TNT;
    boolean protectTnt = isTnt && config.getBool("protection", "blockTnt");
    // If TNT is blocked, check if the user has used `/chunk tnt` to enable
    // it in this chunk.
    if (protectTnt && CHUNK_HANLDE.isTntEnabled(CHUNK)) {
        protectTnt = false;
    }
    if (protectTnt) {
        cancelExplosionEvent(hardCancel, e);
        return;
    }

    // Cancel crepper explosions if protection against them is enabled
    // within the config.
    boolean isCreeper = TYPE == EntityType.CREEPER;
    if (isCreeper && config.getBool("protection", "blockCreeper")) {
        cancelExplosionEvent(hardCancel, e);
        return;
    }

    // If wither damage is prevented within the config, cancel this event
    // if it's a wither event.
    boolean isWither = TYPE == EntityType.WITHER || TYPE == EntityType.WITHER_SKULL;
    if (isWither && config.getBool("protection", "blockWither")) {
        cancelExplosionEvent(hardCancel, e);
    }
}
 
Example 6
Source File: CraftTNTPrimed.java    From Thermos with GNU General Public License v3.0 4 votes vote down vote up
public EntityType getType() {
    return EntityType.PRIMED_TNT;
}