Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ jobs:

strategy:
matrix:
node-version: [12.x, 14.x, 16.x]
node-version: [20.x, 22.x]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM ubuntu:focal
FROM ubuntu:noble
LABEL MAINTAINER='William Dizon <[email protected]>'

#update and accept all prompts
Expand All @@ -18,7 +18,7 @@ RUN apt-get update && apt-get install -y \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

#install node from nodesource following instructions: https://github.com/nodesource/distributions#debinstall
RUN curl -fsSL https://deb.nodesource.com/setup_14.x | bash - \
RUN curl -fsSL https://deb.nodesource.com/setup_22.x | bash - \
&& apt-get install -y nodejs \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

Expand Down
10 changes: 5 additions & 5 deletions Dockerfile.dev
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM ubuntu:focal as build
FROM ubuntu:noble as build
LABEL MAINTAINER='William Dizon <[email protected]>'

#set build directory
Expand All @@ -9,7 +9,7 @@ ARG DEBIAN_FRONTEND=noninteractive
RUN apt-get update && apt-get install -y \
curl \
build-essential \
&& curl -fsSL https://deb.nodesource.com/setup_14.x | bash - \
&& curl -fsSL https://deb.nodesource.com/setup_22.x | bash - \
&& apt-get install -y nodejs

# copy package.json and npm install
Expand All @@ -21,7 +21,7 @@ RUN npm install
COPY . /build

#final image
FROM ubuntu:focal
FROM ubuntu:noble

WORKDIR /usr/games/minecraft

Expand All @@ -34,10 +34,10 @@ RUN apt-get update && apt-get install -y \
git \
curl \
rlwrap \
openjdk-17-jre-headless \
openjdk-21-jre-headless \
openjdk-8-jre-headless \
ca-certificates-java \
&& curl -fsSL https://deb.nodesource.com/setup_14.x | bash - \
&& curl -fsSL https://deb.nodesource.com/setup_22.x | bash - \
&& apt-get install -y nodejs \
&& apt-get autoremove -y \
&& apt-get clean \
Expand Down
75 changes: 39 additions & 36 deletions mineos.js
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ mineos.mc = function(server_name, base_dir) {
unzipper.on('error', function (err) {
cb(err);
});

unzipper.on('extract', function (log) {
move_to_parent_dir(self.env.cwd, cb);
});
Expand Down Expand Up @@ -506,7 +506,7 @@ mineos.mc = function(server_name, base_dir) {
'xmx': function (cb) {
self.sc(function (err, dict) {
var value = parseInt((dict.java || {}).java_xmx) || 0;

cb((value >= 0 ? null : 'XMX heapsize must be positive integer >= 0'), value);
});
},
Expand Down Expand Up @@ -550,7 +550,7 @@ mineos.mc = function(server_name, base_dir) {
args.push('-Xmx{0}M'.format(results.xmx));
if (results.xms > 0)
args.push('-Xms{0}M'.format(results.xms));

if (results.java_tweaks) {
var splits = results.java_tweaks.split(/ /);
for (var i in splits)
Expand Down Expand Up @@ -704,7 +704,7 @@ mineos.mc = function(server_name, base_dir) {
self.copy_profile = function(callback) {
function rsync_profile(source, dest, username, groupname, callback_er) {
var rsync = require('rsync');

var obj = rsync.build({
source: source,
destination: dest,
Expand Down Expand Up @@ -757,7 +757,7 @@ mineos.mc = function(server_name, base_dir) {
shell:'ssh',
output: [function(output) {
stdout.push(output);
},
},
function(output) {
stderr.push(output);
}]
Expand All @@ -781,7 +781,7 @@ mineos.mc = function(server_name, base_dir) {
continue; //known pattern on freebsd: 'sent 79 bytes received 19 bytes 196.00 bytes/sec'
all_files = all_files.concat(incr_file_list[i].toString().split('\n'))
}

cb(null, all_files.filter(function(n){ return n.length }));
}
], callback)
Expand Down Expand Up @@ -846,23 +846,23 @@ mineos.mc = function(server_name, base_dir) {
async.apply(self.stuff, 'stop'),
function(cb) {
async.whilst(
function() {
function() {
if (iterations > MAX_ITERATIONS_TO_QUIT)
return false;
else
return (self.server_name in mineos.server_pids_up())
return (self.server_name in mineos.server_pids_up())
},
function(cc) {
function(cc) {
iterations += 1;
setTimeout(cc, test_interval_ms)
setTimeout(cc, test_interval_ms)
},
function(ignored_err) {
if (self.server_name in mineos.server_pids_up())
cb(true); //error, stop did not succeed
else
cb(null); //no error, stop succeeded as expected
}
);
);
}
], callback);
}
Expand Down Expand Up @@ -897,7 +897,7 @@ mineos.mc = function(server_name, base_dir) {
iterations += 1;
setTimeout(cb, test_interval_ms);
},
function() {
function() {
if (iterations > MAX_ITERATIONS_TO_QUIT)
return false;
else
Expand All @@ -909,7 +909,7 @@ mineos.mc = function(server_name, base_dir) {
else
callback(null); //no error, stop succeeded: true
}
)
)
}
}

Expand All @@ -928,7 +928,7 @@ mineos.mc = function(server_name, base_dir) {
})
},
function(cb) {
cb(null, child_process.spawn(binary,
cb(null, child_process.spawn(binary,
['-S', 'mc-{0}'.format(self.server_name),
'-p', '0', '-X', 'eval', 'stuff "{0}\012"'.format(msg)],
params));
Expand All @@ -952,7 +952,7 @@ mineos.mc = function(server_name, base_dir) {
})
},
function(cb) {
cb(null, child_process.spawn(binary,
cb(null, child_process.spawn(binary,
['-S', 'mc-{0}'.format(self.server_name),
'-p', '0', '-X', 'eval', 'stuff "save-all\012"'],
params));
Expand All @@ -968,7 +968,7 @@ mineos.mc = function(server_name, base_dir) {
var TIMEOUT_LENGTH = 10000;
var tail = require('tail').Tail;

try {
try {
var new_tail = new tail(path.join(self.env.cwd, 'logs/latest.log'));
} catch (e) {
callback(true);
Expand Down Expand Up @@ -1099,7 +1099,7 @@ mineos.mc = function(server_name, base_dir) {
callback(code);
})
}

self.list_increments = function(callback) {
var binary = which.sync('rdiff-backup');
var args = ['--list-increments', self.env.bwd];
Expand Down Expand Up @@ -1155,7 +1155,10 @@ mineos.mc = function(server_name, base_dir) {

rdiff.stdout.on('data', function(data) {
var buffer = Buffer.from(data, 'ascii');
var lines = buffer.toString('ascii').split('\n');

// Since rdiff-backup v2.1.1a0 increments are listed in ascending order instead of descending
// https://github.com/rdiff-backup/rdiff-backup/blob/v2.1.1a0/CHANGELOG.adoc#11-changes
var lines = buffer.toString('ascii').split('\n').reverse();
var incrs = 0;

for (var i=0; i < lines.length; i++) {
Expand Down Expand Up @@ -1212,11 +1215,11 @@ mineos.mc = function(server_name, base_dir) {
});

callback(err || inner_err, all_info);
});
});
} else {
callback(err, all_info);
}
})
})
}

