Public static inventory getHunter () {
return Bukkit.createInventory (null, 6 * 9, "§e§lJobs §8» Menu | Hunters ");
}
To open an inventory for one player, the problem is if a second one opens the inv that both players see the stats of the other can I reopen the inventory for each separately?
So e.g. Somehow with new inventory or something?
You would have to regulate that with a HashMap.
Inventory invA = getHunter ();
Inventory invB = getHunter ();
… Fill A and b with the desired content…
playerA.openInventory (invA);
playerB.openInventory (invB);
Will lead to fine spaghetti code over long or short, because you have to fill up the inventory somehow.
Instead of the static method, you should better solve the whole thing with a separate class and without a static method, which later also manages the entire inventory logic, so that the class where all your event handlers are located does not have to do this, which is easy to do with subsequent extensions Spaghetti code leads:
public class Hunter {
private final inventory inventory;
public Hunter () {
inventory = Bukkit.createInventory (null, 6 * 9, "§e§lJobs §8» Menu | Hunters ");
}
public void show (player player) {
Objects.requireNotNull (player);
player.openInventory (inventory);
}
// more methods that are responsible for managing the inventory, in here!
}
somewhere in the event handler or something (for 2 players then do 2x accordingly):
Hunter hunter = new Hunter ();
hunter.show (player);