@@ -280,8 +280,8 @@ int ModApiMainMenu::l_get_favorites(lua_State *L)
280
280
{
281
281
std::string listtype = " local" ;
282
282
283
- if (!lua_isnone (L,1 )) {
284
- listtype = luaL_checkstring (L,1 );
283
+ if (!lua_isnone (L, 1 )) {
284
+ listtype = luaL_checkstring (L, 1 );
285
285
}
286
286
287
287
std::vector<ServerListSpec> servers;
@@ -298,19 +298,19 @@ int ModApiMainMenu::l_get_favorites(lua_State *L)
298
298
299
299
for (const Json::Value &server : servers) {
300
300
301
- lua_pushnumber (L,index );
301
+ lua_pushnumber (L, index );
302
302
303
303
lua_newtable (L);
304
304
int top_lvl2 = lua_gettop (L);
305
305
306
306
if (!server[" clients" ].asString ().empty ()) {
307
307
std::string clients_raw = server[" clients" ].asString ();
308
308
char * endptr = 0 ;
309
- int numbervalue = strtol (clients_raw.c_str (),&endptr,10 );
309
+ int numbervalue = strtol (clients_raw.c_str (), &endptr,10 );
310
310
311
311
if ((!clients_raw.empty ()) && (*endptr == 0 )) {
312
- lua_pushstring (L," clients" );
313
- lua_pushnumber (L,numbervalue);
312
+ lua_pushstring (L, " clients" );
313
+ lua_pushnumber (L, numbervalue);
314
314
lua_settable (L, top_lvl2);
315
315
}
316
316
}
@@ -319,83 +319,83 @@ int ModApiMainMenu::l_get_favorites(lua_State *L)
319
319
320
320
std::string clients_max_raw = server[" clients_max" ].asString ();
321
321
char * endptr = 0 ;
322
- int numbervalue = strtol (clients_max_raw.c_str (),&endptr,10 );
322
+ int numbervalue = strtol (clients_max_raw.c_str (), &endptr,10 );
323
323
324
324
if ((!clients_max_raw.empty ()) && (*endptr == 0 )) {
325
- lua_pushstring (L," clients_max" );
326
- lua_pushnumber (L,numbervalue);
325
+ lua_pushstring (L, " clients_max" );
326
+ lua_pushnumber (L, numbervalue);
327
327
lua_settable (L, top_lvl2);
328
328
}
329
329
}
330
330
331
331
if (!server[" version" ].asString ().empty ()) {
332
- lua_pushstring (L," version" );
332
+ lua_pushstring (L, " version" );
333
333
std::string topush = server[" version" ].asString ();
334
- lua_pushstring (L,topush.c_str ());
334
+ lua_pushstring (L, topush.c_str ());
335
335
lua_settable (L, top_lvl2);
336
336
}
337
337
338
338
if (!server[" proto_min" ].asString ().empty ()) {
339
- lua_pushstring (L," proto_min" );
339
+ lua_pushstring (L, " proto_min" );
340
340
lua_pushinteger (L, server[" proto_min" ].asInt ());
341
341
lua_settable (L, top_lvl2);
342
342
}
343
343
344
344
if (!server[" proto_max" ].asString ().empty ()) {
345
- lua_pushstring (L," proto_max" );
345
+ lua_pushstring (L, " proto_max" );
346
346
lua_pushinteger (L, server[" proto_max" ].asInt ());
347
347
lua_settable (L, top_lvl2);
348
348
}
349
349
350
350
if (!server[" password" ].asString ().empty ()) {
351
- lua_pushstring (L," password" );
351
+ lua_pushstring (L, " password" );
352
352
lua_pushboolean (L, server[" password" ].asBool ());
353
353
lua_settable (L, top_lvl2);
354
354
}
355
355
356
356
if (!server[" creative" ].asString ().empty ()) {
357
- lua_pushstring (L," creative" );
357
+ lua_pushstring (L, " creative" );
358
358
lua_pushboolean (L, server[" creative" ].asBool ());
359
359
lua_settable (L, top_lvl2);
360
360
}
361
361
362
362
if (!server[" damage" ].asString ().empty ()) {
363
- lua_pushstring (L," damage" );
363
+ lua_pushstring (L, " damage" );
364
364
lua_pushboolean (L, server[" damage" ].asBool ());
365
365
lua_settable (L, top_lvl2);
366
366
}
367
367
368
368
if (!server[" pvp" ].asString ().empty ()) {
369
- lua_pushstring (L," pvp" );
369
+ lua_pushstring (L, " pvp" );
370
370
lua_pushboolean (L, server[" pvp" ].asBool ());
371
371
lua_settable (L, top_lvl2);
372
372
}
373
373
374
374
if (!server[" description" ].asString ().empty ()) {
375
- lua_pushstring (L," description" );
375
+ lua_pushstring (L, " description" );
376
376
std::string topush = server[" description" ].asString ();
377
- lua_pushstring (L,topush.c_str ());
377
+ lua_pushstring (L, topush.c_str ());
378
378
lua_settable (L, top_lvl2);
379
379
}
380
380
381
381
if (!server[" name" ].asString ().empty ()) {
382
- lua_pushstring (L," name" );
382
+ lua_pushstring (L, " name" );
383
383
std::string topush = server[" name" ].asString ();
384
- lua_pushstring (L,topush.c_str ());
384
+ lua_pushstring (L, topush.c_str ());
385
385
lua_settable (L, top_lvl2);
386
386
}
387
387
388
388
if (!server[" address" ].asString ().empty ()) {
389
- lua_pushstring (L," address" );
389
+ lua_pushstring (L, " address" );
390
390
std::string topush = server[" address" ].asString ();
391
- lua_pushstring (L,topush.c_str ());
391
+ lua_pushstring (L, topush.c_str ());
392
392
lua_settable (L, top_lvl2);
393
393
}
394
394
395
395
if (!server[" port" ].asString ().empty ()) {
396
- lua_pushstring (L," port" );
396
+ lua_pushstring (L, " port" );
397
397
std::string topush = server[" port" ].asString ();
398
- lua_pushstring (L,topush.c_str ());
398
+ lua_pushstring (L, topush.c_str ());
399
399
lua_settable (L, top_lvl2);
400
400
}
401
401
@@ -406,6 +406,37 @@ int ModApiMainMenu::l_get_favorites(lua_State *L)
406
406
lua_settable (L, top_lvl2);
407
407
}
408
408
409
+ if (server[" clients_list" ].isArray ()) {
410
+ unsigned int index_lvl2 = 1 ;
411
+ lua_pushstring (L, " clients_list" );
412
+ lua_newtable (L);
413
+ int top_lvl3 = lua_gettop (L);
414
+ for (const Json::Value &client : server[" clients_list" ]) {
415
+ lua_pushnumber (L, index_lvl2);
416
+ std::string topush = client.asString ();
417
+ lua_pushstring (L, topush.c_str ());
418
+ lua_settable (L, top_lvl3);
419
+ index_lvl2++;
420
+ }
421
+ lua_settable (L, top_lvl2);
422
+ }
423
+
424
+ if (server[" mods" ].isArray ()) {
425
+ unsigned int index_lvl2 = 1 ;
426
+ lua_pushstring (L, " mods" );
427
+ lua_newtable (L);
428
+ int top_lvl3 = lua_gettop (L);
429
+ for (const Json::Value &mod : server[" mods" ]) {
430
+
431
+ lua_pushnumber (L, index_lvl2);
432
+ std::string topush = mod.asString ();
433
+ lua_pushstring (L, topush.c_str ());
434
+ lua_settable (L, top_lvl3);
435
+ index_lvl2++;
436
+ }
437
+ lua_settable (L, top_lvl2);
438
+ }
439
+
409
440
lua_settable (L, top);
410
441
index ++;
411
442
}
0 commit comments