9
0
mirror of https://github.com/Auxilor/EcoMobs.git synced 2025-12-30 04:19:29 +00:00

Merge remote-tracking branch 'origin/master'

# Conflicts:
#	gradle.properties
This commit is contained in:
Auxilor
2021-09-26 13:57:30 +01:00
17 changed files with 328 additions and 17 deletions

View File

@@ -7,8 +7,8 @@
<h4 align="center">Source code for EcoBosses, a premium spigot plugin.</h4>
<p align="center">
<a href="https://www.spigotmc.org/resources/ecobosses.79573/">
<img alt="spigot" src="https://img.shields.io/badge/spigot-ecobosses-blue?style=for-the-badge"/>
<a href="https://polymart.org/resource/1-16-1-17-ecobosses.525">
<img alt="spigot" src="https://img.shields.io/badge/polymart-ecobosses-blue?style=for-the-badge"/>
</a>
<a href="https://bstats.org/plugin/bukkit/EcoBosses" alt="bstats servers">
<img src="https://img.shields.io/bstats/servers/10635?color=blue&style=for-the-badge"/>

View File

@@ -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 {
@@ -46,7 +47,7 @@ allprojects {
}
dependencies {
compileOnly 'com.willfp:eco:6.8.0'
compileOnly 'com.willfp:eco:6.8.1'
compileOnly 'org.jetbrains:annotations:19.0.0'
@@ -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'

View File

@@ -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'
}

View File

@@ -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;
@@ -30,7 +27,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;
}
@@ -46,7 +43,7 @@ public class EcoBossesPlugin extends EcoPlugin {
@Override
protected List<PluginCommand> loadPluginCommands() {
return Arrays.asList(
return List.of(
new CommandEcobosses(this)
);
}

View File

@@ -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;
@@ -122,6 +124,11 @@ public class EcoBoss extends PluginDependent<EcoPlugin> {
@Getter
private final int attackDamage;
/**
* Age state.
*/
@Getter
private final boolean baby;
/**
* The follow range.
@@ -293,7 +300,7 @@ public class EcoBoss extends PluginDependent<EcoPlugin> {
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<Requirement, List<String>> requirements = new HashMap<>();
@@ -302,6 +309,12 @@ public class EcoBoss extends PluginDependent<EcoPlugin> {
*/
private final Map<UUID, Boolean> cachedRequirements = new HashMap<>();
/**
* The equipment for the boss.
*/
@Getter
private final Map<EquipmentSlot, EquipmentPiece> equipment = new HashMap<>();
/**
* Create a new Boss.
*
@@ -317,6 +330,7 @@ public class EcoBoss extends PluginDependent<EcoPlugin> {
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");
@@ -337,6 +351,60 @@ public class EcoBoss extends PluginDependent<EcoPlugin> {
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(
@@ -475,7 +543,12 @@ public class EcoBoss extends PluginDependent<EcoPlugin> {
this.effectNames = new ArrayList<>();
for (String string : this.getConfig().getStrings("effects")) {
String effectName = string.split(":")[0];
List<String> args = Arrays.asList(string.replace(effectName + ":", "").split(":"));
List<String> 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));
}

View File

@@ -11,15 +11,21 @@ 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 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.Ageable;
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;
@@ -102,6 +108,11 @@ public class LivingEcoBoss extends PluginDependent<EcoPlugin> {
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)));
}
@@ -109,6 +120,35 @@ public class LivingEcoBoss extends PluginDependent<EcoPlugin> {
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));

View File

@@ -1,10 +1,18 @@
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.Creeper;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Zombie;
import org.jetbrains.annotations.NotNull;
import java.util.Arrays;
@UtilityClass
@SuppressWarnings("unchecked")
public class BossEntityUtils {
@@ -14,7 +22,29 @@ public class BossEntityUtils {
* @param id The name.
* @return The boss type.
*/
public static BossType getBossType(@NotNull final String id) {
public static BossType getBossType(@NotNull String id) {
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;
}
MythicMob mob = MythicMobs.inst().getMobManager().getMythicMob(id.replace("mythicmobs:", "")
.replace("_" + level, ""));
if (mob != null) {
return new MythicMobsBossType(mob, level);
}
}
if (id.equalsIgnoreCase("charged_creeper")) {
return new ChargedCreeperBossType();
}
try {
Class<? extends LivingEntity> type = (Class<? extends LivingEntity>) EntityType.valueOf(id.toUpperCase()).getEntityClass();
assert type != null;
@@ -22,6 +52,6 @@ public class BossEntityUtils {
} catch (IllegalArgumentException ignored) {
}
return null;
return new VanillaBossType(Zombie.class);
}
}

View File

@@ -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;
}
}

View File

@@ -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;
}
}

View File

@@ -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;
@@ -23,6 +24,7 @@ class VanillaBossType extends BossType {
@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);
return result;
}
}

View File

@@ -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) {
}

View File

@@ -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
@@ -91,6 +92,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

View File

@@ -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
@@ -94,6 +95,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

View File

@@ -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
@@ -95,6 +96,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

View File

@@ -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
@@ -95,6 +96,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

View File

@@ -5,6 +5,9 @@ api-version: 1.16
authors: [Auxilor]
website: willfp.com
load: STARTUP
softdepend:
- MythicMobs
- LevelledMobs
depend:
- eco

View File

@@ -1,2 +1,2 @@
version = 6.5.5
version = 6.6.2
plugin-name = EcoBosses