jaydevelopsstuff / Pluto

A Terraria server written in Java aiming to be optimized, simple, and easy to use.
https://discord.gg/vXFjfJHnRu
GNU General Public License v3.0
3 stars 0 forks source link

Suggestion #2

Open DeeChael opened 1 year ago

DeeChael commented 1 year ago

Hi! I'm interested in Terraria server in java and I've tried to develop one on my own, however, i don't have enough time to do so.

Luckily I saw your project, after viewing your codes, I think I have some advice for you:

  1. You can make the console command system with mojang's brigadier and jline, and I have an example for you: https://github.com/DeeChael/KookCli/blob/master/kook-cli-core/src/main/java/net/deechael/kookcli/KookCli.java#L77
  2. Though you've changed the method to store items, my suggestion is that it's not a good idea to read item data from a file. Actually, you can generate java code with the files at once and copy it into your Items class.
  3. Some classes maybe are in the wrong package, actually the structure of minecraft vanilla server is very great (though the implmentation code is bad)

More advice will come in the future.

jaydevelopsstuff commented 1 year ago

Thanks for the suggestions I appreciate it!

Here are my responses:

  1. I'll consider using brigadier but for now the command system isn't a very high priority.
  2. Originally I did just generate Java source for the Items class, however this caused some issues because Java has limits on how large classes/enums/files can be and since Terraria has ~5000 items that method just wasn't feasible.
  3. I'm open to refactoring if you can point out specific things you think could use changing.

If I'm going to be frank, this project wasn't really meant to become a genuine replacement for the vanilla Terraria server, as that is a lot of work and there's not much need for a rewrite. I mainly did this so I could have some fun messing around with the Terraria protocol (which is absolutely horrible by the way). Despite all this, if there are people that have genuine interest in Pluto and see opportunities for it I'm happy to look into that.

DeeChael commented 1 year ago

Thanks for your response! I'll review the source code in the coming weeks, and find something that can be improved. However, I'm not really good at programming, so it maybe takes some time.

So here is a little advice:

  1. Logger is supposed to be delivered when creating a new channel handler object instead of accessing it from a static field: https://github.com/jaydevelopsstuff/Pluto/blob/master/src/main/java/net/guardiandev/pluto/network/channel/GeneralChannelHandler.java
  2. You add a method named "readPacket" in ClientPacket class (I understand your design is that create a client packet object then invoke "readPacket" method), actually you can add a constructor with only one parameter which should be a ByteBuf and create a new instance while receiving a client packet with this constructor by reflecting: https://github.com/jaydevelopsstuff/Pluto/blob/6f8497298bd74ebd8de2aff8a213a6fdc1ea3d99/src/main/java/net/guardiandev/pluto/network/packet/client/ClientPacket.java#L10