By continuing to use this site, you agree to the Terms of Service of this website, including usage of cookies.
OK, Don't show this again
This plugin prevents players from escaping during combat, manages combat interactions, and handles penalties for leaving combat.
use AEDXDEV\Combat\Main as Combat;
// Check if a player is in combat
// Returns true if the player is in combat, false otherwise
Combat::getInstance()->isInCombat($player);
use AEDXDEV\Combat\Main as Combat;
// Add two players to combat
Combat::getInstance()->addCombat($player1, $player2);
use AEDXDEV\Combat\Main as Combat;
// Get the player who is in combat with the specified player
// Returns the opponent player or null if not found
Combat::getInstance()->getPlayerCombat($player);
use AEDXDEV\Combat\Main as Combat;
// Remove a player from combat
Combat::getInstance()->removeCombat($player);
Custom combat events are fired during combat interactions:
If a player leaves combat, they may be penalized based on the configuration:
use AEDXDEV\Combat\Main as Combat;
use AEDXDEV\Combat\event\CombatStartEvent;
use AEDXDEV\Combat\event\CombatAttackEvent;
use AEDXDEV\Combat\event\CombatEndEvent;
// Called a player attack a player
public function onCombatStart(CombatStartEvent $event): void{
$player1 = $event->getPlayer1(); // damager
$player2 = $event->getPlayer2(); // victim
$time = $event->getTime();
// change the time
$event->setTime(10); // 10 seconds
// use penalty
if (!$event->getPenalty()){
$event->setPenalty(true);
}
// for 1vs1
if (!$event->getHidePlayers()){
$event->setHidePlayers(true);
}
}
// Called when a player is in combat attacked
public function onCombatAttack(CombatAttackEvent $event): void{
$damager = $event->getDamager();
$entity = $event->getEntity(); // victim
if (!$event->inInSameCombat()){ // attack a player not
$event->cancel();
}
}
// Called when the combat time ends
public function onCombatEnd(CombatEndEvent $event): void{
$player1 = $event->getPlayer1();
$player2 = $event->getPlayer2();
}
Configure the plugin through config.yml
:
Enable: true # Enables or disables the plugin.
CancelIfNotInSameCombat: false # Cancels actions if players are not engaged in the same combat.
Penalty: false # Enables or disables penalties for leaving combat.
Penalties:
Health: 5 # The amount of health to reduce when penalizing a player.
ItemLoss: true # Whether the player will lose their items upon leaving combat.
sendMessages: true # Enables or disables messages during combat events.
Messages:
Start: "§eYou are now in combat with {PLAYER}" # When combat begins.
InSameCombat: "§cYou cannot proceed because you are not fighting the same opponent!" # When a player tries to attack a different opponent.
End: "§eYou are no longer in combat." # When combat ends.
QuitPenalty: "§cYou have been penalized for leaving combat." # When a player is penalized for leaving combat.
Time: 10 # Duration of the combat period (in seconds).
You can leave one review per plugin release, and delete or update your review at any time