Sign on Chest

Discussion in 'Plugin Development' started by catchaser9620, Aug 3, 2012.

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

    travja

    Should look something like this
    Code:java
    1. public class blah extends JavaPlugin{
    2. public Listener PL = new PL(this);
    3. onEnable(){
    4. this.getServer().getPluginManager().registerEvents(PL, this);
    5. }
    6. onDisable(){
    7. }
    8. }
     
  2. Offline

    catchaser9620

    there was an extra Listener in the: public Listener PL =new PL(this);
    from your eralier reply: public Listener variable = new Listener classname(this);

    EDIT: got an another error:
    16:20:41 [SEVERE] Wrong method arguments used for event type registered
     
  3. Offline

    travja

    oh, sorry, my bad. So, is it working now then?
     
  4. Offline

    catchaser9620

    got an another error:
    16:20:41 [SEVERE] Wrong method arguments used for event type registered

    Code:
            this.getServer().getPluginManager().registerEvents(itembank, this);
     
  5. Offline

    travja

    Can you give me your listener class?
     
  6. Offline

    catchaser9620

    Code:
    package com.github.catchaser.listeners;
     
    import org.bukkit.ChatColor;
    import org.bukkit.Material;
    import org.bukkit.block.BlockFace;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    import org.bukkit.event.block.Action;
    import org.bukkit.event.block.SignChangeEvent;
    import org.bukkit.event.player.PlayerInteractEvent;
     
    import com.github.catchaser.BaseCommands;
     
    public class itembank implements Listener{
       
        @SuppressWarnings("unused")
        private BaseCommands plugin;
       
        public itembank(BaseCommands plugin) {
            this.plugin = plugin;
        }
     
       
        @EventHandler
        public void onInteract(PlayerInteractEvent e, SignChangeEvent s) {
            if(e.getAction() == Action.LEFT_CLICK_BLOCK){
                if(e.getClickedBlock().getTypeId() == Material.CHEST.getId()) {
                    if(e.getItem().getType() == Material.SIGN) {
                        for (BlockFace f : (new BlockFace[]{BlockFace.NORTH, BlockFace.EAST, BlockFace.SOUTH, BlockFace.WEST}))
                            {
                            e.getClickedBlock().getRelative(f).getLocation().getBlock().getState().setType(Material.WALL_SIGN);
                            e.getClickedBlock().getRelative(f).getLocation().getBlock().getState().update();
                            s.setLine(0, ChatColor.WHITE + "BaseCommands");
                            s.setLine(1, ChatColor.DARK_AQUA + "ITEMBANK");
                            s.setLine(2, e.getPlayer().getName());
                            }   
                    }
                }
            }
        }
    }
    
     
  7. Offline

    travja

    I myself would actually make a separate @EventHandler for the SignChangeEvent and check if the sign being changed qualifies for what you need.
     
  8. Offline

    catchaser9620

    ok
     
  9. Offline

    travja

    Just give a status report when you are done testing!
     
  10. Offline

    catchaser9620

    same error: Wrong method arguments used for event type registered
     
  11. Offline

    travja

    Is there any line by that....
     
  12. Offline

    catchaser9620

    no it just says that in the server console
     
  13. Offline

    travja

    I'll show you what I use..
    Registering:
    public Listener PL = new PL(this);
    onEnable(){
    this.getServer().getPluginManager().registerEvents(PL, this);
    }
    Listener Constructor:
    public class PL implements Listener {
    public Main plugin;
    public PL(Main m) {
    this.plugin = m;
    }
    }
    Event Handling:
    @EventHandler
    public void onJoin(PlayerJoinEvent event){
    }


    That's how I do it.... Everything works for me.....
     
  14. Offline

    catchaser9620

    I fixed it it was the public void onInteract(PlayerInteractEvent e) { i got rid of the SignChangeEvent part in it
     
  15. Offline

    travja

    Ok, that's what I was kind of trying to say earlier, but YAY! And good luck, and remember we are always here if you need us!
     
    catchaser9620 likes this.
  16. Offline

    catchaser9620

    Ok i sorta fixed it the sign still wont place though
     
  17. Offline

    travja

    ok.... Did you follow a similar code from the video?
     
  18. Offline

    catchaser9620

    i havent watched the video yet me bro stole my head phones and my parents yell at me if i listen to anything with out head phones on :(
     
  19. Offline

    travja

    Lol, I haven't watched that video in a while so I don't quite remember but at one point I did make a redcarpet plugin.... So when you get a chance watch the vid. And Good luck!
     
  20. Offline

    catchaser9620

    ok i sort of got it it posts the sign but it doesnt put it on the chest lol
     
  21. Offline

    travja

    oh, ok, are you using Material.SIGN or Material.WALL_SIGN?
     
  22. Offline

    catchaser9620

    e.getItem().getType() == Material.SIGN
    then later do the : e.getClickedBlock().getRelative(f).getLocation().getBlock().getState().setType(Material.WALL_SIGN);
     
  23. Offline

    Thumbz

    Alright, so I'm doing something similar to this involving placing cacti on grass and I've found that if you try to place an unplaceable block it doesn't register as RIGHT_CLICK_BLOCK, but instead RIGHT_CLICK_AIR.

    To test it, just do this:
    Code:
        @EventHandler
        public void onPlayerInteract(PlayerInteractEvent event)
        {
            if(Action.RIGHT_CLICK_AIR == event.getAction())
            {  log.info("[NaturalPlacement] AirRightClick!");
     
                    if(Action.RIGHT_CLICK_BLOCK == event.getAction())
            {  log.info("[NaturalPlacement] BlockRightClick!");
            }
    And try right clicking grass with a cacti in hand, and then sand. Then try it with a rose, and you'll get the opposite. I have no idea why, and, what's worse, is that you can't get the block that was clicked if it returns rightclickair.
     
Thread Status:
Not open for further replies.

Share This Page