Need Help With Inventory GUI Command In My Plugin

Discussion in 'Plugin Development' started by KingOfTheEast01, Apr 8, 2016.

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


    Hello everybody! I made this post for an obvious reason which as you can see has been stated in the title. Basically I have been learning basic bukkit plugin coding from Ben from the youtube channel TheBCBroz. Basically I want to make a plugin that uses the inventory GUI feature of the org.bukkit files. So I began a code for a command which would be /navigation. I want it to open up an inventory which has a compass in the middle of five slots which you can click on and for now I have decided it will just teleport you to a spawn point. Overtime I've been able to think and have decided I am going to make an inventory GUI for a shop on my server, but I would need inventoryClick events. I don't know how to do that right now and also I don't know how to make one of those events add or subtract from your balance in the economy feature of essentials, and Ben has a tutorial right after the inventory tutorials on how to make an inventoryClick event that tps you to a specific spot in the world. So I would just like to work on that event right now, but I can't finish my code for the navigation GUI to open. I have managed to successfully give it a description in /help LukesFirstPlugin. LukesFirstPlugin is the name of my plugin and yes I am aware it is cheesy, but it's just my basic plugin I will be using to test out everything I learn about plugins right now. and I don't plan on making it public currently. So anyways, I have successfully made the description for it in the /help command lists although I believe my plugin.yml just did that for me and it has nothing to do with the fact that the command has been registered or made correctly, which brings me to my next point. I have typed the command in-game and not only did it not do anything, but it didn't even say I did the wrong command, which brings me to the question. Does it actually do something and knows the navigation command exists, but doesn't know exactly what it does? Or did I screw something up. The code for my navigation command's class file will be below. I believe I have registered it correctly, but if you need to see my main class then I will show you, but my /hello command works correctly. Basically it just says "Hello" and lists the servers current GOP's which are listed in the config file although it gives a syntax error where the GOP's name's should be, but I believe that is just an error in the plugin.getConfig part of things. Either that is my problem or maybe I should have made the config in notepad so it would sort my lists and such better. I don't know exactly what that problem is, but I know the 'hello" command does what it's essentially supposed to do. Anyways I will show you the navigation command's class files now so you don't have to hear me rambling on now. XD I have a habit of doing so

    Here's the code, and P.S. I know there is some way you can post a code in a box people can scroll up and down through, but I don't know how to do that sorry. And if there is any other code you need which there probably will be considering I import things and have packages and class files and stuff like the all intervened, just tell me so. Thanks! :)

    package com.filmsfilms.firstplugin.commands;

    import org.bukkit.Bukkit;
    import org.bukkit.ChatColor;
    import org.bukkit.Material;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandExecutor;
    import org.bukkit.command.CommandSender;
    import org.bukkit.entity.Player;
    import org.bukkit.inventory.Inventory;
    import org.bukkit.inventory.ItemStack;
    import org.bukkit.inventory.meta.ItemMeta;

    public class Navigation implements CommandExecutor{

    public boolean onCommand(CommandSender sender, Command command,
    String commandLabel, String[] args) {
    if (commandLabel.equalsIgnoreCase("Navigation") ){
    if(!(sender instanceof Player)) {
    sender.sendMessage("You must be a player to use this command");
    return false;


    Player player = (Player) sender;
    Inventory inv = Bukkit.createInventory(null, 5, "Navigation Panel");
    ItemStack spawnItem = nameItem(Material.COMPASS, ChatColor.AQUA + "Teleport To Spawn");
    inv.setItem(2, spawnItem);

    return true;


    private ItemStack nameItem(ItemStack item, String name){
    ItemMeta meta = item.getItemMeta();
    return item;


    private ItemStack nameItem(Material item, String name) {
    return nameItem(new ItemStack(item, name));



    private boolean nameItem(ItemStack itemStack) {
    // TODO Auto-generated method stub
    return false;

    private ItemStack nameItem(Material compass, String string) {
    // TODO Auto-generated method stub
    return null;

    Thanks for the help you guys! I really appreciate it XD :)
    -Lucas (KingOfTheEast01 and upcoming coder :))
  2. Offline


    1. Put the [ code] [/code] around your code. Those tags keep formatting and makes it easier to read.
    2. He is the worst way to learn Java or bukkit. Stop watching him immediately. Instead, if you have not officially learned Java yet, then please go to the following link, find a tutorial for JAVA, learn Java (which should take only a week), and then come to bukkit. You Must know JAVA before working on Bukkit. There have been many threads discussing this in the past, explaining why you should learn Java first. If you have learned Java already, also go to the following link, scroll down to the Bukkit section, and find a tutorial there:

      Yeah, can you condense this? Can you explain in just a few lines what exactly your problem is (or better yet, use the format in the "How to make a PluginDeve Thread" sticky)?

      You do not own You must only use domains you own, or if you do not own a webside, use me.<Name>.<Project>
Thread Status:
Not open for further replies.

Share This Page