mirror of
https://github.com/danbulant/flying-squid
synced 2026-06-17 13:31:16 +00:00
Change to async emits
This commit is contained in:
parent
fa99c91551
commit
a68b10bfa0
3 changed files with 14 additions and 15 deletions
|
|
@ -3,6 +3,7 @@ var EventEmitter = require('events').EventEmitter;
|
|||
var path = require('path');
|
||||
var requireIndex = require('requireindex');
|
||||
var plugins = requireIndex(path.join(__dirname, 'lib', 'plugins'));
|
||||
require('emit-then').register();
|
||||
if (process.env.NODE_ENV === 'dev'){
|
||||
require('longjohn');
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,12 +13,12 @@ module.exports = (obj) => {
|
|||
defaultCancel = dC;
|
||||
}
|
||||
|
||||
await obj.emit(eventName + '_cancel', data, cancel);
|
||||
await obj.emit(eventName, data, cancelled, cancelCount);
|
||||
await obj.emitThen(eventName + '_cancel', data, cancel).catch((err)=> setTimeout(() => {throw err;},0));
|
||||
await obj.emitThen(eventName, data, cancelled, cancelCount).catch((err)=> setTimeout(() => {throw err;},0));
|
||||
|
||||
if (!hiddenCancelled && !cancelled) await func(data);
|
||||
else if (cancelFunc && defaultCancel) cancelFunc(data);
|
||||
if (!hiddenCancelled && !cancelled) await func(data).catch((err)=> setTimeout(() => {throw err;},0));
|
||||
else if (cancelFunc && defaultCancel) await cancelFunc(data).catch((err)=> setTimeout(() => {throw err;},0));
|
||||
|
||||
await obj.emit(eventName + '_done', data, cancelled);
|
||||
await obj.emitThen(eventName + '_done', data, cancelled).catch((err)=> setTimeout(() => {throw err;},0));
|
||||
}
|
||||
}
|
||||
|
|
@ -53,16 +53,14 @@ module.exports.player=function(player,serv) {
|
|||
serv.playNoteBlock(data.note, player.world, reference);
|
||||
});
|
||||
|
||||
player.on('dig_cancel', async ({position, reference}, cancel) => {
|
||||
if (status != 0 || player.gameMode == 1) return;
|
||||
return player.world.getBlockType(reference).then((id) => {
|
||||
if (id != 25) return;
|
||||
cancel(false);
|
||||
if (!player.world.blockEntityData[reference.toString()]) player.world.blockEntityData[reference.toString()] = {};
|
||||
var data = player.world.blockEntityData[reference.toString()];
|
||||
if (typeof data.note == 'undefined') data.note = 0;
|
||||
serv.playNoteBlock(data.not,player.world, reference, data.note);
|
||||
}).catch((err)=> setTimeout(() => {throw err;},0));
|
||||
player.on('dig_cancel', async ({position}, cancel) => {
|
||||
var id = await player.world.getBlockType(position);
|
||||
if (id != 25) return;
|
||||
cancel(false);
|
||||
if (!player.world.blockEntityData[position.toString()]) player.world.blockEntityData[position.toString()] = {};
|
||||
var data = player.world.blockEntityData[position.toString()];
|
||||
if (typeof data.note == 'undefined') data.note = 0;
|
||||
serv.playNoteBlock(data.note ,player.world, position);
|
||||
});
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue