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
#
# 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 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
<dependencies>
<dependency>
<groupId>net.sparkomc</groupId>
<artifactId>combatx</artifactId>
<version>1.0</version>
<scope>system</scope>
<systemPath>${basedir}/libs/[file name]</systemPath>
</dependency>
</dependencies>
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
@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.
@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:
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<Player> 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:
public class YourCustomDurationCalculator implements DurationCalculator {
@Override
public int calculate(Player suspect) {
int duration = Your calculation logic...;
return duration;
}
}
and then:
CombatManager.setDurationCalculator(new YourCustomDurationCalculator());
About CombatManager
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
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!
Information
Category | Developer Tools |
---|---|
Published on | March 8, 2024 |
License | Unspecified |
Downloads | 72 |
Stars | 0 |
Watchers | 0 |