Skip to content

Commit 850bef1

Browse files
committed
Move argument validation before activation
1 parent 479ec3b commit 850bef1

File tree

2 files changed

+30
-19
lines changed

2 files changed

+30
-19
lines changed

build/scripts/playerCommands.js

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

src/playerCommands.ts

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -153,20 +153,21 @@ export const commands = commandList({
153153
description: 'Checks the history of all tiles in the selected region. Can be filtered by action.',
154154
perm: Perm.none,
155155
handler({args, outputSuccess, currentTapMode, handleTaps}) {
156-
if(currentTapMode === "off") {
156+
if(currentTapMode === "off" || args.action || args.amount) {
157+
if(args.action && !allowedActions.includes(args.action))
158+
fail(`Invalid action. Allowed actions: ${allowedActions.join(", ")}`);
159+
if(args.amount && args.amount > 100) fail(`Limit cannot be greater than 100.`);
160+
161+
p1 = null;
162+
p2 = null;
157163
handleTaps("on");
158-
outputSuccess(`Aoelog mode enabled. To see the recent history of all tiles in a rectangular region, tap opposite corners of the rectangle. Run /aoelog again to disable.`);
164+
outputSuccess(`Aoelog mode enabled. To see the recent history of all tiles in a rectangular region, tap opposite corners of the rectangle. Run /aoelog with no arguments to disable.`);
159165
} else {
160166
handleTaps("off");
161167
outputSuccess(`Aoelog disabled.`);
162168
}
163-
if(args.action && !allowedActions.includes(args.action))
164-
fail(`Invalid action. Allowed actions: ${allowedActions.join(", ")}`);
165-
if(args.amount && args.amount > 100) fail(`Limit cannot be greater than 100.`);
166-
p1 = null;
167-
p2 = null;
168169
},
169-
tapped({x, y, output, sender, admins, handleTaps, args}) {
170+
tapped({x, y, output, outputFail, sender, admins, handleTaps, args}) {
170171
function handleArea(p1: [number, number], p2: [number, number]){
171172
const minX = Math.min(p1[0], p2[0]);
172173
const maxX = Math.max(p1[0], p2[0]);
@@ -198,7 +199,11 @@ export const commands = commandList({
198199
if(limitTiles === amount) break outer;
199200
}
200201
}
201-
if(limitTiles === amount)
202+
if(limitTiles == 0){
203+
if(args.action) outputFail(`There is no recorded history for the selected region matching the provided filters.`);
204+
else outputFail(`There is no recorded history for the selected region.`);
205+
}
206+
if(limitTiles == amount)
202207
output(`Displaying first ${limitTiles} entries. To show other entries, increase the limit or select a smaller area.`);
203208
}
204209
if(!p1){

0 commit comments

Comments
 (0)