HomeJavaModsCombatX
CombatX
ModsJava

CombatX

A simple Combat Management API for developers

⬇ Download on HangarOpen in MCModsHubGet it on Google Play →
## CombatX **Personally tested version: 1.13, 1.18.2** **Theoretically supports: 1.8.9 - 1.20.4** CombatX will make your combat management more concise. We have added various monitoring for player PVP, such as: player entering combat status, combat status duration, player out of combat status, player attacks player event, player quit event during combat, player death event, etc. **Most of the functionality of this plugin is used as an API, but you can still use it as a functional plugin.** About **Configuration** Most of the usage methods to use the plugin as a functional plugin are introduced in config.yml. config.yml ```yaml # # DO NOT TOUCH THIS # Unless there is a message on the console prompting you to update config.yml version. # config-version: 1 # # Should we check your plugin version on startup? # update-checker: true combat: # # How should we calculate the duration of combat status? # - OVERLAY - This rule will add 2 seconds to the duration of the player's # current combat state every time a player attacks another player. # - STABLE - Always fixed combat state duration to 10 seconds. # # You can also use the API of this plugin to extend the calculation rules. # combat-duration-calculation-rule: OVERLAY # # Action while some conditions are triggered. # - [message] - Send a message to the player. e.g. "[message] Hello!" # - [command-console] - Run a command as console. e.g. "[command-console] say I'm console!" # - [command-player] - Run a command as the player. e.g. "[command-player] say I'm fighting!" # The "/" before the command is not needed. # You can also use placeholders: # - {player} - The player who triggered the condition. # trigger-combat-status: action: - "[message] &cYou are now in combat! Do not leave." out-of-combat-status: action: - "[message] &aYou are now out of combat!" combat-status-quit: action: - "[command-console] clear {player}" ``` ### Support Before reporting a bug, please check that your plugin is up to date, as the issue you are about to report may have been fixed in the latest version. Please don't report bugs in reviews or you won't get any support! Join our [**Discord Server**](https://discord.gg/ndxxaxxx) to get supports. Since the author is in school on weekdays, your problem may not be solved in time, please understand! **Don't forget to leave 5 stars in the review!** ### About API I haven't uploaded the API to the Maven central repository yet, in the meantime you can import it as a local dependency into the project. First you can create the "libs" folder in the project root directory. Then add the following content in pom.xml ```xml net.sparkomc combatx 1.0 system ${basedir}/libs/[file name] ``` Please replace [file name] with the jar name you downloaded ### API Usage **PlayerCombatStatusEvent** - Player enter combat status **PlayerOutOfCombatStatusEvent** - Player combat duration expired **PlayerCombatQuitEvent** - Player quit game while in combat status **PlayerDiedEvent** - Trigger when a player is died ```java @EventHandler public void onDied(PlayerDiedEvent e) { Player player = e.getPlayer(); DamageRecorder recorder = e.getRecorder(); // If the player last received damage from a player for more than 10 seconds or the player died unnaturally, the killer will be null Player killer = e.getKiller(); } ``` **PlayerDamageByPlayerEvent** - An event in which a player is harmed by a player. Supports projectile thrown by players. ```java @EventHandler public void onPlayerDamageByPlayer(PlayerDamageByPlayerEvent e) { Player suspect = e.getSuspect(); Player victim = e.getPlayer(); } ``` About **DamageRecorder** DamageRecorder is used to record the source and value of the damage received by the player, time, whether it is dead, etc. Example method: ```java public void testMethod() { Player player = ...; DamageRecorder recorder = ...; // Damage a player at specified damage (Not physical damage, just record) recorder.damage(player, 1.5); // Get the killer of the player. // If player is not dead, it will throw IllegalStateException // If no one damage him, it will return null Player killer = recorder.getKiller(); // Get the assists of the player (not including killer) // If player is not dead, it will throw IllegalStateException // If no one damage him except the killer, or beside the killer, it will return null List assists = recorder.getAssists(); // Get the total damage of the player got double totalDamage = recorder.getTotalDamage(); // Get the damage caused by the specified player to the player double damage = recorder.getTotalDamage(killer); // Make the player die (Not physical die, just record) recorder.die(); // Get whether the player is dead boolean died = recorder.isDied(); // Get the timestamp of the last time this player took damage long lastDamageTime = recorder.getLastDamageTime(); } ``` About **DamageCalculator** To extend your own combat state duration calculation logic, you can: ```java public class YourCustomDurationCalculator implements DurationCalculator { @Override public int calculate(Player suspect) { int duration = Your calculation logic...; return duration; } } ``` and then: ```java CombatManager.setDurationCalculator(new YourCustomDurationCalculator()); ``` About **CombatManager** ```java public void testMethod() { Player player = ...; // Check if a player is in combat boolean combat = CombatManager.isInCombat(player); // Reset a player's combat record CombatManager.resetCombat(player); // Get the CombatInfo of the player CombatInfo info = CombatManager.getCombatInfo(player); } ``` About **CombatInfo** ```java public void testMethod() { Player player = ...; // Get CombatInfo CombatInfo info = CombatManager.getCombatInfo(player); // Get the DamageRecorder of a player DamageRecorder recorder = info.getRecorder(); // Attack a player (Not physical attack, just record) info.attack(VICTIM, 2); } ``` Thank for using CombatX!

CombatX is a free Minecraft Java mod. Compatible with Minecraft 1.10, 1.10.1, 1.10.2, 1.11 and newer. Downloaded 257 times (via Hangar). Download it and open it directly in the game.

Explore more