self.prune = function(step, callback) {
Expand Down Expand Up @@ -1294,12 +1297,12 @@ mineos.mc = function(server_name, base_dir) {
callback(err, stat_info['gid']);
})
break;
case 'exists':
case 'exists':
fs.stat(self.env.sp, function(err, stat_info) {
callback(null, !!stat_info);
});
break;
case '!exists':
case '!exists':
fs.stat(self.env.sp, function(err, stat_info) {
callback(null, !stat_info);
});
Expand Down Expand Up @@ -1496,14 +1499,14 @@ mineos.mc = function(server_name, base_dir) {
async.waterfall([
async.apply(fs.readdir, self.env.cwd),
function(sf, cb) {
server_files.push.apply(server_files, sf.filter(function(file) {
return file.substr(-4).toLowerCase() == '.jar';
server_files.push.apply(server_files, sf.filter(function(file) {
return file.substr(-4).toLowerCase() == '.jar';
}))
server_files.push.apply(server_files, sf.filter(function(file) {
return file.substr(-5).toLowerCase() == '.phar';
server_files.push.apply(server_files, sf.filter(function(file) {
return file.substr(-5).toLowerCase() == '.phar';
}))
server_files.push.apply(server_files, sf.filter(function(file) {
return file == 'Cuberite';
server_files.push.apply(server_files, sf.filter(function(file) {
return file == 'Cuberite';
}))
cb();
},
Expand All @@ -1521,10 +1524,10 @@ mineos.mc = function(server_name, base_dir) {
if (err) {
cb();
} else {
server_files.push.apply(server_files, files.filter(function(file) {
server_files.push.apply(server_files, files.filter(function(file) {
return ((file.substr(-4).toLowerCase() == '.jar' && server_files.indexOf(file) < 0)
|| (file.substr(-5).toLowerCase() == '.phar' && server_files.indexOf(file) < 0)
|| (file == 'Cuberite' && server_files.indexOf(file) < 0));
|| (file == 'Cuberite' && server_files.indexOf(file) < 0));
}))
cb();
}
Expand Down Expand Up @@ -1573,7 +1576,7 @@ mineos.mc = function(server_name, base_dir) {
self.sc(function(err,dict){
java.usedJavaVersion(dict,callback);
})

break;
default:
callback(true, undefined);
Expand Down Expand Up @@ -1602,7 +1605,7 @@ mineos.mc = function(server_name, base_dir) {
buffer[i] = buffer[i+1];
buffer[i+1] = a;
}
return buffer;
return buffer;
}

function splitBuffer(buf, delimiter) {
Expand Down Expand Up @@ -1652,7 +1655,7 @@ mineos.mc = function(server_name, base_dir) {
'\x00\x6f\x00\x73\x00\x74' +
'\x00\x00\x63\xdd'
}

socket.setTimeout(2500);

socket.on('connect', function() {
Expand Down Expand Up @@ -1688,7 +1691,7 @@ mineos.mc = function(server_name, base_dir) {
players_max: parseInt(buffer_to_ascii(legacy_split[2]))
});
}
}
}
});

socket.on('error', function(err) {
Expand All @@ -1708,7 +1711,7 @@ mineos.mc = function(server_name, base_dir) {
return;
}
send_query_packet(dict['server-port']);
})
})
}

self.query = function(callback) {
Expand Down Expand Up @@ -1779,7 +1782,7 @@ mineos.mc = function(server_name, base_dir) {

self.previous_property = function(restore_as_of, callback) {
self.previous_version('server.properties', restore_as_of, function(err, file_contents) {

if (err) {
callback(err, null)
} else {
Expand Down
Loading