Skip to content

Commit

Permalink
Fix: some bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
hhhxiao committed Aug 12, 2022
1 parent f8b1313 commit 8a5f0cc
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 10 deletions.
19 changes: 19 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,22 @@
### trapdoor-ll-0.17-1.19.10.03

#### 依赖和版本支持

- 需要LiteLoader 2.5.0 或以上版本
- 理论上支持1.19.20.02及以上版本

#### 更新日志

- 支持1.19.20.02 by @dreamguxiang
- 添加`trapdoor crash`命令支持指令崩服
- 添加`trapdoor reload`以支持配置文件热重载(不可重载命令部分)
-`data redstone signal`添加更多的信息显示(信号源的dampening,directlyPowered等)
- 修复`log os`可能显示错误的CPU占用信息的bug(#11)
-`tick`指令添加部分短命令以兼容旧版命令
- 给shortcuts添加新的触发器`destroy`,可在玩家破坏方块时触发
- 修复自动工具选择的耐久阈值设置错误的问题
- 修复部分拼写错误

### trapdoor-ll-0.16-1.19.10.03

#### 依赖和版本支持
Expand Down
8 changes: 6 additions & 2 deletions src/base/Config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,12 @@ namespace trapdoor {

} // namespace

bool Configuration::init(const std::string& fileName) {
bool Configuration::init(const std::string& fileName, bool reload) {
if (!readConfigFile(fileName)) return false;
if (!readCommandConfigs()) return false;
if (!reload) {
if (!readCommandConfigs()) return false;
}

if (!readBasicConfigs()) return false;
if (!readShortcutConfigs()) return false;
if (!readDefaultEnableFunctions()) return false;
Expand Down Expand Up @@ -95,6 +98,7 @@ namespace trapdoor {
}
bool Configuration::readShortcutConfigs() {
try {
this->shortcuts.clear();
auto cc = this->config["shortcuts"];
for (const auto& i : cc.items()) {
Shortcut sh;
Expand Down
6 changes: 3 additions & 3 deletions src/base/TrapdoorMod.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,21 +56,21 @@ namespace trapdoor {
}

void TrapdoorMod::init() {
this->initConfig();
this->initConfig(false);
trapdoor::initCPU();
trapdoor::SubscribeEvents();
trapdoor::initRotateBlockHelper();
trapdoor::setupCommands();
}

bool TrapdoorMod::initConfig() {
bool TrapdoorMod::initConfig(bool reload) {
auto path = std::string("./plugins/trapdoor/");
#ifdef DEV
path = "C:/Users/xhy/dev/trapdoor-ll/src/base/";
logger().consoleLevel = 8;
#endif
logger().debug("Config path: {}", path);
return this->config.init(path + "config.json");
return this->config.init(path + "config.json", reload);
}

TrapdoorMod &mod() {
Expand Down
2 changes: 1 addition & 1 deletion src/commands/TickCommand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ namespace trapdoor {
CommandOutput &output,
std::unordered_map<std::string, DynamicCommand::Result> &results) {
if (origin.getOriginType() == 1) {
output.error("tick command cannot be executed inside a command blockName");
output.error("Tick command cannot be executed inside a command block");
return;
}

Expand Down
2 changes: 1 addition & 1 deletion src/commands/TrapdoorCommand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ namespace trapdoor {
}

ActionResult reloadConfig() {
auto succ = trapdoor::mod().initConfig();
auto succ = trapdoor::mod().initConfig(true);
auto msg = succ ? "Success reload trapdoor config" : "Fail reload trapdoor config";
return {msg, succ};
}
Expand Down
6 changes: 5 additions & 1 deletion src/functions/InventoryTool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,11 @@ namespace trapdoor {
if (item && item->getCount() != 0) {
auto speed = item->getDestroySpeed(*b);
auto remainDamage = item->getMaxDamage() - item->getDamageValue();
if (remainDamage <= 5) continue;

// 跳过已经用坏的工具
if (remainDamage <=
trapdoor::mod().getConfig().getBasicConfig().toolDamageThreshold)
continue;
if (speed > curInfo.speed) {
curInfo = {speed, i, (short)remainDamage};
}
Expand Down
2 changes: 1 addition & 1 deletion src/include/Config.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ namespace trapdoor {
inline BasicConfig& getBasicConfig() { return this->basicConfig; }
inline TweakConfig& getTweakConfig() { return this->tweakConfig; }

bool init(const std::string& fileName);
bool init(const std::string& fileName, bool reload);

std::string dumpConfigInfo();

Expand Down
2 changes: 1 addition & 1 deletion src/include/TrapdoorMod.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ namespace trapdoor {
public:
void init();

bool initConfig();
bool initConfig(bool reload);

void heavyTick();

Expand Down

0 comments on commit 8a5f0cc

Please sign in to comment.