Skip to content

Commit

Permalink
chore: rename plugin to mod
Browse files Browse the repository at this point in the history
  • Loading branch information
OEOTYAN committed Aug 7, 2024
1 parent 502a978 commit d108b92
Show file tree
Hide file tree
Showing 11 changed files with 41 additions and 43 deletions.
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/bug_report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ body:
- type: input
attributes:
label: Version
description: The version of the plugin you are using. (e.g. 1.0.0)
description: The version of the mod you are using. (e.g. 1.0.0)

- type: textarea
attributes:
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
![English](https://img.shields.io/badge/English-inactive?style=for-the-badge)
[![中文](https://img.shields.io/badge/简体中文-informational?style=for-the-badge)](README.zh.md)

A performance optimization plugin for Minecraft Bedrock Dedicated Server (BDS), "LeviOptimize" is designed to enhance server performance by addressing issues related to low ticks per second (TPS). Operating within the LeviLamina framework, it modifies BDS code to achieve notable performance improvements.
A performance optimization mod for Minecraft Bedrock Dedicated Server (BDS), "LeviOptimize" is designed to enhance server performance by addressing issues related to low ticks per second (TPS). Operating within the LeviLamina framework, it modifies BDS code to achieve notable performance improvements.

## Table of Contents

Expand Down Expand Up @@ -33,11 +33,11 @@ lip install github.com/LiteLDev/LeviOptimize

1. Download the latest release from the [Releases page](https://github.com/LiteLDev/LeviOptimize/releases).
2. Unpack the `LeviOptimize-windows-x64.zip` file.
3. Copy the `LeviOptimize` folder to the `plugins` folder of your BDS installation directory.
3. Copy the `LeviOptimize` folder to the `mods` folder of your BDS installation directory.

## Usage

Upon its first run, LeviOptimize will generate configuration files in `plugin/LeviOptimize/config/`. These files are customizable to tailor the plugin's behavior to your needs.
Upon its first run, LeviOptimize will generate configuration files in `mod/LeviOptimize/config/`. These files are customizable to tailor the mod's behavior to your needs.

## Commands

Expand All @@ -52,7 +52,7 @@ Upon its first run, LeviOptimize will generate configuration files in `plugin/Le
- **`fixChunkLeak`**: Addresses the issue of chunks remaining loaded after players leave.
- **`optSeenPercent`**: Caches "SeenPercent" values to improve TPS, with a note of caution regarding potential hash collisions.
- **`optPacketSender`**: Optimizes the packet sending process to improve server performance.
>Some plugins rely on this feature to achieve multi-threaded sending packets, it is best to keep it enabled.
>Some mods rely on this feature to achieve multi-threaded sending packets, it is best to keep it enabled.
- **`optPlayerLookup`**: Optimizes the `Level::getPlayer` method to improve player lookup performance.
- **`optPushEntity`**: Improves server performance by reducing TPS drops from entity cramming with two key options:

Expand Down
4 changes: 2 additions & 2 deletions README.zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ lip install github.com/LiteLDev/LeviOptimize

1.[发布页面](https://github.com/LiteLDev/LeviOptimize/releases)下载最新版本。
2. 解压`LeviOptimize-windows-x64.zip`文件。
3.`LeviOptimize`文件夹复制到BDS安装目录下的`plugins`文件夹中。
3.`LeviOptimize`文件夹复制到BDS安装目录下的`mods`文件夹中。

## 使用

首次运行后,LeviOptimize将在`plugin/LeviOptimize/config/`中生成配置文件。您可以修改这些文件以定制插件的行为。
首次运行后,LeviOptimize将在`mod/LeviOptimize/config/`中生成配置文件。您可以修改这些文件以定制插件的行为。

## 命令

Expand Down
8 changes: 4 additions & 4 deletions manifest.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "${pluginName}",
"entry": "${pluginFile}",
"version": "${pluginVersion}",
"name": "${modName}",
"entry": "${modFile}",
"version": "${modVersion}",
"type": "native"
}
}
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: 3 additions & 3 deletions src/levioptimize/LeviOptimize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

#include "Config.h"
#include "ll/api/Config.h"
#include "ll/api/plugin/RegisterHelper.h"
#include "ll/api/mod/RegisterHelper.h"
#include "ll/api/utils/ErrorUtils.h"

#include <stdexcept>
Expand Down Expand Up @@ -42,7 +42,7 @@ ll::Logger& LeviOptimize::getLogger() const { return getSelf().getLogger(); }

std::string const& LeviOptimize::getName() const { return getSelf().getManifest().name; }

ll::plugin::NativePlugin& LeviOptimize::getSelf() const { return mSelf; }
ll::mod::NativeMod& LeviOptimize::getSelf() const { return mSelf; }

std::filesystem::path LeviOptimize::getConfigPath() const { return getSelf().getConfigDir() / u8"config.json"; }

Expand All @@ -68,4 +68,4 @@ bool LeviOptimize::saveConfig() { return ll::config::saveConfig(mConfig.value(),
bool LeviOptimize::isEnabled() const { return getSelf().isEnabled(); }
} // namespace lo

LL_REGISTER_PLUGIN(lo::LeviOptimize, lo::instance);
LL_REGISTER_MOD(lo::LeviOptimize, lo::instance);
10 changes: 5 additions & 5 deletions src/levioptimize/LeviOptimize.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

#include "Config.h"
#include "ll/api/Logger.h"
#include "ll/api/plugin/NativePlugin.h"
#include "ll/api/mod/NativeMod.h"

#include <string_view>

Expand All @@ -11,7 +11,7 @@ namespace lo {
class LeviOptimize {

public:
LeviOptimize(ll::plugin::NativePlugin& self) : mSelf(self) {}
LeviOptimize(ll::mod::NativeMod& self) : mSelf(self) {}

static LeviOptimize& getInstance();

Expand All @@ -27,7 +27,7 @@ class LeviOptimize {

std::string const& getName() const;

ll::plugin::NativePlugin& getSelf() const;
ll::mod::NativeMod& getSelf() const;

std::filesystem::path getConfigPath() const;

Expand All @@ -40,8 +40,8 @@ class LeviOptimize {
bool isEnabled() const;

private:
ll::plugin::NativePlugin& mSelf;
std::optional<Config> mConfig;
ll::mod::NativeMod& mSelf;
std::optional<Config> mConfig;
};

} // namespace lo
3 changes: 0 additions & 3 deletions src/levioptimize/features/HopperItemOpt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@ LL_TYPE_INSTANCE_HOOK(
int itemCount
) {
auto size = container.getContainerSize();
if (size == 0) {
return false;
}
for (int slot = 0; slot < size; ++slot) {
if (!container.canPushInItem(slot, face, item)) {
continue;
Expand Down
4 changes: 2 additions & 2 deletions src/levioptimize/features/command/TimingCommand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,9 @@ void registerTimingCommand() {
std::ranges::sort(orderdTiming, [](TimingData const& a, TimingData const& b) { return a.avg > b.avg; });

logger.warn("TPS: {:.5f}", double(counttick) / std::chrono::duration<double>(end - begin).count());
logger.warn("ECS cost {:.5f}ms per tick", allTime);
logger.warn("{} ECS cost {:.5f}ms per tick", timings.size(), allTime);

for (size_t i = 0; i < orderdTiming.size() && i < 20; i++) {
for (size_t i = 0; i < orderdTiming.size() /*&& i < 20*/; i++) {
auto& data = orderdTiming[i];
logger.warn(
" | {:.5f}ms {} for {:0>3} {}",
Expand Down
10 changes: 5 additions & 5 deletions tooth.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
{
"format_version": 2,
"tooth": "github.com/LiteLDev/LeviOptimize",
"version": "0.3.0",
"version": "0.3.1",
"info": {
"name": "LeviOptimize",
"description": "A performance optimization plugin for Minecraft Bedrock Server",
"description": "A performance optimization mod for Minecraft Bedrock Server",
"author": "LiteLDev",
"tags": [
"levilamina",
"plugin"
"mod"
]
},
"asset_url": "https://github.com/LiteLDev/LeviOptimize/releases/download/v0.3.0/LeviOptimize-windows-x64.zip",
"asset_url": "https://github.com/LiteLDev/LeviOptimize/releases/download/v0.3.1/LeviOptimize-windows-x64.zip",
"prerequisites": {
"github.com/LiteLDev/LeviLamina": "0.13.x"
},
Expand All @@ -23,4 +23,4 @@
}
]
}
}
}
15 changes: 8 additions & 7 deletions xmake.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ add_rules("mode.release", "mode.debug")
add_repositories("liteldev-repo https://github.com/LiteLDev/xmake-repo.git")

add_requires(
"levilamina 0.13.0",
"levilamina",
"parallel-hashmap"
)

Expand All @@ -12,6 +12,7 @@ if not has_config("vs_runtime") then
end

target("LeviOptimize")
add_rules("@levilamina/linkrule")
add_cxflags(
"/EHa",
"/utf-8",
Expand Down Expand Up @@ -50,19 +51,19 @@ target("LeviOptimize")
set_symbols("debug")

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

local tag = os.iorun("git describe --tags --abbrev=0 --always")
local major, minor, patch, suffix = tag:match("v(%d+)%.(%d+)%.(%d+)(.*)")
if not major then
print("Failed to parse version tag, using 0.0.0")
major, minor, patch = 0, 0, 0
end
local plugin_define = {
pluginName = target:name(),
pluginFile = path.filename(target:targetfile()),
pluginVersion = major .. "." .. minor .. "." .. patch,
local mod_define = {
modName = target:name(),
modFile = path.filename(target:targetfile()),
modVersion = major .. "." .. minor .. "." .. patch,
}

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

0 comments on commit d108b92

Please sign in to comment.