Solved Reload Code not working.

Discussion in 'Spigot Plugin Help' started by YouDoDis, Jan 8, 2020.

  1. Hello Spigoters!

    I'm trying to /shreload working but it's not. When I run it thru console, its just showing me the command. There are no errors or anything.

    Code (Text):
    if (cmd.getName().equalsIgnoreCase("shreload")) {
                   if (sender instanceof org.bukkit.entity.Player && !sender.hasPermission("simplehelp.reload")) {
                    for (String s: getConfig().getStringList("PermMSG"))
                     sender.sendMessage(colorize(s.replace("%player%", sender.getName())));

                    return true;
                   }
                 
                   reloadConfig();


                   {
                    for (String s: getConfig().getStringList("ReloadMSG"))

                     sender.sendMessage(colorize(s.replace("%player%", sender.getName())));
                   }
                  }
            }
     
  2. Don't know if this is the mistake, but you have one bracket "{" more than needed.

    Try this:
    Code (Java):
    if (cmd.getName().equalsIgnoreCase("shreload")) {
        if (sender instanceof org.bukkit.entity.Player && !sender.hasPermission("simplehelp.reload")) {
            for (String s : getConfig().getStringList("PermMSG")) {
                sender.sendMessage(colorize(s.replace("%player%", sender.getName())));
            }

            return true;
        }
                 
        reloadConfig();

        for (String s : getConfig().getStringList("ReloadMSG")) {
            sender.sendMessage(colorize(s.replace("%player%", sender.getName())));
        }
    }
     
  3. please provide the full onCommand()-Method.
    I think that the console is printing out the usage of that command (plugin.yml -> commands -> yourCommand -> usage). This happens when you return false.
     
  4. Thanks! That solved it.
     
  5. I'm sure the IDE would properly recognize mistakes like this, yes, everyone tells you: "Don't follow fixes from IDE because more than half the time they are wrong", but as for brackets, it would tell you whether u need one more or you have one extra one. Atleast it is for me (Eclipse IDE).