code clean-up
This commit is contained in:
parent
227585f1dc
commit
95b13f670d
@ -11,6 +11,6 @@
|
||||
|
||||
"openSbCommands": {
|
||||
"swap": "Usage /swap <name>. Swaps the current character, case-insensitive, only substring required.",
|
||||
"respawninworld": "Usage /respawnInWorld. Sets the respawn flag for the current world until you teleport away."
|
||||
"respawninworld": "Usage /respawninworld. Sets the respawn flag for the current world until you teleport away."
|
||||
}
|
||||
}
|
||||
|
@ -187,7 +187,7 @@ String ClientCommandProcessor::setGravity(String const& argumentsString) {
|
||||
return "You must be an admin to use this command.";
|
||||
|
||||
m_universeClient->worldClient()->overrideGravity(lexicalCast<float>(arguments.at(0)));
|
||||
return strf("Gravity set to {}, the change is LOCAL ONLY", arguments.at(0));
|
||||
return strf("Gravity set to {} (This is client-side!)", arguments.at(0));
|
||||
}
|
||||
|
||||
String ClientCommandProcessor::resetGravity() {
|
||||
@ -431,34 +431,13 @@ String ClientCommandProcessor::swap(String const& argumentsString) {
|
||||
String ClientCommandProcessor::respawnInWorld(String const& argumentsString) {
|
||||
auto arguments = m_parser.tokenizeToStringList(argumentsString);
|
||||
|
||||
if (arguments.size() == 0)
|
||||
return strf("Respawn in this world is currently {}", worldClient->respawnInWorld() ? "true" : "false");
|
||||
|
||||
WorldClientPtr worldClient = m_universeClient->worldClient();
|
||||
|
||||
|
||||
if (arguments.size() == 0) {
|
||||
const std::string stringResult = worldClient->respawnInWorld() ? "true" : "false";
|
||||
return "Respawn in this world is currently " + stringResult; // return the current state of the respawn value when no argument is given
|
||||
}
|
||||
if (arguments.size() > 1) {
|
||||
return "Too many arguments for this command!"; // we dont wanna have too much, right?
|
||||
}
|
||||
|
||||
// behold: probably one of the least efficient ways to convert a Star::String to a boolean
|
||||
bool value;
|
||||
if (arguments[0].toLower() == "true") {
|
||||
value = true;
|
||||
} else if(arguments[0].toLower() == "false") {
|
||||
value = false;
|
||||
}
|
||||
else {
|
||||
return "Invalid argument!"; // at least we get validation if it was not a boolean
|
||||
}
|
||||
|
||||
bool result = worldClient->setRespawnInWorld(value);
|
||||
// Convert boolean to string for the response
|
||||
const std::string stringResult = result ? "true" : "false";
|
||||
|
||||
return "Successfully set respawn in this world to " + stringResult;
|
||||
bool respawnInWorld = Json::parse(arguments.at(0)).toBool();
|
||||
auto worldClient = m_universeClient->worldClient();
|
||||
worldClient->setRespawnInWorld(respawnInWorld);
|
||||
return strf("Respawn in this world set to {} (This is client-side!)", respawnInWorld ? "true" : "false");
|
||||
}
|
||||
|
||||
}
|
@ -142,11 +142,8 @@ bool WorldClient::respawnInWorld() const {
|
||||
return m_respawnInWorld;
|
||||
}
|
||||
|
||||
bool WorldClient::setRespawnInWorld(bool value) {
|
||||
|
||||
m_respawnInWorld = value;
|
||||
|
||||
return m_respawnInWorld;
|
||||
void WorldClient::setRespawnInWorld(bool respawnInWorld) {
|
||||
m_respawnInWorld = respawnInWorld;
|
||||
}
|
||||
|
||||
void WorldClient::removeEntity(EntityId entityId, bool andDie) {
|
||||
|
@ -108,8 +108,7 @@ public:
|
||||
bool mainPlayerDead() const;
|
||||
void reviveMainPlayer();
|
||||
bool respawnInWorld() const;
|
||||
|
||||
bool setRespawnInWorld(bool value);
|
||||
void setRespawnInWorld(bool respawnInWorld);
|
||||
|
||||
void removeEntity(EntityId entityId, bool andDie);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user