Commands register but don't work...

Discussion in 'Plugin Development' started by boss86741, Dec 1, 2012.

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

    boss86741

    I go in-game with my plugin, do /shout and nothing happens. Nothing.

    Source for ShoutCraft.class:

    package com.boss86741.plugins.ShoutCraft;

    import org.bukkit.plugin.java.JavaPlugin;

    /* Below is the code that tells java to use the /shout command in the
    * ShoutCraftCommands.class file. It also tells it what to say to console on the start of
    * the server.*/

    public class ShoutCraft extends JavaPlugin {
    @Override
    public void onEnable() {
    getLogger().info("Shout command and timer working! Minecraft version: 1.4.5");
    getCommand("shout").setExecutor(new ShoutCraftCommands(this));
    getCommand("muteshout").setExecutor(new ShoutCraftCommands(this));
    }

    @Override
    public void onDisable() {
    getLogger().info("OK, ShoutCraft has successfully been disabled!");
    }
    }

    Source for ShoutCraftCommands.class:

    package com.boss86741.plugins.ShoutCraft;

    import net.milkbowl.vault.chat.Chat;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandSender;
    import org.bukkit.entity.Player;
    import org.bukkit.Bukkit;
    import org.bukkit.ChatColor;
    import org.bukkit.command.CommandExecutor;
    import org.bukkit.plugin.RegisteredServiceProvider;

    public class ShoutCraftCommands implements CommandExecutor {
    private ShoutCraft plugin;

    public ShoutCraftCommands(ShoutCraft plugin) {
    this.plugin = plugin;
    }
    // Here is the chat code!
    public static Chat chat = null;

    private boolean setupChat()
    {
    RegisteredServiceProvider<Chat> chatProvider = Bukkit.getServer().getServicesManager().getRegistration(net.milkbowl.vault.chat.Chat.class);
    if (chatProvider != null) {
    chat = chatProvider.getProvider();
    }

    return (chat != null);
    }
    // Below is the command code.


    public boolean onCommand(Player sender, Command cmd, String label, String prefix, String[] args) {
    if(cmd.getName().equalsIgnoreCase("shout")) {
    Player s = (sender);
    String g = (prefix);

    String message = "";

    if (args.length > 1) {
    for (int i = 1; i < args.length; ++i) {
    message += args + " ";
    }
    Bukkit.getServer().broadcastMessage(ChatColor.RED + "" + ChatColor.WHITE + "=[" + g + ChatColor.WHITE + "]=" + s + ChatColor.WHITE + ":" + message);
    }else{
    s.sendMessage(ChatColor.RED + "Usage: /shout <your message here>");
    }
    return true;
    }
    return false;
    }

    public boolean onCommand(String[] args, CommandSender sender, Command cmd) {
    if(cmd.getName().equalsIgnoreCase("muteshout")) {
    CommandSender s = (sender);
    String t = (args[0]);

    Bukkit.getLogger().severe(t + " has been muted by " + s + "! To unmute them, do /unmute <player>!");

    if(cmd.getName().equalsIgnoreCase("shout")) {
    }


    return true;
    }
    return false;
    }


    @Override
    public boolean onCommand(CommandSender arg0, Command arg1, String arg2, String[] arg3) {
    return false;
    }
    }
     
  2. try using an IDE and add @Override on top of ever command function, that it will tell you make a mistake at some point
     
Thread Status:
Not open for further replies.

Share This Page