@huelder/hytale-types 1.0.0

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/bridge.d.ts ADDED
@@ -0,0 +1,189 @@
1
+ /**
2
+ * Hytale TypeScript Runtime - Bridge API Types
3
+ *
4
+ * These types define the JavaScript bridge API exposed as the global `Hytale` object.
5
+ * Raw Java API types come from generated/hytale-api.d.ts.
6
+ *
7
+ * Usage:
8
+ * // Bridge API (global Hytale object)
9
+ * Hytale.commands.register({ name: 'test', execute: (ctx) => ctx.reply('Hi!') });
10
+ * Hytale.events.on('playerJoin', handler);
11
+ * Hytale.log('Hello!');
12
+ *
13
+ * // Raw Java API (via Java.type) - with autocomplete!
14
+ * const Server = Java.type('com.hypixel.hytale.server.core.HytaleServer');
15
+ * const server = Server.get(); // ← autocomplete works!
16
+ */
17
+
18
+ /// <reference path="./generated/hytale-api.d.ts" />
19
+
20
+ /**
21
+ * Command context passed to command handlers.
22
+ */
23
+ interface CommandContext {
24
+ /** Sends a reply message to the command sender. */
25
+ reply(message: string): void;
26
+ /** Gets the raw input string for the command. */
27
+ getInputString(): string;
28
+ /** Checks if the sender is a player. */
29
+ isPlayer(): boolean;
30
+ /** Gets the underlying Java CommandContext for advanced usage. */
31
+ getNative(): any;
32
+ }
33
+
34
+ /**
35
+ * Options for registering a command.
36
+ */
37
+ interface CommandOptions {
38
+ /** The command name (what users type) */
39
+ name: string;
40
+ /** Description of what the command does */
41
+ description?: string;
42
+ /** Function to execute when the command is invoked */
43
+ execute: (ctx: CommandContext) => void;
44
+ }
45
+
46
+ /**
47
+ * Command registration API.
48
+ */
49
+ interface CommandBridge {
50
+ /**
51
+ * Registers a new command.
52
+ * @example
53
+ * Hytale.commands.register({
54
+ * name: 'hello',
55
+ * execute: (ctx) => ctx.reply('Hello!')
56
+ * });
57
+ */
58
+ register(options: CommandOptions): boolean;
59
+ /** Unregisters a command. */
60
+ unregister(name: string): boolean;
61
+ /** Checks if a command is registered. */
62
+ has(name: string): boolean;
63
+ }
64
+
65
+ /**
66
+ * Event subscription API.
67
+ */
68
+ interface EventBridge {
69
+ /**
70
+ * Subscribes to an event.
71
+ * @example
72
+ * Hytale.events.on('playerJoin', (event) => console.log('Joined!'));
73
+ */
74
+ on(eventName: string, handler: (event: any) => void): boolean;
75
+ /** Subscribes to an event for a single invocation. */
76
+ once(eventName: string, handler: (event: any) => void): boolean;
77
+ /** Removes an event handler. */
78
+ off(eventName: string, handler: (event: any) => void): boolean;
79
+ /** Emits a custom event. */
80
+ emit(eventName: string, data: any): void;
81
+ /** Removes all handlers for an event. */
82
+ removeAllListeners(eventName: string): void;
83
+ /** Gets the number of handlers for an event. */
84
+ listenerCount(eventName: string): number;
85
+ }
86
+
87
+ /**
88
+ * The main Hytale bridge API.
89
+ * Available as the global `Hytale` object in all TypeScript mods.
90
+ */
91
+ interface HytaleBridge {
92
+ /** Command registration API */
93
+ readonly commands: CommandBridge;
94
+ /** Event subscription API */
95
+ readonly events: EventBridge;
96
+ /** Logs a message to the server console */
97
+ log(message: string): void;
98
+ /** Logs a warning to the server console */
99
+ warn(message: string): void;
100
+ /** Gets the plugin's data directory path */
101
+ getDataDirectory(): string;
102
+ /** Gets the plugin's name */
103
+ getPluginName(): string;
104
+ }
105
+
106
+ /**
107
+ * Java class type mapping for autocomplete support.
108
+ * Maps fully qualified class names to their TypeScript types from generated/hytale-api.d.ts.
109
+ */
110
+ interface JavaClassMap {
111
+ // Core Server
112
+ 'com.hypixel.hytale.server.core.HytaleServer': HytaleAPI.server.core.HytaleServer;
113
+ 'com.hypixel.hytale.server.core.HytaleServerConfig': HytaleAPI.server.core.HytaleServerConfig;
114
+ 'com.hypixel.hytale.server.core.Message': HytaleAPI.server.core.Message;
115
+
116
+ // Plugin System
117
+ 'com.hypixel.hytale.server.core.plugin.JavaPlugin': HytaleAPI.server.core.plugin.JavaPlugin;
118
+ 'com.hypixel.hytale.server.core.plugin.PluginBase': HytaleAPI.server.core.plugin.PluginBase;
119
+ 'com.hypixel.hytale.server.core.plugin.PluginManager': HytaleAPI.server.core.plugin.PluginManager;
120
+
121
+ // Entity
122
+ 'com.hypixel.hytale.server.core.entity.Entity': HytaleAPI.server.core.entity.Entity;
123
+ 'com.hypixel.hytale.server.core.entity.LivingEntity': HytaleAPI.server.core.entity.LivingEntity;
124
+ 'com.hypixel.hytale.server.core.entity.entities.Player': HytaleAPI.server.core.entity.entities.Player;
125
+
126
+ // World
127
+ 'com.hypixel.hytale.server.core.universe.world.World': HytaleAPI.server.core.universe.world.World;
128
+ 'com.hypixel.hytale.server.core.universe.Universe': HytaleAPI.server.core.universe.Universe;
129
+
130
+ // Commands
131
+ 'com.hypixel.hytale.server.core.command.system.CommandRegistry': HytaleAPI.server.core.command.system.CommandRegistry;
132
+ 'com.hypixel.hytale.server.core.command.system.CommandContext': HytaleAPI.server.core.command.system.CommandContext;
133
+ 'com.hypixel.hytale.server.core.command.system.AbstractCommand': HytaleAPI.server.core.command.system.AbstractCommand;
134
+
135
+ // Events
136
+ 'com.hypixel.hytale.event.EventRegistry': HytaleAPI.event.EventRegistry;
137
+ 'com.hypixel.hytale.event.EventPriority': HytaleAPI.event.EventPriority;
138
+
139
+ // Inventory
140
+ 'com.hypixel.hytale.server.core.inventory.Inventory': HytaleAPI.server.core.inventory.Inventory;
141
+ 'com.hypixel.hytale.server.core.inventory.ItemStack': HytaleAPI.server.core.inventory.ItemStack;
142
+
143
+ // Tasks
144
+ 'com.hypixel.hytale.server.core.task.TaskRegistry': HytaleAPI.server.core.task.TaskRegistry;
145
+
146
+ // Permissions
147
+ 'com.hypixel.hytale.server.core.permissions.PermissionHolder': HytaleAPI.server.core.permissions.PermissionHolder;
148
+ }
149
+
150
+ /**
151
+ * GraalJS Java interop API.
152
+ * Use Java.type() to access raw Java classes with full autocomplete.
153
+ *
154
+ * @example
155
+ * const HytaleServer = Java.type('com.hypixel.hytale.server.core.HytaleServer');
156
+ * const server = HytaleServer.get(); // ← autocomplete works!
157
+ */
158
+ interface JavaInterop {
159
+ /**
160
+ * Gets a Java class by its fully qualified name.
161
+ * Provides autocomplete for known Hytale classes.
162
+ */
163
+ type<K extends keyof JavaClassMap>(className: K): JavaClassMap[K];
164
+
165
+ /**
166
+ * Gets any Java class by its fully qualified name.
167
+ * Use this for classes not in the autocomplete list.
168
+ */
169
+ type<T = any>(className: string): T;
170
+ }
171
+
172
+ // Global declarations
173
+ declare global {
174
+ /** The Hytale bridge API - available in all TypeScript mods */
175
+ const Hytale: HytaleBridge;
176
+
177
+ /** GraalJS Java interop - use to access raw Java classes */
178
+ const Java: JavaInterop;
179
+ }
180
+
181
+ export {
182
+ CommandContext,
183
+ CommandOptions,
184
+ CommandBridge,
185
+ EventBridge,
186
+ HytaleBridge,
187
+ JavaClassMap,
188
+ JavaInterop
189
+ };
@@ -0,0 +1,3 @@
1
+ # This folder contains auto-generated TypeScript types from Java classes.
2
+ # Generated by running: mvn typescript-generator:generate
3
+ # Do not edit these files manually - they will be overwritten.