Skip to content
This repository has been archived by the owner on Sep 20, 2024. It is now read-only.

Commit

Permalink
feat: update to 1.20.61.01 x2
Browse files Browse the repository at this point in the history
  • Loading branch information
smartcmd committed Feb 12, 2024
1 parent 15d0810 commit 3500ae6
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 70 deletions.
57 changes: 20 additions & 37 deletions src/Plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
#include <zlib.h>

// LL
#include <Plugin.h>
#include <ll/api/command/Command.h>
#include <ll/api/command/CommandHandle.h>
#include <ll/api/command/CommandRegistrar.h>
Expand Down Expand Up @@ -171,6 +170,8 @@ namespace plugin {
hookLogger.info("Create available_commands_packet.bin success!");
}

std::unique_ptr<std::reference_wrapper<ll::plugin::NativePlugin>> pluginInstance;

void dumpCreativeItemData(const ll::Logger &logger) {
logger.info("Extracting creative items...");

Expand Down Expand Up @@ -850,24 +851,6 @@ namespace plugin {
dumpPropertyTypeData(logger);
}

Plugin::Plugin() = default;

Plugin& Plugin::getInstance() {
static Plugin instance;
return instance;
}

ll::plugin::NativePlugin& Plugin::getSelf() const { return *mSelf; }

// The global plugin instance.
std::unique_ptr<Plugin> plugin = nullptr;

bool Plugin::load(ll::plugin::NativePlugin& self) {
mSelf = std::addressof(self);
getSelf().getLogger().info("loading...");
return true;
}

// // Use this if command not works
// LL_AUTO_TYPE_INSTANCE_HOOK(
// TextPacketHandleHook,
Expand Down Expand Up @@ -895,11 +878,17 @@ namespace plugin {
class CommandOutput& output
) {
origin(o, output);
ext(Plugin::getInstance().getSelf().getLogger());
ext(pluginInstance->get().getLogger());
}

bool Plugin::enable() {
auto& logger = getSelf().getLogger();
bool load(ll::plugin::NativePlugin& self) {
self.getLogger().info("loading...");
pluginInstance = std::make_unique<std::reference_wrapper<ll::plugin::NativePlugin>>(self);
return true;
}

bool enable(ll::plugin::NativePlugin& self) {
auto& logger = self.getLogger();
logger.info("enabling...");

// TODO: It seems not works, replaced with TextPacket hook. Need to fix it in the future
Expand All @@ -917,24 +906,18 @@ namespace plugin {
return true;
}

bool Plugin::disable() {
getSelf().getLogger().info("disabling...");
bool disable(ll::plugin::NativePlugin&) {
return true;
}

extern "C" {
_declspec(dllexport) bool ll_plugin_load(ll::plugin::NativePlugin& self) {
return Plugin::getInstance().load(self);
}

_declspec(dllexport) bool ll_plugin_enable(ll::plugin::NativePlugin&) { return Plugin::getInstance().enable(); }

_declspec(dllexport) bool ll_plugin_disable(ll::plugin::NativePlugin&) { return Plugin::getInstance().disable(); }
bool unload(ll::plugin::NativePlugin&) {
return true;
}

/// @warning Unloading the plugin may cause a crash if the plugin has not released all of its
/// resources. If you are unsure, keep this function commented out.
// _declspec(dllexport) bool ll_plugin_unload(ll::plugin::NativePlugin&) {
// return RenameThis::getInstance().unload();
// }
extern "C" {
_declspec(dllexport) auto ll_plugin_disable(ll::plugin::NativePlugin& self) -> bool { return disable(self); }
_declspec(dllexport) auto ll_plugin_enable(ll::plugin::NativePlugin& self) -> bool { return enable(self); }
_declspec(dllexport) auto ll_plugin_load(ll::plugin::NativePlugin& self) -> bool { return load(self); }
_declspec(dllexport) auto ll_plugin_unload(ll::plugin::NativePlugin& self) -> bool { return unload(self); }
}
} // namespace plugin
33 changes: 0 additions & 33 deletions src/Plugin.h

This file was deleted.

0 comments on commit 3500ae6

Please sign in to comment.