-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c8f1d6b
commit f4bf3a7
Showing
13 changed files
with
159 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,4 +30,6 @@ target_sources (${CMAKE_PROJECT_NAME} PRIVATE | |
Teleport.hpp | ||
Tps.cpp | ||
Tps.hpp | ||
MSPT.cpp | ||
MSPT.hpp | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
#include "MSPT.hpp" | ||
|
||
#include "Chat.hpp" | ||
#include "Dimension.hpp" | ||
#include "Player.hpp" | ||
#include "Server.hpp" | ||
#include "World.hpp" | ||
#include "logging/logging.hpp" | ||
#include <vector> | ||
|
||
using namespace command_parser; | ||
|
||
void MSPT::autocomplete(UNUSED std::vector<std::string> &args, UNUSED Player *invoker) const { } | ||
|
||
void MSPT::execute(std::vector<std::string> &args, Player *invoker) const | ||
{ | ||
switch (args.size()) { | ||
case 0: { | ||
if (invoker) { | ||
auto msg = chat::Message("Dimension MSPT: min avg max"); | ||
msg.style().italic = true; | ||
invoker->getDimension()->getWorld()->getChat()->sendSystemMessage(msg, *invoker); | ||
for (const auto &each : invoker->getDimension()->getWorld()->getMSPTInfos()) { | ||
auto msg = chat::Message(each.first + " " + each.second.toString()); | ||
msg.style().italic = true; | ||
invoker->getDimension()->getWorld()->getChat()->sendSystemMessage(msg, *invoker); | ||
} | ||
} else { | ||
LINFO("Dimension MSPT: min avg max"); | ||
for (const auto &each : Server::getInstance()->getWorldGroup("default")->getWorld("default")->getMSPTInfos()) | ||
LINFO(each.first + " " + each.second.toString()); | ||
} | ||
break; | ||
} | ||
case 1: | ||
if (auto search = Server::getInstance()->getWorldGroup("default")->getWorld("default")->getDimensions().find(args[0]); | ||
search != Server::getInstance()->getWorldGroup("default")->getWorld("default")->getDimensions().end()) { | ||
if (invoker) { | ||
invoker->getDimension()->getWorld()->getChat()->sendSystemMessage(chat::Message("Dimension MSPT: min avg max", {false, true}), *invoker); | ||
invoker->getDimension()->getWorld()->getChat()->sendSystemMessage( | ||
chat::Message(args[0] + " " + search->second->getMSPTInfos().toString(), {false, true}), *invoker | ||
); | ||
} else { | ||
LINFO("Dimension MSPT: min avg max"); | ||
LINFO(args[0] + " " + search->second->getMSPTInfos().toString()); | ||
} | ||
} else { | ||
if (invoker) | ||
invoker->getDimension()->getWorld()->getChat()->sendSystemMessage("Dimension " + args[0] + " not found", *invoker); | ||
else | ||
LINFO("Dimension {} not found", args[0]); | ||
} | ||
break; | ||
default: | ||
this->help(args, invoker); | ||
break; | ||
} | ||
} | ||
|
||
void MSPT::help(UNUSED std::vector<std::string> &args, Player *invoker) const | ||
{ | ||
if (invoker) | ||
invoker->getDimension()->getWorld()->getChat()->sendSystemMessage(_help, *invoker); | ||
else | ||
LINFO(_help); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#ifndef CUBICSERVER_COMMANDPARSER_COMMANDS_MSPT_HPP | ||
#define CUBICSERVER_COMMANDPARSER_COMMANDS_MSPT_HPP | ||
|
||
#include "CommandBase.hpp" | ||
|
||
namespace command_parser { | ||
struct MSPT : public CommandBase { | ||
MSPT(): | ||
CommandBase("mspt", "/mspt (dimension)", false) | ||
{ | ||
} | ||
~MSPT() override = default; | ||
|
||
void autocomplete(std::vector<std::string> &args, Player *invoker) const override; | ||
void execute(std::vector<std::string> &args, Player *invoker) const override; | ||
void help(std::vector<std::string> &args, Player *invoker) const override; | ||
}; | ||
} | ||
|
||
#endif // CUBICSERVER_COMMANDPARSER_COMMANDS_MSPT_HPP |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters