Looping through signs

Discussion in 'Plugin Development' started by BillyBobJoe168, Apr 12, 2014.

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

    BillyBobJoe168

    Hi guys, I am making a minigame plugin and I'm sure you all have seen a plugin with join signs that show the number of players in an arena. I would like to know how to do this. I already have the code for join signs but the problem is, I want to get all signs that have the first line say [PVC] and the second line say join to display the number of players. I do not want a sign change event because this would not work out when I reload the server. I have thought of a way which is too loop through all the signs in a world to pick out the signs that have the correct lines 1 and 2 and then be able to edit the 4th line. I do not need the code to edit the 4th line just the code (or tips) for looping through all the signs or even better, if someone would give me a better idea. Thanks:)
     
  2. Offline

    amhokies

    Make it so that when you place the signs and put a certain line of text at the top, they become the "status" signs, and store the location of the sign into a configuration file. Then when the server starts up, you can simply load the signs into memory and be able to access each of them by the location.
     
  3. Offline

    BillyBobJoe168

    amhokies oh ok I saw this idea somewhere just didn't know how to implement it..? So how would you "get" the sign from the config if you store the coordinates?
     
  4. Offline

    xTrollxDudex

    BillyBobJoe168
    Well you could do a loop through world loaded chunks and get tile entities, check if instanceof Sign, cast and get line, or do as amhokies said and construct a new location for the x, y, z, and world, then getBlock() from that location
     
  5. Offline

    BillyBobJoe168

    Oh I get it is it something like if (getBlock(worldname, x, y, z) == Material.Sign) { sign.setLine(4, line here); } or something similar to that? Haven't tested this.
     
  6. Offline

    xTrollxDudex

    BillyBobJoe168
    It's a Location method
    Ex
    PHP:
    Location loc // ...
    Block at loc.getBlock();
     
  7. Offline

    JBoss925

    Use that ^^ either ^^ or store the locations when u update the sign and remove them when u update them so that they no longer comply with ur plugin's sign rules then iterate through them and change the fourth line. This method may cause less lag, but it's much more complicated than ^^
     
  8. Offline

    BillyBobJoe168

    k thanks:D
     
Thread Status:
Not open for further replies.

Share This Page