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:


    Code:
    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:


    Code:
    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[i] + " ";
     
                        }
     
                        Bukkit.getServer().broadcastMessage(ChatColor.RED + "[S]" + 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. Offline

    raGan.

    there's no need to make 2 threads, just edit the first one
     
  3. Offline

    NoLiver92

    also have you looked in the plugin.yml? you should have a section like this:

    commands:
    shout:
    muteshout:
    <any command here>
     
  4. Offline

    boss86741

    Here is plugin.yml:

    Code:
    main: com.boss86741.plugins.ShoutCraft.ShoutCraft
    name: ShoutCraft
    version: 0.1.5
    author: boss86741
    description: Adds shout messages to your server. Works with Herochat and PermissionsEX.
    depend: [Herochat, Vault]
    prefix: ShoutCraft
    website: http://www.thebossserver.com/
    commands:
      shout:
          description: This command makes you broadcast a message to the server globaly.
          permission: shoutcraft.shout
          permission-message: You do not have permission to use this command.
      muteshout:
          description: This command disables another player from shouting
          permission: shoutcraft.mute
          permission-message: You do not have permission to use this command.
    permissions:
      shoutcraft.shout:
          description: Allows you to shout (talk globaly) with the timer.
          default: true
      shoutcraft.mute:
          description: Allows a mod or admin to mute a player from shouting.
          default: op
     
  5. Offline

    Gravity Retired Staff

    Duplicate thread, locked.
     
Thread Status:
Not open for further replies.

Share This Page