superzanti / ServerSync

Sync files between client and server for Minecraft Forge
GNU General Public License v3.0
160 stars 26 forks source link

Silent run as client #65

Closed TomberWolf closed 7 years ago

TomberWolf commented 7 years ago

It would be nice if we could run the client in a silent mode. So we can use it for a mod pack and run it before Minecraft starts and all of the needed files would be synced without the need of updating them manually.

rheimus commented 7 years ago

I like the sound of that. Let me just confirm we are on the same page.

from some action (eg. user presses play in their client) serversync runs its client update and closes without building it's GUI, or perhaps better it builds a specific progress GUI that just closes when complete.

Minecraft is triggered to run on completion of the update.

TomberWolf commented 7 years ago

To make it more clear:

We're providing our mod pack with a batch file that runs the Minecraft jar. So it would be easy to run the serversync client at first with "-silent" for example. It checks if updates are available and if not it closes and the batch file runs Minecraft.

If there are new updates it could show a progress bar with informations that it's updating or something like that, does the updates, closes and Minecraft runs.

Smooth, easy to manage and always up to date.

rheimus commented 7 years ago

Sweet, yeah should be able to fairly easily get that functionality going.

I'll add it to the priority updates

rheimus commented 7 years ago

Added a pre-release of 'headless' client sync. This has had minimal testing but it should work as expected, note that the progress-only option currently just uses ServerSyncs normal GUI.

TomberWolf commented 7 years ago
E:\>java -jar serversync-2.6.13.jar silent
finished loading config
Loading language file: de_de
No language file available for: de_de, defaulting to en_US
finished loading config
Exception in thread "Thread-3" java.lang.NullPointerException
        at com.superzanti.serversync.ClientWorker.run(ClientWorker.java:86)
        at java.lang.Thread.run(Unknown Source)
rheimus commented 7 years ago

ahh, yes. Helps to fix the GUI update calls. I'll bash out another candidate

rheimus commented 7 years ago

New version in the releases should sort the GUI calls when in silent, gave it a breif test run on both silent and progress-only. Both seem to be working as intended.

TomberWolf commented 7 years ago

That did the trick! Thanks, mate!

rheimus commented 7 years ago

Shall do some further testing and push a release if all goes well

P3rf3ctXZer0 commented 7 years ago

"(user presses play in their client) serversync runs its client update and closes without building it's GUI, or perhaps better it builds a specific progress GUI that just closes when complete.

Minecraft is triggered to run on completion of the update."

I like this idea; my players don't seem to understand the concept of updating and its hindering my ability to get people to connect. Since I have pokecube ... I get a younger crowd. It would really assist me in growing my player base if there was a way to check for updates automatically on launch without bats of any kind.

Although instead of a gui it could use a progress bar. @superzanti

rheimus commented 7 years ago

I'll look into a way to hook into the Minecraft launcher.

TomberWolf commented 7 years ago

In some cases, ServerSync doesn't remove files which are not longer present on the server. The error tells that the file is currently in use.

java.nio.file.FileSystemException: mods\NotEnoughItems-1.10.2-2.1.3.207-universal.jar: Der Prozess kann nicht auf die Datei zugreifen, da sie von einem anderen Prozess verwendet wird.

        at sun.nio.fs.WindowsException.translateToIOException(Unknown Source)
        at sun.nio.fs.WindowsException.rethrowAsIOException(Unknown Source)
        at sun.nio.fs.WindowsException.rethrowAsIOException(Unknown Source)
        at sun.nio.fs.WindowsFileSystemProvider.implDelete(Unknown Source)
        at sun.nio.fs.AbstractFileSystemProvider.delete(Unknown Source)
        at java.nio.file.Files.delete(Unknown Source)
        at com.superzanti.serversync.util.SyncFile$1.run(SyncFile.java:262)
rheimus commented 7 years ago

Interesting, could you post the batch file you are using, removing any sensitive info of course (IP addresses etc)

rheimus commented 7 years ago

I get the feeling we have an async process running here with a bit of a race condition

TomberWolf commented 7 years ago

Sure. Strange: The same thing happened when I opened the ServerSync client jar itself with it's GUI. And today I've updated some other mod files without any problems. Don't ask me how it happened but it did.

Please don't wonder if you take a look at my launcher batch. We're using a different folder structure than MC does. And it's a really simple batch file, nothing special. Minecraft Launcher.zip

rheimus commented 7 years ago

Looks like it must be an issue with serversync, nothing out of the ordinary in the batch.

Does it output the ____ part before starting Minecraft?

TomberWolf commented 7 years ago

Yes. The line is just for a better overview after running ServerSync.

rheimus commented 7 years ago

Might have to add some more specialised error handling around deletion. Any particular file it fails to delete or just random?

