diff --git a/eco-core/core-plugin/src/main/java/com/willfp/illusioner/config/configs/Attacks.java b/eco-core/core-plugin/src/main/java/com/willfp/illusioner/config/configs/Attacks.java index 748d69d..9ee2033 100644 --- a/eco-core/core-plugin/src/main/java/com/willfp/illusioner/config/configs/Attacks.java +++ b/eco-core/core-plugin/src/main/java/com/willfp/illusioner/config/configs/Attacks.java @@ -1,13 +1,13 @@ package com.willfp.illusioner.config.configs; -import com.willfp.eco.util.config.StaticBaseConfig; +import com.willfp.eco.util.config.BaseConfig; import com.willfp.illusioner.IllusionerPlugin; -public class Attacks extends StaticBaseConfig { +public class Attacks extends BaseConfig { /** * Instantiate attacks.yml. */ public Attacks() { - super("attacks", IllusionerPlugin.getInstance()); + super("attacks", false, IllusionerPlugin.getInstance()); } } diff --git a/eco-core/core-plugin/src/main/java/com/willfp/illusioner/config/configs/Sounds.java b/eco-core/core-plugin/src/main/java/com/willfp/illusioner/config/configs/Sounds.java index e534883..605ccc6 100644 --- a/eco-core/core-plugin/src/main/java/com/willfp/illusioner/config/configs/Sounds.java +++ b/eco-core/core-plugin/src/main/java/com/willfp/illusioner/config/configs/Sounds.java @@ -1,13 +1,13 @@ package com.willfp.illusioner.config.configs; -import com.willfp.eco.util.config.StaticBaseConfig; +import com.willfp.eco.util.config.BaseConfig; import com.willfp.illusioner.IllusionerPlugin; -public class Sounds extends StaticBaseConfig { +public class Sounds extends BaseConfig { /** * Instantiate sounds.yml. */ public Sounds() { - super("sounds", IllusionerPlugin.getInstance()); + super("sounds", false, IllusionerPlugin.getInstance()); } } diff --git a/eco-core/core-plugin/src/main/java/com/willfp/illusioner/illusioner/IllusionerManager.java b/eco-core/core-plugin/src/main/java/com/willfp/illusioner/illusioner/IllusionerManager.java index cd294f7..04e60c9 100644 --- a/eco-core/core-plugin/src/main/java/com/willfp/illusioner/illusioner/IllusionerManager.java +++ b/eco-core/core-plugin/src/main/java/com/willfp/illusioner/illusioner/IllusionerManager.java @@ -1,6 +1,5 @@ package com.willfp.illusioner.illusioner; -import com.willfp.eco.util.plugin.AbstractEcoPlugin; import com.willfp.illusioner.IllusionerPlugin; import com.willfp.illusioner.illusioner.options.IllusionerOptions; diff --git a/eco-core/core-plugin/src/main/java/com/willfp/illusioner/illusioner/listeners/AttackListeners.java b/eco-core/core-plugin/src/main/java/com/willfp/illusioner/illusioner/listeners/AttackListeners.java index efe51d8..633ff03 100644 --- a/eco-core/core-plugin/src/main/java/com/willfp/illusioner/illusioner/listeners/AttackListeners.java +++ b/eco-core/core-plugin/src/main/java/com/willfp/illusioner/illusioner/listeners/AttackListeners.java @@ -6,6 +6,8 @@ import com.willfp.illusioner.illusioner.OptionedSound; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.Sound; +import org.bukkit.block.Block; +import org.bukkit.block.BlockFace; import org.bukkit.entity.EntityType; import org.bukkit.entity.Player; import org.bukkit.entity.Projectile; @@ -128,5 +130,29 @@ public class AttackListeners implements Listener { event.setCancelled(true); } } + + if (IllusionerManager.OPTIONS.getGameplayOptions().isTeleport()) { + if (NumberUtils.randFloat(0, 100) < IllusionerManager.OPTIONS.getGameplayOptions().getTeleportChance()) { + int range = IllusionerManager.OPTIONS.getGameplayOptions().getTeleportRange(); + for (int x = -range; x <= range; x++) { + for (int y = -range; y <= range; y++) { + for (int z = -range; z <= range; z++) { + Location location = event.getEntity().getLocation().clone(); + location.setX(x); + location.setY(y); + location.setZ(z); + + Block block = location.getBlock(); + + if (block.getType() == Material.AIR && block.getRelative(BlockFace.UP).getType() == Material.AIR) { + event.getEntity().teleport(location); + OptionedSound optionedSound = IllusionerManager.OPTIONS.getGameplayOptions().getTeleportSound(); + location.getWorld().playSound(location, optionedSound.getSound(), optionedSound.getVolume(), optionedSound.getPitch()); + } + } + } + } + } + } } } diff --git a/eco-core/core-plugin/src/main/java/com/willfp/illusioner/illusioner/options/GameplayOptions.java b/eco-core/core-plugin/src/main/java/com/willfp/illusioner/illusioner/options/GameplayOptions.java index bb5daf9..100cdba 100644 --- a/eco-core/core-plugin/src/main/java/com/willfp/illusioner/illusioner/options/GameplayOptions.java +++ b/eco-core/core-plugin/src/main/java/com/willfp/illusioner/illusioner/options/GameplayOptions.java @@ -70,8 +70,33 @@ public class GameplayOptions extends PluginDependent { @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) { @@ -98,10 +123,20 @@ public class GameplayOptions extends PluginDependent { 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().getInt("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")); diff --git a/eco-core/core-plugin/src/main/resources/config.yml b/eco-core/core-plugin/src/main/resources/config.yml index 196e3cf..5e23780 100644 --- a/eco-core/core-plugin/src/main/resources/config.yml +++ b/eco-core/core-plugin/src/main/resources/config.yml @@ -18,10 +18,16 @@ xp: 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: 10 + 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 diff --git a/eco-core/core-plugin/src/main/resources/sounds.yml b/eco-core/core-plugin/src/main/resources/sounds.yml index 9197a07..4f06120 100644 --- a/eco-core/core-plugin/src/main/resources/sounds.yml +++ b/eco-core/core-plugin/src/main/resources/sounds.yml @@ -18,6 +18,12 @@ summon: volume: 1 pitch: 2 +teleport: + # When the illusioner teleports + sound: ENTITY_ENDERMAN_TELEPORT + volume: 1 + pitch: 0.7 + spawn: 1: broadcast: true