use of com.github.sirblobman.combatlogx.api.listener.IDeathListener in project CombatLogX by SirBlobman.
the class ListenerDeathEffects method onDeath.
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onDeath(PlayerDeathEvent e) {
YamlConfiguration configuration = getConfiguration();
List<String> enabledDeathEffectList = configuration.getStringList("death-effect-list");
if (enabledDeathEffectList.isEmpty())
return;
Player player = e.getEntity();
boolean requireCombatDeath = configuration.getBoolean("combat-death-only");
if (requireCombatDeath) {
ICombatLogX combatLogX = getCombatLogX();
IDeathListener deathListener = combatLogX.getDeathListener();
if (!deathListener.contains(player))
return;
}
if (enabledDeathEffectList.contains("BLOOD")) {
playBloodEffect(player);
}
if (enabledDeathEffectList.contains("LIGHTNING")) {
playLightningEffect(player);
}
}
use of com.github.sirblobman.combatlogx.api.listener.IDeathListener in project CombatLogX by SirBlobman.
the class PunishManager method runKillCheck.
private void runKillCheck(Player player) {
ConfigurationManager configurationManager = this.plugin.getConfigurationManager();
YamlConfiguration configuration = configurationManager.get("punish.yml");
String killOptionString = configuration.getString("kill-time");
if (killOptionString == null) {
killOptionString = "QUIT";
}
if (killOptionString.equals("QUIT")) {
IDeathListener listenerDeath = this.plugin.getDeathListener();
listenerDeath.add(player);
player.setHealth(0.0D);
}
if (killOptionString.equals("JOIN")) {
YamlConfiguration playerData = this.plugin.getData(player);
playerData.set("kill-on-join", true);
this.plugin.saveData(player);
}
}
use of com.github.sirblobman.combatlogx.api.listener.IDeathListener 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);
}
Aggregations