Development Assistance Config Problems

Discussion in 'Plugin Help/Development/Requests' started by piggykiller100, Feb 22, 2015.

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

    piggykiller100

    Code:
        public void onEnable() {
            getConfig().options().copyDefaults(true);
            saveConfig();
    
        }
    
        public boolean onCommand(CommandSender sender, Command cmd, String label,
                String[] args) {
            Player player = (Player) sender;
            if (cmd.getName().equalsIgnoreCase("spam")) {
                if (player.hasPermission("spam.use")) {
                    if (args.length == 1) {
                        @SuppressWarnings("deprecation")
                        Player target = Bukkit.getServer().getPlayer(args[0]);
                        if (target.isOnline()) {
                            sender.sendMessage(ChatColor.DARK_GRAY
                                    + "> "
                                    + ChatColor.GREEN
                                    + "Staff"
                                    + ChatColor.DARK_GRAY
                                    + " > "
                                    + ChatColor.GREEN
                                    + "You have /spam'd "
                                    + target.getName()
                                    + ". Remember, you need proof before /spaming them.");
    
                            if (!(getConfig().isSet(target.getName()))) {
    
                                sender.sendMessage("dudu");
                                getConfig().createSection(target.getName() + "coom");
    
                            }
    
                        } else {
    
                            sender.sendMessage(ChatColor.RED
                                    + "That player is not online at the moment!");
    
                        }
                    } else {
                        sender.sendMessage(ChatColor.RED
                                + "Imporoper usage: /spam <player>");
                    }
                } else {
    
                    sender.sendMessage(ChatColor.RED
                            + "You do not have that permission!");
    
                }
            }
            return false;
        }
    }
    Im trying to make a plugin that logs a players name when they do /spam, and it reads it trough but it dosent make the section help
     
  2. Offline

    scrollbar

    It looks like your onEnable section doesn't register your command at all.
    You need to add this line:
    this.getCommand("spam").setExecutor(this);

    Also you need to implement command executor.
     
  3. Offline

    timtower Administrator Administrator Moderator

    1. If you don't set the executor then it takes the class extending JavaPlugin
    2. JavaPlugin implements CommandExecutor already.
     
Thread Status:
Not open for further replies.

Share This Page