Skip to content
This repository has been archived by the owner on Oct 30, 2022. It is now read-only.

Commit

Permalink
Match LXL_Player
Browse files Browse the repository at this point in the history
  • Loading branch information
Rjlintkh committed Feb 25, 2022
1 parent 7a0ef92 commit 969a015
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 4 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@bdsx/bdsx-lxl",
"version": "1.1.2",
"version": "1.1.3",
"description": "LiteXLoader ported into BDSX",
"main": "index.js",
"keywords": [],
Expand Down
26 changes: 24 additions & 2 deletions src/api/player.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { serverInstance } from "bdsx/bds/server";
import { bin } from "bdsx/bin";
import { bedrockServer } from "bdsx/launcher";
import { LlAPI, MCAPI } from "../dep/native";
import { playerDB } from "../utils/playerDB";
import { logger, playerDataDB, PrivateFields, Tag2Value } from "./api_help";
import { DirectionAngle$newAngle, FloatPos, FloatPos$newPos, IntPos, IntPos$newPos } from "./base";
import { Block$newBlock } from "./block";
Expand Down Expand Up @@ -66,7 +67,17 @@ export class LXL_Player {
return null;
}

return MCAPI.Player.getXuid(player);
let xuid!: string;
try {
xuid = MCAPI.Player.getXuid(player);
} catch {
logger.debug("Fail in getXuid!");
const res = playerDB.run(`SELECT XUID FROM player WHERE NAME = ?`, [LlAPI.Player.getRealName(player)]);
if (res.length) {
xuid = res[0].XUID;
}
}
return xuid;
}

get uuid() {
Expand All @@ -81,7 +92,18 @@ export class LXL_Player {
return "";
}

return player.getCertificate().getIdentityString();
let uuid!: string;
try {
uuid = player.getCertificate().getIdentityString();
} catch {
logger.debug("Fail in getXuid!");
const res = playerDB.run(`SELECT UUID FROM player WHERE NAME = ?`, [LlAPI.Player.getRealName(player)]);
if (res.length) {
uuid = res[0].UUID;
}
}

return uuid;
}

get permLevel() {
Expand Down
3 changes: 3 additions & 0 deletions src/utils/logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ export class Logger {
info(message: string) {
console.info(`\x1b[97m[${this.time()} Info][${this.prefix}] ${message}\x1b[0m`);
}
debug(message: string) {
console.info(`\x1b[3m${this.time()} Warn][${this.prefix}] ${message}\x1b[0m`);
}
warn(message: string) {
console.info(`\x1b[93m[${this.time()} Warn][${this.prefix}] ${message}\x1b[0m`);
}
Expand Down

0 comments on commit 969a015

Please sign in to comment.