mirror of
https://github.com/Auxilor/EcoMobs.git
synced 2025-12-21 07:59:28 +00:00
Moved Potion Effect, Shuffle Hotbar, Summon, into effects
This commit is contained in:
@@ -11,12 +11,10 @@ import com.willfp.ecobosses.bosses.effects.Effects;
|
|||||||
import com.willfp.ecobosses.bosses.util.bosstype.BossEntityUtils;
|
import com.willfp.ecobosses.bosses.util.bosstype.BossEntityUtils;
|
||||||
import com.willfp.ecobosses.bosses.util.bosstype.BossType;
|
import com.willfp.ecobosses.bosses.util.bosstype.BossType;
|
||||||
import com.willfp.ecobosses.bosses.util.obj.BossbarProperties;
|
import com.willfp.ecobosses.bosses.util.obj.BossbarProperties;
|
||||||
import com.willfp.ecobosses.bosses.util.obj.EffectOption;
|
|
||||||
import com.willfp.ecobosses.bosses.util.obj.ExperienceOptions;
|
import com.willfp.ecobosses.bosses.util.obj.ExperienceOptions;
|
||||||
import com.willfp.ecobosses.bosses.util.obj.ImmunityOptions;
|
import com.willfp.ecobosses.bosses.util.obj.ImmunityOptions;
|
||||||
import com.willfp.ecobosses.bosses.util.obj.OptionedSound;
|
import com.willfp.ecobosses.bosses.util.obj.OptionedSound;
|
||||||
import com.willfp.ecobosses.bosses.util.obj.SpawnTotem;
|
import com.willfp.ecobosses.bosses.util.obj.SpawnTotem;
|
||||||
import com.willfp.ecobosses.bosses.util.obj.SummonsOption;
|
|
||||||
import com.willfp.ecobosses.bosses.util.obj.TargetMode;
|
import com.willfp.ecobosses.bosses.util.obj.TargetMode;
|
||||||
import com.willfp.ecobosses.bosses.util.obj.TeleportOptions;
|
import com.willfp.ecobosses.bosses.util.obj.TeleportOptions;
|
||||||
import lombok.AccessLevel;
|
import lombok.AccessLevel;
|
||||||
@@ -32,7 +30,6 @@ import org.bukkit.configuration.file.YamlConfiguration;
|
|||||||
import org.bukkit.entity.LivingEntity;
|
import org.bukkit.entity.LivingEntity;
|
||||||
import org.bukkit.event.entity.EntityDamageEvent;
|
import org.bukkit.event.entity.EntityDamageEvent;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.potion.PotionEffectType;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -144,24 +141,6 @@ public class EcoBoss extends PluginDependent {
|
|||||||
@Getter
|
@Getter
|
||||||
private final ExperienceOptions experienceOptions;
|
private final ExperienceOptions experienceOptions;
|
||||||
|
|
||||||
/**
|
|
||||||
* The effects.
|
|
||||||
*/
|
|
||||||
@Getter
|
|
||||||
private final Set<EffectOption> effects;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The summons.
|
|
||||||
*/
|
|
||||||
@Getter
|
|
||||||
private final Set<SummonsOption> summons;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The shuffle chance.
|
|
||||||
*/
|
|
||||||
@Getter
|
|
||||||
private final double shuffleChance;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If attacks should be called on injury.
|
* If attacks should be called on injury.
|
||||||
*/
|
*/
|
||||||
@@ -347,33 +326,6 @@ public class EcoBoss extends PluginDependent {
|
|||||||
double projectile = this.getConfig().getDouble("defence.incoming-multipliers.projectile");
|
double projectile = this.getConfig().getDouble("defence.incoming-multipliers.projectile");
|
||||||
this.incomingMultipliers.put(EntityDamageEvent.DamageCause.PROJECTILE, projectile);
|
this.incomingMultipliers.put(EntityDamageEvent.DamageCause.PROJECTILE, projectile);
|
||||||
|
|
||||||
// Effects
|
|
||||||
this.effects = new HashSet<>();
|
|
||||||
for (String string : this.getConfig().getStrings("attacks.potion-effects")) {
|
|
||||||
String[] split = string.split(":");
|
|
||||||
PotionEffectType type = PotionEffectType.getByName(split[0].toUpperCase());
|
|
||||||
assert type != null;
|
|
||||||
this.effects.add(new EffectOption(
|
|
||||||
Double.parseDouble(split[3]),
|
|
||||||
Integer.parseInt(split[1]) - 1,
|
|
||||||
Integer.parseInt(split[2]),
|
|
||||||
type
|
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Summons
|
|
||||||
this.summons = new HashSet<>();
|
|
||||||
for (String string : this.getConfig().getStrings("attacks.summons")) {
|
|
||||||
String[] split = string.split(":");
|
|
||||||
this.summons.add(new SummonsOption(
|
|
||||||
Double.parseDouble(split[1]),
|
|
||||||
BossEntityUtils.getBossType(split[0].toUpperCase())
|
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Shuffle
|
|
||||||
this.shuffleChance = this.getConfig().getDouble("attacks.shuffle-chance");
|
|
||||||
|
|
||||||
// Attack on injure
|
// Attack on injure
|
||||||
this.attackOnInjure = this.getConfig().getBool("attacks.on-injure");
|
this.attackOnInjure = this.getConfig().getBool("attacks.on-injure");
|
||||||
|
|
||||||
@@ -494,7 +446,7 @@ public class EcoBoss extends PluginDependent {
|
|||||||
*
|
*
|
||||||
* @return The effects.
|
* @return The effects.
|
||||||
*/
|
*/
|
||||||
public Set<Effect> createEffectTickers() {
|
public Set<Effect> createEffects() {
|
||||||
Set<Effect> effects = new HashSet<>();
|
Set<Effect> effects = new HashSet<>();
|
||||||
this.effectNames.forEach((string, args) -> {
|
this.effectNames.forEach((string, args) -> {
|
||||||
effects.add(Effects.getEffect(string, args));
|
effects.add(Effects.getEffect(string, args));
|
||||||
|
|||||||
@@ -3,36 +3,24 @@ package com.willfp.ecobosses.bosses;
|
|||||||
import com.willfp.eco.core.EcoPlugin;
|
import com.willfp.eco.core.EcoPlugin;
|
||||||
import com.willfp.eco.core.PluginDependent;
|
import com.willfp.eco.core.PluginDependent;
|
||||||
import com.willfp.eco.core.scheduling.RunnableTask;
|
import com.willfp.eco.core.scheduling.RunnableTask;
|
||||||
import com.willfp.eco.util.NumberUtils;
|
|
||||||
import com.willfp.eco.util.StringUtils;
|
import com.willfp.eco.util.StringUtils;
|
||||||
|
import com.willfp.ecobosses.bosses.effects.Effect;
|
||||||
import com.willfp.ecobosses.bosses.tick.BossTicker;
|
import com.willfp.ecobosses.bosses.tick.BossTicker;
|
||||||
import com.willfp.ecobosses.bosses.tick.tickers.BossBarTicker;
|
import com.willfp.ecobosses.bosses.tick.tickers.BossBarTicker;
|
||||||
import com.willfp.ecobosses.bosses.tick.tickers.HealthPlaceholderTicker;
|
import com.willfp.ecobosses.bosses.tick.tickers.HealthPlaceholderTicker;
|
||||||
import com.willfp.ecobosses.bosses.tick.tickers.TargetTicker;
|
import com.willfp.ecobosses.bosses.tick.tickers.TargetTicker;
|
||||||
import com.willfp.ecobosses.bosses.util.obj.EffectOption;
|
|
||||||
import com.willfp.ecobosses.bosses.util.obj.OptionedSound;
|
import com.willfp.ecobosses.bosses.util.obj.OptionedSound;
|
||||||
import com.willfp.ecobosses.bosses.util.obj.SummonsOption;
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.Sound;
|
|
||||||
import org.bukkit.attribute.Attribute;
|
import org.bukkit.attribute.Attribute;
|
||||||
import org.bukkit.attribute.AttributeInstance;
|
import org.bukkit.attribute.AttributeInstance;
|
||||||
import org.bukkit.attribute.AttributeModifier;
|
import org.bukkit.attribute.AttributeModifier;
|
||||||
import org.bukkit.boss.BarFlag;
|
import org.bukkit.boss.BarFlag;
|
||||||
import org.bukkit.entity.Entity;
|
|
||||||
import org.bukkit.entity.LivingEntity;
|
import org.bukkit.entity.LivingEntity;
|
||||||
import org.bukkit.entity.Mob;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.ItemStack;
|
|
||||||
import org.bukkit.persistence.PersistentDataType;
|
import org.bukkit.persistence.PersistentDataType;
|
||||||
import org.bukkit.potion.PotionEffect;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.concurrent.atomic.AtomicLong;
|
import java.util.concurrent.atomic.AtomicLong;
|
||||||
|
|
||||||
@@ -52,6 +40,11 @@ public class LivingEcoBoss extends PluginDependent {
|
|||||||
*/
|
*/
|
||||||
private final Set<BossTicker> tickers;
|
private final Set<BossTicker> tickers;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The effects.
|
||||||
|
*/
|
||||||
|
private final Set<Effect> effects;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create new living EcoBoss.
|
* Create new living EcoBoss.
|
||||||
*
|
*
|
||||||
@@ -85,13 +78,13 @@ public class LivingEcoBoss extends PluginDependent {
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
this.tickers.addAll(boss.createEffectTickers());
|
|
||||||
|
|
||||||
|
// Effects
|
||||||
|
this.effects = new HashSet<>();
|
||||||
|
this.effects.addAll(boss.createEffects());
|
||||||
|
|
||||||
AtomicLong currentTick = new AtomicLong(0);
|
AtomicLong currentTick = new AtomicLong(0);
|
||||||
this.getPlugin().getRunnableFactory().create(runnable -> {
|
this.getPlugin().getRunnableFactory().create(runnable -> this.tick(currentTick.getAndAdd(1), runnable)).runTaskTimer(0, 1);
|
||||||
this.tick(currentTick.getAndAdd(1), runnable);
|
|
||||||
}).runTaskTimer(0, 1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onSpawn() {
|
private void onSpawn() {
|
||||||
@@ -137,10 +130,16 @@ public class LivingEcoBoss extends PluginDependent {
|
|||||||
for (BossTicker ticker : tickers) {
|
for (BossTicker ticker : tickers) {
|
||||||
ticker.tick(boss, entity, tick);
|
ticker.tick(boss, entity, tick);
|
||||||
}
|
}
|
||||||
|
for (Effect effect : effects) {
|
||||||
|
effect.tick(boss, entity, tick);
|
||||||
|
}
|
||||||
if (entity.isDead()) {
|
if (entity.isDead()) {
|
||||||
for (BossTicker ticker : tickers) {
|
for (BossTicker ticker : tickers) {
|
||||||
ticker.onDeath(boss, entity, tick);
|
ticker.onDeath(boss, entity, tick);
|
||||||
}
|
}
|
||||||
|
for (Effect effect : effects) {
|
||||||
|
effect.onDeath(boss, entity, tick);
|
||||||
|
}
|
||||||
runnable.cancel();
|
runnable.cancel();
|
||||||
boss.removeLivingBoss(entity.getUniqueId());
|
boss.removeLivingBoss(entity.getUniqueId());
|
||||||
}
|
}
|
||||||
@@ -156,46 +155,8 @@ public class LivingEcoBoss extends PluginDependent {
|
|||||||
player.getWorld().playSound(entity.getLocation(), sound.getSound(), sound.getVolume(), sound.getPitch());
|
player.getWorld().playSound(entity.getLocation(), sound.getSound(), sound.getVolume(), sound.getPitch());
|
||||||
}
|
}
|
||||||
|
|
||||||
for (EffectOption effect : boss.getEffects()) {
|
for (Effect effect : effects) {
|
||||||
if (NumberUtils.randFloat(0, 100) > effect.getChance()) {
|
effect.onAttack(boss, entity, player);
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
player.addPotionEffect(new PotionEffect(effect.getEffectType(), effect.getDuration(), effect.getLevel()));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (NumberUtils.randFloat(0, 100) < boss.getShuffleChance()) {
|
|
||||||
List<ItemStack> hotbar = new ArrayList<>();
|
|
||||||
for (int i = 0; i < 9; i++) {
|
|
||||||
hotbar.add(player.getInventory().getItem(i));
|
|
||||||
}
|
|
||||||
Collections.shuffle(hotbar);
|
|
||||||
int i2 = 0;
|
|
||||||
for (ItemStack item : hotbar) {
|
|
||||||
player.getInventory().setItem(i2, item);
|
|
||||||
i2++;
|
|
||||||
}
|
|
||||||
player.playSound(player.getLocation(), Sound.ENTITY_ENDER_PEARL_THROW, 1, 0.5f);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (SummonsOption summon : boss.getSummons()) {
|
|
||||||
if (NumberUtils.randFloat(0, 100) > summon.getChance()) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
Location loc = player.getLocation().add(NumberUtils.randInt(2, 6), 0, NumberUtils.randInt(2, 6));
|
|
||||||
while (!loc.getBlock().getType().equals(Material.AIR)) {
|
|
||||||
loc.add(0, 1, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
Entity summonedEntity = summon.getType().spawnBossEntity(loc);
|
|
||||||
if (summonedEntity instanceof Mob) {
|
|
||||||
((Mob) summonedEntity).setTarget(player);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (OptionedSound sound : boss.getSummonSounds()) {
|
|
||||||
player.getWorld().playSound(entity.getLocation(), sound.getSound(), sound.getVolume(), sound.getPitch());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,11 @@
|
|||||||
package com.willfp.ecobosses.bosses.effects;
|
package com.willfp.ecobosses.bosses.effects;
|
||||||
|
|
||||||
|
import com.willfp.ecobosses.bosses.EcoBoss;
|
||||||
import com.willfp.ecobosses.bosses.tick.BossTicker;
|
import com.willfp.ecobosses.bosses.tick.BossTicker;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.entity.LivingEntity;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -40,4 +43,44 @@ public abstract class Effect implements BossTicker {
|
|||||||
* @return The usage.
|
* @return The usage.
|
||||||
*/
|
*/
|
||||||
public abstract String getUsage();
|
public abstract String getUsage();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle the boss attacking a player.
|
||||||
|
*
|
||||||
|
* @param boss The boss.
|
||||||
|
* @param entity The boss entity.
|
||||||
|
* @param player The player.
|
||||||
|
*/
|
||||||
|
public void onAttack(@NotNull final EcoBoss boss,
|
||||||
|
@NotNull final LivingEntity entity,
|
||||||
|
@NotNull final Player player) {
|
||||||
|
// Override when needed.
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tick the effect.
|
||||||
|
*
|
||||||
|
* @param boss The boss.
|
||||||
|
* @param entity The boss entity.
|
||||||
|
* @param tick The current tick: counts up from zero.
|
||||||
|
*/
|
||||||
|
public void tick(@NotNull final EcoBoss boss,
|
||||||
|
@NotNull final LivingEntity entity,
|
||||||
|
final long tick) {
|
||||||
|
// Override when needed.
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* On boss death.
|
||||||
|
*
|
||||||
|
* @param boss The boss.
|
||||||
|
* @param entity The boss entity.
|
||||||
|
* @param tick The current tick: counts up from zero.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void onDeath(@NotNull final EcoBoss boss,
|
||||||
|
@NotNull final LivingEntity entity,
|
||||||
|
final long tick) {
|
||||||
|
// Override when needed.
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,11 @@
|
|||||||
package com.willfp.ecobosses.bosses.effects;
|
package com.willfp.ecobosses.bosses.effects;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
import com.willfp.ecobosses.bosses.effects.effects.DamageNearbyPlayers;
|
import com.willfp.ecobosses.bosses.effects.effects.EffectDamageNearbyPlayers;
|
||||||
import com.willfp.ecobosses.bosses.effects.effects.LightningNearbyEntities;
|
import com.willfp.ecobosses.bosses.effects.effects.EffectGivePotionEffect;
|
||||||
|
import com.willfp.ecobosses.bosses.effects.effects.EffectLightningNearbyEntities;
|
||||||
|
import com.willfp.ecobosses.bosses.effects.effects.EffectShuffleHotbar;
|
||||||
|
import com.willfp.ecobosses.bosses.effects.effects.EffectSummon;
|
||||||
import lombok.experimental.UtilityClass;
|
import lombok.experimental.UtilityClass;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
@@ -17,8 +20,11 @@ public class Effects {
|
|||||||
* Registered effects.
|
* Registered effects.
|
||||||
*/
|
*/
|
||||||
private static final Map<String, Function<List<String>, Effect>> EFFECTS = new ImmutableMap.Builder<String, Function<List<String>, Effect>>()
|
private static final Map<String, Function<List<String>, Effect>> EFFECTS = new ImmutableMap.Builder<String, Function<List<String>, Effect>>()
|
||||||
.put("damage-nearby-players", DamageNearbyPlayers::new)
|
.put("damage-nearby-players", EffectDamageNearbyPlayers::new)
|
||||||
.put("lightning-nearby-entities", LightningNearbyEntities::new)
|
.put("lightning-nearby-entities", EffectLightningNearbyEntities::new)
|
||||||
|
.put("summon", EffectSummon::new)
|
||||||
|
.put("give-potion-effect", EffectGivePotionEffect::new)
|
||||||
|
.put("shuffle-hotbar", EffectShuffleHotbar::new)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -9,12 +9,12 @@ import org.jetbrains.annotations.NotNull;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class DamageNearbyPlayers extends Effect {
|
public class EffectDamageNearbyPlayers extends Effect {
|
||||||
private final int frequency;
|
private final int frequency;
|
||||||
private final double damage;
|
private final double damage;
|
||||||
private final double radius;
|
private final double radius;
|
||||||
|
|
||||||
public DamageNearbyPlayers(@NotNull final List<String> args) {
|
public EffectDamageNearbyPlayers(@NotNull final List<String> args) {
|
||||||
super(args);
|
super(args);
|
||||||
|
|
||||||
if (args.size() < 3) {
|
if (args.size() < 3) {
|
||||||
@@ -0,0 +1,48 @@
|
|||||||
|
package com.willfp.ecobosses.bosses.effects.effects;
|
||||||
|
|
||||||
|
import com.willfp.eco.util.NumberUtils;
|
||||||
|
import com.willfp.ecobosses.bosses.EcoBoss;
|
||||||
|
import com.willfp.ecobosses.bosses.effects.Effect;
|
||||||
|
import org.bukkit.entity.LivingEntity;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.potion.PotionEffect;
|
||||||
|
import org.bukkit.potion.PotionEffectType;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class EffectGivePotionEffect extends Effect {
|
||||||
|
private final PotionEffectType type;
|
||||||
|
private final double chance;
|
||||||
|
private final int duration;
|
||||||
|
private final int strength;
|
||||||
|
|
||||||
|
public EffectGivePotionEffect(@NotNull final List<String> args) {
|
||||||
|
super(args);
|
||||||
|
|
||||||
|
if (args.size() < 4) {
|
||||||
|
showConfigError("Incorrect amount of arguments!");
|
||||||
|
}
|
||||||
|
|
||||||
|
type = PotionEffectType.getByName(args.get(0).toUpperCase());
|
||||||
|
chance = Double.parseDouble(args.get(1));
|
||||||
|
duration = Integer.parseInt(args.get(2));
|
||||||
|
strength = Integer.parseInt(args.get(3));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getUsage() {
|
||||||
|
return "give-potion-effect:<effect>:<chance>:<duration>:<strength>";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onAttack(@NotNull final EcoBoss boss,
|
||||||
|
@NotNull final LivingEntity entity,
|
||||||
|
@NotNull final Player player) {
|
||||||
|
if (NumberUtils.randFloat(0, 100) > this.chance) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
player.addPotionEffect(new PotionEffect(type, duration, strength - 1));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -10,13 +10,13 @@ import org.jetbrains.annotations.NotNull;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class LightningNearbyEntities extends Effect {
|
public class EffectLightningNearbyEntities extends Effect {
|
||||||
private final int frequency;
|
private final int frequency;
|
||||||
private final double chance;
|
private final double chance;
|
||||||
private final double damage;
|
private final double damage;
|
||||||
private final double radius;
|
private final double radius;
|
||||||
|
|
||||||
public LightningNearbyEntities(@NotNull final List<String> args) {
|
public EffectLightningNearbyEntities(@NotNull final List<String> args) {
|
||||||
super(args);
|
super(args);
|
||||||
|
|
||||||
if (args.size() < 4) {
|
if (args.size() < 4) {
|
||||||
@@ -0,0 +1,54 @@
|
|||||||
|
package com.willfp.ecobosses.bosses.effects.effects;
|
||||||
|
|
||||||
|
import com.willfp.eco.util.NumberUtils;
|
||||||
|
import com.willfp.ecobosses.bosses.EcoBoss;
|
||||||
|
import com.willfp.ecobosses.bosses.effects.Effect;
|
||||||
|
import org.bukkit.Sound;
|
||||||
|
import org.bukkit.entity.LivingEntity;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class EffectShuffleHotbar extends Effect {
|
||||||
|
private final double chance;
|
||||||
|
|
||||||
|
public EffectShuffleHotbar(@NotNull final List<String> args) {
|
||||||
|
super(args);
|
||||||
|
|
||||||
|
if (args.size() < 1) {
|
||||||
|
showConfigError("Incorrect amount of arguments!");
|
||||||
|
}
|
||||||
|
|
||||||
|
chance = Double.parseDouble(args.get(0));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getUsage() {
|
||||||
|
return "shuffle-hotbar:<effect>:<chance>:<duration>:<strength>";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onAttack(@NotNull final EcoBoss boss,
|
||||||
|
@NotNull final LivingEntity entity,
|
||||||
|
@NotNull final Player player) {
|
||||||
|
if (NumberUtils.randFloat(0, 100) > this.chance) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
List<ItemStack> hotbar = new ArrayList<>();
|
||||||
|
for (int i = 0; i < 9; i++) {
|
||||||
|
hotbar.add(player.getInventory().getItem(i));
|
||||||
|
}
|
||||||
|
Collections.shuffle(hotbar);
|
||||||
|
int i2 = 0;
|
||||||
|
for (ItemStack item : hotbar) {
|
||||||
|
player.getInventory().setItem(i2, item);
|
||||||
|
i2++;
|
||||||
|
}
|
||||||
|
player.playSound(player.getLocation(), Sound.ENTITY_ENDER_PEARL_THROW, 1, 0.5f);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,65 @@
|
|||||||
|
package com.willfp.ecobosses.bosses.effects.effects;
|
||||||
|
|
||||||
|
import com.willfp.eco.util.NumberUtils;
|
||||||
|
import com.willfp.ecobosses.bosses.EcoBoss;
|
||||||
|
import com.willfp.ecobosses.bosses.effects.Effect;
|
||||||
|
import com.willfp.ecobosses.bosses.util.bosstype.BossEntityUtils;
|
||||||
|
import com.willfp.ecobosses.bosses.util.bosstype.BossType;
|
||||||
|
import com.willfp.ecobosses.bosses.util.obj.OptionedSound;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.entity.Entity;
|
||||||
|
import org.bukkit.entity.LivingEntity;
|
||||||
|
import org.bukkit.entity.Mob;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class EffectSummon extends Effect {
|
||||||
|
private final BossType type;
|
||||||
|
private final double chance;
|
||||||
|
|
||||||
|
public EffectSummon(@NotNull final List<String> args) {
|
||||||
|
super(args);
|
||||||
|
|
||||||
|
if (args.size() < 2) {
|
||||||
|
showConfigError("Incorrect amount of arguments!");
|
||||||
|
}
|
||||||
|
|
||||||
|
type = BossEntityUtils.getBossType(args.get(0));
|
||||||
|
chance = Double.parseDouble(args.get(1));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getUsage() {
|
||||||
|
return "summon:<entity>:<chance>";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onAttack(@NotNull final EcoBoss boss,
|
||||||
|
@NotNull final LivingEntity entity,
|
||||||
|
@NotNull final Player player) {
|
||||||
|
if (NumberUtils.randFloat(0, 100) > this.chance) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Location loc = player.getLocation().add(NumberUtils.randInt(2, 6), 0, NumberUtils.randInt(2, 6));
|
||||||
|
for (int i = 0; i < 15; i++) {
|
||||||
|
if (loc.getBlock().getType() == Material.AIR) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
loc.add(0, 1, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
Entity summonedEntity = type.spawnBossEntity(loc);
|
||||||
|
if (summonedEntity instanceof Mob) {
|
||||||
|
((Mob) summonedEntity).setTarget(player);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (OptionedSound sound : boss.getSummonSounds()) {
|
||||||
|
player.getWorld().playSound(entity.getLocation(), sound.getSound(), sound.getVolume(), sound.getPitch());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,49 +0,0 @@
|
|||||||
package com.willfp.ecobosses.bosses.util.obj;
|
|
||||||
|
|
||||||
import lombok.Getter;
|
|
||||||
import org.bukkit.potion.PotionEffectType;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
|
|
||||||
public class EffectOption {
|
|
||||||
/**
|
|
||||||
* The chance of the effect being applied.
|
|
||||||
*/
|
|
||||||
@Getter
|
|
||||||
private final double chance;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The level of the effect.
|
|
||||||
*/
|
|
||||||
@Getter
|
|
||||||
private final int level;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The potion effect type.
|
|
||||||
*/
|
|
||||||
@Getter
|
|
||||||
private final PotionEffectType effectType;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The duration, in ticks.
|
|
||||||
*/
|
|
||||||
@Getter
|
|
||||||
private final int duration;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create a new effect option.
|
|
||||||
*
|
|
||||||
* @param chance The chance.
|
|
||||||
* @param level The level.
|
|
||||||
* @param duration The duration in ticks.
|
|
||||||
* @param effectType The effect.
|
|
||||||
*/
|
|
||||||
public EffectOption(final double chance,
|
|
||||||
final int level,
|
|
||||||
final int duration,
|
|
||||||
@NotNull final PotionEffectType effectType) {
|
|
||||||
this.chance = chance;
|
|
||||||
this.level = level;
|
|
||||||
this.effectType = effectType;
|
|
||||||
this.duration = duration;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,31 +0,0 @@
|
|||||||
package com.willfp.ecobosses.bosses.util.obj;
|
|
||||||
|
|
||||||
import com.willfp.ecobosses.bosses.util.bosstype.BossType;
|
|
||||||
import lombok.Getter;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
|
|
||||||
public class SummonsOption {
|
|
||||||
/**
|
|
||||||
* The chance of a mob being spawned.
|
|
||||||
*/
|
|
||||||
@Getter
|
|
||||||
private final double chance;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The type of entity to summon.
|
|
||||||
*/
|
|
||||||
@Getter
|
|
||||||
private final BossType type;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create a new summons option.
|
|
||||||
*
|
|
||||||
* @param chance The chance.
|
|
||||||
* @param type The entity type.
|
|
||||||
*/
|
|
||||||
public SummonsOption(final double chance,
|
|
||||||
@NotNull final BossType type) {
|
|
||||||
this.chance = chance;
|
|
||||||
this.type = type;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -54,7 +54,10 @@ broadcast:
|
|||||||
- "&f - %third%&f (%third_damage% Damage)"
|
- "&f - %third%&f (%third_damage% Damage)"
|
||||||
- ""
|
- ""
|
||||||
|
|
||||||
effects: []
|
effects:
|
||||||
|
- "summon:wolf:15"
|
||||||
|
- "give-potion-effect:wither:4:200:10"
|
||||||
|
- "give-potion-effect:hunger:10:600:10"
|
||||||
|
|
||||||
defence:
|
defence:
|
||||||
immunities:
|
immunities:
|
||||||
@@ -78,22 +81,6 @@ attacks:
|
|||||||
# Chance is rolled when boss attacks player
|
# Chance is rolled when boss attacks player
|
||||||
on-injure: true # If chance should be rolled when boss is attacked too
|
on-injure: true # If chance should be rolled when boss is attacked too
|
||||||
|
|
||||||
# Potion effects are formatted like this:
|
|
||||||
# effect:level:duration:chance
|
|
||||||
# Duration is in ticks, chance is as a percentage
|
|
||||||
potion-effects:
|
|
||||||
- "wither:4:200:10"
|
|
||||||
- "hunger:10:600:10"
|
|
||||||
|
|
||||||
# Bonus enemies that spawn to fight you
|
|
||||||
# entity:chance
|
|
||||||
# Chance is as a percentage
|
|
||||||
summons:
|
|
||||||
- "wolf:15"
|
|
||||||
|
|
||||||
# Chance to shuffle your hotbar as a percentage - set to 0 to disable.
|
|
||||||
shuffle-chance: 0
|
|
||||||
|
|
||||||
# How the boss decides who to attack
|
# How the boss decides who to attack
|
||||||
target:
|
target:
|
||||||
distance: 15 # The distance to check for nearby players.
|
distance: 15 # The distance to check for nearby players.
|
||||||
|
|||||||
@@ -54,7 +54,12 @@ broadcast:
|
|||||||
- "&f - &9%third%&f (%third_damage% Damage)"
|
- "&f - &9%third%&f (%third_damage% Damage)"
|
||||||
- ""
|
- ""
|
||||||
|
|
||||||
effects: [ ]
|
effects:
|
||||||
|
- "summon:evoker:10"
|
||||||
|
- "summon:vindicator:10"
|
||||||
|
- "shuffle-hotbar:10"
|
||||||
|
- "give-potion-effect:confusion:10:200:10"
|
||||||
|
- "give-potion-effect:blindness:1:40:20"
|
||||||
|
|
||||||
defence:
|
defence:
|
||||||
immunities:
|
immunities:
|
||||||
@@ -78,23 +83,6 @@ attacks:
|
|||||||
# Chance is rolled when boss attacks player
|
# Chance is rolled when boss attacks player
|
||||||
on-injure: true # If chance should be rolled when boss is attacked too
|
on-injure: true # If chance should be rolled when boss is attacked too
|
||||||
|
|
||||||
# Potion effects are formatted like this:
|
|
||||||
# effect:level:duration:chance
|
|
||||||
# Duration is in ticks, chance is as a percentage
|
|
||||||
potion-effects:
|
|
||||||
- "confusion:10:200:10"
|
|
||||||
- "blindness:1:40:20"
|
|
||||||
|
|
||||||
# Bonus enemies that spawn to fight you
|
|
||||||
# entity:chance
|
|
||||||
# Chance is as a percentage
|
|
||||||
summons:
|
|
||||||
- "evoker:10"
|
|
||||||
- "vindicator:10"
|
|
||||||
|
|
||||||
# Chance to shuffle your hotbar as a percentage - set to 0 to disable.
|
|
||||||
shuffle-chance: 10
|
|
||||||
|
|
||||||
# How the boss decides who to attack
|
# How the boss decides who to attack
|
||||||
target:
|
target:
|
||||||
distance: 15 # The distance to check for nearby players.
|
distance: 15 # The distance to check for nearby players.
|
||||||
|
|||||||
@@ -56,6 +56,12 @@ broadcast:
|
|||||||
|
|
||||||
effects:
|
effects:
|
||||||
- "damage-nearby-players:15:2:3"
|
- "damage-nearby-players:15:2:3"
|
||||||
|
- "summon:iron_golem:10"
|
||||||
|
- "summon:vindicator:5"
|
||||||
|
- "shuffle-hotbar:30"
|
||||||
|
- "give-potion-effect:weakness:5:100:10"
|
||||||
|
- "give-potion-effect:slow:5:100:20"
|
||||||
|
- "give-potion-effect:levitation:3:50:10"
|
||||||
|
|
||||||
defence:
|
defence:
|
||||||
immunities:
|
immunities:
|
||||||
@@ -79,24 +85,6 @@ attacks:
|
|||||||
# Chance is rolled when boss attacks player
|
# Chance is rolled when boss attacks player
|
||||||
on-injure: true # If chance should be rolled when boss is attacked too
|
on-injure: true # If chance should be rolled when boss is attacked too
|
||||||
|
|
||||||
# Potion effects are formatted like this:
|
|
||||||
# effect:level:duration:chance
|
|
||||||
# Duration is in ticks, chance is as a percentage
|
|
||||||
potion-effects:
|
|
||||||
- "weakness:5:100:10"
|
|
||||||
- "slow:5:100:20"
|
|
||||||
- "levitation:3:50:10"
|
|
||||||
|
|
||||||
# Bonus enemies that spawn to fight you
|
|
||||||
# entity:chance
|
|
||||||
# Chance is as a percentage
|
|
||||||
summons:
|
|
||||||
- "iron_golem:5"
|
|
||||||
- "vindicator:10"
|
|
||||||
|
|
||||||
# Chance to shuffle your hotbar as a percentage - set to 0 to disable.
|
|
||||||
shuffle-chance: 30
|
|
||||||
|
|
||||||
# How the boss decides who to attack
|
# How the boss decides who to attack
|
||||||
target:
|
target:
|
||||||
distance: 15 # The distance to check for nearby players.
|
distance: 15 # The distance to check for nearby players.
|
||||||
|
|||||||
@@ -56,6 +56,12 @@ broadcast:
|
|||||||
|
|
||||||
effects:
|
effects:
|
||||||
- "lightning-nearby-entities:100:15:2:3"
|
- "lightning-nearby-entities:100:15:2:3"
|
||||||
|
- "summon:spider:15"
|
||||||
|
- "summon:cave_spider:15"
|
||||||
|
- "give-potion-effect:poison:8:200:10"
|
||||||
|
- "give-potion-effect:slow:4:100:20"
|
||||||
|
- "give-potion-effect:hunger:5:400:10"
|
||||||
|
- "give-potion-effect:slow_digging:3:40:10"
|
||||||
|
|
||||||
defence:
|
defence:
|
||||||
immunities:
|
immunities:
|
||||||
@@ -79,25 +85,6 @@ attacks:
|
|||||||
# Chance is rolled when boss attacks player
|
# Chance is rolled when boss attacks player
|
||||||
on-injure: true # If chance should be rolled when boss is attacked too
|
on-injure: true # If chance should be rolled when boss is attacked too
|
||||||
|
|
||||||
# Potion effects are formatted like this:
|
|
||||||
# effect:level:duration:chance
|
|
||||||
# Duration is in ticks, chance is as a percentage
|
|
||||||
potion-effects:
|
|
||||||
- "poison:8:200:10"
|
|
||||||
- "slow:4:100:20"
|
|
||||||
- "hunger:5:400:10"
|
|
||||||
- "slow_digging:3:40:10"
|
|
||||||
|
|
||||||
# Bonus enemies that spawn to fight you
|
|
||||||
# entity:chance
|
|
||||||
# Chance is as a percentage
|
|
||||||
summons:
|
|
||||||
- "spider:15"
|
|
||||||
- "cave_spider:15"
|
|
||||||
|
|
||||||
# Chance to shuffle your hotbar as a percentage - set to 0 to disable.
|
|
||||||
shuffle-chance: 0
|
|
||||||
|
|
||||||
# How the boss decides who to attack
|
# How the boss decides who to attack
|
||||||
target:
|
target:
|
||||||
distance: 15 # The distance to check for nearby players.
|
distance: 15 # The distance to check for nearby players.
|
||||||
|
|||||||
Reference in New Issue
Block a user