From 147be9ab7c0656eba6382db55540bc9d9475cad7 Mon Sep 17 00:00:00 2001 From: Craftinators Date: Fri, 24 Feb 2023 21:22:25 -0500 Subject: [PATCH] clean: use preferred method --- .../user/manager/UserEmoteModel.java | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/common/src/main/java/com/hibiscusmc/hmccosmetics/user/manager/UserEmoteModel.java b/common/src/main/java/com/hibiscusmc/hmccosmetics/user/manager/UserEmoteModel.java index dd171510..63ee7c72 100644 --- a/common/src/main/java/com/hibiscusmc/hmccosmetics/user/manager/UserEmoteModel.java +++ b/common/src/main/java/com/hibiscusmc/hmccosmetics/user/manager/UserEmoteModel.java @@ -16,6 +16,7 @@ import org.bukkit.entity.EntityType; import org.bukkit.entity.Player; import org.jetbrains.annotations.NotNull; +import java.util.Collections; import java.util.List; import java.util.UUID; @@ -35,13 +36,16 @@ public class UserEmoteModel extends PlayerModel { @Override public void playAnimation(@NotNull String id) { - if (id.contains(":")) id = id.split(":", 2)[1]; + if (id.contains(":")) id = id.split(":", 2)[1]; // A:B -> B -> B.B.B if (!id.contains(".")) id = id + "." + id + "." + id; // Make into a format that playerAnimator works with. Requires 3 splits. + super.playAnimation(id); + emotePlaying = id; + // Add config option that either allows player to move or forces them into a spot. Player player = user.getPlayer(); - List viewer = List.of(user.getPlayer()); + List viewer = Collections.singletonList(user.getPlayer()); List outsideViewers = PacketManager.getViewers(player.getLocation()); outsideViewers.remove(player); @@ -49,13 +53,16 @@ public class UserEmoteModel extends PlayerModel { Location newLocation = player.getLocation().clone(); newLocation.setPitch(0); + double DISTANCE = Settings.getEmoteDistance(); + Location thirdPersonLocation = newLocation.add(newLocation.getDirection().normalize().multiply(DISTANCE)); if (thirdPersonLocation.getBlock().getType() != Material.AIR) { stopAnimation(); MessagesUtil.sendMessage(player, "emote-blocked"); return; } + user.getPlayer().setInvisible(true); user.hideCosmetics(CosmeticUser.HiddenReason.EMOTE); @@ -88,10 +95,10 @@ public class UserEmoteModel extends PlayerModel { emotePlaying = null; despawn(); Bukkit.getScheduler().runTask(HMCCosmeticsPlugin.getInstance(), () -> { - if (user.getPlayer() == null) return; Player player = user.getPlayer(); - List viewer = List.of(user.getPlayer()); - if (viewer == null) return; + if (player == null) return; + + List viewer = Collections.singletonList(player); List outsideViewers = PacketManager.getViewers(player.getLocation()); outsideViewers.remove(player);