| 95 | } |
| 96 | |
| 97 | String CommandProcessor::admin(ConnectionId connectionId, String const&) { |
| 98 | auto config = Root::singleton().configuration(); |
| 99 | if (m_universe->canBecomeAdmin(connectionId)) { |
| 100 | if (connectionId == ServerConnectionId) |
| 101 | return "Invalid client state"; |
| 102 | |
| 103 | if (!config->get("allowAdminCommands").toBool()) |
| 104 | return "Admin commands disabled on this server."; |
| 105 | |
| 106 | bool wasAdmin = m_universe->isAdmin(connectionId); |
| 107 | m_universe->setAdmin(connectionId, !wasAdmin); |
| 108 | |
| 109 | if (!wasAdmin) |
| 110 | return strf("Admin privileges now given to player {}", m_universe->clientNick(connectionId)); |
| 111 | else |
| 112 | return strf("Admin privileges taken away from {}", m_universe->clientNick(connectionId)); |
| 113 | } else { |
| 114 | return "Insufficient privileges to make self admin."; |
| 115 | } |
| 116 | } |
| 117 | |
| 118 | String CommandProcessor::pvp(ConnectionId connectionId, String const&) { |
| 119 | if (!m_universe->isPvp(connectionId)) { |
nothing calls this directly
no test coverage detected