| 551 | } |
| 552 | |
| 553 | String CommandProcessor::spawnLiquid(ConnectionId connectionId, String const& argumentString) { |
| 554 | if (auto errorMsg = adminCheck(connectionId, "spawn liquid")) |
| 555 | return *errorMsg; |
| 556 | |
| 557 | try { |
| 558 | auto arguments = m_parser.tokenizeToStringList(argumentString); |
| 559 | |
| 560 | auto liquidsDatabase = Root::singleton().liquidsDatabase(); |
| 561 | |
| 562 | if (!liquidsDatabase->isLiquidName(arguments.at(0))) |
| 563 | return strf("No such liquid {}", arguments.at(0)); |
| 564 | |
| 565 | LiquidId liquid = liquidsDatabase->liquidId(arguments.at(0)); |
| 566 | |
| 567 | float quantity = 1.0f; |
| 568 | if (arguments.size() > 1) { |
| 569 | if (auto maybeQuantity = maybeLexicalCast<float>(arguments.at(1))) |
| 570 | quantity = *maybeQuantity; |
| 571 | else |
| 572 | return strf("Could not parse quantity value '{}'", arguments.at(1)); |
| 573 | } |
| 574 | |
| 575 | bool done = m_universe->executeForClient(connectionId, [&](WorldServer* world, PlayerPtr const& player) { |
| 576 | world->modifyTile(Vec2I(player->aimPosition().floor()), PlaceLiquid{liquid, quantity}, true); |
| 577 | }); |
| 578 | return done ? "" : "Invalid client state"; |
| 579 | |
| 580 | } catch (StarException const& exception) { |
| 581 | Logger::warn( |
| 582 | "Could not spawn liquid '{}', exception caught: {}", argumentString, outputException(exception, false)); |
| 583 | return "Could not spawn liquid."; |
| 584 | } |
| 585 | } |
| 586 | |
| 587 | String CommandProcessor::kick(ConnectionId connectionId, String const& argumentString) { |
| 588 | if (auto errorMsg = adminCheck(connectionId, "kick a user")) |
nothing calls this directly
no test coverage detected