forked from WorldEditAxe/eaglerproxy
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathtypes.ts
159 lines (141 loc) · 3.13 KB
/
types.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
import { randomUUID } from "crypto"
import { Client } from "minecraft-protocol"
import { WebSocketServer, WebSocket } from "ws"
import { BRANDING, VERSION, NETWORK_VERSION } from "./config.js"
import { EaglerSkinPacketId, SkinId } from "./eaglerPacketDef.js"
import { Logger } from "./logger.js"
export type UUID = ReturnType<typeof randomUUID>
export enum State {
PRE_HANDSHAKE,
POST_HANDSHAKE,
DISCONNECTED
}
export type MOTD = {
icon?: Buffer, // 16384
motd: [string, string]
}
export type PlayerStats = {
max: number,
onlineCount: number
}
export type ProxyGlobals = {
brand: typeof BRANDING,
version: typeof VERSION,
MOTDVersion: typeof NETWORK_VERSION,
serverName: string,
secure: false,
proxyUUID: UUID,
MOTD: MOTD,
wsServer: WebSocketServer,
players: Map<string, ProxiedPlayer>,
logger: Logger,
config: Config
}
export type Config = {
name: string,
bindPort: number,
bindHost: string,
maxPlayers: number,
motd: {
iconURL?: string,
l1: string,
l2: string
},
server: {
host: string,
port: number
},
security: {
enabled: boolean
key: string,
cert: string
}
}
export enum ChatColor {
BLACK = "§0",
DARK_BLUE = "§1",
DARK_GREEN = "§2",
DARK_CYAN = "§3",
DARK_RED = "§4",
PURPLE = "§5",
GOLD = "§6",
GRAY = "§7",
DARK_GRAY = "§8",
BLUE = "§9",
BRIGHT_GREEN = "§a",
CYAN = "§b",
RED = "§c",
PINK = "§d",
YELLOW = "§e",
WHITE = "§f",
// text styling
OBFUSCATED = '§k',
BOLD = '§l',
STRIKETHROUGH = '§m',
UNDERLINED = '§n',
ITALIC = '§o',
RESET = '§r'
}
export type ChatExtra = {
text: string,
bold?: boolean,
italic?: boolean,
underlined?: boolean,
strikethrough?: boolean,
obfuscated?: boolean,
color?: ChatColor | 'reset'
}
export type Chat = {
text?: string,
bold?: boolean,
italic?: boolean,
underlined?: boolean,
strikethrough?: boolean,
obfuscated?: boolean,
color?: ChatColor | 'reset',
extra?: ChatExtra[]
}
export class ProxiedPlayer {
public username: string
public uuid: string
public clientBrand: string
public state: State
public ws: WebSocket
public ip: string
public remotePort: number
public remoteConnection: Client
public skin: {
type: "CUSTOM" | "BUILTIN",
skinId?: number,
customSkin?: Buffer
}
public queuedEaglerSkinPackets: UnpackedChannelMessage[]
}
export enum ChannelMessageType {
CLIENT = 0x17,
SERVER = 0x3f
}
export type UnpackedChannelMessage = {
channel: string,
data: Buffer,
type: ChannelMessageType
}
export type DecodedCFetchSkin = {
id: EaglerSkinPacketId.C_FETCH_SKIN,
uuid: UUID
}
export type DecodedSSkinFetchBuiltin = {
id: EaglerSkinPacketId.S_SKIN_DL_BI,
uuid: UUID,
skinId: SkinId
}
export type DecodedSSkinDl = {
id: EaglerSkinPacketId.S_SKIN_DL,
uuid: UUID,
skin: Buffer
}
export type DecodedCSkinReq = {
id: EaglerSkinPacketId.C_REQ_SKIN,
uuid: UUID,
url: string
}