mirror of
https://github.com/Auxilor/EcoMobs.git
synced 2025-12-23 17:09:27 +00:00
Updated to 2.5.0 and allowed attacking the illusioner to trigger attacks
This commit is contained in:
@@ -8,6 +8,6 @@ public class Attacks extends BaseConfig {
|
||||
* Instantiate attacks.yml.
|
||||
*/
|
||||
public Attacks() {
|
||||
super("attacks", false, IllusionerPlugin.getInstance());
|
||||
super("attacks", false, IllusionerPlugin.getInstance(), "effects.", "summons.");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ import org.bukkit.Sound;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Projectile;
|
||||
import org.bukkit.event.EventHandler;
|
||||
@@ -35,13 +36,31 @@ public class AttackListeners implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!(event.getEntity() instanceof Player)) {
|
||||
return;
|
||||
}
|
||||
|
||||
handleAttack((LivingEntity) event.getDamager(), (Player) event.getEntity());
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when a player attacks an illusioner.
|
||||
*
|
||||
* @param event The event to listen for.
|
||||
*/
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void onAttackIllusioner(@NotNull final EntityDamageByEntityEvent event) {
|
||||
if (!event.getEntity().getType().equals(EntityType.ILLUSIONER)) {
|
||||
return;
|
||||
}
|
||||
|
||||
Player temp = null;
|
||||
|
||||
if (event.getEntity() instanceof Player) {
|
||||
temp = (Player) event.getEntity();
|
||||
} else if (event.getEntity() instanceof Projectile) {
|
||||
if (((Projectile) event.getEntity()).getShooter() instanceof Player) {
|
||||
temp = (Player) ((Projectile) event.getEntity()).getShooter();
|
||||
if (event.getDamager() instanceof Player) {
|
||||
temp = (Player) event.getDamager();
|
||||
} else if (event.getDamager() instanceof Projectile) {
|
||||
if (((Projectile) event.getDamager()).getShooter() instanceof Player) {
|
||||
temp = (Player) ((Projectile) event.getDamager()).getShooter();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,11 +70,16 @@ public class AttackListeners implements Listener {
|
||||
|
||||
Player player = temp;
|
||||
|
||||
handleAttack((LivingEntity) event.getEntity(), player);
|
||||
}
|
||||
|
||||
private void handleAttack(@NotNull final LivingEntity illusioner,
|
||||
@NotNull final Player player) {
|
||||
OptionedSound hitSound = IllusionerManager.OPTIONS.getGameplayOptions().getHitSound();
|
||||
if (hitSound.isBroadcast()) {
|
||||
player.getWorld().playSound(event.getEntity().getLocation(), hitSound.getSound(), hitSound.getVolume(), hitSound.getPitch());
|
||||
player.getWorld().playSound(illusioner.getLocation(), hitSound.getSound(), hitSound.getVolume(), hitSound.getPitch());
|
||||
} else {
|
||||
player.playSound(event.getEntity().getLocation(), hitSound.getSound(), hitSound.getVolume(), hitSound.getPitch());
|
||||
player.playSound(illusioner.getLocation(), hitSound.getSound(), hitSound.getVolume(), hitSound.getPitch());
|
||||
}
|
||||
|
||||
IllusionerManager.OPTIONS.getGameplayOptions().getEffectOptions().forEach(effectOption -> {
|
||||
@@ -95,9 +119,9 @@ public class AttackListeners implements Listener {
|
||||
|
||||
OptionedSound summonSound = IllusionerManager.OPTIONS.getGameplayOptions().getSummonSound();
|
||||
if (summonSound.isBroadcast()) {
|
||||
player.getWorld().playSound(event.getEntity().getLocation(), summonSound.getSound(), summonSound.getVolume(), summonSound.getPitch());
|
||||
player.getWorld().playSound(illusioner.getLocation(), summonSound.getSound(), summonSound.getVolume(), summonSound.getPitch());
|
||||
} else {
|
||||
player.playSound(event.getEntity().getLocation(), summonSound.getSound(), summonSound.getVolume(), summonSound.getPitch());
|
||||
player.playSound(illusioner.getLocation(), summonSound.getSound(), summonSound.getVolume(), summonSound.getPitch());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import com.willfp.illusioner.config.IllusionerConfigs;
|
||||
import com.willfp.illusioner.illusioner.OptionedSound;
|
||||
import lombok.Getter;
|
||||
import lombok.ToString;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
@@ -148,10 +149,13 @@ public class GameplayOptions extends PluginDependent {
|
||||
|
||||
summonerOptions.clear();
|
||||
IllusionerConfigs.ATTACKS.getConfig().getConfigurationSection("summons").getKeys(false).forEach(key -> {
|
||||
Bukkit.getLogger().info(key + " bruh ");
|
||||
EntityType type = EntityType.valueOf(IllusionerConfigs.ATTACKS.getString("summons." + key + ".type"));
|
||||
double chance = IllusionerConfigs.ATTACKS.getDouble("summons." + key + ".chance");
|
||||
summonerOptions.add(new SummonerOption(chance, type));
|
||||
});
|
||||
|
||||
Bukkit.getLogger().info(summonerOptions.toString());
|
||||
}
|
||||
|
||||
public static class EffectOption {
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
version = 2.4.1
|
||||
version = 2.5.0
|
||||
plugin-name = Illusioner
|
||||
Reference in New Issue
Block a user