9
0
mirror of https://github.com/Auxilor/EcoMobs.git synced 2025-12-21 16:09:24 +00:00

Began conversion into ecobosses

This commit is contained in:
Auxilor
2021-03-11 13:44:14 +00:00
parent bbd78d8e03
commit 6d8b7405f7
43 changed files with 613 additions and 1054 deletions

View File

@@ -1,17 +1,16 @@
package com.willfp.illusioner;
package com.willfp.ecobosses;
import com.willfp.eco.util.command.AbstractCommand;
import com.willfp.eco.util.display.DisplayModule;
import com.willfp.eco.util.integrations.IntegrationLoader;
import com.willfp.eco.util.plugin.AbstractEcoPlugin;
import com.willfp.eco.util.protocollib.AbstractPacketAdapter;
import com.willfp.illusioner.commands.CommandIldrop;
import com.willfp.illusioner.commands.CommandIlreload;
import com.willfp.illusioner.config.IllusionerConfigs;
import com.willfp.illusioner.illusioner.IllusionerManager;
import com.willfp.illusioner.illusioner.listeners.AttackListeners;
import com.willfp.illusioner.illusioner.listeners.DeathListeners;
import com.willfp.illusioner.illusioner.listeners.SpawnListeners;
import com.willfp.ecobosses.commands.CommandEbdrop;
import com.willfp.ecobosses.commands.CommandEbreload;
import com.willfp.ecobosses.config.EcoBossesConfigs;
import com.willfp.ecobosses.bosses.listeners.AttackListeners;
import com.willfp.ecobosses.bosses.listeners.DeathListeners;
import com.willfp.ecobosses.bosses.listeners.SpawnListeners;
import lombok.Getter;
import org.bukkit.event.Listener;
import org.jetbrains.annotations.Nullable;
@@ -21,18 +20,18 @@ import java.util.Arrays;
import java.util.List;
@SuppressWarnings("unused")
public class IllusionerPlugin extends AbstractEcoPlugin {
public class EcoBossesPlugin extends AbstractEcoPlugin {
/**
* Instance of the plugin.
*/
@Getter
private static IllusionerPlugin instance;
private static EcoBossesPlugin instance;
/**
* Internal constructor called by bukkit on plugin load.
*/
public IllusionerPlugin() {
super("Illusioner", 86576, 9596, "com.willfp.illusioner.proxy", "&9");
public EcoBossesPlugin() {
super("EcoBosses", 86576, 9596, "com.willfp.ecobosses.proxy", "&9");
instance = this;
}
@@ -94,8 +93,8 @@ public class IllusionerPlugin extends AbstractEcoPlugin {
@Override
public List<AbstractCommand> getCommands() {
return Arrays.asList(
new CommandIlreload(this),
new CommandIldrop(this)
new CommandEbreload(this),
new CommandEbdrop(this)
);
}
@@ -126,7 +125,7 @@ public class IllusionerPlugin extends AbstractEcoPlugin {
@Override
public List<Class<?>> getUpdatableClasses() {
return Arrays.asList(
IllusionerConfigs.class
EcoBossesConfigs.class
);
}

View File

@@ -0,0 +1,5 @@
package com.willfp.ecobosses.bosses;
public class EcoBoss {
}

View File

@@ -1,8 +1,7 @@
package com.willfp.illusioner.illusioner.listeners;
package com.willfp.ecobosses.bosses.listeners;
import com.willfp.eco.util.NumberUtils;
import com.willfp.illusioner.illusioner.IllusionerManager;
import com.willfp.illusioner.illusioner.OptionedSound;
import com.willfp.ecobosses.bosses.util.OptionedSound;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Sound;

View File

@@ -1,10 +1,8 @@
package com.willfp.illusioner.illusioner.listeners;
package com.willfp.ecobosses.bosses.listeners;
import com.willfp.eco.util.drops.DropQueue;
import com.willfp.eco.util.events.entitydeathbyentity.EntityDeathByEntityEvent;
import com.willfp.illusioner.illusioner.IllusionerManager;
import com.willfp.illusioner.illusioner.OptionedSound;
import com.willfp.ecobosses.bosses.util.OptionedSound;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.entity.Projectile;

View File

@@ -1,11 +1,9 @@
package com.willfp.illusioner.illusioner.listeners;
package com.willfp.ecobosses.bosses.listeners;
import com.willfp.eco.util.internal.PluginDependent;
import com.willfp.eco.util.plugin.AbstractEcoPlugin;
import com.willfp.illusioner.illusioner.BlockStructure;
import com.willfp.illusioner.illusioner.IllusionerManager;
import com.willfp.illusioner.proxy.proxies.EntityIllusionerProxy;
import com.willfp.illusioner.proxy.proxies.IllusionerHelperProxy;
import com.willfp.illusioner.util.ProxyUtils;
import com.willfp.ecobosses.bosses.util.SpawnTotem;
import com.willfp.ecobosses.proxy.proxies.CustomIllusionerProxy;
import com.willfp.ecobosses.util.ProxyUtils;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.entity.Illusioner;
@@ -56,7 +54,7 @@ public class SpawnListeners extends PluginDependent implements Listener {
block3 = event.getBlock().getRelative(0, 1, 0);
}
matches = BlockStructure.matches(new BlockStructure(block1.getType(), block2.getType(), block3.getType()));
matches = SpawnTotem.matches(new SpawnTotem(block1.getType(), block2.getType(), block3.getType()));
if (matches) {
match.add(block1);
match.add(block2);
@@ -78,7 +76,7 @@ public class SpawnListeners extends PluginDependent implements Listener {
}
});
EntityIllusionerProxy illusioner = ProxyUtils.getProxy(IllusionerHelperProxy.class).spawn(event.getBlock().getLocation());
CustomIllusionerProxy illusioner = ProxyUtils.getProxy(IllusionerHelperProxy.class).spawn(event.getBlock().getLocation());
illusioner.createBossbar(this.getPlugin());
}
@@ -99,7 +97,7 @@ public class SpawnListeners extends PluginDependent implements Listener {
Illusioner illusioner = (Illusioner) event.getEntity();
EntityIllusionerProxy internalIllusioner = ProxyUtils.getProxy(IllusionerHelperProxy.class).adapt(illusioner);
CustomIllusionerProxy internalIllusioner = ProxyUtils.getProxy(IllusionerHelperProxy.class).adapt(illusioner);
if (internalIllusioner == null) {
return;

View File

@@ -0,0 +1,157 @@
package com.willfp.ecobosses.bosses.options;
import com.willfp.eco.util.internal.PluginDependent;
import com.willfp.eco.util.plugin.AbstractEcoPlugin;
import com.willfp.ecobosses.bosses.util.EffectOption;
import com.willfp.ecobosses.bosses.util.OptionedSound;
import com.willfp.ecobosses.config.EcoBossesConfigs;
import lombok.Getter;
import lombok.ToString;
import org.bukkit.Sound;
import org.bukkit.entity.EntityType;
import org.bukkit.potion.PotionEffectType;
import org.jetbrains.annotations.NotNull;
import java.util.HashSet;
import java.util.Set;
@ToString
public class GameplayOptions extends PluginDependent {
/**
* The sound played when the illusioner takes damage.
*/
@Getter
private OptionedSound hitSound;
/**
* The sound played when the illusioner spawns.
*/
@Getter
private OptionedSound summonSound;
/**
* The potion effect options.
*/
@Getter
private final Set<EffectOption> effectOptions = new HashSet<>();
/**
* The mob summon options.
*/
@Getter
private final Set<SummonerOption> summonerOptions = new HashSet<>();
/**
* If the illusioner should shuffle hotbars.
*/
@Getter
private boolean shuffle;
/**
* The chance of the illusioner shuffling a hotbar.
*/
@Getter
private double shuffleChance;
/**
* If the illusioner is immune to explosion damage.
*/
@Getter
private boolean ignoreExplosionDamage;
/**
* If the illusioner is immune to fire damage.
*/
@Getter
private boolean ignoreFire;
/**
* If the illusioner is immune to suffocation damage.
*/
@Getter
private boolean ignoreSuffocation;
/**
* If the illusioner can teleport.
*/
@Getter
private boolean teleport;
/**
* Teleport range.
*/
@Getter
private int teleportRange;
/**
* Teleport chance.
*/
@Getter
private double teleportChance;
/**
* Teleport sound.
*/
@Getter
private OptionedSound teleportSound;
/**
* Gameplay options.
*
* @param plugin The plugin.
*/
public GameplayOptions(@NotNull final AbstractEcoPlugin plugin) {
super(plugin);
}
/**
* Reload the options.
*/
public void reload() {
hitSound = new OptionedSound(
Sound.valueOf(EcoBossesConfigs.SOUNDS.getString("hit.sound")),
(float) EcoBossesConfigs.SOUNDS.getDouble("hit.volume"),
(float) EcoBossesConfigs.SOUNDS.getDouble("hit.pitch"),
EcoBossesConfigs.SOUNDS.getBool("hit.broadcast")
);
summonSound = new OptionedSound(
Sound.valueOf(EcoBossesConfigs.SOUNDS.getString("summon.sound")),
(float) EcoBossesConfigs.SOUNDS.getDouble("summon.volume"),
(float) EcoBossesConfigs.SOUNDS.getDouble("summon.pitch"),
EcoBossesConfigs.SOUNDS.getBool("summon.broadcast")
);
shuffle = EcoBossesConfigs.ATTACKS.getBool("shuffle.enabled");
shuffleChance = EcoBossesConfigs.ATTACKS.getDouble("shuffle.chance");
ignoreExplosionDamage = this.getPlugin().getConfigYml().getBool("ignore-explosion-damage");
ignoreFire = this.getPlugin().getConfigYml().getBool("ignore-fire-damage");
ignoreSuffocation = this.getPlugin().getConfigYml().getBool("ignore-suffocation-damage");
teleport = this.getPlugin().getConfigYml().getBool("teleport-on-damage.enabled");
teleportRange = this.getPlugin().getConfigYml().getInt("teleport-on-damage.range");
teleportChance = this.getPlugin().getConfigYml().getDouble("teleport-on-damage.chance");
Sound sound = Sound.valueOf(EcoBossesConfigs.SOUNDS.getString("teleport.sound"));
float volume = (float) EcoBossesConfigs.SOUNDS.getDouble("teleport.volume");
float pitch = (float) EcoBossesConfigs.SOUNDS.getDouble("teleport.pitch");
teleportSound = new OptionedSound(sound, volume, pitch, true);
effectOptions.clear();
EcoBossesConfigs.ATTACKS.getConfig().getConfigurationSection("effects").getKeys(false).forEach(key -> {
PotionEffectType type = PotionEffectType.getByName(EcoBossesConfigs.ATTACKS.getString("effects." + key + ".type"));
int level = EcoBossesConfigs.ATTACKS.getInt("effects." + key + ".level");
int duration = EcoBossesConfigs.ATTACKS.getInt("effects." + key + ".duration");
double chance = EcoBossesConfigs.ATTACKS.getDouble("effects." + key + ".chance");
effectOptions.add(new EffectOption(chance, level, duration, type));
});
summonerOptions.clear();
EcoBossesConfigs.ATTACKS.getConfig().getConfigurationSection("summons").getKeys(false).forEach(key -> {
EntityType type = EntityType.valueOf(EcoBossesConfigs.ATTACKS.getString("summons." + key + ".type"));
double chance = EcoBossesConfigs.ATTACKS.getDouble("summons." + key + ".chance");
summonerOptions.add(new SummonerOption(chance, type));
});
}
}

View File

@@ -1,12 +1,12 @@
package com.willfp.illusioner.illusioner.options;
package com.willfp.ecobosses.bosses.options;
import com.willfp.eco.util.NumberUtils;
import com.willfp.eco.util.internal.PluginDependent;
import com.willfp.eco.util.plugin.AbstractEcoPlugin;
import com.willfp.eco.util.tuples.Pair;
import com.willfp.illusioner.config.IllusionerConfigs;
import com.willfp.illusioner.illusioner.BlockStructure;
import com.willfp.illusioner.illusioner.OptionedSound;
import com.willfp.ecobosses.config.EcoBossesConfigs;
import com.willfp.ecobosses.bosses.util.SpawnTotem;
import com.willfp.ecobosses.bosses.util.OptionedSound;
import lombok.Getter;
import lombok.ToString;
import org.bukkit.Material;
@@ -62,7 +62,7 @@ public class IllusionerOptions extends PluginDependent {
* The spawn block structure.
*/
@Getter
private BlockStructure spawnStructure;
private SpawnTotem spawnStructure;
/**
* The max health.
@@ -117,24 +117,24 @@ public class IllusionerOptions extends PluginDependent {
override = this.getPlugin().getConfigYml().getBool("override");
spawnSounds = new HashSet<>();
IllusionerConfigs.SOUNDS.getConfig().getConfigurationSection("spawn").getKeys(false).forEach(key -> {
Sound sound = Sound.valueOf(IllusionerConfigs.SOUNDS.getString("spawn." + key + ".sound"));
boolean broadcast = IllusionerConfigs.SOUNDS.getBool("spawn." + key + ".broadcast");
float volume = (float) IllusionerConfigs.SOUNDS.getDouble("spawn." + key + ".volume");
float pitch = (float) IllusionerConfigs.SOUNDS.getDouble("spawn." + key + ".pitch");
EcoBossesConfigs.SOUNDS.getConfig().getConfigurationSection("spawn").getKeys(false).forEach(key -> {
Sound sound = Sound.valueOf(EcoBossesConfigs.SOUNDS.getString("spawn." + key + ".sound"));
boolean broadcast = EcoBossesConfigs.SOUNDS.getBool("spawn." + key + ".broadcast");
float volume = (float) EcoBossesConfigs.SOUNDS.getDouble("spawn." + key + ".volume");
float pitch = (float) EcoBossesConfigs.SOUNDS.getDouble("spawn." + key + ".pitch");
spawnSounds.add(new OptionedSound(sound, volume, pitch, broadcast));
});
deathSounds = new HashSet<>();
IllusionerConfigs.SOUNDS.getConfig().getConfigurationSection("death").getKeys(false).forEach(key -> {
Sound sound = Sound.valueOf(IllusionerConfigs.SOUNDS.getString("death." + key + ".sound"));
boolean broadcast = IllusionerConfigs.SOUNDS.getBool("death." + key + ".broadcast");
float volume = (float) IllusionerConfigs.SOUNDS.getDouble("death." + key + ".volume");
float pitch = (float) IllusionerConfigs.SOUNDS.getDouble("death." + key + ".pitch");
EcoBossesConfigs.SOUNDS.getConfig().getConfigurationSection("death").getKeys(false).forEach(key -> {
Sound sound = Sound.valueOf(EcoBossesConfigs.SOUNDS.getString("death." + key + ".sound"));
boolean broadcast = EcoBossesConfigs.SOUNDS.getBool("death." + key + ".broadcast");
float volume = (float) EcoBossesConfigs.SOUNDS.getDouble("death." + key + ".volume");
float pitch = (float) EcoBossesConfigs.SOUNDS.getDouble("death." + key + ".pitch");
deathSounds.add(new OptionedSound(sound, volume, pitch, broadcast));
});
spawnStructure = new BlockStructure(
spawnStructure = new SpawnTotem(
Material.valueOf(this.getPlugin().getConfigYml().getString("spawn.bottom-block")),
Material.valueOf(this.getPlugin().getConfigYml().getString("spawn.middle-block")),
Material.valueOf(this.getPlugin().getConfigYml().getString("spawn.top-block"))
@@ -143,8 +143,8 @@ public class IllusionerOptions extends PluginDependent {
gameplayOptions.reload();
drops = new ArrayList<>();
for (String key : IllusionerConfigs.DROPS.getConfig().getKeys(false)) {
ItemStack itemStack = IllusionerConfigs.DROPS.getConfig().getItemStack(key);
for (String key : EcoBossesConfigs.DROPS.getConfig().getKeys(false)) {
ItemStack itemStack = EcoBossesConfigs.DROPS.getConfig().getItemStack(key);
if (itemStack == null || itemStack.getType() == Material.AIR) {
continue;
}

View File

@@ -0,0 +1,48 @@
package com.willfp.ecobosses.bosses.util;
import lombok.experimental.UtilityClass;
import org.bukkit.Bukkit;
import org.bukkit.attribute.Attribute;
import org.bukkit.boss.BarFlag;
import org.bukkit.boss.BossBar;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
@UtilityClass
public class BossbarUtils {
public BossBar createBossBar(@NotNull final LivingEntity entity) {
if (bossBar != null) {
return bossBar;
}
BossBar bossBar = Bukkit.getServer().createBossBar(this.displayName, IllusionerManager.OPTIONS.getColor(), IllusionerManager.OPTIONS.getStyle(), (BarFlag) null);
this.bossBar = bossBar;
LivingEntity entity = (LivingEntity) this.getBukkitEntity();
plugin.getRunnableFactory().create(runnable -> {
if (!entity.isDead()) {
bossBar.getPlayers().forEach(bossBar::removePlayer);
entity.getNearbyEntities(50, 50, 50).forEach(entity1 -> {
if (entity1 instanceof Player) {
bossBar.addPlayer((Player) entity1);
}
});
} else {
runnable.cancel();
}
}).runTaskTimer(0, 40);
plugin.getRunnableFactory().create(runnable -> {
if (!entity.isDead()) {
bossBar.setProgress(entity.getHealth() / entity.getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue());
} else {
bossBar.getPlayers().forEach(bossBar::removePlayer);
bossBar.setVisible(false);
runnable.cancel();
}
}).runTaskTimer(0, 1);
return bossBar;
}
}

View File

@@ -0,0 +1,49 @@
package com.willfp.ecobosses.bosses.util;
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;
}
}

View File

@@ -1,4 +1,4 @@
package com.willfp.illusioner.illusioner;
package com.willfp.ecobosses.bosses.util;
import lombok.Getter;
import org.bukkit.Sound;
@@ -23,27 +23,18 @@ public class OptionedSound {
@Getter
private final float pitch;
/**
* If the sound should be played to the whole server.
*/
@Getter
private final boolean broadcast;
/**
* Create a new optioned sound.
*
* @param sound The sound.
* @param volume The volume.
* @param pitch The pitch, from 0.5 to 2.
* @param broadcast If the sound should be played to the whole server.
*/
public OptionedSound(@NotNull final Sound sound,
final float volume,
final float pitch,
final boolean broadcast) {
final float pitch) {
this.sound = sound;
this.volume = volume;
this.pitch = pitch;
this.broadcast = broadcast;
}
}

View File

@@ -0,0 +1,59 @@
package com.willfp.ecobosses.bosses.util;
import lombok.Getter;
import org.bukkit.Material;
import org.jetbrains.annotations.NotNull;
import java.util.Objects;
public class SpawnTotem {
/**
* The bottom block.
*/
@Getter
private final Material bottom;
/**
* The middle block.
*/
@Getter
private final Material middle;
/**
* The top block.
*/
@Getter
private final Material top;
/**
* Create a new spawn totem.
*
* @param bottom The bottom block.
* @param middle The middle block.
* @param top The top block.
*/
public SpawnTotem(@NotNull final Material bottom,
@NotNull final Material middle,
@NotNull final Material top) {
this.bottom = bottom;
this.middle = middle;
this.top = top;
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (!(o instanceof SpawnTotem)) {
return false;
}
SpawnTotem that = (SpawnTotem) o;
return getBottom() == that.getBottom() && getMiddle() == that.getMiddle() && getTop() == that.getTop();
}
@Override
public int hashCode() {
return Objects.hash(getBottom(), getMiddle(), getTop());
}
}

View File

@@ -0,0 +1,31 @@
package com.willfp.ecobosses.bosses.util;
import lombok.Getter;
import org.bukkit.entity.EntityType;
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 EntityType type;
/**
* Create a new summons option.
*
* @param chance The chance.
* @param type The entity type.
*/
public SummonsOption(final double chance,
@NotNull final EntityType type) {
this.chance = chance;
this.type = type;
}
}

View File

@@ -0,0 +1,30 @@
package com.willfp.ecobosses.commands;
import com.willfp.eco.util.command.AbstractCommand;
import com.willfp.ecobosses.EcoBossesPlugin;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull;
import java.util.List;
public class CommandEbdrop extends AbstractCommand {
/**
* Instantiate a new executor for /ebdrop.
*
* @param plugin The plugin to manage the execution for.
*/
public CommandEbdrop(@NotNull final EcoBossesPlugin plugin) {
super(plugin, "ebdrop", "ecobosses.ebdrop", true);
}
@Override
public void onExecute(@NotNull final CommandSender sender,
@NotNull final List<String> args) {
Player player = (Player) sender;
ItemStack itemStack = player.getInventory().getItemInMainHand();
player.sendMessage(this.getPlugin().getLangYml().getMessage("sent-drop"));
}
}

View File

@@ -1,26 +1,27 @@
package com.willfp.illusioner.commands;
package com.willfp.ecobosses.commands;
import com.willfp.eco.util.command.AbstractCommand;
import com.willfp.illusioner.IllusionerPlugin;
import com.willfp.ecobosses.EcoBossesPlugin;
import org.bukkit.command.CommandSender;
import org.jetbrains.annotations.NotNull;
import java.util.List;
public class CommandIlreload extends AbstractCommand {
public class CommandEbreload extends AbstractCommand {
/**
* Instantiate a new executor for /ilreload.
* Instantiate a new executor for /ebreload.
*
* @param plugin The plugin to manage the execution for.
*/
public CommandIlreload(@NotNull final IllusionerPlugin plugin) {
super(plugin, "ilreload", "illusioner.reload", false);
public CommandEbreload(@NotNull final EcoBossesPlugin plugin) {
super(plugin, "ebreload", "ecobosses.reload", false);
}
@Override
public void onExecute(@NotNull final CommandSender sender,
@NotNull final List<String> args) {
this.getPlugin().reload();
this.getPlugin().reload();
sender.sendMessage(this.getPlugin().getLangYml().getMessage("reloaded"));
}
}

View File

@@ -0,0 +1,15 @@
package com.willfp.ecobosses.config;
import com.willfp.eco.util.config.updating.annotations.ConfigUpdater;
import lombok.experimental.UtilityClass;
@UtilityClass
public class EcoBossesConfigs {
/**
* Update all configs.
*/
@ConfigUpdater
public void updateConfigs() {
}
}

View File

@@ -1,8 +1,8 @@
package com.willfp.illusioner.util;
package com.willfp.ecobosses.util;
import com.willfp.eco.util.proxy.AbstractProxy;
import com.willfp.illusioner.IllusionerPlugin;
import com.willfp.illusioner.proxy.util.ProxyFactory;
import com.willfp.ecobosses.EcoBossesPlugin;
import com.willfp.ecobosses.proxy.util.ProxyFactory;
import lombok.experimental.UtilityClass;
import org.jetbrains.annotations.NotNull;
@@ -16,6 +16,6 @@ public class ProxyUtils {
* @return The proxy implementation.
*/
public @NotNull <T extends AbstractProxy> T getProxy(@NotNull final Class<T> proxyClass) {
return new ProxyFactory<>(IllusionerPlugin.getInstance(), proxyClass).getProxy();
return new ProxyFactory<>(EcoBossesPlugin.getInstance(), proxyClass).getProxy();
}
}

View File

@@ -1,42 +0,0 @@
package com.willfp.illusioner.commands;
import com.willfp.eco.util.NumberUtils;
import com.willfp.eco.util.command.AbstractCommand;
import com.willfp.illusioner.IllusionerPlugin;
import com.willfp.illusioner.config.IllusionerConfigs;
import org.bukkit.Material;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull;
import java.util.List;
public class CommandIldrop extends AbstractCommand {
/**
* Instantiate a new executor for /ildrop.
*
* @param plugin The plugin to manage the execution for.
*/
public CommandIldrop(@NotNull final IllusionerPlugin plugin) {
super(plugin, "ildrop", "illusioner.drop", true);
}
@Override
public void onExecute(@NotNull final CommandSender sender,
@NotNull final List<String> args) {
Player player = (Player) sender;
ItemStack itemStack = player.getInventory().getItemInMainHand();
if (itemStack.getType() == Material.AIR) {
player.sendMessage(this.getPlugin().getLangYml().getMessage("no-item-held"));
return;
}
IllusionerConfigs.DROPS.getConfig().set(String.valueOf(NumberUtils.randInt(0, 100000)), itemStack);
IllusionerConfigs.DROPS.save();
IllusionerConfigs.DROPS.clearCache();
player.sendMessage(this.getPlugin().getLangYml().getMessage("added-drop"));
this.getPlugin().reload();
}
}

View File

@@ -1,35 +0,0 @@
package com.willfp.illusioner.config;
import com.willfp.eco.util.config.updating.annotations.ConfigUpdater;
import com.willfp.illusioner.config.configs.Attacks;
import com.willfp.illusioner.config.configs.Drops;
import com.willfp.illusioner.config.configs.Sounds;
import lombok.experimental.UtilityClass;
@UtilityClass
public class IllusionerConfigs {
/**
* drops.yml.
*/
public static final Drops DROPS = new Drops();
/**
* sounds.yml.
*/
public static final Sounds SOUNDS = new Sounds();
/**
* attacks.yml.
*/
public static final Attacks ATTACKS = new Attacks();
/**
* Update all configs.
*/
@ConfigUpdater
public void updateConfigs() {
DROPS.save();
SOUNDS.update();
ATTACKS.update();
}
}

View File

@@ -1,13 +0,0 @@
package com.willfp.illusioner.config.configs;
import com.willfp.eco.util.config.BaseConfig;
import com.willfp.illusioner.IllusionerPlugin;
public class Attacks extends BaseConfig {
/**
* Instantiate attacks.yml.
*/
public Attacks() {
super("attacks", false, IllusionerPlugin.getInstance(), "effects.", "summons.");
}
}

View File

@@ -1,26 +0,0 @@
package com.willfp.illusioner.config.configs;
import com.willfp.eco.util.config.BaseConfig;
import com.willfp.illusioner.IllusionerPlugin;
import java.io.IOException;
public class Drops extends BaseConfig {
/**
* Instantiate drops.yml.
*/
public Drops() {
super("drops", false, IllusionerPlugin.getInstance());
}
/**
* Save config to drops.yml.
*/
public void save() {
try {
this.getConfig().save(this.getConfigFile());
} catch (IOException e) {
e.printStackTrace();
}
}
}

View File

@@ -1,13 +0,0 @@
package com.willfp.illusioner.config.configs;
import com.willfp.eco.util.config.BaseConfig;
import com.willfp.illusioner.IllusionerPlugin;
public class Sounds extends BaseConfig {
/**
* Instantiate sounds.yml.
*/
public Sounds() {
super("sounds", false, IllusionerPlugin.getInstance());
}
}

View File

@@ -1,52 +0,0 @@
package com.willfp.illusioner.illusioner;
import lombok.Getter;
import org.bukkit.Material;
import org.jetbrains.annotations.NotNull;
public class BlockStructure {
/**
* The bottom block.
*/
@Getter
private final Material bottom;
/**
* The middle block.
*/
@Getter
private final Material middle;
/**
* The top block.
*/
@Getter
private final Material top;
/**
* Create a new block structure.
*
* @param bottom The bottom block.
* @param middle The middle block.
* @param top The top block.
*/
public BlockStructure(@NotNull final Material bottom,
@NotNull final Material middle,
@NotNull final Material top) {
this.bottom = bottom;
this.middle = middle;
this.top = top;
}
/**
* If a block structure matches the specified structure in illusioner options.
*
* @param structure The block structure to test against.
* @return If the structures match.
*/
public static boolean matches(@NotNull final BlockStructure structure) {
return structure.getBottom().equals(IllusionerManager.OPTIONS.getSpawnStructure().getBottom())
&& structure.getMiddle().equals(IllusionerManager.OPTIONS.getSpawnStructure().getMiddle())
&& structure.getTop().equals(IllusionerManager.OPTIONS.getSpawnStructure().getTop());
}
}

View File

@@ -1,11 +0,0 @@
package com.willfp.illusioner.illusioner;
import com.willfp.illusioner.IllusionerPlugin;
import com.willfp.illusioner.illusioner.options.IllusionerOptions;
public class IllusionerManager {
/**
* The options related to the illusioner.
*/
public static final IllusionerOptions OPTIONS = new IllusionerOptions(IllusionerPlugin.getInstance());
}

View File

@@ -1,226 +0,0 @@
package com.willfp.illusioner.illusioner.options;
import com.willfp.eco.util.internal.PluginDependent;
import com.willfp.eco.util.plugin.AbstractEcoPlugin;
import com.willfp.illusioner.config.IllusionerConfigs;
import com.willfp.illusioner.illusioner.OptionedSound;
import lombok.Getter;
import lombok.ToString;
import org.bukkit.Sound;
import org.bukkit.entity.EntityType;
import org.bukkit.potion.PotionEffectType;
import org.jetbrains.annotations.NotNull;
import java.util.HashSet;
import java.util.Set;
@ToString
public class GameplayOptions extends PluginDependent {
/**
* The sound played when the illusioner takes damage.
*/
@Getter
private OptionedSound hitSound;
/**
* The sound played when the illusioner spawns.
*/
@Getter
private OptionedSound summonSound;
/**
* The potion effect options.
*/
@Getter
private final Set<EffectOption> effectOptions = new HashSet<>();
/**
* The mob summon options.
*/
@Getter
private final Set<SummonerOption> summonerOptions = new HashSet<>();
/**
* If the illusioner should shuffle hotbars.
*/
@Getter
private boolean shuffle;
/**
* The chance of the illusioner shuffling a hotbar.
*/
@Getter
private double shuffleChance;
/**
* If the illusioner is immune to explosion damage.
*/
@Getter
private boolean ignoreExplosionDamage;
/**
* If the illusioner is immune to fire damage.
*/
@Getter
private boolean ignoreFire;
/**
* If the illusioner is immune to suffocation damage.
*/
@Getter
private boolean ignoreSuffocation;
/**
* If the illusioner can teleport.
*/
@Getter
private boolean teleport;
/**
* Teleport range.
*/
@Getter
private int teleportRange;
/**
* Teleport chance.
*/
@Getter
private double teleportChance;
/**
* Teleport sound.
*/
@Getter
private OptionedSound teleportSound;
/**
* Gameplay options.
*
* @param plugin The plugin.
*/
public GameplayOptions(@NotNull final AbstractEcoPlugin plugin) {
super(plugin);
}
/**
* Reload the options.
*/
public void reload() {
hitSound = new OptionedSound(
Sound.valueOf(IllusionerConfigs.SOUNDS.getString("hit.sound")),
(float) IllusionerConfigs.SOUNDS.getDouble("hit.volume"),
(float) IllusionerConfigs.SOUNDS.getDouble("hit.pitch"),
IllusionerConfigs.SOUNDS.getBool("hit.broadcast")
);
summonSound = new OptionedSound(
Sound.valueOf(IllusionerConfigs.SOUNDS.getString("summon.sound")),
(float) IllusionerConfigs.SOUNDS.getDouble("summon.volume"),
(float) IllusionerConfigs.SOUNDS.getDouble("summon.pitch"),
IllusionerConfigs.SOUNDS.getBool("summon.broadcast")
);
shuffle = IllusionerConfigs.ATTACKS.getBool("shuffle.enabled");
shuffleChance = IllusionerConfigs.ATTACKS.getDouble("shuffle.chance");
ignoreExplosionDamage = this.getPlugin().getConfigYml().getBool("ignore-explosion-damage");
ignoreFire = this.getPlugin().getConfigYml().getBool("ignore-fire-damage");
ignoreSuffocation = this.getPlugin().getConfigYml().getBool("ignore-suffocation-damage");
teleport = this.getPlugin().getConfigYml().getBool("teleport-on-damage.enabled");
teleportRange = this.getPlugin().getConfigYml().getInt("teleport-on-damage.range");
teleportChance = this.getPlugin().getConfigYml().getDouble("teleport-on-damage.chance");
Sound sound = Sound.valueOf(IllusionerConfigs.SOUNDS.getString("teleport.sound"));
float volume = (float) IllusionerConfigs.SOUNDS.getDouble("teleport.volume");
float pitch = (float) IllusionerConfigs.SOUNDS.getDouble("teleport.pitch");
teleportSound = new OptionedSound(sound, volume, pitch, true);
effectOptions.clear();
IllusionerConfigs.ATTACKS.getConfig().getConfigurationSection("effects").getKeys(false).forEach(key -> {
PotionEffectType type = PotionEffectType.getByName(IllusionerConfigs.ATTACKS.getString("effects." + key + ".type"));
int level = IllusionerConfigs.ATTACKS.getInt("effects." + key + ".level");
int duration = IllusionerConfigs.ATTACKS.getInt("effects." + key + ".duration");
double chance = IllusionerConfigs.ATTACKS.getDouble("effects." + key + ".chance");
effectOptions.add(new EffectOption(chance, level, duration, type));
});
summonerOptions.clear();
IllusionerConfigs.ATTACKS.getConfig().getConfigurationSection("summons").getKeys(false).forEach(key -> {
EntityType type = EntityType.valueOf(IllusionerConfigs.ATTACKS.getString("summons." + key + ".type"));
double chance = IllusionerConfigs.ATTACKS.getDouble("summons." + key + ".chance");
summonerOptions.add(new SummonerOption(chance, type));
});
}
public static 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;
}
}
public static class SummonerOption {
/**
* The chance of a mob being spawned.
*/
@Getter
private final double chance;
/**
* The type of entity to summon.
*/
@Getter
private final EntityType type;
/**
* Create a new summoner option.
*
* @param chance The chance.
* @param type The entity type.
*/
public SummonerOption(final double chance,
@NotNull final EntityType type) {
this.chance = chance;
this.type = type;
}
}
}

View File

@@ -1,34 +0,0 @@
# All chances are percentages and can include decimals
shuffle: # Shuffles the items around in your hotbar
enabled: true
chance: 5
effects:
# Types can be found here: https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/potion/PotionEffectType.html
# Duration is in ticks, there are 20 ticks in a second
1:
type: BLINDNESS
level: 1
duration: 40
chance: 20
2:
type: CONFUSION
level: 10
duration: 200
chance: 10
3:
type: SLOW
level: 3
duration: 60
chance: 10
summons:
# Entity Types can be found here: https://hub.spigotmc.org/javadocs/spigot/org/bukkit/entity/EntityType.html
# Entities are summoned close to the player
1:
type: VINDICATOR
chance: 10
2:
type: EVOKER
chance: 10

View File

@@ -0,0 +1,85 @@
enabled: true
name: "Illusioner" # Display name
base-mob: custom_illusioner # Any existing mob - custom_illusioner is also accepted (like in the old Illusioner plugin)
spawn-egg:
mob-type: illusioner
display-name: "Illusioner Spawn Egg"
lore: []
bossbar:
enabled: true
color: BLUE # Choose from: BLUE, GREEN, PINK, PURPLE, RED, WHITE, YELLOW
style: SOLID # Choose from: SOLID, SEGMENTED_6, SEGMENTED_10, SEGMENTED_12, SEGMENTED_20
max-health: 600
attack-damage: 50
spawn-totem:
enabled: true
top: carved_pumpkin
middle: beacon
bottom: diamond
rewards:
xp:
minimum: 20000
maximum: 25000
drops:
# Get items to add here by copying the console output for /ebdrop
defence:
immunities:
explosion: true
fire: false
drowning: true
projectiles: false
suffocation: true
# If the boss should teleport when damaged
teleport:
enabled: false
range: 7
chance: 15 # As a percentage
attacks:
# 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
sounds:
# Sounds are formatted like this:
# sound:volume:pitch
# Sound is the sound ID
# Volume is the distance that it can be heard from
# Pitch is 0.5-2
spawn: # On spawn
- "entity_illusioner_mirror_move:1000:0.5"
- "entity_wither_spawn:1000L:2"
death: # On death
- "entity_evoker_prepare_wololo:50:0.8"
- "entity_illusioner_prepare_blindness:50:1"
- "entity_wither_death:50:2"
summon: # On summon enemy
- "entity_evoker_prepare_attack:1:2"
injure: # On take damage
- "entity_illusioner_cast_spell:1:2"

View File

@@ -1,36 +1,4 @@
#
# Illusioner
# EcoBosses
# by Auxilor
#
name: "Illusioner" # What should the display name of the Illusioner be?
override: true # Should the illusioner override all "vanilla" illusioners (adds support for /spawn but may cause issues with other custom mob plugins)
bossbar:
color: BLUE # Choose from: BLUE, GREEN, PINK, PURPLE, RED, WHITE, YELLOW
style: SOLID # Choose from: SOLID, SEGMENTED_6, SEGMENTED_10, SEGMENTED_12, SEGMENTED_20
xp:
# Chosen at random between a minimum and maximum
minimum: 20000 # Xp points, not levels
maximum: 25000
max-health: 600 # Hearts is this number divided by 2, eg 600 is 300 hearts
attack-damage: 50 # This isn't an easy boss. Recommend to keep this high
ignore-explosion-damage: true
ignore-fire-damage: false
ignore-suffocation-damage: true
teleport-on-damage:
enabled: true
range: 7
chance: 15 # As a percentage
spawn:
# Configure a 3x1 tall column of blocks to summon an illusioner
# Plan to add support for other shapes in the future
top-block: CARVED_PUMPKIN
middle-block: BEACON
bottom-block: DIAMOND_BLOCK
#

View File

@@ -1 +0,0 @@
# Add drops with /ildrop

View File

@@ -1,8 +1,6 @@
messages:
prefix: "&9&lIllusioner &f» "
prefix: "&9&lEcoBosses &f» "
no-permission: "&cYou don't have permission to do this!"
not-player: "&cThis command must be run by a player"
reloaded: "Reloaded!"
no-item-held: "&cYou aren't holding an item!"
added-drop: "Added drop to Illusioner"
reload-plugin: "Run /ilreload to reload illusioner!"
sent-drop: "Check console for the drop!"

View File

@@ -1,30 +1,31 @@
name: Illusioner
name: EcoBosses
version: ${projectVersion}
main: com.willfp.illusioner.IllusionerPlugin
main: com.willfp.ecobosses.EcoBossesPlugin
api-version: 1.15
authors: [Auxilor]
website: willfp.com
load: STARTUP
commands:
ilreload:
ebreload:
description: Reloads config
permission: illusioner.reload
ildrop:
description: Adds the item in your hand as a drop
permission: illusioner.drop
permission: ecobosses.reload
ebdrop:
description: Sends the held item to console to be added as a drop
permission: ecobosses.ebdrop
permissions:
illusioner.*:
description: All illusioner permissions
ecobosses.*:
description: All ecobosses permissions
default: op
children:
illusioner.reload: true
illusioner.updateannounce: true
ecobosses.reload: true
ecobosses.ebdrop: true
illusioner.updateannounce:
description: Informs admins of a new update
default: op
illusioner.reload:
ecobosses.reload:
description: Allows reloading the config
default: op
ecobosses.ebdrop:
description: Allows the use of /ebdrop
default: op

View File

@@ -1,53 +0,0 @@
# A sound is defined as follows:
# broadcast - Should the whole server hear this or just the player?
# volume - How far away should people be able to hear this?
# pitch - Range is 0.5 to 2, 0.5 is lower pitch and half speed, 2 is higher pitch and double speed
# Add as many sounds as you want
hit:
# When the player attacks the illusioner
broadcast: false
sound: ENTITY_ILLUSIONER_CAST_SPELL
volume: 1
pitch: 2
summon:
# When an entity is summoned by the illusioner
broadcast: false
sound: ENTITY_EVOKER_PREPARE_ATTACK
volume: 1
pitch: 2
teleport:
# When the illusioner teleports
sound: ENTITY_ENDERMAN_TELEPORT
volume: 1
pitch: 0.7
spawn:
1:
broadcast: true
sound: ENTITY_ILLUSIONER_MIRROR_MOVE
volume: 1000
pitch: 0.5
2:
broadcast: true
sound: ENTITY_WITHER_SPAWN
volume: 1000
pitch: 2
death:
1:
broadcast: true
sound: ENTITY_EVOKER_PREPARE_WOLOLO
volume: 50
pitch: 0.8
2:
broadcast: true
sound: ENTITY_ILLUSIONER_PREPARE_BLINDNESS
volume: 50
pitch: 1
3:
broadcast: true
sound: ENTITY_WITHER_DEATH
volume: 50
pitch: 2