TNT+

Discussion in 'Plugin Requests' started by Vercetti, Nov 3, 2015.

Thread Status:
Not open for further replies.
  1. Offline

    Vercetti

    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!
     
    Last edited: Nov 3, 2015
  2. Offline

    PresentingTulip

    I'll make this for you.
     
  3. Offline

    madtomic

    Let me know, I'd like this too. This is genius!
     
  4. Offline

    Vercetti

    Thanks
     
  5. Offline

    Vercetti

    UP
    I'm really looking forward
     
  6. Offline

    tkuiyeager1

  7. Offline

    Lordloss

    that will make the player breaking it blow up. sounds funny, but why xD
     
  8. Offline

    PresentingTulip

    Just make it. I have it untested.
     
  9. Offline

    sebagius7110

    Would you like it to damage the terrain? or no.
     
  10. Offline

    iwuvbubbles

    I can make it. seems it's being made though.
     
  11. Offline

    Chloe-chan

    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.
     
    Last edited: Nov 9, 2015
  12. Offline

    madtomic

    Don't work. Here is the error: http://pastebin.com/fv4SSNeV
     
  13. Offline

    Chloe-chan

    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.
     
    Last edited: Nov 8, 2015
  14. There are so many of these already, just a quick google search can find them for you :)
     
  15. Offline

    madtomic

    @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. :D

    @bwfcwalshy

    We are encouraging everyone and we like fresh codes! :p
     
  16. Offline

    Chloe-chan

    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).
     
    Last edited: Nov 9, 2015
  17. Offline

    madtomic

    @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.
     
  18. Offline

    Chloe-chan

    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.
     
Thread Status:
Not open for further replies.

Share This Page