forked from unimatrix/web
Page and filter the text mission journal
This commit is contained in:
parent
7ca12b9559
commit
be992d6afa
1 changed files with 19 additions and 4 deletions
|
|
@ -48,21 +48,33 @@ final class QuestMenus implements Listener {
|
|||
boolean starterAction=Set.of("obtain","parts","repair").contains(verb);
|
||||
boolean roleStep=Set.of("dossier","cargo","partner").contains(verb);
|
||||
boolean nativeStep=roleStep||Set.of("research","meat","supply","refine").contains(verb);
|
||||
if((roleStep?args.length<3||args.length>5:args.length!=(list?2:3))||!nativeStep&&!starterAction&&!Set.of("list","show","start","claim","briefing").contains(verb)||
|
||||
if((roleStep?args.length<3||args.length>5:list?args.length<2||args.length>4:args.length!=3)||!nativeStep&&!starterAction&&!Set.of("list","show","start","claim","briefing").contains(verb)||
|
||||
!Set.of("personal","pol").contains(args[1].toLowerCase(Locale.ROOT))){
|
||||
player.sendMessage("Use /missions list <personal|pol> or /missions <show|start|claim|briefing> <personal|pol> <id>. POL steps: /missions <research|meat|supply|refine> pol <id>.");
|
||||
player.sendMessage("Use /missions list <personal|pol> [page] [branch] or /missions <show|start|claim|briefing> <personal|pol> <id>. POL steps: /missions <research|meat|supply|refine> pol <id>.");
|
||||
return;
|
||||
}
|
||||
String kind=args[1].toLowerCase(Locale.ROOT);
|
||||
int page;
|
||||
try{page=list&&args.length>=3?Integer.parseInt(args[2]):1;}catch(NumberFormatException invalid){page=0;}
|
||||
if(page<1||page>10000){player.sendMessage("Enter a mission page from 1 to 10000.");return;}
|
||||
int offset=(page-1)*10;
|
||||
String branchFilter=list&&args.length==4?args[3]:"";
|
||||
roleScope.remove(player.getUniqueId());
|
||||
var read=new JsonObject();read.addProperty("action","read");read.addProperty("kind",kind);
|
||||
request(player,read,data->{
|
||||
if(!"active".equals(text(data,"state",""))){player.sendMessage("No active quest season is available.");return;}
|
||||
int listed=0;
|
||||
for(var value:data.getAsJsonArray("quests")){
|
||||
var row=value.getAsJsonObject();String id=text(row,"id","");
|
||||
if(list){if(!text(row,"state","").equals("claimed"))player.sendMessage(id+" · "+text(row,"title","Mission")+" · "+text(row,"state",""));continue;}
|
||||
if(list){
|
||||
String branch=text(row,"branch","");
|
||||
if(text(row,"state","").equals("claimed")||!branchFilter.isEmpty()&&!branch.equalsIgnoreCase(branchFilter))continue;
|
||||
int position=listed++;
|
||||
if(position>=offset&&position<offset+10)player.sendMessage(id+" · "+text(row,"title","Mission")+" · "+text(row,"state","")+" · "+branch);
|
||||
continue;
|
||||
}
|
||||
if(!id.equalsIgnoreCase(args[2]))continue;
|
||||
if(website(row)){website(player);return;}
|
||||
if(website(row)&&!verb.equals("show")){website(player);return;}
|
||||
String state=text(row,"state","");
|
||||
if(starterAction){
|
||||
String expected=verb.equals("obtain")?"S1-H-01":"S1-H-02";
|
||||
|
|
@ -82,6 +94,7 @@ final class QuestMenus implements Listener {
|
|||
player.sendMessage(id+" · "+text(row,"title","Mission")+" · "+state);
|
||||
player.sendMessage(text(row,"objective","Complete the verified objective."));
|
||||
player.sendMessage("Progress: "+text(row,"progress","0")+" / "+text(row,"target","0"));
|
||||
if(website(row))website(player);
|
||||
if(kind.equals("personal")&&id.equals("S1-H-01"))player.sendMessage("Starter kit: /missions obtain personal "+id);
|
||||
if(kind.equals("personal")&&id.equals("S1-H-02"))player.sendMessage("Starter repair: /missions parts personal "+id+" or /missions repair personal "+id);
|
||||
if(state.equals("active")&&!yes(row,"canClaim")&&text(row,"metric","").equals("citizen-introduction")){
|
||||
|
|
@ -96,6 +109,8 @@ final class QuestMenus implements Listener {
|
|||
return;
|
||||
}
|
||||
if(!list)player.sendMessage("That mission is not available to you.");
|
||||
else if(listed<=offset)player.sendMessage("No missions on this page.");
|
||||
else if(listed>offset+10)player.sendMessage("Next: /missions list "+kind+" "+(offset/10+2)+(branchFilter.isEmpty()?"":" "+branchFilter));
|
||||
});
|
||||
}
|
||||
private void roleMissionCommand(Player player,String kind,JsonObject data,JsonObject row,String verb,String[] args){
|
||||
|
|
|
|||
Loading…
Reference in a new issue

Staff