TomberWolf commented 7 years ago

For now it was just NotEnoughItems-1.10.2-2.1.3.207-universal.jar. Several updates after that issue worked like a charm without any problems.

rheimus commented 7 years ago

@TomberWolf This could potentially happen if serversync was opened twice, or if it had not finished before being opened again.

TomberWolf commented 7 years ago

I thought in the same way, so I've checked the processes to make sure that there were no other java processes. Dunno. It never happened again.

P3rf3ctXZer0 commented 7 years ago

@rheimus any updates on a test release for an update at start release? I cannot tell you the number of people who ask me the same question ... it is very much a pain in the ass to try and re-explain the same thing every damn time.

PS thank you very much for all your efforts by the way.

TomberWolf commented 7 years ago

It works. You just need to run Minecraft in a batch file witch the serversync silent before.

P3rf3ctXZer0 commented 7 years ago

So your saying @TomberWolf that all my clients have to do is launch the game - not a bat - and it will automatically update their clients?

If not then its not enough because not everyone understand to run a 3rd party app. Most people are stupid lets face it. Also the younger the player base the deeper the naivety.

Also I am not a coder just a moderator so making bats and hooks are very difficult for me.

rheimus commented 7 years ago

@P3rf3ctXZer0 Using a batch file would essentially be like creating a shortcut to the minecraft launcher, could even tell windows / linux / whatever to give it a nice icon :)

It lets you intercept the users request to run something, in this case the minecraft launcher, and run whatever commands you like before that happens.

Your program flow from a users perspective would be:

All you really need to know to create a batch file is where the minecraft launcher & serversync are located on your target machines, which is the hard part as by default it's not always in the same place.

You could even bypass the launcher entirely and just directly launch minecraft.

I'm happy to make a custom batch file for you if it works with your target audience.

http://minecraft.gamepedia.com/Minecraft_launcher has some useful material on directly launching minecraft and connecting to a server

rheimus commented 7 years ago

I have made very little progress in the research front for hooking into the native minecraft launcher. It's probably next up on my agenda though.

TomberWolf commented 7 years ago

Would it not be much easier to just add a command within the updating process that runs the launcher after finishing the sync directly from the serversync.jar?

So players just need to run serversync.jar that handles the rest. Done.

rheimus commented 7 years ago

@TomberWolf Probably yeah, just requires me to either have some sort of auto discovery of where the minecraft launcher is or to have the user set the location manually.

Would be interesting to see if you can set up a profile in the launcher to point to serversync instead of minecraft, then I just need to pass the args along to minecraft after running serversyncs update.

P3rf3ctXZer0 commented 7 years ago

@rheimus Thank you for all your effort. I would love a custom bat file. Its got to be technic pack ready though because everyone appears to be pretty stupid ... I don't see whats so hard about just launching a jar file.

rheimus commented 7 years ago

@P3rf3ctXZer0 I'll grab a copy of technic over the weekend and see how they are structuring themselves, should be able to throw something together.

P3rf3ctXZer0 commented 7 years ago

@rheimus I very much appreciate that. At any rate I believe people are so used to auto updating that they think that games just code themselves at this point.

rheimus commented 7 years ago

had a brief look at technics layout, its not quite standard mc. shall investigate further

TomberWolf commented 7 years ago

Okay, crazy!! The process in use issue seems to be mod related. Today I've updated Not Enough Items and ServerSync has the same issue again. But just and only with this special mod. How strange is that?

rheimus commented 7 years ago

Strange indeed, ill have to pick apart NEI to see what's up.

rheimus commented 7 years ago

which version of NEI? The JEI wrapper for 10.2 or the normal one for 1.7.10?

TomberWolf commented 7 years ago

https://minecraft.curseforge.com/projects/not-enough-items-1-8/files?filter-game-version=2020709689%3A6170

rheimus commented 7 years ago

Cheers shall have a poke around it's files

rheimus commented 7 years ago

Nothing terribly out of the ordinary in NEI. Its .info file is named neimod.info, could possibly be stumbling SS, but I'm pretty sure SS just falls back to hash comparison if it cant find mcmod.info

rheimus commented 7 years ago

SS seems to have no issue transferring NEI on its own, probably a deeper issue.

P3rf3ctXZer0 commented 7 years ago

@rheimus how is the status of making a useable auto updater ... unfortunately even a tutorial as good as this still leaves people stupid.

https://docs.google.com/document/d/1nsZZSRFc_7ci2TgOOl_4g8hylX_0NRB8teEx2zZ4abs/edit?usp=sharing

rheimus commented 7 years ago

That's a pretty thorough guide! Its actually useful to have that as I can follow the guide to determine a common setup. Am attempting to build a 'catch all' batch for you that should work in most cases.

Unfortunately its not really something I can test at work, IT would not be happy to see minecraft & game launchers on my system :smile:

