feat(inspire): export accepted native absorption events
Release / release (push) Failing after 9m42s

This commit is contained in:
dmg committed 2026-09-26 08:57:01 -04:00
1 parent 93897ce516
commit 9b378b4237
9 files changed
+403 -18

No files matched your search

@@ -767,6 +767,7 @@ public final class FantasyStickPlugin extends JavaPlugin {
abilityEngine.enableCastEventsFor("stone_skin");
abilityEngine.enableCastEventsFor("shield_bash");
abilityEngine.enableCastEventsFor("hex");
abilityEngine.enableCastEventsFor("inspire");
abilityEngine.enableCastEventsFor("mending_light");
abilityEngine.enableCastEventsFor("purify");
abilityEngine.enableCastEventsFor("guardian_bond");
@@ -73,7 +73,8 @@ public final class AbilityEngine implements Consumer<ControlInput>, AutoCloseabl
if (castEvents == null || record == null
|| !(definition.id().equals("great_sword") || definition.id().equals("longbow")
|| definition.id().equals("quickstep") || definition.id().equals("second_wind")
|| definition.id().equals("shield_bash") || definition.id().equals("hex"))
|| definition.id().equals("shield_bash") || definition.id().equals("hex")
|| definition.id().equals("inspire"))
|| !eventOwnedAbilities.contains(definition.id())) return;
resolve(castEvents.begin(input, record, definition), "refused", reason);
}
@@ -354,6 +355,7 @@ public final class AbilityEngine implements Consumer<ControlInput>, AutoCloseabl
private final Map<String, Object> castEvidence = new HashMap<>();
private boolean castPublished;
private final Map<UUID, String> observedEffects = new HashMap<>();
private final Map<UUID, Map<String, Object>> observedEndEvidence = new HashMap<>();
private final Set<AutoCloseable> owned = new HashSet<>();
private String outcome;
private Map<String, Object> resolutionEvidence = Map.of();
@@ -496,6 +498,17 @@ public final class AbilityEngine implements Consumer<ControlInput>, AutoCloseabl
castEvents.outgoingPrevented(audit, application, debuffedAttacker, protectedTarget,
incoming, remaining, actual, evidence);
}
@Override public void acceptedAbsorption(UUID application, Player target, Entity attacker,
double incoming, double before, double after,
double consumed, double remaining,
org.bukkit.Location targetAtHit, org.bukkit.Location attackerAtHit) {
if (castEvents == null || audit == null) return;
try {
var aided = sessions.active(target.getUniqueId()).filter(sessions::current).orElse(null);
castEvents.absorbed(audit, application, target, aided, attacker, incoming,
before, after, consumed, remaining, targetAtHit, attackerAtHit);
} catch (RuntimeException ignored) { /* Recording cannot change native absorption or support. */ }
}
@Override public void acceptedBoost(EquipmentSessions.Active attacking, Player attacker,
Entity target, double base, double bonus, double finalDamage,
java.math.BigDecimal percent) {
@@ -503,11 +516,16 @@ public final class AbilityEngine implements Consumer<ControlInput>, AutoCloseabl
castEvents.boosted(audit, attacking, attacker, target, base, bonus, finalDamage, percent);
}
@Override public void effectEnded(UUID application, String reason) {
effectEnded(application, reason, Map.of());
effectEnded(application, reason, observedEndEvidence.getOrDefault(application, Map.of()));
}
@Override public void effectEndEvidence(UUID application, Map<String, Object> evidence) {
if (observedEffects.containsKey(application))
observedEndEvidence.put(application, Map.copyOf(Objects.requireNonNull(evidence)));
}
@Override public void effectEnded(UUID application, String reason, Map<String, Object> evidence) {
Objects.requireNonNull(application); Objects.requireNonNull(reason); Objects.requireNonNull(evidence);
var effectId = observedEffects.remove(application);
observedEndEvidence.remove(application);
if (effectId != null && castEvents != null)
castEvents.effectEnded(audit, application, effectId, reason, evidence);
}
@@ -45,6 +45,11 @@ public interface AbilityExecution extends AutoCloseable {
/** Record only the winning owned outgoing reduction after final uncancelled native damage. */
default void acceptedOutgoingMitigation(UUID application, Entity debuffedAttacker, Entity protectedTarget,
double incoming, double remaining, double actual) { }
/** Record only observed native consumption of this execution's owned temporary health. */
default void acceptedAbsorption(UUID application, org.bukkit.entity.Player target, Entity attacker,
double incoming, double before, double after, double consumed,
double remaining, org.bukkit.Location targetAtHit,
org.bukkit.Location attackerAtHit) { }
/** Record a winning outgoing bonus only after a positive uncancelled native hit. */
void acceptedBoost(games.dmg.fantasystick.session.EquipmentSessions.Active attacking,
org.bukkit.entity.Player attacker, Entity target,
@@ -55,6 +60,8 @@ public interface AbilityExecution extends AutoCloseable {
default void effectEnded(UUID applicationId, String reason, Map<String, Object> evidence) {
effectEnded(applicationId, reason);
}
/** Capture remaining owned effect state during resource cleanup for the terminal effect record. */
default void effectEndEvidence(UUID applicationId, Map<String, Object> evidence) { }
/** Attach an observed native admission to the one pending cast record; never publish guessed velocity. */
default void castEvidence(Map<String, Object> evidence) { }
/** Attach actual final native position to an already chosen or interrupted resolution during cleanup. */
@@ -8,7 +8,38 @@ public final class Inspire implements AbilityEffect,AutoCloseable{
public AbilityDefinition definition(){var s=settings;return new AbilityDefinition("inspire","Inspire",Material.AMETHYST_SHARD,List.of("Grant "+s.baseTemporaryHealth()+" + CHR modifier temporary health for "+seconds(s.duration())+" seconds.","Range "+BigDecimal.valueOf(s.range()).stripTrailingZeros().toPlainString()+" blocks for an aimed fantasy player."),"Sneak+Use selects self; normal Use requires an aimed fantasy player.",Map.of(Stat.CHR,BigInteger.valueOf(12),Stat.WIS,BigInteger.TEN),BigInteger.ONE,AbilityDefinition.Category.BUF,AbilityDefinition.Activation.DELAYED,ControlInput.Gesture.USE,s.cooldown(),Map.of("base-temporary-health",new BigDecimal(s.baseTemporaryHealth()),"range",BigDecimal.valueOf(s.range()).stripTrailingZeros(),"duration-seconds",BigDecimal.valueOf(s.duration().toNanos()).movePointLeft(9)),AbilityDefinition.TargetPolicy.ALLY,this);}
@Override public boolean accepts(ControlInput input){if(closed||!(input.target() instanceof Player target))return false;if(input.player().isSneaking())return target==input.player();return target!=input.player()&&inRange(input.player(),target,settings.range());}
public static BigInteger amount(BigInteger charisma){return amount(BigInteger.valueOf(4),charisma);}static BigInteger amount(BigInteger base,BigInteger charisma){Objects.requireNonNull(base);Objects.requireNonNull(charisma);if(base.signum()<0||charisma.signum()<0)throw new IllegalArgumentException("Invalid Inspire amount");var delta=charisma.subtract(BigInteger.TEN);var divided=delta.divideAndRemainder(BigInteger.TWO);var modifier=divided[0];if(delta.signum()<0&&divided[1].signum()!=0)modifier=modifier.subtract(BigInteger.ONE);return base.add(modifier);}
@Override public void activate(AbilityExecution execution){if(closed||!execution.stillCurrent()||!(execution.input().target() instanceof Player target))return;var s=from(execution.definition());if(execution.input().player().isSneaking()?target!=execution.input().player():target==execution.input().player()||!inRange(execution.input().player(),target,s.range())){execution.finish();return;}var exact=amount(s.baseTemporaryHealth(),execution.character().stats().get(Stat.CHR));double nativeAmount=exact.bitLength()>1023?Double.MAX_VALUE:exact.doubleValue();if(!Double.isFinite(nativeAmount)||nativeAmount<=0){execution.finish();return;}execution.own(temporaryHealth.grant(execution,target,nativeAmount));execution.later(s.duration(),execution::finish);}
@Override public void activate(AbilityExecution execution) {
if(closed||!execution.stillCurrent()||!(execution.input().target() instanceof Player target))return;
var s=from(execution.definition());
if(execution.input().player().isSneaking()?target!=execution.input().player():target==execution.input().player()||!inRange(execution.input().player(),target,s.range())){
execution.resolve("miss",Map.of("reason","target_ineligible_after_cooldown"));execution.finish();return;
}
var exact=amount(s.baseTemporaryHealth(),execution.character().stats().get(Stat.CHR));
double nativeAmount=exact.bitLength()>1023?Double.MAX_VALUE:exact.doubleValue();
if(!Double.isFinite(nativeAmount)||nativeAmount<=0){execution.resolve("miss",Map.of("reason","no_positive_temporary_health"));execution.finish();return;}
var application=new java.util.concurrent.atomic.AtomicReference<UUID>();
var grant=temporaryHealth.grantObserved(execution,target,nativeAmount,accepted->{
try{execution.acceptedAbsorption(application.get(),accepted.target(),accepted.attacker(),accepted.incoming(),
accepted.before(),accepted.after(),accepted.consumed(),accepted.remaining(),accepted.targetAtHit(),accepted.attackerAtHit());}
catch(RuntimeException ignored){/* Audit cannot change native absorption or party rewards. */}
},remaining->{
var id=application.get();
if(id!=null)execution.effectEndEvidence(id,Map.of("remaining_amount",
BigDecimal.valueOf(remaining).stripTrailingZeros().toPlainString()));
});
execution.own(grant);
var evidence=new LinkedHashMap<String,Object>();
evidence.put("granted_amount",BigDecimal.valueOf(nativeAmount).stripTrailingZeros().toPlainString());
evidence.put("remaining_amount",BigDecimal.valueOf(nativeAmount).stripTrailingZeros().toPlainString());
evidence.put("duration_seconds",seconds(s.duration()));
var activatedAt=execution.now();if(activatedAt!=null)evidence.put("effect_until",activatedAt.plus(s.duration()).toString());
temporaryHealth.currentSession(target).ifPresent(active->{
evidence.put("target_character_id",active.character().toString());
evidence.put("target_session_id",active.session().toString());
});
application.set(execution.effectApplied("inspire",target,evidence));
execution.later(s.duration(),()->{execution.resolve("expired");execution.finish();});
}
private static boolean inRange(Player source,Player target,double range){try{var a=source.getLocation();var b=target.getLocation();return a.getWorld()==b.getWorld()&&a.distanceSquared(b)<=range*range&&source.hasLineOfSight(target);}catch(RuntimeException invalid){return false;}}
private static Settings from(AbilityDefinition d){var p=d.parameters();return new Settings(p.get("base-temporary-health").toBigIntegerExact(),d.cooldown(),p.get("range").doubleValue(),Duration.ofNanos(p.get("duration-seconds").movePointRight(9).longValueExact()));}
private static String seconds(Duration d){return BigDecimal.valueOf(d.toNanos()).movePointLeft(9).stripTrailingZeros().toPlainString();}
@@ -13,21 +13,83 @@ import org.bukkit.projectiles.ProjectileSource;
/** Plugin-owned temporary-health ledger layered over unrelated native absorption. */
public final class TemporaryHealth implements Listener,AutoCloseable{
public record Support(UUID target,UUID supportingCharacter,EquipmentSessions.Active aided,BigDecimal amount){}
private final class Grant implements AutoCloseable{final long sequence;final AbilityExecution execution;final Player target;double remaining;boolean closed;
Grant(AbilityExecution e,Player t,double amount){sequence=++sequences;execution=e;target=t;remaining=amount;}
@Override public void close(){if(closed)return;double before=owned(target.getUniqueId());closed=true;var list=grants.get(target.getUniqueId());if(list!=null){list.remove(this);if(list.isEmpty())grants.remove(target.getUniqueId());}double after=owned(target.getUniqueId());removeNative(target,Math.max(0,before-after));}}
public record Accepted(Player target,Entity attacker,double incoming,double before,double after,
double consumed,double remaining,org.bukkit.Location targetAtHit,
org.bukkit.Location attackerAtHit){}
private final class Grant implements AutoCloseable{final long sequence;final AbilityExecution execution;final Player target;
final Consumer<Accepted> observation;final Consumer<Double> onEnd;double remaining;boolean closed;
Grant(AbilityExecution e,Player t,double amount,Consumer<Accepted> observation,Consumer<Double> onEnd){
sequence=++sequences;execution=e;target=t;remaining=amount;this.observation=observation;this.onEnd=onEnd;}
@Override public void close(){if(closed)return;double before=owned(target.getUniqueId());closed=true;var list=grants.get(target.getUniqueId());if(list!=null){list.remove(this);if(list.isEmpty())grants.remove(target.getUniqueId());}double after=owned(target.getUniqueId());removeNative(target,Math.max(0,before-after));if(onEnd!=null)try{onEnd.accept(Math.max(0,remaining));}catch(RuntimeException ignored){/* Cleanup is independent of recording. */}}
}
private final EquipmentSessions sessions;private final PartyRoster parties;private final Consumer<Runnable> nextTick;private final Consumer<Support> supports;
private final Map<UUID,List<Grant>> grants=new HashMap<>();private long sequences;private boolean closed;
private final Map<UUID,List<Grant>> grants=new HashMap<>();
private final Set<EntityDamageEvent> pending=Collections.newSetFromMap(new IdentityHashMap<>());
private long sequences;private boolean closed;
public TemporaryHealth(EquipmentSessions sessions,PartyRoster parties,Consumer<Runnable> nextTick,Consumer<Support> supports){this.sessions=Objects.requireNonNull(sessions);this.parties=Objects.requireNonNull(parties);this.nextTick=Objects.requireNonNull(nextTick);this.supports=Objects.requireNonNull(supports);}
public AutoCloseable grant(AbilityExecution execution,Player target,double amount){Objects.requireNonNull(execution);Objects.requireNonNull(target);if(closed||!Double.isFinite(amount)||amount<=0)throw new IllegalArgumentException("Invalid temporary health grant");double before=owned(target.getUniqueId());var grant=new Grant(execution,target,amount);grants.computeIfAbsent(target.getUniqueId(),ignored->new ArrayList<>()).add(grant);double after=owned(target.getUniqueId());addNative(target,Math.max(0,after-before));return grant;}
@EventHandler(priority=EventPriority.MONITOR,ignoreCancelled=true)public void damage(EntityDamageEvent event){if(closed||!(event.getEntity() instanceof Player target))return;var owner=strongest(target.getUniqueId());if(owner==null||!owner.execution.stillCurrent())return;double before=target.getAbsorptionAmount(),owned=owned(target.getUniqueId());if(!Double.isFinite(before)||before<=0||owned<=0)return;Entity attacker=event instanceof EntityDamageByEntityEvent by?attacker(by):null;var aided=sessions.active(target.getUniqueId()).orElse(null);boolean qualifies=aided!=null&&sessions.current(aided)&&!aided.character().equals(owner.execution.input().session().character())&&sameParty(owner.execution.input().player(),target);UUID enemy=attacker==null?null:attacker.getUniqueId();
try{nextTick.accept(()->consume(target,before,owned,owner,qualifies?aided:null,enemy));}catch(RuntimeException ignored){}}
private void consume(Player target,double before,double ownedBefore,Grant owner,EquipmentSessions.Active aided,UUID enemy){if(closed)return;double after=target.getAbsorptionAmount();double consumed=Math.min(ownedBefore,Math.max(0,before-after));if(!Double.isFinite(consumed)||consumed<=0)return;var list=grants.get(target.getUniqueId());if(list==null)return;var amount=BigDecimal.valueOf(consumed).stripTrailingZeros();owner.execution.report(AbilityReport.Type.PREVENTION,target,amount);for(var grant:List.copyOf(list))grant.remaining=Math.max(0,grant.remaining-consumed);list.removeIf(g->g.closed||g.remaining<=1e-9);if(list.isEmpty())grants.remove(target.getUniqueId());if(aided!=null&&enemy!=null)supports.accept(new Support(enemy,owner.execution.input().session().character(),aided,amount));}
public AutoCloseable grant(AbilityExecution execution,Player target,double amount){
return grantObserved(execution,target,amount,null);
}
public AutoCloseable grantObserved(AbilityExecution execution,Player target,double amount,Consumer<Accepted> observation){
return grantObserved(execution,target,amount,observation,null);
}
public AutoCloseable grantObserved(AbilityExecution execution,Player target,double amount,
Consumer<Accepted> observation,Consumer<Double> onEnd){
Objects.requireNonNull(execution);Objects.requireNonNull(target);
if(closed||!Double.isFinite(amount)||amount<=0)throw new IllegalArgumentException("Invalid temporary health grant");
double before=owned(target.getUniqueId());var grant=new Grant(execution,target,amount,observation,onEnd);
addNative(target,Math.max(0,amount-before)); // Do not retain an owned grant if the native setter refuses it.
grants.computeIfAbsent(target.getUniqueId(),ignored->new ArrayList<>()).add(grant);
return grant;
}
public Optional<EquipmentSessions.Active> currentSession(Player target){
return sessions.active(target.getUniqueId()).filter(sessions::current);
}
@EventHandler(priority=EventPriority.MONITOR,ignoreCancelled=true)public void damage(EntityDamageEvent event){
if(closed||pending.contains(event)||!(event.getEntity() instanceof Player target)
||!Double.isFinite(event.getDamage())||event.getDamage()<=0)return;
var owner=strongest(target.getUniqueId());if(owner==null||!owner.execution.stillCurrent())return;
double before=target.getAbsorptionAmount(),owned=owned(target.getUniqueId());
if(!Double.isFinite(before)||before<=0||owned<=0)return;
Entity attacker=event instanceof EntityDamageByEntityEvent by?attacker(by):null;
var targetAtHit=auditLocation(target);var attackerAtHit=auditLocation(attacker);
var aided=sessions.active(target.getUniqueId()).orElse(null);
boolean qualifies=aided!=null&&sessions.current(aided)&&!aided.character().equals(owner.execution.input().session().character())&&sameParty(owner.execution.input().player(),target);
UUID enemy=attacker==null?null:attacker.getUniqueId();double incoming=event.getDamage();
pending.add(event);
try{nextTick.accept(()->{
try{consume(event,target,before,owned,owner,qualifies?aided:null,enemy,attacker,incoming,targetAtHit,attackerAtHit);}
finally{pending.remove(event);}
});}
catch(RuntimeException ignored){pending.remove(event);}
}
private void consume(EntityDamageEvent event,Player target,double before,double ownedBefore,Grant owner,
EquipmentSessions.Active aided,UUID enemy,Entity attacker,double incoming,
org.bukkit.Location targetAtHit,org.bukkit.Location attackerAtHit){
if(closed||event.isCancelled()||!Double.isFinite(event.getDamage())||event.getDamage()<=0)return;
double after=target.getAbsorptionAmount();double consumed=Math.min(ownedBefore,Math.max(0,before-after));
if(!Double.isFinite(consumed)||consumed<=0)return;
var list=grants.get(target.getUniqueId());if(list==null||owner.closed||!list.contains(owner)||!owner.execution.stillCurrent())return;
var amount=BigDecimal.valueOf(consumed).stripTrailingZeros();
try{owner.execution.report(AbilityReport.Type.PREVENTION,target,amount);}
catch(RuntimeException ignored){/* Feedback must not affect accepted absorption. */}
for(var grant:List.copyOf(list))grant.remaining=Math.max(0,grant.remaining-consumed);
list.removeIf(g->g.closed||g.remaining<=1e-9);if(list.isEmpty())grants.remove(target.getUniqueId());
if(owner.observation!=null)try{owner.observation.accept(new Accepted(target,attacker,incoming,before,after,
consumed,Math.max(0,owner.remaining),targetAtHit,attackerAtHit));}
catch(RuntimeException ignored){/* Audit must not affect native absorption or rewards. */}
if(aided!=null&&enemy!=null)supports.accept(new Support(enemy,owner.execution.input().session().character(),aided,amount));
}
private static org.bukkit.Location auditLocation(Entity entity){
if(entity==null)return null;
try{var location=entity.getLocation();return location==null?null:location.clone();}
catch(RuntimeException unavailable){return null;}
}
private boolean sameParty(Player source,Player target){var a=parties.partyOf(source.getUniqueId()).orElse(null);var b=parties.partyOf(target.getUniqueId()).orElse(null);return a!=null&&b!=null&&a.id().equals(b.id());}
private Grant strongest(UUID target){Grant result=null;var list=grants.get(target);if(list!=null)for(var grant:List.copyOf(list))if(!grant.closed&&grant.remaining>0&&grant.execution.stillCurrent()&&(result==null||grant.remaining>result.remaining||grant.remaining==result.remaining&&grant.sequence>result.sequence))result=grant;return result;}
private double owned(UUID target){double result=0;var list=grants.get(target);if(list!=null)for(var grant:List.copyOf(list))if(!grant.closed&&grant.remaining>result)result=grant.remaining;return result;}
private static Entity attacker(EntityDamageByEntityEvent event){Entity causing=event.getDamageSource().getCausingEntity();if(causing!=null)return causing;if(event.getDamager() instanceof Projectile p){ProjectileSource shooter=p.getShooter();if(shooter instanceof Entity e)return e;}return event.getDamager();}
private static void addNative(Player target,double amount){if(amount<=0)return;double current=target.getAbsorptionAmount(),next=current+amount;if(!Double.isFinite(current)||current<0||!Double.isFinite(next))throw new IllegalStateException("Temporary health exceeds native range");target.setAbsorptionAmount(next);}
private static void removeNative(Player target,double amount){if(amount<=0)return;double current=target.getAbsorptionAmount();if(Double.isFinite(current)&&current>=0)target.setAbsorptionAmount(Math.max(0,current-amount));}
@Override public void close(){if(closed)return;for(var list:List.copyOf(grants.values()))for(var grant:List.copyOf(list))grant.close();closed=true;grants.clear();}
@Override public void close(){if(closed)return;for(var list:List.copyOf(grants.values()))for(var grant:List.copyOf(list))grant.close();closed=true;grants.clear();pending.clear();}
}
@@ -256,6 +256,39 @@ public final class AbilityCastEventBridge {
} catch (RuntimeException ignored) { /* Logging cannot alter accepted native damage. */ }
}
/** Inspire reports actual accepted native absorption, not a displayed health grant. */
public void absorbed(Cast cast, UUID effectApplication, org.bukkit.entity.Player protectedTarget,
games.dmg.fantasystick.session.EquipmentSessions.Active aided, Entity attacker,
double incoming, double before, double after, double consumed, double remaining,
Location targetAtHit, Location attackerAtHit) {
if (cast == null || effectApplication == null || !Double.isFinite(consumed) || consumed <= 0) return;
try {
var data = new LinkedHashMap<String, Object>();
UUID application = UUID.randomUUID();
data.put("application_id", application.toString());
data.put("effect_application_id", effectApplication.toString());
data.put("causation_id", cast.actionId().toString());
data.put("protected_target_id", protectedTarget.getUniqueId().toString());
data.put("protected_target_type", "PLAYER");
if (aided != null) {
data.put("protected_character_id", aided.character().toString());
data.put("protected_session_id", aided.session().toString());
}
if (targetAtHit != null) data.put("protected_location", locationData(targetAtHit));
if (attacker != null) {
data.put("attacker_entity_id", attacker.getUniqueId().toString());
data.put("attacker_entity_type", entityType(attacker));
if (attackerAtHit != null) data.put("attacker_location", locationData(attackerAtHit));
} else data.put("attacker_status", "not_applicable");
data.put("incoming_amount", decimal(incoming));
data.put("absorption_before", decimal(before));
data.put("absorption_after", decimal(after));
data.put("actual_amount", decimal(consumed));
data.put("remaining_amount", decimal(remaining));
emit(cast, "combat.prevented", "accepted", data, application);
} catch (RuntimeException ignored) { /* Native absorption and party rewards are independent of logging. */ }
}
public void boosted(Cast cast, games.dmg.fantasystick.session.EquipmentSessions.Active attacking,
org.bukkit.entity.Player attacker, Entity target, double base, double bonus,
double finalDamage, java.math.BigDecimal percent) {
@@ -72,11 +72,12 @@ public final class InspireSettings implements AutoCloseable {
public Inspire.Settings settings() { return parse(effectiveValues); }
/** Publish only after the caller returns the durable acknowledgment to the server thread. */
public synchronized void publish(Update update) {
public synchronized boolean publish(Update update) {
Objects.requireNonNull(update);
if (update.sequence() <= publishedSequence) return;
if (update.sequence() <= publishedSequence) return false;
parse(update.values());
effectiveValues = update.values(); publishedSequence = update.sequence();
return true;
}
public CompletionStage<Update> set(String key, String value) {
@@ -1358,7 +1358,40 @@ public final class EquipmentAdminCommand implements TabExecutor, AutoCloseable {
});
}
private void inspireConfiguration(CommandSender sender,String[] args){String key=args[1];if(args.length==2){sender.sendMessage(key+"="+inspireSettings.value(key)+" (applies to future Inspire casts only)");return;}java.util.concurrent.CompletionStage<games.dmg.fantasystick.persistence.InspireSettings.Update> operation;try{operation=inspireSettings.set(key,args[2]);}catch(IllegalArgumentException invalid){sender.sendMessage("Inspire setting is invalid; the effective value is unchanged.");return;}operation.whenComplete((saved,failure)->{if(failure!=null)report(null,"config-"+key,failure);if(closed)return;try{nextTick.accept(()->{if(closed)return;if(failure==null){inspire.configure(saved.settings());abilities.replace(inspire.definition());inspireSettings.publish(saved);}if(!sender.hasPermission(PERMISSION)||sender instanceof org.bukkit.entity.Player player&&!player.isOnline())return;sender.sendMessage(failure==null?"Saved "+key+"="+saved.value()+" for future Inspire casts; active effects and deadlines are unchanged.":"Inspire configuration save failed; the effective setting is unchanged.");});}catch(RuntimeException rejected){report(null,"config-response",rejected);}});}
private void inspireConfiguration(CommandSender sender, String[] args) {
String key = args[1];
var actor = abilityConfigEvents == null ? null : abilityConfigEvents.capture(sender);
String before = inspireSettings.value(key);
if (args.length == 2) {
if (abilityConfigEvents != null) abilityConfigEvents.read(actor, "inspire", key, before);
sender.sendMessage(key + "=" + before + " (applies to future Inspire casts only)"); return;
}
java.util.concurrent.CompletionStage<games.dmg.fantasystick.persistence.InspireSettings.Update> operation;
try { operation = inspireSettings.set(key, args[2]); }
catch (IllegalArgumentException invalid) {
sender.sendMessage("Inspire setting is invalid; the effective value is unchanged."); return;
}
operation.whenComplete((saved, failure) -> {
if (failure != null) report(null, "config-" + key, failure);
if (closed) return;
try { nextTick.accept(() -> {
if (closed) return;
String effectiveBefore = failure == null ? inspireSettings.value(key) : null;
boolean applied = failure == null && inspireSettings.publish(saved);
if (applied) {
inspire.configure(inspireSettings.settings()); abilities.replace(inspire.definition());
if (abilityConfigEvents != null)
abilityConfigEvents.changed(actor, "inspire", key, effectiveBefore, saved.value());
}
if (!sender.hasPermission(PERMISSION)
|| sender instanceof org.bukkit.entity.Player player && !player.isOnline()) return;
sender.sendMessage(failure != null
? "Inspire configuration save failed; the effective setting is unchanged."
: applied ? "Saved " + key + "=" + saved.value() + " for future Inspire casts; active effects and deadlines are unchanged."
: "Saved request was superseded; effective " + key + "=" + inspireSettings.value(key) + ".");
}); } catch (RuntimeException rejected) { report(null, "config-response", rejected); }
});
}
private void mendingLightConfiguration(CommandSender sender, String[] args) {
String key = args[1];