Removing a block and registerEvents() not working?

Discussion in 'Plugin Development' started by Chibbey, Jan 4, 2014.

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

    Chibbey

    Hello. So I'm just testing things out right now for fun and for some reason when I do in the onEnable()
    Code:java
    1. public void onEnable() {
    2. Bukkit.getServer().getPluginManager().registerEvents(this, this);
    3. }

    It wont let me do registerEvents() and it's underlined in red and I have to put (Plugin) on the left side of the second this so like this
    Code:java
    1. Bukkit.getServer().getPluginManager().registerEvents(this, this);

    and I also have to let it implement Plugin but then I have to make it an abstract class. So could you help me with this. Im using 1.6.4 craftbukkit. Should I update to 1.7.2? But it works for all my other plugins. I don't get it at all.

    And for my problem with removing blocks im testing it so when a player right click a Iron block it sends them a message saying "
    You clicked the Iron Block for a Iron Block


    "
    And it adds a Iron block to their Inventory now I just got to figure out to remove the Iron block they clicked. I have it in a PlayerInteractEvent and so far I got
    Code:java
    1. e.getClickedBlock().getLocation().<I Don't Know>;

    So how would I remove the block? Please help me!

    I think I got it... testing....

    It didn't work.... Please help me!

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 6, 2016
  2. Offline

    16davidjm6

    Chibbey

    to use getServer().getPluginManager().registerEvents(this,this); your class must extend JavaPlugin and implement Listener so that

    Code:java
    1. public class MyPlugin extends JavaPlugin implements Listener{
    2.  
    3. //your code
    4.  
    5. }


    for getting rid of the block, try this:
    Code:java
    1. e.getClickedBlock().setType(Material.AIR);
     
  3. Offline

    Chibbey

    16davidjm6
    Oh........... I thought you could just implement Listener, didnt know you had to extend Javaplugin. And that is what i tried for removing blocks. But maybe if i try now it will work cause im extending Javaplugin. So its registering the event properly now. Ill tell you if it did. :)

    16davidjm6
    I figured it out! I was suppose to right click the block and not left click :p. And I had to extends JavaPlugin. But yea but then It messed up when I right clicked. So I changed it to left click. So ima make a plugin for this to post on bukkit dev

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 6, 2016
Thread Status:
Not open for further replies.

Share This Page