Share exact Navigator request builders with contract fixtures
Some checks failed
Guild and Smuggler Navigator Build / navigator (push) Successful in 1m54s
DuneRealms Plugin CI / plugins (push) Failing after 3m11s

This commit is contained in:
unimatrixgit 2026-11-29 23:47:12 +01:00
commit d45fe6471c

View file

@ -110,20 +110,24 @@ final class OrganisationMenus implements Listener {
smugglerRequest(player,contact,origin,"home_quote",query,quote->{
var view=new SmugglerDestinations.Quote(destination,quote.get("fareMinor").getAsLong(),
quote.get("affordable").getAsBoolean()?null:"Insufficient available funds in your personal account.");
var booking=new JsonObject();booking.add("target",target);
booking.addProperty("requestId",UUID.randomUUID().toString());booking.addProperty("confirmed",true);
for(String field:List.of("keyId","version","fareMinor"))booking.add(field,quote.get(field));
for(String side:List.of("origin","target")){
var pin=quote.getAsJsonObject(side);
booking.add(side+"HomeBlockId",pin.get("homeBlockId"));booking.add(side+"Revision",pin.get("claimRevision"));
}
var booking=smugglerBooking(target,quote,UUID.randomUUID());
confirmSmugglerPassage(player,view,()->smugglerRequest(player,contact,origin,"home_board",booking,
ticket->player.sendMessage("Smuggler passage: "+ticket.get("state").getAsString())),back);
});
}
static JsonObject smugglerBooking(JsonObject target,JsonObject quote,UUID requestId){
var booking=new JsonObject();booking.add("target",target);
booking.addProperty("requestId",requestId.toString());booking.addProperty("confirmed",true);
for(String field:List.of("keyId","version","fareMinor"))booking.add(field,quote.get(field));
for(String side:List.of("origin","target")){
var pin=quote.getAsJsonObject(side);
booking.add(side+"HomeBlockId",pin.get("homeBlockId"));booking.add(side+"Revision",pin.get("claimRevision"));
}
return booking;
}
private void smugglerRequest(Player player,UUID contact,JsonObject origin,String action,JsonObject fields,Consumer<JsonObject> callback){
if(!busy.add(player.getUniqueId()))return;
var request=fields.deepCopy();request.addProperty("action",action);request.add("origin",origin);
var request=smugglerFields(origin,action,fields);
player.closeInventory();
try{
bridge.homeSmuggler(player,contact,request).whenComplete((response,failure)->Bukkit.getScheduler().runTask(plugin,()->{
@ -135,6 +139,9 @@ final class OrganisationMenus implements Listener {
}));
}catch(Exception failure){busy.remove(player.getUniqueId());player.sendMessage("Smuggler Navigator is unavailable.");}
}
static JsonObject smugglerFields(JsonObject origin,String action,JsonObject fields){
var request=fields.deepCopy();request.addProperty("action",action);request.add("origin",origin);return request;
}
void smugglerNavigator(Player player, List<SmugglerDestinations.Destination> destinations,
int pageNumber, Consumer<SmugglerDestinations.Destination> select, Runnable back) {
var screen = panel(player, "Smuggler Navigator", false);