A damage summary module
Collections, a local class and global bridge results.
Module source
This demonstrates Java collections and bridge variables; it is not a complete combat system. Save it as plugins/Skript/scripts/modules/combat_core.jv.
class Hit {
final String source;
final double damage;
Hit(String source, double damage) {
this.source = source;
this.damage = damage;
}
}
List<Hit> hits = List.of(new Hit("Zombie", 4.5), new Hit("Skeleton", 3.0));
double total = hits.stream().mapToDouble(hit -> hit.damage).sum();
setVar("combat_total_damage", total);
setVar("combat_hit_count", hits.size());
sender.sendMessage("Total damage: " + total);
Run from Skript
command /combat:
trigger:
run jv "modules/combat_core.jv"
send "Total: %{combat_total_damage}%" to sender
Wait for readiness after reloading the script before invoking the command. If the module is pending or fails, the following send does not run in that invocation.
Result scopes
Unprefixed names are global. To keep results within this event, use _combat_total_damage and _combat_hit_count on both sides of the bridge.
This example does not claim separate live-server validation. Test it with your own configuration before using it for gameplay.