Solved Function replace

Discussion in 'Plugin Development' started by Clybzotik, Jan 11, 2019.

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

    Clybzotik

    Hello, I ran into such a problem: I cannot replace part of a string with an integer type, I get an error. The method replace (char, char) in the type String is not applicable for the arguments (String, int)

    Sorry for bad english
     
  2. Offline

    CraftCreeper6

    @Clybzotik
    I assume you're doing this

    string#replace("t", 1)
    String#replace takes in two arguments, both as chars. Or characters.

    In order to make yours correct you must use

    string#replace('t', (char)1)
     
  3. Offline

    Clybzotik

    I tried to do it but still get an error. Here is my code:
    PHP:
    s.replace(" %X"killer.getLocation().getBlockX());
     
  4. Offline

    CraftCreeper6

    @Clybzotik
    Us
    Code:
    s = s#replaceAll("%X", killer#getLocation()#getBlockX())
     
  5. Offline

    torpkev

    Couldn't you just put .toString() on the end of the getBlockX() ?
     
  6. Offline

    KarimAKL

    @Clybzotik Something like this should work:
    Code:Java
    1. s = s.replace(" %X", ""+killer.getLocation().getBlockX());
     
  7. That should work
     
Thread Status:
Not open for further replies.

Share This Page