splitting a players name

Discussion in 'Plugin Development' started by nitrousspark, Nov 25, 2012.

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

    nitrousspark

    im trying to make a random nicknamer with the colors and im trying to place different stuff between peoples names, how do i do this
     
  2. Offline

    Bavestry

    You probably need to give more info... but if you just want to split the player's name at any point, just try using one of the vowels.
    Code:
    String name = player.getName();
    
    if(name.contains("a"){
    name = name.split("a") + "What to add to the name inbetween everything and the every letter a";
    }
    Pretty sure that's how splitting strings works. Someone else can probably correct me if I'm wrong.
     
  3. Offline

    nitrousspark

    ok now its giving me an error

    int r1 = new Random().nextInt(4) + 1;
    String name = target.getName();
    if (name.contains("a")) {
    name = name.split("a") + r1;
    }

    its saying, "name.split("a") + r1", is an error

    The operator + is undefined for the argument type(s) String[], int

    any help?

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 30, 2016
  4. Offline

    Bavestry

    I have no idea honestly. You'll have to wait for someone else to answer.. :/
     
  5. Offline

    nitrousspark

    i know im waiting
     
  6. Offline

    QuantumDev

    Your "name" variable is a string; the name.split("a") function returns an array of Strings.
     
    Bavestry likes this.
Thread Status:
Not open for further replies.

Share This Page