From 5df72de18ce4a6df2a0e63aeaf91a93f647951ac Mon Sep 17 00:00:00 2001 From: ShrBox Date: Sun, 16 Jun 2024 22:06:21 +0800 Subject: [PATCH] feat: adapt to LeviLamina 1.0.x --- manifest.json | 2 +- src/legacy/api/EventAPI.cpp | 6 ++---- src/legacy/api/ItemAPI.cpp | 2 +- src/legacy/api/PlayerAPI.cpp | 15 ++++++++------- src/legacy/api/ScoreboardAPI.cpp | 6 ++++-- src/legacy/api/SimulatedPlayerAPI.cpp | 6 +++--- tooth.json | 6 +++--- tooth.lua.json | 10 +++++----- tooth.nodejs.json | 10 +++++----- tooth.python.json | 10 +++++----- tooth.quickjs.json | 10 +++++----- xmake.lua | 8 ++++---- 12 files changed, 46 insertions(+), 45 deletions(-) diff --git a/manifest.json b/manifest.json index 43775e9..b78dc8a 100644 --- a/manifest.json +++ b/manifest.json @@ -4,7 +4,7 @@ "type": "native", "description": "A plugin engine for running LLSE plugins on LeviLamina", "author": "LiteLDev", - "version": "0.7.12", + "version": "0.8.0", "dependencies": [ { "name": "LegacyMoney" diff --git a/src/legacy/api/EventAPI.cpp b/src/legacy/api/EventAPI.cpp index 53674c4..b803159 100644 --- a/src/legacy/api/EventAPI.cpp +++ b/src/legacy/api/EventAPI.cpp @@ -38,7 +38,6 @@ #include "ll/api/event/player/PlayerSprintEvent.h" #include "ll/api/event/player/PlayerSwingEvent.h" #include "ll/api/event/player/PlayerUseItemEvent.h" -#include "ll/api/event/player/PlayerUseItemOnEvent.h" #include "ll/api/event/server/ServerStartedEvent.h" #include "ll/api/event/world/BlockChangedEvent.h" #include "ll/api/event/world/FireSpreadEvent.h" @@ -349,7 +348,7 @@ void EnableEventListener(int eventId) { break; case EVENT_TYPES::onUseItemOn: - bus.emplaceListener([](PlayerUseItemOnEvent& ev) { + bus.emplaceListener([](PlayerInteractBlockEvent& ev) { IF_LISTENED(EVENT_TYPES::onUseItemOn) { CallEvent( EVENT_TYPES::onUseItemOn, @@ -615,13 +614,12 @@ void EnableEventListener(int eventId) { break; case EVENT_TYPES::onBlockInteracted: - bus.emplaceListener([](PlayerInteractBlockEvent& ev) { IF_LISTENED(EVENT_TYPES::onBlockInteracted) { CallEvent( EVENT_TYPES::onBlockInteracted, PlayerClass::newPlayer(&ev.self()), - BlockClass::newBlock(ev.pos(), ev.self().getDimensionId()) + BlockClass::newBlock(ev.blockPos(), ev.self().getDimensionId()) ); } IF_LISTENED_END(EVENT_TYPES::onBlockInteracted); diff --git a/src/legacy/api/ItemAPI.cpp b/src/legacy/api/ItemAPI.cpp index aca0140..3d6a93e 100644 --- a/src/legacy/api/ItemAPI.cpp +++ b/src/legacy/api/ItemAPI.cpp @@ -293,7 +293,7 @@ Local ItemClass::isStackable() { Local ItemClass::isWearableItem() { try { - return Boolean::newBoolean(get()->isWearableItem()); + return Boolean::newBoolean(get()->isHumanoidWearableItem()); } CATCH("Fail in isWearableItem!"); } diff --git a/src/legacy/api/PlayerAPI.cpp b/src/legacy/api/PlayerAPI.cpp index 05912f3..40030a8 100644 --- a/src/legacy/api/PlayerAPI.cpp +++ b/src/legacy/api/PlayerAPI.cpp @@ -565,8 +565,8 @@ Local McClass::deletePlayerScore(const Arguments& args) { if (!id.isValid()) { return Boolean::newBoolean(true); } - return Boolean::newBoolean(scoreboard.getScoreboardIdentityRef(id)->removeFromObjective(scoreboard, *objective) - ); + objective->_resetPlayer(id); + return Boolean::newBoolean(true); } CATCH("Fail in deletePlayerScore!") } @@ -1553,7 +1553,7 @@ Local PlayerClass::talkAs(const Arguments& args) { if (!player) return Local(); TextPacket pkt = - TextPacket::createChat(player->getName(), args[0].asString().toString(), player->getXuid(), ""); + TextPacket::createChat(player->getName(), args[0].asString().toString(), player->getXuid(), "", ""); if (ll::service::getLevel().has_value()) { IF_LISTENED(EVENT_TYPES::onChat) { CallEventRtnValue( @@ -1587,7 +1587,7 @@ Local PlayerClass::talkTo(const Arguments& args) { if (!player) return Local(); TextPacket pkt = - TextPacket::createChat(player->getRealName(), args[0].asString().toString(), player->getXuid(), ""); + TextPacket::createChat(player->getRealName(), args[0].asString().toString(), player->getXuid(), "", ""); target->sendNetworkPacket(pkt); return Boolean::newBoolean(true); } @@ -2084,7 +2084,8 @@ Local PlayerClass::deleteScore(const Arguments& args) { if (!id.isValid()) { return Boolean::newBoolean(true); } - return Boolean::newBoolean(scoreboard.getScoreboardIdentityRef(id)->removeFromObjective(scoreboard, *obj)); + obj->_resetPlayer(id); + return Boolean::newBoolean(true); } CATCH("Fail in deleteScore!"); } @@ -3470,7 +3471,7 @@ Local PlayerClass::getBiomeId() { try { Player* player = get(); if (!player) return Local(); - Biome& bio = player->getDimensionBlockSource().getBiome(player->getFeetBlockPos()); + Biome const& bio = player->getDimensionBlockSource().getBiome(player->getFeetBlockPos()); return Number::newNumber(ll::memory::dAccess(&bio, 0x80)); } CATCH("Fail in getBiomeId!"); @@ -3480,7 +3481,7 @@ Local PlayerClass::getBiomeName() { try { Player* player = get(); if (!player) return Local(); - Biome& bio = player->getDimensionBlockSource().getBiome(player->getFeetBlockPos()); + Biome const& bio = player->getDimensionBlockSource().getBiome(player->getFeetBlockPos()); return String::newString(ll::memory::dAccess(&bio, 0x08).getString()); } CATCH("Fail in getBiomeName!"); diff --git a/src/legacy/api/ScoreboardAPI.cpp b/src/legacy/api/ScoreboardAPI.cpp index fcc884e..9b7fa46 100644 --- a/src/legacy/api/ScoreboardAPI.cpp +++ b/src/legacy/api/ScoreboardAPI.cpp @@ -241,7 +241,8 @@ Local ObjectiveClass::deleteScore(const Arguments& args) { if (!id.isValid()) { return Boolean::newBoolean(true); } - return Boolean::newBoolean(scoreboard.getScoreboardIdentityRef(id)->removeFromObjective(scoreboard, *obj)); + obj->_resetPlayer(id); + return Boolean::newBoolean(true); } else if (IsInstanceOf(args[0])) { Player* player = PlayerClass::extract(args[0]); Scoreboard& scoreboard = ll::service::getLevel()->getScoreboard(); @@ -253,7 +254,8 @@ Local ObjectiveClass::deleteScore(const Arguments& args) { if (!id.isValid()) { return Boolean::newBoolean(true); } - return Boolean::newBoolean(scoreboard.getScoreboardIdentityRef(id)->removeFromObjective(scoreboard, *obj)); + obj->_resetPlayer(id); + return Boolean::newBoolean(true); } else { LOG_WRONG_ARG_TYPE(); return Local(); diff --git a/src/legacy/api/SimulatedPlayerAPI.cpp b/src/legacy/api/SimulatedPlayerAPI.cpp index d43c94a..5b4dbb1 100644 --- a/src/legacy/api/SimulatedPlayerAPI.cpp +++ b/src/legacy/api/SimulatedPlayerAPI.cpp @@ -392,7 +392,7 @@ Local PlayerClass::simulateLookAt(const Arguments& args) { auto pos = IntPos::extractPos(args[0]); auto did = pos->getDimensionId(); if (dimid == did || did < 0 || did > 2) { - sp->simulateLookAt(pos->getBlockPos()); + sp->simulateLookAt(pos->getBlockPos(), (sim::LookDuration)0); return Boolean::newBoolean(true); } lse::getSelfPluginInstance().getLogger().debug("Can't simulate look at other dimension!"); @@ -401,7 +401,7 @@ Local PlayerClass::simulateLookAt(const Arguments& args) { auto pos = FloatPos::extractPos(args[0]); auto did = pos->getDimensionId(); if (dimid == did || did < 0 || did > 2) { - sp->simulateLookAt(pos->getVec3()); + sp->simulateLookAt(pos->getVec3(), (sim::LookDuration)0); return Boolean::newBoolean(true); } lse::getSelfPluginInstance().getLogger().debug("Can't simulate look at other dimension!"); @@ -411,7 +411,7 @@ Local PlayerClass::simulateLookAt(const Arguments& args) { auto pos = IntPos::extractPos(block->getPos()); auto did = pos->getDimensionId(); if (dimid == did || did < 0 || did > 2) { - sp->simulateLookAt(pos->getBlockPos()); + sp->simulateLookAt(pos->getBlockPos(), (sim::LookDuration)0); return Boolean::newBoolean(true); } lse::getSelfPluginInstance().getLogger().debug("Can't simulate look at other dimension!"); diff --git a/tooth.json b/tooth.json index 8c0edd4..39aba82 100644 --- a/tooth.json +++ b/tooth.json @@ -1,7 +1,7 @@ { "format_version": 2, "tooth": "github.com/LiteLDev/LegacyScriptEngine", - "version": "0.7.12", + "version": "0.8.0", "info": { "name": "LegacyScriptEngine", "description": "A plugin engine for running LLSE plugins on LeviLamina", @@ -12,7 +12,7 @@ ] }, "dependencies": { - "gitea.litebds.com/LiteLDev/legacy-script-engine-lua": "0.7.12", - "gitea.litebds.com/LiteLDev/legacy-script-engine-quickjs": "0.7.12" + "gitea.litebds.com/LiteLDev/legacy-script-engine-lua": "0.8.0", + "gitea.litebds.com/LiteLDev/legacy-script-engine-quickjs": "0.8.0" } } diff --git a/tooth.lua.json b/tooth.lua.json index 89f0c40..dbe07e3 100644 --- a/tooth.lua.json +++ b/tooth.lua.json @@ -1,7 +1,7 @@ { "format_version": 2, "tooth": "gitea.litebds.com/LiteLDev/legacy-script-engine-lua", - "version": "0.7.12", + "version": "0.8.0", "info": { "name": "LegacyScriptEngine with Lua backend", "description": "A plugin engine for running LLSE plugins on LeviLamina", @@ -12,12 +12,12 @@ ] }, "dependencies": { - "github.com/LiteLDev/LegacyRemoteCall": "0.7.x", - "github.com/LiteLDev/LegacyParticleAPI": "0.7.x", - "github.com/LiteLDev/LegacyMoney": "0.7.x" + "github.com/LiteLDev/LegacyRemoteCall": "0.8.x", + "github.com/LiteLDev/LegacyParticleAPI": "0.8.x", + "github.com/LiteLDev/LegacyMoney": "0.8.x" }, "prerequisites": { - "github.com/LiteLDev/LeviLamina": "0.12.x" + "github.com/LiteLDev/LeviLamina": "1.0.x" }, "files": { "place": [ diff --git a/tooth.nodejs.json b/tooth.nodejs.json index 12956d9..8fab029 100644 --- a/tooth.nodejs.json +++ b/tooth.nodejs.json @@ -1,7 +1,7 @@ { "format_version": 2, "tooth": "gitea.litebds.com/LiteLDev/legacy-script-engine-nodejs", - "version": "0.7.12", + "version": "0.8.0", "info": { "name": "LegacyScriptEngine with NodeJs backend", "description": "A plugin engine for running LLSE plugins on LeviLamina", @@ -12,14 +12,14 @@ ] }, "dependencies": { - "github.com/LiteLDev/LegacyRemoteCall": "0.7.x", - "github.com/LiteLDev/LegacyParticleAPI": "0.7.x", - "github.com/LiteLDev/LegacyMoney": "0.7.x", + "github.com/LiteLDev/LegacyRemoteCall": "0.8.x", + "github.com/LiteLDev/LegacyParticleAPI": "0.8.x", + "github.com/LiteLDev/LegacyMoney": "0.8.x", "gitea.litebds.com/ShrBox/7-zip": "23.x", "gitea.litebds.com/LiteLDev/node-binaries": "16.16.0" }, "prerequisites": { - "github.com/LiteLDev/LeviLamina": "0.12.x" + "github.com/LiteLDev/LeviLamina": "1.0.x" }, "files": { "place": [ diff --git a/tooth.python.json b/tooth.python.json index b0e1108..86cc1e5 100644 --- a/tooth.python.json +++ b/tooth.python.json @@ -1,7 +1,7 @@ { "format_version": 2, "tooth": "gitea.litebds.com/LiteLDev/legacy-script-engine-python", - "version": "0.7.12", + "version": "0.8.0", "info": { "name": "LegacyScriptEngine with Python backend", "description": "A plugin engine for running LLSE plugins on LeviLamina", @@ -12,13 +12,13 @@ ] }, "dependencies": { - "github.com/LiteLDev/LegacyRemoteCall": "0.7.x", - "github.com/LiteLDev/LegacyParticleAPI": "0.7.x", - "github.com/LiteLDev/LegacyMoney": "0.7.x", + "github.com/LiteLDev/LegacyRemoteCall": "0.8.x", + "github.com/LiteLDev/LegacyParticleAPI": "0.8.x", + "github.com/LiteLDev/LegacyMoney": "0.8.x", "gitea.litebds.com/LiteLDev/python-binaries": "3.10.11" }, "prerequisites": { - "github.com/LiteLDev/LeviLamina": "0.12.x" + "github.com/LiteLDev/LeviLamina": "1.0.x" }, "files": { "place": [ diff --git a/tooth.quickjs.json b/tooth.quickjs.json index 7b2eb3f..e0b25ee 100644 --- a/tooth.quickjs.json +++ b/tooth.quickjs.json @@ -1,7 +1,7 @@ { "format_version": 2, "tooth": "gitea.litebds.com/LiteLDev/legacy-script-engine-quickjs", - "version": "0.7.12", + "version": "0.8.0", "info": { "name": "LegacyScriptEngine with QuickJs backend", "description": "A plugin engine for running LLSE plugins on LeviLamina", @@ -12,12 +12,12 @@ ] }, "dependencies": { - "github.com/LiteLDev/LegacyRemoteCall": "0.7.x", - "github.com/LiteLDev/LegacyParticleAPI": "0.7.x", - "github.com/LiteLDev/LegacyMoney": "0.7.x" + "github.com/LiteLDev/LegacyRemoteCall": "0.8.x", + "github.com/LiteLDev/LegacyParticleAPI": "0.8.x", + "github.com/LiteLDev/LegacyMoney": "0.8.x" }, "prerequisites": { - "github.com/LiteLDev/LeviLamina": "0.12.x" + "github.com/LiteLDev/LeviLamina": "1.0.x" }, "files": { "place": [ diff --git a/xmake.lua b/xmake.lua index d504506..33af6d7 100644 --- a/xmake.lua +++ b/xmake.lua @@ -6,10 +6,10 @@ add_requires( "demangler", "dyncall", "fmt", - "legacymoney 0.7.0", - "legacyparticleapi 0.7.0", - "legacyremotecall 0.7.0", - "levilamina 0.12.3", + "legacymoney 0.8.0", + "legacyparticleapi 0.8.0", + "legacyremotecall 0.8.0", + "levilamina develop", "lightwebsocketclient", "magic_enum", "nlohmann_json",