Solved Sign Format Help

Discussion in 'Plugin Development' started by MrGriefer_, Jan 17, 2018.

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

    MrGriefer_

    Hello everyone,

    I'm working on my mini game plugin and decided to create just a simple leaderboard signs with the format:
    Line 1: Prefix
    Line 2: Kills: AMOUNT
    Line 3: #RANK
    Line 4: Player name

    I'm trying to check if the sign's line 2 is the stats, but the problem is how can I get the stat name without the colon mark and getting the amount.

    Example (open)
    [​IMG]
     
    Last edited: Jan 17, 2018
  2. @MrGriefer_
    <your string> = <your string>.replace("Shots: ", "");
    then you should be left with 7926
     
  3. Offline

    MrGriefer_

    How to get the stat type? Like shots or kills without anything else
     
  4. @MrGriefer_

    String line2 = sign.getLine(1);
    String[] lineArray = line2.split(":");
    String name = lineArray[0];

    That should leave you with Shots if you have Shots: 234
     
  5. Offline

    MrGriefer_

    Using .split(":"); won't really work because there is a space. Shots: 7926.
     
  6. Offline

    timtower Administrator Administrator Moderator

  7. Offline

    MrGriefer_

    I don't think that will work when getting the stat name. How do you get it like this:
    PHP:
    if (StatisticType.getStatType(sign.getLine(1).replace(?, ?)) != null)
     
  8. Offline

    timtower Administrator Administrator Moderator

    @MrGriefer_ If you have a set format that is required then you can split on this: ": ", before is the stat type, after the value.
     
  9. Offline

    MrGriefer_

    Hmm... Weird doesn't seem to work.

    PHP:
    String[] stat sign.getLine(1).split(": ");
    if (
    StatisticType.getStatType(stat[0]) != null)
    Used println to check if it works but it doesn't seem to work.
     
  10. Offline

    timtower Administrator Administrator Moderator

    @MrGriefer_ What doesn't work then?
    Did you print the line, the values in stat, the return of getStatType?
     
  11. Offline

    v8web

    then you should be left with 7926
     
  12. What is the goal above this?
    You could save the location of the block to a file, and save the stats to a file, and then you could use the sign as write-only.
     
Thread Status:
Not open for further replies.

Share This Page