Giving a sign custom data for reference in code.

Discussion in 'Plugin Development' started by Shzylo, Sep 6, 2013.

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

    Shzylo

    I am working on a minigame plugin, and I want to give my signs a type of data to read from, so I don't have to check each sign line to make sure its a certain sign, but instead if that sign has those certain lines, to give it that custom data. This is my current setup:

    Code:java
    1. @EventHandler
    2. public void placedSign(SignChangeEvent e) {
    3. String[] lines = e.getLines();
    4.  
    5. if (lines[0].equalsIgnoreCase("[epb]")) {
    6. e.setLine(0, ChatColor.WHITE + "[" + ChatColor.AQUA + "E" + ChatColor.RED + "PB" + ChatColor.WHITE + "]");
    7.  
    8. if (lines[1].equalsIgnoreCase("ready")) {
    9. e.setLine(1, ChatColor.GREEN + "Right-Click");
    10. e.setLine(2, ChatColor.GREEN + "To Ready");
    11. } else
    12. e.setLine(1, ChatColor.RED + "ERROR!");
    13. }
    14. }
    15.  
    16. @EventHandler
    17. public void rightClickSign(PlayerInteractEvent e) {
    18. Player p = e.getPlayer();
    19. Block b = e.getClickedBlock();
    20. Action act = e.getAction();
    21.  
    22. if(b != null) {
    23. if (act == Action.RIGHT_CLICK_AIR || act == Action.RIGHT_CLICK_BLOCK || act == Action.LEFT_CLICK_AIR || act == Action.LEFT_CLICK_BLOCK) {
    24. if (b.getType().equals(Material.WALL_SIGN) || b.getType().equals(Material.SIGN_POST) || b.getType().equals(Material.SIGN)) {
    25. // ?
    26. }
    27. }
    28. }
    29. }

    Again, I would like to give signs with certain information on it certain data to read from later.

    Ex: A sign's first line is "[epb]" so I give it data, so later on, I call a method that handles signs with that data when it is clicked.
     
  2. Offline

    Compressions

    Shzylo I don't really understand what you're asking. Try to use proper grammar.
     
  3. Offline

    Shzylo

    Sorry about that, I am always rushing when posting. I have updated the bottom of the post so you could read it better.
     
  4. Offline

    Forseth11

    Shzylo just forget the data idea and check the first line or save the sign location in the config for latter use.
     
Thread Status:
Not open for further replies.

Share This Page