Solved return true; showing as if it's return false;

Discussion in 'Spigot Plugin Development' started by DecisionsYT, May 13, 2016.

Thread Status:
Not open for further replies.
  1. Hey!

    In my command spy plugin, when doing /cmdspy (to show the usage message) I'm getting the thing you'd get if you'd return fasle;

    CODE:

    Code (Text):
    package ChatFilter;

    import java.util.ArrayList;
    import org.bukkit.Bukkit;
    import org.bukkit.ChatColor;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandExecutor;
    import org.bukkit.command.CommandSender;
    import org.bukkit.entity.Player;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    import org.bukkit.event.player.PlayerCommandPreprocessEvent;

    import me.DecisionsYT.Main;

    public class CmdSpy implements Listener, CommandExecutor {
     
    Main plugin;
     
        public CmdSpy(Main passedPlugin) {
            this.plugin = passedPlugin;
        }

          public ArrayList<String> spy = new ArrayList<String>();
     
        @EventHandler
        public void PlayerCommand(PlayerCommandPreprocessEvent e) {
            Player player = e.getPlayer();
            for (Player p : Bukkit.getOnlinePlayers())
              if (this.spy.contains(p.getName()))
                  player.sendMessage(" ");
                  player.sendMessage(ChatColor.translateAlternateColorCodes('&', plugin.getConfig().getString("CmdSpy-Format").replace("{player}", e.getPlayer().getName()).replace("{command}", e.getMessage())));
            }

      public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
     
       
            if (sender.hasPermission("ChatX.CmdSpy")) {
                if (args.length == 0) {
                    sender.sendMessage(ChatColor.translateAlternateColorCodes('&', plugin.getConfig().getString("CmdSpy-Usage")));
                }
             }
         
            if (args.length == 1) {
                if (sender.hasPermission("ChatX.CmdSpy")) {
                    if (args[0].equalsIgnoreCase("On")) {
                        sender.sendMessage(ChatColor.translateAlternateColorCodes('&', plugin.getConfig().getString("CmdSpy-Enabled")));
                        this.spy.add(sender.getName());
                    }
                }
            }
         
                if (sender.hasPermission("ChatX.CmdSpy")) {
                    if (args[0].equalsIgnoreCase("Off")) {
                        sender.sendMessage(ChatColor.translateAlternateColorCodes('&', plugin.getConfig().getString("CmdSpy-Disabled")));
                        this.spy.remove(sender.getName());
                    }
                }
         
            if (!sender.hasPermission("ChatX.CmdSpy")) {
                sender.sendMessage(ChatColor.translateAlternateColorCodes('&', plugin.getConfig().getString("No-Perm-Message")));
            }
     
     
     
        return true;
            }
          }
     
    #1 DecisionsYT, May 13, 2016
    Last edited: May 13, 2016
  2. did you set the command executor?
     
  3. yup
     
  4. Your code is literally irking me, how about you use some else if statements or at least return after each command/statement.
     
Thread Status:
Not open for further replies.