Coder Social home page Coder Social logo

node-minecraft-wrap's Introduction

minecraft wrap

NPM version Build Status

Download and wrap the vanilla minecraft server and client in node.js.

Install

To install a downloadMinecraft and a runMinecraft command line programs, run:

npm install -g minecraft-wrap

Usage

downloadMinecraft 1.8.8 1.8.8.jar server
runMinecraft [<minecraft dir>] [<version>] [<username>] [<password>] [<stop>]

See examples

API

download(minecraftVersion,filename,done)

download the vanilla server of version minecraftVersion jar file at filename.

It checks with a md5 hash that the file downloaded is correct and it doesn't download it if the destination file is already the correct file.

downloadClient(minecraftVersion,filename,done)

download the vanilla client of version minecraftVersion jar file at filename.

downloadBedrockServer(os, version, outputPath, suffixVersion)

os: 'win' | 'linux' version: valid bedrock version (ie: '1.16.220') outputPath: name of folder to extract server to suffixVersion: the name of the outputFolder will be suffixed to the end of the folder name, ie: output to output1.16.220

download + unzip the bedrock server

new WrapServer(MC_SERVER_JAR,MC_SERVER_PATH[,OPTIONS])

initialize a wrapper with jar MC_SERVER_JAR, store mc server file at MC_SERVER_PATH

OPTIONS is an object containing the following optional properties:

  • minMem : the minimum memory allocated to the minecraft server, default to 512
  • maxMem : the maximum memory allocated to the minecraft server, default to 512
  • doneRegex : the regex to check for the server message announcing the server has started, default to new RegExp(/\[Server thread\/INFO\]: Done/)
  • noOverride : don't override config files
  • javaPath : specify path to a java executable to use, by default it's just java

WrapServer.startServer(propOverrides, done)

start the minecraft server with properties overrides propOverrides. Calls done when the server is started.

WrapServer.stopServer(done)

stop the minecraft server, calls done when the server is stopped.

WrapServer.deleteServerData(done)

delete the minecraft server data.

WrapServer.writeServer(line)

write line to the server.

"line" (line)

the Wrap instance emit that event when the server write a line

new WrapClient(clientPath,version)

create a client wrapper instance

  • using clientPath as minecraft directory (or the default os specific path if undefined)
  • with minecraft version version (or the version of the selected profile if undefined)

WrapClient.prepare()

prepare all the files requires for the minecraft client in the minecraft directory.

return a promise

WrapClient.auth(username,password)

authenticate the user using username and password. If these parameters are undefined, the selected user in the profile is used

return a promise

WrapClient.setAuthInfo(playerName,uuid,accessToken,userProperties)

set the authentication information directly without contacting the mojang servers. playerName, uuid, accessToken and userProperties need to be provided.

WrapClient.start()

start the client

return a promise that is resolved when the client is properly started

WrapClient.stop()

stop the client

return a promise that is resolved when the client is stopped

new LauncherDownload(mcPath,os="linux")

create a launcher downloader with mcPath as minecraft directory path

LauncherDownload.getWholeClient(version)

get the client jar, the assets, the libraries and extract the native libraries for the version version. return an object of arrays of the paths of the downloaded files

LauncherDownload.getVersionsList()

get and return a promise of the version list

LauncherDownload.getVersionInfos(version)

get and save the version infos and return a promise of it

LauncherDownload.getAssetIndex(version)

get and save the asset index and return a promise of it

LauncherDownload.getAllAssets(version)

get all the assets, save them and return a promise of an array of the paths

LauncherDownload.getAsset(assetFile,version)

get the asset assetFile, save it and return a promise of its path

LauncherDownload.getClient(version, [path])

get the client jar, save it and return return a promise of its path

LauncherDownload.getServer(version, [path])

get the server jar, save it and return return a promise of its path

LauncherDownload.extractNatives(version)

extract the natives files and return a promise to the path of the dir

LauncherDownload.getLibraries(version)

get all the libraries, save them and return a promise of an array of the paths

Testing

