Skip to content

Commit

Permalink
Merge pull request #19 from zimuya4153/main
Browse files Browse the repository at this point in the history
adapt: adapt to GMLIB v0.13.8
  • Loading branch information
killcerr authored Oct 31, 2024
2 parents f13dc99 + fa4afd9 commit 7db7ae9
Show file tree
Hide file tree
Showing 12 changed files with 40 additions and 49 deletions.
3 changes: 0 additions & 3 deletions .gitmodules

This file was deleted.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# FreeCamera
Free Camera Plugin on Bedrock Dedicated Server
Free Camera Mod on Bedrock Dedicated Server

# 开源许可
## 源代码可用性
Expand Down
6 changes: 3 additions & 3 deletions manifest.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"name": "${pluginName}",
"entry": "${pluginFile}",
"name": "${modName}",
"entry": "${modFile}",
"type": "native",
"author": "GroupMountain",
"description": "Free Camera",
"version": "0.13.1",
"version": "0.13.2",
"dependencies": [
{
"name": "GMLIB"
Expand Down
14 changes: 7 additions & 7 deletions scripts/after_build.lua
Original file line number Diff line number Diff line change
Expand Up @@ -82,16 +82,16 @@ function string_formatter(str, variables)
end)
end

function pack_plugin(target,plugin_define)
function pack_mod(target,mod_define)
import("lib.detect.find_file")

local manifest_path = find_file("manifest.json", os.projectdir())
if manifest_path then
local manifest = io.readfile(manifest_path)
local bindir = path.join(os.projectdir(), "bin")
local outputdir = path.join(bindir, plugin_define.pluginName)
local targetfile = path.join(outputdir, plugin_define.pluginFile)
local pdbfile = path.join(outputdir, path.basename(plugin_define.pluginFile) .. ".pdb")
local outputdir = path.join(bindir, mod_define.modName)
local targetfile = path.join(outputdir, mod_define.modFile)
local pdbfile = path.join(outputdir, path.basename(mod_define.modFile) .. ".pdb")
local manifestfile = path.join(outputdir, "manifest.json")
local oritargetfile = target:targetfile()
local oripdbfile = path.join(path.directory(oritargetfile), path.basename(oritargetfile) .. ".pdb")
Expand All @@ -102,17 +102,17 @@ function pack_plugin(target,plugin_define)
os.cp(oripdbfile, pdbfile)
end

formattedmanifest = string_formatter(manifest, plugin_define)
formattedmanifest = string_formatter(manifest, mod_define)
io.writefile(manifestfile,formattedmanifest)
cprint("${bright green}[Plugin Packer]: ${reset}plugin already generated to " .. outputdir)
cprint("${bright green}[Mod Packer]: ${reset}mod already generated to " .. outputdir)
else
cprint("${bright yellow}warn: ${reset}not found manifest.json in root dir!")
end
end


return {
pack_plugin = pack_plugin,
pack_mod = pack_mod,
beautify_json = beautify_json,
string_formatter = string_formatter
}
6 changes: 2 additions & 4 deletions src/Command.cpp
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
#include "Global.h"

using namespace ll::command;

void RegisterCommand() {
auto& cmd = CommandRegistrar::getInstance()
auto& cmd = ll::command::CommandRegistrar::getInstance()
.getOrCreateCommand("freecamera", tr("freecamera.command.desc"), CommandPermissionLevel::Any);
ll::service::getCommandRegistry()->registerAlias("freecamera", "fc");
cmd.overload().execute<[&](CommandOrigin const& origin, CommandOutput& output) {
auto entity = (GMLIB_Actor*)origin.getEntity();
auto entity = (gmlib::world::Actor*)origin.getEntity();
if (entity && entity->isPlayer()) {
auto pl = (Player*)entity;
auto guid = pl->getNetworkIdentifier().mGuid.g;
Expand Down
8 changes: 4 additions & 4 deletions src/Entry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#include "Global.h"
#include "Language.h"

ll::Logger logger(PLUGIN_NAME);
ll::Logger logger(MOD_NAME);

namespace FreeCamera {

Expand All @@ -20,11 +20,11 @@ bool Entry::load() {
mI18n->updateOrCreateLanguage("en_US", en_US);
mI18n->updateOrCreateLanguage("zh_CN", zh_CN);
mI18n->loadAllLanguages();
if (Version::getProtocolVersion() != TARGET_PROTOCOL) {
if (gmlib::Version::getProtocolVersion() != TARGET_PROTOCOL) {
logger.error(tr("error.protocolMismatch.info"));
logger.error(
tr("error.protocolMismatch.version",
{std::to_string(TARGET_PROTOCOL), std::to_string(Version::getProtocolVersion())})
{std::to_string(TARGET_PROTOCOL), std::to_string(gmlib::Version::getProtocolVersion())})
);
return false;
}
Expand Down Expand Up @@ -56,7 +56,7 @@ bool Entry::unload() {

Config& Entry::getConfig() { return mConfig.value(); }

LangI18n& Entry::getI18n() { return mI18n.value(); }
gmlib::i18n::LangI18n& Entry::getI18n() { return mI18n.value(); }

} // namespace FreeCamera

Expand Down
12 changes: 5 additions & 7 deletions src/Entry.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@

namespace FreeCamera {

using namespace GMLIB::Files::I18n;

class Entry {

public:
Expand All @@ -15,25 +13,25 @@ class Entry {

[[nodiscard]] ll::mod::NativeMod& getSelf() const { return mSelf; }

/// @return True if the plugin is loaded successfully.
/// @return True if the mod is loaded successfully.
bool load();

/// @return True if the plugin is enabled successfully.
/// @return True if the mod is enabled successfully.
bool enable();

/// @return True if the plugin is disabled successfully.
/// @return True if the mod is disabled successfully.
bool disable();

bool unload();

Config& getConfig();

LangI18n& getI18n();
gmlib::i18n::LangI18n& getI18n();

private:
ll::mod::NativeMod& mSelf;
std::optional<Config> mConfig;
std::optional<LangI18n> mI18n;
std::optional<gmlib::i18n::LangI18n> mI18n;
};

} // namespace FreeCamera
6 changes: 3 additions & 3 deletions src/FreeCamera.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ std::unordered_set<uint64> FreeCamList;

namespace FreeCamera {

void EnableFreeCameraPacket(Player* pl) { ((GMLIB_Player*)pl)->setClientGamemode(GameType::Spectator); }
void EnableFreeCameraPacket(Player* pl) { ((gmlib::world::Player*)pl)->setClientGamemode(GameType::Spectator); }

void SendFakePlayerPacket(Player* pl) {
// Client Player
Expand All @@ -15,7 +15,7 @@ void SendFakePlayerPacket(Player* pl) {
pl->sendNetworkPacket(pkt1);
// Update Skin
auto skin = pl->getSkin();
GMLIB_BinaryStream bs;
gmlib::network::BinaryStream bs;
bs.writePacketHeader(MinecraftPacketIds::PlayerSkin);
bs.writeUuid(randomUuid);
bs.writeSkin(skin);
Expand All @@ -26,7 +26,7 @@ void SendFakePlayerPacket(Player* pl) {
}

void DisableFreeCameraPacket(Player* pl) {
((GMLIB_Player*)pl)->setClientGamemode(pl->getPlayerGameType());
((gmlib::world::Player*)pl)->setClientGamemode(pl->getPlayerGameType());
auto uniqueId = pl->getOrCreateUniqueID();
uniqueId.id = uniqueId.id + 114514;
auto pkt2 = RemoveActorPacket(uniqueId);
Expand Down
6 changes: 2 additions & 4 deletions src/Global.h
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
#pragma once
#include <include_all.h>
#include <headers/include_all.h>

#define PLUGIN_NAME "FreeCamera"
#define MOD_NAME "FreeCamera"
#define TARGET_PROTOCOL 686

using namespace GMLIB;

extern ll::Logger logger;
extern std::unordered_set<uint64> FreeCamList;

Expand Down
4 changes: 2 additions & 2 deletions src/MemoryOperators.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// This file will make your plugin use LeviLamina's memory operators by default.
// This improves the memory management of your plugin and is recommended to use.
// This file will make your mod use LeviLamina's memory operators by default.
// This improves the memory management of your mod and is recommended to use.

#define LL_MEMORY_OPERATORS

Expand Down
10 changes: 5 additions & 5 deletions tooth.json
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
{
"format_version": 2,
"tooth": "github.com/GroupMountain/FreeCamera",
"version": "0.13.0",
"version": "0.13.2",
"info": {
"name": "FreeCamera",
"description": "Free Camera Plugin on Bedrock Dedicated Server",
"description": "Free Camera Mod on Bedrock Dedicated Server",
"author": "GroupMountain",
"tags": [
"levilamina",
"freecamera"
]
},
"asset_url": "https://github.com/GroupMountain/FreeCamera/releases/download/v0.13.0/FreeCamera-windows-x64.zip",
"asset_url": "https://github.com/GroupMountain/FreeCamera/releases/download/v0.13.2/FreeCamera-windows-x64.zip",
"dependencies": {
"github.com/GroupMountain/GMLIB": ">=0.13.0"
"github.com/GroupMountain/GMLIB": ">=0.13.8"
},
"files": {
"place": [
Expand All @@ -23,4 +23,4 @@
}
]
}
}
}
12 changes: 6 additions & 6 deletions xmake.lua
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ add_requires("gmlib")
-- import("package.tools.xmake").install(package)
-- end)

target("FreeCamera") -- Change this to your plugin name.
target("FreeCamera") -- Change this to your mod name.
add_cxflags(
"/EHa",
"/utf-8"
Expand All @@ -70,12 +70,12 @@ target("FreeCamera") -- Change this to your plugin name.
set_languages("cxx23")

after_build(function (target)
local plugin_packer = import("scripts.after_build")
local mod_packer = import("scripts.after_build")

local plugin_define = {
pluginName = target:name(),
pluginFile = path.filename(target:targetfile()),
local mod_define = {
modName = target:name(),
modFile = path.filename(target:targetfile()),
}

plugin_packer.pack_plugin(target,plugin_define)
mod_packer.pack_mod(target,mod_define)
end)

0 comments on commit 7db7ae9

Please sign in to comment.