Skip to content
This repository has been archived by the owner on Oct 28, 2023. It is now read-only.

Commit

Permalink
Fix more bugs && Add /helper update /lltpa update
Browse files Browse the repository at this point in the history
  • Loading branch information
ShrBox committed Jan 21, 2022
1 parent 4446b69 commit 3f8207a
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 55 deletions.
7 changes: 6 additions & 1 deletion CHANGELOG.txt
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@
Support for LiteLoaderBDS 2.0.7
## LLHelper
- Fixed a problem of `/ban`
- Added `/helper update`

## LLtpa
- Added `/lltpa update`
2 changes: 1 addition & 1 deletion LLHelper/Helper.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#pragma warning(disable:4996)

bool CheckAutoUpdate(bool isUpdateManually, bool forceUpdate = false);
#define _ver "220120"
#define _ver "220121"
#define LLHELPER_VERSION LL::Version{ 2,0, std::stoi(_ver)}

/////////////////////// LL AutoUpgrade ///////////////////////
Expand Down
6 changes: 3 additions & 3 deletions LLHelper/command.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class GmodeCommand : public Command {
};

class BanCommand : public Command {
enum BANOP {
enum BANOP : int {
ban = 1,
unban = 2,
banip = 3,
Expand Down Expand Up @@ -309,11 +309,11 @@ class HelperCommand : public Command {
public:
void execute(CommandOrigin const& ori, CommandOutput& outp) const {
switch (action) {
case reload:
case HelperOP::reload:
loadCfg();
outp.success(tr("hreload.success"));
break;
case update:
case HelperOP::update:
std::thread th([]() {
CheckAutoUpdate(true, false);
});
Expand Down
79 changes: 32 additions & 47 deletions LLtpa/Teleport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -516,46 +516,6 @@ class SuicideCommand : public Command {
}
};

class LLTPAUpdateCommand : public Command {
enum class Operation {
Force,
} operation;
bool isSet;

public:
void execute(CommandOrigin const& ori, CommandOutput& output) const override {
bool isForce = false;
if (isSet) {
switch (operation) {
case Operation::Force:
isForce = true;
break;
default:
break;
}
}
CheckAutoUpdate(true, isForce);
}

static void setup(CommandRegistry* registry) {
registry->registerCommand(
"lltpaupdate",
"Update LLTpa",
CommandPermissionLevel::Console,
{ (CommandFlagValue)0 },
{ (CommandFlagValue)0x80 }
);
registry->addEnum<Operation>("force", { {"force", Operation::Force} });
registry->registerOverload<LLTPAUpdateCommand>(
"lltpaupdate",
RegisterCommandHelper::makeOptional<CommandParameterDataType::ENUM>(
&LLTPAUpdateCommand::operation, "optional", "force",
&LLTPAUpdateCommand::isSet
)
);
}
};

void loadCfg() {
//config
if (!std::filesystem::exists("plugins/LLtpa"))
Expand Down Expand Up @@ -603,17 +563,43 @@ void loadCfg() {
}
}

class ReloadCommand : public Command {
class LLtpaCommand : public Command {
enum LLtpaOP : int {
reload = 0,
update = 1
} op;
std::string isForce;
bool isForce_set;

public:
void execute(CommandOrigin const& ori, CommandOutput& outp) const {
loadCfg();
outp.success("Reloaded");
switch (op) {
case LLtpaOP::reload:
loadCfg();
outp.success("Reloaded");
break;
case LLtpaOP::update:
bool force = false;
if (isForce_set) {
if (isForce == "true") {
force = true;
}
else {
force = false;
}
}
std::thread th([force]() {
CheckAutoUpdate(true, force);
});
th.detach();
}
}
static void setup(CommandRegistry* registry) {
using RegisterCommandHelper::makeMandatory;
using RegisterCommandHelper::makeOptional;
registry->registerCommand("tpareload", "Reload LLTpa's config", CommandPermissionLevel::GameMasters, { (CommandFlagValue)0 }, { (CommandFlagValue)0x80 });
registry->registerOverload<ReloadCommand>("tpareload");
registry->registerCommand("lltpa", "LLtpa manage command", CommandPermissionLevel::GameMasters, { (CommandFlagValue)0 }, { (CommandFlagValue)0x80 });
registry->addEnum<LLtpaOP>("LLtpaOP", { {"reload", LLtpaOP::reload}, {"update", LLtpaOP::update} });
registry->registerOverload<LLtpaCommand>("lltpa", makeMandatory<CommandParameterDataType::ENUM>(&LLtpaCommand::op, "OP", "LLtpaOP"), makeOptional(&LLtpaCommand::isForce, "isForce", &LLtpaCommand::isForce_set));
}
};

Expand All @@ -633,15 +619,14 @@ void tpa_entry() {
init();
schTask();
Event::RegCmdEvent::subscribe([](const Event::RegCmdEvent& e) {
LLTPAUpdateCommand::setup(e.mCommandRegistry);
if (Settings::TPA_ENABLED) TpaCommand::setup(e.mCommandRegistry);
if (Settings::HOME_ENABLED) {
HomeCommand::setup(e.mCommandRegistry);
}
WarpCommand::setup(e.mCommandRegistry);
if (Settings::BACK_ENABLED) BackCommand::setup(e.mCommandRegistry);
if (Settings::SUICIDE_ENABLED) SuicideCommand::setup(e.mCommandRegistry);
ReloadCommand::setup(e.mCommandRegistry);
LLtpaCommand::setup(e.mCommandRegistry);
return true;
});
if (Settings::BACK_ENABLED) {
Expand Down
2 changes: 1 addition & 1 deletion LLtpa/Tpa.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#pragma once

bool CheckAutoUpdate(bool isUpdateManually, bool forceUpdate = false);
#define _ver "220120"
#define _ver "220121"
#define LLTPA_VERSION LL::Version{ 2,0, std::stoi(_ver)}

/////////////////////// LL AutoUpgrade ///////////////////////
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Some example plugins for [LiteLoader](https://github.com/LiteLDev/BDSLiteLoader)
| /gmode <player> <pode(0/1/2/3)> | Change gamemode | OP |
| /ban <ban/unban/list> [player] [time(second)] | Ban/unban a player | OP |
| /transfer <player> <IP> <port> | Transfer a player to another server | OP |
| /helper reload | Reload LLHelper.json | OP |
| /helper <reload/update> | Reload config/Check plugin's update | OP |
| /skick <player> | Force kick a player from server | OP |
| /cname <set/rm> <player> [nickname] | Set nickname for a player | OP |
| /vanish | invisibility(only effective for players who can see you) | OP |
Expand All @@ -35,6 +35,7 @@ Some example plugins for [LiteLoader](https://github.com/LiteLDev/BDSLiteLoader)
| /warp <add/del/go/ls> [warp] | Add a warp/delete warp/go to warp/list warp | OP |
| /home <add/del/go/ls> [home] | Add a home/delete home/go home/list home | Player |
| /item | Show the item info on hand | Player |
| /lltpa <reload/update> [isForce: true or false] | Reload config/Check plugin's update | OP |

# Config
## LLHelper
Expand Down
3 changes: 2 additions & 1 deletion README_zh-cn.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
| /gmode <玩家> <模式(0/1/2/3)> | 切换玩家游戏模式 | OP |
| /ban <ban/unban/list> [玩家] [时间(秒)] | 封禁/解封一名玩家 | OP |
| /transfer <玩家> <IP> <端口> | 将一名玩家转移到其它服务器 | OP |
| /helper reload | 重载LLHelper配置文件 | OP |
| /helper <reload/update> | 重载配置文件/检查插件更新 | OP |
| /skick <玩家> | 以暴力的方式强制踢出一名玩家 | OP |
| /cname <set/rm> <玩家> [假名] | 给玩家设置假名 | OP |
| /vanish | 隐身(仅对可以看见你的玩家有效) | OP |
Expand All @@ -35,6 +35,7 @@
| /warp <add/del/go/ls> [地标] | 添加一个地标/删除地标/前往地标/列出地标 | OP |
| /home <add/del/go/ls> [] | 添加一个家/删除家/前往家/列出家 | 玩家 |
| /item | 查询你手上的物品信息 | 玩家 |
| /lltpa <reload/update> [是否强制: true or false] | 重载配置文件/检查插件更新 | OP |

# 配置文件
## LLHelper
Expand Down

0 comments on commit 3f8207a

Please sign in to comment.