@jsprismarine/prismarine
Version:
Dedicated Minecraft Bedrock Edition server written in TypeScript
131 lines • 4.5 kB
TypeScript
import { Vector3 } from '../../math/src/index.ts';
import { Gametype } from '../../minecraft/src/index.ts';
import { InetAddress } from '../../raknet/src/index.ts';
import { default as Server } from './Server';
import { default as Human } from './entity/Human';
import { default as ClientConnection } from './network/ClientConnection';
import { default as PlayerSession } from './network/PlayerSession';
import { default as MovementType } from './network/type/MovementType';
import { default as TextType } from './network/type/TextType';
import { default as Device } from './utils/Device';
import { default as Skin } from './utils/skin/Skin';
import { World } from './world/';
import { default as Chunk } from './world/chunk/Chunk';
/**
* Default spawn view distance used in vanilla
*/
export declare const VANILLA_DEFAULT_SPAWN_RADIUS = 4;
export default class Player extends Human {
private readonly address;
private readonly networkSession;
private permissions;
/**
* Timer used for various metrics.
*/
private timer;
private connected;
xuid: string;
randomId: number;
locale: string;
skin: Skin | null;
viewDistance: number;
gamemode: Gametype;
private onGround;
private flying;
private sneaking;
platformChatId: string;
device: Device | null;
readonly chunkSendQueue: Set<Chunk>;
/**
* Player's constructor.
*/
constructor({ connection, world, server, uuid }: {
connection: ClientConnection;
world: World;
server: Server;
uuid?: string;
});
/**
* On enable hook.
* @group Lifecycle
*/
enable(): Promise<void>;
/**
* On disable hook.
* @group Lifecycle
*/
disable(): Promise<void>;
private chatHandler;
/**
* Used to match vanilla behavior, will send chunks
* with an initial view radius of VANILLA_DEFAULT_SPAWN_RADIUS.
*/
sendInitialSpawnChunks(): Promise<void>;
/**
* Change the player's current world.
* @param {World} world - the new world
*/
setWorld(world: World): Promise<void>;
isOnline(): boolean;
update(tick: number): Promise<void>;
kick(reason?: string): Promise<void>;
sendSettings(): Promise<void>;
/**
* Player spawning logic.
*/
sendSpawn(): Promise<void>;
sendDespawn(): Promise<void>;
/**
* Send a chat message to the client.
* @param message - the message
*/
sendMessage(message: string, type?: TextType, parameters?: string[], needsTranslation?: boolean): Promise<void>;
setGamemode(mode?: Gametype): Promise<void>;
getNetworkSession(): PlayerSession;
getAddress(): InetAddress;
getName(): string;
getFormattedUsername(): string;
getPermissions(): string[];
/**
* Get the XUID of the player.
* @returns {string | null} XUID of the player or null if not available
*/
getXUID(): string | null;
isPlayer(): boolean;
/**
* Check if the `Player` is an operator.
* @returns `true` if this player is an operator otherwise `false`.
*/
isOp(): boolean;
setSprinting(sprinting: boolean): Promise<void>;
isFlying(): boolean;
setFlying(flying: boolean): Promise<void>;
isSneaking(): boolean;
setSneaking(val: boolean): Promise<void>;
isOnGround(): boolean;
setOnGround(val: boolean): Promise<void>;
/**
* Set the position.
* @param {object} options - The options to set the position.
* @param {Vector3} options.position - The new position.
* @param {MovementType} [options.type=MovementType.Normal] - The movement type.
* @param {number} [options.pitch=this.pitch] - The new pitch.
* @param {number} [options.yaw=this.yaw] - The new yaw.
* @param {number} [options.headYaw=this.headYaw] - The new head yaw.
* @param {boolean} [broadcast=true] - Whether to broadcast the position change.
* @remarks This will notify the player's client about the position change.
*/
setPosition({ position, type, pitch, yaw, headYaw }: {
position: Vector3;
type?: MovementType;
pitch?: number;
yaw?: number;
headYaw?: number;
}, broadcast?: boolean): Promise<void>;
/**
* Send the position to all the players in the same world.
* @returns {Promise<void>} A promise that resolves when the position is sent.
*/
sendPosition(): Promise<void>;
}
//# sourceMappingURL=Player.d.ts.map