use of com.github.sirblobman.combatlogx.api.object.NoEntryMode in project CombatLogX by SirBlobman.
the class RegionVulnerableListener method onDamage.
@EventHandler(priority = EventPriority.HIGHEST)
public void onDamage(EntityDamageByEntityEvent e) {
RegionHandler regionHandler = this.regionExpansion.getRegionHandler();
NoEntryMode noEntryMode = regionHandler.getNoEntryMode();
if (noEntryMode != NoEntryMode.VULNERABLE)
return;
Entity damaged = e.getEntity();
Player player = getPlayerOrPassenger(damaged);
if (player == null)
return;
if (isInCombat(player)) {
ICombatManager combatManager = getCombatManager();
LivingEntity enemy = combatManager.getEnemy(player);
TagType tagType = getTagType(enemy);
Location location = player.getLocation();
if (regionHandler.isSafeZone(player, location, tagType)) {
e.setCancelled(false);
}
}
}
use of com.github.sirblobman.combatlogx.api.object.NoEntryMode in project CombatLogX by SirBlobman.
the class RegionHandler method preventEntry.
public final void preventEntry(Cancellable e, Player player, Location fromLocation, Location toLocation) {
if (player == null) {
return;
}
ICombatLogX plugin = this.expansion.getPlugin();
JavaPlugin javaPlugin = plugin.getPlugin();
ICombatManager combatManager = plugin.getCombatManager();
if (!combatManager.isInCombat(player)) {
return;
}
LivingEntity enemy = combatManager.getEnemy(player);
sendEntryDeniedMessage(player, enemy);
NoEntryMode noEntryMode = getNoEntryMode();
switch(noEntryMode) {
case KILL_PLAYER:
player.setHealth(0.0D);
break;
case TELEPORT_TO_ENEMY:
if (enemy != null) {
player.teleport(enemy);
break;
}
case CANCEL_EVENT:
e.setCancelled(true);
break;
case KNOCKBACK_PLAYER:
if (player.isInsideVehicle()) {
if (!player.leaveVehicle()) {
e.setCancelled(true);
break;
}
}
Runnable task = () -> knockbackPlayer(player, fromLocation, toLocation);
BukkitScheduler scheduler = Bukkit.getScheduler();
scheduler.runTaskLater(javaPlugin, task, 1L);
break;
case DISABLED:
case VULNERABLE:
default:
break;
}
}
Aggregations