Solved My plugin can't be recognized!

Discussion in 'Plugin Development' started by Gorro_Rojo, May 31, 2013.

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

    Gorro_Rojo

    well, basicly that, i made a plugin, and no matter how many times i see the code, i can't figure it out! please help me! (i've just started the plugin, that's why there's not much to it XD)

    Code:
    package com.gorro_rojo.earthcraft;
     
    //woooo imports!
    import java.io.File;
    import java.util.logging.Logger;
     
    import org.bukkit.ChatColor;
    import org.bukkit.Server;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandSender;
    import org.bukkit.configuration.Configuration;
    import org.bukkit.entity.Player;
    import org.bukkit.inventory.Inventory;
    import org.bukkit.plugin.java.JavaPlugin;
     
    public class EarthCraft extends JavaPlugin {
       
        //Let's get everything nice and clear, here we'll set all the variables
        //-----------------------------------------------
        Logger logger = getLogger();
        Player player;
        Inventory inv;
        Server server;
        CommandSender sender;
        Command cmd;
        String commandLabel;
        Configuration config;
        //-----------------------------------------------
       
       
        @Override
        public void onEnable() {
            File file = new File(getDataFolder() + File.separator + "config.yml");
            if(!file.exists()) {
                this.getLogger().info("Generating config.yml...");
               
                this.getConfig().addDefault("messageprefix", "");
                this.getConfig().options().copyDefaults(true);
                this.saveConfig();
                logger.info("[EarthCraft] Configuration file created");
            }
            this.getServer().getPluginManager().registerEvents(null, null);
        }
        @Override
        public void onDisable() {
            logger.info("[EarthCraft] Disabled!");
        }
       
       
        public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
            if (commandLabel.equalsIgnoreCase("b")) {
                String message = (getConfig().getString("messageprefix") + args[0]);
                //Here I replace every color code to an actual color
                message = message.replaceAll("&0", ChatColor.BLACK + "");
                message = message.replaceAll("&1", ChatColor.DARK_BLUE + "");
                message = message.replaceAll("&2", ChatColor.DARK_GREEN + "");
                message = message.replaceAll("&3", ChatColor.DARK_AQUA + "");
                message = message.replaceAll("&4", ChatColor.DARK_RED + "");
                message = message.replaceAll("&5", ChatColor.DARK_PURPLE + "");
                message = message.replaceAll("&6", ChatColor.GOLD + "");
                message = message.replaceAll("&7", ChatColor.GRAY + "");
                message = message.replaceAll("&8", ChatColor.DARK_GRAY + "");
                message = message.replaceAll("&9", ChatColor.BLUE + "");
                message = message.replaceAll("&a", ChatColor.GREEN + "");
                message = message.replaceAll("&b", ChatColor.AQUA + "");
                message = message.replaceAll("&c", ChatColor.RED + "");
                message = message.replaceAll("&d", ChatColor.LIGHT_PURPLE + "");
                message = message.replaceAll("&e", ChatColor.YELLOW + "");
                message = message.replaceAll("&f", ChatColor.WHITE + "");
                message = message.replaceAll("&k", ChatColor.MAGIC + "");
                message = message.replaceAll("&l", ChatColor.BOLD + "");
                message = message.replaceAll("&m", ChatColor.STRIKETHROUGH + "");
                message = message.replaceAll("&n", ChatColor.UNDERLINE + "");
                message = message.replaceAll("&o", ChatColor.ITALIC + "");
                message = message.replaceAll("&r", ChatColor.RESET + "");
               
                if(args.length < 1) {
                   
                    sender.sendMessage(ChatColor.GOLD +"Not enough arguments!");
                }else{
                    for(Player player: getServer().getOnlinePlayers()) {
                        player.sendMessage(message);
                    }
                }               
                }
               
               
           
            return false;
        }
       
     
    }
     
  2. Offline

    EvilKanoa

    Have you got a plugin.yml file?
     
  3. Offline

    Gorro_Rojo

    yup:
    Code:
    name: EarthCraft Custom Plugin
    main: com.gorro_rojo.earthcraft.EarthCraft
    version: 0.1
    commands:
      b:
        description: Broadcasts a message to the server.
        usage: /b <message>
        permission: ec.b
     
  4. Offline

    AeroUK

    Any error in console?
     
  5. Offline

    Gorro_Rojo

    yeah, large error, how do i copy it?
     
  6. Offline

    Rocoty

    This line:
    Code:
    this.getServer().getPluginManager().registerEvents(null, null);
    Remove it
     
  7. Offline

    Gorro_Rojo

    YES! thank you so much
     
Thread Status:
Not open for further replies.

Share This Page