oldstuffs / SmartInventory

Moved to https://github.com/Infumia/InfumiaLib
MIT License
15 stars 1 forks source link

Should I use this instead of MinusKube's version? #32

Closed GustavHaavik closed 4 years ago

GustavHaavik commented 4 years ago

The title explains it :)

portlek commented 4 years ago

Yes, ^^ there is some same logics but usage is a little bit different. Usage examples are here; https://github.com/spigotplugins/fakeplayer/blob/master/fakeplayer/src/main/java/io/github/portlek/fakeplayer/file/provider/ListMenuProvider.java https://github.com/spigotplugins/fakeplayer/blob/master/fakeplayer/src/main/java/io/github/portlek/fakeplayer/file/MenuFile.java#L110 these may help but I will make usage examples ASAP.

GustavHaavik commented 4 years ago

aaah. okay, I will be implementing this instead of the other tomorrow then. It also seems like this is more up to date.

portlek commented 4 years ago

alright, ^^ if you find any bug just open it. I should fix it cuz I'm using the library too :DD

GustavHaavik commented 4 years ago

I am not sure how I would do this, you can see here how I do it currently with Kube's version https://github.com/MinusKube/SmartInvs/issues/147

portlek commented 4 years ago

is it happening with this library?

GustavHaavik commented 4 years ago

No with the MinusKube's

GustavHaavik commented 4 years ago

Havent tried with this yet, unsure how :/

portlek commented 4 years ago

alright try that and share the result, im not sure about minuskube's library

GustavHaavik commented 4 years ago

I am still not sure on how to use this library

portlek commented 4 years ago

It's almost the same as minus's lib. there are just a few changes in creating/showing pages. Just look at these classes; https://github.com/spigotplugins/fakeplayer/blob/master/fakeplayer/src/main/java/io/github/portlek/fakeplayer/file/provider/ListMenuProvider.java https://github.com/spigotplugins/fakeplayer/blob/master/fakeplayer/src/main/java/io/github/portlek/fakeplayer/file/MenuFile.java#L110 https://github.com/spigotplugins/fakeplayer/blob/master/fakeplayer/src/main/java/io/github/portlek/fakeplayer/FakePlayerAPI.java#L41 https://github.com/spigotplugins/fakeplayer/blob/master/fakeplayer/src/main/java/io/github/portlek/fakeplayer/FakePlayerAPI.java#L53

GustavHaavik commented 4 years ago

Can you give an example on how to create an inventory. It is honestly too much

portlek commented 4 years ago
Page.build(
  FakePlayer.getAPI().inventory,
  yourClassWhichImplementsInventoryProvided)
.row(6)
.title(this.title.build());
portlek commented 4 years ago

page.open(player);

GustavHaavik commented 4 years ago

Should I create some instance of the api, and how would I do that?

GustavHaavik commented 4 years ago

What is FakePlayer.getAPI().inventory

portlek commented 4 years ago

https://github.com/spigotplugins/fakeplayer/blob/master/fakeplayer/src/main/java/io/github/portlek/fakeplayer/FakePlayerAPI.java#L41 here is

GustavHaavik commented 4 years ago

I cannot initalize FakePlayerAPI

GustavHaavik commented 4 years ago

private FakePlayerAPI fakePlayerAPI = new FakePlayerAPI(this);

portlek commented 4 years ago

It's my plugin, not library stuff.

GustavHaavik commented 4 years ago

what should I put instead of FakePlayer.getAPI().inventory

portlek commented 4 years ago

It depends on your plugin. Can you share your plugin repository? I can't understand how you can't do that.

GustavHaavik commented 4 years ago

I am trying to create a menu from config this is what I have got Page MENU = Page.build( new BasicSmartInventory(plugin), )

GustavHaavik commented 4 years ago

What should I put in the class that implements InventoryProvided

portlek commented 4 years ago

Do like that;

private static YourPluginClass instance;

private SmartInventory inventory;

@Override
public onEnable() {
  instance = this;
  inventory = new BasicSmartInventory(plugin);
  inventory.init();
}

public SmartInventory getInventory() {
  return this.inventory;
}

public static YourPluginClass getInstance() {
  return instance;
}

Another class;

public void openTheMenu(Player player) {
  Page.build(YourPluginClass.getInstance().getInventory(),
      new YourInventoryProvidedClass(elements/other stuff))
    .open(player);
}
public final class YourInventoryProvidedClass implements InventoryProvided {

  @Override
  public void init(InventoryContents contensts) {
  }

}
portlek commented 4 years ago

the inventory provided class is the same as minus's lib.

GustavHaavik commented 4 years ago

Cant I create all menus on server load and store them in a list for later use, to prevent creating the inventory everytime a player opens the inventory

GustavHaavik commented 4 years ago

nvm

portlek commented 4 years ago

you can store.

Map<String, Page> pages = new HashMap<>();
onEnable() {
  pages.put("the-page-key", Page.build(...., ....).methods().othermethods());
}

and then when you want to open the menu just pages.get("the-page-key").open(player);

GustavHaavik commented 4 years ago

Does this also have like a parent option, so I can set a parent page?

GustavHaavik commented 4 years ago

How do I get the player who opens the menu

GustavHaavik commented 4 years ago

Oh nvm

GustavHaavik commented 4 years ago

How do I make clickable items

portlek commented 4 years ago

use Icon class

GustavHaavik commented 4 years ago

What is the difference between Icon.cancel(itemstack) and Icon.from(itemstack)

portlek commented 4 years ago

just look the class, you will understand https://github.com/portlek/SmartInventory/blob/master/src/main/java/io/github/portlek/smartinventory/Icon.java

GustavHaavik commented 4 years ago

How would I go about making a back button, so it returns to a parent menu?

portlek commented 4 years ago

probably I removed that feature, and I will add it to the feature.