Public Arena System Libraries

Status
This thread has been locked.
PebbleHost
High performance, consistent uptime and fast support. Minecraft hosting that just works.

Quokka

Manager & Developer
Premium
Feedback score
3
Posts
213
Reactions
94
Resources
0
Interesting, thanks for sharing mate. :)
 

GotoFinal

Feedback score
1
Posts
33
Reactions
15
Resources
0
Maybe if you knew how to use them ¯\_(ツ)_/¯
how? never. As this is just full of bad code, but seems that you don't know that so let me help you, maybe you will learn something new:

1. You did't use maven/gradle, so it is just pain to use in normal project.
2. https://github.com/Caleb-Neufeld/Arena-Libraries/blob/master/src/Arena.java#L17 you are passing raw Location instances, same in getters, so if someone would use "getOne" he can also modify that arena, and that i just stupid, imagine that player.getLocation().addX(5) would move player... this is just bad practice in object oriented languages.
3. "getOne" is just bad name, get one, one what?
4. getRandomUnusedArena is not random
5. You are storing all instances of arenas in static instance in this class, just is just wrong on all levels as:
a) static variables should not be used like that, as this means you can't control how it behaves without editing that code directly, and that is not valid OOP
b) this class is already an arena, adding second responsibility for it is also against OOP or KISS.
6. "getArenas" returns raw instance of that list, that is also bad practice and might lead to unexpected concurrent modification exceptions, all getters like that should only return a copy or unmodifable view. (Like server.getPlayers())

now we will look at Team class https://github.com/Caleb-Neufeld/Arena-Libraries/blob/master/src/Team.java
7. simillar issues like last time, you are passing array but not cloning it, and why not a list?
8. why you just generate all that setters and getters it would be better to add normal methods like addPlayer, isPlayerInTeam etc.

and now https://github.com/Caleb-Neufeld/Arena-Libraries/blob/master/src/Duel.java
9. again that static array list and same issues as in Arena class.
10. this code seems to expect two teams as it does not support more positions but does not validate that
11. why would id or arena of duel change after it is created? that is again against all good OOP practices.
12. And again teams are modifable, this time there is only getter, but that getter is returning raw array so values can be changed.

This is just code full of bad OOP, just look how normal good java applications works, like spring for example. you will not find random getters setters etc here, object code is not about just creating classes with random fields and generating getters and setters to them. In many cases after creation of an object you don't need access to that data anymore.
And after all that are just 3 random classes that anyone can write in few minutes, and they are just really badly written.

I know I sound very negative etc, but I only want to help, as maybe you will learn something from that and look for more materials to learn about valid OOP code, you can also google for that KISS and maybe SOLID, as that are very useful "rules" in programming. (also breaking them is not always bad too ;) )
 

Sniper

Software Developer
Supreme
Feedback score
65
Posts
1,312
Reactions
695
Resources
0
GotoFinal The reason the getters an setters are odd is because they're all coded through someone else's computer, I was walking them through it over discord. I usually put a load() and unload() method to only write to the file, which when doing so causes lag, so I do it so you put it in your onEnable and onDisable, that's why the private static list is there.

In the end I got him to send me the classes and I uploaded them to GitHub. I'll make some changes to the code so it would be more my style and less his. Thanks for the information.
 
Status
This thread has been locked.
Top