Compare commits
17 Commits
+1
-1
Submodule SDK-GMLIB updated: 9935ed4063...fd8463224f
+174
-33
@@ -1,3 +1,6 @@
|
|||||||
|
// LiteLoader-AIDS automatic generated
|
||||||
|
/// <reference path="D:\LiteLoader\VSCode/dts/HelperLib-master/src/index.d.ts"/>
|
||||||
|
|
||||||
const GMLIB_API = {
|
const GMLIB_API = {
|
||||||
createFloatingText: ll.import("GMLIB_API", "createFloatingText"),
|
createFloatingText: ll.import("GMLIB_API", "createFloatingText"),
|
||||||
deleteFloatingText: ll.import("GMLIB_API", "deleteFloatingText"),
|
deleteFloatingText: ll.import("GMLIB_API", "deleteFloatingText"),
|
||||||
@@ -16,6 +19,7 @@ const GMLIB_API = {
|
|||||||
setPlayerNbt: ll.import("GMLIB_API", "setPlayerNbt"),
|
setPlayerNbt: ll.import("GMLIB_API", "setPlayerNbt"),
|
||||||
setPlayerNbtTags: ll.import("GMLIB_API", "setPlayerNbtTags"),
|
setPlayerNbtTags: ll.import("GMLIB_API", "setPlayerNbtTags"),
|
||||||
resourcePackTranslate: ll.import("GMLIB_API", "resourcePackTranslate"),
|
resourcePackTranslate: ll.import("GMLIB_API", "resourcePackTranslate"),
|
||||||
|
getResourcePackI18nLanguage: ll.import("GMLIB_API", "getResourcePackI18nLanguage"),
|
||||||
chooseResourcePackI18nLanguage: ll.import("GMLIB_API", "chooseResourcePackI18nLanguage"),
|
chooseResourcePackI18nLanguage: ll.import("GMLIB_API", "chooseResourcePackI18nLanguage"),
|
||||||
setEducationFeatureEnabled: ll.import("GMLib_ServerAPI", "setEducationFeatureEnabled"),
|
setEducationFeatureEnabled: ll.import("GMLib_ServerAPI", "setEducationFeatureEnabled"),
|
||||||
registerAbilityCommand: ll.import("GMLib_ServerAPI", "registerAbilityCommand"),
|
registerAbilityCommand: ll.import("GMLib_ServerAPI", "registerAbilityCommand"),
|
||||||
@@ -34,6 +38,7 @@ const GMLIB_API = {
|
|||||||
getExperimentTranslatedName: ll.import("GMLIB_API", "getExperimentTranslatedName"),
|
getExperimentTranslatedName: ll.import("GMLIB_API", "getExperimentTranslatedName"),
|
||||||
getExperimentEnabled: ll.import("GMLib_ModAPI", "getExperimentEnabled"),
|
getExperimentEnabled: ll.import("GMLib_ModAPI", "getExperimentEnabled"),
|
||||||
setExperimentEnabled: ll.import("GMLib_ModAPI", "setExperimentEnabled"),
|
setExperimentEnabled: ll.import("GMLib_ModAPI", "setExperimentEnabled"),
|
||||||
|
unregisterRecipe: ll.import("GMLIB_API", "unregisterRecipe"),
|
||||||
registerExperimentsRequire: ll.import("GMLib_ModAPI", "registerExperimentsRequire"),
|
registerExperimentsRequire: ll.import("GMLib_ModAPI", "registerExperimentsRequire"),
|
||||||
registerStoneCutterRecipe: ll.import("GMLib_ModAPI", "registerStoneCutterRecipe"),
|
registerStoneCutterRecipe: ll.import("GMLib_ModAPI", "registerStoneCutterRecipe"),
|
||||||
registerSmithingTrimRecipe: ll.import("GMLib_ModAPI", "registerSmithingTrimRecipe"),
|
registerSmithingTrimRecipe: ll.import("GMLib_ModAPI", "registerSmithingTrimRecipe"),
|
||||||
@@ -87,7 +92,8 @@ const GMLIB_API = {
|
|||||||
setWorldSpawn: ll.import("GMLIB_API", "setWorldSpawn"),
|
setWorldSpawn: ll.import("GMLIB_API", "setWorldSpawn"),
|
||||||
getPlayerSpawnPoint: ll.import("GMLIB_API", "getPlayerSpawnPoint"),
|
getPlayerSpawnPoint: ll.import("GMLIB_API", "getPlayerSpawnPoint"),
|
||||||
setPlayerSpawnPoint: ll.import("GMLIB_API", "setPlayerSpawnPoint"),
|
setPlayerSpawnPoint: ll.import("GMLIB_API", "setPlayerSpawnPoint"),
|
||||||
clearPlayerSpawnPoint: ll.import("GMLIB_API", "clearPlayerSpawnPoint")
|
clearPlayerSpawnPoint: ll.import("GMLIB_API", "clearPlayerSpawnPoint"),
|
||||||
|
setCustomPackPath: ll.import("GMLIB_API", "setCustomPackPath")
|
||||||
}
|
}
|
||||||
|
|
||||||
const FloatingTextList = [];
|
const FloatingTextList = [];
|
||||||
@@ -99,10 +105,6 @@ class StaticFloatingText {
|
|||||||
this.mPlaceholderAPI = papi;
|
this.mPlaceholderAPI = papi;
|
||||||
this.mRuntimeId = GMLIB_API.createFloatingText(this.mPosition, this.mText, this.mPlaceholderAPI);
|
this.mRuntimeId = GMLIB_API.createFloatingText(this.mPosition, this.mText, this.mPlaceholderAPI);
|
||||||
FloatingTextList.push(this);
|
FloatingTextList.push(this);
|
||||||
this.sendToClients();
|
|
||||||
mc.listen("onJoin", (pl) => {
|
|
||||||
this.sendToClient(pl);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sendToClient(player) {
|
sendToClient(player) {
|
||||||
@@ -278,22 +280,15 @@ class Minecraft {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static getPlayerNbt(uuid) {
|
static getPlayerNbt(uuid) {
|
||||||
let snbt = GMLIB_API.getPlayerNbt(uuid);
|
return GMLIB_API.getPlayerNbt(uuid);
|
||||||
if (snbt == "null") {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
let nbt = NBT.parseSNBT(snbt);
|
|
||||||
return nbt;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static setPlayerNbt(uuid, nbt, forceCreate = true) {
|
static setPlayerNbt(uuid, nbt, forceCreate = true) {
|
||||||
let snbt = nbt.toSNBT();
|
return GMLIB_API.setPlayerNbt(uuid, nbt, forceCreate);
|
||||||
return GMLIB_API.setPlayerNbt(uuid, snbt, forceCreate);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static setPlayerNbtTags(uuid, nbt, tags) {
|
static setPlayerNbtTags(uuid, nbt, tags) {
|
||||||
let snbt = nbt.toSNBT();
|
return GMLIB_API.setPlayerNbtTags(uuid, nbt, tags);
|
||||||
return GMLIB_API.setPlayerNbtTags(uuid, snbt, tags);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static getPlayerPosition(uuid) {
|
static getPlayerPosition(uuid) {
|
||||||
@@ -316,18 +311,6 @@ class Minecraft {
|
|||||||
return GMLIB_API.setWorldSpawn(pos);
|
return GMLIB_API.setWorldSpawn(pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
static getPlayerSpawnPoint() {
|
|
||||||
return GMLIB_API.getPlayerSpawnPoint();
|
|
||||||
}
|
|
||||||
|
|
||||||
static setPlayerSpawnPoint(pos) {
|
|
||||||
GMLIB_API.setPlayerSpawnPoint(pos);
|
|
||||||
}
|
|
||||||
|
|
||||||
static clearPlayerSpawnPoint() {
|
|
||||||
GMLIB_API.clearPlayerSpawnPoint();
|
|
||||||
}
|
|
||||||
|
|
||||||
static setEducationFeatureEnabled() {
|
static setEducationFeatureEnabled() {
|
||||||
return GMLIB_API.setEducationFeatureEnabled();
|
return GMLIB_API.setEducationFeatureEnabled();
|
||||||
}
|
}
|
||||||
@@ -364,10 +347,6 @@ class Minecraft {
|
|||||||
return GMLIB_API.setUnknownBlockCleaner();
|
return GMLIB_API.setUnknownBlockCleaner();
|
||||||
}
|
}
|
||||||
|
|
||||||
static playerToEntity(player) {
|
|
||||||
return GMLIB_API.PlayerToEntity(player);
|
|
||||||
}
|
|
||||||
|
|
||||||
static spawnEntity(pos, name) {
|
static spawnEntity(pos, name) {
|
||||||
return GMLIB_API.spawnEntity(pos, name);
|
return GMLIB_API.spawnEntity(pos, name);
|
||||||
}
|
}
|
||||||
@@ -380,10 +359,18 @@ class Minecraft {
|
|||||||
return GMLIB_API.throwEntity(entity, proj, speed = 2, offset = 3);
|
return GMLIB_API.throwEntity(entity, proj, speed = 2, offset = 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
static chooseResourcePackI18nLanguage(language) {
|
static getServerLanguage() {
|
||||||
|
return GMLIB_API.getResourcePackI18nLanguage(language);
|
||||||
|
}
|
||||||
|
|
||||||
|
static setServerLanguage(language) {
|
||||||
return GMLIB_API.chooseResourcePackI18nLanguage(language);
|
return GMLIB_API.chooseResourcePackI18nLanguage(language);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static setCustomPackPath(path) {
|
||||||
|
GMLIB_API.setCustomPackPath(path);
|
||||||
|
}
|
||||||
|
|
||||||
static resourcePackTranslate(key, params = []) {
|
static resourcePackTranslate(key, params = []) {
|
||||||
return GMLIB_API.resourcePackTranslate(key, params);
|
return GMLIB_API.resourcePackTranslate(key, params);
|
||||||
}
|
}
|
||||||
@@ -394,6 +381,10 @@ class Recipes {
|
|||||||
throw new Error("Static class cannot be instantiated");
|
throw new Error("Static class cannot be instantiated");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static unregisterRecipe(recipeId) {
|
||||||
|
return GMLIB_API.unregisterRecipe(recipeId);
|
||||||
|
}
|
||||||
|
|
||||||
static registerStoneCutterRecipe(recipeId, inputName, inputAux, outputName, outputAux, outputCount) {
|
static registerStoneCutterRecipe(recipeId, inputName, inputAux, outputName, outputAux, outputCount) {
|
||||||
return GMLIB_API.registerStoneCutterRecipe(recipeId, inputName, inputAux, outputName, outputAux, outputCount);
|
return GMLIB_API.registerStoneCutterRecipe(recipeId, inputName, inputAux, outputName, outputAux, outputCount);
|
||||||
}
|
}
|
||||||
@@ -465,6 +456,53 @@ class Experiments {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class Version {
|
||||||
|
constructor(major, minor, patch) {
|
||||||
|
this.mMajor = major;
|
||||||
|
this.mMinor = minor;
|
||||||
|
this.mPatch = patch;
|
||||||
|
}
|
||||||
|
|
||||||
|
toString(prefix = true) {
|
||||||
|
let result = `${this.mMajor}.${this.mMinor}.${this.mPatch}`;
|
||||||
|
if (prefix) {
|
||||||
|
result = "v" + result;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
toArray() {
|
||||||
|
return [this.mMajor, this.mMinor, this.mPatch];
|
||||||
|
}
|
||||||
|
|
||||||
|
valueOf() {
|
||||||
|
return 100000000 * this.mMajor + 10000 * this.mMinor + this.mPatch;
|
||||||
|
}
|
||||||
|
|
||||||
|
static fromString(string) {
|
||||||
|
if (typeof string === 'string' || string instanceof String) {
|
||||||
|
let pattern = /^v?\d+\.\d+\.\d+$/;
|
||||||
|
if (pattern.test(string)) {
|
||||||
|
let regex = /\d+/g;
|
||||||
|
let numbers = string.match(regex);
|
||||||
|
let array = numbers.slice(0, 3).map(Number);
|
||||||
|
return new Version(array[0], array[1], array[2]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
static fromArray(array) {
|
||||||
|
if (Array.isArray(array) && array.length == 3) {
|
||||||
|
let isNumber = array.every(element => typeof element == "number");
|
||||||
|
if (isNumber) {
|
||||||
|
return new Version(array[0], array[1], array[2])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
class GMLIB {
|
class GMLIB {
|
||||||
constructor() {
|
constructor() {
|
||||||
throw new Error("Static class cannot be instantiated");
|
throw new Error("Static class cannot be instantiated");
|
||||||
@@ -649,6 +687,7 @@ class JsonConfig {
|
|||||||
constructor(path, defultValue = {}) {
|
constructor(path, defultValue = {}) {
|
||||||
this.mData = defultValue;
|
this.mData = defultValue;
|
||||||
this.mPath = path;
|
this.mPath = path;
|
||||||
|
this.init();
|
||||||
}
|
}
|
||||||
|
|
||||||
init() {
|
init() {
|
||||||
@@ -688,6 +727,99 @@ class JsonConfig {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class JsonLanguage extends JsonConfig {
|
||||||
|
constructor(path, defultValue = {}) {
|
||||||
|
super(path, defultValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
translate(key, data = []) {
|
||||||
|
let result = this.get(key);
|
||||||
|
if (result == null) {
|
||||||
|
return key;
|
||||||
|
}
|
||||||
|
data.forEach((val, index) => {
|
||||||
|
let old = `{${index + 1}}`;
|
||||||
|
result = result.split(old).join(val);
|
||||||
|
});
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class JsonI18n {
|
||||||
|
constructor(path, localLangCode = "en_US") {
|
||||||
|
if (!path.endsWith("/") && !path.endsWith("\\")) {
|
||||||
|
path = path + "/";
|
||||||
|
}
|
||||||
|
this.mPath = path;
|
||||||
|
this.mLangCode = localLangCode;
|
||||||
|
this.mAllLanguages = {};
|
||||||
|
this.mDefaultLangCode = "en_US";
|
||||||
|
this.loadAllLanguages();
|
||||||
|
}
|
||||||
|
|
||||||
|
loadAllLanguages() {
|
||||||
|
let exist_list = File.getFilesList(this.mPath);
|
||||||
|
exist_list.forEach((name) => {
|
||||||
|
let code = name.replace(".json", "");
|
||||||
|
let path = this.mPath + name;
|
||||||
|
let language = new JsonLanguage(path);
|
||||||
|
this.mAllLanguages[code] = language;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
loadLanguage(langCode, defaultData = {}) {
|
||||||
|
let langPath = this.mPath;
|
||||||
|
langPath = langPath + langCode + ".json";
|
||||||
|
let language = new JsonLanguage(langPath, defaultData);
|
||||||
|
this.mAllLanguages[langCode] = language;
|
||||||
|
}
|
||||||
|
|
||||||
|
chooseLanguage(langCode) {
|
||||||
|
this.mLangCode = langCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
setDefaultLanguage(langCode) {
|
||||||
|
this.mDefaultLangCode = langCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
translate(key, data = [], langCode = this.mLangCode) {
|
||||||
|
let language = this.mAllLanguages[langCode];
|
||||||
|
let result = language.translate(key, data);
|
||||||
|
if (result == key) {
|
||||||
|
let language = this.mAllLanguages[this.mDefaultLangCode];
|
||||||
|
if (language) {
|
||||||
|
result = language.translate(key, data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
LLSE_Player.prototype.toEntity = function () {
|
||||||
|
return GMLIB_API.PlayerToEntity(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
LLSE_Player.prototype.getSpawnPoint = function () {
|
||||||
|
return GMLIB_API.getPlayerSpawnPoint(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
LLSE_Player.prototype.setSpawnPoint = function (pos) {
|
||||||
|
return GMLIB_API.setPlayerSpawnPoint(this, pos);
|
||||||
|
}
|
||||||
|
|
||||||
|
LLSE_Player.prototype.clearSpawnPoint = function () {
|
||||||
|
return GMLIB_API.clearPlayerSpawnPoint(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
LLSE_Entity.prototype.shootProjectile = function (proj, speed = 2, offset = 3) {
|
||||||
|
return GMLIB_API.shootProjectile(this, proj, speed, offset);
|
||||||
|
}
|
||||||
|
|
||||||
|
LLSE_Entity.prototype.throwEntity = function (proj, speed = 2, offset = 3) {
|
||||||
|
return GMLIB_API.throwEntity(this, proj, speed, offset);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
StaticFloatingText,
|
StaticFloatingText,
|
||||||
DynamicFloatingText,
|
DynamicFloatingText,
|
||||||
@@ -696,5 +828,14 @@ module.exports = {
|
|||||||
Experiments,
|
Experiments,
|
||||||
GMLIB,
|
GMLIB,
|
||||||
Scoreboard,
|
Scoreboard,
|
||||||
JsonConfig
|
JsonConfig,
|
||||||
|
JsonLanguage,
|
||||||
|
JsonI18n,
|
||||||
|
Version
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+2
-1
@@ -1,7 +1,8 @@
|
|||||||
{
|
{
|
||||||
"name": "${pluginName}",
|
"name": "${pluginName}",
|
||||||
"entry": "${pluginFile}",
|
"entry": "${pluginFile}",
|
||||||
"version": "0.9.4",
|
"version": "0.12.4",
|
||||||
|
"author": "GroupMountain",
|
||||||
"type": "native",
|
"type": "native",
|
||||||
"dependencies": [
|
"dependencies": [
|
||||||
{
|
{
|
||||||
|
|||||||
+33
-19
@@ -14,6 +14,16 @@ ActorUniqueID parseScriptUniqueID(std::string uniqueId) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Export_Compatibility_API() {
|
void Export_Compatibility_API() {
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "unregisterRecipe", [](std::string id) -> bool {
|
||||||
|
auto level = GMLIB_Level::getInstance();
|
||||||
|
if (!level) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return GMLIB::Mod::CustomRecipe::unregisterRecipe(id);
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "setCustomPackPath", [](std::string path) -> void {
|
||||||
|
GMLIB::Mod::CustomPacks::addCustomPackPath(path);
|
||||||
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "getServerMspt", []() -> float {
|
RemoteCall::exportAs("GMLIB_API", "getServerMspt", []() -> float {
|
||||||
auto level = GMLIB_Level::getInstance();
|
auto level = GMLIB_Level::getInstance();
|
||||||
if (!level) {
|
if (!level) {
|
||||||
@@ -43,25 +53,21 @@ void Export_Compatibility_API() {
|
|||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "getPlayerNbt", [](std::string uuid) -> std::string {
|
RemoteCall::exportAs("GMLIB_API", "getPlayerNbt", [](std::string uuid) -> std::unique_ptr<CompoundTag> {
|
||||||
auto uid = mce::UUID::fromString(uuid);
|
auto uid = mce::UUID::fromString(uuid);
|
||||||
auto nbt = GMLIB_Player::getPlayerNbt(uid);
|
return std::move(GMLIB_Player::getPlayerNbt(uid));
|
||||||
if (nbt) {
|
|
||||||
return nbt->toSnbt();
|
|
||||||
}
|
|
||||||
return "null";
|
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "setPlayerNbt", [](std::string uuid, std::string snbt, bool forceCreate) -> bool {
|
RemoteCall::exportAs("GMLIB_API", "setPlayerNbt", [](std::string uuid, CompoundTag* nbt, bool forceCreate) -> bool {
|
||||||
auto uid = mce::UUID::fromString(uuid);
|
auto uid = mce::UUID::fromString(uuid);
|
||||||
auto nbt = CompoundTag::fromSnbt(snbt);
|
logger.warn(nbt->toSnbt());
|
||||||
return GMLIB_Player::setPlayerNbt(uid, *nbt, forceCreate);
|
return GMLIB_Player::setPlayerNbt(uid, *nbt, forceCreate);
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs(
|
RemoteCall::exportAs(
|
||||||
"GMLIB_API",
|
"GMLIB_API",
|
||||||
"setPlayerNbtTags",
|
"setPlayerNbtTags",
|
||||||
[](std::string uuid, std::string snbt, std::vector<std::string> tags) -> bool {
|
[](std::string uuid, CompoundTag* nbt, std::vector<std::string> tags) -> bool {
|
||||||
auto uid = mce::UUID::fromString(uuid);
|
auto uid = mce::UUID::fromString(uuid);
|
||||||
auto nbt = CompoundTag::fromSnbt(snbt);
|
logger.warn(nbt->toSnbt());
|
||||||
return GMLIB_Player::setPlayerNbtTags(uid, *nbt, tags);
|
return GMLIB_Player::setPlayerNbtTags(uid, *nbt, tags);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
@@ -84,7 +90,7 @@ void Export_Compatibility_API() {
|
|||||||
"GMLIB_API",
|
"GMLIB_API",
|
||||||
"createFloatingText",
|
"createFloatingText",
|
||||||
[](std::pair<Vec3, int> pos, std::string text, bool papi) -> int {
|
[](std::pair<Vec3, int> pos, std::string text, bool papi) -> int {
|
||||||
auto ft = new GMLIB::Server::FloatingText(text, pos.first, pos.second, papi);
|
auto ft = new GMLIB::Server::StaticFloatingText(text, pos.first, pos.second, papi);
|
||||||
return ft->getRuntimeID();
|
return ft->getRuntimeID();
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
@@ -102,7 +108,7 @@ void Export_Compatibility_API() {
|
|||||||
RemoteCall::exportAs("GMLIB_API", "sendFloatingTextToPlayer", [](int id, Player* pl) -> bool {
|
RemoteCall::exportAs("GMLIB_API", "sendFloatingTextToPlayer", [](int id, Player* pl) -> bool {
|
||||||
auto ft = GMLIB::Server::FloatingText::getFloatingText(id);
|
auto ft = GMLIB::Server::FloatingText::getFloatingText(id);
|
||||||
if (ft) {
|
if (ft) {
|
||||||
ft->sendToClient(pl);
|
ft->sendToClient(*pl);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@@ -118,7 +124,7 @@ void Export_Compatibility_API() {
|
|||||||
RemoteCall::exportAs("GMLIB_API", "removeFloatingTextFromPlayer", [](int id, Player* pl) -> bool {
|
RemoteCall::exportAs("GMLIB_API", "removeFloatingTextFromPlayer", [](int id, Player* pl) -> bool {
|
||||||
auto ft = GMLIB::Server::FloatingText::getFloatingText(id);
|
auto ft = GMLIB::Server::FloatingText::getFloatingText(id);
|
||||||
if (ft) {
|
if (ft) {
|
||||||
ft->removeFromClient(pl);
|
ft->removeFromClient(*pl);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@@ -134,7 +140,7 @@ void Export_Compatibility_API() {
|
|||||||
RemoteCall::exportAs("GMLIB_API", "updateClientFloatingTextData", [](int id, Player* pl) -> bool {
|
RemoteCall::exportAs("GMLIB_API", "updateClientFloatingTextData", [](int id, Player* pl) -> bool {
|
||||||
auto ft = GMLIB::Server::FloatingText::getFloatingText(id);
|
auto ft = GMLIB::Server::FloatingText::getFloatingText(id);
|
||||||
if (ft) {
|
if (ft) {
|
||||||
ft->updateClient(pl);
|
ft->updateClient(*pl);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@@ -148,8 +154,8 @@ void Export_Compatibility_API() {
|
|||||||
return false;
|
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 = GMLIB::Version(a, b, c, "", "");
|
||||||
return LIB_VERSION.satisfies(version);
|
return version >= LIB_VERSION;
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "getVersion_LRCA", []() -> std::string { return LIB_VERSION.asString(); });
|
RemoteCall::exportAs("GMLIB_API", "getVersion_LRCA", []() -> std::string { return LIB_VERSION.asString(); });
|
||||||
RemoteCall::exportAs("GMLIB_API", "getVersion_GMLIB", []() -> std::string {
|
RemoteCall::exportAs("GMLIB_API", "getVersion_GMLIB", []() -> std::string {
|
||||||
@@ -158,10 +164,18 @@ void Export_Compatibility_API() {
|
|||||||
RemoteCall::exportAs(
|
RemoteCall::exportAs(
|
||||||
"GMLIB_API",
|
"GMLIB_API",
|
||||||
"resourcePackTranslate",
|
"resourcePackTranslate",
|
||||||
[](std::string key, std::vector<std::string> params) -> std::string { return I18n::get(key, params); }
|
[](std::string key, std::vector<std::string> params) -> std::string { return I18nAPI::get(key, params); }
|
||||||
);
|
);
|
||||||
RemoteCall::exportAs("GMLIB_API", "chooseResourcePackI18nLanguage", [](std::string code) -> void {
|
RemoteCall::exportAs("GMLIB_API", "chooseResourcePackI18nLanguage", [](std::string code) -> void {
|
||||||
I18n::chooseLanguage(code);
|
if (GMLIB_Level::getInstance()) {
|
||||||
|
I18nAPI::chooseLanguage(code);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "getResourcePackI18nLanguage", []() -> std::string {
|
||||||
|
if (GMLIB_Level::getInstance()) {
|
||||||
|
return I18nAPI::getCurrentLanguageCode();
|
||||||
|
}
|
||||||
|
return "unknown";
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "getPlayerPosition", [](std::string uuid) -> std::pair<BlockPos, int> {
|
RemoteCall::exportAs("GMLIB_API", "getPlayerPosition", [](std::string uuid) -> std::pair<BlockPos, int> {
|
||||||
auto uid = mce::UUID::fromString(uuid);
|
auto uid = mce::UUID::fromString(uuid);
|
||||||
@@ -376,7 +390,7 @@ void Export_Compatibility_API() {
|
|||||||
auto auids = GMLIB_Scoreboard::getInstance()->getInstance()->getAllEntities();
|
auto auids = GMLIB_Scoreboard::getInstance()->getInstance()->getAllEntities();
|
||||||
std::vector<std::string> result;
|
std::vector<std::string> result;
|
||||||
for (auto auid : auids) {
|
for (auto auid : auids) {
|
||||||
result.push_back(std::to_string(auid.get()));
|
result.push_back(std::to_string(auid.id));
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
});
|
});
|
||||||
|
|||||||
+5
-1
@@ -17,7 +17,11 @@ bool LRCA::load() {
|
|||||||
ExportPAPI();
|
ExportPAPI();
|
||||||
Export_Event_API();
|
Export_Event_API();
|
||||||
logger.info("GMLIB-LegacyRemoteCallApi Loaded!");
|
logger.info("GMLIB-LegacyRemoteCallApi Loaded!");
|
||||||
logger.info("Version: {}", LIB_VERSION.asString());
|
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())
|
||||||
|
);
|
||||||
logger.info("Author: GroupMountain");
|
logger.info("Author: GroupMountain");
|
||||||
logger.info("Repository: https://github.com/GroupMountain/GMLIB-LegacyRemoteCallApi");
|
logger.info("Repository: https://github.com/GroupMountain/GMLIB-LegacyRemoteCallApi");
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
+43
-6
@@ -105,14 +105,13 @@ void Export_Event_API() {
|
|||||||
);
|
);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
case doHash("onTextSend"): {
|
case doHash("onEntityChangeDim"): {
|
||||||
auto Call = RemoteCall::importAs<bool(std::string author, std::string message)>(eventName, eventId);
|
auto Call = RemoteCall::importAs<bool(Actor * entity, int toDimId)>(eventName, eventId);
|
||||||
eventBus->emplaceListener<GMLIB::Event::PacketEvent::TextPacketSendBeforeEvent>(
|
eventBus->emplaceListener<GMLIB::Event::EntityEvent::ActorChangeDimensionBeforeEvent>(
|
||||||
[Call](GMLIB::Event::PacketEvent::TextPacketSendBeforeEvent& ev) {
|
[Call](GMLIB::Event::EntityEvent::ActorChangeDimensionBeforeEvent& ev) {
|
||||||
auto pkt = ev.getPacket();
|
|
||||||
bool result = true;
|
bool result = true;
|
||||||
try {
|
try {
|
||||||
result = Call(pkt.mAuthor, pkt.mMessage);
|
result = Call(&ev.self(), ev.getToDimensionId());
|
||||||
} catch (...) {}
|
} catch (...) {}
|
||||||
if (!result) {
|
if (!result) {
|
||||||
ev.cancel();
|
ev.cancel();
|
||||||
@@ -152,6 +151,44 @@ void Export_Event_API() {
|
|||||||
);
|
);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
case doHash("onMobHurted"): {
|
||||||
|
auto Call = RemoteCall::importAs<bool(Actor * mob, Actor * source, float damage, int cause)>(
|
||||||
|
eventName,
|
||||||
|
eventId
|
||||||
|
);
|
||||||
|
eventBus->emplaceListener<GMLIB::Event::EntityEvent::MobHurtAfterEvent>(
|
||||||
|
[Call](GMLIB::Event::EntityEvent::MobHurtAfterEvent& ev) {
|
||||||
|
auto& damageSource = ev.getSource();
|
||||||
|
Actor* source = nullptr;
|
||||||
|
if (damageSource.isEntitySource()) {
|
||||||
|
auto uniqueId = damageSource.getDamagingEntityUniqueID();
|
||||||
|
source = ll::service::getLevel()->fetchEntity(uniqueId);
|
||||||
|
if (source->getOwner()) {
|
||||||
|
source = source->getOwner();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
Call(&ev.self(), source, ev.getDamage(), (int)damageSource.getCause());
|
||||||
|
} catch (...) {}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
case doHash("onEndermanTake"): {
|
||||||
|
auto Call = RemoteCall::importAs<bool(Actor * mob)>(eventName, eventId);
|
||||||
|
eventBus->emplaceListener<GMLIB::Event::EntityEvent::EndermanTakeBlockBeforeEvent>(
|
||||||
|
[Call](GMLIB::Event::EntityEvent::EndermanTakeBlockBeforeEvent& ev) {
|
||||||
|
bool result = true;
|
||||||
|
try {
|
||||||
|
result = Call(&ev.self());
|
||||||
|
} catch (...) {}
|
||||||
|
if (!result) {
|
||||||
|
ev.cancel();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-2
@@ -3,8 +3,9 @@
|
|||||||
|
|
||||||
#include <RemoteCallAPI.h>
|
#include <RemoteCallAPI.h>
|
||||||
|
|
||||||
#define PLUGIN_NAME "GMLIB-LRCA"
|
#define PLUGIN_NAME fmt::format(fg(fmt::color::light_green), "GMLIB-LRCA")
|
||||||
#define LIB_VERSION SemVersion(0, 9, 4, "", "")
|
|
||||||
|
#define LIB_VERSION GMLIB::Version(0, 12, 2)
|
||||||
|
|
||||||
extern ll::Logger logger;
|
extern ll::Logger logger;
|
||||||
|
|
||||||
|
|||||||
@@ -2,16 +2,18 @@
|
|||||||
|
|
||||||
void Export_Legacy_GMLib_ServerAPI() {
|
void Export_Legacy_GMLib_ServerAPI() {
|
||||||
RemoteCall::exportAs("GMLib_ServerAPI", "setEducationFeatureEnabled", []() -> void {
|
RemoteCall::exportAs("GMLib_ServerAPI", "setEducationFeatureEnabled", []() -> void {
|
||||||
GMLIB_Level::addEducationEditionRequired();
|
GMLIB_Level::tryEnableEducationEdition();
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLib_ServerAPI", "registerAbilityCommand", []() -> void {
|
RemoteCall::exportAs("GMLib_ServerAPI", "registerAbilityCommand", []() -> void {
|
||||||
GMLIB_Level::forceEnableAbilityCommand();
|
GMLIB_Level::tryRegisterAbilityCommand();
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLib_ServerAPI", "setEnableAchievement", []() -> void {
|
RemoteCall::exportAs("GMLib_ServerAPI", "setEnableAchievement", []() -> void {
|
||||||
GMLIB_Level::setForceAchievementsEnabled();
|
GMLIB_Level::setForceAchievementsEnabled();
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLib_ServerAPI", "setForceTrustSkins", []() -> void { GMLIB_Level::setForceTrustSkin(); });
|
RemoteCall::exportAs("GMLib_ServerAPI", "setForceTrustSkins", []() -> void { GMLIB_Level::trustAllSkins(); });
|
||||||
RemoteCall::exportAs("GMLib_ServerAPI", "enableCoResourcePack", []() -> void { GMLIB_Level::setCoResourcePack(); });
|
RemoteCall::exportAs("GMLib_ServerAPI", "enableCoResourcePack", []() -> void {
|
||||||
|
GMLIB_Level::requireServerResourcePackAndAllowClientResourcePack();
|
||||||
|
});
|
||||||
RemoteCall::exportAs("GMLib_ServerAPI", "getLevelName", []() -> std::string {
|
RemoteCall::exportAs("GMLib_ServerAPI", "getLevelName", []() -> std::string {
|
||||||
auto level = GMLIB_Level::getInstance();
|
auto level = GMLIB_Level::getInstance();
|
||||||
if (!level) {
|
if (!level) {
|
||||||
|
|||||||
+60
-26
@@ -3,6 +3,16 @@
|
|||||||
|
|
||||||
namespace PAPIRemoteCall {
|
namespace PAPIRemoteCall {
|
||||||
|
|
||||||
|
std::string removeBrackets(std::string a1) {
|
||||||
|
a1.erase(a1.find_last_not_of("%") + 1);
|
||||||
|
return a1;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool isParameters(std::string 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 GMLIB::Server::PlaceholderAPI::getValue(from); }
|
||||||
|
|
||||||
std::string GetValueWithPlayer(std::string const& a1, std::string const& a2) {
|
std::string GetValueWithPlayer(std::string const& a1, std::string const& a2) {
|
||||||
@@ -15,12 +25,24 @@ bool registerPlayerPlaceholder(
|
|||||||
std::string const& PAPIName
|
std::string const& PAPIName
|
||||||
) {
|
) {
|
||||||
if (RemoteCall::hasFunc(PluginName, FuncName)) {
|
if (RemoteCall::hasFunc(PluginName, FuncName)) {
|
||||||
auto Call = RemoteCall::importAs<std::string(Player * pl)>(PluginName, FuncName);
|
if (isParameters(PAPIName)) {
|
||||||
GMLIB::Server::PlaceholderAPI::registerPlayerPlaceholder(
|
auto Call = RemoteCall::importAs<std::string(Player * pl, std::unordered_map<std::string, std::string>)>(
|
||||||
PAPIName,
|
PluginName,
|
||||||
[Call](Player* sp) { return Call(sp); },
|
FuncName
|
||||||
PluginName
|
);
|
||||||
);
|
GMLIB::Server::PlaceholderAPI::registerPlayerPlaceholder(
|
||||||
|
PAPIName,
|
||||||
|
[Call](Player* sp, std::unordered_map<std::string, std::string> map) { return Call(sp, map); },
|
||||||
|
PluginName
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
auto Call = RemoteCall::importAs<std::string(Player * pl)>(PluginName, FuncName);
|
||||||
|
GMLIB::Server::PlaceholderAPI::registerPlayerPlaceholder(
|
||||||
|
PAPIName,
|
||||||
|
[Call](Player* sp) { return Call(sp); },
|
||||||
|
PluginName
|
||||||
|
);
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@@ -32,12 +54,22 @@ bool registerServerPlaceholder(
|
|||||||
std::string const& PAPIName
|
std::string const& PAPIName
|
||||||
) {
|
) {
|
||||||
if (RemoteCall::hasFunc(PluginName, FuncName)) {
|
if (RemoteCall::hasFunc(PluginName, FuncName)) {
|
||||||
auto Call = RemoteCall::importAs<std::string()>(PluginName, FuncName);
|
if (isParameters(PAPIName)) {
|
||||||
GMLIB::Server::PlaceholderAPI::registerServerPlaceholder(
|
auto Call =
|
||||||
PAPIName,
|
RemoteCall::importAs<std::string(std::unordered_map<std::string, std::string>)>(PluginName, FuncName);
|
||||||
[Call]() { return Call(); },
|
GMLIB::Server::PlaceholderAPI::registerServerPlaceholder(
|
||||||
PluginName
|
PAPIName,
|
||||||
);
|
[Call](std::unordered_map<std::string, std::string> map) { return Call(map); },
|
||||||
|
PluginName
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
auto Call = RemoteCall::importAs<std::string()>(PluginName, FuncName);
|
||||||
|
GMLIB::Server::PlaceholderAPI::registerServerPlaceholder(
|
||||||
|
PAPIName,
|
||||||
|
[Call]() { return Call(); },
|
||||||
|
PluginName
|
||||||
|
);
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@@ -50,20 +82,22 @@ bool registerStaticPlaceholder(
|
|||||||
int num
|
int num
|
||||||
) {
|
) {
|
||||||
if (RemoteCall::hasFunc(PluginName, FuncName)) {
|
if (RemoteCall::hasFunc(PluginName, FuncName)) {
|
||||||
auto Call = RemoteCall::importAs<std::string()>(PluginName, FuncName);
|
if (isParameters(PAPIName)) {
|
||||||
if (num == -1) {
|
auto Call = RemoteCall::importAs<std::string()>(PluginName, FuncName);
|
||||||
GMLIB::Server::PlaceholderAPI::registerStaticPlaceholder(
|
if (num == -1) {
|
||||||
PAPIName,
|
GMLIB::Server::PlaceholderAPI::registerStaticPlaceholder(
|
||||||
[Call] { return Call(); },
|
PAPIName,
|
||||||
PluginName
|
[Call] { return Call(); },
|
||||||
);
|
PluginName
|
||||||
} else {
|
);
|
||||||
GMLIB::Server::PlaceholderAPI::registerStaticPlaceholder(
|
} else {
|
||||||
PAPIName,
|
GMLIB::Server::PlaceholderAPI::registerStaticPlaceholder(
|
||||||
num,
|
PAPIName,
|
||||||
[Call] { return Call(); },
|
num,
|
||||||
PluginName
|
[Call] { return Call(); },
|
||||||
);
|
PluginName
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-3
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"format_version": 2,
|
"format_version": 2,
|
||||||
"tooth": "github.com/GroupMountain/GMLIB-LegacyRemoteCallApi",
|
"tooth": "github.com/GroupMountain/GMLIB-LegacyRemoteCallApi",
|
||||||
"version": "0.9.4",
|
"version": "0.12.2",
|
||||||
"info": {
|
"info": {
|
||||||
"name": "GMLIB-LegacyRemoteCallApi",
|
"name": "GMLIB-LegacyRemoteCallApi",
|
||||||
"description": "Legacy RemoteCall API for GMLIB",
|
"description": "Legacy RemoteCall API for GMLIB",
|
||||||
@@ -14,9 +14,9 @@
|
|||||||
"library"
|
"library"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"asset_url": "https://github.com/GroupMountain/GMLIB-LegacyRemoteCallApi/releases/download/v0.9.4/GMLIB-LegacyRemoteCallApi-windows-x64.zip",
|
"asset_url": "https://github.com/GroupMountain/GMLIB-LegacyRemoteCallApi/releases/download/v0.12.2/GMLIB-LegacyRemoteCallApi-windows-x64.zip",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"github.com/GroupMountain/GMLIB": ">=0.9.6"
|
"github.com/GroupMountain/GMLIB": ">=0.12.4"
|
||||||
},
|
},
|
||||||
"files": {
|
"files": {
|
||||||
"place": [
|
"place": [
|
||||||
|
|||||||
Reference in New Issue
Block a user