Solved Plugin Problem (No errors in code, but plugin won't load...)

Discussion in 'Plugin Development' started by Matthiaantje, Aug 30, 2016.

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

    Matthiaantje

    Hay everyone!
    I've another problem here ;(,
    Here's my code
    Code:
    package core;
    
    import org.bukkit.Bukkit;
    import org.bukkit.ChatColor;
    import org.bukkit.Material;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandSender;
    import org.bukkit.entity.Player;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    import org.bukkit.event.inventory.InventoryClickEvent;
    import org.bukkit.event.inventory.InventoryDragEvent;
    import org.bukkit.inventory.Inventory;
    import org.bukkit.inventory.ItemStack;
    import org.bukkit.inventory.meta.ItemMeta;
    import org.bukkit.inventory.meta.SkullMeta;
    import org.bukkit.plugin.java.JavaPlugin;
    
    public class cord extends JavaPlugin{
    
       public static Inventory CoreInv = Bukkit.createInventory(null, 27, ChatColor.GOLD + "The Core");
       {
         ItemStack selector = new ItemStack(Material.COMPASS);
         ItemMeta selectorMeta = selector.getItemMeta();
         selectorMeta.setDisplayName(ChatColor.AQUA + "Server Selector");
         selector.setItemMeta(selectorMeta);
         CoreInv.setItem(10, selector);
         ItemStack warper = new ItemStack(Material.MAGMA_CREAM);
         ItemMeta warperMeta = warper.getItemMeta();
         warperMeta.setDisplayName(ChatColor.GREEN + "Warper");
         warper.setItemMeta(warperMeta);
         CoreInv.setItem(12, warper);
         ItemStack vanity = new ItemStack(Material.RED_ROSE);
         ItemMeta vanityMeta = vanity.getItemMeta();
         vanityMeta.setDisplayName(ChatColor.RED + "Vanity Menu");
         vanity.setItemMeta(vanityMeta);
         CoreInv.setItem(14, vanity);
       }
       public static Inventory SelectorInv = Bukkit.createInventory
           (null, 27, ChatColor.GOLD + "Server Selector");
       {
         ItemStack quake = new ItemStack (Material.FIREWORK);
         ItemMeta quakeMeta = quake.getItemMeta();
         quakeMeta.setDisplayName(ChatColor.AQUA + "Quake");
         quake.setItemMeta(quakeMeta);
         SelectorInv.setItem(10, quake);
         ItemStack skywars = new ItemStack (Material.EYE_OF_ENDER);
         ItemMeta skywarsMeta = skywars.getItemMeta();
         skywarsMeta.setDisplayName(ChatColor.GREEN + "Skywars");
         skywars.setItemMeta(skywarsMeta);
         SelectorInv.setItem(11, skywars);
       }
       
       public static Inventory WarperInv = Bukkit.createInventory
           (null, 27, ChatColor.GOLD + "Warper Menu!");
       {
         ItemStack rank = new ItemStack(Material.DIAMOND);
         ItemMeta rankMeta = rank.getItemMeta();
         rankMeta.setDisplayName(ChatColor.AQUA + "Ranks!");
         rank.setItemMeta(rankMeta);
         WarperInv.setItem(11, rank);
       }
       
       public static Inventory VanityInv = Bukkit.createInventory(null, 54, ChatColor.GOLD + "Vanity Menu!");
       {
         ItemStack vanity = new ItemStack(Material.SKULL, 1);
         SkullMeta vanityMeta = (SkullMeta) vanity.getItemMeta();
         vanityMeta.setOwner("Seska_Rotan");
         vanity.setItemMeta(vanityMeta);
         VanityInv.setItem(10, vanity);
       }
       
       @Override
       public boolean onCommand (CommandSender sender, Command cmd, String label, String[] args)
       {
         if(cmd.getName().equalsIgnoreCase("cchelp"))
         {
           Player player = (Player) sender;
           player.sendMessage(ChatColor.AQUA + "/core - This Will Give You The Core!");
           player.sendMessage(ChatColor.AQUA + "/cchelp - The General Help Command!");
           player.sendMessage(ChatColor.AQUA + "/sb - Simple Broadcast Command!");
           player.sendMessage(ChatColor.AQUA + "/ccreload - Reloads CommandCore!");
         }
         if(cmd.getName().equalsIgnoreCase("core"))
         {
           Player player = (Player) sender;
           player.openInventory(CoreInv);
         }
         if(cmd.getName().equalsIgnoreCase("server"))
         {
           Player player = (Player) sender;
           player.openInventory(SelectorInv);
         }
         if(cmd.getName().equalsIgnoreCase("vanity"))
         {
           Player player = (Player) sender;
           player.openInventory(VanityInv);
         }
         if(cmd.getName().equalsIgnoreCase("warper"))
         {
           Player player = (Player) sender;
           player.openInventory(WarperInv);
         }
         if(cmd.getName().equalsIgnoreCase("ccreload"))
         {
           Player player = (Player) sender;
           player.sendMessage(ChatColor.GREEN + "Config reloaded!");
         }
         if(cmd.getName().equalsIgnoreCase("sb"))
         {
           Player player = (Player) sender;
           if(player.hasPermission("ccore.perms"))
           {
             String message = ChatColor.RED + "";
             for (String part : args) {
              if (message != "") message += " ";
              message += ChatColor.GREEN + part;
             }
             Bukkit.getServer().broadcastMessage
             (ChatColor.GOLD + "[MiniCord]" + " " +  ChatColor.GREEN + message);
           }
           else
           {
             player.sendMessage(ChatColor.RED + "You do have the permissions to use this command!");
           }
         }
         return false;
       }
       
       @EventHandler
       public void onInventoryClick(InventoryClickEvent e, InventoryDragEvent ed)
       {
         if(e.getInventory() == CoreInv)
         {
           
         }
         ed.setCancelled(true);
       }
       
       public void loadConfiguration()
       {
         System.out.println(ChatColor.GREEN + "Config Loaded/Updated!");
       }
       
       public void onEnable()
       {
         getServer().getPluginManager().registerEvents((Listener) this, this);
         System.out.println(ChatColor.GREEN + "CommandCore succesfully Loaded!");
         System.out.println(ChatColor.GREEN + "Loading CommandCore Config!");
         loadConfiguration();
       }
       
    }
    
    Plugin.yml:
    main: core.cord
    name: CommandCordReloaded
    version: 0.1
    author: Matthiaantje
    
    commands:
      core:
      description: Gives The Core
      cchelp:
      description: general help command!
      sb:
      description: general broadcast command!
      ccreload:
      description: general reload command!
      vanity:
      description: Gives Vanity
      server:
      description: Gives Server
      warper:
      description: Gives Warper
       
    permissions:
      ccore.perms:
      default: op
    
    
    Problem: the plugin won't show itself after reloading or restarting... altough it is in the plugins folder...
    Can someone please help me...
     

    Attached Files:

    Last edited: Aug 30, 2016
  2. Online

    timtower Moderator Moderator

  3. Offline

    Zombie_Striker

    @Matthiaantje
    We will not download anything. Either post it in pastebin, or post it here inside the [code][/code] tags.

    Does the server log say that it is registering the plugin? Does it log that the plugin was being enabled? Were there any changes made to the jar before the reload?
     
  4. Offline

    TehCoderHD

    Code:
    package core;
    
    import org.bukkit.Bukkit;
    import org.bukkit.ChatColor;
    import org.bukkit.Material;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandSender;
    import org.bukkit.entity.Player;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    import org.bukkit.event.inventory.InventoryClickEvent;
    import org.bukkit.event.inventory.InventoryDragEvent;
    import org.bukkit.inventory.Inventory;
    import org.bukkit.inventory.ItemStack;
    import org.bukkit.inventory.meta.ItemMeta;
    import org.bukkit.inventory.meta.SkullMeta;
    import org.bukkit.plugin.java.JavaPlugin;
    
    public class cord extends JavaPlugin{
    
        public static Inventory CoreInv = Bukkit.createInventory(null, 27, ChatColor.GOLD + "The Core");
        {
            ItemStack selector = new ItemStack(Material.COMPASS);
            ItemMeta selectorMeta = selector.getItemMeta();
            selectorMeta.setDisplayName(ChatColor.AQUA + "Server Selector");
            selector.setItemMeta(selectorMeta);
            CoreInv.setItem(10, selector);
            ItemStack warper = new ItemStack(Material.MAGMA_CREAM);
            ItemMeta warperMeta = warper.getItemMeta();
            warperMeta.setDisplayName(ChatColor.GREEN + "Warper");
            warper.setItemMeta(warperMeta);
            CoreInv.setItem(12, warper);
            ItemStack vanity = new ItemStack(Material.RED_ROSE);
            ItemMeta vanityMeta = vanity.getItemMeta();
            vanityMeta.setDisplayName(ChatColor.RED + "Vanity Menu");
            vanity.setItemMeta(vanityMeta);
            CoreInv.setItem(14, vanity);
        }
        public static Inventory SelectorInv = Bukkit.createInventory
                (null, 27, ChatColor.GOLD + "Server Selector");
        {
            ItemStack quake = new ItemStack (Material.FIREWORK);
            ItemMeta quakeMeta = quake.getItemMeta();
            quakeMeta.setDisplayName(ChatColor.AQUA + "Quake");
            quake.setItemMeta(quakeMeta);
            SelectorInv.setItem(10, quake);
            ItemStack skywars = new ItemStack (Material.EYE_OF_ENDER);
            ItemMeta skywarsMeta = skywars.getItemMeta();
            skywarsMeta.setDisplayName(ChatColor.GREEN + "Skywars");
            skywars.setItemMeta(skywarsMeta);
            SelectorInv.setItem(11, skywars);
        }
       
        public static Inventory WarperInv = Bukkit.createInventory
                (null, 27, ChatColor.GOLD + "Warper Menu!");
        {
            ItemStack rank = new ItemStack(Material.DIAMOND);
            ItemMeta rankMeta = rank.getItemMeta();
            rankMeta.setDisplayName(ChatColor.AQUA + "Ranks!");
            rank.setItemMeta(rankMeta);
            WarperInv.setItem(11, rank);
        }
       
        public static Inventory VanityInv = Bukkit.createInventory(null, 54, ChatColor.GOLD + "Vanity Menu!");
        {
            ItemStack vanity = new ItemStack(Material.SKULL, 1);
            SkullMeta vanityMeta = (SkullMeta) vanity.getItemMeta();
            vanityMeta.setOwner("Seska_Rotan");
            vanity.setItemMeta(vanityMeta);
            VanityInv.setItem(10, vanity);
        }
       
        @Override
        public boolean onCommand (CommandSender sender, Command cmd, String label, String[] args)
        {
            if(cmd.getName().equalsIgnoreCase("cchelp"))
            {
                Player player = (Player) sender;
                player.sendMessage(ChatColor.AQUA + "/core - This Will Give You The Core!");
                player.sendMessage(ChatColor.AQUA + "/cchelp - The General Help Command!");
                player.sendMessage(ChatColor.AQUA + "/sb - Simple Broadcast Command!");
                player.sendMessage(ChatColor.AQUA + "/ccreload - Reloads CommandCore!");
            }
            if(cmd.getName().equalsIgnoreCase("core"))
            {
                Player player = (Player) sender;
                player.openInventory(CoreInv);
            }
            if(cmd.getName().equalsIgnoreCase("server"))
            {
                Player player = (Player) sender;
                player.openInventory(SelectorInv);
            }
            if(cmd.getName().equalsIgnoreCase("vanity"))
            {
                Player player = (Player) sender;
                player.openInventory(VanityInv);
            }
            if(cmd.getName().equalsIgnoreCase("warper"))
            {
                Player player = (Player) sender;
                player.openInventory(WarperInv);
            }
            if(cmd.getName().equalsIgnoreCase("ccreload"))
            {
                Player player = (Player) sender;
                player.sendMessage(ChatColor.GREEN + "Config reloaded!");
            }
            if(cmd.getName().equalsIgnoreCase("sb"))
            {
                Player player = (Player) sender;
                if(player.hasPermission("ccore.perms"))
                {
                    String message = ChatColor.RED + "";
                    for (String part : args) {
                        if (message != "") message += " ";
                        message += ChatColor.GREEN + part;
                    }
                    Bukkit.getServer().broadcastMessage
                    (ChatColor.GOLD + "[MiniCord]" + " " +  ChatColor.GREEN + message);
                }
                else
                {
                    player.sendMessage(ChatColor.RED + "You do have the permissions to use this command!");
                }
            }
            return false;
        }
       
        @EventHandler
        public void onInventoryClick(InventoryClickEvent e, InventoryDragEvent ed)
        {
            if(e.getInventory() == CoreInv)
            {
               
            }
            ed.setCancelled(true);
        }
       
        public void loadConfiguration()
        {
            System.out.println(ChatColor.GREEN + "Config Loaded/Updated!");
        }
       
        public void onEnable()
        {
            getServer().getPluginManager().registerEvents((Listener) this, this);
            System.out.println(ChatColor.GREEN + "CommandCore succesfully Loaded!");
            System.out.println(ChatColor.GREEN + "Loading CommandCore Config!");
            loadConfiguration();
        }
       
    }
    
    Plugin.yml:
    main: core.cord
    name: CommandCordReloaded
    version: 0.1
    author: Matthiaantje
    
    commands:
      core:
        description: Gives The Core
      cchelp:
        description: general help command!
      sb:
        description: general broadcast command!
      ccreload:
        description: general reload command!
      vanity:
        description: Gives Vanity
      server:
        description: Gives Server
      warper:
        description: Gives Warper
       
    permissions:
      ccore.perms:
        default: op
    
    
    Downloaded it for him. Code above!
     
  5. Offline

    Zombie_Striker

    @Matthiaantje
    There should not be any empty lines in the config.yml.

    Most likely, your issue is that you are casting your main class which is not a listener to a listener. This is most likely breaking your plugin every time it loads. add "implments Listener" right after JavaPlugin, and remove the cast from the onEnable.
     
  6. Offline

    Matthiaantje

    Okay! Figured it out myself :)!
    Looked like there was a compiling error due the fact I didn't wrote my Plugin.yml in Eclipse but in Brackets!!!
    So, looked it up at the Bukkit forums, and after I readed a thread about it, it was solved!!! So, Thanks anyway!!!
     
Thread Status:
Not open for further replies.

Share This Page