Code cleanup/rewrite possible for certain parts of the plugin? #525
Replies: 6 comments 11 replies
-
Lol, not crazy, most of the TARDIS code I would guess is pretty terrible. Comes from never actually being taught any programming and just learning it all myself as needed, I only started coding in Java because my son was playing Minecraft - TARDIS was my second or third ever plugin. I'd love to go back to school/uni and do it properly. TARDIS would make a good project to recode efficiently. Definitely a bit old for that now, maybe when I retire... I used to collect metrics on TARDIS but removed the code years ago. Maybe it's time to add some back. I reckon there's a good chunk of TARDIS features that hardly anyone uses, just today when adding some Javadoc comments I had to look up what some methods were actually for - had quite a few "oh yeah" moments where I had completely forgotten about some things that you could do. While the code is getting a bit shabby, I don't consider it broken enough to do big rewrites (nor do I really have the time), so if you want to have a go, feel free. I'm happy to update to new Minecraft/Spigot versions and fix bugs as they are reported, and pop in a new feature of two as the mood takes me :) |
Beta Was this translation helpful? Give feedback.
-
Don't know that the Junk TARDIS metric is very useful, it just shows that it is enabled in the config... What custom stats do we want to track? |
Beta Was this translation helpful? Give feedback.
-
@eccentricdevotion Are you in the community discord server by any chance? I had some ideas about restructuring some big parts of the code to make writing new features and maintaining existing code way easier, but seeing how big the codebase is, I'd want to talk about some of that stuff before writing it and trying to get it merged haha |
Beta Was this translation helpful? Give feedback.
-
On the subject of this, I ran a global inspection and IntelliJ spit out several thousand "warnings". Notably, it wanted to replace all switch statements with enchanted switch expressions or whatever the other term is. It also pointed out that the for loop in TARDISRandomTheEnd never actually loops, because it returns on the first run here: https://github.com/eccentricdevotion/TARDIS/blob/v4.0/src/main/java/me/eccentric_nz/TARDIS/api/TARDISRandomTheEnd.java#L89 It also offered about 312 classes to be converted to records but warned that the local fields would become public instead of private (not sure if this is a huge issue). Additionally, it offered blocks of code to be converted into native text blocks. Finally, it suggested 2 instances of a string compare with ==s instead of .equals() and another change to inline casting. Here is that commit that does most of the above minus records: Chew@d7d1c3d |
Beta Was this translation helpful? Give feedback.
-
Java 16 suggestions... |
Beta Was this translation helpful? Give feedback.
-
@Chew Feel free to submit a PR |
Beta Was this translation helpful? Give feedback.
-
Hello! I've been using the TARDIS plugin since 2014 and I'm in awe at how many awesome features keep getting added, even to this day. However, after doing some major server upgrades and digging through some of the code, I've noticed it looks like a lot of features could be modernized or rewritten. I understand that when this plugin was created, Bukkit was an entirely different API and Minecraft was a very different game. A lot of new programming practices and technologies have also been created since then.
Through time a lot of of the plugin's code has been updated, but as with any project, when more and more features get added everything has the tendency to turn into spaghetti. A lot of the bugs I've encountered look like the kind of bugs that come to exist indirectly - when new features are added they don't (and realistically can't) take into account all the effects they can have on other parts of the codebase.
I'd be interested in trying to take a few parts of the plugin and rewrite them to be more stable and follow more strict OOP principles. I was thinking I'd start with the junk TARDIS as a small piece and see how it goes, pretty much just rewrite the feature from the ground up. I'd test it extensively and PR it and see how it goes.
Some of the other things that I think could be improved on aren't as simple though, namely the database and TIPS. As far as the database goes, I think it'd be very helpful to use a migrations system or ORM framework to make changes to the database schema rather than a big list of
CREATE TABLE IF NOT EXISTS...
every time the plugin starts. However, everything in the plugin needs the database, so it's a very very big task to make any non-backwards-compatible changes to it. I also had some ideas for ways to improve the algorithm TIPS uses to partition out TARDIS interiors, but that's almost impossible to change on existing servers due to TARDISes already relying on the previous locations TIPS gave them.Anyways, I love this plugin and so do my players, but running a TARDIS server has been a little.. challenging for a variety of reasons. I'm also not really sure if it'd be worth it to clean up certain parts of the plugin, like how many people realistically use the junk TARDIS anyways? Are there any sort of metrics about how many servers and players are using the TARDIS plugin? It could also be cool to add some anonymous feature-specific metrics about how many people use certain things like the junk TARDIS, rechargers, etc.
Thanks for reading this far, let me know if you agree with any of this or if I'm just a crazy person lol
Beta Was this translation helpful? Give feedback.
All reactions