Solved Method not recognized

Discussion in 'Plugin Development' started by nivilom86, Oct 8, 2014.

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


    Hello !
    I'm sorry to bother you, but I've a problem with a method, which is not recognized. Here the code :
    1. package fr.applecraft.BlockChange;
    3. import org.bukkit.Bukkit;
    4. import org.bukkit.block.Block;
    5. import;
    6. import org.bukkit.World;
    8. public class BlockDetect extends JavaPlugin
    9. {
    10. public Block findTheBlock()
    11. {
    12. int x = -85;
    13. int y = 70;
    14. int z = 260;
    15. Block block = (Block) getBlockAt(x,y,z);
    16. return block;
    17. }
    18. }

    The method in question is "getBlockAt(x,y,z)".
    I'm a beginner in Java, that's why I don't understand this error.

    Thanks for reading ;D
  2. Offline


    The method getBlockAt(int, int, int) is not in the type JavaPlugn (which your class is), it is a static method in the World class, World.getBlockAt(x,y,z); should work.

    I think that you should learn java more before starting to code with bukkit.
  3. Offline


    Why are you using a method for this? You can simply do the following:
    1. // If you don't have a world object already
    2. Block b = Bukkit.getWorld("worldName").getBlockAt(x, y, z);
    3. // Or, if you already have a world object
    4. Block b = w.getBlockAt(x, y, z);
  4. NonameSL It's not a static method as that would make no sense. :)
  5. Offline


    OK, thanks for your answers, there are really helpful for me ;)
Thread Status:
Not open for further replies.

Share This Page