@hylithiumjs.com/core 1.1.3 → 1.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +3 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -0
- package/dist/types.d.ts +329 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +3 -0
- package/package.json +40 -40
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
export * from "./types";
|
|
2
|
-
import type { EventHandler, EventType, EventTitleUtil as EventTitleUtilType } from "./types";
|
|
2
|
+
import type { EventHandler, EventType, EventTitleUtil as EventTitleUtilType, MySQLManager as MySQLManagerType, TableBuilderConstructor } from "./types";
|
|
3
3
|
export declare const EventTitleUtil: EventTitleUtilType;
|
|
4
|
+
export declare const MySQL: MySQLManagerType;
|
|
5
|
+
export declare const TableBuilder: TableBuilderConstructor;
|
|
4
6
|
export declare const handlers: EventHandler[];
|
|
5
7
|
export declare function EventListener(eventType: EventType): (target: unknown, propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor;
|
|
6
8
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,OAAO,KAAK,EACV,YAAY,EACZ,SAAS,EACT,cAAc,IAAI,kBAAkB,EACpC,YAAY,IAAI,gBAAgB,EAChC,uBAAuB,EACxB,MAAM,SAAS,CAAC;AAGjB,eAAO,MAAM,cAAc,EAAyC,kBAAkB,CAAC;AAGvF,eAAO,MAAM,KAAK,EAAuC,gBAAgB,CAAC;AAC1E,eAAO,MAAM,YAAY,EAAuC,uBAAuB,CAAC;AAExF,eAAO,MAAM,QAAQ,EAAE,YAAY,EAAwE,CAAC;AAE5G,wBAAgB,aAAa,CAAC,SAAS,EAAE,SAAS,IAC/B,QAAQ,OAAO,EAAE,aAAa,MAAM,EAAE,YAAY,kBAAkB,wBAOtF"}
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
export * from "./types";
|
|
2
2
|
// Exportar EventTitleUtil como valor (injetado pelo Java runtime)
|
|
3
3
|
export const EventTitleUtil = globalThis.EventTitleUtil;
|
|
4
|
+
// MySQL exports (injetado pelo Java runtime)
|
|
5
|
+
export const MySQL = globalThis.MySQLManager;
|
|
6
|
+
export const TableBuilder = globalThis.TableBuilder;
|
|
4
7
|
// Usar array global existente ou criar novo (evita sobrescrever handlers de outros plugins)
|
|
5
8
|
export const handlers = globalThis.handlers || (globalThis.handlers = []);
|
|
6
9
|
export function EventListener(eventType) {
|
package/dist/types.d.ts
CHANGED
|
@@ -1,3 +1,301 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Represents a row returned from a MySQL query.
|
|
3
|
+
* Keys are column names, values are the column data.
|
|
4
|
+
*/
|
|
5
|
+
export interface MySQLRow {
|
|
6
|
+
[key: string]: string | number | boolean | null | Date;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Column information returned from getColumns().
|
|
10
|
+
*/
|
|
11
|
+
export interface MySQLColumnInfo {
|
|
12
|
+
name: string;
|
|
13
|
+
type: string;
|
|
14
|
+
size: number;
|
|
15
|
+
nullable: boolean;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* MySQL Manager for database connections and operations.
|
|
19
|
+
* Uses HikariCP connection pooling for efficient connection management.
|
|
20
|
+
*/
|
|
21
|
+
export interface MySQLManager {
|
|
22
|
+
/**
|
|
23
|
+
* Gets the singleton instance of MySQLManager.
|
|
24
|
+
*/
|
|
25
|
+
getInstance(): MySQLManager;
|
|
26
|
+
/**
|
|
27
|
+
* Connects to a MySQL database.
|
|
28
|
+
* @param host Database host
|
|
29
|
+
* @param port Database port (typically 3306)
|
|
30
|
+
* @param database Database name
|
|
31
|
+
* @param user Username
|
|
32
|
+
* @param password Password
|
|
33
|
+
* @returns true if connection successful
|
|
34
|
+
*/
|
|
35
|
+
connect(host: string, port: number, database: string, user: string, password: string): boolean;
|
|
36
|
+
/**
|
|
37
|
+
* Disconnects from the database and closes the connection pool.
|
|
38
|
+
*/
|
|
39
|
+
disconnect(): void;
|
|
40
|
+
/**
|
|
41
|
+
* Checks if currently connected to the database.
|
|
42
|
+
*/
|
|
43
|
+
isConnected(): boolean;
|
|
44
|
+
/**
|
|
45
|
+
* Executes an UPDATE, INSERT, or DELETE statement.
|
|
46
|
+
* @param sql SQL statement
|
|
47
|
+
* @returns Number of affected rows, or -1 on error
|
|
48
|
+
*/
|
|
49
|
+
executeUpdate(sql: string): number;
|
|
50
|
+
/**
|
|
51
|
+
* Executes a SELECT query and returns results.
|
|
52
|
+
* @param sql SQL query
|
|
53
|
+
* @returns Array of row objects
|
|
54
|
+
*/
|
|
55
|
+
executeQuery(sql: string): MySQLRow[];
|
|
56
|
+
/**
|
|
57
|
+
* Creates a prepared statement builder.
|
|
58
|
+
* @param sql SQL with ? placeholders
|
|
59
|
+
* @returns PreparedStatementBuilder instance
|
|
60
|
+
*/
|
|
61
|
+
prepareStatement(sql: string): PreparedStatementBuilder;
|
|
62
|
+
/**
|
|
63
|
+
* Creates a table using a TableBuilder.
|
|
64
|
+
* @param builder TableBuilder instance
|
|
65
|
+
* @returns true if table created successfully
|
|
66
|
+
*/
|
|
67
|
+
createTable(builder: TableBuilder): boolean;
|
|
68
|
+
/**
|
|
69
|
+
* Drops a table.
|
|
70
|
+
* @param tableName Table name
|
|
71
|
+
* @returns true if table dropped successfully
|
|
72
|
+
*/
|
|
73
|
+
dropTable(tableName: string): boolean;
|
|
74
|
+
/**
|
|
75
|
+
* Checks if a table exists.
|
|
76
|
+
* @param tableName Table name
|
|
77
|
+
* @returns true if table exists
|
|
78
|
+
*/
|
|
79
|
+
tableExists(tableName: string): boolean;
|
|
80
|
+
/**
|
|
81
|
+
* Truncates a table (removes all data).
|
|
82
|
+
* @param tableName Table name
|
|
83
|
+
* @returns true if successful
|
|
84
|
+
*/
|
|
85
|
+
truncateTable(tableName: string): boolean;
|
|
86
|
+
/**
|
|
87
|
+
* Gets all table names in the current database.
|
|
88
|
+
* @returns Array of table names
|
|
89
|
+
*/
|
|
90
|
+
getTables(): string[];
|
|
91
|
+
/**
|
|
92
|
+
* Gets column info for a table.
|
|
93
|
+
* @param tableName Table name
|
|
94
|
+
* @returns Array of column info objects
|
|
95
|
+
*/
|
|
96
|
+
getColumns(tableName: string): MySQLColumnInfo[];
|
|
97
|
+
/**
|
|
98
|
+
* Begins a transaction.
|
|
99
|
+
* @returns Transaction instance
|
|
100
|
+
*/
|
|
101
|
+
beginTransaction(): MySQLTransaction;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Transaction wrapper for atomic database operations.
|
|
105
|
+
*/
|
|
106
|
+
export interface MySQLTransaction {
|
|
107
|
+
/**
|
|
108
|
+
* Executes an UPDATE within the transaction.
|
|
109
|
+
*/
|
|
110
|
+
executeUpdate(sql: string): number;
|
|
111
|
+
/**
|
|
112
|
+
* Creates a prepared statement within the transaction.
|
|
113
|
+
*/
|
|
114
|
+
prepareStatement(sql: string): PreparedStatementBuilder;
|
|
115
|
+
/**
|
|
116
|
+
* Commits the transaction.
|
|
117
|
+
*/
|
|
118
|
+
commit(): boolean;
|
|
119
|
+
/**
|
|
120
|
+
* Rolls back the transaction.
|
|
121
|
+
*/
|
|
122
|
+
rollback(): boolean;
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Prepared Statement Builder for safe parameterized SQL queries.
|
|
126
|
+
* Prevents SQL injection by using parameterized queries.
|
|
127
|
+
*/
|
|
128
|
+
export interface PreparedStatementBuilder {
|
|
129
|
+
/**
|
|
130
|
+
* Sets a string parameter.
|
|
131
|
+
* @param index Parameter index (1-based)
|
|
132
|
+
* @param value String value
|
|
133
|
+
*/
|
|
134
|
+
setString(index: number, value: string): PreparedStatementBuilder;
|
|
135
|
+
/**
|
|
136
|
+
* Sets an integer parameter.
|
|
137
|
+
* @param index Parameter index (1-based)
|
|
138
|
+
* @param value Integer value
|
|
139
|
+
*/
|
|
140
|
+
setInt(index: number, value: number): PreparedStatementBuilder;
|
|
141
|
+
/**
|
|
142
|
+
* Sets a long parameter.
|
|
143
|
+
* @param index Parameter index (1-based)
|
|
144
|
+
* @param value Long value
|
|
145
|
+
*/
|
|
146
|
+
setLong(index: number, value: number): PreparedStatementBuilder;
|
|
147
|
+
/**
|
|
148
|
+
* Sets a double parameter.
|
|
149
|
+
* @param index Parameter index (1-based)
|
|
150
|
+
* @param value Double value
|
|
151
|
+
*/
|
|
152
|
+
setDouble(index: number, value: number): PreparedStatementBuilder;
|
|
153
|
+
/**
|
|
154
|
+
* Sets a float parameter.
|
|
155
|
+
* @param index Parameter index (1-based)
|
|
156
|
+
* @param value Float value
|
|
157
|
+
*/
|
|
158
|
+
setFloat(index: number, value: number): PreparedStatementBuilder;
|
|
159
|
+
/**
|
|
160
|
+
* Sets a boolean parameter.
|
|
161
|
+
* @param index Parameter index (1-based)
|
|
162
|
+
* @param value Boolean value
|
|
163
|
+
*/
|
|
164
|
+
setBoolean(index: number, value: boolean): PreparedStatementBuilder;
|
|
165
|
+
/**
|
|
166
|
+
* Sets a null parameter.
|
|
167
|
+
* @param index Parameter index (1-based)
|
|
168
|
+
*/
|
|
169
|
+
setNull(index: number): PreparedStatementBuilder;
|
|
170
|
+
/**
|
|
171
|
+
* Sets a timestamp parameter.
|
|
172
|
+
* @param index Parameter index (1-based)
|
|
173
|
+
* @param timestamp Unix timestamp in milliseconds
|
|
174
|
+
*/
|
|
175
|
+
setTimestamp(index: number, timestamp: number): PreparedStatementBuilder;
|
|
176
|
+
/**
|
|
177
|
+
* Executes an UPDATE, INSERT, or DELETE statement.
|
|
178
|
+
* @returns Number of affected rows, or -1 on error
|
|
179
|
+
*/
|
|
180
|
+
executeUpdate(): number;
|
|
181
|
+
/**
|
|
182
|
+
* Executes an INSERT and returns the generated key.
|
|
183
|
+
* @returns Generated key, or -1 on error
|
|
184
|
+
*/
|
|
185
|
+
executeInsert(): number;
|
|
186
|
+
/**
|
|
187
|
+
* Executes a SELECT query and returns results.
|
|
188
|
+
* @returns Array of row objects
|
|
189
|
+
*/
|
|
190
|
+
executeQuery(): MySQLRow[];
|
|
191
|
+
/**
|
|
192
|
+
* Executes a SELECT query and returns the first result.
|
|
193
|
+
* @returns First row object, or null if no results
|
|
194
|
+
*/
|
|
195
|
+
executeQuerySingle(): MySQLRow | null;
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* Fluent builder for creating MySQL CREATE TABLE statements.
|
|
199
|
+
*/
|
|
200
|
+
export interface TableBuilder {
|
|
201
|
+
/**
|
|
202
|
+
* Adds a column with type only.
|
|
203
|
+
* @param name Column name
|
|
204
|
+
* @param type Column type (e.g., "INT", "VARCHAR")
|
|
205
|
+
*/
|
|
206
|
+
addColumn(name: string, type: string): TableBuilder;
|
|
207
|
+
/**
|
|
208
|
+
* Adds a column with type and size.
|
|
209
|
+
* @param name Column name
|
|
210
|
+
* @param type Column type
|
|
211
|
+
* @param size Column size
|
|
212
|
+
*/
|
|
213
|
+
addColumn(name: string, type: string, size: number): TableBuilder;
|
|
214
|
+
/**
|
|
215
|
+
* Adds a column with type, size, and default value.
|
|
216
|
+
*/
|
|
217
|
+
addColumn(name: string, type: string, size: number, defaultValue: string): TableBuilder;
|
|
218
|
+
/** Adds VARCHAR column */
|
|
219
|
+
addVarchar(name: string, size: number): TableBuilder;
|
|
220
|
+
/** Adds INT column */
|
|
221
|
+
addInt(name: string): TableBuilder;
|
|
222
|
+
/** Adds BIGINT column */
|
|
223
|
+
addBigInt(name: string): TableBuilder;
|
|
224
|
+
/** Adds TEXT column */
|
|
225
|
+
addText(name: string): TableBuilder;
|
|
226
|
+
/** Adds BOOLEAN column */
|
|
227
|
+
addBoolean(name: string): TableBuilder;
|
|
228
|
+
/** Adds DATETIME column */
|
|
229
|
+
addDatetime(name: string): TableBuilder;
|
|
230
|
+
/** Adds TIMESTAMP column */
|
|
231
|
+
addTimestamp(name: string): TableBuilder;
|
|
232
|
+
/** Adds DOUBLE column */
|
|
233
|
+
addDouble(name: string): TableBuilder;
|
|
234
|
+
/** Adds FLOAT column */
|
|
235
|
+
addFloat(name: string): TableBuilder;
|
|
236
|
+
/** Adds BLOB column */
|
|
237
|
+
addBlob(name: string): TableBuilder;
|
|
238
|
+
/** Adds JSON column */
|
|
239
|
+
addJson(name: string): TableBuilder;
|
|
240
|
+
/**
|
|
241
|
+
* Sets a column as primary key.
|
|
242
|
+
* @param column Column name
|
|
243
|
+
*/
|
|
244
|
+
primaryKey(column: string): TableBuilder;
|
|
245
|
+
/**
|
|
246
|
+
* Sets a column as auto increment.
|
|
247
|
+
* @param column Column name
|
|
248
|
+
*/
|
|
249
|
+
autoIncrement(column: string): TableBuilder;
|
|
250
|
+
/**
|
|
251
|
+
* Sets a column as NOT NULL.
|
|
252
|
+
* @param column Column name
|
|
253
|
+
*/
|
|
254
|
+
notNull(column: string): TableBuilder;
|
|
255
|
+
/**
|
|
256
|
+
* Sets a column as UNIQUE.
|
|
257
|
+
* @param column Column name
|
|
258
|
+
*/
|
|
259
|
+
unique(column: string): TableBuilder;
|
|
260
|
+
/**
|
|
261
|
+
* Adds a foreign key constraint.
|
|
262
|
+
* @param column Local column name
|
|
263
|
+
* @param refTable Reference table name
|
|
264
|
+
* @param refColumn Reference column name
|
|
265
|
+
*/
|
|
266
|
+
foreignKey(column: string, refTable: string, refColumn: string): TableBuilder;
|
|
267
|
+
/**
|
|
268
|
+
* Sets whether to use IF NOT EXISTS.
|
|
269
|
+
* @param value true to use IF NOT EXISTS
|
|
270
|
+
*/
|
|
271
|
+
ifNotExists(value: boolean): TableBuilder;
|
|
272
|
+
/**
|
|
273
|
+
* Sets the storage engine.
|
|
274
|
+
* @param engine Engine name (e.g., "InnoDB", "MyISAM")
|
|
275
|
+
*/
|
|
276
|
+
engine(engine: string): TableBuilder;
|
|
277
|
+
/**
|
|
278
|
+
* Sets the character set.
|
|
279
|
+
* @param charset Character set (e.g., "utf8mb4")
|
|
280
|
+
*/
|
|
281
|
+
charset(charset: string): TableBuilder;
|
|
282
|
+
/**
|
|
283
|
+
* Sets the collation.
|
|
284
|
+
* @param collate Collation (e.g., "utf8mb4_unicode_ci")
|
|
285
|
+
*/
|
|
286
|
+
collate(collate: string): TableBuilder;
|
|
287
|
+
/**
|
|
288
|
+
* Builds the CREATE TABLE SQL statement.
|
|
289
|
+
* @returns SQL statement
|
|
290
|
+
*/
|
|
291
|
+
build(): string;
|
|
292
|
+
}
|
|
293
|
+
/**
|
|
294
|
+
* TableBuilder constructor interface.
|
|
295
|
+
*/
|
|
296
|
+
export interface TableBuilderConstructor {
|
|
297
|
+
new (tableName: string): TableBuilder;
|
|
298
|
+
}
|
|
1
299
|
export interface BootEvent {
|
|
2
300
|
toString(): string;
|
|
3
301
|
}
|
|
@@ -160,6 +458,20 @@ export interface LivingEntityUseBlockEvent {
|
|
|
160
458
|
getBlockType(): string;
|
|
161
459
|
}
|
|
162
460
|
export interface BreakBlockEvent {
|
|
461
|
+
getPlayer(): Player | null;
|
|
462
|
+
getEvent(): BreakBlockEventData;
|
|
463
|
+
getItemInHand(): ItemStack;
|
|
464
|
+
getTargetBlock(): Vector3i;
|
|
465
|
+
getBlockType(): BlockType;
|
|
466
|
+
setTargetBlock(arg0: Vector3i): void;
|
|
467
|
+
isCancelled(): boolean;
|
|
468
|
+
setCancelled(arg0: boolean): void;
|
|
469
|
+
}
|
|
470
|
+
/**
|
|
471
|
+
* The inner event data for BreakBlockEvent.
|
|
472
|
+
* Access via event.getEvent() when you need the raw event.
|
|
473
|
+
*/
|
|
474
|
+
export interface BreakBlockEventData {
|
|
163
475
|
getItemInHand(): ItemStack;
|
|
164
476
|
getTargetBlock(): Vector3i;
|
|
165
477
|
getBlockType(): BlockType;
|
|
@@ -168,6 +480,21 @@ export interface BreakBlockEvent {
|
|
|
168
480
|
setCancelled(arg0: boolean): void;
|
|
169
481
|
}
|
|
170
482
|
export interface PlaceBlockEvent {
|
|
483
|
+
getPlayer(): Player | null;
|
|
484
|
+
getEvent(): PlaceBlockEventData;
|
|
485
|
+
getRotation(): RotationTuple;
|
|
486
|
+
setRotation(arg0: RotationTuple): void;
|
|
487
|
+
getItemInHand(): ItemStack;
|
|
488
|
+
getTargetBlock(): Vector3i;
|
|
489
|
+
setTargetBlock(arg0: Vector3i): void;
|
|
490
|
+
isCancelled(): boolean;
|
|
491
|
+
setCancelled(arg0: boolean): void;
|
|
492
|
+
}
|
|
493
|
+
/**
|
|
494
|
+
* The inner event data for PlaceBlockEvent.
|
|
495
|
+
* Access via event.getEvent() when you need the raw event.
|
|
496
|
+
*/
|
|
497
|
+
export interface PlaceBlockEventData {
|
|
171
498
|
getRotation(): RotationTuple;
|
|
172
499
|
setRotation(arg0: RotationTuple): void;
|
|
173
500
|
getItemInHand(): ItemStack;
|
|
@@ -5403,5 +5730,7 @@ declare global {
|
|
|
5403
5730
|
const WhitelistRemoveCommand: WhitelistRemoveCommand;
|
|
5404
5731
|
const WhitelistStatusCommand: WhitelistStatusCommand;
|
|
5405
5732
|
const EventTitleUtil: EventTitleUtil;
|
|
5733
|
+
const MySQLManager: MySQLManager;
|
|
5734
|
+
const TableBuilder: TableBuilderConstructor;
|
|
5406
5735
|
}
|
|
5407
5736
|
//# sourceMappingURL=types.d.ts.map
|