node-minecraft-protocol icon indicating copy to clipboard operation
node-minecraft-protocol copied to clipboard

Advanced proxy example with multiple servers

Open misiek08 opened this issue 9 years ago • 16 comments

Hi! I think we need example proxy code with switching servers, so it will work a little like MCProxy or Bungeecord to show NMP's power.

misiek08 avatar Nov 10 '15 02:11 misiek08

Yeah it might be interesting to do an example like that.

rom1504 avatar Nov 10 '15 09:11 rom1504

While having such a project would be fun, it wouldn't belong in the examples. It is a very complex task with lots of pitfalls, and wouldn't fit a single small file showing off a feature.

roblabla avatar Nov 10 '15 13:11 roblabla

I mean just proxy with switching servers without complex logic and plugins, so only handling command or pluginmessage to reconnect player internally to another server.

I tried repeating same steps as BungeeCord do, but it didn't work in some situations. I'll share code (it's a bit old) when I get home later today.

misiek08 avatar Nov 10 '15 14:11 misiek08

The problem is switching server is hard to get right. You need to keep a mapping of the entityId of each player of each server. You need to make sure those ids never collision with some id assigned by other servers. Then there is the trouble of the scoreboard that needs to be reset when switching server. The player list has a similar problem.

It's just a complicated mess and making a proper example that works in every situation requires careful handling of almost every packet. Not to mention, with every mc update, it'll probably keep getting bigger and more convoluted. I think it's a great idea, but i don't think it belongs in the nmp examples.

On Tue, Nov 10, 2015, 3:16 PM Misiek [email protected] wrote:

I mean just proxy with switching servers without complex logic and plugins, so only handling command or pluginmessage to reconnect player internally to another server.

I tried repeating same steps as BungeeCord do, but it didn't work in some situations. I'll share code (it's a bit old) when I get home later today.

— Reply to this email directly or view it on GitHub https://github.com/PrismarineJS/node-minecraft-protocol/issues/302#issuecomment-155432232 .

roblabla avatar Nov 10 '15 14:11 roblabla

I knew about scoreboards and player list and it's very easy to clear them (my code wasn't doing it), so I'll rewrite this code in next few weeks (I take much time for testing, writing code takes few minutes) and try with other solution. I was looking at other solutions and they don't care about entityIds, but are only clearing scoreboard and playerlist. I'll try to reproduce one solution in NMP first.

misiek08 avatar Nov 10 '15 18:11 misiek08

hey @misiek08 did you manage to get any of this code written in the end I'd be really interested in taking a look

vimes1984 avatar Mar 22 '16 11:03 vimes1984

me too - this would be very helpful for a project I am involved in as well.

growlf avatar Mar 22 '16 19:03 growlf

I gave up on NMP and did own implementation in Go. Saved me many hours fighting with this library. I had to implement only few packets and pass-through others, so it worked good. I was sys-admin on some minecraft server-network and I left, because of way too small salary :)

If NMP will stabilize with multiple protocol support and API I can try again with proxy.

EDIT: Doing such proxy, even with EMP, should take about 300-500 lines of code to write, so just try on your own. I gave up, because my implementation need to ask HTTP server for permission when someone is connecting and this didn't work well with NMP.

misiek08 avatar Mar 22 '16 23:03 misiek08

do you have the Go implementation you wrote I can take a peek at by any chance?

vimes1984 avatar Mar 22 '16 23:03 vimes1984

I can't share it now, because it contains data about endpoints used for auth, but I think about making it clean and selling it, because it was pretty fast.

misiek08 avatar Mar 23 '16 01:03 misiek08

If NMP will stabilize with multiple protocol support and API I can try again with proxy.

NMP API has been mostly stable for a long time (let's say 3 years). multiple version support is a new thing, yes. Not sure what's your point about that.

What would be nice concerning proxy and nmp is a proxy lib. There is a client lib based on nmp (mineflayer) and a server lib based on nmp (flying-squid, although it could be made more of a lib and less of a server) but there is no proxy lib currently. If someone would create a proxy lib on top of nmp, it could make it much easier to build any kind of nmp proxy.

https://github.com/Egoscio/gelato is interesting, but it's more of a proxy/wrapper than a proxy lib.

A proxy lib should provide proxy functionnalities and not force their usage. Then all these various proxy projects could be simplified by using that proxy lib.

rom1504 avatar Mar 23 '16 12:03 rom1504

I'll see if I can't write that :D

vimes1984 avatar Mar 23 '16 12:03 vimes1984

That sounds like that is the ticket, then. Right. Well, time to roll up the sleeves and get started.

growlf avatar Mar 23 '16 16:03 growlf

By the way, Rom1504? I don't know if you hear this enough, but thank you and the others in the FlyingSquid and Prismarine groups for this amazing option to enhance our servers and the community. You folx rock!

growlf avatar Mar 23 '16 16:03 growlf

@rom1504 where does mcserve sit in the node-minecraft-protocol spectrum then?

vimes1984 avatar Mar 23 '16 17:03 vimes1984

It's a vanilla (java, mojang) minecraft server wrapper. Similar to https://github.com/rom1504/node-minecraft-wrap/blob/master/lib/wrap.js with some more functionalities.

rom1504 avatar Mar 23 '16 18:03 rom1504