Compare commits
10 Commits
@@ -1,5 +1,5 @@
|
||||
Diagnostics:
|
||||
Suppress: ["-Wmicrosoft-enum-forward-reference", "-Wc++11-narrowing", "-Wc++2b-extensions", "-Wmicrosoft-cast"]
|
||||
CompileFlags:
|
||||
Add: ["-ferror-limit=0", "-D__FUNCTION__=\"dummy\"", "-D_CRT_USE_BUILTIN_OFFSETOF", "-std:c++latest"]
|
||||
Add: ["-ferror-limit=0", "-D__FUNCTION__=\"dummy\"", "-D_CRT_USE_BUILTIN_OFFSETOF", "-std=c++23"]
|
||||
Remove: ["/Yu_HeaderOutputPredefine.h", "/FI_HeaderOutputPredefine.h"]
|
||||
|
||||
@@ -16,7 +16,7 @@ jobs:
|
||||
|
||||
- uses: xmake-io/github-action-setup-xmake@v1
|
||||
with:
|
||||
xmake-version: branch@master
|
||||
xmake-version: latest
|
||||
- run: |
|
||||
xmake repo -u
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ jobs:
|
||||
|
||||
- uses: xmake-io/github-action-setup-xmake@v1
|
||||
with:
|
||||
xmake-version: branch@master
|
||||
xmake-version: latest
|
||||
- run: |
|
||||
xmake repo -u
|
||||
|
||||
|
||||
@@ -1,6 +1,110 @@
|
||||
# Cleaner
|
||||
服务器实体清理插件
|
||||
|
||||
## 配置文件
|
||||
```jsonc
|
||||
{
|
||||
"version": 2, // 配置文件版本(勿动)
|
||||
"language": "zh_CN", // 语言(目前支持zh_CN和en_US)
|
||||
"Basic": { // 基础配置
|
||||
"Command": "cleaner", // 清理命令
|
||||
"Notice1": 20, // 提示1发送时间(剩余时间) (单位:秒)
|
||||
"Notice2": 5, // 提示2发送时间(剩余时间) (单位:秒)
|
||||
"ConsoleLog": true, // 是否在控制台输出清理日志
|
||||
"SendBroadcast": true, // 是否发送广播
|
||||
"SendToast": true // 是否发送Toast(屏幕上方)
|
||||
},
|
||||
"IgnoreTags": [ // 忽略的实体标签
|
||||
"ignore",
|
||||
"不清理"
|
||||
],
|
||||
"AutoCleanCount": { // 自动清理数量配置
|
||||
"Enabled": true, // 是否启用
|
||||
"TriggerCount": 900 // 触发清理最低数量
|
||||
},
|
||||
"AutoCleanTPS": { // 自动清理TPS配置
|
||||
"Enabled": true, // 是否启用
|
||||
"TriggerTPS": 15 // 触发清理最低TPS
|
||||
},
|
||||
"ItemDespawn": { // 掉落物自然刷新配置
|
||||
"Enabled": true, // 是否启用
|
||||
"DespawnTime": 6000, // 刷新时间(单位:tick)
|
||||
"WhiteList": [ // 白名单
|
||||
"minecraft:elytra"
|
||||
]
|
||||
},
|
||||
"CleanInanimate": { // 非生物实体清理配置
|
||||
"Enabled": true, // 是否启用
|
||||
"Blacklist": [ // 黑名单
|
||||
"minecraft:xp_orb",
|
||||
"minecraft:arrow",
|
||||
"minecraft:fireball",
|
||||
"minecraft:small_fireball",
|
||||
"minecraft:wither_skull",
|
||||
"minecraft:wither_skull_dangerous",
|
||||
"minecraft:dragon_fireball"
|
||||
]
|
||||
},
|
||||
"CleanItem": { // 掉落物清理配置
|
||||
"Enabled": true, // 是否启用
|
||||
"ExistTicks": 0, // 安全时间(掉落物存在时间小于这个时间则不会清理) 单位:tick
|
||||
"Whitelist": [ // 白名单
|
||||
"minecraft:netherite_helmet",
|
||||
"minecraft:netherite_sword",
|
||||
"minecraft:netherite_chestplate",
|
||||
"minecraft:diamond_helmet",
|
||||
"minecraft:netherite_leggings",
|
||||
"minecraft:undyed_shulker_box",
|
||||
"minecraft:netherite_boots",
|
||||
"minecraft:shulker_box",
|
||||
"minecraft:elytra",
|
||||
"minecraft:dragon_egg",
|
||||
"minecraft:nether_star",
|
||||
"minecraft:diamond_sword",
|
||||
"minecraft:diamond_chestplate",
|
||||
"minecraft:diamond_boots",
|
||||
"minecraft:diamond_leggings",
|
||||
"minecraft:diamond_hoe",
|
||||
"minecraft:netherite_hoe",
|
||||
"minecraft:diamond_axe",
|
||||
"minecraft:netherite_axe",
|
||||
"minecraft:netherite_pickaxe",
|
||||
"minecraft:diamond_pickaxe"
|
||||
]
|
||||
},
|
||||
"CleanMobs": { // 生物实体清理配置
|
||||
"Enabled": true, // 是否启用
|
||||
"CleanMonstors": true, // 是否清理怪物
|
||||
"CleanPeacefulMobs": false, // 是否清理和平生物
|
||||
"EnableAutoExclude": true, // 无用
|
||||
"BlackList": [ // 黑名单
|
||||
"minecraft:guardian",
|
||||
"minecraft:zombie_pigman"
|
||||
],
|
||||
"Whitelist": [ // 白名单
|
||||
"minecraft:ender_dragon",
|
||||
"minecraft:shulker",
|
||||
"minecraft:wither",
|
||||
"minecraft:elder_guardian",
|
||||
"minecraft:piglin_brute",
|
||||
"minecraft:ender_pearl",
|
||||
"minecraft:phantom"
|
||||
]
|
||||
},
|
||||
"ScheduleClean": { // 定时清理配置
|
||||
"Enabled": true, // 是否启用
|
||||
"CleanInterval": 3600 // 清理间隔 单位:秒
|
||||
},
|
||||
"VoteClean": { // 投票清理配置
|
||||
"Enabled": true, // 是否启用
|
||||
"VoteCleanCommand": "voteclean", // 投票清理指令
|
||||
"Cooldown": 120, // 投票冷却时间 单位:秒
|
||||
"CheckDelay": 30, // 投票时长 单位:秒
|
||||
"Percentage": 50 // 投票百分比(大于此值则清理)
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
# 开源许可
|
||||
## 源代码可用性
|
||||
- 您可以自由地获取、使用和修改本插件的源代码,无论是个人使用还是商业目的。
|
||||
|
||||
+4
-4
@@ -1,8 +1,8 @@
|
||||
{
|
||||
"name": "${pluginName}",
|
||||
"entry": "${pluginFile}",
|
||||
"name": "${modName}",
|
||||
"entry": "${modFile}",
|
||||
"type": "native",
|
||||
"version": "0.13.0",
|
||||
"version": "0.13.2",
|
||||
"author": "GroupMountain",
|
||||
"description": "Clean Entities",
|
||||
"dependencies": [
|
||||
@@ -10,4 +10,4 @@
|
||||
"name": "GMLIB"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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")
|
||||
@@ -102,9 +102,9 @@ 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
|
||||
@@ -112,7 +112,7 @@ end
|
||||
|
||||
|
||||
return {
|
||||
pack_plugin = pack_plugin,
|
||||
pack_mod = pack_mod,
|
||||
beautify_json = beautify_json,
|
||||
string_formatter = string_formatter
|
||||
}
|
||||
|
||||
@@ -95,7 +95,7 @@ bool ShouldClean(Actor* actor) {
|
||||
|
||||
int ExecuteClean() {
|
||||
int clean_count = 0;
|
||||
auto all_entities = GMLIB_Level::getLevel()->getAllEntities();
|
||||
auto all_entities = GMLIB_Level::getLevel()->getRuntimeActorList();
|
||||
for (auto entity : all_entities) {
|
||||
if (ShouldClean(entity)) {
|
||||
entity->despawn();
|
||||
@@ -107,8 +107,8 @@ int ExecuteClean() {
|
||||
|
||||
int CountEntities() {
|
||||
int clean_count = 0;
|
||||
auto all_entities = GMLIB_Level::getLevel()->getAllEntities();
|
||||
for (auto entity : all_entities) {
|
||||
auto all_entities = GMLIB_Level::getLevel()->getRuntimeActorList();
|
||||
for (auto* entity : all_entities) {
|
||||
if (ShouldClean(entity)) {
|
||||
clean_count++;
|
||||
}
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
#pragma once
|
||||
#include "Plugin.h"
|
||||
#include "Mod.h"
|
||||
#include <include_all.h>
|
||||
#include <regex>
|
||||
|
||||
|
||||
+1
-1
@@ -16,7 +16,7 @@ std::string en_US = R"(
|
||||
cleaner.output.count2=Attention! The system will automatically clean server entities in %1$s seconds!
|
||||
cleaner.output.finish=Cleaning complete! A total of %1$s entities have been cleaned this time.
|
||||
cleaner.output.opClean=Admin has enabled server entity cleaning.
|
||||
cleaner.output.reload=Cleaner plugin reloaded. Some configurations may require a server restart to take effect.
|
||||
cleaner.output.reload=Cleaner mod reloaded. Some configurations may require a server restart to take effect.
|
||||
cleaner.output.triggerAutoCleanCount=Too many server entities detected! There are %1$s cleanable entities currently on the server. Auto-clean program has been activated.
|
||||
cleaner.output.triggerAutoCleanTps=Low TPS detected! Server average TPS %1$s\nClean program has been initiated.
|
||||
cleaner.vote.cooldown=Vote cleaning cooldown...
|
||||
|
||||
@@ -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.
|
||||
// You should not modify anything in this file.
|
||||
|
||||
#define LL_MEMORY_OPERATORS
|
||||
|
||||
@@ -44,8 +44,8 @@ ServerTimeScheduler& Entry::getScheduler() { return mScheduler.value(); }
|
||||
|
||||
} // namespace Cleaner
|
||||
|
||||
LL_REGISTER_PLUGIN(Cleaner::Entry, Cleaner::instance);
|
||||
LL_REGISTER_MOD(Cleaner::Entry, Cleaner::instance);
|
||||
|
||||
std::string tr(std::string const& key, std::vector<std::string> const& params) {
|
||||
return I18nAPI::get(key, params, Cleaner::Entry::getInstance().getConfig().language);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
#pragma once
|
||||
|
||||
#include "Config.h"
|
||||
#include <ll/api/mod/NativeMod.h>
|
||||
#include <ll/api/schedule/Scheduler.h>
|
||||
|
||||
namespace Cleaner {
|
||||
|
||||
using namespace ll::schedule;
|
||||
|
||||
class Entry {
|
||||
|
||||
public:
|
||||
static Entry& getInstance();
|
||||
|
||||
Entry(ll::mod::NativeMod& self) : mSelf(self) {}
|
||||
|
||||
[[nodiscard]] ll::mod::NativeMod& getSelf() const { return mSelf; }
|
||||
|
||||
/// @return True if the mod is loaded successfully.
|
||||
bool load();
|
||||
|
||||
/// @return True if the mod is enabled successfully.
|
||||
bool enable();
|
||||
|
||||
/// @return True if the mod is disabled successfully.
|
||||
bool disable();
|
||||
|
||||
// TODO: Implement this method if you need to unload the mod.
|
||||
// /// @return True if the mod is unloaded successfully.
|
||||
// bool unload();
|
||||
|
||||
Config& getConfig();
|
||||
|
||||
void saveConfig();
|
||||
|
||||
ServerTimeScheduler& getScheduler();
|
||||
|
||||
private:
|
||||
ll::mod::NativeMod& mSelf;
|
||||
std::optional<Config> mConfig;
|
||||
std::optional<ServerTimeScheduler> mScheduler;
|
||||
};
|
||||
|
||||
} // namespace Cleaner
|
||||
@@ -1,45 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "Config.h"
|
||||
#include <ll/api/plugin/NativePlugin.h>
|
||||
#include <ll/api/schedule/Scheduler.h>
|
||||
|
||||
namespace Cleaner {
|
||||
|
||||
using namespace ll::schedule;
|
||||
|
||||
class Entry {
|
||||
|
||||
public:
|
||||
static Entry& getInstance();
|
||||
|
||||
Entry(ll::plugin::NativePlugin& self) : mSelf(self) {}
|
||||
|
||||
[[nodiscard]] ll::plugin::NativePlugin& getSelf() const { return mSelf; }
|
||||
|
||||
/// @return True if the plugin is loaded successfully.
|
||||
bool load();
|
||||
|
||||
/// @return True if the plugin is enabled successfully.
|
||||
bool enable();
|
||||
|
||||
/// @return True if the plugin is disabled successfully.
|
||||
bool disable();
|
||||
|
||||
// TODO: Implement this method if you need to unload the plugin.
|
||||
// /// @return True if the plugin is unloaded successfully.
|
||||
// bool unload();
|
||||
|
||||
Config& getConfig();
|
||||
|
||||
void saveConfig();
|
||||
|
||||
ServerTimeScheduler& getScheduler();
|
||||
|
||||
private:
|
||||
ll::plugin::NativePlugin& mSelf;
|
||||
std::optional<Config> mConfig;
|
||||
std::optional<ServerTimeScheduler> mScheduler;
|
||||
};
|
||||
|
||||
} // namespace Cleaner
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "Features/Cleaner.h"
|
||||
#include "Plugin.h"
|
||||
#include "Mod.h"
|
||||
|
||||
struct CleanerParam {
|
||||
enum class Despawn { despawn } despawn;
|
||||
|
||||
+5
-5
@@ -1,10 +1,10 @@
|
||||
{
|
||||
"format_version": 2,
|
||||
"tooth": "github.com/GroupMountain/Cleaner",
|
||||
"version": "0.13.0",
|
||||
"version": "0.13.2",
|
||||
"info": {
|
||||
"name": "Cleaner",
|
||||
"description": "A Powerful Entities Cleaning up Plugin for BDS",
|
||||
"description": "A Powerful Entities Cleaning up Mod for BDS",
|
||||
"author": "GroupMountain",
|
||||
"source": "github.com/GroupMountain/Cleaner",
|
||||
"tags": [
|
||||
@@ -13,15 +13,15 @@
|
||||
"gmlib"
|
||||
]
|
||||
},
|
||||
"asset_url": "https://github.com/GroupMountain/Cleaner/releases/download/v0.13.0/Cleaner-windows-x64.zip",
|
||||
"asset_url": "https://github.com/GroupMountain/Cleaner/releases/download/v0.13.2/Cleaner-windows-x64.zip",
|
||||
"dependencies": {
|
||||
"github.com/GroupMountain/GMLIB": ">=0.13.0"
|
||||
"github.com/GroupMountain/GMLIB": ">=0.13.7"
|
||||
},
|
||||
"files": {
|
||||
"place": [
|
||||
{
|
||||
"src": "Cleaner/*",
|
||||
"dest": "plugins/Cleaner"
|
||||
"dest": "mods/Cleaner"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@@ -9,9 +9,9 @@ end
|
||||
|
||||
-- Option 1: Use the latest version of LeviLamina released on GitHub.
|
||||
add_requires("levilamina")
|
||||
add_requires("gmlib")
|
||||
add_requires("gmlib 0.13.7")
|
||||
|
||||
target("Cleaner") -- Change this to your plugin name.
|
||||
target("Cleaner") -- Change this to your mod name.
|
||||
add_cxflags(
|
||||
"/EHa",
|
||||
"/utf-8"
|
||||
@@ -34,12 +34,12 @@ target("Cleaner") -- 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)
|
||||
|
||||
Reference in New Issue
Block a user