From 51188fdeba8e9676c8800e5a83a271b50e4836f1 Mon Sep 17 00:00:00 2001 From: LoJoSho Date: Fri, 22 Dec 2023 21:25:50 -0600 Subject: [PATCH] feat: move to Hibiscus Commmons library --- build.gradle.kts | 44 ++--- common/build.gradle.kts | 30 ---- .../hmccosmetics/HMCCosmeticsPlugin.java | 108 +++--------- .../hmccosmetics/api/HMCCosmeticsAPI.java | 4 +- .../hmccosmetics/command/CosmeticCommand.java | 2 +- .../command/CosmeticCommandTabComplete.java | 2 +- .../hmccosmetics/config/DatabaseSettings.java | 2 +- .../hmccosmetics/config/Settings.java | 2 +- .../hmccosmetics/config/WardrobeSettings.java | 4 +- .../config/serializer/ItemSerializer.java | 165 ------------------ .../config/serializer/LocationSerializer.java | 46 ----- .../hmccosmetics/cosmetic/Cosmetic.java | 6 +- .../hmccosmetics/cosmetic/Cosmetics.java | 8 +- .../cosmetic/types/CosmeticArmorType.java | 13 +- .../cosmetic/types/CosmeticBackpackType.java | 24 +-- .../cosmetic/types/CosmeticBalloonType.java | 14 +- .../cosmetic/types/CosmeticEmoteType.java | 2 +- .../cosmetic/types/CosmeticMainhandType.java | 6 +- .../hmccosmetics/database/types/SQLData.java | 2 +- .../com/hibiscusmc/hmccosmetics/gui/Menu.java | 12 +- .../hibiscusmc/hmccosmetics/gui/MenuItem.java | 2 +- .../hibiscusmc/hmccosmetics/gui/Menus.java | 6 +- .../action/actions/ActionConsoleCommand.java | 2 +- .../gui/action/actions/ActionParticle.java | 4 +- .../action/actions/ActionPlayerCommand.java | 2 +- .../hmccosmetics/gui/special/DyeMenu.java | 2 +- .../hmccosmetics/gui/type/Type.java | 2 +- .../gui/type/types/TypeCosmetic.java | 8 +- .../gui/type/types/TypeEmpty.java | 6 +- .../hibiscusmc/hmccosmetics/hooks/Hook.java | 100 ----------- .../hmccosmetics/hooks/HookFlag.java | 5 - .../hibiscusmc/hmccosmetics/hooks/Hooks.java | 89 ---------- .../hmccosmetics/hooks/items/HookDenizen.java | 27 --- .../hmccosmetics/hooks/items/HookEco.java | 18 -- .../hmccosmetics/hooks/items/HookGeary.java | 28 --- .../hooks/items/HookHMCCosmetics.java | 4 +- .../hooks/items/HookItemAdder.java | 47 ----- .../hooks/items/HookMMOItems.java | 22 --- .../hmccosmetics/hooks/items/HookMythic.java | 25 --- .../hmccosmetics/hooks/items/HookOraxen.java | 28 --- .../hmccosmetics/hooks/misc/HookCMI.java | 36 ---- .../hmccosmetics/hooks/misc/HookHMCColor.java | 12 -- .../hooks/misc/HookLibsDisguises.java | 33 ---- .../hooks/misc/HookModelEngine.java | 10 -- .../hooks/misc/HookPremiumVanish.java | 38 ---- .../hooks/misc/HookSuperVanish.java | 38 ---- .../placeholders/HookPlaceholderAPI.java | 20 --- .../listener/PlayerConnectionListener.java | 4 +- .../listener/PlayerGameListener.java | 47 +++-- .../{NMSHandler.java => HMCCNMSHandler.java} | 9 +- ...{NMSHandlers.java => HMCCNMSHandlers.java} | 8 +- .../hmccosmetics/user/CosmeticUser.java | 27 +-- .../user/manager/UserBackpackManager.java | 39 +++-- .../user/manager/UserBalloonManager.java | 15 +- .../user/manager/UserBalloonPufferfish.java | 12 +- .../user/manager/UserEmoteManager.java | 4 +- .../user/manager/UserEmoteModel.java | 31 ++-- .../hmccosmetics/user/manager/UserEntity.java | 12 +- .../user/manager/UserWardrobeManager.java | 74 ++++---- ...toryUtils.java => HMCCInventoryUtils.java} | 14 +- .../hmccosmetics/util/MessagesUtil.java | 6 +- .../hmccosmetics/util/PlayerUtils.java | 12 +- .../hmccosmetics/util/ServerUtils.java | 2 +- .../hmccosmetics/util/TranslationUtil.java | 4 +- .../util/builder/ColorBuilder.java | 39 ----- .../hmccosmetics/util/misc/Adventure.java | 18 -- .../hmccosmetics/util/misc/StringUtils.java | 21 --- ...ketManager.java => HMCCPacketManager.java} | 141 ++------------- .../wrappers/WrapperPlayServerPlayerInfo.java | 4 +- .../{NMSHandler.java => HMCCNMSHandler.java} | 25 +-- .../{NMSHandler.java => HMCCNMSHandler.java} | 25 +-- .../{NMSHandler.java => HMCCNMSHandler.java} | 25 +-- .../{NMSHandler.java => HMCCNMSHandler.java} | 26 +-- .../{NMSHandler.java => HMCCNMSHandler.java} | 25 +-- .../{NMSHandler.java => HMCCNMSHandler.java} | 25 +-- .../{NMSHandler.java => HMCCNMSHandler.java} | 25 +-- 76 files changed, 291 insertions(+), 1538 deletions(-) delete mode 100644 common/src/main/java/com/hibiscusmc/hmccosmetics/config/serializer/ItemSerializer.java delete mode 100644 common/src/main/java/com/hibiscusmc/hmccosmetics/config/serializer/LocationSerializer.java delete mode 100644 common/src/main/java/com/hibiscusmc/hmccosmetics/hooks/Hook.java delete mode 100644 common/src/main/java/com/hibiscusmc/hmccosmetics/hooks/HookFlag.java delete mode 100644 common/src/main/java/com/hibiscusmc/hmccosmetics/hooks/Hooks.java delete mode 100644 common/src/main/java/com/hibiscusmc/hmccosmetics/hooks/items/HookDenizen.java delete mode 100644 common/src/main/java/com/hibiscusmc/hmccosmetics/hooks/items/HookEco.java delete mode 100644 common/src/main/java/com/hibiscusmc/hmccosmetics/hooks/items/HookGeary.java delete mode 100644 common/src/main/java/com/hibiscusmc/hmccosmetics/hooks/items/HookItemAdder.java delete mode 100644 common/src/main/java/com/hibiscusmc/hmccosmetics/hooks/items/HookMMOItems.java delete mode 100644 common/src/main/java/com/hibiscusmc/hmccosmetics/hooks/items/HookMythic.java delete mode 100644 common/src/main/java/com/hibiscusmc/hmccosmetics/hooks/items/HookOraxen.java delete mode 100644 common/src/main/java/com/hibiscusmc/hmccosmetics/hooks/misc/HookCMI.java delete mode 100644 common/src/main/java/com/hibiscusmc/hmccosmetics/hooks/misc/HookHMCColor.java delete mode 100644 common/src/main/java/com/hibiscusmc/hmccosmetics/hooks/misc/HookLibsDisguises.java delete mode 100644 common/src/main/java/com/hibiscusmc/hmccosmetics/hooks/misc/HookModelEngine.java delete mode 100644 common/src/main/java/com/hibiscusmc/hmccosmetics/hooks/misc/HookPremiumVanish.java delete mode 100644 common/src/main/java/com/hibiscusmc/hmccosmetics/hooks/misc/HookSuperVanish.java delete mode 100644 common/src/main/java/com/hibiscusmc/hmccosmetics/hooks/placeholders/HookPlaceholderAPI.java rename common/src/main/java/com/hibiscusmc/hmccosmetics/nms/{NMSHandler.java => HMCCNMSHandler.java} (77%) rename common/src/main/java/com/hibiscusmc/hmccosmetics/nms/{NMSHandlers.java => HMCCNMSHandlers.java} (85%) rename common/src/main/java/com/hibiscusmc/hmccosmetics/util/{InventoryUtils.java => HMCCInventoryUtils.java} (92%) delete mode 100644 common/src/main/java/com/hibiscusmc/hmccosmetics/util/builder/ColorBuilder.java delete mode 100644 common/src/main/java/com/hibiscusmc/hmccosmetics/util/misc/Adventure.java delete mode 100644 common/src/main/java/com/hibiscusmc/hmccosmetics/util/misc/StringUtils.java rename common/src/main/java/com/hibiscusmc/hmccosmetics/util/packets/{PacketManager.java => HMCCPacketManager.java} (74%) rename v1_18_R2/src/main/java/com/hibiscusmc/hmccosmetics/nms/v1_18_R2/{NMSHandler.java => HMCCNMSHandler.java} (84%) rename v1_19_R1/src/main/java/com/hibiscusmc/hmccosmetics/nms/v1_19_R1/{NMSHandler.java => HMCCNMSHandler.java} (84%) rename v1_19_R2/src/main/java/com/hibiscusmc/hmccosmetics/nms/v1_19_R2/{NMSHandler.java => HMCCNMSHandler.java} (84%) rename v1_19_R3/src/main/java/com/hibiscusmc/hmccosmetics/nms/v1_19_R3/{NMSHandler.java => HMCCNMSHandler.java} (85%) rename v1_20_R1/src/main/java/com/hibiscusmc/hmccosmetics/nms/v1_20_R1/{NMSHandler.java => HMCCNMSHandler.java} (86%) rename v1_20_R2/src/main/java/com/hibiscusmc/hmccosmetics/nms/v1_20_R2/{NMSHandler.java => HMCCNMSHandler.java} (86%) rename v1_20_R3/src/main/java/com/hibiscusmc/hmccosmetics/nms/v1_20_R3/{NMSHandler.java => HMCCNMSHandler.java} (86%) diff --git a/build.gradle.kts b/build.gradle.kts index 6bb1ffc7..0cdb2a75 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -66,33 +66,38 @@ allprojects { // Eco-Suite/Auxilor Repo maven("https://repo.auxilor.io/repository/maven-public/") + + // Hibiscus Commons + maven("https://repo.hibiscusmc.com/releases") } dependencies { compileOnly(fileTree("${project.rootDir}/lib") { include("*.jar") }) compileOnly("com.mojang:authlib:1.5.25") - compileOnly("org.spigotmc:spigot-api:1.18.2-R0.1-SNAPSHOT") + compileOnly("io.papermc.paper:paper-api:1.18.2-R0.1-SNAPSHOT") compileOnly("org.jetbrains:annotations:23.0.0") compileOnly("com.comphenix.protocol:ProtocolLib:5.1.0") compileOnly("me.clip:placeholderapi:2.11.3") compileOnly("com.ticxo.modelengine:ModelEngine:R4.0.2") - compileOnly("com.github.oraxen:oraxen:1.160.0") - compileOnly("com.github.LoneDev6:API-ItemsAdder:3.2.5") - compileOnly("com.mineinabyss:geary-papermc:0.27.0") compileOnly("com.sk89q.worldguard:worldguard-bukkit:7.1.0-SNAPSHOT") compileOnly("it.unimi.dsi:fastutil:8.5.11") - compileOnly("com.github.LeonMangler:SuperVanish:6.2.17") compileOnly("org.projectlombok:lombok:1.18.2") + compileOnly("me.lojosho:HibiscusCommons:0.1.6") // Handled by Spigot Library Loader - compileOnly("net.kyori:adventure-api:4.11.0") - compileOnly("net.kyori:adventure-text-minimessage:4.11.0") - compileOnly("net.kyori:adventure-platform-bukkit:4.1.2") - compileOnly("org.spongepowered:configurate-yaml:4.2.0-SNAPSHOT") + compileOnly("net.kyori:adventure-api:4.15.0") + compileOnly("net.kyori:adventure-text-minimessage:4.15.0") + compileOnly("net.kyori:adventure-platform-bukkit:4.3.1") annotationProcessor("org.projectlombok:lombok:1.18.28") testCompileOnly("org.projectlombok:lombok:1.18.28") testAnnotationProcessor("org.projectlombok:lombok:1.18.28") + + implementation("dev.triumphteam:triumph-gui:3.1.7") { + exclude("net.kyori") // Already have adventure API + } + implementation("com.owen1212055:particlehelper:1.0.0-SNAPSHOT") + implementation("com.ticxo.playeranimator:PlayerAnimator:R1.2.7") } } @@ -105,14 +110,6 @@ dependencies { implementation(project(path = ":v1_20_R1", configuration = "reobf")) implementation(project(path = ":v1_20_R2", configuration = "reobf")) implementation(project(path = ":v1_20_R3", configuration = "reobf")) - - implementation("dev.triumphteam:triumph-gui:3.1.3") - implementation("org.bstats:bstats-bukkit:3.0.2") - implementation("com.jeff_media:SpigotUpdateChecker:3.0.0") - implementation("com.owen1212055:particlehelper:1.0.0-SNAPSHOT") - implementation("com.ticxo.playeranimator:PlayerAnimator:R1.2.7") - implementation("com.github.BG-Software-LLC:CommentedConfiguration:bed3c46369") - implementation("org.spongepowered:configurate-yaml:4.2.0-SNAPSHOT") } tasks { @@ -146,12 +143,8 @@ tasks { mergeServiceFiles() relocate("dev.triumphteam.gui", "com.hisbiscusmc.hmccosmetics.gui") - relocate("org.bstats", "com.hisbiscusmc.hmccosmetics.bstats") - relocate("com.jeff_media.updatechecker", "com.hisbiscusmc.hmccosmetics.updatechecker") relocate("com.owen1212055.particlehelper", "com.hisbiscusmc.hmccosmetics.particlehelper") relocate("com.ticxo.playeranimator", "com.hisbiscusmc.hmccosmetics.playeranimator") - relocate("com.bgsoftware", "com.hisbiscusmc.hmccosmetics.configupdater") - relocate("org.spongepowered.configurate", "com.hisbiscusmc.hmccosmetics.configurate") archiveFileName.set("HMCCosmeticsRemapped-${project.version}.jar") dependencies { @@ -178,20 +171,13 @@ bukkit { main = "com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin" apiVersion = "1.18" authors = listOf("LoJoSho") - depend = listOf("ProtocolLib") + depend = listOf("HibiscusCommons", "ProtocolLib") softDepend = listOf("ModelEngine", "Oraxen", "ItemsAdder", "Geary", "HMCColor", "WorldGuard", "MythicMobs", "PlaceholderAPI", "SuperVanish", "PremiumVanish", "LibsDisguises", "Denizen", "MMOItems", "Eco") version = "${project.version}" loadBefore = listOf( "Cosmin" // Fixes an issue with Cosmin loading before and taking /cosmetic, when messing with what we do. ) - libraries = listOf( - "net.kyori:adventure-api:4.11.0", - "net.kyori:adventure-text-minimessage:4.11.0", - "net.kyori:adventure-platform-bukkit:4.1.2" - //"org.spongepowered:configurate-yaml:4.2.0-SNAPSHOT" // Readd when 4.2.0 releases - ) - commands { register("cosmetic") { description = "Base Cosmetic Command" diff --git a/common/build.gradle.kts b/common/build.gradle.kts index 24397e73..386f8098 100644 --- a/common/build.gradle.kts +++ b/common/build.gradle.kts @@ -3,36 +3,6 @@ plugins { id("maven-publish") } -dependencies { - compileOnly("com.mojang:authlib:1.5.25") - compileOnly("io.papermc.paper:paper-api:1.18.2-R0.1-SNAPSHOT") - compileOnly("org.jetbrains:annotations:23.0.0") - compileOnly("com.comphenix.protocol:ProtocolLib:5.1.0") - compileOnly("me.clip:placeholderapi:2.11.3") - compileOnly("com.ticxo.modelengine:ModelEngine:R4.0.2") - compileOnly("com.github.oraxen:oraxen:1.160.0") - compileOnly("com.github.LoneDev6:API-ItemsAdder:3.2.5") - compileOnly("com.mineinabyss:geary-papermc:0.24-SNAPSHOT") - //compileOnly("com.hibiscus:hmccolor:0.3-SNAPSHOT") USE LIB PROVIDED FILE - compileOnly("com.sk89q.worldguard:worldguard-bukkit:7.1.0-SNAPSHOT") - compileOnly("it.unimi.dsi:fastutil:8.5.11") - compileOnly("io.lumine:Mythic-Dist:5.2.1") - compileOnly("com.denizenscript:denizen:1.2.7-SNAPSHOT") - compileOnly("com.github.LeonMangler:SuperVanish:6.2.17") - compileOnly("net.Indyuce:MMOItems-API:6.9.4-SNAPSHOT") - compileOnlyApi("LibsDisguises:LibsDisguises:10.0.21") { - exclude("org.spigotmc", "spigot") - } - compileOnly("com.willfp:eco:6.67.2") - - implementation("dev.triumphteam:triumph-gui:3.1.3") - implementation("org.bstats:bstats-bukkit:3.0.0") - implementation("com.jeff_media:SpigotUpdateChecker:3.0.0") - implementation("com.owen1212055:particlehelper:1.0.0-SNAPSHOT") - implementation("com.ticxo.playeranimator:PlayerAnimator:R1.2.7") - implementation("com.github.BG-Software-LLC:CommentedConfiguration:bed3c46369") -} - java { toolchain.languageVersion.set(JavaLanguageVersion.of(17 )) diff --git a/common/src/main/java/com/hibiscusmc/hmccosmetics/HMCCosmeticsPlugin.java b/common/src/main/java/com/hibiscusmc/hmccosmetics/HMCCosmeticsPlugin.java index bb6f76fd..2767802a 100644 --- a/common/src/main/java/com/hibiscusmc/hmccosmetics/HMCCosmeticsPlugin.java +++ b/common/src/main/java/com/hibiscusmc/hmccosmetics/HMCCosmeticsPlugin.java @@ -1,96 +1,71 @@ package com.hibiscusmc.hmccosmetics; -import com.bgsoftware.common.config.CommentedConfiguration; import com.hibiscusmc.hmccosmetics.api.events.HMCCosmeticSetupEvent; import com.hibiscusmc.hmccosmetics.command.CosmeticCommand; import com.hibiscusmc.hmccosmetics.command.CosmeticCommandTabComplete; import com.hibiscusmc.hmccosmetics.config.DatabaseSettings; import com.hibiscusmc.hmccosmetics.config.Settings; import com.hibiscusmc.hmccosmetics.config.WardrobeSettings; -import com.hibiscusmc.hmccosmetics.config.serializer.ItemSerializer; -import com.hibiscusmc.hmccosmetics.config.serializer.LocationSerializer; 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.Hooks; +import com.hibiscusmc.hmccosmetics.hooks.items.HookHMCCosmetics; +import com.hibiscusmc.hmccosmetics.hooks.placeholders.HMCPlaceholderExpansion; import com.hibiscusmc.hmccosmetics.hooks.worldguard.WGHook; import com.hibiscusmc.hmccosmetics.hooks.worldguard.WGListener; import com.hibiscusmc.hmccosmetics.listener.PaperPlayerGameListener; import com.hibiscusmc.hmccosmetics.listener.PlayerConnectionListener; import com.hibiscusmc.hmccosmetics.listener.PlayerGameListener; -import com.hibiscusmc.hmccosmetics.nms.NMSHandlers; +import com.hibiscusmc.hmccosmetics.nms.HMCCNMSHandlers; import com.hibiscusmc.hmccosmetics.user.CosmeticUser; import com.hibiscusmc.hmccosmetics.user.CosmeticUsers; import com.hibiscusmc.hmccosmetics.util.MessagesUtil; -import com.hibiscusmc.hmccosmetics.util.ServerUtils; import com.hibiscusmc.hmccosmetics.util.TranslationUtil; -import com.jeff_media.updatechecker.UpdateCheckSource; -import com.jeff_media.updatechecker.UpdateChecker; import com.ticxo.playeranimator.PlayerAnimatorImpl; -import lombok.Getter; -import org.bstats.bukkit.Metrics; +import me.lojosho.hibiscuscommons.HibiscusCommonsPlugin; +import me.lojosho.hibiscuscommons.HibiscusPlugin; +import me.lojosho.hibiscuscommons.config.serializer.ItemSerializer; +import me.lojosho.hibiscuscommons.config.serializer.LocationSerializer; +import me.lojosho.shaded.configupdater.common.config.CommentedConfiguration; +import me.lojosho.shaded.configurate.ConfigurateException; +import me.lojosho.shaded.configurate.ConfigurationNode; +import me.lojosho.shaded.configurate.ConfigurationOptions; +import me.lojosho.shaded.configurate.yaml.NodeStyle; +import me.lojosho.shaded.configurate.yaml.YamlConfigurationLoader; import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; import org.bukkit.permissions.Permission; -import org.bukkit.plugin.java.JavaPlugin; -import org.spongepowered.configurate.ConfigurateException; -import org.spongepowered.configurate.ConfigurationNode; -import org.spongepowered.configurate.ConfigurationOptions; -import org.spongepowered.configurate.yaml.NodeStyle; -import org.spongepowered.configurate.yaml.YamlConfigurationLoader; import java.io.File; import java.nio.file.Path; -public final class HMCCosmeticsPlugin extends JavaPlugin { +public final class HMCCosmeticsPlugin extends HibiscusPlugin { private static HMCCosmeticsPlugin instance; - private static boolean disable = false; private static YamlConfigurationLoader configLoader; - private static final int pluginId = 13873; - private static boolean onLatestVersion = true; - private static String latestVersion = ""; - @Getter - private static boolean onPaper = false; + + public HMCCosmeticsPlugin() { + super(13873, 1879); + new HookHMCCosmetics(); + } @Override - public void onEnable() { + public void onStart() { // Plugin startup logic instance = this; - // bstats https://bstats.org/plugin/bukkit/HMCCosmetics/13873 - Metrics metrics = new Metrics(this, pluginId); // NMS version check - if (!NMSHandlers.isVersionSupported()) { + if (!HMCCNMSHandlers.isVersionSupported()) { getLogger().severe("This version is not supported! Consider switching versions?"); getServer().getPluginManager().disablePlugin(this); return; } - // Update Checker - UpdateChecker checker = new UpdateChecker(this, UpdateCheckSource.POLYMART, "1879") - .onSuccess((commandSenders, latestVersion) -> { - HMCCosmeticsPlugin.latestVersion = (String) latestVersion; - if (!HMCCosmeticsPlugin.latestVersion.equalsIgnoreCase(getDescription().getVersion())) { - getLogger().info("+++++++++++++++++++++++++++++++++++"); - getLogger().info("There is a new update for HMCCosmetics!"); - getLogger().info("Please download it as soon as possible for possible fixes and new features."); - getLogger().info("Current Version " + getDescription().getVersion() + " | Latest Version " + latestVersion); - getLogger().info("Spigot: https://www.spigotmc.org/resources/100107/"); - getLogger().info("Polymart: https://polymart.org/resource/1879"); - getLogger().info("+++++++++++++++++++++++++++++++++++"); - } - }) - .setNotifyRequesters(false) - .setNotifyOpsOnJoin(false) - .checkEveryXHours(24) - .checkNow(); - onLatestVersion = checker.isUsingLatestVersion(); // File setup saveDefaultConfig(); if (!Path.of(getDataFolder().getPath(), "messages.yml").toFile().exists()) saveResource("messages.yml", false); @@ -103,7 +78,7 @@ public final class HMCCosmeticsPlugin extends JavaPlugin { if (!emoteFile.exists()) emoteFile.mkdir(); // Player Animator - if (!NMSHandlers.getVersion().contains("v1_20_R2") && !NMSHandlers.getVersion().contains("v1_20_R3")) PlayerAnimatorImpl.initialize(this); // PlayerAnimator does not support 1.20.2 yet + if (!HMCCNMSHandlers.getVersion().contains("v1_20_R2") && !HMCCNMSHandlers.getVersion().contains("v1_20_R3")) PlayerAnimatorImpl.initialize(this); // PlayerAnimator does not support 1.20.2 yet // Configuration Sync final File configFile = Path.of(getInstance().getDataFolder().getPath(), "config.yml").toFile(); @@ -118,6 +93,9 @@ public final class HMCCosmeticsPlugin extends JavaPlugin { e.printStackTrace(); } + // Move this over to Hibiscus Commons later + if (Bukkit.getPluginManager().getPlugin("PlaceholderAPI") != null) new HMCPlaceholderExpansion().register(); + // Setup setup(); @@ -129,9 +107,7 @@ public final class HMCCosmeticsPlugin extends JavaPlugin { getServer().getPluginManager().registerEvents(new PlayerConnectionListener(), this); getServer().getPluginManager().registerEvents(new PlayerGameListener(), this); // Taken from PaperLib - if (ServerUtils.hasClass("com.destroystokyo.paper.PaperConfig") || ServerUtils.hasClass("io.papermc.paper.configuration.Configuration")) { - onPaper = true; - getLogger().info("Detected Paper! Enabling Paper support..."); + if (HibiscusCommonsPlugin.isOnPaper()) { getServer().getPluginManager().registerEvents(new PaperPlayerGameListener(), this); } // Database @@ -152,9 +128,8 @@ public final class HMCCosmeticsPlugin extends JavaPlugin { } @Override - public void onDisable() { + public void onEnd() { // Plugin shutdown logic - disable = true; for (Player player : Bukkit.getOnlinePlayers()) { CosmeticUser user = CosmeticUsers.getUser(player); if (user == null) continue; @@ -227,9 +202,6 @@ public final class HMCCosmeticsPlugin extends JavaPlugin { throw new RuntimeException(e); } - // Misc Hooks setup (like items) - Hooks.setup(); - // Cosmetics setup Cosmetics.setup(); @@ -265,7 +237,7 @@ public final class HMCCosmeticsPlugin extends JavaPlugin { } } - if (Settings.isEmotesEnabled() && !NMSHandlers.getVersion().contains("v1_20_R2") && !NMSHandlers.getVersion().contains("v1_20_R3")) EmoteManager.loadEmotes(); // PlayerAnimator does not support 1.20.2 yet + if (Settings.isEmotesEnabled() && !HMCCNMSHandlers.getVersion().contains("v1_20_R2") && !HMCCNMSHandlers.getVersion().contains("v1_20_R3")) 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"); @@ -275,28 +247,4 @@ public final class HMCCosmeticsPlugin extends JavaPlugin { Bukkit.getPluginManager().callEvent(new HMCCosmeticSetupEvent()); } - - public static boolean isDisable() { - return disable; - } - - public static YamlConfigurationLoader getConfigLoader() { - return configLoader; - } - - public static void saveConfig(ConfigurationNode node) { - try { - HMCCosmeticsPlugin.getConfigLoader().save(node); - HMCCosmeticsPlugin.getInstance().getLogger().info("Set new location " + node.path()); - } catch (ConfigurateException e) { - throw new RuntimeException(e); - } - } - - public static boolean isOnLatestVersion() { - return onLatestVersion; - } - public static String getLatestVersion() { - return latestVersion; - } } diff --git a/common/src/main/java/com/hibiscusmc/hmccosmetics/api/HMCCosmeticsAPI.java b/common/src/main/java/com/hibiscusmc/hmccosmetics/api/HMCCosmeticsAPI.java index 45754a02..52c2f344 100644 --- a/common/src/main/java/com/hibiscusmc/hmccosmetics/api/HMCCosmeticsAPI.java +++ b/common/src/main/java/com/hibiscusmc/hmccosmetics/api/HMCCosmeticsAPI.java @@ -6,7 +6,7 @@ import com.hibiscusmc.hmccosmetics.cosmetic.CosmeticSlot; import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetics; import com.hibiscusmc.hmccosmetics.gui.Menu; import com.hibiscusmc.hmccosmetics.gui.Menus; -import com.hibiscusmc.hmccosmetics.nms.NMSHandlers; +import com.hibiscusmc.hmccosmetics.nms.HMCCNMSHandlers; import com.hibiscusmc.hmccosmetics.user.CosmeticUser; import com.hibiscusmc.hmccosmetics.user.CosmeticUsers; import org.bukkit.Color; @@ -103,7 +103,7 @@ public class HMCCosmeticsAPI { */ @Nullable public static String getNMSVersion() { - return NMSHandlers.getVersion(); + return HMCCNMSHandlers.getVersion(); } /** 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 901c71b8..b80c992b 100644 --- a/common/src/main/java/com/hibiscusmc/hmccosmetics/command/CosmeticCommand.java +++ b/common/src/main/java/com/hibiscusmc/hmccosmetics/command/CosmeticCommand.java @@ -16,11 +16,11 @@ 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; -import com.hibiscusmc.hmccosmetics.hooks.Hooks; import com.hibiscusmc.hmccosmetics.user.CosmeticUser; import com.hibiscusmc.hmccosmetics.user.CosmeticUsers; import com.hibiscusmc.hmccosmetics.util.MessagesUtil; import com.hibiscusmc.hmccosmetics.util.ServerUtils; +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; diff --git a/common/src/main/java/com/hibiscusmc/hmccosmetics/command/CosmeticCommandTabComplete.java b/common/src/main/java/com/hibiscusmc/hmccosmetics/command/CosmeticCommandTabComplete.java index 264fae4f..463d7d1d 100644 --- a/common/src/main/java/com/hibiscusmc/hmccosmetics/command/CosmeticCommandTabComplete.java +++ b/common/src/main/java/com/hibiscusmc/hmccosmetics/command/CosmeticCommandTabComplete.java @@ -9,9 +9,9 @@ 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.hooks.Hooks; import com.hibiscusmc.hmccosmetics.user.CosmeticUser; import com.hibiscusmc.hmccosmetics.user.CosmeticUsers; +import me.lojosho.hibiscuscommons.hooks.Hooks; import org.bukkit.Bukkit; import org.bukkit.command.Command; import org.bukkit.command.CommandSender; diff --git a/common/src/main/java/com/hibiscusmc/hmccosmetics/config/DatabaseSettings.java b/common/src/main/java/com/hibiscusmc/hmccosmetics/config/DatabaseSettings.java index 6d7ecb15..931ee612 100644 --- a/common/src/main/java/com/hibiscusmc/hmccosmetics/config/DatabaseSettings.java +++ b/common/src/main/java/com/hibiscusmc/hmccosmetics/config/DatabaseSettings.java @@ -1,7 +1,7 @@ package com.hibiscusmc.hmccosmetics.config; import lombok.Getter; -import org.spongepowered.configurate.ConfigurationNode; +import me.lojosho.shaded.configurate.ConfigurationNode; public class DatabaseSettings { 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 8112b7a3..013b8165 100644 --- a/common/src/main/java/com/hibiscusmc/hmccosmetics/config/Settings.java +++ b/common/src/main/java/com/hibiscusmc/hmccosmetics/config/Settings.java @@ -3,9 +3,9 @@ package com.hibiscusmc.hmccosmetics.config; import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin; import com.hibiscusmc.hmccosmetics.util.MessagesUtil; import lombok.Getter; +import me.lojosho.shaded.configurate.ConfigurationNode; import org.bukkit.inventory.EquipmentSlot; import org.bukkit.util.Vector; -import org.spongepowered.configurate.ConfigurationNode; import java.util.ArrayList; import java.util.List; diff --git a/common/src/main/java/com/hibiscusmc/hmccosmetics/config/WardrobeSettings.java b/common/src/main/java/com/hibiscusmc/hmccosmetics/config/WardrobeSettings.java index 95a5d1a8..55e82ef4 100644 --- a/common/src/main/java/com/hibiscusmc/hmccosmetics/config/WardrobeSettings.java +++ b/common/src/main/java/com/hibiscusmc/hmccosmetics/config/WardrobeSettings.java @@ -1,15 +1,15 @@ package com.hibiscusmc.hmccosmetics.config; import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin; -import com.hibiscusmc.hmccosmetics.config.serializer.LocationSerializer; import com.hibiscusmc.hmccosmetics.util.MessagesUtil; import com.hibiscusmc.hmccosmetics.util.misc.Utils; import lombok.Getter; +import me.lojosho.hibiscuscommons.config.serializer.LocationSerializer; +import me.lojosho.shaded.configurate.ConfigurationNode; import net.kyori.adventure.bossbar.BossBar; import org.apache.commons.lang3.EnumUtils; import org.bukkit.GameMode; import org.bukkit.Location; -import org.spongepowered.configurate.ConfigurationNode; import java.util.Collection; import java.util.HashMap; diff --git a/common/src/main/java/com/hibiscusmc/hmccosmetics/config/serializer/ItemSerializer.java b/common/src/main/java/com/hibiscusmc/hmccosmetics/config/serializer/ItemSerializer.java deleted file mode 100644 index def63c96..00000000 --- a/common/src/main/java/com/hibiscusmc/hmccosmetics/config/serializer/ItemSerializer.java +++ /dev/null @@ -1,165 +0,0 @@ -package com.hibiscusmc.hmccosmetics.config.serializer; - -import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin; -import com.hibiscusmc.hmccosmetics.hooks.Hooks; -import com.hibiscusmc.hmccosmetics.util.InventoryUtils; -import com.hibiscusmc.hmccosmetics.util.MessagesUtil; -import com.hibiscusmc.hmccosmetics.util.ServerUtils; -import com.hibiscusmc.hmccosmetics.util.builder.ColorBuilder; -import com.hibiscusmc.hmccosmetics.util.misc.StringUtils; -import com.hibiscusmc.hmccosmetics.util.misc.Utils; -import org.apache.commons.lang3.EnumUtils; -import org.bukkit.*; -import org.bukkit.enchantments.Enchantment; -import org.bukkit.inventory.ItemFlag; -import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.meta.ItemMeta; -import org.bukkit.inventory.meta.SkullMeta; -import org.bukkit.persistence.PersistentDataType; -import org.checkerframework.checker.nullness.qual.Nullable; -import org.spongepowered.configurate.ConfigurationNode; -import org.spongepowered.configurate.serialize.SerializationException; -import org.spongepowered.configurate.serialize.TypeSerializer; - -import java.lang.reflect.Type; -import java.util.ArrayList; -import java.util.stream.Collectors; - -public class ItemSerializer implements TypeSerializer { - - public static final ItemSerializer INSTANCE = new ItemSerializer(); - private static final String MATERIAL = "material"; - private static final String AMOUNT = "amount"; - private static final String NAME = "name"; - private static final String UNBREAKABLE = "unbreakable"; - private static final String GLOWING = "glowing"; - private static final String LORE = "lore"; - private static final String MODEL_DATA = "model-data"; - private static final String NBT_TAGS = "nbt-tag"; - private static final String ENCHANTS = "enchants"; - private static final String ITEM_FLAGS = "item-flags"; - private static final String TEXTURE = "texture"; - private static final String OWNER = "owner"; - private static final String COLOR = "color"; - private static final String RED = "red"; - private static final String GREEN = "green"; - private static final String BLUE = "blue"; - - private ItemSerializer() { - } - - @Override - public ItemStack deserialize(final Type type, final ConfigurationNode source) - throws SerializationException { - final ConfigurationNode materialNode = source.node(MATERIAL); - final ConfigurationNode amountNode = source.node(AMOUNT); - final ConfigurationNode nameNode = source.node(NAME); - final ConfigurationNode unbreakableNode = source.node(UNBREAKABLE); - final ConfigurationNode glowingNode = source.node(GLOWING); - final ConfigurationNode loreNode = source.node(LORE); - final ConfigurationNode modelDataNode = source.node(MODEL_DATA); - final ConfigurationNode nbtNode = source.node(NBT_TAGS); - final ConfigurationNode enchantsNode = source.node(ENCHANTS); - final ConfigurationNode itemFlagsNode = source.node(ITEM_FLAGS); - final ConfigurationNode textureNode = source.node(TEXTURE); - final ConfigurationNode ownerNode = source.node(OWNER); - final ConfigurationNode colorNode = source.node(COLOR); - final ConfigurationNode redNode = colorNode.node(RED); - final ConfigurationNode greenNode = colorNode.node(GREEN); - final ConfigurationNode blueNode = colorNode.node(BLUE); - - if (materialNode.virtual()) return null; - - String material = materialNode.getString(); - - ItemStack item = Hooks.getItem(material); - if (item == null) { - HMCCosmeticsPlugin.getInstance().getLogger().severe("Invalid Material -> " + material); - return new ItemStack(Material.AIR); - } - item.setAmount(amountNode.getInt(1)); - - ItemMeta itemMeta = item.getItemMeta(); - if (itemMeta == null) return item; - if (!nameNode.virtual()) - itemMeta.setDisplayName(StringUtils.parseStringToString(Utils.replaceIfNull(nameNode.getString(), ""))); - if (!unbreakableNode.virtual()) itemMeta.setUnbreakable(unbreakableNode.getBoolean()); - if (!glowingNode.virtual()) { - itemMeta.addItemFlags(ItemFlag.HIDE_ENCHANTS); - itemMeta.addEnchant(Enchantment.LUCK, 1, true); - } - if (!loreNode.virtual()) itemMeta.setLore(Utils.replaceIfNull(loreNode.getList(String.class), - new ArrayList()). - stream().map(StringUtils::parseStringToString).collect(Collectors.toList())); - if (!modelDataNode.virtual()) itemMeta.setCustomModelData(modelDataNode.getInt()); - - if (!nbtNode.virtual()) { - for (ConfigurationNode nbtNodes : nbtNode.childrenMap().values()) { - itemMeta.getPersistentDataContainer().set(NamespacedKey.minecraft(nbtNodes.key().toString()), PersistentDataType.STRING, nbtNodes.getString()); - } - } - - if (!enchantsNode.virtual()) { - for (ConfigurationNode enchantNode : enchantsNode.childrenMap().values()) { - if (Enchantment.getByKey(NamespacedKey.minecraft(enchantNode.key().toString())) == null) continue; - itemMeta.addEnchant(Enchantment.getByKey(NamespacedKey.minecraft(enchantNode.key().toString())), enchantNode.getInt(1), true); - } - } - - try { - if (!itemFlagsNode.virtual()) { - for (String itemFlag : itemFlagsNode.getList(String.class)) { - if (!EnumUtils.isValidEnum(ItemFlag.class, itemFlag)) continue; - MessagesUtil.sendDebugMessages("Added " + itemFlag + " to the item!"); - itemMeta.addItemFlags(ItemFlag.valueOf(itemFlag)); - } - } - } catch (Exception e) { - e.printStackTrace(); - } - - if (item.getType() == Material.PLAYER_HEAD) { - SkullMeta skullMeta = (SkullMeta) itemMeta; - if (!ownerNode.virtual()) { - String ownerString = ownerNode.getString(); - if (ownerString.contains("%")) { - // This means it has PAPI placeholders in it - skullMeta.getPersistentDataContainer().set(InventoryUtils.getSkullOwner(), PersistentDataType.STRING, ownerString); - } - OfflinePlayer player = Bukkit.getOfflinePlayer(ownerString); - skullMeta.setOwningPlayer(player); - } - - if (!textureNode.virtual()) { - String textureString = textureNode.getString(); - if (textureString.contains("%")) { - // This means it has PAPI placeholders in it - skullMeta.getPersistentDataContainer().set(InventoryUtils.getSkullTexture(), PersistentDataType.STRING, textureString); - } - Bukkit.getUnsafe().modifyItemStack(item, "{SkullOwner:{Id:[I;0,0,0,0],Properties:{textures:[{Value:\"" - + textureString + "\"}]}}}"); - - - itemMeta = skullMeta; - } - } - - if (!colorNode.virtual()) { - if (ColorBuilder.canBeColored(item.getType())) { - if (!redNode.virtual()) { - itemMeta = ColorBuilder.color(itemMeta, Color.fromRGB(redNode.getInt(0), greenNode.getInt(0), blueNode.getInt(0))); - } else { - itemMeta = ColorBuilder.color(itemMeta, ServerUtils.hex2Rgb(colorNode.getString("#FFFFFF"))); - } - } - } - - item.setItemMeta(itemMeta); - return item; - } - @Override - public void serialize(final Type type, @Nullable final ItemStack obj, final ConfigurationNode node) throws SerializationException { - - } - -} diff --git a/common/src/main/java/com/hibiscusmc/hmccosmetics/config/serializer/LocationSerializer.java b/common/src/main/java/com/hibiscusmc/hmccosmetics/config/serializer/LocationSerializer.java deleted file mode 100644 index b5f55845..00000000 --- a/common/src/main/java/com/hibiscusmc/hmccosmetics/config/serializer/LocationSerializer.java +++ /dev/null @@ -1,46 +0,0 @@ -package com.hibiscusmc.hmccosmetics.config.serializer; - -import org.bukkit.Bukkit; -import org.bukkit.Location; -import org.bukkit.World; -import org.checkerframework.checker.nullness.qual.Nullable; -import org.spongepowered.configurate.ConfigurationNode; -import org.spongepowered.configurate.serialize.SerializationException; -import org.spongepowered.configurate.serialize.TypeSerializer; - -import java.lang.reflect.Type; - -public class LocationSerializer implements TypeSerializer { - - public static final LocationSerializer INSTANCE = new LocationSerializer(); - - private static final String WORLD = "world"; - private static final String X = "x"; - private static final String Y = "y"; - private static final String Z = "z"; - private static final String PITCH = "pitch"; - private static final String YAW = "yaw"; - - - private LocationSerializer() {} - - @Override - @Nullable - public Location deserialize(final Type type, final ConfigurationNode source) throws SerializationException { - final World world = Bukkit.getWorld(source.node(WORLD).getString()); - if (world == null) return null; - return new Location( - world, - source.node(X).getDouble(), - source.node(Y).getDouble(), - source.node(Z).getDouble(), - source.node(YAW).getFloat(), - source.node(PITCH).getFloat() - ); - } - - @Override - public void serialize(final Type type, @Nullable final Location loc, final ConfigurationNode source) throws SerializationException { - // Empty - } -} diff --git a/common/src/main/java/com/hibiscusmc/hmccosmetics/cosmetic/Cosmetic.java b/common/src/main/java/com/hibiscusmc/hmccosmetics/cosmetic/Cosmetic.java index 924a5695..63c97ea5 100644 --- a/common/src/main/java/com/hibiscusmc/hmccosmetics/cosmetic/Cosmetic.java +++ b/common/src/main/java/com/hibiscusmc/hmccosmetics/cosmetic/Cosmetic.java @@ -1,16 +1,16 @@ package com.hibiscusmc.hmccosmetics.cosmetic; -import com.hibiscusmc.hmccosmetics.config.serializer.ItemSerializer; import com.hibiscusmc.hmccosmetics.user.CosmeticUser; import com.hibiscusmc.hmccosmetics.util.MessagesUtil; import lombok.Getter; import lombok.Setter; +import me.lojosho.hibiscuscommons.config.serializer.ItemSerializer; +import me.lojosho.shaded.configurate.ConfigurationNode; +import me.lojosho.shaded.configurate.serialize.SerializationException; import org.bukkit.Material; import org.bukkit.inventory.ItemStack; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import org.spongepowered.configurate.ConfigurationNode; -import org.spongepowered.configurate.serialize.SerializationException; import java.util.logging.Level; 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 8769b4f6..e8c5e6fc 100644 --- a/common/src/main/java/com/hibiscusmc/hmccosmetics/cosmetic/Cosmetics.java +++ b/common/src/main/java/com/hibiscusmc/hmccosmetics/cosmetic/Cosmetics.java @@ -5,14 +5,14 @@ import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin; import com.hibiscusmc.hmccosmetics.config.Settings; import com.hibiscusmc.hmccosmetics.cosmetic.types.*; import com.hibiscusmc.hmccosmetics.util.MessagesUtil; +import me.lojosho.shaded.configurate.CommentedConfigurationNode; +import me.lojosho.shaded.configurate.ConfigurateException; +import me.lojosho.shaded.configurate.ConfigurationNode; +import me.lojosho.shaded.configurate.yaml.YamlConfigurationLoader; import org.apache.commons.lang3.EnumUtils; import org.jetbrains.annotations.Contract; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import org.spongepowered.configurate.CommentedConfigurationNode; -import org.spongepowered.configurate.ConfigurateException; -import org.spongepowered.configurate.ConfigurationNode; -import org.spongepowered.configurate.yaml.YamlConfigurationLoader; import java.io.File; import java.nio.file.Files; diff --git a/common/src/main/java/com/hibiscusmc/hmccosmetics/cosmetic/types/CosmeticArmorType.java b/common/src/main/java/com/hibiscusmc/hmccosmetics/cosmetic/types/CosmeticArmorType.java index 969fe373..71b51f2a 100644 --- a/common/src/main/java/com/hibiscusmc/hmccosmetics/cosmetic/types/CosmeticArmorType.java +++ b/common/src/main/java/com/hibiscusmc/hmccosmetics/cosmetic/types/CosmeticArmorType.java @@ -2,11 +2,11 @@ package com.hibiscusmc.hmccosmetics.cosmetic.types; import com.hibiscusmc.hmccosmetics.config.Settings; import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic; -import com.hibiscusmc.hmccosmetics.nms.NMSHandlers; +import com.hibiscusmc.hmccosmetics.nms.HMCCNMSHandlers; import com.hibiscusmc.hmccosmetics.user.CosmeticUser; -import com.hibiscusmc.hmccosmetics.util.InventoryUtils; -import com.hibiscusmc.hmccosmetics.util.MessagesUtil; -import com.hibiscusmc.hmccosmetics.util.packets.PacketManager; +import com.hibiscusmc.hmccosmetics.util.HMCCInventoryUtils; +import com.hibiscusmc.hmccosmetics.util.packets.HMCCPacketManager; +import me.lojosho.shaded.configurate.ConfigurationNode; import org.bukkit.Bukkit; import org.bukkit.entity.Entity; import org.bukkit.entity.HumanEntity; @@ -14,7 +14,6 @@ import org.bukkit.entity.Player; import org.bukkit.inventory.EquipmentSlot; import org.bukkit.inventory.ItemStack; import org.jetbrains.annotations.NotNull; -import org.spongepowered.configurate.ConfigurationNode; public class CosmeticArmorType extends Cosmetic { @@ -23,7 +22,7 @@ public class CosmeticArmorType extends Cosmetic { public CosmeticArmorType(String id, ConfigurationNode config) { super(id, config); - this.equipSlot = InventoryUtils.getEquipmentSlot(getSlot()); + this.equipSlot = HMCCInventoryUtils.getEquipmentSlot(getSlot()); } @Override @@ -36,7 +35,7 @@ public class CosmeticArmorType extends Cosmetic { && ((user.getEntity() instanceof Player) && !user.getPlayer().getInventory().getItemInOffHand().getType().isAir())) return; ItemStack item = getItem(user); if (item == null) return; - NMSHandlers.getHandler().equipmentSlotUpdate(entity.getEntityId(), equipSlot, item, PacketManager.getViewers(entity.getLocation())); + HMCCNMSHandlers.getHandler().equipmentSlotUpdate(entity.getEntityId(), equipSlot, item, HMCCPacketManager.getViewers(entity.getLocation())); } public ItemStack getItem(@NotNull CosmeticUser user) { 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 7682f2ed..e2a3e42a 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 @@ -2,11 +2,12 @@ package com.hibiscusmc.hmccosmetics.cosmetic.types; import com.hibiscusmc.hmccosmetics.config.Settings; import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic; -import com.hibiscusmc.hmccosmetics.nms.NMSHandlers; +import com.hibiscusmc.hmccosmetics.nms.HMCCNMSHandlers; import com.hibiscusmc.hmccosmetics.user.CosmeticUser; import com.hibiscusmc.hmccosmetics.util.MessagesUtil; -import com.hibiscusmc.hmccosmetics.util.packets.PacketManager; +import com.hibiscusmc.hmccosmetics.util.packets.HMCCPacketManager; import lombok.Getter; +import me.lojosho.shaded.configurate.ConfigurationNode; import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.entity.Entity; @@ -15,7 +16,6 @@ import org.bukkit.entity.Player; import org.bukkit.inventory.EquipmentSlot; import org.bukkit.inventory.ItemStack; import org.jetbrains.annotations.NotNull; -import org.spongepowered.configurate.ConfigurationNode; import java.util.ArrayList; import java.util.List; @@ -55,12 +55,12 @@ public class CosmeticBackpackType extends Cosmetic { user.getUserBackpackManager().getEntityManager().teleport(loc); user.getUserBackpackManager().getEntityManager().setRotation((int) loc.getYaw(), isFirstPersonCompadible()); - PacketManager.sendEntitySpawnPacket(user.getEntity().getLocation(), user.getUserBackpackManager().getFirstArmorStandId(), EntityType.ARMOR_STAND, UUID.randomUUID(), outsideViewers); - PacketManager.sendArmorstandMetadata(user.getUserBackpackManager().getFirstArmorStandId(), outsideViewers); - NMSHandlers.getHandler().equipmentSlotUpdate(user.getUserBackpackManager().getFirstArmorStandId(), EquipmentSlot.HEAD, user.getUserCosmeticItem(this, getItem()), outsideViewers); + HMCCPacketManager.sendEntitySpawnPacket(user.getEntity().getLocation(), user.getUserBackpackManager().getFirstArmorStandId(), EntityType.ARMOR_STAND, UUID.randomUUID(), outsideViewers); + HMCCPacketManager.sendArmorstandMetadata(user.getUserBackpackManager().getFirstArmorStandId(), outsideViewers); + HMCCNMSHandlers.getHandler().equipmentSlotUpdate(user.getUserBackpackManager().getFirstArmorStandId(), EquipmentSlot.HEAD, user.getUserCosmeticItem(this, getItem()), outsideViewers); // If true, it will send the riding packet to all players. If false, it will send the riding packet only to new players - if (Settings.isBackpackForceRidingEnabled()) PacketManager.sendRidingPacket(entity.getEntityId(), user.getUserBackpackManager().getFirstArmorStandId(), user.getUserBackpackManager().getEntityManager().getViewers()); - else PacketManager.sendRidingPacket(entity.getEntityId(), user.getUserBackpackManager().getFirstArmorStandId(), outsideViewers); + if (Settings.isBackpackForceRidingEnabled()) HMCCPacketManager.sendRidingPacket(entity.getEntityId(), user.getUserBackpackManager().getFirstArmorStandId(), user.getUserBackpackManager().getEntityManager().getViewers()); + else HMCCPacketManager.sendRidingPacket(entity.getEntityId(), user.getUserBackpackManager().getFirstArmorStandId(), outsideViewers); if (!user.isInWardrobe() && isFirstPersonCompadible() && user.getPlayer() != null) { List owner = List.of(user.getPlayer()); @@ -68,16 +68,16 @@ public class CosmeticBackpackType extends Cosmetic { ArrayList particleCloud = user.getUserBackpackManager().getAreaEffectEntityId(); for (int i = 0; i < particleCloud.size(); i++) { if (i == 0) { - PacketManager.sendRidingPacket(entity.getEntityId(), particleCloud.get(i), owner); + HMCCPacketManager.sendRidingPacket(entity.getEntityId(), particleCloud.get(i), owner); } else { - PacketManager.sendRidingPacket(particleCloud.get(i - 1), particleCloud.get(i) , owner); + HMCCPacketManager.sendRidingPacket(particleCloud.get(i - 1), particleCloud.get(i) , owner); } } - PacketManager.sendRidingPacket(particleCloud.get(particleCloud.size() - 1), user.getUserBackpackManager().getFirstArmorStandId(), owner); + HMCCPacketManager.sendRidingPacket(particleCloud.get(particleCloud.size() - 1), user.getUserBackpackManager().getFirstArmorStandId(), owner); if (!user.getHidden()) { //if (loc.getPitch() < -70) NMSHandlers.getHandler().equipmentSlotUpdate(user.getUserBackpackManager().getFirstArmorStandId(), EquipmentSlot.HEAD, new ItemStack(Material.AIR), owner); //else NMSHandlers.getHandler().equipmentSlotUpdate(user.getUserBackpackManager().getFirstArmorStandId(), EquipmentSlot.HEAD, firstPersonBackpack, owner); - NMSHandlers.getHandler().equipmentSlotUpdate(user.getUserBackpackManager().getFirstArmorStandId(), EquipmentSlot.HEAD, user.getUserCosmeticItem(this, firstPersonBackpack), owner); + HMCCNMSHandlers.getHandler().equipmentSlotUpdate(user.getUserBackpackManager().getFirstArmorStandId(), EquipmentSlot.HEAD, user.getUserCosmeticItem(this, firstPersonBackpack), owner); } MessagesUtil.sendDebugMessages("First Person Backpack Update[owner=" + user.getUniqueId() + ",player_location=" + loc + "]!", Level.INFO); } diff --git a/common/src/main/java/com/hibiscusmc/hmccosmetics/cosmetic/types/CosmeticBalloonType.java b/common/src/main/java/com/hibiscusmc/hmccosmetics/cosmetic/types/CosmeticBalloonType.java index 851aaeed..020fba0b 100644 --- a/common/src/main/java/com/hibiscusmc/hmccosmetics/cosmetic/types/CosmeticBalloonType.java +++ b/common/src/main/java/com/hibiscusmc/hmccosmetics/cosmetic/types/CosmeticBalloonType.java @@ -4,16 +4,16 @@ import com.hibiscusmc.hmccosmetics.config.Settings; import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic; import com.hibiscusmc.hmccosmetics.user.CosmeticUser; import com.hibiscusmc.hmccosmetics.user.manager.UserBalloonManager; -import com.hibiscusmc.hmccosmetics.util.packets.PacketManager; +import com.hibiscusmc.hmccosmetics.util.packets.HMCCPacketManager; import lombok.Getter; +import me.lojosho.shaded.configurate.ConfigurationNode; +import me.lojosho.shaded.configurate.serialize.SerializationException; import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.entity.Entity; import org.bukkit.entity.Player; import org.bukkit.util.Vector; import org.jetbrains.annotations.NotNull; -import org.spongepowered.configurate.ConfigurationNode; -import org.spongepowered.configurate.serialize.SerializationException; import java.util.List; @@ -69,11 +69,11 @@ public class CosmeticBalloonType extends Cosmetic { Location currentLocation = user.getBalloonManager().getLocation(); newLocation = newLocation.clone().add(getBalloonOffset()); - List viewer = PacketManager.getViewers(entity.getLocation()); + List viewer = HMCCPacketManager.getViewers(entity.getLocation()); if (entity.getLocation().getWorld() != userBalloonManager.getLocation().getWorld()) { userBalloonManager.getModelEntity().teleport(newLocation); - PacketManager.sendTeleportPacket(userBalloonManager.getPufferfishBalloonId(), newLocation, false, viewer); + HMCCPacketManager.sendTeleportPacket(userBalloonManager.getPufferfishBalloonId(), newLocation, false, viewer); return; } @@ -81,8 +81,8 @@ public class CosmeticBalloonType extends Cosmetic { userBalloonManager.setVelocity(velocity.multiply(1.1)); userBalloonManager.setLocation(newLocation); - PacketManager.sendTeleportPacket(userBalloonManager.getPufferfishBalloonId(), newLocation, false, viewer); - PacketManager.sendLeashPacket(userBalloonManager.getPufferfishBalloonId(), entity.getEntityId(), viewer); + HMCCPacketManager.sendTeleportPacket(userBalloonManager.getPufferfishBalloonId(), newLocation, false, viewer); + HMCCPacketManager.sendLeashPacket(userBalloonManager.getPufferfishBalloonId(), entity.getEntityId(), viewer); if (user.getHidden()) { userBalloonManager.getPufferfish().hidePufferfish(); return; diff --git a/common/src/main/java/com/hibiscusmc/hmccosmetics/cosmetic/types/CosmeticEmoteType.java b/common/src/main/java/com/hibiscusmc/hmccosmetics/cosmetic/types/CosmeticEmoteType.java index e032b0fd..c0260c28 100644 --- a/common/src/main/java/com/hibiscusmc/hmccosmetics/cosmetic/types/CosmeticEmoteType.java +++ b/common/src/main/java/com/hibiscusmc/hmccosmetics/cosmetic/types/CosmeticEmoteType.java @@ -3,8 +3,8 @@ 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; -import org.spongepowered.configurate.ConfigurationNode; public class CosmeticEmoteType extends Cosmetic { diff --git a/common/src/main/java/com/hibiscusmc/hmccosmetics/cosmetic/types/CosmeticMainhandType.java b/common/src/main/java/com/hibiscusmc/hmccosmetics/cosmetic/types/CosmeticMainhandType.java index 1935e43e..0c22416e 100644 --- a/common/src/main/java/com/hibiscusmc/hmccosmetics/cosmetic/types/CosmeticMainhandType.java +++ b/common/src/main/java/com/hibiscusmc/hmccosmetics/cosmetic/types/CosmeticMainhandType.java @@ -3,10 +3,10 @@ package com.hibiscusmc.hmccosmetics.cosmetic.types; import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic; import com.hibiscusmc.hmccosmetics.user.CosmeticUser; import com.hibiscusmc.hmccosmetics.util.PlayerUtils; -import com.hibiscusmc.hmccosmetics.util.packets.PacketManager; +import com.hibiscusmc.hmccosmetics.util.packets.HMCCPacketManager; +import me.lojosho.shaded.configurate.ConfigurationNode; import org.bukkit.entity.Player; import org.jetbrains.annotations.NotNull; -import org.spongepowered.configurate.ConfigurationNode; public class CosmeticMainhandType extends Cosmetic { @@ -18,6 +18,6 @@ public class CosmeticMainhandType extends Cosmetic { public void update(@NotNull CosmeticUser user) { Player player = user.getPlayer(); - PacketManager.equipmentSlotUpdate(player.getEntityId(), user, getSlot(), PlayerUtils.getNearbyPlayers(player)); + HMCCPacketManager.equipmentSlotUpdate(player.getEntityId(), user, getSlot(), PlayerUtils.getNearbyPlayers(player)); } } diff --git a/common/src/main/java/com/hibiscusmc/hmccosmetics/database/types/SQLData.java b/common/src/main/java/com/hibiscusmc/hmccosmetics/database/types/SQLData.java index a0a32d07..2b0c605f 100644 --- a/common/src/main/java/com/hibiscusmc/hmccosmetics/database/types/SQLData.java +++ b/common/src/main/java/com/hibiscusmc/hmccosmetics/database/types/SQLData.java @@ -57,7 +57,7 @@ public abstract class SQLData extends Data { throw new RuntimeException(e); } }; - if (!HMCCosmeticsPlugin.isDisable()) { + if (!HMCCosmeticsPlugin.getInstance().isDisabled()) { Bukkit.getScheduler().runTaskAsynchronously(HMCCosmeticsPlugin.getInstance(), run); } else { run.run(); diff --git a/common/src/main/java/com/hibiscusmc/hmccosmetics/gui/Menu.java b/common/src/main/java/com/hibiscusmc/hmccosmetics/gui/Menu.java index 8d3efb33..404ce320 100644 --- a/common/src/main/java/com/hibiscusmc/hmccosmetics/gui/Menu.java +++ b/common/src/main/java/com/hibiscusmc/hmccosmetics/gui/Menu.java @@ -3,20 +3,22 @@ package com.hibiscusmc.hmccosmetics.gui; import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin; import com.hibiscusmc.hmccosmetics.api.events.PlayerMenuOpenEvent; import com.hibiscusmc.hmccosmetics.config.Settings; -import com.hibiscusmc.hmccosmetics.config.serializer.ItemSerializer; import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic; import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetics; import com.hibiscusmc.hmccosmetics.gui.type.Type; import com.hibiscusmc.hmccosmetics.gui.type.Types; -import com.hibiscusmc.hmccosmetics.hooks.Hooks; import com.hibiscusmc.hmccosmetics.user.CosmeticUser; import com.hibiscusmc.hmccosmetics.util.MessagesUtil; -import com.hibiscusmc.hmccosmetics.util.misc.Adventure; -import com.hibiscusmc.hmccosmetics.util.misc.StringUtils; import dev.triumphteam.gui.builder.item.ItemBuilder; import dev.triumphteam.gui.guis.Gui; import dev.triumphteam.gui.guis.GuiItem; import lombok.Getter; +import me.lojosho.hibiscuscommons.config.serializer.ItemSerializer; +import me.lojosho.hibiscuscommons.hooks.Hooks; +import me.lojosho.hibiscuscommons.util.Adventure; +import me.lojosho.hibiscuscommons.util.StringUtils; +import me.lojosho.shaded.configurate.ConfigurationNode; +import me.lojosho.shaded.configurate.serialize.SerializationException; import net.kyori.adventure.text.Component; import org.bukkit.Bukkit; import org.bukkit.entity.Player; @@ -24,8 +26,6 @@ import org.bukkit.event.inventory.ClickType; import org.bukkit.inventory.ItemStack; import org.jetbrains.annotations.Contract; import org.jetbrains.annotations.NotNull; -import org.spongepowered.configurate.ConfigurationNode; -import org.spongepowered.configurate.serialize.SerializationException; import java.util.*; import java.util.concurrent.atomic.AtomicInteger; diff --git a/common/src/main/java/com/hibiscusmc/hmccosmetics/gui/MenuItem.java b/common/src/main/java/com/hibiscusmc/hmccosmetics/gui/MenuItem.java index 66238b42..85397570 100644 --- a/common/src/main/java/com/hibiscusmc/hmccosmetics/gui/MenuItem.java +++ b/common/src/main/java/com/hibiscusmc/hmccosmetics/gui/MenuItem.java @@ -1,8 +1,8 @@ package com.hibiscusmc.hmccosmetics.gui; import com.hibiscusmc.hmccosmetics.gui.type.Type; +import me.lojosho.shaded.configurate.ConfigurationNode; import org.bukkit.inventory.ItemStack; -import org.spongepowered.configurate.ConfigurationNode; import java.util.List; diff --git a/common/src/main/java/com/hibiscusmc/hmccosmetics/gui/Menus.java b/common/src/main/java/com/hibiscusmc/hmccosmetics/gui/Menus.java index 81efdad5..b9306f03 100644 --- a/common/src/main/java/com/hibiscusmc/hmccosmetics/gui/Menus.java +++ b/common/src/main/java/com/hibiscusmc/hmccosmetics/gui/Menus.java @@ -3,12 +3,12 @@ package com.hibiscusmc.hmccosmetics.gui; import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin; import com.hibiscusmc.hmccosmetics.config.Settings; import com.hibiscusmc.hmccosmetics.util.MessagesUtil; +import me.lojosho.shaded.configurate.CommentedConfigurationNode; +import me.lojosho.shaded.configurate.ConfigurateException; +import me.lojosho.shaded.configurate.yaml.YamlConfigurationLoader; import org.apache.commons.io.FilenameUtils; import org.jetbrains.annotations.Contract; import org.jetbrains.annotations.NotNull; -import org.spongepowered.configurate.CommentedConfigurationNode; -import org.spongepowered.configurate.ConfigurateException; -import org.spongepowered.configurate.yaml.YamlConfigurationLoader; import java.io.File; import java.nio.file.Files; diff --git a/common/src/main/java/com/hibiscusmc/hmccosmetics/gui/action/actions/ActionConsoleCommand.java b/common/src/main/java/com/hibiscusmc/hmccosmetics/gui/action/actions/ActionConsoleCommand.java index 7487d963..d866297c 100644 --- a/common/src/main/java/com/hibiscusmc/hmccosmetics/gui/action/actions/ActionConsoleCommand.java +++ b/common/src/main/java/com/hibiscusmc/hmccosmetics/gui/action/actions/ActionConsoleCommand.java @@ -2,8 +2,8 @@ package com.hibiscusmc.hmccosmetics.gui.action.actions; import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin; import com.hibiscusmc.hmccosmetics.gui.action.Action; -import com.hibiscusmc.hmccosmetics.hooks.Hooks; import com.hibiscusmc.hmccosmetics.user.CosmeticUser; +import me.lojosho.hibiscuscommons.hooks.Hooks; import org.bukkit.Bukkit; import org.jetbrains.annotations.NotNull; diff --git a/common/src/main/java/com/hibiscusmc/hmccosmetics/gui/action/actions/ActionParticle.java b/common/src/main/java/com/hibiscusmc/hmccosmetics/gui/action/actions/ActionParticle.java index 944b3665..9706a926 100644 --- a/common/src/main/java/com/hibiscusmc/hmccosmetics/gui/action/actions/ActionParticle.java +++ b/common/src/main/java/com/hibiscusmc/hmccosmetics/gui/action/actions/ActionParticle.java @@ -4,7 +4,7 @@ import com.hibiscusmc.hmccosmetics.gui.action.Action; import com.hibiscusmc.hmccosmetics.user.CosmeticUser; import com.hibiscusmc.hmccosmetics.util.MessagesUtil; import com.hibiscusmc.hmccosmetics.util.ServerUtils; -import com.hibiscusmc.hmccosmetics.util.packets.PacketManager; +import com.hibiscusmc.hmccosmetics.util.packets.HMCCPacketManager; import com.owen1212055.particlehelper.api.particle.types.BlockDataParticle; import com.owen1212055.particlehelper.api.particle.types.DestinationParticle; import com.owen1212055.particlehelper.api.particle.types.velocity.VelocityParticle; @@ -44,7 +44,7 @@ public class ActionParticle extends Action { particle = ServerUtils.addParticleValues(particle, rawString); Location location = user.getPlayer().getLocation(); - for (Player player : PacketManager.getViewers(location)) { + for (Player player : HMCCPacketManager.getViewers(location)) { particle.compile().send(player, location); } } diff --git a/common/src/main/java/com/hibiscusmc/hmccosmetics/gui/action/actions/ActionPlayerCommand.java b/common/src/main/java/com/hibiscusmc/hmccosmetics/gui/action/actions/ActionPlayerCommand.java index d6f098da..2f95b5e3 100644 --- a/common/src/main/java/com/hibiscusmc/hmccosmetics/gui/action/actions/ActionPlayerCommand.java +++ b/common/src/main/java/com/hibiscusmc/hmccosmetics/gui/action/actions/ActionPlayerCommand.java @@ -1,9 +1,9 @@ package com.hibiscusmc.hmccosmetics.gui.action.actions; import com.hibiscusmc.hmccosmetics.gui.action.Action; -import com.hibiscusmc.hmccosmetics.hooks.Hooks; import com.hibiscusmc.hmccosmetics.user.CosmeticUser; import com.hibiscusmc.hmccosmetics.util.MessagesUtil; +import me.lojosho.hibiscuscommons.hooks.Hooks; import org.jetbrains.annotations.NotNull; public class ActionPlayerCommand extends Action { diff --git a/common/src/main/java/com/hibiscusmc/hmccosmetics/gui/special/DyeMenu.java b/common/src/main/java/com/hibiscusmc/hmccosmetics/gui/special/DyeMenu.java index ba88076e..d101a39a 100644 --- a/common/src/main/java/com/hibiscusmc/hmccosmetics/gui/special/DyeMenu.java +++ b/common/src/main/java/com/hibiscusmc/hmccosmetics/gui/special/DyeMenu.java @@ -6,8 +6,8 @@ import com.hibiscusmc.hmccolor.shaded.gui.guis.GuiItem; import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin; import com.hibiscusmc.hmccosmetics.config.Settings; import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic; -import com.hibiscusmc.hmccosmetics.hooks.Hooks; import com.hibiscusmc.hmccosmetics.user.CosmeticUser; +import me.lojosho.hibiscuscommons.hooks.Hooks; import org.bukkit.Bukkit; import org.bukkit.Color; import org.bukkit.Material; diff --git a/common/src/main/java/com/hibiscusmc/hmccosmetics/gui/type/Type.java b/common/src/main/java/com/hibiscusmc/hmccosmetics/gui/type/Type.java index 07bb197e..49b2768a 100644 --- a/common/src/main/java/com/hibiscusmc/hmccosmetics/gui/type/Type.java +++ b/common/src/main/java/com/hibiscusmc/hmccosmetics/gui/type/Type.java @@ -1,9 +1,9 @@ package com.hibiscusmc.hmccosmetics.gui.type; import com.hibiscusmc.hmccosmetics.user.CosmeticUser; +import me.lojosho.shaded.configurate.ConfigurationNode; import org.bukkit.event.inventory.ClickType; import org.bukkit.inventory.ItemStack; -import org.spongepowered.configurate.ConfigurationNode; public abstract class Type { diff --git a/common/src/main/java/com/hibiscusmc/hmccosmetics/gui/type/types/TypeCosmetic.java b/common/src/main/java/com/hibiscusmc/hmccosmetics/gui/type/types/TypeCosmetic.java index 90250b52..3479b3fb 100644 --- a/common/src/main/java/com/hibiscusmc/hmccosmetics/gui/type/types/TypeCosmetic.java +++ b/common/src/main/java/com/hibiscusmc/hmccosmetics/gui/type/types/TypeCosmetic.java @@ -2,16 +2,18 @@ package com.hibiscusmc.hmccosmetics.gui.type.types; import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin; import com.hibiscusmc.hmccosmetics.config.Settings; -import com.hibiscusmc.hmccosmetics.config.serializer.ItemSerializer; import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic; import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetics; import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticArmorType; import com.hibiscusmc.hmccosmetics.gui.action.Actions; import com.hibiscusmc.hmccosmetics.gui.special.DyeMenu; import com.hibiscusmc.hmccosmetics.gui.type.Type; -import com.hibiscusmc.hmccosmetics.hooks.Hooks; import com.hibiscusmc.hmccosmetics.user.CosmeticUser; import com.hibiscusmc.hmccosmetics.util.MessagesUtil; +import me.lojosho.hibiscuscommons.config.serializer.ItemSerializer; +import me.lojosho.hibiscuscommons.hooks.Hooks; +import me.lojosho.shaded.configurate.ConfigurationNode; +import me.lojosho.shaded.configurate.serialize.SerializationException; import org.bukkit.Bukkit; import org.bukkit.entity.Player; import org.bukkit.event.inventory.ClickType; @@ -21,8 +23,6 @@ import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.inventory.meta.SkullMeta; import org.jetbrains.annotations.Contract; import org.jetbrains.annotations.NotNull; -import org.spongepowered.configurate.ConfigurationNode; -import org.spongepowered.configurate.serialize.SerializationException; import java.util.ArrayList; import java.util.List; diff --git a/common/src/main/java/com/hibiscusmc/hmccosmetics/gui/type/types/TypeEmpty.java b/common/src/main/java/com/hibiscusmc/hmccosmetics/gui/type/types/TypeEmpty.java index 28dd17df..ead56dc7 100644 --- a/common/src/main/java/com/hibiscusmc/hmccosmetics/gui/type/types/TypeEmpty.java +++ b/common/src/main/java/com/hibiscusmc/hmccosmetics/gui/type/types/TypeEmpty.java @@ -2,15 +2,15 @@ package com.hibiscusmc.hmccosmetics.gui.type.types; import com.hibiscusmc.hmccosmetics.gui.action.Actions; import com.hibiscusmc.hmccosmetics.gui.type.Type; -import com.hibiscusmc.hmccosmetics.hooks.Hooks; import com.hibiscusmc.hmccosmetics.user.CosmeticUser; +import me.lojosho.hibiscuscommons.hooks.Hooks; +import me.lojosho.shaded.configurate.ConfigurationNode; +import me.lojosho.shaded.configurate.serialize.SerializationException; import org.bukkit.event.inventory.ClickType; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.inventory.meta.SkullMeta; import org.jetbrains.annotations.NotNull; -import org.spongepowered.configurate.ConfigurationNode; -import org.spongepowered.configurate.serialize.SerializationException; import java.util.ArrayList; import java.util.List; diff --git a/common/src/main/java/com/hibiscusmc/hmccosmetics/hooks/Hook.java b/common/src/main/java/com/hibiscusmc/hmccosmetics/hooks/Hook.java deleted file mode 100644 index 92bcc01d..00000000 --- a/common/src/main/java/com/hibiscusmc/hmccosmetics/hooks/Hook.java +++ /dev/null @@ -1,100 +0,0 @@ -package com.hibiscusmc.hmccosmetics.hooks; - -import org.bukkit.event.Listener; -import org.bukkit.inventory.ItemStack; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -/** - * Represents a hook into other minecraft plugins - */ -public abstract class Hook implements Listener { - private final String id; - private boolean active = false; - private boolean itemHook = false; - - public Hook(@NotNull String id, HookFlag... flags) { - this.id = id; - for (HookFlag flag : flags) { - switch (flag) { - case ITEM_SUPPORT: - setEnabledItemHook(true); - break; - } - } - Hooks.addHook(this); - } - - /** - * Loads this hook - * - * @implNote By default, this method does nothing. It should be overridden by child classes to implement any necessary loading logic - */ - public void load() { } - - /** - * Gets an {@link ItemStack} that is associated with the provided id from the hooked plugin - * @param itemId The id of the {@link ItemStack} - * @return The {@link ItemStack} with the id provided. If an invalid id was provided or if the hook doesn't have any related {@link ItemStack}s then this will return null - * @implNote By default, this method returns null. It should be overridden by child classes if you will to have your hook return a related {@link ItemStack} - */ - @Nullable - public ItemStack getItem(@NotNull String itemId) { - return null; - } - - /** - * Gets the id of this hook - * - * @return The unique id for this hook - */ - @NotNull - public final String getId() { - return id; - } - - /** - * Gets whether this hook has been activated - * @return true if this hook is active, false otherwise - * @deprecated As of release 2.2.5+, replaced by {@link #isActive()} - */ - @Deprecated - public boolean getActive() { - return this.active; - } - - /** - * Gets whether this hook has been activated - * @return true if this hook is active, false otherwise - * @since 2.2.5 - */ - public final boolean isActive() { - return this.active; - } - - /** - * Sets whether this hook is active - * @param active true to activate the hook, false otherwise - */ - public final void setActive(boolean active) { - this.active = active; - } - - /** - * Whether the method {@link #getItem(String)} should return a non-null value - * @return true if {@link #getItem(String)} should return a non-null value, false otherwise - * - * @apiNote Even though this method returns true does not mean that {@link #getItem(String)} won't return null, rather if this returns false then {@link #getItem(String)} should return false everytime - */ - public final boolean hasEnabledItemHook() { - return itemHook; - } - - /** - * Sets whether the method {@link #getItem(String)} should return a non-null value - * @param enabled true if {@link #getItem(String)} should return a non-null value, false otherwise - */ - public final void setEnabledItemHook(boolean enabled) { - itemHook = enabled; - } -} diff --git a/common/src/main/java/com/hibiscusmc/hmccosmetics/hooks/HookFlag.java b/common/src/main/java/com/hibiscusmc/hmccosmetics/hooks/HookFlag.java deleted file mode 100644 index e8a7fcf0..00000000 --- a/common/src/main/java/com/hibiscusmc/hmccosmetics/hooks/HookFlag.java +++ /dev/null @@ -1,5 +0,0 @@ -package com.hibiscusmc.hmccosmetics.hooks; - -public enum HookFlag { - ITEM_SUPPORT -} diff --git a/common/src/main/java/com/hibiscusmc/hmccosmetics/hooks/Hooks.java b/common/src/main/java/com/hibiscusmc/hmccosmetics/hooks/Hooks.java deleted file mode 100644 index 8f77e542..00000000 --- a/common/src/main/java/com/hibiscusmc/hmccosmetics/hooks/Hooks.java +++ /dev/null @@ -1,89 +0,0 @@ -package com.hibiscusmc.hmccosmetics.hooks; - -import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin; -import com.hibiscusmc.hmccosmetics.hooks.items.*; -import com.hibiscusmc.hmccosmetics.hooks.misc.*; -import com.hibiscusmc.hmccosmetics.hooks.placeholders.HookPlaceholderAPI; -import me.clip.placeholderapi.PlaceholderAPI; -import org.bukkit.Bukkit; -import org.bukkit.Material; -import org.bukkit.OfflinePlayer; -import org.bukkit.inventory.ItemStack; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -import java.util.HashMap; - -public class Hooks { - - private static final HashMap hooks = new HashMap<>(); - private static final HookOraxen ORAXEN_HOOK = new HookOraxen(); - private static final HookItemAdder ITEMADDER_HOOK = new HookItemAdder(); - private static final HookGeary GEARY_HOOK = new HookGeary(); - private static final HookMythic MYTHIC_HOOK = new HookMythic(); - private static final HookDenizen DENIZEN_HOOK = new HookDenizen(); - private static final HookHMCCosmetics HMCCOSMETIC_HOOK = new HookHMCCosmetics(); - private static final HookPlaceholderAPI PAPI_HOOK = new HookPlaceholderAPI(); - private static final HookPremiumVanish PREMIUM_VANISH_HOOK = new HookPremiumVanish(); - private static final HookSuperVanish SUPER_VANISH_HOOK = new HookSuperVanish(); - private static final HookHMCColor HMC_COLOR_HOOK = new HookHMCColor(); - private static final HookCMI CMI_HOOK = new HookCMI(); - private static final HookLibsDisguises LIBS_DISGUISES_HOOK = new HookLibsDisguises(); - private static final HookModelEngine MODEL_ENGINE_HOOK = new HookModelEngine(); - private static final HookMMOItems MMO_ITEMS_HOOK = new HookMMOItems(); - private static final HookEco ECO_ITEMS_HOOK = new HookEco(); - - public static Hook getHook(@NotNull String id) { - return hooks.get(id.toLowerCase()); - } - - public static boolean isItemHook(@NotNull String id) { - return hooks.containsKey(id.toLowerCase()); - } - - public static void addHook(Hook hook) { - hooks.put(hook.getId().toLowerCase(), hook); - } - - public static void setup() { - for (Hook hook : hooks.values()) { - if (Bukkit.getPluginManager().getPlugin(hook.getId()) != null) { - HMCCosmeticsPlugin.getInstance().getServer().getPluginManager().registerEvents(hook, HMCCosmeticsPlugin.getInstance()); - hook.setActive(true); - hook.load(); - HMCCosmeticsPlugin.getInstance().getLogger().info("Successfully hooked into " + hook.getId()); - } - } - } - - @Nullable - public static ItemStack getItem(@NotNull String raw) { - if (!raw.contains(":")) { - Material mat = Material.getMaterial(raw.toUpperCase()); - if (mat == null) return null; - return new ItemStack(mat); - } - // Ex. Oraxen:BigSword - // split[0] is the plugin name - // split[1] is the item name - String[] split = raw.split(":", 2); - - if (!isItemHook(split[0])) return null; - Hook hook = getHook(split[0]); - if (!hook.hasEnabledItemHook()) return null; - if (!hook.isActive()) return null; - return hook.getItem(split[1]); - } - - @NotNull - public static String processPlaceholders(OfflinePlayer player, String raw) { - if (getHook("PlaceholderAPI").isActive()) return PlaceholderAPI.setPlaceholders(player, raw); - return raw; - } - - public static boolean isActiveHook(String id) { - Hook hook = getHook(id); - if (hook == null) return false; - return hook.isActive(); - } -} diff --git a/common/src/main/java/com/hibiscusmc/hmccosmetics/hooks/items/HookDenizen.java b/common/src/main/java/com/hibiscusmc/hmccosmetics/hooks/items/HookDenizen.java deleted file mode 100644 index 2887722f..00000000 --- a/common/src/main/java/com/hibiscusmc/hmccosmetics/hooks/items/HookDenizen.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.hibiscusmc.hmccosmetics.hooks.items; - -import com.denizenscript.denizen.objects.ItemTag; -import com.denizenscript.denizencore.utilities.CoreUtilities; -import com.hibiscusmc.hmccosmetics.hooks.Hook; -import com.hibiscusmc.hmccosmetics.hooks.HookFlag; -import org.bukkit.inventory.ItemStack; -import org.jetbrains.annotations.NotNull; - -/** - * A hook that integrates the plugin {@link com.denizenscript.denizen.Denizen Denizen} to provide custom items - */ -@SuppressWarnings("SpellCheckingInspection") -public class HookDenizen extends Hook { - public HookDenizen() { - super("denizen", HookFlag.ITEM_SUPPORT); - } - - /** - * Gets a cosmetic {@link ItemStack} that is associated with the provided id from the plugin {@link com.denizenscript.denizen.Denizen Denizen} - */ - @Override - public ItemStack getItem(@NotNull String itemId) { - ItemTag item = ItemTag.valueOf(itemId, CoreUtilities.noDebugContext); - return item == null ? null : item.getItemStack(); - } -} diff --git a/common/src/main/java/com/hibiscusmc/hmccosmetics/hooks/items/HookEco.java b/common/src/main/java/com/hibiscusmc/hmccosmetics/hooks/items/HookEco.java deleted file mode 100644 index e9fa5d80..00000000 --- a/common/src/main/java/com/hibiscusmc/hmccosmetics/hooks/items/HookEco.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.hibiscusmc.hmccosmetics.hooks.items; - -import com.hibiscusmc.hmccosmetics.hooks.Hook; -import com.hibiscusmc.hmccosmetics.hooks.HookFlag; -import com.willfp.eco.core.items.Items; -import org.bukkit.inventory.ItemStack; -import org.jetbrains.annotations.NotNull; - -public class HookEco extends Hook { - public HookEco() { - super("Eco", HookFlag.ITEM_SUPPORT); - } - - @Override - public ItemStack getItem(@NotNull String itemId) { - return Items.lookup(itemId).getItem(); - } -} diff --git a/common/src/main/java/com/hibiscusmc/hmccosmetics/hooks/items/HookGeary.java b/common/src/main/java/com/hibiscusmc/hmccosmetics/hooks/items/HookGeary.java deleted file mode 100644 index 51ce0bea..00000000 --- a/common/src/main/java/com/hibiscusmc/hmccosmetics/hooks/items/HookGeary.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.hibiscusmc.hmccosmetics.hooks.items; - -import com.hibiscusmc.hmccosmetics.hooks.Hook; -import com.hibiscusmc.hmccosmetics.hooks.HookFlag; -import com.mineinabyss.geary.papermc.tracking.items.ItemTrackingKt; -import com.mineinabyss.geary.prefabs.PrefabKey; -import org.bukkit.inventory.ItemStack; -import org.jetbrains.annotations.NotNull; - -/** - * A hook that integrates the plugin {@link com.mineinabyss.geary.papermc.GearyPlugin Geary} to provide custom items - */ -public class HookGeary extends Hook { - - public HookGeary() { - super("geary", HookFlag.ITEM_SUPPORT); - } - - /** - * Gets a cosmetic {@link ItemStack} that is associated with the provided id from the plugin {@link com.mineinabyss.geary.papermc.GearyPlugin Geary} - */ - @Override - public ItemStack getItem(@NotNull String itemId) { - PrefabKey prefabKey = PrefabKey.Companion.ofOrNull(itemId); - if (prefabKey == null) return null; - return ItemTrackingKt.getGearyItems().createItem(prefabKey, null); - } -} diff --git a/common/src/main/java/com/hibiscusmc/hmccosmetics/hooks/items/HookHMCCosmetics.java b/common/src/main/java/com/hibiscusmc/hmccosmetics/hooks/items/HookHMCCosmetics.java index 6e0ad7aa..fb732660 100644 --- a/common/src/main/java/com/hibiscusmc/hmccosmetics/hooks/items/HookHMCCosmetics.java +++ b/common/src/main/java/com/hibiscusmc/hmccosmetics/hooks/items/HookHMCCosmetics.java @@ -2,8 +2,8 @@ package com.hibiscusmc.hmccosmetics.hooks.items; import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic; import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetics; -import com.hibiscusmc.hmccosmetics.hooks.Hook; -import com.hibiscusmc.hmccosmetics.hooks.HookFlag; +import me.lojosho.hibiscuscommons.hooks.Hook; +import me.lojosho.hibiscuscommons.hooks.HookFlag; import org.bukkit.inventory.ItemStack; import org.jetbrains.annotations.NotNull; diff --git a/common/src/main/java/com/hibiscusmc/hmccosmetics/hooks/items/HookItemAdder.java b/common/src/main/java/com/hibiscusmc/hmccosmetics/hooks/items/HookItemAdder.java deleted file mode 100644 index 341d6f99..00000000 --- a/common/src/main/java/com/hibiscusmc/hmccosmetics/hooks/items/HookItemAdder.java +++ /dev/null @@ -1,47 +0,0 @@ -package com.hibiscusmc.hmccosmetics.hooks.items; - -import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin; -import com.hibiscusmc.hmccosmetics.config.Settings; -import com.hibiscusmc.hmccosmetics.hooks.Hook; -import com.hibiscusmc.hmccosmetics.hooks.HookFlag; -import dev.lone.itemsadder.api.CustomStack; -import dev.lone.itemsadder.api.Events.ItemsAdderLoadDataEvent; -import org.bukkit.Material; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.bukkit.inventory.ItemStack; -import org.jetbrains.annotations.NotNull; - -/** - * A hook that integrates the plugin {@link dev.lone.itemsadder.api.ItemsAdder ItemsAdder} to provide custom items - */ -@SuppressWarnings("SpellCheckingInspection") -public class HookItemAdder extends Hook { - private boolean enabled = false; - - public HookItemAdder() { - super("itemsadder", HookFlag.ITEM_SUPPORT); - } - - /** - * Gets a cosmetic {@link ItemStack} that is associated with the provided id from the plugin {@link dev.lone.itemsadder.api.ItemsAdder ItemsAdder} - */ - @Override - public ItemStack getItem(@NotNull String itemId) { - if (enabled) { - CustomStack stack = CustomStack.getInstance(itemId); - if (stack == null) return null; - return stack.getItemStack(); - } else { - return new ItemStack(Material.AIR); - } - } - - @EventHandler(priority = EventPriority.MONITOR) - public void onItemAdderDataLoad(ItemsAdderLoadDataEvent event) { - // By default, it will only run once at startup, if hook setting is enabled - if (enabled && !Settings.isItemsAdderChangeReload()) return; - this.enabled = true; - HMCCosmeticsPlugin.setup(); - } -} diff --git a/common/src/main/java/com/hibiscusmc/hmccosmetics/hooks/items/HookMMOItems.java b/common/src/main/java/com/hibiscusmc/hmccosmetics/hooks/items/HookMMOItems.java deleted file mode 100644 index 4a6b9eec..00000000 --- a/common/src/main/java/com/hibiscusmc/hmccosmetics/hooks/items/HookMMOItems.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.hibiscusmc.hmccosmetics.hooks.items; - -import com.hibiscusmc.hmccosmetics.hooks.Hook; -import com.hibiscusmc.hmccosmetics.hooks.HookFlag; -import net.Indyuce.mmoitems.MMOItems; -import org.bukkit.inventory.ItemStack; -import org.jetbrains.annotations.NotNull; - -public class HookMMOItems extends Hook { - public HookMMOItems() { - super("MMOItems", HookFlag.ITEM_SUPPORT); - } - - @Override - public ItemStack getItem(@NotNull String itemId) { - String[] split = itemId.split(":", 2); - if (split.length == 2) { - return MMOItems.plugin.getItem(split[0], split[1]); - } - return null; - } -} diff --git a/common/src/main/java/com/hibiscusmc/hmccosmetics/hooks/items/HookMythic.java b/common/src/main/java/com/hibiscusmc/hmccosmetics/hooks/items/HookMythic.java deleted file mode 100644 index 5765cd5e..00000000 --- a/common/src/main/java/com/hibiscusmc/hmccosmetics/hooks/items/HookMythic.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.hibiscusmc.hmccosmetics.hooks.items; - -import com.hibiscusmc.hmccosmetics.hooks.Hook; -import com.hibiscusmc.hmccosmetics.hooks.HookFlag; -import io.lumine.mythic.bukkit.MythicBukkit; -import org.bukkit.inventory.ItemStack; -import org.jetbrains.annotations.NotNull; - -/** - * A hook that integrates the plugin {@link io.lumine.mythic.bukkit.MythicBukkit MythicBukkit} to provide custom items - */ -@SuppressWarnings("SpellCheckingInspection") -public class HookMythic extends Hook { - public HookMythic() { - super("mythicmobs", HookFlag.ITEM_SUPPORT); - } - - /** - * Gets a cosmetic {@link ItemStack} that is associated with the provided id from the plugin {@link io.lumine.mythic.bukkit.MythicBukkit MythicBukkit} - */ - @Override - public ItemStack getItem(@NotNull String itemId) { - return MythicBukkit.inst().getItemManager().getItemStack(itemId); - } -} diff --git a/common/src/main/java/com/hibiscusmc/hmccosmetics/hooks/items/HookOraxen.java b/common/src/main/java/com/hibiscusmc/hmccosmetics/hooks/items/HookOraxen.java deleted file mode 100644 index 88ffe1ae..00000000 --- a/common/src/main/java/com/hibiscusmc/hmccosmetics/hooks/items/HookOraxen.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.hibiscusmc.hmccosmetics.hooks.items; - -import com.hibiscusmc.hmccosmetics.hooks.Hook; -import com.hibiscusmc.hmccosmetics.hooks.HookFlag; -import io.th0rgal.oraxen.api.OraxenItems; -import io.th0rgal.oraxen.items.ItemBuilder; -import org.bukkit.inventory.ItemStack; -import org.jetbrains.annotations.NotNull; - -/** - * A hook that integrates the plugin {@link io.th0rgal.oraxen.OraxenPlugin OraxenPlugin} to provide custom items - */ -@SuppressWarnings("SpellCheckingInspection") -public class HookOraxen extends Hook { - public HookOraxen() { - super("oraxen", HookFlag.ITEM_SUPPORT); - } - - /** - * Gets a cosmetic {@link ItemStack} that is associated with the provided id from the plugin {@link io.th0rgal.oraxen.OraxenPlugin OraxenPlugin} - */ - @Override - public ItemStack getItem(@NotNull String itemId) { - ItemBuilder builder = OraxenItems.getItemById(itemId); - if (builder == null) return null; - return builder.build(); - } -} diff --git a/common/src/main/java/com/hibiscusmc/hmccosmetics/hooks/misc/HookCMI.java b/common/src/main/java/com/hibiscusmc/hmccosmetics/hooks/misc/HookCMI.java deleted file mode 100644 index f4d31614..00000000 --- a/common/src/main/java/com/hibiscusmc/hmccosmetics/hooks/misc/HookCMI.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.hibiscusmc.hmccosmetics.hooks.misc; - -import com.Zrips.CMI.events.CMIPlayerUnVanishEvent; -import com.Zrips.CMI.events.CMIPlayerVanishEvent; -import com.hibiscusmc.hmccosmetics.hooks.Hook; -import com.hibiscusmc.hmccosmetics.user.CosmeticUser; -import com.hibiscusmc.hmccosmetics.user.CosmeticUsers; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.jetbrains.annotations.NotNull; - -/** - * A hook that integrates the plugin {@link com.Zrips.CMI.CMI CMI} - */ -public class HookCMI extends Hook { - public HookCMI() { - super("CMI"); - } - - @EventHandler(priority = EventPriority.MONITOR) - public void onPlayerVanish(@NotNull CMIPlayerVanishEvent event) { - Player player = event.getPlayer(); - CosmeticUser user = CosmeticUsers.getUser(player); - if (user == null) return; - user.hideCosmetics(CosmeticUser.HiddenReason.PLUGIN); - } - - @EventHandler(priority = EventPriority.MONITOR) - public void onPlayerShow(@NotNull CMIPlayerUnVanishEvent event) { - Player player = event.getPlayer(); - CosmeticUser user = CosmeticUsers.getUser(player); - if (user == null) return; - user.showCosmetics(); - } -} diff --git a/common/src/main/java/com/hibiscusmc/hmccosmetics/hooks/misc/HookHMCColor.java b/common/src/main/java/com/hibiscusmc/hmccosmetics/hooks/misc/HookHMCColor.java deleted file mode 100644 index a2eb10a1..00000000 --- a/common/src/main/java/com/hibiscusmc/hmccosmetics/hooks/misc/HookHMCColor.java +++ /dev/null @@ -1,12 +0,0 @@ -package com.hibiscusmc.hmccosmetics.hooks.misc; - -import com.hibiscusmc.hmccosmetics.hooks.Hook; - -/** - * A hook that integrates the plugin {@link com.hibiscusmc.hmccolor.HMCColor HMCColor} - */ -public class HookHMCColor extends Hook { - public HookHMCColor() { - super("HMCColor"); - } -} diff --git a/common/src/main/java/com/hibiscusmc/hmccosmetics/hooks/misc/HookLibsDisguises.java b/common/src/main/java/com/hibiscusmc/hmccosmetics/hooks/misc/HookLibsDisguises.java deleted file mode 100644 index f43444f6..00000000 --- a/common/src/main/java/com/hibiscusmc/hmccosmetics/hooks/misc/HookLibsDisguises.java +++ /dev/null @@ -1,33 +0,0 @@ -package com.hibiscusmc.hmccosmetics.hooks.misc; - -import com.hibiscusmc.hmccosmetics.hooks.Hook; -import com.hibiscusmc.hmccosmetics.user.CosmeticUser; -import com.hibiscusmc.hmccosmetics.user.CosmeticUsers; -import me.libraryaddict.disguise.events.DisguiseEvent; -import me.libraryaddict.disguise.events.UndisguiseEvent; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.jetbrains.annotations.NotNull; - -public class HookLibsDisguises extends Hook { - public HookLibsDisguises() { - super("LibsDisguises"); - } - - @EventHandler(priority = EventPriority.MONITOR) - public void onPlayerVanish(@NotNull DisguiseEvent event) { - if (!(event.getEntity() instanceof Player player)) return; - CosmeticUser user = CosmeticUsers.getUser(player); - if (user == null) return; - user.hideCosmetics(CosmeticUser.HiddenReason.PLUGIN); - } - - @EventHandler(priority = EventPriority.MONITOR) - public void onPlayerShow(@NotNull UndisguiseEvent event) { - if (!(event.getEntity() instanceof Player player)) return; - CosmeticUser user = CosmeticUsers.getUser(player); - if (user == null) return; - user.showCosmetics(); - } -} diff --git a/common/src/main/java/com/hibiscusmc/hmccosmetics/hooks/misc/HookModelEngine.java b/common/src/main/java/com/hibiscusmc/hmccosmetics/hooks/misc/HookModelEngine.java deleted file mode 100644 index df761b0e..00000000 --- a/common/src/main/java/com/hibiscusmc/hmccosmetics/hooks/misc/HookModelEngine.java +++ /dev/null @@ -1,10 +0,0 @@ -package com.hibiscusmc.hmccosmetics.hooks.misc; - -import com.hibiscusmc.hmccosmetics.hooks.Hook; - -public class HookModelEngine extends Hook { - - public HookModelEngine() { - super("ModelEngine"); - } -} diff --git a/common/src/main/java/com/hibiscusmc/hmccosmetics/hooks/misc/HookPremiumVanish.java b/common/src/main/java/com/hibiscusmc/hmccosmetics/hooks/misc/HookPremiumVanish.java deleted file mode 100644 index d731d986..00000000 --- a/common/src/main/java/com/hibiscusmc/hmccosmetics/hooks/misc/HookPremiumVanish.java +++ /dev/null @@ -1,38 +0,0 @@ -package com.hibiscusmc.hmccosmetics.hooks.misc; - -import com.hibiscusmc.hmccosmetics.hooks.Hook; -import com.hibiscusmc.hmccosmetics.user.CosmeticUser; -import com.hibiscusmc.hmccosmetics.user.CosmeticUsers; -import de.myzelyam.api.vanish.PlayerHideEvent; -import de.myzelyam.api.vanish.PlayerShowEvent; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.jetbrains.annotations.NotNull; - -/** - * A hook that integrates the plugin {@link de.myzelyam.api.vanish.VanishAPI Supervanish} - * - * @implSpec Supervanish and Premium Vanish both use the same api - */ -public class HookPremiumVanish extends Hook { - public HookPremiumVanish() { - super("PremiumVanish"); - } - - @EventHandler(priority = EventPriority.NORMAL) - public void onPlayerVanish(@NotNull PlayerHideEvent event) { - Player player = event.getPlayer(); - CosmeticUser user = CosmeticUsers.getUser(player); - if (user == null) return; - user.hideCosmetics(CosmeticUser.HiddenReason.PLUGIN); - } - - @EventHandler(priority = EventPriority.NORMAL) - public void onPlayerShow(@NotNull PlayerShowEvent event) { - Player player = event.getPlayer(); - CosmeticUser user = CosmeticUsers.getUser(player); - if (user == null) return; - user.showCosmetics(); - } -} diff --git a/common/src/main/java/com/hibiscusmc/hmccosmetics/hooks/misc/HookSuperVanish.java b/common/src/main/java/com/hibiscusmc/hmccosmetics/hooks/misc/HookSuperVanish.java deleted file mode 100644 index bc375811..00000000 --- a/common/src/main/java/com/hibiscusmc/hmccosmetics/hooks/misc/HookSuperVanish.java +++ /dev/null @@ -1,38 +0,0 @@ -package com.hibiscusmc.hmccosmetics.hooks.misc; - -import com.hibiscusmc.hmccosmetics.hooks.Hook; -import com.hibiscusmc.hmccosmetics.user.CosmeticUser; -import com.hibiscusmc.hmccosmetics.user.CosmeticUsers; -import de.myzelyam.api.vanish.PlayerHideEvent; -import de.myzelyam.api.vanish.PlayerShowEvent; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.jetbrains.annotations.NotNull; - -/** - * A hook that integrates the plugin {@link de.myzelyam.api.vanish.VanishAPI Supervanish} - * - * @implSpec Supervanish and Premium Vanish both use the same api - */ -public class HookSuperVanish extends Hook { - public HookSuperVanish() { - super("SuperVanish"); - } - - @EventHandler(priority = EventPriority.NORMAL) - public void onPlayerVanish(@NotNull PlayerHideEvent event) { - Player player = event.getPlayer(); - CosmeticUser user = CosmeticUsers.getUser(player); - if (user == null) return; - user.hideCosmetics(CosmeticUser.HiddenReason.PLUGIN); - } - - @EventHandler(priority = EventPriority.NORMAL) - public void onPlayerShow(@NotNull PlayerShowEvent event) { - Player player = event.getPlayer(); - CosmeticUser user = CosmeticUsers.getUser(player); - if (user == null) return; - user.showCosmetics(); - } -} diff --git a/common/src/main/java/com/hibiscusmc/hmccosmetics/hooks/placeholders/HookPlaceholderAPI.java b/common/src/main/java/com/hibiscusmc/hmccosmetics/hooks/placeholders/HookPlaceholderAPI.java deleted file mode 100644 index 034b462d..00000000 --- a/common/src/main/java/com/hibiscusmc/hmccosmetics/hooks/placeholders/HookPlaceholderAPI.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.hibiscusmc.hmccosmetics.hooks.placeholders; - -import com.hibiscusmc.hmccosmetics.hooks.Hook; - -/** - * A hook that integrates the plugin {@link me.clip.placeholderapi.PlaceholderAPI PlaceholderAPI} - */ -public class HookPlaceholderAPI extends Hook { - public HookPlaceholderAPI() { - super("PlaceholderAPI"); - } - - /** - * Registers HMCCosmetics Placeholder Expansion - */ - @Override - public void load() { - new HMCPlaceholderExpansion().register(); - } -} diff --git a/common/src/main/java/com/hibiscusmc/hmccosmetics/listener/PlayerConnectionListener.java b/common/src/main/java/com/hibiscusmc/hmccosmetics/listener/PlayerConnectionListener.java index 905d1f12..54761618 100644 --- a/common/src/main/java/com/hibiscusmc/hmccosmetics/listener/PlayerConnectionListener.java +++ b/common/src/main/java/com/hibiscusmc/hmccosmetics/listener/PlayerConnectionListener.java @@ -20,12 +20,12 @@ public class PlayerConnectionListener implements Listener { @EventHandler(priority = EventPriority.MONITOR) public void onPlayerJoin(@NotNull PlayerJoinEvent event) { if (event.getPlayer().isOp() || event.getPlayer().hasPermission("hmccosmetics.notifyupdate")) { - if (!HMCCosmeticsPlugin.getLatestVersion().equalsIgnoreCase(HMCCosmeticsPlugin.getInstance().getDescription().getVersion()) && HMCCosmeticsPlugin.getLatestVersion().isEmpty()) + if (!HMCCosmeticsPlugin.getInstance().getLatestVersion().equalsIgnoreCase(HMCCosmeticsPlugin.getInstance().getDescription().getVersion()) && HMCCosmeticsPlugin.getInstance().getLatestVersion().isEmpty()) MessagesUtil.sendMessageNoKey( event.getPlayer(), "
" + "There is a new version of HMCCosmetics available!
" + - "Current version: " + HMCCosmeticsPlugin.getInstance().getDescription().getVersion() + " | Latest version: " + HMCCosmeticsPlugin.getLatestVersion() + "
" + + "Current version: " + HMCCosmeticsPlugin.getInstance().getDescription().getVersion() + " | Latest version: " + HMCCosmeticsPlugin.getInstance().getLatestVersion() + "
" + "Download it on Spigot or Polymart!" + "
" ); 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 b2e7bce2..6addfcf0 100644 --- a/common/src/main/java/com/hibiscusmc/hmccosmetics/listener/PlayerGameListener.java +++ b/common/src/main/java/com/hibiscusmc/hmccosmetics/listener/PlayerGameListener.java @@ -19,13 +19,15 @@ import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticBalloonType; import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticEmoteType; import com.hibiscusmc.hmccosmetics.gui.Menu; import com.hibiscusmc.hmccosmetics.gui.Menus; -import com.hibiscusmc.hmccosmetics.nms.NMSHandlers; +import com.hibiscusmc.hmccosmetics.nms.HMCCNMSHandlers; import com.hibiscusmc.hmccosmetics.user.CosmeticUser; import com.hibiscusmc.hmccosmetics.user.CosmeticUsers; import com.hibiscusmc.hmccosmetics.user.manager.UserEmoteManager; -import com.hibiscusmc.hmccosmetics.util.InventoryUtils; +import com.hibiscusmc.hmccosmetics.util.HMCCInventoryUtils; import com.hibiscusmc.hmccosmetics.util.MessagesUtil; -import com.hibiscusmc.hmccosmetics.util.packets.PacketManager; +import com.hibiscusmc.hmccosmetics.util.packets.HMCCPacketManager; +import me.lojosho.hibiscuscommons.api.events.HibiscusPlayerUnVanishEvent; +import me.lojosho.hibiscuscommons.api.events.HibiscusPlayerVanishEvent; import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.Material; @@ -79,14 +81,14 @@ public class PlayerGameListener implements Listener { ItemStack item = event.getCurrentItem(); if (item == null) return; - if (Settings.isDestroyLooseCosmetics() && InventoryUtils.isCosmeticItem(event.getCurrentItem())) { + if (Settings.isDestroyLooseCosmetics() && HMCCInventoryUtils.isCosmeticItem(event.getCurrentItem())) { MessagesUtil.sendDebugMessages("remvoe item"); event.getWhoClicked().getInventory().removeItem(event.getCurrentItem()); } EquipmentSlot slot = getArmorSlot(item.getType()); if (slot == null) return; - CosmeticSlot cosmeticSlot = InventoryUtils.BukkitCosmeticSlot(slot); + CosmeticSlot cosmeticSlot = HMCCInventoryUtils.BukkitCosmeticSlot(slot); if (cosmeticSlot == null) return; if (!user.hasCosmeticInSlot(cosmeticSlot)) return; Bukkit.getScheduler().runTaskLater(HMCCosmeticsPlugin.getInstance(), () -> { @@ -241,7 +243,7 @@ public class PlayerGameListener implements Listener { CosmeticUser user = CosmeticUsers.getUser(event.getPlayer().getUniqueId()); if (user == null) return; - CosmeticSlot cosmeticSlot = InventoryUtils.BukkitCosmeticSlot(slot); + CosmeticSlot cosmeticSlot = HMCCInventoryUtils.BukkitCosmeticSlot(slot); if (!user.hasCosmeticInSlot(cosmeticSlot)) { MessagesUtil.sendDebugMessages("No cosmetic in " + cosmeticSlot); @@ -267,10 +269,10 @@ public class PlayerGameListener implements Listener { } Bukkit.getScheduler().runTaskLater(HMCCosmeticsPlugin.getInstance(), () -> { user.updateCosmetic(CosmeticSlot.OFFHAND); - List viewers = PacketManager.getViewers(user.getEntity().getLocation()); + List viewers = HMCCPacketManager.getViewers(user.getEntity().getLocation()); if (viewers.isEmpty()) return; viewers.remove(user.getPlayer()); - NMSHandlers.getHandler().equipmentSlotUpdate(user.getEntity().getEntityId(), EquipmentSlot.HAND, event.getPlayer().getInventory().getItemInMainHand(), viewers); + HMCCNMSHandlers.getHandler().equipmentSlotUpdate(user.getEntity().getEntityId(), EquipmentSlot.HAND, event.getPlayer().getInventory().getItemInMainHand(), viewers); }, 2); } @@ -350,7 +352,7 @@ public class PlayerGameListener implements Listener { ItemStack[] equippedArmor = event.getPlayer().getInventory().getArmorContents(); if (equippedArmor.length == 0) return; for (ItemStack armor : equippedArmor) { - if (InventoryUtils.isCosmeticItem(armor)) armor.setAmount(0); + if (HMCCInventoryUtils.isCosmeticItem(armor)) armor.setAmount(0); } } } @@ -364,8 +366,8 @@ public class PlayerGameListener implements Listener { // We know that no other entity besides a regular player will be in the wardrobe List viewer = List.of(user.getPlayer()); user.getBalloonManager().getPufferfish().spawnPufferfish(npclocation.clone().add(cosmetic.getBalloonOffset()), viewer); - PacketManager.sendLeashPacket(user.getBalloonManager().getPufferfishBalloonId(), user.getWardrobeManager().getNPC_ID(), viewer); - PacketManager.sendTeleportPacket(user.getBalloonManager().getPufferfishBalloonId(), npclocation, false, viewer); + HMCCPacketManager.sendLeashPacket(user.getBalloonManager().getPufferfishBalloonId(), user.getWardrobeManager().getNPC_ID(), viewer); + HMCCPacketManager.sendTeleportPacket(user.getBalloonManager().getPufferfishBalloonId(), npclocation, false, viewer); user.getBalloonManager().getModelEntity().teleport(npclocation); } } @@ -390,6 +392,21 @@ public class PlayerGameListener implements Listener { } } + @EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) + public void onPlayerVanish(HibiscusPlayerVanishEvent event) { + CosmeticUser user = CosmeticUsers.getUser(event.getPlayer()); + if (user == null) return; + user.hideCosmetics(CosmeticUser.HiddenReason.PLUGIN); + } + + @EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) + public void onPlayerUnVanish(HibiscusPlayerUnVanishEvent event) { + CosmeticUser user = CosmeticUsers.getUser(event.getPlayer()); + if (user == null) return; + if (!user.getHidden()) return; + if (user.getHiddenReason().equals(CosmeticUser.HiddenReason.PLUGIN)) user.showCosmetics(); + } + private void registerInventoryClickListener() { ProtocolLibrary.getProtocolManager().addPacketListener(new PacketAdapter(HMCCosmeticsPlugin.getInstance(), ListenerPriority.NORMAL, PacketType.Play.Client.WINDOW_CLICK) { @Override @@ -407,7 +424,7 @@ public class PlayerGameListener implements Listener { CosmeticUser user = CosmeticUsers.getUser(player); if (user == null) return; if (user.isInWardrobe()) return; - CosmeticSlot cosmeticSlot = InventoryUtils.NMSCosmeticSlot(slotClicked); + CosmeticSlot cosmeticSlot = HMCCInventoryUtils.NMSCosmeticSlot(slotClicked); if (cosmeticSlot == null) return; if (!user.hasCosmeticInSlot(cosmeticSlot)) return; Bukkit.getScheduler().runTaskLater(HMCCosmeticsPlugin.getInstance(), () -> user.updateCosmetic(cosmeticSlot), 1); @@ -436,7 +453,7 @@ public class PlayerGameListener implements Listener { if (!user.isInWardrobe()) { for (Cosmetic cosmetic : user.getCosmetics()) { if ((cosmetic instanceof CosmeticArmorType cosmeticArmorType)) { - items.put(InventoryUtils.getPacketArmorSlot(cosmeticArmorType.getEquipSlot()), user.getUserCosmeticItem(cosmeticArmorType)); + items.put(HMCCInventoryUtils.getPacketArmorSlot(cosmeticArmorType.getEquipSlot()), user.getUserCosmeticItem(cosmeticArmorType)); } } } @@ -522,11 +539,11 @@ public class PlayerGameListener implements Listener { } } default -> { - CosmeticArmorType cosmeticArmor = (CosmeticArmorType) user.getCosmetic(InventoryUtils.getItemSlotToCosmeticSlot(pair.getFirst())); + CosmeticArmorType cosmeticArmor = (CosmeticArmorType) user.getCosmetic(HMCCInventoryUtils.getItemSlotToCosmeticSlot(pair.getFirst())); if (cosmeticArmor == null) continue; ItemStack item = user.getUserCosmeticItem(cosmeticArmor); if (item == null) continue; - Pair armorPair = new Pair<>(InventoryUtils.itemBukkitSlot(cosmeticArmor.getEquipSlot()), item); + Pair armorPair = new Pair<>(HMCCInventoryUtils.itemBukkitSlot(cosmeticArmor.getEquipSlot()), item); armor.set(i, armorPair); } } diff --git a/common/src/main/java/com/hibiscusmc/hmccosmetics/nms/NMSHandler.java b/common/src/main/java/com/hibiscusmc/hmccosmetics/nms/HMCCNMSHandler.java similarity index 77% rename from common/src/main/java/com/hibiscusmc/hmccosmetics/nms/NMSHandler.java rename to common/src/main/java/com/hibiscusmc/hmccosmetics/nms/HMCCNMSHandler.java index d98b0c99..9e0cb646 100644 --- a/common/src/main/java/com/hibiscusmc/hmccosmetics/nms/NMSHandler.java +++ b/common/src/main/java/com/hibiscusmc/hmccosmetics/nms/HMCCNMSHandler.java @@ -1,8 +1,5 @@ package com.hibiscusmc.hmccosmetics.nms; -import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticBalloonType; -import com.hibiscusmc.hmccosmetics.user.CosmeticUser; -import com.hibiscusmc.hmccosmetics.user.manager.UserBalloonManager; import org.bukkit.Location; import org.bukkit.entity.ArmorStand; import org.bukkit.entity.Entity; @@ -13,11 +10,7 @@ import org.bukkit.inventory.ItemStack; import java.util.HashMap; import java.util.List; -public interface NMSHandler { - - int getNextEntityId(); - - Entity getEntity(int entityId); +public interface HMCCNMSHandler { ArmorStand getMEGEntity(Location loc); diff --git a/common/src/main/java/com/hibiscusmc/hmccosmetics/nms/NMSHandlers.java b/common/src/main/java/com/hibiscusmc/hmccosmetics/nms/HMCCNMSHandlers.java similarity index 85% rename from common/src/main/java/com/hibiscusmc/hmccosmetics/nms/NMSHandlers.java rename to common/src/main/java/com/hibiscusmc/hmccosmetics/nms/HMCCNMSHandlers.java index 07bf93d8..098158c4 100644 --- a/common/src/main/java/com/hibiscusmc/hmccosmetics/nms/NMSHandlers.java +++ b/common/src/main/java/com/hibiscusmc/hmccosmetics/nms/HMCCNMSHandlers.java @@ -8,15 +8,15 @@ import org.jetbrains.annotations.Nullable; import java.lang.reflect.InvocationTargetException; import java.util.logging.Level; -public class NMSHandlers { +public class HMCCNMSHandlers { private static final String[] SUPPORTED_VERSION = new String[]{"v1_18_R2", "v1_19_R1", "v1_19_R2", "v1_19_R3", "v1_20_R1", "v1_20_R2", "v1_20_R3"}; - private static NMSHandler handler; + private static HMCCNMSHandler handler; @Getter private static String version; @Nullable - public static NMSHandler getHandler() { + public static HMCCNMSHandler getHandler() { if (handler != null) { return handler; } else { @@ -42,7 +42,7 @@ public class NMSHandlers { MessagesUtil.sendDebugMessages(packageVersion + " has been detected.", Level.INFO); version = packageVersion; try { - handler = (NMSHandler) Class.forName("com.hibiscusmc.hmccosmetics.nms." + packageVersion + ".NMSHandler").getConstructor().newInstance(); + handler = (HMCCNMSHandler) Class.forName("com.hibiscusmc.hmccosmetics.nms." + packageVersion + ".HMCCNMSHandler").getConstructor().newInstance(); return; } catch (ClassNotFoundException | InvocationTargetException | InstantiationException | IllegalAccessException | NoSuchMethodException e) { 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 0d1a9662..7aec0b88 100644 --- a/common/src/main/java/com/hibiscusmc/hmccosmetics/user/CosmeticUser.java +++ b/common/src/main/java/com/hibiscusmc/hmccosmetics/user/CosmeticUser.java @@ -13,17 +13,18 @@ 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.CosmeticMainhandType; -import com.hibiscusmc.hmccosmetics.hooks.Hooks; -import com.hibiscusmc.hmccosmetics.nms.NMSHandlers; +import com.hibiscusmc.hmccosmetics.nms.HMCCNMSHandlers; 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.InventoryUtils; +import com.hibiscusmc.hmccosmetics.util.HMCCInventoryUtils; import com.hibiscusmc.hmccosmetics.util.MessagesUtil; import com.hibiscusmc.hmccosmetics.util.PlayerUtils; -import com.hibiscusmc.hmccosmetics.util.packets.PacketManager; +import com.hibiscusmc.hmccosmetics.util.packets.HMCCPacketManager; import lombok.Getter; +import me.lojosho.hibiscuscommons.hooks.Hooks; +import me.lojosho.hibiscuscommons.util.InventoryUtils; import org.bukkit.Bukkit; import org.bukkit.Color; import org.bukkit.Material; @@ -197,13 +198,13 @@ public class CosmeticUser { if (!Settings.isCosmeticForceOffhandCosmeticShow() && armorType.getEquipSlot().equals(EquipmentSlot.OFF_HAND) && !getPlayer().getInventory().getItemInOffHand().getType().isAir()) continue; - items.put(InventoryUtils.getEquipmentSlot(armorType.getSlot()), armorType.getItem(this)); + items.put(HMCCInventoryUtils.getEquipmentSlot(armorType.getSlot()), armorType.getItem(this)); continue; } updateCosmetic(cosmetic.getSlot()); } if (items.isEmpty()) return; - NMSHandlers.getHandler().equipmentSlotUpdate(getEntity().getEntityId(), items, PlayerUtils.getNearbyPlayers(getEntity().getLocation())); + HMCCNMSHandlers.getHandler().equipmentSlotUpdate(getEntity().getEntityId(), items, PlayerUtils.getNearbyPlayers(getEntity().getLocation())); MessagesUtil.sendDebugMessages("updateCosmetic (All) - end - " + items.size()); } @@ -215,7 +216,7 @@ public class CosmeticUser { ItemStack item = null; if (hideCosmetics) { if (cosmetic instanceof CosmeticBackpackType || cosmetic instanceof CosmeticBalloonType) return new ItemStack(Material.AIR); - return getPlayer().getInventory().getItem(InventoryUtils.getEquipmentSlot(cosmetic.getSlot())); + return getPlayer().getInventory().getItem(HMCCInventoryUtils.getEquipmentSlot(cosmetic.getSlot())); } if (cosmetic instanceof CosmeticArmorType armorType) { item = armorType.getItem(this, cosmetic.getItem()); @@ -288,7 +289,7 @@ public class CosmeticUser { mapMeta.setColor(color); } } - itemMeta.getPersistentDataContainer().set(InventoryUtils.getCosmeticKey(), PersistentDataType.STRING, cosmetic.getId()); + itemMeta.getPersistentDataContainer().set(HMCCInventoryUtils.getCosmeticKey(), PersistentDataType.STRING, cosmetic.getId()); itemMeta.getPersistentDataContainer().set(InventoryUtils.getOwnerKey(), PersistentDataType.STRING, getEntity().getUniqueId().toString()); item.setItemMeta(itemMeta); @@ -402,7 +403,7 @@ public class CosmeticUser { if (this.userBalloonManager == null) return; List sentTo = PlayerUtils.getNearbyPlayers(getEntity().getLocation()); - PacketManager.sendEntityDestroyPacket(userBalloonManager.getPufferfishBalloonId(), sentTo); + HMCCPacketManager.sendEntityDestroyPacket(userBalloonManager.getPufferfishBalloonId(), sentTo); this.userBalloonManager.remove(); this.userBalloonManager = null; @@ -423,12 +424,12 @@ public class CosmeticUser { } public void removeArmor(CosmeticSlot slot) { - EquipmentSlot equipmentSlot = InventoryUtils.getEquipmentSlot(slot); + EquipmentSlot equipmentSlot = HMCCInventoryUtils.getEquipmentSlot(slot); if (equipmentSlot == null) return; if (getPlayer() != null) { - NMSHandlers.getHandler().equipmentSlotUpdate(getEntity().getEntityId(), equipmentSlot, getPlayer().getInventory().getItem(equipmentSlot), PlayerUtils.getNearbyPlayers(getEntity().getLocation())); + HMCCNMSHandlers.getHandler().equipmentSlotUpdate(getEntity().getEntityId(), equipmentSlot, getPlayer().getInventory().getItem(equipmentSlot), PlayerUtils.getNearbyPlayers(getEntity().getLocation())); } else { - PacketManager.equipmentSlotUpdate(getEntity().getEntityId(), this, slot, PlayerUtils.getNearbyPlayers(getEntity().getLocation())); + HMCCPacketManager.equipmentSlotUpdate(getEntity().getEntityId(), this, slot, PlayerUtils.getNearbyPlayers(getEntity().getLocation())); } } @@ -530,7 +531,7 @@ public class CosmeticUser { CosmeticBalloonType balloonType = (CosmeticBalloonType) getCosmetic(CosmeticSlot.BALLOON); getBalloonManager().addPlayerToModel(this, balloonType); List viewer = PlayerUtils.getNearbyPlayers(getEntity().getLocation()); - PacketManager.sendLeashPacket(getBalloonManager().getPufferfishBalloonId(), getPlayer().getEntityId(), viewer); + HMCCPacketManager.sendLeashPacket(getBalloonManager().getPufferfishBalloonId(), getPlayer().getEntityId(), viewer); } if (hasCosmeticInSlot(CosmeticSlot.BACKPACK) && isBackpackSpawned()) { CosmeticBackpackType cosmeticBackpackType = (CosmeticBackpackType) getCosmetic(CosmeticSlot.BACKPACK); 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 ea6d1655..f5c1d1a1 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 @@ -2,13 +2,14 @@ package com.hibiscusmc.hmccosmetics.user.manager; import com.hibiscusmc.hmccosmetics.cosmetic.CosmeticSlot; import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticBackpackType; -import com.hibiscusmc.hmccosmetics.hooks.Hooks; -import com.hibiscusmc.hmccosmetics.nms.NMSHandlers; +import com.hibiscusmc.hmccosmetics.nms.HMCCNMSHandlers; import com.hibiscusmc.hmccosmetics.user.CosmeticUser; import com.hibiscusmc.hmccosmetics.util.MessagesUtil; -import com.hibiscusmc.hmccosmetics.util.packets.PacketManager; +import com.hibiscusmc.hmccosmetics.util.packets.HMCCPacketManager; import com.ticxo.modelengine.api.ModelEngineAPI; import lombok.Getter; +import me.lojosho.hibiscuscommons.hooks.Hooks; +import me.lojosho.hibiscuscommons.util.ServerUtils; import org.bukkit.Material; import org.bukkit.entity.Entity; import org.bukkit.entity.EntityType; @@ -36,7 +37,7 @@ public class UserBackpackManager { public UserBackpackManager(CosmeticUser user) { this.user = user; this.backpackHidden = false; - this.invisibleArmorStand = NMSHandlers.getHandler().getNextEntityId(); + this.invisibleArmorStand = ServerUtils.getNextEntityId(); this.entityManager = new UserEntity(user.getUniqueId()); this.entityManager.refreshViewers(user.getEntity().getLocation()); } @@ -55,8 +56,8 @@ public class UserBackpackManager { getEntityManager().setIds(List.of(invisibleArmorStand)); getEntityManager().teleport(user.getEntity().getLocation()); List outsideViewers = getEntityManager().getViewers(); - PacketManager.sendEntitySpawnPacket(user.getEntity().getLocation(), getFirstArmorStandId(), EntityType.ARMOR_STAND, UUID.randomUUID(), getEntityManager().getViewers()); - PacketManager.sendArmorstandMetadata(getFirstArmorStandId(), outsideViewers); + HMCCPacketManager.sendEntitySpawnPacket(user.getEntity().getLocation(), getFirstArmorStandId(), EntityType.ARMOR_STAND, UUID.randomUUID(), getEntityManager().getViewers()); + HMCCPacketManager.sendArmorstandMetadata(getFirstArmorStandId(), outsideViewers); Entity entity = user.getEntity(); @@ -73,21 +74,21 @@ public class UserBackpackManager { if (cosmeticBackpackType.isFirstPersonCompadible()) { for (int i = particleCloud.size(); i < cosmeticBackpackType.getHeight(); i++) { - int entityId = NMSHandlers.getHandler().getNextEntityId(); - PacketManager.sendEntitySpawnPacket(user.getEntity().getLocation(), entityId, EntityType.AREA_EFFECT_CLOUD, UUID.randomUUID()); - PacketManager.sendCloudEffect(entityId, PacketManager.getViewers(user.getEntity().getLocation())); + int entityId = ServerUtils.getNextEntityId(); + HMCCPacketManager.sendEntitySpawnPacket(user.getEntity().getLocation(), entityId, EntityType.AREA_EFFECT_CLOUD, UUID.randomUUID()); + HMCCPacketManager.sendCloudEffect(entityId, HMCCPacketManager.getViewers(user.getEntity().getLocation())); this.particleCloud.add(entityId); } // Copied code from updating the backpack for (int i = 0; i < particleCloud.size(); i++) { - if (i == 0) PacketManager.sendRidingPacket(entity.getEntityId(), particleCloud.get(i), owner); - else PacketManager.sendRidingPacket(particleCloud.get(i - 1), particleCloud.get(i) , owner); + if (i == 0) HMCCPacketManager.sendRidingPacket(entity.getEntityId(), particleCloud.get(i), owner); + else HMCCPacketManager.sendRidingPacket(particleCloud.get(i - 1), particleCloud.get(i) , owner); } - PacketManager.sendRidingPacket(particleCloud.get(particleCloud.size() - 1), user.getUserBackpackManager().getFirstArmorStandId(), owner); - if (!user.getHidden()) NMSHandlers.getHandler().equipmentSlotUpdate(user.getUserBackpackManager().getFirstArmorStandId(), EquipmentSlot.HEAD, user.getUserCosmeticItem(cosmeticBackpackType, cosmeticBackpackType.getFirstPersonBackpack()), owner); + HMCCPacketManager.sendRidingPacket(particleCloud.get(particleCloud.size() - 1), user.getUserBackpackManager().getFirstArmorStandId(), owner); + if (!user.getHidden()) HMCCNMSHandlers.getHandler().equipmentSlotUpdate(user.getUserBackpackManager().getFirstArmorStandId(), EquipmentSlot.HEAD, user.getUserCosmeticItem(cosmeticBackpackType, cosmeticBackpackType.getFirstPersonBackpack()), owner); } - NMSHandlers.getHandler().equipmentSlotUpdate(getFirstArmorStandId(), EquipmentSlot.HEAD, user.getUserCosmeticItem(cosmeticBackpackType), outsideViewers); - PacketManager.sendRidingPacket(entity.getEntityId(), passengerIDs, outsideViewers); + HMCCNMSHandlers.getHandler().equipmentSlotUpdate(getFirstArmorStandId(), EquipmentSlot.HEAD, user.getUserCosmeticItem(cosmeticBackpackType), outsideViewers); + HMCCPacketManager.sendRidingPacket(entity.getEntityId(), passengerIDs, outsideViewers); // No one should be using ME because it barely works but some still use it, so it's here if (cosmeticBackpackType.getModelName() != null && Hooks.isActiveHook("ModelEngine")) { @@ -107,10 +108,10 @@ public class UserBackpackManager { } public void despawnBackpack() { - PacketManager.sendEntityDestroyPacket(invisibleArmorStand, getEntityManager().getViewers()); + HMCCPacketManager.sendEntityDestroyPacket(invisibleArmorStand, getEntityManager().getViewers()); if (particleCloud != null) { for (Integer entityId : particleCloud) { - PacketManager.sendEntityDestroyPacket(entityId, getEntityManager().getViewers()); + HMCCPacketManager.sendEntityDestroyPacket(entityId, getEntityManager().getViewers()); } this.particleCloud = null; } @@ -139,11 +140,11 @@ public class UserBackpackManager { } public void setItem(ItemStack item) { - NMSHandlers.getHandler().equipmentSlotUpdate(getFirstArmorStandId(), EquipmentSlot.HEAD, item, getEntityManager().getViewers()); + HMCCNMSHandlers.getHandler().equipmentSlotUpdate(getFirstArmorStandId(), EquipmentSlot.HEAD, item, getEntityManager().getViewers()); } public void clearItems() { ItemStack item = new ItemStack(Material.AIR); - NMSHandlers.getHandler().equipmentSlotUpdate(getFirstArmorStandId(), EquipmentSlot.HEAD, item, getEntityManager().getViewers()); + HMCCNMSHandlers.getHandler().equipmentSlotUpdate(getFirstArmorStandId(), EquipmentSlot.HEAD, item, getEntityManager().getViewers()); } } 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 07366f5b..7442776a 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 @@ -2,17 +2,18 @@ package com.hibiscusmc.hmccosmetics.user.manager; import com.hibiscusmc.hmccosmetics.config.Settings; import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticBalloonType; -import com.hibiscusmc.hmccosmetics.hooks.Hooks; -import com.hibiscusmc.hmccosmetics.nms.NMSHandlers; +import com.hibiscusmc.hmccosmetics.nms.HMCCNMSHandlers; import com.hibiscusmc.hmccosmetics.user.CosmeticUser; import com.hibiscusmc.hmccosmetics.user.CosmeticUsers; import com.hibiscusmc.hmccosmetics.util.MessagesUtil; -import com.hibiscusmc.hmccosmetics.util.packets.PacketManager; +import com.hibiscusmc.hmccosmetics.util.packets.HMCCPacketManager; import com.ticxo.modelengine.api.ModelEngineAPI; import com.ticxo.modelengine.api.entity.data.BukkitEntityData; import com.ticxo.modelengine.api.model.ActiveModel; import com.ticxo.modelengine.api.model.ModeledEntity; import lombok.Getter; +import me.lojosho.hibiscuscommons.hooks.Hooks; +import me.lojosho.hibiscuscommons.nms.NMSHandlers; import org.bukkit.Color; import org.bukkit.Location; import org.bukkit.entity.ArmorStand; @@ -37,7 +38,7 @@ public class UserBalloonManager { public UserBalloonManager(CosmeticUser user, @NotNull Location location) { this.user = user; this.pufferfish = new UserBalloonPufferfish(user.getUniqueId(), NMSHandlers.getHandler().getNextEntityId(), UUID.randomUUID()); - this.modelEntity = NMSHandlers.getHandler().getMEGEntity(location.add(Settings.getBalloonOffset())); + this.modelEntity = HMCCNMSHandlers.getHandler().getMEGEntity(location.add(Settings.getBalloonOffset())); } public void spawnModel(@NotNull CosmeticBalloonType cosmeticBalloonType, Color color) { @@ -169,16 +170,16 @@ public class UserBalloonManager { } public void sendRemoveLeashPacket(List viewer) { - PacketManager.sendLeashPacket(getPufferfishBalloonId(), -1, viewer); + HMCCPacketManager.sendLeashPacket(getPufferfishBalloonId(), -1, viewer); } public void sendRemoveLeashPacket() { - PacketManager.sendLeashPacket(getPufferfishBalloonId(), -1, getLocation()); + HMCCPacketManager.sendLeashPacket(getPufferfishBalloonId(), -1, getLocation()); } public void sendLeashPacket(int entityId) { if (cosmeticBalloonType.isShowLead()) { - PacketManager.sendLeashPacket(getPufferfishBalloonId(), entityId, getLocation()); + HMCCPacketManager.sendLeashPacket(getPufferfishBalloonId(), entityId, getLocation()); } } diff --git a/common/src/main/java/com/hibiscusmc/hmccosmetics/user/manager/UserBalloonPufferfish.java b/common/src/main/java/com/hibiscusmc/hmccosmetics/user/manager/UserBalloonPufferfish.java index ac8bca12..4b23bad8 100644 --- a/common/src/main/java/com/hibiscusmc/hmccosmetics/user/manager/UserBalloonPufferfish.java +++ b/common/src/main/java/com/hibiscusmc/hmccosmetics/user/manager/UserBalloonPufferfish.java @@ -3,7 +3,7 @@ package com.hibiscusmc.hmccosmetics.user.manager; import com.hibiscusmc.hmccosmetics.user.CosmeticUser; import com.hibiscusmc.hmccosmetics.user.CosmeticUsers; import com.hibiscusmc.hmccosmetics.util.PlayerUtils; -import com.hibiscusmc.hmccosmetics.util.packets.PacketManager; +import com.hibiscusmc.hmccosmetics.util.packets.HMCCPacketManager; import org.bukkit.Location; import org.bukkit.entity.EntityType; import org.bukkit.entity.Player; @@ -32,13 +32,13 @@ public class UserBalloonPufferfish extends UserEntity { } public void hidePufferfish() { - PacketManager.sendEntityDestroyPacket(pufferFishEntityId, getViewers()); + HMCCPacketManager.sendEntityDestroyPacket(pufferFishEntityId, getViewers()); getViewers().clear(); } public void spawnPufferfish(Location location, List sendTo) { - PacketManager.sendEntitySpawnPacket(location, pufferFishEntityId, EntityType.PUFFERFISH, uuid, sendTo); - PacketManager.sendInvisibilityPacket(pufferFishEntityId, sendTo); + HMCCPacketManager.sendEntitySpawnPacket(location, pufferFishEntityId, EntityType.PUFFERFISH, uuid, sendTo); + HMCCPacketManager.sendInvisibilityPacket(pufferFishEntityId, sendTo); } @Override @@ -52,7 +52,7 @@ public class UserBalloonPufferfish extends UserEntity { CosmeticUser user = CosmeticUsers.getUser(player); if (user != null && getOwner() != user.getUniqueId() && user.isInWardrobe()) { // Fixes issue where players in wardrobe would see other players cosmetics if they were not in wardrobe removePlayers.add(player); - PacketManager.sendEntityDestroyPacket(getPufferFishEntityId(), List.of(player)); + HMCCPacketManager.sendEntityDestroyPacket(getPufferFishEntityId(), List.of(player)); continue; } if (!getViewers().contains(player)) { @@ -64,7 +64,7 @@ public class UserBalloonPufferfish extends UserEntity { for (Player viewerPlayer : getViewers()) { if (!players.contains(viewerPlayer)) { removePlayers.add(viewerPlayer); - PacketManager.sendEntityDestroyPacket(getPufferFishEntityId(), List.of(viewerPlayer)); + HMCCPacketManager.sendEntityDestroyPacket(getPufferFishEntityId(), List.of(viewerPlayer)); } } } 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 2f5b968a..82d99568 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 @@ -4,7 +4,7 @@ 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.nms.NMSHandlers; +import com.hibiscusmc.hmccosmetics.nms.HMCCNMSHandlers; import com.hibiscusmc.hmccosmetics.user.CosmeticUser; import com.hibiscusmc.hmccosmetics.util.MessagesUtil; import org.bukkit.Bukkit; @@ -49,7 +49,7 @@ public class UserEmoteManager { } // Show the text if (text != null && textEntity == null) { - textEntity = NMSHandlers.getHandler().spawnDisplayEntity(user.getPlayer().getLocation().add(0, 3, 0), text); + textEntity = HMCCNMSHandlers.getHandler().spawnDisplayEntity(user.getPlayer().getLocation().add(0, 3, 0), text); } } catch (Exception e) { e.printStackTrace(); 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 c49e18ec..2aade4b0 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 @@ -2,12 +2,11 @@ package com.hibiscusmc.hmccosmetics.user.manager; import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin; import com.hibiscusmc.hmccosmetics.config.Settings; -import com.hibiscusmc.hmccosmetics.nms.NMSHandlers; import com.hibiscusmc.hmccosmetics.user.CosmeticUser; import com.hibiscusmc.hmccosmetics.util.MessagesUtil; -import com.hibiscusmc.hmccosmetics.util.ServerUtils; -import com.hibiscusmc.hmccosmetics.util.packets.PacketManager; +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; @@ -29,7 +28,7 @@ public class UserEmoteModel extends PlayerModel { public UserEmoteModel(@NotNull CosmeticUser user) { super(user.getPlayer()); this.user = user; - armorStandId = NMSHandlers.getHandler().getNextEntityId(); + armorStandId = ServerUtils.getNextEntityId(); getRangeManager().setRenderDistance(Settings.getViewDistance()); } @@ -42,9 +41,9 @@ public class UserEmoteModel extends PlayerModel { // Add config option that either allows player to move or forces them into a spot. Player player = user.getPlayer(); List viewer = Collections.singletonList(user.getPlayer()); - List outsideViewers = PacketManager.getViewers(player.getLocation()); + List outsideViewers = HMCCPacketManager.getViewers(player.getLocation()); // Send equipment packet to the player as well (Fixes Optifine still rendering armor when emoting) - PacketManager.equipmentSlotUpdate(player, true, outsideViewers); + HMCCPacketManager.equipmentSlotUpdate(player, true, outsideViewers); outsideViewers.remove(player); user.getPlayer().setInvisible(true); @@ -75,12 +74,12 @@ public class UserEmoteModel extends PlayerModel { MessagesUtil.sendMessage(player, "emote-blocked"); } - PacketManager.sendEntitySpawnPacket(thirdPersonLocation, armorStandId, EntityType.ARMOR_STAND, UUID.randomUUID(), viewer); - PacketManager.sendInvisibilityPacket(armorStandId, viewer); - PacketManager.sendLookPacket(armorStandId, thirdPersonLocation, viewer); + HMCCPacketManager.sendEntitySpawnPacket(thirdPersonLocation, armorStandId, EntityType.ARMOR_STAND, UUID.randomUUID(), viewer); + HMCCPacketManager.sendInvisibilityPacket(armorStandId, viewer); + HMCCPacketManager.sendLookPacket(armorStandId, thirdPersonLocation, viewer); - PacketManager.gamemodeChangePacket(player, 3); - PacketManager.sendCameraPacket(armorStandId, viewer); + HMCCPacketManager.gamemodeChangePacket(player, 3); + HMCCPacketManager.sendCameraPacket(armorStandId, viewer); } @@ -108,16 +107,16 @@ public class UserEmoteModel extends PlayerModel { if (player == null) return; List viewer = Collections.singletonList(player); - List outsideViewers = PacketManager.getViewers(player.getLocation()); + List outsideViewers = HMCCPacketManager.getViewers(player.getLocation()); // Send Equipment packet to all (Fixes Optifine Issue) - PacketManager.equipmentSlotUpdate(player, false, outsideViewers); + HMCCPacketManager.equipmentSlotUpdate(player, false, outsideViewers); outsideViewers.remove(player); int entityId = player.getEntityId(); - PacketManager.sendCameraPacket(entityId, viewer); - PacketManager.sendEntityDestroyPacket(armorStandId, viewer); + HMCCPacketManager.sendCameraPacket(entityId, viewer); + HMCCPacketManager.sendEntityDestroyPacket(armorStandId, viewer); if (this.originalGamemode != null) { - PacketManager.gamemodeChangePacket(player, ServerUtils.convertGamemode(this.originalGamemode)); + HMCCPacketManager.gamemodeChangePacket(player, com.hibiscusmc.hmccosmetics.util.ServerUtils.convertGamemode(this.originalGamemode)); player.setGameMode(this.originalGamemode); } diff --git a/common/src/main/java/com/hibiscusmc/hmccosmetics/user/manager/UserEntity.java b/common/src/main/java/com/hibiscusmc/hmccosmetics/user/manager/UserEntity.java index e500d294..7cd90b8a 100644 --- a/common/src/main/java/com/hibiscusmc/hmccosmetics/user/manager/UserEntity.java +++ b/common/src/main/java/com/hibiscusmc/hmccosmetics/user/manager/UserEntity.java @@ -4,7 +4,7 @@ import com.hibiscusmc.hmccosmetics.config.Settings; import com.hibiscusmc.hmccosmetics.user.CosmeticUser; import com.hibiscusmc.hmccosmetics.user.CosmeticUsers; import com.hibiscusmc.hmccosmetics.util.PlayerUtils; -import com.hibiscusmc.hmccosmetics.util.packets.PacketManager; +import com.hibiscusmc.hmccosmetics.util.packets.HMCCPacketManager; import lombok.Getter; import lombok.Setter; import org.bukkit.Location; @@ -47,7 +47,7 @@ public class UserEntity { CosmeticUser user = CosmeticUsers.getUser(player); if (user != null && owner != user.getUniqueId() && user.isInWardrobe()) { // Fixes issue where players in wardrobe would see other players cosmetics if they were not in wardrobe removePlayers.add(player); - PacketManager.sendEntityDestroyPacket(ids, List.of(player)); + HMCCPacketManager.sendEntityDestroyPacket(ids, List.of(player)); continue; } if (!viewers.contains(player)) { @@ -59,7 +59,7 @@ public class UserEntity { for (Player viewerPlayer : viewers) { if (!players.contains(viewerPlayer)) { removePlayers.add(viewerPlayer); - PacketManager.sendEntityDestroyPacket(ids, List.of(viewerPlayer)); + HMCCPacketManager.sendEntityDestroyPacket(ids, List.of(viewerPlayer)); } } } @@ -76,7 +76,7 @@ public class UserEntity { } this.location = location; for (Integer entity : ids) { - PacketManager.sendTeleportPacket(entity, location, false, getViewers()); + HMCCPacketManager.sendTeleportPacket(entity, location, false, getViewers()); } setLastPositionUpdate(System.currentTimeMillis()); } @@ -90,8 +90,8 @@ public class UserEntity { for (Integer entity : ids) { // First person backpacks need both packets to rotate properly, otherwise they look off // Regular backpacks just need the look packet - if (additonalPacket) PacketManager.sendRotationPacket(entity, yaw, false, getViewers()); - PacketManager.sendLookPacket(entity, location, getViewers()); + if (additonalPacket) HMCCPacketManager.sendRotationPacket(entity, yaw, false, getViewers()); + HMCCPacketManager.sendLookPacket(entity, location, getViewers()); } } } 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 0950b1e7..d46fb1cd 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 @@ -9,11 +9,11 @@ import com.hibiscusmc.hmccosmetics.cosmetic.CosmeticSlot; import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticBalloonType; import com.hibiscusmc.hmccosmetics.gui.Menu; import com.hibiscusmc.hmccosmetics.gui.Menus; -import com.hibiscusmc.hmccosmetics.nms.NMSHandlers; +import com.hibiscusmc.hmccosmetics.nms.HMCCNMSHandlers; import com.hibiscusmc.hmccosmetics.user.CosmeticUser; import com.hibiscusmc.hmccosmetics.util.MessagesUtil; import com.hibiscusmc.hmccosmetics.util.ServerUtils; -import com.hibiscusmc.hmccosmetics.util.packets.PacketManager; +import com.hibiscusmc.hmccosmetics.util.packets.HMCCPacketManager; import lombok.Getter; import net.kyori.adventure.audience.Audience; import net.kyori.adventure.bossbar.BossBar; @@ -68,8 +68,8 @@ public class UserWardrobeManager { private WardrobeStatus wardrobeStatus; public UserWardrobeManager(CosmeticUser user, Wardrobe wardrobe) { - NPC_ID = NMSHandlers.getHandler().getNextEntityId(); - ARMORSTAND_ID = NMSHandlers.getHandler().getNextEntityId(); + NPC_ID = me.lojosho.hibiscuscommons.util.ServerUtils.getNextEntityId(); + ARMORSTAND_ID = me.lojosho.hibiscuscommons.util.ServerUtils.getNextEntityId(); WARDROBE_UUID = UUID.randomUUID(); this.user = user; @@ -94,50 +94,50 @@ public class UserWardrobeManager { user.hidePlayer(); List viewer = Collections.singletonList(player); - List outsideViewers = PacketManager.getViewers(viewingLocation); + List outsideViewers = HMCCPacketManager.getViewers(viewingLocation); outsideViewers.remove(player); MessagesUtil.sendMessage(player, "opened-wardrobe"); Runnable run = () -> { // Armorstand - PacketManager.sendEntitySpawnPacket(viewingLocation, ARMORSTAND_ID, EntityType.ARMOR_STAND, UUID.randomUUID(), viewer); - PacketManager.sendArmorstandMetadata(ARMORSTAND_ID, viewer); - PacketManager.sendLookPacket(ARMORSTAND_ID, viewingLocation, viewer); + HMCCPacketManager.sendEntitySpawnPacket(viewingLocation, ARMORSTAND_ID, EntityType.ARMOR_STAND, UUID.randomUUID(), viewer); + HMCCPacketManager.sendArmorstandMetadata(ARMORSTAND_ID, viewer); + HMCCPacketManager.sendLookPacket(ARMORSTAND_ID, viewingLocation, viewer); // Player user.getPlayer().teleport(viewingLocation, PlayerTeleportEvent.TeleportCause.PLUGIN); user.getPlayer().setInvisible(true); - PacketManager.gamemodeChangePacket(player, 3); - PacketManager.sendCameraPacket(ARMORSTAND_ID, viewer); + HMCCPacketManager.gamemodeChangePacket(player, 3); + HMCCPacketManager.sendCameraPacket(ARMORSTAND_ID, viewer); // NPC npcName = "WardrobeNPC-" + NPC_ID; while (npcName.length() > 16) { npcName = npcName.substring(16); } - PacketManager.sendFakePlayerInfoPacket(player, NPC_ID, WARDROBE_UUID, npcName, viewer); + HMCCPacketManager.sendFakePlayerInfoPacket(player, NPC_ID, WARDROBE_UUID, npcName, viewer); // NPC 2 Bukkit.getScheduler().runTaskLater(HMCCosmeticsPlugin.getInstance(), () -> { if (!user.isInWardrobe()) return; // If a player exits the wardrobe right away, no need to spawn the NPC - PacketManager.sendFakePlayerSpawnPacket(npcLocation, WARDROBE_UUID, NPC_ID, viewer); - PacketManager.sendPlayerOverlayPacket(NPC_ID, viewer); + HMCCPacketManager.sendFakePlayerSpawnPacket(npcLocation, WARDROBE_UUID, NPC_ID, viewer); + HMCCPacketManager.sendPlayerOverlayPacket(NPC_ID, viewer); MessagesUtil.sendDebugMessages("Spawned Fake Player on " + npcLocation); - NMSHandlers.getHandler().hideNPCName(player, npcName); + HMCCNMSHandlers.getHandler().hideNPCName(player, npcName); }, 4); // Location - PacketManager.sendLookPacket(NPC_ID, npcLocation, viewer); - PacketManager.sendRotationPacket(NPC_ID, npcLocation, true, viewer); + HMCCPacketManager.sendLookPacket(NPC_ID, npcLocation, viewer); + HMCCPacketManager.sendRotationPacket(NPC_ID, npcLocation, true, viewer); // Misc if (user.hasCosmeticInSlot(CosmeticSlot.BACKPACK)) { // Maybe null as backpack maybe despawned before entering if (user.getUserBackpackManager() == null) user.respawnBackpack(); user.getUserBackpackManager().getEntityManager().teleport(npcLocation.clone().add(0, 2, 0)); - NMSHandlers.getHandler().equipmentSlotUpdate(user.getUserBackpackManager().getFirstArmorStandId(), EquipmentSlot.HEAD, user.getUserCosmeticItem(user.getCosmetic(CosmeticSlot.BACKPACK)), viewer); - PacketManager.ridingMountPacket(NPC_ID, user.getUserBackpackManager().getFirstArmorStandId(), viewer); + HMCCNMSHandlers.getHandler().equipmentSlotUpdate(user.getUserBackpackManager().getFirstArmorStandId(), EquipmentSlot.HEAD, user.getUserCosmeticItem(user.getCosmetic(CosmeticSlot.BACKPACK)), viewer); + HMCCPacketManager.ridingMountPacket(NPC_ID, user.getUserBackpackManager().getFirstArmorStandId(), viewer); } if (user.hasCosmeticInSlot(CosmeticSlot.BALLOON)) { @@ -147,7 +147,7 @@ public class UserWardrobeManager { //PacketManager.sendLeashPacket(VIEWER.getBalloonEntity().getModelId(), NPC_ID, viewer); Location balloonLocation = npcLocation.clone().add(cosmetic.getBalloonOffset()); - PacketManager.sendTeleportPacket(user.getBalloonManager().getPufferfishBalloonId(), balloonLocation , false, viewer); + HMCCPacketManager.sendTeleportPacket(user.getBalloonManager().getPufferfishBalloonId(), balloonLocation , false, viewer); user.getBalloonManager().getModelEntity().teleport(balloonLocation); user.getBalloonManager().setLocation(balloonLocation); } @@ -193,7 +193,7 @@ public class UserWardrobeManager { Player player = user.getPlayer(); List viewer = Collections.singletonList(player); - List outsideViewers = PacketManager.getViewers(viewingLocation); + List outsideViewers = HMCCPacketManager.getViewers(viewingLocation); outsideViewers.remove(player); if (player != null) MessagesUtil.sendMessage(player, "closed-wardrobe"); @@ -212,25 +212,25 @@ public class UserWardrobeManager { // NPC if (user.hasCosmeticInSlot(CosmeticSlot.BALLOON)) user.getBalloonManager().sendRemoveLeashPacket(); - PacketManager.sendEntityDestroyPacket(NPC_ID, viewer); // Success - PacketManager.sendRemovePlayerPacket(player, WARDROBE_UUID, viewer); // Success + HMCCPacketManager.sendEntityDestroyPacket(NPC_ID, viewer); // Success + HMCCPacketManager.sendRemovePlayerPacket(player, WARDROBE_UUID, viewer); // Success // Player - PacketManager.sendCameraPacket(player.getEntityId(), viewer); + HMCCPacketManager.sendCameraPacket(player.getEntityId(), viewer); user.getPlayer().setInvisible(false); // Armorstand - PacketManager.sendEntityDestroyPacket(ARMORSTAND_ID, viewer); // Sucess + HMCCPacketManager.sendEntityDestroyPacket(ARMORSTAND_ID, viewer); // Sucess //PacketManager.sendEntityDestroyPacket(player.getEntityId(), viewer); // Success if (WardrobeSettings.isForceExitGamemode()) { MessagesUtil.sendDebugMessages("Force Exit Gamemode " + WardrobeSettings.getExitGamemode()); player.setGameMode(WardrobeSettings.getExitGamemode()); - PacketManager.gamemodeChangePacket(player, ServerUtils.convertGamemode(WardrobeSettings.getExitGamemode())); // Success + HMCCPacketManager.gamemodeChangePacket(player, ServerUtils.convertGamemode(WardrobeSettings.getExitGamemode())); // Success } else { MessagesUtil.sendDebugMessages("Original Gamemode " + this.originalGamemode); player.setGameMode(this.originalGamemode); - PacketManager.gamemodeChangePacket(player, ServerUtils.convertGamemode(this.originalGamemode)); // Success + HMCCPacketManager.gamemodeChangePacket(player, ServerUtils.convertGamemode(this.originalGamemode)); // Success } user.showPlayer(); @@ -247,7 +247,7 @@ public class UserWardrobeManager { player.teleport(Objects.requireNonNullElseGet(exitLocation, () -> player.getWorld().getSpawnLocation()), PlayerTeleportEvent.TeleportCause.PLUGIN); if (WardrobeSettings.isEquipPumpkin()) { - NMSHandlers.getHandler().equipmentSlotUpdate(user.getPlayer().getEntityId(), EquipmentSlot.HEAD, player.getInventory().getHelmet(), viewer); + HMCCNMSHandlers.getHandler().equipmentSlotUpdate(user.getPlayer().getEntityId(), EquipmentSlot.HEAD, player.getInventory().getHelmet(), viewer); } if (WardrobeSettings.isEnabledBossbar()) { @@ -275,30 +275,30 @@ public class UserWardrobeManager { } MessagesUtil.sendDebugMessages("WardrobeUpdate[user=" + user.getUniqueId() + ",status=" + getWardrobeStatus() + "]"); List viewer = Collections.singletonList(player); - List outsideViewers = PacketManager.getViewers(viewingLocation); + List outsideViewers = HMCCPacketManager.getViewers(viewingLocation); outsideViewers.remove(player); Location location = npcLocation; int yaw = data.get(); location.setYaw(yaw); - PacketManager.sendLookPacket(NPC_ID, location, viewer); + HMCCPacketManager.sendLookPacket(NPC_ID, location, viewer); user.hidePlayer(); int rotationSpeed = WardrobeSettings.getRotationSpeed(); location.setYaw(ServerUtils.getNextYaw(yaw - 30, rotationSpeed)); - PacketManager.sendRotationPacket(NPC_ID, location, true, viewer); + HMCCPacketManager.sendRotationPacket(NPC_ID, location, true, viewer); int nextyaw = ServerUtils.getNextYaw(yaw, rotationSpeed); data.set(nextyaw); for (CosmeticSlot slot : CosmeticSlot.values()) { - PacketManager.equipmentSlotUpdate(NPC_ID, user, slot, viewer); + HMCCPacketManager.equipmentSlotUpdate(NPC_ID, user, slot, viewer); } if (user.hasCosmeticInSlot(CosmeticSlot.BACKPACK) && user.getUserBackpackManager() != null) { - PacketManager.sendTeleportPacket(user.getUserBackpackManager().getFirstArmorStandId(), location, false, viewer); - PacketManager.ridingMountPacket(NPC_ID, user.getUserBackpackManager().getFirstArmorStandId(), viewer); + HMCCPacketManager.sendTeleportPacket(user.getUserBackpackManager().getFirstArmorStandId(), location, false, viewer); + HMCCPacketManager.ridingMountPacket(NPC_ID, user.getUserBackpackManager().getFirstArmorStandId(), viewer); user.getUserBackpackManager().getEntityManager().setRotation(nextyaw); - PacketManager.sendEntityDestroyPacket(user.getUserBackpackManager().getFirstArmorStandId(), outsideViewers); + HMCCPacketManager.sendEntityDestroyPacket(user.getUserBackpackManager().getFirstArmorStandId(), outsideViewers); } if (user.hasCosmeticInSlot(CosmeticSlot.BALLOON)) { @@ -307,15 +307,15 @@ public class UserWardrobeManager { //user.getBalloonManager().getModelEntity().teleport(npcLocation.add(Settings.getBalloonOffset())); user.getBalloonManager().sendRemoveLeashPacket(outsideViewers); if (user.getBalloonManager().getBalloonType() != UserBalloonManager.BalloonType.MODELENGINE) { - PacketManager.sendEntityDestroyPacket(user.getBalloonManager().getModelId(), outsideViewers); + HMCCPacketManager.sendEntityDestroyPacket(user.getBalloonManager().getModelId(), outsideViewers); } user.getBalloonManager().sendLeashPacket(NPC_ID); } if (WardrobeSettings.isEquipPumpkin()) { - NMSHandlers.getHandler().equipmentSlotUpdate(user.getPlayer().getEntityId(), EquipmentSlot.HEAD, new ItemStack(Material.CARVED_PUMPKIN), viewer); + HMCCNMSHandlers.getHandler().equipmentSlotUpdate(user.getPlayer().getEntityId(), EquipmentSlot.HEAD, new ItemStack(Material.CARVED_PUMPKIN), viewer); } else { - PacketManager.equipmentSlotUpdate(user.getPlayer(), true, viewer); // Optifine dumbassery + HMCCPacketManager.equipmentSlotUpdate(user.getPlayer(), true, viewer); // Optifine dumbassery } } }; diff --git a/common/src/main/java/com/hibiscusmc/hmccosmetics/util/InventoryUtils.java b/common/src/main/java/com/hibiscusmc/hmccosmetics/util/HMCCInventoryUtils.java similarity index 92% rename from common/src/main/java/com/hibiscusmc/hmccosmetics/util/InventoryUtils.java rename to common/src/main/java/com/hibiscusmc/hmccosmetics/util/HMCCInventoryUtils.java index 18c75154..271649bf 100644 --- a/common/src/main/java/com/hibiscusmc/hmccosmetics/util/InventoryUtils.java +++ b/common/src/main/java/com/hibiscusmc/hmccosmetics/util/HMCCInventoryUtils.java @@ -11,7 +11,7 @@ import org.jetbrains.annotations.Contract; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -public class InventoryUtils { +public class HMCCInventoryUtils { /** * Converts from the Bukkit item slots to ProtocolLib item slots. Will produce a null if an improper bukkit item slot is sent through @@ -163,16 +163,4 @@ public class InventoryUtils { public static NamespacedKey getCosmeticKey() { return new NamespacedKey(HMCCosmeticsPlugin.getInstance(), "cosmetic"); } - - public static NamespacedKey getOwnerKey() { - return new NamespacedKey(HMCCosmeticsPlugin.getInstance(), "owner"); - } - - public static NamespacedKey getSkullOwner() { - return new NamespacedKey(HMCCosmeticsPlugin.getInstance(), "skullowner"); - } - - public static NamespacedKey getSkullTexture() { - return new NamespacedKey(HMCCosmeticsPlugin.getInstance(), "skulltexture"); - } } diff --git a/common/src/main/java/com/hibiscusmc/hmccosmetics/util/MessagesUtil.java b/common/src/main/java/com/hibiscusmc/hmccosmetics/util/MessagesUtil.java index 96648e90..5c8ffa1d 100644 --- a/common/src/main/java/com/hibiscusmc/hmccosmetics/util/MessagesUtil.java +++ b/common/src/main/java/com/hibiscusmc/hmccosmetics/util/MessagesUtil.java @@ -2,9 +2,10 @@ package com.hibiscusmc.hmccosmetics.util; import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin; import com.hibiscusmc.hmccosmetics.config.Settings; -import com.hibiscusmc.hmccosmetics.hooks.Hooks; import com.hibiscusmc.hmccosmetics.user.CosmeticUser; -import com.hibiscusmc.hmccosmetics.util.misc.Adventure; +import me.lojosho.hibiscuscommons.hooks.Hooks; +import me.lojosho.hibiscuscommons.util.Adventure; +import me.lojosho.shaded.configurate.ConfigurationNode; import net.kyori.adventure.audience.Audience; import net.kyori.adventure.platform.bukkit.BukkitAudiences; import net.kyori.adventure.text.Component; @@ -14,7 +15,6 @@ import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import org.spongepowered.configurate.ConfigurationNode; import java.time.Duration; import java.util.HashMap; diff --git a/common/src/main/java/com/hibiscusmc/hmccosmetics/util/PlayerUtils.java b/common/src/main/java/com/hibiscusmc/hmccosmetics/util/PlayerUtils.java index 739a0a66..97448418 100644 --- a/common/src/main/java/com/hibiscusmc/hmccosmetics/util/PlayerUtils.java +++ b/common/src/main/java/com/hibiscusmc/hmccosmetics/util/PlayerUtils.java @@ -3,13 +3,12 @@ package com.hibiscusmc.hmccosmetics.util; import com.comphenix.protocol.wrappers.WrappedGameProfile; import com.comphenix.protocol.wrappers.WrappedSignedProperty; import com.hibiscusmc.hmccosmetics.config.Settings; +import me.lojosho.hibiscuscommons.util.packets.PacketManager; import org.bukkit.Location; -import org.bukkit.entity.Entity; import org.bukkit.entity.Player; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import java.util.ArrayList; import java.util.List; public class PlayerUtils { @@ -32,13 +31,6 @@ public class PlayerUtils { @NotNull public static List getNearbyPlayers(@NotNull Location location) { - List players = new ArrayList<>(); - int viewDistance = Settings.getViewDistance(); - for (Entity entity : location.getWorld().getNearbyEntities(location, viewDistance, viewDistance, viewDistance)) { - if (entity instanceof Player) { - players.add((Player) entity); - } - } - return players; + return PacketManager.getViewers(location, Settings.getViewDistance()); } } diff --git a/common/src/main/java/com/hibiscusmc/hmccosmetics/util/ServerUtils.java b/common/src/main/java/com/hibiscusmc/hmccosmetics/util/ServerUtils.java index 3a3aebf6..69d08157 100644 --- a/common/src/main/java/com/hibiscusmc/hmccosmetics/util/ServerUtils.java +++ b/common/src/main/java/com/hibiscusmc/hmccosmetics/util/ServerUtils.java @@ -1,11 +1,11 @@ package com.hibiscusmc.hmccosmetics.util; -import com.hibiscusmc.hmccosmetics.nms.NMSHandlers; import com.owen1212055.particlehelper.api.particle.MultiParticle; import com.owen1212055.particlehelper.api.particle.Particle; import com.owen1212055.particlehelper.api.particle.types.*; import com.owen1212055.particlehelper.api.particle.types.dust.transition.TransitionDustParticle; import com.owen1212055.particlehelper.api.particle.types.note.MultiNoteParticle; +import me.lojosho.hibiscuscommons.nms.NMSHandlers; import org.bukkit.Color; import org.bukkit.GameMode; import org.bukkit.Material; diff --git a/common/src/main/java/com/hibiscusmc/hmccosmetics/util/TranslationUtil.java b/common/src/main/java/com/hibiscusmc/hmccosmetics/util/TranslationUtil.java index 0acb8a39..cd403de3 100644 --- a/common/src/main/java/com/hibiscusmc/hmccosmetics/util/TranslationUtil.java +++ b/common/src/main/java/com/hibiscusmc/hmccosmetics/util/TranslationUtil.java @@ -1,7 +1,7 @@ package com.hibiscusmc.hmccosmetics.util; -import com.hibiscusmc.hmccosmetics.util.misc.StringUtils; -import org.spongepowered.configurate.ConfigurationNode; +import me.lojosho.hibiscuscommons.util.StringUtils; +import me.lojosho.shaded.configurate.ConfigurationNode; import java.util.ArrayList; import java.util.HashMap; diff --git a/common/src/main/java/com/hibiscusmc/hmccosmetics/util/builder/ColorBuilder.java b/common/src/main/java/com/hibiscusmc/hmccosmetics/util/builder/ColorBuilder.java deleted file mode 100644 index 61dff661..00000000 --- a/common/src/main/java/com/hibiscusmc/hmccosmetics/util/builder/ColorBuilder.java +++ /dev/null @@ -1,39 +0,0 @@ -package com.hibiscusmc.hmccosmetics.util.builder; - -import org.bukkit.Color; -import org.bukkit.Material; -import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.meta.ItemMeta; -import org.bukkit.inventory.meta.LeatherArmorMeta; -import org.bukkit.inventory.meta.PotionMeta; -import org.jetbrains.annotations.NotNull; - -public class ColorBuilder { - - public static boolean canBeColored(final Material material) { - return canBeColored(new ItemStack(material)); - } - - public static boolean canBeColored(final @NotNull ItemStack itemStack) { - final ItemMeta itemMeta = itemStack.getItemMeta(); - - return (itemMeta instanceof LeatherArmorMeta || - itemMeta instanceof PotionMeta); - } - - /** - * @param color armor color - * @return this - */ - - public static ItemMeta color(ItemMeta itemMeta, final Color color) { - if (itemMeta instanceof final PotionMeta meta) { - meta.setColor(color); - } - if (itemMeta instanceof final LeatherArmorMeta meta) { - meta.setColor(color); - } - return itemMeta; - } - -} diff --git a/common/src/main/java/com/hibiscusmc/hmccosmetics/util/misc/Adventure.java b/common/src/main/java/com/hibiscusmc/hmccosmetics/util/misc/Adventure.java deleted file mode 100644 index 745eb3f1..00000000 --- a/common/src/main/java/com/hibiscusmc/hmccosmetics/util/misc/Adventure.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.hibiscusmc.hmccosmetics.util.misc; - -import net.kyori.adventure.text.minimessage.MiniMessage; -import net.kyori.adventure.text.minimessage.tag.standard.StandardTags; -import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer; - -public class Adventure { - - public static final LegacyComponentSerializer SERIALIZER = LegacyComponentSerializer.builder() - .hexColors() - .useUnusualXRepeatedCharacterHexFormat() - .build(); - - public static final MiniMessage MINI_MESSAGE = MiniMessage.builder().tags( - StandardTags.defaults() - ). - build(); -} \ No newline at end of file diff --git a/common/src/main/java/com/hibiscusmc/hmccosmetics/util/misc/StringUtils.java b/common/src/main/java/com/hibiscusmc/hmccosmetics/util/misc/StringUtils.java deleted file mode 100644 index 5c33d6b1..00000000 --- a/common/src/main/java/com/hibiscusmc/hmccosmetics/util/misc/StringUtils.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.hibiscusmc.hmccosmetics.util.misc; - -import net.kyori.adventure.text.Component; -import org.jetbrains.annotations.NotNull; - -public class StringUtils { - - /** - * @param parsed message to be parsed - * @return MiniMessage parsed string - */ - @NotNull - public static Component parse(final String parsed) { - return Adventure.MINI_MESSAGE.deserialize(parsed); - } - - @NotNull - public static String parseStringToString(final String parsed) { - return Adventure.SERIALIZER.serialize(Adventure.MINI_MESSAGE.deserialize(parsed)); - } -} diff --git a/common/src/main/java/com/hibiscusmc/hmccosmetics/util/packets/PacketManager.java b/common/src/main/java/com/hibiscusmc/hmccosmetics/util/packets/HMCCPacketManager.java similarity index 74% rename from common/src/main/java/com/hibiscusmc/hmccosmetics/util/packets/PacketManager.java rename to common/src/main/java/com/hibiscusmc/hmccosmetics/util/packets/HMCCPacketManager.java index 971c1260..0746a3e5 100644 --- a/common/src/main/java/com/hibiscusmc/hmccosmetics/util/packets/PacketManager.java +++ b/common/src/main/java/com/hibiscusmc/hmccosmetics/util/packets/HMCCPacketManager.java @@ -7,16 +7,15 @@ import com.comphenix.protocol.wrappers.*; import com.google.common.collect.Lists; import com.hibiscusmc.hmccosmetics.config.Settings; import com.hibiscusmc.hmccosmetics.cosmetic.CosmeticSlot; -import com.hibiscusmc.hmccosmetics.nms.NMSHandlers; +import com.hibiscusmc.hmccosmetics.nms.HMCCNMSHandlers; import com.hibiscusmc.hmccosmetics.user.CosmeticUser; import com.hibiscusmc.hmccosmetics.user.CosmeticUsers; -import com.hibiscusmc.hmccosmetics.util.InventoryUtils; -import com.hibiscusmc.hmccosmetics.util.MessagesUtil; +import com.hibiscusmc.hmccosmetics.util.HMCCInventoryUtils; import com.hibiscusmc.hmccosmetics.util.PlayerUtils; import com.hibiscusmc.hmccosmetics.util.packets.wrappers.WrapperPlayServerNamedEntitySpawn; import com.hibiscusmc.hmccosmetics.util.packets.wrappers.WrapperPlayServerPlayerInfo; import com.hibiscusmc.hmccosmetics.util.packets.wrappers.WrapperPlayServerRelEntityMove; -import it.unimi.dsi.fastutil.ints.IntArrayList; +import me.lojosho.hibiscuscommons.util.packets.PacketManager; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.entity.EntityType; @@ -27,7 +26,7 @@ import org.jetbrains.annotations.NotNull; import java.util.*; -public class PacketManager { +public class HMCCPacketManager extends PacketManager { public static void sendEntitySpawnPacket( final @NotNull Location location, @@ -57,29 +56,6 @@ public class PacketManager { for (Player p : sendTo) sendPacket(p, packet); } - public static void gamemodeChangePacket( - Player player, - int gamemode - ) { - PacketContainer packet = new PacketContainer(PacketType.Play.Server.GAME_STATE_CHANGE); - packet.getGameStateIDs().write(0, 3); - // Tells what event this is. This is a change gamemode event. - packet.getFloat().write(0, (float) gamemode); - sendPacket(player, packet); - MessagesUtil.sendDebugMessages("Gamemode Change sent to " + player + " to be " + gamemode); - } - - public static void ridingMountPacket( - int mountId, - int passengerId, - @NotNull List sendTo - ) { - PacketContainer packet = new PacketContainer(PacketType.Play.Server.MOUNT); - packet.getIntegers().write(0, mountId); - packet.getIntegerArrays().write(0, new int[]{passengerId}); - for (Player p : sendTo) sendPacket(p, packet); - } - public static void equipmentSlotUpdate( Player player, boolean empty, @@ -91,7 +67,7 @@ public class PacketManager { if (empty) item = new ItemStack(Material.AIR); items.put(slot, item); } - NMSHandlers.getHandler().equipmentSlotUpdate(player.getEntityId(), items, sendTo); + HMCCNMSHandlers.getHandler().equipmentSlotUpdate(player.getEntityId(), items, sendTo); } public static void equipmentSlotUpdate( @NotNull Player player, @@ -117,7 +93,7 @@ public class PacketManager { ) { if (cosmeticSlot == CosmeticSlot.BACKPACK || cosmeticSlot == CosmeticSlot.BALLOON || cosmeticSlot == CosmeticSlot.EMOTE) return; - NMSHandlers.getHandler().equipmentSlotUpdate(entityId, InventoryUtils.getEquipmentSlot(cosmeticSlot), user.getUserCosmeticItem(cosmeticSlot), sendTo); + HMCCNMSHandlers.getHandler().equipmentSlotUpdate(entityId, HMCCInventoryUtils.getEquipmentSlot(cosmeticSlot), user.getUserCosmeticItem(cosmeticSlot), sendTo); } public static void sendArmorstandMetadata( @@ -129,7 +105,7 @@ public class PacketManager { packet.getIntegers().write(0, entityId); WrappedDataWatcher wrapper = new WrappedDataWatcher(); - if (NMSHandlers.getVersion().contains("v1_18_R2") || NMSHandlers.getVersion().contains("v1_19_R1")) { + if (HMCCNMSHandlers.getVersion().contains("v1_18_R2") || HMCCNMSHandlers.getVersion().contains("v1_19_R1")) { wrapper.setObject(new WrappedDataWatcher.WrappedDataWatcherObject(0, WrappedDataWatcher.Registry.get(Byte.class)), (byte) 0x20); wrapper.setObject(new WrappedDataWatcher.WrappedDataWatcherObject(15, WrappedDataWatcher.Registry.get(Byte.class)), (byte) 0x10); packet.getWatchableCollectionModifier().write(0, wrapper.getWatchableObjects()); @@ -151,7 +127,7 @@ public class PacketManager { packet.getIntegers().write(0, entityId); WrappedDataWatcher wrapper = new WrappedDataWatcher(); - if (NMSHandlers.getVersion().contains("v1_18_R2") || NMSHandlers.getVersion().contains("v1_19_R1")) { + if (HMCCNMSHandlers.getVersion().contains("v1_18_R2") || HMCCNMSHandlers.getVersion().contains("v1_19_R1")) { wrapper.setObject(new WrappedDataWatcher.WrappedDataWatcherObject(0, WrappedDataWatcher.Registry.get(Byte.class)), (byte) 0x20); packet.getWatchableCollectionModifier().write(0, wrapper.getWatchableObjects()); } else { @@ -171,7 +147,7 @@ public class PacketManager { packet.getIntegers().write(0, entityId); WrappedDataWatcher wrapper = new WrappedDataWatcher(); - if (NMSHandlers.getVersion().contains("v1_18_R2") || NMSHandlers.getVersion().contains("v1_19_R1")) { + if (HMCCNMSHandlers.getVersion().contains("v1_18_R2") || HMCCNMSHandlers.getVersion().contains("v1_19_R1")) { wrapper.setObject(new WrappedDataWatcher.WrappedDataWatcherObject(0, WrappedDataWatcher.Registry.get(Byte.class)), (byte) 0x20); wrapper.setObject(new WrappedDataWatcher.WrappedDataWatcherObject(8, WrappedDataWatcher.Registry.get(Float.class)), 0f); packet.getWatchableCollectionModifier().write(0, wrapper.getWatchableObjects()); @@ -185,17 +161,6 @@ public class PacketManager { for (Player p : sendTo) sendPacket(p, packet); } - public static void sendLookPacket( - int entityId, - @NotNull Location location, - @NotNull List sendTo - ) { - PacketContainer packet = new PacketContainer(PacketType.Play.Server.ENTITY_HEAD_ROTATION); - packet.getIntegers().write(0, entityId); - packet.getBytes().write(0, (byte) (location.getYaw() * 256.0F / 360.0F)); - for (Player p : sendTo) sendPacket(p, packet); - } - public static void sendRotationPacket( int entityId, Location location, @@ -288,41 +253,6 @@ public class PacketManager { sendRidingPacket(mountId, new int[] {passengerId}, sendTo); } - /** - * Destroys an entity from a player - * @param entityId The entity to delete for a player - * @param sendTo The players the packet should be sent to - */ - public static void sendEntityDestroyPacket(final int entityId, @NotNull List sendTo) { - PacketContainer packet = new PacketContainer(PacketType.Play.Server.ENTITY_DESTROY); - packet.getModifier().write(0, new IntArrayList(new int[]{entityId})); - for (final Player p : sendTo) sendPacket(p, packet); - } - - /** - * Destroys an entity from a player - * @param sendTo The players the packet should be sent to - */ - public static void sendEntityDestroyPacket(final List ids, @NotNull List sendTo) { - PacketContainer packet = new PacketContainer(PacketType.Play.Server.ENTITY_DESTROY); - IntArrayList entities = new IntArrayList(new int[]{}); - for (int id : ids) entities.add(id); - packet.getModifier().write(0, entities); - for (final Player p : sendTo) sendPacket(p, packet); - } - - /** - * Sends a camera packet - * @param entityId The Entity ID that camera will go towards - * @param sendTo The players that will be sent this packet - */ - public static void sendCameraPacket(final int entityId, @NotNull List sendTo) { - PacketContainer packet = new PacketContainer(PacketType.Play.Server.CAMERA); - packet.getIntegers().write(0, entityId); - for (final Player p : sendTo) sendPacket(p, packet); - MessagesUtil.sendDebugMessages(sendTo + " | " + entityId + " has had a camera packet on them!"); - } - /** * * @param location Location of the fake player. @@ -336,7 +266,7 @@ public class PacketManager { final int entityId, final @NotNull List sendTo ) { - if (NMSHandlers.getVersion().contains("v1_18_R2") || NMSHandlers.getVersion().contains("v1_19_R1") || NMSHandlers.getVersion().contains("v1_19_R2") || NMSHandlers.getVersion().contains("v1_19_R3") || NMSHandlers.getVersion().contains("v1_20_R1")) { + if (HMCCNMSHandlers.getVersion().contains("v1_18_R2") || HMCCNMSHandlers.getVersion().contains("v1_19_R1") || HMCCNMSHandlers.getVersion().contains("v1_19_R2") || HMCCNMSHandlers.getVersion().contains("v1_19_R3") || HMCCNMSHandlers.getVersion().contains("v1_20_R1")) { WrapperPlayServerNamedEntitySpawn wrapper = new WrapperPlayServerNamedEntitySpawn(); wrapper.setEntityID(entityId); wrapper.setPlayerUUID(uuid); @@ -374,7 +304,7 @@ public class PacketManager { WrappedSignedProperty skinData = PlayerUtils.getSkin(skinnedPlayer); if (skinData != null) wrappedGameProfile.getProperties().put("textures", skinData); // For sor some reason <1.19.2 handles it on the 0 field index, newer versions handles it on the 1 - if (NMSHandlers.getVersion().contains("v1_18_R2") || NMSHandlers.getVersion().contains("v1_19_R1")) { + if (HMCCNMSHandlers.getVersion().contains("v1_18_R2") || HMCCNMSHandlers.getVersion().contains("v1_19_R1")) { info.getHandle().getPlayerInfoDataLists().write(0, Collections.singletonList(new PlayerInfoData( wrappedGameProfile, 0, @@ -418,7 +348,7 @@ public class PacketManager { packet.getIntegers().write(0, playerId); WrappedDataWatcher wrapper = new WrappedDataWatcher(); - if (NMSHandlers.getVersion().contains("v1_18_R2") || NMSHandlers.getVersion().contains("v1_19_R1")) { + if (HMCCNMSHandlers.getVersion().contains("v1_18_R2") || HMCCNMSHandlers.getVersion().contains("v1_19_R1")) { wrapper.setObject(new WrappedDataWatcher.WrappedDataWatcherObject(17, WrappedDataWatcher.Registry.get(Byte.class)), mask); packet.getWatchableCollectionModifier().write(0, wrapper.getWatchableObjects()); } else { @@ -444,7 +374,7 @@ public class PacketManager { final UUID uuid, final List sendTo ) { - if (NMSHandlers.getVersion().contains("v1_18_R2") || NMSHandlers.getVersion().contains("v1_19_R1")) { + if (HMCCNMSHandlers.getVersion().contains("v1_18_R2") || HMCCNMSHandlers.getVersion().contains("v1_19_R1")) { WrapperPlayServerPlayerInfo info = new WrapperPlayServerPlayerInfo(); // Remove player is deprecated on 1.19.3+, but we still need to support 1.18.2 info.setAction(EnumWrappers.PlayerInfoAction.REMOVE_PLAYER); @@ -472,51 +402,6 @@ public class PacketManager { sendLeashPacket(leashedEntity, entityId, getViewers(location)); } - /** - * Sends a leash packet, useful for balloons! - * @param leashedEntity Entity being leashed (ex. a horse) - * @param entityId Entity this is affecting (ex. a player) - * @param sendTo Whom to send the packet to - */ - public static void sendLeashPacket( - final int leashedEntity, - final int entityId, - final @NotNull List sendTo - ) { - PacketContainer packet = new PacketContainer(PacketType.Play.Server.ATTACH_ENTITY); - packet.getIntegers().write(0, leashedEntity); - packet.getIntegers().write(1, entityId); - for (final Player p : sendTo) { - sendPacket(p, packet); - } - } - - /** - * Used when a player is sent 8+ blocks. - * @param entityId Entity this affects - * @param location Location a player is being teleported to - * @param onGround If the packet is on the ground - * @param sendTo Whom to send the packet to - */ - public static void sendTeleportPacket( - final int entityId, - final @NotNull Location location, - boolean onGround, - final @NotNull List sendTo - ) { - PacketContainer packet = new PacketContainer(PacketType.Play.Server.ENTITY_TELEPORT); - packet.getIntegers().write(0, entityId); - packet.getDoubles().write(0, location.getX()); - packet.getDoubles().write(1, location.getY()); - packet.getDoubles().write(2, location.getZ()); - packet.getBytes().write(0, (byte) (location.getYaw() * 256.0F / 360.0F)); - packet.getBytes().write(1, (byte) (location.getPitch() * 256.0F / 360.0F)); - packet.getBooleans().write(0, onGround); - for (final Player p : sendTo) { - sendPacket(p, packet); - } - } - /** * Sends a movement packet from one location to another * @param entityId Entity this will affect diff --git a/common/src/main/java/com/hibiscusmc/hmccosmetics/util/packets/wrappers/WrapperPlayServerPlayerInfo.java b/common/src/main/java/com/hibiscusmc/hmccosmetics/util/packets/wrappers/WrapperPlayServerPlayerInfo.java index 9ab572cb..095dea01 100644 --- a/common/src/main/java/com/hibiscusmc/hmccosmetics/util/packets/wrappers/WrapperPlayServerPlayerInfo.java +++ b/common/src/main/java/com/hibiscusmc/hmccosmetics/util/packets/wrappers/WrapperPlayServerPlayerInfo.java @@ -4,7 +4,7 @@ import com.comphenix.protocol.PacketType; import com.comphenix.protocol.events.PacketContainer; import com.comphenix.protocol.wrappers.EnumWrappers.PlayerInfoAction; import com.comphenix.protocol.wrappers.PlayerInfoData; -import com.hibiscusmc.hmccosmetics.nms.NMSHandlers; +import com.hibiscusmc.hmccosmetics.nms.HMCCNMSHandlers; import java.util.List; import java.util.Set; @@ -26,7 +26,7 @@ public class WrapperPlayServerPlayerInfo extends AbstractPacket { } public void setAction(PlayerInfoAction value) { - if (NMSHandlers.getVersion().contains("v1_17_R1") || NMSHandlers.getVersion().contains("v1_18_R2") || NMSHandlers.getVersion().contains("v1_19_R1")) { + if (HMCCNMSHandlers.getVersion().contains("v1_17_R1") || HMCCNMSHandlers.getVersion().contains("v1_18_R2") || HMCCNMSHandlers.getVersion().contains("v1_19_R1")) { handle.getPlayerInfoAction().write(0, value); return; } diff --git a/v1_18_R2/src/main/java/com/hibiscusmc/hmccosmetics/nms/v1_18_R2/NMSHandler.java b/v1_18_R2/src/main/java/com/hibiscusmc/hmccosmetics/nms/v1_18_R2/HMCCNMSHandler.java similarity index 84% rename from v1_18_R2/src/main/java/com/hibiscusmc/hmccosmetics/nms/v1_18_R2/NMSHandler.java rename to v1_18_R2/src/main/java/com/hibiscusmc/hmccosmetics/nms/v1_18_R2/HMCCNMSHandler.java index 96748e5f..d92eaf30 100644 --- a/v1_18_R2/src/main/java/com/hibiscusmc/hmccosmetics/nms/v1_18_R2/NMSHandler.java +++ b/v1_18_R2/src/main/java/com/hibiscusmc/hmccosmetics/nms/v1_18_R2/HMCCNMSHandler.java @@ -1,8 +1,5 @@ package com.hibiscusmc.hmccosmetics.nms.v1_18_R2; -import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticBalloonType; -import com.hibiscusmc.hmccosmetics.user.CosmeticUser; -import com.hibiscusmc.hmccosmetics.user.manager.UserBalloonManager; import com.mojang.datafixers.util.Pair; import net.minecraft.network.protocol.Packet; import net.minecraft.network.protocol.game.ClientboundContainerSetSlotPacket; @@ -31,27 +28,7 @@ import java.util.Collections; import java.util.HashMap; import java.util.List; -public class NMSHandler implements com.hibiscusmc.hmccosmetics.nms.NMSHandler { - @Override - public int getNextEntityId() { - return net.minecraft.world.entity.Entity.nextEntityId(); - } - - @Override - public org.bukkit.entity.Entity getEntity(int entityId) { - net.minecraft.world.entity.Entity entity = getNMSEntity(entityId); - if (entity == null) return null; - return entity.getBukkitEntity(); - } - - private net.minecraft.world.entity.Entity getNMSEntity(int entityId) { - for (ServerLevel world : ((CraftServer) Bukkit.getServer()).getHandle().getServer().getAllLevels()) { - net.minecraft.world.entity.Entity entity = world.getEntity(entityId); - if (entity == null) continue; - return entity; - } - return null; - } +public class HMCCNMSHandler implements com.hibiscusmc.hmccosmetics.nms.HMCCNMSHandler { @Override public ArmorStand getMEGEntity(Location loc) { diff --git a/v1_19_R1/src/main/java/com/hibiscusmc/hmccosmetics/nms/v1_19_R1/NMSHandler.java b/v1_19_R1/src/main/java/com/hibiscusmc/hmccosmetics/nms/v1_19_R1/HMCCNMSHandler.java similarity index 84% rename from v1_19_R1/src/main/java/com/hibiscusmc/hmccosmetics/nms/v1_19_R1/NMSHandler.java rename to v1_19_R1/src/main/java/com/hibiscusmc/hmccosmetics/nms/v1_19_R1/HMCCNMSHandler.java index 22b76437..fed4ab62 100644 --- a/v1_19_R1/src/main/java/com/hibiscusmc/hmccosmetics/nms/v1_19_R1/NMSHandler.java +++ b/v1_19_R1/src/main/java/com/hibiscusmc/hmccosmetics/nms/v1_19_R1/HMCCNMSHandler.java @@ -1,8 +1,5 @@ package com.hibiscusmc.hmccosmetics.nms.v1_19_R1; -import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticBalloonType; -import com.hibiscusmc.hmccosmetics.user.CosmeticUser; -import com.hibiscusmc.hmccosmetics.user.manager.UserBalloonManager; import com.mojang.datafixers.util.Pair; import net.minecraft.network.protocol.Packet; import net.minecraft.network.protocol.game.ClientboundContainerSetSlotPacket; @@ -31,27 +28,7 @@ import java.util.Collections; import java.util.HashMap; import java.util.List; -public class NMSHandler implements com.hibiscusmc.hmccosmetics.nms.NMSHandler { - @Override - public int getNextEntityId() { - return net.minecraft.world.entity.Entity.nextEntityId(); - } - - @Override - public org.bukkit.entity.Entity getEntity(int entityId) { - net.minecraft.world.entity.Entity entity = getNMSEntity(entityId); - if (entity == null) return null; - return entity.getBukkitEntity(); - } - - private net.minecraft.world.entity.Entity getNMSEntity(int entityId) { - for (ServerLevel world : ((CraftServer) Bukkit.getServer()).getHandle().getServer().getAllLevels()) { - net.minecraft.world.entity.Entity entity = world.getEntity(entityId); - if (entity == null) continue; - return entity; - } - return null; - } +public class HMCCNMSHandler implements com.hibiscusmc.hmccosmetics.nms.HMCCNMSHandler { @Override public ArmorStand getMEGEntity(Location loc) { diff --git a/v1_19_R2/src/main/java/com/hibiscusmc/hmccosmetics/nms/v1_19_R2/NMSHandler.java b/v1_19_R2/src/main/java/com/hibiscusmc/hmccosmetics/nms/v1_19_R2/HMCCNMSHandler.java similarity index 84% rename from v1_19_R2/src/main/java/com/hibiscusmc/hmccosmetics/nms/v1_19_R2/NMSHandler.java rename to v1_19_R2/src/main/java/com/hibiscusmc/hmccosmetics/nms/v1_19_R2/HMCCNMSHandler.java index c5797848..be7a2a28 100644 --- a/v1_19_R2/src/main/java/com/hibiscusmc/hmccosmetics/nms/v1_19_R2/NMSHandler.java +++ b/v1_19_R2/src/main/java/com/hibiscusmc/hmccosmetics/nms/v1_19_R2/HMCCNMSHandler.java @@ -1,8 +1,5 @@ package com.hibiscusmc.hmccosmetics.nms.v1_19_R2; -import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticBalloonType; -import com.hibiscusmc.hmccosmetics.user.CosmeticUser; -import com.hibiscusmc.hmccosmetics.user.manager.UserBalloonManager; import com.mojang.datafixers.util.Pair; import net.minecraft.network.protocol.Packet; import net.minecraft.network.protocol.game.ClientboundContainerSetSlotPacket; @@ -31,27 +28,7 @@ import java.util.Collections; import java.util.HashMap; import java.util.List; -public class NMSHandler implements com.hibiscusmc.hmccosmetics.nms.NMSHandler { - @Override - public int getNextEntityId() { - return net.minecraft.world.entity.Entity.nextEntityId(); - } - - @Override - public org.bukkit.entity.Entity getEntity(int entityId) { - net.minecraft.world.entity.Entity entity = getNMSEntity(entityId); - if (entity == null) return null; - return entity.getBukkitEntity(); - } - - private net.minecraft.world.entity.Entity getNMSEntity(int entityId) { - for (ServerLevel world : ((CraftServer) Bukkit.getServer()).getHandle().getServer().getAllLevels()) { - net.minecraft.world.entity.Entity entity = world.getEntity(entityId); - if (entity == null) continue; - return entity; - } - return null; - } +public class HMCCNMSHandler implements com.hibiscusmc.hmccosmetics.nms.HMCCNMSHandler { @Override public ArmorStand getMEGEntity(Location loc) { diff --git a/v1_19_R3/src/main/java/com/hibiscusmc/hmccosmetics/nms/v1_19_R3/NMSHandler.java b/v1_19_R3/src/main/java/com/hibiscusmc/hmccosmetics/nms/v1_19_R3/HMCCNMSHandler.java similarity index 85% rename from v1_19_R3/src/main/java/com/hibiscusmc/hmccosmetics/nms/v1_19_R3/NMSHandler.java rename to v1_19_R3/src/main/java/com/hibiscusmc/hmccosmetics/nms/v1_19_R3/HMCCNMSHandler.java index 9b3b6373..9e07fbe1 100644 --- a/v1_19_R3/src/main/java/com/hibiscusmc/hmccosmetics/nms/v1_19_R3/NMSHandler.java +++ b/v1_19_R3/src/main/java/com/hibiscusmc/hmccosmetics/nms/v1_19_R3/HMCCNMSHandler.java @@ -1,8 +1,5 @@ package com.hibiscusmc.hmccosmetics.nms.v1_19_R3; -import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticBalloonType; -import com.hibiscusmc.hmccosmetics.user.CosmeticUser; -import com.hibiscusmc.hmccosmetics.user.manager.UserBalloonManager; import com.hibiscusmc.hmccosmetics.util.MessagesUtil; import com.mojang.datafixers.util.Pair; import net.minecraft.network.chat.Component; @@ -27,7 +24,6 @@ import org.bukkit.craftbukkit.v1_19_R3.entity.CraftPlayer; import org.bukkit.craftbukkit.v1_19_R3.inventory.CraftItemStack; import org.bukkit.craftbukkit.v1_19_R3.scoreboard.CraftScoreboard; import org.bukkit.entity.ArmorStand; -import org.bukkit.entity.Entity; import org.bukkit.entity.Player; import org.bukkit.event.entity.CreatureSpawnEvent; import org.bukkit.inventory.ItemStack; @@ -37,27 +33,7 @@ import java.util.Collections; import java.util.HashMap; import java.util.List; -public class NMSHandler implements com.hibiscusmc.hmccosmetics.nms.NMSHandler { - @Override - public int getNextEntityId() { - return net.minecraft.world.entity.Entity.nextEntityId(); - } - - @Override - public org.bukkit.entity.Entity getEntity(int entityId) { - net.minecraft.world.entity.Entity entity = getNMSEntity(entityId); - if (entity == null) return null; - return entity.getBukkitEntity(); - } - - private net.minecraft.world.entity.Entity getNMSEntity(int entityId) { - for (ServerLevel world : ((CraftServer) Bukkit.getServer()).getHandle().getServer().getAllLevels()) { - net.minecraft.world.entity.Entity entity = world.getEntity(entityId); - if (entity == null) continue; - return entity; - } - return null; - } +public class HMCCNMSHandler implements com.hibiscusmc.hmccosmetics.nms.HMCCNMSHandler { @Override public ArmorStand getMEGEntity(Location loc) { diff --git a/v1_20_R1/src/main/java/com/hibiscusmc/hmccosmetics/nms/v1_20_R1/NMSHandler.java b/v1_20_R1/src/main/java/com/hibiscusmc/hmccosmetics/nms/v1_20_R1/HMCCNMSHandler.java similarity index 86% rename from v1_20_R1/src/main/java/com/hibiscusmc/hmccosmetics/nms/v1_20_R1/NMSHandler.java rename to v1_20_R1/src/main/java/com/hibiscusmc/hmccosmetics/nms/v1_20_R1/HMCCNMSHandler.java index b1b750c0..764c3cb6 100644 --- a/v1_20_R1/src/main/java/com/hibiscusmc/hmccosmetics/nms/v1_20_R1/NMSHandler.java +++ b/v1_20_R1/src/main/java/com/hibiscusmc/hmccosmetics/nms/v1_20_R1/HMCCNMSHandler.java @@ -1,8 +1,5 @@ package com.hibiscusmc.hmccosmetics.nms.v1_20_R1; -import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticBalloonType; -import com.hibiscusmc.hmccosmetics.user.CosmeticUser; -import com.hibiscusmc.hmccosmetics.user.manager.UserBalloonManager; import com.hibiscusmc.hmccosmetics.util.MessagesUtil; import com.mojang.datafixers.util.Pair; import net.minecraft.network.chat.Component; @@ -36,27 +33,7 @@ import java.util.Collections; import java.util.HashMap; import java.util.List; -public class NMSHandler implements com.hibiscusmc.hmccosmetics.nms.NMSHandler { - @Override - public int getNextEntityId() { - return net.minecraft.world.entity.Entity.nextEntityId(); - } - - @Override - public org.bukkit.entity.Entity getEntity(int entityId) { - net.minecraft.world.entity.Entity entity = getNMSEntity(entityId); - if (entity == null) return null; - return entity.getBukkitEntity(); - } - - private net.minecraft.world.entity.Entity getNMSEntity(int entityId) { - for (ServerLevel world : ((CraftServer) Bukkit.getServer()).getHandle().getServer().getAllLevels()) { - net.minecraft.world.entity.Entity entity = world.getEntity(entityId); - if (entity == null) continue; - return entity; - } - return null; - } +public class HMCCNMSHandler implements com.hibiscusmc.hmccosmetics.nms.HMCCNMSHandler { @Override public ArmorStand getMEGEntity(Location loc) { diff --git a/v1_20_R2/src/main/java/com/hibiscusmc/hmccosmetics/nms/v1_20_R2/NMSHandler.java b/v1_20_R2/src/main/java/com/hibiscusmc/hmccosmetics/nms/v1_20_R2/HMCCNMSHandler.java similarity index 86% rename from v1_20_R2/src/main/java/com/hibiscusmc/hmccosmetics/nms/v1_20_R2/NMSHandler.java rename to v1_20_R2/src/main/java/com/hibiscusmc/hmccosmetics/nms/v1_20_R2/HMCCNMSHandler.java index 9d8ae762..25488c90 100644 --- a/v1_20_R2/src/main/java/com/hibiscusmc/hmccosmetics/nms/v1_20_R2/NMSHandler.java +++ b/v1_20_R2/src/main/java/com/hibiscusmc/hmccosmetics/nms/v1_20_R2/HMCCNMSHandler.java @@ -1,8 +1,5 @@ package com.hibiscusmc.hmccosmetics.nms.v1_20_R2; -import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticBalloonType; -import com.hibiscusmc.hmccosmetics.user.CosmeticUser; -import com.hibiscusmc.hmccosmetics.user.manager.UserBalloonManager; import com.hibiscusmc.hmccosmetics.util.MessagesUtil; import com.mojang.datafixers.util.Pair; import net.minecraft.network.chat.Component; @@ -36,27 +33,7 @@ import java.util.Collections; import java.util.HashMap; import java.util.List; -public class NMSHandler implements com.hibiscusmc.hmccosmetics.nms.NMSHandler { - @Override - public int getNextEntityId() { - return net.minecraft.world.entity.Entity.nextEntityId(); - } - - @Override - public org.bukkit.entity.Entity getEntity(int entityId) { - net.minecraft.world.entity.Entity entity = getNMSEntity(entityId); - if (entity == null) return null; - return entity.getBukkitEntity(); - } - - private net.minecraft.world.entity.Entity getNMSEntity(int entityId) { - for (ServerLevel world : ((CraftServer) Bukkit.getServer()).getHandle().getServer().getAllLevels()) { - net.minecraft.world.entity.Entity entity = world.getEntity(entityId); - if (entity == null) continue; - return entity; - } - return null; - } +public class HMCCNMSHandler implements com.hibiscusmc.hmccosmetics.nms.HMCCNMSHandler { @Override public ArmorStand getMEGEntity(Location loc) { diff --git a/v1_20_R3/src/main/java/com/hibiscusmc/hmccosmetics/nms/v1_20_R3/NMSHandler.java b/v1_20_R3/src/main/java/com/hibiscusmc/hmccosmetics/nms/v1_20_R3/HMCCNMSHandler.java similarity index 86% rename from v1_20_R3/src/main/java/com/hibiscusmc/hmccosmetics/nms/v1_20_R3/NMSHandler.java rename to v1_20_R3/src/main/java/com/hibiscusmc/hmccosmetics/nms/v1_20_R3/HMCCNMSHandler.java index 3f649e94..53f80c5f 100644 --- a/v1_20_R3/src/main/java/com/hibiscusmc/hmccosmetics/nms/v1_20_R3/NMSHandler.java +++ b/v1_20_R3/src/main/java/com/hibiscusmc/hmccosmetics/nms/v1_20_R3/HMCCNMSHandler.java @@ -1,8 +1,5 @@ package com.hibiscusmc.hmccosmetics.nms.v1_20_R3; -import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticBalloonType; -import com.hibiscusmc.hmccosmetics.user.CosmeticUser; -import com.hibiscusmc.hmccosmetics.user.manager.UserBalloonManager; import com.hibiscusmc.hmccosmetics.util.MessagesUtil; import com.mojang.datafixers.util.Pair; import net.minecraft.network.chat.Component; @@ -36,27 +33,7 @@ import java.util.Collections; import java.util.HashMap; import java.util.List; -public class NMSHandler implements com.hibiscusmc.hmccosmetics.nms.NMSHandler { - @Override - public int getNextEntityId() { - return net.minecraft.world.entity.Entity.nextEntityId(); - } - - @Override - public org.bukkit.entity.Entity getEntity(int entityId) { - net.minecraft.world.entity.Entity entity = getNMSEntity(entityId); - if (entity == null) return null; - return entity.getBukkitEntity(); - } - - private net.minecraft.world.entity.Entity getNMSEntity(int entityId) { - for (ServerLevel world : ((CraftServer) Bukkit.getServer()).getHandle().getServer().getAllLevels()) { - net.minecraft.world.entity.Entity entity = world.getEntity(entityId); - if (entity == null) continue; - return entity; - } - return null; - } +public class HMCCNMSHandler implements com.hibiscusmc.hmccosmetics.nms.HMCCNMSHandler { @Override public ArmorStand getMEGEntity(Location loc) {