Whats wrong with this?

Discussion in 'Plugin Development' started by goldendraws, Aug 21, 2015.

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

    goldendraws

    Hey there!

    What's wrong with this code:

    Code:
    package Plugins_Main_Hotbar;
    
    import org.bukkit.Bukkit;
    import org.bukkit.ChatColor;
    import org.bukkit.Material;
    import org.bukkit.entity.Player;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    import org.bukkit.event.player.PlayerInteractEvent;
    import org.bukkit.inventory.Inventory;
    import org.bukkit.inventory.ItemStack;
    import org.bukkit.plugin.java.JavaPlugin;
    
    
    
    public class Hotbar extends JavaPlugin implements Listener{
    
        private Inventory inv = Bukkit.createInventory(null, 9, ChatColor.UNDERLINE + "Server information");
                                                               
        public void onEnable() {
            inv.clear();
            getServer().getPluginManager().registerEvents(this, this);
        }
    
        public void onDisable() {
            inv.clear();
        }
    
    
        @EventHandler
    public void onClickItem(PlayerInteractEvent e) {
            Player p = e.getPlayer();
            if(p.getItemInHand() == null){
                return;
            }
            ItemStack is = p.getItemInHand();
        if(is.getType() != Material.PAPER)
        return;
        e.setCancelled(true);
        p.openInventory(inv);
       
        }
    
    
    
    
    
    
    
    }
    

    Then the plugin.yml is

    Code:
    name: Hotbar+
    main: Plugins_Main_Hotbar.Hotbar
    version: 1.0
    author: goldendraws
    
    It just doesn't work on my server. Doesn't show up in /plugins either.
     
  2. Offline

    Shortninja66

    1. I believe you can't have any symbols like the plus sign in your plugin name. Make it "HotbarPlus".
    2. Do NOT capitalize anything in your package names.
     
  3. Offline

    teej107

    I'm pretty sure you can have anything as long as it is surrounded in quotes if needed.

    @goldendraws If a plugin failed to load, it will throw an error. Otherwise you put it in the wrong directory.
     
    Shortninja66 likes this.
  4. Offline

    Shortninja66

    @teej107 Hm, not sure. I remember naming one of my plugins with a plus in it and I think it didn't work. I didn't use quotes, though.
     
Thread Status:
Not open for further replies.

Share This Page