use of com.github.sirblobman.combatlogx.api.manager.ICombatManager in project CombatLogX by SirBlobman.
the class ListenerForceField method updateForceField.
protected void updateForceField(Player player) {
ICombatManager combatManager = getCombatManager();
if (!combatManager.isInCombat(player)) {
return;
}
Location playerLocation = player.getLocation();
if (isSafe(player, playerLocation)) {
return;
}
if (isSafeMode())
safeForceField(player);
else
this.forceFieldExecutor.submit(() -> safeForceField(player));
}
use of com.github.sirblobman.combatlogx.api.manager.ICombatManager in project CombatLogX by SirBlobman.
the class ListenerForceField method safeForceField.
private void safeForceField(Player player) {
ICombatManager combatManager = getCombatManager();
LivingEntity enemy = combatManager.getEnemy(player);
safeForceField(player, enemy);
}
use of com.github.sirblobman.combatlogx.api.manager.ICombatManager in project CombatLogX by SirBlobman.
the class ListenerForceField method updateForceField.
protected void updateForceField(Player player, LivingEntity enemy) {
ICombatManager combatManager = getCombatManager();
if (!combatManager.isInCombat(player)) {
return;
}
Location playerLocation = player.getLocation();
if (isSafe(player, playerLocation)) {
return;
}
if (isSafeMode())
safeForceField(player, enemy);
else
this.forceFieldExecutor.submit(() -> safeForceField(player, enemy));
}
use of com.github.sirblobman.combatlogx.api.manager.ICombatManager in project CombatLogX by SirBlobman.
the class ListenerForceField method onMove.
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onMove(PlayerMoveEvent e) {
Location toLocation = e.getTo();
if (toLocation == null || !isEnabled()) {
return;
}
Player player = e.getPlayer();
if (canBypass(player)) {
return;
}
ICombatManager combatManager = getCombatManager();
if (!combatManager.isInCombat(player)) {
return;
}
Location fromLocation = e.getFrom();
if (Objects.equals(WorldXYZ.from(toLocation), WorldXYZ.from(fromLocation))) {
return;
}
if (isSafe(player, toLocation)) {
return;
}
updateForceField(player);
}
use of com.github.sirblobman.combatlogx.api.manager.ICombatManager in project CombatLogX by SirBlobman.
the class ListenerTeleport method checkEnderPearlRetag.
private void checkEnderPearlRetag(PlayerTeleportEvent e) {
printDebug("Checking if ender pearl should re-tag player...");
if (!shouldRetag()) {
printDebug("Re-tag option is disabled.");
return;
}
if (e.isCancelled()) {
printDebug("Event was cancelled, ignoring.");
return;
}
TeleportCause teleportCause = e.getCause();
if (teleportCause != TeleportCause.ENDER_PEARL) {
printDebug("Teleport cause was not ENDER_PEARL, ignoring.");
return;
}
Player player = e.getPlayer();
ICombatManager combatManager = getCombatManager();
LivingEntity enemy = combatManager.getEnemy(player);
combatManager.tag(player, enemy, TagType.UNKNOWN, TagReason.UNKNOWN);
printDebug("Player will be re-tagged. Done.");
}
Aggregations