Skip to content

Commit 96fc209

Browse files
Merge pull request #189 from rune-js/console-commands
add support for auto completion and help for server commands in client
2 parents 97f7725 + dc4b70c commit 96fc209

File tree

4 files changed

+135
-95
lines changed

4 files changed

+135
-95
lines changed

src/net/inbound-packets/command-packet.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { inputCommandAction } from '../../world/actor/player/action/input-command-action';
2+
import { Rights } from '../../world/actor/player/player';
23

34
const commandPacket = (player, packet) => {
45
const input = packet.buffer.getString();
@@ -13,8 +14,11 @@ const commandPacket = (player, packet) => {
1314
const command = args[0];
1415

1516
args.splice(0, 1);
16-
17-
inputCommandAction(player, command, isConsole, args);
17+
if(player.rights !== Rights.ADMIN) {
18+
player.sendLogMessage('You need to be an administrator to use commands.', isConsole);
19+
} else {
20+
inputCommandAction(player, command, isConsole, args);
21+
}
1822
};
1923

2024
export default [{

src/net/outbound-packets.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -482,6 +482,13 @@ export class OutboundPackets {
482482
this.queue(packet);
483483
}
484484

485+
public sendConsoleCommand(command: string, help: string): void {
486+
const packet = new Packet(85, PacketType.DYNAMIC_SMALL);
487+
packet.putString(command);
488+
packet.putString(help);
489+
this.queue(packet);
490+
}
491+
485492
public updateSkill(skillId: number, level: number, exp: number): void {
486493
const packet = new Packet(34);
487494
packet.put(level);

src/world/actor/player/action/input-command-action.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ export interface CommandActionPlugin extends ActionPlugin {
4040
/**
4141
* A directory of all command interaction plugins.
4242
*/
43-
let commandInteractions: CommandActionPlugin[] = [];
43+
export let commandInteractions: CommandActionPlugin[] = [];
4444

4545
/**
4646
* Sets the list of command interaction plugins.

0 commit comments

Comments
 (0)