mirror of
https://github.com/Auxilor/EcoMobs.git
synced 2025-12-21 16:09:24 +00:00
Added teleportation options
This commit is contained in:
@@ -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());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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"));
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user