Kit Gui/Inventory Open With Command

Discussion in 'Plugin Development' started by AwaitingComplex, Aug 23, 2015.

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

    AwaitingComplex

    Hey, I recently created a kit gui, which now has a lore to it *cheers*.
    But I need some help with these 3 issues/lack of knowledge:
    1 - How can I set it to open by a command instead of using a book
    2 - How can I make it so when you click the "Next page" it opens another inventory
    3 - Is it possible to have less than 54 rows, like is it possible to have around 9?

    Here are the codes of the plugin:

    KitGui (
    The basic one)
    http://hastebin.com/ucafesirut.avrasm

    KitGui (
    The next page one)
    http://hastebin.com/asopapexac.avrasm

    SetItem (
    Basicly the setItemToInventory)
    http://hastebin.com/ewugacuxoy.avrasm

    GiveKit (
    Performs the command when you click an item)
    http://hastebin.com/oqemekumen.avrasm

    Thanks for taking your time to read through this.
    Any help is appreciated, Im quite new to coding and this is my first time coding a Kit GUI/Selector so :p

    Sincerely
    -AwaitingComplex
     
  2. Just have a command and open it.

    Listen for next page to be clicked and open the other one.

    Of course, it has to be a multiple of 9 but equal to or less than 54
    A way to check would be this method
    Code:
    public boolean isCorrect(int number){
        if(number % 9 == 0 && number <= 54)
            return true;
       return false;
    }
     
    mine-care likes this.
  3. Offline

    AwaitingComplex

    1 - I know that but it doesn't seem to work for some reason heres what I did:
    http://hastebin.com/toyicazisi.avrasm
    2 - I tried that but it didnt work:
    http://hastebin.com/taboramima.avrasm (I get an error on the "invent")
    3 - Can I simply replace 54 with 9 in here?
    http://hastebin.com/pobeqaxomi.avrasm
     
  4. I can think of a few reasons but @mine-care is going to lecture you so I wont state them.

    Error?

    Yep.
     
  5. Offline

    AwaitingComplex

  6. Offline

    AwaitingComplex

    It is in the kitGUItwo

    public static Inventory invent = Bukkit.createInventory(null, 54, ChatColor.RED + "" + ChatColor.BOLD + "Kit GUI");
     
  7. Offline

    AwaitingComplex

    How can I grab it from kitGUItwo then?
     
  8. @AwaitingComplex Well remove the static abuse, make a way to get the class instance, then just grab it like that. You could even make a method which adds all items and things rather than just a empty inventory.
     
  9. Offline

    AwaitingComplex

    Could you explain that a bit more detailed? I really have no idea hwo Im gonna get the class instance or make a method that adds all items and things. And who is mine-care and how is he gonna help me?
     
  10. Offline

    AwaitingComplex

    @bwfcwalshy What about the command to open an inventory and mine-care, how can I get in touch with him?
     
  11. @AwaitingComplex you don't need to get in touch with him, he'll post it here. As for the command, why is player final? And what about it doesn't work? Is it registered?
     
  12. Offline

    mine-care

    There are a few corrections i wanted to sugest concering your code.
    Code:
    public class kitGUItwo | public class setItem | public class giveKit | public class kitGUI 
    Follow java naming conventions

    Code:
    setItem.setItemToInv1(Integer.valueOf(0), p, ChatColor.GRAY + "" + ChatColor.BOLD + "-", new ItemStack (Material.THIN_GLASS));
    I saw that piece of code repeated a lot, you can use a loop instead to make things clear or at least cache this inventory instead of creating it over and over when the player opens it.

    Code:
     if (((e.getPlayer() instanceof Player)))  Player p = (Player)e.getPlayer();
    e.getPlayer already returns Player object so no need for checks and casting.

    Code:
    Integer.valueOf(...)
    is that nessesary? any number provided to the method as parameter is an int by itself, i dont see why it has to be an Integer object...

    In class "setItem" what is the key difference between the two methods in there? i dont seem to be able to spot it.

    Also why are there two kitGUI classes?

    Quite some severe static use i can also see, Use static properly, it is not just the easy access of Class.StaticComponent but a whole theory behind it in Object oriented programming.

    I would recomend reading about Object orientation, static modifier, Access modifiers, loops, methods, and finally efficiency.

    I was informed because @bwfcwalshy tagh'ed me :- )
     
  13. Offline

    AwaitingComplex

    I figured out the command now thanks, I forgot to register it and implement CommandExecutor >.<

    @mine-care I figured out the command, and the setItem was because I thought I had to, but I found out I didnt so I removed it after. Is it however important having the class names like this: SetItem with uppercase letter instead of having setItem?

    <Edited by bwfcwalshy: Merged posts, please use the edit button rather than double posting.>

    @bwfcwalshy I think I found the way to import the kitGUItwo into the giveKit, but it still doesnt open the menu.
    Please help
    http://hastebin.com/yotigeyusa.avrasm

    <Edited by bwfcwalshy: Merged posts, please use the edit button rather than double posting.>

    @bwfcwalshy Ok sorry, could you help me though?
     
    Last edited: Aug 23, 2015
  14. Offline

    mine-care

    Well it is Java Naming Convention, Drawn by docs:
    (http://www.oracle.com/technetwork/java/codeconventions-135099.html)
     
  15. Offline

    CraftBang

    Just one thing,
    http://hastebin.com/ewugacuxoy.avrasm
    Your method setItem#setItemToInv

    Code:
    ChatColor desc = ChatColor.RED;    //It's red
    ChatColor esc = ChatColor.BOLD;     
    
    if (p.hasPermission(perm))       
           desc = ChatColor.GREEN;     
    else {desc = ChatColor.RED;} 
    
    You could remove the else, because if the player doesn't have the permission, then desc will still be ChatColor.RED
     
Thread Status:
Not open for further replies.

Share This Page