Skip to content

Commit

Permalink
Omit 'quest_slot' param of '/inspectquest' chat command to list all q…
Browse files Browse the repository at this point in the history
  • Loading branch information
AntumDeluge committed Oct 15, 2023
1 parent 5f37421 commit af4f332
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 14 deletions.
2 changes: 1 addition & 1 deletion src/games/stendhal/client/actions/GMHelpAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public boolean execute(final String[] params, final String remainder) {
"\t\tShow complete details of #player.",
"- /inspectkill <player> <creature>",
"\t\tShow creature kill counts of #player for #creature.",
"- /inspectquest <player> <quest_slot>",
"- /inspectquest <player> [<quest_slot>]",
"\t\tShow the state of quest for #player.",
"- /script <scriptname>",
"\t\tLoad (or reload) a script on the server. See #/gmhelp #script for details.",
Expand Down
10 changes: 7 additions & 3 deletions src/games/stendhal/client/actions/InspectQuestAction.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/***************************************************************************
* Copyright © 2020 - Arianne *
* Copyright © 2020-2023 - Arianne *
***************************************************************************
***************************************************************************
* *
Expand All @@ -24,7 +24,11 @@ public boolean execute(final String[] params, final String remainder) {

action.put("type", INSPECTQUEST);
action.put("target", params[0]);
action.put("quest_slot", params[1]);
// FIXME: Why does param[1] result as null when single parameter given?
// Clue may be in `games.stendhal.client.scripting.SlashActionParser.parse`.
if (params.length > 1 && params[1] != null) {
action.put("quest_slot", params[1]);
}

ClientSingletonRepository.getClientFramework().send(action);

Expand All @@ -38,6 +42,6 @@ public int getMaximumParameters() {

@Override
public int getMinimumParameters() {
return 2;
return 1;
}
}
26 changes: 20 additions & 6 deletions src/games/stendhal/server/actions/admin/InspectQuestAction.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/***************************************************************************
* Copyright © 2020 - Arianne *
* Copyright © 2020-2023 - Arianne *
***************************************************************************
***************************************************************************
* *
Expand All @@ -13,6 +13,8 @@

import static games.stendhal.common.constants.Actions.INSPECTQUEST;

import java.util.Arrays;

import games.stendhal.server.actions.CommandCenter;
import games.stendhal.server.entity.Entity;
import games.stendhal.server.entity.player.Player;
Expand All @@ -34,17 +36,29 @@ protected void perform(final Player admin, final RPAction action) {
final Entity target = getTargetAnyZone(admin, action);

if (target == null) {
final String text = "Entity not found for action" + action;
final String text = "Entity not found for action: " + action;
admin.sendPrivateText(text);
return;
}

if (target instanceof Player && action.has("quest_slot")) {
if (target instanceof Player) {
final Player player = (Player) target;
final String questSlot = action.get("quest_slot");
final String questState = player.getQuest(questSlot);
if (action.has("quest_slot")) {
// get a specific quest
final String questSlot = action.get("quest_slot");
final String questState = player.getQuest(questSlot);

admin.sendPrivateText(questSlot + " (" + player.getName() + "): " + questState);
admin.sendPrivateText(questSlot + " (" + player.getName() + "): " + questState);
} else {
// get all quests
final StringBuilder sb = new StringBuilder("Quest states for player " + player.getName() + ":");
final String[] slots = player.getQuests().toArray(new String[0]);
Arrays.sort(slots);
for (final String questSlot: slots) {
sb.append("\n" + questSlot + ": " + player.getQuest(questSlot));
}
admin.sendPrivateText(sb.toString());
}
}
}
}
10 changes: 6 additions & 4 deletions srcjs/stendhal/SlashActionRepo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ export class SlashActionRepo {
"\t\tShow complete details of #player.",
"- /inspectkill <player> <creature>",
"\t\tShow creature kill counts of #player for #creature.",
"- /inspectquest <player> <quest_slot>",
"- /inspectquest <player> [<quest_slot>]",
"\t\tShow the state of quest for #player.",
"- /script <scriptname>",
"\t\tLoad (or reload) a script on the server. See #/gmhelp #script for details.",
Expand Down Expand Up @@ -613,13 +613,15 @@ export class SlashActionRepo {
execute: (type: string, params: string[], remainder: string): boolean => {
const action: Action = {
"type": "inspectquest",
"target": params[0],
"quest_slot": params[1]
"target": params[0]
};
if (params.length > 1) {
action["quest_slot"] = params[1];
}
this.sendAction(action);
return true;
},
minParams: 2,
minParams: 1,
maxParams: 2
};

Expand Down

0 comments on commit af4f332

Please sign in to comment.