use of com.github.sirblobman.combatlogx.api.ICombatLogX in project CombatLogX by SirBlobman.
the class ListenerLootProtection method onDeath.
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onDeath(EntityDeathEvent e) {
LivingEntity entity = e.getEntity();
ICombatLogX combatLogX = getCombatLogX();
IDeathListener deathListener = combatLogX.getDeathListener();
YamlConfiguration configuration = getExpansionConfigurationManager().get("config.yml");
if (entity instanceof Player) {
Player player = (Player) entity;
if (configuration.getBoolean("only-protect-after-log", false) && !deathListener.contains(player)) {
return;
}
}
UUID entityId = entity.getUniqueId();
UUID enemyId = this.enemyMap.get(entityId);
if (!checkVoidKill(e) && entity instanceof Player) {
Player player = (Player) entity;
PlayerDataManager playerDataManager = getPlayerDataManager();
YamlConfiguration playerData = playerDataManager.get(player);
String enemyIdString = playerData.getString("loot-protection-enemy");
if (enemyIdString != null) {
playerData.set("loot-protection-enemy", null);
playerDataManager.save(player);
enemyId = UUID.fromString(enemyIdString);
}
}
if (enemyId == null) {
return;
}
Entity enemy = Bukkit.getEntity(enemyId);
if (enemy == null) {
return;
}
enemyId = enemy.getUniqueId();
WorldXYZ entityLocation = WorldXYZ.from(entity);
ConcurrentLinkedQueue<ProtectedItem> protectedItemQueue = new ConcurrentLinkedQueue<>();
List<ItemStack> dropList = e.getDrops();
for (ItemStack drop : dropList) {
ProtectedItem protectedItem = new ProtectedItem(entityLocation, drop);
protectedItem.setOwnerUUID(enemyId);
protectedItemQueue.add(protectedItem);
}
this.pendingProtectionMap.put(entityLocation, protectedItemQueue);
String entityName = (entity.getCustomName() == null ? entity.getName() : entity.getCustomName());
long timeLeftMillis = this.protectedItemMap.getExpiration();
long timeLeftSeconds = TimeUnit.MILLISECONDS.toSeconds(timeLeftMillis);
String timeLeft = Long.toString(timeLeftSeconds);
Replacer replacer = message -> message.replace("{time}", timeLeft).replace("{enemy}", entityName);
sendMessageWithPrefix(enemy, "expansion.loot-protection.enemy-died", replacer, true);
}
use of com.github.sirblobman.combatlogx.api.ICombatLogX in project CombatLogX by SirBlobman.
the class ListenerDamage method checkTag.
private void checkTag(Entity entity, Entity enemy, TagReason tagReason) {
if (!(entity instanceof Player)) {
return;
}
Player player = (Player) entity;
if (hasBypassPermission(player)) {
return;
}
if (!(enemy instanceof LivingEntity)) {
return;
}
LivingEntity livingEnemy = (LivingEntity) enemy;
EntityType enemyType = livingEnemy.getType();
if (isDisabled(enemyType)) {
return;
}
SpawnReason spawnReason = getSpawnReason(livingEnemy);
if (isDisabled(spawnReason)) {
return;
}
ICombatLogX plugin = getCombatLogX();
ICombatManager combatManager = plugin.getCombatManager();
combatManager.tag(player, livingEnemy, TagType.MOB, tagReason);
}
use of com.github.sirblobman.combatlogx.api.ICombatLogX in project CombatLogX by SirBlobman.
the class SpawnReasonManager_New method getPlugin.
private JavaPlugin getPlugin() {
MobTaggerExpansion expansion = getExpansion();
ICombatLogX combatLogX = expansion.getPlugin();
return combatLogX.getPlugin();
}
use of com.github.sirblobman.combatlogx.api.ICombatLogX in project CombatLogX by SirBlobman.
the class Reward method getEntityName.
private String getEntityName(LivingEntity entity) {
ICombatLogX plugin = this.expansion.getPlugin();
MultiVersionHandler multiVersionHandler = plugin.getMultiVersionHandler();
EntityHandler entityHandler = multiVersionHandler.getEntityHandler();
return entityHandler.getName(entity);
}
use of com.github.sirblobman.combatlogx.api.ICombatLogX in project CombatLogX by SirBlobman.
the class ScoreboardExpansion method onEnable.
@Override
public void onEnable() {
ICombatLogX plugin = getPlugin();
ITimerManager timerManager = plugin.getTimerManager();
timerManager.addUpdaterTask(new ScoreboardUpdater(this));
}
Aggregations