Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suggestion #2

Open
DeeChael opened this issue Mar 25, 2023 · 2 comments
Open

Suggestion #2

DeeChael opened this issue Mar 25, 2023 · 2 comments

Comments

@DeeChael
Copy link

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
Copy link
Owner

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
Copy link
Author

DeeChael commented Apr 1, 2023

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:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants