API Easy Menu Maker API v2.1 (with Interfaces)

Discussion in 'Resources' started by 567legodude, Mar 19, 2015.

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

    Agentleader1

  2. Invisible

    nverdier

  3. Offline

    MrFrozen

    A oke got ya, anyways nice contribution to the communinty for newer ppl.

    Oke thanks I will take a look now!
     
    Last edited by a moderator: May 19, 2015
  4. Offline

    567legodude

    @teej107 Oooooooohhhhhh, after looking at the post by @nverdier I understand about interfaces now. I may think about adding that in the future, because right now, this version is a little buggy.
     
  5. Offline

    Eggspurt

    I have an issue which I am sure its not your side its my sided...

    But when I have this

    public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args){
    Player player = (Player)sender;
    if (cmd.getName().equalsIgnoreCase("test")) {
    menu.showMenu(player);
    return true;
    }
    return true;
    }

    and type /test in game it gives me this
    Code:
    [15:30:24 ERROR]: null
    org.bukkit.command.CommandException: Unhandled exception executing command 'test
    ' in plugin GUITestPlugin v1
            at org.bukkit.command.PluginCommand.execute(PluginCommand.java:46) ~[spi
    got.jar:git-Spigot-dbe012b-63e28b1]
            at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:14
    1) ~[spigot.jar:git-Spigot-dbe012b-63e28b1]
            at org.bukkit.craftbukkit.v1_8_R2.CraftServer.dispatchCommand(CraftServe
    r.java:646) ~[spigot.jar:git-Spigot-dbe012b-63e28b1]
            at net.minecraft.server.v1_8_R2.PlayerConnection.handleCommand(PlayerCon
    nection.java:1133) [spigot.jar:git-Spigot-dbe012b-63e28b1]
            at net.minecraft.server.v1_8_R2.PlayerConnection.a(PlayerConnection.java
    :968) [spigot.jar:git-Spigot-dbe012b-63e28b1]
            at net.minecraft.server.v1_8_R2.PacketPlayInChat.a(PacketPlayInChat.java
    :45) [spigot.jar:git-Spigot-dbe012b-63e28b1]
            at net.minecraft.server.v1_8_R2.PacketPlayInChat.a(PacketPlayInChat.java
    :1) [spigot.jar:git-Spigot-dbe012b-63e28b1]
            at net.minecraft.server.v1_8_R2.PlayerConnectionUtils$1.run(SourceFile:1
    3) [spigot.jar:git-Spigot-dbe012b-63e28b1]
            at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) [
    ?:1.8.0_25]
            at java.util.concurrent.FutureTask.run(Unknown Source) [?:1.8.0_25]
            at net.minecraft.server.v1_8_R2.SystemUtils.a(SourceFile:60) [spigot.jar
    :git-Spigot-dbe012b-63e28b1]
            at net.minecraft.server.v1_8_R2.MinecraftServer.A(MinecraftServer.java:7
    10) [spigot.jar:git-Spigot-dbe012b-63e28b1]
            at net.minecraft.server.v1_8_R2.DedicatedServer.A(DedicatedServer.java:3
    68) [spigot.jar:git-Spigot-dbe012b-63e28b1]
            at net.minecraft.server.v1_8_R2.MinecraftServer.z(MinecraftServer.java:6
    51) [spigot.jar:git-Spigot-dbe012b-63e28b1]
            at net.minecraft.server.v1_8_R2.MinecraftServer.run(MinecraftServer.java
    :554) [spigot.jar:git-Spigot-dbe012b-63e28b1]
            at java.lang.Thread.run(Unknown Source) [?:1.8.0_25]
    Caused by: java.lang.ClassCastException: org.bukkit.craftbukkit.v1_8_R2.inventor
    y.CraftInventoryCustom cannot be cast to zach.stuff.MenuMaker
            at zach.stuff.Main.onCommand(Main.java:31) ~[?:?]
            at org.bukkit.command.PluginCommand.execute(PluginCommand.java:44) ~[spi
    got.jar:git-Spigot-dbe012b-63e28b1]
            ... 15 more
     
  6. Offline

    567legodude

    @Eggspurt To be honest I'm not sure what you did. It's throwing a ClassCastException. It says org.bukkit.craftbukkit.v1_8_R2.inventory.CraftInventoryCustom cannot be cast to zach.stuff.MenuMaker, which I'm not so sure how to fix in your case.
     
  7. Offline

    Eggspurt

    Hey thanks for the quick reply, I don't want to waste your time as much as I am already, do you think you could provide an example I could use?
     
  8. Offline

    567legodude

    @Eggspurt Well, this version doesn't work so well, but I would do it like this.
    Code:
    MenuMaker menu = new MenuMaker(this, "My Inventory", 3);
    //add the items and stuff.
    
    public boolean onCommand(args) {
        player.openInventory(menu.getMenu());
    }
     
  9. Offline

    Eggspurt

    But how do I 'get' "menu" from

    Code:
    
        public Inventory myMenu() {
           MenuMaker menu = new MenuMaker(this, "My Menu", 3);
           menu.setAll(menu.createItem(Material.STAINED_GLASS_PANE, 1, "*", null, (short) 0));
           menu.setItem(10, menu.createItem(Material.APPLE, 1, null, null, (short) 0), "give <p> 260 1");
        
           return menu.getMenu();
        }
    Sorry, I figured it out, thanks for your help :)
     
    Last edited: May 29, 2015
  10. Offline

    567legodude

    @Eggspurt The problem with what you did was that, its going to register a listener each time you open the menu, which means that when you click an item after opening it 5 times, it will run the command that you set on it 5 times.
     
    Eggspurt likes this.
  11. Offline

    Eggspurt

    Oh, well I resolved it, another question I have is, how would I make it so if I click a specific block it opens a different InventoryGUI?
     
  12. Invisible

    nverdier

    Just check the block when it's pressed and run a different block of code that opens a different GUI.
     
  13. Offline

    Eggspurt

    I did that and it just closes the inventory, do you have an example I could refer to?
     
  14. Offline

    MineStein

    So what is the point of using this versus the features built-in to Bukkit?
     
  15. Offline

    567legodude

    @teej107 Well, I did it, I completely remade the menu maker, using interfaces now (Took me a while but I understand now). Also, I compare the inventory and not just the title. I'll update the main post sometime when I make sure it's ready.
    EDIT: Alright, I updated the post. It's there now.

    And also, I see what you mean, you can do pretty much anything you want using interfaces, this is the test plugin I made for this, and it works, it sends you a message for whatever slot you click: http://pastebin.com/n7KZSqwm

    Other EDIT: @bwfcwalshy I remember you saying that you were gonna use this in an API. I just updated this to version 2.0, and it's a lot better than the last one, so if you can, you should update it.
     
    Last edited: Jun 12, 2015
    teej107 likes this.
  16. Offline

    Eggspurt

    Thanks for updating it's nice to use and all, I haven't been able to resolve my issue in the PM's but I will just use /sudo :p, do you think that will cause any issues?
     
    Last edited: Jun 15, 2015
Thread Status:
Not open for further replies.

Share This Page