Compare commits
5 Commits
@@ -12,7 +12,7 @@ jobs:
|
|||||||
|
|
||||||
- uses: xmake-io/github-action-setup-xmake@v1
|
- uses: xmake-io/github-action-setup-xmake@v1
|
||||||
with:
|
with:
|
||||||
xmake-version: 2.9.9
|
xmake-version: 3.0.0
|
||||||
|
|
||||||
- run: |
|
- run: |
|
||||||
xmake repo -u
|
xmake repo -u
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ jobs:
|
|||||||
|
|
||||||
- uses: xmake-io/github-action-setup-xmake@v1
|
- uses: xmake-io/github-action-setup-xmake@v1
|
||||||
with:
|
with:
|
||||||
xmake-version: 2.9.9
|
xmake-version: 3.0.0
|
||||||
|
|
||||||
- run: |
|
- run: |
|
||||||
xmake repo -u
|
xmake repo -u
|
||||||
|
|||||||
@@ -19,31 +19,6 @@ const PlaceholderAPI = {
|
|||||||
getAllPAPI: ll.imports("BEPlaceholderAPI", "getAllPAPI")
|
getAllPAPI: ll.imports("BEPlaceholderAPI", "getAllPAPI")
|
||||||
}
|
}
|
||||||
|
|
||||||
Function.prototype.getName =
|
|
||||||
/**
|
|
||||||
* 获取函数名字
|
|
||||||
* @returns {string}
|
|
||||||
*/
|
|
||||||
function () {
|
|
||||||
return this.name || this.toString().match(/function\s*([^(]*)\(/)?.[1] || getStringHashCode(this.toString()).toString(16);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取字符串哈希值
|
|
||||||
* @param {string} str 字符串
|
|
||||||
* @returns {number}
|
|
||||||
*/
|
|
||||||
function getStringHashCode(str) {
|
|
||||||
let hash = 0, chr;
|
|
||||||
if (str.length === 0) return hash;
|
|
||||||
for (let i = 0; i < str.length; i++) {
|
|
||||||
chr = str.charCodeAt(i);
|
|
||||||
hash = ((hash << 5) - hash) + chr;
|
|
||||||
hash |= 0;
|
|
||||||
}
|
|
||||||
return hash;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** PAPI变量类 */
|
/** PAPI变量类 */
|
||||||
class PAPI {
|
class PAPI {
|
||||||
constructor() {
|
constructor() {
|
||||||
@@ -58,8 +33,8 @@ class PAPI {
|
|||||||
* @returns {boolean} 是否注册成功
|
* @returns {boolean} 是否注册成功
|
||||||
*/
|
*/
|
||||||
static registerPlayerPlaceholder(func, PluginName, PAPIName) {
|
static registerPlayerPlaceholder(func, PluginName, PAPIName) {
|
||||||
ll.export(func, PluginName, func.getName());
|
ll.export(func, PluginName, `Placeholder_${PAPIName}`);
|
||||||
PlaceholderAPI.registerPlayerPlaceholderAPI(PluginName, func.getName(), PAPIName);
|
PlaceholderAPI.registerPlayerPlaceholderAPI(PluginName, `Placeholder_${PAPIName}`, PAPIName);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -70,8 +45,8 @@ class PAPI {
|
|||||||
* @returns {boolean} 是否注册成功
|
* @returns {boolean} 是否注册成功
|
||||||
*/
|
*/
|
||||||
static registerServerPlaceholder(func, PluginName, PAPIName) {
|
static registerServerPlaceholder(func, PluginName, PAPIName) {
|
||||||
ll.export(func, PluginName, func.getName());
|
ll.export(func, PluginName, `Placeholder_${PAPIName}`);
|
||||||
PlaceholderAPI.registerServerPlaceholderAPI(PluginName, func.getName(), PAPIName);
|
PlaceholderAPI.registerServerPlaceholderAPI(PluginName, `Placeholder_${PAPIName}`, PAPIName);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -83,8 +58,8 @@ class PAPI {
|
|||||||
* @returns {boolean} 是否注册成功
|
* @returns {boolean} 是否注册成功
|
||||||
*/
|
*/
|
||||||
static registerStaticPlaceholder(func, PluginName, PAPIName, UpdateInterval = 50) {
|
static registerStaticPlaceholder(func, PluginName, PAPIName, UpdateInterval = 50) {
|
||||||
ll.export(func, PluginName, func.getName());
|
ll.export(func, PluginName, `Placeholder_${PAPIName}`);
|
||||||
PlaceholderAPI.registerStaticPlaceholderAPI(PluginName, func.getName(), PAPIName, UpdateInterval);
|
PlaceholderAPI.registerStaticPlaceholderAPI(PluginName, `Placeholder_${PAPIName}`, PAPIName, UpdateInterval);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
+4
-4
@@ -116,7 +116,7 @@ module.exports = {
|
|||||||
*/
|
*/
|
||||||
emplaceListener: function (eventName, callback, priority = this.EventPriority.Normal, pluginName = getPluginName()) {
|
emplaceListener: function (eventName, callback, priority = this.EventPriority.Normal, pluginName = getPluginName()) {
|
||||||
if (typeof callback !== "function") throw new Error("callback must be a function!");
|
if (typeof callback !== "function") throw new Error("callback must be a function!");
|
||||||
const /** @type {number} */ eventId = ll.importss("GMLIB_Event_API", "emplaceListener")(pluginName, eventName, priority);
|
const /** @type {number} */ eventId = ll.imports("GMLIB_Event_API", "emplaceListener")(pluginName, eventName, priority);
|
||||||
if (eventId === -1) throw new Error(`Event ${eventName} creation failed!`);
|
if (eventId === -1) throw new Error(`Event ${eventName} creation failed!`);
|
||||||
ll.exports((...data) => {
|
ll.exports((...data) => {
|
||||||
let /** @type {boolean} */ result = typeof (data.slice(-1)[0]) === "boolean" ? data.pop() : false;
|
let /** @type {boolean} */ result = typeof (data.slice(-1)[0]) === "boolean" ? data.pop() : false;
|
||||||
@@ -146,7 +146,7 @@ module.exports = {
|
|||||||
* @param {boolean}
|
* @param {boolean}
|
||||||
*/
|
*/
|
||||||
removeListener: function (eventId) {
|
removeListener: function (eventId) {
|
||||||
const result = ll.importss("GMLIB_Event_API", "removeListener")(eventId);
|
const result = ll.imports("GMLIB_Event_API", "removeListener")(eventId);
|
||||||
if (result) {
|
if (result) {
|
||||||
for (let [eventName, eventIds] of Object.entries(this.mEventData)) {
|
for (let [eventName, eventIds] of Object.entries(this.mEventData)) {
|
||||||
this.mEventData[eventName] = eventIds.filter(id => id !== eventId);
|
this.mEventData[eventName] = eventIds.filter(id => id !== eventId);
|
||||||
@@ -162,7 +162,7 @@ module.exports = {
|
|||||||
* @returns {boolean}
|
* @returns {boolean}
|
||||||
*/
|
*/
|
||||||
hasListener: function (eventId) {
|
hasListener: function (eventId) {
|
||||||
return ll.importss("GMLIB_Event_API", "hasListener")(eventId);
|
return ll.imports("GMLIB_Event_API", "hasListener")(eventId);
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -171,7 +171,7 @@ module.exports = {
|
|||||||
* @returns {number?}
|
* @returns {number?}
|
||||||
*/
|
*/
|
||||||
getListenerPriority: function (eventId) {
|
getListenerPriority: function (eventId) {
|
||||||
const priority = ll.importss("GMLIB_Event_API", "getListenerPriority")(eventId);
|
const priority = ll.imports("GMLIB_Event_API", "getListenerPriority")(eventId);
|
||||||
return priority === -1 ? undefined : priority;
|
return priority === -1 ? undefined : priority;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
+8
-33
@@ -47,56 +47,31 @@ const getPluginName = () => {
|
|||||||
return "Unknown";
|
return "Unknown";
|
||||||
};
|
};
|
||||||
|
|
||||||
Function.prototype.getName =
|
|
||||||
/**
|
|
||||||
* 获取函数名字
|
|
||||||
* @returns {string}
|
|
||||||
*/
|
|
||||||
function () {
|
|
||||||
return this.name || this.toString().match(/function\s*([^(]*)\(/)?.[1] || getStringHashCode(this.toString()).toString(16);
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取字符串哈希值
|
|
||||||
* @param {string} str 字符串
|
|
||||||
* @returns {number}
|
|
||||||
*/
|
|
||||||
function getStringHashCode(str) {
|
|
||||||
let hash = 0, chr;
|
|
||||||
if (str.length === 0) return hash;
|
|
||||||
for (let i = 0; i < str.length; i++) {
|
|
||||||
chr = str.charCodeAt(i);
|
|
||||||
hash = ((hash << 5) - hash) + chr;
|
|
||||||
hash |= 0;
|
|
||||||
}
|
|
||||||
return hash;
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
translate(value, actor = undefined, language = "") {
|
translate(value, actor = undefined, language = "") {
|
||||||
return actor instanceof LLSE_Entity
|
return actor instanceof LLSE_Entity
|
||||||
? ll.importss("PlaceholderAPI", "translateFromActor")(value, actor, language)
|
? ll.imports("PlaceholderAPI", "translateFromActor")(value, actor, language)
|
||||||
: ll.importss("PlaceholderAPI", "translate")(value, language);
|
: ll.imports("PlaceholderAPI", "translate")(value, language);
|
||||||
},
|
},
|
||||||
registerPlaceholder(placeholder, callback) {
|
registerPlaceholder(placeholder, callback) {
|
||||||
const pluginName = getPluginName();
|
const pluginName = getPluginName();
|
||||||
ll.exports((...args) => {
|
ll.exports((...args) => {
|
||||||
if(!args[0].uniqueId) args[0] = undefined;
|
if(!args[0].uniqueId) args[0] = undefined;
|
||||||
return callback(...args) ?? "<std::nullopt>";
|
return callback(...args) ?? "<std::nullopt>";
|
||||||
}, pluginName, callback.getName());
|
}, pluginName, `Placeholder_${placeholder}`);
|
||||||
ll.importss("PlaceholderAPI", "registerPlaceholder")(placeholder, callback.getName(), pluginName);
|
ll.imports("PlaceholderAPI", "registerPlaceholder")(placeholder, `Placeholder_${placeholder}`, pluginName);
|
||||||
},
|
},
|
||||||
unregisterPlaceholder(placeholder) {
|
unregisterPlaceholder(placeholder) {
|
||||||
return ll.importss("PlaceholderAPI", "unregisterPlaceholder")(placeholder);
|
return ll.imports("PlaceholderAPI", "unregisterPlaceholder")(placeholder);
|
||||||
},
|
},
|
||||||
unregisterPlaceholderFromModName(placeholder) {
|
unregisterPlaceholderFromModName(placeholder) {
|
||||||
return ll.importss("PlaceholderAPI", "unregisterPlaceholderFromModName")(placeholder);
|
return ll.imports("PlaceholderAPI", "unregisterPlaceholderFromModName")(placeholder);
|
||||||
},
|
},
|
||||||
getValue(placeholder, actor = undefined, params = {}, language = "") {
|
getValue(placeholder, actor = undefined, params = {}, language = "") {
|
||||||
if (actor instanceof LLSE_Player) actor = ll.imports("GMLib_ServerAPI", "PlayerToEntity")(actor);
|
if (actor instanceof LLSE_Player) actor = ll.imports("GMLib_ServerAPI", "PlayerToEntity")(actor);
|
||||||
const result = actor instanceof LLSE_Entity
|
const result = actor instanceof LLSE_Entity
|
||||||
? ll.importss("PlaceholderAPI", "getValueFromActor")(placeholder, actor, params, language)
|
? ll.imports("PlaceholderAPI", "getValueFromActor")(placeholder, actor, params, language)
|
||||||
: ll.importss("PlaceholderAPI", "getValue")(placeholder, params, language);
|
: ll.imports("PlaceholderAPI", "getValue")(placeholder, params, language);
|
||||||
return result !== "<std::nullopt>" ? result : undefined;
|
return result !== "<std::nullopt>" ? result : undefined;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
+3
-3
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "${pluginName}",
|
"name": "${modName}",
|
||||||
"entry": "${pluginFile}",
|
"entry": "${modFile}",
|
||||||
"version": "1.1.2",
|
"version": "${modVersion}",
|
||||||
"author": "GroupMountain",
|
"author": "GroupMountain",
|
||||||
"type": "native",
|
"type": "native",
|
||||||
"passive": true,
|
"passive": true,
|
||||||
|
|||||||
@@ -1,121 +0,0 @@
|
|||||||
function beautify_json(value, indent)
|
|
||||||
import("core.base.json")
|
|
||||||
local json_text = ""
|
|
||||||
local stack = {}
|
|
||||||
|
|
||||||
local function escape_str(s)
|
|
||||||
return string.gsub(s, '[%c\\"]', function(c)
|
|
||||||
local replacements = {['\b'] = '\\b', ['\f'] = '\\f', ['\n'] = '\\n', ['\r'] = '\\r', ['\t'] = '\\t', ['"'] = '\\"', ['\\'] = '\\\\'}
|
|
||||||
return replacements[c] or string.format('\\u%04x', c:byte())
|
|
||||||
end)
|
|
||||||
end
|
|
||||||
|
|
||||||
local function is_null(v)
|
|
||||||
return v == json.null
|
|
||||||
end
|
|
||||||
|
|
||||||
local function is_empty_table(t)
|
|
||||||
if type(t) ~= 'table' then return false end
|
|
||||||
for _ in pairs(t) do
|
|
||||||
return false
|
|
||||||
end
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
|
|
||||||
local function is_array(t)
|
|
||||||
return type(t) == 'table' and json.is_marked_as_array(t) or #t > 0
|
|
||||||
end
|
|
||||||
|
|
||||||
local function serialize(val, level)
|
|
||||||
local spaces = string.rep(" ", level * indent)
|
|
||||||
|
|
||||||
if type(val) == "table" and not stack[val] then
|
|
||||||
if is_empty_table(val) then
|
|
||||||
json_text = json_text .. (is_array(val) and "[]" or "{}")
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
stack[val] = true
|
|
||||||
local isArray = is_array(val)
|
|
||||||
json_text = json_text .. (isArray and "[\n" or "{\n")
|
|
||||||
|
|
||||||
local keys = isArray and {} or {}
|
|
||||||
for k in pairs(val) do
|
|
||||||
table.insert(keys, k)
|
|
||||||
end
|
|
||||||
if not isArray then
|
|
||||||
table.sort(keys)
|
|
||||||
end
|
|
||||||
|
|
||||||
for _, k in ipairs(keys) do
|
|
||||||
local v = val[k]
|
|
||||||
json_text = json_text .. spaces .. (isArray and "" or '"' .. escape_str(tostring(k)) .. '": ')
|
|
||||||
serialize(v, level + 1)
|
|
||||||
json_text = json_text .. ",\n"
|
|
||||||
end
|
|
||||||
|
|
||||||
json_text = string.sub(json_text, 1, -3) .. "\n" .. string.rep(" ", (level - 1) * indent) .. (isArray and "]" or "}")
|
|
||||||
stack[val] = nil
|
|
||||||
elseif type(val) == "string" then
|
|
||||||
json_text = json_text .. '"' .. escape_str(val) .. '"'
|
|
||||||
elseif type(val) == "number" then
|
|
||||||
if val % 1 == 0 then
|
|
||||||
json_text = json_text .. tostring(math.floor(val))
|
|
||||||
else
|
|
||||||
json_text = json_text .. tostring(val)
|
|
||||||
end
|
|
||||||
elseif type(val) == "boolean" then
|
|
||||||
json_text = json_text .. tostring(val)
|
|
||||||
elseif is_null(val) then
|
|
||||||
json_text = json_text .. "null"
|
|
||||||
else
|
|
||||||
error("Invalid value type: " .. type(val))
|
|
||||||
end
|
|
||||||
end
|
|
||||||
serialize(value, 1)
|
|
||||||
return json_text
|
|
||||||
end
|
|
||||||
|
|
||||||
function string_formatter(str, variables)
|
|
||||||
return str:gsub("%${(.-)}", function(var)
|
|
||||||
return variables[var] or "${" .. var .. "}"
|
|
||||||
end)
|
|
||||||
end
|
|
||||||
|
|
||||||
function pack_plugin(target,plugin_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/DLL")
|
|
||||||
local pdbdir = path.join(os.projectdir(), "bin/PDB")
|
|
||||||
local outputdir = path.join(bindir, plugin_define.pluginName)
|
|
||||||
local targetfile = path.join(outputdir, plugin_define.pluginFile)
|
|
||||||
local pdbfile = path.join(pdbdir, path.basename(plugin_define.pluginFile) .. ".pdb")
|
|
||||||
local libfile = path.join(os.projectdir(), "lib")
|
|
||||||
local manifestfile = path.join(outputdir, "manifest.json")
|
|
||||||
local oritargetfile = target:targetfile()
|
|
||||||
local oripdbfile = path.join(path.directory(oritargetfile), path.basename(oritargetfile) .. ".pdb")
|
|
||||||
|
|
||||||
os.mkdir(outputdir)
|
|
||||||
os.cp(oritargetfile, targetfile)
|
|
||||||
if os.isfile(oripdbfile) then
|
|
||||||
os.cp(oripdbfile, pdbfile)
|
|
||||||
end
|
|
||||||
os.cp(libfile, outputdir)
|
|
||||||
|
|
||||||
formattedmanifest = string_formatter(manifest, plugin_define)
|
|
||||||
io.writefile(manifestfile,formattedmanifest)
|
|
||||||
cprint("${bright green}[Plugin Packer]: ${reset}plugin already generated to " .. outputdir)
|
|
||||||
else
|
|
||||||
cprint("${bright yellow}warn: ${reset}not found manifest.json in root dir!")
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
return {
|
|
||||||
pack_plugin = pack_plugin,
|
|
||||||
beautify_json = beautify_json,
|
|
||||||
string_formatter = string_formatter
|
|
||||||
}
|
|
||||||
@@ -78,6 +78,7 @@ void Export_BinaryStream_API() {
|
|||||||
EXPORTAPI("writeItem", ItemStack*, bs->writeNetworkItemStackDescriptor(NetworkItemStackDescriptor(*value)));
|
EXPORTAPI("writeItem", ItemStack*, bs->writeNetworkItemStackDescriptor(NetworkItemStackDescriptor(*value)));
|
||||||
EXPORTAPI("writeString", std::string const&, bs->writeString(value));
|
EXPORTAPI("writeString", std::string const&, bs->writeString(value));
|
||||||
EXPORTAPI("writeCompoundTag", CompoundTag*, bs->writeCompoundTag(*value));
|
EXPORTAPI("writeCompoundTag", CompoundTag*, bs->writeCompoundTag(*value));
|
||||||
|
EXPORTAPI("writeUnsignedChar", uchar, bs->writeUnsignedChar(value));
|
||||||
EXPORTAPI2(writeBool);
|
EXPORTAPI2(writeBool);
|
||||||
EXPORTAPI2(writeByte);
|
EXPORTAPI2(writeByte);
|
||||||
EXPORTAPI2(writeDouble);
|
EXPORTAPI2(writeDouble);
|
||||||
@@ -86,7 +87,6 @@ void Export_BinaryStream_API() {
|
|||||||
EXPORTAPI2(writeSignedInt);
|
EXPORTAPI2(writeSignedInt);
|
||||||
EXPORTAPI2(writeSignedInt64);
|
EXPORTAPI2(writeSignedInt64);
|
||||||
EXPORTAPI2(writeSignedShort);
|
EXPORTAPI2(writeSignedShort);
|
||||||
EXPORTAPI2(writeUnsignedChar);
|
|
||||||
EXPORTAPI2(writeUnsignedInt);
|
EXPORTAPI2(writeUnsignedInt);
|
||||||
EXPORTAPI2(writeUnsignedInt64);
|
EXPORTAPI2(writeUnsignedInt64);
|
||||||
EXPORTAPI2(writeUnsignedShort);
|
EXPORTAPI2(writeUnsignedShort);
|
||||||
|
|||||||
@@ -492,6 +492,7 @@ void Export_Compatibility_API() {
|
|||||||
if (auto uce = UserCache::getInstance()->from(mce::UUID::fromString(uuid))) {
|
if (auto uce = UserCache::getInstance()->from(mce::UUID::fromString(uuid))) {
|
||||||
return uce->mName;
|
return uce->mName;
|
||||||
}
|
}
|
||||||
|
return "";
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "getNameByXuid", [](std::string const& xuid) -> std::string {
|
RemoteCall::exportAs("GMLIB_API", "getNameByXuid", [](std::string const& xuid) -> std::string {
|
||||||
if (auto uce = UserCache::getInstance()->from(xuid, UserCache::QueryType::Xuid)) {
|
if (auto uce = UserCache::getInstance()->from(xuid, UserCache::QueryType::Xuid)) {
|
||||||
@@ -558,7 +559,7 @@ void Export_Compatibility_API() {
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
RemoteCall::exportAs("GMLIB_API", "getBlockDestroySpeed", [](Block const* block) -> float {
|
RemoteCall::exportAs("GMLIB_API", "getBlockDestroySpeed", [](Block const* block) -> float {
|
||||||
return block->mDirectData->mUnkc08fbd.as<float>();
|
return block->mDirectData->mDestroySpeed;
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "getDestroyBlockSpeed", [](ItemStack const* item, Block const* block) -> float {
|
RemoteCall::exportAs("GMLIB_API", "getDestroyBlockSpeed", [](ItemStack const* item, Block const* block) -> float {
|
||||||
return item->getItem()->getDestroySpeed(*item, *block);
|
return item->getItem()->getDestroySpeed(*item, *block);
|
||||||
@@ -612,7 +613,7 @@ void Export_Compatibility_API() {
|
|||||||
"getBlockLightEmission",
|
"getBlockLightEmission",
|
||||||
[](std::string const& blockName, short legacyData) -> char {
|
[](std::string const& blockName, short legacyData) -> char {
|
||||||
return Block::tryGetFromRegistry(blockName)
|
return Block::tryGetFromRegistry(blockName)
|
||||||
.transform([](const Block& block) -> char { return block.mDirectData->mUnkda4e0e.as<char>(); })
|
.transform([](const Block& block) -> char { return block.mDirectData->mLightEmission->mValue; })
|
||||||
.value_or(-1);
|
.value_or(-1);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|||||||
+1
-1
@@ -22,7 +22,7 @@ bool LegacyRemoteCallApi::load() {
|
|||||||
logger->info(
|
logger->info(
|
||||||
"Loaded Version: {} with {}",
|
"Loaded Version: {} with {}",
|
||||||
fmt::format(fg(fmt::color::pink), "GMLIB-" GMLIB_FILE_VERSION_STRING),
|
fmt::format(fg(fmt::color::pink), "GMLIB-" GMLIB_FILE_VERSION_STRING),
|
||||||
fmt::format(fg(fmt::color::light_green), "GMLIB-LegacyRemoteCallApi-" + LIB_VERSION.to_string())
|
fmt::format(fg(fmt::color::light_green), "GMLIB-LegacyRemoteCallApi-{}", LIB_VERSION.to_string())
|
||||||
);
|
);
|
||||||
logger->info("Author: GroupMountain");
|
logger->info("Author: GroupMountain");
|
||||||
logger->info("Repository: https://github.com/GroupMountain/GMLIB-LegacyRemoteCallApi");
|
logger->info("Repository: https://github.com/GroupMountain/GMLIB-LegacyRemoteCallApi");
|
||||||
|
|||||||
+45
-54
@@ -162,12 +162,10 @@ void Export_Event_API() {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
case doHash("gmlib::PlayerStartSleepBeforeEvent"): {
|
case doHash("gmlib::PlayerStartSleepBeforeEvent"): {
|
||||||
REGISTER_EVENT_LISTEN(
|
REGISTER_EVENT_LISTEN(ila::mc::PlayerStartSleepBeforeEvent,
|
||||||
ila::mc::PlayerStartSleepBeforeEvent,
|
(Player * entity, BlockPos pos, bool isCancelled),
|
||||||
(Player * entity, BlockPos pos, bool isCancelled),
|
(&event.self(), event.pos(), event.isCancelled()),
|
||||||
(&event.self(), event.pos(), event.isCancelled()),
|
event.setCancelled(result););
|
||||||
event.setCancelled(result);
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
case doHash("gmlib::PlayerStartSleepAfterEvent"): {
|
case doHash("gmlib::PlayerStartSleepAfterEvent"): {
|
||||||
REGISTER_EVENT_LISTEN(
|
REGISTER_EVENT_LISTEN(
|
||||||
@@ -251,43 +249,36 @@ void Export_Event_API() {
|
|||||||
({event.pos(), event.blockSource().getDimensionId()}, event.isCancelled()),
|
({event.pos(), event.blockSource().getDimensionId()}, event.isCancelled()),
|
||||||
event.setCancelled(result););
|
event.setCancelled(result););
|
||||||
}
|
}
|
||||||
case doHash("gmlib::SpawnWanderingTraderAfterEvent"): {
|
case doHash("gmlib::HandleRequestActionBeforeEvent"): {
|
||||||
REGISTER_EVENT_LISTEN(
|
// clang-format off
|
||||||
ila::mc::SpawnWanderingTraderAfterEvent,
|
REGISTER_EVENT_LISTEN(
|
||||||
(std::pair<BlockPos, int> pos),
|
ila::mc::PlayerRequestItemActionBeforeEvent,
|
||||||
({event.pos(), event.blockSource().getDimensionId()}),
|
(
|
||||||
);
|
Player * player,
|
||||||
|
std::string const& actionType,
|
||||||
|
int count,
|
||||||
|
std::string const& sourceContainerNetId,
|
||||||
|
int sourceSlot,
|
||||||
|
std::string const& destinationContainerNetId,
|
||||||
|
int destinationSlot,
|
||||||
|
bool isCancelled
|
||||||
|
),
|
||||||
|
(
|
||||||
|
(Player*)&event.self(),
|
||||||
|
magic_enum::enum_name(event.actionType()).data(),
|
||||||
|
event.amount(),
|
||||||
|
magic_enum::enum_name(event.src().mFullContainerName.mName).data(),
|
||||||
|
(int)event.src().mSlot,
|
||||||
|
magic_enum::enum_name(event.dst().mFullContainerName.mName).data(),
|
||||||
|
(int)event.dst().mSlot,
|
||||||
|
event.isCancelled()
|
||||||
|
),
|
||||||
|
event.setCancelled(result);,
|
||||||
|
);
|
||||||
|
// clang-format on
|
||||||
}
|
}
|
||||||
case doHash("gmlib::HandleRequestActionBeforeEvent"): {
|
case doHash("gmlib::HandleRequestActionAfterEvent"): {
|
||||||
// clang-format off
|
// clang-format off
|
||||||
REGISTER_EVENT_LISTEN(
|
|
||||||
ila::mc::PlayerRequestItemActionBeforeEvent,
|
|
||||||
(
|
|
||||||
Player * player,
|
|
||||||
std::string const& actionType,
|
|
||||||
int count,
|
|
||||||
std::string const& sourceContainerNetId,
|
|
||||||
int sourceSlot,
|
|
||||||
std::string const& destinationContainerNetId,
|
|
||||||
int destinationSlot,
|
|
||||||
bool isCancelled
|
|
||||||
),
|
|
||||||
(
|
|
||||||
(Player*)&event.self(),
|
|
||||||
magic_enum::enum_name(event.actionType()).data(),
|
|
||||||
event.amount(),
|
|
||||||
magic_enum::enum_name(event.src().mFullContainerName.mName).data(),
|
|
||||||
(int)event.src().mSlot,
|
|
||||||
magic_enum::enum_name(event.dst().mFullContainerName.mName).data(),
|
|
||||||
(int)event.dst().mSlot,
|
|
||||||
event.isCancelled()
|
|
||||||
),
|
|
||||||
event.setCancelled(result);,
|
|
||||||
);
|
|
||||||
// clang-format on
|
|
||||||
}
|
|
||||||
case doHash("gmlib::HandleRequestActionAfterEvent"): {
|
|
||||||
// clang-format off
|
|
||||||
REGISTER_EVENT_LISTEN(
|
REGISTER_EVENT_LISTEN(
|
||||||
ila::mc::PlayerRequestItemActionAfterEvent,
|
ila::mc::PlayerRequestItemActionAfterEvent,
|
||||||
(
|
(
|
||||||
@@ -310,18 +301,18 @@ void Export_Event_API() {
|
|||||||
),
|
),
|
||||||
,
|
,
|
||||||
);
|
);
|
||||||
// clang-format on
|
// clang-format on
|
||||||
}
|
}
|
||||||
case doHash("gmlib::ContainerClosePacketSendAfterEvent"): {
|
case doHash("gmlib::ContainerClosePacketSendAfterEvent"): {
|
||||||
REGISTER_EVENT_LISTEN(
|
REGISTER_EVENT_LISTEN(
|
||||||
ila::mc::PlayerCloseContainerAfterEvent,
|
ila::mc::PlayerCloseContainerAfterEvent,
|
||||||
(Player * player, int containerId, bool serverInitiatedClose, bool),
|
(Player * player, int containerId, bool serverInitiatedClose, bool),
|
||||||
(&event.self(), (int)event.containerId(), event.serverInitiatedClose(), false),
|
(&event.self(), (int)event.containerId(), event.serverInitiatedClose(), false),
|
||||||
,
|
,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
+5
-5
@@ -2,7 +2,7 @@
|
|||||||
"format_version": 3,
|
"format_version": 3,
|
||||||
"format_uuid": "289f771f-2c9a-4d73-9f3f-8492495a924d",
|
"format_uuid": "289f771f-2c9a-4d73-9f3f-8492495a924d",
|
||||||
"tooth": "github.com/GroupMountain/GMLIB-LegacyRemoteCallApi",
|
"tooth": "github.com/GroupMountain/GMLIB-LegacyRemoteCallApi",
|
||||||
"version": "1.1.2",
|
"version": "1.4.0",
|
||||||
"info": {
|
"info": {
|
||||||
"name": "GMLIB-LegacyRemoteCallApi",
|
"name": "GMLIB-LegacyRemoteCallApi",
|
||||||
"description": "Legacy RemoteCall API for GMLIB",
|
"description": "Legacy RemoteCall API for GMLIB",
|
||||||
@@ -19,15 +19,15 @@
|
|||||||
{
|
{
|
||||||
"platform": "win-x64",
|
"platform": "win-x64",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"github.com/LiteLDev/LeviLamina": ">=1.2.0",
|
"github.com/LiteLDev/LeviLamina": ">=1.3.0",
|
||||||
"github.com/GroupMountain/GMLIB-Release": ">=1.2.0-rc.1",
|
"github.com/GroupMountain/GMLIB-Release": ">=1.3.0-rc.1",
|
||||||
"github.com/MiracleForest/iListenAttentively-Release": ">=0.5.0-rc.1"
|
"github.com/MiracleForest/iListenAttentively-Release": ">=0.6.0"
|
||||||
},
|
},
|
||||||
"assets": [
|
"assets": [
|
||||||
{
|
{
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"urls": [
|
"urls": [
|
||||||
"https://github.com/GroupMountain/GMLIB-LegacyRemoteCallApi/releases/download/v$(version)/GMLIB-LegacyRemoteCallApi-windows-x64.zip"
|
"https://{{tooth}}/releases/download/v{{version}}/GMLIB-LegacyRemoteCallApi-windows-x64.zip"
|
||||||
],
|
],
|
||||||
"placements": [
|
"placements": [
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -8,11 +8,11 @@ if not has_config("vs_runtime") then
|
|||||||
set_runtimes("MD")
|
set_runtimes("MD")
|
||||||
end
|
end
|
||||||
|
|
||||||
add_requires("levilamina 1.2.0", {configs = {target_type = "server"}})
|
add_requires("levilamina 1.4.1", {configs = {target_type = "server"}})
|
||||||
add_requires("legacyremotecall")
|
add_requires("legacyremotecall")
|
||||||
add_requires("levibuildscript")
|
add_requires("levibuildscript")
|
||||||
add_requires("ilistenattentively 0.5.0-rc.1")
|
add_requires("ilistenattentively 0.7.0")
|
||||||
add_requires("gmlib 1.2.0-rc.1")
|
add_requires("gmlib 1.4.0")
|
||||||
|
|
||||||
target("GMLIB-LegacyRemoteCallApi")
|
target("GMLIB-LegacyRemoteCallApi")
|
||||||
add_cxflags(
|
add_cxflags(
|
||||||
@@ -38,18 +38,15 @@ target("GMLIB-LegacyRemoteCallApi")
|
|||||||
"gmlib"
|
"gmlib"
|
||||||
)
|
)
|
||||||
add_rules("@levibuildscript/linkrule")
|
add_rules("@levibuildscript/linkrule")
|
||||||
|
add_rules("@levibuildscript/modpacker")
|
||||||
set_exceptions("none")
|
set_exceptions("none")
|
||||||
set_kind("shared")
|
set_kind("shared")
|
||||||
set_languages("cxx20")
|
set_languages("cxx20")
|
||||||
set_symbols("debug")
|
set_symbols("debug")
|
||||||
|
|
||||||
after_build(function (target)
|
after_build(function (target)
|
||||||
local plugin_packer = import("scripts.after_build")
|
local target_path = path.join("bin", target:name(), "lib")
|
||||||
|
if os.exists(target_path) then
|
||||||
local plugin_define = {
|
os.rm(target_path)
|
||||||
pluginName = target:name(),
|
end
|
||||||
pluginFile = path.filename(target:targetfile()),
|
os.cp("lib", target_path)
|
||||||
}
|
|
||||||
|
|
||||||
plugin_packer.pack_plugin(target,plugin_define)
|
|
||||||
end)
|
end)
|
||||||
Reference in New Issue
Block a user