Skip to content

Commit 1a8364f

Browse files
authored
Merge pull request #306 from runejs/fix/item-swapping
Fixing item swapping and moving functionality
2 parents 0597f27 + 1fd01dd commit 1a8364f

File tree

8 files changed

+317
-845
lines changed

8 files changed

+317
-845
lines changed

package-lock.json

Lines changed: 301 additions & 821 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -28,22 +28,17 @@
2828
"author": "Tynarus",
2929
"license": "GPL-3.0",
3030
"dependencies": {
31-
"@hapi/joi": "^16.1.8",
3231
"@runejs/core": "^1.3.2",
3332
"@runejs/filestore": "^0.13.3",
3433
"@runejs/login-server": "^1.1.0",
3534
"@runejs/update-server": "^1.1.1",
36-
"bcrypt": "^5.0.0",
3735
"bigi": "^1.4.2",
38-
"body-parser": "^1.19.0",
39-
"crc-32": "^1.2.0",
40-
"express": "^4.17.1",
4136
"js-yaml": "^3.13.1",
4237
"json5": "^2.1.3",
4338
"lodash": "^4.17.15",
4439
"quadtree-lib": "^1.0.9",
45-
"rxjs": "^7.0.0-beta.8",
46-
"source-map-support": "^0.5.16",
40+
"rxjs": "^7.0.0",
41+
"source-map-support": "^0.5.19",
4742
"ts-node": "^9.1.1",
4843
"tslib": "^2.1.0",
4944
"typescript": "^4.2.3",
@@ -58,22 +53,19 @@
5853
"@babel/preset-env": "^7.10.2",
5954
"@babel/preset-typescript": "^7.10.1",
6055
"@halkeye/tscpaths": "0.0.9",
61-
"@types/body-parser": "^1.17.1",
62-
"@types/express": "^4.17.2",
63-
"@types/hapi__joi": "^16.0.6",
6456
"@types/js-yaml": "^3.12.1",
6557
"@types/json5": "0.0.30",
6658
"@types/lodash": "^4.14.149",
6759
"@types/node": "^14.14.37",
6860
"@types/uuid": "^3.4.6",
6961
"@types/yargs": "^13.0.4",
70-
"@typescript-eslint/eslint-plugin": "^4.6.0",
71-
"@typescript-eslint/eslint-plugin-tslint": "^4.6.0",
72-
"@typescript-eslint/parser": "^4.6.0",
62+
"@typescript-eslint/eslint-plugin": "^4.22.0",
63+
"@typescript-eslint/eslint-plugin-tslint": "^4.22.0",
64+
"@typescript-eslint/parser": "^4.22.0",
7365
"babel-plugin-module-resolver": "^4.0.0",
7466
"chokidar": "^3.4.3",
7567
"concurrently": "^5.1.0",
76-
"eslint": "^7.12.1",
68+
"eslint": "^7.25.0",
7769
"mkdirp": "^1.0.4",
7870
"nodemon": "^2.0.6",
7971
"rimraf": "^3.0.2",

src/game-engine/world/action/hooks/task.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import uuidv4 from 'uuid/v4';
22
import { lastValueFrom, Subscription, timer } from 'rxjs';
33
import { Actor } from '@engine/world/actor/actor';
4-
import { ActionHook } from '@engine/world/action/hooks/index';
4+
import { ActionHook } from '@engine/world/action';
55
import { World } from '@engine/world';
66
import { logger } from '@runejs/core';
77
import { Player } from '@engine/world/actor/player/player';

src/game-engine/world/action/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ export class ActionPipeline {
143143
}
144144

145145
private async runActionHandler(actionHandler: any, ...args: any[]): Promise<void> {
146-
const runnableHooks: RunnableHooks | null | undefined = actionHandler(...args);
146+
const runnableHooks: RunnableHooks | null | undefined = await actionHandler(...args);
147147

148148
if(!runnableHooks?.hooks || runnableHooks.hooks.length === 0) {
149149
return;

src/game-engine/world/action/item-swap.action.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,13 @@ export interface ItemSwapAction {
4343
* @param toSlot
4444
* @param widget
4545
*/
46-
const itemSwapActionPipe = async (player: Player, fromSlot: number, toSlot: number, widget: {
47-
widgetId: number; containerId: number; }): Promise<RunnableHooks<ItemSwapAction>> => {
46+
const itemSwapActionPipe = (player: Player, fromSlot: number, toSlot: number,
47+
widget: { widgetId: number, containerId: number }): RunnableHooks<ItemSwapAction> => {
4848
const matchingHooks = getActionHooks<ItemSwapActionHook>('item_swap')
4949
.filter(plugin => numberHookFilter(plugin.widgetId || plugin.widgetIds, widget.widgetId));
5050

5151
if(!matchingHooks || matchingHooks.length === 0) {
52-
await player.sendMessage(`Unhandled Swap Items action: widget[${widget.widgetId}] container[${widget.containerId}] fromSlot[${fromSlot} toSlot${toSlot}`);
52+
player.sendMessage(`Unhandled Swap Items action: widget[${widget.widgetId}] container[${widget.containerId}] fromSlot[${fromSlot} toSlot${toSlot}`);
5353
return null;
5454
}
5555

src/game-engine/world/action/move-item.action.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,13 @@ export interface MoveItemAction {
4444
* @param toSlot
4545
* @param widget
4646
*/
47-
const moveItemActionPipe = async (player: Player, fromSlot: number, toSlot: number,
48-
widget: { widgetId: number, containerId: number }): Promise<RunnableHooks<MoveItemAction>> => {
47+
const moveItemActionPipe = (player: Player, fromSlot: number, toSlot: number,
48+
widget: { widgetId: number, containerId: number }): RunnableHooks<MoveItemAction> => {
4949
const matchingHooks = getActionHooks<MoveItemActionHook>('move_item')
5050
.filter(plugin => numberHookFilter(plugin.widgetId || plugin.widgetIds, widget.widgetId));
5151

5252
if(!matchingHooks || matchingHooks.length === 0) {
53-
await player.sendMessage(`Unhandled Move Item action: widget[${widget.widgetId}] container[${widget.containerId}] fromSlot[${fromSlot} toSlot${toSlot}`);
53+
player.sendMessage(`Unhandled Move Item action: widget[${widget.widgetId}] container[${widget.containerId}] fromSlot[${fromSlot} toSlot${toSlot}`);
5454
return null;
5555
}
5656

src/plugins/dialogue/item-selection.plugin.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { widgetInteractionActionHandler } from '@engine/world/action/widget-inte
55
*/
66
export const action: widgetInteractionActionHandler = (details) => {
77
const { player, widgetId, childId } = details;
8-
player.interfaceState.closeWidget(widgetId, childId);
8+
player.interfaceState.closeWidget('chatbox', widgetId, childId);
99
};
1010

1111
export default {

src/plugins/skills/level-up-dialogue.plugin.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ const widgetIds = [
1414
* Handles a level-up dialogue action.
1515
*/
1616
export const handler: widgetInteractionActionHandler = ({ player }) =>
17-
player.interfaceState.closeChatOverlayWidget();
17+
player.interfaceState.closeWidget('chatbox');
1818

1919
export default {
2020
pluginId: 'rs:close_level_up_message',

0 commit comments

Comments
 (0)