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