Merge branch 'develop' of https://github.com/GroupMountain/GMLIB-LegacyRemoteCallApi
This commit is contained in:
+34
-5
@@ -6,10 +6,15 @@ const GMLIB_API = {
|
||||
sendFloatingText: ll.import("GMLIB_API", "sendFloatingText"),
|
||||
removeFloatingTextFromPlayer: ll.import("GMLIB_API", "removeFloatingTextFromPlayer"),
|
||||
removeFloatingText: ll.import("GMLIB_API", "removeFloatingText"),
|
||||
updateClientFloatingTextData: ll.import("GMLIB_API", "updateClientFloatingTextData"),
|
||||
updateAllClientsFloatingTextData: ll.import("GMLIB_API", "updateAllClientsFloatingTextData"),
|
||||
getServerMspt: ll.import("GMLIB_API", "getServerMspt"),
|
||||
getServerCurrentTps: ll.import("GMLIB_API", "getServerCurrentTps"),
|
||||
getServerAverageTps: ll.import("GMLIB_API", "getServerAverageTps"),
|
||||
getAllPlayerUuids: ll.import("GMLIB_API", "getAllPlayerUuids"),
|
||||
getPlayerNbt: ll.import("GMLIB_API", "getPlayerNbt"),
|
||||
setPlayerNbt: ll.import("GMLIB_API", "setPlayerNbt"),
|
||||
setPlayerNbtTags: ll.import("GMLIB_API", "setPlayerNbtTags"),
|
||||
setEducationFeatureEnabled: ll.import("GMLib_ServerAPI", "setEducationFeatureEnabled"),
|
||||
registerAbilityCommand: ll.import("GMLib_ServerAPI", "registerAbilityCommand"),
|
||||
setEnableAchievement: ll.import("GMLib_ServerAPI", "setEnableAchievement"),
|
||||
@@ -72,6 +77,14 @@ class StaticFloatingText {
|
||||
return GMLIB_API.removeFloatingText(this.mRuntimeId);
|
||||
}
|
||||
|
||||
updateClient(player) {
|
||||
return GMLIB_API.updateClientFloatingTextData(this.mRuntimeId, player);
|
||||
}
|
||||
|
||||
updateClients() {
|
||||
return GMLIB_API.updateAllClientsFloatingTextData(this.mRuntimeId);
|
||||
}
|
||||
|
||||
getRuntimeId() {
|
||||
return this.mRuntimeId;
|
||||
}
|
||||
@@ -86,7 +99,7 @@ class StaticFloatingText {
|
||||
|
||||
update() {
|
||||
GMLIB_API.setFloatingTextData(this.mRuntimeId, this.mText);
|
||||
return this.sendToClients();
|
||||
return this.updateClients();
|
||||
}
|
||||
|
||||
updateText(newText) {
|
||||
@@ -109,13 +122,13 @@ class StaticFloatingText {
|
||||
}
|
||||
|
||||
static getFloatingText(runtimeId) {
|
||||
FloatingTextList.forEach((ft) => {
|
||||
for (const ft of FloatingTextList) {
|
||||
if (ft.getRuntimeId() == runtimeId) {
|
||||
if (!ft.isDynamic()) {
|
||||
return ft;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -178,13 +191,13 @@ class DynamicFloatingText extends StaticFloatingText {
|
||||
}
|
||||
|
||||
static getFloatingText(runtimeId) {
|
||||
FloatingTextList.forEach((ft) => {
|
||||
for (const ft of FloatingTextList) {
|
||||
if (ft.getRuntimeId() == runtimeId) {
|
||||
if (ft.isDynamic()) {
|
||||
return ft;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -220,6 +233,22 @@ class Minecraft {
|
||||
return GMLIB_API.getAllPlayerUuids();
|
||||
}
|
||||
|
||||
static getPlayerNbt(uuid) {
|
||||
let snbt = GMLIB_API.getPlayerNbt(uuid);
|
||||
let nbt = NBT.parseSNBT(snbt);
|
||||
return nbt;
|
||||
}
|
||||
|
||||
static setPlayerNbt(uuid, nbt) {
|
||||
let snbt = nbt.toSNBT();
|
||||
return GMLIB_API.setPlayerNbt(uuid, snbt);
|
||||
}
|
||||
|
||||
static setPlayerNbtTags(uuid, nbt, tags) {
|
||||
let snbt = nbt.toSNBT();
|
||||
return GMLIB_API.setPlayerNbtTags(uuid, snbt, tags);
|
||||
}
|
||||
|
||||
static setEducationFeatureEnabled() {
|
||||
return GMLIB_API.setEducationFeatureEnabled();
|
||||
}
|
||||
|
||||
@@ -25,6 +25,24 @@ void Export_Compatibility_API() {
|
||||
RemoteCall::exportAs("GMLIB_API", "getAllPlayerUuids", []() -> std::vector<std::string> {
|
||||
return GMLIB_Player::getAllUuids();
|
||||
});
|
||||
RemoteCall::exportAs("GMLIB_API", "getPlayerNbt", [](std::string uuid) -> std::string {
|
||||
auto uid = mce::UUID::fromString(uuid);
|
||||
return GMLIB_Player::getPlayerNbt(uid)->toSnbt();
|
||||
});
|
||||
RemoteCall::exportAs("GMLIB_API", "setPlayerNbt", [](std::string uuid, std::string snbt) -> bool {
|
||||
auto uid = mce::UUID::fromString(uuid);
|
||||
auto nbt = CompoundTag::fromSnbt(snbt);
|
||||
return GMLIB_Player::setPlayerNbt(uid, *nbt);
|
||||
});
|
||||
RemoteCall::exportAs(
|
||||
"GMLIB_API",
|
||||
"setPlayerNbtTags",
|
||||
[](std::string uuid, std::string snbt, std::vector<std::string> tags) -> bool {
|
||||
auto uid = mce::UUID::fromString(uuid);
|
||||
auto nbt = CompoundTag::fromSnbt(snbt);
|
||||
return GMLIB_Player::setPlayerNbtTags(uid, *nbt, tags);
|
||||
}
|
||||
);
|
||||
RemoteCall::exportAs("GMLIB_API", "getAllExperiments", []() -> std::vector<int> {
|
||||
auto map = GMLIB_Level::getAllExperiments();
|
||||
std::vector<int> result;
|
||||
@@ -91,6 +109,22 @@ void Export_Compatibility_API() {
|
||||
}
|
||||
return false;
|
||||
});
|
||||
RemoteCall::exportAs("GMLIB_API", "updateClientFloatingTextData", [](int id, Player* pl) -> bool {
|
||||
auto ft = GMLIB::Server::FloatingText::getFloatingText(id);
|
||||
if (ft) {
|
||||
ft->updateClient(pl);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
RemoteCall::exportAs("GMLIB_API", "updateAllClientsFloatingTextData", [](int id) -> bool {
|
||||
auto ft = GMLIB::Server::FloatingText::getFloatingText(id);
|
||||
if (ft) {
|
||||
ft->updateAllClients();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
RemoteCall::exportAs("GMLIB_API", "isVersionMatched", [](int a, int b, int c) -> bool {
|
||||
auto version = SemVersion(a, b, c, "", "");
|
||||
return LIB_VERSION.satisfies(version);
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
#pragma once
|
||||
#include <GMLIB/include_lib.h>
|
||||
#include <include_all.h>
|
||||
#include <RemoteCallAPI.h>
|
||||
|
||||
#define PLUGIN_NAME "GMLIB-LRCA"
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
// This file will make your plugin use LeviLamina's memory operators by default.
|
||||
// This improves the memory management of your plugin and is recommended to use.
|
||||
// You should not modify anything in this file.
|
||||
|
||||
#define LL_MEMORY_OPERATORS
|
||||
|
||||
#include <ll/api/memory/MemoryOperators.h>
|
||||
Reference in New Issue
Block a user