Why does'nt the EVEN work?

Discussion in 'Plugin Development' started by Marius A. Winsjansen, Sep 23, 2011.

Thread Status:
Not open for further replies.
  1. Greetings,

    I am very new to developing plugins, but i know so much that this code shouldt be wrong:

    Code:
    PluginManager pm = getServer().getPluginManager();
    pm.registerEvent([B][U]Event[/U][/B].Type.BLOCK_PLACE, blockListener, Priority.Normal, this);
    log.info("BroadCast is enable!");
    its the "Event" in "Event.Type.BLOCK_PLACE" that doesnt work!

    WHY??

    I hope some1 can help me!

    Regards
    TheSuperMar10
     
  2. Offline

    rmb938

    Do you have this as an import?

    Code:
    import org.bukkit.event.Event;
     
  3. No i didnt, since the netbeans didnt ask for importing it (like it do on EVERY other things-.-!)

    Well, thansk for the help m8!! :D wierd it didnt do it by it self :S

    @rmb938

    I have another problame, i hope you can look at:

    When i place other things than grass, it still says its grass, what have i done wrong in this code?


    Code:
    public class BL extends BlockListener {
        public void onBlockPlace(BlockPlaceEvent event){
            Player p = event.getPlayer();
            String playername = p.getName();
            Server s = p.getServer();
            s.broadcastMessage(playername + " has placed a block!");
            if(event.getBlock().getType() == Material.GRASS);
            s.broadcastMessage(playername + "has placed grass!");
    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 19, 2016
  4. Offline

    daemitus

    You have a semicolon there.

    Also, you could try
    s.broadcastMessage(playername + " has placed " + event.getBlock().getType().name());

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 19, 2016
  5. but what should i have there, if its not semicolon? i cant use { thats just cancel the hole thing?

    Okey, i have edit the code alittle bit, but its still dont work (i know i should probebly use else statment on this, but i cant remeber how to use more than 1!

    It would be very nice if some1 could help me whit this one, i REALLY wanna learn java and this is my first plugin so.. Hope some1 can look at this code:

    Code:
    public class BL extends BlockListener {
    	public void onBlockPlace(BlockPlaceEvent event){
    		Player p = event.getPlayer();
    		String playername = p.getName();
    		Server s = p.getServer();
    		if(event.getBlock().getType() == Material.LAVA)
    		s.broadcastMessage(playername + " has placed LAVA!");
    		if(event.getBlock().getType() == Material.TNT);
    		s.broadcastMessage(playername + " has placed TNT!");
    		if(event.getBlock().getType() == Material.FIRE)
    		s.broadcastMessage(playername + " has placed FIRE!");
    It says i place tnt no mather what block i place and the lava and fire never come uP! :/

    Oh, sorry it says lava on lava, and fire on fire, but tnt on everythign:/

    I DID IT :D it was the semicolons! THANKS :D

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

Share This Page