use of com.github.sirblobman.combatlogx.api.manager.ICombatManager in project CombatLogX by SirBlobman.
the class ActionBarUpdater method replacePlaceholders.
private String replacePlaceholders(Player player, String message, long timeLeftMillis) {
if (message.contains("{bars}")) {
String bars = getBars(player, timeLeftMillis);
message = message.replace("{bars}", bars);
}
ICombatLogX combatLogX = getCombatLogX();
ICombatManager combatManager = combatLogX.getCombatManager();
LivingEntity enemy = combatManager.getEnemy(player);
return combatManager.replaceVariables(player, enemy, message);
}
use of com.github.sirblobman.combatlogx.api.manager.ICombatManager in project CombatLogX by SirBlobman.
the class ListenerEssentials method onTeleportRequest.
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onTeleportRequest(TPARequestEvent e) {
if (isTeleportRequestEnabled())
return;
ICombatManager combatManager = getCombatManager();
LanguageManager languageManager = getLanguageManager();
CommandSource requester = e.getRequester();
Player player = requester.getPlayer();
if (player == null)
return;
if (combatManager.isInCombat(player)) {
sendMessageWithPrefix(player, "expansion.essentials-compatibility.prevent-teleport-request-self", null, true);
e.setCancelled(true);
return;
}
IUser targetUser = e.getTarget();
Player target = targetUser.getBase();
if (target == null)
return;
if (combatManager.isInCombat(target)) {
sendMessageWithPrefix(player, "expansion.essentials-compatibility.prevent-teleport-request-other", null, true);
e.setCancelled(true);
// return;
}
}
use of com.github.sirblobman.combatlogx.api.manager.ICombatManager in project CombatLogX by SirBlobman.
the class ListenerTeleport method checkUntag.
private void checkUntag(PlayerTeleportEvent e) {
printDebug("Checking if player should be untagged by teleport event...");
if (!shouldUntag()) {
printDebug("Untag option is set to false, not untagging.");
return;
}
if (e.isCancelled()) {
printDebug("Event was cancelled, not untagging.");
return;
}
TeleportCause teleportCause = e.getCause();
if (teleportCause == TeleportCause.UNKNOWN) {
printDebug("Teleport cause was unknown, not untagging.");
return;
}
Player player = e.getPlayer();
ICombatManager combatManager = getCombatManager();
combatManager.untag(player, UntagReason.EXPIRE);
printDebug("Untagging player due to teleport event.");
}
use of com.github.sirblobman.combatlogx.api.manager.ICombatManager in project CombatLogX by SirBlobman.
the class ListenerGameMode method checkUntag.
private void checkUntag(Player player) {
if (!shouldUntagOnSwitch())
return;
ICombatLogX plugin = getCombatLogX();
ICombatManager combatManager = plugin.getCombatManager();
combatManager.untag(player, UntagReason.EXPIRE);
}
use of com.github.sirblobman.combatlogx.api.manager.ICombatManager in project CombatLogX by SirBlobman.
the class RegionMoveListener method onMove.
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onMove(PlayerMoveEvent e) {
Location toLocation = e.getTo();
if (toLocation == null) {
return;
}
Player player = e.getPlayer();
ICombatLogX combatLogX = getCombatLogX();
ICombatManager combatManager = combatLogX.getCombatManager();
if (!combatManager.isInCombat(player)) {
return;
}
LivingEntity enemy = combatManager.getEnemy(player);
TagType tagType = getTagType(enemy);
RegionHandler regionHandler = getRegionHandler();
if (regionHandler.isSafeZone(player, toLocation, tagType)) {
Location fromLocation = e.getFrom();
if (!regionHandler.isSafeZone(player, fromLocation, tagType)) {
regionHandler.preventEntry(e, player, fromLocation, toLocation);
}
}
}
Aggregations