Lobby system help.

Discussion in 'Plugin Development' started by 1928i, Apr 22, 2014.

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

    1928i

    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 :)
     
  2. Offline

    Slikey

    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?
     
  3. Offline

    1928i

    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.
     
  4. Offline

    Slikey

    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!
     
    TigerHix likes this.
  5. Offline

    1928i

    I'll consider that, but I already have this written, anyone want to help, I really need this fixed.
     
  6. Offline

    1928i

    Please. I really need the help :/
     
  7. Offline

    TigerHix

    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..
     
  8. Offline

    Not2EXceL

    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.
     
    Dread9Nought likes this.
  9. Offline

    Slikey

    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.
     
  10. Offline

    Not2EXceL

    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.
     
  11. Offline

    1928i

    Ok, all this chat is super confusing, does anyone know how to fix my problem?
     
  12. Offline

    1928i

    Anyone help?
     
Thread Status:
Not open for further replies.

Share This Page