Error in my code?

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(schild, player);
			}
		}
	}
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...
 

fromgate

Administrator
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());
 
Top