diff --git a/common/src/main/java/com/hibiscusmc/hmccosmetics/config/Settings.java b/common/src/main/java/com/hibiscusmc/hmccosmetics/config/Settings.java index 560d514d..66599cfd 100644 --- a/common/src/main/java/com/hibiscusmc/hmccosmetics/config/Settings.java +++ b/common/src/main/java/com/hibiscusmc/hmccosmetics/config/Settings.java @@ -124,6 +124,8 @@ public class Settings { private static String equipableCosmeticColor; @Getter private static String lockedCosmeticColor; + @Getter + private static boolean emoteCameraEnabled; public static void load(ConfigurationNode source) { @@ -158,6 +160,7 @@ public class Settings { addBootsEnchants = cosmeticSettings.node(COSMETIC_ADD_ENCHANTS_BOOTS_PATH).getBoolean(false); tickPeriod = cosmeticSettings.node(TICK_PERIOD_PATH).getInt(-1); viewDistance = cosmeticSettings.node(VIEW_DISTANCE_PATH).getInt(); + emoteCameraEnabled = cosmeticSettings.node("emote-camera").getBoolean(true); ConfigurationNode menuSettings = source.node(MENU_SETTINGS_PATH); diff --git a/common/src/main/java/com/hibiscusmc/hmccosmetics/listener/PlayerGameListener.java b/common/src/main/java/com/hibiscusmc/hmccosmetics/listener/PlayerGameListener.java index f7ae8e7f..6b0d0a12 100644 --- a/common/src/main/java/com/hibiscusmc/hmccosmetics/listener/PlayerGameListener.java +++ b/common/src/main/java/com/hibiscusmc/hmccosmetics/listener/PlayerGameListener.java @@ -184,11 +184,15 @@ public class PlayerGameListener implements Listener { } } - @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) + @EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) public void onPlayerLook(PlayerMoveEvent event) { Player player = event.getPlayer(); CosmeticUser user = CosmeticUsers.getUser(player); if (user == null) return; + if (user.getUserEmoteManager().isPlayingEmote()) { + event.setCancelled(true); + return; + } // Really need to look into optimization of this user.updateCosmetic(CosmeticSlot.BACKPACK); user.updateCosmetic(CosmeticSlot.BALLOON); 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 c4aa3bdc..c49e18ec 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 @@ -47,39 +47,42 @@ public class UserEmoteModel extends PlayerModel { PacketManager.equipmentSlotUpdate(player, true, outsideViewers); outsideViewers.remove(player); - Location newLocation = player.getLocation().clone(); - newLocation.setPitch(0); - - double DISTANCE = Settings.getEmoteDistance(); - - Location thirdPersonLocation = newLocation.add(newLocation.getDirection().normalize().multiply(DISTANCE)); - if (DISTANCE > 0) { - MessagesUtil.sendDebugMessages("Yaw " + (int) thirdPersonLocation.getYaw()); - MessagesUtil.sendDebugMessages("New Yaw " + ServerUtils.getNextYaw((int) thirdPersonLocation.getYaw(), 180)); - thirdPersonLocation.setYaw(ServerUtils.getNextYaw((int) thirdPersonLocation.getYaw(), 180)); - } - if (Settings.isCosmeticEmoteBlockCheck() && thirdPersonLocation.getBlock().getType().isOccluding()) { - stopAnimation(); - MessagesUtil.sendMessage(player, "emote-blocked"); - return; - } - // Check if block below player is an air block - if (Settings.isEmoteAirCheck() && newLocation.clone().subtract(0, 1, 0).getBlock().getType().isAir()) { - stopAnimation(); - MessagesUtil.sendMessage(player, "emote-blocked"); - } - user.getPlayer().setInvisible(true); user.hideCosmetics(CosmeticUser.HiddenReason.EMOTE); originalGamemode = player.getGameMode(); - PacketManager.sendEntitySpawnPacket(thirdPersonLocation, armorStandId, EntityType.ARMOR_STAND, UUID.randomUUID(), viewer); - PacketManager.sendInvisibilityPacket(armorStandId, viewer); - PacketManager.sendLookPacket(armorStandId, thirdPersonLocation, viewer); + if (Settings.isEmoteCameraEnabled()) { + Location newLocation = player.getLocation().clone(); + newLocation.setPitch(0); + + double DISTANCE = Settings.getEmoteDistance(); + + Location thirdPersonLocation = newLocation.add(newLocation.getDirection().normalize().multiply(DISTANCE)); + if (DISTANCE > 0) { + MessagesUtil.sendDebugMessages("Yaw " + (int) thirdPersonLocation.getYaw()); + MessagesUtil.sendDebugMessages("New Yaw " + ServerUtils.getNextYaw((int) thirdPersonLocation.getYaw(), 180)); + thirdPersonLocation.setYaw(ServerUtils.getNextYaw((int) thirdPersonLocation.getYaw(), 180)); + } + if (Settings.isCosmeticEmoteBlockCheck() && thirdPersonLocation.getBlock().getType().isOccluding()) { + stopAnimation(); + MessagesUtil.sendMessage(player, "emote-blocked"); + return; + } + // Check if block below player is an air block + if (Settings.isEmoteAirCheck() && newLocation.clone().subtract(0, 1, 0).getBlock().getType().isAir()) { + stopAnimation(); + MessagesUtil.sendMessage(player, "emote-blocked"); + } + + PacketManager.sendEntitySpawnPacket(thirdPersonLocation, armorStandId, EntityType.ARMOR_STAND, UUID.randomUUID(), viewer); + PacketManager.sendInvisibilityPacket(armorStandId, viewer); + PacketManager.sendLookPacket(armorStandId, thirdPersonLocation, viewer); + + PacketManager.gamemodeChangePacket(player, 3); + PacketManager.sendCameraPacket(armorStandId, viewer); + } - PacketManager.gamemodeChangePacket(player, 3); - PacketManager.sendCameraPacket(armorStandId, viewer); MessagesUtil.sendDebugMessages("playAnimation run"); } diff --git a/common/src/main/resources/config.yml b/common/src/main/resources/config.yml index dce3084f..e116e2f7 100644 --- a/common/src/main/resources/config.yml +++ b/common/src/main/resources/config.yml @@ -29,6 +29,8 @@ cosmetic-settings: emote-air-check: true # Check if there is air under a player, if there is, don't play emote emote-damage-leave: true # If the player should leave the emote when they take damage emote-invincible: false # If the player should not take damage while doing an emote + # If a player should be put into camera mode when looking at an emote. Highly recommend keeping it as true. + emote-camera: true helmet-add-enchantments: false # If the plugin should keep enchants on helmets. This is useful as some enchantments are client side only. chest-add-enchantments: false # If the plugin should keep enchants on chestplate. This is useful as some enchantments are client side only.