Added option to prevent bosses from exploding.

This commit is contained in:
Brianna 2019-10-19 17:24:57 -04:00
parent 0aca79652f
commit 2a6a2f5118
2 changed files with 16 additions and 0 deletions

View File

@ -7,12 +7,16 @@ import com.songoda.epicbosses.events.BossDamageEvent;
import com.songoda.epicbosses.holder.ActiveBossHolder;
import com.songoda.epicbosses.managers.BossEntityManager;
import com.songoda.epicbosses.managers.files.BossesFileManager;
import com.songoda.epicbosses.settings.Settings;
import com.songoda.epicbosses.utils.ServerUtils;
import org.bukkit.entity.*;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityCombustEvent;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityExplodeEvent;
import org.bukkit.event.entity.ExplosionPrimeEvent;
/**
* @author Charles Cullen
@ -85,4 +89,13 @@ public class BossDamageListener implements Listener {
activeBossHolder.getMapOfDamagingUsers().put(player.getUniqueId(), currentDamage + damage);
}
@EventHandler(priority = EventPriority.HIGHEST)
public void onBossExplode(ExplosionPrimeEvent event) {
if (!(event.getEntity() instanceof LivingEntity)) return;
LivingEntity livingEntity = (LivingEntity) event.getEntity();
ActiveBossHolder activeBossHolder = this.bossEntityManager.getActiveBossHolder(livingEntity);
if (activeBossHolder != null && !Settings.BOSS_EXPLOSIONS.getBoolean())
event.setCancelled(true);
}
}

View File

@ -28,6 +28,9 @@ public class Settings {
"Which economy plugin should be used?",
"Supported plugins you have installed: \"" + EconomyManager.getManager().getRegisteredPlugins().stream().collect(Collectors.joining("\", \"")) + "\".");
public static final ConfigSetting BOSS_EXPLOSIONS = new ConfigSetting(config, "Toggles.bossExplosions", false,
"Should bosses such as Creepers be allowed to explode?");
public static final ConfigSetting BOSS_SHOP = new ConfigSetting(config, "Toggles.bossShop", true);
public static final ConfigSetting ENDERMAN_TELEPORTING = new ConfigSetting(config, "Toggles.endermanTeleporting", true);