mirror of
https://github.com/HibiscusMC/HMCCosmetics.git
synced 2025-12-19 15:09:19 +00:00
chore: remove emotes
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
package com.hibiscusmc.hmccosmetics;
|
||||
|
||||
import com.hibiscusmc.hmccosmetics.api.HMCCosmeticsAPI;
|
||||
import com.hibiscusmc.hmccosmetics.api.events.HMCCosmeticSetupEvent;
|
||||
import com.hibiscusmc.hmccosmetics.command.CosmeticCommand;
|
||||
import com.hibiscusmc.hmccosmetics.command.CosmeticCommandTabComplete;
|
||||
@@ -10,7 +9,6 @@ import com.hibiscusmc.hmccosmetics.config.WardrobeSettings;
|
||||
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
|
||||
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetics;
|
||||
import com.hibiscusmc.hmccosmetics.database.Database;
|
||||
import com.hibiscusmc.hmccosmetics.emotes.EmoteManager;
|
||||
import com.hibiscusmc.hmccosmetics.gui.Menu;
|
||||
import com.hibiscusmc.hmccosmetics.gui.Menus;
|
||||
import com.hibiscusmc.hmccosmetics.hooks.items.HookHMCCosmetics;
|
||||
@@ -26,7 +24,6 @@ import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUsers;
|
||||
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||
import com.hibiscusmc.hmccosmetics.util.TranslationUtil;
|
||||
import com.ticxo.playeranimator.PlayerAnimatorImpl;
|
||||
import me.lojosho.hibiscuscommons.HibiscusCommonsPlugin;
|
||||
import me.lojosho.hibiscuscommons.HibiscusPlugin;
|
||||
import me.lojosho.hibiscuscommons.config.serializer.ItemSerializer;
|
||||
@@ -68,9 +65,6 @@ public final class HMCCosmeticsPlugin extends HibiscusPlugin {
|
||||
if (!Path.of(getDataFolder().getPath() + "/cosmetics/").toFile().exists()) saveResource("cosmetics/defaultcosmetics.yml", false);
|
||||
if (!Path.of(getDataFolder().getPath() + "/menus/").toFile().exists()) saveResource("menus/defaultmenu.yml", false);
|
||||
|
||||
// Player Animator ~ Do no longer support running this on a version that PlayerAnimator is supported
|
||||
// if (HMCCosmeticsAPI.getNMSVersion().contains("v1_19_R3") || HMCCosmeticsAPI.getNMSVersion().contains("v1_20_R1")) PlayerAnimatorImpl.initialize(this); // PlayerAnimator does not support 1.20.2 yet
|
||||
|
||||
// Configuration Sync
|
||||
final File configFile = Path.of(getInstance().getDataFolder().getPath(), "config.yml").toFile();
|
||||
final File messageFile = Path.of(getInstance().getDataFolder().getPath(), "messages.yml").toFile();
|
||||
@@ -125,9 +119,6 @@ public final class HMCCosmeticsPlugin extends HibiscusPlugin {
|
||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||
CosmeticUser user = CosmeticUsers.getUser(player);
|
||||
if (user == null) continue;
|
||||
if (user.getUserEmoteManager().isPlayingEmote()) {
|
||||
player.setInvisible(false);
|
||||
}
|
||||
if (user.isInWardrobe()) {
|
||||
user.leaveWardrobe(true);
|
||||
}
|
||||
@@ -229,8 +220,6 @@ public final class HMCCosmeticsPlugin extends HibiscusPlugin {
|
||||
}
|
||||
}
|
||||
|
||||
//if (Settings.isEmotesEnabled() && (HMCCosmeticsAPI.getNMSVersion().contains("v1_19_R3") || HMCCosmeticsAPI.getNMSVersion().contains("v1_20_R1"))) EmoteManager.loadEmotes(); // PlayerAnimator does not support 1.20.2 yet
|
||||
|
||||
getInstance().getLogger().info("Successfully Enabled HMCCosmetics");
|
||||
getInstance().getLogger().info(Cosmetics.values().size() + " Cosmetics Successfully Setup");
|
||||
getInstance().getLogger().info(Menus.getMenuNames().size() + " Menus Successfully Setup");
|
||||
|
||||
@@ -1,54 +0,0 @@
|
||||
package com.hibiscusmc.hmccosmetics.api.events;
|
||||
|
||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Called when a player starts playing an emote.
|
||||
*/
|
||||
public class PlayerEmoteStartEvent extends PlayerCosmeticEvent implements Cancellable {
|
||||
private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||
|
||||
private final String animationId;
|
||||
|
||||
private boolean cancel = false;
|
||||
|
||||
public PlayerEmoteStartEvent(@NotNull CosmeticUser who, @NotNull String animationId) {
|
||||
super(who);
|
||||
this.animationId = animationId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the animation id of the emote the player started playing.
|
||||
*
|
||||
* @implNote The returned string of this method may be an invalid animation id.
|
||||
* Make sure to validate it before use by calling {@link com.hibiscusmc.hmccosmetics.emotes.EmoteManager#get(String)}.
|
||||
*
|
||||
* @return the animation id of the emote which the player started playing
|
||||
*/
|
||||
@NotNull
|
||||
public String getAnimationId() {
|
||||
return animationId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return cancel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCancelled(boolean cancel) {
|
||||
this.cancel = cancel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull HandlerList getHandlers() {
|
||||
return HANDLER_LIST;
|
||||
}
|
||||
|
||||
public static @NotNull HandlerList getHandlerList() {
|
||||
return HANDLER_LIST;
|
||||
}
|
||||
}
|
||||
@@ -1,64 +0,0 @@
|
||||
package com.hibiscusmc.hmccosmetics.api.events;
|
||||
|
||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||
import com.hibiscusmc.hmccosmetics.user.manager.UserEmoteManager;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Called when a player stops playing an emote.
|
||||
*/
|
||||
public class PlayerEmoteStopEvent extends PlayerCosmeticEvent implements Cancellable {
|
||||
private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||
|
||||
private final UserEmoteManager.StopEmoteReason reason;
|
||||
|
||||
private boolean cancel = false;
|
||||
|
||||
public PlayerEmoteStopEvent(@NotNull CosmeticUser who, @NotNull UserEmoteManager.StopEmoteReason reason) {
|
||||
super(who);
|
||||
this.reason = reason;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the {@link UserEmoteManager.StopEmoteReason} as to why the emote has stopped playing
|
||||
*
|
||||
* @return The {@link UserEmoteManager.StopEmoteReason} why the emote has stopped playing
|
||||
* @deprecated As of release 2.2.5+, replaced by {@link #getReason()}
|
||||
*/
|
||||
@Deprecated(forRemoval = true)
|
||||
@NotNull
|
||||
public UserEmoteManager.StopEmoteReason getStopEmoteReason() {
|
||||
return reason;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the {@link UserEmoteManager.StopEmoteReason} as to why the emote has stopped playing.
|
||||
*
|
||||
* @return the reason why the emote has stopped playing
|
||||
* @since 2.2.5
|
||||
*/
|
||||
public @NotNull UserEmoteManager.StopEmoteReason getReason() {
|
||||
return reason;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return cancel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCancelled(boolean cancel) {
|
||||
this.cancel = cancel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull HandlerList getHandlers() {
|
||||
return HANDLER_LIST;
|
||||
}
|
||||
|
||||
public static @NotNull HandlerList getHandlerList() {
|
||||
return HANDLER_LIST;
|
||||
}
|
||||
}
|
||||
@@ -10,9 +10,7 @@ import com.hibiscusmc.hmccosmetics.config.WardrobeSettings;
|
||||
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
|
||||
import com.hibiscusmc.hmccosmetics.cosmetic.CosmeticSlot;
|
||||
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetics;
|
||||
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticEmoteType;
|
||||
import com.hibiscusmc.hmccosmetics.database.Database;
|
||||
import com.hibiscusmc.hmccosmetics.emotes.EmoteManager;
|
||||
import com.hibiscusmc.hmccosmetics.gui.Menu;
|
||||
import com.hibiscusmc.hmccosmetics.gui.Menus;
|
||||
import com.hibiscusmc.hmccosmetics.gui.special.DyeMenu;
|
||||
@@ -23,7 +21,6 @@ import com.hibiscusmc.hmccosmetics.util.HMCCServerUtils;
|
||||
import me.lojosho.hibiscuscommons.hooks.Hooks;
|
||||
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
|
||||
import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver;
|
||||
import org.apache.commons.lang3.EnumUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Color;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
@@ -464,59 +461,6 @@ public class CosmeticCommand implements CommandExecutor {
|
||||
if (!silent) MessagesUtil.sendMessage(sender, "debug-enabled");
|
||||
}
|
||||
}
|
||||
case ("emote") -> {
|
||||
if (!sender.hasPermission("hmccosmetics.cmd.emote")) {
|
||||
if (!silent) MessagesUtil.sendMessage(sender, "no-permission");
|
||||
return true;
|
||||
}
|
||||
if (sender.hasPermission("hmccosmetics.cmd.emote.other")) {
|
||||
if (args.length >= 2) player = Bukkit.getPlayer(args[1]);
|
||||
}
|
||||
if (player == null) {
|
||||
if (!silent) MessagesUtil.sendMessage(sender, "invalid-player");
|
||||
return true;
|
||||
}
|
||||
CosmeticUser user = CosmeticUsers.getUser(player);
|
||||
if (!user.hasCosmeticInSlot(CosmeticSlot.EMOTE)) {
|
||||
if (!silent) MessagesUtil.sendMessage(sender, "emote-none");
|
||||
return true;
|
||||
}
|
||||
|
||||
CosmeticEmoteType cosmeticEmoteType = (CosmeticEmoteType) user.getCosmetic(CosmeticSlot.EMOTE);
|
||||
cosmeticEmoteType.run(user);
|
||||
return true;
|
||||
}
|
||||
|
||||
case ("playemote") -> {
|
||||
// /cosmetic playEmote <emoteId> [playerName]
|
||||
if (!sender.hasPermission("hmccosmetics.cmd.playemote")) {
|
||||
if (!silent) MessagesUtil.sendMessage(sender, "no-permission");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (args.length < 2) {
|
||||
if (!silent) MessagesUtil.sendMessage(player, "not-enough-args");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!EmoteManager.has(args[1])) {
|
||||
MessagesUtil.sendDebugMessages("Did not contain " + args[1]);
|
||||
if (!silent) MessagesUtil.sendMessage(sender, "emote-invalid");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (sender.hasPermission("hmccosmetics.cmd.playemote.other")) {
|
||||
if (args.length >= 3) player = Bukkit.getPlayer(args[2]);
|
||||
}
|
||||
if (player == null) {
|
||||
if (!silent) MessagesUtil.sendMessage(sender, "invalid-player");
|
||||
return true;
|
||||
}
|
||||
CosmeticUser user = CosmeticUsers.getUser(player);
|
||||
user.getUserEmoteManager().playEmote(args[1]);
|
||||
return true;
|
||||
}
|
||||
|
||||
case "disableall" -> {
|
||||
if (!sender.hasPermission("hmccosmetics.cmd.disableall")) {
|
||||
if (!silent) MessagesUtil.sendMessage(sender, "no-permission");
|
||||
|
||||
@@ -6,7 +6,6 @@ import com.hibiscusmc.hmccosmetics.config.WardrobeSettings;
|
||||
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
|
||||
import com.hibiscusmc.hmccosmetics.cosmetic.CosmeticSlot;
|
||||
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetics;
|
||||
import com.hibiscusmc.hmccosmetics.emotes.EmoteManager;
|
||||
import com.hibiscusmc.hmccosmetics.gui.Menu;
|
||||
import com.hibiscusmc.hmccosmetics.gui.Menus;
|
||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||
@@ -44,8 +43,6 @@ public class CosmeticCommandTabComplete implements TabCompleter {
|
||||
if (hasPermission(sender, "hmccosmetics.cmd.hide")) completions.add("hide");
|
||||
if (hasPermission(sender, "hmccosmetics.cmd.show")) completions.add("show");
|
||||
if (hasPermission(sender, "hmccosmetics.cmd.debug")) completions.add("debug");
|
||||
if (hasPermission(sender, "hmccosmetics.cmd.emote")) completions.add("emote");
|
||||
if (hasPermission(sender, "hmccosmetics.cmd.playemote")) completions.add("playemote");
|
||||
if (hasPermission(sender, "hmccosmetics.cmd.disableall")) completions.add("disableall");
|
||||
if (hasPermission(sender, "hmccosmetics.cmd.hiddenreasons")) completions.add("hiddenreasons");
|
||||
if (hasPermission(sender, "hmccosmetics.cmd.clearhiddenreasons")) completions.add("clearhiddenreasons");
|
||||
@@ -74,7 +71,7 @@ public class CosmeticCommandTabComplete implements TabCompleter {
|
||||
if (menu.canOpen(user.getPlayer())) completions.add(menu.getId());
|
||||
}
|
||||
}
|
||||
case "dataclear", "hide", "show", "emote", "hiddenreasons", "clearhiddenreasons" -> {
|
||||
case "dataclear", "hide", "show", "hiddenreasons", "clearhiddenreasons" -> {
|
||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||
completions.add(player.getName());
|
||||
}
|
||||
@@ -102,7 +99,6 @@ public class CosmeticCommandTabComplete implements TabCompleter {
|
||||
completions.add(wardrobe.getId());
|
||||
}
|
||||
}
|
||||
case "playemote" -> completions.addAll(EmoteManager.getAllNames());
|
||||
}
|
||||
StringUtil.copyPartialMatches(args[1], completions, finalCompletions);
|
||||
}
|
||||
@@ -112,7 +108,7 @@ public class CosmeticCommandTabComplete implements TabCompleter {
|
||||
case "dye" -> {
|
||||
completions.add("#FFFFFF");
|
||||
}
|
||||
case "menu", "wardrobe", "apply", "unapply", "playemote" -> {
|
||||
case "menu", "wardrobe", "apply", "unapply" -> {
|
||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||
completions.add(player.getName());
|
||||
}
|
||||
|
||||
@@ -35,7 +35,6 @@ public class Settings {
|
||||
private static final String ITEM_PROCESS_LORE_PATH = "lore";
|
||||
private static final String DISABLED_GAMEMODE_PATH = "disabled-gamemode";
|
||||
private static final String DISABLED_GAMEMODE_GAMEMODES_PATH = "gamemodes";
|
||||
private static final String EMOTE_DISTANCE_PATH = "emote-distance";
|
||||
private static final String HOOK_SETTING_PATH = "hook-settings";
|
||||
private static final String HOOK_ITEMADDER_PATH = "itemsadder";
|
||||
private static final String HOOK_NEXO_PATH = "nexo";
|
||||
@@ -43,13 +42,6 @@ public class Settings {
|
||||
private static final String HOOK_WORLDGUARD_PATH = "worldguard";
|
||||
private static final String HOOK_WG_MOVE_CHECK_PATH = "player-move-check";
|
||||
private static final String HOOK_WG_MOVE_CHECK_PATH_LEGACY = "player_move_check";
|
||||
private static final String COSMETIC_EMOTE_ENABLE = "emote-enable";
|
||||
private static final String COSMETIC_EMOTE_CHECK_PATH = "emote-block-check";
|
||||
private static final String COSMETIC_EMOTE_AIR_CHECK_PATH = "emote-air-check";
|
||||
private static final String COSMETIC_EMOTE_DAMAGE_PATH = "emote-damage-leave";
|
||||
private static final String COSMETIC_EMOTE_INVINCIBLE_PATH = "emote-invincible";
|
||||
private static final String COSMETIC_EMOTE_CAMERA_PATH = "emote-camera";
|
||||
private static final String COSMETIC_EMOTE_MOVE_CHECK_PATH = "emote-move";
|
||||
private static final String COSMETIC_DISABLED_WORLDS_PATH = "disabled-worlds";
|
||||
private static final String COSMETIC_PACKET_ENTITY_TELEPORT_COOLDOWN_PATH = "entity-cooldown-teleport-packet";
|
||||
private static final String COSMETIC_BACKPACK_FORCE_RIDING_PACKET_PATH = "backpack-force-riding-packet";
|
||||
@@ -104,22 +96,12 @@ public class Settings {
|
||||
private static boolean nexoChangeReload;
|
||||
@Getter
|
||||
private static boolean worldGuardMoveCheck;
|
||||
@Getter
|
||||
private static boolean cosmeticEmoteBlockCheck;
|
||||
private static final HashMap<EquipmentSlot, SlotOptionConfig> slotOptions = new HashMap<>();
|
||||
@Getter
|
||||
private static boolean emoteAirCheck;
|
||||
@Getter
|
||||
private static boolean emoteDamageLeave;
|
||||
@Getter
|
||||
private static boolean emoteInvincible;
|
||||
@Getter
|
||||
private static boolean destroyLooseCosmetics;
|
||||
@Getter
|
||||
private static boolean backpackForceRidingEnabled;
|
||||
@Getter
|
||||
private static boolean emotesEnabled;
|
||||
@Getter
|
||||
private static boolean disabledGamemodesEnabled;
|
||||
@Getter
|
||||
private static boolean balloonHeadForward;
|
||||
@@ -165,10 +147,6 @@ public class Settings {
|
||||
private static String equipableCosmeticColor;
|
||||
@Getter
|
||||
private static String lockedCosmeticColor;
|
||||
@Getter
|
||||
private static boolean emoteCameraEnabled;
|
||||
@Getter
|
||||
private static boolean emoteMoveCheck;
|
||||
@Getter @Setter
|
||||
private static boolean allPlayersHidden;
|
||||
@Getter
|
||||
@@ -209,12 +187,6 @@ public class Settings {
|
||||
unapplyOnDeath = cosmeticSettings.node(UNAPPLY_DEATH_PATH).getBoolean(false);
|
||||
forcePermissionJoin = cosmeticSettings.node(FORCE_PERMISSION_JOIN_PATH).getBoolean(false);
|
||||
forceShowOnJoin = cosmeticSettings.node(FORCE_SHOW_COSMETICS_PATH).getBoolean(false);
|
||||
emotesEnabled = cosmeticSettings.node(COSMETIC_EMOTE_ENABLE).getBoolean(true);
|
||||
emoteDistance = cosmeticSettings.node(EMOTE_DISTANCE_PATH).getDouble(-3);
|
||||
cosmeticEmoteBlockCheck = cosmeticSettings.node(COSMETIC_EMOTE_CHECK_PATH).getBoolean(true);
|
||||
emoteAirCheck = cosmeticSettings.node(COSMETIC_EMOTE_AIR_CHECK_PATH).getBoolean(true);
|
||||
emoteDamageLeave = cosmeticSettings.node(COSMETIC_EMOTE_DAMAGE_PATH).getBoolean(false);
|
||||
emoteInvincible = cosmeticSettings.node(COSMETIC_EMOTE_INVINCIBLE_PATH).getBoolean(false);
|
||||
destroyLooseCosmetics = cosmeticSettings.node(COSMETIC_DESTROY_LOOSE_COSMETIC_PATH).getBoolean(false);
|
||||
backpackForceRidingEnabled = cosmeticSettings.node(COSMETIC_BACKPACK_FORCE_RIDING_PACKET_PATH).getBoolean(false);
|
||||
|
||||
@@ -231,8 +203,6 @@ public class Settings {
|
||||
|
||||
tickPeriod = cosmeticSettings.node(TICK_PERIOD_PATH).getInt(-1);
|
||||
viewDistance = cosmeticSettings.node(VIEW_DISTANCE_PATH).getInt(-3);
|
||||
emoteCameraEnabled = cosmeticSettings.node(COSMETIC_EMOTE_CAMERA_PATH).getBoolean(true);
|
||||
emoteMoveCheck = cosmeticSettings.node(COSMETIC_EMOTE_MOVE_CHECK_PATH).getBoolean(false);
|
||||
packetEntityTeleportCooldown = cosmeticSettings.node(COSMETIC_PACKET_ENTITY_TELEPORT_COOLDOWN_PATH).getInt(-1);
|
||||
balloonHeadForward = cosmeticSettings.node(COSMETIC_BALLOON_HEAD_FORWARD_PATH).getBoolean(false);
|
||||
backpackPreventDarkness = cosmeticSettings.node(BACKPACK_PREVENT_DARKNESS_PATH).getBoolean(true);
|
||||
|
||||
@@ -28,9 +28,7 @@ public abstract class CosmeticProvider {
|
||||
|
||||
Map.entry(CosmeticSlot.BACKPACK, CosmeticBackpackType::new),
|
||||
|
||||
Map.entry(CosmeticSlot.BALLOON, CosmeticBalloonType::new),
|
||||
|
||||
Map.entry(CosmeticSlot.EMOTE, CosmeticEmoteType::new)
|
||||
Map.entry(CosmeticSlot.BALLOON, CosmeticBalloonType::new)
|
||||
);
|
||||
|
||||
private static final String EXCEPTION_MESSAGE = "Unknown slot %s provided for mapping, if you registered your own CosmeticSlot please ensure that you've also registered a custom CosmeticProvider! Or if you have already registered a custom CosmeticProvider ensure it is registered in your plugins `onLoad` method instead of `onEnable`!";
|
||||
|
||||
@@ -20,7 +20,6 @@ public class CosmeticSlot {
|
||||
public static final CosmeticSlot OFFHAND = register("OFFHAND");
|
||||
public static final CosmeticSlot BACKPACK = register("BACKPACK");
|
||||
public static final CosmeticSlot BALLOON = register("BALLOON");
|
||||
public static final CosmeticSlot EMOTE = register("EMOTE");
|
||||
|
||||
private final String name;
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ public class CosmeticArmorType extends Cosmetic {
|
||||
|
||||
@Override
|
||||
public void update(@NotNull CosmeticUser user) {
|
||||
if (user.getUserEmoteManager().isPlayingEmote() || user.isInWardrobe()) return;
|
||||
if (user.isInWardrobe()) return;
|
||||
Entity entity = Bukkit.getEntity(user.getUniqueId());
|
||||
if (entity == null) return;
|
||||
if (Settings.getSlotOption(equipSlot).isRequireEmpty() && entity instanceof HumanEntity humanEntity) {
|
||||
|
||||
@@ -1,38 +0,0 @@
|
||||
package com.hibiscusmc.hmccosmetics.cosmetic.types;
|
||||
|
||||
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
|
||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||
import me.lojosho.shaded.configurate.ConfigurationNode;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class CosmeticEmoteType extends Cosmetic {
|
||||
|
||||
private final String animationId;
|
||||
private final String text;
|
||||
|
||||
public CosmeticEmoteType(String id, ConfigurationNode config) {
|
||||
super(id, config);
|
||||
|
||||
animationId = config.node("animation").getString();
|
||||
text = config.node("text").getString();
|
||||
MessagesUtil.sendDebugMessages("CosmeticEmoteType Animation id " + animationId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(CosmeticUser user) {
|
||||
// Nothing
|
||||
}
|
||||
|
||||
public void run(@NotNull CosmeticUser user) {
|
||||
user.getUserEmoteManager().playEmote(this);
|
||||
}
|
||||
|
||||
public String getAnimationId() {
|
||||
return animationId;
|
||||
}
|
||||
|
||||
public String getText() {
|
||||
return text;
|
||||
}
|
||||
}
|
||||
@@ -1,85 +0,0 @@
|
||||
package com.hibiscusmc.hmccosmetics.emotes;
|
||||
|
||||
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
|
||||
import com.ticxo.playeranimator.api.PlayerAnimator;
|
||||
import com.ticxo.playeranimator.api.animation.pack.AnimationPack;
|
||||
import org.apache.commons.io.FilenameUtils;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Manages Emotes
|
||||
*/
|
||||
@SuppressWarnings("SpellCheckingInspection")
|
||||
public class EmoteManager {
|
||||
private static final @NotNull Map<String, String> emotes = new HashMap<>();
|
||||
|
||||
/**
|
||||
* Loads all BlockBench animations from the emotes folder and puts it into the animation manager registry and local registry
|
||||
*/
|
||||
public static void loadEmotes() {
|
||||
// Clear the PlayerAnimator and local registries
|
||||
PlayerAnimator.api.getAnimationManager().clearRegistry();
|
||||
emotes.clear();
|
||||
|
||||
// Get the emote directory and check if it exists
|
||||
File emoteDir = new File(HMCCosmeticsPlugin.getInstance().getDataFolder().getPath() + "/emotes/");
|
||||
if (!emoteDir.exists()) return;
|
||||
|
||||
// Get all the files inside the directory and check if it isn't 0
|
||||
File[] emoteFiles = emoteDir.listFiles();
|
||||
if (emoteFiles == null || emoteFiles.length == 0) return;
|
||||
|
||||
// Remove any files that don't have the file extension ".bbmodel" and check if there are still resulting files
|
||||
emoteFiles = Arrays.stream(emoteFiles).filter(file -> file.getPath().endsWith(".bbmodel")).distinct().toArray(File[]::new);
|
||||
if (emoteFiles.length == 0) return;
|
||||
|
||||
// Loop through all files, importing all block bench animations into the registry
|
||||
for (File animationFile : emoteFiles) {
|
||||
String animationKey = FilenameUtils.removeExtension(animationFile.getName());
|
||||
PlayerAnimator.api.getAnimationManager().importAnimations(animationKey, animationFile);
|
||||
}
|
||||
|
||||
// Loops through all the entries in the registries and unpacks any animation packs to ensure if there were multiple animations
|
||||
// inside a singular file, that they are added to the local registry individually for tab completion
|
||||
for (Map.Entry<String, AnimationPack> packEntry : PlayerAnimator.api.getAnimationManager().getRegistry().entrySet()) {
|
||||
packEntry.getValue().getAnimations().keySet().forEach(animationName -> {
|
||||
// API key is the format "animationKey.animationFileName.animationName"
|
||||
String apiKey = packEntry.getKey().replace(":", ".") + "." + animationName;
|
||||
emotes.put(animationName, apiKey);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if there is an animation with the specified name
|
||||
* @param animationName Name whose presence is to be tested
|
||||
* @return True if this registry contains a mapping for the specified name
|
||||
*/
|
||||
public static boolean has(@NotNull String animationName) {
|
||||
return emotes.containsKey(animationName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the {@code API key} to which the specified name is mapped, or {@code null} if this map contains no mapping for the name.
|
||||
* @param animationName Name whose {@code API key} is to be fetched
|
||||
* @return The {@code API key} of the specified name or {@code null} if there was no animation name found
|
||||
*/
|
||||
public static @Nullable String get(@NotNull String animationName) {
|
||||
return emotes.get(animationName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a set of all the laoded animation names
|
||||
* @return A set of all loaded animation names
|
||||
*/
|
||||
public static @NotNull Set<String> getAllNames() {
|
||||
return emotes.keySet();
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.hibiscusmc.hmccosmetics.hooks.worldguard;
|
||||
|
||||
import com.hibiscusmc.hmccosmetics.api.events.PlayerEmoteStartEvent;
|
||||
import com.hibiscusmc.hmccosmetics.config.Wardrobe;
|
||||
import com.hibiscusmc.hmccosmetics.config.WardrobeSettings;
|
||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||
@@ -12,7 +11,6 @@ import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
||||
import com.sk89q.worldguard.protection.regions.RegionContainer;
|
||||
import com.sk89q.worldguard.protection.regions.RegionQuery;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
@@ -79,23 +77,6 @@ public class WGListener implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL)
|
||||
public void onPlayerEmote(PlayerEmoteStartEvent event) {
|
||||
Player player = event.getUser().getPlayer();
|
||||
if (player == null) return;
|
||||
Location location = player.getLocation();
|
||||
ApplicableRegionSet set = getRegions(location);
|
||||
for (ProtectedRegion protectedRegion : set.getRegions()) {
|
||||
if (protectedRegion.getFlags().containsKey(WGHook.getEmotesEnableFlag())) {
|
||||
if (protectedRegion.getFlags().get(WGHook.getEmotesEnableFlag()).toString().equalsIgnoreCase("DENY")) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private ApplicableRegionSet getRegions(Location location) {
|
||||
com.sk89q.worldedit.util.Location loc = BukkitAdapter.adapt(location);
|
||||
RegionContainer region = WorldGuard.getInstance().getPlatform().getRegionContainer();
|
||||
|
||||
@@ -9,7 +9,6 @@ import com.hibiscusmc.hmccosmetics.database.Database;
|
||||
import com.hibiscusmc.hmccosmetics.gui.Menus;
|
||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUsers;
|
||||
import com.hibiscusmc.hmccosmetics.user.manager.UserEmoteManager;
|
||||
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.event.EventHandler;
|
||||
@@ -95,10 +94,6 @@ public class PlayerConnectionListener implements Listener {
|
||||
user.leaveWardrobe(true);
|
||||
user.getPlayer().setInvisible(false);
|
||||
}
|
||||
if (user.getUserEmoteManager().isPlayingEmote()) {
|
||||
user.getUserEmoteManager().stopEmote(UserEmoteManager.StopEmoteReason.CONNECTION);
|
||||
event.getPlayer().setInvisible(false);
|
||||
}
|
||||
Menus.removeCooldown(event.getPlayer().getUniqueId()); // Removes any menu cooldowns a player might have
|
||||
Database.save(user);
|
||||
user.destroy();
|
||||
|
||||
@@ -14,11 +14,9 @@ import com.hibiscusmc.hmccosmetics.cosmetic.CosmeticSlot;
|
||||
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticArmorType;
|
||||
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticBackpackType;
|
||||
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticBalloonType;
|
||||
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticEmoteType;
|
||||
import com.hibiscusmc.hmccosmetics.gui.Menu;
|
||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUsers;
|
||||
import com.hibiscusmc.hmccosmetics.user.manager.UserEmoteManager;
|
||||
import com.hibiscusmc.hmccosmetics.user.manager.UserWardrobeManager;
|
||||
import com.hibiscusmc.hmccosmetics.util.HMCCInventoryUtils;
|
||||
import com.hibiscusmc.hmccosmetics.util.HMCCServerUtils;
|
||||
@@ -95,10 +93,6 @@ public class PlayerGameListener implements Listener {
|
||||
CosmeticUser user = CosmeticUsers.getUser(event.getPlayer().getUniqueId());
|
||||
|
||||
if (user == null) return;
|
||||
if (event.isSneaking()) {
|
||||
user.getUserEmoteManager().stopEmote(UserEmoteManager.StopEmoteReason.SNEAK);
|
||||
}
|
||||
|
||||
if (!event.isSneaking()) return;
|
||||
if (!user.isInWardrobe()) return;
|
||||
|
||||
@@ -136,9 +130,6 @@ public class PlayerGameListener implements Listener {
|
||||
}, 2);
|
||||
|
||||
if (event.getCause().equals(PlayerTeleportEvent.TeleportCause.NETHER_PORTAL) || event.getCause().equals(PlayerTeleportEvent.TeleportCause.END_PORTAL)) return;
|
||||
if (user.getUserEmoteManager().isPlayingEmote()) {
|
||||
user.getUserEmoteManager().stopEmote(UserEmoteManager.StopEmoteReason.TELEPORT);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
||||
@@ -180,14 +171,6 @@ public class PlayerGameListener implements Listener {
|
||||
if (!(event.getEntity() instanceof Player player)) return;
|
||||
CosmeticUser user = CosmeticUsers.getUser(player);
|
||||
if (user == null) return;
|
||||
if (user.getUserEmoteManager().isPlayingEmote()) {
|
||||
if (Settings.isEmoteInvincible()) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
if (Settings.isEmoteDamageLeave()) {
|
||||
user.getUserEmoteManager().stopEmote(UserEmoteManager.StopEmoteReason.DAMAGE);
|
||||
}
|
||||
}
|
||||
if (user.isInWardrobe()) {
|
||||
if (WardrobeSettings.isPreventDamage()) {
|
||||
event.setCancelled(true);
|
||||
@@ -202,10 +185,6 @@ public class PlayerGameListener implements Listener {
|
||||
Player player = event.getPlayer();
|
||||
CosmeticUser user = CosmeticUsers.getUser(player);
|
||||
if (user == null) return;
|
||||
if (!Settings.isEmoteMoveCheck() && user.getUserEmoteManager().isPlayingEmote()) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
user.updateCosmetic(CosmeticSlot.BACKPACK);
|
||||
user.updateCosmetic(CosmeticSlot.BALLOON);
|
||||
}
|
||||
@@ -269,12 +248,6 @@ public class PlayerGameListener implements Listener {
|
||||
CosmeticUser user = CosmeticUsers.getUser(event.getPlayer().getUniqueId());
|
||||
if (user == null) return;
|
||||
// Really need to look into optimization of this
|
||||
if (user.hasCosmeticInSlot(CosmeticSlot.EMOTE) && event.getPlayer().isSneaking() && event.getPlayer().hasPermission("hmccosmetics.emote.shiftrun")) {
|
||||
CosmeticEmoteType cosmeticEmoteType = (CosmeticEmoteType) user.getCosmetic(CosmeticSlot.EMOTE);
|
||||
cosmeticEmoteType.run(user);
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
Bukkit.getScheduler().runTaskLater(HMCCosmeticsPlugin.getInstance(), () -> {
|
||||
if (user.getEntity() == null) return; // Player has likely logged off
|
||||
user.updateCosmetic(CosmeticSlot.OFFHAND);
|
||||
@@ -666,10 +639,6 @@ public class PlayerGameListener implements Listener {
|
||||
Player player = event.getPlayer();
|
||||
CosmeticUser user = CosmeticUsers.getUser(player);
|
||||
if (user == null) return;
|
||||
if (user.getUserEmoteManager().isPlayingEmote()) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
if (!user.isInWardrobe()) return;
|
||||
if (!user.getWardrobeManager().getWardrobeStatus().equals(UserWardrobeManager.WardrobeStatus.RUNNING)) return;
|
||||
|
||||
@@ -688,7 +657,7 @@ public class PlayerGameListener implements Listener {
|
||||
if (event.getPlayer() == null) return;
|
||||
CosmeticUser user = CosmeticUsers.getUser(event.getPlayer());
|
||||
if (user == null) return;
|
||||
if (user.getUserEmoteManager().isPlayingEmote() || user.isInWardrobe()) {
|
||||
if (user.isInWardrobe()) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@ import com.hibiscusmc.hmccosmetics.database.UserData;
|
||||
import com.hibiscusmc.hmccosmetics.gui.Menus;
|
||||
import com.hibiscusmc.hmccosmetics.user.manager.UserBackpackManager;
|
||||
import com.hibiscusmc.hmccosmetics.user.manager.UserBalloonManager;
|
||||
import com.hibiscusmc.hmccosmetics.user.manager.UserEmoteManager;
|
||||
import com.hibiscusmc.hmccosmetics.user.manager.UserWardrobeManager;
|
||||
import com.hibiscusmc.hmccosmetics.util.HMCCInventoryUtils;
|
||||
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||
@@ -54,8 +53,6 @@ public class CosmeticUser implements CosmeticHolder {
|
||||
private UserBalloonManager userBalloonManager;
|
||||
@Getter
|
||||
private UserBackpackManager userBackpackManager;
|
||||
@Getter
|
||||
private final UserEmoteManager userEmoteManager;
|
||||
|
||||
// Cosmetic Settings/Toggles
|
||||
private final ArrayList<HiddenReason> hiddenReason = new ArrayList<>();
|
||||
@@ -74,7 +71,6 @@ public class CosmeticUser implements CosmeticHolder {
|
||||
|
||||
public CosmeticUser(@NotNull UUID uuid) {
|
||||
this.uniqueId = uuid;
|
||||
this.userEmoteManager = new UserEmoteManager(this);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -194,7 +190,7 @@ public class CosmeticUser implements CosmeticHolder {
|
||||
|
||||
this.updateCosmetic();
|
||||
|
||||
if(isHidden() && !getUserEmoteManager().isPlayingEmote() && !playerCosmetics.isEmpty()) {
|
||||
if(isHidden() && !playerCosmetics.isEmpty()) {
|
||||
MessagesUtil.sendActionBar(getPlayer(), "hidden-cosmetics");
|
||||
}
|
||||
}
|
||||
@@ -282,9 +278,6 @@ public class CosmeticUser implements CosmeticHolder {
|
||||
if (slot == CosmeticSlot.BALLOON) {
|
||||
despawnBalloon();
|
||||
}
|
||||
if (slot == CosmeticSlot.EMOTE) {
|
||||
if (getUserEmoteManager().isPlayingEmote()) getUserEmoteManager().stopEmote(UserEmoteManager.StopEmoteReason.UNEQUIP);
|
||||
}
|
||||
colors.remove(slot);
|
||||
playerCosmetics.remove(slot);
|
||||
removeArmor(slot);
|
||||
@@ -317,7 +310,7 @@ public class CosmeticUser implements CosmeticHolder {
|
||||
|
||||
for (Cosmetic cosmetic : playerCosmetics.values()) {
|
||||
if (cosmetic instanceof CosmeticArmorType armorType) {
|
||||
if (getUserEmoteManager().isPlayingEmote() || isInWardrobe()) return;
|
||||
if (isInWardrobe()) return;
|
||||
if (!(getEntity() instanceof HumanEntity humanEntity)) return;
|
||||
|
||||
boolean requireEmpty = Settings.getSlotOption(armorType.getEquipSlot()).isRequireEmpty();
|
||||
|
||||
@@ -1,94 +0,0 @@
|
||||
package com.hibiscusmc.hmccosmetics.user.manager;
|
||||
|
||||
import com.hibiscusmc.hmccosmetics.api.events.PlayerEmoteStartEvent;
|
||||
import com.hibiscusmc.hmccosmetics.api.events.PlayerEmoteStopEvent;
|
||||
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticEmoteType;
|
||||
import com.hibiscusmc.hmccosmetics.emotes.EmoteManager;
|
||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class UserEmoteManager {
|
||||
|
||||
private CosmeticUser user;
|
||||
private UserEmoteModel model;
|
||||
private Entity textEntity;
|
||||
|
||||
public UserEmoteManager(CosmeticUser user) {
|
||||
this.user = user;
|
||||
}
|
||||
|
||||
public void playEmote(String animationId) {
|
||||
MessagesUtil.sendDebugMessages("playEmote " + animationId);
|
||||
playEmote(EmoteManager.get(animationId), null);
|
||||
}
|
||||
|
||||
public void playEmote(@NotNull CosmeticEmoteType cosmeticEmoteType) {
|
||||
MessagesUtil.sendDebugMessages("playEmote " + cosmeticEmoteType.getAnimationId());
|
||||
playEmote(EmoteManager.get(cosmeticEmoteType.getAnimationId()), cosmeticEmoteType.getText());
|
||||
}
|
||||
|
||||
public void playEmote(String emoteAnimation, String text) {
|
||||
if (isPlayingEmote()) return;
|
||||
if (user.isInWardrobe()) return;
|
||||
// API
|
||||
PlayerEmoteStartEvent event = new PlayerEmoteStartEvent(user, emoteAnimation);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
if (event.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
// Internal
|
||||
try {
|
||||
model = new UserEmoteModel(user);
|
||||
// Play animation id
|
||||
if (emoteAnimation != null) {
|
||||
model.playAnimation(emoteAnimation);
|
||||
}
|
||||
// Show the text
|
||||
if (text != null && textEntity == null) {
|
||||
// removed in 2.7.0
|
||||
//textEntity = HMCCNMSHandlers.getHandler().spawnDisplayEntity(user.getPlayer().getLocation().add(0, 3, 0), text);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isPlayingEmote() {
|
||||
if (model == null) return false;
|
||||
return model.isPlayingAnimation();
|
||||
}
|
||||
|
||||
public void stopEmote(StopEmoteReason emoteReason) {
|
||||
if (!isPlayingEmote()) return;
|
||||
// API
|
||||
PlayerEmoteStopEvent event = new PlayerEmoteStopEvent(user, emoteReason);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
if (event.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
// Internal
|
||||
model.stopAnimation();
|
||||
if (textEntity != null) {
|
||||
textEntity.remove();
|
||||
textEntity = null;
|
||||
}
|
||||
}
|
||||
|
||||
public void despawnTextEntity() {
|
||||
if (textEntity != null) {
|
||||
textEntity.remove();
|
||||
textEntity = null;
|
||||
}
|
||||
}
|
||||
|
||||
public enum StopEmoteReason {
|
||||
SNEAK,
|
||||
DAMAGE,
|
||||
CONNECTION,
|
||||
TELEPORT,
|
||||
UNEQUIP
|
||||
}
|
||||
}
|
||||
@@ -1,134 +0,0 @@
|
||||
package com.hibiscusmc.hmccosmetics.user.manager;
|
||||
|
||||
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
|
||||
import com.hibiscusmc.hmccosmetics.config.Settings;
|
||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||
import com.hibiscusmc.hmccosmetics.util.HMCCServerUtils;
|
||||
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||
import com.hibiscusmc.hmccosmetics.util.packets.HMCCPacketManager;
|
||||
import com.ticxo.playeranimator.api.model.player.PlayerModel;
|
||||
import me.lojosho.hibiscuscommons.util.ServerUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Location;
|
||||
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;
|
||||
|
||||
public class UserEmoteModel extends PlayerModel {
|
||||
|
||||
private final CosmeticUser user;
|
||||
private String emotePlaying;
|
||||
private final int armorStandId;
|
||||
private GameMode originalGamemode;
|
||||
|
||||
public UserEmoteModel(@NotNull CosmeticUser user) {
|
||||
super(user.getPlayer());
|
||||
this.user = user;
|
||||
armorStandId = ServerUtils.getNextEntityId();
|
||||
getRangeManager().setRenderDistance(Settings.getViewDistance());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void playAnimation(@NotNull String id) {
|
||||
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<Player> viewer = Collections.singletonList(user.getPlayer());
|
||||
List<Player> outsideViewers = HMCCPacketManager.getViewers(player.getLocation());
|
||||
// Send equipment packet to the player as well (Fixes Optifine still rendering armor when emoting)
|
||||
HMCCPacketManager.equipmentSlotUpdate(player, true, outsideViewers);
|
||||
outsideViewers.remove(player);
|
||||
|
||||
user.getPlayer().setInvisible(true);
|
||||
user.hideCosmetics(CosmeticUser.HiddenReason.EMOTE);
|
||||
|
||||
originalGamemode = player.getGameMode();
|
||||
|
||||
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");
|
||||
}
|
||||
|
||||
HMCCPacketManager.sendEntitySpawnPacket(thirdPersonLocation, armorStandId, EntityType.ARMOR_STAND, UUID.randomUUID(), viewer);
|
||||
HMCCPacketManager.sendInvisibilityPacket(armorStandId, viewer);
|
||||
HMCCPacketManager.sendLookPacket(armorStandId, thirdPersonLocation, viewer);
|
||||
|
||||
HMCCPacketManager.gamemodeChangePacket(player, 3);
|
||||
HMCCPacketManager.sendCameraPacket(armorStandId, viewer);
|
||||
}
|
||||
|
||||
|
||||
MessagesUtil.sendDebugMessages("playAnimation run");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean update() {
|
||||
if (super.getAnimationProperty() == null) {
|
||||
stopAnimation();
|
||||
return false;
|
||||
}
|
||||
boolean update = (super.update() && isPlayingAnimation());
|
||||
if (!update) {
|
||||
stopAnimation();
|
||||
}
|
||||
return update;
|
||||
}
|
||||
|
||||
public void stopAnimation() {
|
||||
emotePlaying = null;
|
||||
despawn();
|
||||
Bukkit.getScheduler().runTask(HMCCosmeticsPlugin.getInstance(), () -> {
|
||||
Player player = user.getPlayer();
|
||||
if (player == null) return;
|
||||
|
||||
List<Player> viewer = Collections.singletonList(player);
|
||||
List<Player> outsideViewers = HMCCPacketManager.getViewers(player.getLocation());
|
||||
// Send Equipment packet to all (Fixes Optifine Issue)
|
||||
HMCCPacketManager.equipmentSlotUpdate(player, false, outsideViewers);
|
||||
outsideViewers.remove(player);
|
||||
|
||||
int entityId = player.getEntityId();
|
||||
HMCCPacketManager.sendCameraPacket(entityId, viewer);
|
||||
HMCCPacketManager.sendEntityDestroyPacket(armorStandId, viewer);
|
||||
if (this.originalGamemode != null) {
|
||||
HMCCPacketManager.gamemodeChangePacket(player, HMCCServerUtils.convertGamemode(this.originalGamemode));
|
||||
player.setGameMode(this.originalGamemode);
|
||||
}
|
||||
|
||||
if (user.getPlayer() != null) player.setInvisible(false);
|
||||
user.getUserEmoteManager().despawnTextEntity();
|
||||
user.showPlayer();
|
||||
user.showCosmetics(CosmeticUser.HiddenReason.EMOTE);
|
||||
});
|
||||
}
|
||||
|
||||
public boolean isPlayingAnimation() {
|
||||
return emotePlaying != null;
|
||||
}
|
||||
}
|
||||
@@ -40,17 +40,6 @@ cosmetic-settings:
|
||||
gamemodes:
|
||||
- "SPECTATOR"
|
||||
|
||||
# This disables the entire internal emote system within the plugin. This option requires a restart.
|
||||
emote-enable: true
|
||||
emote-distance: -3 # This shows how far away the camera should be while a player is doing an emote. Negative is behind player.
|
||||
emote-block-check: true # If the server should check if the block is open where the camera is placed (prevents players viewing through blocks)
|
||||
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
|
||||
# If a player should be able to move in an emote. This option really only affects if "emote-camera" is false
|
||||
emote-move: false
|
||||
# This make it so it always sends the riding packets for the backpack. This sends more packets but is more reliable for servers which modify player passengers.
|
||||
backpack-force-riding-packet: false
|
||||
# This prevents the backpack from being dark when the player is below a block at the expense of making the backpack bright
|
||||
|
||||
Reference in New Issue
Block a user