MCPcopy Create free account
hub / github.com/OpenStarbound/OpenStarbound / spawnLiquid

Method spawnLiquid

source/game/StarCommandProcessor.cpp:553–585  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

551}
552
553String 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
587String CommandProcessor::kick(ConnectionId connectionId, String const& argumentString) {
588 if (auto errorMsg = adminCheck(connectionId, "kick a user"))

Callers

nothing calls this directly

Calls 13

singletonClass · 0.85
strfFunction · 0.85
tokenizeToStringListMethod · 0.80
liquidsDatabaseMethod · 0.80
isLiquidNameMethod · 0.80
executeForClientMethod · 0.80
floorMethod · 0.80
outputExceptionFunction · 0.50
atMethod · 0.45
liquidIdMethod · 0.45
sizeMethod · 0.45
modifyTileMethod · 0.45

Tested by

no test coverage detected