[JAVA] Adding dashes "-" back to Minecraft's UUIDs

Discussion in 'Plugin Development' started by Quackster, May 27, 2014.

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

    Quackster

    Hello

    I worked on this for my server and I store the UUID's with dashes, so when I had to grab the UUID from Minecraft's API it returned it wthout dashes so I created a function that adds them back

    Code:
    public static String insertDashUUID(String uuid) {
    StringBuffer sb = new StringBuffer(uuid);
    sb.insert(8, "-");
     
    sb = new StringBuffer(sb.toString());
    sb.insert(13, "-");
     
    sb = new StringBuffer(sb.toString());
    sb.insert(18, "-");
     
    sb = new StringBuffer(sb.toString());
    sb.insert(23, "-");
     
    return sb.toString();
    }
    
    Example

    I only added this because it was easier than doing player.getUniqueId().toString().replace("-", "") every time I wanted to grab their UUID.
     
  2. Offline

    mbaxter ʇıʞʞnq ɐ sɐɥ ı

    Moved. Not a Tool.
     
  3. Offline

    Garris0n

  4. Offline

    Quackster

    My apologies. I thought it didn't belong because of

     
Thread Status:
Not open for further replies.

Share This Page