mirror of
https://github.com/tribufu/node-gamedig
synced 2026-06-01 09:42:41 +00:00
Convert tabs to spaces
This commit is contained in:
parent
0dd25bfcda
commit
3674d384d0
39 changed files with 2414 additions and 2414 deletions
|
|
@ -1,36 +1,36 @@
|
|||
const request = require('request');
|
||||
|
||||
class Terraria extends require('./core') {
|
||||
run(state) {
|
||||
request({
|
||||
uri: 'http://'+this.options.address+':'+this.options.port_query+'/v2/server/status',
|
||||
timeout: 3000,
|
||||
qs: {
|
||||
players: 'true',
|
||||
token: this.options.token
|
||||
}
|
||||
}, (e,r,body) => {
|
||||
if(e) return this.fatal('HTTP error');
|
||||
let json;
|
||||
try {
|
||||
json = JSON.parse(body);
|
||||
} catch(e) {
|
||||
return this.fatal('Invalid JSON');
|
||||
}
|
||||
|
||||
if(json.status !== 200) return this.fatal('Invalid status');
|
||||
run(state) {
|
||||
request({
|
||||
uri: 'http://'+this.options.address+':'+this.options.port_query+'/v2/server/status',
|
||||
timeout: 3000,
|
||||
qs: {
|
||||
players: 'true',
|
||||
token: this.options.token
|
||||
}
|
||||
}, (e,r,body) => {
|
||||
if(e) return this.fatal('HTTP error');
|
||||
let json;
|
||||
try {
|
||||
json = JSON.parse(body);
|
||||
} catch(e) {
|
||||
return this.fatal('Invalid JSON');
|
||||
}
|
||||
|
||||
for (const one of json.players) {
|
||||
state.players.push({name:one.nickname,team:one.team});
|
||||
}
|
||||
|
||||
state.name = json.name;
|
||||
state.raw.port = json.port;
|
||||
state.raw.numplayers = json.playercount;
|
||||
if(json.status !== 200) return this.fatal('Invalid status');
|
||||
|
||||
this.finish(state);
|
||||
});
|
||||
}
|
||||
for (const one of json.players) {
|
||||
state.players.push({name:one.nickname,team:one.team});
|
||||
}
|
||||
|
||||
state.name = json.name;
|
||||
state.raw.port = json.port;
|
||||
state.raw.numplayers = json.playercount;
|
||||
|
||||
this.finish(state);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Terraria;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue