Solved [Help] Signs...

Discussion in 'Plugin Development' started by XvBaseballkidvX, Mar 15, 2014.

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

    XvBaseballkidvX

    Hello everyone!

    I am currently working on a minigame lobby plugin and am having a horrible time with signs...

    For some strange reason I am unable to grab the sign's text. However I am able to get the location, get the world, etc. I just can't seem to get the signs text!

    Here is my SignUtil class:
    Code:java
    1. public class SignUtil {
    2.  
    3. private static SignUtil u = new SignUtil();
    4.  
    5. public static SignUtil getManager() {
    6. return u;
    7. }
    8.  
    9. ArrayList<Sign> signs = new ArrayList<Sign>();
    10.  
    11. public void addSign(Block block) {
    12. if (block.getState().getType() == Material.SIGN_POST || block.getState().getType() == Material.WALL_SIGN || block.getState().getType() == Material.SIGN) {
    13. Sign sign = (Sign) block.getState();
    14. signs.add(sign);
    15. }
    16. }
    17.  
    18. public void removeSign(Block block) {
    19. if (block.getState() instanceof Sign) {
    20. Sign sign = (Sign) block.getState();
    21. for (Sign s : signs) {
    22. if (sign.getLine(1).equalsIgnoreCase(s.getLine(1))) {
    23. signs.remove(s);
    24. }
    25. }
    26. }
    27. }
    28.  
    29. public void updateAllSigns() {
    30. for (Sign sign : signs) {
    31. sign.update();
    32. }
    33. }
    34.  
    35. public List<Sign> getSigns() {
    36. return signs;
    37. }
    38.  
    39. public void startUpdateTask() {
    40. new BukkitRunnable() {
    41. public void run() {
    42. for (Sign sign : signs) {
    43. //Where I need to get the text and update the signs with player count data etc.
    44. }
    45. }
    46. }.runTaskTimer(Main.getInstance(), 20, 20);
    47. }
    48.  
    49. public void say(String msg){
    50. System.out.println(msg);
    51. }
    52. }


    Thank you for reading!
    All help is much appreciated!

    NOTE: The signs are being added to the list correctly! I am able to retrieve other data from the signs, just not the text! (Which is what I need!)

    EDIT: The sign's text returns nothing when there is something on it. I even did a check, this is me trying to get the data:

    Code:
    String line = sign.getLine(1);
    System.out.println("Line: " + line);
    This is what I recieved in the console:
    Code:
    Line: 
     
  2. Offline

    Crafted Evil

    Change that to:
     
  3. Offline

    XvBaseballkidvX

    Crafted Evil I don't even call that method... So that can't be the problem lol

    EDITS: Damn typos!
     
  4. Offline

    Crafted Evil

    What are you trying to do? I might have read wrong then. Are you trying to get the information off the sign then edit the sign is it equals something or....?
     
  5. Offline

    XvBaseballkidvX

    Crafted Evil This is what I am trying to do:
    1. Get the signs lines
    2. Use those lines to set the new data for the sign (Like map name, Arena id, etc);
    3. Update the sign

    When ever I call sign.update() it clears the signs data (Let me do some more testing, it might be something else that clears the signs text) :l
     
  6. Offline

    Sir_Mr_Bman

    Crafted Evil If I'm correct, he's trying to do something like detect if a sign says [Map] and then the plugin would control what map the sign goes to... or something of the sort.
     
  7. Offline

    Garris0n

    1. You should check if the Material is equal to WALL_SIGN or SIGN_POST, getting the blockstate is relatively expensive and it's inefficient to check with it.
    2. You know that getLine(1) will return the second line of the sign right? Indices start at 0 in Java. If you did not know that I could see it being problematic.
     
  8. Offline

    Crafted Evil

    Ah, okay.
     
  9. Offline

    XvBaseballkidvX

    Garris0n I am aware :p The problem is I can't get the text on the sign, I have no idea why... I am able to retrieve all other sign data. *cries* ;-;

    Okay, I think this will help clear things up.

    Code:
    Code:java
    1. public void startUpdateTask() {
    2. new BukkitRunnable() {
    3. public void run() {
    4. for (Sign sign : signs) {
    5. sign.setLine(0, sign.getLine(0));
    6. sign.setLine(1, sign.getLine(1));
    7. sign.setLine(2, "Something");
    8. sign.update();
    9. }
    10. }
    11. }.runTaskTimer(Main.getInstance(), 20, 20);
    12. }


    As soon as I create the sign:
    http://prntscr.com/318kwk

    After the sign updates:
    http://prntscr.com/318kyt

    This is honestly driving me insane!

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 7, 2016
  10. Offline

    Sir_Mr_Bman

    Garris0n XvBaseballkidvX So I decided to look into the materials potentially being the same. I don't think they are (from what I can tell). However, you can check if the sign in question is a wall sign with a boolean method isWallSign()


    The text moves down 1 line. That could be your issue!!

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 7, 2016
  11. Offline

    XvBaseballkidvX

    Sir_Mr_Bman That isn't the issue. Look at my update task, I have the signs's text set to "Something" on Line 2.
    Even if the text moved down one line where did the "[Click to Join]" sign text go?

    Any ideas on why this is happening?

    Bump ;-;

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 7, 2016
  12. Offline

    XvBaseballkidvX

    I fixed it :3
     
Thread Status:
Not open for further replies.

Share This Page