I have been working hard on a plugin for a mini-game server I will be released soon. I have been working on an inventory to come up after you click on something to open it. This will contain a lobby system where there are three parts consisting of three rows, one for the lobbies that are open, another with lobbies with so many people that will only except doners, and a final row where there will be the full unjoinable lobbies. The thing is, I want to make it so the object goes into the next vacant slot and will not constantly keep an exact order, sort of like the system on Mineplex. The problem is is that I can't get it to work. I am aware it is a little overwealming if you don't know what it's doing, but I thought the method would work. But when I try to open the inventory, it doesn't open. Here is the pastebin of the code for it: http://pastebin.com/bZ3cZhP3 Please comment if you can help me. Thanks
Sorry, but you might have to get a better solution for your switch-tree. You are trying to put up an inventory-menu. This menu shall have visible and invisible buttons, which follow an exact order? You don't want to add items or buttons just to the inventory because of the order? How about putting up a Map<String, ItemStack> and iterate over it. The String is a condition, which has to be true and display the ItemStack on the menu if the condition is accepted. Did I undertand that right?
It actually won't have invisible and visible button. What the switch tree is doing is seeing if in inventory slot 0 if it is an item or air, if it is an item, it checks slot 1 for the same thing and so on and so forth but if it is air, it will place the block. That's what that is running.
By the way: If you want nice, readable and reliable code, please inform yourself about redundancy-avoidance. You save a lot of time if you avoid duplicate code and encapsulate your code in the way OOP gives possibilities!
The most awesome switch tree I have seen. At least you need to state what are the meaning of your variables, like what is lobby1int? lobby1greenloop? etc. And explain whats your purpose of coding these lines, and how it doesn't work..
Since when was recursion or looping part of OOP? There's no need for any encapsulation either. Someone either taught you the wrong definitions or you just are trying to act smart. Either way, your suggestion is a much better way than OP's current schema. 1928i Just because you have it written doesn't mean that you can't rewrite it. Not only would we be able to assist better if it was written cleaner, but updating/extending the inventory would be a cinch.
Redundancy-avoidance is a big part of OOP. If you encapsulate the code, you won't waste any lines on duplicated code if you are doing it right. And if you loop in a class, or maybe do some recursion on methods, you should always keep in mind, what this class is made for and keep class clean from topical unrelated code. As you might see, that his posted code is just one method, he might be able to source this out to an own class, to handle this.
Redundancy-avoidance is a big part of many things, not even relative to OOP. Do you even understand what encapsulation is? Because what you're describing is minimization.