9
0
mirror of https://github.com/HibiscusMC/HMCCosmetics.git synced 2025-12-21 07:59:19 +00:00

Compare commits

..

1 Commits

Author SHA1 Message Date
Boy0000
684e02f768 drop protocollib 2025-05-22 22:10:31 +02:00
45 changed files with 737 additions and 923 deletions

View File

@@ -8,7 +8,7 @@ plugins {
} }
group = "com.hibiscusmc" group = "com.hibiscusmc"
version = "2.8.1${getGitCommitHash()}" version = "2.7.8${getGitCommitHash()}"
allprojects { allprojects {
apply(plugin = "java") apply(plugin = "java")
@@ -16,7 +16,6 @@ allprojects {
repositories { repositories {
mavenCentral() mavenCentral()
mavenLocal()
// Paper Repo // Paper Repo
maven("https://repo.papermc.io/repository/maven-public/") maven("https://repo.papermc.io/repository/maven-public/")
@@ -25,7 +24,8 @@ allprojects {
// Jitpack // Jitpack
maven("https://jitpack.io") maven("https://jitpack.io")
// Geary // ProtocolLib repo
maven("https://repo.dmulloy2.net/repository/public/") //ProtocolLib Repo, constantly down
maven("https://repo.mineinabyss.com/releases/") maven("https://repo.mineinabyss.com/releases/")
maven("https://repo.mineinabyss.com/snapshots/") maven("https://repo.mineinabyss.com/snapshots/")
@@ -69,13 +69,14 @@ allprojects {
// Hibiscus Commons // Hibiscus Commons
maven("https://repo.hibiscusmc.com/releases") maven("https://repo.hibiscusmc.com/releases")
mavenLocal()
} }
dependencies { dependencies {
compileOnly(fileTree("${project.rootDir}/lib") { include("*.jar") }) compileOnly(fileTree("${project.rootDir}/lib") { include("*.jar") })
compileOnly("com.mojang:authlib:1.5.25") compileOnly("com.mojang:authlib:1.5.25")
//compileOnly("org.spigotmc:spigot-api:1.18.2-R0.1-SNAPSHOT") //compileOnly("org.spigotmc:spigot-api:1.18.2-R0.1-SNAPSHOT")
compileOnly("io.papermc.paper:paper-api:1.20.6-R0.1-SNAPSHOT") compileOnly("io.papermc.paper:paper-api:1.20.4-R0.1-SNAPSHOT")
compileOnly("org.jetbrains:annotations:24.1.0") compileOnly("org.jetbrains:annotations:24.1.0")
compileOnly("me.clip:placeholderapi:2.11.6") compileOnly("me.clip:placeholderapi:2.11.6")
compileOnly("com.ticxo.modelengine:ModelEngine:R4.0.6") compileOnly("com.ticxo.modelengine:ModelEngine:R4.0.6")
@@ -85,19 +86,18 @@ allprojects {
exclude(group = "com.google.code.gson") exclude(group = "com.google.code.gson")
exclude(group = "it.unimi.dsi") exclude(group = "it.unimi.dsi")
exclude(group = "com.sk89q.jnbt") exclude(group = "com.sk89q.jnbt")
exclude(group = "org.enginehub.lin-bus.format")
} }
compileOnly("io.github.toxicity188:BetterHud-standard-api:1.12") //Standard api compileOnly("io.github.toxicity188:BetterHud-standard-api:1.12") //Standard api
compileOnly("io.github.toxicity188:BetterHud-bukkit-api:1.12") //Platform api compileOnly("io.github.toxicity188:BetterHud-bukkit-api:1.12") //Platform api
compileOnly("io.github.toxicity188:BetterCommand:1.3") //BetterCommand library compileOnly("io.github.toxicity188:BetterCommand:1.3") //BetterCommand library
//compileOnly("it.unimi.dsi:fastutil:8.5.14") //compileOnly("it.unimi.dsi:fastutil:8.5.14")
compileOnly("org.projectlombok:lombok:1.18.34") compileOnly("org.projectlombok:lombok:1.18.34")
compileOnly("me.lojosho:HibiscusCommons:0.7.1-6c4e262c") compileOnly("me.lojosho:HibiscusCommons:0.6.3-32402bd")
// Handled by Spigot Library Loader // Handled by Spigot Library Loader
compileOnly("net.kyori:adventure-api:4.24.0") compileOnly("net.kyori:adventure-api:4.19.0")
compileOnly("net.kyori:adventure-text-minimessage:4.24.0") compileOnly("net.kyori:adventure-text-minimessage:4.19.0")
compileOnly("net.kyori:adventure-platform-bukkit:4.4.1") compileOnly("net.kyori:adventure-platform-bukkit:4.3.4")
annotationProcessor("org.projectlombok:lombok:1.18.36") annotationProcessor("org.projectlombok:lombok:1.18.36")
testCompileOnly("org.projectlombok:lombok:1.18.36") testCompileOnly("org.projectlombok:lombok:1.18.36")
@@ -107,7 +107,7 @@ allprojects {
exclude("net.kyori") // Already have adventure API exclude("net.kyori") // Already have adventure API
} }
implementation("com.owen1212055:particlehelper:1.0.0-SNAPSHOT") implementation("com.owen1212055:particlehelper:1.0.0-SNAPSHOT")
implementation("com.ticxo.playeranimator:PlayerAnimator:R1.2.8") implementation("com.ticxo.playeranimator:PlayerAnimator:R1.2.7")
} }
tasks { tasks {
@@ -140,12 +140,12 @@ tasks {
} }
runServer { runServer {
minecraftVersion("1.21.8") minecraftVersion("1.21.4")
downloadPlugins { downloadPlugins {
hangar("PlaceholderAPI", "2.11.6") hangar("PlaceholderAPI", "2.11.6")
url("https://download.luckperms.net/1593/bukkit/loader/LuckPerms-Bukkit-5.5.8.jar") url("https://ci.dmulloy2.net/job/ProtocolLib/lastSuccessfulBuild/artifact/build/libs/ProtocolLib.jar")
github("Test-Account666", "PlugManX", "2.4.1", "PlugManX-2.4.1.jar") url("https://download.luckperms.net/1567/bukkit/loader/LuckPerms-Bukkit-5.4.150.jar")
} }
} }
@@ -182,7 +182,7 @@ bukkit {
apiVersion = "1.20" apiVersion = "1.20"
authors = listOf("LoJoSho") authors = listOf("LoJoSho")
depend = listOf("HibiscusCommons") depend = listOf("HibiscusCommons")
softDepend = listOf("Nexo", "BetterHud", "ModelEngine", "Oraxen", "ItemsAdder", "Geary", "HMCColor", "WorldGuard", "MythicMobs", "PlaceholderAPI", "SuperVanish", "PremiumVanish", "LibsDisguises", "Denizen", "MMOItems", "Eco") softDepend = listOf("BetterHud", "ModelEngine", "Nexo", "Oraxen", "ItemsAdder", "Geary", "HMCColor", "WorldGuard", "MythicMobs", "PlaceholderAPI", "SuperVanish", "PremiumVanish", "LibsDisguises", "Denizen", "MMOItems", "Eco")
version = "${project.version}" version = "${project.version}"
loadBefore = listOf( loadBefore = listOf(
"Cosmin" // Fixes an issue with Cosmin loading before and taking /cosmetic, when messing with what we do. "Cosmin" // Fixes an issue with Cosmin loading before and taking /cosmetic, when messing with what we do.
@@ -304,4 +304,4 @@ fun getGitCommitHash(): String {
} }
} }
return "" return ""
} }

View File

@@ -1,6 +1,11 @@
plugins { plugins {
id("java") id("java")
id("maven-publish") id("maven-publish")
id("io.papermc.paperweight.userdev") version "2.0.0-beta.17"
}
dependencies {
paperweight.paperDevBundle("1.21.4-R0.1-SNAPSHOT")
} }
java { java {

View File

@@ -11,8 +11,6 @@ import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetics;
import com.hibiscusmc.hmccosmetics.database.Database; import com.hibiscusmc.hmccosmetics.database.Database;
import com.hibiscusmc.hmccosmetics.gui.Menu; import com.hibiscusmc.hmccosmetics.gui.Menu;
import com.hibiscusmc.hmccosmetics.gui.Menus; import com.hibiscusmc.hmccosmetics.gui.Menus;
import com.hibiscusmc.hmccosmetics.gui.special.DyeMenuProvider;
import com.hibiscusmc.hmccosmetics.gui.special.impl.HMCColorDyeMenu;
import com.hibiscusmc.hmccosmetics.hooks.items.HookHMCCosmetics; import com.hibiscusmc.hmccosmetics.hooks.items.HookHMCCosmetics;
import com.hibiscusmc.hmccosmetics.hooks.misc.HookBetterHud; import com.hibiscusmc.hmccosmetics.hooks.misc.HookBetterHud;
import com.hibiscusmc.hmccosmetics.hooks.placeholders.HMCPlaceholderExpansion; import com.hibiscusmc.hmccosmetics.hooks.placeholders.HMCPlaceholderExpansion;
@@ -22,7 +20,6 @@ import com.hibiscusmc.hmccosmetics.listener.PaperPlayerGameListener;
import com.hibiscusmc.hmccosmetics.listener.PlayerConnectionListener; import com.hibiscusmc.hmccosmetics.listener.PlayerConnectionListener;
import com.hibiscusmc.hmccosmetics.listener.PlayerGameListener; import com.hibiscusmc.hmccosmetics.listener.PlayerGameListener;
import com.hibiscusmc.hmccosmetics.listener.ServerListener; import com.hibiscusmc.hmccosmetics.listener.ServerListener;
import com.hibiscusmc.hmccosmetics.packets.CosmeticPacketInterface;
import com.hibiscusmc.hmccosmetics.user.CosmeticUser; import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
import com.hibiscusmc.hmccosmetics.user.CosmeticUsers; import com.hibiscusmc.hmccosmetics.user.CosmeticUsers;
import com.hibiscusmc.hmccosmetics.util.MessagesUtil; import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
@@ -31,7 +28,6 @@ import me.lojosho.hibiscuscommons.HibiscusCommonsPlugin;
import me.lojosho.hibiscuscommons.HibiscusPlugin; import me.lojosho.hibiscuscommons.HibiscusPlugin;
import me.lojosho.hibiscuscommons.config.serializer.ItemSerializer; import me.lojosho.hibiscuscommons.config.serializer.ItemSerializer;
import me.lojosho.hibiscuscommons.config.serializer.LocationSerializer; import me.lojosho.hibiscuscommons.config.serializer.LocationSerializer;
import me.lojosho.hibiscuscommons.hooks.Hooks;
import me.lojosho.shaded.configupdater.common.config.CommentedConfiguration; import me.lojosho.shaded.configupdater.common.config.CommentedConfiguration;
import me.lojosho.shaded.configurate.ConfigurateException; import me.lojosho.shaded.configurate.ConfigurateException;
import me.lojosho.shaded.configurate.ConfigurationOptions; import me.lojosho.shaded.configurate.ConfigurationOptions;
@@ -67,12 +63,7 @@ public final class HMCCosmeticsPlugin extends HibiscusPlugin {
if (!Path.of(getDataFolder().getPath(), "messages.yml").toFile().exists()) saveResource("messages.yml", false); if (!Path.of(getDataFolder().getPath(), "messages.yml").toFile().exists()) saveResource("messages.yml", false);
if (!Path.of(getDataFolder().getPath(), "translations.yml").toFile().exists()) saveResource("translations.yml", false); if (!Path.of(getDataFolder().getPath(), "translations.yml").toFile().exists()) saveResource("translations.yml", false);
if (!Path.of(getDataFolder().getPath() + "/cosmetics/").toFile().exists()) saveResource("cosmetics/defaultcosmetics.yml", false); if (!Path.of(getDataFolder().getPath() + "/cosmetics/").toFile().exists()) saveResource("cosmetics/defaultcosmetics.yml", false);
if (!Path.of(getDataFolder().getPath() + "/menus/").toFile().exists()) { if (!Path.of(getDataFolder().getPath() + "/menus/").toFile().exists()) saveResource("menus/defaultmenu.yml", false);
saveResource("menus/defaultmenu_hats.yml", false);
saveResource("menus/defaultmenu_balloons.yml", false);
saveResource("menus/defaultmenu_hands.yml", false);
saveResource("menus/defaultmenu_backpacks.yml", false);
}
// Configuration Sync // Configuration Sync
final File configFile = Path.of(getInstance().getDataFolder().getPath(), "config.yml").toFile(); final File configFile = Path.of(getInstance().getDataFolder().getPath(), "config.yml").toFile();
@@ -92,7 +83,6 @@ public final class HMCCosmeticsPlugin extends HibiscusPlugin {
// Setup // Setup
setup(); setup();
setPacketInterface(new CosmeticPacketInterface());
// Commands // Commands
getServer().getPluginCommand("cosmetic").setExecutor(new CosmeticCommand()); getServer().getPluginCommand("cosmetic").setExecutor(new CosmeticCommand());
@@ -113,11 +103,6 @@ public final class HMCCosmeticsPlugin extends HibiscusPlugin {
if (Bukkit.getPluginManager().getPlugin("WorldGuard") != null && Settings.isWorldGuardMoveCheck()) { if (Bukkit.getPluginManager().getPlugin("WorldGuard") != null && Settings.isWorldGuardMoveCheck()) {
getServer().getPluginManager().registerEvents(new WGListener(), this); getServer().getPluginManager().registerEvents(new WGListener(), this);
} }
// HMCColor
if (Hooks.isActiveHook("HMCColor")) {
DyeMenuProvider.setDyeMenuProvider(new HMCColorDyeMenu());
}
} }
@Override @Override

View File

@@ -12,6 +12,7 @@ import com.hibiscusmc.hmccosmetics.user.CosmeticUserProvider;
import com.hibiscusmc.hmccosmetics.user.CosmeticUsers; import com.hibiscusmc.hmccosmetics.user.CosmeticUsers;
import me.lojosho.hibiscuscommons.nms.MinecraftVersion; import me.lojosho.hibiscuscommons.nms.MinecraftVersion;
import me.lojosho.hibiscuscommons.nms.NMSHandlers; import me.lojosho.hibiscuscommons.nms.NMSHandlers;
import me.lojosho.shaded.configurate.ConfigurationNode;
import org.bukkit.Color; import org.bukkit.Color;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
@@ -20,6 +21,7 @@ import org.jetbrains.annotations.Nullable;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.UUID; import java.util.UUID;
import java.util.function.BiConsumer;
/** /**
* The main API class for HMCCosmetics. This class provides methods to interact with the plugin. * The main API class for HMCCosmetics. This class provides methods to interact with the plugin.

View File

@@ -1,6 +1,7 @@
package com.hibiscusmc.hmccosmetics.api.events; package com.hibiscusmc.hmccosmetics.api.events;
import com.hibiscusmc.hmccosmetics.user.CosmeticUser; import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
import org.bukkit.event.Event;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
/** /**

View File

@@ -14,7 +14,6 @@ import com.hibiscusmc.hmccosmetics.database.Database;
import com.hibiscusmc.hmccosmetics.gui.Menu; import com.hibiscusmc.hmccosmetics.gui.Menu;
import com.hibiscusmc.hmccosmetics.gui.Menus; import com.hibiscusmc.hmccosmetics.gui.Menus;
import com.hibiscusmc.hmccosmetics.gui.special.DyeMenu; import com.hibiscusmc.hmccosmetics.gui.special.DyeMenu;
import com.hibiscusmc.hmccosmetics.gui.special.DyeMenuProvider;
import com.hibiscusmc.hmccosmetics.user.CosmeticUser; import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
import com.hibiscusmc.hmccosmetics.user.CosmeticUsers; import com.hibiscusmc.hmccosmetics.user.CosmeticUsers;
import com.hibiscusmc.hmccosmetics.util.MessagesUtil; import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
@@ -330,7 +329,7 @@ public class CosmeticCommand implements CommandExecutor {
} }
user.addCosmetic(cosmetic, color); // #FFFFFF user.addCosmetic(cosmetic, color); // #FFFFFF
} else { } else {
DyeMenuProvider.openMenu(player, user, cosmetic); DyeMenu.openMenu(user, cosmetic);
} }
} }
case ("setwardrobesetting") -> { case ("setwardrobesetting") -> {
@@ -401,7 +400,6 @@ public class CosmeticCommand implements CommandExecutor {
if (user.hasCosmeticInSlot(CosmeticSlot.BACKPACK)) { if (user.hasCosmeticInSlot(CosmeticSlot.BACKPACK)) {
player.sendMessage("Backpack Location -> " + user.getUserBackpackManager().getEntityManager().getLocation()); player.sendMessage("Backpack Location -> " + user.getUserBackpackManager().getEntityManager().getLocation());
} }
player.sendMessage("Cosmetic Passengers -> " + user.getUserBackpackManager().getAreaEffectEntityId());
player.sendMessage("Cosmetics -> " + user.getCosmetics()); player.sendMessage("Cosmetics -> " + user.getCosmetics());
player.sendMessage("EntityId -> " + player.getEntityId()); player.sendMessage("EntityId -> " + player.getEntityId());
return true; return true;

View File

@@ -228,9 +228,9 @@ public class Settings {
lockedCosmeticColor = shadingSettings.node(LOCKED_COSMETIC_COLOR_PATH).getString(); lockedCosmeticColor = shadingSettings.node(LOCKED_COSMETIC_COLOR_PATH).getString();
ConfigurationNode cosmeticTypeSettings = menuSettings.node(COSMETIC_TYPE_SETTINGS_PATH); ConfigurationNode cosmeticTypeSettings = menuSettings.node(COSMETIC_TYPE_SETTINGS_PATH);
cosmeticEquipClickType = cosmeticTypeSettings.node(EQUIP_CLICK_TYPE).getString("ANY"); cosmeticEquipClickType = cosmeticTypeSettings.node(EQUIP_CLICK_TYPE).getString("ALL");
cosmeticUnEquipClickType = cosmeticTypeSettings.node(UNEQUIP_CLICK_TYPE).getString("ANY"); cosmeticUnEquipClickType = cosmeticTypeSettings.node(UNEQUIP_CLICK_TYPE).getString("ALL");
cosmeticDyeClickType = cosmeticTypeSettings.node(DYE_CLICK_TYPE).getString("ANY"); cosmeticDyeClickType = cosmeticTypeSettings.node(DYE_CLICK_TYPE).getString("ALL");
final var balloonSection = cosmeticSettings.node(BALLOON_OFFSET); final var balloonSection = cosmeticSettings.node(BALLOON_OFFSET);
balloonOffset = loadVector(balloonSection); balloonOffset = loadVector(balloonSection);

View File

@@ -3,16 +3,16 @@ package com.hibiscusmc.hmccosmetics.cosmetic;
import com.hibiscusmc.hmccosmetics.user.CosmeticUser; import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
import com.hibiscusmc.hmccosmetics.util.MessagesUtil; import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
import lombok.AccessLevel; import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
import me.lojosho.hibiscuscommons.config.serializer.ItemSerializer; import me.lojosho.hibiscuscommons.config.serializer.ItemSerializer;
import me.lojosho.shaded.configurate.ConfigurationNode; import me.lojosho.shaded.configurate.ConfigurationNode;
import me.lojosho.shaded.configurate.serialize.SerializationException; import me.lojosho.shaded.configurate.serialize.SerializationException;
import org.bukkit.ChatColor; import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.format.NamedTextColor;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
@@ -26,16 +26,13 @@ public abstract class Cosmetic {
static { static {
UNDEFINED_DISPLAY_ITEM_STACK = new ItemStack(Material.BARRIER); UNDEFINED_DISPLAY_ITEM_STACK = new ItemStack(Material.BARRIER);
UNDEFINED_DISPLAY_ITEM_STACK.editMeta(meta -> {
ItemMeta meta = UNDEFINED_DISPLAY_ITEM_STACK.getItemMeta(); meta.displayName(Component.text("Undefined Item Display", NamedTextColor.RED));
if (meta != null) { meta.lore(List.of(
// Legacy methods for Spigot >:( Component.text("Please check your configurations & console to", NamedTextColor.RED),
meta.setDisplayName(ChatColor.translateAlternateColorCodes('&', "&cUndefined Item Display")); Component.text("ensure there are no errors.", NamedTextColor.RED)
meta.setLore(List.of( ));
ChatColor.translateAlternateColorCodes('&', "&cPlease check your configurations & console to"), });
ChatColor.translateAlternateColorCodes('&', "&censure there are no errors.")));
}
UNDEFINED_DISPLAY_ITEM_STACK.setItemMeta(meta);
} }
/** Identifier of the cosmetic. */ /** Identifier of the cosmetic. */
@@ -57,12 +54,8 @@ public abstract class Cosmetic {
/** Whether the cosmetic is dyeable or not. */ /** Whether the cosmetic is dyeable or not. */
private boolean dyeable; private boolean dyeable;
/** The config for the cosmetic */
private ConfigurationNode config;
protected Cosmetic(@NotNull String id, @NotNull ConfigurationNode config) { protected Cosmetic(@NotNull String id, @NotNull ConfigurationNode config) {
this.id = id; this.id = id;
this.config = config;
if (!config.node("permission").virtual()) { if (!config.node("permission").virtual()) {
this.permission = config.node("permission").getString(); this.permission = config.node("permission").getString();
@@ -140,14 +133,4 @@ public abstract class Cosmetic {
throw new RuntimeException(e); throw new RuntimeException(e);
} }
} }
/**
* While cosmetics registered in HMCC are made through a configuration, cosmetics registered from other plugins
* may not and instead opt for {@link Cosmetic#Cosmetic(String, String, ItemStack, String, CosmeticSlot, boolean)}, which doesn't use a config.
* This should be used only for reference.
*/
@ApiStatus.Experimental
public @Nullable ConfigurationNode getConfig() {
return config;
}
} }

View File

@@ -2,10 +2,12 @@ package com.hibiscusmc.hmccosmetics.cosmetic;
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin; import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
import com.hibiscusmc.hmccosmetics.cosmetic.types.*; import com.hibiscusmc.hmccosmetics.cosmetic.types.*;
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import me.lojosho.shaded.configurate.ConfigurationNode; import me.lojosho.shaded.configurate.ConfigurationNode;
import org.bukkit.plugin.Plugin; import org.bukkit.plugin.Plugin;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.Map; import java.util.Map;
import java.util.function.BiFunction; import java.util.function.BiFunction;
@@ -22,6 +24,8 @@ public abstract class CosmeticProvider {
Map.entry(CosmeticSlot.BOOTS, CosmeticArmorType::new), Map.entry(CosmeticSlot.BOOTS, CosmeticArmorType::new),
Map.entry(CosmeticSlot.OFFHAND, CosmeticArmorType::new), Map.entry(CosmeticSlot.OFFHAND, CosmeticArmorType::new),
Map.entry(CosmeticSlot.MAINHAND, CosmeticMainhandType::new),
Map.entry(CosmeticSlot.BACKPACK, CosmeticBackpackType::new), Map.entry(CosmeticSlot.BACKPACK, CosmeticBackpackType::new),
Map.entry(CosmeticSlot.BALLOON, CosmeticBalloonType::new) Map.entry(CosmeticSlot.BALLOON, CosmeticBalloonType::new)

View File

@@ -48,11 +48,9 @@ public class CosmeticArmorType extends Cosmetic {
} }
public ItemStack getItem(@NotNull CosmeticUser user, ItemStack cosmeticItem) { public ItemStack getItem(@NotNull CosmeticUser user, ItemStack cosmeticItem) {
Player player = user.getPlayer(); if (!(user.getEntity() instanceof HumanEntity humanEntity)) return null;
if (player == null) return null;
if (Settings.getSlotOption(equipSlot).isAddEnchantments()) { if (Settings.getSlotOption(equipSlot).isAddEnchantments()) {
ItemStack equippedItem = player.getInventory().getItem(equipSlot); ItemStack equippedItem = humanEntity.getInventory().getItem(equipSlot);
cosmeticItem.addUnsafeEnchantments(equippedItem.getEnchantments()); cosmeticItem.addUnsafeEnchantments(equippedItem.getEnchantments());
} }
// Basically, if force offhand is off AND there is no item in an offhand slot, then the equipment packet to add the cosmetic // Basically, if force offhand is off AND there is no item in an offhand slot, then the equipment packet to add the cosmetic

View File

@@ -5,13 +5,13 @@ import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
import com.hibiscusmc.hmccosmetics.user.CosmeticUser; import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
import com.hibiscusmc.hmccosmetics.user.manager.UserBackpackManager; import com.hibiscusmc.hmccosmetics.user.manager.UserBackpackManager;
import com.hibiscusmc.hmccosmetics.user.manager.UserEntity; import com.hibiscusmc.hmccosmetics.user.manager.UserEntity;
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
import com.hibiscusmc.hmccosmetics.util.packets.HMCCPacketManager; import com.hibiscusmc.hmccosmetics.util.packets.HMCCPacketManager;
import lombok.Getter; import lombok.Getter;
import me.lojosho.hibiscuscommons.util.packets.PacketManager; import me.lojosho.hibiscuscommons.util.packets.PacketManager;
import me.lojosho.shaded.configurate.ConfigurationNode; import me.lojosho.shaded.configurate.ConfigurationNode;
import org.bukkit.Bukkit;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.attribute.Attribute;
import org.bukkit.attribute.AttributeInstance;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType; import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@@ -22,6 +22,7 @@ import org.jetbrains.annotations.NotNull;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.UUID; import java.util.UUID;
import java.util.logging.Level;
public class CosmeticBackpackType extends Cosmetic { public class CosmeticBackpackType extends Cosmetic {
@@ -64,14 +65,6 @@ public class CosmeticBackpackType extends Cosmetic {
HMCCPacketManager.sendEntitySpawnPacket(entityLocation, firstArmorStandId, EntityType.ARMOR_STAND, UUID.randomUUID(), outsideViewers); HMCCPacketManager.sendEntitySpawnPacket(entityLocation, firstArmorStandId, EntityType.ARMOR_STAND, UUID.randomUUID(), outsideViewers);
HMCCPacketManager.sendArmorstandMetadata(firstArmorStandId, outsideViewers); HMCCPacketManager.sendArmorstandMetadata(firstArmorStandId, outsideViewers);
if (user.getPlayer() != null) {
AttributeInstance scaleAttribute = user.getPlayer().getAttribute(Attribute.GENERIC_SCALE);
if (scaleAttribute != null) {
HMCCPacketManager.sendEntityScalePacket(user.getUserBackpackManager().getFirstArmorStandId(), scaleAttribute.getValue(), outsideViewers);
}
}
PacketManager.equipmentSlotUpdate(firstArmorStandId, EquipmentSlot.HEAD, user.getUserCosmeticItem(this, getItem()), outsideViewers); PacketManager.equipmentSlotUpdate(firstArmorStandId, 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 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()) HMCCPacketManager.sendRidingPacket(entity.getEntityId(), firstArmorStandId, entityManager.getViewers()); if (Settings.isBackpackForceRidingEnabled()) HMCCPacketManager.sendRidingPacket(entity.getEntityId(), firstArmorStandId, entityManager.getViewers());

View File

@@ -0,0 +1,23 @@
package com.hibiscusmc.hmccosmetics.cosmetic.types;
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
import com.hibiscusmc.hmccosmetics.util.HMCCPlayerUtils;
import com.hibiscusmc.hmccosmetics.util.packets.HMCCPacketManager;
import me.lojosho.shaded.configurate.ConfigurationNode;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
public class CosmeticMainhandType extends Cosmetic {
public CosmeticMainhandType(String id, ConfigurationNode config) {
super(id, config);
}
@Override
protected void doUpdate(@NotNull CosmeticUser user) {
Player player = user.getPlayer();
HMCCPacketManager.equipmentSlotUpdate(player.getEntityId(), user, getSlot(), HMCCPacketManager.getViewers(player.getLocation()));
}
}

View File

@@ -1,5 +1,6 @@
package com.hibiscusmc.hmccosmetics.database.types; package com.hibiscusmc.hmccosmetics.database.types;
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
import com.hibiscusmc.hmccosmetics.config.Settings; import com.hibiscusmc.hmccosmetics.config.Settings;
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic; import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
import com.hibiscusmc.hmccosmetics.cosmetic.CosmeticSlot; import com.hibiscusmc.hmccosmetics.cosmetic.CosmeticSlot;
@@ -8,6 +9,7 @@ import com.hibiscusmc.hmccosmetics.database.UserData;
import com.hibiscusmc.hmccosmetics.user.CosmeticUser; import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
import com.hibiscusmc.hmccosmetics.util.MessagesUtil; import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
import org.apache.commons.lang3.EnumUtils; import org.apache.commons.lang3.EnumUtils;
import org.bukkit.Bukkit;
import org.bukkit.Color; import org.bukkit.Color;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
@@ -85,7 +87,7 @@ public abstract class Data {
private boolean shouldHiddenSave(CosmeticUser.HiddenReason reason) { private boolean shouldHiddenSave(CosmeticUser.HiddenReason reason) {
switch (reason) { switch (reason) {
case EMOTE, NONE, GAMEMODE, WORLD, DISABLED, POTION -> { case EMOTE, NONE, GAMEMODE, WORLD, DISABLED -> {
return false; return false;
} }
default -> { default -> {

View File

@@ -39,12 +39,10 @@ public class MySQLData extends SQLData {
try { try {
openConnection(); openConnection();
if (connection == null) throw new NullPointerException("Connection is null"); if (connection == null) throw new NullPointerException("Connection is null");
try (PreparedStatement preparedStatement = connection.prepareStatement("CREATE TABLE IF NOT EXISTS `COSMETICDATABASE` " + connection.prepareStatement("CREATE TABLE IF NOT EXISTS `COSMETICDATABASE` " +
"(UUID varchar(36) PRIMARY KEY, " + "(UUID varchar(36) PRIMARY KEY, " +
"COSMETICS MEDIUMTEXT " + "COSMETICS MEDIUMTEXT " +
");")) { ");").execute();
preparedStatement.execute();
}
} catch (SQLException | NullPointerException e) { } catch (SQLException | NullPointerException e) {
plugin.getLogger().severe(""); plugin.getLogger().severe("");
plugin.getLogger().severe(""); plugin.getLogger().severe("");
@@ -62,11 +60,17 @@ public class MySQLData extends SQLData {
@Override @Override
public void clear(UUID uniqueId) { public void clear(UUID uniqueId) {
Bukkit.getScheduler().runTaskAsynchronously(HMCCosmeticsPlugin.getInstance(), () -> { Bukkit.getScheduler().runTaskAsynchronously(HMCCosmeticsPlugin.getInstance(), () -> {
try (PreparedStatement preparedSt = preparedStatement("DELETE FROM COSMETICDATABASE WHERE UUID=?;")) { PreparedStatement preparedSt = null;
try {
preparedSt = preparedStatement("DELETE FROM COSMETICDATABASE WHERE UUID=?;");
preparedSt.setString(1, uniqueId.toString()); preparedSt.setString(1, uniqueId.toString());
preparedSt.executeUpdate(); preparedSt.executeUpdate();
} catch (SQLException e) { } catch (SQLException e) {
e.printStackTrace(); e.printStackTrace();
} finally {
try {
if (preparedSt != null) preparedSt.close();
} catch (SQLException e) {}
} }
}); });
} }

View File

@@ -6,6 +6,7 @@ import com.hibiscusmc.hmccosmetics.cosmetic.CosmeticSlot;
import com.hibiscusmc.hmccosmetics.database.UserData; import com.hibiscusmc.hmccosmetics.database.UserData;
import com.hibiscusmc.hmccosmetics.user.CosmeticUser; import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Color;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
@@ -22,17 +23,22 @@ public abstract class SQLData extends Data {
return CompletableFuture.supplyAsync(() -> { return CompletableFuture.supplyAsync(() -> {
UserData data = new UserData(uniqueId); UserData data = new UserData(uniqueId);
try (PreparedStatement preparedStatement = preparedStatement("SELECT * FROM COSMETICDATABASE WHERE UUID = ?;")){ PreparedStatement preparedStatement = null;
try {
preparedStatement = preparedStatement("SELECT * FROM COSMETICDATABASE WHERE UUID = ?;");
preparedStatement.setString(1, uniqueId.toString()); preparedStatement.setString(1, uniqueId.toString());
try (ResultSet rs = preparedStatement.executeQuery()) { ResultSet rs = preparedStatement.executeQuery();
if (rs.next()) { if (rs.next()) {
String rawData = rs.getString("COSMETICS"); String rawData = rs.getString("COSMETICS");
HashMap<CosmeticSlot, Map.Entry<Cosmetic, Integer>> cosmetics = deserializeData(rawData); HashMap<CosmeticSlot, Map.Entry<Cosmetic, Integer>> cosmetics = deserializeData(rawData);
data.setCosmetics(cosmetics); data.setCosmetics(cosmetics);
}
} }
} catch (SQLException e) { } catch (SQLException e) {
e.printStackTrace(); e.printStackTrace();
} finally {
try {
if (preparedStatement != null) preparedStatement.close();
} catch (SQLException e) {}
} }
return data; return data;
}); });
@@ -42,12 +48,18 @@ public abstract class SQLData extends Data {
@SuppressWarnings("resource") @SuppressWarnings("resource")
public void save(CosmeticUser user) { public void save(CosmeticUser user) {
Runnable run = () -> { Runnable run = () -> {
try (PreparedStatement preparedSt = preparedStatement("REPLACE INTO COSMETICDATABASE(UUID,COSMETICS) VALUES(?,?);")) { PreparedStatement preparedSt = null;
try {
preparedSt = preparedStatement("REPLACE INTO COSMETICDATABASE(UUID,COSMETICS) VALUES(?,?);");
preparedSt.setString(1, user.getUniqueId().toString()); preparedSt.setString(1, user.getUniqueId().toString());
preparedSt.setString(2, serializeData(user)); preparedSt.setString(2, serializeData(user));
preparedSt.executeUpdate(); preparedSt.executeUpdate();
} catch (SQLException e) { } catch (SQLException e) {
throw new RuntimeException(e); throw new RuntimeException(e);
} finally {
try {
if (preparedSt != null) preparedSt.close();
} catch (SQLException e) {}
} }
}; };
if (!HMCCosmeticsPlugin.getInstance().isDisabled()) { if (!HMCCosmeticsPlugin.getInstance().isDisabled()) {

View File

@@ -35,12 +35,10 @@ public class SQLiteData extends SQLData {
connection = DriverManager.getConnection("jdbc:sqlite:" + dataFolder); connection = DriverManager.getConnection("jdbc:sqlite:" + dataFolder);
openConnection(); openConnection();
try (PreparedStatement preparedStatement = connection.prepareStatement("CREATE TABLE IF NOT EXISTS `COSMETICDATABASE` " + connection.prepareStatement("CREATE TABLE IF NOT EXISTS `COSMETICDATABASE` " +
"(UUID varchar(36) PRIMARY KEY, " + "(UUID varchar(36) PRIMARY KEY, " +
"COSMETICS MEDIUMTEXT " + "COSMETICS MEDIUMTEXT " +
");")) { ");").execute();
preparedStatement.execute();
}
} catch (SQLException e) { } catch (SQLException e) {
throw new RuntimeException(e); throw new RuntimeException(e);
} }
@@ -50,11 +48,17 @@ public class SQLiteData extends SQLData {
@SuppressWarnings("resource") @SuppressWarnings("resource")
public void clear(UUID uniqueId) { public void clear(UUID uniqueId) {
Bukkit.getScheduler().runTaskAsynchronously(HMCCosmeticsPlugin.getInstance(), () -> { Bukkit.getScheduler().runTaskAsynchronously(HMCCosmeticsPlugin.getInstance(), () -> {
try (PreparedStatement preparedSt = preparedStatement("DELETE FROM COSMETICDATABASE WHERE UUID=?;")){ PreparedStatement preparedSt = null;
try {
preparedSt = preparedStatement("DELETE FROM COSMETICDATABASE WHERE UUID=?;");
preparedSt.setString(1, uniqueId.toString()); preparedSt.setString(1, uniqueId.toString());
preparedSt.executeUpdate(); preparedSt.executeUpdate();
} catch (SQLException e) { } catch (SQLException e) {
e.printStackTrace(); e.printStackTrace();
} finally {
try {
if (preparedSt != null) preparedSt.close();
} catch (SQLException e) {}
} }
}); });
} }

View File

@@ -14,18 +14,21 @@ import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
import com.hibiscusmc.hmccosmetics.util.MessagesUtil; import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
import dev.triumphteam.gui.builder.item.ItemBuilder; import dev.triumphteam.gui.builder.item.ItemBuilder;
import dev.triumphteam.gui.components.GuiType; import dev.triumphteam.gui.components.GuiType;
import dev.triumphteam.gui.components.InventoryProvider;
import dev.triumphteam.gui.guis.Gui; import dev.triumphteam.gui.guis.Gui;
import dev.triumphteam.gui.guis.GuiItem; import dev.triumphteam.gui.guis.GuiItem;
import lombok.Getter; import lombok.Getter;
import me.lojosho.hibiscuscommons.config.serializer.ItemSerializer; import me.lojosho.hibiscuscommons.config.serializer.ItemSerializer;
import me.lojosho.hibiscuscommons.hooks.Hooks; import me.lojosho.hibiscuscommons.hooks.Hooks;
import me.lojosho.hibiscuscommons.util.AdventureUtils; import me.lojosho.hibiscuscommons.util.AdventureUtils;
import me.lojosho.hibiscuscommons.util.StringUtils;
import me.lojosho.shaded.configurate.ConfigurationNode; import me.lojosho.shaded.configurate.ConfigurationNode;
import me.lojosho.shaded.configurate.serialize.SerializationException; import me.lojosho.shaded.configurate.serialize.SerializationException;
import net.kyori.adventure.text.Component; import net.kyori.adventure.text.Component;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType; import org.bukkit.event.inventory.ClickType;
import org.bukkit.event.inventory.InventoryType;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.Contract; import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
@@ -182,25 +185,18 @@ public class Menu {
if (taskid.get() != -1) Bukkit.getScheduler().cancelTask(taskid.get()); if (taskid.get() != -1) Bukkit.getScheduler().cancelTask(taskid.get());
}); });
Runnable openGuiTask = () -> {
gui.open(viewer);
updateMenu(viewer, cosmeticHolder, gui); // fixes shading? I know I do this twice but it's easier than writing a whole new class to deal with this shit
};
// API // API
if (cosmeticHolder instanceof CosmeticUser user) { if (cosmeticHolder instanceof CosmeticUser user) {
PlayerMenuOpenEvent event = new PlayerMenuOpenEvent(user, this); PlayerMenuOpenEvent event = new PlayerMenuOpenEvent(user, this);
Bukkit.getScheduler().runTask(HMCCosmeticsPlugin.getInstance(), () -> { Bukkit.getScheduler().runTask(HMCCosmeticsPlugin.getInstance(), () -> Bukkit.getPluginManager().callEvent(event));
Bukkit.getPluginManager().callEvent(event); if (event.isCancelled()) return;
if (!event.isCancelled()) {
openGuiTask.run();
}
});
} }
// Internal // Internal
else {
Bukkit.getScheduler().runTask(HMCCosmeticsPlugin.getInstance(), openGuiTask); Bukkit.getScheduler().runTask(HMCCosmeticsPlugin.getInstance(), () -> {
} gui.open(viewer);
updateMenu(viewer, cosmeticHolder, gui); // fixes shading? I know I do this twice but it's easier than writing a whole new class to deal with this shit
});
} }
private void updateMenu(Player viewer, CosmeticHolder cosmeticHolder, Gui gui) { private void updateMenu(Player viewer, CosmeticHolder cosmeticHolder, Gui gui) {

View File

@@ -3,6 +3,8 @@ package com.hibiscusmc.hmccosmetics.gui;
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin; import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
import com.hibiscusmc.hmccosmetics.config.Settings; import com.hibiscusmc.hmccosmetics.config.Settings;
import com.hibiscusmc.hmccosmetics.util.MessagesUtil; import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
import lombok.Getter;
import lombok.Setter;
import me.lojosho.shaded.configurate.CommentedConfigurationNode; import me.lojosho.shaded.configurate.CommentedConfigurationNode;
import me.lojosho.shaded.configurate.ConfigurateException; import me.lojosho.shaded.configurate.ConfigurateException;
import me.lojosho.shaded.configurate.yaml.YamlConfigurationLoader; import me.lojosho.shaded.configurate.yaml.YamlConfigurationLoader;

View File

@@ -10,7 +10,6 @@ import org.jetbrains.annotations.NotNull;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.logging.Level;
@SuppressWarnings("unused") @SuppressWarnings("unused")
public class Actions { public class Actions {
@@ -31,6 +30,7 @@ public class Actions {
private static final ActionCosmeticHide ACTION_HIDE = new ActionCosmeticHide(); private static final ActionCosmeticHide ACTION_HIDE = new ActionCosmeticHide();
private static final ActionCosmeticToggle ACTION_TOGGLE = new ActionCosmeticToggle(); private static final ActionCosmeticToggle ACTION_TOGGLE = new ActionCosmeticToggle();
public static Action getAction(@NotNull String id) { public static Action getAction(@NotNull String id) {
return actions.get(id.toUpperCase()); return actions.get(id.toUpperCase());
} }
@@ -45,13 +45,13 @@ public class Actions {
public static void runActions(Player viewer, CosmeticHolder cosmeticHolder, @NotNull List<String> raw) { public static void runActions(Player viewer, CosmeticHolder cosmeticHolder, @NotNull List<String> raw) {
for (String a : raw) { for (String a : raw) {
String id = StringUtils.substringBetween(a, "[", "]"); String id = StringUtils.substringBetween(a, "[", "]").toUpperCase();
String message = StringUtils.substringAfter(a, "] "); String message = StringUtils.substringAfter(a, "] ");
MessagesUtil.sendDebugMessages("ID is " + id + " // Raw Data is " + message); MessagesUtil.sendDebugMessages("ID is " + id + " // Raw Data is " + message);
if (id != null && isAction(id.toUpperCase())) { if (isAction(id)) {
getAction(id).run(viewer, cosmeticHolder, message); getAction(id).run(viewer, cosmeticHolder, message);
} else { } else {
MessagesUtil.sendDebugMessages("Invalid Action ID (" + id + ") used in menus (Full raw: '" + a + "'). Make sure all actions are properly typed out. Here are all possible actions: " + actions.keySet(), Level.WARNING); MessagesUtil.sendDebugMessages("Possible ids: " + actions.keySet());
} }
} }
} }

View File

@@ -1,20 +1,67 @@
package com.hibiscusmc.hmccosmetics.gui.special; package com.hibiscusmc.hmccosmetics.gui.special;
import com.hibiscusmc.hmccolor.HMCColorApi;
import com.hibiscusmc.hmccolor.shaded.gui.guis.Gui;
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.cosmetic.Cosmetic;
import com.hibiscusmc.hmccosmetics.cosmetic.CosmeticHolder; import com.hibiscusmc.hmccosmetics.cosmetic.CosmeticHolder;
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
import me.lojosho.hibiscuscommons.hooks.Hooks;
import me.lojosho.hibiscuscommons.nms.NMSHandlers;
import me.lojosho.hibiscuscommons.util.AdventureUtils;
import me.lojosho.hibiscuscommons.util.StringUtils;
import org.bukkit.Bukkit;
import org.bukkit.Color;
import org.bukkit.Material;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
public interface DyeMenu { public class DyeMenu {
public static void openMenu(@NotNull Player viewer, @NotNull CosmeticHolder cosmeticHolder, Cosmetic cosmetic) {
if (!Hooks.isActiveHook("HMCColor")) {
addCosmetic(viewer, cosmeticHolder, cosmetic, null);
return;
}
ItemStack originalItem = cosmetic.getItem();
if (originalItem == null || !cosmetic.isDyeable()) return;
/** Gui gui = HMCColorApi.createColorMenu(viewer);
* Overrideable method that is called when a player wishing to dye a menu. gui.updateTitle(AdventureUtils.MINI_MESSAGE.deserialize(Hooks.processPlaceholders(viewer, StringUtils.parseStringToString(Settings.getDyeMenuName()))));
* After the method is called, the menu plugin itself is supposed to handle everything else, including adding the cosmetic to the CosmeticHolder gui.setItem(Settings.getDyeMenuInputSlot(), new GuiItem(originalItem));
* gui.setDefaultTopClickAction(event -> {
* @param viewer The player that is viewing the menu if (event.getSlot() == Settings.getDyeMenuOutputSlot()) {
* @param cosmeticHolder The CosmeticHolder that is being dyed (Can be different from the viewer) ItemStack item = event.getInventory().getItem(Settings.getDyeMenuOutputSlot());
* @param cosmetic (The cosmetic that is wished to be dyed) if (item == null) return;
*/
void openMenu(@NotNull Player viewer, @NotNull CosmeticHolder cosmeticHolder, @NotNull Cosmetic cosmetic);
Color color = NMSHandlers.getHandler().getUtilHandler().getColor(item);
if (color == null) return;
addCosmetic(viewer, cosmeticHolder, cosmetic, color);
event.setCancelled(true);
} else event.setCancelled(true);
});
gui.setPlayerInventoryAction(event -> event.setCancelled(true));
gui.setCloseGuiAction(event -> {});
gui.open(viewer);
}
public static void openMenu(@NotNull CosmeticUser user, Cosmetic cosmetic) {
Player player = user.getPlayer();
if (player == null) return;
openMenu(player, user, cosmetic);
}
private static void addCosmetic(@NotNull Player viewer, @NotNull CosmeticHolder cosmeticHolder, @NotNull Cosmetic cosmetic, @Nullable Color color) {
cosmeticHolder.addCosmetic(cosmetic, color);
viewer.setItemOnCursor(new ItemStack(Material.AIR));
Bukkit.getScheduler().runTaskLater(HMCCosmeticsPlugin.getInstance(), () -> {
viewer.closeInventory();
cosmeticHolder.updateCosmetic(cosmetic.getSlot());
}, 2);
}
} }

View File

@@ -1,42 +0,0 @@
package com.hibiscusmc.hmccosmetics.gui.special;
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
import com.hibiscusmc.hmccosmetics.cosmetic.CosmeticHolder;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
public class DyeMenuProvider {
private static DyeMenu instance = null;
/**
* Sets the provider of the DyeMenu. Check {@link DyeMenuProvider#hasMenuProvider()} before attempting to set this,
* it is locked once a dye menu has been set!
* @param dyeMenu The dye menu implementation that wishes to be the provider.
* @throws IllegalStateException IllegalStateException will be thrown if a dye menu provider already is set by another plugin.
*/
public static void setDyeMenuProvider(@NotNull DyeMenu dyeMenu) throws IllegalStateException {
if (instance != null) {
throw new IllegalStateException("DyeMenu Implementation has already been set by another plugin.");
}
instance = dyeMenu;
}
/**
* Called when wishing to dye a cosmetic to hand it off to the dye menu implementation
* @param viewer The viewer of the menu
* @param cosmeticHolder The cosmetic holder that the player viewer wishing to modify (could be themselves or another CosmeticHolder)
* @param cosmetic The cosmetic the user wishes to dye
*/
public static void openMenu(@NotNull Player viewer, @NotNull CosmeticHolder cosmeticHolder, @NotNull Cosmetic cosmetic) {
instance.openMenu(viewer, cosmeticHolder, cosmetic);
}
/**
* Does HMCC have a dye menu provider already set?
* @return True if it is already set and locked; false if none have been set.
*/
public static boolean hasMenuProvider() {
return instance != null;
}
}

View File

@@ -1,58 +0,0 @@
package com.hibiscusmc.hmccosmetics.gui.special.impl;
import com.hibiscusmc.hmccolor.HMCColorApi;
import com.hibiscusmc.hmccolor.shaded.gui.guis.Gui;
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.cosmetic.CosmeticHolder;
import com.hibiscusmc.hmccosmetics.gui.special.DyeMenu;
import me.lojosho.hibiscuscommons.hooks.Hooks;
import me.lojosho.hibiscuscommons.nms.NMSHandlers;
import me.lojosho.hibiscuscommons.util.AdventureUtils;
import org.bukkit.Bukkit;
import org.bukkit.Color;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
public class HMCColorDyeMenu implements DyeMenu {
@Override
public void openMenu(@NotNull Player viewer, @NotNull CosmeticHolder cosmeticHolder, @NotNull Cosmetic cosmetic) {
ItemStack originalItem = cosmetic.getItem();
if (originalItem == null || !cosmetic.isDyeable()) return;
Gui gui = HMCColorApi.createColorMenu(viewer);
gui.updateTitle(AdventureUtils.MINI_MESSAGE.deserialize(Hooks.processPlaceholders(viewer, Settings.getDyeMenuName())));
gui.setItem(Settings.getDyeMenuInputSlot(), new GuiItem(originalItem));
gui.setDefaultTopClickAction(event -> {
if (event.getSlot() == Settings.getDyeMenuOutputSlot()) {
ItemStack item = event.getInventory().getItem(Settings.getDyeMenuOutputSlot());
if (item == null) return;
Color color = NMSHandlers.getHandler().getUtilHandler().getColor(item);
if (color == null) return;
addCosmetic(viewer, cosmeticHolder, cosmetic, color);
event.setCancelled(true);
} else event.setCancelled(true);
});
gui.setPlayerInventoryAction(event -> event.setCancelled(true));
gui.setCloseGuiAction(event -> {});
gui.open(viewer);
}
private void addCosmetic(@NotNull Player viewer, @NotNull CosmeticHolder cosmeticHolder, @NotNull Cosmetic cosmetic, @Nullable Color color) {
cosmeticHolder.addCosmetic(cosmetic, color);
viewer.setItemOnCursor(new ItemStack(Material.AIR));
Bukkit.getScheduler().runTaskLater(HMCCosmeticsPlugin.getInstance(), () -> {
viewer.closeInventory();
cosmeticHolder.updateCosmetic(cosmetic.getSlot());
}, 2);
}
}

View File

@@ -8,7 +8,6 @@ import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetics;
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticArmorType; import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticArmorType;
import com.hibiscusmc.hmccosmetics.gui.action.Actions; import com.hibiscusmc.hmccosmetics.gui.action.Actions;
import com.hibiscusmc.hmccosmetics.gui.special.DyeMenu; import com.hibiscusmc.hmccosmetics.gui.special.DyeMenu;
import com.hibiscusmc.hmccosmetics.gui.special.DyeMenuProvider;
import com.hibiscusmc.hmccosmetics.gui.type.Type; import com.hibiscusmc.hmccosmetics.gui.type.Type;
import com.hibiscusmc.hmccosmetics.user.CosmeticUser; import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
import com.hibiscusmc.hmccosmetics.util.MessagesUtil; import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
@@ -67,11 +66,14 @@ public class TypeCosmetic extends Type {
MessagesUtil.sendDebugMessages("Required click type: " + requiredClick); MessagesUtil.sendDebugMessages("Required click type: " + requiredClick);
MessagesUtil.sendDebugMessages("Click type: " + clickType.name()); MessagesUtil.sendDebugMessages("Click type: " + clickType.name());
boolean isRequiredClick = requiredClick.equalsIgnoreCase("ANY") || requiredClick.equalsIgnoreCase(clickType.name());
boolean isDyeClick = dyeClick.equalsIgnoreCase("ANY") || dyeClick.equalsIgnoreCase(clickType.name());
if (!isRequiredClick && !isDyeClick) {
MessagesUtil.sendMessage(viewer.getPlayer(), "invalid-click-type");
return;
}
final boolean isRequiredClick = requiredClick.equalsIgnoreCase("ANY") || requiredClick.equalsIgnoreCase(clickType.name()); if (!isRequiredClick && isDyeClick) isUnEquippingCosmetic = false;
final boolean isDyeClick = dyeClick.equalsIgnoreCase("ANY") || dyeClick.equalsIgnoreCase(clickType.name());
if (!isRequiredClick) isUnEquippingCosmetic = false;
List<String> actionStrings = new ArrayList<>(); List<String> actionStrings = new ArrayList<>();
ConfigurationNode actionConfig = config.node("actions"); ConfigurationNode actionConfig = config.node("actions");
@@ -103,11 +105,9 @@ public class TypeCosmetic extends Type {
} else { } else {
if (!actionConfig.node("on-equip").virtual()) actionStrings.addAll(actionConfig.node("on-equip").getList(String.class)); if (!actionConfig.node("on-equip").virtual()) actionStrings.addAll(actionConfig.node("on-equip").getList(String.class));
MessagesUtil.sendDebugMessages("on-equip"); MessagesUtil.sendDebugMessages("on-equip");
MessagesUtil.sendDebugMessages("Preparing for on-equip with the following checks:");
MessagesUtil.sendDebugMessages("CosmeticDyeable? " + cosmetic.isDyeable() + " / isDyeClick? " + isDyeClick + " / isHMCColorActive? " + Hooks.isActiveHook("HMCColor"));
// TODO: Redo this // TODO: Redo this
if (cosmetic.isDyeable() && isDyeClick && DyeMenuProvider.hasMenuProvider()) { if (cosmetic.isDyeable() && isDyeClick && Hooks.isActiveHook("HMCColor")) {
DyeMenuProvider.openMenu(viewer, cosmeticHolder, cosmetic); DyeMenu.openMenu(viewer, cosmeticHolder, cosmetic);
} else if (isRequiredClick) { } else if (isRequiredClick) {
cosmeticHolder.addCosmetic(cosmetic); cosmeticHolder.addCosmetic(cosmetic);
} }

View File

@@ -9,6 +9,7 @@ import com.hibiscusmc.hmccosmetics.user.CosmeticUsers;
import com.hibiscusmc.hmccosmetics.util.MessagesUtil; import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
import com.hibiscusmc.hmccosmetics.util.TranslationUtil; import com.hibiscusmc.hmccosmetics.util.TranslationUtil;
import me.clip.placeholderapi.expansion.PlaceholderExpansion; import me.clip.placeholderapi.expansion.PlaceholderExpansion;
import org.apache.commons.lang3.EnumUtils;
import org.bukkit.OfflinePlayer; import org.bukkit.OfflinePlayer;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.inventory.meta.ItemMeta;

View File

@@ -20,6 +20,7 @@ import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.event.player.PlayerTeleportEvent; import org.bukkit.event.player.PlayerTeleportEvent;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;

View File

@@ -0,0 +1,27 @@
package com.hibiscusmc.hmccosmetics.listener;
import com.hibiscusmc.hmccosmetics.nms.CosmeticChannelHandler;
import io.netty.channel.Channel;
import io.netty.channel.ChannelPipeline;
import net.minecraft.network.Connection;
import org.bukkit.craftbukkit.entity.CraftPlayer;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent;
public class PlayerPacketListener implements Listener {
@EventHandler
public void onPlayerJoin(PlayerJoinEvent event) {
Player player = event.getPlayer();
Channel channel = ((CraftPlayer) event.getPlayer()).getHandle().connection.connection.channel;
ChannelPipeline pipeline = channel.pipeline();
CosmeticChannelHandler channelHandler = new CosmeticChannelHandler(player);
for (String key : pipeline.toMap().keySet()) {
if (!(pipeline.get(key) instanceof Connection)) continue;
pipeline.addBefore(key, "hmccosmetics_channel_handler", channelHandler);
}
}
}

View File

@@ -0,0 +1,247 @@
package com.hibiscusmc.hmccosmetics.nms;
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
import com.hibiscusmc.hmccosmetics.config.Settings;
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
import com.hibiscusmc.hmccosmetics.cosmetic.CosmeticSlot;
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticArmorType;
import com.hibiscusmc.hmccosmetics.gui.Menu;
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
import com.hibiscusmc.hmccosmetics.user.CosmeticUsers;
import com.hibiscusmc.hmccosmetics.user.manager.UserWardrobeManager;
import com.hibiscusmc.hmccosmetics.util.HMCCInventoryUtils;
import com.hibiscusmc.hmccosmetics.util.HMCCServerUtils;
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
import com.mojang.datafixers.util.Pair;
import io.netty.buffer.Unpooled;
import io.netty.channel.ChannelDuplexHandler;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelPromise;
import me.lojosho.hibiscuscommons.nms.NMSHandlers;
import net.minecraft.core.NonNullList;
import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.network.protocol.Packet;
import net.minecraft.network.protocol.game.*;
import net.minecraft.network.protocol.status.ClientboundStatusResponsePacket;
import net.minecraft.network.protocol.status.ServerboundStatusRequestPacket;
import net.minecraft.world.inventory.ClickType;
import net.minecraft.world.item.ItemStack;
import org.bukkit.Bukkit;
import org.bukkit.craftbukkit.CraftEquipmentSlot;
import org.bukkit.craftbukkit.inventory.CraftItemStack;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.inventory.EquipmentSlot;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Objects;
public class CosmeticChannelHandler extends ChannelDuplexHandler {
private final Player player;
public CosmeticChannelHandler(Player player) {
this.player = player;
}
@Override
public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) throws Exception {
if (!(msg instanceof Packet packet)) {
super.write(ctx, msg, promise);
return;
}
switch (packet) {
case ClientboundContainerSetContentPacket setContentPacket -> msg = handleMenuChange(setContentPacket);
case ClientboundContainerSetSlotPacket setSlotPacket -> msg = handleSlotChange(setSlotPacket);
case ClientboundSetEquipmentPacket equipmentPacket -> msg = handlePlayerEquipment(equipmentPacket);
case ClientboundSetPassengersPacket passengerPacket -> msg = handlePassengerSet(passengerPacket);
default -> {
}
}
if (msg == null) return;
else super.write(ctx, msg, promise);
}
private Packet<?> handleMenuChange(ClientboundContainerSetContentPacket packet) {
MessagesUtil.sendDebugMessages("Menu Initial ");
int windowId = packet.getContainerId();
NonNullList<ItemStack> slotData = NonNullList.create();
slotData.addAll(packet.getItems());
if (windowId != 0) return packet;
CosmeticUser user = CosmeticUsers.getUser(player);
if (user == null) return packet;
HashMap<Integer, ItemStack> items = new HashMap<>();
if (!user.isInWardrobe()) for (Cosmetic cosmetic : user.getCosmetics()) if (cosmetic instanceof CosmeticArmorType armorType) {
boolean requireEmpty = Settings.getSlotOption(armorType.getEquipSlot()).isRequireEmpty();
boolean isAir = user.getPlayer().getInventory().getItem(armorType.getEquipSlot()).getType().isAir();
MessagesUtil.sendDebugMessages("Menu Fired (Checks) - " + armorType.getId() + " - " + requireEmpty + " - " + isAir);
if (requireEmpty && !isAir) continue;
items.put(HMCCInventoryUtils.getPacketArmorSlot(armorType.getEquipSlot()), CraftItemStack.asNMSCopy(user.getUserCosmeticItem(armorType)));
}
for (int slot = 0; slot < 46; slot++) {
if ((slot >= 5 && slot <= 8) || slot == 45) {
if (!items.containsKey(slot)) continue;
slotData.set(slot, items.get(slot));
if (Settings.isDebugMode()) MessagesUtil.sendDebugMessages("Set " + slot + " as " + items.get(slot));
}
}
MessagesUtil.sendDebugMessages("Menu Fired, updated cosmetics " + " on slotdata " + windowId + " with " + slotData.size());
return new ClientboundContainerSetContentPacket(0, packet.getStateId(), slotData, packet.getCarriedItem());
}
private Packet<?> handleSlotChange(ClientboundContainerSetSlotPacket packet) {
MessagesUtil.sendDebugMessages("SetSlot Initial ");
int windowId = packet.getContainerId();
if (windowId != 0) return packet;
CosmeticUser user = CosmeticUsers.getUser(player);
if (user == null || user.isInWardrobe()) return packet;
int slot = packet.getSlot();
MessagesUtil.sendDebugMessages("SetSlot Slot " + slot);
CosmeticSlot cosmeticSlot = HMCCInventoryUtils.NMSCosmeticSlot(slot);
EquipmentSlot equipmentSlot = HMCCInventoryUtils.getPacketArmorSlot(slot);
if (cosmeticSlot == null || equipmentSlot == null) return packet;
if (!user.hasCosmeticInSlot(cosmeticSlot)) return packet;
if (Settings.getSlotOption(equipmentSlot).isRequireEmpty()) {
if (!player.getInventory().getItem(equipmentSlot).getType().isAir()) return packet;
}
ItemStack item = CraftItemStack.asNMSCopy(user.getUserCosmeticItem(cosmeticSlot));
return new ClientboundContainerSetSlotPacket(0, packet.getStateId(), slot, item);
}
private Packet<?> handlePlayerEquipment(ClientboundSetEquipmentPacket packet) {
CosmeticUser user = CosmeticUsers.getUser(packet.getEntity());
if (user == null || user.isInWardrobe()) return packet;
List<Pair<net.minecraft.world.entity.EquipmentSlot, ItemStack>> armor = packet.getSlots();
for (int i = 0; i < armor.size(); i++) {
Pair<net.minecraft.world.entity.EquipmentSlot, ItemStack> pair = armor.get(i);
if (pair.getFirst() == net.minecraft.world.entity.EquipmentSlot.MAINHAND) {
if (user.getPlayer().getUniqueId() == player.getUniqueId())
continue; // When a player scrolls real fast, it messes up the mainhand. This fixes it
if (user.getPlayer() != null && user.getPlayer().isInvisible())
continue; // Fixes integration with GSit still showing mainhand even when hidden
armor.set(i, new Pair<>(pair.getFirst(), CraftItemStack.asNMSCopy(player.getInventory().getItemInMainHand())));
} else {
EquipmentSlot slot = CraftEquipmentSlot.getSlot(pair.getFirst());
if (slot == null) continue;
CosmeticSlot cosmeticSlot = HMCCInventoryUtils.BukkitCosmeticSlot(slot);
if (cosmeticSlot == null) continue;
if (Settings.getSlotOption(slot).isRequireEmpty() && player.getInventory().getItem(slot).getType().isAir())
continue;
CosmeticArmorType cosmeticArmor = (CosmeticArmorType) user.getCosmetic(cosmeticSlot);
if (cosmeticArmor == null) continue;
ItemStack item = CraftItemStack.asNMSCopy(user.getUserCosmeticItem(cosmeticSlot));
if (item == null) continue;
armor.set(i, new Pair<>(pair.getFirst(), item));
}
}
MessagesUtil.sendDebugMessages("Equipment for " + user.getPlayer().getName() + " has been updated for " + player.getName());
return new ClientboundSetEquipmentPacket(packet.getEntity(), armor);
}
private Packet<?> handlePassengerSet(ClientboundSetPassengersPacket packet) {
CosmeticUser viewerUser = CosmeticUsers.getUser(player);
if (viewerUser == null || viewerUser.isInWardrobe()) return packet;
int ownerId = packet.getVehicle();
MessagesUtil.sendDebugMessages("Mount Packet Sent - Read - EntityID: " + ownerId);
Entity entity = HMCCServerUtils.getEntity(ownerId);
if (entity == null) return packet;
CosmeticUser user = CosmeticUsers.getUser(entity.getUniqueId());
if (user == null) return packet;
MessagesUtil.sendDebugMessages("Mount Packet Sent - " + user.getUniqueId());
if (!user.hasCosmeticInSlot(CosmeticSlot.BACKPACK)) return packet;
if (user.getUserBackpackManager() == null) return packet;
List<Integer> passengers = new ArrayList<>(user.getUserBackpackManager().getEntityManager().getIds());
for (int passenger : packet.getPassengers()) passengers.add(passenger);
int[] passengerIds = passengers.stream().mapToInt(Integer::intValue).toArray();
return (Packet<?>) NMSHandlers.getHandler().getPacketHandler().createMountPacket(ownerId, passengerIds);
}
@Override
public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
if (!(msg instanceof Packet packet)) {
super.channelRead(ctx, msg);
return;
}
switch (packet) {
case ServerboundContainerClickPacket clickPacket -> handleInventoryClick(clickPacket);
case ServerboundPlayerActionPacket playerActionPacket -> msg = handlePlayerAction(playerActionPacket);
case ServerboundSwingPacket swingPacket -> msg = handlePlayerArm(swingPacket);
case ServerboundUseItemOnPacket useItemOnPacket -> msg = handleEntityUse(useItemOnPacket);
default -> {
}
}
if (msg == null) return;
else super.channelRead(ctx, msg);
}
private void handleInventoryClick(ServerboundContainerClickPacket packet) {
ClickType clickType = packet.getClickType();
int slotClicked = packet.getSlotNum();
if (clickType != ClickType.PICKUP || slotClicked == -999) return;
CosmeticUser user = CosmeticUsers.getUser(player);
if (user == null || user.isInWardrobe()) return;
CosmeticSlot cosmeticSlot = HMCCInventoryUtils.NMSCosmeticSlot(slotClicked);
if (cosmeticSlot == null || !user.hasCosmeticInSlot(cosmeticSlot)) return;
Bukkit.getScheduler().runTaskLater(HMCCosmeticsPlugin.getInstance(), () -> user.updateCosmetic(cosmeticSlot), 1);
MessagesUtil.sendDebugMessages("Packet fired, updated cosmetic " + cosmeticSlot);
}
private Packet<?> handlePlayerAction(ServerboundPlayerActionPacket packet) {
ServerboundPlayerActionPacket.Action action = packet.getAction();
MessagesUtil.sendDebugMessages("EntityStatus Initial " + player.getEntityId() + " - " + action);
if (action != ServerboundPlayerActionPacket.Action.SWAP_ITEM_WITH_OFFHAND) return packet;
CosmeticUser user = CosmeticUsers.getUser(player);
if (user == null) {
MessagesUtil.sendDebugMessages("EntityStatus User is null");
return packet;
}
if (!user.hasCosmeticInSlot(CosmeticSlot.OFFHAND)) return packet;
return null;
}
private Packet<?> handlePlayerArm(ServerboundSwingPacket packet) {
CosmeticUser user = CosmeticUsers.getUser(player);
if (user == null || !user.isInWardrobe() || !user.getWardrobeManager().getWardrobeStatus().equals(UserWardrobeManager.WardrobeStatus.RUNNING)) return packet;
Menu menu = user.getWardrobeManager().getLastOpenMenu();
if (menu == null) return packet;
menu.openMenu(user);
return null;
}
private Packet<?> handleEntityUse(ServerboundUseItemOnPacket packet) {
CosmeticUser user = CosmeticUsers.getUser(player);
if (user == null || !user.isInWardrobe()) return packet;
else return null;
}
}

View File

@@ -1,225 +0,0 @@
package com.hibiscusmc.hmccosmetics.packets;
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
import com.hibiscusmc.hmccosmetics.config.Settings;
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
import com.hibiscusmc.hmccosmetics.cosmetic.CosmeticSlot;
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticArmorType;
import com.hibiscusmc.hmccosmetics.gui.Menu;
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
import com.hibiscusmc.hmccosmetics.user.CosmeticUsers;
import com.hibiscusmc.hmccosmetics.user.manager.UserBackpackManager;
import com.hibiscusmc.hmccosmetics.user.manager.UserWardrobeManager;
import com.hibiscusmc.hmccosmetics.util.HMCCInventoryUtils;
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
import com.hibiscusmc.hmccosmetics.util.packets.HMCCPacketManager;
import me.lojosho.hibiscuscommons.packets.PacketAction;
import me.lojosho.hibiscuscommons.packets.PacketInterface;
import me.lojosho.hibiscuscommons.packets.wrapper.*;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.inventory.EquipmentSlot;
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull;
import java.util.*;
public class CosmeticPacketInterface implements PacketInterface {
@Override
public @NotNull PacketAction writeContainerContent(@NotNull Player player, @NotNull ContainerContentWrapper wrapper) {
int windowId = wrapper.getWindowId();
MessagesUtil.sendDebugMessages("writeContainerContent (windowid: " + windowId + " )");
if (windowId != 0) return PacketAction.NOTHING;
List<ItemStack> slotData = wrapper.getSlotData();
CosmeticUser user = CosmeticUsers.getUser(player);
if (user == null) return PacketAction.NOTHING;
HashMap<Integer, ItemStack> cosmeticItems = new HashMap<>();
if (!user.isInWardrobe()) {
for (Cosmetic cosmetic : user.getCosmetics()) {
if (cosmetic instanceof CosmeticArmorType armorType) {
boolean requireEmpty = Settings.getSlotOption(armorType.getEquipSlot()).isRequireEmpty();
boolean isAir = user.getPlayer().getInventory().getItem(armorType.getEquipSlot()).getType().isAir();
MessagesUtil.sendDebugMessages("Menu Fired (Checks) - " + armorType.getId() + " - " + requireEmpty + " - " + isAir);
if (requireEmpty && !isAir) continue;
cosmeticItems.put(HMCCInventoryUtils.getPacketArmorSlot(armorType.getEquipSlot()), user.getUserCosmeticItem(armorType));
}
}
}
for (int slot = 0; slot < 46; slot++) {
if ((slot >= 5 && slot <= 8) || slot == 45) {
if (!cosmeticItems.containsKey(slot)) continue;
slotData.set(slot, cosmeticItems.get(slot));
if (Settings.isDebugMode()) MessagesUtil.sendDebugMessages("Set " + slot + " as " + cosmeticItems.get(slot));
}
}
wrapper.setSlotData(slotData);
MessagesUtil.sendDebugMessages("Menu Fired, updated cosmetics " + " on slotdata " + windowId + " with " + slotData.size());
return PacketAction.CHANGED;
}
@Override
public @NotNull PacketAction writeSlotContent(@NotNull Player player, @NotNull SlotContentWrapper wrapper) {
int windowId = wrapper.getWindowId();
int slot = wrapper.getSlot();
ItemStack itemStack = wrapper.getItemStack();
MessagesUtil.sendDebugMessages("SetSlot Initial ");
if (windowId != 0) return PacketAction.NOTHING;
CosmeticUser user = CosmeticUsers.getUser(player);
if (user == null || user.isInWardrobe()) return PacketAction.NOTHING;
MessagesUtil.sendDebugMessages("SetSlot Slot " + slot);
CosmeticSlot cosmeticSlot = HMCCInventoryUtils.NMSCosmeticSlot(slot);
EquipmentSlot equipmentSlot = HMCCInventoryUtils.getPacketArmorSlot(slot);
if (cosmeticSlot == null || equipmentSlot == null) return PacketAction.NOTHING;
if (!user.hasCosmeticInSlot(cosmeticSlot)) return PacketAction.NOTHING;
if (Settings.getSlotOption(equipmentSlot).isRequireEmpty()) {
if (!player.getInventory().getItem(equipmentSlot).getType().isAir()) return PacketAction.NOTHING;
}
wrapper.setItemStack(user.getUserCosmeticItem(cosmeticSlot));
return PacketAction.CHANGED;
}
@Override
public @NotNull PacketAction writeEquipmentContent(@NotNull Player player, @NotNull EntityEquipmentWrapper wrapper) {
if (player.getEntityId() != wrapper.getEntityId()) return PacketAction.NOTHING;
CosmeticUser user = CosmeticUsers.getUser(player);
if (user == null || user.isInWardrobe()) return PacketAction.NOTHING;
Map<EquipmentSlot, ItemStack> armor = wrapper.getArmor();
for (Map.Entry<EquipmentSlot, ItemStack> armorSlot : armor.entrySet()) {
EquipmentSlot slot = armorSlot.getKey();
if (slot == EquipmentSlot.HAND) {
if (user.getPlayer().getUniqueId() == player.getUniqueId())
continue; // When a player scrolls real fast, it messes up the mainhand. This fixes it
if (user.getPlayer() != null && user.getPlayer().isInvisible())
continue; // Fixes integration with GSit still showing mainhand even when hidden
armor.put(slot, player.getInventory().getItemInMainHand());
} else {
CosmeticSlot cosmeticSlot = HMCCInventoryUtils.BukkitCosmeticSlot(slot);
if (cosmeticSlot == null) continue;
if (Settings.getSlotOption(slot).isRequireEmpty() && player.getInventory().getItem(slot).getType().isAir())
continue;
CosmeticArmorType cosmeticArmor = (CosmeticArmorType) user.getCosmetic(cosmeticSlot);
if (cosmeticArmor == null) continue;
ItemStack item = user.getUserCosmeticItem(cosmeticSlot);
if (item == null) continue;
armor.put(slot, item);
}
}
wrapper.setArmor(armor);
MessagesUtil.sendDebugMessages("Equipment for " + user.getPlayer().getName() + " has been updated for " + player.getName());
return PacketAction.CHANGED;
}
@Override
public @NotNull PacketAction writePassengerContent(@NotNull Player player, @NotNull PassengerWrapper wrapper) {
return PacketAction.NOTHING;
// TODO: Figure out what to do with this, because with it in, it ruins backpacks (they keep getting thrown to random locations).
// When you have this all disabled, it works better
/*
CosmeticUser viewerUser = CosmeticUsers.getUser(player);
if (viewerUser == null || viewerUser.isInWardrobe()) return PacketAction.NOTHING;
int ownerId = wrapper.getOwner();
List<Integer> originalPassengers = wrapper.getPassengers();
MessagesUtil.sendDebugMessages("Mount Packet Read - EntityID: " + ownerId);
Optional<CosmeticUser> optionalCosmeticUser = CosmeticUsers.values().stream().filter(user -> user.getPlayer() != null).filter(user -> ownerId == user.getPlayer().getEntityId()).findFirst();
if (optionalCosmeticUser.isEmpty()) return PacketAction.NOTHING;
CosmeticUser user = optionalCosmeticUser.get();
MessagesUtil.sendDebugMessages("Mount Packet Sent - " + user.getUniqueId());
if (!user.hasCosmeticInSlot(CosmeticSlot.BACKPACK)) return PacketAction.NOTHING;
if (user.getUserBackpackManager() == null) return PacketAction.NOTHING;
List<Integer> passengers = new ArrayList<>(user.getUserBackpackManager().getEntityManager().getIds());
passengers.addAll(originalPassengers);
wrapper.setPassengers(passengers);
return PacketAction.CHANGED;
*/
}
@Override
public PacketAction readPlayerScale(@NotNull Player player, @NotNull PlayerScaleWrapper wrapper) {
int entityId = wrapper.getEntityId();
Player changedPlayer = Bukkit.getOnlinePlayers().stream()
.filter(onlinePlayer -> onlinePlayer.getEntityId() == entityId)
.findFirst()
.orElse(null);
if (changedPlayer == null) return PacketAction.NOTHING;
CosmeticUser cosmeticUser = CosmeticUsers.getUser(changedPlayer.getUniqueId());
if (cosmeticUser == null || cosmeticUser.isInWardrobe()) return PacketAction.NOTHING;
UserBackpackManager backpack = cosmeticUser.getUserBackpackManager();
if (backpack != null) {
for (int cosmeticId : backpack.getEntityManager().getIds()) {
HMCCPacketManager.sendEntityScalePacket(cosmeticId, wrapper.getScale(), Collections.singletonList(player));
}
}
return PacketAction.NOTHING;
}
@Override
public @NotNull PacketAction readInventoryClick(@NotNull Player player, @NotNull InventoryClickWrapper wrapper) {
int clickType = wrapper.getClickType();
int slotNumber = wrapper.getSlotNumber();
if (clickType != 0 || slotNumber == -999) return PacketAction.NOTHING;
CosmeticUser user = CosmeticUsers.getUser(player);
if (user == null || user.isInWardrobe()) return PacketAction.NOTHING;
CosmeticSlot cosmeticSlot = HMCCInventoryUtils.NMSCosmeticSlot(slotNumber);
if (cosmeticSlot == null || !user.hasCosmeticInSlot(cosmeticSlot)) return PacketAction.NOTHING;
Bukkit.getScheduler().runTaskLater(HMCCosmeticsPlugin.getInstance(), () -> user.updateCosmetic(cosmeticSlot), 1);
MessagesUtil.sendDebugMessages("Packet fired, updated cosmetic " + cosmeticSlot);
return PacketAction.NOTHING;
}
@Override
public @NotNull PacketAction readPlayerAction(@NotNull Player player, @NotNull PlayerActionWrapper wrapper) {
String actionType = wrapper.getActionType();
MessagesUtil.sendDebugMessages("EntityStatus Initial " + player.getEntityId() + " - " + actionType);
// If it's not SWAP_ITEM_WITH_OFFHAND, ignore
if (!actionType.equalsIgnoreCase("SWAP_ITEM_WITH_OFFHAND")) return PacketAction.NOTHING;
CosmeticUser user = CosmeticUsers.getUser(player);
if (user == null) {
MessagesUtil.sendDebugMessages("EntityStatus User is null");
return PacketAction.NOTHING;
}
if (!user.hasCosmeticInSlot(CosmeticSlot.OFFHAND)) return PacketAction.NOTHING;
return PacketAction.CANCELLED;
}
@Override
public @NotNull PacketAction readPlayerArm(@NotNull Player player, @NotNull PlayerSwingWrapper wrapper) {
CosmeticUser user = CosmeticUsers.getUser(player);
if (user == null || !user.isInWardrobe() || !user.getWardrobeManager().getWardrobeStatus().equals(UserWardrobeManager.WardrobeStatus.RUNNING)) return PacketAction.NOTHING;
Menu menu = user.getWardrobeManager().getLastOpenMenu();
if (menu == null) return PacketAction.NOTHING;
menu.openMenu(user);
return PacketAction.CANCELLED;
}
@Override
public @NotNull PacketAction readEntityHandle(@NotNull Player player, @NotNull PlayerInteractWrapper wrapper) {
CosmeticUser user = CosmeticUsers.getUser(player);
if (user == null || !user.isInWardrobe()) return PacketAction.NOTHING;
else return PacketAction.CANCELLED;
}
}

View File

@@ -13,6 +13,7 @@ import com.hibiscusmc.hmccosmetics.cosmetic.CosmeticSlot;
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticArmorType; import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticArmorType;
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticBackpackType; import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticBackpackType;
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticBalloonType; import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticBalloonType;
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticMainhandType;
import com.hibiscusmc.hmccosmetics.database.UserData; import com.hibiscusmc.hmccosmetics.database.UserData;
import com.hibiscusmc.hmccosmetics.gui.Menus; import com.hibiscusmc.hmccosmetics.gui.Menus;
import com.hibiscusmc.hmccosmetics.user.manager.UserBackpackManager; import com.hibiscusmc.hmccosmetics.user.manager.UserBackpackManager;
@@ -21,6 +22,7 @@ import com.hibiscusmc.hmccosmetics.user.manager.UserWardrobeManager;
import com.hibiscusmc.hmccosmetics.util.HMCCInventoryUtils; import com.hibiscusmc.hmccosmetics.util.HMCCInventoryUtils;
import com.hibiscusmc.hmccosmetics.util.MessagesUtil; import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
import com.hibiscusmc.hmccosmetics.util.packets.HMCCPacketManager; import com.hibiscusmc.hmccosmetics.util.packets.HMCCPacketManager;
import com.ticxo.modelengine.api.nms.NMSHandler;
import lombok.Getter; import lombok.Getter;
import me.lojosho.hibiscuscommons.hooks.Hooks; import me.lojosho.hibiscuscommons.hooks.Hooks;
import me.lojosho.hibiscuscommons.nms.NMSHandlers; import me.lojosho.hibiscuscommons.nms.NMSHandlers;
@@ -28,6 +30,7 @@ import me.lojosho.hibiscuscommons.util.InventoryUtils;
import me.lojosho.hibiscuscommons.util.packets.PacketManager; import me.lojosho.hibiscuscommons.util.packets.PacketManager;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Color; import org.bukkit.Color;
import org.bukkit.FireworkEffect;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
import org.bukkit.entity.HumanEntity; import org.bukkit.entity.HumanEntity;
@@ -36,7 +39,6 @@ import org.bukkit.inventory.EquipmentSlot;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.*; import org.bukkit.inventory.meta.*;
import org.bukkit.persistence.PersistentDataType; import org.bukkit.persistence.PersistentDataType;
import org.bukkit.potion.PotionEffectType;
import org.bukkit.scheduler.BukkitTask; import org.bukkit.scheduler.BukkitTask;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
@@ -142,18 +144,13 @@ public class CosmeticUser implements CosmeticHolder {
showCosmetics(HiddenReason.GAMEMODE); showCosmetics(HiddenReason.GAMEMODE);
} }
if (bukkitPlayer != null && Settings.getDisabledWorlds().contains(bukkitPlayer.getLocation().getWorld().getName())) { if (bukkitPlayer != null && Settings.getDisabledWorlds().contains(getEntity().getLocation().getWorld().getName())) {
MessagesUtil.sendDebugMessages("Hiding Cosmetics due to world"); MessagesUtil.sendDebugMessages("Hiding Cosmetics due to world");
hideCosmetics(CosmeticUser.HiddenReason.WORLD); hideCosmetics(CosmeticUser.HiddenReason.WORLD);
} else if (this.isHidden(HiddenReason.WORLD)) { } else if (this.isHidden(HiddenReason.WORLD)) {
MessagesUtil.sendDebugMessages("Showing Cosmetics due to world"); MessagesUtil.sendDebugMessages("Showing Cosmetics due to world");
showCosmetics(HiddenReason.WORLD); showCosmetics(HiddenReason.WORLD);
} }
if (bukkitPlayer != null && bukkitPlayer.hasPotionEffect(PotionEffectType.INVISIBILITY)) {
hideCosmetics(HiddenReason.POTION);
}
if (Settings.isAllPlayersHidden()) { if (Settings.isAllPlayersHidden()) {
hideCosmetics(HiddenReason.DISABLED); hideCosmetics(HiddenReason.DISABLED);
} }
@@ -348,7 +345,7 @@ public class CosmeticUser implements CosmeticHolder {
if (cosmetic instanceof CosmeticArmorType armorType) { if (cosmetic instanceof CosmeticArmorType armorType) {
item = armorType.getItem(this, cosmetic.getItem()); item = armorType.getItem(this, cosmetic.getItem());
} }
if (cosmetic instanceof CosmeticBackpackType) { if (cosmetic instanceof CosmeticBackpackType || cosmetic instanceof CosmeticMainhandType) {
item = cosmetic.getItem(); item = cosmetic.getItem();
} }
if (cosmetic instanceof CosmeticBalloonType) { if (cosmetic instanceof CosmeticBalloonType) {
@@ -606,7 +603,7 @@ public class CosmeticUser implements CosmeticHolder {
* @return Entity * @return Entity
*/ */
public Entity getEntity() { public Entity getEntity() {
return getPlayer(); return Bukkit.getEntity(uniqueId);
} }
public Color getCosmeticColor(CosmeticSlot slot) { public Color getCosmeticColor(CosmeticSlot slot) {
@@ -629,12 +626,7 @@ public class CosmeticUser implements CosmeticHolder {
if (isInWardrobe() && !ignoreWardrobe) { if (isInWardrobe() && !ignoreWardrobe) {
if (WardrobeSettings.isTryCosmeticsInWardrobe() && userWardrobeManager.getWardrobeStatus().equals(UserWardrobeManager.WardrobeStatus.RUNNING)) return true; if (WardrobeSettings.isTryCosmeticsInWardrobe() && userWardrobeManager.getWardrobeStatus().equals(UserWardrobeManager.WardrobeStatus.RUNNING)) return true;
} }
final Player player = getPlayer(); return getEntity().hasPermission(cosmetic.getPermission());
if (player != null) return player.hasPermission(cosmetic.getPermission());
// This sucks, but basically if we can find a player, use that. If not, try to find the entity. If it can't find the entity, just return false.
final Entity entity = getEntity();
if (entity != null) return entity.hasPermission(cosmetic.getPermission());
return false;
} }
public void hidePlayer() { public void hidePlayer() {

View File

@@ -5,12 +5,12 @@ import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticBackpackType;
import com.hibiscusmc.hmccosmetics.user.CosmeticUser; import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
import com.hibiscusmc.hmccosmetics.util.MessagesUtil; import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
import com.hibiscusmc.hmccosmetics.util.packets.HMCCPacketManager; import com.hibiscusmc.hmccosmetics.util.packets.HMCCPacketManager;
import com.ticxo.modelengine.api.ModelEngineAPI;
import lombok.Getter; import lombok.Getter;
import me.lojosho.hibiscuscommons.hooks.Hooks;
import me.lojosho.hibiscuscommons.util.ServerUtils; import me.lojosho.hibiscuscommons.util.ServerUtils;
import me.lojosho.hibiscuscommons.util.packets.PacketManager; import me.lojosho.hibiscuscommons.util.packets.PacketManager;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.attribute.Attribute;
import org.bukkit.attribute.AttributeInstance;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType; import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@@ -20,6 +20,7 @@ import org.bukkit.inventory.ItemStack;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.UUID; import java.util.UUID;
import java.util.logging.Level;
public class UserBackpackManager { public class UserBackpackManager {
@@ -58,13 +59,6 @@ public class UserBackpackManager {
HMCCPacketManager.sendEntitySpawnPacket(user.getEntity().getLocation(), getFirstArmorStandId(), EntityType.ARMOR_STAND, UUID.randomUUID(), getEntityManager().getViewers()); HMCCPacketManager.sendEntitySpawnPacket(user.getEntity().getLocation(), getFirstArmorStandId(), EntityType.ARMOR_STAND, UUID.randomUUID(), getEntityManager().getViewers());
HMCCPacketManager.sendArmorstandMetadata(getFirstArmorStandId(), outsideViewers); HMCCPacketManager.sendArmorstandMetadata(getFirstArmorStandId(), outsideViewers);
if (user.getPlayer() != null) {
AttributeInstance scaleAttribute = user.getPlayer().getAttribute(Attribute.GENERIC_SCALE);
if (scaleAttribute != null) {
HMCCPacketManager.sendEntityScalePacket(getFirstArmorStandId(), scaleAttribute.getValue(), outsideViewers);
}
}
Entity entity = user.getEntity(); Entity entity = user.getEntity();
int[] passengerIDs = new int[entity.getPassengers().size() + 1]; int[] passengerIDs = new int[entity.getPassengers().size() + 1];

View File

@@ -99,12 +99,7 @@ public class UserBalloonManager {
} }
public void remove() { public void remove() {
// This code is like a brick road, always bumpy. pufferfish.destroyPufferfish();
// Basically, the balloon viewers ignore people in wardrobe, which well, if your the user in the wardrobe, ain't including you.
// This manually passes in the viewers for it to destroy, which includes the person in the wardrobe
if (user.getPlayer() != null && user.isInWardrobe()) pufferfish.destroyPufferfish(List.of(user.getPlayer()));
else pufferfish.destroyPufferfish();
if (balloonType == BalloonType.MODELENGINE) { if (balloonType == BalloonType.MODELENGINE) {
final ModeledEntity entity = ModelEngineAPI.getModeledEntity(modelEntity); final ModeledEntity entity = ModelEngineAPI.getModeledEntity(modelEntity);
if (entity == null) { if (entity == null) {

View File

@@ -1,12 +1,17 @@
package com.hibiscusmc.hmccosmetics.user.manager; package com.hibiscusmc.hmccosmetics.user.manager;
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin; import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
import com.hibiscusmc.hmccosmetics.user.CosmeticUsers;
import com.hibiscusmc.hmccosmetics.util.HMCCPlayerUtils;
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
import com.hibiscusmc.hmccosmetics.util.packets.HMCCPacketManager; import com.hibiscusmc.hmccosmetics.util.packets.HMCCPacketManager;
import lombok.Getter; import lombok.Getter;
import org.bukkit.Bukkit;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.entity.EntityType; import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.UUID; import java.util.UUID;
@@ -40,12 +45,6 @@ public class UserBalloonPufferfish extends UserEntity {
destroyed = true; destroyed = true;
} }
public void destroyPufferfish(List<Player> viewers) {
HMCCPacketManager.sendEntityDestroyPacket(pufferFishEntityId, viewers);
//getViewers().clear();
destroyed = true;
}
@Override @Override
public List<Player> refreshViewers(Location location) { public List<Player> refreshViewers(Location location) {
if (destroyed) return List.of(); //Prevents refreshing a destroyed entity if (destroyed) return List.of(); //Prevents refreshing a destroyed entity

View File

@@ -1,8 +1,8 @@
package com.hibiscusmc.hmccosmetics.user.manager; package com.hibiscusmc.hmccosmetics.user.manager;
import com.hibiscusmc.hmccosmetics.config.Settings;
import com.hibiscusmc.hmccosmetics.user.CosmeticUser; import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
import com.hibiscusmc.hmccosmetics.user.CosmeticUsers; import com.hibiscusmc.hmccosmetics.user.CosmeticUsers;
import com.hibiscusmc.hmccosmetics.util.HMCCPlayerUtils;
import com.hibiscusmc.hmccosmetics.util.MessagesUtil; import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
import com.hibiscusmc.hmccosmetics.util.packets.HMCCPacketManager; import com.hibiscusmc.hmccosmetics.util.packets.HMCCPacketManager;
import lombok.Getter; import lombok.Getter;

View File

@@ -117,8 +117,6 @@ public class UserWardrobeManager {
// Armorstand // Armorstand
HMCCPacketManager.sendEntitySpawnPacket(viewingLocation, ARMORSTAND_ID, EntityType.ARMOR_STAND, UUID.randomUUID(), viewer); HMCCPacketManager.sendEntitySpawnPacket(viewingLocation, ARMORSTAND_ID, EntityType.ARMOR_STAND, UUID.randomUUID(), viewer);
HMCCPacketManager.sendArmorstandMetadata(ARMORSTAND_ID, viewer); HMCCPacketManager.sendArmorstandMetadata(ARMORSTAND_ID, viewer);
NMSHandlers.getHandler().getPacketHandler().sendTeleportPacket(ARMORSTAND_ID, viewingLocation.getX(), viewingLocation.getY(), viewingLocation.getZ(), viewingLocation.getYaw(), viewingLocation.getPitch(), false, viewer);
//NMSHandlers.getHandler().getPacketHandler().sendLookAtPacket(ARMORSTAND_ID, viewingLocation, viewer);
HMCCPacketManager.sendRotateHeadPacket(ARMORSTAND_ID, viewingLocation, viewer); HMCCPacketManager.sendRotateHeadPacket(ARMORSTAND_ID, viewingLocation, viewer);
// Player // Player
@@ -236,7 +234,7 @@ public class UserWardrobeManager {
// NPC // NPC
if (user.isBalloonSpawned()) user.getBalloonManager().sendRemoveLeashPacket(); if (user.isBalloonSpawned()) user.getBalloonManager().sendRemoveLeashPacket();
HMCCPacketManager.sendEntityDestroyPacket(NPC_ID, viewer); // Success HMCCPacketManager.sendEntityDestroyPacket(NPC_ID, viewer); // Success
HMCCPacketManager.sendRemovePlayerPacket(player, WARDROBE_UUID, viewer); // Success HMCCPacketManager.sendRemovePlayerPacket(WARDROBE_UUID, viewer); // Success
// Player // Player
HMCCPacketManager.sendCameraPacket(player.getEntityId(), viewer); HMCCPacketManager.sendCameraPacket(player.getEntityId(), viewer);
@@ -316,10 +314,8 @@ public class UserWardrobeManager {
HMCCPacketManager.sendRotateHeadPacket(NPC_ID, location, viewer); HMCCPacketManager.sendRotateHeadPacket(NPC_ID, location, viewer);
user.hidePlayer(); user.hidePlayer();
int rotationSpeed = WardrobeSettings.getRotationSpeed(); int rotationSpeed = WardrobeSettings.getRotationSpeed();
int newYaw = HMCCServerUtils.getNextYaw(yaw - 30, rotationSpeed); location.setYaw(HMCCServerUtils.getNextYaw(yaw - 30, rotationSpeed));
location.setYaw(newYaw); HMCCPacketManager.sendRotationPacket(NPC_ID, location, true, viewer);
NMSHandlers.getHandler().getPacketHandler().sendRotationPacket(NPC_ID, newYaw, 0, false, viewer);
HMCCPacketManager.sendRotationPacket(NPC_ID, newYaw, true, viewer);
int nextyaw = HMCCServerUtils.getNextYaw(yaw, rotationSpeed); int nextyaw = HMCCServerUtils.getNextYaw(yaw, rotationSpeed);
data.set(nextyaw); data.set(nextyaw);
@@ -327,10 +323,11 @@ public class UserWardrobeManager {
HMCCPacketManager.equipmentSlotUpdate(NPC_ID, user, slot, viewer); HMCCPacketManager.equipmentSlotUpdate(NPC_ID, user, slot, viewer);
} }
// Handle backpacks
if (user.hasCosmeticInSlot(CosmeticSlot.BACKPACK) && user.getUserBackpackManager() != null) { if (user.hasCosmeticInSlot(CosmeticSlot.BACKPACK) && user.getUserBackpackManager() != null) {
HMCCPacketManager.sendTeleportPacket(user.getUserBackpackManager().getFirstArmorStandId(), location, false, viewer); HMCCPacketManager.sendTeleportPacket(user.getUserBackpackManager().getFirstArmorStandId(), location, false, viewer);
HMCCPacketManager.ridingMountPacket(NPC_ID, user.getUserBackpackManager().getFirstArmorStandId(), viewer); HMCCPacketManager.ridingMountPacket(NPC_ID, user.getUserBackpackManager().getFirstArmorStandId(), viewer);
user.getUserBackpackManager().getEntityManager().setRotation(nextyaw); //user.getUserBackpackManager().getEntityManager().setRotation(nextyaw);
HMCCPacketManager.sendEntityDestroyPacket(user.getUserBackpackManager().getFirstArmorStandId(), outsideViewers); HMCCPacketManager.sendEntityDestroyPacket(user.getUserBackpackManager().getFirstArmorStandId(), outsideViewers);
} }
@@ -362,5 +359,4 @@ public class UserWardrobeManager {
RUNNING, RUNNING,
STOPPING, STOPPING,
} }
} }

View File

@@ -50,6 +50,18 @@ public class HMCCInventoryUtils {
}; };
} }
// public static CosmeticSlot getItemSlotToCosmeticSlot(final EnumWrappers.ItemSlot slot) {
// return switch (slot) {
// case HEAD -> CosmeticSlot.HELMET;
// case CHEST -> CosmeticSlot.CHESTPLATE;
// case LEGS -> CosmeticSlot.LEGGINGS;
// case FEET -> CosmeticSlot.BOOTS;
// case OFFHAND -> CosmeticSlot.OFFHAND;
// case MAINHAND -> CosmeticSlot.MAINHAND;
// default -> null;
// };
// }
public static CosmeticSlot BukkitCosmeticSlot(EquipmentSlot slot) { public static CosmeticSlot BukkitCosmeticSlot(EquipmentSlot slot) {
return switch (slot) { return switch (slot) {
case HAND -> CosmeticSlot.MAINHAND; case HAND -> CosmeticSlot.MAINHAND;
@@ -118,6 +130,32 @@ public class HMCCInventoryUtils {
return SLOT_MAP.get(slot); return SLOT_MAP.get(slot);
} }
// public static EquipmentSlot getEquipmentSlot(@NotNull EnumWrappers.ItemSlot slot) {
// switch (slot) {
// case HEAD -> {
// return EquipmentSlot.HEAD;
// }
// case CHEST -> {
// return EquipmentSlot.CHEST;
// }
// case LEGS -> {
// return EquipmentSlot.LEGS;
// }
// case FEET -> {
// return EquipmentSlot.FEET;
// }
// case OFFHAND -> {
// return EquipmentSlot.OFF_HAND;
// }
// case MAINHAND -> {
// return EquipmentSlot.HAND;
// }
// default -> {
// return null;
// }
// }
// }
public static boolean isCosmeticItem(ItemStack itemStack) { public static boolean isCosmeticItem(ItemStack itemStack) {
if (itemStack == null) return false; if (itemStack == null) return false;
itemStack = itemStack.clone(); itemStack = itemStack.clone();

View File

@@ -18,20 +18,6 @@ public class HMCCServerUtils {
private static String COLOR_CHAR = "&"; private static String COLOR_CHAR = "&";
/**
* Converts a bukkit gamemode into an integer for use in packets
* @param gamemode Bukkit gamemode to convert.
* @return int of the gamemode
*/
public static int convertGamemode(final GameMode gamemode) {
return switch (gamemode) {
case SURVIVAL -> 0;
case CREATIVE -> 1;
case ADVENTURE -> 2;
case SPECTATOR -> 3;
};
}
public static org.bukkit.entity.Entity getEntity(int entityId) { public static org.bukkit.entity.Entity getEntity(int entityId) {
return NMSHandlers.getHandler().getUtilHandler().getEntity(entityId); return NMSHandlers.getHandler().getUtilHandler().getEntity(entityId);
} }

View File

@@ -1,5 +1,6 @@
package com.hibiscusmc.hmccosmetics.util; package com.hibiscusmc.hmccosmetics.util;
import me.lojosho.hibiscuscommons.util.StringUtils;
import me.lojosho.shaded.configurate.ConfigurationNode; import me.lojosho.shaded.configurate.ConfigurationNode;
import java.util.ArrayList; import java.util.ArrayList;
@@ -31,7 +32,7 @@ public class TranslationUtil {
public static String getTranslation(String key, String message) { public static String getTranslation(String key, String message) {
List<TranslationPair> pairs = keys.get(key); List<TranslationPair> pairs = keys.get(key);
for (TranslationPair pair : pairs) { for (TranslationPair pair : pairs) {
if (pair.key().equals(message)) return pair.value(); if (pair.key().equals(message)) return StringUtils.parseStringToString(pair.value());
} }
return message; return message;

View File

@@ -1,25 +1,27 @@
package com.hibiscusmc.hmccosmetics.util.packets; package com.hibiscusmc.hmccosmetics.util.packets;
import com.google.common.collect.Lists;
import com.hibiscusmc.hmccosmetics.config.Settings; import com.hibiscusmc.hmccosmetics.config.Settings;
import com.hibiscusmc.hmccosmetics.cosmetic.CosmeticSlot; import com.hibiscusmc.hmccosmetics.cosmetic.CosmeticSlot;
import com.hibiscusmc.hmccosmetics.user.CosmeticUser; import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
import com.hibiscusmc.hmccosmetics.user.CosmeticUsers; import com.hibiscusmc.hmccosmetics.user.CosmeticUsers;
import com.hibiscusmc.hmccosmetics.util.HMCCInventoryUtils; import com.hibiscusmc.hmccosmetics.util.HMCCInventoryUtils;
import me.lojosho.hibiscuscommons.nms.NMSHandlers; import me.lojosho.hibiscuscommons.nms.NMSHandlers;
import me.lojosho.hibiscuscommons.nms.NMSHandlers;
import me.lojosho.hibiscuscommons.util.packets.PacketManager; import me.lojosho.hibiscuscommons.util.packets.PacketManager;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.entity.Display; import org.bukkit.entity.*;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.ItemDisplay;
import org.bukkit.entity.Player;
import org.bukkit.inventory.EquipmentSlot; import org.bukkit.inventory.EquipmentSlot;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.joml.Quaternionf; import org.joml.Quaternionf;
import org.joml.Vector3f; import org.joml.Vector3f;
import java.util.*; import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
public class HMCCPacketManager extends PacketManager { public class HMCCPacketManager extends PacketManager {
@@ -83,26 +85,18 @@ public class HMCCPacketManager extends PacketManager {
equipmentSlotUpdate(entityId, HMCCInventoryUtils.getEquipmentSlot(cosmeticSlot), user.getUserCosmeticItem(cosmeticSlot), sendTo); equipmentSlotUpdate(entityId, HMCCInventoryUtils.getEquipmentSlot(cosmeticSlot), user.getUserCosmeticItem(cosmeticSlot), sendTo);
} }
public static void sendArmorstandMetadata( public static void sendArmorstandMetadata(int entityId, List<Player> sendTo) {
int entityId, // 0x21 = Invisible + Fire (Aka, burns to make it not take the light of the block its in, avoiding turning it black)
List<Player> sendTo
) {
byte mask = (byte) (Settings.isBackpackPreventDarkness() ? 0x21 : 0x20); byte mask = (byte) (Settings.isBackpackPreventDarkness() ? 0x21 : 0x20);
Map<Integer, Number> dataValues = Map.of(0, mask, 15, (byte) 0x10); Map<Integer, Number> dataValues = Map.of(0, mask, 15, (byte) 0x10);
NMSHandlers.getHandler().getPacketHandler().sendSharedEntityData(entityId, dataValues, sendTo); NMSHandlers.getHandler().getPacketHandler().sendSharedEntityData(entityId, dataValues, sendTo);
} }
public static void sendInvisibilityPacket( public static void sendInvisibilityPacket(int entityId, List<Player> sendTo) {
int entityId,
List<Player> sendTo
) {
NMSHandlers.getHandler().getPacketHandler().sendSharedEntityData(entityId, Map.of(0, (byte) 0x20), sendTo); NMSHandlers.getHandler().getPacketHandler().sendSharedEntityData(entityId, Map.of(0, (byte) 0x20), sendTo);
} }
public static void sendCloudEffect( public static void sendCloudEffect(int entityId, List<Player> sendTo) {
int entityId,
List<Player> sendTo
) {
Map<Integer, Number> dataValues = Map.of(0, (byte) 0x20, 8, 0f); Map<Integer, Number> dataValues = Map.of(0, (byte) 0x20, 8, 0f);
NMSHandlers.getHandler().getPacketHandler().sendSharedEntityData(entityId, dataValues, sendTo); NMSHandlers.getHandler().getPacketHandler().sendSharedEntityData(entityId, dataValues, sendTo);
} }
@@ -121,7 +115,11 @@ public class HMCCPacketManager extends PacketManager {
boolean onGround, boolean onGround,
@NotNull List<Player> sendTo @NotNull List<Player> sendTo
) { ) {
NMSHandlers.getHandler().getPacketHandler().sendRotationPacket(entityId, location.getYaw(), location.getPitch(), onGround, sendTo); float ROTATION_FACTOR = 256.0F / 360.0F;
byte yaw = (byte) (location.getYaw() * ROTATION_FACTOR);
byte pitch = (byte) (location.getPitch() * ROTATION_FACTOR);
NMSHandlers.getHandler().getPacketHandler().sendRotationPacket(entityId, yaw, pitch, onGround, sendTo);
} }
public static void sendRotationPacket( public static void sendRotationPacket(
@@ -130,9 +128,11 @@ public class HMCCPacketManager extends PacketManager {
boolean onGround, boolean onGround,
@NotNull List<Player> sendTo @NotNull List<Player> sendTo
) { ) {
NMSHandlers.getHandler().getPacketHandler().sendRotationPacket(entityId, yaw, 0, onGround, sendTo); float ROTATION_FACTOR = 256.0F / 360.0F;
NMSHandlers.getHandler().getPacketHandler().sendRotationPacket(entityId, yaw * ROTATION_FACTOR, 0, onGround, sendTo);
} }
/** /**
* Mostly to deal with backpacks, this deals with entities riding other entities. * Mostly to deal with backpacks, this deals with entities riding other entities.
* @param mountId The entity that is the "mount", ex. a player * @param mountId The entity that is the "mount", ex. a player
@@ -232,13 +232,11 @@ public class HMCCPacketManager extends PacketManager {
/** /**
* Removes a fake player from being seen by players. * Removes a fake player from being seen by players.
* @param player Which gameprofile to wrap for removing the player.
* @param uuid What is the fake player UUID * @param uuid What is the fake player UUID
* @param sendTo Whom to send the packet to * @param sendTo Whom to send the packet to
*/ */
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
public static void sendRemovePlayerPacket( public static void sendRemovePlayerPacket(
final Player player,
final UUID uuid, final UUID uuid,
final List<Player> sendTo final List<Player> sendTo
) { ) {
@@ -271,19 +269,7 @@ public class HMCCPacketManager extends PacketManager {
NMSHandlers.getHandler().getPacketHandler().sendMovePacket(entityId, from, to, onGround, sendTo); NMSHandlers.getHandler().getPacketHandler().sendMovePacket(entityId, from, to, onGround, sendTo);
} }
public static void sendEntityScalePacket( public static void sendDisplayEntityMetadataPacket(int entityid, ItemStack backpackItem, List<Player> sendTo) {
int entityId,
double scale,
List<Player> sendTo
) {
NMSHandlers.getHandler().getPacketHandler().sendEntityScalePacket(entityId, scale, sendTo);
}
// For future transition to display entities
public static void sendDisplayEntityMetadataPacket(
int entityid,
ItemStack backpackItem,
List<Player> sendTo) {
// TODO: Make the default values adjustable // TODO: Make the default values adjustable
Vector3f translation = new Vector3f(0, 3, 0); Vector3f translation = new Vector3f(0, 3, 0);
Vector3f scale = new Vector3f(1, 1, 1); Vector3f scale = new Vector3f(1, 1, 1);

View File

@@ -3,7 +3,7 @@
# #
config-version: 1 config-version: 1
default-menu: defaultmenu_hats default-menu: defaultmenu
debug-mode: false debug-mode: false
database-settings: database-settings:
type: sqlite # SQLite (Default), MYSQL, NONE type: sqlite # SQLite (Default), MYSQL, NONE
@@ -41,7 +41,7 @@ cosmetic-settings:
- "SPECTATOR" - "SPECTATOR"
# This make it so it always sends the riding packets for the backpack. This sends more packets but is more reliable for servers which modify player passengers. # This make it so it always sends the riding packets for the backpack. This sends more packets but is more reliable for servers which modify player passengers.
backpack-force-riding-packet: true backpack-force-riding-packet: false
# This prevents the backpack from being dark when the player is below a block at the expense of making the backpack bright # This prevents the backpack from being dark when the player is below a block at the expense of making the backpack bright
backpack-prevent-darkness: true backpack-prevent-darkness: true
# This helps reduce the amount of packets sent for packet entities, but reduces accuracy of the entity. This is in milliseconds. -1 to disable. # This helps reduce the amount of packets sent for packet entities, but reduces accuracy of the entity. This is in milliseconds. -1 to disable.
@@ -96,8 +96,8 @@ menu-settings:
# The shading is done through the title and by shifting textures around. This is done by offsets. # The shading is done through the title and by shifting textures around. This is done by offsets.
# Only Nexo is support by default. Vanilla can't properly handle it without a lot of unicodes and ItemsAdder adds weird offsets and decolors it. (This is why it is disabled by default) # Only Nexo is support by default. Vanilla can't properly handle it without a lot of unicodes and ItemsAdder adds weird offsets and decolors it. (This is why it is disabled by default)
enabled: false # Default of menus having shading. This can be toggled individually in menus with "shading: true/false" enabled: false # Default of menus having shading. This can be toggled individually in menus with "shading: true/false"
first-row-shift: "<shift:-153>" # Nexo: "<shift:-153>" first-row-shift: "<shift:-169>" # Nexo: "<shift:-169>"
sequent-row-shift: " <shift:-153>" # Nexo: " <shift:-153>" (Space is important here!) sequent-row-shift: " <shift:-169>" # Nexo: " <shift:-169>" (Space is important here!)
individual-column-shift: "<shift:-3>" # Nexo: "<shift:-3>" individual-column-shift: "<shift:-3>" # Nexo: "<shift:-3>"
background: "<glyph:shade_row_<row>:colorable> " # Nexo: "<glyph:shade_row_<row>:colorable> background: "<glyph:shade_row_<row>:colorable> " # Nexo: "<glyph:shade_row_<row>:colorable>
clear-background: "<glyph:clear_row_<row>:colorable> " # Nexo: "<glyph:clear_row_<row>:colorable> " clear-background: "<glyph:clear_row_<row>:colorable> " # Nexo: "<glyph:clear_row_<row>:colorable> "

View File

@@ -0,0 +1,180 @@
title: "<white>"
rows: 6
refresh-rate: 20 # Set to -1 or remove to disable auto-updating, leading to it only using event-based updates.
items:
beanie:
slots:
- 0
item:
material: hmccosmetics:beanie
lore:
- ""
- "<gray>Enabled: <#6D9DC5>%HMCCosmetics_equipped_beanie%"
- "<gray>Allowed: <#6D9DC5>%HMCCosmetics_unlocked_beanie%"
type: cosmetic
cosmetic: beanie
backpack:
slots:
- 1
item:
material: hmccosmetics:backpack
lore:
- ""
- "<gray>Enabled: <#6D9DC5>%HMCCosmetics_equipped_backpack%"
- "<gray>Allowed: <#6D9DC5>%HMCCosmetics_unlocked_backpack%"
type: cosmetic
cosmetic: backpack
future_wings:
slots:
- 2
item:
material: hmccosmetics:future_wings
lore:
- ""
- "<gray>Enabled: <#6D9DC5>%HMCCosmetics_equipped_future_wings%"
- "<gray>Allowed: <#6D9DC5>%HMCCosmetics_unlocked_future_wings%"
type: cosmetic
cosmetic: future_wings
lantern_cosmetic:
slots:
- 3
item:
material: hmccosmetics:lantern_cosmetic
lore:
- ""
- "<gray>Enabled: <#6D9DC5>%HMCCosmetics_equipped_lantern_cosmetic%"
- "<gray>Allowed: <#6D9DC5>%HMCCosmetics_unlocked_lantern_cosmetic%"
type: cosmetic
cosmetic: lantern_cosmetic
baseball_hat:
slots:
- 4
item:
material: hmccosmetics:baseball_hat
lore:
- ""
- "<gray>Enabled: <#6D9DC5>%HMCCosmetics_equipped_baseball_hat%"
- "<gray>Allowed: <#6D9DC5>%HMCCosmetics_unlocked_baseball_hat%"
type: cosmetic
cosmetic: baseball_hat
frog_hat:
slots:
- 5
item:
material: hmccosmetics:frog_hat
lore:
- ""
- "<gray>Enabled: <#6D9DC5>%HMCCosmetics_equipped_frog_hat%"
- "<gray>Allowed: <#6D9DC5>%HMCCosmetics_unlocked_frog_hat%"
type: cosmetic
cosmetic: frog_hat
jetpack:
slots:
- 6
item:
material: hmccosmetics:jetpack
lore:
- ""
- "<gray>Enabled: <#6D9DC5>%HMCCosmetics_equipped_jetpack%"
- "<gray>Allowed: <#6D9DC5>%HMCCosmetics_unlocked_jetpack%"
type: cosmetic
cosmetic: jetpack
hammer:
slots:
- 7
item:
material: hmccosmetics:hammer
lore:
- ""
- "<gray>Enabled: <#6D9DC5>%HMCCosmetics_equipped_hammer%"
- "<gray>Allowed: <#6D9DC5>%HMCCosmetics_unlocked_hammer%"
type: cosmetic
cosmetic: hammer
chestplate:
slots:
- 8
item:
material: hmccosmetics:chestplate
lore:
- ""
- "<gray>Enabled: <#6D9DC5>%HMCCosmetics_equipped_chestplate%"
- "<gray>Allowed: <#6D9DC5>%HMCCosmetics_unlocked_chestplate%"
type: cosmetic
cosmetic: chestplate
pants:
slots:
- 9
item:
material: hmccosmetics:pants
lore:
- ""
- "<gray>Enabled: <#6D9DC5>%HMCCosmetics_equipped_pants%"
- "<gray>Allowed: <#6D9DC5>%HMCCosmetics_unlocked_pants%"
type: cosmetic
cosmetic: pants
boots:
slots:
- 10
item:
material: hmccosmetics:boots
lore:
- ""
- "<gray>Enabled: <#6D9DC5>%HMCCosmetics_equipped_boots%"
- "<gray>Allowed: <#6D9DC5>%HMCCosmetics_unlocked_boots%"
type: cosmetic
cosmetic: boots
kite:
slots:
- 11
item:
material: hmccosmetics:kite
lore:
- ""
- "<gray>Enabled: <#6D9DC5>%HMCCosmetics_equipped_kite%"
- "<gray>Allowed: <#6D9DC5>%HMCCosmetics_unlocked_kite%"
type: cosmetic
cosmetic: kite
explorer_backpack:
slots:
- 12
item:
material: hmccosmetics:explorer_backpack
lore:
- ""
- "<gray>Enabled: <#6D9DC5>%HMCCosmetics_equipped_explorer_backpack%"
- "<gray>Allowed: <#6D9DC5>%HMCCosmetics_unlocked_explorer_backpack%"
type: cosmetic
cosmetic: explorer_backpack
garbage_truck_balloon:
slots:
- 13
item:
material: hmccosmetics:garbage_truck_balloon
lore:
- ""
- "<gray>Enabled: <#6D9DC5>%HMCCosmetics_equipped_garbage_truck_balloon%"
- "<gray>Allowed: <#6D9DC5>%HMCCosmetics_unlocked_garbage_truck_balloon%"
type: cosmetic
cosmetic: garbage_truck_balloon
earth_day_grabber:
slots:
- 14
item:
material: hmccosmetics:earth_day_grabber
lore:
- ""
- "<gray>Enabled: <#6D9DC5>%HMCCosmetics_equipped_earth_day_grabber%"
- "<gray>Allowed: <#6D9DC5>%HMCCosmetics_unlocked_earth_day_grabber%"
type: cosmetic
cosmetic: earth_day_grabber
hibiscus_flower:
slots:
- 15
item:
material: hmccosmetics:hibiscus_flower
lore:
- ""
- "<gray>Enabled: <#6D9DC5>%HMCCosmetics_equipped_hibiscus_flower%"
- "<gray>Allowed: <#6D9DC5>%HMCCosmetics_unlocked_hibiscus_flower%"
type: cosmetic
cosmetic: hibiscus_flower

View File

@@ -1,99 +0,0 @@
title: "<white>"
rows: 6
items:
backpack:
slots:
- 1
item:
material: hmccosmetics:backpack
lore:
- ""
- "<gray>Enabled: <#6D9DC5>%HMCCosmetics_equipped_backpack%"
- "<gray>Allowed: <#6D9DC5>%HMCCosmetics_unlocked_backpack%"
type: cosmetic
cosmetic: backpack
future_wings:
slots:
- 2
item:
material: hmccosmetics:future_wings
lore:
- ""
- "<gray>Enabled: <#6D9DC5>%HMCCosmetics_equipped_future_wings%"
- "<gray>Allowed: <#6D9DC5>%HMCCosmetics_unlocked_future_wings%"
type: cosmetic
cosmetic: future_wings
jetpack:
slots:
- 3
item:
material: hmccosmetics:jetpack
lore:
- ""
- "<gray>Enabled: <#6D9DC5>%HMCCosmetics_equipped_jetpack%"
- "<gray>Allowed: <#6D9DC5>%HMCCosmetics_unlocked_jetpack%"
type: cosmetic
cosmetic: jetpack
explorer_backpack:
slots:
- 4
item:
material: hmccosmetics:explorer_backpack
lore:
- ""
- "<gray>Enabled: <#6D9DC5>%HMCCosmetics_equipped_explorer_backpack%"
- "<gray>Allowed: <#6D9DC5>%HMCCosmetics_unlocked_explorer_backpack%"
type: cosmetic
cosmetic: explorer_backpack
button_backpacks_menu:
slots:
- 0
item:
material: PAPER
model-data: 18
name: "<blue>Backpack Cosmetics"
amount: 1
type: empty
actions:
any:
- "[MENU] defaultmenu_backpacks"
- "[SOUND] minecraft:ui.button.click 1 1"
button_hand_menu:
slots:
- 18
item:
material: PAPER
model-data: 19
name: "<blue>Hand Cosmetics"
amount: 1
type: empty
actions:
any:
- "[MENU] defaultmenu_hands"
- "[SOUND] minecraft:ui.button.click 1 1"
button_balloon_menu:
slots:
- 27
item:
material: PAPER
model-data: 20
name: "<blue>Balloon Cosmetics"
amount: 1
type: empty
actions:
any:
- "[MENU] defaultmenu_balloons"
- "[SOUND] minecraft:ui.button.click 1 1"
button_hats_menu:
slots:
- 36
item:
material: PAPER
model-data: 17
name: "<blue>Hat Cosmetics"
amount: 1
type: empty
actions:
any:
- "[MENU] defaultmenu_hats"
- "[SOUND] minecraft:ui.button.click 1 1"

View File

@@ -1,77 +0,0 @@
title: "<white>"
rows: 6
items:
garbage_truck_balloon:
slots:
- 1
item:
material: hmccosmetics:garbage_truck_balloon
lore:
- ""
- "<gray>Enabled: <#6D9DC5>%HMCCosmetics_equipped_garbage_truck_balloon%"
- "<gray>Allowed: <#6D9DC5>%HMCCosmetics_unlocked_garbage_truck_balloon%"
type: cosmetic
cosmetic: garbage_truck_balloon
kite:
slots:
- 2
item:
material: hmccosmetics:kite
lore:
- ""
- "<gray>Enabled: <#6D9DC5>%HMCCosmetics_equipped_kite%"
- "<gray>Allowed: <#6D9DC5>%HMCCosmetics_unlocked_kite%"
type: cosmetic
cosmetic: kite
button_backpacks_menu:
slots:
- 27
item:
material: PAPER
model-data: 18
name: "<blue>Backpack Cosmetics"
amount: 1
type: empty
actions:
any:
- "[MENU] defaultmenu_backpacks"
- "[SOUND] minecraft:ui.button.click 1 1"
button_hand_menu:
slots:
- 36
item:
material: PAPER
model-data: 19
name: "<blue>Hand Cosmetics"
amount: 1
type: empty
actions:
any:
- "[MENU] defaultmenu_hands"
- "[SOUND] minecraft:ui.button.click 1 1"
button_balloon_menu:
slots:
- 0
item:
material: PAPER
model-data: 20
name: "<blue>Balloon Cosmetics"
amount: 1
type: empty
actions:
any:
- "[MENU] defaultmenu_balloons"
- "[SOUND] minecraft:ui.button.click 1 1"
button_hats_menu:
slots:
- 18
item:
material: PAPER
model-data: 17
name: "<blue>Hat Cosmetics"
amount: 1
type: empty
actions:
any:
- "[MENU] defaultmenu_hats"
- "[SOUND] minecraft:ui.button.click 1 1"

View File

@@ -1,99 +0,0 @@
title: "<white>"
rows: 6
items:
lantern_cosmetic:
slots:
- 1
item:
material: hmccosmetics:lantern_cosmetic
lore:
- ""
- "<gray>Enabled: <#6D9DC5>%HMCCosmetics_equipped_lantern_cosmetic%"
- "<gray>Allowed: <#6D9DC5>%HMCCosmetics_unlocked_lantern_cosmetic%"
type: cosmetic
cosmetic: lantern_cosmetic
hammer:
slots:
- 2
item:
material: hmccosmetics:hammer
lore:
- ""
- "<gray>Enabled: <#6D9DC5>%HMCCosmetics_equipped_hammer%"
- "<gray>Allowed: <#6D9DC5>%HMCCosmetics_unlocked_hammer%"
type: cosmetic
cosmetic: hammer
earth_day_grabber:
slots:
- 3
item:
material: hmccosmetics:earth_day_grabber
lore:
- ""
- "<gray>Enabled: <#6D9DC5>%HMCCosmetics_equipped_earth_day_grabber%"
- "<gray>Allowed: <#6D9DC5>%HMCCosmetics_unlocked_earth_day_grabber%"
type: cosmetic
cosmetic: earth_day_grabber
hibiscus_flower:
slots:
- 4
item:
material: hmccosmetics:hibiscus_flower
lore:
- ""
- "<gray>Enabled: <#6D9DC5>%HMCCosmetics_equipped_hibiscus_flower%"
- "<gray>Allowed: <#6D9DC5>%HMCCosmetics_unlocked_hibiscus_flower%"
type: cosmetic
cosmetic: hibiscus_flower
button_backpacks_menu:
slots:
- 36
item:
material: PAPER
model-data: 18
name: "<blue>Backpack Cosmetics"
amount: 1
type: empty
actions:
any:
- "[MENU] defaultmenu_backpacks"
- "[SOUND] minecraft:ui.button.click 1 1"
button_hand_menu:
slots:
- 0
item:
material: PAPER
model-data: 19
name: "<blue>Hand Cosmetics"
amount: 1
type: empty
actions:
any:
- "[MENU] defaultmenu_hands"
- "[SOUND] minecraft:ui.button.click 1 1"
button_balloon_menu:
slots:
- 18
item:
material: PAPER
model-data: 20
name: "<blue>Balloon Cosmetics"
amount: 1
type: empty
actions:
any:
- "[MENU] defaultmenu_balloons"
- "[SOUND] minecraft:ui.button.click 1 1"
button_hats_menu:
slots:
- 27
item:
material: PAPER
model-data: 17
name: "<blue>Hat Cosmetics"
amount: 1
type: empty
actions:
any:
- "[MENU] defaultmenu_hats"
- "[SOUND] minecraft:ui.button.click 1 1"

View File

@@ -1,88 +0,0 @@
title: "<white>"
rows: 6
items:
beanie:
slots:
- 1
item:
material: hmccosmetics:beanie
lore:
- ""
- "<gray>Enabled: <#6D9DC5>%HMCCosmetics_equipped_beanie%"
- "<gray>Allowed: <#6D9DC5>%HMCCosmetics_unlocked_beanie%"
type: cosmetic
cosmetic: beanie
baseball_hat:
slots:
- 2
item:
material: hmccosmetics:baseball_hat
lore:
- ""
- "<gray>Enabled: <#6D9DC5>%HMCCosmetics_equipped_baseball_hat%"
- "<gray>Allowed: <#6D9DC5>%HMCCosmetics_unlocked_baseball_hat%"
type: cosmetic
cosmetic: baseball_hat
frog_hat:
slots:
- 3
item:
material: hmccosmetics:frog_hat
lore:
- ""
- "<gray>Enabled: <#6D9DC5>%HMCCosmetics_equipped_frog_hat%"
- "<gray>Allowed: <#6D9DC5>%HMCCosmetics_unlocked_frog_hat%"
type: cosmetic
cosmetic: frog_hat
button_hats_menu:
slots:
- 0
item:
material: PAPER
model-data: 17
name: "<blue>Hat Cosmetics"
amount: 1
type: empty
actions:
any:
- "[MENU] defaultmenu_hats"
- "[SOUND] minecraft:ui.button.click 1 1"
button_backpacks_menu:
slots:
- 18
item:
material: PAPER
model-data: 18
name: "<blue>Backpack Cosmetics"
amount: 1
type: empty
actions:
any:
- "[MENU] defaultmenu_backpacks"
- "[SOUND] minecraft:ui.button.click 1 1"
button_hand_menu:
slots:
- 27
item:
material: PAPER
model-data: 19
name: "<blue>Hand Cosmetics"
amount: 1
type: empty
actions:
any:
- "[MENU] defaultmenu_hands"
- "[SOUND] minecraft:ui.button.click 1 1"
button_balloon_menu:
slots:
- 36
item:
material: PAPER
model-data: 20
name: "<blue>Balloon Cosmetics"
amount: 1
type: empty
actions:
any:
- "[MENU] defaultmenu_balloons"
- "[SOUND] minecraft:ui.button.click 1 1"

View File

@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.12-bin.zip distributionUrl=https\://services.gradle.org/distributions/gradle-8.14-bin.zip
networkTimeout=10000 networkTimeout=10000
validateDistributionUrl=true validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME