Command error

Discussion in 'Plugin Development' started by Verify_x, Mar 2, 2014.

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

    Verify_x

    My command isn't working, I've registered them in the Main class and plugin.yml here's the code for the main class, the command class, and my plugin.yml. All the other commands are working just not the youtube one.
    Code:
    package me.verify.main;
     
    import me.verify.main.InventoryListener;
    import me.verify.main.PlayerListener;
     
    import org.bukkit.plugin.PluginManager;
    import org.bukkit.plugin.java.JavaPlugin;
     
     
    public class Main extends JavaPlugin {
     
     
        public void onEnable() {
            PluginManager pm = getServer().getPluginManager();
           
              pm.registerEvents(new InventoryListener(), this);
              pm.registerEvents(new PlayerListener(), this);
              getCommand("help").setExecutor(new Help());
              getCommand("economy").setExecutor(new EcoHelp());
              getCommand("staff").setExecutor(new StaffList());
              getCommand("cc").setExecutor(new ClearChat());
              getCommand("rules").setExecutor(new Rules());
              getCommand("pl a").setExecutor(new NoPluginShow());
              getCommand("pl").setExecutor(new NoPluginShow());
              getCommand("plugins").setExecutor(new NoPluginShow());
              getCommand("?").setExecutor(new NoPluginShow());
              getCommand("youtube").setExecutor(new Youtube());
           
              System.out.println("cPVP Enabled!");
        }
     
        public void onDisable() {
              System.out.println("cPVP Enabled!");
        }
     
    }

    Code:
    package me.verify.main;
     
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandExecutor;
    import org.bukkit.command.CommandSender;
    import org.bukkit.entity.Player;
     
    public class Youtube implements CommandExecutor{
     
        @Override
        public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] arg3) {
              if((sender instanceof Player)) {
                  Player player = (Player)sender;
                  if(commandLabel.equalsIgnoreCase("youtube")){
                      player.sendMessage("§c§m-------[-§r§fYou§4Tube§c§m-]-------");
                      player.sendMessage("§fAntique§4DZN§f -§c http://bit.ly/NHvvNb");
                      player.sendMessage("§fLeafyIs§4Sleepy§f -§c http://bit.ly/1jJaNI7");
                      player.sendMessage("§c§m-------[-§r§fYou§4Tube Info§c§m-]-------");
                      player.sendMessage("To receive You§4Tube§f rank you must create a video for the server. You §4§l§oNEED§r to have at a minimum of 100 subscribers and 1000 video views to make the cut. You§4Tube§f rank gets the same exact thing §aVIP§f rank gets.");
                   
                  }
            }
            return false;
     
        }
    }
    


    Code:
    name: cPVP
    main: me.verify.main.Main
    version: 0.1
    author: Verify_x
    commands:
        help:
        economy:
        staff:
        cc:
        rules:
        pl:
        pl a:
        ?:
        plugins:
        youtube:
     
  2. Offline

    Minesuchtiiii

    retrurn true;
     
  3. Offline

    mazentheamazin

    Verify_x
    I normally don't use commandLabel, I use cmd i.e
    Code:java
    1. if(cmd.getName().equalsIgnoreCase("youtube")) {
    2. //Send them the message
    3. }
     
    badboysteee98 likes this.
  4. Offline

    badboysteee98

    In your onCommand change your
    Code:java
    1. if (sender instanceof Player) {
    2. }


    To

    Code:java
    1. if (!(sender instanceof Player)) {
    2. }


    Also your onEnable() change your

    System.out.println("Plugin Enabled!");

    To

    Bukkit.getServer().getLogger().info("Plugin Enabled!")
     
  5. Offline

    Minesuchtiiii

    @badboysteee98
    He can also use System.out.println if he wants, it*s the same thing!
     
  6. Offline

    Jombi

    No. That would block him from using the command as a player.

    Code:java
    1. if(commandLabel.equalsIgnoreCase("youtube")){{


    Change to

    Code:java
    1. if(cmd.getName().equalsIgnoreCase("youtube")){
     
  7. Offline

    badboysteee98

    Oh I didn't see that that what he's command was under sorry my mistake.

    I know he can but it's easier when it comes to register events

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 7, 2016
  8. Offline

    Minesuchtiiii

    Dont think so.. it's also a bit more text =)
     
Thread Status:
Not open for further replies.

Share This Page