Havent had much luck with hooking into standard Minecraft workflow.

TomberWolf commented 7 years ago

Today there was an update for Optifine (client side only). http://adf.ly/404181/optifine.net/adloadx?f=OptiFine_1.10.2_HD_U_D8.jar

Same issue as with Not Enough Items.

So: The new one is copied like a charm, the older versions stuck.


java.nio.file.FileSystemException: mods\OptiFine_1.10.2_HD_U_D7.jar: Der Prozess kann nicht auf die Datei zugreifen, da sie von einem anderen Prozess verwendet wird.

        at sun.nio.fs.WindowsException.translateToIOException(Unknown Source)
        at sun.nio.fs.WindowsException.rethrowAsIOException(Unknown Source)
        at sun.nio.fs.WindowsException.rethrowAsIOException(Unknown Source)
        at sun.nio.fs.WindowsFileSystemProvider.implDelete(Unknown Source)
        at sun.nio.fs.AbstractFileSystemProvider.delete(Unknown Source)
        at java.nio.file.Files.delete(Unknown Source)
        at com.superzanti.serversync.util.SyncFile$1.run(SyncFile.java:262)
java.nio.file.FileSystemException: mods\NotEnoughItems-1.10.2-2.1.3.219-universal.jar: Der Prozess kann nicht auf die Datei zugreifen, da sie von einem anderen Prozess verwendet wird.

        at sun.nio.fs.WindowsException.translateToIOException(Unknown Source)
        at sun.nio.fs.WindowsException.rethrowAsIOException(Unknown Source)
        at sun.nio.fs.WindowsException.rethrowAsIOException(Unknown Source)
        at sun.nio.fs.WindowsFileSystemProvider.implDelete(Unknown Source)
        at sun.nio.fs.AbstractFileSystemProvider.delete(Unknown Source)
        at java.nio.file.Files.delete(Unknown Source)
        at com.superzanti.serversync.util.SyncFile$1.run(SyncFile.java:262)
rheimus commented 7 years ago

Useful information indeed. Sounds like SS might be holding leftover file access from the update phase.

Good find thank you :+1:

rheimus commented 7 years ago

@P3rf3ctXZer0 Start_NeverEndingInstability.zip

Haven't exactly done thorough testing on it but that batch file should be runnable from anywhere on a windows machine, at the moment I have left it as running any serversync that it finds in the Instances folder.

If you want it to specifically run your modpacks serversync only then theres a commented out line in the batch file that you can implement to make it only run serversync on your pack.

The file is also fairly heavily commented if you are interested in what it is doing.

Basically it just searches for serversync (assuming that people have followed your guide and are using curse) and runs it in progress mode then runs the curse client as your users will still need to log in etc.

P3rf3ctXZer0 commented 7 years ago

Thank you that is awesome :) - just one problem ... I have idiots ignoring the guide completely - I need it to auto run without them knowing - or caring in most cases as I am sad to say but I will use that bat I like shortcuts XD

I am sorry I am asking this of you.

rheimus commented 7 years ago

@P3rf3ctXZer0 So we need something that searches for your modpack regardless of the launcher being used?

To clarify, as long as the user is using curse that batch should work regardless of what settings they have used. We could always make several batches for each launcher that basically just do the same thing.

P3rf3ctXZer0 commented 7 years ago

It needs to be code that launches the moment someone launches the modpack like pre-modpack launch. Do you play smite or league legends? If so think of the way their clients update or think of the way world of warcraft updates. If need be you can only make changes for the vanilla minecraft launcher. ... what about a launcher in a launcher like League? Basically a user launches league - they sign in - then it loads client and checks for updates and restarts as needed and player launches client again and they get in game and can play because no updates are detected.

We need a way to force players to update on launch without them clicking anything.

rheimus commented 7 years ago

The hook is the problem, launchers lock you down to only being able to run minecraft specifically.

Short of writing a hijack virus we cant really use any part of the launcher process, writing a custom launcher has the same problem that your clients would need to download and use the custom version (virus has the same problem too for that matter).

We only really have access to these events:

P3rf3ctXZer0 commented 7 years ago

Hmmm ... see if you can talk to a dev who made a completely custom client. https://discord.gg/HNKTMNh ask for "Peterix" He knows a great deal about client code who knows maybe he can hook your mod right into his client.

Here is the launcher he and his team created https://multimc.org/.

rheimus commented 7 years ago

I'm not sure that SS would work as an integrated part of a launcher on further thought:

To get an ideal setup we either have to use explicit user interaction (i.e. the batch file) as this is the user saying I want to specifically connect to this server, or we need to shift the sync process to post connection request.

Post connection request as far as I know at the moment does not play well with forge as its really designed around pre-loading everything.