Small Errors

Discussion in 'Plugin Development' started by flaminsnowman99, May 7, 2012.

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

    flaminsnowman99

    So i am working on my plugin and i have the beginning of the code done. But its getting some small errors. First, heres the code.
    Code:
    import org.bukkit.Bukkit;
    import org.bukkit.ChatColor;
    import org.bukkit.Location;
    import org.bukkit.Material;
    import org.bukkit.block.Block;
    import org.bukkit.block.Chest;
    import org.bukkit.plugin.java.JavaPlugin;
     
    public class BOSCannon extends JavaPlugin{
       
        }
       
        if (block.getState() instanceof Chest) {
           
            } else {
     
                Location chestlocation = block.getLocation();
     
                Block block1 = chestlocation.add(1,0,0).getBlock();
                Block block2 = chestlocation.add(-1,0,0).getBlock();
                Block block3 = chestlocation.add(0,0,1).getBlock();
                Block block4 = chestlocation.add(0,0,-1).getBlock();
                Block block5 = chestlocation.add(1,0,1).getBlock();
                Block block6 = chestlocation.add(-1,0,1).getBlock();
                Block block7 = chestlocation.add(1,0,-1).getBlock();
                Block block8 = chestlocation.add(-1,0,-1).getBlock();
                Block block9 = chestlocation.add(0,1,0).getBlock();
               
                if (block1.getType() == Material.PLANK && block1.getData() == 2) {
                    // Wood Slap touching
                }
                if (block2.getType() == Material.STEP && block1.getData() == 2) {
                    // Wood Slap touching
                }
                if (block3.getType() == Material.STEP && block1.getData() == 2) {
                    // Wood Slap touching
                }
                if (block4.getType() == Material.STEP && block1.getData() == 2) {
                    // Wood Slap touching
                }
                if (block5.getType() == Material.PLANK && block1.getData() == 2) {
                    // Wood Slap touching
                }
                if (block6.getType() == Material.PLANK && block1.getData() == 2) {
                    // Wood Slap touching
                }
                if (block7.getType() == Material.STEP && block1.getData() == 2) {
                    // Wood Slap touching
                }
                if (block8.getType() == Material.STEP && block1.getData() == 2) {
                    // Wood Slap touching
                }
                if (block9.getType() == Material.LEVER && block9.getData() == 2) {
                   
                    Bukkit.broadcastMessage(ChatColor.YELLOW + "Cannon Created!");
                   
                }
            }
        }
    }
    The first error is on the line
    Code:
    Location chestlocation = block.getLocation();
    Where it says block. It says block cannot be resolved. Which means i need to make a local variable but im not sure what it should be.
    The nest errors is here.
    Code:
    public class BOSCannon extends JavaPlugin{
     
        }
    Under the }. It wants me to insert another one but if i do then it cant read the code below it. I've tried adding an extra one at the end but it doesnt seem to work. So help with either error is greatly appreciated. Thanks! Also, i know it says its gonna be a cannon, i realize that shape is not a cannon. Just the beginnings of one.
     
  2. Offline

    Blairjam

    Ok, you are extending JavaPlugin, which requires the methods onEnable() and onDisable(). Then you need to move the rest of your code into a class implementing Listener, and then register the events you create there in the onEnable() method that you created prior.
     
  3. They aren't required anymore. If you don't need them you can just remove 'em.
     
    Blairjam likes this.
  4. Offline

    Darksonn

    Ok I tried to fix you code while also writing whats wrong, but this code is just so messy and, I would seriusly just recreate this. Also tells me what you want to do, then I might be able to help you better.
     
  5. Offline

    flaminsnowman99

    Darksonn, I am trying to write code for a shaped object. This object will be a cannon when finished. So, my thought was to check the world for chests. Then to check and see if the blocks around it match the shape. (The broadcast message part was a test) Also I realized after reading this post that I forgot to add the onEnable() and onDisable() parts :p
    Also ignore all the //comments, they were there for no apparent reason
     
Thread Status:
Not open for further replies.

Share This Page