generated from LiteLDev/levilamina-mod-template
-
Notifications
You must be signed in to change notification settings - Fork 0
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
b208da2
commit 2e166ff
Showing
26 changed files
with
984 additions
and
107 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,49 @@ | ||
{ | ||
"languageName": "English (United Kingdom)", | ||
"undefinedError": "§r(Ranks) Sorry, an unknown error has occurred..", | ||
"undefinedRank": "§r(Ranks) Unknown rank {rankName}! Available ranks: {ranks}.", | ||
"dropdownDontPoint": "Don't point", | ||
"commandAddRankDescription": "Create a new rank.", | ||
"commandSetRankDescription": "Set a new rank for the player.", | ||
"commandSetRankDescription": "Set a new rank for a player.", | ||
"commandRemoveRankDescription": "Remove rank.", | ||
"commandEditRankDescription": "Change rank.", | ||
"commandEditRankDescription": "Edit rank.", | ||
"commandAddRankUsing": "§r(Ranks) Usage: /addrank <rankName: string> <prefix: string> <chatFormat: string> <scoreTagFormat: string> [inheritanceRank: string]", | ||
"addRankAlreadyExists": "§r(Ranks) A rank with this name already exists!", | ||
"addRankSuccess": "§r(Ranks) You have successfully created a rank called {rankName}!", | ||
"commandSetRankUsing": "§r(Ranks) Usage: /setrank <player: target> <rankName: string>", | ||
"commandSetRankUndefinedPlayer": "§r(Ranks) Failed to get a player!", | ||
"commandSetRankUndefinedRank": "§r(Ranks) Unknown rank {rankName}! Available ranks: {ranks}.", | ||
"commandSetRankSuperRank": "§r(Ranks) This rank can only be set from the console!", | ||
"commandSetRankSuperPlayer": "§r(Ranks) Player {playerName} can only be set from the console!", | ||
"commandSetRankUndefinedError": "§r(Ranks) Unfortunately, an unknown error has occurred..", | ||
"commandSetRankSuccess": "§r(Ranks) You have successfully set the {playerName} player's {rankName} rank!", | ||
"commandSetRankSuccessMultiply": "§r(Ranks) You have successfully set the players {playerNames} rank {rankName}!", | ||
"formSetRankTitle": "Setting a new rank for the player", | ||
"formSetRankDropdownPlayers": "Select the player from the list to whom you want to set a new rank:", | ||
"formSetRankDropdownRanks": "Select the rank from the list that you want to set for the player:" | ||
"commandSetRankUndefinedPlayer": "§r(Ranks) Failed to get player!", | ||
"setRankSuperRank": "§r(Ranks) This rank can only be set from console!", | ||
"setRankSuperPlayer": "§r(Ranks) Player {playerName} can only be set to rank from console!", | ||
"setRankSuccess": "§r(Ranks) You have successfully set player {playerName} to rank {rankName}!", | ||
"commandSetRankSuccessMultiply": "§r(Ranks) You have successfully set the rank of {playerNames} to {rankName}!", | ||
"commandRemoveRankUsing": "§r(Ranks) Usage: /removerank <rankName: string>", | ||
"commandRemoveRankSuccess": "§r(Ranks) You have successfully removed the rank of {rankName}.", | ||
"commandEditRankUsing": "§r(Ranks) Usage: /editrank <rankName: string> <prefix: string> <chatFormat: string> <scoreTagFormat: string> <inheritanceRank: string> <availableCommands: string>", | ||
"editRankSuperRank": "§r(Ranks) This rank can only be edited from the console!", | ||
"editRankInvalidFormatAvailableCommands": "§r(Ranks) Please enter available commands this rank separated by a semicolon («;», without quotes).", | ||
"editRankSuccess": "§r(Ranks) You have successfully edited the rank {rankName}.", | ||
"formAddRankTitle": "Creating a new rank", | ||
"formAddRankInputRankName": "Enter the name of the future rank:", | ||
"formAddRankInputRankNamePlaceholder": "Name of the future rank", | ||
"formAddRankInputPrefix": "Enter the prefix of the future rank:", | ||
"formAddRankInputPrefixPlaceholder": "Prefix of the future rank", | ||
"formAddRankInputChatFormat": "Enter the format for displaying messages of the player who will have this rank (the following variables are supported: {prefix} - rank prefix, {playerName} - player name, {message} - message sent by the player):", | ||
"formAddRankInputChatFormatPlaceholder": "Player message display format", | ||
"formAddRankInputScoreTagFormat": "Enter the player's scoreTag format (the {prefix} variable is supported - rank prefix):", | ||
"formAddRankInputScoreTagFormatPlaceholder": "Player scoreTag format", | ||
"formAddRankDropdownRanks": "Select a rank from the list from which the future rank will be inherited:", | ||
"formSetRankTitle": "Setting a new rank for a player", | ||
"formSetRankDropdownPlayers": "Select a player from the list to whom you want to set a new rank:", | ||
"formSetRankDropdownRanks": "Select a rank from the list that you want to set for the player:", | ||
"formEditRankTitle": "Editing a rank", | ||
"formEditRankDropdownRanks": "Select a rank from the list that you want to edit:", | ||
"formEditRankInputPrefix": "Enter the new prefix of the selected rank:", | ||
"formEditRankInputPrefixPlaceholder": "New rank prefix", | ||
"formEditRankInputChatFormat": "Enter the new format for displaying player messages that will have the selected rank (supported variables {prefix} - rank prefix, {playerName} - player name, {message} - message sent by the player):", | ||
"formEditRankInputChatFormatPlaceholder": "New format for displaying player messages", | ||
"formEditRankInputScoreTagFormat": "Enter the new format for the player's scoreTag (supported variable {prefix} - rank prefix):", | ||
"formEditRankInputScoreTagFormatPlaceholder": "New format for the player's scoreTag", | ||
"formEditRankDropdownInheritanceRanks": "Select a rank from the list, from which the selected rank will inherit:", | ||
"formEditRankInputAvailableCommands": "Enter new commands for the selected rank separated by semicolons («;», without quotes; enter the value «null» (without quotes) if you want to remove commands specifically available to this rank):", | ||
"formEditRankInputAvailableCommandsPlaceholder": "New rank commands" | ||
} |
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 |
---|---|---|
@@ -1,18 +1,49 @@ | ||
{ | ||
"languageName": "Русский (Россия)", | ||
"undefinedError": "§r(Ранги) К сожалению, произошла неизвестная ошибка..", | ||
"undefinedRank": "§r(Ранги) Неизвестный ранг {rankName}! Доступные ранги: {ranks}.", | ||
"dropdownDontPoint": "Не указывать", | ||
"commandAddRankDescription": "Создать новый ранг.", | ||
"commandSetRankDescription": "Установить игроку новый ранг.", | ||
"commandRemoveRankDescription": "Удалить ранг.", | ||
"commandEditRankDescription": "Изменить ранг.", | ||
"commandEditRankDescription": "Отредактировать ранг.", | ||
"commandAddRankUsing": "§r(Ранги) Использование: /addrank <rankName: string> <prefix: string> <chatFormat: string> <scoreTagFormat: string> [inheritanceRank: string]", | ||
"addRankAlreadyExists": "§r(Ранги) Ранг с таким названием уже существует!", | ||
"addRankSuccess": "§r(Ранги) Вы успешно создали ранг под названием {rankName}!", | ||
"commandSetRankUsing": "§r(Ранги) Использование: /setrank <player: target> <rankName: string>", | ||
"commandSetRankUndefinedPlayer": "§r(Ранги) Не удалось получить игрока!", | ||
"commandSetRankUndefinedRank": "§r(Ранги) Неизвестный ранг {rankName}! Доступные ранги: {ranks}.", | ||
"commandSetRankSuperRank": "§r(Ранги) Данный ранг можно устанавливать только с консоли!", | ||
"commandSetRankSuperPlayer": "§r(Ранги) Игроку {playerName} можно устанавливать ранг только с консоли!", | ||
"commandSetRankUndefinedError": "§r(Ранги) К сожалению, произошла неизвестная ошибка..", | ||
"commandSetRankSuccess": "§r(Ранги) Вы успешно установили игроку {playerName} ранг {rankName}!", | ||
"setRankSuperRank": "§r(Ранги) Данный ранг можно устанавливать только с консоли!", | ||
"setRankSuperPlayer": "§r(Ранги) Игроку {playerName} можно устанавливать ранг только с консоли!", | ||
"setRankSuccess": "§r(Ранги) Вы успешно установили игроку {playerName} ранг {rankName}!", | ||
"commandSetRankSuccessMultiply": "§r(Ранги) Вы успешно установили игрокам {playerNames} ранг {rankName}!", | ||
"commandRemoveRankUsing": "§r(Ранги) Использование: /removerank <rankName: string>", | ||
"commandRemoveRankSuccess": "§r(Ранги) Вы успешно удалили ранг {rankName}.", | ||
"commandEditRankUsing": "§r(Ранги) Использование: /editrank <rankName: string> <prefix: string> <chatFormat: string> <scoreTagFormat: string> <inheritanceRank: string> <availableCommands: string>", | ||
"editRankSuperRank": "§r(Ранги) Данный ранг можно редактировать только с консоли!", | ||
"editRankInvalidFormatAvailableCommands": "§r(Ранги) Пожалуйста, вводите доступные команды этому рангу через точку с запятой («;», без кавычек).", | ||
"editRankSuccess": "§r(Ранги) Вы успешно отредактировали ранг {rankName}.", | ||
"formAddRankTitle": "Создание нового ранга", | ||
"formAddRankInputRankName": "Введите название будущего ранга:", | ||
"formAddRankInputRankNamePlaceholder": "Название будущего ранга", | ||
"formAddRankInputPrefix": "Введите префикс будущего ранга:", | ||
"formAddRankInputPrefixPlaceholder": "Префикс будущего ранга", | ||
"formAddRankInputChatFormat": "Введите формат отображения сообщений игрока, который будет иметь этот ранг (поддерживаются переменные {prefix} - префикс ранга, {playerName} - имя игрока, {message} - сообщение, отправленное игроком):", | ||
"formAddRankInputChatFormatPlaceholder": "Формат отображения сообщений игрока", | ||
"formAddRankInputScoreTagFormat": "Введите формат scoreTag'а игрока (поддерживается переменная {prefix} - префикс ранга):", | ||
"formAddRankInputScoreTagFormatPlaceholder": "Формат scoreTag'а игрока", | ||
"formAddRankDropdownRanks": "Выберите ранг из списка, от которого будет наследоваться будущий ранг:", | ||
"formSetRankTitle": "Установка игроку нового ранга", | ||
"formSetRankDropdownPlayers": "Выберите игрока из списка, которому хотите установить новый ранг:", | ||
"formSetRankDropdownRanks": "Выберите ранг из списка, который хотите установить игроку:" | ||
"formSetRankDropdownRanks": "Выберите ранг из списка, который хотите установить игроку:", | ||
"formEditRankTitle": "Редактирование ранга", | ||
"formEditRankDropdownRanks": "Выберите ранг из списка, который хотите редактировать:", | ||
"formEditRankInputPrefix": "Введите новый префикс выбранного ранга:", | ||
"formEditRankInputPrefixPlaceholder": "Новый префикс ранга", | ||
"formEditRankInputChatFormat": "Введите новый формат отображения сообщений игрока, который будет иметь выбранный ранг (поддерживаются переменные {prefix} - префикс ранга, {playerName} - имя игрока, {message} - сообщение, отправленное игроком):", | ||
"formEditRankInputChatFormatPlaceholder": "Новый формат отображения сообщений игрока", | ||
"formEditRankInputScoreTagFormat": "Введите новый формат scoreTag'а игрока (поддерживается переменная {prefix} - префикс ранга):", | ||
"formEditRankInputScoreTagFormatPlaceholder": "Новый формат scoreTag'а игрока", | ||
"formEditRankDropdownInheritanceRanks": "Выберите ранг из списка, от которого будет наследоваться выбранный ранг:", | ||
"formEditRankInputAvailableCommands": "Введите новые команды для выбранного ранга через точку с запятой («;», без кавычек; введите значение «null» (без кавычек), если хотите убрать команды, специально доступные этому рангу):", | ||
"formEditRankInputAvailableCommandsPlaceholder": "Новые команды ранга" | ||
} |
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 |
---|---|---|
@@ -0,0 +1,67 @@ | ||
#include "AddRankCommand.h" | ||
#include "../Utils.hpp" | ||
#include "../forms/AddRankForm.h" | ||
#include "../manager/ranks/RanksManager.h" | ||
#include <mc/server/ServerPlayer.h> | ||
|
||
namespace power_ranks::commands { | ||
|
||
void AddRankCommand::execute( | ||
const CommandOrigin& origin, | ||
CommandOutput& output, | ||
const Parameter& parameter, | ||
const Command& _ | ||
) { | ||
std::string localeName = origin.getEntity() == nullptr || !origin.getEntity()->isType(ActorType::Player) | ||
? manager::ConfigManager::getConfig().defaultLocaleName | ||
: static_cast<ServerPlayer&>(*origin.getEntity()).getLocaleName(); | ||
|
||
if (manager::RanksManager::getRank(parameter.rankName).has_value()) { | ||
output.error(manager::LanguageManager::getInstance()->getTranslate("addRankAlreadyExists", localeName)); | ||
return; | ||
} | ||
|
||
std::optional<object::Rank*> inheritanceRank = manager::RanksManager::getRank(parameter.inheritanceRank); | ||
if (parameter.inheritanceRank != "null" && !inheritanceRank.has_value()) { | ||
std::string ranks = ""; | ||
for (std::pair<std::string, object::Rank*> pair : manager::RanksManager::getRanks()) { | ||
if (ranks.empty()) { | ||
ranks = pair.first; | ||
continue; | ||
} | ||
|
||
ranks += ", " + pair.first; | ||
} | ||
|
||
output.error(Utils::strReplace( | ||
manager::LanguageManager::getInstance()->getTranslate("undefinedRank", localeName), | ||
{"{rankName}", "{ranks}"}, | ||
{parameter.rankName, ranks} | ||
)); | ||
return; | ||
} | ||
|
||
manager::RanksManager::addRank( | ||
parameter.rankName, | ||
parameter.prefix, | ||
parameter.chatFormat, | ||
parameter.scoreTagFormat, | ||
inheritanceRank | ||
); | ||
output.success(Utils::strReplace( | ||
manager::LanguageManager::getInstance()->getTranslate("addRankSuccess", localeName), | ||
"{rankName}", | ||
parameter.rankName | ||
)); | ||
} | ||
|
||
void AddRankCommand::executeWithoutParameter(const CommandOrigin& origin, CommandOutput& output) { | ||
if (origin.getEntity() == nullptr || !origin.getEntity()->isType(ActorType::Player)) { | ||
output.error(manager::LanguageManager::getInstance()->getTranslate("commandAddRankUsing")); | ||
return; | ||
} | ||
|
||
forms::AddRankForm::init(static_cast<ServerPlayer&>(*origin.getEntity())); | ||
} | ||
|
||
} // namespace power_ranks::commands |
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,39 @@ | ||
#pragma once | ||
|
||
#include "../manager/command/CommandManager.h" | ||
#include "../manager/lang/LanguageManager.h" | ||
#include <fmt/std.h> | ||
#include <ll/api/command/SoftEnum.h> | ||
#include <mc/server/commands/CommandFlag.h> | ||
#include <mc/server/commands/CommandOrigin.h> | ||
#include <mc/server/commands/CommandOutput.h> | ||
#include <mc/server/commands/CommandPermissionLevel.h> | ||
#include <mc/world/level/Command.h> | ||
|
||
namespace power_ranks::commands { | ||
|
||
class AddRankCommand { | ||
public: | ||
struct Parameter { | ||
std::string rankName; | ||
std::string prefix; | ||
std::string chatFormat; | ||
std::string scoreTagFormat; | ||
ll::command::SoftEnum<manager::CommandManager::RankNames> inheritanceRank = "null"; | ||
}; | ||
|
||
static std::string getName() { return "addrank"; }; | ||
static std::string getDescription() { | ||
return manager::LanguageManager::getInstance()->getTranslate("commandAddRankDescription"); | ||
}; | ||
static CommandPermissionLevel getRequirement() { return CommandPermissionLevel::GameDirectors; }; | ||
static CommandFlag getFlag() { return CommandFlagValue::NotCheat; }; | ||
|
||
static std::vector<std::string> getAliases() { return {"add-rank"}; }; | ||
|
||
static void | ||
execute(const CommandOrigin& origin, CommandOutput& output, const Parameter& parameter, const Command& command); | ||
static void executeWithoutParameter(const CommandOrigin& origin, CommandOutput& output); | ||
}; | ||
|
||
} // namespace power_ranks::commands |
Oops, something went wrong.