Initial commit
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>ProjectCranked</artifactId>
|
||||
<groupId>net.crankedpvp</groupId>
|
||||
<version>1.0</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>Bosses</artifactId>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>8</maven.compiler.source>
|
||||
<maven.compiler.target>8</maven.compiler.target>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>net.crankedpvp</groupId>
|
||||
<artifactId>Utils</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.crankedpvp</groupId>
|
||||
<artifactId>Keys</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.crankedpvp</groupId>
|
||||
<artifactId>LootTable</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.crankedpvp</groupId>
|
||||
<artifactId>Leaderboards</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.crankedpvp</groupId>
|
||||
<artifactId>Core</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.massivecraft</groupId>
|
||||
<artifactId>Factions</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.crankedpvp</groupId>
|
||||
<artifactId>StorageUtilsShaded</artifactId>
|
||||
<version>1.0</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>${project.basedir}/../StorageUtils/target/StorageUtils-1.0-shaded.jar</systemPath>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
@@ -0,0 +1,57 @@
|
||||
package net.crankedpvp.bosses;
|
||||
|
||||
import de.tr7zw.nbtapi.NBTItem;
|
||||
import net.crankedpvp.bosses.struct.Boss;
|
||||
import net.crankedpvp.bosses.struct.BossPlaceCooldown;
|
||||
import net.crankedpvp.bosses.struct.BossRegister;
|
||||
import net.crankedpvp.crankedutils.utils.cache.CacheManager;
|
||||
import net.crankedpvp.crankedutils.utils.cache.CachedPlayer;
|
||||
import net.crankedpvp.crankedutils.utils.items.ItemUtils;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
import static net.crankedpvp.bosses.struct.BossPlaceCooldown.BOSS_PLACE_COOLDOWN_NAME;
|
||||
|
||||
public class BossAPI {
|
||||
|
||||
public static boolean isBossEgg(ItemStack itemStack) {
|
||||
if (ItemUtils.isAirOrNull(itemStack)) return false;
|
||||
|
||||
NBTItem nbtItem = new NBTItem(itemStack);
|
||||
|
||||
if (!nbtItem.hasKey("cosmicData")) return false;
|
||||
return nbtItem.getString("cosmicData").equals("boss-egg");
|
||||
}
|
||||
|
||||
public static boolean isBossEgg(NBTItem nbtItem) {
|
||||
if (!nbtItem.hasKey("cosmicData")) return false;
|
||||
return nbtItem.getString("cosmicData").equals("boss-egg");
|
||||
}
|
||||
|
||||
public static Optional<Boss> getBossFromEgg(ItemStack itemStack) {
|
||||
if (ItemUtils.isAirOrNull(itemStack)) return Optional.empty();
|
||||
|
||||
NBTItem nbtItem = new NBTItem(itemStack);
|
||||
|
||||
if (!isBossEgg(itemStack)) return Optional.empty();
|
||||
|
||||
return Optional.of(BossRegister.getInstance().getBossFromID(nbtItem.getString("boss-type")));
|
||||
}
|
||||
|
||||
public static boolean isOnBossPlaceCooldown(Player player) {
|
||||
CachedPlayer cachedPlayer = CacheManager.getInstance().getCachedPlayer(player);
|
||||
|
||||
if (!cachedPlayer.hasCache(BOSS_PLACE_COOLDOWN_NAME)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return ((BossPlaceCooldown) cachedPlayer.getCache(BOSS_PLACE_COOLDOWN_NAME)).isActive();
|
||||
}
|
||||
|
||||
public static void registerBossPlaceCooldown(Player player) {
|
||||
CachedPlayer cachedPlayer = CacheManager.getInstance().getCachedPlayer(player);
|
||||
cachedPlayer.registerCache(new BossPlaceCooldown());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
package net.crankedpvp.bosses;
|
||||
|
||||
import lombok.Getter;
|
||||
import me.mattstudios.mf.base.CommandManager;
|
||||
import me.mattstudios.mf.base.components.TypeResult;
|
||||
import net.crankedpvp.bosses.abilities.BroodMotherMinion;
|
||||
import net.crankedpvp.bosses.abilities.NoPot;
|
||||
import net.crankedpvp.bosses.commands.AdminCommand;
|
||||
import net.crankedpvp.bosses.commands.BossesCommand;
|
||||
import net.crankedpvp.bosses.language.LanguageHandler;
|
||||
import net.crankedpvp.bosses.listeners.BossListeners;
|
||||
import net.crankedpvp.bosses.struct.Boss;
|
||||
import net.crankedpvp.bosses.struct.BossManager;
|
||||
import net.crankedpvp.bosses.struct.BossRegister;
|
||||
import net.crankedpvp.bosses.struct.config.BossConfigManager;
|
||||
import net.crankedpvp.crankedutils.utils.PluginUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import java.util.Locale;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Getter
|
||||
public class BossPlugin extends JavaPlugin {
|
||||
|
||||
@Getter
|
||||
private static BossPlugin instance;
|
||||
|
||||
private CommandManager commandManager;
|
||||
private BossRegister bossRegister;
|
||||
private BossManager bossManager;
|
||||
private LanguageHandler languageHandler;
|
||||
private BossConfigManager bossConfigManager;
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
instance = this;
|
||||
this.languageHandler = new LanguageHandler(this);
|
||||
this.languageHandler.load();
|
||||
|
||||
this.bossRegister = new BossRegister(this);
|
||||
this.bossRegister.initialize();
|
||||
|
||||
this.bossManager = new BossManager();
|
||||
this.commandManager = new CommandManager(this);
|
||||
|
||||
PluginUtils.registerListeners(this,
|
||||
new BossListeners(this),
|
||||
new NoPot(),
|
||||
new BroodMotherMinion());
|
||||
|
||||
Bukkit.getScheduler().runTask(this, () -> {
|
||||
this.bossConfigManager = new BossConfigManager(this);
|
||||
this.bossConfigManager.setupFiles();
|
||||
|
||||
this.registerCommandParameters();
|
||||
this.registerCommandCompletion();
|
||||
|
||||
this.commandManager.register(new AdminCommand(this), new BossesCommand());
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
this.getBossManager().killAllAliveBosses();
|
||||
this.bossRegister.unregisterAll();
|
||||
}
|
||||
|
||||
private void registerCommandParameters() {
|
||||
this.commandManager.getParameterHandler().register(Boss.class, argument -> {
|
||||
Boss boss = BossRegister.getInstance().getBossFromID(String.valueOf(argument).toLowerCase(Locale.ROOT));
|
||||
return new TypeResult(boss, argument);
|
||||
});
|
||||
}
|
||||
|
||||
private void registerCommandCompletion() {
|
||||
this.commandManager.getCompletionHandler().register("#bosses", input -> {
|
||||
return BossRegister.getInstance().getRegisteredBosses().values().stream().map(Boss::getID).collect(Collectors.toList());
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package net.crankedpvp.bosses.abilities;
|
||||
|
||||
import net.crankedpvp.bosses.struct.Boss;
|
||||
import net.crankedpvp.bosses.struct.BossAbility;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
public class BroodMotherBlind extends BossAbility {
|
||||
@Override
|
||||
public String getName() {
|
||||
return "Brood Mother Blind";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void abilityEffect(Boss boss, LivingEntity bossEntity, Player player) {
|
||||
bossEntity.getNearbyEntities(6D, 6D, 6D).stream()
|
||||
.filter(entity -> entity instanceof Player)
|
||||
.map(entity -> (Player)entity)
|
||||
.forEach(loopPlayer -> {
|
||||
loopPlayer.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, 3 * 20, 9, true));
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCooldownLength() {
|
||||
return 7;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double procChance() {
|
||||
return 15;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
package net.crankedpvp.bosses.abilities;
|
||||
|
||||
import net.crankedpvp.bosses.struct.Boss;
|
||||
import net.crankedpvp.bosses.struct.BossAbility;
|
||||
import net.crankedpvp.crankedutils.utils.CC;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.EntityType;
|
||||
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.EntityDeathEvent;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class BroodMotherMinion extends BossAbility implements Listener {
|
||||
|
||||
private List<LivingEntity> minions = new ArrayList<>();
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "Brood Mother Minion";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void abilityEffect(Boss boss, LivingEntity bossEntity, Player player) {
|
||||
for(int i = 0; i < 3; i++) {
|
||||
Location location = bossEntity.getLocation();
|
||||
LivingEntity minion = (LivingEntity) bossEntity.getWorld().spawnEntity(location, EntityType.CAVE_SPIDER);
|
||||
minion.setRemoveWhenFarAway(true);
|
||||
minion.setMaxHealth(100);
|
||||
minion.setHealth(100);
|
||||
minion.setCanPickupItems(false);
|
||||
minion.setCustomNameVisible(true);
|
||||
minion.setCustomName(CC.translate("&d&lBrood Minion"));
|
||||
minion.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, Integer.MAX_VALUE, 4));
|
||||
minions.add(minion);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCooldownLength() {
|
||||
return 15;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double procChance() {
|
||||
return 10;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onMinionDeath(EntityDeathEvent event) {
|
||||
if(minions.contains(event.getEntity())) event.getDrops().clear();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
package net.crankedpvp.bosses.abilities;
|
||||
|
||||
import net.crankedpvp.bosses.BossPlugin;
|
||||
import net.crankedpvp.bosses.struct.Boss;
|
||||
import net.crankedpvp.bosses.struct.BossAbility;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class BroodMotherWeb extends BossAbility {
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "Brood Mother Web";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void abilityEffect(Boss boss, LivingEntity bossEntity, Player player) {
|
||||
|
||||
bossEntity.getNearbyEntities(6D, 6D, 6D).stream()
|
||||
.filter(entity -> entity instanceof Player)
|
||||
.map(entity -> (Player)entity)
|
||||
.forEach(loopPlayer -> {
|
||||
List<Location> locations = new ArrayList<>();
|
||||
for(Location location : Arrays.asList(player.getLocation(), player.getEyeLocation())) if(trySetupWebBlock(location)) locations.add(location);
|
||||
BossPlugin.getInstance().getServer().getScheduler().runTaskLater(BossPlugin.getInstance(), () -> {
|
||||
for(Location location : locations) tryRemoveWebBlock(location);
|
||||
}, 3 * 20L);
|
||||
});
|
||||
}
|
||||
|
||||
private void tryRemoveWebBlock(Location location) {
|
||||
if(location.getBlock().getType() == Material.WEB)
|
||||
location.getBlock().setType(Material.AIR);
|
||||
}
|
||||
|
||||
private boolean trySetupWebBlock(Location location) {
|
||||
if(location.getBlock().getType() == Material.AIR) {
|
||||
location.getBlock().setType(Material.WEB);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCooldownLength() {
|
||||
return 10;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double procChance() {
|
||||
return 5;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package net.crankedpvp.bosses.abilities;
|
||||
|
||||
import net.crankedpvp.bosses.struct.Boss;
|
||||
import net.crankedpvp.bosses.struct.BossAbility;
|
||||
import net.crankedpvp.crankedutils.utils.CC;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class DamageTick extends BossAbility {
|
||||
@Override
|
||||
public String getName() {
|
||||
return "Damage Tick";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void abilityEffect(Boss boss, LivingEntity bossEntity, Player player) {
|
||||
bossEntity.getNearbyEntities(6D, 6D, 6D).stream()
|
||||
.filter(entity -> entity instanceof Player)
|
||||
.map(entity -> (Player)entity)
|
||||
.forEach(loopPlayer -> {
|
||||
if(Math.random() < 0.15) {
|
||||
loopPlayer.damage(6D);
|
||||
loopPlayer.sendMessage(CC.translate(boss.getBossDisplayName().split("\\|")[0] + "&8- &c&l[TICKED: -6HP]"));
|
||||
}
|
||||
loopPlayer.damage(2D);
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCooldownLength() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double procChance() {
|
||||
return 30;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package net.crankedpvp.bosses.abilities;
|
||||
|
||||
import net.crankedpvp.bosses.struct.Boss;
|
||||
import net.crankedpvp.bosses.struct.BossAbility;
|
||||
import net.crankedpvp.crankedutils.utils.CC;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class Heal extends BossAbility {
|
||||
@Override
|
||||
public String getName() {
|
||||
return "Heal";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void abilityEffect(Boss boss, LivingEntity bossEntity, Player player) {
|
||||
bossEntity.setHealth(bossEntity.getHealth() + 20);
|
||||
bossEntity.setMaxHealth(bossEntity.getMaxHealth() + 20);
|
||||
bossEntity.getNearbyEntities(10D, 10D, 10D).stream()
|
||||
.filter(entity -> entity instanceof Player)
|
||||
.map(entity -> (Player)entity)
|
||||
.forEach(loopPlayer -> loopPlayer.sendMessage(CC.translate(boss.getBossDisplayName().split("\\|")[0] + "&8- &a&l[HEAL: +20HP]")));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCooldownLength() {
|
||||
return 10;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double procChance() {
|
||||
return 25;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package net.crankedpvp.bosses.abilities;
|
||||
|
||||
import net.crankedpvp.bosses.bosses.KingSlime;
|
||||
import net.crankedpvp.bosses.struct.Boss;
|
||||
import net.crankedpvp.bosses.struct.BossAbility;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class Knockback extends BossAbility {
|
||||
|
||||
private Boss boss;
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "Knockback";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void abilityEffect(Boss boss, LivingEntity bossEntity, Player player) {
|
||||
this.boss = boss;
|
||||
bossEntity.getNearbyEntities(8D, 8D, 8D).stream()
|
||||
.filter(entity -> entity instanceof Player)
|
||||
.map(entity -> (Player)entity)
|
||||
.forEach(loopPlayer -> {
|
||||
loopPlayer.setVelocity(loopPlayer.getLocation().getDirection().multiply(-1.1));
|
||||
loopPlayer.playSound(loopPlayer.getLocation(), Sound.BAT_TAKEOFF, 2.0F, 8.0F);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public int getCooldownLength() {
|
||||
return (boss instanceof KingSlime) ? 7 : 12;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double procChance() {
|
||||
return (boss instanceof KingSlime) ? 40 : 20;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package net.crankedpvp.bosses.abilities;
|
||||
|
||||
import net.crankedpvp.bosses.struct.Boss;
|
||||
import net.crankedpvp.bosses.struct.BossAbility;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class Launch extends BossAbility {
|
||||
@Override
|
||||
public String getName() {
|
||||
return "Launch";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void abilityEffect(Boss boss, LivingEntity bossEntity, Player player) {
|
||||
bossEntity.getNearbyEntities(6D, 6D, 6D).stream()
|
||||
.filter(entity -> entity instanceof Player)
|
||||
.map(entity -> (Player)entity)
|
||||
.forEach(loopPlayer -> {
|
||||
Location loc = loopPlayer.getLocation().add(0.0, 6.0, 0.0);
|
||||
loopPlayer.setVelocity(loopPlayer.getVelocity().add(loopPlayer.getLocation().toVector().subtract(loc.toVector()).normalize().multiply(3)));
|
||||
loopPlayer.playSound(loopPlayer.getLocation(), Sound.BAT_TAKEOFF, 2.0F, 4.0F);
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCooldownLength() {
|
||||
return 15;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double procChance() {
|
||||
return 20;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package net.crankedpvp.bosses.abilities;
|
||||
|
||||
import net.crankedpvp.bosses.struct.Boss;
|
||||
import net.crankedpvp.bosses.struct.BossAbility;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class LightningStrike extends BossAbility {
|
||||
@Override
|
||||
public String getName() {
|
||||
return "Lightning Strike";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void abilityEffect(Boss boss, LivingEntity bossEntity, Player player) {
|
||||
bossEntity.getNearbyEntities(6D, 6D, 6D).stream()
|
||||
.filter(entity -> entity instanceof Player)
|
||||
.map(entity -> (Player)entity)
|
||||
.forEach(loopPlayer -> {
|
||||
loopPlayer.getLocation().getWorld().strikeLightningEffect(loopPlayer.getLocation());
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCooldownLength() {
|
||||
return 3;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double procChance() {
|
||||
return 12;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
package net.crankedpvp.bosses.abilities;
|
||||
|
||||
import net.crankedpvp.bosses.BossPlugin;
|
||||
import net.crankedpvp.bosses.struct.Boss;
|
||||
import net.crankedpvp.bosses.struct.BossAbility;
|
||||
import net.crankedpvp.crankedutils.utils.CC;
|
||||
import net.crankedpvp.crankedutils.utils.TitleUtils;
|
||||
import org.bukkit.entity.EntityType;
|
||||
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.PotionSplashEvent;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class NoPot extends BossAbility implements Listener {
|
||||
|
||||
private final List<Player> blockedFromUsingPotions = new ArrayList<>();
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "No Pot";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void abilityEffect(Boss boss, LivingEntity BossEntity, Player player) {
|
||||
blockedFromUsingPotions.add(player);
|
||||
TitleUtils.sendTitle(player, CC.translate("&c&lPOTIONS BLOCKED"), CC.translate("&7You cannot use potions for 5s"), 0, 2, 0);
|
||||
BossPlugin.getInstance().getServer().getScheduler().runTaskLater(BossPlugin.getInstance(), () -> {
|
||||
blockedFromUsingPotions.remove(player);
|
||||
}, 5 * 20L);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCooldownLength() {
|
||||
return 20;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double procChance() {
|
||||
return 5;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPotionSplashEvent(PotionSplashEvent event) {
|
||||
if(!(event.getEntity().getShooter() instanceof Player)) return;
|
||||
Player player = (Player) event.getEntity().getShooter();
|
||||
if(event.getPotion().getType() == EntityType.SPLASH_POTION) {
|
||||
if(!blockedFromUsingPotions.contains(player)) return;
|
||||
event.getEntity().remove();
|
||||
player.sendMessage(CC.translate("&c&l(!) &cYou cannot throw potions while blocked"));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package net.crankedpvp.bosses.abilities;
|
||||
|
||||
import net.crankedpvp.bosses.struct.Boss;
|
||||
import net.crankedpvp.bosses.struct.BossAbility;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class Pull extends BossAbility {
|
||||
@Override
|
||||
public String getName() {
|
||||
return "Pull";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void abilityEffect(Boss boss, LivingEntity bossEntity, Player player) {
|
||||
bossEntity.getNearbyEntities(6D, 6D, 6D).stream()
|
||||
.filter(entity -> entity instanceof Player)
|
||||
.map(entity -> (Player)entity)
|
||||
.forEach(loopPlayer -> {
|
||||
loopPlayer.setVelocity(loopPlayer.getLocation().getDirection().multiply(1.2));
|
||||
loopPlayer.playSound(loopPlayer.getLocation(), Sound.BAT_TAKEOFF, 2.0F, 2.0F);
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCooldownLength() {
|
||||
return 7;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double procChance() {
|
||||
return 50;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package net.crankedpvp.bosses.abilities;
|
||||
|
||||
import net.crankedpvp.bosses.struct.Boss;
|
||||
import net.crankedpvp.bosses.struct.BossAbility;
|
||||
import org.bukkit.entity.Arrow;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class ShootArrow extends BossAbility {
|
||||
@Override
|
||||
public String getName() {
|
||||
return "Arrow";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void abilityEffect(Boss boss, LivingEntity bossEntity, Player player) {
|
||||
Arrow arrow = bossEntity.launchProjectile(Arrow.class);
|
||||
arrow.setKnockbackStrength(arrow.getKnockbackStrength() * 2);
|
||||
arrow.spigot().setDamage(arrow.spigot().getDamage() * 3);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCooldownLength() {
|
||||
return 5;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double procChance() {
|
||||
return 30;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
package net.crankedpvp.bosses.abilities;
|
||||
|
||||
import net.crankedpvp.bosses.BossPlugin;
|
||||
import net.crankedpvp.bosses.interfaces.TrapAttributes;
|
||||
import net.crankedpvp.bosses.struct.Boss;
|
||||
import net.crankedpvp.bosses.struct.BossAbility;
|
||||
import net.crankedpvp.crankedutils.utils.CC;
|
||||
import net.crankedpvp.crankedutils.utils.TitleUtils;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class Trap extends BossAbility {
|
||||
|
||||
private Boss boss;
|
||||
@Override
|
||||
public String getName() {
|
||||
return "Trap Ability";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void abilityEffect(Boss boss, LivingEntity bossEntity, Player player) {
|
||||
this.boss = boss;
|
||||
|
||||
String subTitle = getSubTitle();
|
||||
double tickDamage = getTickDamage();
|
||||
|
||||
bossEntity.getNearbyEntities(6D, 6D, 6D).stream()
|
||||
.filter(entity -> entity instanceof Player)
|
||||
.map(entity -> (Player)entity)
|
||||
.forEach(loopPlayer -> {
|
||||
loopPlayer.setWalkSpeed(0F);
|
||||
loopPlayer.damage(tickDamage);
|
||||
|
||||
//loopPlayer.addPotionEffect(new PotionEffect(PotionEffectType.JUMP, Integer.MAX_VALUE, 200));
|
||||
//PotionEffectUtils.addPotionEffect(loopPlayer, PotionEffectType.JUMP, Integer.MAX_VALUE, "TrapBossEffect", 5);
|
||||
|
||||
loopPlayer.playSound(loopPlayer.getLocation(), Sound.PISTON_RETRACT, 2.0F, 3.0F);
|
||||
|
||||
TitleUtils.sendTitle(loopPlayer, CC.translate("&c&lTRAPPED"), CC.translate("&7" + subTitle), 0, 4, 0);
|
||||
|
||||
BossPlugin.getInstance().getServer().getScheduler().runTaskLater(BossPlugin.getInstance(), () -> {
|
||||
loopPlayer.setWalkSpeed(0.2F);
|
||||
loopPlayer.damage(tickDamage);
|
||||
}, 5 * 20L);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private String getSubTitle() {
|
||||
if(!(boss instanceof TrapAttributes)) return "You have been trapped";
|
||||
TrapAttributes trapAttributes = ((TrapAttributes)boss);
|
||||
if(trapAttributes.getSubTitle() == null) return "You have been trapped";
|
||||
return trapAttributes.getSubTitle();
|
||||
}
|
||||
|
||||
private double getTickDamage() {
|
||||
if(!(boss instanceof TrapAttributes)) return 1;
|
||||
return ((TrapAttributes)boss).getTickDamage();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCooldownLength() {
|
||||
if(!(boss instanceof TrapAttributes)) return 1;
|
||||
return ((TrapAttributes)boss).getCooldownLength();
|
||||
}
|
||||
|
||||
@Override
|
||||
public double procChance() {
|
||||
return 10;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package net.crankedpvp.bosses.abilities;
|
||||
|
||||
import net.crankedpvp.bosses.struct.Boss;
|
||||
import net.crankedpvp.bosses.struct.BossAbility;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
|
||||
public class TreasureGoblinLootDrop extends BossAbility {
|
||||
@Override
|
||||
public final String getName() {
|
||||
return "Treasure Goblin Drop";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void abilityEffect(final Boss boss, final LivingEntity bossEntity, final Player player) {
|
||||
final World world = bossEntity.getWorld();
|
||||
final Location bossLocation = bossEntity.getLocation();
|
||||
//TODO: fix this
|
||||
//final ItemStack itemStack = CrankedCrateKeysAPI.getRandomItem(CrankedCrateKeysPlugin.getInstance().getCrateLootManager().getCachedCrateLoot().get(CrateType.RARE_KEY));
|
||||
//world.dropItem(bossLocation, itemStack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final int getCooldownLength() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final double procChance() {
|
||||
return 100;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,152 @@
|
||||
package net.crankedpvp.bosses.bosses;
|
||||
|
||||
import net.crankedpvp.bosses.interfaces.Incrementable;
|
||||
import net.crankedpvp.bosses.struct.*;
|
||||
import net.crankedpvp.loottable.struct.LootTableType;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class BroodMother extends Boss implements Incrementable {
|
||||
@Override
|
||||
public String getName() {
|
||||
return "Brood Mother";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getBossDisplayName() {
|
||||
return "&5&lBrood Mother &8| {health}";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSpawnEggName() {
|
||||
return "&5&lBrood Mother";
|
||||
}
|
||||
|
||||
@Override
|
||||
public BossGear getBossGear() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getSpawnEggLore() {
|
||||
return Arrays.asList(
|
||||
"&7This monster egg contains a",
|
||||
"&cdangerous &7warzone boss.",
|
||||
"",
|
||||
"&5&lLORE",
|
||||
"&7&oA profound spider lost from",
|
||||
"&7&oits counterparts in the cavern",
|
||||
"&7&olayer of the Cosmoverse.",
|
||||
"&7&oAlthough, it's still a fighter..",
|
||||
"",
|
||||
"&5&lINFO",
|
||||
" &f• Difficulty: &e&lMEDIUM",
|
||||
" &f• Warzone Only: &c&lFALSE"
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BossAttributes getAttributes() {
|
||||
return BossAttributes.builder().build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Short getSpawnEggId() {
|
||||
return 52;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Sound getSpawnSound() {
|
||||
return Sound.SPIDER_WALK;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Sound getDeathSound() {
|
||||
return Sound.SPIDER_DEATH;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PotionEffect> getEffects() {
|
||||
return Arrays.asList(new PotionEffect(PotionEffectType.FIRE_RESISTANCE, Integer.MAX_VALUE, 0, true, false),
|
||||
new PotionEffect(PotionEffectType.SPEED, Integer.MAX_VALUE, 2, true, false));
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityType getEntityType() {
|
||||
return EntityType.SPIDER;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBaby() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public LootTableType getLootTableType() {
|
||||
return LootTableType.MYTHIC_KEY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRewardAmount() {
|
||||
return 5;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMaxHealth() {
|
||||
return 500.0D;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean showDeathMessage() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BossRewardSystem getBossRewardSystem() {
|
||||
return BossRewardSystem.GIVE_TO_TOP_3_PLAYERS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean showsInGui() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected BossPhaseInfo getPhaseOne() {
|
||||
return BossPhaseInfo.builder()
|
||||
.outgoingDamageIncrease(250)
|
||||
.incomingDamageDecrease(5)
|
||||
.abilities(Arrays.asList(BossAbilities.BROOD_MOTHER_BLIND, BossAbilities.BROOD_MOTHER_MINION, BossAbilities.DAMAGE_TICK))
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected BossPhaseInfo getPhaseTwo() {
|
||||
return BossPhaseInfo.builder()
|
||||
.outgoingDamageIncrease(500)
|
||||
.incomingDamageDecrease(10)
|
||||
.abilities(Arrays.asList(BossAbilities.BROOD_MOTHER_BLIND, BossAbilities.PULL, BossAbilities.DAMAGE_TICK, BossAbilities.BROOD_MOTHER_MINION))
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected BossPhaseInfo getPhaseThree() {
|
||||
return BossPhaseInfo.builder()
|
||||
.outgoingDamageIncrease(1000)
|
||||
.incomingDamageDecrease(15)
|
||||
.abilities(Arrays.asList(BossAbilities.BROOD_MOTHER_BLIND, BossAbilities.BROOD_MOTHER_WEB, BossAbilities.BROOD_MOTHER_MINION, BossAbilities.DAMAGE_TICK))
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void afterSpawn(LivingEntity livingEntity) {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,206 @@
|
||||
package net.crankedpvp.bosses.bosses;
|
||||
|
||||
import net.crankedpvp.bosses.interfaces.Incrementable;
|
||||
import net.crankedpvp.bosses.interfaces.TrapAttributes;
|
||||
import net.crankedpvp.bosses.struct.*;
|
||||
import net.crankedpvp.crankedutils.utils.items.ItemBuilder;
|
||||
import net.crankedpvp.crankedutils.utils.items.SkullUtils;
|
||||
import net.crankedpvp.loottable.struct.LootTableType;
|
||||
import org.bukkit.Color;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Skeleton;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class Cerberus extends Boss implements TrapAttributes, Incrementable {
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "Cerberus";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getBossDisplayName() {
|
||||
return "&6&lCerberus &8| {health}";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSpawnEggName() {
|
||||
return "&6&lCerberus &8(&4Admin Only&8)";
|
||||
}
|
||||
|
||||
@Override
|
||||
public BossGear getBossGear() {
|
||||
return BossGear.builder()
|
||||
.helmet(new ItemBuilder(SkullUtils.getSkull("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNDdjYTc4ODNiMWI5YjJiYjU4OGUxYTcxZDMzYjI5MjNiN2M3OTI2ZGZiYTZkYjEzNDE0MzM5OTYxMTM2ZmRkOCJ9fX0=")))
|
||||
.weapon(new ItemBuilder(Material.DIAMOND_SWORD).addEnchantment(Enchantment.DAMAGE_ALL, 5))
|
||||
.chestplate(new ItemBuilder(Material.LEATHER_CHESTPLATE).setLeatherArmorColor(Color.RED).setGlowing())
|
||||
.leggings(new ItemBuilder(Material.LEATHER_LEGGINGS).setLeatherArmorColor(Color.RED).setGlowing())
|
||||
.boots(new ItemBuilder(Material.LEATHER_BOOTS).setLeatherArmorColor(Color.RED).setGlowing())
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getSpawnEggLore() {
|
||||
return Arrays.asList(
|
||||
"&7This monster egg contains a",
|
||||
"&cdangerous &7warzone boss.",
|
||||
"",
|
||||
"&6&lLORE",
|
||||
"&7&oAn allegedly impossible boss",
|
||||
"&7&ofrom early 2018... are you able",
|
||||
"&7&oto defeat it now? Or will it",
|
||||
"&7&ostill rule the world...?",
|
||||
"",
|
||||
"&6&lINFO",
|
||||
" &f• Difficulty: &4&lEXTREME",
|
||||
" &f• Warzone Only: &a&lTRUE"
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BossAttributes getAttributes() {
|
||||
return BossAttributes.builder().build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Short getSpawnEggId() {
|
||||
return 67;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Sound getSpawnSound() {
|
||||
return Sound.WITHER_SPAWN;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Sound getDeathSound() {
|
||||
return Sound.WITHER_DEATH;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PotionEffect> getEffects() {
|
||||
return Arrays.asList(new PotionEffect(PotionEffectType.FIRE_RESISTANCE, Integer.MAX_VALUE, 0, true, false),
|
||||
new PotionEffect(PotionEffectType.SPEED, Integer.MAX_VALUE, 4, true, false),
|
||||
new PotionEffect(PotionEffectType.FAST_DIGGING, Integer.MAX_VALUE, 4, true, false)
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityType getEntityType() {
|
||||
return EntityType.SKELETON;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBaby() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public LootTableType getLootTableType() {
|
||||
return LootTableType.SEASON_KEY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRewardAmount() {
|
||||
return 5;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMaxHealth() {
|
||||
return 1000.0D;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean showDeathMessage() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BossRewardSystem getBossRewardSystem() {
|
||||
return BossRewardSystem.GIVE_TO_TOP_3_PLAYERS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean showsInGui() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected BossPhaseInfo getPhaseOne() {
|
||||
return BossPhaseInfo.builder()
|
||||
.outgoingDamageIncrease(650)
|
||||
.abilities(Arrays.asList(
|
||||
BossAbilities.LIGHTNING_STRIKE,
|
||||
BossAbilities.PULL,
|
||||
BossAbilities.KNOCKBACK,
|
||||
BossAbilities.DAMAGE_TICK,
|
||||
BossAbilities.SHOOT_ARROW,
|
||||
BossAbilities.LAUNCH
|
||||
))
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected BossPhaseInfo getPhaseTwo() {
|
||||
return BossPhaseInfo.builder()
|
||||
.outgoingDamageIncrease(1000)
|
||||
.abilities(Arrays.asList(
|
||||
BossAbilities.LIGHTNING_STRIKE,
|
||||
BossAbilities.TRAP,
|
||||
BossAbilities.PULL,
|
||||
BossAbilities.KNOCKBACK,
|
||||
BossAbilities.DAMAGE_TICK,
|
||||
BossAbilities.SHOOT_ARROW,
|
||||
BossAbilities.LAUNCH
|
||||
))
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected BossPhaseInfo getPhaseThree() {
|
||||
return BossPhaseInfo.builder()
|
||||
.outgoingDamageIncrease(1500)
|
||||
.incomingDamageDecrease(5)
|
||||
.abilities(Arrays.asList(
|
||||
BossAbilities.LIGHTNING_STRIKE,
|
||||
BossAbilities.TRAP,
|
||||
BossAbilities.PULL,
|
||||
BossAbilities.KNOCKBACK,
|
||||
BossAbilities.DAMAGE_TICK,
|
||||
BossAbilities.SHOOT_ARROW,
|
||||
BossAbilities.LAUNCH
|
||||
))
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void afterSpawn(LivingEntity livingEntity) {
|
||||
((Skeleton) livingEntity).setSkeletonType(Skeleton.SkeletonType.WITHER);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public String getSubTitle() {
|
||||
return "&fCome to the &6Cerberus &flittle one...";
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getTickDamage() {
|
||||
return 4;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCooldownLength() {
|
||||
return 18;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,174 @@
|
||||
package net.crankedpvp.bosses.bosses;
|
||||
|
||||
import net.crankedpvp.bosses.interfaces.Incrementable;
|
||||
import net.crankedpvp.bosses.interfaces.TrapAttributes;
|
||||
import net.crankedpvp.bosses.interfaces.WarzoneOnly;
|
||||
import net.crankedpvp.bosses.struct.*;
|
||||
import net.crankedpvp.loottable.struct.LootTableType;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class CrankedGuardian extends Boss implements TrapAttributes, Incrementable, WarzoneOnly {
|
||||
@Override
|
||||
public String getName() {
|
||||
return "Cranked Guardian";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getBossDisplayName() {
|
||||
return "&e&lCranked Guardian &8| {health}";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSpawnEggName() {
|
||||
return "&e&lCranked Guardian";
|
||||
}
|
||||
|
||||
@Override
|
||||
public BossGear getBossGear() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getSpawnEggLore() {
|
||||
return Arrays.asList(
|
||||
"&7This monster egg contains a",
|
||||
"&cdangerous &7warzone boss.",
|
||||
"",
|
||||
"&e&lLORE",
|
||||
"&7&oA lost golem from the village",
|
||||
"&7&oof estupia, wandered into the",
|
||||
"&7&olands of cranked and guards it",
|
||||
"&7&owith his life to this very day..",
|
||||
"",
|
||||
"&e&lINFO",
|
||||
" &f• Difficulty: &c&lHARD",
|
||||
" &f• Warzone Only: &a&lTRUE"
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BossAttributes getAttributes() {
|
||||
return BossAttributes.builder().build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Short getSpawnEggId() {
|
||||
return 56;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Sound getSpawnSound() {
|
||||
return Sound.IRONGOLEM_WALK;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Sound getDeathSound() {
|
||||
return Sound.IRONGOLEM_DEATH;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PotionEffect> getEffects() {
|
||||
return Arrays.asList(new PotionEffect(PotionEffectType.FIRE_RESISTANCE, Integer.MAX_VALUE, 0, true, false),
|
||||
new PotionEffect(PotionEffectType.SPEED, Integer.MAX_VALUE, 4, true, false),
|
||||
new PotionEffect(PotionEffectType.FAST_DIGGING, Integer.MAX_VALUE, 4, true, false)
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityType getEntityType() {
|
||||
return EntityType.IRON_GOLEM;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBaby() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public LootTableType getLootTableType() {
|
||||
return LootTableType.SEASON_KEY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRewardAmount() {
|
||||
return 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMaxHealth() {
|
||||
return 350.0D;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean showDeathMessage() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BossRewardSystem getBossRewardSystem() {
|
||||
return BossRewardSystem.GIVE_TO_TOP_3_PLAYERS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean showsInGui() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected BossPhaseInfo getPhaseOne() {
|
||||
return BossPhaseInfo.builder()
|
||||
.outgoingDamageIncrease(250)
|
||||
.incomingDamageDecrease(5)
|
||||
.abilities(Arrays.asList(BossAbilities.DAMAGE_TICK, BossAbilities.LIGHTNING_STRIKE, BossAbilities.LAUNCH))
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected BossPhaseInfo getPhaseTwo() {
|
||||
return BossPhaseInfo.builder()
|
||||
.outgoingDamageIncrease(500)
|
||||
.incomingDamageDecrease(5)
|
||||
.abilities(Arrays.asList(BossAbilities.KNOCKBACK, BossAbilities.DAMAGE_TICK, BossAbilities.LIGHTNING_STRIKE, BossAbilities.SHOOT_ARROW))
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected BossPhaseInfo getPhaseThree() {
|
||||
return BossPhaseInfo.builder()
|
||||
.outgoingDamageIncrease(1000)
|
||||
.incomingDamageDecrease(5)
|
||||
.abilities(Arrays.asList(BossAbilities.TRAP, BossAbilities.PULL, BossAbilities.KNOCKBACK, BossAbilities.DAMAGE_TICK, BossAbilities.LIGHTNING_STRIKE, BossAbilities.SHOOT_ARROW, BossAbilities.LAUNCH))
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void afterSpawn(LivingEntity livingEntity) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public String getSubTitle() {
|
||||
return "The cranked guardian has trapped you";
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getTickDamage() {
|
||||
return 3;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCooldownLength() {
|
||||
return 15;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,205 @@
|
||||
package net.crankedpvp.bosses.bosses;
|
||||
|
||||
import net.crankedpvp.bosses.interfaces.Incrementable;
|
||||
import net.crankedpvp.bosses.interfaces.TrapAttributes;
|
||||
import net.crankedpvp.bosses.struct.*;
|
||||
import net.crankedpvp.crankedutils.utils.items.ItemBuilder;
|
||||
import net.crankedpvp.crankedutils.utils.items.SkullUtils;
|
||||
import net.crankedpvp.loottable.struct.LootTableType;
|
||||
import org.bukkit.Color;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Skeleton;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class Cranker extends Boss implements TrapAttributes, Incrementable {
|
||||
@Override
|
||||
public String getName() {
|
||||
return "Cranker";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getBossDisplayName() {
|
||||
return "&4&lCranker &8| {health}";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSpawnEggName() {
|
||||
return "&c&ki&4✧&c&ki&r &4&lCranker &c&ki&4✧&c&ki&r";
|
||||
}
|
||||
|
||||
@Override
|
||||
public BossGear getBossGear() {
|
||||
return BossGear.builder()
|
||||
.helmet(new ItemBuilder(SkullUtils.getSkull("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNDdjYTc4ODNiMWI5YjJiYjU4OGUxYTcxZDMzYjI5MjNiN2M3OTI2ZGZiYTZkYjEzNDE0MzM5OTYxMTM2ZmRkOCJ9fX0=")))
|
||||
.weapon(new ItemBuilder(Material.DIAMOND_SWORD).addEnchantment(Enchantment.DAMAGE_ALL, 5))
|
||||
.chestplate(new ItemBuilder(Material.LEATHER_CHESTPLATE).setLeatherArmorColor(Color.RED).setGlowing())
|
||||
.leggings(new ItemBuilder(Material.LEATHER_LEGGINGS).setLeatherArmorColor(Color.RED).setGlowing())
|
||||
.boots(new ItemBuilder(Material.LEATHER_BOOTS).setLeatherArmorColor(Color.RED).setGlowing())
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getSpawnEggLore() {
|
||||
return Arrays.asList(
|
||||
"&7This monster egg contains a",
|
||||
"&cdangerous &7warzone boss.",
|
||||
"",
|
||||
"&4&lLORE",
|
||||
"&7&oAn allegedly impossible boss",
|
||||
"&7&ofrom early 2018... are you able",
|
||||
"&7&oto defeat it now? Or will it",
|
||||
"&7&ostill rule the world...?",
|
||||
"",
|
||||
"&4&lINFO",
|
||||
" &f• Difficulty: &4&lEXTREME",
|
||||
" &f• Warzone Only: &a&lTRUE"
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BossAttributes getAttributes() {
|
||||
return BossAttributes.builder().build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Short getSpawnEggId() {
|
||||
return 67;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Sound getSpawnSound() {
|
||||
return Sound.WITHER_SPAWN;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Sound getDeathSound() {
|
||||
return Sound.WITHER_DEATH;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PotionEffect> getEffects() {
|
||||
return Arrays.asList(new PotionEffect(PotionEffectType.FIRE_RESISTANCE, Integer.MAX_VALUE, 0, true, false),
|
||||
new PotionEffect(PotionEffectType.SPEED, Integer.MAX_VALUE, 4, true, false),
|
||||
new PotionEffect(PotionEffectType.FAST_DIGGING, Integer.MAX_VALUE, 4, true, false)
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityType getEntityType() {
|
||||
return EntityType.SKELETON;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBaby() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public LootTableType getLootTableType() {
|
||||
return LootTableType.SEASON_KEY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRewardAmount() {
|
||||
return 5;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMaxHealth() {
|
||||
return 1000.0D;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean showDeathMessage() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BossRewardSystem getBossRewardSystem() {
|
||||
return BossRewardSystem.GIVE_TO_TOP_3_PLAYERS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean showsInGui() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected BossPhaseInfo getPhaseOne() {
|
||||
return BossPhaseInfo.builder()
|
||||
.outgoingDamageIncrease(650)
|
||||
.abilities(Arrays.asList(
|
||||
BossAbilities.LIGHTNING_STRIKE,
|
||||
BossAbilities.PULL,
|
||||
BossAbilities.KNOCKBACK,
|
||||
BossAbilities.DAMAGE_TICK,
|
||||
BossAbilities.SHOOT_ARROW,
|
||||
BossAbilities.LAUNCH
|
||||
))
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected BossPhaseInfo getPhaseTwo() {
|
||||
return BossPhaseInfo.builder()
|
||||
.outgoingDamageIncrease(1000)
|
||||
.abilities(Arrays.asList(
|
||||
BossAbilities.LIGHTNING_STRIKE,
|
||||
BossAbilities.TRAP,
|
||||
BossAbilities.PULL,
|
||||
BossAbilities.KNOCKBACK,
|
||||
BossAbilities.DAMAGE_TICK,
|
||||
BossAbilities.SHOOT_ARROW,
|
||||
BossAbilities.LAUNCH
|
||||
))
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected BossPhaseInfo getPhaseThree() {
|
||||
return BossPhaseInfo.builder()
|
||||
.outgoingDamageIncrease(1500)
|
||||
.incomingDamageDecrease(5)
|
||||
.abilities(Arrays.asList(
|
||||
BossAbilities.LIGHTNING_STRIKE,
|
||||
BossAbilities.TRAP,
|
||||
BossAbilities.PULL,
|
||||
BossAbilities.KNOCKBACK,
|
||||
BossAbilities.DAMAGE_TICK,
|
||||
BossAbilities.SHOOT_ARROW,
|
||||
BossAbilities.LAUNCH
|
||||
))
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void afterSpawn(LivingEntity livingEntity) {
|
||||
((Skeleton) livingEntity).setSkeletonType(Skeleton.SkeletonType.WITHER);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public String getSubTitle() {
|
||||
return "Your &csoul &7is mine... love, &4Cranker";
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getTickDamage() {
|
||||
return 4;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCooldownLength() {
|
||||
return 18;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,155 @@
|
||||
package net.crankedpvp.bosses.bosses;
|
||||
|
||||
import net.crankedpvp.bosses.interfaces.Incrementable;
|
||||
import net.crankedpvp.bosses.struct.*;
|
||||
import net.crankedpvp.loottable.struct.LootTableType;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Wolf;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class CrazedWerewolf extends Boss implements Incrementable {
|
||||
@Override
|
||||
public String getName() {
|
||||
return "Crazed Werewolf";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getBossDisplayName() {
|
||||
return "&b&lCrazed Werewolf &8| {health}";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSpawnEggName() {
|
||||
return "&b&lCrazed Werewolf Spawn Egg";
|
||||
}
|
||||
|
||||
@Override
|
||||
public BossGear getBossGear() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getSpawnEggLore() {
|
||||
return Arrays.asList(
|
||||
"&7This monster egg contains a",
|
||||
"&cdangerous &7warzone boss.",
|
||||
"",
|
||||
"&b&lLORE",
|
||||
"&7&oA werewolf would usually stay with",
|
||||
"&7&oit's pack, with it's family..",
|
||||
"&7&oUnless it was crazy, and had unusual",
|
||||
"&7&oideas and intentions...",
|
||||
"",
|
||||
"&b&lINFO",
|
||||
" &f• Difficulty: &a&lEASY",
|
||||
" &f• Warzone Only: &c&lFALSE"
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BossAttributes getAttributes() {
|
||||
return BossAttributes.builder().build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Short getSpawnEggId() {
|
||||
return 95;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Sound getSpawnSound() {
|
||||
return Sound.WOLF_BARK;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Sound getDeathSound() {
|
||||
return Sound.WOLF_DEATH;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PotionEffect> getEffects() {
|
||||
return Arrays.asList(new PotionEffect(PotionEffectType.FIRE_RESISTANCE, Integer.MAX_VALUE, 0, true, false),
|
||||
new PotionEffect(PotionEffectType.SPEED, Integer.MAX_VALUE, 2, true, false));
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityType getEntityType() {
|
||||
return EntityType.WOLF;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBaby() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public LootTableType getLootTableType() {
|
||||
return LootTableType.MYTHIC_KEY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRewardAmount() {
|
||||
return 3;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMaxHealth() {
|
||||
return 300.0D;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean showDeathMessage() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BossRewardSystem getBossRewardSystem() {
|
||||
return BossRewardSystem.GIVE_TO_TOP_PLAYER;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean showsInGui() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected BossPhaseInfo getPhaseOne() {
|
||||
return BossPhaseInfo.builder()
|
||||
.outgoingDamageIncrease(30)
|
||||
.incomingDamageDecrease(5)
|
||||
.abilities(Collections.singletonList(BossAbilities.DAMAGE_TICK))
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected BossPhaseInfo getPhaseTwo() {
|
||||
return BossPhaseInfo.builder()
|
||||
.outgoingDamageIncrease(60)
|
||||
.incomingDamageDecrease(10)
|
||||
.abilities(Collections.singletonList(BossAbilities.DAMAGE_TICK))
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected BossPhaseInfo getPhaseThree() {
|
||||
return BossPhaseInfo.builder()
|
||||
.outgoingDamageIncrease(90)
|
||||
.incomingDamageDecrease(15)
|
||||
.abilities(Collections.singletonList(BossAbilities.DAMAGE_TICK))
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void afterSpawn(LivingEntity livingEntity) {
|
||||
((Wolf) livingEntity).setAngry(true);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,153 @@
|
||||
package net.crankedpvp.bosses.bosses;
|
||||
|
||||
import net.crankedpvp.bosses.interfaces.Incrementable;
|
||||
import net.crankedpvp.bosses.struct.*;
|
||||
import net.crankedpvp.loottable.struct.LootTableType;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class FireLord extends Boss implements Incrementable {
|
||||
@Override
|
||||
public String getName() {
|
||||
return "Fire Lord";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getBossDisplayName() {
|
||||
return "&6&lFire Lord &8| {health}";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSpawnEggName() {
|
||||
return "&6&lFire Lord Spawn Egg";
|
||||
}
|
||||
|
||||
@Override
|
||||
public BossGear getBossGear() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getSpawnEggLore() {
|
||||
return Arrays.asList(
|
||||
"&7This monster egg contains a",
|
||||
"&cdangerous &7warzone boss.",
|
||||
"",
|
||||
"&6&lLORE",
|
||||
"&7&oHow did the fire lord escape",
|
||||
"&7&othe nether? Who knows, but it",
|
||||
"&7&odoesn't matter.. it's here now.",
|
||||
"",
|
||||
"&6&lINFO",
|
||||
" &f• Difficulty: &a&lEASY",
|
||||
" &f• Warzone Only: &c&lFALSE"
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BossAttributes getAttributes() {
|
||||
return BossAttributes.builder().build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Short getSpawnEggId() {
|
||||
return 61;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Sound getSpawnSound() {
|
||||
return Sound.BLAZE_BREATH;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Sound getDeathSound() {
|
||||
return Sound.BLAZE_DEATH;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PotionEffect> getEffects() {
|
||||
return Arrays.asList(new PotionEffect(PotionEffectType.FIRE_RESISTANCE, Integer.MAX_VALUE, 0, true, false),
|
||||
new PotionEffect(PotionEffectType.SPEED, Integer.MAX_VALUE, 1, true, false));
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityType getEntityType() {
|
||||
return EntityType.BLAZE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBaby() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public LootTableType getLootTableType() {
|
||||
return LootTableType.MYTHIC_KEY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRewardAmount() {
|
||||
return 3;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMaxHealth() {
|
||||
return 350.0D;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean showDeathMessage() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BossRewardSystem getBossRewardSystem() {
|
||||
return BossRewardSystem.GIVE_TO_TOP_PLAYER;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean showsInGui() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected BossPhaseInfo getPhaseOne() {
|
||||
return BossPhaseInfo.builder()
|
||||
.outgoingDamageIncrease(30)
|
||||
.incomingDamageDecrease(5)
|
||||
.abilities(Collections.singletonList(BossAbilities.DAMAGE_TICK))
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected BossPhaseInfo getPhaseTwo() {
|
||||
return BossPhaseInfo.builder()
|
||||
.outgoingDamageIncrease(60)
|
||||
.incomingDamageDecrease(10)
|
||||
.abilities(Collections.singletonList(BossAbilities.DAMAGE_TICK))
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected BossPhaseInfo getPhaseThree() {
|
||||
return BossPhaseInfo.builder()
|
||||
.outgoingDamageIncrease(90)
|
||||
.incomingDamageDecrease(15)
|
||||
.abilities(Collections.singletonList(BossAbilities.DAMAGE_TICK))
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void afterSpawn(LivingEntity livingEntity) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,180 @@
|
||||
package net.crankedpvp.bosses.bosses;
|
||||
|
||||
import net.crankedpvp.bosses.interfaces.Incrementable;
|
||||
import net.crankedpvp.bosses.interfaces.TrapAttributes;
|
||||
import net.crankedpvp.bosses.interfaces.WarzoneOnly;
|
||||
import net.crankedpvp.bosses.struct.*;
|
||||
import net.crankedpvp.crankedutils.utils.items.ItemBuilder;
|
||||
import net.crankedpvp.loottable.struct.LootTableType;
|
||||
import org.bukkit.Color;
|
||||
import org.bukkit.DyeColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class Gauntlet extends Boss implements TrapAttributes, Incrementable, WarzoneOnly {
|
||||
@Override
|
||||
public String getName() {
|
||||
return "Gauntlet";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getBossDisplayName() {
|
||||
return "&6&lThe Gauntlet &8| {health}";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSpawnEggName() {
|
||||
return "&6&lThe Gauntlet";
|
||||
}
|
||||
|
||||
@Override
|
||||
public BossGear getBossGear() {
|
||||
return BossGear.builder()
|
||||
.weapon(new ItemBuilder(Material.GOLD_AXE).setGlowing())
|
||||
.helmet(new ItemBuilder(Material.STAINED_GLASS, 1, DyeColor.RED.getData()).setGlowing())
|
||||
.chestplate(new ItemBuilder(Material.LEATHER_CHESTPLATE).setLeatherArmorColor(Color.GRAY).setGlowing())
|
||||
.leggings(new ItemBuilder(Material.LEATHER_LEGGINGS).setLeatherArmorColor(Color.GRAY).setGlowing())
|
||||
.boots(new ItemBuilder(Material.LEATHER_BOOTS).setLeatherArmorColor(Color.GRAY).setGlowing())
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getSpawnEggLore() {
|
||||
return Arrays.asList(
|
||||
"&7This monster egg contains a",
|
||||
"&cdangerous &7warzone boss.",
|
||||
"",
|
||||
"&6&lLORE",
|
||||
"&7&oIt's no longer just a glove.",
|
||||
"&7&oThis is THE gauntlet. Good luck",
|
||||
"&7&ofighting him, you'll need it.",
|
||||
"&7&oThe gauntlet awakens...",
|
||||
"",
|
||||
"&6&lINFO",
|
||||
" &f• Difficulty: &c&lHARD",
|
||||
" &f• Warzone Only: &a&lTRUE"
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BossAttributes getAttributes() {
|
||||
return BossAttributes.builder().build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Short getSpawnEggId() {
|
||||
return 54;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Sound getSpawnSound() {
|
||||
return Sound.ZOMBIE_WOODBREAK;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Sound getDeathSound() {
|
||||
return Sound.ZOMBIE_DEATH;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PotionEffect> getEffects() {
|
||||
return Arrays.asList(new PotionEffect(PotionEffectType.FIRE_RESISTANCE, Integer.MAX_VALUE, 0, true, false),
|
||||
new PotionEffect(PotionEffectType.SPEED, Integer.MAX_VALUE, 3, true, false));
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityType getEntityType() {
|
||||
return EntityType.ZOMBIE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBaby() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public LootTableType getLootTableType() {
|
||||
return LootTableType.SEASON_KEY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRewardAmount() {
|
||||
return 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMaxHealth() {
|
||||
return 1000.0D;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean showDeathMessage() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BossRewardSystem getBossRewardSystem() {
|
||||
return BossRewardSystem.GIVE_TO_TOP_3_PLAYERS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean showsInGui() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected BossPhaseInfo getPhaseOne() {
|
||||
return BossPhaseInfo.builder()
|
||||
.outgoingDamageIncrease(650)
|
||||
.incomingDamageDecrease(20)
|
||||
.abilities(Arrays.asList(BossAbilities.LIGHTNING_STRIKE))
|
||||
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected BossPhaseInfo getPhaseTwo() {
|
||||
return BossPhaseInfo.builder()
|
||||
.outgoingDamageIncrease(950)
|
||||
.incomingDamageDecrease(25)
|
||||
.abilities(Arrays.asList(BossAbilities.LIGHTNING_STRIKE, BossAbilities.TRAP, BossAbilities.DAMAGE_TICK))
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected BossPhaseInfo getPhaseThree() {
|
||||
return BossPhaseInfo.builder()
|
||||
.outgoingDamageIncrease(1400)
|
||||
.incomingDamageDecrease(50)
|
||||
.abilities(Arrays.asList(BossAbilities.LIGHTNING_STRIKE, BossAbilities.TRAP, BossAbilities.HEAL, BossAbilities.DAMAGE_TICK))
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void afterSpawn(LivingEntity livingEntity) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getSubTitle() {
|
||||
return "The gauntlet boss has trapped you";
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getTickDamage() {
|
||||
return 3;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCooldownLength() {
|
||||
return 15;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,161 @@
|
||||
package net.crankedpvp.bosses.bosses;
|
||||
|
||||
import net.crankedpvp.bosses.interfaces.Incrementable;
|
||||
import net.crankedpvp.bosses.struct.*;
|
||||
import net.crankedpvp.crankedutils.utils.items.ItemBuilder;
|
||||
import net.crankedpvp.loottable.struct.LootTableType;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Slime;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class KingSlime extends Boss implements Incrementable {
|
||||
@Override
|
||||
public String getName() {
|
||||
return "King Slime";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getBossDisplayName() {
|
||||
return "&e&lKing Slime &8| &7{health}";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSpawnEggName() {
|
||||
return "&e&lKing Slime";
|
||||
}
|
||||
|
||||
@Override
|
||||
public BossGear getBossGear() {
|
||||
return BossGear.builder()
|
||||
.boots(new ItemBuilder(Material.DIAMOND_BOOTS))
|
||||
.leggings(new ItemBuilder(Material.DIAMOND_LEGGINGS))
|
||||
.chestplate(new ItemBuilder(Material.DIAMOND_CHESTPLATE))
|
||||
.helmet(new ItemBuilder(Material.DIAMOND_HELMET))
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getSpawnEggLore() {
|
||||
return Arrays.asList(
|
||||
"&7This monster egg contains a",
|
||||
"&cdangerous &7warzone boss.",
|
||||
"",
|
||||
"&e&lLORE",
|
||||
"&7&oAn enormous slime, rumored to be",
|
||||
"&7&othe king of all slimes in the",
|
||||
"&7&oCosmoverse. Apparently he has",
|
||||
"&7&oanger issues. Be warned...",
|
||||
"",
|
||||
"&e&lINFO",
|
||||
" &f• Difficulty: &e&lMEDIUM",
|
||||
" &f• Warzone Only: &c&lFALSE"
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BossAttributes getAttributes() {
|
||||
return BossAttributes.builder().build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Short getSpawnEggId() {
|
||||
return 55;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Sound getSpawnSound() {
|
||||
return Sound.SLIME_WALK;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Sound getDeathSound() {
|
||||
return Sound.SLIME_ATTACK;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PotionEffect> getEffects() {
|
||||
return Collections.singletonList(new PotionEffect(PotionEffectType.FIRE_RESISTANCE, Integer.MAX_VALUE, 0, true, false));
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityType getEntityType() {
|
||||
return EntityType.SLIME;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBaby() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public LootTableType getLootTableType() {
|
||||
return LootTableType.MYTHIC_KEY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRewardAmount() {
|
||||
return 5;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMaxHealth() {
|
||||
return 2000.0D;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean showDeathMessage() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BossRewardSystem getBossRewardSystem() {
|
||||
return BossRewardSystem.GIVE_TO_TOP_3_PLAYERS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean showsInGui() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected BossPhaseInfo getPhaseOne() {
|
||||
return BossPhaseInfo.builder()
|
||||
.outgoingDamageIncrease(250)
|
||||
.incomingDamageDecrease(15)
|
||||
.abilities(Collections.singletonList(BossAbilities.KNOCKBACK))
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected BossPhaseInfo getPhaseTwo() {
|
||||
return BossPhaseInfo.builder()
|
||||
.outgoingDamageIncrease(500)
|
||||
.incomingDamageDecrease(30)
|
||||
.abilities(Arrays.asList(BossAbilities.DAMAGE_TICK))
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected BossPhaseInfo getPhaseThree() {
|
||||
return BossPhaseInfo.builder()
|
||||
.outgoingDamageIncrease(1000)
|
||||
.incomingDamageDecrease(50)
|
||||
.abilities(Arrays.asList(BossAbilities.HEAL, BossAbilities.DAMAGE_TICK))
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void afterSpawn(LivingEntity livingEntity) {
|
||||
((Slime)livingEntity).setSize(8);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,177 @@
|
||||
package net.crankedpvp.bosses.bosses;
|
||||
|
||||
import net.crankedpvp.bosses.interfaces.Incrementable;
|
||||
import net.crankedpvp.bosses.interfaces.TrapAttributes;
|
||||
import net.crankedpvp.bosses.struct.*;
|
||||
import net.crankedpvp.crankedutils.utils.items.ItemBuilder;
|
||||
import net.crankedpvp.loottable.struct.LootTableType;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class PlagueBloater extends Boss implements TrapAttributes, Incrementable {
|
||||
@Override
|
||||
public String getName() {
|
||||
return "Plague Bloater";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getBossDisplayName() {
|
||||
return "&2&lPlague Bloater &8| {health}";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSpawnEggName() {
|
||||
return "&2&lPlague Bloater";
|
||||
}
|
||||
|
||||
@Override
|
||||
public BossGear getBossGear() {
|
||||
return BossGear.builder()
|
||||
.weapon(new ItemBuilder(Material.DIAMOND_AXE).addEnchantment(Enchantment.DAMAGE_ALL, 5).setGlowing())
|
||||
.helmet(new ItemBuilder(Material.DIAMOND_HELMET).setGlowing())
|
||||
.chestplate(new ItemBuilder(Material.DIAMOND_CHESTPLATE).setGlowing())
|
||||
.leggings(new ItemBuilder(Material.DIAMOND_LEGGINGS).setGlowing())
|
||||
.boots(new ItemBuilder(Material.DIAMOND_BOOTS).setGlowing())
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getSpawnEggLore() {
|
||||
return Arrays.asList(
|
||||
"&7This monster egg contains a",
|
||||
"&cdangerous &7warzone boss.",
|
||||
"",
|
||||
"&2&lLORE",
|
||||
"&7&oThe host vessel of the most deadly",
|
||||
"&7&oplague virus strain ever",
|
||||
"&7&odiscovered. Wherever this",
|
||||
"&7&oabomination goes, death soon",
|
||||
"&7&ofollows. stay weary..",
|
||||
"",
|
||||
"&2&lDIFFICULTY",
|
||||
"&2Ultimate"
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BossAttributes getAttributes() {
|
||||
return BossAttributes.builder().build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Short getSpawnEggId() {
|
||||
return 54;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Sound getSpawnSound() {
|
||||
return Sound.ZOMBIE_WOODBREAK;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Sound getDeathSound() {
|
||||
return Sound.ZOMBIE_DEATH;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PotionEffect> getEffects() {
|
||||
return Arrays.asList(
|
||||
new PotionEffect(PotionEffectType.FIRE_RESISTANCE, Integer.MAX_VALUE, 0, true, false),
|
||||
new PotionEffect(PotionEffectType.SPEED, Integer.MAX_VALUE, 2, true, false)
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityType getEntityType() {
|
||||
return EntityType.GIANT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBaby() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public LootTableType getLootTableType() {
|
||||
return LootTableType.ABYSS_KEY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRewardAmount() {
|
||||
return 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMaxHealth() {
|
||||
return 2500.0D;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean showDeathMessage() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BossRewardSystem getBossRewardSystem() {
|
||||
return BossRewardSystem.GIVE_TO_TOP_3_PLAYERS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean showsInGui() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected BossPhaseInfo getPhaseOne() {
|
||||
return BossPhaseInfo.builder()
|
||||
.outgoingDamageIncrease(250)
|
||||
.incomingDamageDecrease(10)
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected BossPhaseInfo getPhaseTwo() {
|
||||
return BossPhaseInfo.builder()
|
||||
.outgoingDamageIncrease(500)
|
||||
.incomingDamageDecrease(20)
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected BossPhaseInfo getPhaseThree() {
|
||||
return BossPhaseInfo.builder()
|
||||
.outgoingDamageIncrease(1000)
|
||||
.incomingDamageDecrease(30)
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void afterSpawn(LivingEntity livingEntity) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public String getSubTitle() {
|
||||
return "The cranked guardian has trapped you";
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getTickDamage() {
|
||||
return 5;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCooldownLength() {
|
||||
return 12;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,158 @@
|
||||
package net.crankedpvp.bosses.bosses;
|
||||
|
||||
import net.crankedpvp.bosses.interfaces.Incrementable;
|
||||
import net.crankedpvp.bosses.struct.*;
|
||||
import net.crankedpvp.loottable.struct.LootTableType;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Slime;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class Slimicle extends Boss implements Incrementable {
|
||||
@Override
|
||||
public String getName() {
|
||||
return "Slimicle";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getBossDisplayName() {
|
||||
return "&a&lSlimicle &8| {health}";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSpawnEggName() {
|
||||
return "&a&lSlimicle Spawn Egg";
|
||||
}
|
||||
|
||||
@Override
|
||||
public BossGear getBossGear() {
|
||||
return BossGear.builder()
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getSpawnEggLore() {
|
||||
return Arrays.asList(
|
||||
"&7This monster egg contains a",
|
||||
"&cdangerous &7warzone boss.",
|
||||
"",
|
||||
"&a&lLORE",
|
||||
"&7&oA child of the King Slime",
|
||||
"&7&oWill it hold the same power",
|
||||
"&7&oas it's ancestors? Let's hope",
|
||||
"&7&oit doesn't...",
|
||||
"",
|
||||
"&a&lINFO",
|
||||
" &f• Difficulty: &a&lEASY",
|
||||
" &f• Warzone Only: &c&lFALSE"
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BossAttributes getAttributes() {
|
||||
return BossAttributes.builder().build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Short getSpawnEggId() {
|
||||
return 55;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Sound getSpawnSound() {
|
||||
return Sound.SLIME_WALK;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Sound getDeathSound() {
|
||||
return Sound.SLIME_ATTACK;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PotionEffect> getEffects() {
|
||||
return Arrays.asList(new PotionEffect(PotionEffectType.FIRE_RESISTANCE, Integer.MAX_VALUE, 0, true, false),
|
||||
new PotionEffect(PotionEffectType.SPEED, Integer.MAX_VALUE, 1, true, false));
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityType getEntityType() {
|
||||
return EntityType.SLIME;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBaby() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public LootTableType getLootTableType() {
|
||||
return LootTableType.MYTHIC_KEY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRewardAmount() {
|
||||
return 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMaxHealth() {
|
||||
return 400.0D;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean showDeathMessage() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BossRewardSystem getBossRewardSystem() {
|
||||
return BossRewardSystem.GIVE_TO_TOP_PLAYER;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean showsInGui() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected BossPhaseInfo getPhaseOne() {
|
||||
return BossPhaseInfo.builder()
|
||||
.outgoingDamageIncrease(30)
|
||||
.incomingDamageDecrease(5)
|
||||
.abilities(Collections.singletonList(BossAbilities.DAMAGE_TICK))
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected BossPhaseInfo getPhaseTwo() {
|
||||
return BossPhaseInfo.builder()
|
||||
.outgoingDamageIncrease(60)
|
||||
.incomingDamageDecrease(15)
|
||||
.abilities(Collections.singletonList(BossAbilities.DAMAGE_TICK))
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected BossPhaseInfo getPhaseThree() {
|
||||
return BossPhaseInfo.builder()
|
||||
.outgoingDamageIncrease(90)
|
||||
.incomingDamageDecrease(30)
|
||||
.abilities(Collections.singletonList(BossAbilities.DAMAGE_TICK))
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void afterSpawn(LivingEntity livingEntity) {
|
||||
((Slime)livingEntity).setSize(4);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,150 @@
|
||||
package net.crankedpvp.bosses.bosses;
|
||||
|
||||
import net.crankedpvp.bosses.interfaces.Incrementable;
|
||||
import net.crankedpvp.bosses.struct.*;
|
||||
import net.crankedpvp.crankedutils.utils.items.ItemBuilder;
|
||||
import net.crankedpvp.loottable.struct.LootTableType;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class TreasureGoblin extends Boss implements Incrementable {
|
||||
@Override
|
||||
public String getName() {
|
||||
return "Treasure Goblin";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getBossDisplayName() {
|
||||
return "&6&lTreasure Goblin";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSpawnEggName() {
|
||||
return "&6&lTreasure Goblin";
|
||||
}
|
||||
|
||||
@Override
|
||||
public BossGear getBossGear() {
|
||||
return BossGear.builder()
|
||||
.boots(new ItemBuilder(Material.GOLD_BOOTS)).build();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getSpawnEggLore() {
|
||||
return Arrays.asList(
|
||||
"&7This monster egg contains a",
|
||||
"&cdangerous &7warzone boss.",
|
||||
"",
|
||||
"&6&lLORE",
|
||||
"&7&oTreasure Goblin.. back from",
|
||||
"&7&othe dead, he's here scavenging",
|
||||
"&7&ofor treasures his family left",
|
||||
"&7&obehind in 2018.. take more from him",
|
||||
"",
|
||||
"&6&lINFO",
|
||||
" &f• Difficulty: &6&lEVENT",
|
||||
" &f• Warzone Only: &c&lFALSE"
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BossAttributes getAttributes() {
|
||||
return BossAttributes.builder().build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Short getSpawnEggId() {
|
||||
return 62;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Sound getSpawnSound() {
|
||||
return Sound.ZOMBIE_PIG_IDLE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Sound getDeathSound() {
|
||||
return Sound.ZOMBIE_PIG_DEATH;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PotionEffect> getEffects() {
|
||||
return Arrays.asList(new PotionEffect(PotionEffectType.FIRE_RESISTANCE, Integer.MAX_VALUE, 0, true, false),
|
||||
new PotionEffect(PotionEffectType.SPEED, Integer.MAX_VALUE, 2, true, false));
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityType getEntityType() {
|
||||
return EntityType.PIG_ZOMBIE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBaby() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public LootTableType getLootTableType() {
|
||||
return LootTableType.ABYSS_KEY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRewardAmount() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMaxHealth() {
|
||||
return 15.0D;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean showDeathMessage() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BossRewardSystem getBossRewardSystem() {
|
||||
return BossRewardSystem.GIVE_TO_TOP_PLAYER;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean showsInGui() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected BossPhaseInfo getPhaseOne() {
|
||||
return BossPhaseInfo.builder()
|
||||
.abilities(Arrays.asList(BossAbilities.TREASURE_GOBLIN_LOOT))
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected BossPhaseInfo getPhaseTwo() {
|
||||
return BossPhaseInfo.builder()
|
||||
.abilities(Arrays.asList(BossAbilities.TREASURE_GOBLIN_LOOT))
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected BossPhaseInfo getPhaseThree() {
|
||||
return BossPhaseInfo.builder()
|
||||
.abilities(Arrays.asList(BossAbilities.TREASURE_GOBLIN_LOOT))
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void afterSpawn(LivingEntity livingEntity) {
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,158 @@
|
||||
package net.crankedpvp.bosses.bosses;
|
||||
|
||||
import net.crankedpvp.bosses.interfaces.Incrementable;
|
||||
import net.crankedpvp.bosses.struct.*;
|
||||
import net.crankedpvp.crankedutils.utils.items.ItemBuilder;
|
||||
import net.crankedpvp.loottable.struct.LootTableType;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class Warlord extends Boss implements Incrementable {
|
||||
@Override
|
||||
public String getName() {
|
||||
return "Warlord";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getBossDisplayName() {
|
||||
return "&c&lWarlord &8| {health}";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSpawnEggName() {
|
||||
return "&c&lWarlord Spawn Egg";
|
||||
}
|
||||
|
||||
@Override
|
||||
public BossGear getBossGear() {
|
||||
return BossGear.builder()
|
||||
.weapon(new ItemBuilder(Material.GOLD_AXE))
|
||||
.helmet(new ItemBuilder(Material.GOLD_HELMET).setGlowing())
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getSpawnEggLore() {
|
||||
return Arrays.asList(
|
||||
"&7This monster egg contains a",
|
||||
"&cdangerous &7warzone boss.",
|
||||
"",
|
||||
"&c&lLORE",
|
||||
"&7&oAlthough it seems easy at first,",
|
||||
"&7&othe Warlord can be challenging",
|
||||
"&7&oat times, don't underestimate it",
|
||||
"",
|
||||
"&c&lINFO",
|
||||
" &f• Difficulty: &a&lEASY",
|
||||
" &f• Warzone Only: &c&lFALSE"
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BossAttributes getAttributes() {
|
||||
return BossAttributes.builder().build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Short getSpawnEggId() {
|
||||
return 54;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Sound getSpawnSound() {
|
||||
return Sound.ZOMBIE_WOODBREAK;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Sound getDeathSound() {
|
||||
return Sound.ZOMBIE_DEATH;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PotionEffect> getEffects() {
|
||||
return Arrays.asList(new PotionEffect(PotionEffectType.FIRE_RESISTANCE, Integer.MAX_VALUE, 0, true, false),
|
||||
new PotionEffect(PotionEffectType.SPEED, Integer.MAX_VALUE, 1, true, false));
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityType getEntityType() {
|
||||
return EntityType.ZOMBIE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBaby() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public LootTableType getLootTableType() {
|
||||
return LootTableType.MYTHIC_KEY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRewardAmount() {
|
||||
return 3;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMaxHealth() {
|
||||
return 250.0D;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean showDeathMessage() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BossRewardSystem getBossRewardSystem() {
|
||||
return BossRewardSystem.GIVE_TO_TOP_PLAYER;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean showsInGui() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected BossPhaseInfo getPhaseOne() {
|
||||
return BossPhaseInfo.builder()
|
||||
.outgoingDamageIncrease(30)
|
||||
.incomingDamageDecrease(5)
|
||||
.abilities(Collections.singletonList(BossAbilities.DAMAGE_TICK))
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected BossPhaseInfo getPhaseTwo() {
|
||||
return BossPhaseInfo.builder()
|
||||
.outgoingDamageIncrease(60)
|
||||
.incomingDamageDecrease(10)
|
||||
.abilities(Collections.singletonList(BossAbilities.DAMAGE_TICK))
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected BossPhaseInfo getPhaseThree() {
|
||||
return BossPhaseInfo.builder()
|
||||
.outgoingDamageIncrease(90)
|
||||
.incomingDamageDecrease(15)
|
||||
.abilities(Collections.singletonList(BossAbilities.DAMAGE_TICK))
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void afterSpawn(LivingEntity livingEntity) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
package net.crankedpvp.bosses.commands;
|
||||
|
||||
import me.mattstudios.mf.annotations.*;
|
||||
import me.mattstudios.mf.base.CommandBase;
|
||||
import net.crankedpvp.bosses.BossPlugin;
|
||||
import net.crankedpvp.bosses.language.Language;
|
||||
import net.crankedpvp.bosses.language.LanguageHandler;
|
||||
import net.crankedpvp.bosses.struct.Boss;
|
||||
import net.crankedpvp.bosses.struct.BossManager;
|
||||
import net.crankedpvp.crankedutils.utils.InventoryUtils;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
@Command("cbo")
|
||||
@Alias({"cboss", "cbosses"})
|
||||
public class AdminCommand extends CommandBase {
|
||||
|
||||
private final LanguageHandler languageHandler;
|
||||
private BossPlugin plugin;
|
||||
|
||||
|
||||
private final BossManager bossManager;
|
||||
|
||||
public AdminCommand(BossPlugin plugin) {
|
||||
this.bossManager = plugin.getBossManager();
|
||||
this.languageHandler = plugin.getLanguageHandler();
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Default
|
||||
@Permission("cranked.admin")
|
||||
public void mainCommand(CommandSender sender) {
|
||||
Language.CBO_COMMAND_HELP.send(sender);
|
||||
}
|
||||
|
||||
@SubCommand("reload")
|
||||
@WrongUsage("&cUsage: /cbo reload")
|
||||
@Permission("cranked.admin")
|
||||
public void reloadCommand(Player sender) {
|
||||
Language.ADMIN_RELOADING.send(sender);
|
||||
long then = System.currentTimeMillis();
|
||||
|
||||
this.languageHandler.load();
|
||||
this.plugin.getBossConfigManager().reloadFiles();
|
||||
|
||||
long diff = System.currentTimeMillis() - then;
|
||||
Language.ADMIN_RELOADED.send(sender, str -> str.replace("%took%", String.valueOf(diff)));
|
||||
}
|
||||
|
||||
@SubCommand("egg")
|
||||
@Permission("cranked.admin")
|
||||
public void eggCommand(CommandSender sender, @Completion("#bosses") Boss boss, @Completion("#players") @Optional Player player) {
|
||||
if (boss == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
ItemStack spawnEgg = boss.getSpawnEgg();
|
||||
|
||||
if (player != null) {
|
||||
player.getInventory().addItem(spawnEgg);
|
||||
return;
|
||||
}
|
||||
|
||||
if (sender instanceof Player) {
|
||||
InventoryUtils.giveItemToPlayer(((Player) sender), spawnEgg);
|
||||
}
|
||||
}
|
||||
|
||||
@SubCommand("clear")
|
||||
@Permission("cranked.admin")
|
||||
public void clearCommand(CommandSender sender) {
|
||||
this.bossManager.killAllAliveBosses();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package net.crankedpvp.bosses.commands;
|
||||
|
||||
import me.mattstudios.mf.annotations.Command;
|
||||
import me.mattstudios.mf.annotations.Default;
|
||||
import me.mattstudios.mf.base.CommandBase;
|
||||
import net.crankedpvp.bosses.inventory.BossesInventory;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@Command("bosses")
|
||||
public class BossesCommand extends CommandBase {
|
||||
|
||||
@Default
|
||||
public void mainCommand(CommandSender sender) {
|
||||
if(!(sender instanceof Player)) return;
|
||||
Player player = (Player)sender;
|
||||
BossesInventory bossesInventory = new BossesInventory();
|
||||
bossesInventory.getUI().open(player);
|
||||
player.playSound(player.getLocation(), Sound.CHEST_OPEN, 2.0F, 2.0F);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package net.crankedpvp.bosses.events;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.Setter;
|
||||
import net.crankedpvp.bosses.struct.Boss;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
@Getter
|
||||
@RequiredArgsConstructor
|
||||
public class BossDeathEvent extends Event implements Cancellable {
|
||||
|
||||
private final Boss boss;
|
||||
private final LivingEntity entity;
|
||||
private final Player Killer;
|
||||
|
||||
@Setter
|
||||
private boolean cancelled;
|
||||
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package net.crankedpvp.bosses.events;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.Setter;
|
||||
import net.crankedpvp.bosses.struct.Boss;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
|
||||
@Getter
|
||||
@RequiredArgsConstructor
|
||||
public class BossIncomingPlayerDamageEvent extends Event implements Cancellable {
|
||||
|
||||
private final Boss boss;
|
||||
private final LivingEntity victim;
|
||||
private final Player attacker;
|
||||
private final EntityDamageByEntityEvent damageEvent;
|
||||
|
||||
@Setter
|
||||
private boolean cancelled;
|
||||
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package net.crankedpvp.bosses.events;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.Setter;
|
||||
import net.crankedpvp.bosses.struct.Boss;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
|
||||
@Getter
|
||||
@RequiredArgsConstructor
|
||||
public class BossOutgoingPlayerDamageEvent extends Event implements Cancellable {
|
||||
|
||||
private final Boss boss;
|
||||
private final LivingEntity attacker;
|
||||
private final Player victim;
|
||||
private final EntityDamageByEntityEvent damageEvent;
|
||||
|
||||
@Setter
|
||||
private boolean cancelled;
|
||||
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package net.crankedpvp.bosses.events;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.Setter;
|
||||
import net.crankedpvp.bosses.struct.Boss;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
@Getter
|
||||
@RequiredArgsConstructor
|
||||
public class BossSpawnEvent extends Event implements Cancellable {
|
||||
|
||||
private final Boss boss;
|
||||
private final LivingEntity entity;
|
||||
|
||||
@Setter
|
||||
private boolean cancelled;
|
||||
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
package net.crankedpvp.bosses.interfaces;
|
||||
|
||||
public interface Incrementable {
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package net.crankedpvp.bosses.interfaces;
|
||||
|
||||
public interface LootTableLoot {
|
||||
|
||||
// If a boss implements this interface it will give the loot inside the loot table as a reward
|
||||
// instead of a crate key
|
||||
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
package net.crankedpvp.bosses.interfaces;
|
||||
|
||||
public interface Reloadable {
|
||||
|
||||
void reloadValues();
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package net.crankedpvp.bosses.interfaces;
|
||||
|
||||
public interface TrapAttributes {
|
||||
|
||||
String getSubTitle();
|
||||
double getTickDamage();
|
||||
int getCooldownLength();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
package net.crankedpvp.bosses.interfaces;
|
||||
|
||||
public interface WarzoneOnly {
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
package net.crankedpvp.bosses.inventory;
|
||||
|
||||
import dev.triumphteam.gui.guis.Gui;
|
||||
import dev.triumphteam.gui.guis.GuiItem;
|
||||
import net.crankedpvp.bosses.BossPlugin;
|
||||
import net.crankedpvp.bosses.struct.Boss;
|
||||
import net.crankedpvp.crankedutils.utils.CC;
|
||||
import net.crankedpvp.crankedutils.utils.items.ItemBuilder;
|
||||
import org.bukkit.DyeColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class BossesInventory {
|
||||
private final Gui bossesInventory;
|
||||
|
||||
public Gui getUI() {
|
||||
return this.bossesInventory;
|
||||
}
|
||||
|
||||
Collection<Boss> bosses = BossPlugin.getInstance().getBossRegister().getRegisteredBosses().values();
|
||||
|
||||
public BossesInventory() {
|
||||
this.bossesInventory = new Gui(6, "Cranked Bosses");
|
||||
this.bossesInventory.setDefaultClickAction(event -> event.setCancelled(true));
|
||||
this.bossesInventory.getFiller().fillBorder(new GuiItem(createFillerItem()));
|
||||
this.bossesInventory.updateItem(6, 5, new GuiItem(createExitItem(), event -> event.getWhoClicked().closeInventory()));
|
||||
this.bossesInventory.updateItem(1, 5, new GuiItem(createInformationItem()));
|
||||
|
||||
|
||||
for(Boss boss : bosses.stream().filter(Boss::showsInGui).collect(Collectors.toList())) {
|
||||
this.bossesInventory.addItem(new GuiItem(boss.getSpawnEgg(), event -> {
|
||||
if(event.getWhoClicked().hasPermission("cranked.admin")) event.getWhoClicked().getInventory().addItem(boss.getSpawnEgg());
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
private ItemStack createExitItem() {
|
||||
ItemStack item = new ItemStack(Material.BED);
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
meta.setDisplayName(CC.translate("&cExit Bosses menu"));
|
||||
item.setItemMeta(meta);
|
||||
return item;
|
||||
}
|
||||
|
||||
private ItemStack createInformationItem() {
|
||||
return new ItemBuilder(Material.BOOK, "&a&lCranked Bosses",
|
||||
"&7Bosses are tough AI mobs that",
|
||||
"&7can be fought by players to",
|
||||
"&7obtain high-tier loot.",
|
||||
"",
|
||||
"&7Bosses can spawn in naturally",
|
||||
"&7however you can also spawn them",
|
||||
"&7in using boss spawn eggs as shown",
|
||||
"&7in this inventory.")
|
||||
.colorize().build();
|
||||
}
|
||||
|
||||
private ItemStack createFillerItem() {
|
||||
ItemStack item = new ItemStack(Material.STAINED_GLASS_PANE, 1, DyeColor.GRAY.getData());
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
meta.setDisplayName(CC.translate("&cCranked&fPvP"));
|
||||
item.setItemMeta(meta);
|
||||
return item;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,107 @@
|
||||
package net.crankedpvp.bosses.language;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import net.crankedpvp.crankedutils.utils.CC;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.function.UnaryOperator;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public enum Language {
|
||||
|
||||
MAX_BOSSES,
|
||||
|
||||
CBO_COMMAND_HELP,
|
||||
|
||||
BOSS_DAMAGE_TITLE,
|
||||
BOSS_DAMAGE_LINE,
|
||||
SPAWN_BOSS_IN_WARZONE,
|
||||
|
||||
ADMIN_RELOADING,
|
||||
ADMIN_RELOADED,
|
||||
|
||||
TOO_MANY_BOSSES,
|
||||
;
|
||||
|
||||
private String value;
|
||||
private ImmutableList<String> valueList;
|
||||
|
||||
public String getValue() {
|
||||
return this.value != null ? this.value : this.name();
|
||||
}
|
||||
|
||||
public String getValue(UnaryOperator<String> function) {
|
||||
return this.value != null ? function.apply(this.value) : this.name();
|
||||
}
|
||||
|
||||
public String getPath() {
|
||||
return this.name();
|
||||
}
|
||||
|
||||
public List<String> getValuesAsList() {
|
||||
return this.valueList;
|
||||
}
|
||||
|
||||
public List<String> getValuesAsList(String oldString, String newString) {
|
||||
List<String> list = new ArrayList<>(this.valueList);
|
||||
list.replaceAll(s -> s.replace(oldString, newString));
|
||||
return list;
|
||||
}
|
||||
|
||||
void setValue(String value) {
|
||||
this.value = CC.translate(value);
|
||||
|
||||
List<String> tempList = Arrays.stream(StringUtils.split(value, System.lineSeparator()))
|
||||
.map(CC::translate)
|
||||
.collect(Collectors.toList());
|
||||
this.valueList = ImmutableList.copyOf(tempList);
|
||||
}
|
||||
|
||||
void setValue(List<String> valueList) {
|
||||
this.value = CC.translate(valueList.parallelStream().collect(Collectors.joining(System.lineSeparator())));
|
||||
|
||||
List<String> tempList = valueList.stream()
|
||||
.map(CC::translate)
|
||||
.collect(Collectors.toList());
|
||||
this.valueList = ImmutableList.copyOf(tempList);
|
||||
}
|
||||
|
||||
public void send(CommandSender sender, UnaryOperator<String> function) {
|
||||
sender.sendMessage(CC.translate(this.getValue(function)));
|
||||
}
|
||||
|
||||
public void send(CommandSender sender) {
|
||||
sender.sendMessage(CC.translate(this.getValue()));
|
||||
}
|
||||
|
||||
|
||||
public void send(Collection<CommandSender> senders, UnaryOperator<String> function) {
|
||||
String msg = CC.translate(this.getValue(function));
|
||||
senders.forEach(sender -> sender.sendMessage(msg));
|
||||
}
|
||||
|
||||
public void sendPlayers(Collection<? extends Player> senders, UnaryOperator<String> function) {
|
||||
String msg = CC.translate(this.getValue(function));
|
||||
senders.forEach(sender -> sender.sendMessage(msg));
|
||||
}
|
||||
|
||||
public void send(CommandSender ...senders) {
|
||||
String msg = CC.translate(this.getValue());
|
||||
Arrays.asList(senders).forEach(sender -> sender.sendMessage(msg));
|
||||
}
|
||||
|
||||
public String getMessage() {
|
||||
return CC.translate(this.getValue());
|
||||
}
|
||||
|
||||
public String getMessage(UnaryOperator<String> function) {
|
||||
return CC.translate(this.getValue(function));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
package net.crankedpvp.bosses.language;
|
||||
|
||||
import org.bukkit.configuration.InvalidConfigurationException;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
|
||||
public final class LanguageHandler {
|
||||
|
||||
private final File file;
|
||||
private final FileConfiguration config;
|
||||
private final String path;
|
||||
private final JavaPlugin plugin;
|
||||
|
||||
public LanguageHandler(JavaPlugin plugin) {
|
||||
this.plugin = plugin;
|
||||
this.path = "language.yml";
|
||||
file = new File(plugin.getDataFolder(), path);
|
||||
config = new YamlConfiguration();
|
||||
}
|
||||
|
||||
public void load() {
|
||||
this.saveDefaultConfig();
|
||||
|
||||
this.loadConfigFromDisk();
|
||||
this.copyDefaults();
|
||||
this.save();
|
||||
|
||||
this.loadConfigFromDisk();
|
||||
|
||||
this.loadLangMessages();
|
||||
}
|
||||
|
||||
private void loadLangMessages() {
|
||||
for (Language entry : Language.values()) {
|
||||
String path = entry.getPath();
|
||||
if (config.isList(path)) {
|
||||
entry.setValue(config.getStringList(path));
|
||||
continue;
|
||||
}
|
||||
entry.setValue(config.getString(path));
|
||||
}
|
||||
}
|
||||
|
||||
private void loadConfigFromDisk() {
|
||||
try {
|
||||
config.load(file);
|
||||
} catch (IOException | InvalidConfigurationException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void save() {
|
||||
try {
|
||||
config.save(file);
|
||||
} catch (IOException e) {
|
||||
plugin.getLogger().severe("Could not save config file for " + file.getPath() + "!");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private void copyDefaults() {
|
||||
InputStream defConfig = plugin.getResource(this.path);
|
||||
if (defConfig != null) {
|
||||
config.setDefaults(YamlConfiguration.loadConfiguration(new InputStreamReader(defConfig)));
|
||||
}
|
||||
config.options().copyDefaults(true);
|
||||
}
|
||||
|
||||
private void saveDefaultConfig() {
|
||||
if (!file.exists()) {
|
||||
file.getParentFile().mkdirs();
|
||||
plugin.saveResource(file.getName(),false);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,174 @@
|
||||
package net.crankedpvp.bosses.listeners;
|
||||
|
||||
import net.crankedpvp.bosses.BossAPI;
|
||||
import net.crankedpvp.bosses.BossPlugin;
|
||||
import net.crankedpvp.bosses.events.BossDeathEvent;
|
||||
import net.crankedpvp.bosses.events.BossIncomingPlayerDamageEvent;
|
||||
import net.crankedpvp.bosses.events.BossOutgoingPlayerDamageEvent;
|
||||
import net.crankedpvp.bosses.events.BossSpawnEvent;
|
||||
import net.crankedpvp.bosses.interfaces.WarzoneOnly;
|
||||
import net.crankedpvp.bosses.language.Language;
|
||||
import net.crankedpvp.bosses.struct.*;
|
||||
import net.crankedpvp.crankedutils.utils.Arrow;
|
||||
import net.crankedpvp.crankedutils.utils.CC;
|
||||
import net.crankedpvp.crankedutils.utils.FactionUtils;
|
||||
import net.crankedpvp.crankedutils.utils.WorldGuardUtils;
|
||||
import net.crankedpvp.crankedutils.utils.items.ItemUtils;
|
||||
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.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
import org.bukkit.event.entity.EntityDeathEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
|
||||
public class BossListeners implements Listener {
|
||||
|
||||
private final BossManager bossManager;
|
||||
|
||||
public BossListeners(BossPlugin plugin) {
|
||||
this.bossManager = plugin.getBossManager();
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
public void onBossIncomingDamage(BossIncomingPlayerDamageEvent event) {
|
||||
LivingEntity bossEntity = event.getVictim();
|
||||
|
||||
event.getBoss().onIncomingDamage(event.getDamageEvent(), bossEntity, event.getAttacker());
|
||||
|
||||
double baseDamage = event.getDamageEvent().getFinalDamage();
|
||||
double damage = bossEntity.getHealth() - baseDamage >= 0 ? baseDamage : bossEntity.getHealth();
|
||||
|
||||
this.bossManager.updateDamageDealtToBossByPlayer(event.getVictim(), event.getAttacker(), damage);
|
||||
event.getBoss().updateBossDisplayNameAndHealthDisplay(bossEntity, bossEntity.getHealth() - damage);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
public void onBossOutgoingDamage(BossOutgoingPlayerDamageEvent event) {
|
||||
event.getBoss().onOutgoingDamage(event.getDamageEvent(), event.getAttacker(), event.getVictim());
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onBossSpawn(BossSpawnEvent event) {
|
||||
this.bossManager.addBossToCache(event.getEntity(), event.getBoss());
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void onBossDeath(BossDeathEvent event) {
|
||||
BossInfo bossInfo = this.bossManager.getBossInfo(event.getEntity());
|
||||
bossInfo.getBoss().handleBossDeath(event, bossInfo);
|
||||
this.bossManager.removeBossFromCache(event.getEntity());
|
||||
for (BossAbility bossAbility : bossInfo.getBoss().getBossAbilities()) {
|
||||
bossAbility.removeFromCooldownCache(event.getEntity());
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
public void onBossEggClick(PlayerInteractEvent event) {
|
||||
if (event.getAction() != Action.RIGHT_CLICK_BLOCK) return;
|
||||
BossAPI.getBossFromEgg(event.getItem()).ifPresent(boss -> {
|
||||
event.setCancelled(true);
|
||||
Location clickedLocation = event.getClickedBlock().getLocation();
|
||||
if(boss instanceof WarzoneOnly) {
|
||||
if (!WorldGuardUtils.getRegionName(clickedLocation).equals("spawn_warzone") || !clickedLocation.getWorld().getName().equals("world")) {
|
||||
Language.SPAWN_BOSS_IN_WARZONE.send(event.getPlayer());
|
||||
return;
|
||||
}
|
||||
if (!FactionUtils.isWarZone(clickedLocation)) {
|
||||
Language.SPAWN_BOSS_IN_WARZONE.send(event.getPlayer());
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if(!WorldGuardUtils.canPvPInRegion(clickedLocation)) {
|
||||
Language.SPAWN_BOSS_IN_WARZONE.send(event.getPlayer());
|
||||
return;
|
||||
}
|
||||
|
||||
if(this.bossManager.getAliveBossesAmount() >= Integer.parseInt(Language.MAX_BOSSES.getValue())) {
|
||||
Language.TOO_MANY_BOSSES.send(event.getPlayer());
|
||||
return;
|
||||
}
|
||||
|
||||
if (BossAPI.isOnBossPlaceCooldown(event.getPlayer())) {
|
||||
event.getPlayer().sendMessage(CC.translate("&4&lBoss " + Arrow.arrow() + " &7You cannot place another boss egg for now"));
|
||||
return;
|
||||
}
|
||||
|
||||
BossAPI.registerBossPlaceCooldown(event.getPlayer());
|
||||
|
||||
event.getPlayer().setItemInHand(ItemUtils.decreaseItemStackAmountByOne(event.getItem()));
|
||||
boss.spawnBoss(event.getClickedBlock().getLocation().add(0.5, 1, 0.5));
|
||||
});
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onBossDeath(EntityDeathEvent event) {
|
||||
if (!this.bossManager.isBoss(event.getEntity())) return;
|
||||
event.getDrops().clear();
|
||||
Player killer = event.getEntity().getKiller();
|
||||
Boss boss = this.bossManager.getBoss(event.getEntity());
|
||||
BossDeathEvent bossDeathEvent = new BossDeathEvent(boss, event.getEntity(), killer);
|
||||
Bukkit.getPluginManager().callEvent(bossDeathEvent);
|
||||
}
|
||||
|
||||
|
||||
@EventHandler
|
||||
public void onBossDamage(EntityDamageEvent event) {
|
||||
if (!this.bossManager.isBoss(event.getEntity())) return;
|
||||
|
||||
LivingEntity entity = (LivingEntity) event.getEntity();
|
||||
Boss boss = this.bossManager.getBoss(entity);
|
||||
BossAttributes attributes = boss.getAttributes();
|
||||
|
||||
if(attributes == null) return;
|
||||
switch (event.getCause()) {
|
||||
case FALL:
|
||||
if(attributes.isImmuneToFallDamage()) event.setCancelled(true);
|
||||
break;
|
||||
case FIRE:
|
||||
case LAVA:
|
||||
if (attributes.isImmuneToFireDamage()) event.setCancelled(true);
|
||||
break;
|
||||
case MAGIC:
|
||||
if (attributes.isImmuneToMagicDamage()) event.setCancelled(true);
|
||||
break;
|
||||
case PROJECTILE:
|
||||
if (attributes.isImmuneToProjectileDamage()) event.setCancelled(true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void onBossDamagedByPlayer(EntityDamageByEntityEvent event) {
|
||||
if (!this.bossManager.isBoss(event.getEntity())) return;
|
||||
if (!(event.getDamager() instanceof Player)) return;
|
||||
|
||||
if (event.isCancelled()) return;
|
||||
|
||||
Player player = ((Player) event.getDamager());
|
||||
LivingEntity entity = (LivingEntity) event.getEntity();
|
||||
Boss boss = this.bossManager.getBoss(entity);
|
||||
|
||||
BossIncomingPlayerDamageEvent bossIncomingPlayerDamageEvent = new BossIncomingPlayerDamageEvent(boss, entity, player, event);
|
||||
Bukkit.getPluginManager().callEvent(bossIncomingPlayerDamageEvent);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
public void onBossDamageToPlayer(EntityDamageByEntityEvent event) {
|
||||
if (!this.bossManager.isBoss(event.getDamager())) return;
|
||||
if (!(event.getEntity() instanceof Player)) return;
|
||||
|
||||
Player player = ((Player) event.getEntity());
|
||||
LivingEntity entity = (LivingEntity) event.getDamager();
|
||||
Boss boss = this.bossManager.getBoss(entity);
|
||||
|
||||
BossOutgoingPlayerDamageEvent bossOutgoingPlayerDamageEvent = new BossOutgoingPlayerDamageEvent(boss, entity, player, event);
|
||||
Bukkit.getPluginManager().callEvent(bossOutgoingPlayerDamageEvent);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,263 @@
|
||||
package net.crankedpvp.bosses.struct;
|
||||
|
||||
import de.tr7zw.nbtapi.NBTItem;
|
||||
import lombok.Getter;
|
||||
import net.crankedpvp.bosses.events.BossDeathEvent;
|
||||
import net.crankedpvp.bosses.events.BossSpawnEvent;
|
||||
import net.crankedpvp.bosses.interfaces.Incrementable;
|
||||
import net.crankedpvp.bosses.interfaces.LootTableLoot;
|
||||
import net.crankedpvp.bosses.language.Language;
|
||||
import net.crankedpvp.crankedcore.CrankedCore;
|
||||
import net.crankedpvp.crankedcore.data.CrankedUser;
|
||||
import net.crankedpvp.crankedutils.CrankedUtils;
|
||||
import net.crankedpvp.crankedutils.utils.*;
|
||||
import net.crankedpvp.crankedutils.utils.items.ItemBuilder;
|
||||
import net.crankedpvp.cratekeys.enums.CrateKeyType;
|
||||
import net.crankedpvp.cratekeys.items.CrateKeyItem;
|
||||
import net.crankedpvp.leaderboards.LeaderboardsAPI;
|
||||
import net.crankedpvp.loottable.LootTableAPI;
|
||||
import net.crankedpvp.loottable.struct.LootTableType;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
|
||||
public abstract class Boss implements Listener {
|
||||
|
||||
@Getter
|
||||
private final transient DamageHandler damageHandler;
|
||||
private final transient EnumMap<BossPhase, BossPhaseInfo> fightPhases;
|
||||
private transient BossPhase previousPhase;
|
||||
|
||||
protected Boss() {
|
||||
this.damageHandler = CrankedUtils.instance.getDamageHandler();
|
||||
this.fightPhases = new EnumMap<>(BossPhase.class);
|
||||
this.fightPhases.put(BossPhase.PHASE_ONE, this.getPhaseOne());
|
||||
this.fightPhases.put(BossPhase.PHASE_TWO, this.getPhaseTwo());
|
||||
this.fightPhases.put(BossPhase.PHASE_THREE, this.getPhaseThree());
|
||||
this.previousPhase = BossPhase.PHASE_ONE;
|
||||
}
|
||||
|
||||
public abstract String getName();
|
||||
|
||||
public abstract String getBossDisplayName();
|
||||
|
||||
public abstract String getSpawnEggName();
|
||||
|
||||
public abstract BossGear getBossGear();
|
||||
|
||||
public abstract List<String> getSpawnEggLore();
|
||||
|
||||
public abstract BossAttributes getAttributes();
|
||||
|
||||
public abstract Short getSpawnEggId();
|
||||
|
||||
public abstract Sound getSpawnSound();
|
||||
|
||||
public abstract Sound getDeathSound();
|
||||
|
||||
public abstract List<PotionEffect> getEffects();
|
||||
|
||||
public abstract EntityType getEntityType();
|
||||
|
||||
public abstract boolean isBaby();
|
||||
|
||||
public abstract LootTableType getLootTableType();
|
||||
|
||||
public abstract int getRewardAmount();
|
||||
|
||||
public abstract double getMaxHealth();
|
||||
|
||||
public abstract boolean showDeathMessage();
|
||||
|
||||
public abstract BossRewardSystem getBossRewardSystem();
|
||||
|
||||
public abstract boolean showsInGui();
|
||||
|
||||
protected abstract BossPhaseInfo getPhaseOne();
|
||||
|
||||
protected abstract BossPhaseInfo getPhaseTwo();
|
||||
|
||||
protected abstract BossPhaseInfo getPhaseThree();
|
||||
|
||||
protected abstract void afterSpawn(LivingEntity livingEntity);
|
||||
|
||||
public double chanceToGetReward() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
public void onIncomingDamage(EntityDamageByEntityEvent event, LivingEntity bossEntity, Player player) {
|
||||
BossPhaseInfo bossPhaseInfo = this.fightPhases.get(this.getBossPhase(bossEntity));
|
||||
BossPhase bossPhase = this.getBossPhase(bossEntity);
|
||||
|
||||
if (this.previousPhase != bossPhase) {
|
||||
this.previousPhase = bossPhase;
|
||||
for (PotionEffect potionEffect : bossPhaseInfo.getPotionEffects()) {
|
||||
bossEntity.addPotionEffect(potionEffect);
|
||||
}
|
||||
}
|
||||
|
||||
this.getDamageHandler().reduceDamage(bossPhaseInfo.getIncomingDamageDecrease(), event, this.getName());
|
||||
|
||||
for (BossAbilities ability : bossPhaseInfo.getAbilities()) {
|
||||
ability.getAbilityInstance().procAbility(this, bossEntity, player);
|
||||
}
|
||||
}
|
||||
|
||||
public void onOutgoingDamage(EntityDamageByEntityEvent event, LivingEntity bossEntity, Player player) {
|
||||
BossPhaseInfo bossPhaseInfo = this.fightPhases.get(this.getBossPhase(bossEntity));
|
||||
|
||||
this.getDamageHandler().increaseDamage(bossPhaseInfo.getOutgoingDamageIncrease(), event, this.getName());
|
||||
}
|
||||
|
||||
protected List<ItemStack> getLootForRarity(LootTableType lootTableType) {
|
||||
return LootTableAPI.getAllLootFromLootTable(lootTableType);
|
||||
}
|
||||
|
||||
public String getID() {
|
||||
return this.getName().replace(" ", "").toLowerCase(Locale.ROOT);
|
||||
}
|
||||
|
||||
|
||||
public ItemStack getSpawnEgg() {
|
||||
ItemStack itemStack = new ItemBuilder(Material.MONSTER_EGG)
|
||||
.setDurability(this.getSpawnEggId())
|
||||
.setLore(this.getSpawnEggLore())
|
||||
.setName(this.getSpawnEggName())
|
||||
.colorize()
|
||||
.build();
|
||||
|
||||
NBTItem nbtItem = new NBTItem(itemStack);
|
||||
nbtItem.setString("cosmicData", "boss-egg");
|
||||
nbtItem.setString("boss-type", this.getID());
|
||||
return nbtItem.getItem();
|
||||
}
|
||||
|
||||
public LivingEntity spawnBoss(Location spawnLocation) {
|
||||
String[] disabledWorlds = new String[]{"world_outpost", "desert_world", "Desert", "world_routpost"};
|
||||
if(Arrays.stream(disabledWorlds).anyMatch(worldName -> worldName.equals(spawnLocation.getWorld().getName()))) {
|
||||
System.out.println("Disabling boss spawn of boss: " + this.getName() + " at " + LocationUtils.locationToFancy(spawnLocation) + " due to being a disabled world");
|
||||
return null;
|
||||
}
|
||||
LivingEntity boss = (LivingEntity) spawnLocation.getWorld().spawnEntity(spawnLocation, this.getEntityType());
|
||||
|
||||
boss.setRemoveWhenFarAway(false);
|
||||
boss.setMaxHealth(this.getMaxHealth());
|
||||
boss.setHealth(this.getMaxHealth());
|
||||
boss.setCanPickupItems(false);
|
||||
boss.setCustomNameVisible(true);
|
||||
this.updateBossDisplayNameAndHealthDisplay(boss, getMaxHealth());
|
||||
if(this.getBossGear() != null) this.getBossGear().applyArmorToBoss(boss);
|
||||
|
||||
if (this.getEffects() != null)
|
||||
this.getEffects().forEach(boss::addPotionEffect);
|
||||
|
||||
if (this.getSpawnSound() != null)
|
||||
spawnLocation.getWorld().playSound(spawnLocation, this.getSpawnSound(), 1, 1);
|
||||
|
||||
|
||||
BossSpawnEvent bossSpawnEvent = new BossSpawnEvent(this, boss);
|
||||
Bukkit.getPluginManager().callEvent(bossSpawnEvent);
|
||||
|
||||
this.afterSpawn(boss);
|
||||
return boss;
|
||||
}
|
||||
|
||||
public void giveLootToPlayer(final Player player, final LootTableType lootTableType) {
|
||||
if (player == null) return;
|
||||
|
||||
if (this instanceof LootTableLoot) {
|
||||
for(int i = 0; i < this.getRewardAmount(); i++) {
|
||||
if (Math.random() < chanceToGetReward()) {
|
||||
final ItemStack itemStack = LootTableAPI.getRandomLootItem(lootTableType);
|
||||
PlayerUtils.giveOrDropProtectedItem(player, itemStack, 5);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
for(int i = 0; i < this.getRewardAmount(); i++) {
|
||||
if (Math.random() < chanceToGetReward()) {
|
||||
PlayerUtils.giveOrDropProtectedItem(player, CrateKeyItem.getItem(CrateKeyType.valueOf(lootTableType.name())), 5);
|
||||
player.getLocation().getWorld().playSound(player.getLocation(), this.getDeathSound(), 1, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void updateBossDisplayNameAndHealthDisplay(LivingEntity entity, double entityHealth) {
|
||||
entity.setCustomName(CC.translate(this.getBossDisplayName().replace("{health}", this.getHealthString(entity, entityHealth))));
|
||||
}
|
||||
|
||||
public void updateBossDisplayNameAndHealthDisplay(LivingEntity entity) {
|
||||
entity.setCustomName(CC.translate(this.getBossDisplayName().replace("{health}", this.getHealthString(entity, entity.getHealth()))));
|
||||
}
|
||||
|
||||
public BossPhase getBossPhase(LivingEntity entity) {
|
||||
double entityHealth = entity.getHealth();
|
||||
double entityMaxHealth = entity.getMaxHealth();
|
||||
return entityHealth > entityMaxHealth / 2 ? BossPhase.PHASE_ONE : entityHealth > entityMaxHealth / 4 ? BossPhase.PHASE_TWO : BossPhase.PHASE_THREE;
|
||||
}
|
||||
|
||||
private String getHealthString(LivingEntity entity, double entityHealth) {
|
||||
double entityMaxHealth = this.getMaxHealth();
|
||||
ChatColor color = entityHealth > entityMaxHealth / 2 ? ChatColor.GREEN : entityHealth > entityMaxHealth / 4 ? ChatColor.GOLD : ChatColor.RED;
|
||||
return color + "" + (int) entityHealth + "&8/&a" + (int) entityMaxHealth + "&r";
|
||||
}
|
||||
|
||||
public void handleBossDeath(BossDeathEvent event, BossInfo bossInfo) {
|
||||
if(event.getBoss() instanceof Incrementable) {
|
||||
if(event.getKiller() != null)
|
||||
LeaderboardsAPI.getPlayerStats(event.getKiller().getUniqueId()).incrementBossKills();
|
||||
}
|
||||
switch (this.getBossRewardSystem()) {
|
||||
case GIVE_TO_TOP_PLAYER:
|
||||
if (this.showDeathMessage())
|
||||
Language.BOSS_DAMAGE_TITLE.sendPlayers(this.getPlayersWhoReceiveBossDeathMessage(), s -> s.replace("{boss}", event.getBoss().getName()));
|
||||
|
||||
if (bossInfo.getHighestDamage() != null)
|
||||
this.giveRewardsToOnePlayer(event, bossInfo, 1, bossInfo.getHighestDamage());
|
||||
break;
|
||||
case GIVE_TO_TOP_3_PLAYERS:
|
||||
int i = 1;
|
||||
if (this.showDeathMessage())
|
||||
Language.BOSS_DAMAGE_TITLE.sendPlayers(this.getPlayersWhoReceiveBossDeathMessage(), s -> s.replace("{boss}", event.getBoss().getName()));
|
||||
for (Player player : bossInfo.getTop3HighestDamage()) {
|
||||
this.giveRewardsToOnePlayer(event, bossInfo, i, player);
|
||||
i++;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private List<Player> getPlayersWhoReceiveBossDeathMessage() {
|
||||
return Bukkit.getOnlinePlayers().stream().filter(player -> {
|
||||
CrankedUser crankedUser = CrankedCore.getInstance().getCrankedUserManager().getCrankedUser(player.getUniqueId());
|
||||
return crankedUser.isBossDeathMessagesEnabled();
|
||||
}).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
private void giveRewardsToOnePlayer(BossDeathEvent event, BossInfo bossInfo, int rank, Player player) {
|
||||
event.getBoss().giveLootToPlayer(event.getKiller(), event.getBoss().getLootTableType());
|
||||
double damage = ( bossInfo.getDamageDealtByPlayer(player) / event.getEntity().getMaxHealth()) * 100;
|
||||
|
||||
if (!this.showDeathMessage()) return;
|
||||
Language.BOSS_DAMAGE_LINE.sendPlayers(getPlayersWhoReceiveBossDeathMessage(), s -> s.replace("{rank}", String.valueOf(rank)).replace("{player}", player.getName()).replace("{damage}", NumberUtils.formatMoney(damage)));
|
||||
}
|
||||
|
||||
public Set<BossAbility> getBossAbilities() {
|
||||
Set<BossAbilities> bossAbilities = new HashSet<>();
|
||||
Stream.of(this.getPhaseOne().getAbilities(), this.getPhaseTwo().getAbilities(), this.getPhaseThree().getAbilities())
|
||||
.forEach(bossAbilities::addAll);
|
||||
|
||||
return bossAbilities.stream().map(BossAbilities::getAbilityInstance).collect(Collectors.toSet());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package net.crankedpvp.bosses.struct;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import net.crankedpvp.bosses.abilities.*;
|
||||
|
||||
@AllArgsConstructor
|
||||
public enum BossAbilities {
|
||||
|
||||
LIGHTNING_STRIKE(new LightningStrike()),
|
||||
BROOD_MOTHER_BLIND(new BroodMotherBlind()),
|
||||
BROOD_MOTHER_WEB(new BroodMotherWeb()),
|
||||
BROOD_MOTHER_MINION(new BroodMotherMinion()),
|
||||
TREASURE_GOBLIN_LOOT(new TreasureGoblinLootDrop()),
|
||||
TRAP(new Trap()),
|
||||
|
||||
DAMAGE_TICK(new DamageTick()),
|
||||
HEAL(new Heal()),
|
||||
KNOCKBACK(new Knockback()),
|
||||
PULL(new Pull()),
|
||||
LAUNCH(new Launch()),
|
||||
SHOOT_ARROW(new ShootArrow()),
|
||||
//NOPOT(new NoPot()),
|
||||
;
|
||||
|
||||
@Getter
|
||||
private final BossAbility abilityInstance;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
package net.crankedpvp.bosses.struct;
|
||||
|
||||
import net.crankedpvp.crankedutils.utils.StringUtils;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Locale;
|
||||
import java.util.UUID;
|
||||
|
||||
public abstract class BossAbility {
|
||||
|
||||
private final HashMap<UUID, Long> bossAbilityCooldowns;
|
||||
|
||||
protected BossAbility() {
|
||||
this.bossAbilityCooldowns = new HashMap<>();
|
||||
}
|
||||
|
||||
public abstract String getName();
|
||||
|
||||
protected abstract void abilityEffect(Boss boss, LivingEntity BossEntity, Player player);
|
||||
|
||||
public abstract int getCooldownLength();
|
||||
|
||||
public abstract double procChance();
|
||||
|
||||
public void updateAbilityCooldown(LivingEntity entity) {
|
||||
this.bossAbilityCooldowns.put(entity.getUniqueId(), System.currentTimeMillis());
|
||||
}
|
||||
|
||||
public boolean isAbilityOnCooldown(LivingEntity entity) {
|
||||
return (this.getCooldownLength() * 1000L) + this.bossAbilityCooldowns.getOrDefault(entity.getUniqueId(), 0L) > System.currentTimeMillis();
|
||||
}
|
||||
|
||||
public void removeFromCooldownCache(LivingEntity entity) {
|
||||
this.bossAbilityCooldowns.remove(entity.getUniqueId());
|
||||
}
|
||||
|
||||
public void procAbility(Boss boss, LivingEntity bossEntity, Player player) {
|
||||
if (this.isAbilityOnCooldown(bossEntity)) return;
|
||||
if (Math.random() * 100 > this.procChance()) return;
|
||||
|
||||
this.updateAbilityCooldown(bossEntity);
|
||||
this.abilityEffect(boss, bossEntity, player);
|
||||
}
|
||||
|
||||
public String getID() {
|
||||
return StringUtils.toNiceString(this.getName()).toLowerCase(Locale.ROOT);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package net.crankedpvp.bosses.struct;
|
||||
|
||||
import net.crankedpvp.crankedutils.utils.cache.cooldown.CurrentCooldown;
|
||||
|
||||
public class BossAbilityCooldown extends CurrentCooldown {
|
||||
|
||||
public BossAbilityCooldown(BossAbility bossAbility, int durationInSeconds) {
|
||||
super("boss_ability_" + bossAbility.getID(), durationInSeconds);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package net.crankedpvp.bosses.struct;
|
||||
|
||||
import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
|
||||
@Getter
|
||||
@Builder
|
||||
public class BossAttributes {
|
||||
|
||||
@Builder.Default
|
||||
private boolean immuneToFireDamage = true;
|
||||
@Builder.Default
|
||||
private boolean immuneToFallDamage = true;
|
||||
@Builder.Default
|
||||
private boolean immuneToMagicDamage = true;
|
||||
@Builder.Default
|
||||
private boolean immuneToProjectileDamage = true;
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
package net.crankedpvp.bosses.struct;
|
||||
|
||||
import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
import net.crankedpvp.crankedutils.utils.items.ItemBuilder;
|
||||
import net.crankedpvp.crankedutils.utils.items.ItemUtils;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
|
||||
@Getter
|
||||
@Builder
|
||||
public class BossGear {
|
||||
|
||||
@Builder.Default
|
||||
private ItemBuilder helmet = new ItemBuilder(Material.AIR);
|
||||
@Builder.Default
|
||||
private ItemBuilder chestplate = new ItemBuilder(Material.AIR);
|
||||
@Builder.Default
|
||||
private ItemBuilder leggings = new ItemBuilder(Material.AIR);
|
||||
@Builder.Default
|
||||
private ItemBuilder boots = new ItemBuilder(Material.AIR);
|
||||
@Builder.Default
|
||||
private ItemBuilder weapon = new ItemBuilder(Material.AIR);
|
||||
|
||||
public void applyArmorToBoss(LivingEntity entity) {
|
||||
this.setHelmet(this.helmet, entity);
|
||||
this.setChestplate(this.chestplate, entity);
|
||||
this.setLeggings(this.leggings, entity);
|
||||
this.setBoots(this.boots, entity);
|
||||
this.setWeapon(this.weapon, entity);
|
||||
}
|
||||
|
||||
private void setWeapon(ItemBuilder weapon, LivingEntity entity) {
|
||||
if (ItemUtils.isAirOrNull(weapon.build())) return;
|
||||
entity.getEquipment().setItemInHand(weapon.setUnbreakable(true).build());
|
||||
entity.getEquipment().setItemInHandDropChance(0.0f);
|
||||
}
|
||||
|
||||
private void setHelmet(ItemBuilder helmet, LivingEntity entity) {
|
||||
if (ItemUtils.isAirOrNull(helmet.build())) return;
|
||||
entity.getEquipment().setHelmet(helmet.setUnbreakable(true).build());
|
||||
entity.getEquipment().setHelmetDropChance(0.0f);
|
||||
}
|
||||
|
||||
private void setChestplate(ItemBuilder chest, LivingEntity entity) {
|
||||
if (ItemUtils.isAirOrNull(chest.build())) return;
|
||||
entity.getEquipment().setChestplate(chest.setUnbreakable(true).build());
|
||||
entity.getEquipment().setChestplateDropChance(0.0f);
|
||||
}
|
||||
|
||||
private void setLeggings(ItemBuilder legs, LivingEntity entity) {
|
||||
if (ItemUtils.isAirOrNull(legs.build())) return;
|
||||
entity.getEquipment().setLeggings(legs.setUnbreakable(true).build());
|
||||
entity.getEquipment().setLeggingsDropChance(0.0f);
|
||||
}
|
||||
|
||||
private void setBoots(ItemBuilder boots, LivingEntity entity) {
|
||||
if (ItemUtils.isAirOrNull(boots.build())) return;
|
||||
entity.getEquipment().setBoots(boots.setUnbreakable(true).build());
|
||||
entity.getEquipment().setBootsDropChance(0.0f);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
package net.crankedpvp.bosses.struct;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@AllArgsConstructor
|
||||
public class BossInfo {
|
||||
|
||||
@Getter
|
||||
private final Boss boss;
|
||||
@Getter
|
||||
private final LivingEntity livingEntity;
|
||||
private final HashMap<UUID, Double> damageDealtToBossByPlayers = new HashMap<>();
|
||||
|
||||
public void updatePlayerDamage(Player player, double damage) {
|
||||
this.damageDealtToBossByPlayers.put(player.getUniqueId(), damage + this.getDamageDealtByPlayer(player));
|
||||
}
|
||||
|
||||
public double getDamageDealtByPlayer(Player player) {
|
||||
return this.damageDealtToBossByPlayers.getOrDefault(player.getUniqueId(), 0.0);
|
||||
}
|
||||
|
||||
public List<Player> getTop3HighestDamage() {
|
||||
return this.damageDealtToBossByPlayers.entrySet().stream()
|
||||
.sorted(Map.Entry.<UUID, Double>comparingByValue().reversed())
|
||||
.limit(3)
|
||||
.map(Map.Entry::getKey)
|
||||
.map(Bukkit::getPlayer)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
public Player getHighestDamage() {
|
||||
return this.damageDealtToBossByPlayers.entrySet().stream()
|
||||
.sorted(Map.Entry.<UUID, Double>comparingByValue().reversed())
|
||||
.map(Map.Entry::getKey)
|
||||
.map(Bukkit::getPlayer)
|
||||
.findFirst()
|
||||
.orElse(null)
|
||||
;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
package net.crankedpvp.bosses.struct;
|
||||
|
||||
import net.crankedpvp.bosses.interfaces.Incrementable;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.UUID;
|
||||
|
||||
public class BossManager {
|
||||
|
||||
private final HashMap<UUID, BossInfo> aliveBosses;
|
||||
|
||||
public BossManager() {
|
||||
this.aliveBosses = new HashMap<>();
|
||||
}
|
||||
|
||||
public void addBossToCache(LivingEntity entity, Boss boss) {
|
||||
this.aliveBosses.put(entity.getUniqueId(), new BossInfo(boss, entity));
|
||||
}
|
||||
|
||||
public void removeBossFromCache(Entity entity) {
|
||||
this.aliveBosses.remove(entity.getUniqueId());
|
||||
}
|
||||
|
||||
public Collection<BossInfo> getAllAliveBossesInfo() {
|
||||
return this.aliveBosses.values();
|
||||
}
|
||||
|
||||
public Collection<UUID> getAllAliveBossesIds() {
|
||||
return this.aliveBosses.keySet();
|
||||
}
|
||||
|
||||
public int getAliveBossesAmount() {
|
||||
int alive = 0;
|
||||
for(BossInfo boss : this.getAllAliveBossesInfo()) {
|
||||
if(boss.getBoss() instanceof Incrementable) alive++;
|
||||
}
|
||||
return alive;
|
||||
}
|
||||
|
||||
public boolean isBoss(Entity entity) {
|
||||
if (!(entity instanceof LivingEntity)) return false;
|
||||
return this.aliveBosses.containsKey(entity.getUniqueId());
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Boss getBoss(Entity entity) {
|
||||
if (!this.aliveBosses.containsKey(entity.getUniqueId())) {
|
||||
return null;
|
||||
}
|
||||
return this.aliveBosses.get(entity.getUniqueId()).getBoss();
|
||||
}
|
||||
|
||||
public BossInfo getBossInfo(Entity entity) {
|
||||
return this.aliveBosses.get(entity.getUniqueId());
|
||||
}
|
||||
|
||||
private void clearCache() {
|
||||
this.aliveBosses.clear();
|
||||
}
|
||||
|
||||
public void killAllAliveBosses() {
|
||||
for (BossInfo bossInfo : this.getAllAliveBossesInfo()) {
|
||||
bossInfo.getLivingEntity().remove();
|
||||
}
|
||||
this.clearCache();
|
||||
}
|
||||
|
||||
public void updateDamageDealtToBossByPlayer(Entity boss, Player player, double damage) {
|
||||
this.getBossInfo(boss).updatePlayerDamage(player, damage);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package net.crankedpvp.bosses.struct;
|
||||
|
||||
public enum BossPhase {
|
||||
|
||||
PHASE_ONE,
|
||||
PHASE_TWO,
|
||||
PHASE_THREE,
|
||||
;
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package net.crankedpvp.bosses.struct;
|
||||
|
||||
import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
import org.bukkit.Effect;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
@Getter
|
||||
@Builder
|
||||
public class BossPhaseInfo {
|
||||
|
||||
@Builder.Default
|
||||
private List<PotionEffect> potionEffects = Collections.emptyList();
|
||||
@Builder.Default
|
||||
private List<BossAbilities> abilities = Collections.emptyList();
|
||||
@Builder.Default
|
||||
private double outgoingDamageIncrease = 0;
|
||||
@Builder.Default
|
||||
private double incomingDamageDecrease = 0;
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package net.crankedpvp.bosses.struct;
|
||||
|
||||
import net.crankedpvp.crankedutils.utils.cache.cooldown.CurrentCooldown;
|
||||
|
||||
public class BossPlaceCooldown extends CurrentCooldown {
|
||||
|
||||
public static int BOSS_PLACE_COOLDOWN_TIME = 5;
|
||||
public static String BOSS_PLACE_COOLDOWN_NAME = "boos-place-cooldown";
|
||||
|
||||
public BossPlaceCooldown() {
|
||||
super(BOSS_PLACE_COOLDOWN_NAME, BOSS_PLACE_COOLDOWN_TIME);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
package net.crankedpvp.bosses.struct;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import net.crankedpvp.bosses.BossPlugin;
|
||||
import net.crankedpvp.bosses.bosses.*;
|
||||
import org.apache.commons.lang.Validate;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public class BossRegister {
|
||||
|
||||
@Getter
|
||||
private static BossRegister instance;
|
||||
private final BossPlugin plugin;
|
||||
private final Map<String, Boss> registeredBosses;
|
||||
|
||||
public BossRegister(BossPlugin plugin) {
|
||||
instance = this;
|
||||
this.plugin = plugin;
|
||||
this.registeredBosses = new HashMap<>();
|
||||
}
|
||||
|
||||
public void initialize() {
|
||||
registerAll(
|
||||
new KingSlime(),
|
||||
new BroodMother(),
|
||||
new Gauntlet(),
|
||||
//new PlagueBloater(),
|
||||
new TreasureGoblin(),
|
||||
new CrankedGuardian(),
|
||||
new Cranker(),
|
||||
new Warlord(),
|
||||
new CrazedWerewolf(),
|
||||
new FireLord(),
|
||||
new Slimicle(),
|
||||
new Cerberus()
|
||||
);
|
||||
}
|
||||
|
||||
public void registerAll(Boss... bosses) {
|
||||
for (Boss boss : bosses) {
|
||||
register(boss);
|
||||
}
|
||||
}
|
||||
|
||||
public void register(Boss boss) {
|
||||
try {
|
||||
this.registeredBosses.put(boss.getID(), boss);
|
||||
this.plugin.getServer().getPluginManager().registerEvents(boss, plugin);
|
||||
} catch (Exception e) {
|
||||
Bukkit.getLogger().warning("Failed to register boss " + boss.getName());
|
||||
System.out.println(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public void unregisterAll() {
|
||||
this.registeredBosses.forEach(((enchantName, boss) -> HandlerList.unregisterAll(boss)));
|
||||
this.registeredBosses.clear();
|
||||
}
|
||||
|
||||
private void unregister(Boss boss) {
|
||||
HandlerList.unregisterAll(boss);
|
||||
this.registeredBosses.remove(boss.getName());
|
||||
}
|
||||
|
||||
public void reload() {
|
||||
this.unregisterAll();
|
||||
this.initialize();
|
||||
}
|
||||
|
||||
public Collection<Boss> getBosses() {
|
||||
return Collections.unmodifiableCollection(this.registeredBosses.values());
|
||||
}
|
||||
|
||||
public boolean isBoss(String name) {
|
||||
return (getBossFromID(name) != null);
|
||||
}
|
||||
|
||||
public Boss getBossFromID(String name) {
|
||||
Validate.notNull(name);
|
||||
Validate.notEmpty(name);
|
||||
return this.registeredBosses.get(name.toLowerCase());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package net.crankedpvp.bosses.struct;
|
||||
|
||||
public enum BossRewardSystem {
|
||||
|
||||
GIVE_TO_TOP_PLAYER,
|
||||
GIVE_TO_TOP_3_PLAYERS,
|
||||
;
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package net.crankedpvp.bosses.struct.annotations;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* don't forget to not make the field final when using this annotation
|
||||
*/
|
||||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.FIELD)
|
||||
public @interface ConfigValue {
|
||||
|
||||
String path() default "boss.";
|
||||
String name() default "";
|
||||
|
||||
}
|
||||
@@ -0,0 +1,125 @@
|
||||
package net.crankedpvp.bosses.struct.config;
|
||||
|
||||
import lombok.AccessLevel;
|
||||
import lombok.Getter;
|
||||
import net.crankedpvp.bosses.BossPlugin;
|
||||
import net.crankedpvp.bosses.struct.Boss;
|
||||
import net.crankedpvp.bosses.interfaces.Reloadable;
|
||||
import net.crankedpvp.bosses.struct.annotations.ConfigValue;
|
||||
import net.crankedpvp.crankedutils.utils.CC;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.configuration.InvalidConfigurationException;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
@Getter
|
||||
public class BossConfig {
|
||||
|
||||
@Getter(value = AccessLevel.PRIVATE)
|
||||
private final BossPlugin plugin;
|
||||
private final String path;
|
||||
private FileConfiguration config;
|
||||
private final File configFile;
|
||||
private final Boss boss;
|
||||
|
||||
public BossConfig(BossPlugin plugin, String path, Boss boss) {
|
||||
this.plugin = plugin;
|
||||
this.path = path;
|
||||
this.boss = boss;
|
||||
this.configFile = new File(plugin.getDataFolder(), path);
|
||||
}
|
||||
|
||||
public void setupConfigFile() {
|
||||
this.createDefaultFile();
|
||||
this.config = YamlConfiguration.loadConfiguration(configFile);
|
||||
|
||||
this.loadVariables();
|
||||
|
||||
boolean result = this.saveConfig();
|
||||
if (result) this.loadConfigFromDisk();
|
||||
|
||||
}
|
||||
|
||||
public boolean saveConfig() {
|
||||
try {
|
||||
config.save(configFile);
|
||||
return true;
|
||||
} catch (IOException e) {
|
||||
plugin.getLogger().severe("Could not save config file for " + path);
|
||||
e.printStackTrace();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void createDefaultFile() {
|
||||
if (!configFile.exists()) {
|
||||
try {
|
||||
configFile.getParentFile().mkdirs();
|
||||
configFile.createNewFile();
|
||||
} catch (IOException e) {
|
||||
plugin.getLogger().severe("Could not create config file for " + path);
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void reloadConfig() {
|
||||
config = YamlConfiguration.loadConfiguration(configFile);
|
||||
this.loadVariables();
|
||||
}
|
||||
|
||||
public void loadConfigFromDisk() {
|
||||
try {
|
||||
config.load(configFile);
|
||||
} catch (IOException | InvalidConfigurationException e) {
|
||||
plugin.getLogger().severe("Could not load config for " + path);
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void loadVariables() {
|
||||
boolean needSave = false;
|
||||
for (Field field : this.boss.getClass().getDeclaredFields()) {
|
||||
|
||||
try {
|
||||
field.setAccessible(true);
|
||||
|
||||
if (field.isAnnotationPresent(ConfigValue.class)) {
|
||||
ConfigValue annotationValue = field.getAnnotation(ConfigValue.class);
|
||||
|
||||
String name = annotationValue.name().equals("") ? field.getName() : annotationValue.name();
|
||||
|
||||
String path = annotationValue.path().endsWith(".") ? annotationValue.path() : annotationValue.path() + ".";
|
||||
|
||||
if (!this.config.contains(path + name)) {
|
||||
this.config.set(path + name, field.get(this.boss));
|
||||
needSave = true;
|
||||
continue;
|
||||
}
|
||||
|
||||
Object fieldValue = this.config.get(path + name);
|
||||
|
||||
if (fieldValue instanceof String) fieldValue = CC.translate((String) fieldValue);
|
||||
|
||||
field.set(this.boss, fieldValue);
|
||||
}
|
||||
} catch (IllegalAccessException | NullPointerException | IllegalArgumentException e) {
|
||||
Bukkit.getConsoleSender().sendMessage(CC.translate("&c[CrankedEnchants] - Error invalid config value for boss " + this.boss.getName()));
|
||||
}
|
||||
|
||||
if (this.boss instanceof Reloadable) {
|
||||
Reloadable reloadableEnchantment = ((Reloadable) this.boss);
|
||||
reloadableEnchantment.reloadValues();
|
||||
}
|
||||
}
|
||||
if (needSave) {
|
||||
saveConfig();
|
||||
reloadConfig();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package net.crankedpvp.bosses.struct.config;
|
||||
|
||||
import lombok.Getter;
|
||||
import net.crankedpvp.bosses.BossPlugin;
|
||||
import net.crankedpvp.bosses.struct.Boss;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class BossConfigManager {
|
||||
|
||||
@Getter
|
||||
private final Map<Boss, BossConfig> configs = new HashMap<>();
|
||||
|
||||
public BossConfigManager(BossPlugin plugin) {
|
||||
for (Boss boss : plugin.getBossRegister().getBosses()) {
|
||||
BossConfig BossConfig = new BossConfig(plugin, "bosses/" + boss.getID() + ".yml", boss);
|
||||
configs.put(boss, BossConfig);
|
||||
}
|
||||
}
|
||||
|
||||
public void setupFiles() {
|
||||
configs.values().forEach(BossConfig::setupConfigFile);
|
||||
}
|
||||
|
||||
public void reloadFiles() {
|
||||
configs.values().forEach(BossConfig::reloadConfig);
|
||||
}
|
||||
|
||||
public BossConfig getAbstractConfig(Boss Boss) {
|
||||
return configs.get(Boss);
|
||||
}
|
||||
|
||||
public FileConfiguration getConfig(Boss Boss) {
|
||||
return getAbstractConfig(Boss).getConfig();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
CBO_COMMAND_HELP:
|
||||
- "&8--- &4Cranked &cBosses &8---"
|
||||
- "&4/cbo &cegg &7<boss> [player]"
|
||||
ADMIN_RELOADING: "&c&l(!) &7Reloading configs now..."
|
||||
ADMIN_RELOADED: "&c&l(!) &7Reloaded configs and other cool stuff. Took &4%took%ms&7."
|
||||
BOSS_DAMAGE_TITLE:
|
||||
- "&c&l(!) &7The {boss} was successfully killed"
|
||||
- "&7Top Damage:"
|
||||
BOSS_DAMAGE_LINE: "&6Rank: #{rank} &8- &7{player} &4Damage: &c{damage}%"
|
||||
SPAWN_BOSS_IN_WARZONE: "&4&lBosses &8➥ &7Boss eggs can only be used in warzone."
|
||||
TOO_MANY_BOSSES: "&4&lBosses &8➥ &7There are too many bosses spawned in"
|
||||
|
||||
MAX_BOSSES: 100
|
||||
@@ -0,0 +1,7 @@
|
||||
name: CrankedBosses
|
||||
main: net.crankedpvp.bosses.BossPlugin
|
||||
version: ${git.total.commit.count}.0
|
||||
description: "§fCommit ID: §a${git.commit.id.abbrev}"
|
||||
website: https://crankedpvp.net/
|
||||
depend:
|
||||
- CrankedUtils
|
||||
Reference in New Issue
Block a user