Complete US-012 with consent-based player parties, lifecycle rules, session-bound book controls and current-session native damage protection. Preserve the existing approved inventory/input and read-only book prerequisites without claiming their broader stories complete. Verify 516 tests with clean and versioned builds; scoped Semgrep and npm audit report no findings. No deployment changes.
32 lines
1.4 KiB
Java
32 lines
1.4 KiB
Java
package games.dmg.fantasystick.session;
|
|
|
|
import java.util.Objects;
|
|
import java.util.function.BooleanSupplier;
|
|
import org.bukkit.entity.Entity;
|
|
import org.bukkit.entity.Player;
|
|
|
|
/**
|
|
* Internal server-thread input port for book/combat/ability adapters, not an add-on API.
|
|
* Containment of vanilla item behavior is separate from executing an ability. Recipients
|
|
* must revalidate after deferred work; this notification is never durable cast authority.
|
|
*/
|
|
public record ControlInput(Player player, EquipmentSessions.Active session, int slot, String ability,
|
|
Kind kind, Gesture gesture, Entity target, int heldTicks, float attackStrength,
|
|
BooleanSupplier validity) {
|
|
public enum Kind { BOOK, BASIC_ATTACK, ABILITY }
|
|
public enum Gesture { USE, ATTACK, DRAW_RELEASE }
|
|
|
|
public ControlInput {
|
|
Objects.requireNonNull(player);
|
|
Objects.requireNonNull(session);
|
|
Objects.requireNonNull(ability);
|
|
Objects.requireNonNull(kind);
|
|
Objects.requireNonNull(gesture);
|
|
Objects.requireNonNull(validity);
|
|
if (slot < 0 || slot > 8 || heldTicks < 0 || !Float.isFinite(attackStrength)
|
|
|| attackStrength < 0 || attackStrength > 1) throw new IllegalArgumentException("Invalid control input");
|
|
}
|
|
|
|
public boolean stillCurrent() { return validity.getAsBoolean(); }
|
|
}
|