Compare commits
4 Commits
Vendored
+3
-3
@@ -12,7 +12,7 @@ export class PAPI {
|
||||
pluginsName: string,
|
||||
/** PAPI变量 */
|
||||
PAPIName: string
|
||||
): boolean;
|
||||
): void;
|
||||
|
||||
/** 注册一个服务器PAPI变量 */
|
||||
static registerServerPlaceholder(
|
||||
@@ -25,7 +25,7 @@ export class PAPI {
|
||||
pluginsName: string,
|
||||
/** PAPI变量 */
|
||||
PAPIName: string
|
||||
): boolean;
|
||||
): void;
|
||||
|
||||
/** 注册一个静态PAPI变量 */
|
||||
static registerStaticPlaceholder(
|
||||
@@ -37,7 +37,7 @@ export class PAPI {
|
||||
PAPIName: string,
|
||||
/** 更新时间 */
|
||||
UpdateInterval: number
|
||||
): boolean;
|
||||
): void;
|
||||
|
||||
/** 获取一个服务器变量的值 */
|
||||
static getValue(
|
||||
|
||||
@@ -59,7 +59,7 @@ class PAPI {
|
||||
*/
|
||||
static registerPlayerPlaceholder(func, PluginName, PAPIName) {
|
||||
ll.export(func, PluginName, func.getName());
|
||||
return PlaceholderAPI.registerPlayerPlaceholderAPI(PluginName, func.getName(), PAPIName);
|
||||
PlaceholderAPI.registerPlayerPlaceholderAPI(PluginName, func.getName(), PAPIName);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -71,7 +71,7 @@ class PAPI {
|
||||
*/
|
||||
static registerServerPlaceholder(func, PluginName, PAPIName) {
|
||||
ll.export(func, PluginName, func.getName());
|
||||
return PlaceholderAPI.registerServerPlaceholderAPI(PluginName, func.getName(), PAPIName);
|
||||
PlaceholderAPI.registerServerPlaceholderAPI(PluginName, func.getName(), PAPIName);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -84,7 +84,7 @@ class PAPI {
|
||||
*/
|
||||
static registerStaticPlaceholder(func, PluginName, PAPIName, UpdateInterval = 50) {
|
||||
ll.export(func, PluginName, func.getName());
|
||||
return PlaceholderAPI.registerStaticPlaceholderAPI(PluginName, func.getName(), PAPIName, UpdateInterval);
|
||||
PlaceholderAPI.registerStaticPlaceholderAPI(PluginName, func.getName(), PAPIName, UpdateInterval);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+3
-1
@@ -5,7 +5,9 @@ const getPluginName = () => {
|
||||
try {
|
||||
throw new Error("getPluginName");
|
||||
} catch (error) {
|
||||
return error.stack.trim().match(/plugins\\(.*)\\.*\.js:[0-9]+\)$/i)?.[1] || "Unknown";
|
||||
return error.stack.trim().match(/plugins\\(.*)\\.*\.js:[0-9]+\)$/i)?.[1]
|
||||
|| error.stack.trim().match(/at <anonymous> \(([^\\|/]+)(.*?):\d+:\d+\)$/i)?.[1]
|
||||
|| "Unknown";
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Vendored
+42
@@ -0,0 +1,42 @@
|
||||
/** 翻译带PAPI变量文本 */
|
||||
export function translate(
|
||||
/** 要翻译的文本 */
|
||||
value: String,
|
||||
/** 实体对象 */
|
||||
actor?: Entity,
|
||||
/** 目标翻译语言 */
|
||||
language?: String
|
||||
): String;
|
||||
|
||||
/** 注册PAPI变量 */
|
||||
export function registerPlaceholder(
|
||||
/** papi变量 */
|
||||
placeholder: String,
|
||||
/** 回调 */
|
||||
callback: (
|
||||
/** 实体对象 */ actor: Entity,
|
||||
/** 参数 */ params: String[],
|
||||
/** 目标翻译语言 */language: String
|
||||
) => String | undefined
|
||||
): void;
|
||||
|
||||
/** 注销PAPI变量 */
|
||||
export function unregisterPlaceholder(
|
||||
/** papi变量 */
|
||||
placeholder: String
|
||||
): Boolean;
|
||||
|
||||
/** 根据模组名注销PAPI变量 */
|
||||
export function unregisterPlaceholderFromModName(
|
||||
/** 模组名 */
|
||||
modName: String
|
||||
): Boolean;
|
||||
|
||||
/** 获取一个papi变量的值 */
|
||||
export function getValue(
|
||||
/** papi变量名 */
|
||||
placeholder: String,
|
||||
actor?: Entity,
|
||||
params?: Record<String, String>,
|
||||
language?: string
|
||||
): Boolean;
|
||||
@@ -0,0 +1,65 @@
|
||||
/// <reference path='d:/dts/dts/helperlib/src/index.d.ts'/>
|
||||
|
||||
const getPluginName = () => {
|
||||
try {
|
||||
throw new Error("getPluginName");
|
||||
} catch (error) {
|
||||
return error.stack.trim().match(/plugins\\(.*)\\.*\.js:[0-9]+\)$/i)?.[1]
|
||||
|| error.stack.trim().match(/at <anonymous> \(([^\\|/]+)(.*?):\d+:\d+\)$/i)?.[1]
|
||||
|| "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 = {
|
||||
translate(value, actor = undefined, language = "") {
|
||||
return actor instanceof LLSE_Entity
|
||||
? ll.imports("PlaceholderAPI", "translateFromActor")(value, actor, language)
|
||||
: ll.imports("PlaceholderAPI", "translate")(value, language);
|
||||
},
|
||||
registerPlaceholder(placeholder, callback) {
|
||||
const pluginName = getPluginName();
|
||||
ll.exports((...args) => {
|
||||
if(!args[0].uniqueId) args[0] = undefined;
|
||||
return callback(...args) ?? "<std::nullopt>";
|
||||
}, pluginName, callback.getName());
|
||||
ll.imports("PlaceholderAPI", "registerPlaceholder")(placeholder, callback.getName(), pluginName);
|
||||
},
|
||||
unregisterPlaceholder(placeholder) {
|
||||
return ll.imports("PlaceholderAPI", "unregisterPlaceholder")(placeholder);
|
||||
},
|
||||
unregisterPlaceholderFromModName(placeholder) {
|
||||
return ll.imports("PlaceholderAPI", "unregisterPlaceholderFromModName")(placeholder);
|
||||
},
|
||||
getValue(placeholder, actor = undefined, params = {}, language = "") {
|
||||
if (actor instanceof LLSE_Player) actor = ll.import("GMLib_ServerAPI", "PlayerToEntity")(actor);
|
||||
const result = actor instanceof LLSE_Entity
|
||||
? ll.imports("PlaceholderAPI", "getValueFromActor")(placeholder, actor, params, language)
|
||||
: ll.imports("PlaceholderAPI", "getValue")(placeholder, params, language);
|
||||
return result !== "<std::nullopt>" ? result : undefined;
|
||||
}
|
||||
};
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "${pluginName}",
|
||||
"entry": "${pluginFile}",
|
||||
"version": "0.13.6",
|
||||
"version": "1.0.0-rc.1",
|
||||
"author": "GroupMountain",
|
||||
"type": "native",
|
||||
"passive": true,
|
||||
|
||||
+15
-8
@@ -1,15 +1,16 @@
|
||||
#include "Global.h"
|
||||
using namespace ll::hash_utils;
|
||||
#include <gmlib/mc/network/BinaryStream.h>
|
||||
#include <mc/world/item/NetworkItemStackDescriptor.h>
|
||||
|
||||
class LegacyScriptBinaryStreamManager {
|
||||
private:
|
||||
int64 mNextBinaryStreamId = 0;
|
||||
std::unordered_map<uint64, std::shared_ptr<GMLIB_BinaryStream>> mBinaryStream;
|
||||
std::unordered_map<uint64, std::shared_ptr<GMBinaryStream>> mBinaryStream;
|
||||
|
||||
public:
|
||||
uint getNextId() { return mNextBinaryStreamId++; }
|
||||
|
||||
void cretateBinaryStream(uint id) { mBinaryStream[id] = std::make_shared<GMLIB_BinaryStream>(); }
|
||||
void cretateBinaryStream(uint id) { mBinaryStream[id] = std::make_shared<GMBinaryStream>(); }
|
||||
|
||||
uint64 copyBinaryStream(uint id) {
|
||||
auto nextId = getNextId();
|
||||
@@ -22,7 +23,7 @@ public:
|
||||
|
||||
void removeBinaryStream(uint64 id) { mBinaryStream.erase(id); }
|
||||
|
||||
std::shared_ptr<GMLIB_BinaryStream> getBinaryStream(uint64 id) {
|
||||
std::shared_ptr<GMBinaryStream> getBinaryStream(uint64 id) {
|
||||
return mBinaryStream.contains(id) ? mBinaryStream.at(id) : nullptr;
|
||||
}
|
||||
|
||||
@@ -47,7 +48,7 @@ template <typename T, typename R, typename A, typename... AS>
|
||||
struct Info<R (T::*)(A, AS...)> {
|
||||
using ArgT = A;
|
||||
};
|
||||
#define EXPORTAPI2(T) EXPORTAPI(#T, Info<decltype(&GMLIB_BinaryStream::T)>::ArgT, bs->T(value))
|
||||
#define EXPORTAPI2(T) EXPORTAPI(#T, Info<decltype(&BinaryStream::T)>::ArgT, bs->T(value))
|
||||
|
||||
void Export_BinaryStream_API() {
|
||||
RemoteCall::exportAs("GMLIB_BinaryStream_API", "create", []() -> uint64 {
|
||||
@@ -60,17 +61,23 @@ void Export_BinaryStream_API() {
|
||||
});
|
||||
RemoteCall::exportAs("GMLIB_BinaryStream_API", "reset", [](uint64 id) -> void {
|
||||
if (BinaryStreamManager.getBinaryStream(id) == nullptr) BinaryStreamManager.cretateBinaryStream(id);
|
||||
else BinaryStreamManager.getBinaryStream(id)->reset();
|
||||
else {
|
||||
auto bs = BinaryStreamManager.getBinaryStream(id);
|
||||
bs->mBuffer.clear();
|
||||
bs->mReadPointer = 0;
|
||||
bs->mHasOverflowed = false;
|
||||
}
|
||||
});
|
||||
RemoteCall::exportAs("GMLIB_BinaryStream_API", "sendTo", [](uint64 id, Player* player) -> void {
|
||||
if (auto bs = BinaryStreamManager.getBinaryStream(id); bs != nullptr) bs->sendTo(*player);
|
||||
if (auto bs = BinaryStreamManager.getBinaryStream(id); bs != nullptr)
|
||||
bs->sendTo(static_cast<GMPlayer&>(*player));
|
||||
});
|
||||
RemoteCall::exportAs("GMLIB_BinaryStream_API", "destroy", [](uint64 id) -> void {
|
||||
BinaryStreamManager.removeBinaryStream(id);
|
||||
});
|
||||
EXPORTAPI("writePacketHeader", int, bs->writePacketHeader((MinecraftPacketIds)value));
|
||||
EXPORTAPI("writeUuid", std::string const&, bs->writeUuid(mce::UUID::fromString(value)));
|
||||
EXPORTAPI("writeItem", ItemStack*, bs->writeType(NetworkItemStackDescriptor(*value)));
|
||||
EXPORTAPI("writeItem", ItemStack*, bs->writeNetworkItemStackDescriptor(NetworkItemStackDescriptor(*value)));
|
||||
EXPORTAPI("writeString", std::string const&, bs->writeString(value));
|
||||
EXPORTAPI("writeCompoundTag", CompoundTag*, bs->writeCompoundTag(*value));
|
||||
EXPORTAPI2(writeBool);
|
||||
|
||||
+284
-229
File diff suppressed because it is too large
Load Diff
+8
-3
@@ -13,15 +13,15 @@ bool LegacyRemoteCallApi::load() {
|
||||
Export_Legacy_GMLib_ServerAPI();
|
||||
Export_Compatibility_API();
|
||||
ExportPAPI();
|
||||
Export_Event_API();
|
||||
// Export_Event_API();
|
||||
Export_BinaryStream_API();
|
||||
// Export_Form_API();
|
||||
auto logger = ll::io::LoggerRegistry::getInstance().getOrCreate(PLUGIN_NAME);
|
||||
logger->info("GMLIB-LegacyRemoteCallApi Loaded!");
|
||||
logger->info(
|
||||
"Loaded Version: {} with {}",
|
||||
fmt::format(fg(fmt::color::pink), "GMLIB-" + GMLIB::Version::getLibVersionString()),
|
||||
fmt::format(fg(fmt::color::light_green), "GMLIB-LegacyRemoteCallApi-" + LIB_VERSION.asString())
|
||||
fmt::format(fg(fmt::color::pink), "GMLIB-" GMLIB_FILE_VERSION_STRING),
|
||||
fmt::format(fg(fmt::color::light_green), "GMLIB-LegacyRemoteCallApi-" + LIB_VERSION.to_string())
|
||||
);
|
||||
logger->info("Author: GroupMountain");
|
||||
logger->info("Repository: https://github.com/GroupMountain/GMLIB-LegacyRemoteCallApi");
|
||||
@@ -35,3 +35,8 @@ bool LegacyRemoteCallApi::disable() { return true; }
|
||||
} // namespace gmlib
|
||||
|
||||
LL_REGISTER_MOD(gmlib::LegacyRemoteCallApi, gmlib::LegacyRemoteCallApi::getInstance());
|
||||
|
||||
|
||||
ll::thread::ThreadPoolExecutor const& getThreadPoolExecutor() {
|
||||
return gmlib::LegacyRemoteCallApi::getInstance().getThreadPoolExecutor();
|
||||
}
|
||||
+5
-1
@@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
#include <ll/api/mod/NativeMod.h>
|
||||
#include <ll/api/mod/RegisterHelper.h>
|
||||
#include <ll/api/thread/ThreadPoolExecutor.h>
|
||||
|
||||
namespace gmlib {
|
||||
|
||||
@@ -9,7 +10,7 @@ class LegacyRemoteCallApi {
|
||||
public:
|
||||
static LegacyRemoteCallApi& getInstance();
|
||||
|
||||
LegacyRemoteCallApi() : mSelf(*ll::mod::NativeMod::current()) {}
|
||||
LegacyRemoteCallApi() : mSelf(*ll::mod::NativeMod::current()), mThreadPoolExecutor(getSelf().getName()) {}
|
||||
|
||||
[[nodiscard]] ll::mod::NativeMod& getSelf() const { return mSelf; }
|
||||
|
||||
@@ -26,8 +27,11 @@ public:
|
||||
// /// @return True if the plugin is unloaded successfully.
|
||||
// bool unload();
|
||||
|
||||
ll::thread::ThreadPoolExecutor& getThreadPoolExecutor() { return mThreadPoolExecutor; }
|
||||
|
||||
private:
|
||||
ll::mod::NativeMod& mSelf;
|
||||
ll::thread::ThreadPoolExecutor mThreadPoolExecutor;
|
||||
};
|
||||
|
||||
} // namespace gmlib
|
||||
|
||||
+170
-173
@@ -83,152 +83,149 @@ void Export_Event_API() {
|
||||
}
|
||||
case doHash("gmlib::ClientLoginAfterEvent"): {
|
||||
REGISTER_EVENT_LISTEN(
|
||||
GMLIB::Event::PacketEvent::ClientLoginAfterEvent,
|
||||
ila::mc::ClientLoginAfterEvent,
|
||||
(std::string const& realName,
|
||||
std::string const& uuid,
|
||||
std::string const& serverXuid,
|
||||
std::string const& clientXuid),
|
||||
(event.getRealName(),
|
||||
event.getUuid().asString(),
|
||||
event.getServerAuthXuid(),
|
||||
event.getClientAuthXuid()),
|
||||
(event.realName(),
|
||||
event.uuid().asString(),
|
||||
event.serverAuthXuid(),
|
||||
event.clientAuthXuid()),
|
||||
if (result) event.disConnectClient();
|
||||
);
|
||||
}
|
||||
case doHash("gmlib::WeatherUpdateBeforeEvent"): {
|
||||
REGISTER_EVENT_LISTEN(
|
||||
GMLIB::Event::LevelEvent::WeatherUpdateBeforeEvent,
|
||||
ila::mc::WeatherUpdateBeforeEvent,
|
||||
(float rainLevel, int rainTime, float lightningLevel, int lightningTime, bool isCancelled),
|
||||
(event.getRainLevel(),
|
||||
event.getRainingLastTick(),
|
||||
event.getLightningLevel(),
|
||||
event.getLightningLastTick(),
|
||||
(event.rainLevel(),
|
||||
event.rainTime(),
|
||||
event.lightningLevel(),
|
||||
event.lightningTime(),
|
||||
event.isCancelled()),
|
||||
event.setCancelled(result);
|
||||
);
|
||||
}
|
||||
case doHash("gmlib::WeatherUpdateAfterEvent"): {
|
||||
REGISTER_EVENT_LISTEN(
|
||||
GMLIB::Event::LevelEvent::WeatherUpdateAfterEvent,
|
||||
ila::mc::WeatherUpdateAfterEvent,
|
||||
(float rainLevel, int rainTime, float lightningLevel, int lightningTime),
|
||||
(event.getRainLevel(),
|
||||
event.getRainingLastTick(),
|
||||
event.getLightningLevel(),
|
||||
event.getLightningLastTick()),
|
||||
(event.rainLevel(), event.rainTime(), event.lightningLevel(), event.lightningTime()),
|
||||
,
|
||||
);
|
||||
}
|
||||
case doHash("gmlib::MobPickupItemBeforeEvent"): {
|
||||
REGISTER_EVENT_LISTEN(
|
||||
GMLIB::Event::EntityEvent::MobPickupItemBeforeEvent,
|
||||
ila::mc::ActorPickupItemBeforeEvent,
|
||||
(Actor * mob, Actor * item, bool isCancelled),
|
||||
(&event.self(), (Actor*)&event.getItemActor(), event.isCancelled()),
|
||||
(&event.self(), (Actor*)&event.itemActor(), event.isCancelled()),
|
||||
event.setCancelled(result);
|
||||
);
|
||||
}
|
||||
case doHash("gmlib::MobPickupItemAfterEvent"): {
|
||||
REGISTER_EVENT_LISTEN(
|
||||
GMLIB::Event::EntityEvent::MobPickupItemAfterEvent,
|
||||
ila::mc::ActorPickupItemAfterEvent,
|
||||
(Actor * mob, Actor * item),
|
||||
(&event.self(), (Actor*)&event.getItemActor()),
|
||||
(&event.self(), (Actor*)&event.itemActor()),
|
||||
,
|
||||
);
|
||||
}
|
||||
case doHash("gmlib::ItemActorSpawnBeforeEvent"): {
|
||||
REGISTER_EVENT_LISTEN(
|
||||
GMLIB::Event::EntityEvent::ItemActorSpawnBeforeEvent,
|
||||
ila::mc::SpawnItemActorBeforeEvent,
|
||||
(ItemStack * item, std::pair<Vec3, int> position, int64 spawnerUniqueId, bool isCancelled),
|
||||
(&event.getItem(),
|
||||
{event.getPosition(), event.getBlockSource().getDimensionId().id},
|
||||
event.getSpawner().has_value() ? event.getSpawner()->getOrCreateUniqueID().rawID : -1,
|
||||
(&event.item(),
|
||||
{event.pos(), event.blockSource().getDimensionId().id},
|
||||
event.spawner() ? event.spawner()->getOrCreateUniqueID().rawID : -1,
|
||||
event.isCancelled()),
|
||||
event.setCancelled(result);
|
||||
);
|
||||
}
|
||||
case doHash("gmlib::ItemActorSpawnAfterEvent"): {
|
||||
REGISTER_EVENT_LISTEN(
|
||||
GMLIB::Event::EntityEvent::ItemActorSpawnAfterEvent,
|
||||
ila::mc::SpawnItemActorAfterEvent,
|
||||
(Actor * item, std::pair<Vec3, int> position, int64 spawnerUniqueId),
|
||||
(&event.self(),
|
||||
{event.getPosition(), event.getBlockSource().getDimensionId().id},
|
||||
event.getSpawner().has_value() ? event.getSpawner()->getOrCreateUniqueID().rawID : -1),
|
||||
(event.itemActor(),
|
||||
{event.pos(), event.blockSource().getDimensionId().id},
|
||||
event.spawner() ? event.spawner()->getOrCreateUniqueID().rawID : -1),
|
||||
,
|
||||
);
|
||||
}
|
||||
case doHash("gmlib::ActorChangeDimensionBeforeEvent"): {
|
||||
REGISTER_EVENT_LISTEN(
|
||||
GMLIB::Event::EntityEvent::ActorChangeDimensionBeforeEvent,
|
||||
ila::mc::ActorChangeDimensionBeforeEvent,
|
||||
(Actor * entity, int toDimId, bool isCancelled),
|
||||
(&event.self(), event.getToDimensionId(), event.isCancelled()),
|
||||
(&event.self(), event.toDimensionId(), event.isCancelled()),
|
||||
event.setCancelled(result);
|
||||
);
|
||||
}
|
||||
case doHash("gmlib::ActorChangeDimensionAfterEvent"): {
|
||||
REGISTER_EVENT_LISTEN(
|
||||
GMLIB::Event::EntityEvent::ActorChangeDimensionAfterEvent,
|
||||
ila::mc::ActorChangeDimensionAfterEvent,
|
||||
(Actor * entity, int fromDimId, int toDimId),
|
||||
(&event.self(), event.getFromDimensionId(), event.getToDimensionId()),
|
||||
,
|
||||
);
|
||||
}
|
||||
case doHash("gmlib::PlayerStartSleepBeforeEvent"): {
|
||||
REGISTER_EVENT_LISTEN(
|
||||
GMLIB::Event::PlayerEvent::PlayerStartSleepBeforeEvent,
|
||||
(Player * entity, BlockPos pos, bool isCancelled),
|
||||
(&event.self(), event.getPosition(), event.isCancelled()),
|
||||
event.setCancelled(result);
|
||||
);
|
||||
}
|
||||
case doHash("gmlib::PlayerStartSleepAfterEvent"): {
|
||||
REGISTER_EVENT_LISTEN(
|
||||
GMLIB::Event::PlayerEvent::PlayerStartSleepAfterEvent,
|
||||
(Player * entity, BlockPos pos, int result),
|
||||
(&event.self(), event.getPosition(), (int)event.getResult()),
|
||||
,
|
||||
);
|
||||
}
|
||||
case doHash("gmlib::PlayerStopSleepBeforeEvent"): {
|
||||
REGISTER_EVENT_LISTEN(
|
||||
GMLIB::Event::PlayerEvent::PlayerStopSleepBeforeEvent,
|
||||
(Player * entity, bool forcefulWakeUp, bool updateLevelList, bool isCancelled),
|
||||
(&event.self(), event.isForcefulWakeUp(), event.isUpdateLevelList(), event.isCancelled()),
|
||||
event.setCancelled(result);
|
||||
);
|
||||
}
|
||||
case doHash("gmlib::PlayerStopSleepAfterEvent"): {
|
||||
REGISTER_EVENT_LISTEN(
|
||||
GMLIB::Event::PlayerEvent::PlayerStopSleepAfterEvent,
|
||||
(Player * entity, bool forcefulWakeUp, bool updateLevelList, bool),
|
||||
(&event.self(), event.isForcefulWakeUp(), event.isUpdateLevelList(), false),
|
||||
(&event.self(), event.fromDimensionId(), event.toDimensionId()),
|
||||
,
|
||||
);
|
||||
}
|
||||
// case doHash("gmlib::PlayerStartSleepBeforeEvent"): {
|
||||
// REGISTER_EVENT_LISTEN(
|
||||
// GMLIB::Event::PlayerEvent::PlayerStartSleepBeforeEvent,
|
||||
// (Player * entity, BlockPos pos, bool isCancelled),
|
||||
// (&event.self(), event.getPosition(), event.isCancelled()),
|
||||
// event.setCancelled(result);
|
||||
// );
|
||||
// }
|
||||
// case doHash("gmlib::PlayerStartSleepAfterEvent"): {
|
||||
// REGISTER_EVENT_LISTEN(
|
||||
// GMLIB::Event::PlayerEvent::PlayerStartSleepAfterEvent,
|
||||
// (Player * entity, BlockPos pos, int result),
|
||||
// (&event.self(), event.getPosition(), (int)event.getResult()),
|
||||
// ,
|
||||
// );
|
||||
// }
|
||||
// case doHash("gmlib::PlayerStopSleepBeforeEvent"): {
|
||||
// REGISTER_EVENT_LISTEN(
|
||||
// GMLIB::Event::PlayerEvent::PlayerStopSleepBeforeEvent,
|
||||
// (Player * entity, bool forcefulWakeUp, bool updateLevelList, bool isCancelled),
|
||||
// (&event.self(), event.isForcefulWakeUp(), event.isUpdateLevelList(), event.isCancelled()),
|
||||
// event.setCancelled(result);
|
||||
// );
|
||||
// }
|
||||
// case doHash("gmlib::PlayerStopSleepAfterEvent"): {
|
||||
// REGISTER_EVENT_LISTEN(
|
||||
// GMLIB::Event::PlayerEvent::PlayerStopSleepAfterEvent,
|
||||
// (Player * entity, bool forcefulWakeUp, bool updateLevelList, bool),
|
||||
// (&event.self(), event.isForcefulWakeUp(), event.isUpdateLevelList(), false),
|
||||
// ,
|
||||
// );
|
||||
// }
|
||||
case doHash("gmlib::DeathMessageAfterEvent"): {
|
||||
REGISTER_EVENT_LISTEN(
|
||||
GMLIB::Event::EntityEvent::DeathMessageAfterEvent,
|
||||
ila::mc::DeathMessageAfterEvent,
|
||||
(std::string const& message, std::vector<std::string>, Actor* dead),
|
||||
(event.getDeathMessage().first, event.getDeathMessage().second, &event.self()),
|
||||
(event.result().first, event.result().second, &event.self()),
|
||||
,
|
||||
);
|
||||
}
|
||||
case doHash("gmlib::MobHurtAfterEvent"): {
|
||||
REGISTER_EVENT_LISTEN(
|
||||
GMLIB::Event::EntityEvent::MobHurtAfterEvent,
|
||||
(Actor * mob, Actor * source, float damage, int cause),
|
||||
(&event.self(), source, -event.getDamage(), (int)damageSource.getCause()),
|
||||
,
|
||||
auto& damageSource = event.getSource();
|
||||
Actor* source = nullptr;
|
||||
if (damageSource.isEntitySource()) {
|
||||
auto uniqueId = damageSource.getDamagingEntityUniqueID();
|
||||
source = ll::service::getLevel()->fetchEntity(uniqueId, false);
|
||||
if (source->getOwner()) source = source->getOwner();
|
||||
}
|
||||
);
|
||||
}
|
||||
// case doHash("gmlib::MobHurtAfterEvent"): {
|
||||
// REGISTER_EVENT_LISTEN(
|
||||
// GMLIB::Event::EntityEvent::MobHurtAfterEvent,
|
||||
// (Actor * mob, Actor * source, float damage, int cause),
|
||||
// (&event.self(), source, -event.getDamage(), (int)damageSource.getCause()),
|
||||
// ,
|
||||
// auto& damageSource = event.getSource();
|
||||
// Actor* source = nullptr;
|
||||
// if (damageSource.isEntitySource()) {
|
||||
// auto uniqueId = damageSource.getDamagingEntityUniqueID();
|
||||
// source = ll::service::getLevel()->fetchEntity(uniqueId, false);
|
||||
// if (source->getOwner()) source = source->getOwner();
|
||||
// }
|
||||
// );
|
||||
// }
|
||||
case doHash("gmlib::EndermanTakeBlockBeforeEvent"): {
|
||||
REGISTER_EVENT_LISTEN(
|
||||
GMLIB::Event::EntityEvent::EndermanTakeBlockBeforeEvent,
|
||||
ila::mc::EndermanTakeBlockBeforeEvent,
|
||||
(Actor * mob, bool isCancelled),
|
||||
(&event.self(), event.isCancelled()),
|
||||
event.setCancelled(result);
|
||||
@@ -236,7 +233,7 @@ void Export_Event_API() {
|
||||
}
|
||||
case doHash("gmlib::DragonRespawnBeforeEvent"): {
|
||||
REGISTER_EVENT_LISTEN(
|
||||
GMLIB::Event::EntityEvent::DragonRespawnBeforeEvent,
|
||||
ila::mc::DragonRespawnBeforeEvent,
|
||||
(bool isCancelled),
|
||||
(event.isCancelled()),
|
||||
event.setCancelled(result);
|
||||
@@ -244,111 +241,111 @@ void Export_Event_API() {
|
||||
}
|
||||
case doHash("gmlib::DragonRespawnAfterEvent"): {
|
||||
REGISTER_EVENT_LISTEN(
|
||||
GMLIB::Event::EntityEvent::DragonRespawnAfterEvent,
|
||||
ila::mc::DragonRespawnAfterEvent,
|
||||
(Actor * mob),
|
||||
(event.getEnderDragon()),
|
||||
);
|
||||
}
|
||||
case doHash("gmlib::ProjectileCreateBeforeEvent"): {
|
||||
REGISTER_EVENT_LISTEN(
|
||||
GMLIB::Event::EntityEvent::ProjectileCreateBeforeEvent,
|
||||
(Actor * mob, int64 uniqueId, bool isCancelled),
|
||||
(&event.self(),
|
||||
event.getShooter() ? event.getShooter()->getOrCreateUniqueID().rawID : -1,
|
||||
event.isCancelled()),
|
||||
event.setCancelled(result);
|
||||
);
|
||||
}
|
||||
case doHash("gmlib::ProjectileCreateAfterEvent"): {
|
||||
REGISTER_EVENT_LISTEN(
|
||||
GMLIB::Event::EntityEvent::ProjectileCreateAfterEvent,
|
||||
(Actor * mob, int64 uniqueId),
|
||||
(&event.self(), event.getShooter() ? event.getShooter()->getOrCreateUniqueID().rawID : -1),
|
||||
(&event.self()),
|
||||
);
|
||||
}
|
||||
// case doHash("gmlib::ProjectileCreateBeforeEvent"): {
|
||||
// REGISTER_EVENT_LISTEN(
|
||||
// ila::mc::ProjectileCreateBeforeEvent,
|
||||
// (Actor * mob, int64 uniqueId, bool isCancelled),
|
||||
// (&event.self(),
|
||||
// event.getShooter() ? event.getShooter()->getOrCreateUniqueID().rawID : -1,
|
||||
// event.isCancelled()),
|
||||
// event.setCancelled(result);
|
||||
// );
|
||||
// }
|
||||
// case doHash("gmlib::ProjectileCreateAfterEvent"): {
|
||||
// REGISTER_EVENT_LISTEN(
|
||||
// GMLIB::Event::EntityEvent::ProjectileCreateAfterEvent,
|
||||
// (Actor * mob, int64 uniqueId),
|
||||
// (&event.self(), event.getShooter() ? event.getShooter()->getOrCreateUniqueID().rawID : -1),
|
||||
// );
|
||||
// }
|
||||
case doHash("gmlib::SpawnWanderingTraderBeforeEvent"): {
|
||||
REGISTER_EVENT_LISTEN(
|
||||
GMLIB::Event::EntityEvent::SpawnWanderingTraderBeforeEvent,
|
||||
ila::mc::SpawnWanderingTraderBeforeEvent,
|
||||
(std::pair<BlockPos, int> pos, bool isCancelled),
|
||||
({event.getPos(), event.getRegion().getDimensionId()}, event.isCancelled()),
|
||||
({event.pos(), event.blockSource().getDimensionId()}, event.isCancelled()),
|
||||
event.setCancelled(result);
|
||||
);
|
||||
}
|
||||
case doHash("gmlib::SpawnWanderingTraderAfterEvent"): {
|
||||
REGISTER_EVENT_LISTEN(
|
||||
GMLIB::Event::EntityEvent::SpawnWanderingTraderAfterEvent,
|
||||
ila::mc::SpawnWanderingTraderAfterEvent,
|
||||
(std::pair<BlockPos, int> pos),
|
||||
({event.getPos(), event.getRegion().getDimensionId()}),
|
||||
);
|
||||
}
|
||||
case doHash("gmlib::HandleRequestActionBeforeEvent"): {
|
||||
// clang-format off
|
||||
REGISTER_EVENT_LISTEN(
|
||||
GMLIB::Event::PlayerEvent::HandleRequestActionBeforeEvent,
|
||||
(
|
||||
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(requestAction.mActionType).data(),
|
||||
(int)requestAction.mAmount,
|
||||
magic_enum::enum_name(requestAction.mSrc->mFullContainerName.mName).data(),
|
||||
(int)requestAction.mSrc->mSlot,
|
||||
magic_enum::enum_name(requestAction.mDst->mFullContainerName.mName).data(),
|
||||
(int)requestAction.mDst->mSlot,
|
||||
event.isCancelled()
|
||||
),
|
||||
event.setCancelled(result);,
|
||||
auto& requestAction = (ItemStackRequestActionTransferBase&)event.getRequestAction();
|
||||
);
|
||||
// clang-format on
|
||||
}
|
||||
case doHash("gmlib::HandleRequestActionAfterEvent"): {
|
||||
// clang-format off
|
||||
REGISTER_EVENT_LISTEN(
|
||||
GMLIB::Event::PlayerEvent::HandleRequestActionAfterEvent,
|
||||
(
|
||||
Player * player,
|
||||
std::string const& actionType,
|
||||
int count,
|
||||
std::string const& sourceContainerNetId,
|
||||
int sourceSlot,
|
||||
std::string const& destinationContainerNetId,
|
||||
int destinationSlot
|
||||
),
|
||||
(
|
||||
(Player*)&event.self(),
|
||||
magic_enum::enum_name(requestAction.mActionType).data(),
|
||||
(int)requestAction.mAmount,
|
||||
magic_enum::enum_name(requestAction.mSrc->mFullContainerName.mName).data(),
|
||||
(int)requestAction.mSrc->mSlot,
|
||||
magic_enum::enum_name(requestAction.mDst->mFullContainerName.mName).data(),
|
||||
(int)requestAction.mDst->mSlot
|
||||
),
|
||||
,
|
||||
auto& requestAction = (ItemStackRequestActionTransferBase&)event.getRequestAction();
|
||||
);
|
||||
// clang-format on
|
||||
}
|
||||
case doHash("gmlib::ContainerClosePacketSendAfterEvent"): {
|
||||
REGISTER_EVENT_LISTEN(
|
||||
GMLIB::Event::PacketEvent::ContainerClosePacketSendAfterEvent,
|
||||
(Player * player, int containerId, bool serverInitiatedClose, bool),
|
||||
(event.getServerNetworkHandler()
|
||||
._getServerPlayer(event.getNetworkIdentifier(), event.getPacket().mClientSubId),
|
||||
(int)event.getPacket().mContainerId,
|
||||
event.getPacket().mServerInitiatedClose,
|
||||
false),
|
||||
,
|
||||
({event.pos(), event.blockSource().getDimensionId()}),
|
||||
);
|
||||
}
|
||||
// case doHash("gmlib::HandleRequestActionBeforeEvent"): {
|
||||
// // clang-format off
|
||||
// REGISTER_EVENT_LISTEN(
|
||||
// GMLIB::Event::PlayerEvent::HandleRequestActionBeforeEvent,
|
||||
// (
|
||||
// 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(requestAction.mActionType).data(),
|
||||
// (int)requestAction.mAmount,
|
||||
// magic_enum::enum_name(requestAction.mSrc->mFullContainerName.mName).data(),
|
||||
// (int)requestAction.mSrc->mSlot,
|
||||
// magic_enum::enum_name(requestAction.mDst->mFullContainerName.mName).data(),
|
||||
// (int)requestAction.mDst->mSlot,
|
||||
// event.isCancelled()
|
||||
// ),
|
||||
// event.setCancelled(result);,
|
||||
// auto& requestAction = (ItemStackRequestActionTransferBase&)event.getRequestAction();
|
||||
// );
|
||||
// // clang-format on
|
||||
// }
|
||||
// case doHash("gmlib::HandleRequestActionAfterEvent"): {
|
||||
// // clang-format off
|
||||
// REGISTER_EVENT_LISTEN(
|
||||
// GMLIB::Event::PlayerEvent::HandleRequestActionAfterEvent,
|
||||
// (
|
||||
// Player * player,
|
||||
// std::string const& actionType,
|
||||
// int count,
|
||||
// std::string const& sourceContainerNetId,
|
||||
// int sourceSlot,
|
||||
// std::string const& destinationContainerNetId,
|
||||
// int destinationSlot
|
||||
// ),
|
||||
// (
|
||||
// (Player*)&event.self(),
|
||||
// magic_enum::enum_name(requestAction.mActionType).data(),
|
||||
// (int)requestAction.mAmount,
|
||||
// magic_enum::enum_name(requestAction.mSrc->mFullContainerName.mName).data(),
|
||||
// (int)requestAction.mSrc->mSlot,
|
||||
// magic_enum::enum_name(requestAction.mDst->mFullContainerName.mName).data(),
|
||||
// (int)requestAction.mDst->mSlot
|
||||
// ),
|
||||
// ,
|
||||
// auto& requestAction = (ItemStackRequestActionTransferBase&)event.getRequestAction();
|
||||
// );
|
||||
// // clang-format on
|
||||
// }
|
||||
// case doHash("gmlib::ContainerClosePacketSendAfterEvent"): {
|
||||
// REGISTER_EVENT_LISTEN(
|
||||
// GMLIB::Event::PacketEvent::ContainerClosePacketSendAfterEvent,
|
||||
// (Player * player, int containerId, bool serverInitiatedClose, bool),
|
||||
// (event.getServerNetworkHandler()
|
||||
// ._getServerPlayer(event.getNetworkIdentifier(), event.getPacket().mClientSubId),
|
||||
// (int)event.getPacket().mContainerId,
|
||||
// event.getPacket().mServerInitiatedClose,
|
||||
// false),
|
||||
// ,
|
||||
// );
|
||||
// }
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
+16
-6
@@ -1,15 +1,24 @@
|
||||
#pragma once
|
||||
#include <include_all.h>
|
||||
|
||||
// clang-format off
|
||||
#define GMLIB_Gloabl_Using
|
||||
#include <gmlib/GlobalUsing.h>
|
||||
#include <gmlib/include_all.h>
|
||||
#include <ila/include_all.h>
|
||||
#include <RemoteCallAPI.h>
|
||||
// clang-format on
|
||||
|
||||
#define PLUGIN_NAME fmt::format(fg(fmt::color::light_green), "GMLIB-LRCA")
|
||||
|
||||
#define LIB_VERSION_MAJOR 0
|
||||
#define LIB_VERSION_MINOR 13
|
||||
#define LIB_VERSION_PATCH 6
|
||||
#define LIB_VERSION_MAJOR 1
|
||||
#define LIB_VERSION_MINOR 0
|
||||
#define LIB_VERSION_PATCH 0
|
||||
#define LIB_VERSION_PRERELEASE "rc.1"
|
||||
|
||||
#define LIB_VERSION GMLIB::Version(LIB_VERSION_MAJOR, LIB_VERSION_MINOR, LIB_VERSION_PATCH)
|
||||
#ifdef LIB_VERSION_PRERELEASE
|
||||
#define LIB_VERSION ll::data::Version(LIB_VERSION_MAJOR, LIB_VERSION_MINOR, LIB_VERSION_PATCH, LIB_VERSION_PRERELEASE)
|
||||
#else
|
||||
#define LIB_VERSION ll::data::Version(LIB_VERSION_MAJOR, LIB_VERSION_MINOR, LIB_VERSION_PATCH)
|
||||
#endif
|
||||
|
||||
extern void Export_Legacy_GMLib_ModAPI();
|
||||
extern void Export_Legacy_GMLib_ServerAPI();
|
||||
@@ -17,4 +26,5 @@ extern void Export_Compatibility_API();
|
||||
extern void ExportPAPI();
|
||||
extern void Export_Event_API();
|
||||
extern void Export_BinaryStream_API();
|
||||
extern ll::thread::ThreadPoolExecutor const& getThreadPoolExecutor();
|
||||
// extern void Export_Form_API();
|
||||
+81
-80
@@ -1,4 +1,6 @@
|
||||
#include "Global.h"
|
||||
#include <gmlib/mc/world/Level.h>
|
||||
#include <mc/world/item/crafting/RecipeIngredient.h>
|
||||
|
||||
std::unordered_set<std::string> HardCodedKeys = {"AlwaysUnlocked", "PlayerHasManyItems", "PlayerInWater", "None"};
|
||||
|
||||
@@ -17,17 +19,18 @@ void Export_Legacy_GMLib_ModAPI() {
|
||||
std::string const& result,
|
||||
int count,
|
||||
std::string const& unlock) -> void {
|
||||
if (!GMLIB_Level::getInstance().has_value()) return;
|
||||
std::vector<RecipeIngredient> types;
|
||||
for (auto ing : ingredients) {
|
||||
types.emplace_back(ing, 0, 1);
|
||||
}
|
||||
GMLIB::Mod::JsonRecipe::registerShapelessCraftingTableRecipe(
|
||||
recipe_id,
|
||||
types,
|
||||
RecipeIngredient(result, 0, count),
|
||||
makeRecipeUnlockingKey(unlock)
|
||||
);
|
||||
// if (!GMLIB_Level::getInstance().has_value()) return;
|
||||
// std::vector<RecipeIngredient> types;
|
||||
// for (auto ing : ingredients) {
|
||||
// types.emplace_back(ing, 0, 1);
|
||||
// }
|
||||
// GMLIB::Mod::JsonRecipe::registerShapelessCraftingTableRecipe(
|
||||
// recipe_id,
|
||||
// types,
|
||||
// RecipeIngredient(result, 0, count),
|
||||
// makeRecipeUnlockingKey(unlock)
|
||||
// );
|
||||
throw std::runtime_error("GMLib_ModAPI::registerShapelessRecipe is not implemented");
|
||||
}
|
||||
);
|
||||
RemoteCall::exportAs(
|
||||
@@ -39,18 +42,19 @@ void Export_Legacy_GMLib_ModAPI() {
|
||||
std::string const& result,
|
||||
int count,
|
||||
std::string const& unlock) -> void {
|
||||
if (!GMLIB_Level::getInstance().has_value()) return;
|
||||
std::vector<RecipeIngredient> types;
|
||||
for (auto ing : ingredients) {
|
||||
types.push_back(RecipeIngredient(ing, 0, 1));
|
||||
}
|
||||
GMLIB::Mod::JsonRecipe::registerShapedCraftingTableRecipe(
|
||||
recipe_id,
|
||||
shape,
|
||||
types,
|
||||
RecipeIngredient(result, 0, count),
|
||||
makeRecipeUnlockingKey(unlock)
|
||||
);
|
||||
// if (!GMLIB_Level::getInstance().has_value()) return;
|
||||
// std::vector<RecipeIngredient> types;
|
||||
// for (auto ing : ingredients) {
|
||||
// types.push_back(RecipeIngredient(ing, 0, 1));
|
||||
// }
|
||||
// GMLIB::Mod::JsonRecipe::registerShapedCraftingTableRecipe(
|
||||
// recipe_id,
|
||||
// shape,
|
||||
// types,
|
||||
// RecipeIngredient(result, 0, count),
|
||||
// makeRecipeUnlockingKey(unlock)
|
||||
// );
|
||||
throw std::runtime_error("GMLib_ModAPI::registerShapedRecipe is not implemented");
|
||||
}
|
||||
);
|
||||
RemoteCall::exportAs(
|
||||
@@ -60,13 +64,14 @@ void Export_Legacy_GMLib_ModAPI() {
|
||||
std::string const& input,
|
||||
std::string const& output,
|
||||
std::vector<std::string> tags) -> void {
|
||||
if (!GMLIB_Level::getInstance().has_value()) return;
|
||||
GMLIB::Mod::JsonRecipe::registerFurnaceRecipe(
|
||||
recipe_id,
|
||||
RecipeIngredient(input, 0, 1),
|
||||
RecipeIngredient(output, 0, 1),
|
||||
tags
|
||||
);
|
||||
// if (!GMLIB_Level::getInstance().has_value()) return;
|
||||
// GMLIB::Mod::JsonRecipe::registerFurnaceRecipe(
|
||||
// recipe_id,
|
||||
// RecipeIngredient(input, 0, 1),
|
||||
// RecipeIngredient(output, 0, 1),
|
||||
// tags
|
||||
// );
|
||||
throw std::runtime_error("GMLib_ModAPI::registerFurnaceRecipe is not implemented");
|
||||
}
|
||||
);
|
||||
RemoteCall::exportAs(
|
||||
@@ -74,8 +79,10 @@ void Export_Legacy_GMLib_ModAPI() {
|
||||
"registerBrewingMixRecipe",
|
||||
[](std::string const& recipe_id, std::string const& input, std::string const& output, std::string const& reagent
|
||||
) -> void {
|
||||
if (!GMLIB_Level::getInstance().has_value()) return;
|
||||
GMLIB::Mod::JsonRecipe::registerBrewingMixRecipe(recipe_id, input, output, RecipeIngredient(reagent, 0, 1));
|
||||
// if (!GMLIB_Level::getInstance().has_value()) return;
|
||||
// GMLIB::Mod::JsonRecipe::registerBrewingMixRecipe(recipe_id, input, output, RecipeIngredient(reagent, 0,
|
||||
// 1));
|
||||
throw std::runtime_error("GMLib_ModAPI::registerBrewingMixRecipe is not implemented");
|
||||
}
|
||||
);
|
||||
RemoteCall::exportAs(
|
||||
@@ -83,13 +90,14 @@ void Export_Legacy_GMLib_ModAPI() {
|
||||
"registerBrewingContainerRecipe",
|
||||
[](std::string const& recipe_id, std::string const& input, std::string const& output, std::string const& reagent
|
||||
) -> void {
|
||||
if (!GMLIB_Level::getInstance().has_value()) return;
|
||||
GMLIB::Mod::JsonRecipe::registerBrewingContainerRecipe(
|
||||
recipe_id,
|
||||
RecipeIngredient(input, 0, 1),
|
||||
RecipeIngredient(output, 0, 1),
|
||||
RecipeIngredient(reagent, 0, 1)
|
||||
);
|
||||
// if (!GMLIB_Level::getInstance().has_value()) return;
|
||||
// GMLIB::Mod::JsonRecipe::registerBrewingContainerRecipe(
|
||||
// recipe_id,
|
||||
// RecipeIngredient(input, 0, 1),
|
||||
// RecipeIngredient(output, 0, 1),
|
||||
// RecipeIngredient(reagent, 0, 1)
|
||||
// );
|
||||
throw std::runtime_error("GMLib_ModAPI::registerBrewingContainerRecipe is not implemented");
|
||||
}
|
||||
);
|
||||
RemoteCall::exportAs(
|
||||
@@ -100,14 +108,15 @@ void Export_Legacy_GMLib_ModAPI() {
|
||||
std::string const& base,
|
||||
std::string const& addition,
|
||||
std::string const& result) -> void {
|
||||
if (!GMLIB_Level::getInstance().has_value()) return;
|
||||
GMLIB::Mod::JsonRecipe::registerSmithingTransformRecipe(
|
||||
recipe_id,
|
||||
smithing_template,
|
||||
base,
|
||||
addition,
|
||||
result
|
||||
);
|
||||
// if (!GMLIB_Level::getInstance().has_value()) return;
|
||||
// GMLIB::Mod::JsonRecipe::registerSmithingTransformRecipe(
|
||||
// recipe_id,
|
||||
// smithing_template,
|
||||
// base,
|
||||
// addition,
|
||||
// result
|
||||
// );
|
||||
throw std::runtime_error("GMLib_ModAPI::registerSmithingTransformRecipe is not implemented");
|
||||
}
|
||||
);
|
||||
RemoteCall::exportAs(
|
||||
@@ -117,8 +126,9 @@ void Export_Legacy_GMLib_ModAPI() {
|
||||
std::string const& smithing_template,
|
||||
std::string const& base,
|
||||
std::string const& addition) -> void {
|
||||
if (!GMLIB_Level::getInstance().has_value()) return;
|
||||
GMLIB::Mod::JsonRecipe::registerSmithingTrimRecipe(recipe_id, smithing_template, base, addition);
|
||||
// if (!GMLIB_Level::getInstance().has_value()) return;
|
||||
// GMLIB::Mod::JsonRecipe::registerSmithingTrimRecipe(recipe_id, smithing_template, base, addition);
|
||||
throw std::runtime_error("GMLib_ModAPI::registerSmithingTrimRecipe is not implemented");
|
||||
}
|
||||
);
|
||||
RemoteCall::exportAs(
|
||||
@@ -130,49 +140,40 @@ void Export_Legacy_GMLib_ModAPI() {
|
||||
std::string const& output,
|
||||
int output_data,
|
||||
int output_count) -> void {
|
||||
if (!GMLIB_Level::getInstance().has_value()) return;
|
||||
GMLIB::Mod::JsonRecipe::registerStoneCutterRecipe(
|
||||
recipe_id,
|
||||
RecipeIngredient(input, 0, 1),
|
||||
RecipeIngredient(output, 0, 1)
|
||||
);
|
||||
// if (!GMLIB_Level::getInstance().has_value()) return;
|
||||
// GMLIB::Mod::JsonRecipe::registerStoneCutterRecipe(
|
||||
// recipe_id,
|
||||
// RecipeIngredient(input, 0, 1),
|
||||
// RecipeIngredient(output, 0, 1)
|
||||
// );
|
||||
throw std::runtime_error("GMLib_ModAPI::registerStoneCutterRecipe is not implemented");
|
||||
}
|
||||
);
|
||||
// 错误方块清理
|
||||
RemoteCall::exportAs("GMLib_ModAPI", "setUnknownBlockCleaner", []() -> void {
|
||||
GMLIB::Mod::VanillaFix::setAutoCleanUnknownBlockEnabled();
|
||||
// GMLIB::Mod::VanillaFix::setAutoCleanUnknownBlockEnabled();
|
||||
throw std::runtime_error("GMLib_ModAPI::setUnknownBlockCleaner is not implemented");
|
||||
});
|
||||
// 实验性
|
||||
RemoteCall::exportAs("GMLib_ModAPI", "registerExperimentsRequire", [](int experiment_id) -> void {
|
||||
auto list = GMLIB_Level::getAllExperiments();
|
||||
std::unordered_set<AllExperiments> set(list.begin(), list.end());
|
||||
if (set.contains((AllExperiments)experiment_id)) {
|
||||
GMLIB_Level::addExperimentsRequire((AllExperiments)experiment_id);
|
||||
} else {
|
||||
ll::io::LoggerRegistry::getInstance().getOrCreate("Server")->error("Experiment ID '{}' does not exist!", experiment_id);
|
||||
}
|
||||
GMLevel::getInstance().and_then([&](GMLevel& level) {
|
||||
level.setExperimentEnabled((AllExperiments)experiment_id);
|
||||
return true;
|
||||
});
|
||||
});
|
||||
RemoteCall::exportAs("GMLib_ModAPI", "setExperimentEnabled", [](int experiment_id, bool value) -> void {
|
||||
if (GMLIB_Level::getInstance()) {
|
||||
auto list = GMLIB_Level::getAllExperiments();
|
||||
std::unordered_set<AllExperiments> set(list.begin(), list.end());
|
||||
if (set.contains((AllExperiments)experiment_id)) {
|
||||
GMLIB_Level::getInstance()->setExperimentEnabled(((AllExperiments)experiment_id), value);
|
||||
} else ll::io::LoggerRegistry::getInstance().getOrCreate("Server")->error("Experiment ID '{}' does not exist!", experiment_id);
|
||||
}
|
||||
GMLevel::getInstance().and_then([&](GMLevel& level) {
|
||||
level.setExperimentEnabled((AllExperiments)experiment_id, value);
|
||||
return true;
|
||||
});
|
||||
});
|
||||
RemoteCall::exportAs("GMLib_ModAPI", "getExperimentEnabled", [](int experiment_id) -> bool {
|
||||
if (GMLIB_Level::getInstance()) {
|
||||
auto list = GMLIB_Level::getAllExperiments();
|
||||
std::unordered_set<AllExperiments> set(list.begin(), list.end());
|
||||
if (set.contains((AllExperiments)experiment_id)) {
|
||||
return GMLIB_Level::getInstance()->getExperimentEnabled(((AllExperiments)experiment_id));
|
||||
}
|
||||
ll::io::LoggerRegistry::getInstance().getOrCreate("Server")->error("Experiment ID '{}' does not exist!", experiment_id);
|
||||
}
|
||||
return false;
|
||||
return GMLevel::getInstance()
|
||||
.transform([&](GMLevel& level) { return level.getExperimentEnabled((AllExperiments)experiment_id); })
|
||||
.value_or(false);
|
||||
});
|
||||
RemoteCall::exportAs("GMLib_ModAPI", "setFixI18nEnabled", []() -> void {
|
||||
GMLIB::Mod::VanillaFix::setFixI18nEnabled();
|
||||
// GMLIB::Mod::VanillaFix::setFixI18nEnabled();
|
||||
throw std::runtime_error("GMLib_ModAPI::setFixI18nEnabled is not implemented");
|
||||
});
|
||||
}
|
||||
+35
-24
@@ -2,57 +2,68 @@
|
||||
|
||||
void Export_Legacy_GMLib_ServerAPI() {
|
||||
RemoteCall::exportAs("GMLib_ServerAPI", "setEducationFeatureEnabled", []() -> void {
|
||||
GMLIB_Level::tryEnableEducationEdition();
|
||||
// GMLIB_Level::tryEnableEducationEdition();
|
||||
throw std::runtime_error("GMLib_ServerAPI::setEducationFeatureEnabled is not implemented");
|
||||
});
|
||||
RemoteCall::exportAs("GMLib_ServerAPI", "registerAbilityCommand", []() -> void {
|
||||
GMLIB_Level::tryRegisterAbilityCommand();
|
||||
// GMLIB_Level::tryRegisterAbilityCommand();
|
||||
throw std::runtime_error("GMLib_ServerAPI::registerAbilityCommand is not implemented");
|
||||
});
|
||||
RemoteCall::exportAs("GMLib_ServerAPI", "setEnableAchievement", []() -> void {
|
||||
GMLIB_Level::setForceAchievementsEnabled();
|
||||
// GMLIB_Level::setForceAchievementsEnabled();
|
||||
throw std::runtime_error("GMLib_ServerAPI::setEnableAchievement is not implemented");
|
||||
});
|
||||
RemoteCall::exportAs("GMLib_ServerAPI", "setForceTrustSkins", []() -> void {
|
||||
// GMLIB_Level::trustAllSkins();
|
||||
throw std::runtime_error("GMLib_ServerAPI::setForceTrustSkins is not implemented");
|
||||
});
|
||||
RemoteCall::exportAs("GMLib_ServerAPI", "setForceTrustSkins", []() -> void { GMLIB_Level::trustAllSkins(); });
|
||||
RemoteCall::exportAs("GMLib_ServerAPI", "enableCoResourcePack", []() -> void {
|
||||
GMLIB_Level::requireServerResourcePackAndAllowClientResourcePack();
|
||||
// GMLIB_Level::requireServerResourcePackAndAllowClientResourcePack();
|
||||
throw std::runtime_error("GMLib_ServerAPI::enableCoResourcePack is not implemented");
|
||||
});
|
||||
RemoteCall::exportAs("GMLib_ServerAPI", "getLevelName", []() -> std::string {
|
||||
return GMLIB_Level::getInstance()
|
||||
.transform([](GMLIB_Level& level) -> std::string { return level.getLevelName(); })
|
||||
.value_or("");
|
||||
return GMLevel::getInstance().transform(
|
||||
[](GMLevel& level) -> std::string { return level.getLevelName(); }
|
||||
).value_or("");
|
||||
});
|
||||
RemoteCall::exportAs("GMLib_ServerAPI", "setLevelName", [](std::string const& name) -> void {
|
||||
if (auto level = GMLIB_Level::getInstance()) {
|
||||
if (auto level = GMLevel::getInstance()) {
|
||||
level->setLevelName(name);
|
||||
}
|
||||
});
|
||||
RemoteCall::exportAs("GMLib_ServerAPI", "getLevelSeed", []() -> std::string {
|
||||
return GMLIB_Level::getInstance()
|
||||
.transform([](GMLIB_Level& level) -> std::string { return std::to_string(level.getSeed()); })
|
||||
return GMLevel::getInstance()
|
||||
.transform([](GMLevel& level) -> std::string { return std::to_string(level.getSeed()); })
|
||||
.value_or("");
|
||||
});
|
||||
RemoteCall::exportAs("GMLib_ServerAPI", "setFakeSeed", [](int64_t seed) -> void {
|
||||
return GMLIB_Level::setFakeSeed(seed);
|
||||
// return GMLIB_Level::setFakeSeed(seed);
|
||||
throw std::runtime_error("GMLib_ServerAPI::setFakeSeed is not implemented");
|
||||
});
|
||||
RemoteCall::exportAs(
|
||||
"GMLib_ServerAPI",
|
||||
"spawnEntity",
|
||||
[](std::pair<Vec3, int> pos, std::string const& name) -> Actor* {
|
||||
return GMLIB_Spawner::spawnEntity(pos.first, pos.second, name).as_ptr();
|
||||
return GMSpawner::spawnEntity(pos.first, pos.second, name).as_ptr();
|
||||
}
|
||||
);
|
||||
RemoteCall::exportAs(
|
||||
"GMLib_ServerAPI",
|
||||
"shootProjectile",
|
||||
[](Actor* owner, std::string const& name, float speed, float offset) -> Actor* {
|
||||
auto ac = (GMLIB_Actor*)owner;
|
||||
return ac->shootProjectile(name, speed, offset).as_ptr();
|
||||
auto actor = GMSpawner::spawnEntity(owner->getPosition(), owner->getDimensionId(), name);
|
||||
if (!actor) return nullptr;
|
||||
((GMActor*)owner)->setProjectile((GMActor&)*actor, speed, offset);
|
||||
return actor.as_ptr();
|
||||
}
|
||||
);
|
||||
RemoteCall::exportAs(
|
||||
"GMLib_ServerAPI",
|
||||
"throwEntity",
|
||||
[](Actor* owner, Actor* actor, float speed, float offset) -> bool {
|
||||
auto ac = (GMLIB_Actor*)owner;
|
||||
return ac->throwEntity(*actor, speed, offset);
|
||||
auto ac = (GMActor*)owner;
|
||||
ac->setProjectile((GMActor&)*actor, speed, offset);
|
||||
return true;
|
||||
}
|
||||
);
|
||||
RemoteCall::exportAs("GMLib_ServerAPI", "PlayerToEntity", [](Player* player) -> Actor* { return (Actor*)player; });
|
||||
@@ -60,18 +71,18 @@ void Export_Legacy_GMLib_ServerAPI() {
|
||||
"GMLib_ServerAPI",
|
||||
"addFakeList",
|
||||
[](const std::string& name, const std::string& xuid) -> bool {
|
||||
return GMLIB::Server::FakeList::addFakeList(name, xuid, ActorUniqueID(-1));
|
||||
PlayerListAPI::push_back(name, xuid);
|
||||
return true;
|
||||
}
|
||||
);
|
||||
RemoteCall::exportAs("GMLib_ServerAPI", "removeFakeList", [](const std::string& nameOrXuid) -> bool {
|
||||
return GMLIB::Server::FakeList::removeFakeList(nameOrXuid);
|
||||
});
|
||||
RemoteCall::exportAs("GMLib_ServerAPI", "removeAllFakeList", []() -> void {
|
||||
return GMLIB::Server::FakeList::removeAllFakeLists();
|
||||
PlayerListAPI::resetListName(nameOrXuid);
|
||||
return true;
|
||||
});
|
||||
RemoteCall::exportAs("GMLib_ServerAPI", "removeAllFakeList", []() -> void { PlayerListAPI::clear(); });
|
||||
RemoteCall::exportAs("GMLib_ServerAPI", "getMaxPlayers", []() -> int {
|
||||
return GMLIB_Level::getInstance().transform(
|
||||
[](GMLIB_Level& level) -> int { return level.getMaxPlayerCount(); }
|
||||
return GMLevel::getInstance().transform(
|
||||
[](GMLevel& level) -> int { return level.getMaxPlayerCount(); }
|
||||
).value_or(0);
|
||||
});
|
||||
}
|
||||
|
||||
+133
-69
@@ -2,122 +2,178 @@
|
||||
#include <regex>
|
||||
|
||||
namespace PAPIRemoteCall {
|
||||
|
||||
std::string removeBrackets(std::string a1) {
|
||||
a1.erase(a1.find_last_not_of("%") + 1);
|
||||
return a1;
|
||||
}
|
||||
|
||||
bool isParameters(std::string const& str) {
|
||||
std::regex reg("[<]([^<>]+)[>]");
|
||||
return std::regex_search(removeBrackets(str), reg);
|
||||
}
|
||||
|
||||
std::string GetValue(std::string const& from) { return GMLIB::Server::PlaceholderAPI::getValue(from); }
|
||||
std::string GetValue(std::string const& from) { return PlaceholderAPI::getValue(from, std::nullopt).value_or(""); }
|
||||
|
||||
std::string GetValueWithPlayer(std::string const& key, Player* player) {
|
||||
return GMLIB::Server::PlaceholderAPI::getValue(key, player);
|
||||
return PlaceholderAPI::getValue(key, (GMActor*)player).value_or("");
|
||||
}
|
||||
|
||||
bool registerPlayerPlaceholder(
|
||||
void registerPlayerPlaceholder(
|
||||
std::string const& PluginName,
|
||||
std::string const& FuncName,
|
||||
std::string const& PAPIName
|
||||
) {
|
||||
if (RemoteCall::hasFunc(PluginName, FuncName)) {
|
||||
GMLIB::Server::PlaceholderAPI::unregisterPlaceholder(PAPIName);
|
||||
if (isParameters(PAPIName)) {
|
||||
auto Call = RemoteCall::importAs<std::string(Player * pl, std::unordered_map<std::string, std::string>)>(
|
||||
if (!RemoteCall::hasFunc(PluginName, FuncName)) return;
|
||||
auto func = [=]() -> void {
|
||||
PlaceholderAPI::unregisterPlaceholder(PAPIName);
|
||||
std::weak_ptr mod = ll::mod::ModManagerRegistry::getInstance().getMod(PluginName);
|
||||
if (mod.expired()) return;
|
||||
PlaceholderAPI::registerPlaceholder(
|
||||
PAPIName,
|
||||
[Call = RemoteCall::importAs<std::string(Player * pl, std::unordered_map<std::string, std::string>)>(
|
||||
PluginName,
|
||||
FuncName
|
||||
)](optional_ref<GMActor> actor, std::unordered_map<std::string, std::string> const& params, auto&&...
|
||||
) -> std::optional<std::string> {
|
||||
if (actor.has_value() && ((Actor*)actor.as_ptr())->isPlayer()) {
|
||||
return Call((Player*)actor.as_ptr(), params);
|
||||
}
|
||||
return std::nullopt;
|
||||
},
|
||||
mod
|
||||
);
|
||||
GMLIB::Server::PlaceholderAPI::registerPlayerPlaceholder(
|
||||
PAPIName,
|
||||
[Call](Player* sp, std::unordered_map<std::string, std::string> map) { return Call(sp, map); },
|
||||
PluginName
|
||||
);
|
||||
};
|
||||
if (ll::mod::ModManagerRegistry::getInstance().hasMod(PluginName)) {
|
||||
func();
|
||||
} else {
|
||||
auto Call = RemoteCall::importAs<std::string(Player * pl)>(PluginName, FuncName);
|
||||
GMLIB::Server::PlaceholderAPI::registerPlayerPlaceholder(
|
||||
PAPIName,
|
||||
[Call](Player* sp) { return Call(sp); },
|
||||
PluginName
|
||||
);
|
||||
getThreadPoolExecutor().execute(func);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool registerServerPlaceholder(
|
||||
void registerServerPlaceholder(
|
||||
std::string const& PluginName,
|
||||
std::string const& FuncName,
|
||||
std::string const& PAPIName
|
||||
) {
|
||||
if (RemoteCall::hasFunc(PluginName, FuncName)) {
|
||||
GMLIB::Server::PlaceholderAPI::unregisterPlaceholder(PAPIName);
|
||||
if (isParameters(PAPIName)) {
|
||||
auto Call =
|
||||
RemoteCall::importAs<std::string(std::unordered_map<std::string, std::string>)>(PluginName, FuncName);
|
||||
GMLIB::Server::PlaceholderAPI::registerServerPlaceholder(
|
||||
if (!RemoteCall::hasFunc(PluginName, FuncName)) return;
|
||||
auto func = [=]() -> void {
|
||||
PlaceholderAPI::unregisterPlaceholder(PAPIName);
|
||||
std::weak_ptr mod = ll::mod::ModManagerRegistry::getInstance().getMod(PluginName);
|
||||
if (mod.expired()) return;
|
||||
PlaceholderAPI::registerPlaceholder(
|
||||
PAPIName,
|
||||
[Call](std::unordered_map<std::string, std::string> map) { return Call(map); },
|
||||
PluginName
|
||||
[Call = RemoteCall::importAs<std::string(std::unordered_map<std::string, std::string>)>(
|
||||
PluginName,
|
||||
FuncName
|
||||
)](auto, std::unordered_map<std::string, std::string> const& params, auto&&...
|
||||
) -> std::optional<std::string> { return Call(params); },
|
||||
mod
|
||||
);
|
||||
};
|
||||
if (ll::mod::ModManagerRegistry::getInstance().hasMod(PluginName)) {
|
||||
func();
|
||||
} else {
|
||||
auto Call = RemoteCall::importAs<std::string()>(PluginName, FuncName);
|
||||
GMLIB::Server::PlaceholderAPI::registerServerPlaceholder(PAPIName, [Call]() { return Call(); }, PluginName);
|
||||
getThreadPoolExecutor().execute(func);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool registerStaticPlaceholder(
|
||||
void registerStaticPlaceholder(
|
||||
std::string const& PluginName,
|
||||
std::string const& FuncName,
|
||||
std::string const& PAPIName,
|
||||
int num
|
||||
) {
|
||||
if (RemoteCall::hasFunc(PluginName, FuncName)) {
|
||||
GMLIB::Server::PlaceholderAPI::unregisterPlaceholder(PAPIName);
|
||||
if (isParameters(PAPIName)) {
|
||||
auto Call = RemoteCall::importAs<std::string()>(PluginName, FuncName);
|
||||
if (num == -1) {
|
||||
GMLIB::Server::PlaceholderAPI::registerStaticPlaceholder(
|
||||
if (!RemoteCall::hasFunc(PluginName, FuncName)) return;
|
||||
auto func = [=]() -> void {
|
||||
PlaceholderAPI::unregisterPlaceholder(PAPIName);
|
||||
std::weak_ptr mod = ll::mod::ModManagerRegistry::getInstance().getMod(PluginName);
|
||||
if (mod.expired()) return;
|
||||
PlaceholderAPI::registerPlaceholder(
|
||||
PAPIName,
|
||||
[Call] { return Call(); },
|
||||
PluginName
|
||||
[Call = RemoteCall::importAs<std::string()>(PluginName, FuncName)](auto&&...
|
||||
) -> std::optional<std::string> { return Call(); },
|
||||
mod
|
||||
);
|
||||
};
|
||||
if (ll::mod::ModManagerRegistry::getInstance().hasMod(PluginName)) {
|
||||
func();
|
||||
} else {
|
||||
GMLIB::Server::PlaceholderAPI::registerStaticPlaceholder(
|
||||
PAPIName,
|
||||
num,
|
||||
[Call] { return Call(); },
|
||||
PluginName
|
||||
);
|
||||
getThreadPoolExecutor().execute(func);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
std::string translateStringWithPlayer(std::string const& str, Player* pl) {
|
||||
return GMLIB::Server::PlaceholderAPI::translateString(str, pl);
|
||||
return PlaceholderAPI::translate(str, (GMActor*)pl);
|
||||
}
|
||||
|
||||
std::string translateString(std::string const& str) { return GMLIB::Server::PlaceholderAPI::translateString(str); }
|
||||
std::string translateString(std::string const& str) { return PlaceholderAPI::translate(str, std::nullopt); }
|
||||
|
||||
bool unRegisterPlaceholder(std::string const& str) { return GMLIB::Server::PlaceholderAPI::unregisterPlaceholder(str); }
|
||||
bool unRegisterPlaceholder(std::string const& str) { return PlaceholderAPI::unregisterPlaceholder(str); }
|
||||
|
||||
std::vector<std::string> getAllPAPI() { return GMLIB::Server::PlaceholderAPI::getAllPAPI(); }
|
||||
std::vector<std::string> getAllPAPI() {
|
||||
std::vector<std::string> result;
|
||||
for (auto& papi : PlaceholderAPI::getAllPlaceholderData()) {
|
||||
result.push_back(papi.first);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
} // namespace PAPIRemoteCall
|
||||
|
||||
namespace NewPapiRemoteCall {
|
||||
std::string translate(std::string const& value, std::string const& language) {
|
||||
return PlaceholderAPI::translate(value, std::nullopt, language);
|
||||
}
|
||||
std::string translateFromActor(std::string const& value, Actor* actor, std::string const& language) {
|
||||
return PlaceholderAPI::translate(value, (GMActor*)actor, language);
|
||||
}
|
||||
void registerPlaceholder(std::string const& placeholder, std::string const& funcName, std::string const& pluginName) {
|
||||
if (!RemoteCall::hasFunc(pluginName, funcName)) return;
|
||||
auto func = [=]() -> void {
|
||||
if (std::weak_ptr mod = ll::mod::ModManagerRegistry::getInstance().getMod(pluginName); !mod.expired()) {
|
||||
PlaceholderAPI::unregisterPlaceholder(placeholder);
|
||||
PlaceholderAPI::registerPlaceholder(
|
||||
placeholder,
|
||||
[Call = RemoteCall::importAs<
|
||||
std::string(Actor*, std::unordered_map<std::string, std::string>, std::string)>(
|
||||
pluginName,
|
||||
funcName
|
||||
)](optional_ref<GMActor> actor,
|
||||
std::unordered_map<std::string, std::string> const& params,
|
||||
std::string const& language) -> std::optional<std::string> {
|
||||
auto result = Call((Actor*)actor.as_ptr(), params, language);
|
||||
return result == "<std::nullopt>" ? std::nullopt : std::optional(result);
|
||||
},
|
||||
mod
|
||||
);
|
||||
}
|
||||
};
|
||||
if (ll::mod::ModManagerRegistry::getInstance().hasMod(pluginName)) {
|
||||
func();
|
||||
} else {
|
||||
getThreadPoolExecutor().execute(func);
|
||||
}
|
||||
}
|
||||
bool unregisterPlaceholder(std::string const& placeholder) {
|
||||
return PlaceholderAPI::unregisterPlaceholder(placeholder);
|
||||
}
|
||||
bool unregisterPlaceholderFromModName(std::string const& pluginName) {
|
||||
std::weak_ptr plugin = ll::mod::ModManagerRegistry::getInstance().getMod(pluginName);
|
||||
if (plugin.expired()) return false;
|
||||
return PlaceholderAPI::unregisterPlaceholder(plugin);
|
||||
}
|
||||
std::string getValue(
|
||||
std::string const& placeholder,
|
||||
std::unordered_map<std::string, std::string> params,
|
||||
std::string const& language
|
||||
) {
|
||||
return PlaceholderAPI::getValue(placeholder, std::nullopt, params, language).value_or("<std::nullopt>");
|
||||
}
|
||||
std::string getValueFromActor(
|
||||
std::string const& placeholder,
|
||||
Actor* actor,
|
||||
std::unordered_map<std::string, std::string> params,
|
||||
std::string const& language
|
||||
) {
|
||||
return PlaceholderAPI::getValue(placeholder, (GMActor*)actor, params, language).value_or("<std::nullopt>");
|
||||
}
|
||||
} // namespace NewPapiRemoteCall
|
||||
|
||||
#define EXPORTAPI(T) \
|
||||
RemoteCall::exportAs("BEPlaceholderAPI", ll::utils::string_utils::replaceAll(#T, "PAPIRemoteCall::", ""), T);
|
||||
|
||||
#define EXPORTAPI2(T) RemoteCall::exportAs("PlaceholderAPI", #T, NewPapiRemoteCall::T);
|
||||
|
||||
void ExportPAPI() {
|
||||
EXPORTAPI(PAPIRemoteCall::registerPlayerPlaceholder);
|
||||
EXPORTAPI(PAPIRemoteCall::registerServerPlaceholder);
|
||||
@@ -128,4 +184,12 @@ void ExportPAPI() {
|
||||
EXPORTAPI(PAPIRemoteCall::translateStringWithPlayer);
|
||||
EXPORTAPI(PAPIRemoteCall::unRegisterPlaceholder);
|
||||
EXPORTAPI(PAPIRemoteCall::getAllPAPI);
|
||||
|
||||
EXPORTAPI2(translate);
|
||||
EXPORTAPI2(translateFromActor);
|
||||
EXPORTAPI2(registerPlaceholder);
|
||||
EXPORTAPI2(unregisterPlaceholder);
|
||||
EXPORTAPI2(unregisterPlaceholderFromModName);
|
||||
EXPORTAPI2(getValue);
|
||||
EXPORTAPI2(getValueFromActor);
|
||||
}
|
||||
+30
-14
@@ -1,29 +1,45 @@
|
||||
{
|
||||
"format_version": 2,
|
||||
"format_version": 3,
|
||||
"format_uuid": "289f771f-2c9a-4d73-9f3f-8492495a924d",
|
||||
"tooth": "github.com/GroupMountain/GMLIB-LegacyRemoteCallApi",
|
||||
"version": "0.13.6",
|
||||
"version": "1.0.0-rc.1",
|
||||
"info": {
|
||||
"name": "GMLIB-LegacyRemoteCallApi",
|
||||
"description": "Legacy RemoteCall API for GMLIB",
|
||||
"source": "github.com/GroupMountain/GMLIB-LegacyRemoteCallApi",
|
||||
"author": "GroupMountain",
|
||||
"tags": [
|
||||
"levilamina",
|
||||
"platform:levilamina",
|
||||
"type:mod",
|
||||
"gmlib",
|
||||
"lse",
|
||||
"library"
|
||||
]
|
||||
],
|
||||
"avatar_url": "https://raw.githubusercontent.com/GroupMountain/GMLIB-LegacyRemoteCallApi/refs/heads/main/icon.jpg"
|
||||
},
|
||||
"asset_url": "https://github.com/GroupMountain/GMLIB-LegacyRemoteCallApi/releases/download/v0.13.6/GMLIB-LegacyRemoteCallApi-windows-x64.zip",
|
||||
"dependencies": {
|
||||
"github.com/GroupMountain/GMLIB": ">=0.13.9"
|
||||
},
|
||||
"files": {
|
||||
"place": [
|
||||
"variants": [
|
||||
{
|
||||
"src": "GMLIB-LegacyRemoteCallApi/*",
|
||||
"dest": "plugins/GMLIB-LegacyRemoteCallApi"
|
||||
"platform": "win-x64",
|
||||
"dependencies": {
|
||||
"github.com/LiteLDev/LeviLamina": ">=1.1.1",
|
||||
"github.com/GroupMountain/GMLIB-Release": ">=1.0.0-rc.3"
|
||||
},
|
||||
"assets": [
|
||||
{
|
||||
"type": "zip",
|
||||
"urls": [
|
||||
"https://github.com/GroupMountain/GMLIB-LegacyRemoteCallApi/releases/download/v$(version)/GMLIB-LegacyRemoteCallApi-windows-x64.zip"
|
||||
],
|
||||
"placements": [
|
||||
{
|
||||
"type": "dir",
|
||||
"src": "GMLIB-LegacyRemoteCallApi",
|
||||
"dest": "plugins/GMLIB-LegacyRemoteCallApi/"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"remove_files": [
|
||||
"plugins/GMLIB-LegacyRemoteCallApi"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -2,6 +2,7 @@ add_rules("mode.debug", "mode.release")
|
||||
|
||||
add_repositories("liteldev-repo https://github.com/LiteLDev/xmake-repo.git")
|
||||
add_repositories("groupmountain-repo https://github.com/GroupMountain/xmake-repo.git")
|
||||
add_repositories("miracleforest-repo https://github.com/MiracleForest/xmake-repo.git")
|
||||
|
||||
if not has_config("vs_runtime") then
|
||||
set_runtimes("MD")
|
||||
@@ -11,6 +12,7 @@ add_requires("levilamina", {configs = {target_type = "server"}})
|
||||
add_requires("legacyremotecall")
|
||||
add_requires("gmlib")
|
||||
add_requires("levibuildscript")
|
||||
add_requires("ilistenattentively")
|
||||
|
||||
target("GMLIB-LegacyRemoteCallApi")
|
||||
add_cxflags(
|
||||
@@ -19,7 +21,8 @@ target("GMLIB-LegacyRemoteCallApi")
|
||||
)
|
||||
add_defines(
|
||||
"NOMINMAX",
|
||||
"UNICODE"
|
||||
"UNICODE",
|
||||
"_HAS_CXX23=1"
|
||||
)
|
||||
add_files(
|
||||
"src/**.cpp"
|
||||
@@ -30,12 +33,13 @@ target("GMLIB-LegacyRemoteCallApi")
|
||||
add_packages(
|
||||
"levilamina",
|
||||
"legacyremotecall",
|
||||
"gmlib"
|
||||
"gmlib",
|
||||
"ilistenattentively"
|
||||
)
|
||||
add_rules("@levibuildscript/linkrule")
|
||||
set_exceptions("none")
|
||||
set_kind("shared")
|
||||
set_languages("c++23")
|
||||
set_languages("cxx20")
|
||||
set_symbols("debug")
|
||||
|
||||
after_build(function (target)
|
||||
|
||||
Reference in New Issue
Block a user