From c5f5032e170f1a583e961d22f640e93e114408d3 Mon Sep 17 00:00:00 2001 From: Auxilor Date: Sun, 19 Sep 2021 11:30:25 +0100 Subject: [PATCH 01/14] Updated README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 46eaf47..a269095 100644 --- a/README.md +++ b/README.md @@ -7,8 +7,8 @@

Source code for EcoBosses, a premium spigot plugin.

- - spigot + + spigot From 60b4c1c2468df7d20de9d66ab3e89fed4583e7f7 Mon Sep 17 00:00:00 2001 From: Auxilor Date: Sun, 19 Sep 2021 11:30:51 +0100 Subject: [PATCH 02/14] Updated to eco 6.8.1 polymart resource checker --- build.gradle | 2 +- .../src/main/java/com/willfp/ecobosses/EcoBossesPlugin.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/build.gradle b/build.gradle index cffaf1b..f589465 100644 --- a/build.gradle +++ b/build.gradle @@ -46,7 +46,7 @@ allprojects { } dependencies { - compileOnly 'com.willfp:eco:6.8.0' + compileOnly 'com.willfp:eco:6.8.1' compileOnly 'org.jetbrains:annotations:19.0.0' diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecobosses/EcoBossesPlugin.java b/eco-core/core-plugin/src/main/java/com/willfp/ecobosses/EcoBossesPlugin.java index eab742d..508019c 100644 --- a/eco-core/core-plugin/src/main/java/com/willfp/ecobosses/EcoBossesPlugin.java +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecobosses/EcoBossesPlugin.java @@ -30,7 +30,7 @@ public class EcoBossesPlugin extends EcoPlugin { * Internal constructor called by bukkit on plugin load. */ public EcoBossesPlugin() { - super(86576, 10635, "com.willfp.ecobosses.proxy", "&9"); + super(525, 10635, "com.willfp.ecobosses.proxy", "&9"); instance = this; } From 436e8332135e3280c1baec0f3450af477155894e Mon Sep 17 00:00:00 2001 From: Auxilor Date: Sun, 19 Sep 2021 11:31:03 +0100 Subject: [PATCH 03/14] Updated to 6.5.5 --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index d82dc52..39c83ae 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,2 +1,2 @@ -version = 6.5.4 +version = 6.5.5 plugin-name = EcoBosses \ No newline at end of file From 7ea1f8938bb0fadfe6ac05618b8bffc93c952557 Mon Sep 17 00:00:00 2001 From: Auxilor Date: Sun, 19 Sep 2021 13:33:23 +0100 Subject: [PATCH 04/14] Added option to set boss gear (armor / weapon) --- .../com/willfp/ecobosses/bosses/EcoBoss.java | 64 ++++++++++++++++++- .../ecobosses/bosses/LivingEcoBoss.java | 32 ++++++++++ .../bosses/util/obj/EquipmentPiece.java | 8 +++ .../src/main/resources/bosses/alpha_wolf.yml | 17 +++++ .../main/resources/bosses/dark_guardian.yml | 17 +++++ .../src/main/resources/bosses/steel_golem.yml | 17 +++++ .../src/main/resources/bosses/tarantula.yml | 17 +++++ 7 files changed, 171 insertions(+), 1 deletion(-) create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecobosses/bosses/util/obj/EquipmentPiece.java diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecobosses/bosses/EcoBoss.java b/eco-core/core-plugin/src/main/java/com/willfp/ecobosses/bosses/EcoBoss.java index a84a89c..b6be417 100644 --- a/eco-core/core-plugin/src/main/java/com/willfp/ecobosses/bosses/EcoBoss.java +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecobosses/bosses/EcoBoss.java @@ -20,6 +20,7 @@ import com.willfp.ecobosses.bosses.util.bosstype.BossEntityUtils; import com.willfp.ecobosses.bosses.util.bosstype.BossType; import com.willfp.ecobosses.bosses.util.obj.ArgumentedEffectName; import com.willfp.ecobosses.bosses.util.obj.BossbarProperties; +import com.willfp.ecobosses.bosses.util.obj.EquipmentPiece; import com.willfp.ecobosses.bosses.util.obj.ExperienceOptions; import com.willfp.ecobosses.bosses.util.obj.ImmunityOptions; import com.willfp.ecobosses.bosses.util.obj.OptionedSound; @@ -39,6 +40,7 @@ import org.bukkit.enchantments.Enchantment; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.event.entity.EntityDamageEvent; +import org.bukkit.inventory.EquipmentSlot; import org.bukkit.inventory.ItemFlag; import org.bukkit.inventory.ItemStack; import org.bukkit.persistence.PersistentDataType; @@ -293,7 +295,7 @@ public class EcoBoss extends PluginDependent { private final ItemStack spawnEgg; /** - * All the requirements needed in order to use the enchantment. + * All the requirements needed in order to spawn the boss. */ private final Map> requirements = new HashMap<>(); @@ -302,6 +304,12 @@ public class EcoBoss extends PluginDependent { */ private final Map cachedRequirements = new HashMap<>(); + /** + * The equipment for the boss. + */ + @Getter + private final Map equipment = new HashMap<>(); + /** * Create a new Boss. * @@ -337,6 +345,60 @@ public class EcoBoss extends PluginDependent { this.movementSpeedMultiplier = this.getConfig().getInt("movement-speed"); this.timeToLive = this.getConfig().getInt("time-to-live", -1); + // Equipment + ItemStack helmet = Items.lookup(this.getConfig().getString("gear.helmet.item")).getItem(); + ItemStack chestplate = Items.lookup(this.getConfig().getString("gear.chestplate.item")).getItem(); + ItemStack leggings = Items.lookup(this.getConfig().getString("gear.leggings.item")).getItem(); + ItemStack boots = Items.lookup(this.getConfig().getString("gear.boots.item")).getItem(); + ItemStack hand = Items.lookup(this.getConfig().getString("gear.hand.item")).getItem(); + + if (helmet.getType() != Material.AIR) { + this.equipment.put( + EquipmentSlot.HEAD, + new EquipmentPiece( + helmet, + this.getConfig().getDouble("gear.helmet.chance") + ) + ); + } + if (chestplate.getType() != Material.AIR) { + this.equipment.put( + EquipmentSlot.CHEST, + new EquipmentPiece( + chestplate, + this.getConfig().getDouble("gear.chestplate.chance") + ) + ); + } + if (leggings.getType() != Material.AIR) { + this.equipment.put( + EquipmentSlot.LEGS, + new EquipmentPiece( + leggings, + this.getConfig().getDouble("gear.leggings.chance") + ) + ); + } + if (boots.getType() != Material.AIR) { + this.equipment.put( + EquipmentSlot.FEET, + new EquipmentPiece( + boots, + this.getConfig().getDouble("gear.boots.chance") + ) + ); + } + if (hand.getType() != Material.AIR) { + this.equipment.put( + EquipmentSlot.HAND, + new EquipmentPiece( + hand, + this.getConfig().getDouble("gear.hand.chance") + ) + ); + } + + // Spawn Totem this.spawnTotemEnabled = this.getConfig().getBool("spawn-totem.enabled"); this.spawnTotem = new SpawnTotem( diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecobosses/bosses/LivingEcoBoss.java b/eco-core/core-plugin/src/main/java/com/willfp/ecobosses/bosses/LivingEcoBoss.java index d481371..4a9e41c 100644 --- a/eco-core/core-plugin/src/main/java/com/willfp/ecobosses/bosses/LivingEcoBoss.java +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecobosses/bosses/LivingEcoBoss.java @@ -11,6 +11,7 @@ import com.willfp.ecobosses.bosses.tick.tickers.BossBarTicker; import com.willfp.ecobosses.bosses.tick.tickers.DeathTimeTicker; import com.willfp.ecobosses.bosses.tick.tickers.NamePlaceholderTicker; import com.willfp.ecobosses.bosses.tick.tickers.TargetTicker; +import com.willfp.ecobosses.bosses.util.obj.EquipmentPiece; import com.willfp.ecobosses.bosses.util.obj.OptionedSound; import lombok.Getter; import org.bukkit.Bukkit; @@ -20,6 +21,8 @@ import org.bukkit.attribute.AttributeModifier; import org.bukkit.boss.BarFlag; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; +import org.bukkit.inventory.EntityEquipment; +import org.bukkit.inventory.EquipmentSlot; import org.bukkit.persistence.PersistentDataType; import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffectType; @@ -109,6 +112,35 @@ public class LivingEcoBoss extends PluginDependent { entity.setCustomName(boss.getDisplayName()); entity.setCustomNameVisible(true); + EntityEquipment equipment = entity.getEquipment(); + if (equipment != null) { + EquipmentPiece head = boss.getEquipment().get(EquipmentSlot.HEAD); + EquipmentPiece chest = boss.getEquipment().get(EquipmentSlot.CHEST); + EquipmentPiece legs = boss.getEquipment().get(EquipmentSlot.LEGS); + EquipmentPiece boots = boss.getEquipment().get(EquipmentSlot.FEET); + EquipmentPiece hand = boss.getEquipment().get(EquipmentSlot.HAND); + if (head != null) { + equipment.setHelmet(head.itemStack(), true); + equipment.setHelmetDropChance((float) head.chance()); + } + if (chest != null) { + equipment.setChestplate(chest.itemStack(), true); + equipment.setChestplateDropChance((float) chest.chance()); + } + if (legs != null) { + equipment.setLeggings(legs.itemStack(), true); + equipment.setLeggingsDropChance((float) legs.chance()); + } + if (boots != null) { + equipment.setBoots(boots.itemStack(), true); + equipment.setBootsDropChance((float) boots.chance()); + } + if (hand != null) { + equipment.setItemInMainHand(hand.itemStack(), true); + equipment.setItemInMainHandDropChance((float) hand.chance()); + } + } + AttributeInstance movementSpeed = entity.getAttribute(Attribute.GENERIC_MOVEMENT_SPEED); assert movementSpeed != null; movementSpeed.addModifier(new AttributeModifier(entity.getUniqueId(), "ecobosses-movement-multiplier", boss.getMovementSpeedMultiplier() - 1, AttributeModifier.Operation.MULTIPLY_SCALAR_1)); diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecobosses/bosses/util/obj/EquipmentPiece.java b/eco-core/core-plugin/src/main/java/com/willfp/ecobosses/bosses/util/obj/EquipmentPiece.java new file mode 100644 index 0000000..798876b --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecobosses/bosses/util/obj/EquipmentPiece.java @@ -0,0 +1,8 @@ +package com.willfp.ecobosses.bosses.util.obj; + +import org.bukkit.inventory.ItemStack; +import org.jetbrains.annotations.NotNull; + +public record EquipmentPiece(@NotNull ItemStack itemStack, + double chance) { +} diff --git a/eco-core/core-plugin/src/main/resources/bosses/alpha_wolf.yml b/eco-core/core-plugin/src/main/resources/bosses/alpha_wolf.yml index 6c40a06..ee39081 100644 --- a/eco-core/core-plugin/src/main/resources/bosses/alpha_wolf.yml +++ b/eco-core/core-plugin/src/main/resources/bosses/alpha_wolf.yml @@ -91,6 +91,23 @@ effects: - "give-potion-effect:wither:4:200:10" - "give-potion-effect:hunger:10:600:10" +gear: + helmet: + item: "" + chance: 100 + chestplate: + item: "" + chance: 100 + leggings: + item: "" + chance: 100 + boots: + item: "" + chance: 100 + hand: + item: "" + chance: 100 + defence: immunities: explosion: false diff --git a/eco-core/core-plugin/src/main/resources/bosses/dark_guardian.yml b/eco-core/core-plugin/src/main/resources/bosses/dark_guardian.yml index 49a14ad..9db16f3 100644 --- a/eco-core/core-plugin/src/main/resources/bosses/dark_guardian.yml +++ b/eco-core/core-plugin/src/main/resources/bosses/dark_guardian.yml @@ -94,6 +94,23 @@ effects: - "give-potion-effect:blindness:1:40:20" - "teleport:7:15" +gear: + helmet: + item: "" + chance: 100 + chestplate: + item: "" + chance: 100 + leggings: + item: "" + chance: 100 + boots: + item: "" + chance: 100 + hand: + item: "" + chance: 100 + defence: immunities: explosion: true diff --git a/eco-core/core-plugin/src/main/resources/bosses/steel_golem.yml b/eco-core/core-plugin/src/main/resources/bosses/steel_golem.yml index 8eee847..99bd570 100644 --- a/eco-core/core-plugin/src/main/resources/bosses/steel_golem.yml +++ b/eco-core/core-plugin/src/main/resources/bosses/steel_golem.yml @@ -95,6 +95,23 @@ effects: - "give-potion-effect:slow:5:100:20" - "give-potion-effect:levitation:3:50:10" +gear: + helmet: + item: "" + chance: 100 + chestplate: + item: "" + chance: 100 + leggings: + item: "" + chance: 100 + boots: + item: "" + chance: 100 + hand: + item: "" + chance: 100 + defence: immunities: explosion: true diff --git a/eco-core/core-plugin/src/main/resources/bosses/tarantula.yml b/eco-core/core-plugin/src/main/resources/bosses/tarantula.yml index ae4c3d4..e711c38 100644 --- a/eco-core/core-plugin/src/main/resources/bosses/tarantula.yml +++ b/eco-core/core-plugin/src/main/resources/bosses/tarantula.yml @@ -95,6 +95,23 @@ effects: - "give-potion-effect:hunger:5:400:10" - "give-potion-effect:slow_digging:3:40:10" +gear: + helmet: + item: "" + chance: 100 + chestplate: + item: "" + chance: 100 + leggings: + item: "" + chance: 100 + boots: + item: "" + chance: 100 + hand: + item: "" + chance: 100 + defence: immunities: explosion: false From 31ccdf25893d2871f6508f4b0b22f3a4edff5683 Mon Sep 17 00:00:00 2001 From: Auxilor Date: Sun, 19 Sep 2021 13:33:32 +0100 Subject: [PATCH 05/14] Updated to 6.6.0 --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index 39c83ae..e18feb0 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,2 +1,2 @@ -version = 6.5.5 +version = 6.6.0 plugin-name = EcoBosses \ No newline at end of file From a2c8b73dbc43bb7663e0ef4a745ab044b659e320 Mon Sep 17 00:00:00 2001 From: _OfTeN_ Date: Sun, 19 Sep 2021 22:49:49 +0300 Subject: [PATCH 06/14] Added MythicMobs mobs support. Usage: 'base-mob: mythicmobs__' --- build.gradle | 11 ++++- eco-core/core-plugin/build.gradle | 1 + .../com/willfp/ecobosses/EcoBossesPlugin.java | 12 ++--- .../ecobosses/bosses/LivingEcoBoss.java | 2 + .../bosses/util/bosstype/BossEntityUtils.java | 35 ++++++++++++-- .../util/bosstype/MythicMobsBossType.java | 46 +++++++++++++++++++ 6 files changed, 96 insertions(+), 11 deletions(-) create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecobosses/bosses/util/bosstype/MythicMobsBossType.java diff --git a/build.gradle b/build.gradle index f589465..c3dc3f5 100644 --- a/build.gradle +++ b/build.gradle @@ -39,6 +39,7 @@ allprojects { maven { url 'https://maven.sk89q.com/repo/' } maven { url 'https://github.com/factions-site/repo/raw/public/' } maven { url 'https://repo.extendedclip.com/content/repositories/placeholderapi/' } + maven { url 'https://mvn.lumine.io/repository/maven-public/' } } jar { @@ -85,7 +86,15 @@ shadowJar { } jar { - archiveFileName = findProperty("plugin-name") + " v" + findProperty("version") + " " + "unshaded" + ".jar" + archiveFileName = findProperty("plugin-name") + " v" + findProperty("version") + ".jar" +} + +publishing { + publications { + maven(MavenPublication) { + from(components.java) + } + } } group = 'com.willfp' diff --git a/eco-core/core-plugin/build.gradle b/eco-core/core-plugin/build.gradle index 9cb6f92..c463a83 100644 --- a/eco-core/core-plugin/build.gradle +++ b/eco-core/core-plugin/build.gradle @@ -6,4 +6,5 @@ dependencies { compileOnly 'commons-io:commons-io:2.8.0' compileOnly 'com.destroystokyo.paper:paper-api:1.16.3-R0.1-SNAPSHOT' compileOnly 'com.github.lokka30:LevelledMobs:3.1.4' + compileOnly 'io.lumine.xikage:MythicMobs:4.9.1' } \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecobosses/EcoBossesPlugin.java b/eco-core/core-plugin/src/main/java/com/willfp/ecobosses/EcoBossesPlugin.java index 508019c..ff15fe1 100644 --- a/eco-core/core-plugin/src/main/java/com/willfp/ecobosses/EcoBossesPlugin.java +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecobosses/EcoBossesPlugin.java @@ -3,12 +3,9 @@ package com.willfp.ecobosses; import com.willfp.eco.core.EcoPlugin; import com.willfp.eco.core.command.impl.PluginCommand; import com.willfp.eco.core.integrations.IntegrationLoader; -import com.willfp.ecobosses.bosses.listeners.AttackListeners; -import com.willfp.ecobosses.bosses.listeners.AutoSpawnTimer; -import com.willfp.ecobosses.bosses.listeners.DeathListeners; -import com.willfp.ecobosses.bosses.listeners.PassiveListeners; -import com.willfp.ecobosses.bosses.listeners.SpawnListeners; +import com.willfp.ecobosses.bosses.listeners.*; import com.willfp.ecobosses.bosses.util.BossUtils; +import com.willfp.ecobosses.bosses.util.bosstype.BossEntityUtils; import com.willfp.ecobosses.commands.CommandEcobosses; import com.willfp.ecobosses.integrations.levelledmobs.LevelledMobsListener; import com.willfp.ecobosses.util.DiscoverRecipeListener; @@ -46,7 +43,7 @@ public class EcoBossesPlugin extends EcoPlugin { @Override protected List loadPluginCommands() { - return Arrays.asList( + return List.of( new CommandEcobosses(this) ); } @@ -54,7 +51,8 @@ public class EcoBossesPlugin extends EcoPlugin { @Override protected List loadIntegrationLoaders() { return Arrays.asList( - new IntegrationLoader("LevelledMobs", () -> this.getEventManager().registerListener(new LevelledMobsListener())) + new IntegrationLoader("LevelledMobs", () -> this.getEventManager().registerListener(new LevelledMobsListener())), + new IntegrationLoader("MythicMobs", () -> BossEntityUtils.mythicMobs = true) ); } diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecobosses/bosses/LivingEcoBoss.java b/eco-core/core-plugin/src/main/java/com/willfp/ecobosses/bosses/LivingEcoBoss.java index 4a9e41c..307667d 100644 --- a/eco-core/core-plugin/src/main/java/com/willfp/ecobosses/bosses/LivingEcoBoss.java +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecobosses/bosses/LivingEcoBoss.java @@ -13,11 +13,13 @@ import com.willfp.ecobosses.bosses.tick.tickers.NamePlaceholderTicker; import com.willfp.ecobosses.bosses.tick.tickers.TargetTicker; import com.willfp.ecobosses.bosses.util.obj.EquipmentPiece; import com.willfp.ecobosses.bosses.util.obj.OptionedSound; +import io.lumine.xikage.mythicmobs.mobs.MythicMob; import lombok.Getter; import org.bukkit.Bukkit; import org.bukkit.attribute.Attribute; import org.bukkit.attribute.AttributeInstance; import org.bukkit.attribute.AttributeModifier; +import org.bukkit.block.Block; import org.bukkit.boss.BarFlag; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecobosses/bosses/util/bosstype/BossEntityUtils.java b/eco-core/core-plugin/src/main/java/com/willfp/ecobosses/bosses/util/bosstype/BossEntityUtils.java index 2f1a15e..4458205 100644 --- a/eco-core/core-plugin/src/main/java/com/willfp/ecobosses/bosses/util/bosstype/BossEntityUtils.java +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecobosses/bosses/util/bosstype/BossEntityUtils.java @@ -1,26 +1,55 @@ package com.willfp.ecobosses.bosses.util.bosstype; +import io.lumine.xikage.mythicmobs.MythicMobs; +import io.lumine.xikage.mythicmobs.mobs.MythicMob; +import lombok.Getter; +import lombok.Setter; import lombok.experimental.UtilityClass; import org.bukkit.entity.EntityType; import org.bukkit.entity.LivingEntity; import org.jetbrains.annotations.NotNull; +import java.util.Arrays; + @UtilityClass @SuppressWarnings("unchecked") public class BossEntityUtils { + + @Getter + @Setter + public static boolean mythicMobs = false; + /** * Get boss type. * * @param id The name. * @return The boss type. */ - public static BossType getBossType(@NotNull final String id) { + public static BossType getBossType(@NotNull String id) { + + if (mythicMobs && id.startsWith("mythicmobs_")) { + int level; + + try { + level = Integer.parseInt(Arrays.stream(id.split("_")).toList().get(id.split("_").length-1)); + } catch (NumberFormatException exception) { + level = 1; + } + + MythicMob mob = MythicMobs.inst().getMobManager().getMythicMob(id.replace("mythicmobs_", "").replace("_"+level, "")); + + if (mob != null) { + return new MythicMobsBossType(mob, level); + } + + else id = "zombie"; + } + try { Class type = (Class) EntityType.valueOf(id.toUpperCase()).getEntityClass(); assert type != null; return new VanillaBossType(type); - } catch (IllegalArgumentException ignored) { - } + } catch (IllegalArgumentException ignored) {} return null; } diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecobosses/bosses/util/bosstype/MythicMobsBossType.java b/eco-core/core-plugin/src/main/java/com/willfp/ecobosses/bosses/util/bosstype/MythicMobsBossType.java new file mode 100644 index 0000000..1ef6a02 --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecobosses/bosses/util/bosstype/MythicMobsBossType.java @@ -0,0 +1,46 @@ +package com.willfp.ecobosses.bosses.util.bosstype; + +import io.lumine.xikage.mythicmobs.MythicMobs; +import io.lumine.xikage.mythicmobs.adapters.AbstractLocation; +import io.lumine.xikage.mythicmobs.adapters.AbstractWorld; +import io.lumine.xikage.mythicmobs.api.exceptions.InvalidMobTypeException; +import io.lumine.xikage.mythicmobs.mobs.MythicMob; +import org.bukkit.Location; +import org.bukkit.entity.LivingEntity; +import org.jetbrains.annotations.NotNull; + +public class MythicMobsBossType extends BossType { + + /** + * The entity type. + */ + private final MythicMob boss; + + /** + * Level of MythicMobs mob + */ + private final int level; + + /** + * Create new vanilla boss type. + * + * @param boss The MythicMob. + */ + public MythicMobsBossType(MythicMob boss, int level) { + this.boss = boss; + this.level = level; + } + + + @Override + public LivingEntity spawnBossEntity(@NotNull Location location) { + try { + return (LivingEntity) MythicMobs.inst().getAPIHelper().spawnMythicMob(boss, location, level); + } catch (InvalidMobTypeException e) { + e.printStackTrace(); + } + return null; + } + + +} From 203bec560eff623b9ae2e9de40447e427d08f658 Mon Sep 17 00:00:00 2001 From: _OfTeN_ Date: Sun, 19 Sep 2021 23:01:40 +0300 Subject: [PATCH 07/14] Updated how mythic mob fetcher works --- .../bosses/util/bosstype/BossEntityUtils.java | 26 ++++++++++--------- .../core-plugin/src/main/resources/plugin.yml | 3 +++ 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecobosses/bosses/util/bosstype/BossEntityUtils.java b/eco-core/core-plugin/src/main/java/com/willfp/ecobosses/bosses/util/bosstype/BossEntityUtils.java index 4458205..5a2b062 100644 --- a/eco-core/core-plugin/src/main/java/com/willfp/ecobosses/bosses/util/bosstype/BossEntityUtils.java +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecobosses/bosses/util/bosstype/BossEntityUtils.java @@ -27,22 +27,24 @@ public class BossEntityUtils { */ public static BossType getBossType(@NotNull String id) { - if (mythicMobs && id.startsWith("mythicmobs_")) { - int level; + if (id.startsWith("mythicmobs_")) { + if (mythicMobs) { + int level; - try { - level = Integer.parseInt(Arrays.stream(id.split("_")).toList().get(id.split("_").length-1)); - } catch (NumberFormatException exception) { - level = 1; - } + try { + level = Integer.parseInt(Arrays.stream(id.split("_")).toList().get(id.split("_").length-1)); + } catch (NumberFormatException exception) { + level = 1; + } - MythicMob mob = MythicMobs.inst().getMobManager().getMythicMob(id.replace("mythicmobs_", "").replace("_"+level, "")); + MythicMob mob = MythicMobs.inst().getMobManager().getMythicMob(id.replace("mythicmobs_", "").replace("_"+level, "")); - if (mob != null) { - return new MythicMobsBossType(mob, level); - } + if (mob != null) { + return new MythicMobsBossType(mob, level); + } + else id = "zombie"; + } else id = "zombie"; - else id = "zombie"; } try { diff --git a/eco-core/core-plugin/src/main/resources/plugin.yml b/eco-core/core-plugin/src/main/resources/plugin.yml index 5f4310d..5e53d69 100644 --- a/eco-core/core-plugin/src/main/resources/plugin.yml +++ b/eco-core/core-plugin/src/main/resources/plugin.yml @@ -5,6 +5,9 @@ api-version: 1.16 authors: [Auxilor] website: willfp.com load: STARTUP +softdepend: + - MythicMobs + - LevelledMobs depend: - eco From 468b0b4292b4be61b497a6ca17f6c5b4046d89e3 Mon Sep 17 00:00:00 2001 From: _OfTeN_ Date: Mon, 20 Sep 2021 11:16:44 +0300 Subject: [PATCH 08/14] Added 'baby: true/false' option for boss config to control the mob age. --- .../src/main/java/com/willfp/ecobosses/bosses/EcoBoss.java | 6 ++++++ .../java/com/willfp/ecobosses/bosses/LivingEcoBoss.java | 6 ++++++ .../core-plugin/src/main/resources/bosses/alpha_wolf.yml | 1 + .../core-plugin/src/main/resources/bosses/dark_guardian.yml | 1 + .../core-plugin/src/main/resources/bosses/steel_golem.yml | 1 + .../core-plugin/src/main/resources/bosses/tarantula.yml | 1 + 6 files changed, 16 insertions(+) diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecobosses/bosses/EcoBoss.java b/eco-core/core-plugin/src/main/java/com/willfp/ecobosses/bosses/EcoBoss.java index b6be417..0d9d840 100644 --- a/eco-core/core-plugin/src/main/java/com/willfp/ecobosses/bosses/EcoBoss.java +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecobosses/bosses/EcoBoss.java @@ -124,6 +124,11 @@ public class EcoBoss extends PluginDependent { @Getter private final int attackDamage; + /** + * Age state. + */ + @Getter + private final boolean baby; /** * The follow range. @@ -325,6 +330,7 @@ public class EcoBoss extends PluginDependent { this.name = name; this.livingBosses = new HashMap<>(); this.isGlowing = this.getConfig().getBool("glowing"); + this.baby = this.getConfig().getBool("baby"); this.displayName = this.getConfig().getString("name"); diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecobosses/bosses/LivingEcoBoss.java b/eco-core/core-plugin/src/main/java/com/willfp/ecobosses/bosses/LivingEcoBoss.java index 307667d..8e8b33d 100644 --- a/eco-core/core-plugin/src/main/java/com/willfp/ecobosses/bosses/LivingEcoBoss.java +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecobosses/bosses/LivingEcoBoss.java @@ -21,6 +21,7 @@ import org.bukkit.attribute.AttributeInstance; import org.bukkit.attribute.AttributeModifier; import org.bukkit.block.Block; import org.bukkit.boss.BarFlag; +import org.bukkit.entity.Ageable; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.inventory.EntityEquipment; @@ -107,6 +108,11 @@ public class LivingEcoBoss extends PluginDependent { if (boss.isGlowing()) entity.addPotionEffect(new PotionEffect(PotionEffectType.GLOWING, Integer.MAX_VALUE, 1, false, false, false)); + if (entity instanceof Ageable ageable) { + if (boss.isBaby()) ageable.setBaby(); + else ageable.setAdult(); + } + if (boss.getTimeToLive() > 0) { entity.setMetadata("death-time", this.getPlugin().getMetadataValueFactory().create(System.currentTimeMillis() + (boss.getTimeToLive() * 1000L))); } diff --git a/eco-core/core-plugin/src/main/resources/bosses/alpha_wolf.yml b/eco-core/core-plugin/src/main/resources/bosses/alpha_wolf.yml index ee39081..09f7408 100644 --- a/eco-core/core-plugin/src/main/resources/bosses/alpha_wolf.yml +++ b/eco-core/core-plugin/src/main/resources/bosses/alpha_wolf.yml @@ -2,6 +2,7 @@ enabled: true name: "&fAlpha Wolf &7| &c%health%♥ &7| &e%time%" # Display name base-mob: wolf +baby: false # If set to true: will make the boss mob baby (if possible) bossbar: enabled: true diff --git a/eco-core/core-plugin/src/main/resources/bosses/dark_guardian.yml b/eco-core/core-plugin/src/main/resources/bosses/dark_guardian.yml index 9db16f3..f134f64 100644 --- a/eco-core/core-plugin/src/main/resources/bosses/dark_guardian.yml +++ b/eco-core/core-plugin/src/main/resources/bosses/dark_guardian.yml @@ -2,6 +2,7 @@ enabled: true name: "&9Dark Guardian &7| &c%health%♥ &7| &e%time%" # Display name base-mob: ravager +baby: false # If set to true: will make the boss mob baby (if possible) bossbar: enabled: true diff --git a/eco-core/core-plugin/src/main/resources/bosses/steel_golem.yml b/eco-core/core-plugin/src/main/resources/bosses/steel_golem.yml index 99bd570..631c162 100644 --- a/eco-core/core-plugin/src/main/resources/bosses/steel_golem.yml +++ b/eco-core/core-plugin/src/main/resources/bosses/steel_golem.yml @@ -2,6 +2,7 @@ enabled: true name: "&8Steel Golem &7| &c%health%♥ &7| &e%time%" # Display name base-mob: iron_golem +baby: false # If set to true: will make the boss mob baby (if possible) bossbar: enabled: true diff --git a/eco-core/core-plugin/src/main/resources/bosses/tarantula.yml b/eco-core/core-plugin/src/main/resources/bosses/tarantula.yml index e711c38..91f1ff9 100644 --- a/eco-core/core-plugin/src/main/resources/bosses/tarantula.yml +++ b/eco-core/core-plugin/src/main/resources/bosses/tarantula.yml @@ -2,6 +2,7 @@ enabled: true name: "&4Tarantula &7| &c%health%♥ &7| &e%time%" # Display name base-mob: cave_spider +baby: false # If set to true: will make the boss mob baby (if possible) bossbar: enabled: true From 77985e5a230e22c23f2310811faa304f2fe6e160 Mon Sep 17 00:00:00 2001 From: Auxilor Date: Mon, 20 Sep 2021 16:46:07 +0100 Subject: [PATCH 09/14] Improved mythicmobs pr --- .../com/willfp/ecobosses/EcoBossesPlugin.java | 3 +- .../bosses/util/bosstype/BossEntityUtils.java | 38 ++++++++----------- 2 files changed, 17 insertions(+), 24 deletions(-) diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecobosses/EcoBossesPlugin.java b/eco-core/core-plugin/src/main/java/com/willfp/ecobosses/EcoBossesPlugin.java index ff15fe1..7f1d29d 100644 --- a/eco-core/core-plugin/src/main/java/com/willfp/ecobosses/EcoBossesPlugin.java +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecobosses/EcoBossesPlugin.java @@ -51,8 +51,7 @@ public class EcoBossesPlugin extends EcoPlugin { @Override protected List loadIntegrationLoaders() { return Arrays.asList( - new IntegrationLoader("LevelledMobs", () -> this.getEventManager().registerListener(new LevelledMobsListener())), - new IntegrationLoader("MythicMobs", () -> BossEntityUtils.mythicMobs = true) + new IntegrationLoader("LevelledMobs", () -> this.getEventManager().registerListener(new LevelledMobsListener())) ); } diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecobosses/bosses/util/bosstype/BossEntityUtils.java b/eco-core/core-plugin/src/main/java/com/willfp/ecobosses/bosses/util/bosstype/BossEntityUtils.java index 5a2b062..9bdc61d 100644 --- a/eco-core/core-plugin/src/main/java/com/willfp/ecobosses/bosses/util/bosstype/BossEntityUtils.java +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecobosses/bosses/util/bosstype/BossEntityUtils.java @@ -7,6 +7,7 @@ import lombok.Setter; import lombok.experimental.UtilityClass; import org.bukkit.entity.EntityType; import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Zombie; import org.jetbrains.annotations.NotNull; import java.util.Arrays; @@ -14,11 +15,6 @@ import java.util.Arrays; @UtilityClass @SuppressWarnings("unchecked") public class BossEntityUtils { - - @Getter - @Setter - public static boolean mythicMobs = false; - /** * Get boss type. * @@ -27,32 +23,30 @@ public class BossEntityUtils { */ public static BossType getBossType(@NotNull String id) { - if (id.startsWith("mythicmobs_")) { - if (mythicMobs) { - int level; + if (id.startsWith("mythicmobs:")) { + int level; - try { - level = Integer.parseInt(Arrays.stream(id.split("_")).toList().get(id.split("_").length-1)); - } catch (NumberFormatException exception) { - level = 1; - } + try { + level = Integer.parseInt(Arrays.stream(id.split("_")).toList().get(id.split("_").length - 1)); + } catch (NumberFormatException exception) { + level = 1; + } - MythicMob mob = MythicMobs.inst().getMobManager().getMythicMob(id.replace("mythicmobs_", "").replace("_"+level, "")); - - if (mob != null) { - return new MythicMobsBossType(mob, level); - } - else id = "zombie"; - } else id = "zombie"; + MythicMob mob = MythicMobs.inst().getMobManager().getMythicMob(id.replace("mythicmobs:", "") + .replace("_" + level, "")); + if (mob != null) { + return new MythicMobsBossType(mob, level); + } } try { Class type = (Class) EntityType.valueOf(id.toUpperCase()).getEntityClass(); assert type != null; return new VanillaBossType(type); - } catch (IllegalArgumentException ignored) {} + } catch (IllegalArgumentException ignored) { + } - return null; + return new VanillaBossType(Zombie.class); } } From 260aec8ba4d6ca676e4fccb8a8eab62caf01df0b Mon Sep 17 00:00:00 2001 From: Auxilor Date: Mon, 20 Sep 2021 16:46:13 +0100 Subject: [PATCH 10/14] Updated to 6.6.1 --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index e18feb0..33d7ff4 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,2 +1,2 @@ -version = 6.6.0 +version = 6.6.1 plugin-name = EcoBosses \ No newline at end of file From 0747a0a3d4b9a062b31b4514a54f97dd9a052690 Mon Sep 17 00:00:00 2001 From: _OfTeN_ Date: Mon, 20 Sep 2021 22:00:01 +0300 Subject: [PATCH 11/14] Added ability to use "charged_creeper" as 'base-mob:' or in 'summon:' effect to spawn charged creepers --- .../bosses/util/bosstype/BossEntityUtils.java | 5 +++++ .../bosses/util/bosstype/VanillaBossType.java | 22 ++++++++++++++++++- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecobosses/bosses/util/bosstype/BossEntityUtils.java b/eco-core/core-plugin/src/main/java/com/willfp/ecobosses/bosses/util/bosstype/BossEntityUtils.java index 9bdc61d..b8813b7 100644 --- a/eco-core/core-plugin/src/main/java/com/willfp/ecobosses/bosses/util/bosstype/BossEntityUtils.java +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecobosses/bosses/util/bosstype/BossEntityUtils.java @@ -5,6 +5,7 @@ import io.lumine.xikage.mythicmobs.mobs.MythicMob; import lombok.Getter; import lombok.Setter; import lombok.experimental.UtilityClass; +import org.bukkit.entity.Creeper; import org.bukkit.entity.EntityType; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Zombie; @@ -40,6 +41,10 @@ public class BossEntityUtils { } } + if (id.equalsIgnoreCase("charged_creeper")) { + return new VanillaBossType(Creeper.class, true); + } + try { Class type = (Class) EntityType.valueOf(id.toUpperCase()).getEntityClass(); assert type != null; diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecobosses/bosses/util/bosstype/VanillaBossType.java b/eco-core/core-plugin/src/main/java/com/willfp/ecobosses/bosses/util/bosstype/VanillaBossType.java index 7899d6b..708b6ea 100644 --- a/eco-core/core-plugin/src/main/java/com/willfp/ecobosses/bosses/util/bosstype/VanillaBossType.java +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecobosses/bosses/util/bosstype/VanillaBossType.java @@ -1,6 +1,7 @@ package com.willfp.ecobosses.bosses.util.bosstype; import org.bukkit.Location; +import org.bukkit.entity.Creeper; import org.bukkit.entity.LivingEntity; import org.jetbrains.annotations.NotNull; @@ -12,6 +13,11 @@ class VanillaBossType extends BossType { */ private final Class entityClass; + /** + * If the entity is Creeper and should or should not be charged. + */ + private final boolean creeperCharged; + /** * Create new vanilla boss type. * @@ -19,10 +25,24 @@ class VanillaBossType extends BossType { */ VanillaBossType(@NotNull final Class entityClass) { this.entityClass = entityClass; + this.creeperCharged = false; + } + + /** + * Create new vanilla boss type. + * + * @param entityClass The entity class. + * @param creeperCharged The creeper power state. + */ + VanillaBossType(@NotNull final Class entityClass, boolean creeperCharged) { + this.entityClass = entityClass; + this.creeperCharged = creeperCharged; } @Override public LivingEntity spawnBossEntity(@NotNull final Location location) { - return Objects.requireNonNull(location.getWorld()).spawn(location, entityClass); + LivingEntity result = Objects.requireNonNull(location.getWorld()).spawn(location, entityClass); + if (result instanceof Creeper creeper && creeperCharged) creeper.setPowered(true); + return result; } } From b75b83aebf02ceb8694c9ca5547dfeb28645a21a Mon Sep 17 00:00:00 2001 From: Auxilor Date: Tue, 21 Sep 2021 08:44:37 +0100 Subject: [PATCH 12/14] Updated PR to use ChargedCreeperBossType --- .../bosses/util/bosstype/BossEntityUtils.java | 2 +- .../util/bosstype/ChargedCreeperBossType.java | 30 +++++++++++++++++++ .../bosses/util/bosstype/VanillaBossType.java | 18 ----------- 3 files changed, 31 insertions(+), 19 deletions(-) create mode 100644 eco-core/core-plugin/src/main/java/com/willfp/ecobosses/bosses/util/bosstype/ChargedCreeperBossType.java diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecobosses/bosses/util/bosstype/BossEntityUtils.java b/eco-core/core-plugin/src/main/java/com/willfp/ecobosses/bosses/util/bosstype/BossEntityUtils.java index b8813b7..cc50e7c 100644 --- a/eco-core/core-plugin/src/main/java/com/willfp/ecobosses/bosses/util/bosstype/BossEntityUtils.java +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecobosses/bosses/util/bosstype/BossEntityUtils.java @@ -42,7 +42,7 @@ public class BossEntityUtils { } if (id.equalsIgnoreCase("charged_creeper")) { - return new VanillaBossType(Creeper.class, true); + return new ChargedCreeperBossType(); } try { diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecobosses/bosses/util/bosstype/ChargedCreeperBossType.java b/eco-core/core-plugin/src/main/java/com/willfp/ecobosses/bosses/util/bosstype/ChargedCreeperBossType.java new file mode 100644 index 0000000..c867868 --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecobosses/bosses/util/bosstype/ChargedCreeperBossType.java @@ -0,0 +1,30 @@ +package com.willfp.ecobosses.bosses.util.bosstype; + +import org.bukkit.Location; +import org.bukkit.entity.Creeper; +import org.bukkit.entity.LivingEntity; +import org.jetbrains.annotations.NotNull; + +import java.util.Objects; + +class ChargedCreeperBossType extends VanillaBossType { + /** + * Create new Charged Creeper boss type. + */ + ChargedCreeperBossType() { + super(Creeper.class); + } + + /** + * Spawn a charged creeper. + * + * @param location The location. + * @return The entity. + */ + @Override + public LivingEntity spawnBossEntity(@NotNull final Location location) { + Creeper creeper = Objects.requireNonNull(location.getWorld()).spawn(location, Creeper.class); + creeper.setPowered(true); + return creeper; + } +} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecobosses/bosses/util/bosstype/VanillaBossType.java b/eco-core/core-plugin/src/main/java/com/willfp/ecobosses/bosses/util/bosstype/VanillaBossType.java index 708b6ea..f1f3195 100644 --- a/eco-core/core-plugin/src/main/java/com/willfp/ecobosses/bosses/util/bosstype/VanillaBossType.java +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecobosses/bosses/util/bosstype/VanillaBossType.java @@ -13,11 +13,6 @@ class VanillaBossType extends BossType { */ private final Class entityClass; - /** - * If the entity is Creeper and should or should not be charged. - */ - private final boolean creeperCharged; - /** * Create new vanilla boss type. * @@ -25,24 +20,11 @@ class VanillaBossType extends BossType { */ VanillaBossType(@NotNull final Class entityClass) { this.entityClass = entityClass; - this.creeperCharged = false; - } - - /** - * Create new vanilla boss type. - * - * @param entityClass The entity class. - * @param creeperCharged The creeper power state. - */ - VanillaBossType(@NotNull final Class entityClass, boolean creeperCharged) { - this.entityClass = entityClass; - this.creeperCharged = creeperCharged; } @Override public LivingEntity spawnBossEntity(@NotNull final Location location) { LivingEntity result = Objects.requireNonNull(location.getWorld()).spawn(location, entityClass); - if (result instanceof Creeper creeper && creeperCharged) creeper.setPowered(true); return result; } } From f1c26763e07abe1a4894d8576293b4522a40a905 Mon Sep 17 00:00:00 2001 From: Auxilor Date: Tue, 21 Sep 2021 08:44:47 +0100 Subject: [PATCH 13/14] Updated to 6.6.2 --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index 33d7ff4..cc8a0c6 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,2 +1,2 @@ -version = 6.6.1 +version = 6.6.2 plugin-name = EcoBosses \ No newline at end of file From 0e2cdb71cbac7606bf3a3320c279f5556a9292ef Mon Sep 17 00:00:00 2001 From: _OfTeN_ Date: Sun, 26 Sep 2021 03:20:09 +0300 Subject: [PATCH 14/14] Fixed mythicmobs:mob_level not working in summon effect. --- .../src/main/java/com/willfp/ecobosses/bosses/EcoBoss.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecobosses/bosses/EcoBoss.java b/eco-core/core-plugin/src/main/java/com/willfp/ecobosses/bosses/EcoBoss.java index 0d9d840..ee99878 100644 --- a/eco-core/core-plugin/src/main/java/com/willfp/ecobosses/bosses/EcoBoss.java +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecobosses/bosses/EcoBoss.java @@ -543,7 +543,12 @@ public class EcoBoss extends PluginDependent { this.effectNames = new ArrayList<>(); for (String string : this.getConfig().getStrings("effects")) { String effectName = string.split(":")[0]; - List args = Arrays.asList(string.replace(effectName + ":", "").split(":")); + List args = new ArrayList<>(Arrays.asList(string.replace(effectName + ":", "").split(":"))); + if (args.contains("mythicmobs")) { + String newArg = "mythicmobs:" + args.get(args.indexOf("mythicmobs")+1); + args.set(args.indexOf("mythicmobs"), newArg); + args.remove(args.get(args.indexOf(newArg)+1)); + } this.effectNames.add(new ArgumentedEffectName(effectName, args)); }