feat(events): audit Health Steal final-blow journeys
Release / release (push) Failing after 10m36s

This commit is contained in:
dmg committed 2026-10-01 01:11:10 -04:00
1 parent 908b0b02aa
commit 03c121287c
9 files changed
+560 -26

No files matched your search

@@ -159,6 +159,8 @@ public final class FantasyStickPlugin extends JavaPlugin {
private games.dmg.fantasystick.passive.QuickerRegenerationII quickerRegenerationII;
private games.dmg.fantasystick.persistence.HealthStealSettings healthStealSettings;
private games.dmg.fantasystick.passive.HealthSteal healthSteal;
private games.dmg.fantasystick.events.HealthStealEventBridge healthStealEvents;
private java.util.concurrent.CompletionStage<Void> healthStealAuditDrain = java.util.concurrent.CompletableFuture.completedFuture(null);
private games.dmg.fantasystick.passive.SpeedI speedI;
private games.dmg.fantasystick.passive.LowLightVision lowLightVision;
private games.dmg.fantasystick.passive.PassiveRegistry passiveRegistry;
@@ -864,6 +866,10 @@ public final class FantasyStickPlugin extends JavaPlugin {
abilityEngine.enableCastEventsFor("meteor");
admin.attachAbilityConfigEvents(new games.dmg.fantasystick.events.AbilityConfigEventBridge(eventLog::emit, Clock.systemUTC()));
passiveEvents = new games.dmg.fantasystick.events.PassiveEventBridge(eventLog::emit, Clock.systemUTC());books.attachPassiveEvents(passiveEvents);admin.attachPassiveEvents(passiveEvents);
healthStealEvents = new games.dmg.fantasystick.events.HealthStealEventBridge(
eventLog::emit, Clock.systemUTC(), getDataFolder().toPath(),
failure -> getLogger().log(Level.WARNING, "Health Steal event intent failed", failure));
healthSteal.attachEvents(healthStealEvents);
recoveryEvents = new games.dmg.fantasystick.events.RecoveryEventBridge(
eventLog::emit, Clock.systemUTC(), getDataFolder().toPath(), sessions,
failure -> getLogger().log(Level.WARNING, "Recovery event intent failed", failure));
@@ -1049,6 +1055,11 @@ public final class FantasyStickPlugin extends JavaPlugin {
if (failure != null) getLogger().log(Level.WARNING, "Previous admin experience intent drain failed", failure);
if (replayGrantEvents != null) replayGrantEvents.replay();
});
var replayHealthStealEvents = healthStealEvents;
healthStealAuditDrain.whenComplete((ignored, failure) -> {
if (failure != null) getLogger().log(Level.WARNING, "Previous Health Steal event drain failed", failure);
if (replayHealthStealEvents != null) replayHealthStealEvents.replay();
});
var replayRecoveryEvents = recoveryEvents;
recoveryAuditDrain.whenComplete((ignored, failure) -> {
if (failure != null) getLogger().log(Level.WARNING, "Previous recovery event intent drain failed", failure);
@@ -1137,6 +1148,7 @@ public final class FantasyStickPlugin extends JavaPlugin {
var closingPartyCapacityEvents = partyCapacityEvents; partyCapacityEvents = null;
var closingSheetPackEvents = sheetResourcePackEvents; sheetResourcePackEvents = null;
var closingGrantEvents = adminExperienceEvents; adminExperienceEvents = null;
var closingHealthStealEvents = healthStealEvents; healthStealEvents = null;
var closingRecoveryEvents = recoveryEvents; recoveryEvents = null;
var closingIdentityAuditEvents = identityAuditEvents; identityAuditEvents = null;
var closingAdminRevivalAuditEvents = adminRevivalEvents; adminRevivalEvents = null;
@@ -1499,6 +1511,14 @@ public final class FantasyStickPlugin extends JavaPlugin {
return null;
}).thenCompose(ignored -> closingGrantEvents.drained());
});
if (closingHealthStealEvents != null) cleanup("Health Steal event intent drain", () -> {
var storageDrained = closingCharacters == null
? java.util.concurrent.CompletableFuture.<Void>completedFuture(null) : closingCharacters.drained();
healthStealAuditDrain = storageDrained.handle((ignored, failure) -> {
if (failure != null) getLogger().log(Level.WARNING, "Character storage drain failed", failure);
closingHealthStealEvents.close(); return null;
}).thenCompose(ignored -> closingHealthStealEvents.drained());
});
if (closingRecoveryEvents != null) cleanup("recovery event intent drain", () -> {
var settingsDrained = closingOutOfCombatRecoverySettings == null
? java.util.concurrent.CompletableFuture.<Void>completedFuture(null)
@@ -897,7 +897,8 @@ public final class CharacterBookController implements Consumer<ControlInput>, Au
|| !(event.getCommonConnection() instanceof io.papermc.paper.connection.PlayerGameConnection connection)
|| event.getTag() == null) return;
var player=connection.getPlayer();String raw=event.getTag().string();if(raw.length()>120)return;var match=ABILITY_PAYLOAD.matcher(raw);if(!match.matches())return;String passive=match.group(2);var definition=passives.find(passive).orElse(null);if(definition==null)return;var view=passiveViews.get(player.getUniqueId());boolean owned=games.dmg.fantasystick.passive.QuickerRegenerationI.ID.equals(passive)
|| games.dmg.fantasystick.passive.QuickerRegenerationII.ID.equals(passive);
|| games.dmg.fantasystick.passive.QuickerRegenerationII.ID.equals(passive)
|| games.dmg.fantasystick.passive.HealthSteal.ID.equals(passive);
if (view == null || view.input().player() != player || !view.nonce().equals(match.group(1)) || !view.ids().contains(passive)
|| !passiveViews.remove(player.getUniqueId(), view) || !view.input().stillCurrent()) {if(owned)refusePassive(player,definition,unlock,"stale_forged_or_repeated_action");return;}
var audit=owned&&passiveEvents!=null?passiveEvents.begin(view.input(),view.before(),definition,unlock):null;
@@ -0,0 +1,141 @@
package games.dmg.fantasystick.events;
import games.dmg.fantasystick.persistence.CharacterRecord;
import games.dmg.fantasystick.session.EquipmentSessions;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.nio.charset.StandardCharsets;
import java.nio.file.Path;
import java.time.Clock;
import java.time.Instant;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Objects;
import java.util.UUID;
import java.util.concurrent.CompletionStage;
import java.util.function.Consumer;
import java.util.function.Function;
import org.bukkit.Location;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.event.entity.EntityDamageEvent;
/** Audit-only final-blow snapshots; replaying a heal intent never invokes gameplay. */
public final class HealthStealEventBridge implements AutoCloseable {
public record Damage(UUID id, Instant time, UUID target, String targetType,
UUID directEntity, String cause, String amount, EventInput.Location location) { }
public record Action(UUID id, Damage damage, EventInput.Context context, EventInput.Location targetLocation,
UUID targetCharacter, UUID targetSession, BigInteger configured, BigDecimal requested,
CharacterRecord before, BigDecimal healthBefore, BigDecimal maximum) { }
private final Consumer<EventInput> sink;
private final Clock clock;
private final FeatureEventOutbox outbox;
public HealthStealEventBridge(Consumer<EventInput> sink, Clock clock) {
this.sink = Objects.requireNonNull(sink); this.clock = Objects.requireNonNull(clock); outbox = null;
}
public HealthStealEventBridge(Function<EventInput, CompletionStage<LocalEventLog.Delivery>> sink,
Clock clock, Path data, Consumer<Throwable> failures) {
this.sink = event -> sink.apply(event); this.clock = Objects.requireNonNull(clock);
outbox = new FeatureEventOutbox(data, "health-steal-event-intents", java.util.Set.of("combat.healed"), sink, failures);
}
/** Called only for an already accepted lethal candidate, before its native death callback. */
public Damage damage(EntityDamageEvent event) {
try {
var target = event.getEntity(); var direct = event.getDamageSource().getDirectEntity();
if (direct == null && event instanceof org.bukkit.event.entity.EntityDamageByEntityEvent byEntity)
direct = byEntity.getDamager();
return new Damage(UUID.randomUUID(), clock.instant(), target.getUniqueId(),
target instanceof Player ? "PLAYER" : target.getType().name(), direct == null ? null : direct.getUniqueId(),
event.getCause().name(), Double.toString(event.getFinalDamage()), location(target.getLocation()));
} catch (RuntimeException unavailable) { return null; }
}
public Action begin(Damage damage, LivingEntity target, Player player, EquipmentSessions.Active active,
CharacterRecord before, EquipmentSessions.Active targetActive,
BigInteger configured, double requested, double current, double maximum) {
if (damage == null) return null;
try {
var context = new EventInput.Context(player.getUniqueId(), player.getName(), active.character(),
before.name(), active.session(), location(player.getLocation()));
var action = new Action(id(damage.id(), "defeat"), damage, context, location(target.getLocation()),
targetActive == null ? null : targetActive.character(), targetActive == null ? null : targetActive.session(),
configured, BigDecimal.valueOf(requested), before, BigDecimal.valueOf(current), BigDecimal.valueOf(maximum));
emit("action.observed", action, "observed", null, before, null, action.healthBefore(), null, action.maximum(), null);
return action;
} catch (RuntimeException unavailable) { return null; }
}
public void refused(Action action, String reason) {
if (action != null) emit("action.resolved", action, "refused", reason, action.before(), null,
action.healthBefore(), null, action.maximum(), null);
}
public void failed(Action action, String reason) {
if (action != null) emit("action.resolved", action, "failed", reason, action.before(), null,
action.healthBefore(), null, action.maximum(), null);
}
public void healed(Action action, CharacterRecord before, CharacterRecord after,
double nativeBefore, double nativeAfter, double maximum, double accepted) {
if (action == null) return;
var prior = BigDecimal.valueOf(nativeBefore); var next = BigDecimal.valueOf(nativeAfter);
var limit = BigDecimal.valueOf(maximum); var amount = BigDecimal.valueOf(accepted);
emit("action.resolved", action, "accepted", "native_health_acknowledged", before, after, prior, next, limit, amount);
emit("combat.healed", action, "accepted", "native_health_acknowledged", before, after, prior, next, limit, amount);
}
private void emit(String type, Action action, String outcome, String reason, CharacterRecord before,
CharacterRecord after, BigDecimal prior, BigDecimal next, BigDecimal maximum, BigDecimal accepted) {
try {
var data = new LinkedHashMap<String, Object>(); var damage = action.damage();
data.put("action_kind", "health_steal_final_blow"); data.put("passive_id", "health_steal");
data.put("healing_source", "health_steal"); data.put("defeat_id", action.id().toString());
data.put("damage_causation_id", damage.id().toString()); data.put("damage_accepted_at", damage.time().toString());
data.put("damage_cause", damage.cause()); data.put("damage_amount", damage.amount());
data.put("target_id", damage.target().toString()); data.put("target_type", damage.targetType());
if (damage.directEntity() != null) data.put("direct_entity_id", damage.directEntity().toString());
if (damage.location() != null) data.put("damage_target_location", values(damage.location()));
if (action.targetLocation() != null) data.put("target_location", values(action.targetLocation()));
data.put("target_location_capture_quality", action.targetLocation() == null ? "unavailable" : "exact");
data.put("location_capture_quality", action.context().location() == null ? "unavailable" : "exact");
if (action.targetCharacter() != null) {
data.put("target_character_id", action.targetCharacter().toString());
data.put("target_session_id", action.targetSession().toString());
}
data.put("defeat_consumption", "consumed_once"); data.put("configured_amount", action.configured().toString());
data.put("requested_amount", action.requested().toPlainString()); data.put("health_before", prior.toPlainString());
data.put("maximum_health", maximum.toPlainString()); data.put("before_revision", before.revision().toString());
data.put("points_before", before.unspentPoints().toString()); data.put("outcome", outcome);
if (reason != null) data.put("reason", reason);
if (after != null && next != null) {
data.put("health_after", next.toPlainString()); data.put("final_amount", next.subtract(prior).toPlainString());
data.put("native_accepted_amount", accepted.toPlainString()); data.put("persisted_health", after.health().toPlainString());
data.put("after_revision", after.revision().toString()); data.put("points_after", after.unspentPoints().toString());
data.put("native_publication", "acknowledged");
}
var event = new EventInput(id(action.id(), type), action.id(), clock.instant(), type, action.context(), Map.copyOf(data));
if (type.equals("combat.healed") && outbox != null) outbox.accepted(event); else sink.accept(event);
} catch (RuntimeException ignored) { /* Audit failure cannot authorize another defeat, save or native heal. */ }
}
private EventInput.Location location(Location value) {
try {
if (value == null || value.getWorld() == null) return null;
return new EventInput.Location(value.getWorld().getUID(), value.getWorld().getName(), value.getX(), value.getY(),
value.getZ(), clock.instant(), "exact");
} catch (RuntimeException unavailable) { return null; }
}
private static Map<String, Object> values(EventInput.Location location) {
return Map.of("world_id", location.worldId().toString(), "world_name", location.worldName(),
"x", location.x(), "y", location.y(), "z", location.z(), "captured_at", location.capturedAt().toString(),
"quality", location.quality());
}
private static UUID id(UUID operation, String type) {
return UUID.nameUUIDFromBytes(("fantasystick:health-steal:" + operation + ":" + type).getBytes(StandardCharsets.UTF_8));
}
public void replay() { if (outbox != null) outbox.replay(); }
public CompletionStage<Void> drained() {
return outbox == null ? java.util.concurrent.CompletableFuture.completedFuture(null) : outbox.drained();
}
@Override public void close() { if (outbox != null) outbox.close(); }
}
@@ -31,7 +31,10 @@ public final class PassiveEventBridge {
private void emit(String type,Action action,String outcome,String reason,CharacterRecord after){var before=action.before();var data=new LinkedHashMap<String,Object>();data.put("action_kind",action.learn()?"passive_learn":"passive_unlearn");data.put("passive_id",action.passive());data.put("expected_revision",before.revision().toString());data.put("before_revision",before.revision().toString());data.put("points_before",before.unspentPoints().toString());data.put("point_cost",action.definition().pointCost().toString());var requirements=new LinkedHashMap<String,Object>();action.definition().requirements().entrySet().stream().sorted(Map.Entry.comparingByKey()).forEach(entry->requirements.put(entry.getKey().name(),entry.getValue().toString()));data.put("stat_prerequisites",requirements);var statValues=new LinkedHashMap<String,Object>();action.definition().requirements().keySet().stream().sorted().forEach(stat->{var value=before.stats().get(stat);if(value!=null)statValues.put(stat.name(),value.toString());});data.put("stat_values_before",statValues);data.put("passive_slots_before",before.passives());data.put("passive_prerequisites",action.definition().prerequisites().stream().sorted().toList());data.put("outcome",outcome);if(after!=null){data.put("after_revision",after.revision().toString());data.put("points_after",after.unspentPoints().toString());data.put("passive_slots_after",after.passives());int slot=(action.learn()?after.passives():before.passives()).indexOf(action.passive());data.put("passive_slot",slot);data.put("slot_index_base",0);data.put("native_publication","acknowledged");data.put("owned_cleanup",action.learn()?"passive_state_acknowledged":"passive_state_acknowledged");}if(reason!=null)data.put(type.startsWith("passive.")?"native_boundary":"reason",reason);try{sink.accept(new EventInput(id(action.actionId(),type),action.actionId(),clock.instant(),type,action.context(),Map.copyOf(data)));}catch(RuntimeException ignored){}
}
private void config(String type,String actorKind,UUID player,String playerName,String key,String before,String after){var action=UUID.randomUUID();var data=new LinkedHashMap<String,Object>();data.put("actor_kind",actorKind);if(player!=null)data.put("actor_player_id",player.toString());if(playerName!=null)data.put("actor_player_name",playerName);data.put("key",key);if(before!=null)data.put("before",before);data.put("after",after);data.put("application","future_recovery_pulses");data.put("outcome","acknowledged");var context=player==null?null:new EventInput.Context(player,playerName,null,null,null,null);try{sink.accept(new EventInput(id(action,type),action,clock.instant(),type,context,Map.copyOf(data)));}catch(RuntimeException ignored){}
public void configRead(String actorKind,UUID player,String playerName,String key,String value,String application){config("config.read",actorKind,player,playerName,key,null,value,application);}
public void configChanged(String actorKind,UUID player,String playerName,String key,String before,String after,String application){config("config.changed",actorKind,player,playerName,key,before,after,application);}
private void config(String type,String actorKind,UUID player,String playerName,String key,String before,String after){config(type,actorKind,player,playerName,key,before,after,"future_recovery_pulses");}
private void config(String type,String actorKind,UUID player,String playerName,String key,String before,String after,String application){var action=UUID.randomUUID();var data=new LinkedHashMap<String,Object>();data.put("actor_kind",actorKind);if(player!=null)data.put("actor_player_id",player.toString());if(playerName!=null)data.put("actor_player_name",playerName);data.put("key",key);if(before!=null)data.put("before",before);data.put("after",after);data.put("application",application);data.put("outcome","acknowledged");var context=player==null?null:new EventInput.Context(player,playerName,null,null,null,null);try{sink.accept(new EventInput(id(action,type),action,clock.instant(),type,context,Map.copyOf(data)));}catch(RuntimeException ignored){}
}
private EventInput.Context context(org.bukkit.entity.Player player,EquipmentSessions.Active active,String name){return new EventInput.Context(player.getUniqueId(),player.getName(),active.character(),name,active.session(),location(player.getLocation()));}
private EventInput.Location location(Location value){return new EventInput.Location(value.getWorld().getUID(),value.getWorld().getName(),value.getX(),value.getY(),value.getZ(),clock.instant(),"exact");}
@@ -1,6 +1,7 @@
package games.dmg.fantasystick.passive;
import games.dmg.fantasystick.ability.AbilityReport;
import games.dmg.fantasystick.events.HealthStealEventBridge;
import games.dmg.fantasystick.party.CombatSources;
import games.dmg.fantasystick.presentation.CombatFeedback;
import games.dmg.fantasystick.persistence.CharacterRecord;
@@ -46,8 +47,8 @@ public final class HealthSteal implements Listener, AutoCloseable {
public static Settings defaults() { return new Settings(BigInteger.ONE); }
}
public record Failure(UUID character, Throwable cause) { }
private record Candidate(LivingEntity target, CombatSources.Origin origin) { }
private record Heal(EquipmentSessions.Active active, double amount) { }
private record Candidate(LivingEntity target, CombatSources.Origin origin, HealthStealEventBridge.Damage audit) { }
private record Heal(EquipmentSessions.Active active, double amount, HealthStealEventBridge.Action audit) { }
private final CharacterStorage characters;
private final EquipmentSessions sessions;
@@ -80,6 +81,11 @@ public final class HealthSteal implements Listener, AutoCloseable {
this.failures = Objects.requireNonNull(failures); this.feedback = feedback; sources = new CombatSources(sessions);
}
private HealthStealEventBridge events;
public void attachEvents(HealthStealEventBridge bridge) {
if (closed || events != null || !lethal.isEmpty() || !pending.isEmpty()) throw new IllegalStateException("Health Steal events already attached or evaluation started");
events = Objects.requireNonNull(bridge);
}
public void configure(Settings value) { settings = Objects.requireNonNull(value); }
public BigInteger healing() { return settings.healing(); }
public PassiveDefinition definition() {
@@ -102,7 +108,7 @@ public final class HealthSteal implements Listener, AutoCloseable {
|| event.getFinalDamage() < remaining) {
lethal.remove(targetId); return;
}
lethal.put(targetId, new Candidate(target, origin));
lethal.put(targetId, new Candidate(target, origin, events == null ? null : events.damage(event)));
}
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
@@ -151,58 +157,75 @@ public final class HealthSteal implements Listener, AutoCloseable {
double amount = configured.bitLength() > 1023 ? maximum - current - reserved : configured.doubleValue();
double proposed = Math.min(maximum - current - reserved, amount);
if (!Double.isFinite(current) || !Double.isFinite(maximum) || current < 0 || maximum <= 0
|| !Double.isFinite(proposed) || proposed <= 0) return;
|| !Double.isFinite(proposed)) return;
var audit = events == null ? null : events.begin(candidate.audit(), target, player, active, record,
target instanceof Player ? sessions.active(target.getUniqueId()).orElse(null) : null,
configured, proposed, current, maximum);
if (proposed <= 0) { if (events != null) events.refused(audit, "full_health_or_no_available_capacity"); return; }
var healing = new EntityRegainHealthEvent(player, proposed, EntityRegainHealthEvent.RegainReason.CUSTOM);
healingEvents.accept(healing);
try { healingEvents.accept(healing); }
catch (RuntimeException failure) { if (events != null) events.failed(audit, "native_healing_validation_failed"); throw failure; }
double accepted = Math.min(proposed, Math.min(maximum - current - reserved, healing.getAmount()));
if (healing.isCancelled() || !Double.isFinite(accepted) || accepted <= 0) return;
if (healing.isCancelled() || !Double.isFinite(accepted) || accepted <= 0) {
if (events != null) events.refused(audit, healing.isCancelled() ? "native_event_cancelled" : "no_positive_healing_accepted"); return;
}
var queue = pending.computeIfAbsent(active.character(), ignored -> new ArrayDeque<>());
if (queue.size() >= MAX_PENDING_PER_CHARACTER) return;
queue.addLast(new Heal(active, accepted));
if (queue.size() >= MAX_PENDING_PER_CHARACTER) { if (events != null) events.refused(audit, "pending_heal_capacity"); return; }
queue.addLast(new Heal(active, accepted, audit));
if (queue.size() == 1) attempt(active.character());
}
private void attempt(UUID character) {
var queue = pending.get(character); var operation = queue == null ? null : queue.peekFirst();
if (closed || operation == null) return;
if (!sessions.current(operation.active())) { finish(character); return; }
if (!sessions.current(operation.active())) { auditFailed(operation, "source_session_changed"); finish(character); return; }
var record = sessions.currentRecord(operation.active()).orElse(null);
var player = sessions.currentPlayer(operation.active()).orElse(null);
if (record == null || player == null || record.dead() || !record.passives().contains(ID)) { finish(character); return; }
if (record == null || player == null || record.dead() || !record.passives().contains(ID)) {
auditFailed(operation, "character_unavailable_or_passive_removed"); finish(character); return;
}
double nativeBefore = player.getHealth();
BigDecimal target = record.health().add(BigDecimal.valueOf(operation.amount()));
BigDecimal limit;
try { limit = nativeLimit.get(); }
catch (RuntimeException failure) { report(character, failure); finish(character); return; }
catch (RuntimeException failure) { auditFailed(operation, "native_health_limit_unavailable"); report(character, failure); finish(character); return; }
BigInteger expected = record.revision();
characters.saveHealth(character, expected, target, limit).whenComplete((saved, failure) -> {
try { nextTick.accept(() -> complete(character, operation, expected, nativeBefore, saved, failure)); }
catch (RuntimeException rejected) { report(character, rejected); }
try { nextTick.accept(() -> complete(character, operation, expected, record, nativeBefore, saved, failure)); }
catch (RuntimeException rejected) { auditFailed(operation, "scheduler_rejected_after_save_uncertain"); report(character, rejected); }
});
}
private void complete(UUID character, Heal operation, BigInteger expected, double nativeBefore,
private void complete(UUID character, Heal operation, BigInteger expected, CharacterRecord before, double nativeBefore,
java.util.Optional<CharacterRecord> saved, Throwable failure) {
try {
if (closed || failure != null || saved == null || saved.isEmpty()) {
auditFailed(operation, closed ? "closed_after_save" : failure != null ? "health_save_failed" : "character_unavailable");
if (failure != null) report(character, failure); return;
}
var record = saved.orElseThrow();
if (!sessions.current(operation.active())
|| !sessions.acknowledgeProgress(operation.active(), expected, record)) return;
|| !sessions.acknowledgeProgress(operation.active(), expected, record)) {
auditFailed(operation, "saved_but_session_publication_refused"); return;
}
var player = sessions.currentPlayer(operation.active()).orElse(null);
if (player == null || Double.compare(player.getHealth(), nativeBefore) != 0) return;
if (player == null || Double.compare(player.getHealth(), nativeBefore) != 0) {
auditFailed(operation, "saved_but_native_health_changed"); return;
}
var attribute = player.getAttribute(Attribute.MAX_HEALTH);
if (attribute == null) return;
if (attribute == null) { auditFailed(operation, "saved_but_maximum_health_unavailable"); return; }
double maximum = Math.min(attribute.getValue(), record.maximumHealth().doubleValue());
double publish = Math.min(maximum, record.health().doubleValue());
if (Double.isFinite(maximum) && Double.isFinite(publish) && publish > nativeBefore) {
player.setHealth(publish);
try { player.setHealth(publish); }
catch (RuntimeException nativeFailure) { auditFailed(operation, "native_health_publication_failed"); throw nativeFailure; }
if (events != null) events.healed(operation.audit(), before, record, nativeBefore, publish, maximum, operation.amount());
if (feedback != null) feedback.report("Health Steal", player, AbilityReport.Type.HEALING, player,
BigDecimal.valueOf(publish - nativeBefore).stripTrailingZeros());
}
} else auditFailed(operation, "saved_but_no_positive_native_heal");
} finally { finish(character); }
}
private void auditFailed(Heal operation, String reason) { if (events != null) events.failed(operation.audit(), reason); }
private void finish(UUID character) {
var queue = pending.get(character);
@@ -1320,9 +1320,15 @@ public final class EquipmentAdminCommand implements TabExecutor, AutoCloseable {
}
private void healthStealConfiguration(CommandSender sender, String[] args) {
String key = games.dmg.fantasystick.persistence.HealthStealSettings.KEY;
String before = healthStealSettings.value();
String actorKind = sender instanceof org.bukkit.entity.Player ? "player"
: sender instanceof org.bukkit.command.BlockCommandSender ? "command_block" : "console";
UUID actorPlayer = sender instanceof org.bukkit.entity.Player player ? player.getUniqueId() : null;
String actorName = sender instanceof org.bukkit.entity.Player ? sender.getName() : null;
if (args.length == 2) {
sender.sendMessage(games.dmg.fantasystick.persistence.HealthStealSettings.KEY + "="
+ healthStealSettings.value() + " (applies to later qualifying final blows only)"); return;
if (passiveEvents != null) passiveEvents.configRead(actorKind, actorPlayer, actorName, key, before, "future_qualifying_defeats");
sender.sendMessage(key + "=" + before + " (applies to later qualifying final blows only)"); return;
}
java.util.concurrent.CompletionStage<games.dmg.fantasystick.persistence.HealthStealSettings.Update> operation;
try { operation = healthStealSettings.set(args[2]); }
@@ -1335,7 +1341,10 @@ public final class EquipmentAdminCommand implements TabExecutor, AutoCloseable {
if (closed) return; boolean applied = false;
if (failure == null) {
applied = healthStealSettings.publish(saved);
if (applied) { healthSteal.configure(saved.settings()); passiveRegistry.replace(healthSteal.definition()); }
if (applied) {
healthSteal.configure(saved.settings()); passiveRegistry.replace(healthSteal.definition());
if (passiveEvents != null) passiveEvents.configChanged(actorKind, actorPlayer, actorName, key, before, saved.value(), "future_qualifying_defeats");
}
}
if (!sender.hasPermission(PERMISSION)
|| sender instanceof org.bukkit.entity.Player player && !player.isOnline()) return;