The command&events decorators (@command, @commandable, @event, @eventable)
Information
Installation
Disadvantages
Examples
Sources
Event decorator
1. Information:
There is a snippet which helps to registry any commands/events to Rage API with the simple interface by using decorators.
Library: rage-decorators [github] [npm-package]
If you're using typescript, make sure there two options (experimentalDecorators, emitDecoratorMetadata) are true in your tsconfig.json:
{
"compilerOptions": {
"experimentalDecorators": true,
"emitDecoratorMetadata": true
},
}
2. Installation:
Via npm: $ npm i --save rage-decorators
Via yarn: $ yarn add rage-decorators
3. Disadvantages:
Disadvantage 1: the snippet requires rage-decorators package
4. Examples:
Simple example:
My example of command list:
5. Source:
Sources is now allowed on github repository and as npm package:
https://github.com/READYTOMASSACRE/rage-decorators
the source of decorators.ts (server-side only, for supporting events, client-side usage npm package)
the source of decorators.js (server-side only, for supporting events, client-side usage npm package)
6. Event decorator:
Event decorator is now avaliable in npm package, here an usaging example:
import { eventable, event } from 'rage-decorators'
@eventable()
class Foo {
@event("playerJoin")
playerJoin(player: PlayerMp): void {
console.log(`Player[${player.id}]${player.name} has joined to the server`)
}
}