Suggested name: TNT+ What I want: When player break ( with hand ) the TNT block he explodes immediately No need permission and commands When I like it by: When you have time to code this! Thanks!
Sorry if I stole anyone's plugin... but it seems like no one has posted any plugin so far. I've made a simple plugin to do this, download link here. This plugin will spawn a primed TNT with a fuse of 1 tick at the location of the TNT, when it is broken by a player which is in survival mode and holding nothing (using hand). Code: Code: package com.gmail.cle.surreal.plugins.tntplus; import org.bukkit.Bukkit; import org.bukkit.GameMode; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.plugin.java.JavaPlugin; public class TNTPlus extends JavaPlugin implements Listener { @Override public void onEnable() { Bukkit.getServer().getPluginManager().registerEvents(this, this); } @EventHandler public void onTntBreak(BlockBreakEvent event) { // Check if the player is in survival mode if (event.getPlayer().getGameMode() != GameMode.SURVIVAL) return; // Check if the player is holding anything on hand if (event.getPlayer().getItemInHand().getAmount() > 0) return; // Check if the block broken is TNT if (event.getBlock().getType() != Material.TNT) return; event.setCancelled(true); event.getBlock().setType(Material.AIR); Location location = event.getPlayer().getEyeLocation(); location.getWorld().createExplosion(location.getX(), location.getY(), location.getZ(), 4f, false, false); /*Entity e = location.getWorld().spawnEntity(location, EntityType.PRIMED_TNT); if (e != null) { TNTPrimed tnt = (TNTPrimed) e; tnt.setFuseTicks(1); }*/ } } EDIT: @madtomic I've updated the plugin to support older Minecraft versions. Same link as above. EDIT (10th Nov): Changed from using PrimedTNT to an actual explosion at the player's location (and doesn't break blocks). Same link as above.
I've built that plugin using 1.8.8 Spigot, give me a few moment. I'll recompile it using 1.7 Bukkit. EDIT: Updated the plugin. Same link as above.
@Chloe-chan Thank you for adding support for 1.7 EDIT: This plugin will spawn a primed TNT with a fuse of 1 tick at the location of the TNT, when it is broken by a player which is in survival mode and holding nothing (using hand). Can you just simply explode the player with TNT when the TNT block is broken? Skip spawning a primed TNT. @bwfcwalshy We are encouraging everyone and we like fresh codes!
Do you want to kill the player in the process, or simply shift the primed TNT to the player's location ? I feel the latter is much more reasonable, instead of directly killing the player. Or simply just create an explosion at the player's location? EDIT: I've updated the link above again, this time the explosion will be at the player's location (and doesn't break blocks).
@Chloe-chan I will check it out when I get home. I think the original request is to kill anyone breaking TNT blocks. I will see if this shift to player's location would do the job killing the player for sure. While we are exploring this. I would assume the TNT block would stay in place or vanish after break? Now, we have to think about players running around laying TNTs.
If they aren't wearing any armour, they will be killed by the explosion. And yes, the TNT block will vanish after the break. I can easily edit the code to kill the one who breaks the TNT block if OP wants it so.