Replace doesn't work.

Discussion in 'Spigot Plugin Development' started by commandROD, Feb 22, 2020.

Thread Status:
Not open for further replies.
  1. Hello,
    I'm trying to make a plugin and the replace just doesn't work.
    Can someone help me?
    Screenshot of the code:
    https://prnt.sc/r66cse
    https://prnt.sc/r66dbv
    [​IMG]
    (I will save you some time, replaceAll and replaceFirst doesn't work for some reason.)
     
  2. First: The problem is that the return type of p.getGameMode() is not a string. You should check what object the getGameMode() method returns and how you can get the name of the game mode.

    Second: Is getConfig().getString("prefix" + "Commands.Gamemode") right? Because it will return the string of the path "prefixCommands.Gamemode" and not of the path "prefix" and the path "Commands.Gamemode". I think it should be like so:

    Code (Java):
    getConfig().getString("prefix") + getConfig().getString("Commands.Gamemode")
     
  3. I’m busy at the moment, I will try it later and I’ll let you know
    Thanks :)
     
  4. You should really listen to your IDE, as it probably tells you exactly what the error is if you hover over that little red squiggly underline.
     
  5. I think that is fot the "p.getGameMode"
    Code (Text):
    if(p.getGameMode() == GameMode.CREATIVE) {
                                    p.sendMessage(Utils.chat(getConfig().getString("Prefix" + "Commands.Gamemode").replace("<gamemode>", "creative")));
                                    }
    Try with all gamemodes.
     
  6. BlackNike6 Thank you!
     
    • Like Like x 1
Thread Status:
Not open for further replies.