1新增 2修复
- 新增getEntityOwnerUniqueId接口 - 修复注册PAPI变量无法使用匿名函数 - 修复注册相同PAPI名字无法重载
This commit is contained in:
@@ -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变量名
|
||||
|
||||
Vendored
+3
@@ -1083,6 +1083,9 @@ interface Entity {
|
||||
|
||||
/** (GMLIB)获取实体的命名 */
|
||||
getNameTag(): string;
|
||||
|
||||
/** 获取实体的主人 */
|
||||
getEntityOwner(): Entity | null;
|
||||
}
|
||||
|
||||
interface Block {
|
||||
|
||||
+15
-3
@@ -318,6 +318,8 @@ const GMLIB_API = {
|
||||
getPlayerArmorCoverPercentage: ll.import("GMLIB_API", "getPlayerArmorCoverPercentage"),
|
||||
/** 获取玩家盔甲值 @type {function(Player):number} */
|
||||
getPlayerArmorValue: ll.import("GMLIB_API", "getPlayerArmorValue"),
|
||||
/** 获取实体主人的UniqueID @type {function(Entity):Entity} */
|
||||
getEntityOwnerUniqueId: ll.import("GMLIB_API", "getEntityOwnerUniqueId")
|
||||
}
|
||||
|
||||
/** 静态悬浮字类列表 @type {Map<number,StaticFloatingText>} */
|
||||
@@ -2357,7 +2359,7 @@ LLSE_Player.prototype.getHungry =
|
||||
* @returns {number}
|
||||
*/
|
||||
function () {
|
||||
return GMLIB_API.getPlayerHungry(this)
|
||||
return GMLIB_API.getPlayerHungry(this);
|
||||
}
|
||||
|
||||
LLSE_Player.prototype.getArmorCoverPercentage =
|
||||
@@ -2366,7 +2368,7 @@ LLSE_Player.prototype.getArmorCoverPercentage =
|
||||
* @returns {number}
|
||||
*/
|
||||
function () {
|
||||
return GMLIB_API.getPlayerArmorCoverPercentage(this)
|
||||
return GMLIB_API.getPlayerArmorCoverPercentage(this);
|
||||
}
|
||||
|
||||
LLSE_Player.prototype.getArmorValue =
|
||||
@@ -2375,7 +2377,17 @@ LLSE_Player.prototype.getArmorValue =
|
||||
* @returns {number}
|
||||
*/
|
||||
function () {
|
||||
return GMLIB_API.getPlayerArmorValue(this)
|
||||
return GMLIB_API.getPlayerArmorValue(this);
|
||||
}
|
||||
|
||||
LLSE_Player.prototype.getEntityOwner =
|
||||
/**
|
||||
* 获取实体的主人
|
||||
* @returns {Entity|null}
|
||||
*/
|
||||
function () {
|
||||
const uniqueId = GMLIB_API.getEntityOwnerUniqueId(this);
|
||||
return uniqueId === -1 ? null : Minecraft.getEntityFromUniqueId(uniqueId);
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
|
||||
Reference in New Issue
Block a user