プラグインのバグのためのプラグインをコーディングしたい(ChestShop)。 プレイヤーが右クリックしたとき(サインの2行目が「B Free」または「Free」、3行目が「Iron_Ingot」)、イベントをキャンセルしてメッセージを送信します。Player sign interact
public void onPlayerInteract(PlayerInteractEvent e){
Player player = e.getPlayer();
if(e.getAction().equals(Action.RIGHT_CLICK_BLOCK) || e.getAction().equals(Action.LEFT_CLICK_BLOCK)){
if(e.getClickedBlock().getState() instanceof Sign){
Sign sign = (Sign) e.getClickedBlock().getState();
if(sign.getLine(2).equals("B Free") || sign.getLine(2).equals("Free")){
if(sign.getLine(3).equals("Iron_Ingot"))
e.setCancelled(true);
e.getPlayer().sendMessage("You can not click this sign");
}
}
}
}
コードの一部が間違っている、私はこれを試してみましたが、それはうまくいきませんでしたか? どのような方法を使用できますか?
Block.getStateが(何ですか)? – TsundereBug
それを使用するブロックを指定します。 – drhopeness
あなたは '@ EventHandler'を忘れましたか? また、イベントが登録されていることを確認してください。 –