pack-mc-2
Version:
PackMc2-Beta OpenSource v1.0.0
25 lines (23 loc) • 635 B
JavaScript
var {ActivePlugin} = require( "../../src/Plugin" )
class CustomCommand extends ActivePlugin {
constructor( ctx ){
super( "CustomCommand", ctx )
this.cmdlist = {}
this.sign = "!"
}
createCmd( name, handle ){
this.cmdlist[name] = handle
return this
}
onMinecraft( mc ){
mc.world.afterEvents.chatSend.subscribe( event => {
if( event.message[0] == this.sign ){
var cmd = event.message.slice(1).split( " " )
if( Object.keys( this.cmdlist ).includes( cmd[0] ) ){
this.cmdlist[ cmd[0] ]( event.sender, cmd, mc )
}
}
})
}
}
module.exports = CustomCommand