mirror of
https://github.com/asphyxia-core/plugins.git
synced 2026-04-26 10:16:30 -05:00
Fix GITADORA Plugin errors when launch asphyxia with devmode.
This commit is contained in:
parent
aaa4a93f57
commit
d863a522b1
|
|
@ -46,7 +46,15 @@ export async function readMDBFile(path: string, processHandler?: processRawDataH
|
||||||
break;
|
break;
|
||||||
case '.b64':
|
case '.b64':
|
||||||
const buff = await IO.ReadFile(path, 'utf-8');
|
const buff = await IO.ReadFile(path, 'utf-8');
|
||||||
const json = Buffer.from(buff, 'base64').toString('utf-8')
|
const bufferCtor = (globalThis as {
|
||||||
|
Buffer?: {
|
||||||
|
from(input: string, encoding: string): { toString(encoding: string): string }
|
||||||
|
}
|
||||||
|
}).Buffer
|
||||||
|
if (!bufferCtor) {
|
||||||
|
throw new Error('Buffer is not available in the current environment.')
|
||||||
|
}
|
||||||
|
const json = bufferCtor.from(buff, 'base64').toString('utf-8')
|
||||||
// Uncomment to save the decoded base64 file as JSON.
|
// Uncomment to save the decoded base64 file as JSON.
|
||||||
// await IO.WriteFile(path.replace(".b64",".json"), json)
|
// await IO.WriteFile(path.replace(".b64",".json"), json)
|
||||||
result = JSON.parse(json)
|
result = JSON.parse(json)
|
||||||
|
|
|
||||||
|
|
@ -60,7 +60,6 @@ export async function applySharedFavoriteMusicToExtra(refid : string, extra : Ex
|
||||||
let favoriteMusic = await loadFavoriteMusic(refid)
|
let favoriteMusic = await loadFavoriteMusic(refid)
|
||||||
|
|
||||||
if (favoriteMusic == null) {
|
if (favoriteMusic == null) {
|
||||||
logger.debugInfo(`No shared favourite music available for profile ${refid}. Using game specific favorites. Favorites will be saved as shared favorites at the end of the game session.`);
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -84,10 +83,17 @@ export async function saveFavoriteMusic(refid: string, data : FavoriteMusic) : P
|
||||||
}, data)
|
}, data)
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function loadFavoriteMusic(refid : string) : Promise<FavoriteMusic>
|
export async function loadFavoriteMusic(refid : string) : Promise<FavoriteMusic | null>
|
||||||
{
|
{
|
||||||
return await DB.FindOne<FavoriteMusic>(refid, {
|
const favoriteMusic = await DB.FindOne<FavoriteMusic>(refid, {
|
||||||
collection: 'favoritemusic'
|
collection: 'favoritemusic'
|
||||||
})
|
})
|
||||||
|
|
||||||
|
if (!favoriteMusic) {
|
||||||
|
logger.debugInfo(`No shared favourite music available for profile ${refid}. Using game specific favorites. Favorites will be saved as shared favorites at the end of the game session.`);
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
|
return favoriteMusic
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
/// <reference lib="es2020.bigint" />
|
||||||
|
|
||||||
import { getEncoreStageData } from "../data/extrastage";
|
import { getEncoreStageData } from "../data/extrastage";
|
||||||
import Logger from "../utils/logger";
|
import Logger from "../utils/logger";
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
/// <reference lib="es2020.bigint" />
|
||||||
|
|
||||||
import { getDefaultPlayerInfo, PlayerInfo } from "../models/playerinfo";
|
import { getDefaultPlayerInfo, PlayerInfo } from "../models/playerinfo";
|
||||||
import { PlayerRanking } from "../models/playerranking";
|
import { PlayerRanking } from "../models/playerranking";
|
||||||
import { getDefaultProfile, Profile } from "../models/profile";
|
import { getDefaultProfile, Profile } from "../models/profile";
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,14 @@ export const isDM = (info: EamuseInfo) => {
|
||||||
|
|
||||||
export const getVersion = (info: EamuseInfo) => {
|
export const getVersion = (info: EamuseInfo) => {
|
||||||
const moduleName: string = info.module;
|
const moduleName: string = info.module;
|
||||||
return moduleName.match(/([^_]*)_(.*)/)[1];
|
const moduleMatch = moduleName.match(/([^_]*)_(.*)/);
|
||||||
|
|
||||||
|
if (moduleMatch && moduleMatch[1]) {
|
||||||
|
return moduleMatch[1];
|
||||||
|
}
|
||||||
|
|
||||||
|
console.error(`Unable to parse version from module name "${moduleName}".`);
|
||||||
|
return "unknown";
|
||||||
};
|
};
|
||||||
|
|
||||||
export function isRequiredCoreVersion(major: number, minor: number) {
|
export function isRequiredCoreVersion(major: number, minor: number) {
|
||||||
|
|
@ -19,8 +26,8 @@ export function isRequiredCoreVersion(major: number, minor: number) {
|
||||||
};
|
};
|
||||||
|
|
||||||
export function isAsphyxiaDebugMode() : boolean {
|
export function isAsphyxiaDebugMode() : boolean {
|
||||||
const argv = process.argv
|
const argv = (globalThis as { process?: { argv?: string[] } }).process?.argv ?? [];
|
||||||
return argv.includes("--dev") || argv.includes("--console")
|
return argv.includes("--dev") || argv.includes("--console");
|
||||||
}
|
}
|
||||||
|
|
||||||
export function isSharedFavoriteMusicEnabled() : boolean{
|
export function isSharedFavoriteMusicEnabled() : boolean{
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user