feat: add setMaxPlayers api
This commit is contained in:
Vendored
+9
-1
@@ -359,7 +359,7 @@ export class Minecraft {
|
|||||||
): string;
|
): string;
|
||||||
|
|
||||||
/** 通过附魔ID获取附魔命名空间ID */
|
/** 通过附魔ID获取附魔命名空间ID */
|
||||||
static getMaxPlayers(
|
static getEnchantTypeNameFromId(
|
||||||
/** 附魔ID */
|
/** 附魔ID */
|
||||||
id: number
|
id: number
|
||||||
): string | null;
|
): string | null;
|
||||||
@@ -367,6 +367,14 @@ export class Minecraft {
|
|||||||
/** 获取最大玩家数 */
|
/** 获取最大玩家数 */
|
||||||
static getMaxPlayers(): number;
|
static getMaxPlayers(): number;
|
||||||
|
|
||||||
|
/** 设置最大玩家数 */
|
||||||
|
static setMaxPlayers(
|
||||||
|
/** 最大玩家数 */
|
||||||
|
count: number,
|
||||||
|
/** 是否忽略原版限制 */
|
||||||
|
ignoreVanillaLimit?: boolean
|
||||||
|
): void;
|
||||||
|
|
||||||
/** 玩家是否拥有NBT */
|
/** 玩家是否拥有NBT */
|
||||||
static hasPlayerNbt(
|
static hasPlayerNbt(
|
||||||
/** 玩家的uuid */
|
/** 玩家的uuid */
|
||||||
|
|||||||
@@ -280,6 +280,8 @@ const GMLIB_API = {
|
|||||||
getEnchantTypeNameFromId: ll.imports("GMLIB_API", "getEnchantTypeNameFromId"),
|
getEnchantTypeNameFromId: ll.imports("GMLIB_API", "getEnchantTypeNameFromId"),
|
||||||
/** 获取最大玩家数 @type {function():number} */
|
/** 获取最大玩家数 @type {function():number} */
|
||||||
getMaxPlayers: ll.imports("GMLib_ServerAPI", "getMaxPlayers"),
|
getMaxPlayers: ll.imports("GMLib_ServerAPI", "getMaxPlayers"),
|
||||||
|
/** 获取最大玩家数 @type {function(number,boolean):void} */
|
||||||
|
setMaxPlayers: ll.imports("GMLib_ServerAPI", "setMaxPlayers"),
|
||||||
/** 丢出玩家背包内物品 @type {function(Player,Item,boolean):boolean} */
|
/** 丢出玩家背包内物品 @type {function(Player,Item,boolean):boolean} */
|
||||||
dropPlayerItem: ll.imports("GMLIB_API", "dropPlayerItem"),
|
dropPlayerItem: ll.imports("GMLIB_API", "dropPlayerItem"),
|
||||||
/** 获取玩家的RuntimeId @type {function(Player):number} */
|
/** 获取玩家的RuntimeId @type {function(Player):number} */
|
||||||
@@ -1113,6 +1115,15 @@ class Minecraft {
|
|||||||
return GMLIB_API.getMaxPlayers();
|
return GMLIB_API.getMaxPlayers();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置最大玩家数量
|
||||||
|
* @param {number} count 最大玩家数量
|
||||||
|
* @param {boolean} [ignoreVanillaLimit=false] 是否忽略原版限制
|
||||||
|
*/
|
||||||
|
static setMaxPlayers(count, ignoreVanillaLimit = false) {
|
||||||
|
return GMLIB_API.setMaxPlayers(count, ignoreVanillaLimit);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 玩家是否拥有NBT
|
* 玩家是否拥有NBT
|
||||||
* @param {string} uuid 玩家的uuid
|
* @param {string} uuid 玩家的uuid
|
||||||
|
|||||||
@@ -79,4 +79,9 @@ void Export_Legacy_GMLib_ServerAPI() {
|
|||||||
[](GMLevel& level) -> int { return level.getMaxPlayerCount(); }
|
[](GMLevel& level) -> int { return level.getMaxPlayerCount(); }
|
||||||
).value_or(0);
|
).value_or(0);
|
||||||
});
|
});
|
||||||
|
RemoteCall::exportAs("GMLib_ServerAPI", "setMaxPlayers", [&](int count, bool ignoreVanillaLimit) {
|
||||||
|
if (auto level = GMLevel::getInstance(); level) {
|
||||||
|
level->setMaxPlayerCount(count, ignoreVanillaLimit);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user