Skip to content

Commit

Permalink
feat: adapt to LeviLamina 0.12.x
Browse files Browse the repository at this point in the history
  • Loading branch information
ShrBox committed Apr 28, 2024
1 parent 44b413f commit baee684
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 12 deletions.
4 changes: 2 additions & 2 deletions src/legacy/api/CommandAPI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ Local<Value> McClass::runcmd(const Arguments& args) {
CATCH("Fail in RunCmd!")
}

I18n* getI18n(); // Stupid Mojang
I18n& getI18n(); // Stupid Mojang

Local<Value> McClass::runcmdEx(const Arguments& args) {
CHECK_ARGS_COUNT(args, 1)
Expand All @@ -204,7 +204,7 @@ Local<Value> McClass::runcmdEx(const Arguments& args) {
command->run(origin, output);
for (auto msg : output.getMessages()) {
std::string temp;
getI18n()->getCurrentLanguage()->get(msg.getMessageId(), temp, msg.getParams());
getI18n().getCurrentLanguage()->get(msg.getMessageId(), temp, msg.getParams());
outputStr += temp.append("\n");
}
if (output.getMessages().size()) {
Expand Down
5 changes: 3 additions & 2 deletions src/legacy/events/EventHooks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,17 +69,18 @@ LL_TYPE_INSTANCE_HOOK(
void,
Player& player,
BlockPos const& blockPos,
Block const& block,
uchar unk_char
) {
IF_LISTENED(EVENT_TYPES::onStartDestroyBlock) {
CallEventVoid(
EVENT_TYPES::onStartDestroyBlock,
PlayerClass::newPlayer(&player),
BlockClass::newBlock(blockPos, player.getDimensionId())
BlockClass::newBlock(&block, &blockPos, player.getDimensionId())
);
}
IF_LISTENED_END(EVENT_TYPES::onStartDestroyBlock)
origin(player, blockPos, unk_char);
origin(player, blockPos, block, unk_char);
}

LL_TYPE_INSTANCE_HOOK(
Expand Down
2 changes: 1 addition & 1 deletion src/legacy/legacyapi/command/DynamicCommand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -688,7 +688,7 @@ DynamicCommandInstance::DynamicCommandInstance(
description_(std::make_unique<std::string>(description)),
permission_(permission),
flag_(flag),
builder(std::make_unique<ll::memory::NativeClosure<std::unique_ptr<Command>>>(commandBuilder, (uintptr_t)this)) {}
builder(std::make_unique<ll::memory::NativeClosure<std::unique_ptr<Command>()>>(commandBuilder, (uintptr_t)this)) {}

DynamicCommandInstance::~DynamicCommandInstance() = default;

Expand Down
8 changes: 2 additions & 6 deletions src/legacy/legacyapi/command/DynamicCommand.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include "fmt/core.h"
#include "ll/api/base/Concepts.h"
#include "ll/api/base/Macro.h"
#include "ll/api/memory/Closure.h"
#include "ll/api/memory/Memory.h"
#include "ll/api/service/Bedrock.h"
#include "magic_enum.hpp"
Expand Down Expand Up @@ -43,11 +44,6 @@
#include <utility>
#include <vector>

namespace ll::memory {
template <class Ret, class... Args>
class NativeClosure;
}

class Actor;
class DynamicCommandInstance;

Expand Down Expand Up @@ -600,7 +596,7 @@ class DynamicCommandInstance {
CommandFlag flag_;

public:
std::unique_ptr<ll::memory::NativeClosure<std::unique_ptr<Command>>> builder;
std::unique_ptr<ll::memory::NativeClosure<std::unique_ptr<Command>()>> builder;
// Parameter Pointers to DynamicCommand Extra Part
size_t commandSize = sizeof(DynamicCommand);
std::unordered_map<std::string, DynamicCommand::ParameterPtr> parameterPtrs = {};
Expand Down
3 changes: 2 additions & 1 deletion src/lse/PluginMigration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#include "Entry.h"
#include "legacyapi/utils/FileHelper.h"
#include "ll/api/Expected.h"

#include <filesystem>
#include <fmt/format.h>
Expand Down Expand Up @@ -99,7 +100,7 @@ auto migratePlugin(const PluginManager& pluginManager, const std::filesystem::pa
std::filesystem::remove(path);
#endif

auto manifestJson = ll::reflection::serialize<nlohmann::ordered_json>(manifest);
auto manifestJson = ll::reflection::serialize<nlohmann::ordered_json>(manifest).value();

std::ofstream manifestFile{pluginDir / "manifest.json"};
manifestFile << manifestJson.dump(4);
Expand Down

0 comments on commit baee684

Please sign in to comment.