Sign Questions

Discussion in 'Plugin Development' started by chriztopia, Nov 4, 2012.

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

    chriztopia

    I want to set a sign so that if it is using my plugin it can only be broken by someone with permission. Also I am having a problem with LWC and Essentials showing text when you click a sign. How can I stop this?
     
  2. Offline

    gomeow

    To check if they have permission:
    on the event:
    Code:
    if(event.isCancelled(false)) { //checks to see if another plugin did not cancel it,
    //Do what you want to do
    }
     
  3. Offline

    cman1885

    If I recall isCancelled takes no parameters? It wouldn't make sense for it to take params.
     
  4. Offline

    gomeow

    cman1885
    maybe, well change it to:
    Code:
    if(event.isCancelled() == false) { //checks to see if another plugin did not cancel it,
    //Do what you want to do
    }
     
  5. Offline

    cman1885

    if(!event.isCancelled()) more simple/elegant
     
    Canownueasy likes this.
  6. Offline

    Sheepii

    uh try this
    Code:
        @EventHandler
        public void onplayerBreakASignYo(BlockBreakEvent event)
        {
     
        if(event.getBlock().getType() == Material.SIGN){
            Sign sign =  (Sign) event.getBlock();
            if(sign.getLine(1).equalsIgnoreCase("Whatever your sign says"))
            {
                if(event.getPlayer().hasPermission("permission.node"))
                {
                    return;
                }
                else
                    event.setCancelled(true);
                event.getPlayer().sendMessage("Yo dude, you don't have permission to mess up this sign.");
            }
           
        }
     
  7. Offline

    gomeow

    I would use !event.isCancelled() because then it checks if another plugin cancelled it
     
  8. Offline

    Sheepii

    Code:
    @EventHandler
     
    public void onPlayerInteractWithASignHurrDurr(PlayerInteractEvent event)
     
    if(event.isCancelled())
     
    {
     
    if(event.getClickedBlock().getType() == Material.SIGN)
     
    {
     
    //Stuff you want it to do.
     
    }
     
  9. Offline

    gomeow

    Why would you reserve a post? It's not even your thread
     
  10. Offline

    Sheepii

    I was trying to think of what to say lol
    This post has been edited 6 times. It was last edited by SaintMotherfuckingX A moment ago.
     
  11. Offline

    gomeow

    You mean !event.isCancelled()?
     
  12. Offline

    Sheepii

    No. Why would you check if it's not cancelled. LWC is cancelling the event PlayerInteractEvent due to permissions being on the sign. LWC's mentality:

    Code:
    @EventHandler
     
    public void onPlayerTouchMyF'inSigns(PlayerInteractEvent event)
     
    if(event.getBlockClicked().getType() == Material.SIGN)
    Sign sign =(Sign) event.getBlockClicked();
     
    if(playerssigns.contains(sign.getLine(1).equalsIgnoreCase(player.getName()))
    if(playersign.haspermissiontodoanythingwiththesign() == false)
    event.setCancelled();
    You need to say, "Even though this scumbag plugin is cancelling the event, I want you to do it anyways." With his code, basically java is going, I really don't know what is going on, but something is stopping me from doing something. Think of it as an invisible barrier, that the plugin can't get around, and by adding event.isCancelled() it's saying, oh, you're being cancelled, oh well, do it anyways because my plugin is more important than LWC.
     
  13. Offline

    chriztopia

    Just wondering buy wouldnt event.setcancel also stop my plugin? and would I need to use LWC permissions such as Check for the LWC permissions and if it exists then do Event Cancel.
     
  14. Offline

    Sheepii

    Because it returns a true or false statement. setCancelled() can only be a true or false statement. Basically, you're seeing if it's cancelled, if another plugin is cancelling it, just do it anyways. Think of the setCancelled() as coming to a fork in the road. And you can go one way, or you can go the other, and by not seeing if the event is cancelled, you basically don't even know if you're at the fork in the road, you're just walking straight into the sign that's telling you to go left or right and you're not going any further. You can also set Priority.HIGHEST on your eventhandlers.
     
Thread Status:
Not open for further replies.

Share This Page