1新增 2修复

- 新增getEntityOwnerUniqueId接口
- 修复注册PAPI变量无法使用匿名函数
- 修复注册相同PAPI名字无法重载
This commit is contained in:
子沐呀
2024-07-18 21:39:49 +08:00
Unverified
parent a47f8c729d
commit 52897a25a7
5 changed files with 47 additions and 12 deletions
+20 -9
View File
@@ -19,14 +19,25 @@ const PlaceholderAPI = {
getAllPAPI: ll.import("BEPlaceholderAPI", "getAllPAPI")
}
Function.prototype.getName =
/**
* 获取函数名字
* @returns {string}
*/
function () {
return this.name || this.toString().match(/function\s*([^(]*)\(/)[1] || Math.ceil(Math.random() * 1000000).toString(16);
}
Function.prototype.getName =
/**
* 获取函数名字
* @returns {string}
*/
function () {
return this.name || this.toString().match(/function\s*([^(]*)\(/)?.[1] || this.toString().hashCode().toString(16);
}
String.prototype.hashCode = function () {
var hash = 0, i, chr;
if (this.length === 0) return hash;
for (i = 0; i < this.length; i++) {
chr = this.charCodeAt(i);
hash = ((hash << 5) - hash) + chr;
hash |= 0;
}
return hash;
};
/** PAPI变量类 */
class PAPI {
@@ -79,7 +90,7 @@ class PAPI {
static getValue(key) {
return PlaceholderAPI.getValueAPI(key);
}
/**
* 获取一个玩家变量的值
* @param {string} key PAPI变量名