Skip to content

Commit

Permalink
refactor: rewrite experiments shit
Browse files Browse the repository at this point in the history
  • Loading branch information
KobeBryant114514 committed May 13, 2024
1 parent 531ee70 commit e08e5d9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 19 deletions.
16 changes: 3 additions & 13 deletions lib/GMLIB_API-JS.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const GMLIB_API = {
PlayerToEntity: ll.import("GMLib_ServerAPI", "PlayerToEntity"),
setUnknownBlockCleaner: ll.import("GMLib_ModAPI", "setUnknownBlockCleaner"),
getAllExperiments: ll.import("GMLIB_API", "getAllExperiments"),
getExperimentTranslatedName: ll.import("GMLIB_API", "getExperimentTranslatedName"),
getExperimentTranslateKey: ll.import("GMLIB_API", "getExperimentTranslateKey"),
getExperimentEnabled: ll.import("GMLib_ModAPI", "getExperimentEnabled"),
setExperimentEnabled: ll.import("GMLib_ModAPI", "setExperimentEnabled"),
unregisterRecipe: ll.import("GMLIB_API", "unregisterRecipe"),
Expand Down Expand Up @@ -432,18 +432,8 @@ class Experiments {
return GMLIB_API.getAllExperiments();
}

static getExperimentTranslatedName(id) {
return GMLIB_API.getExperimentTranslatedName(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 getExperimentTranslateKey(id) {
return GMLIB_API.getExperimentTranslateKey(id);
}

static getExperimentEnabled(id) {
Expand Down
12 changes: 6 additions & 6 deletions src/CompatibilityApi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,12 @@ void Export_Compatibility_API() {
}
return result;
});
RemoteCall::exportAs("GMLIB_API", "getExperimentTranslatedName", [](int id) -> std::string {
auto map = GMLIB_Level::getAllExperimentsTranslateKeys();
if (map.count(id)) {
return std::string(map[id]);
}
return "";
RemoteCall::exportAs("GMLIB_API", "getExperimentTranslateKey", [](int id) -> std::string {
std::string result;
try {
result = Experiments::getExperimentTextID(AllExperiments(id));
} catch (...) {}
return result;
});
RemoteCall::exportAs(
"GMLIB_API",
Expand Down

0 comments on commit e08e5d9

Please sign in to comment.