Solved Weird issue which I can't seem to fix...

Discussion in 'Spigot Plugin Development' started by Kieraaaan, Jun 11, 2017.

Thread Status:
Not open for further replies.
  1. I'm coding a plugin and I came across a weird issue which I have tried to tackle numerous ways but it keeps defeating me. I am making a MoTD plugin and I have set the command to check if in the config.yml the "message" is empty so then it would send the player a message saying there is no MoTD.

    But whenever I type /motd set "message" and then I type /motd play (which sends you what the MoTD currently is, even though the "message" has text in it, it still says there is no MoTD which is weird. I have tried adding a return true; to stop it from saying that but then when I type /motd play and there is no message it doesn't say that.

    Here is the code:
    Code (Text):
    if (!sender.hasPermission("motd.play")) {
                                                        sender.sendMessage(
                                                                "§cYou don't have permission to use this command.");
                                                    } else {
                                                        if (args[0].equalsIgnoreCase("play")) {
                                                            sender.sendMessage(getConfig().getString("message",
                                                                    "§cConfig.yml file error."));
                                                            return true;
                                                        }
                                                        if (getConfig().getString("message") != "") {
                                                            sender.sendMessage("§cThere is currently no MoTD set.");
                                                        }
    Let's just say there is a message in "message".
    Could someone please give me a solution to this issue!

    Thank you.
     
  2. You have already made the same thread a few hours ago and i told you the solution and you made it with your own way and locked the thread.
     
  3. This isn't the same issue... Last time I couldn't check for the string but now it keeps saying that there is no message yet there is.
     
  4. Use String#equals() to compare strings.
     
  5. when u set the config, do you call saveConfig() after?


    Sent from my iPhone using Tapatalk
     
  6. yes i do.
     
  7. its all solved now. thank u all for ur help.

    no more threads going up.
     
Thread Status:
Not open for further replies.