Setting Sign Text

Discussion in 'Plugin Development' started by FuZioN720, May 29, 2013.

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

    FuZioN720

    Hello, I'm having trouble setting text on sign i thought i had my code right but it's giving me an error in the console on the setline code, Here is my code, also this code is in the player interact event:
    Code:java
    1.  
    2. if (event.getAction() == Action.LEFT_CLICK_BLOCK){
    3. ItemStack item = player.getItemInHand();
    4. Block block = event.getClickedBlock().getLocation().add(0,2,0).getBlock();
    5. if(item.getType().equals(Material.NETHER_STAR)){
    6. if (item.hasItemMeta() == true){
    7. if (item.getItemMeta().getDisplayName().equals(ChatColor.DARK_PURPLE + "" + ChatColor.BOLD +"Hearthstone")){
    8. event.getClickedBlock().getLocation().add(0,1,0).getBlock().setType(Material.CHEST);
    9. event.getClickedBlock().getLocation().add(1,1,0).getBlock().setType(Material.CHEST);
    10. event.getClickedBlock().getLocation().add(0,1,1).getBlock().setType(Material.SIGN_POST);
    11. Sign sign = (Sign)block.getState();
    12. sign.setLine(0, "[Shop]");
    13. sign.setLine(1, player.getName());
    14. player.sendMessage(ChatColor.GREEN + "Shop Created!");
    15. event.setCancelled(true);
    16. }
    17. }
    18. }
    19. }
    20.  
     
  2. Offline

    Nitnelave

    When you are reporting an error from the console, ALWAYS include the error, and point out the line mentioned in the error.
    Here, the problem is that you set the block
    event.getClickedBlock().getLocation().add(0,1,1) to a sign, but you're casting the block event.getClickedBlock().getLocation().add(0,2,0) to a sign on the line Sign sign = (Sign)block.getState();
    It can't work, only when you click on a sign.
     
  3. Offline

    FuZioN720

Thread Status:
Not open for further replies.

Share This Page