Compare commits
2 Commits
+48
-45
@@ -1,51 +1,54 @@
|
||||
/**
|
||||
* @returns {string}
|
||||
*/
|
||||
const getPluginName = () => {
|
||||
// quickjs
|
||||
try {
|
||||
throw new Error("getPluginName");
|
||||
} catch (error) {
|
||||
const /** @type {string} */ line = error.stack.trim().split("\n").pop().trim();
|
||||
if (line.includes("<anonymous>")) {
|
||||
return line.slice(
|
||||
line.indexOf("(") + 1,
|
||||
line.indexOf("\\")
|
||||
);
|
||||
}
|
||||
if (line.includes("<eval>")) {
|
||||
return line.slice(
|
||||
line.indexOf("/", line.indexOf("/") + 1) + 1,
|
||||
line.indexOf("\\")
|
||||
);
|
||||
}
|
||||
}
|
||||
if (getPluginName.PluginNameCache) return getPluginName.PluginNameCache;
|
||||
|
||||
// nodejs
|
||||
try {
|
||||
const path = require('path');
|
||||
const selfFileName = path.basename(__filename);
|
||||
const pluginDirectory = Object.entries(
|
||||
require('module')._pathCache
|
||||
).find(
|
||||
([key, _]) =>
|
||||
key.includes(selfFileName)
|
||||
)[0].split("\u0000")[1];
|
||||
const directories = pluginDirectory.split("\\");
|
||||
const pluginName = directories[directories.findIndex(value => value === "plugins") + 1].trim();
|
||||
if (pluginName) return pluginName;
|
||||
} catch { }
|
||||
try {
|
||||
throw new Error("getPluginName");
|
||||
} catch (error) {
|
||||
const /** @type {string} */ line = error.stack.trim().split("\n").pop().trim();
|
||||
if (line.includes(".js") && /:\d+:\d+$/.test(line)) {
|
||||
const directories = line.split("\\");
|
||||
const pluginName = directories[directories.findIndex(value => value === "plugins") + 1].trim();
|
||||
if (pluginName) return pluginName;
|
||||
return getPluginName.PluginNameCache = (() => {
|
||||
if (ll.getCurrentPluginInfo) return ll.getCurrentPluginInfo().name;
|
||||
|
||||
const error = new Error("getPluginName");
|
||||
switch (ll.scriptEngineVersion) {
|
||||
case "QuickJS": {
|
||||
if (!error.stack) break;
|
||||
const /** @type {string} */ line = error.stack.trim().split("\n").pop().trim();
|
||||
if (line.includes("<anonymous>")) {
|
||||
return line.slice(
|
||||
line.indexOf("(") + 1,
|
||||
line.indexOf("\\")
|
||||
);
|
||||
}
|
||||
if (line.includes("<eval>")) {
|
||||
return line.slice(
|
||||
line.indexOf("/", line.indexOf("/") + 1) + 1,
|
||||
line.indexOf("\\")
|
||||
);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "V8 12.4.254.21-node.21": {
|
||||
try {
|
||||
const selfFileName = require('path').basename(__filename);
|
||||
const pluginDirectory = Object.entries(
|
||||
require('module')._pathCache
|
||||
).find(
|
||||
([key, _]) => key.includes(selfFileName)
|
||||
)[0].split("\u0000")[1];
|
||||
const directories = pluginDirectory.split("\\");
|
||||
const pluginName = directories[directories.findIndex(value => value === "plugins") + 1].trim();
|
||||
if (pluginName) return pluginName;
|
||||
} catch { }
|
||||
|
||||
if (!error.stack) break;
|
||||
const /** @type {string} */ line = error.stack.trim().split("\n").pop().trim();
|
||||
if (line.includes(".js") && /:\d+:\d+$/.test(line)) {
|
||||
const directories = line.split("\\");
|
||||
const pluginName = directories[directories.findIndex(value => value === "plugins") + 1].trim();
|
||||
if (pluginName) return pluginName;
|
||||
}
|
||||
break;
|
||||
}
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
return "Unknown";
|
||||
return "Unknown";
|
||||
})();
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
|
||||
+48
-42
@@ -1,50 +1,56 @@
|
||||
/// <reference path='d:/dts/dts/helperlib/src/index.d.ts'/>
|
||||
|
||||
const getPluginName = () => {
|
||||
// quickjs
|
||||
try {
|
||||
throw new Error("getPluginName");
|
||||
} catch (error) {
|
||||
const /** @type {string} */ line = error.stack.trim().split("\n").pop().trim();
|
||||
if (line.includes("<anonymous>")) {
|
||||
return line.slice(
|
||||
line.indexOf("(") + 1,
|
||||
line.indexOf("\\")
|
||||
);
|
||||
}
|
||||
if (line.includes("<eval>")) {
|
||||
return line.slice(
|
||||
line.indexOf("/", line.indexOf("/") + 1) + 1,
|
||||
line.indexOf("\\")
|
||||
);
|
||||
}
|
||||
}
|
||||
if (getPluginName.PluginNameCache) return getPluginName.PluginNameCache;
|
||||
|
||||
// nodejs
|
||||
try {
|
||||
const path = require('path');
|
||||
const selfFileName = path.basename(__filename);
|
||||
const pluginDirectory = Object.entries(
|
||||
require('module')._pathCache
|
||||
).find(
|
||||
([key, _]) =>
|
||||
key.includes(selfFileName)
|
||||
)[0].split("\u0000")[1];
|
||||
const directories = pluginDirectory.split("\\");
|
||||
const pluginName = directories[directories.findIndex(value => value === "plugins") + 1].trim();
|
||||
if (pluginName) return pluginName;
|
||||
} catch { }
|
||||
try {
|
||||
throw new Error("getPluginName");
|
||||
} catch (error) {
|
||||
const /** @type {string} */ line = error.stack.trim().split("\n").pop().trim();
|
||||
if (line.includes(".js") && /:\d+:\d+$/.test(line)) {
|
||||
const directories = line.split("\\");
|
||||
const pluginName = directories[directories.findIndex(value => value === "plugins") + 1].trim();
|
||||
if (pluginName) return pluginName;
|
||||
return getPluginName.PluginNameCache = (() => {
|
||||
if (ll.getCurrentPluginInfo) return ll.getCurrentPluginInfo().name;
|
||||
|
||||
const error = new Error("getPluginName");
|
||||
switch (ll.scriptEngineVersion) {
|
||||
case "QuickJS": {
|
||||
if (!error.stack) break;
|
||||
const /** @type {string} */ line = error.stack.trim().split("\n").pop().trim();
|
||||
if (line.includes("<anonymous>")) {
|
||||
return line.slice(
|
||||
line.indexOf("(") + 1,
|
||||
line.indexOf("\\")
|
||||
);
|
||||
}
|
||||
if (line.includes("<eval>")) {
|
||||
return line.slice(
|
||||
line.indexOf("/", line.indexOf("/") + 1) + 1,
|
||||
line.indexOf("\\")
|
||||
);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "V8 12.4.254.21-node.21": {
|
||||
try {
|
||||
const selfFileName = require('path').basename(__filename);
|
||||
const pluginDirectory = Object.entries(
|
||||
require('module')._pathCache
|
||||
).find(
|
||||
([key, _]) => key.includes(selfFileName)
|
||||
)[0].split("\u0000")[1];
|
||||
const directories = pluginDirectory.split("\\");
|
||||
const pluginName = directories[directories.findIndex(value => value === "plugins") + 1].trim();
|
||||
if (pluginName) return pluginName;
|
||||
} catch { }
|
||||
|
||||
if (!error.stack) break;
|
||||
const /** @type {string} */ line = error.stack.trim().split("\n").pop().trim();
|
||||
if (line.includes(".js") && /:\d+:\d+$/.test(line)) {
|
||||
const directories = line.split("\\");
|
||||
const pluginName = directories[directories.findIndex(value => value === "plugins") + 1].trim();
|
||||
if (pluginName) return pluginName;
|
||||
}
|
||||
break;
|
||||
}
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
return "Unknown";
|
||||
return "Unknown";
|
||||
})();
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
|
||||
@@ -14,6 +14,9 @@
|
||||
},
|
||||
{
|
||||
"name": "iListenAttentively"
|
||||
},
|
||||
{
|
||||
"name": "ModAPI"
|
||||
}
|
||||
]
|
||||
}
|
||||
+11
-15
@@ -11,7 +11,7 @@ void Export_Compatibility_API() {
|
||||
return CustomRecipeRegistry::getInstance().unregisterRecipe(id, true);
|
||||
});
|
||||
RemoteCall::exportAs("GMLIB_API", "setCustomPackPath", [](std::string const& path) -> void {
|
||||
AddonsLoader::addCustomPackPath(path);
|
||||
AddonsLoader::getInstance().addCustomPackPath(path);
|
||||
});
|
||||
RemoteCall::exportAs("GMLIB_API", "getServerMspt", []() -> double {
|
||||
return GMLevel::getInstance().transform(
|
||||
@@ -19,14 +19,10 @@ void Export_Compatibility_API() {
|
||||
).value_or(0.0);
|
||||
});
|
||||
RemoteCall::exportAs("GMLIB_API", "getServerCurrentTps", []() -> float {
|
||||
return GMLevel::getInstance().transform(
|
||||
[](GMLevel& level) -> float { return level.getServerCurrentTps(); }
|
||||
).value_or(0.0);
|
||||
return TpsStatus::getInstance().getLevelCurrentTps();
|
||||
});
|
||||
RemoteCall::exportAs("GMLIB_API", "getServerAverageTps", []() -> double {
|
||||
return GMLevel::getInstance().transform(
|
||||
[](GMLevel& level) -> double { return level.getServerAverageTps(); }
|
||||
).value_or(0.0);
|
||||
return TpsStatus::getInstance().getLevelAverageTps();
|
||||
});
|
||||
RemoteCall::exportAs("GMLIB_API", "getAllPlayerUuids", []() -> std::vector<std::string> {
|
||||
std::vector<std::string> result;
|
||||
@@ -534,7 +530,7 @@ void Export_Compatibility_API() {
|
||||
.value_or(0);
|
||||
});
|
||||
RemoteCall::exportAs("GMLIB_API", "getBlockTranslateKey", [](Block const* block) -> std::string {
|
||||
return block->getLegacyBlock().mDescriptionId.get() + ".name";
|
||||
return block->mBlockType->mDescriptionId.get() + ".name";
|
||||
});
|
||||
RemoteCall::exportAs("GMLIB_API", "getItemTranslateKey", [](ItemStack* item) -> std::string {
|
||||
return item->getDescriptionId();
|
||||
@@ -573,7 +569,7 @@ void Export_Compatibility_API() {
|
||||
}
|
||||
);
|
||||
RemoteCall::exportAs("GMLIB_API", "itemCanDestroyBlock", [](ItemStack const* item, Block const* block) -> bool {
|
||||
return std::ranges::any_of(item->mCanDestroy, [block](BlockLegacy const* blockLegacy) {
|
||||
return std::ranges::any_of(item->mCanDestroy, [block](BlockType const* blockLegacy) {
|
||||
return blockLegacy && block->getTypeName() == blockLegacy->getTypeName();
|
||||
});
|
||||
});
|
||||
@@ -590,13 +586,13 @@ void Export_Compatibility_API() {
|
||||
return false;
|
||||
});
|
||||
RemoteCall::exportAs("GMLIB_API", "blockCanDropWithAnyTool", [](Block const* block) -> bool {
|
||||
return !block->getLegacyBlock().mRequiresCorrectToolForDrops;
|
||||
return !block->mBlockType->mRequiresCorrectToolForDrops;
|
||||
});
|
||||
RemoteCall::exportAs(
|
||||
"GMLIB_API",
|
||||
"blockPlayerWillDestroy",
|
||||
[](Block const* block, Player* player, std::pair<BlockPos, int> pos) -> bool {
|
||||
return block->getLegacyBlock().playerWillDestroy(*player, pos.first, *block);
|
||||
return block->mBlockType->playerWillDestroy(*player, pos.first, *block);
|
||||
}
|
||||
);
|
||||
RemoteCall::exportAs("GMLIB_API", "playerAttack", [](Player* player, Actor* entity) -> bool {
|
||||
@@ -745,9 +741,9 @@ void Export_Compatibility_API() {
|
||||
"GMLIB_API",
|
||||
"setItemCanDestroy",
|
||||
[](ItemStack const* item, std::vector<std::string> blocks) -> void {
|
||||
std::vector<const BlockLegacy*> data;
|
||||
std::vector<const BlockType*> data;
|
||||
for (auto& name : blocks) {
|
||||
if (auto block = BlockLegacy::tryGetFromRegistry(name)) {
|
||||
if (auto block = BlockType::tryGetFromRegistry(name)) {
|
||||
data.push_back(block.as_ptr());
|
||||
}
|
||||
}
|
||||
@@ -765,9 +761,9 @@ void Export_Compatibility_API() {
|
||||
"GMLIB_API",
|
||||
"setItemCanPlaceOn",
|
||||
[](ItemStack const* item, std::vector<std::string> blocks) -> void {
|
||||
std::vector<const BlockLegacy*> data;
|
||||
std::vector<const BlockType*> data;
|
||||
for (auto& name : blocks) {
|
||||
if (auto block = BlockLegacy::tryGetFromRegistry(name)) {
|
||||
if (auto block = BlockType::tryGetFromRegistry(name)) {
|
||||
data.push_back(block.as_ptr());
|
||||
}
|
||||
}
|
||||
|
||||
+3
-2
@@ -216,10 +216,11 @@ void Export_Event_API() {
|
||||
);
|
||||
}
|
||||
case doHash("gmlib::EndermanTakeBlockBeforeEvent"): {
|
||||
REGISTER_EVENT_LISTEN(ila::mc::EndermanTakeBlockBeforeEvent,
|
||||
REGISTER_EVENT_LISTEN(ila::mc::MobTakeBlockBeforeEvent,
|
||||
(Actor * mob, bool isCancelled),
|
||||
(&event.self(), event.isCancelled()),
|
||||
event.setCancelled(result););
|
||||
event.setCancelled(result);
|
||||
, if (!event.self().isType(ActorType::EnderMan)) return;);
|
||||
}
|
||||
case doHash("gmlib::DragonRespawnBeforeEvent"): {
|
||||
REGISTER_EVENT_LISTEN(ila::mc::DragonRespawnBeforeEvent,
|
||||
|
||||
+12
-4
@@ -2,12 +2,20 @@
|
||||
// clang-format off
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable : 4996)
|
||||
#define GMLIB_GLOBAL_USING
|
||||
#include <gmlib/GlobalUsing.h>
|
||||
#include <gmlib/include_all.h>
|
||||
#pragma include_alias("mc/world/item/HumanoidArmorItem.h", "modapi/item/types/mc/HumanoidArmorItem.h")
|
||||
#include <gmlib/include_ll.h>
|
||||
#include <gmlib/include_lib.h>
|
||||
#include <gmlib/include_mc.h>
|
||||
#include <ila/include_all.h>
|
||||
#include <modapi/addons/AddonsLoader.h>
|
||||
#include <modapi/recipe/CustomRecipeRegistry.h>
|
||||
#include <modapi/item/CustomItemRegistry.h>
|
||||
#include <RemoteCallAPI.h>
|
||||
using namespace gmlib::mod;
|
||||
using namespace gmlib;
|
||||
using namespace gmlib::ui;
|
||||
using namespace gmlib::i18n;
|
||||
using namespace gmlib::memory;
|
||||
using namespace modapi;
|
||||
#pragma warning(pop)
|
||||
// clang-format on
|
||||
|
||||
|
||||
+4
-3
@@ -2,7 +2,7 @@
|
||||
"format_version": 3,
|
||||
"format_uuid": "289f771f-2c9a-4d73-9f3f-8492495a924d",
|
||||
"tooth": "github.com/GroupMountain/GMLIB-LegacyRemoteCallApi",
|
||||
"version": "1.4.1",
|
||||
"version": "1.5.1",
|
||||
"info": {
|
||||
"name": "GMLIB-LegacyRemoteCallApi",
|
||||
"description": "Legacy RemoteCall API for GMLIB",
|
||||
@@ -19,8 +19,9 @@
|
||||
{
|
||||
"platform": "win-x64",
|
||||
"dependencies": {
|
||||
"github.com/LiteLDev/LeviLamina": ">=1.3.0",
|
||||
"github.com/GroupMountain/GMLIB-Release": ">=1.3.0-rc.1",
|
||||
"github.com/LiteLDev/LeviLamina": ">=1.5.0",
|
||||
"github.com/GroupMountain/GMLIB-Release": ">=1.5.2",
|
||||
"github.com/GroupMountain/ModAPI-Release": ">=0.1.0",
|
||||
"github.com/MiracleForest/iListenAttentively-Release": ">=0.6.0"
|
||||
},
|
||||
"assets": [
|
||||
|
||||
@@ -8,11 +8,12 @@ if not has_config("vs_runtime") then
|
||||
set_runtimes("MD")
|
||||
end
|
||||
|
||||
add_requires("levilamina 1.4.1", {configs = {target_type = "server"}})
|
||||
add_requires("levilamina 1.5.2", {configs = {target_type = "server"}})
|
||||
add_requires("legacyremotecall")
|
||||
add_requires("levibuildscript")
|
||||
add_requires("ilistenattentively 0.7.0")
|
||||
add_requires("gmlib 1.4.3")
|
||||
add_requires("levibuildscript 0.5.2")
|
||||
add_requires("ilistenattentively 0.8.0")
|
||||
add_requires("gmlib 1.5.2")
|
||||
add_requires("modapi 0.1.1")
|
||||
|
||||
target("GMLIB-LegacyRemoteCallApi")
|
||||
add_cxflags(
|
||||
@@ -35,7 +36,8 @@ target("GMLIB-LegacyRemoteCallApi")
|
||||
"levilamina",
|
||||
"legacyremotecall",
|
||||
"ilistenattentively",
|
||||
"gmlib"
|
||||
"gmlib",
|
||||
"modapi"
|
||||
)
|
||||
add_rules("@levibuildscript/linkrule")
|
||||
add_rules("@levibuildscript/modpacker")
|
||||
|
||||
Reference in New Issue
Block a user