The MC_SERVER_JAR environment variable must be defined and point the .jar location before calling npm test.

node-minecraft-wrap's People

Contributors

dependabot-preview[bot] avatar dependabot[bot] avatar eejit43 avatar icetank avatar imharvol avatar lluiscab avatar nickelpro avatar rom1504 avatar u9g avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

node-minecraft-wrap's Issues

stop server error

........Server Started !
...[11:42:07] [Server thread/INFO]: Stopping the server
.[11:42:07] [Server thread/INFO]: Stopping server
.[11:42:07] [Server thread/INFO]: Saving players
.[11:42:07] [Server thread/INFO]: Saving worlds
.[11:42:07] [Server thread/INFO]: Saving chunks for level 'world'/Overworld
.[11:42:07] [Server thread/INFO]: Saving chunks for level 'world'/Nether
.[11:42:07] [Server thread/INFO]: Saving chunks for level 'world'/The End
.[11:42:07] [Server Shutdown Thread/INFO]: Stopping server
.[11:42:07] [Server Shutdown Thread/INFO]: Saving players
.2015-09-25 11:42:07,354 ERROR Attempted to append to non-started appender ServerGuiConsole
.Exception in thread "Server Shutdown Thread" org.apache.logging.log4j.core.appender.AppenderLoggingException: Attempted to append to non-started appender ServerGuiConsole
. at org.apache.logging.log4j.core.config.AppenderControl.callAppender(AppenderControl.java:89)
. at org.apache.logging.log4j.core.config.LoggerConfig.callAppenders(LoggerConfig.java:425)
. at org.apache.logging.log4j.core.config.LoggerConfig.log(LoggerConfig.java:406)
. at org.apache.logging.log4j.core.config.LoggerConfig.log(LoggerConfig.java:367)
. at org.apache.logging.log4j.core.Logger.log(Logger.java:110)
. at org.apache.logging.log4j.spi.AbstractLogger.info(AbstractLogger.java:1011)
. at net.minecraft.server.MinecraftServer.t(SourceFile:381)
. at net.minecraft.server.MinecraftServer$2.run(SourceFile:715)
Server Stopped !
Server data deleted !

Server JAR file check is in wrong location

In lib/wrap_server.js on line 95, it checks to see if the server JAR file exists, but it is checking in the directory that this Node application is running from. On line 109, you set the CWD to the directory where the rest of the server files are, so it needs the JAR file to be there. The check on line 95 should check to see if it exists in that directory instead.

Internal issue

I keep on getting this error:
events.js:291
throw er; // Unhandled 'error' event
^
Error: spawn java ENOENT
at Process.ChildProcess._handle.onexit (internal/child_process.js:268:19)
at onErrorNT (internal/child_process.js:464:16)
at processTicksAndRejections (internal/process/task_queues.js:80:21)
Emitted 'error' event on ChildProcess instance at:
at Process.ChildProcess._handle.onexit (internal/child_process.js:274:12)
at onErrorNT (internal/child_process.js:464:16)
at processTicksAndRejections (internal/process/task_queues.js:80:21) {
errno: -2,
code: 'ENOENT',
syscall: 'spawn java',
path: 'java',
spawnargs: [
'-jar',
'-Xms1024M',
'-Xmx1024M',
'./minecraft/Server.jar',
'nogui'
]
}

Spigot support

Working with spigot should be quite similar to working with the vanilla client. Adding support for this can be done by downloading the latest BuildTools.jar file for the given Minecraft version, and running that file to do the download process. Afterwhich, running the server should be nearly identical to vanilla, correct?

wrap.writeServer() not working

I'm trying to use the writeServer() method but it doesn't seem to be working. mc.writeServer('list'); for example set on an interval does nothing.

Check the checksum in download.js

16:20 < unascribed> S3 itself supplies MD5 checksums in the ETag header IIRC, let me check
16:21 < unascribed> yep, ETag of 1.8.3 matches the md5sum of the file
16:22 < unascribed> so you can just pull it from the HTTP headers, make sure to strip the surrounding quotes

That way we can fix interrupted download.

Better find a standard node module to handle reading the ETag / checking it matches with the file.

test client wrapper with more version

I only tested with 1.12
1.9 seems to work

however it seems 1.8 requires a user_properties parameter which the wrapper is not providing

tester with older versions too.

Ram-Option

Right now it seems for me that this module has no way to select how much ram a client should use.
Could you add that?

Downloading versions pre-1.2.5?

tmp $ downloadMinecraft 1.2.4
[Error: download failed : server responds with status 403]

is the error I get when I try to download anything before 1.2.5.

http://minecraft.gamepedia.com/Version_history

1.2.4, 1.2.3, 1.2.2, 1.2.1, 1.1, 1.0.1, 1.0.0, 1.0 also cannot download. Appears that 1.2.5 is the earlier version available through their AmazonAWS download site, so maybe not much node-minecraft-wrap can do here, short of some kind of patching service ala MCNostalgia. Curious how the official Minecraft launcher does it..

Can't find or load main class

I installed the module globally via yarn and executed:
downloadMinecraft 1.13.2 1.13.2.jar client
This worked just fine. Now I tried
runMinecraft ./ 1.13.2 <my username> <my password>
But after that the first time i get something like:

User logged in !
{ AssertionError [ERR_ASSERTION]: wrong size for C:\Users\derPi\Desktop\WrapTest\/assets/objects/d8/d859c9c5be04ffc41479b306814a933983eaa2     35
    at fs.stat.then.stats (C:\Users\derPi\AppData\Local\Yarn\Data\global\node_modules\minecraft-wrap\lib\launcher_download.js:182:45)
  generatedMessage: false,
  name: 'AssertionError [ERR_ASSERTION]',
  code: 'ERR_ASSERTION',
  actual: 23232,
  expected: 27101,
  operator: '==' }

And the second attempt:

User logged in !
Client prepared !
.Error: Could not find or load main class net.minecraft.client.main.Main
.Java HotSpot(TM) 64-Bit Server VM warning: Using incremental CMS is deprecated and will likely be removed in a future release

I don't know whats wrong here

Starting The Server

Hi. What is the "MC_SERVER_JAR" in new WrapServer(MC_SERVER_JAR,MC_SERVER_PATH[,OPTIONS]). I tried the path of the of the .jar file but it does not work. I also tried requiring the jar file but that also does not work. The error is:
/home/container/node_modules/minecraft-wrap/lib/wrap_server.js:80
Object.keys(propOverrides).forEach(prop => { props[prop] = propOverrides[prop] })
^
TypeError: Cannot convert undefined or null to object
at Function.keys (<anonymous>)
at WrapServer.startServer (/home/container/node_modules/minecraft-wrap/lib/wrap_server.js:80:12)
at Object.<anonymous> (/home/container/server.js:56:8)
So I am assuming it is an json object but where do you get it?

Error downloading 1.19 jar

When downloading the 1.19 jar file I'm running into the following error:

Error: download failed : wrong or partial file downloaded https://piston-meta.mojang.com/v1/packages/b03af5eb291163f7acc042d1553f2d212b220ecc/1.19.json <path>/minecraft-jar-extractor/versions/1.19/1.19.json
    at <path>/minecraft-jar-extractor/node_modules/minecraft-wrap/lib/etag_download.js:39:30
    at<path>/minecraft-jar-extractor/node_modules/minecraft-wrap/lib/etag_download.js:58:5
    at Hash.<anonymous> (<path>/minecraft-jar-extractor/node_modules/md5-file/index.js:38:5)
    at Object.onceWrapper (node:events:641:28)
    at Hash.emit (node:events:527:28)
    at emitReadable_ (node:internal/streams/readable:601:12)
    at onEofChunk (node:internal/streams/readable:579:5)
    at readableAddChunk (node:internal/streams/readable:275:5)
    at Hash.Readable.push (node:internal/streams/readable:234:10)
    at node:internal/streams/transform:126:12

Appears to be an issue with an updated etag headers that differs from the parsed md5 sum

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.