diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index c72c7db..ff7fe18 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -4,7 +4,7 @@ stages: variables: name: "EpicBosses" path: "/builds/$CI_PROJECT_PATH" - version: "1.1.0" + version: "1.1.1" build: stage: build diff --git a/plugin-modules/Core/src/com/songoda/epicbosses/api/BossAPI.java b/plugin-modules/Core/src/com/songoda/epicbosses/api/BossAPI.java index 927f1c8..9997ef8 100644 --- a/plugin-modules/Core/src/com/songoda/epicbosses/api/BossAPI.java +++ b/plugin-modules/Core/src/com/songoda/epicbosses/api/BossAPI.java @@ -476,7 +476,7 @@ public class BossAPI { String name = PLUGIN.getBossEntityContainer().getName(bossEntity); - ActiveBossHolder activeBossHolder = PLUGIN.getBossEntityManager().createActiveBossHolder(bossEntity, location, name); + ActiveBossHolder activeBossHolder = PLUGIN.getBossEntityManager().createActiveBossHolder(bossEntity, location, name, player); if(activeBossHolder == null) { Debug.FAILED_TO_CREATE_ACTIVE_BOSS_HOLDER.debug(); diff --git a/plugin-modules/Core/src/com/songoda/epicbosses/events/PreBossDeathEvent.java b/plugin-modules/Core/src/com/songoda/epicbosses/events/PreBossDeathEvent.java index 6855140..26208cb 100644 --- a/plugin-modules/Core/src/com/songoda/epicbosses/events/PreBossDeathEvent.java +++ b/plugin-modules/Core/src/com/songoda/epicbosses/events/PreBossDeathEvent.java @@ -3,6 +3,7 @@ package com.songoda.epicbosses.events; import lombok.Getter; import com.songoda.epicbosses.holder.ActiveBossHolder; import org.bukkit.Location; +import org.bukkit.entity.Player; import org.bukkit.event.Event; import org.bukkit.event.HandlerList; @@ -17,10 +18,12 @@ public class PreBossDeathEvent extends Event { @Getter private ActiveBossHolder activeBossHolder; @Getter private Location location; + @Getter private Player killer; - public PreBossDeathEvent(ActiveBossHolder activeBossHolder, Location location) { + public PreBossDeathEvent(ActiveBossHolder activeBossHolder, Location location, Player killer) { this.activeBossHolder = activeBossHolder; this.location = location; + this.killer = killer; } @Override diff --git a/plugin-modules/Core/src/com/songoda/epicbosses/holder/ActiveBossHolder.java b/plugin-modules/Core/src/com/songoda/epicbosses/holder/ActiveBossHolder.java index 29e18b1..7808885 100644 --- a/plugin-modules/Core/src/com/songoda/epicbosses/holder/ActiveBossHolder.java +++ b/plugin-modules/Core/src/com/songoda/epicbosses/holder/ActiveBossHolder.java @@ -12,6 +12,7 @@ import org.bukkit.Location; import org.bukkit.World; import org.bukkit.entity.Entity; import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; import java.util.*; @@ -30,14 +31,19 @@ public class ActiveBossHolder implements IActiveHolder { @Getter private Map livingEntityMap = new HashMap<>(); @Getter private List postBossDeathHandlers = new ArrayList<>(); @Getter private Map mapOfDamagingUsers = new HashMap<>(); + @Getter private String spawningPlayerName; @Getter @Setter private TargetHandler targetHandler = null; @Getter @Setter private boolean isDead = false, customSpawnMessage = false; - public ActiveBossHolder(BossEntity bossEntity, Location spawnLocation, String name) { + public ActiveBossHolder(BossEntity bossEntity, Location spawnLocation, String name, Player spawningPlayer) { this.location = spawnLocation; this.bossEntity = bossEntity; this.name = name; + + if (spawningPlayer != null) { + this.spawningPlayerName = spawningPlayer.getName(); + } } public void setLivingEntity(int position, LivingEntity livingEntity) { diff --git a/plugin-modules/Core/src/com/songoda/epicbosses/listeners/after/BossDeathListener.java b/plugin-modules/Core/src/com/songoda/epicbosses/listeners/after/BossDeathListener.java index dd5ae0f..cd36a75 100644 --- a/plugin-modules/Core/src/com/songoda/epicbosses/listeners/after/BossDeathListener.java +++ b/plugin-modules/Core/src/com/songoda/epicbosses/listeners/after/BossDeathListener.java @@ -16,6 +16,7 @@ import com.songoda.epicbosses.utils.ServerUtils; import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.entity.EntityDamageEvent; @@ -63,7 +64,7 @@ public class BossDeathListener implements Listener { if(this.bossEntityManager.isAllEntitiesDead(activeBossHolder)) { - PreBossDeathEvent preBossDeathEvent = new PreBossDeathEvent(activeBossHolder, location); + PreBossDeathEvent preBossDeathEvent = new PreBossDeathEvent(activeBossHolder, location, event.getEntity().getKiller()); activeBossHolder.setDead(true); activeBossHolder.killAllMinions(); @@ -86,6 +87,8 @@ public class BossDeathListener implements Listener { ServerUtils serverUtils = ServerUtils.get(); if(commands != null) { + if (activeBossHolder.getSpawningPlayerName() != null) commands.replaceAll(s -> s.replace("{spawner}", activeBossHolder.getSpawningPlayerName())); + if (event.getKiller() != null) commands.replaceAll(s -> s.replace("{killer}", event.getKiller().getName())); commands.forEach(serverUtils::sendConsoleCommand); } @@ -123,6 +126,8 @@ public class BossDeathListener implements Listener { } if(activeBossHolder.getName() != null) messages.replaceAll(s -> s.replace("{boss}", activeBossHolder.getName())); + if (activeBossHolder.getSpawningPlayerName() != null) messages.replaceAll(s -> s.replace("{spawner}", activeBossHolder.getSpawningPlayerName())); + if (event.getKiller() != null) messages.replaceAll(s -> s.replace("{killer}", event.getKiller().getName())); messages.replaceAll(s -> s.replace('&', 'ยง')); diff --git a/plugin-modules/Core/src/com/songoda/epicbosses/listeners/pre/BossSpawnListener.java b/plugin-modules/Core/src/com/songoda/epicbosses/listeners/pre/BossSpawnListener.java index 5868483..5bb0ccf 100644 --- a/plugin-modules/Core/src/com/songoda/epicbosses/listeners/pre/BossSpawnListener.java +++ b/plugin-modules/Core/src/com/songoda/epicbosses/listeners/pre/BossSpawnListener.java @@ -87,7 +87,7 @@ public class BossSpawnListener implements Listener { location.add(0,1,0); } - if(!this.bossLocationManager.canSpawnBoss(player, location)) { + if(!this.bossLocationManager.canSpawnBoss(player, location.clone())) { Message.General_CannotSpawn.msg(player); event.setCancelled(true); return; diff --git a/plugin-modules/Core/src/com/songoda/epicbosses/managers/BossEntityManager.java b/plugin-modules/Core/src/com/songoda/epicbosses/managers/BossEntityManager.java index 836bfc2..a653794 100644 --- a/plugin-modules/Core/src/com/songoda/epicbosses/managers/BossEntityManager.java +++ b/plugin-modules/Core/src/com/songoda/epicbosses/managers/BossEntityManager.java @@ -29,6 +29,7 @@ import org.bukkit.Location; import org.bukkit.World; import org.bukkit.entity.Item; import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; import org.bukkit.util.Vector; @@ -269,8 +270,8 @@ public class BossEntityManager { return newMap; } - public ActiveBossHolder createActiveBossHolder(BossEntity bossEntity, Location spawnLocation, String name) { - ActiveBossHolder activeBossHolder = new ActiveBossHolder(bossEntity, spawnLocation, name); + public ActiveBossHolder createActiveBossHolder(BossEntity bossEntity, Location spawnLocation, String name, Player spawningPlayer) { + ActiveBossHolder activeBossHolder = new ActiveBossHolder(bossEntity, spawnLocation, name, spawningPlayer); this.bossMechanicManager.handleMechanicApplication(bossEntity, activeBossHolder); diff --git a/plugin-modules/Core/src/com/songoda/epicbosses/mechanics/boss/PotionMechanic.java b/plugin-modules/Core/src/com/songoda/epicbosses/mechanics/boss/PotionMechanic.java index 05c5b2a..a1f795f 100644 --- a/plugin-modules/Core/src/com/songoda/epicbosses/mechanics/boss/PotionMechanic.java +++ b/plugin-modules/Core/src/com/songoda/epicbosses/mechanics/boss/PotionMechanic.java @@ -5,6 +5,7 @@ import com.songoda.epicbosses.entity.elements.EntityStatsElement; import com.songoda.epicbosses.entity.elements.MainStatsElement; import com.songoda.epicbosses.holder.ActiveBossHolder; import com.songoda.epicbosses.mechanics.IBossMechanic; +import com.songoda.epicbosses.utils.ServerUtils; import com.songoda.epicbosses.utils.potion.PotionEffectConverter; import com.songoda.epicbosses.utils.potion.holder.PotionEffectHolder; import org.bukkit.entity.LivingEntity; @@ -39,6 +40,11 @@ public class PotionMechanic implements IBossMechanic { if(potionElements != null && !potionElements.isEmpty()) { potionElements.forEach(potionElement -> { PotionEffect potionEffect = this.potionEffectConverter.from(potionElement); + if (potionEffect == null) { + ServerUtils.get().logDebug("Failed to apply potion effect to boss: " + + "[type=" + potionElement.getType() + ",duration=" + potionElement.getDuration() + ",level=" + potionElement.getLevel() + "]"); + return; + } livingEntity.addPotionEffect(potionEffect); }); diff --git a/plugin-modules/Core/src/com/songoda/epicbosses/utils/itemstack/ItemStackUtils.java b/plugin-modules/Core/src/com/songoda/epicbosses/utils/itemstack/ItemStackUtils.java index 09f7023..d26fc25 100644 --- a/plugin-modules/Core/src/com/songoda/epicbosses/utils/itemstack/ItemStackUtils.java +++ b/plugin-modules/Core/src/com/songoda/epicbosses/utils/itemstack/ItemStackUtils.java @@ -1,6 +1,7 @@ package com.songoda.epicbosses.utils.itemstack; import com.songoda.epicbosses.utils.NumberUtils; +import com.songoda.epicbosses.utils.ServerUtils; import com.songoda.epicbosses.utils.StringUtils; //import com.songoda.epicbosses.utils.factory.NbtFactory; import com.songoda.epicbosses.utils.itemstack.enchants.GlowEnchant; @@ -117,6 +118,11 @@ public class ItemStackUtils { for(String x : replacedMap.keySet()) { if(!y.contains(x)) continue; + if (!replacedMap.containsKey(x)) { + ServerUtils.get().logDebug("Failed to apply replaced lore: [y=" + y + "x=" + x + "]"); + continue; + } + y = y.replace(x, replacedMap.get(x)); } }