mirror of
https://github.com/PrismarineJS/node-minecraft-protocol.git
synced 2024-11-14 19:04:59 -05:00
fix gamemode3 in proxy : fix #146
* correctly generate the same uuidv3 than the vanilla server does in offline mode : fix #282 * remove "one player online mode" in the proxy : it doesn't make sense to identify all players as the user/passwd given in the cli. Now both servers in offline mode.
This commit is contained in:
parent
23b077b76f
commit
787f8d3423
3 changed files with 24 additions and 11 deletions
|
@ -2,7 +2,7 @@ var mc = require('../../');
|
|||
|
||||
var states = mc.states;
|
||||
function printHelpAndExit(exitCode) {
|
||||
console.log("usage: node proxy.js [<options>...] <target_srv> <user> [<password>] [<version>]");
|
||||
console.log("usage: node proxy.js [<options>...] <target_srv> [<version>]");
|
||||
console.log("options:");
|
||||
console.log(" --dump name");
|
||||
console.log(" print to stdout messages with the specified name.");
|
||||
|
@ -35,8 +35,6 @@ process.argv.forEach(function(val, index, array) {
|
|||
var args = process.argv.slice(2);
|
||||
var host;
|
||||
var port = 25565;
|
||||
var user;
|
||||
var passwd;
|
||||
var version;
|
||||
|
||||
var printAllNames = false;
|
||||
|
@ -62,8 +60,6 @@ var printNameBlacklist = {};
|
|||
}
|
||||
if(!(i + 2 <= args.length && args.length <= i + 4)) printHelpAndExit(1);
|
||||
host = args[i++];
|
||||
user = args[i++];
|
||||
passwd = args[i++];
|
||||
version = args[i++];
|
||||
})();
|
||||
|
||||
|
@ -98,9 +94,7 @@ srv.on('login', function(client) {
|
|||
var targetClient = mc.createClient({
|
||||
host: host,
|
||||
port: port,
|
||||
username: user,
|
||||
password: passwd,
|
||||
'online-mode': passwd != null ? true : false,
|
||||
username: client.username,
|
||||
keepAlive:false,
|
||||
version:version
|
||||
});
|
||||
|
|
|
@ -46,12 +46,13 @@
|
|||
"minecraft-data": "^0.13.0",
|
||||
"node-uuid": "~1.4.1",
|
||||
"prismarine-nbt": "0.0.1",
|
||||
"protodef": "0.2.0",
|
||||
"readable-stream": "^1.1.0",
|
||||
"superagent": "~0.10.0",
|
||||
"ursa-purejs": "0.0.3",
|
||||
"uuid": "^2.0.1",
|
||||
"yggdrasil": "0.1.0",
|
||||
"protodef":"0.2.0"
|
||||
"uuid-1345": "^0.99.6",
|
||||
"yggdrasil": "0.1.0"
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"ursa": "~0.9.1"
|
||||
|
|
|
@ -4,6 +4,7 @@ var yggserver = require('yggdrasil').server({});
|
|||
var states = require("./states");
|
||||
var bufferEqual = require('buffer-equal');
|
||||
var Server = require('./server');
|
||||
var UUID = require('uuid-1345');
|
||||
|
||||
module.exports=createServer;
|
||||
|
||||
|
@ -194,10 +195,27 @@ function createServer(options) {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
// https://github.com/openjdk-mirror/jdk7u-jdk/blob/f4d80957e89a19a29bb9f9807d2a28351ed7f7df/src/share/classes/java/util/UUID.java#L163
|
||||
function javaUUID(s)
|
||||
{
|
||||
var hash = crypto.createHash("md5");
|
||||
hash.update(s, 'utf8');
|
||||
var buffer = hash.digest();
|
||||
buffer[6] = (buffer[6] & 0x0f) | 0x30;
|
||||
buffer[8] = (buffer[8] & 0x3f) | 0x80;
|
||||
return buffer;
|
||||
}
|
||||
|
||||
function nameToMcOfflineUUID(name)
|
||||
{
|
||||
return (new UUID(javaUUID("OfflinePlayer:"+name))).toString();
|
||||
}
|
||||
|
||||
function loginClient() {
|
||||
var isException = !!server.onlineModeExceptions[client.username.toLowerCase()];
|
||||
if(onlineMode == false || isException) {
|
||||
client.uuid = "0-0-0-0-0";
|
||||
client.uuid = nameToMcOfflineUUID(client.username);
|
||||
}
|
||||
client.write('compress', { threshold: 256 }); // Default threshold is 256
|
||||
client.compressionThreshold = 256;
|
||||
|
|
Loading…
Reference in a new issue