This commit is contained in:
Tsubasa6848
2024-02-26 20:29:58 +08:00
Unverified
4 changed files with 69 additions and 13 deletions
+34 -5
View File
@@ -6,10 +6,15 @@ const GMLIB_API = {
sendFloatingText: ll.import("GMLIB_API", "sendFloatingText"), sendFloatingText: ll.import("GMLIB_API", "sendFloatingText"),
removeFloatingTextFromPlayer: ll.import("GMLIB_API", "removeFloatingTextFromPlayer"), removeFloatingTextFromPlayer: ll.import("GMLIB_API", "removeFloatingTextFromPlayer"),
removeFloatingText: ll.import("GMLIB_API", "removeFloatingText"), removeFloatingText: ll.import("GMLIB_API", "removeFloatingText"),
updateClientFloatingTextData: ll.import("GMLIB_API", "updateClientFloatingTextData"),
updateAllClientsFloatingTextData: ll.import("GMLIB_API", "updateAllClientsFloatingTextData"),
getServerMspt: ll.import("GMLIB_API", "getServerMspt"), getServerMspt: ll.import("GMLIB_API", "getServerMspt"),
getServerCurrentTps: ll.import("GMLIB_API", "getServerCurrentTps"), getServerCurrentTps: ll.import("GMLIB_API", "getServerCurrentTps"),
getServerAverageTps: ll.import("GMLIB_API", "getServerAverageTps"), getServerAverageTps: ll.import("GMLIB_API", "getServerAverageTps"),
getAllPlayerUuids: ll.import("GMLIB_API", "getAllPlayerUuids"), 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"), setEducationFeatureEnabled: ll.import("GMLib_ServerAPI", "setEducationFeatureEnabled"),
registerAbilityCommand: ll.import("GMLib_ServerAPI", "registerAbilityCommand"), registerAbilityCommand: ll.import("GMLib_ServerAPI", "registerAbilityCommand"),
setEnableAchievement: ll.import("GMLib_ServerAPI", "setEnableAchievement"), setEnableAchievement: ll.import("GMLib_ServerAPI", "setEnableAchievement"),
@@ -72,6 +77,14 @@ class StaticFloatingText {
return GMLIB_API.removeFloatingText(this.mRuntimeId); return GMLIB_API.removeFloatingText(this.mRuntimeId);
} }
updateClient(player) {
return GMLIB_API.updateClientFloatingTextData(this.mRuntimeId, player);
}
updateClients() {
return GMLIB_API.updateAllClientsFloatingTextData(this.mRuntimeId);
}
getRuntimeId() { getRuntimeId() {
return this.mRuntimeId; return this.mRuntimeId;
} }
@@ -86,7 +99,7 @@ class StaticFloatingText {
update() { update() {
GMLIB_API.setFloatingTextData(this.mRuntimeId, this.mText); GMLIB_API.setFloatingTextData(this.mRuntimeId, this.mText);
return this.sendToClients(); return this.updateClients();
} }
updateText(newText) { updateText(newText) {
@@ -109,13 +122,13 @@ class StaticFloatingText {
} }
static getFloatingText(runtimeId) { static getFloatingText(runtimeId) {
FloatingTextList.forEach((ft) => { for (const ft of FloatingTextList) {
if (ft.getRuntimeId() == runtimeId) { if (ft.getRuntimeId() == runtimeId) {
if (!ft.isDynamic()) { if (!ft.isDynamic()) {
return ft; return ft;
} }
} }
}); }
return null; return null;
} }
@@ -178,13 +191,13 @@ class DynamicFloatingText extends StaticFloatingText {
} }
static getFloatingText(runtimeId) { static getFloatingText(runtimeId) {
FloatingTextList.forEach((ft) => { for (const ft of FloatingTextList) {
if (ft.getRuntimeId() == runtimeId) { if (ft.getRuntimeId() == runtimeId) {
if (ft.isDynamic()) { if (ft.isDynamic()) {
return ft; return ft;
} }
} }
}); }
return null; return null;
} }
@@ -220,6 +233,22 @@ class Minecraft {
return GMLIB_API.getAllPlayerUuids(); 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() { static setEducationFeatureEnabled() {
return GMLIB_API.setEducationFeatureEnabled(); return GMLIB_API.setEducationFeatureEnabled();
} }
+34
View File
@@ -25,6 +25,24 @@ void Export_Compatibility_API() {
RemoteCall::exportAs("GMLIB_API", "getAllPlayerUuids", []() -> std::vector<std::string> { RemoteCall::exportAs("GMLIB_API", "getAllPlayerUuids", []() -> std::vector<std::string> {
return GMLIB_Player::getAllUuids(); 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> { RemoteCall::exportAs("GMLIB_API", "getAllExperiments", []() -> std::vector<int> {
auto map = GMLIB_Level::getAllExperiments(); auto map = GMLIB_Level::getAllExperiments();
std::vector<int> result; std::vector<int> result;
@@ -91,6 +109,22 @@ void Export_Compatibility_API() {
} }
return false; 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 { RemoteCall::exportAs("GMLIB_API", "isVersionMatched", [](int a, int b, int c) -> bool {
auto version = SemVersion(a, b, c, "", ""); auto version = SemVersion(a, b, c, "", "");
return LIB_VERSION.satisfies(version); return LIB_VERSION.satisfies(version);
+1 -1
View File
@@ -1,5 +1,5 @@
#pragma once #pragma once
#include <GMLIB/include_lib.h> #include <include_all.h>
#include <RemoteCallAPI.h> #include <RemoteCallAPI.h>
#define PLUGIN_NAME "GMLIB-LRCA" #define PLUGIN_NAME "GMLIB-LRCA"
-7
View File
@@ -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>