Compare commits
76 Commits
@@ -9,10 +9,6 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v2
|
||||||
with:
|
|
||||||
submodules: recursive
|
|
||||||
|
|
||||||
- uses: actions/checkout@v4
|
|
||||||
|
|
||||||
- uses: xmake-io/github-action-setup-xmake@v1
|
- uses: xmake-io/github-action-setup-xmake@v1
|
||||||
|
|
||||||
@@ -29,4 +25,10 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
name: ${{ github.event.repository.name }}-windows-x64-${{ github.sha }}
|
name: ${{ github.event.repository.name }}-windows-x64-${{ github.sha }}
|
||||||
path: |
|
path: |
|
||||||
bin/
|
bin/DLL/
|
||||||
|
|
||||||
|
- uses: actions/upload-artifact@v3
|
||||||
|
with:
|
||||||
|
name: PDB
|
||||||
|
path: |
|
||||||
|
bin/PDB/
|
||||||
|
|||||||
@@ -9,10 +9,6 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v2
|
||||||
with:
|
|
||||||
submodules: recursive
|
|
||||||
|
|
||||||
- uses: actions/checkout@v4
|
|
||||||
|
|
||||||
- uses: xmake-io/github-action-setup-xmake@v1
|
- uses: xmake-io/github-action-setup-xmake@v1
|
||||||
|
|
||||||
@@ -29,7 +25,13 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
name: ${{ github.event.repository.name }}-windows-x64-${{ github.sha }}
|
name: ${{ github.event.repository.name }}-windows-x64-${{ github.sha }}
|
||||||
path: |
|
path: |
|
||||||
bin/
|
bin/DLL/
|
||||||
|
|
||||||
|
- uses: actions/upload-artifact@v3
|
||||||
|
with:
|
||||||
|
name: PDB
|
||||||
|
path: |
|
||||||
|
bin/PDB/
|
||||||
|
|
||||||
upload-to-release:
|
upload-to-release:
|
||||||
needs:
|
needs:
|
||||||
@@ -38,24 +40,35 @@ jobs:
|
|||||||
contents: write
|
contents: write
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
- uses: actions/download-artifact@v3
|
- name: Download Plugin
|
||||||
|
uses: actions/download-artifact@v3
|
||||||
with:
|
with:
|
||||||
name: ${{ github.event.repository.name }}-windows-x64-${{ github.sha }}
|
name: ${{ github.event.repository.name }}-windows-x64-${{ github.sha }}
|
||||||
path: release/
|
path: release/Plugin/
|
||||||
|
|
||||||
- run: |
|
- name: Download PDB
|
||||||
cp LICENSE README.md release/
|
uses: actions/download-artifact@v3
|
||||||
|
with:
|
||||||
|
name: PDB
|
||||||
|
path: release/PDB/
|
||||||
|
|
||||||
|
- name: Copy additional files
|
||||||
|
run: |
|
||||||
|
cp LICENSE README.md release/Plugin/
|
||||||
|
|
||||||
- name: Archive release
|
- name: Archive release
|
||||||
run: |
|
run: |
|
||||||
cd release
|
cd release/Plugin
|
||||||
zip -r ../${{ github.event.repository.name }}-windows-x64.zip *
|
zip -r ../${{ github.event.repository.name }}-windows-x64.zip *
|
||||||
cd ..
|
cd ..
|
||||||
|
|
||||||
- uses: softprops/action-gh-release@v1
|
- name: Create GitHub Release
|
||||||
|
id: create_release
|
||||||
|
uses: softprops/action-gh-release@v1
|
||||||
with:
|
with:
|
||||||
append_body: true
|
|
||||||
files: |
|
files: |
|
||||||
${{ github.event.repository.name }}-windows-x64.zip
|
release/${{ github.event.repository.name }}-windows-x64.zip
|
||||||
|
release/PDB/${{ github.event.repository.name }}.pdb
|
||||||
|
|||||||
@@ -15,3 +15,4 @@ build/
|
|||||||
/.xmake
|
/.xmake
|
||||||
/CMakeLists.txt
|
/CMakeLists.txt
|
||||||
/bin
|
/bin
|
||||||
|
.cache/clangd/index
|
||||||
|
|||||||
@@ -1,3 +0,0 @@
|
|||||||
[submodule "SDK-GMLIB"]
|
|
||||||
path = SDK-GMLIB
|
|
||||||
url = https://github.com/GroupMountain/SDK-GMLIB.git
|
|
||||||
@@ -5,6 +5,5 @@ Legacy RemoteCall API for GMLIB. Only for legacy LSE plugin compatibility.
|
|||||||
- 本模块是 `GMLIB` 的 `Legacy RemoteCall API` 模块,是为LL2的LLSE插件的兼容性保留。
|
- 本模块是 `GMLIB` 的 `Legacy RemoteCall API` 模块,是为LL2的LLSE插件的兼容性保留。
|
||||||
- 通过本模块,可以使LSE插件调用 `GMLIB` 内部的API。
|
- 通过本模块,可以使LSE插件调用 `GMLIB` 内部的API。
|
||||||
|
|
||||||
# 注意事项
|
# 开发文档
|
||||||
- 本模块仅为兼容性保留模块,仅保留过去的接口以保留兼容性。
|
- https://groupmountain.github.io/Documentation/
|
||||||
- 本模块不会提供 `GMLIB` 在迁移到 `LeviLamina` 后新开发的接口。
|
|
||||||
|
|||||||
-1
Submodule SDK-GMLIB deleted from 2bb91343e1
+692
-75
@@ -15,7 +15,10 @@ const GMLIB_API = {
|
|||||||
getPlayerNbt: ll.import("GMLIB_API", "getPlayerNbt"),
|
getPlayerNbt: ll.import("GMLIB_API", "getPlayerNbt"),
|
||||||
setPlayerNbt: ll.import("GMLIB_API", "setPlayerNbt"),
|
setPlayerNbt: ll.import("GMLIB_API", "setPlayerNbt"),
|
||||||
setPlayerNbtTags: ll.import("GMLIB_API", "setPlayerNbtTags"),
|
setPlayerNbtTags: ll.import("GMLIB_API", "setPlayerNbtTags"),
|
||||||
|
deletePlayerNbt: ll.import("GMLIB_API", "deletePlayerNbt"),
|
||||||
resourcePackTranslate: ll.import("GMLIB_API", "resourcePackTranslate"),
|
resourcePackTranslate: ll.import("GMLIB_API", "resourcePackTranslate"),
|
||||||
|
resourcePackDefaultTranslate: ll.import("GMLIB_API", "resourcePackDefaultTranslate"),
|
||||||
|
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"),
|
||||||
@@ -31,9 +34,10 @@ const GMLIB_API = {
|
|||||||
PlayerToEntity: ll.import("GMLib_ServerAPI", "PlayerToEntity"),
|
PlayerToEntity: ll.import("GMLib_ServerAPI", "PlayerToEntity"),
|
||||||
setUnknownBlockCleaner: ll.import("GMLib_ModAPI", "setUnknownBlockCleaner"),
|
setUnknownBlockCleaner: ll.import("GMLib_ModAPI", "setUnknownBlockCleaner"),
|
||||||
getAllExperiments: ll.import("GMLIB_API", "getAllExperiments"),
|
getAllExperiments: ll.import("GMLIB_API", "getAllExperiments"),
|
||||||
getExperimentTranslatedName: ll.import("GMLIB_API", "getExperimentTranslatedName"),
|
getExperimentTranslateKey: ll.import("GMLIB_API", "getExperimentTranslateKey"),
|
||||||
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"),
|
||||||
@@ -45,10 +49,89 @@ const GMLIB_API = {
|
|||||||
registerShapelessRecipe: ll.import("GMLib_ModAPI", "registerShapelessRecipe"),
|
registerShapelessRecipe: ll.import("GMLib_ModAPI", "registerShapelessRecipe"),
|
||||||
isVersionMatched: ll.import("GMLIB_API", "isVersionMatched"),
|
isVersionMatched: ll.import("GMLIB_API", "isVersionMatched"),
|
||||||
getVersion_LRCA: ll.import("GMLIB_API", "getVersion_LRCA"),
|
getVersion_LRCA: ll.import("GMLIB_API", "getVersion_LRCA"),
|
||||||
getVersion_GMLIB: ll.import("GMLIB_API", "getVersion_GMLIB")
|
getVersion_GMLIB: ll.import("GMLIB_API", "getVersion_GMLIB"),
|
||||||
|
getPlayerPosition: ll.import("GMLIB_API", "getPlayerPosition"),
|
||||||
|
setPlayerPosition: ll.import("GMLIB_API", "setPlayerPosition"),
|
||||||
|
playerHasScore: ll.import("GMLIB_API", "playerHasScore"),
|
||||||
|
getPlayerScore: ll.import("GMLIB_API", "getPlayerScore"),
|
||||||
|
addPlayerScore: ll.import("GMLIB_API", "addPlayerScore"),
|
||||||
|
reducePlayerScore: ll.import("GMLIB_API", "reducePlayerScore"),
|
||||||
|
setPlayerScore: ll.import("GMLIB_API", "setPlayerScore"),
|
||||||
|
resetPlayerScore: ll.import("GMLIB_API", "resetPlayerScore"),
|
||||||
|
resetPlayerScores: ll.import("GMLIB_API", "resetPlayerScores"),
|
||||||
|
entityHasScore: ll.import("GMLIB_API", "entityHasScore"),
|
||||||
|
getEntityScore: ll.import("GMLIB_API", "getEntityScore"),
|
||||||
|
addEntityScore: ll.import("GMLIB_API", "addEntityScore"),
|
||||||
|
reduceEntityScore: ll.import("GMLIB_API", "reduceEntityScore"),
|
||||||
|
setEntityScore: ll.import("GMLIB_API", "setEntityScore"),
|
||||||
|
resetEntityScore: ll.import("GMLIB_API", "resetEntityScore"),
|
||||||
|
resetEntityScores: ll.import("GMLIB_API", "resetEntityScores"),
|
||||||
|
fakePlayerHasScore: ll.import("GMLIB_API", "fakePlayerHasScore"),
|
||||||
|
getFakePlayerScore: ll.import("GMLIB_API", "getFakePlayerScore"),
|
||||||
|
addFakePlayerScore: ll.import("GMLIB_API", "addFakePlayerScore"),
|
||||||
|
reduceFakePlayerScore: ll.import("GMLIB_API", "reduceFakePlayerScore"),
|
||||||
|
setFakePlayerScore: ll.import("GMLIB_API", "setFakePlayerScore"),
|
||||||
|
resetFakePlayerScore: ll.import("GMLIB_API", "resetFakePlayerScore"),
|
||||||
|
resetFakePlayerScores: ll.import("GMLIB_API", "resetFakePlayerScores"),
|
||||||
|
addObjective: ll.import("GMLIB_API", "addObjective"),
|
||||||
|
addObjectiveWithDisplayName: ll.import("GMLIB_API", "addObjectiveWithDisplayName"),
|
||||||
|
getDisplayName: ll.import("GMLIB_API", "getDisplayName"),
|
||||||
|
setDisplayName: ll.import("GMLIB_API", "setDisplayName"),
|
||||||
|
removeObjective: ll.import("GMLIB_API", "removeObjective"),
|
||||||
|
setDisplayObjective: ll.import("GMLIB_API", "setDisplayObjective"),
|
||||||
|
clearDisplayObjective: ll.import("GMLIB_API", "clearDisplayObjective"),
|
||||||
|
getAllObjectives: ll.import("GMLIB_API", "getAllObjectives"),
|
||||||
|
getAllTrackedTargets: ll.import("GMLIB_API", "getAllTrackedTargets"),
|
||||||
|
getAllScoreboardPlayers: ll.import("GMLIB_API", "getAllScoreboardPlayers"),
|
||||||
|
getAllScoreboardFakePlayers: ll.import("GMLIB_API", "getAllScoreboardFakePlayers"),
|
||||||
|
getAllScoreboardEntities: ll.import("GMLIB_API", "getAllScoreboardEntities"),
|
||||||
|
getPlayerFromUuid: ll.import("GMLIB_API", "getPlayerFromUuid"),
|
||||||
|
getPlayerFromUniqueId: ll.import("GMLIB_API", "getPlayerFromUniqueId"),
|
||||||
|
getEntityFromUniqueId: ll.import("GMLIB_API", "getEntityFromUniqueId"),
|
||||||
|
getWorldSpawn: ll.import("GMLIB_API", "getWorldSpawn"),
|
||||||
|
setWorldSpawn: ll.import("GMLIB_API", "setWorldSpawn"),
|
||||||
|
getPlayerSpawnPoint: ll.import("GMLIB_API", "getPlayerSpawnPoint"),
|
||||||
|
setPlayerSpawnPoint: ll.import("GMLIB_API", "setPlayerSpawnPoint"),
|
||||||
|
clearPlayerSpawnPoint: ll.import("GMLIB_API", "clearPlayerSpawnPoint"),
|
||||||
|
setCustomPackPath: ll.import("GMLIB_API", "setCustomPackPath"),
|
||||||
|
getSupportedLanguages: ll.import("GMLIB_API", "getSupportedLanguages"),
|
||||||
|
loadLanguage: ll.import("GMLIB_API", "loadLanguage"),
|
||||||
|
updateOrCreateLanguageFile: ll.import("GMLIB_API", "updateOrCreateLanguageFile"),
|
||||||
|
loadLanguagePath: ll.import("GMLIB_API", "loadLanguagePath"),
|
||||||
|
mergePatchJson: ll.import("GMLIB_API", "mergePatchJson"),
|
||||||
|
getXuidByUuid: ll.import("GMLIB_API", "getXuidByUuid"),
|
||||||
|
getNameByUuid: ll.import("GMLIB_API", "getNameByUuid"),
|
||||||
|
getUuidByXuid: ll.import("GMLIB_API", "getUuidByXuid"),
|
||||||
|
getNameByXuid: ll.import("GMLIB_API", "getNameByXuid"),
|
||||||
|
getXuidByName: ll.import("GMLIB_API", "getXuidByName"),
|
||||||
|
getUuidByName: ll.import("GMLIB_API", "getUuidByName"),
|
||||||
|
getAllPlayerInfo: ll.import("GMLIB_API", "getAllPlayerInfo"),
|
||||||
|
getBlockRuntimeId: ll.import("GMLIB_API", "getBlockRuntimeId"),
|
||||||
|
addFakeList: ll.import("GMLIB_API", "addFakeList"),
|
||||||
|
removeFakeList: ll.import("GMLIB_API", "removeFakeList"),
|
||||||
|
removeAllFakeLists: ll.import("GMLIB_API", "removeAllFakeList"),
|
||||||
|
setFixI18nEnabled: ll.import("GMLib_ModAPI", "setFixI18nEnabled"),
|
||||||
|
getBlockTranslateKey: ll.import("GMLIB_API", "getBlockTranslateKey"),
|
||||||
|
getItemTranslateKey: ll.import("GMLIB_API", "getItemTranslateKey"),
|
||||||
|
getEntityTranslateKey: ll.import("GMLIB_API", "getEntityTranslateKey"),
|
||||||
|
readNbtFromFile: ll.import("GMLIB_API", "readNbtFromFile"),
|
||||||
|
saveNbtToFile: ll.import("GMLIB_API", "saveNbtToFile"),
|
||||||
|
getBlockDestroySpeed: ll.import("GMLIB_API", "getBlockDestroySpeed"),
|
||||||
|
getDestroyBlockSpeed: ll.import("GMLIB_API", "getDestroyBlockSpeed"),
|
||||||
|
playerDestroyBlock: ll.import("GMLIB_API", "playerDestroyBlock"),
|
||||||
|
itemCanDestroyBlock: ll.import("GMLIB_API", "itemCanDestroyBlock"),
|
||||||
|
itemCanDestroyInCreative: ll.import("GMLIB_API", "itemCanDestroyInCreative"),
|
||||||
|
itemCanDestroySpecial: ll.import("GMLIB_API", "itemCanDestroySpecial"),
|
||||||
|
blockCanDropWithAnyTool: ll.import("GMLIB_API", "blockCanDropWithAnyTool"),
|
||||||
|
blockIsAlwaysDestroyable: ll.import("GMLIB_API", "blockIsAlwaysDestroyable"),
|
||||||
|
blockPlayerWillDestroy: ll.import("GMLIB_API", "blockPlayerWillDestroy"),
|
||||||
|
playerAttack: ll.import("GMLIB_API", "playerAttack"),
|
||||||
|
playerPullInEntity: ll.import("GMLIB_API", "playerPullInEntity"),
|
||||||
|
getBlockTranslateKeyFromName: ll.import("GMLIB_API", "getBlockTranslateKeyFromName")
|
||||||
}
|
}
|
||||||
|
|
||||||
const FloatingTextList = [];
|
const mStaticFloatingTextMap = new Map();
|
||||||
|
const mDynamicFloatingTextMap = new Map();
|
||||||
|
|
||||||
class StaticFloatingText {
|
class StaticFloatingText {
|
||||||
constructor(pos, text, papi = true) {
|
constructor(pos, text, papi = true) {
|
||||||
@@ -56,11 +139,7 @@ class StaticFloatingText {
|
|||||||
this.mText = text;
|
this.mText = text;
|
||||||
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);
|
mStaticFloatingTextMap.set(this.mRuntimeId, this);
|
||||||
this.sendToClients();
|
|
||||||
mc.listen("onJoin", (pl) => {
|
|
||||||
this.sendToClient(pl);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sendToClient(player) {
|
sendToClient(player) {
|
||||||
@@ -114,32 +193,21 @@ class StaticFloatingText {
|
|||||||
}
|
}
|
||||||
|
|
||||||
destroy() {
|
destroy() {
|
||||||
let size_t = FloatingTextList.indexOf(this);
|
mStaticFloatingTextMap.delete(this.mRuntimeId);
|
||||||
FloatingTextList.splice(size_t, 1);
|
|
||||||
return GMLIB_API.deleteFloatingText(this.mRuntimeId);
|
return GMLIB_API.deleteFloatingText(this.mRuntimeId);
|
||||||
}
|
}
|
||||||
|
|
||||||
isDynamic() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
static getFloatingText(runtimeId) {
|
static getFloatingText(runtimeId) {
|
||||||
for (const ft of FloatingTextList) {
|
if (mStaticFloatingTextMap.has(runtimeId)) {
|
||||||
if (ft.getRuntimeId() == runtimeId) {
|
return mStaticFloatingTextMap.get(runtimeId);
|
||||||
if (!ft.isDynamic()) {
|
|
||||||
return ft;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
static getAllFloatingTexts() {
|
static getAllFloatingTexts() {
|
||||||
let result = [];
|
let result = [];
|
||||||
FloatingTextList.forEach((ft) => {
|
mStaticFloatingTextMap.forEach((ft) => {
|
||||||
if (!ft.isDynamic()) {
|
|
||||||
result.push(ft);
|
result.push(ft);
|
||||||
}
|
|
||||||
});
|
});
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@@ -147,9 +215,13 @@ class StaticFloatingText {
|
|||||||
|
|
||||||
class DynamicFloatingText extends StaticFloatingText {
|
class DynamicFloatingText extends StaticFloatingText {
|
||||||
constructor(pos, text, updateRate = 1, papi = true) {
|
constructor(pos, text, updateRate = 1, papi = true) {
|
||||||
super(pos, text, papi);
|
this.mPosition = pos;
|
||||||
|
this.mText = text;
|
||||||
|
this.mPlaceholderAPI = papi;
|
||||||
|
this.mRuntimeId = GMLIB_API.createFloatingText(this.mPosition, this.mText, this.mPlaceholderAPI);
|
||||||
this.mUpdateRate = updateRate;
|
this.mUpdateRate = updateRate;
|
||||||
this.mTaskId = null;
|
this.mTaskId = null;
|
||||||
|
mDynamicFloatingTextMap.set(this.mRuntimeId, this);
|
||||||
this.startUpdate();
|
this.startUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -174,7 +246,7 @@ class DynamicFloatingText extends StaticFloatingText {
|
|||||||
}
|
}
|
||||||
|
|
||||||
stopUpdate() {
|
stopUpdate() {
|
||||||
if (this.mTaskId != null) {
|
if (this.mTaskId) {
|
||||||
clearInterval(this.mTaskId);
|
clearInterval(this.mTaskId);
|
||||||
this.mTaskId = null;
|
this.mTaskId = null;
|
||||||
return true;
|
return true;
|
||||||
@@ -183,32 +255,21 @@ class DynamicFloatingText extends StaticFloatingText {
|
|||||||
}
|
}
|
||||||
|
|
||||||
destroy() {
|
destroy() {
|
||||||
let size_t = FloatingTextList.indexOf(this);
|
mDynamicFloatingTextMap.delete(this.mRuntimeId);
|
||||||
FloatingTextList.splice(size_t, 1);
|
|
||||||
return GMLIB_API.deleteFloatingText(this.mRuntimeId);
|
return GMLIB_API.deleteFloatingText(this.mRuntimeId);
|
||||||
}
|
}
|
||||||
|
|
||||||
isDynamic() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
static getFloatingText(runtimeId) {
|
static getFloatingText(runtimeId) {
|
||||||
for (const ft of FloatingTextList) {
|
if (mDynamicFloatingTextMap.has(runtimeId)) {
|
||||||
if (ft.getRuntimeId() == runtimeId) {
|
return mDynamicFloatingTextMap.get(runtimeId);
|
||||||
if (ft.isDynamic()) {
|
|
||||||
return ft;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
static getAllFloatingTexts() {
|
static getAllFloatingTexts() {
|
||||||
let result = [];
|
let result = [];
|
||||||
FloatingTextList.forEach((ft) => {
|
mDynamicFloatingTextMap.forEach((ft) => {
|
||||||
if (ft.isDynamic()) {
|
|
||||||
result.push(ft);
|
result.push(ft);
|
||||||
}
|
|
||||||
});
|
});
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@@ -236,19 +297,39 @@ class Minecraft {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static getPlayerNbt(uuid) {
|
static getPlayerNbt(uuid) {
|
||||||
let snbt = GMLIB_API.getPlayerNbt(uuid);
|
return GMLIB_API.getPlayerNbt(uuid);
|
||||||
let nbt = NBT.parseSNBT(snbt);
|
|
||||||
return nbt;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static setPlayerNbt(uuid, nbt) {
|
static setPlayerNbt(uuid, nbt, forceCreate = true) {
|
||||||
let snbt = nbt.toSNBT();
|
return GMLIB_API.setPlayerNbt(uuid, nbt, forceCreate);
|
||||||
return GMLIB_API.setPlayerNbt(uuid, snbt);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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 deletePlayerNbt(uuid) {
|
||||||
|
return GMLIB_API.deletePlayerNbt(uuid);
|
||||||
|
}
|
||||||
|
|
||||||
|
static getPlayerPosition(uuid) {
|
||||||
|
let pos = GMLIB_API.getPlayerPosition(uuid);
|
||||||
|
if (pos.dimid == -1) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return pos;
|
||||||
|
}
|
||||||
|
|
||||||
|
static setPlayerPosition(uuid, pos) {
|
||||||
|
return GMLIB_API.setPlayerPosition(uuid, pos);
|
||||||
|
}
|
||||||
|
|
||||||
|
static getWorldSpawn() {
|
||||||
|
return GMLIB_API.getWorldSpawn();
|
||||||
|
}
|
||||||
|
|
||||||
|
static setWorldSpawn(pos) {
|
||||||
|
return GMLIB_API.setWorldSpawn(pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
static setEducationFeatureEnabled() {
|
static setEducationFeatureEnabled() {
|
||||||
@@ -287,10 +368,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);
|
||||||
}
|
}
|
||||||
@@ -303,12 +380,64 @@ 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.chooseResourcePackI18nLanguage(language);
|
return I18nAPI.getCurrentLanguage();
|
||||||
|
}
|
||||||
|
|
||||||
|
static setServerLanguage(language) {
|
||||||
|
return I18nAPI.chooseLanguage(language);
|
||||||
|
}
|
||||||
|
|
||||||
|
static setCustomPackPath(path) {
|
||||||
|
GMLIB_API.setCustomPackPath(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
static resourcePackTranslate(key, params = []) {
|
static resourcePackTranslate(key, params = []) {
|
||||||
return GMLIB_API.resourcePackTranslate(key, params);
|
return I18nAPI.get(key, params);
|
||||||
|
}
|
||||||
|
|
||||||
|
static getPlayerFromUuid(uuid) {
|
||||||
|
return GMLIB_API.getPlayerFromUuid(uuid);
|
||||||
|
}
|
||||||
|
|
||||||
|
static getPlayerFromUniqueId(uniqueId) {
|
||||||
|
return GMLIB_API.getPlayerFromUniqueId(uniqueId);
|
||||||
|
}
|
||||||
|
|
||||||
|
static getEntityFromUniqueId(uniqueId) {
|
||||||
|
return GMLIB_API.getFromUniqueId(uniqueId);
|
||||||
|
}
|
||||||
|
|
||||||
|
static getBlockRuntimeId(block) {
|
||||||
|
return GMLIB_API.getBlockRuntimeId(block);
|
||||||
|
}
|
||||||
|
|
||||||
|
static addFakeList(name, xuid) {
|
||||||
|
return GMLIB_API.addFakeList(name, xuid);
|
||||||
|
}
|
||||||
|
|
||||||
|
static removeFakeList(nameOrXuid) {
|
||||||
|
return GMLIB_API.removeFakeList(nameOrXuid);
|
||||||
|
}
|
||||||
|
|
||||||
|
static removeAllFakeLists() {
|
||||||
|
return GMLIB_API.removeAllFakeLists();
|
||||||
|
}
|
||||||
|
|
||||||
|
static setFixI18nEnabled() {
|
||||||
|
GMLIB_API.setFixI18nEnabled();
|
||||||
|
}
|
||||||
|
|
||||||
|
static saveNbtToFile(path, nbt, isBinary = true) {
|
||||||
|
return GMLIB_API.saveNbtToFile(path, nbt, isBinary);
|
||||||
|
}
|
||||||
|
|
||||||
|
static readNbtFromFile(path, isBinary = true) {
|
||||||
|
return GMLIB_API.readNbtFromFile(path, isBinary);
|
||||||
|
}
|
||||||
|
|
||||||
|
static getBlockTranslateKeyFromName(name) {
|
||||||
|
return GMLIB_API.getBlockTranslateKeyFromName(name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -317,6 +446,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);
|
||||||
}
|
}
|
||||||
@@ -361,18 +494,8 @@ class Experiments {
|
|||||||
return GMLIB_API.getAllExperiments();
|
return GMLIB_API.getAllExperiments();
|
||||||
}
|
}
|
||||||
|
|
||||||
static getExperimentTranslatedName(id) {
|
static getExperimentTranslateKey(id) {
|
||||||
return GMLIB_API.getExperimentTranslatedName(id);
|
return GMLIB_API.getExperimentTranslateKey(id);
|
||||||
}
|
|
||||||
|
|
||||||
static getExperimentsMap() {
|
|
||||||
let ids = this.getAllExperimentIds();
|
|
||||||
let result = {};
|
|
||||||
for (let id in ids) {
|
|
||||||
let name = this.getExperimentTranslatedName(id);
|
|
||||||
result[id] = name;
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static getExperimentEnabled(id) {
|
static getExperimentEnabled(id) {
|
||||||
@@ -388,22 +511,516 @@ class Experiments {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class GMLIB {
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
static isPluginVersionMatched(version) {
|
||||||
|
return GMLIB_API.isVersionMatched(version.mMajor, version.mMinor, version.mPatch);
|
||||||
|
}
|
||||||
|
|
||||||
|
static getLrcaVersion() {
|
||||||
|
return Version.fromString(GMLIB_API.getVersion_LRCA());
|
||||||
|
}
|
||||||
|
|
||||||
|
static getGmlibVersion() {
|
||||||
|
return Version.fromString(GMLIB_API.getVersion_GMLIB());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class Scoreboard {
|
||||||
constructor() {
|
constructor() {
|
||||||
throw new Error("Static class cannot be instantiated");
|
throw new Error("Static class cannot be instantiated");
|
||||||
}
|
}
|
||||||
|
|
||||||
static isVersionMatched(major, minor, patch) {
|
// Targets
|
||||||
return GMLIB_API.isVersionMatched(major, minor, patch);
|
static getAllTrackedEntities() {
|
||||||
|
return GMLIB_API.getAllScoreboardEntities();
|
||||||
}
|
}
|
||||||
|
|
||||||
static getVersion_LRCA() {
|
static getAllTrackedPlayers() {
|
||||||
return GMLIB_API.getVersion_LRCA();
|
return GMLIB_API.getAllScoreboardPlayers();
|
||||||
}
|
}
|
||||||
|
|
||||||
static getVersion_GMLIB() {
|
static getAllTrackedFakePlayers() {
|
||||||
return GMLIB_API.getVersion_GMLIB();
|
return GMLIB_API.getAllScoreboardFakePlayers();
|
||||||
|
}
|
||||||
|
|
||||||
|
static getAllTrackedTargets() {
|
||||||
|
return GMLIB_API.getAllTrackedTargets();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Objectives
|
||||||
|
static addObjective(name, displayName = "") {
|
||||||
|
if (displayName == "") {
|
||||||
|
return GMLIB_API.addObjective(name);
|
||||||
|
}
|
||||||
|
return GMLIB_API.addObjectiveWithDisplayName(name, displayName);
|
||||||
|
}
|
||||||
|
|
||||||
|
static removeObjective(name) {
|
||||||
|
return GMLIB_API.removeObjective(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
static getAllObjectives() {
|
||||||
|
return GMLIB_API.getAllObjectives();
|
||||||
|
}
|
||||||
|
|
||||||
|
static getDisplayName(objective) {
|
||||||
|
return GMLIB_API.getDisplayName(objective);
|
||||||
|
}
|
||||||
|
|
||||||
|
static setDisplayName(objective, displayName) {
|
||||||
|
return GMLIB_API.setDisplayName(objective, displayName);
|
||||||
|
}
|
||||||
|
|
||||||
|
static setDisplay(objective, slot, order = 0) {
|
||||||
|
GMLIB_API.setDisplayObjective(objective, slot, order);
|
||||||
|
}
|
||||||
|
|
||||||
|
static clearDisplay(slot) {
|
||||||
|
GMLIB_API.clearDisplayObjective(slot);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Player Score
|
||||||
|
static getPlayerScore(uuid, objective) {
|
||||||
|
if (GMLIB_API.playerHasScore(uuid, objective)) {
|
||||||
|
return GMLIB_API.getPlayerScore(uuid, objective);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
static addPlayerScore(uuid, objective, value) {
|
||||||
|
return GMLIB_API.addPlayerScore(uuid, objective, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
static reducePlayerScore(uuid, objective, value) {
|
||||||
|
return GMLIB_API.reducePlayerScore(uuid, objective, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
static setPlayerScore(uuid, objective, value) {
|
||||||
|
return GMLIB_API.setPlayerScore(uuid, objective, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
static resetPlayerScore(uuid, objective) {
|
||||||
|
return GMLIB_API.resetPlayerScore(uuid, objective);
|
||||||
|
}
|
||||||
|
|
||||||
|
static resetPlayerScores(uuid) {
|
||||||
|
return GMLIB_API.resetPlayerScores(uuid);
|
||||||
|
}
|
||||||
|
|
||||||
|
// FakePlayer Score
|
||||||
|
static getFakePlayerScore(name, objective) {
|
||||||
|
if (GMLIB_API.fakePlayerHasScore(name, objective)) {
|
||||||
|
return GMLIB_API.getFakePlayerScore(name, objective);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
static addFakePlayerScore(name, objective, value) {
|
||||||
|
return GMLIB_API.addFakePlayerScore(name, objective, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
static reduceFakePlayerScore(name, objective, value) {
|
||||||
|
return GMLIB_API.reduceFakePlayerScore(name, objective, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
static setFakePlayerScore(name, objective, value) {
|
||||||
|
return GMLIB_API.setFakePlayerScore(name, objective, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
static resetFakePlayerScore(name, objective) {
|
||||||
|
return GMLIB_API.resetFakePlayerScore(name, objective);
|
||||||
|
}
|
||||||
|
|
||||||
|
static resetFakePlayerScores(name) {
|
||||||
|
return GMLIB_API.resetFakePlayerScores(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Entity Score
|
||||||
|
static getEntityScore(uniqueId, objective) {
|
||||||
|
if (GMLIB_API.entityHasScore(uniqueId, objective)) {
|
||||||
|
return GMLIB_API.getEntityScore(uniqueId, objective);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
static addEntityScore(uniqueId, objective, value) {
|
||||||
|
return GMLIB_API.addEntityScore(uniqueId, objective, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
static reduceEntityScore(uniqueId, objective, value) {
|
||||||
|
return GMLIB_API.reduceEntityScore(uniqueId, objective, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
static setEntityScore(uniqueId, objective, value) {
|
||||||
|
return GMLIB_API.setEntityScore(uniqueId, objective, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
static resetEntityScore(uniqueId, objective) {
|
||||||
|
return GMLIB_API.resetEntityScore(uniqueId, objective);
|
||||||
|
}
|
||||||
|
|
||||||
|
static resetEntityScores(uniqueId) {
|
||||||
|
return GMLIB_API.resetEntityScores(uniqueId);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
class JsonConfig {
|
||||||
|
constructor(path, defultValue = {}) {
|
||||||
|
this.mData = defultValue;
|
||||||
|
this.mPath = path;
|
||||||
|
this.init();
|
||||||
|
}
|
||||||
|
|
||||||
|
init() {
|
||||||
|
if (File.exists(this.mPath)) {
|
||||||
|
let existDataStr = File.readFrom(this.mPath);
|
||||||
|
existDataStr = existDataStr.replace(/\/\/.*|\/\*[^]*?\*\//g, "");
|
||||||
|
try {
|
||||||
|
let result = GMLIB_API.mergePatchJson(JSON.stringify(this.mData), existDataStr);
|
||||||
|
this.mData = JSON.parse(result);
|
||||||
|
} catch {
|
||||||
|
let newPath = this.mPath + "_old";
|
||||||
|
File.rename(this.mPath, newPath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.save();
|
||||||
|
}
|
||||||
|
|
||||||
|
save(format = 4) {
|
||||||
|
let dataStr = JSON.stringify(this.mData, null, format);
|
||||||
|
File.writeTo(this.mPath, dataStr);
|
||||||
|
}
|
||||||
|
|
||||||
|
getData() {
|
||||||
|
return this.mData;
|
||||||
|
}
|
||||||
|
|
||||||
|
get(key, defultValue = undefined) {
|
||||||
|
let result = this.getData()[key];
|
||||||
|
if (!result && defultValue != undefined) {
|
||||||
|
this.set(key, defultValue);
|
||||||
|
return defultValue;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
set(key, value) {
|
||||||
|
this.getData()[key] = value;
|
||||||
|
this.save();
|
||||||
|
}
|
||||||
|
|
||||||
|
delete(key) {
|
||||||
|
delete this.getData()[key];
|
||||||
|
this.save();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = { StaticFloatingText, DynamicFloatingText, Minecraft, Recipes, Experiments, GMLIB };
|
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;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
class I18nAPI {
|
||||||
|
constructor() {
|
||||||
|
throw new Error("Static class cannot be instantiated");
|
||||||
|
}
|
||||||
|
|
||||||
|
static get(key, params = [], langCode = undefined) {
|
||||||
|
let data = [];
|
||||||
|
params.forEach((param) => {
|
||||||
|
data.push(param);
|
||||||
|
});
|
||||||
|
if (langCode) {
|
||||||
|
return GMLIB_API.resourcePackTranslate(key, data, langCode);
|
||||||
|
}
|
||||||
|
return GMLIB_API.resourcePackDefaultTranslate(key, data);
|
||||||
|
}
|
||||||
|
|
||||||
|
static translate(key, params = [], langCode = undefined) {
|
||||||
|
return I18nAPI.get(key, params, langCode);
|
||||||
|
}
|
||||||
|
|
||||||
|
static getSupportedLanguages() {
|
||||||
|
return GMLIB_API.getSupportedLanguages();
|
||||||
|
}
|
||||||
|
|
||||||
|
static getCurrentLanguage() {
|
||||||
|
return GMLIB_API.getResourcePackI18nLanguage(language);
|
||||||
|
}
|
||||||
|
|
||||||
|
static chooseLanguage(language) {
|
||||||
|
GMLIB_API.chooseResourcePackI18nLanguage(language);
|
||||||
|
}
|
||||||
|
|
||||||
|
static loadLanguage(code, language) {
|
||||||
|
GMLIB_API.loadLanguage(code, language);
|
||||||
|
}
|
||||||
|
|
||||||
|
static updateOrCreateLanguageFile(code, lang, path) {
|
||||||
|
GMLIB_API.updateOrCreateLanguageFile(code, lang, path);
|
||||||
|
}
|
||||||
|
|
||||||
|
static loadLanguageDirectory(path) {
|
||||||
|
GMLIB_API.loadLanguagePath(path);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
class UserCache {
|
||||||
|
constructor() {
|
||||||
|
throw new Error("Static class cannot be instantiated");
|
||||||
|
}
|
||||||
|
|
||||||
|
static getXuidByUuid(uuid) {
|
||||||
|
let result = GMLIB_API.getXuidByUuid(uuid);
|
||||||
|
return result == "" ? null : result;
|
||||||
|
}
|
||||||
|
|
||||||
|
static getUuidByXuid(xuid) {
|
||||||
|
let result = GMLIB_API.getUuidByXuid(xuid);
|
||||||
|
return result == "" ? null : result;
|
||||||
|
}
|
||||||
|
|
||||||
|
static getNameByUuid(uuid) {
|
||||||
|
let result = GMLIB_API.getNameByUuid(uuid);
|
||||||
|
return result == "" ? null : result;
|
||||||
|
}
|
||||||
|
|
||||||
|
static getNameByXuid(xuid) {
|
||||||
|
let result = GMLIB_API.getNameByXuid(xuid);
|
||||||
|
return result == "" ? null : result;
|
||||||
|
}
|
||||||
|
|
||||||
|
static getXuidByName(name) {
|
||||||
|
let result = GMLIB_API.getXuidByName(name);
|
||||||
|
return result == "" ? null : result;
|
||||||
|
}
|
||||||
|
|
||||||
|
static getUuidByName(name) {
|
||||||
|
let result = GMLIB_API.getUuidByName(name);
|
||||||
|
return result == "" ? null : result;
|
||||||
|
}
|
||||||
|
|
||||||
|
static getPlayerInfo(playerIdentifier) {
|
||||||
|
return GMLIB_API.getAllPlayerInfo().find(Info => Object.keys(Info).some(InfoKey => Info[InfoKey] === playerIdentifier));
|
||||||
|
}
|
||||||
|
|
||||||
|
static getAllPlayerInfo() {
|
||||||
|
return GMLIB_API.getAllPlayerInfo();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
LLSE_Entity.prototype.getTranslateKey = function () {
|
||||||
|
return GMLIB_API.getEntityTranslateKey(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
LLSE_Entity.prototype.getTranslateName = function (language) {
|
||||||
|
return I18nAPI.get(this.getTranslateKey(), [], language);
|
||||||
|
}
|
||||||
|
|
||||||
|
LLSE_Block.prototype.getTranslateKey = function () {
|
||||||
|
return GMLIB_API.getBlockTranslateKey(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
LLSE_Block.prototype.getTranslateName = function (language) {
|
||||||
|
return I18nAPI.get(this.getTranslateKey(), [], language);
|
||||||
|
}
|
||||||
|
|
||||||
|
LLSE_Item.prototype.getTranslateKey = function () {
|
||||||
|
return GMLIB_API.getItemTranslateKey(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
LLSE_Item.prototype.getTranslateName = function (language) {
|
||||||
|
return I18nAPI.get(this.getTranslateKey(), [], language);
|
||||||
|
}
|
||||||
|
|
||||||
|
LLSE_Block.prototype.getBlockDestroySpeed = function () {
|
||||||
|
return GMLIB_API.getBlockDestroySpeed(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
LLSE_Item.prototype.getDestroyBlockSpeed = function (block) {
|
||||||
|
return GMLIB_API.getDestroyBlockSpeed(this, block);
|
||||||
|
}
|
||||||
|
|
||||||
|
LLSE_Block.prototype.playerDestroy = function (player) {
|
||||||
|
GMLIB_API.playerDestroyBlock(this, this.pos, player);
|
||||||
|
}
|
||||||
|
|
||||||
|
LLSE_Item.prototype.canDestroy = function (block) {
|
||||||
|
return GMLIB_API.itemCanDestroyBlock(this, block);
|
||||||
|
}
|
||||||
|
|
||||||
|
LLSE_Item.prototype.canDestroyInCreative = function () {
|
||||||
|
return GMLIB_API.itemCanDestroyInCreative(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
LLSE_Item.prototype.canDestroySpecial = function (block) {
|
||||||
|
return GMLIB_API.itemCanDestroySpecial(this, block);
|
||||||
|
}
|
||||||
|
|
||||||
|
LLSE_Block.prototype.canDropWithAnyTool = function () {
|
||||||
|
return GMLIB_API.blockCanDropWithAnyTool(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
LLSE_Block.prototype.isAlwaysDestroyable = function () {
|
||||||
|
return GMLIB_API.blockIsAlwaysDestroyable(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
LLSE_Block.prototype.playerWillDestroy = function (player) {
|
||||||
|
return GMLIB_API.blockPlayerWillDestroy(this, player, this.pos);
|
||||||
|
}
|
||||||
|
|
||||||
|
LLSE_Player.prototype.attack = function (entity) {
|
||||||
|
return GMLIB_API.playerAttack(this, entity);
|
||||||
|
}
|
||||||
|
|
||||||
|
LLSE_Player.prototype.pullInEntity = function (entity) {
|
||||||
|
return GMLIB_API.playerPullInEntity(this, entity);
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
StaticFloatingText,
|
||||||
|
DynamicFloatingText,
|
||||||
|
Minecraft,
|
||||||
|
Recipes,
|
||||||
|
Experiments,
|
||||||
|
Scoreboard,
|
||||||
|
JsonConfig,
|
||||||
|
JsonLanguage,
|
||||||
|
JsonI18n,
|
||||||
|
Version,
|
||||||
|
I18nAPI,
|
||||||
|
UserCache
|
||||||
|
};
|
||||||
@@ -1,6 +1,8 @@
|
|||||||
{
|
{
|
||||||
"name": "${pluginName}",
|
"name": "${pluginName}",
|
||||||
"entry": "${pluginFile}",
|
"entry": "${pluginFile}",
|
||||||
|
"version": "0.12.8",
|
||||||
|
"author": "GroupMountain",
|
||||||
"type": "native",
|
"type": "native",
|
||||||
"dependencies": [
|
"dependencies": [
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -88,10 +88,11 @@ function pack_plugin(target,plugin_define)
|
|||||||
local manifest_path = find_file("manifest.json", os.projectdir())
|
local manifest_path = find_file("manifest.json", os.projectdir())
|
||||||
if manifest_path then
|
if manifest_path then
|
||||||
local manifest = io.readfile(manifest_path)
|
local manifest = io.readfile(manifest_path)
|
||||||
local bindir = path.join(os.projectdir(), "bin")
|
local bindir = path.join(os.projectdir(), "bin/DLL")
|
||||||
|
local pdbdir = path.join(os.projectdir(), "bin/PDB")
|
||||||
local outputdir = path.join(bindir, plugin_define.pluginName)
|
local outputdir = path.join(bindir, plugin_define.pluginName)
|
||||||
local targetfile = path.join(outputdir, plugin_define.pluginFile)
|
local targetfile = path.join(outputdir, plugin_define.pluginFile)
|
||||||
local pdbfile = path.join(outputdir, path.basename(plugin_define.pluginFile) .. ".pdb")
|
local pdbfile = path.join(pdbdir, path.basename(plugin_define.pluginFile) .. ".pdb")
|
||||||
local libfile = path.join(os.projectdir(), "lib")
|
local libfile = path.join(os.projectdir(), "lib")
|
||||||
local manifestfile = path.join(outputdir, "manifest.json")
|
local manifestfile = path.join(outputdir, "manifest.json")
|
||||||
local oritargetfile = target:targetfile()
|
local oritargetfile = target:targetfile()
|
||||||
|
|||||||
+601
-64
@@ -1,144 +1,681 @@
|
|||||||
#include "Global.h"
|
#include "Global.h"
|
||||||
|
#include <regex>
|
||||||
|
|
||||||
|
bool isInteger(const std::string& str) {
|
||||||
|
std::regex pattern("^[+-]?\\d+$");
|
||||||
|
return std::regex_match(str, pattern);
|
||||||
|
}
|
||||||
|
|
||||||
|
ActorUniqueID parseScriptUniqueID(std::string const& uniqueId) {
|
||||||
|
if (!isInteger(uniqueId)) {
|
||||||
|
return ActorUniqueID::INVALID_ID;
|
||||||
|
}
|
||||||
|
return ActorUniqueID(std::stoll(uniqueId));
|
||||||
|
}
|
||||||
|
|
||||||
void Export_Compatibility_API() {
|
void Export_Compatibility_API() {
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "unregisterRecipe", [](std::string const& id) -> bool {
|
||||||
|
auto level = GMLIB_Level::getInstance();
|
||||||
|
if (!level) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return CustomRecipe::unregisterRecipe(id);
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "setCustomPackPath", [](std::string const& path) -> void {
|
||||||
|
CustomPacks::addCustomPackPath(path);
|
||||||
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "getServerMspt", []() -> float {
|
RemoteCall::exportAs("GMLIB_API", "getServerMspt", []() -> float {
|
||||||
auto level = GMLIB_Level::getLevel();
|
auto level = GMLIB_Level::getInstance();
|
||||||
if (!level) {
|
if (!level) {
|
||||||
return 0.0f;
|
return 0.0f;
|
||||||
}
|
}
|
||||||
return level->getServerMspt();
|
return level->getServerMspt();
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "getServerCurrentTps", []() -> float {
|
RemoteCall::exportAs("GMLIB_API", "getServerCurrentTps", []() -> float {
|
||||||
auto level = GMLIB_Level::getLevel();
|
auto level = GMLIB_Level::getInstance();
|
||||||
if (!level) {
|
if (!level) {
|
||||||
return 0.0f;
|
return 0.0f;
|
||||||
}
|
}
|
||||||
return level->getServerCurrentTps();
|
return level->getServerCurrentTps();
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "getServerAverageTps", []() -> float {
|
RemoteCall::exportAs("GMLIB_API", "getServerAverageTps", []() -> float {
|
||||||
auto level = GMLIB_Level::getLevel();
|
auto level = GMLIB_Level::getInstance();
|
||||||
if (!level) {
|
if (!level) {
|
||||||
return 0.0f;
|
return 0.0f;
|
||||||
}
|
}
|
||||||
return level->getServerAverageTps();
|
return level->getServerAverageTps();
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "getAllPlayerUuids", []() -> std::vector<std::string> {
|
RemoteCall::exportAs("GMLIB_API", "getAllPlayerUuids", []() -> std::vector<std::string> {
|
||||||
return GMLIB_Player::getAllUuids();
|
std::vector<std::string> result;
|
||||||
});
|
std::vector<mce::UUID> uuids = GMLIB_Player::getAllUuids();
|
||||||
RemoteCall::exportAs("GMLIB_API", "getPlayerNbt", [](std::string uuid) -> std::string {
|
for (auto& uuid : uuids) {
|
||||||
auto uid = mce::UUID::fromString(uuid);
|
result.push_back(uuid.asString());
|
||||||
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;
|
|
||||||
for (auto& key : map) {
|
|
||||||
result.push_back(key.first);
|
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "getExperimentTranslatedName", [](int id) -> std::string {
|
RemoteCall::exportAs("GMLIB_API", "getPlayerNbt", [](std::string const& uuid) -> std::unique_ptr<CompoundTag> {
|
||||||
auto map = GMLIB_Level::getAllExperimentsTranslateKeys();
|
auto uid = mce::UUID::fromString(uuid);
|
||||||
if (map.count(id)) {
|
return std::move(GMLIB_Player::getPlayerNbt(uid));
|
||||||
return std::string(map[id]);
|
});
|
||||||
|
RemoteCall::exportAs(
|
||||||
|
"GMLIB_API",
|
||||||
|
"setPlayerNbt",
|
||||||
|
[](std::string const& uuid, CompoundTag* nbt, bool forceCreate) -> bool {
|
||||||
|
auto uid = mce::UUID::fromString(uuid);
|
||||||
|
return GMLIB_Player::setPlayerNbt(uid, *nbt, forceCreate);
|
||||||
}
|
}
|
||||||
return "";
|
);
|
||||||
|
RemoteCall::exportAs(
|
||||||
|
"GMLIB_API",
|
||||||
|
"setPlayerNbtTags",
|
||||||
|
[](std::string const& uuid, CompoundTag* nbt, std::vector<std::string> tags) -> bool {
|
||||||
|
auto uid = mce::UUID::fromString(uuid);
|
||||||
|
return GMLIB_Player::setPlayerNbtTags(uid, *nbt, tags);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "deletePlayerNbt", [](std::string const& uuid) -> bool {
|
||||||
|
auto uid = mce::UUID::fromString(uuid);
|
||||||
|
return GMLIB_Player::deletePlayerNbt(uid);
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "getAllExperiments", []() -> std::vector<int> {
|
||||||
|
auto list = GMLIB_Level::getAllExperiments();
|
||||||
|
std::vector<int> result;
|
||||||
|
for (auto& key : list) {
|
||||||
|
result.push_back((int)key);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "getExperimentTranslateKey", [](int id) -> std::string {
|
||||||
|
std::string result;
|
||||||
|
try {
|
||||||
|
result = Experiments::getExperimentTextID(AllExperiments(id));
|
||||||
|
} catch (...) {}
|
||||||
|
return result;
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs(
|
RemoteCall::exportAs(
|
||||||
"GMLIB_API",
|
"GMLIB_API",
|
||||||
"createFloatingText",
|
"createFloatingText",
|
||||||
[](std::pair<Vec3, int> pos, std::string text, bool papi) -> int {
|
[](std::pair<Vec3, int> pos, std::string const& text, bool papi) -> int {
|
||||||
auto ft = new GMLIB::Server::FloatingText(text, pos.first, pos.second, papi);
|
auto& manager = FloatingTextManager::getInstance();
|
||||||
|
auto ft = manager.createStatic(text, pos.first, pos.second, papi);
|
||||||
|
manager.add(ft);
|
||||||
return ft->getRuntimeID();
|
return ft->getRuntimeID();
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
RemoteCall::exportAs("GMLIB_API", "setFloatingTextData", [](int id, std::string text) -> bool {
|
RemoteCall::exportAs("GMLIB_API", "setFloatingTextData", [](int id, std::string const& text) -> bool {
|
||||||
auto ft = GMLIB::Server::FloatingText::getFloatingText(id);
|
if (auto ft = FloatingTextManager::getInstance().getFloatingText(id)) {
|
||||||
if (ft) {
|
|
||||||
ft->setText(text);
|
ft->setText(text);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "deleteFloatingText", [](int id) -> bool {
|
RemoteCall::exportAs("GMLIB_API", "deleteFloatingText", [](int id) -> bool {
|
||||||
return GMLIB::Server::FloatingText::deleteFloatingText(id);
|
return FloatingTextManager::getInstance().remove(id);
|
||||||
});
|
});
|
||||||
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);
|
if (auto ft = FloatingTextManager::getInstance().getFloatingText(id)) {
|
||||||
if (ft) {
|
ft->sendTo(*pl);
|
||||||
ft->sendToClient(pl);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "sendFloatingText", [](int id) -> bool {
|
RemoteCall::exportAs("GMLIB_API", "sendFloatingText", [](int id) -> bool {
|
||||||
auto ft = GMLIB::Server::FloatingText::getFloatingText(id);
|
if (auto ft = FloatingTextManager::getInstance().getFloatingText(id)) {
|
||||||
if (ft) {
|
ft->sendToClients();
|
||||||
ft->sendToAllClients();
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
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);
|
if (auto ft = FloatingTextManager::getInstance().getFloatingText(id)) {
|
||||||
if (ft) {
|
ft->removeFrom(*pl);
|
||||||
ft->removeFromClient(pl);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "removeFloatingText", [](int id) -> bool {
|
RemoteCall::exportAs("GMLIB_API", "removeFloatingText", [](int id) -> bool {
|
||||||
auto ft = GMLIB::Server::FloatingText::getFloatingText(id);
|
if (auto ft = FloatingTextManager::getInstance().getFloatingText(id)) {
|
||||||
if (ft) {
|
ft->removeFromClients();
|
||||||
ft->removeFromAllClients();
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
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);
|
if (auto ft = FloatingTextManager::getInstance().getFloatingText(id)) {
|
||||||
if (ft) {
|
ft->update(*pl);
|
||||||
ft->updateClient(pl);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "updateAllClientsFloatingTextData", [](int id) -> bool {
|
RemoteCall::exportAs("GMLIB_API", "updateAllClientsFloatingTextData", [](int id) -> bool {
|
||||||
auto ft = GMLIB::Server::FloatingText::getFloatingText(id);
|
if (auto ft = FloatingTextManager::getInstance().getFloatingText(id)) {
|
||||||
if (ft) {
|
ft->updateClients();
|
||||||
ft->updateAllClients();
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
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 = Version(a, b, c, "", "");
|
||||||
return LIB_VERSION.satisfies(version);
|
return LIB_VERSION >= 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 {
|
||||||
return GMLIB::Version::getLibVersionString();
|
return Version::getLibVersionString();
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs(
|
RemoteCall::exportAs(
|
||||||
"GMLIB_API",
|
"GMLIB_API",
|
||||||
"resourcePackTranslate",
|
"resourcePackDefaultTranslate",
|
||||||
[](std::string key, std::vector<std::string> params) -> std::string { return I18n::get(key, params); }
|
[](std::string const& key, std::vector<std::string> params) -> std::string { return I18nAPI::get(key, params); }
|
||||||
);
|
);
|
||||||
RemoteCall::exportAs("GMLIB_API", "chooseResourcePackI18nLanguage", [](std::string code) -> void {
|
RemoteCall::exportAs(
|
||||||
I18n::chooseLanguage(code);
|
"GMLIB_API",
|
||||||
|
"resourcePackTranslate",
|
||||||
|
[](std::string const& key, std::vector<std::string> params, std::string const& code) -> std::string {
|
||||||
|
return I18nAPI::get(key, params, code);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "chooseResourcePackI18nLanguage", [](std::string const& code) -> void {
|
||||||
|
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", "getSupportedLanguages", []() -> std::vector<std::string> {
|
||||||
|
if (GMLIB_Level::getInstance()) {
|
||||||
|
return I18nAPI::getSupportedLanguageCodes();
|
||||||
|
}
|
||||||
|
return {};
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "loadLanguage", [](std::string const& code, std::string const& lang) -> void {
|
||||||
|
if (GMLIB_Level::getInstance()) {
|
||||||
|
I18nAPI::loadLanguage(code, lang);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs(
|
||||||
|
"GMLIB_API",
|
||||||
|
"updateOrCreateLanguageFile",
|
||||||
|
[](std::string const& code, std::unordered_map<std::string, std::string> lang, std::string const& path
|
||||||
|
) -> void {
|
||||||
|
if (GMLIB_Level::getInstance()) {
|
||||||
|
I18nAPI::updateOrCreateLanguageFile(path, code, lang);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "loadLanguagePath", [](std::string const& path) -> void {
|
||||||
|
if (GMLIB_Level::getInstance()) {
|
||||||
|
I18nAPI::loadLanguagesFromDirectory(path);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "getPlayerPosition", [](std::string const& uuid) -> std::pair<BlockPos, int> {
|
||||||
|
auto uid = mce::UUID::fromString(uuid);
|
||||||
|
auto pos = GMLIB_Player::getPlayerPosition(uid);
|
||||||
|
if (pos.has_value()) {
|
||||||
|
return pos.value();
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
{0, 0, 0},
|
||||||
|
-1
|
||||||
|
};
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs(
|
||||||
|
"GMLIB_API",
|
||||||
|
"setPlayerPosition",
|
||||||
|
[](std::string const& uuid, std::pair<BlockPos, int> pos) -> bool {
|
||||||
|
auto uid = mce::UUID::fromString(uuid);
|
||||||
|
return GMLIB_Player::setPlayerPosition(uid, pos.first, pos.second);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "playerHasScore", [](std::string const& uuid, std::string const& obj) -> bool {
|
||||||
|
auto uid = mce::UUID::fromString(uuid);
|
||||||
|
if (auto result = GMLIB_Player::getPlayerScore(uid, obj)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "getPlayerScore", [](std::string const& uuid, std::string const& obj) -> int {
|
||||||
|
auto uid = mce::UUID::fromString(uuid);
|
||||||
|
if (auto result = GMLIB_Player::getPlayerScore(uid, obj)) {
|
||||||
|
return result.value();
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs(
|
||||||
|
"GMLIB_API",
|
||||||
|
"addPlayerScore",
|
||||||
|
[](std::string const& uuid, std::string const& obj, int value) -> bool {
|
||||||
|
auto uid = mce::UUID::fromString(uuid);
|
||||||
|
if (auto res = GMLIB_Player::setPlayerScore(uid, obj, value, PlayerScoreSetFunction::Add)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
RemoteCall::exportAs(
|
||||||
|
"GMLIB_API",
|
||||||
|
"reducePlayerScore",
|
||||||
|
[](std::string const& uuid, std::string const& obj, int value) -> bool {
|
||||||
|
auto uid = mce::UUID::fromString(uuid);
|
||||||
|
if (auto res = GMLIB_Player::setPlayerScore(uid, obj, value, PlayerScoreSetFunction::Subtract)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
RemoteCall::exportAs(
|
||||||
|
"GMLIB_API",
|
||||||
|
"setPlayerScore",
|
||||||
|
[](std::string const& uuid, std::string const& obj, int value) -> bool {
|
||||||
|
auto uid = mce::UUID::fromString(uuid);
|
||||||
|
if (auto res = GMLIB_Player::setPlayerScore(uid, obj, value)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "resetPlayerScore", [](std::string const& uuid, std::string const& obj) -> bool {
|
||||||
|
auto uid = mce::UUID::fromString(uuid);
|
||||||
|
return GMLIB_Player::resetPlayerScore(uid, obj);
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "resetPlayerScores", [](std::string const& uuid) -> bool {
|
||||||
|
auto uid = mce::UUID::fromString(uuid);
|
||||||
|
return GMLIB_Player::resetPlayerScore(uid);
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs(
|
||||||
|
"GMLIB_API",
|
||||||
|
"entityHasScore",
|
||||||
|
[](std::string const& uniqueId, std::string const& obj) -> bool {
|
||||||
|
auto auid = parseScriptUniqueID(uniqueId);
|
||||||
|
if (auto result = GMLIB_Scoreboard::getInstance()->getScore(obj, auid)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "getEntityScore", [](std::string const& uniqueId, std::string const& obj) -> int {
|
||||||
|
auto auid = parseScriptUniqueID(uniqueId);
|
||||||
|
if (auto result = GMLIB_Scoreboard::getInstance()->getScore(obj, auid)) {
|
||||||
|
return result.value();
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs(
|
||||||
|
"GMLIB_API",
|
||||||
|
"addEntityScore",
|
||||||
|
[](std::string const& uniqueId, std::string const& obj, int value) -> bool {
|
||||||
|
auto auid = parseScriptUniqueID(uniqueId);
|
||||||
|
if (auto res = GMLIB_Scoreboard::getInstance()->setScore(obj, auid, value, PlayerScoreSetFunction::Add)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
RemoteCall::exportAs(
|
||||||
|
"GMLIB_API",
|
||||||
|
"reduceEntityScore",
|
||||||
|
[](std::string const& uniqueId, std::string const& obj, int value) -> bool {
|
||||||
|
auto auid = parseScriptUniqueID(uniqueId);
|
||||||
|
if (auto res =
|
||||||
|
GMLIB_Scoreboard::getInstance()->setScore(obj, auid, value, PlayerScoreSetFunction::Subtract)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
RemoteCall::exportAs(
|
||||||
|
"GMLIB_API",
|
||||||
|
"setEntityScore",
|
||||||
|
[](std::string const& uniqueId, std::string const& obj, int value) -> bool {
|
||||||
|
auto auid = parseScriptUniqueID(uniqueId);
|
||||||
|
if (auto res = GMLIB_Scoreboard::getInstance()->setScore(obj, auid, value)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
RemoteCall::exportAs(
|
||||||
|
"GMLIB_API",
|
||||||
|
"resetEntityScore",
|
||||||
|
[](std::string const& uniqueId, std::string const& obj) -> bool {
|
||||||
|
auto auid = parseScriptUniqueID(uniqueId);
|
||||||
|
return GMLIB_Scoreboard::getInstance()->resetScore(obj, auid);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "resetEntityScores", [](std::string const& uniqueId) -> bool {
|
||||||
|
auto auid = parseScriptUniqueID(uniqueId);
|
||||||
|
return GMLIB_Scoreboard::getInstance()->resetScore(auid);
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs(
|
||||||
|
"GMLIB_API",
|
||||||
|
"fakePlayerHasScore",
|
||||||
|
[](std::string const& name, std::string const& obj) -> bool {
|
||||||
|
if (auto result = GMLIB_Scoreboard::getInstance()->getScore(obj, name)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "getFakePlayerScore", [](std::string const& name, std::string const& obj) -> int {
|
||||||
|
if (auto result = GMLIB_Scoreboard::getInstance()->getScore(obj, name)) {
|
||||||
|
return result.value();
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs(
|
||||||
|
"GMLIB_API",
|
||||||
|
"addFakePlayerScore",
|
||||||
|
[](std::string const& name, std::string const& obj, int value) -> bool {
|
||||||
|
if (auto res = GMLIB_Scoreboard::getInstance()->setScore(obj, name, value, PlayerScoreSetFunction::Add)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
RemoteCall::exportAs(
|
||||||
|
"GMLIB_API",
|
||||||
|
"reduceFakePlayerScore",
|
||||||
|
[](std::string const& name, std::string const& obj, int value) -> bool {
|
||||||
|
if (auto res =
|
||||||
|
GMLIB_Scoreboard::getInstance()->setScore(obj, name, value, PlayerScoreSetFunction::Subtract)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
RemoteCall::exportAs(
|
||||||
|
"GMLIB_API",
|
||||||
|
"setFakePlayerScore",
|
||||||
|
[](std::string const& name, std::string const& obj, int value) -> bool {
|
||||||
|
if (auto res = GMLIB_Scoreboard::getInstance()->setScore(obj, name, value)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
RemoteCall::exportAs(
|
||||||
|
"GMLIB_API",
|
||||||
|
"resetFakePlayerScore",
|
||||||
|
[](std::string const& name, std::string const& obj) -> bool {
|
||||||
|
return GMLIB_Scoreboard::getInstance()->resetScore(obj, name);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "resetFakePlayerScores", [](std::string const& name) -> bool {
|
||||||
|
return GMLIB_Scoreboard::getInstance()->resetScore(name);
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "addObjective", [](std::string const& obj) -> bool {
|
||||||
|
if (auto res = GMLIB_Scoreboard::getInstance()->addObjective(obj)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs(
|
||||||
|
"GMLIB_API",
|
||||||
|
"addObjectiveWithDisplayName",
|
||||||
|
[](std::string const& obj, std::string const& displayName) -> bool {
|
||||||
|
if (auto res = GMLIB_Scoreboard::getInstance()->addObjective(obj, displayName)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "getDisplayName", [](std::string const& obj) -> std::string {
|
||||||
|
if (auto result = GMLIB_Scoreboard::getInstance()->getObjectiveDisplayName(obj)) {
|
||||||
|
return result.value();
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs(
|
||||||
|
"GMLIB_API",
|
||||||
|
"setDisplayName",
|
||||||
|
[](std::string const& obj, std::string const& displayName) -> bool {
|
||||||
|
return GMLIB_Scoreboard::getInstance()->setObjectiveDisplayName(obj, displayName);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "removeObjective", [](std::string const& obj) -> bool {
|
||||||
|
return GMLIB_Scoreboard::getInstance()->removeObjective(obj);
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs(
|
||||||
|
"GMLIB_API",
|
||||||
|
"setDisplayObjective",
|
||||||
|
[](std::string const& obj, std::string const& slot, int order) -> void {
|
||||||
|
return GMLIB_Scoreboard::getInstance()->setObjectiveDisplay(obj, slot, (ObjectiveSortOrder)order);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "clearDisplayObjective", [](std::string const& slot) -> void {
|
||||||
|
return GMLIB_Scoreboard::getInstance()->clearObjectiveDisplay(slot);
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "getAllObjectives", []() -> std::vector<std::string> {
|
||||||
|
auto objs = GMLIB_Scoreboard::getInstance()->getObjectives();
|
||||||
|
std::vector<std::string> result;
|
||||||
|
for (auto& obj : objs) {
|
||||||
|
result.push_back(obj->getName());
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "getAllScoreboardPlayers", []() -> std::vector<std::string> {
|
||||||
|
auto uuids = GMLIB_Scoreboard::getInstance()->getAllPlayerUuids();
|
||||||
|
std::vector<std::string> result;
|
||||||
|
for (auto& uuid : uuids) {
|
||||||
|
result.push_back(uuid.asString());
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "getAllScoreboardFakePlayers", []() -> std::vector<std::string> {
|
||||||
|
auto names = GMLIB_Scoreboard::getInstance()->getAllFakePlayers();
|
||||||
|
std::vector<std::string> result;
|
||||||
|
for (auto& name : names) {
|
||||||
|
result.push_back(name);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "getAllScoreboardEntities", []() -> std::vector<std::string> {
|
||||||
|
auto uniqueIds = GMLIB_Scoreboard::getInstance()->getAllEntities();
|
||||||
|
std::vector<std::string> result;
|
||||||
|
for (auto& uniqueId : uniqueIds) {
|
||||||
|
result.push_back(std::to_string(uniqueId.id));
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs(
|
||||||
|
"GMLIB_API",
|
||||||
|
"getAllTrackedTargets",
|
||||||
|
[]() -> std::vector<std::unordered_map<std::string, std::string>> {
|
||||||
|
std::vector<std::unordered_map<std::string, std::string>> result;
|
||||||
|
auto uuids = GMLIB_Scoreboard::getInstance()->getAllPlayerUuids();
|
||||||
|
for (auto& uuid : uuids) {
|
||||||
|
std::unordered_map<std::string, std::string> data;
|
||||||
|
data["Type"] = "Player";
|
||||||
|
data["Uuid"] = uuid.asString();
|
||||||
|
result.push_back(data);
|
||||||
|
}
|
||||||
|
auto names = GMLIB_Scoreboard::getInstance()->getAllFakePlayers();
|
||||||
|
for (auto& name : names) {
|
||||||
|
std::unordered_map<std::string, std::string> data;
|
||||||
|
data["Type"] = "FakePlayer";
|
||||||
|
data["Name"] = name;
|
||||||
|
result.push_back(data);
|
||||||
|
}
|
||||||
|
auto uniqueIds = GMLIB_Scoreboard::getInstance()->getAllEntities();
|
||||||
|
for (auto& uniqueId : uniqueIds) {
|
||||||
|
std::unordered_map<std::string, std::string> data;
|
||||||
|
data["Type"] = "Entity";
|
||||||
|
data["UniqueId"] = std::to_string(uniqueId.id);
|
||||||
|
result.push_back(data);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "getPlayerFromUuid", [](std::string const& uuid) -> Player* {
|
||||||
|
auto uid = mce::UUID::fromString(uuid);
|
||||||
|
return ll::service::getLevel()->getPlayer(uuid);
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "getPlayerFromUniqueId", [](std::string const& uniqueId) -> Actor* {
|
||||||
|
auto auid = parseScriptUniqueID(uniqueId);
|
||||||
|
return ll::service::getLevel()->getPlayer(auid);
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "getEntityFromUniqueId", [](std::string const& uniqueId) -> Actor* {
|
||||||
|
auto auid = parseScriptUniqueID(uniqueId);
|
||||||
|
return ll::service::getLevel()->fetchEntity(auid);
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "getWorldSpawn", []() -> std::pair<BlockPos, int> {
|
||||||
|
return {GMLIB_Level::getInstance()->getWorldSpawn(), 0};
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "setWorldSpawn", [](std::pair<BlockPos, int> pos) -> bool {
|
||||||
|
if (pos.second != 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
GMLIB_Level::getInstance()->setWorldSpawn(pos.first);
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "getPlayerSpawnPoint", [](Player* pl) -> std::pair<BlockPos, int> {
|
||||||
|
auto player = (GMLIB_Player*)pl;
|
||||||
|
auto res = player->getSpawnPoint();
|
||||||
|
return {res.first, res.second};
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "setPlayerSpawnPoint", [](Player* pl, std::pair<BlockPos, int> pos) -> void {
|
||||||
|
auto player = (GMLIB_Player*)pl;
|
||||||
|
player->setSpawnPoint(pos.first, pos.second);
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "clearPlayerSpawnPoint", [](Player* pl) -> void {
|
||||||
|
auto player = (GMLIB_Player*)pl;
|
||||||
|
player->clearSpawnPoint();
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs(
|
||||||
|
"GMLIB_API",
|
||||||
|
"mergePatchJson",
|
||||||
|
[](std::string const& oldJson, std::string const& patchJson) -> std::string {
|
||||||
|
auto oldData = nlohmann::ordered_json::parse(oldJson);
|
||||||
|
auto newData = nlohmann::ordered_json::parse(patchJson);
|
||||||
|
oldData.merge_patch(newData);
|
||||||
|
return oldData.dump();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "getXuidByUuid", [](std::string const& uuid) -> std::string {
|
||||||
|
auto uid = mce::UUID::fromString(uuid);
|
||||||
|
auto result = UserCache::getXuidByUuid(uid);
|
||||||
|
return result ? result.value() : "";
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "getNameByUuid", [](std::string const& uuid) -> std::string {
|
||||||
|
auto uid = mce::UUID::fromString(uuid);
|
||||||
|
auto result = UserCache::getNameByUuid(uid);
|
||||||
|
return result ? result.value() : "";
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "getUuidByXuid", [](std::string const& xuid) -> std::string {
|
||||||
|
auto result = UserCache::getUuidByXuid(xuid);
|
||||||
|
return result ? result.value().asString() : "";
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "getNameByXuid", [](std::string const& xuid) -> std::string {
|
||||||
|
auto result = UserCache::getNameByXuid(xuid);
|
||||||
|
return result ? result.value() : "";
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "getXuidByName", [](std::string const& name) -> std::string {
|
||||||
|
auto result = UserCache::getXuidByName(name);
|
||||||
|
return result ? result.value() : "";
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "getUuidByName", [](std::string const& name) -> std::string {
|
||||||
|
auto result = UserCache::getUuidByName(name);
|
||||||
|
return result ? result.value().asString() : "";
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "getUuidByName", [](std::string const& name) -> std::string {
|
||||||
|
auto result = UserCache::getUuidByName(name);
|
||||||
|
return result ? result.value().asString() : "";
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs(
|
||||||
|
"GMLIB_API",
|
||||||
|
"getAllPlayerInfo",
|
||||||
|
[]() -> std::vector<std::unordered_map<std::string, std::string>> {
|
||||||
|
std::vector<std::unordered_map<std::string, std::string>> result;
|
||||||
|
UserCache::forEach([&result](const UserCache::UserCacheEntry& entry) {
|
||||||
|
std::unordered_map<std::string, std::string> info;
|
||||||
|
info["Name"] = entry.mName;
|
||||||
|
info["Xuid"] = entry.mXuid;
|
||||||
|
info["Uuid"] = entry.mUuid.asString();
|
||||||
|
result.push_back(info);
|
||||||
|
});
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "getBlockRuntimeId", [](std::string const& blockName) -> uint {
|
||||||
|
if (auto block = Block::tryGetFromRegistry(blockName)) {
|
||||||
|
return block->getRuntimeId();
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "getBlockTranslateKey", [](Block const* block) -> std::string {
|
||||||
|
return block->buildDescriptionId();
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "getItemTranslateKey", [](ItemStack* item) -> std::string {
|
||||||
|
return item->getDescriptionId();
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "getEntityTranslateKey", [](Actor* entity) -> std::string {
|
||||||
|
return entity->getEntityLocNameString();
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs(
|
||||||
|
"GMLIB_API",
|
||||||
|
"readNbtFromFile",
|
||||||
|
[](std::string const& path, bool isBinary) -> std::unique_ptr<CompoundTag> {
|
||||||
|
if (auto nbt = GMLIB_CompoundTag::readFromFile(path, isBinary)) {
|
||||||
|
return std::make_unique<CompoundTag>(nbt.value());
|
||||||
|
}
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
RemoteCall::exportAs(
|
||||||
|
"GMLIB_API",
|
||||||
|
"saveNbtToFile",
|
||||||
|
[](std::string const& path, CompoundTag* nbt, bool isBinary) -> bool {
|
||||||
|
return GMLIB_CompoundTag::saveToFile(path, *nbt, isBinary);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "getBlockDestroySpeed", [](Block const* block) -> float {
|
||||||
|
return block->getDestroySpeed();
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "getDestroyBlockSpeed", [](ItemStack const* item, Block const* block) -> float {
|
||||||
|
return item->getDestroySpeed(*block);
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs(
|
||||||
|
"GMLIB_API",
|
||||||
|
"playerDestroyBlock",
|
||||||
|
[](Block const* block, std::pair<BlockPos, int> pos, Player* player) -> void {
|
||||||
|
return block->playerDestroy(*player, pos.first);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "itemCanDestroyBlock", [](ItemStack const* item, Block const* block) -> bool {
|
||||||
|
return item->canDestroy(block);
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "itemCanDestroyInCreative", [](ItemStack const* item) -> bool {
|
||||||
|
return item->getItem()->canDestroyInCreative();
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "itemCanDestroySpecial", [](ItemStack const* item, Block const* block) -> bool {
|
||||||
|
return item->canDestroySpecial(*block);
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "blockCanDropWithAnyTool", [](Block const* block) -> bool {
|
||||||
|
return block->canDropWithAnyTool();
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "blockIsAlwaysDestroyable", [](Block const* block) -> bool {
|
||||||
|
return block->getMaterial().isAlwaysDestroyable();
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs(
|
||||||
|
"GMLIB_API",
|
||||||
|
"blockPlayerWillDestroy",
|
||||||
|
[](Block const* block, Player* player, std::pair<BlockPos, int> pos) -> bool {
|
||||||
|
return block->playerWillDestroy(*player, pos.first);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "playerAttack", [](Player* player, Actor* entity) -> bool {
|
||||||
|
return player->attack(*entity, ActorDamageCause::EntityAttack);
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "playerPullInEntity", [](Player* player, Actor* entity) -> bool {
|
||||||
|
return player->pullInEntity(*entity);
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "getBlockTranslateKeyFromName", [](std::string const& blockName) -> std::string {
|
||||||
|
if (auto block = Block::tryGetFromRegistry(blockName)) {
|
||||||
|
return block->buildDescriptionId();
|
||||||
|
}
|
||||||
|
return "tile.unknown.name";
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
+15
-37
@@ -3,56 +3,34 @@
|
|||||||
|
|
||||||
ll::Logger logger(PLUGIN_NAME);
|
ll::Logger logger(PLUGIN_NAME);
|
||||||
|
|
||||||
namespace GMLIB_LegacyRemoteCallApi {
|
namespace GMLIB {
|
||||||
|
|
||||||
namespace {
|
std::unique_ptr<LegacyRemoteCallApi>& LegacyRemoteCallApi::getInstance() {
|
||||||
|
static std::unique_ptr<LegacyRemoteCallApi> instance;
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
|
||||||
std::unique_ptr<std::reference_wrapper<ll::plugin::NativePlugin>>
|
bool LegacyRemoteCallApi::load() {
|
||||||
selfPluginInstance; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables)
|
|
||||||
|
|
||||||
auto disable(ll::plugin::NativePlugin& /*self*/) -> bool { return false; }
|
|
||||||
|
|
||||||
auto enable(ll::plugin::NativePlugin& /*self*/) -> bool { return true; }
|
|
||||||
|
|
||||||
auto load(ll::plugin::NativePlugin& self) -> bool {
|
|
||||||
selfPluginInstance = std::make_unique<std::reference_wrapper<ll::plugin::NativePlugin>>(self);
|
|
||||||
Export_Legacy_GMLib_ModAPI();
|
Export_Legacy_GMLib_ModAPI();
|
||||||
Export_Legacy_GMLib_ServerAPI();
|
Export_Legacy_GMLib_ServerAPI();
|
||||||
Export_Compatibility_API();
|
Export_Compatibility_API();
|
||||||
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-" + 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto unload(ll::plugin::NativePlugin& self) -> bool { return false; }
|
bool LegacyRemoteCallApi::enable() { return true; }
|
||||||
|
|
||||||
} // namespace
|
bool LegacyRemoteCallApi::disable() { return true; }
|
||||||
|
|
||||||
auto getSelfPluginInstance() -> ll::plugin::NativePlugin& {
|
} // namespace GMLIB
|
||||||
if (!selfPluginInstance) {
|
|
||||||
throw std::runtime_error("selfPluginInstance is null");
|
|
||||||
}
|
|
||||||
|
|
||||||
return *selfPluginInstance;
|
LL_REGISTER_PLUGIN(LegacyRemoteCallApi, LegacyRemoteCallApi::getInstance());
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace GMLIB_LegacyRemoteCallApi
|
|
||||||
|
|
||||||
extern "C" {
|
|
||||||
_declspec(dllexport) auto ll_plugin_disable(ll::plugin::NativePlugin& self) -> bool {
|
|
||||||
return GMLIB_LegacyRemoteCallApi::disable(self);
|
|
||||||
}
|
|
||||||
_declspec(dllexport) auto ll_plugin_enable(ll::plugin::NativePlugin& self) -> bool {
|
|
||||||
return GMLIB_LegacyRemoteCallApi::enable(self);
|
|
||||||
}
|
|
||||||
_declspec(dllexport) auto ll_plugin_load(ll::plugin::NativePlugin& self) -> bool {
|
|
||||||
return GMLIB_LegacyRemoteCallApi::load(self);
|
|
||||||
}
|
|
||||||
_declspec(dllexport) auto ll_plugin_unload(ll::plugin::NativePlugin& self) -> bool {
|
|
||||||
return GMLIB_LegacyRemoteCallApi::unload(self);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
+28
-4
@@ -1,9 +1,33 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <ll/api/plugin/NativePlugin.h>
|
#include <ll/api/plugin/NativePlugin.h>
|
||||||
|
#include <ll/api/plugin/RegisterHelper.h>
|
||||||
|
|
||||||
namespace GMLIB_LegacyRemoteCallApi {
|
namespace GMLIB {
|
||||||
|
|
||||||
[[nodiscard]] auto getSelfPluginInstance() -> ll::plugin::NativePlugin&;
|
class LegacyRemoteCallApi {
|
||||||
|
|
||||||
} // namespace GMLIB_LegacyRemoteCallApi
|
public:
|
||||||
|
static std::unique_ptr<LegacyRemoteCallApi>& getInstance();
|
||||||
|
|
||||||
|
LegacyRemoteCallApi(ll::plugin::NativePlugin& self) : mSelf(self) {}
|
||||||
|
|
||||||
|
[[nodiscard]] ll::plugin::NativePlugin& getSelf() const { return mSelf; }
|
||||||
|
|
||||||
|
/// @return True if the plugin is loaded successfully.
|
||||||
|
bool load();
|
||||||
|
|
||||||
|
/// @return True if the plugin is enabled successfully.
|
||||||
|
bool enable();
|
||||||
|
|
||||||
|
/// @return True if the plugin is disabled successfully.
|
||||||
|
bool disable();
|
||||||
|
|
||||||
|
// TODO: Implement this method if you need to unload the plugin.
|
||||||
|
// /// @return True if the plugin is unloaded successfully.
|
||||||
|
// bool unload();
|
||||||
|
|
||||||
|
private:
|
||||||
|
ll::plugin::NativePlugin& mSelf;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace GMLIB
|
||||||
|
|||||||
+74
-35
@@ -6,17 +6,18 @@ void Export_Event_API() {
|
|||||||
RemoteCall::exportAs(
|
RemoteCall::exportAs(
|
||||||
"GMLIB_API",
|
"GMLIB_API",
|
||||||
"callCustomEvent",
|
"callCustomEvent",
|
||||||
[eventBus](std::string eventName, std::string eventId) -> bool {
|
[eventBus](std::string const& eventName, std::string const& eventId) -> bool {
|
||||||
if (RemoteCall::hasFunc(eventName, eventId)) {
|
if (RemoteCall::hasFunc(eventName, eventId)) {
|
||||||
switch (do_hash(eventName)) {
|
switch (doHash(eventName)) {
|
||||||
case do_hash("onClientLogin"): {
|
case doHash("onClientLogin"): {
|
||||||
auto Call = RemoteCall::importAs<
|
auto Call = RemoteCall::importAs<bool(
|
||||||
bool(std::string realName, std::string uuid, std::string serverXuid, std::string clientXuid)>(
|
std::string const& realName,
|
||||||
eventName,
|
std::string const& uuid,
|
||||||
eventId
|
std::string const& serverXuid,
|
||||||
);
|
std::string const& clientXuid
|
||||||
eventBus->emplaceListener<GMLIB::Event::PacketEvent::ClientLoginAfterEvent>(
|
)>(eventName, eventId);
|
||||||
[Call](GMLIB::Event::PacketEvent::ClientLoginAfterEvent& ev) {
|
eventBus->emplaceListener<Event::PacketEvent::ClientLoginAfterEvent>(
|
||||||
|
[Call](Event::PacketEvent::ClientLoginAfterEvent& ev) {
|
||||||
try {
|
try {
|
||||||
Call(
|
Call(
|
||||||
ev.getRealName(),
|
ev.getRealName(),
|
||||||
@@ -29,14 +30,14 @@ void Export_Event_API() {
|
|||||||
);
|
);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
case do_hash("onWeatherChange"): {
|
case doHash("onWeatherChange"): {
|
||||||
auto Call =
|
auto Call =
|
||||||
RemoteCall::importAs<bool(int lightningLevel, int rainLevel, int lightningLast, int rainLast)>(
|
RemoteCall::importAs<bool(int lightningLevel, int rainLevel, int lightningLast, int rainLast)>(
|
||||||
eventName,
|
eventName,
|
||||||
eventId
|
eventId
|
||||||
);
|
);
|
||||||
eventBus->emplaceListener<GMLIB::Event::LevelEvent::WeatherUpdateBeforeEvent>(
|
eventBus->emplaceListener<Event::LevelEvent::WeatherUpdateBeforeEvent>(
|
||||||
[Call](GMLIB::Event::LevelEvent::WeatherUpdateBeforeEvent& ev) {
|
[Call](Event::LevelEvent::WeatherUpdateBeforeEvent& ev) {
|
||||||
bool result = true;
|
bool result = true;
|
||||||
try {
|
try {
|
||||||
result = Call(
|
result = Call(
|
||||||
@@ -53,10 +54,10 @@ void Export_Event_API() {
|
|||||||
);
|
);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
case do_hash("onMobPick"): {
|
case doHash("onMobPick"): {
|
||||||
auto Call = RemoteCall::importAs<bool(Actor * mob, Actor * item)>(eventName, eventId);
|
auto Call = RemoteCall::importAs<bool(Actor * mob, Actor * item)>(eventName, eventId);
|
||||||
eventBus->emplaceListener<GMLIB::Event::EntityEvent::MobPickupItemBeforeEvent>(
|
eventBus->emplaceListener<Event::EntityEvent::MobPickupItemBeforeEvent>(
|
||||||
[Call](GMLIB::Event::EntityEvent::MobPickupItemBeforeEvent& ev) {
|
[Call](Event::EntityEvent::MobPickupItemBeforeEvent& ev) {
|
||||||
bool result = true;
|
bool result = true;
|
||||||
try {
|
try {
|
||||||
result = Call(&ev.self(), (Actor*)&ev.getItemActor());
|
result = Call(&ev.self(), (Actor*)&ev.getItemActor());
|
||||||
@@ -68,11 +69,11 @@ void Export_Event_API() {
|
|||||||
);
|
);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
case do_hash("onItemTrySpawn"): {
|
case doHash("onItemTrySpawn"): {
|
||||||
auto Call = RemoteCall::importAs<
|
auto Call = RemoteCall::importAs<
|
||||||
bool(const ItemStack* item, std::pair<Vec3, int> position, Actor* spawner)>(eventName, eventId);
|
bool(const ItemStack* item, std::pair<Vec3, int> position, Actor* spawner)>(eventName, eventId);
|
||||||
eventBus->emplaceListener<GMLIB::Event::EntityEvent::ItemActorSpawnBeforeEvent>(
|
eventBus->emplaceListener<Event::EntityEvent::ItemActorSpawnBeforeEvent>(
|
||||||
[Call](GMLIB::Event::EntityEvent::ItemActorSpawnBeforeEvent& ev) {
|
[Call](Event::EntityEvent::ItemActorSpawnBeforeEvent& ev) {
|
||||||
auto pos = ev.getPosition();
|
auto pos = ev.getPosition();
|
||||||
auto dimid = ev.getBlockSource().getDimensionId().id;
|
auto dimid = ev.getBlockSource().getDimensionId().id;
|
||||||
std::pair<Vec3, int> lsePos = {pos, dimid};
|
std::pair<Vec3, int> lsePos = {pos, dimid};
|
||||||
@@ -87,14 +88,14 @@ void Export_Event_API() {
|
|||||||
);
|
);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
case do_hash("onItemSpawned"): {
|
case doHash("onItemSpawned"): {
|
||||||
auto Call = RemoteCall::importAs<
|
auto Call = RemoteCall::importAs<
|
||||||
bool(const ItemStack* item, Actor* itemActor, std::pair<Vec3, int> position, Actor* spawner)>(
|
bool(const ItemStack* item, Actor* itemActor, std::pair<Vec3, int> position, Actor* spawner)>(
|
||||||
eventName,
|
eventName,
|
||||||
eventId
|
eventId
|
||||||
);
|
);
|
||||||
eventBus->emplaceListener<GMLIB::Event::EntityEvent::ItemActorSpawnAfterEvent>(
|
eventBus->emplaceListener<Event::EntityEvent::ItemActorSpawnAfterEvent>(
|
||||||
[Call](GMLIB::Event::EntityEvent::ItemActorSpawnAfterEvent& ev) {
|
[Call](Event::EntityEvent::ItemActorSpawnAfterEvent& ev) {
|
||||||
auto pos = ev.getPosition();
|
auto pos = ev.getPosition();
|
||||||
auto dimid = ev.getBlockSource().getDimensionId().id;
|
auto dimid = ev.getBlockSource().getDimensionId().id;
|
||||||
std::pair<Vec3, int> lsePos = {pos, dimid};
|
std::pair<Vec3, int> lsePos = {pos, dimid};
|
||||||
@@ -105,14 +106,13 @@ void Export_Event_API() {
|
|||||||
);
|
);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
case do_hash("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<Event::EntityEvent::ActorChangeDimensionBeforeEvent>(
|
||||||
[Call](GMLIB::Event::PacketEvent::TextPacketSendBeforeEvent& ev) {
|
[Call](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();
|
||||||
@@ -121,10 +121,10 @@ void Export_Event_API() {
|
|||||||
);
|
);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
case do_hash("onLeaveBed"): {
|
case doHash("onLeaveBed"): {
|
||||||
auto Call = RemoteCall::importAs<bool(Player * pl)>(eventName, eventId);
|
auto Call = RemoteCall::importAs<bool(Player * pl)>(eventName, eventId);
|
||||||
eventBus->emplaceListener<GMLIB::Event::PlayerEvent::PlayerStopSleepBeforeEvent>(
|
eventBus->emplaceListener<Event::PlayerEvent::PlayerStopSleepBeforeEvent>(
|
||||||
[Call](GMLIB::Event::PlayerEvent::PlayerStopSleepBeforeEvent& ev) {
|
[Call](Event::PlayerEvent::PlayerStopSleepBeforeEvent& ev) {
|
||||||
bool result = true;
|
bool result = true;
|
||||||
try {
|
try {
|
||||||
result = Call(&ev.self());
|
result = Call(&ev.self());
|
||||||
@@ -136,13 +136,14 @@ void Export_Event_API() {
|
|||||||
);
|
);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
case do_hash("onDeathMessage"): {
|
case doHash("onDeathMessage"): {
|
||||||
auto Call = RemoteCall::importAs<bool(std::string message, std::vector<std::string>, Actor * dead)>(
|
auto Call =
|
||||||
|
RemoteCall::importAs<bool(std::string const& message, std::vector<std::string>, Actor* dead)>(
|
||||||
eventName,
|
eventName,
|
||||||
eventId
|
eventId
|
||||||
);
|
);
|
||||||
eventBus->emplaceListener<GMLIB::Event::EntityEvent::DeathMessageAfterEvent>(
|
eventBus->emplaceListener<Event::EntityEvent::DeathMessageAfterEvent>(
|
||||||
[Call](GMLIB::Event::EntityEvent::DeathMessageAfterEvent& ev) {
|
[Call](Event::EntityEvent::DeathMessageAfterEvent& ev) {
|
||||||
auto msg = ev.getDeathMessage();
|
auto msg = ev.getDeathMessage();
|
||||||
auto source = ev.getDamageSource();
|
auto source = ev.getDamageSource();
|
||||||
try {
|
try {
|
||||||
@@ -152,6 +153,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<Event::EntityEvent::MobHurtAfterEvent>(
|
||||||
|
[Call](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<Event::EntityEvent::EndermanTakeBlockBeforeEvent>(
|
||||||
|
[Call](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;
|
||||||
}
|
}
|
||||||
|
|||||||
+11
-2
@@ -3,8 +3,17 @@
|
|||||||
|
|
||||||
#include <RemoteCallAPI.h>
|
#include <RemoteCallAPI.h>
|
||||||
|
|
||||||
#define PLUGIN_NAME "GMLIB-LRCA"
|
using namespace GMLIB;
|
||||||
#define LIB_VERSION SemVersion(0, 9, 1, "", "")
|
using namespace Server;
|
||||||
|
using namespace Mod;
|
||||||
|
|
||||||
|
#define PLUGIN_NAME fmt::format(fg(fmt::color::light_green), "GMLIB-LRCA")
|
||||||
|
|
||||||
|
#define LIB_VERSION_MAJOR 0
|
||||||
|
#define LIB_VERSION_MINOR 12
|
||||||
|
#define LIB_VERSION_PATCH 8
|
||||||
|
|
||||||
|
#define LIB_VERSION Version(LIB_VERSION_MAJOR, LIB_VERSION_MINOR, LIB_VERSION_PATCH)
|
||||||
|
|
||||||
extern ll::Logger logger;
|
extern ll::Logger logger;
|
||||||
|
|
||||||
|
|||||||
+63
-52
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
std::unordered_set<std::string> HardCodedKeys = {"AlwaysUnlocked", "PlayerHasManyItems", "PlayerInWater", "None"};
|
std::unordered_set<std::string> HardCodedKeys = {"AlwaysUnlocked", "PlayerHasManyItems", "PlayerInWater", "None"};
|
||||||
|
|
||||||
std::variant<std::string, std::vector<RecipeIngredient>> makeRecipeUnlockingKey(std::string& key) {
|
std::variant<std::string, std::vector<RecipeIngredient>> makeRecipeUnlockingKey(std::string const& key) {
|
||||||
if (HardCodedKeys.count(key)) {
|
if (HardCodedKeys.count(key)) {
|
||||||
return key;
|
return key;
|
||||||
}
|
}
|
||||||
@@ -17,12 +17,12 @@ void Export_Legacy_GMLib_ModAPI() {
|
|||||||
RemoteCall::exportAs(
|
RemoteCall::exportAs(
|
||||||
"GMLib_ModAPI",
|
"GMLib_ModAPI",
|
||||||
"registerShapelessRecipe",
|
"registerShapelessRecipe",
|
||||||
[](std::string recipe_id,
|
[](std::string const& recipe_id,
|
||||||
std::vector<std::string> ingredients,
|
std::vector<std::string> ingredients,
|
||||||
std::string result,
|
std::string const& result,
|
||||||
int count,
|
int count,
|
||||||
std::string unlock) -> void {
|
std::string const& unlock) -> void {
|
||||||
auto level = GMLIB_Level::getLevel();
|
auto level = GMLIB_Level::getInstance();
|
||||||
if (!level) {
|
if (!level) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -33,19 +33,19 @@ void Export_Legacy_GMLib_ModAPI() {
|
|||||||
}
|
}
|
||||||
auto res = RecipeIngredient(result, 0, count);
|
auto res = RecipeIngredient(result, 0, count);
|
||||||
auto unl = makeRecipeUnlockingKey(unlock);
|
auto unl = makeRecipeUnlockingKey(unlock);
|
||||||
GMLIB::Mod::CustomRecipe::registerShapelessCraftingTableRecipe(recipe_id, types, res, unl);
|
JsonRecipe::registerShapelessCraftingTableRecipe(recipe_id, types, res, unl);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
RemoteCall::exportAs(
|
RemoteCall::exportAs(
|
||||||
"GMLib_ModAPI",
|
"GMLib_ModAPI",
|
||||||
"registerShapedRecipe",
|
"registerShapedRecipe",
|
||||||
[](std::string recipe_id,
|
[](std::string const& recipe_id,
|
||||||
std::vector<std::string> shape,
|
std::vector<std::string> shape,
|
||||||
std::vector<std::string> ingredients,
|
std::vector<std::string> ingredients,
|
||||||
std::string result,
|
std::string const& result,
|
||||||
int count,
|
int count,
|
||||||
std::string unlock) -> void {
|
std::string const& unlock) -> void {
|
||||||
auto level = GMLIB_Level::getLevel();
|
auto level = GMLIB_Level::getInstance();
|
||||||
if (!level) {
|
if (!level) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -56,61 +56,66 @@ void Export_Legacy_GMLib_ModAPI() {
|
|||||||
}
|
}
|
||||||
auto res = RecipeIngredient(result, 0, count);
|
auto res = RecipeIngredient(result, 0, count);
|
||||||
auto unl = makeRecipeUnlockingKey(unlock);
|
auto unl = makeRecipeUnlockingKey(unlock);
|
||||||
GMLIB::Mod::CustomRecipe::registerShapedCraftingTableRecipe(recipe_id, shape, types, res, unl);
|
JsonRecipe::registerShapedCraftingTableRecipe(recipe_id, shape, types, res, unl);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
RemoteCall::exportAs(
|
RemoteCall::exportAs(
|
||||||
"GMLib_ModAPI",
|
"GMLib_ModAPI",
|
||||||
"registerFurnaceRecipe",
|
"registerFurnaceRecipe",
|
||||||
[](std::string recipe_id, std::string input, std::string output, std::vector<std::string> tags) -> void {
|
[](std::string const& recipe_id,
|
||||||
auto level = GMLIB_Level::getLevel();
|
std::string const& input,
|
||||||
|
std::string const& output,
|
||||||
|
std::vector<std::string> tags) -> void {
|
||||||
|
auto level = GMLIB_Level::getInstance();
|
||||||
if (!level) {
|
if (!level) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
auto inp = RecipeIngredient(input, 0, 1);
|
auto inp = RecipeIngredient(input, 0, 1);
|
||||||
auto outp = RecipeIngredient(output, 0, 1);
|
auto outp = RecipeIngredient(output, 0, 1);
|
||||||
GMLIB::Mod::CustomRecipe::registerFurnaceRecipe(recipe_id, inp, outp, tags);
|
JsonRecipe::registerFurnaceRecipe(recipe_id, inp, outp, tags);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
RemoteCall::exportAs(
|
RemoteCall::exportAs(
|
||||||
"GMLib_ModAPI",
|
"GMLib_ModAPI",
|
||||||
"registerBrewingMixRecipe",
|
"registerBrewingMixRecipe",
|
||||||
[](std::string recipe_id, std::string input, std::string output, std::string reagent) -> void {
|
[](std::string const& recipe_id, std::string const& input, std::string const& output, std::string const& reagent
|
||||||
auto level = GMLIB_Level::getLevel();
|
) -> void {
|
||||||
|
auto level = GMLIB_Level::getInstance();
|
||||||
if (!level) {
|
if (!level) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
auto rea = RecipeIngredient(reagent, 0, 1);
|
auto rea = RecipeIngredient(reagent, 0, 1);
|
||||||
GMLIB::Mod::CustomRecipe::registerBrewingMixRecipe(recipe_id, input, output, rea);
|
JsonRecipe::registerBrewingMixRecipe(recipe_id, input, output, rea);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
RemoteCall::exportAs(
|
RemoteCall::exportAs(
|
||||||
"GMLib_ModAPI",
|
"GMLib_ModAPI",
|
||||||
"registerBrewingContainerRecipe",
|
"registerBrewingContainerRecipe",
|
||||||
[](std::string recipe_id, std::string input, std::string output, std::string reagent) -> void {
|
[](std::string const& recipe_id, std::string const& input, std::string const& output, std::string const& reagent
|
||||||
auto level = GMLIB_Level::getLevel();
|
) -> void {
|
||||||
|
auto level = GMLIB_Level::getInstance();
|
||||||
if (!level) {
|
if (!level) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
auto inp = RecipeIngredient(input, 0, 1);
|
auto inp = RecipeIngredient(input, 0, 1);
|
||||||
auto outp = RecipeIngredient(output, 0, 1);
|
auto outp = RecipeIngredient(output, 0, 1);
|
||||||
auto rea = RecipeIngredient(reagent, 0, 1);
|
auto rea = RecipeIngredient(reagent, 0, 1);
|
||||||
GMLIB::Mod::CustomRecipe::registerBrewingContainerRecipe(recipe_id, inp, outp, rea);
|
JsonRecipe::registerBrewingContainerRecipe(recipe_id, inp, outp, rea);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
RemoteCall::exportAs(
|
RemoteCall::exportAs(
|
||||||
"GMLib_ModAPI",
|
"GMLib_ModAPI",
|
||||||
"registerSmithingTransformRecipe",
|
"registerSmithingTransformRecipe",
|
||||||
[](std::string recipe_id,
|
[](std::string const& recipe_id,
|
||||||
std::string smithing_template,
|
std::string const& smithing_template,
|
||||||
std::string base,
|
std::string const& base,
|
||||||
std::string addition,
|
std::string const& addition,
|
||||||
std::string result) -> void {
|
std::string const& result) -> void {
|
||||||
auto level = GMLIB_Level::getLevel();
|
auto level = GMLIB_Level::getInstance();
|
||||||
if (!level) {
|
if (!level) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
GMLIB::Mod::CustomRecipe::registerSmithingTransformRecipe(
|
JsonRecipe::registerSmithingTransformRecipe(
|
||||||
recipe_id,
|
recipe_id,
|
||||||
smithing_template,
|
smithing_template,
|
||||||
base,
|
base,
|
||||||
@@ -122,66 +127,72 @@ void Export_Legacy_GMLib_ModAPI() {
|
|||||||
RemoteCall::exportAs(
|
RemoteCall::exportAs(
|
||||||
"GMLib_ModAPI",
|
"GMLib_ModAPI",
|
||||||
"registerSmithingTrimRecipe",
|
"registerSmithingTrimRecipe",
|
||||||
[](std::string recipe_id, std::string smithing_template, std::string base, std::string addition) -> void {
|
[](std::string const& recipe_id,
|
||||||
auto level = GMLIB_Level::getLevel();
|
std::string const& smithing_template,
|
||||||
|
std::string const& base,
|
||||||
|
std::string const& addition) -> void {
|
||||||
|
auto level = GMLIB_Level::getInstance();
|
||||||
if (!level) {
|
if (!level) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
GMLIB::Mod::CustomRecipe::registerSmithingTrimRecipe(recipe_id, smithing_template, base, addition);
|
JsonRecipe::registerSmithingTrimRecipe(recipe_id, smithing_template, base, addition);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
RemoteCall::exportAs(
|
RemoteCall::exportAs(
|
||||||
"GMLib_ModAPI",
|
"GMLib_ModAPI",
|
||||||
"registerStoneCutterRecipe",
|
"registerStoneCutterRecipe",
|
||||||
[](std::string recipe_id,
|
[](std::string const& recipe_id,
|
||||||
std::string input,
|
std::string const& input,
|
||||||
int input_data,
|
int input_data,
|
||||||
std::string output,
|
std::string const& output,
|
||||||
int output_data,
|
int output_data,
|
||||||
int output_count) -> void {
|
int output_count) -> void {
|
||||||
auto level = GMLIB_Level::getLevel();
|
auto level = GMLIB_Level::getInstance();
|
||||||
if (!level) {
|
if (!level) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
auto inp = RecipeIngredient(input, 0, 1);
|
auto inp = RecipeIngredient(input, 0, 1);
|
||||||
auto outp = RecipeIngredient(output, 0, 1);
|
auto outp = RecipeIngredient(output, 0, 1);
|
||||||
GMLIB::Mod::CustomRecipe::registerStoneCutterRecipe(recipe_id, inp, outp);
|
JsonRecipe::registerStoneCutterRecipe(recipe_id, inp, outp);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
// 错误方块清理
|
// 错误方块清理
|
||||||
RemoteCall::exportAs("GMLib_ModAPI", "setUnknownBlockCleaner", []() -> void {
|
RemoteCall::exportAs("GMLib_ModAPI", "setUnknownBlockCleaner", []() -> void {
|
||||||
GMLIB::Mod::VanillaFix::setAutoCleanUnknownBlockEnabled();
|
VanillaFix::setAutoCleanUnknownBlockEnabled();
|
||||||
});
|
});
|
||||||
// 实验性
|
// 实验性
|
||||||
RemoteCall::exportAs("GMLib_ModAPI", "registerExperimentsRequire", [](int experiment_id) -> void {
|
RemoteCall::exportAs("GMLib_ModAPI", "registerExperimentsRequire", [](int experiment_id) -> void {
|
||||||
auto map = GMLIB_Level::getAllExperiments();
|
auto list = GMLIB_Level::getAllExperiments();
|
||||||
if (map.count(experiment_id)) {
|
std::unordered_set<AllExperiments> set(list.begin(), list.end());
|
||||||
|
if (set.contains((AllExperiments)experiment_id)) {
|
||||||
GMLIB_Level::addExperimentsRequire((AllExperiments)experiment_id);
|
GMLIB_Level::addExperimentsRequire((AllExperiments)experiment_id);
|
||||||
} else {
|
} else {
|
||||||
ll::Logger("Server").error("Experiment ID '{}' does not exist!", experiment_id);
|
ll::Logger("Server").error("Experiment ID '{}' does not exist!", experiment_id);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLib_ModAPI", "setExperimentEnabled", [](int experiment_id, bool value) -> void {
|
RemoteCall::exportAs("GMLib_ModAPI", "setExperimentEnabled", [](int experiment_id, bool value) -> void {
|
||||||
auto level = GMLIB_Level::getLevel();
|
if (GMLIB_Level::getInstance()) {
|
||||||
if (!level) {
|
auto list = GMLIB_Level::getAllExperiments();
|
||||||
return;
|
std::unordered_set<AllExperiments> set(list.begin(), list.end());
|
||||||
}
|
if (set.contains((AllExperiments)experiment_id)) {
|
||||||
auto map = GMLIB_Level::getAllExperiments();
|
GMLIB_Level::getInstance()->setExperimentEnabled(((AllExperiments)experiment_id), value);
|
||||||
if (map.count(experiment_id)) {
|
|
||||||
GMLIB_Level::getLevel()->setExperimentEnabled(((AllExperiments)experiment_id), value);
|
|
||||||
} else ll::Logger("Server").error("Experiment ID '{}' does not exist!", experiment_id);
|
} else ll::Logger("Server").error("Experiment ID '{}' does not exist!", experiment_id);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLib_ModAPI", "getExperimentEnabled", [](int experiment_id) -> bool {
|
RemoteCall::exportAs("GMLib_ModAPI", "getExperimentEnabled", [](int experiment_id) -> bool {
|
||||||
auto level = GMLIB_Level::getLevel();
|
if (GMLIB_Level::getInstance()) {
|
||||||
if (!level) {
|
auto list = GMLIB_Level::getAllExperiments();
|
||||||
return false;
|
std::unordered_set<AllExperiments> set(list.begin(), list.end());
|
||||||
}
|
if (set.contains((AllExperiments)experiment_id)) {
|
||||||
auto map = GMLIB_Level::getAllExperiments();
|
return GMLIB_Level::getInstance()->getExperimentEnabled(((AllExperiments)experiment_id));
|
||||||
if (map.count(experiment_id)) {
|
|
||||||
return GMLIB_Level::getLevel()->getExperimentEnabled(((AllExperiments)experiment_id));
|
|
||||||
} else {
|
} else {
|
||||||
ll::Logger("Server").error("Experiment ID '{}' does not exist!", experiment_id);
|
ll::Logger("Server").error("Experiment ID '{}' does not exist!", experiment_id);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs("GMLib_ModAPI", "setFixI18nEnabled", []() -> void {
|
||||||
|
VanillaFix::setFixI18nEnabled();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
+43
-19
@@ -1,41 +1,52 @@
|
|||||||
|
#include "GMLIB/Server/FakeListAPI.h"
|
||||||
#include "Global.h"
|
#include "Global.h"
|
||||||
|
#include "mc/world/ActorUniqueID.h"
|
||||||
|
|
||||||
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 {
|
||||||
RemoteCall::exportAs("GMLib_ServerAPI", "getLevelName", []() -> std::string {
|
GMLIB_Level::requireServerResourcePackAndAllowClientResourcePack();
|
||||||
auto level = GMLIB_Level::getLevel();
|
|
||||||
if (!level) {
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
return level->getLevelName();
|
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLib_ServerAPI", "setLevelName", [](std::string name) -> void {
|
RemoteCall::exportAs("GMLib_ServerAPI", "getLevelName", []() -> std::string {
|
||||||
auto level = GMLIB_Level::getLevel();
|
if (auto level = GMLIB_Level::getInstance()) {
|
||||||
if (!level) {
|
return level->getLevelName();
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
return level->setLevelName(name);
|
return {};
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs("GMLib_ServerAPI", "setLevelName", [](std::string const& name) -> void {
|
||||||
|
if (auto level = GMLIB_Level::getInstance()) {
|
||||||
|
level->setLevelName(name);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs("GMLib_ServerAPI", "getLevelSeed", []() -> std::string {
|
||||||
|
if (auto level = GMLIB_Level::getInstance()) {
|
||||||
|
return std::to_string(level->getSeed());
|
||||||
|
}
|
||||||
|
return {};
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLib_ServerAPI", "setFakeSeed", [](int64_t seed) -> void {
|
RemoteCall::exportAs("GMLib_ServerAPI", "setFakeSeed", [](int64_t seed) -> void {
|
||||||
return GMLIB_Level::setFakeSeed(seed);
|
return GMLIB_Level::setFakeSeed(seed);
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLib_ServerAPI", "spawnEntity", [](std::pair<Vec3, int> pos, std::string name) -> Actor* {
|
RemoteCall::exportAs(
|
||||||
|
"GMLib_ServerAPI",
|
||||||
|
"spawnEntity",
|
||||||
|
[](std::pair<Vec3, int> pos, std::string const& name) -> Actor* {
|
||||||
return GMLIB_Spawner::spawnEntity(pos.first, pos.second, name);
|
return GMLIB_Spawner::spawnEntity(pos.first, pos.second, name);
|
||||||
});
|
}
|
||||||
|
);
|
||||||
RemoteCall::exportAs(
|
RemoteCall::exportAs(
|
||||||
"GMLib_ServerAPI",
|
"GMLib_ServerAPI",
|
||||||
"shootProjectile",
|
"shootProjectile",
|
||||||
[](Actor* owner, std::string name, float speed, float offset) -> Actor* {
|
[](Actor* owner, std::string const& name, float speed, float offset) -> Actor* {
|
||||||
auto ac = (GMLIB_Actor*)owner;
|
auto ac = (GMLIB_Actor*)owner;
|
||||||
return ac->shootProjectile(name, speed, offset);
|
return ac->shootProjectile(name, speed, offset);
|
||||||
}
|
}
|
||||||
@@ -45,8 +56,21 @@ void Export_Legacy_GMLib_ServerAPI() {
|
|||||||
"throwEntity",
|
"throwEntity",
|
||||||
[](Actor* owner, Actor* actor, float speed, float offset) -> bool {
|
[](Actor* owner, Actor* actor, float speed, float offset) -> bool {
|
||||||
auto ac = (GMLIB_Actor*)owner;
|
auto ac = (GMLIB_Actor*)owner;
|
||||||
return ac->throwEntity(actor, speed, offset);
|
return ac->throwEntity(*actor, speed, offset);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
RemoteCall::exportAs("GMLib_ServerAPI", "PlayerToEntity", [](Player* player) -> Actor* { return (Actor*)player; });
|
RemoteCall::exportAs("GMLib_ServerAPI", "PlayerToEntity", [](Player* player) -> Actor* { return (Actor*)player; });
|
||||||
|
RemoteCall::exportAs(
|
||||||
|
"GMLib_ServerAPI",
|
||||||
|
"addFakeList",
|
||||||
|
[](const std::string& name, const std::string& xuid) -> bool {
|
||||||
|
return FakeList::addFakeList(name, xuid, ActorUniqueID(-1));
|
||||||
|
}
|
||||||
|
);
|
||||||
|
RemoteCall::exportAs("GMLib_ServerAPI", "removeFakeList", [](const std::string& nameOrXuid) -> bool {
|
||||||
|
return FakeList::removeFakeList(nameOrXuid);
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs("GMLib_ServerAPI", "removeAllFakeList", []() -> void {
|
||||||
|
return FakeList::removeAllFakeLists();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
+42
-12
@@ -3,10 +3,20 @@
|
|||||||
|
|
||||||
namespace PAPIRemoteCall {
|
namespace PAPIRemoteCall {
|
||||||
|
|
||||||
std::string GetValue(std::string const& from) { return GMLIB::Server::PlaceholderAPI::getValue(from); }
|
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 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) {
|
||||||
return GMLIB::Server::PlaceholderAPI::getValue(a1, ll::service::bedrock::getLevel()->getPlayer(a2));
|
return PlaceholderAPI::getValue(a1, ll::service::bedrock::getLevel()->getPlayer(a2));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool registerPlayerPlaceholder(
|
bool registerPlayerPlaceholder(
|
||||||
@@ -15,12 +25,24 @@ bool registerPlayerPlaceholder(
|
|||||||
std::string const& PAPIName
|
std::string const& PAPIName
|
||||||
) {
|
) {
|
||||||
if (RemoteCall::hasFunc(PluginName, FuncName)) {
|
if (RemoteCall::hasFunc(PluginName, FuncName)) {
|
||||||
|
if (isParameters(PAPIName)) {
|
||||||
|
auto Call = RemoteCall::importAs<std::string(Player * pl, std::unordered_map<std::string, std::string>)>(
|
||||||
|
PluginName,
|
||||||
|
FuncName
|
||||||
|
);
|
||||||
|
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);
|
auto Call = RemoteCall::importAs<std::string(Player * pl)>(PluginName, FuncName);
|
||||||
GMLIB::Server::PlaceholderAPI::registerPlayerPlaceholder(
|
PlaceholderAPI::registerPlayerPlaceholder(
|
||||||
PAPIName,
|
PAPIName,
|
||||||
[Call](Player* sp) { return Call(sp); },
|
[Call](Player* sp) { return Call(sp); },
|
||||||
PluginName
|
PluginName
|
||||||
);
|
);
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@@ -32,12 +54,18 @@ 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 =
|
||||||
|
RemoteCall::importAs<std::string(std::unordered_map<std::string, std::string>)>(PluginName, FuncName);
|
||||||
|
PlaceholderAPI::registerServerPlaceholder(
|
||||||
PAPIName,
|
PAPIName,
|
||||||
[Call]() { return Call(); },
|
[Call](std::unordered_map<std::string, std::string> map) { return Call(map); },
|
||||||
PluginName
|
PluginName
|
||||||
);
|
);
|
||||||
|
} else {
|
||||||
|
auto Call = RemoteCall::importAs<std::string()>(PluginName, FuncName);
|
||||||
|
PlaceholderAPI::registerServerPlaceholder(PAPIName, [Call]() { return Call(); }, PluginName);
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@@ -50,35 +78,37 @@ bool registerStaticPlaceholder(
|
|||||||
int num
|
int num
|
||||||
) {
|
) {
|
||||||
if (RemoteCall::hasFunc(PluginName, FuncName)) {
|
if (RemoteCall::hasFunc(PluginName, FuncName)) {
|
||||||
|
if (isParameters(PAPIName)) {
|
||||||
auto Call = RemoteCall::importAs<std::string()>(PluginName, FuncName);
|
auto Call = RemoteCall::importAs<std::string()>(PluginName, FuncName);
|
||||||
if (num == -1) {
|
if (num == -1) {
|
||||||
GMLIB::Server::PlaceholderAPI::registerStaticPlaceholder(
|
PlaceholderAPI::registerStaticPlaceholder(
|
||||||
PAPIName,
|
PAPIName,
|
||||||
[Call] { return Call(); },
|
[Call] { return Call(); },
|
||||||
PluginName
|
PluginName
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
GMLIB::Server::PlaceholderAPI::registerStaticPlaceholder(
|
PlaceholderAPI::registerStaticPlaceholder(
|
||||||
PAPIName,
|
PAPIName,
|
||||||
num,
|
num,
|
||||||
[Call] { return Call(); },
|
[Call] { return Call(); },
|
||||||
PluginName
|
PluginName
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string translateStringWithPlayer(std::string const& str, Player* pl) {
|
std::string translateStringWithPlayer(std::string const& str, Player* pl) {
|
||||||
return GMLIB::Server::PlaceholderAPI::translateString(str, pl);
|
return PlaceholderAPI::translateString(str, pl);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string translateString(std::string const& str) { return GMLIB::Server::PlaceholderAPI::translateString(str); }
|
std::string translateString(std::string const& str) { return PlaceholderAPI::translateString(str); }
|
||||||
|
|
||||||
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() { return PlaceholderAPI::getAllPAPI(); }
|
||||||
|
|
||||||
} // namespace PAPIRemoteCall
|
} // namespace PAPIRemoteCall
|
||||||
|
|
||||||
|
|||||||
+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.1",
|
"version": "0.12.8",
|
||||||
"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.1/GMLIB-LegacyRemoteCallApi-windows-x64.zip",
|
"asset_url": "https://github.com/GroupMountain/GMLIB-LegacyRemoteCallApi/releases/download/v0.12.8/GMLIB-LegacyRemoteCallApi-windows-x64.zip",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"github.com/GroupMountain/GMLIB": ">=0.9.2"
|
"github.com/GroupMountain/GMLIB": ">=0.12.8"
|
||||||
},
|
},
|
||||||
"files": {
|
"files": {
|
||||||
"place": [
|
"place": [
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
add_rules("mode.debug", "mode.release", "mode.releasedbg")
|
add_rules("mode.debug", "mode.release")
|
||||||
|
|
||||||
add_repositories("liteldev-repo https://github.com/LiteLDev/xmake-repo.git")
|
add_repositories("liteldev-repo https://github.com/LiteLDev/xmake-repo.git")
|
||||||
|
add_repositories("groupmountain-repo https://github.com/GroupMountain/xmake-repo.git")
|
||||||
|
|
||||||
if not has_config("vs_runtime") then
|
if not has_config("vs_runtime") then
|
||||||
set_runtimes("MD")
|
set_runtimes("MD")
|
||||||
@@ -9,6 +10,7 @@ end
|
|||||||
-- Option 1: Use the latest version of LeviLamina released on GitHub.
|
-- Option 1: Use the latest version of LeviLamina released on GitHub.
|
||||||
add_requires("levilamina")
|
add_requires("levilamina")
|
||||||
add_requires("legacyremotecall")
|
add_requires("legacyremotecall")
|
||||||
|
add_requires("gmlib")
|
||||||
|
|
||||||
-- Option 2: Use a specific version of LeviLamina released on GitHub.
|
-- Option 2: Use a specific version of LeviLamina released on GitHub.
|
||||||
-- add_requires("levilamina x.x.x")
|
-- add_requires("levilamina x.x.x")
|
||||||
@@ -47,28 +49,27 @@ target("GMLIB-LegacyRemoteCallApi") -- Change this to your plugin name.
|
|||||||
"/utf-8"
|
"/utf-8"
|
||||||
)
|
)
|
||||||
add_defines(
|
add_defines(
|
||||||
"_HAS_CXX23=1" -- To enable C++23 features
|
"NOMINMAX",
|
||||||
|
"UNICODE"
|
||||||
)
|
)
|
||||||
add_files(
|
add_files(
|
||||||
"src/**.cpp"
|
"src/**.cpp"
|
||||||
)
|
)
|
||||||
add_links(
|
|
||||||
"SDK-GMLIB/Lib/GMLIB"
|
|
||||||
)
|
|
||||||
add_includedirs(
|
add_includedirs(
|
||||||
"SDK-GMLIB",
|
|
||||||
"src"
|
"src"
|
||||||
)
|
)
|
||||||
add_packages(
|
add_packages(
|
||||||
"levilamina",
|
"levilamina",
|
||||||
"legacyremotecall"
|
"legacyremotecall",
|
||||||
|
"gmlib"
|
||||||
)
|
)
|
||||||
add_shflags(
|
add_shflags(
|
||||||
"/DELAYLOAD:bedrock_server.dll" -- Magic to import symbols from BDS
|
"/DELAYLOAD:bedrock_server.dll" -- Magic to import symbols from BDS
|
||||||
)
|
)
|
||||||
set_exceptions("none") -- To avoid conflicts with /EHa
|
set_exceptions("none") -- To avoid conflicts with /EHa
|
||||||
set_kind("shared")
|
set_kind("shared")
|
||||||
set_languages("cxx23")
|
set_languages("c++23")
|
||||||
|
set_symbols("debug")
|
||||||
|
|
||||||
after_build(function (target)
|
after_build(function (target)
|
||||||
local plugin_packer = import("scripts.after_build")
|
local plugin_packer = import("scripts.after_build")
|
||||||
|
|||||||
Reference in New Issue
Block a user