Error in my code?

Discussion in 'Plugins for Nukkit' started by JackboyPlay, 19/11/16.

  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
Dismiss Notice
We welcome you on our site. This site is devoted to the Nukkit project and all that is connected with him. Here you can communicate, download plugins, also many other things get acquainted! Register the account right now :3
  1. JackboyPlay

    JackboyPlay Пользователь

    Messages:
    19
    Likes Received:
    1
    Minecraft:
    JackboyPlay
    Hello if I click on a Sign I'll get a nullpointerexception on line 20
    PHP:
    @EventHandler
    public void onInteract(PlayerInteractEvent e){
    Player player e.getPlayer();
    Block block e.getBlock();
    if(
    block.getId() == 63 || block.getId() == 68){
    BlockEntitySign schild = (BlockEntitySign)     Server.getInstance().getLevelByName(player.getLevel().getName()).getBlockEntity(block.getLocation().getDirectionVector());
    Line 20||          if(schild.getText()[0].equalsIgnoreCase("§1[§bItem§1]")){
    player.sendMessage(schild.getText()[0]);
    new 
    FreeSchilder();
    FreeSchilder.openSchild(schildplayer);
    }
    }
    }
    I dont knwow why I'll get this exception because all lines on the sign contains a text/letter

    PS: If you answer please answer in English or German
    PSS: Sorry if this is the wrong section where I post this I cant ready this language on this site...
     
  2. fromgate

    fromgate Administrator

    Messages:
    677
    Likes Received:
    191
    Hi!
    I think, you don't need to use: block.getLocation().getDirectionVector()

    try this:
    BlockEntitySign schild = (BlockEntitySign) player.getLevel().getBlockEntity(block);

    or

    BlockEntitySign schild = (BlockEntitySign) player.getLevel().getBlockEntity(block.getLocation());
     
    JackboyPlay likes this.

Share This Page