Not Responding?

Discussion in 'Spigot Plugin Development' started by Orionweblab, Apr 16, 2017.

  1. I'm trying to make a ClassicTNT plugin that replaces all tnt to tnt:1
    Could someone look at my code?

    Code (Text):
    package main;

    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    import org.bukkit.event.block.BlockPlaceEvent;
    import org.bukkit.plugin.java.JavaPlugin;

    import net.minecraft.server.v1_8_R1.Material;

    public class TNT extends JavaPlugin implements Listener{
        @EventHandler
        void tnt(BlockPlaceEvent e){
            if(e.getBlockPlaced() == Material.TNT){
                e.getBlock().getLocation().getBlock().setTypeId(1);
            }
        }
    }
     
     
  2. Where is it giving errors? I can see a couple of mistakes but just to be sure. Also, change the title of this post to something that explains your error.
    Good luck.
     
  3. I place a block, nothing happens.
     
  4. Does your console give any errors? You first of all didn't register your listener, (which you should do in your onEnable) secondly, you're using the net.minecraft package. Then, use other names for your class, TNT is probably going to error with some of the built-in classes, then last you cannot compare a Block to a Material as far as I know. The code makes no sense, you're literally asking a block's location (which makes sense) and then you're asking that locations block.
    Good luck! :)
     
  5. Change this line and import.
    Code (Text):
            if(e.getBlockPlaced() == Material.TNT){
    to
    Code (Text):
            if(e.getBlockPlaced().getType() == Material.TNT){
    in your onEnable()
    Code (Text):
    Bukkit.getServer().getPluginManager().registerEvents(this, this);
     
    • Agree Agree x 1