From 1b7462becc1d509668271f6d8fa4a0eb16a698ca Mon Sep 17 00:00:00 2001 From: Craftinators Date: Fri, 24 Feb 2023 13:33:45 -0500 Subject: [PATCH] clean: several annotation & naming changes --- .../hmccosmetics/command/CosmeticCommand.java | 2 +- .../hmccosmetics/cosmetic/Cosmetics.java | 10 ++++-- .../cosmetic/types/CosmeticBackpackType.java | 10 +++--- .../hmccosmetics/database/Database.java | 10 +++--- .../hmccosmetics/database/types/Data.java | 7 ++-- .../database/types/InternalData.java | 5 +-- .../database/types/MySQLData.java | 10 ++---- .../database/types/SQLiteData.java | 13 ++----- .../listener/PlayerGameListener.java | 3 +- .../hmccosmetics/user/CosmeticUser.java | 4 +-- .../user/manager/UserBackpackManager.java | 34 +++++++++---------- .../user/manager/UserBalloonManager.java | 5 +-- .../user/manager/UserEmoteManager.java | 3 +- .../user/manager/UserEmoteModel.java | 27 +++++++-------- .../user/manager/UserWardrobeManager.java | 12 +++---- 15 files changed, 74 insertions(+), 81 deletions(-) diff --git a/common/src/main/java/com/hibiscusmc/hmccosmetics/command/CosmeticCommand.java b/common/src/main/java/com/hibiscusmc/hmccosmetics/command/CosmeticCommand.java index 8e77eea3..b5677e46 100644 --- a/common/src/main/java/com/hibiscusmc/hmccosmetics/command/CosmeticCommand.java +++ b/common/src/main/java/com/hibiscusmc/hmccosmetics/command/CosmeticCommand.java @@ -322,7 +322,7 @@ public class CosmeticCommand implements CommandExecutor { } player.sendMessage("Passengers -> " + player.getPassengers()); if (user.hasCosmeticInSlot(CosmeticSlot.BACKPACK)) { - player.sendMessage("Backpack Location -> " + user.getUserBackpackManager().getArmorstand().getLocation()); + player.sendMessage("Backpack Location -> " + user.getUserBackpackManager().getArmorStand().getLocation()); } player.sendMessage("Cosmetics -> " + user.getCosmetic()); player.sendMessage("EntityId -> " + player.getEntityId()); diff --git a/common/src/main/java/com/hibiscusmc/hmccosmetics/cosmetic/Cosmetics.java b/common/src/main/java/com/hibiscusmc/hmccosmetics/cosmetic/Cosmetics.java index c81e409f..2a743eaf 100644 --- a/common/src/main/java/com/hibiscusmc/hmccosmetics/cosmetic/Cosmetics.java +++ b/common/src/main/java/com/hibiscusmc/hmccosmetics/cosmetic/Cosmetics.java @@ -6,6 +6,8 @@ import com.hibiscusmc.hmccosmetics.config.Settings; import com.hibiscusmc.hmccosmetics.cosmetic.types.*; import com.hibiscusmc.hmccosmetics.util.MessagesUtil; import org.apache.commons.lang3.EnumUtils; +import org.jetbrains.annotations.Contract; +import org.jetbrains.annotations.NotNull; import org.spongepowered.configurate.CommentedConfigurationNode; import org.spongepowered.configurate.ConfigurateException; import org.spongepowered.configurate.ConfigurationNode; @@ -17,7 +19,7 @@ import java.util.logging.Level; public class Cosmetics { - private static HashBiMap COSMETICS = HashBiMap.create(); + private static final HashBiMap COSMETICS = HashBiMap.create(); public static void addCosmetic(Cosmetic cosmetic) { COSMETICS.put(cosmetic.getId(), cosmetic); @@ -35,10 +37,14 @@ public class Cosmetics { return COSMETICS.get(id); } + @Contract(pure = true) + @NotNull public static Set values() { return COSMETICS.values(); } + @Contract(pure = true) + @NotNull public static Set keys() { return COSMETICS.keySet(); } @@ -76,7 +82,7 @@ public class Cosmetics { } } - private static void setupCosmetics(CommentedConfigurationNode config) { + private static void setupCosmetics(@NotNull CommentedConfigurationNode config) { for (ConfigurationNode cosmeticConfig : config.childrenMap().values()) { try { String id = cosmeticConfig.key().toString(); diff --git a/common/src/main/java/com/hibiscusmc/hmccosmetics/cosmetic/types/CosmeticBackpackType.java b/common/src/main/java/com/hibiscusmc/hmccosmetics/cosmetic/types/CosmeticBackpackType.java index 660381ce..374bcaa6 100644 --- a/common/src/main/java/com/hibiscusmc/hmccosmetics/cosmetic/types/CosmeticBackpackType.java +++ b/common/src/main/java/com/hibiscusmc/hmccosmetics/cosmetic/types/CosmeticBackpackType.java @@ -29,15 +29,15 @@ public class CosmeticBackpackType extends Cosmetic { Location loc = player.getLocation().clone().add(0, 2, 0); if (user.isInWardrobe() || !user.isBackupSpawned()) return; - if (loc.getWorld() != user.getUserBackpackManager().getArmorstand().getWorld()) { - user.getUserBackpackManager().getArmorstand().teleport(loc); + if (loc.getWorld() != user.getUserBackpackManager().getArmorStand().getWorld()) { + user.getUserBackpackManager().getArmorStand().teleport(loc); } - user.getUserBackpackManager().getArmorstand().teleport(loc); + user.getUserBackpackManager().getArmorStand().teleport(loc); - PacketManager.sendRidingPacket(player.getEntityId(), user.getUserBackpackManager().getFirstArmorstandId(), loc); + PacketManager.sendRidingPacket(player.getEntityId(), user.getUserBackpackManager().getFirstArmorStandId(), loc); - user.getUserBackpackManager().getArmorstand().setRotation(loc.getYaw(), loc.getPitch()); + user.getUserBackpackManager().getArmorStand().setRotation(loc.getYaw(), loc.getPitch()); user.getUserBackpackManager().showBackpack(); } diff --git a/common/src/main/java/com/hibiscusmc/hmccosmetics/database/Database.java b/common/src/main/java/com/hibiscusmc/hmccosmetics/database/Database.java index 83bda8fb..1074469b 100644 --- a/common/src/main/java/com/hibiscusmc/hmccosmetics/database/Database.java +++ b/common/src/main/java/com/hibiscusmc/hmccosmetics/database/Database.java @@ -16,22 +16,20 @@ public class Database { private static Data data; + @Deprecated private static InternalData INTERNAL_DATA = new InternalData(); - private static MySQLData MYSQL_DATA = new MySQLData(); - private static SQLiteData SQLITE_DATA = new SQLiteData(); + + private static final MySQLData MYSQL_DATA = new MySQLData(); + private static final SQLiteData SQLITE_DATA = new SQLiteData(); public Database() { String databaseType = DatabaseSettings.getDatabaseType(); data = INTERNAL_DATA; // default - if (databaseType.equalsIgnoreCase("INTERNAL")) { - data = INTERNAL_DATA; - } if (databaseType.equalsIgnoreCase("MySQL")) { data = MYSQL_DATA; } if (databaseType.equalsIgnoreCase("sqlite")) { data = SQLITE_DATA; - } MessagesUtil.sendDebugMessages("Database is " + data); diff --git a/common/src/main/java/com/hibiscusmc/hmccosmetics/database/types/Data.java b/common/src/main/java/com/hibiscusmc/hmccosmetics/database/types/Data.java index 1a2e2301..5c4c2431 100644 --- a/common/src/main/java/com/hibiscusmc/hmccosmetics/database/types/Data.java +++ b/common/src/main/java/com/hibiscusmc/hmccosmetics/database/types/Data.java @@ -10,6 +10,7 @@ import com.hibiscusmc.hmccosmetics.util.MessagesUtil; import org.apache.commons.lang3.EnumUtils; import org.bukkit.Bukkit; import org.bukkit.Color; +import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.util.HashMap; @@ -36,7 +37,7 @@ public class Data { // Override } // BACKPACK=colorfulbackpack&RRGGBB,HELMET=niftyhat,BALLOON=colorfulballoon,CHESTPLATE=niftychestplate - public String steralizeData(CosmeticUser user) { + public String serializeData(@NotNull CosmeticUser user) { String data = ""; if (user.getHidden()) { if (shouldHiddenSave(user.getHiddenReason())) { @@ -56,7 +57,7 @@ public class Data { return data; } - public Map> desteralizedata(CosmeticUser user, String raw) { + public Map> deserializeData(CosmeticUser user, @NotNull String raw) { Map> cosmetics = new HashMap<>(); boolean checkPermission = Settings.getForcePermissionJoin(); @@ -102,7 +103,7 @@ public class Data { return cosmetics; } - private boolean shouldHiddenSave(CosmeticUser.HiddenReason reason) { + private boolean shouldHiddenSave(CosmeticUser.@NotNull HiddenReason reason) { switch (reason) { case EMOTE, NONE -> { return false; diff --git a/common/src/main/java/com/hibiscusmc/hmccosmetics/database/types/InternalData.java b/common/src/main/java/com/hibiscusmc/hmccosmetics/database/types/InternalData.java index 2651bbf6..83143c89 100644 --- a/common/src/main/java/com/hibiscusmc/hmccosmetics/database/types/InternalData.java +++ b/common/src/main/java/com/hibiscusmc/hmccosmetics/database/types/InternalData.java @@ -14,6 +14,7 @@ import org.bukkit.persistence.PersistentDataType; import java.util.Map; import java.util.UUID; +@Deprecated public class InternalData extends Data { NamespacedKey key = new NamespacedKey(HMCCosmeticsPlugin.getInstance(), "cosmetics"); @@ -27,7 +28,7 @@ public class InternalData extends Data { public void save(CosmeticUser user) { Player player = Bukkit.getPlayer(user.getUniqueId()); - player.getPersistentDataContainer().set(key, PersistentDataType.STRING, steralizeData(user)); + player.getPersistentDataContainer().set(key, PersistentDataType.STRING, serializeData(user)); } @Override @@ -38,7 +39,7 @@ public class InternalData extends Data { if (!player.getPersistentDataContainer().has(key, PersistentDataType.STRING)) return user; String rawData = player.getPersistentDataContainer().get(key, PersistentDataType.STRING); - Map> a = desteralizedata(user, rawData); + Map> a = deserializeData(user, rawData); for (Map cosmeticColors : a.values()) { for (Cosmetic cosmetic : cosmeticColors.keySet()) { Bukkit.getScheduler().runTask(HMCCosmeticsPlugin.getInstance(), () -> { diff --git a/common/src/main/java/com/hibiscusmc/hmccosmetics/database/types/MySQLData.java b/common/src/main/java/com/hibiscusmc/hmccosmetics/database/types/MySQLData.java index 8426da2f..6ae60580 100644 --- a/common/src/main/java/com/hibiscusmc/hmccosmetics/database/types/MySQLData.java +++ b/common/src/main/java/com/hibiscusmc/hmccosmetics/database/types/MySQLData.java @@ -58,7 +58,7 @@ public class MySQLData extends Data { try { PreparedStatement preparedSt = preparedStatement("REPLACE INTO COSMETICDATABASE(UUID,COSMETICS) VALUES(?,?);"); preparedSt.setString(1, user.getUniqueId().toString()); - preparedSt.setString(2, steralizeData(user)); + preparedSt.setString(2, serializeData(user)); preparedSt.executeUpdate(); } catch (SQLException e) { throw new RuntimeException(e); @@ -82,7 +82,7 @@ public class MySQLData extends Data { ResultSet rs = preparedStatement.executeQuery(); if (rs.next()) { String rawData = rs.getString("COSMETICS"); - Map> cosmetics = desteralizedata(user, rawData); + Map> cosmetics = deserializeData(user, rawData); for (Map cosmeticColors : cosmetics.values()) { for (Cosmetic cosmetic : cosmeticColors.keySet()) { Bukkit.getScheduler().runTask(HMCCosmeticsPlugin.getInstance(), () -> { @@ -160,11 +160,7 @@ public class MySQLData extends Data { private boolean isConnectionOpen() { try { - if (connection == null || connection.isClosed()) { - return false; - } else { - return true; - } + return connection != null && !connection.isClosed(); } catch (SQLException e) { throw new RuntimeException(e); } diff --git a/common/src/main/java/com/hibiscusmc/hmccosmetics/database/types/SQLiteData.java b/common/src/main/java/com/hibiscusmc/hmccosmetics/database/types/SQLiteData.java index 52a3d1be..63a690e5 100644 --- a/common/src/main/java/com/hibiscusmc/hmccosmetics/database/types/SQLiteData.java +++ b/common/src/main/java/com/hibiscusmc/hmccosmetics/database/types/SQLiteData.java @@ -52,7 +52,7 @@ public class SQLiteData extends Data { try { PreparedStatement preparedSt = preparedStatement("REPLACE INTO COSMETICDATABASE(UUID,COSMETICS) VALUES(?,?);"); preparedSt.setString(1, user.getUniqueId().toString()); - preparedSt.setString(2, steralizeData(user)); + preparedSt.setString(2, serializeData(user)); preparedSt.executeUpdate(); } catch (SQLException e) { throw new RuntimeException(e); @@ -76,7 +76,7 @@ public class SQLiteData extends Data { ResultSet rs = preparedStatement.executeQuery(); if (rs.next()) { String rawData = rs.getString("COSMETICS"); - Map> cosmetics = desteralizedata(user, rawData); + Map> cosmetics = deserializeData(user, rawData); for (Map cosmeticColors : cosmetics.values()) { for (Cosmetic cosmetic : cosmeticColors.keySet()) { Bukkit.getScheduler().runTask(HMCCosmeticsPlugin.getInstance(), () -> { @@ -114,9 +114,6 @@ public class SQLiteData extends Data { //Bukkit.getScheduler().runTaskAsynchronously(HMCCosmeticsPlugin.getInstance(), () -> { //close Connection if still active - if (connection != null) { - //close(); - } File dataFolder = new File(HMCCosmeticsPlugin.getInstance().getDataFolder(), "database.db"); @@ -151,11 +148,7 @@ public class SQLiteData extends Data { private boolean isConnectionOpen() { try { - if (connection == null || connection.isClosed()) { - return false; - } else { - return true; - } + return connection != null && !connection.isClosed(); } catch (SQLException e) { throw new RuntimeException(e); } 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 6c856e76..1cd42ecd 100644 --- a/common/src/main/java/com/hibiscusmc/hmccosmetics/listener/PlayerGameListener.java +++ b/common/src/main/java/com/hibiscusmc/hmccosmetics/listener/PlayerGameListener.java @@ -23,7 +23,6 @@ import com.hibiscusmc.hmccosmetics.user.CosmeticUsers; import com.hibiscusmc.hmccosmetics.util.InventoryUtils; import com.hibiscusmc.hmccosmetics.util.MessagesUtil; import org.bukkit.Bukkit; -import org.bukkit.Color; import org.bukkit.Material; import org.bukkit.NamespacedKey; import org.bukkit.entity.Entity; @@ -105,7 +104,7 @@ public class PlayerGameListener implements Listener { if (user.hasCosmeticInSlot(CosmeticSlot.BACKPACK)) { user.getUserBackpackManager().hideBackpack(); - user.getUserBackpackManager().getArmorstand().teleport(event.getTo()); + user.getUserBackpackManager().getArmorStand().teleport(event.getTo()); Bukkit.getScheduler().runTaskLater(HMCCosmeticsPlugin.getInstance(), () -> { user.updateCosmetic(); diff --git a/common/src/main/java/com/hibiscusmc/hmccosmetics/user/CosmeticUser.java b/common/src/main/java/com/hibiscusmc/hmccosmetics/user/CosmeticUser.java index 397b9317..b91e1c1e 100644 --- a/common/src/main/java/com/hibiscusmc/hmccosmetics/user/CosmeticUser.java +++ b/common/src/main/java/com/hibiscusmc/hmccosmetics/user/CosmeticUser.java @@ -401,7 +401,7 @@ public class CosmeticUser { PacketManager.sendLeashPacket(getBalloonManager().getPufferfishBalloonId(), -1, viewer); } if (hasCosmeticInSlot(CosmeticSlot.BACKPACK)) { - userBackpackManager.getArmorstand().getEquipment().clear(); + userBackpackManager.getArmorStand().getEquipment().clear(); } updateCosmetic(); MessagesUtil.sendDebugMessages("HideCosmetics"); @@ -427,7 +427,7 @@ public class CosmeticUser { if (hasCosmeticInSlot(CosmeticSlot.BACKPACK)) { CosmeticBackpackType cosmeticBackpackType = (CosmeticBackpackType) getCosmetic(CosmeticSlot.BACKPACK); ItemStack item = getUserCosmeticItem(cosmeticBackpackType); - userBackpackManager.getArmorstand().getEquipment().setHelmet(item); + userBackpackManager.getArmorStand().getEquipment().setHelmet(item); } updateCosmetic(); MessagesUtil.sendDebugMessages("ShowCosmetics"); diff --git a/common/src/main/java/com/hibiscusmc/hmccosmetics/user/manager/UserBackpackManager.java b/common/src/main/java/com/hibiscusmc/hmccosmetics/user/manager/UserBackpackManager.java index ea07078f..bd1b5aa4 100644 --- a/common/src/main/java/com/hibiscusmc/hmccosmetics/user/manager/UserBackpackManager.java +++ b/common/src/main/java/com/hibiscusmc/hmccosmetics/user/manager/UserBackpackManager.java @@ -17,8 +17,8 @@ import java.util.logging.Level; public class UserBackpackManager { private boolean hideBackpack; - private ArmorStand invisibleArmorstand; - private CosmeticUser user; + private ArmorStand invisibleArmorStand; + private final CosmeticUser user; private BackpackType backpackType; public UserBackpackManager(CosmeticUser user) { @@ -27,27 +27,27 @@ public class UserBackpackManager { backpackType = BackpackType.NORMAL; } - public int getFirstArmorstandId() { - return invisibleArmorstand.getEntityId(); + public int getFirstArmorStandId() { + return invisibleArmorStand.getEntityId(); } - public ArmorStand getArmorstand() { - return invisibleArmorstand; + public ArmorStand getArmorStand() { + return invisibleArmorStand; } public void spawnBackpack(CosmeticBackpackType cosmeticBackpackType) { MessagesUtil.sendDebugMessages("spawnBackpack Bukkit - Start"); - if (this.invisibleArmorstand != null) return; + if (this.invisibleArmorStand != null) return; - this.invisibleArmorstand = (ArmorStand) NMSHandlers.getHandler().spawnBackpack(user, cosmeticBackpackType); + this.invisibleArmorStand = (ArmorStand) NMSHandlers.getHandler().spawnBackpack(user, cosmeticBackpackType); if (cosmeticBackpackType.getModelName() != null && HMCCosmeticsPlugin.hasModelEngine()) { if (ModelEngineAPI.api.getModelRegistry().getBlueprint(cosmeticBackpackType.getModelName()) == null) { MessagesUtil.sendDebugMessages("Invalid Model Engine Blueprint " + cosmeticBackpackType.getModelName(), Level.SEVERE); return; } - ModeledEntity modeledEntity = ModelEngineAPI.getOrCreateModeledEntity(invisibleArmorstand); + ModeledEntity modeledEntity = ModelEngineAPI.getOrCreateModeledEntity(invisibleArmorStand); ActiveModel model = ModelEngineAPI.createActiveModel(ModelEngineAPI.getBlueprint(cosmeticBackpackType.getModelName())); model.setCanHurt(false); modeledEntity.addModel(model, false); @@ -57,23 +57,23 @@ public class UserBackpackManager { } public void despawnBackpack() { - if (invisibleArmorstand == null) return; - invisibleArmorstand.setHealth(0); - invisibleArmorstand.remove(); - this.invisibleArmorstand = null; + if (invisibleArmorStand == null) return; + invisibleArmorStand.setHealth(0); + invisibleArmorStand.remove(); + this.invisibleArmorStand = null; } public void hideBackpack() { - if (user.getHidden() == true) return; - getArmorstand().getEquipment().clear(); + if (user.getHidden()) return; + getArmorStand().getEquipment().clear(); hideBackpack = true; } public void showBackpack() { - if (hideBackpack == false) return; + if (!hideBackpack) return; CosmeticBackpackType cosmeticBackpackType = (CosmeticBackpackType) user.getCosmetic(CosmeticSlot.BACKPACK); ItemStack item = user.getUserCosmeticItem(cosmeticBackpackType); - getArmorstand().getEquipment().setHelmet(item); + getArmorStand().getEquipment().setHelmet(item); hideBackpack = false; } diff --git a/common/src/main/java/com/hibiscusmc/hmccosmetics/user/manager/UserBalloonManager.java b/common/src/main/java/com/hibiscusmc/hmccosmetics/user/manager/UserBalloonManager.java index d8f2eada..7c544b3c 100644 --- a/common/src/main/java/com/hibiscusmc/hmccosmetics/user/manager/UserBalloonManager.java +++ b/common/src/main/java/com/hibiscusmc/hmccosmetics/user/manager/UserBalloonManager.java @@ -15,6 +15,7 @@ import org.bukkit.entity.ArmorStand; import org.bukkit.entity.Entity; import org.bukkit.entity.Player; import org.bukkit.util.Vector; +import org.jetbrains.annotations.NotNull; import java.util.UUID; import java.util.logging.Level; @@ -26,13 +27,13 @@ public class UserBalloonManager { private final UUID uniqueID; private final ArmorStand modelEntity; - public UserBalloonManager(Location location) { + public UserBalloonManager(@NotNull Location location) { this.uniqueID = UUID.randomUUID(); this.balloonID = NMSHandlers.getHandler().getNextEntityId(); this.modelEntity = NMSHandlers.getHandler().getMEGEntity(location.add(Settings.getBalloonOffset())); } - public void spawnModel(CosmeticBalloonType cosmeticBalloonType, Color color) { + public void spawnModel(@NotNull CosmeticBalloonType cosmeticBalloonType, Color color) { // redo this if (cosmeticBalloonType.getModelName() != null && HMCCosmeticsPlugin.hasModelEngine()) { balloonType = BalloonType.MODELENGINE; diff --git a/common/src/main/java/com/hibiscusmc/hmccosmetics/user/manager/UserEmoteManager.java b/common/src/main/java/com/hibiscusmc/hmccosmetics/user/manager/UserEmoteManager.java index b4a9ae4d..8e4cc462 100644 --- a/common/src/main/java/com/hibiscusmc/hmccosmetics/user/manager/UserEmoteManager.java +++ b/common/src/main/java/com/hibiscusmc/hmccosmetics/user/manager/UserEmoteManager.java @@ -3,6 +3,7 @@ package com.hibiscusmc.hmccosmetics.user.manager; import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticEmoteType; import com.hibiscusmc.hmccosmetics.user.CosmeticUser; import com.hibiscusmc.hmccosmetics.util.MessagesUtil; +import org.jetbrains.annotations.NotNull; public class UserEmoteManager { @@ -13,7 +14,7 @@ public class UserEmoteManager { this.user = user; } - public void playEmote(CosmeticEmoteType cosmeticEmoteType) { + public void playEmote(@NotNull CosmeticEmoteType cosmeticEmoteType) { MessagesUtil.sendDebugMessages("playEmote " + cosmeticEmoteType.getAnimationId()); playEmote(cosmeticEmoteType.getAnimationId()); } 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 0decd824..dd171510 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 @@ -14,29 +14,27 @@ import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.entity.EntityType; import org.bukkit.entity.Player; -import org.bukkit.inventory.EquipmentSlot; -import org.bukkit.inventory.ItemStack; +import org.jetbrains.annotations.NotNull; -import java.util.HashMap; import java.util.List; import java.util.UUID; public class UserEmoteModel extends PlayerModel { - private CosmeticUser user; + private final CosmeticUser user; private String emotePlaying; - private int armorstandId; + private final int armorStandId; private GameMode originalGamemode; - public UserEmoteModel(CosmeticUser user) { + public UserEmoteModel(@NotNull CosmeticUser user) { super(user.getPlayer()); this.user = user; - armorstandId = NMSHandlers.getHandler().getNextEntityId(); + armorStandId = NMSHandlers.getHandler().getNextEntityId(); getRangeManager().setRenderDistance(Settings.getViewDistance()); } @Override - public void playAnimation(String id) { + public void playAnimation(@NotNull String id) { if (id.contains(":")) id = id.split(":", 2)[1]; if (!id.contains(".")) id = id + "." + id + "." + id; // Make into a format that playerAnimator works with. Requires 3 splits. super.playAnimation(id); @@ -63,12 +61,12 @@ public class UserEmoteModel extends PlayerModel { originalGamemode = player.getGameMode(); - PacketManager.sendEntitySpawnPacket(thirdPersonLocation, armorstandId, EntityType.ARMOR_STAND, UUID.randomUUID(), viewer); - PacketManager.sendInvisibilityPacket(armorstandId, viewer); - PacketManager.sendLookPacket(armorstandId, player.getLocation(), viewer); + PacketManager.sendEntitySpawnPacket(thirdPersonLocation, armorStandId, EntityType.ARMOR_STAND, UUID.randomUUID(), viewer); + PacketManager.sendInvisibilityPacket(armorStandId, viewer); + PacketManager.sendLookPacket(armorStandId, player.getLocation(), viewer); PacketManager.gamemodeChangePacket(player, 3); - PacketManager.sendCameraPacket(armorstandId, viewer); + PacketManager.sendCameraPacket(armorStandId, viewer); MessagesUtil.sendDebugMessages("playAnimation run"); } @@ -99,7 +97,7 @@ public class UserEmoteModel extends PlayerModel { int entityId = player.getEntityId(); PacketManager.sendCameraPacket(entityId, viewer); - PacketManager.sendEntityDestroyPacket(armorstandId, viewer); + PacketManager.sendEntityDestroyPacket(armorStandId, viewer); if (this.originalGamemode != null) { PacketManager.gamemodeChangePacket(player, ServerUtils.convertGamemode(this.originalGamemode)); player.setGameMode(this.originalGamemode); @@ -113,7 +111,6 @@ public class UserEmoteModel extends PlayerModel { } public boolean isPlayingAnimation() { - if (emotePlaying == null) return false; - return true; + return emotePlaying != null; } } diff --git a/common/src/main/java/com/hibiscusmc/hmccosmetics/user/manager/UserWardrobeManager.java b/common/src/main/java/com/hibiscusmc/hmccosmetics/user/manager/UserWardrobeManager.java index e7db2a19..8dfe6730 100644 --- a/common/src/main/java/com/hibiscusmc/hmccosmetics/user/manager/UserWardrobeManager.java +++ b/common/src/main/java/com/hibiscusmc/hmccosmetics/user/manager/UserWardrobeManager.java @@ -114,8 +114,8 @@ public class UserWardrobeManager { // Misc if (user.hasCosmeticInSlot(CosmeticSlot.BACKPACK)) { - user.getUserBackpackManager().getArmorstand().teleport(npcLocation.clone().add(0, 2, 0)); - PacketManager.ridingMountPacket(NPC_ID, user.getUserBackpackManager().getFirstArmorstandId(), viewer); + user.getUserBackpackManager().getArmorStand().teleport(npcLocation.clone().add(0, 2, 0)); + PacketManager.ridingMountPacket(NPC_ID, user.getUserBackpackManager().getFirstArmorStandId(), viewer); } if (user.hasCosmeticInSlot(CosmeticSlot.BALLOON)) { @@ -251,10 +251,10 @@ public class UserWardrobeManager { } if (user.hasCosmeticInSlot(CosmeticSlot.BACKPACK)) { - PacketManager.sendTeleportPacket(user.getUserBackpackManager().getFirstArmorstandId(), location, false, viewer); - PacketManager.ridingMountPacket(NPC_ID, user.getUserBackpackManager().getFirstArmorstandId(), viewer); - user.getUserBackpackManager().getArmorstand().setRotation(nextyaw, 0); - PacketManager.sendEntityDestroyPacket(user.getUserBackpackManager().getFirstArmorstandId(), outsideViewers); + PacketManager.sendTeleportPacket(user.getUserBackpackManager().getFirstArmorStandId(), location, false, viewer); + PacketManager.ridingMountPacket(NPC_ID, user.getUserBackpackManager().getFirstArmorStandId(), viewer); + user.getUserBackpackManager().getArmorStand().setRotation(nextyaw, 0); + PacketManager.sendEntityDestroyPacket(user.getUserBackpackManager().getFirstArmorStandId(), outsideViewers); } if (user.hasCosmeticInSlot(CosmeticSlot.BALLOON)) {