Solved Open a gui with a command

Discussion in 'Plugin Development' started by camman00, Sep 19, 2015.

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

    camman00

    Hello, how would you open a gui using a command?

    Thanks
     
  2. Offline

    Zombie_Striker

    Player#openInventory(Inventory);

    Simple, Right?
     
  3. Offline

    camman00

    I tried using your code and it did not work,
    I also tried
    Code:
     if ((cmd.getName().equalsIgnoreCase("kit")) &&
          ((sender instanceof Player)))
            openGUI(player);
    That did not work either.
    Thanks for the reply though :)
     
  4. Offline

    SuperSniper

    @camman00 As @Zombie_Striker said above, all it is is Player#openInventory(inv);

    but here's a basic usage of it:

    Code:
    // onCommand
    if(!(sender instanceof Player)) {
    return true;
    }
    Player player = (Player)sender;
    // Check command
    // Make the Inventory (Owner, Slots, Name)
    Inventory myInventory = Bxukkit.createInventory(null, 9, "Insert Name Here");
    myInventory.setItem(0, new ItemStack(Material.CHEST));
    player.openInventory(myInventory);
    
    That code would make this:

    upload_2015-9-19_23-58-48.png
     
  5. Offline

    camman00

Thread Status:
Not open for further replies.

Share This Page