diff --git a/src/main/java/fr/openmc/core/features/animations/listeners/EmoteListener.java b/src/main/java/fr/openmc/core/features/animations/listeners/EmoteListener.java index acfc15fca..2fe3241c6 100644 --- a/src/main/java/fr/openmc/core/features/animations/listeners/EmoteListener.java +++ b/src/main/java/fr/openmc/core/features/animations/listeners/EmoteListener.java @@ -96,6 +96,8 @@ private void animationEnd(Player player) { PlayerAnimationInfo info = playingAnimations.remove(player); if (info == null) return; + player.setInvulnerable(false); + sendCamera(player, player); if (info.getArmorStand() != null) info.getArmorStand().remove(); diff --git a/src/main/java/fr/openmc/core/features/animations/listeners/PlayerFinishJoiningListener.java b/src/main/java/fr/openmc/core/features/animations/listeners/PlayerFinishJoiningListener.java index dc40d728a..78ad65def 100644 --- a/src/main/java/fr/openmc/core/features/animations/listeners/PlayerFinishJoiningListener.java +++ b/src/main/java/fr/openmc/core/features/animations/listeners/PlayerFinishJoiningListener.java @@ -4,6 +4,8 @@ import fr.openmc.core.OMCPlugin; import fr.openmc.core.features.animations.Animation; import fr.openmc.core.features.animations.PlayerAnimationInfo; +import fr.openmc.core.features.settings.PlayerSettingsManager; +import fr.openmc.core.features.settings.SettingType; import org.bukkit.GameMode; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -19,16 +21,26 @@ public void onPlayerJoin(PlayerJoinEvent event) { Player player = event.getPlayer(); boolean onGround = player.getLocation().subtract(0, 1, 0).getBlock().getType().isSolid(); + if (!(boolean) PlayerSettingsManager.getPlayerSettings(player.getUniqueId()).getSetting(SettingType.JOIN_ANIMATION)) return; if (player.isFlying() || !onGround || player.getGameMode().equals(GameMode.SPECTATOR)) return; playingAnimations.put(player, new PlayerAnimationInfo()); EmoteListener.setupHead(player); + player.setInvulnerable(true); new BukkitRunnable() { @Override public void run() { - player.playSound(player, "omc_sounds:ambient.join_rift", 1.0f, 1.0f); - CustomPlayer.playEmote(player, Animation.JOIN_RIFT.getNameAnimation()); + if (!player.isOnline()) return; + + player.getWorld().playSound(player.getLocation(), "omc_sounds:ambient.join_rift", 1.0f, 1.0f); + try { + CustomPlayer.playEmote(player, Animation.JOIN_RIFT.getNameAnimation()); + } catch (Exception e) { + playingAnimations.remove(player); + EmoteListener.sendCamera(player, player); + player.setInvulnerable(false); + } } }.runTaskLater(OMCPlugin.getInstance(), 11L); } diff --git a/src/main/java/fr/openmc/core/features/settings/SettingType.java b/src/main/java/fr/openmc/core/features/settings/SettingType.java index cc24a9530..fdad9ccc6 100644 --- a/src/main/java/fr/openmc/core/features/settings/SettingType.java +++ b/src/main/java/fr/openmc/core/features/settings/SettingType.java @@ -32,7 +32,9 @@ public enum SettingType { Material.NOTE_BLOCK, Material.GRAY_DYE, "Activer ou désactiver les sons des messages privés"), TELEPORT_TITLE_FADE(ValueType.BOOLEAN, true, "Fondu du titre lors des téléportations", Material.ENDER_PEARL, Material.GRAY_DYE, "Activer ou désactiver le fondu du titre lors des téléportations"), - + JOIN_ANIMATION(ValueType.BOOLEAN, true, "Animation de connexion", + Material.GLOW_INK_SAC, Material.INK_SAC, "Activer ou désactiver l'animation de connexion"), + ; private final ValueType valueType;