mirror of
https://github.com/HibiscusMC/HMCCosmetics.git
synced 2025-12-29 20:09:13 +00:00
Compare commits
28 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1ef7f4759f | ||
|
|
937f66e8c5 | ||
|
|
158f3afdec | ||
|
|
38bdc01e9f | ||
|
|
797992362a | ||
|
|
9716a079be | ||
|
|
dfe51ba5b8 | ||
|
|
f5e81446a6 | ||
|
|
c99a57a6bf | ||
|
|
79630263f2 | ||
|
|
478c4280c1 | ||
|
|
4fd439acc4 | ||
|
|
58c955a00f | ||
|
|
2f9325b2fb | ||
|
|
823270648b | ||
|
|
d5e988261b | ||
|
|
13303096ec | ||
|
|
3ee79e8443 | ||
|
|
7785556967 | ||
|
|
1296ca6e92 | ||
|
|
f56d5c9093 | ||
|
|
bae04fba3f | ||
|
|
cbe5404399 | ||
|
|
dc4098782a | ||
|
|
2eb0b26fb3 | ||
|
|
22159fa9f4 | ||
|
|
539c09801c | ||
|
|
bed5cd7bbb |
@@ -8,7 +8,7 @@ plugins {
|
|||||||
}
|
}
|
||||||
|
|
||||||
group = "com.hibiscusmc"
|
group = "com.hibiscusmc"
|
||||||
version = "2.8.0${getGitCommitHash()}"
|
version = "2.8.1${getGitCommitHash()}"
|
||||||
|
|
||||||
allprojects {
|
allprojects {
|
||||||
apply(plugin = "java")
|
apply(plugin = "java")
|
||||||
@@ -85,18 +85,19 @@ 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.0-d301221e")
|
compileOnly("me.lojosho:HibiscusCommons:0.7.1-6c4e262c")
|
||||||
|
|
||||||
// Handled by Spigot Library Loader
|
// Handled by Spigot Library Loader
|
||||||
compileOnly("net.kyori:adventure-api:4.23.0")
|
compileOnly("net.kyori:adventure-api:4.24.0")
|
||||||
compileOnly("net.kyori:adventure-text-minimessage:4.23.0")
|
compileOnly("net.kyori:adventure-text-minimessage:4.24.0")
|
||||||
compileOnly("net.kyori:adventure-platform-bukkit:4.4.0")
|
compileOnly("net.kyori:adventure-platform-bukkit:4.4.1")
|
||||||
|
|
||||||
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")
|
||||||
@@ -106,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.7")
|
implementation("com.ticxo.playeranimator:PlayerAnimator:R1.2.8")
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks {
|
tasks {
|
||||||
@@ -139,11 +140,12 @@ tasks {
|
|||||||
}
|
}
|
||||||
|
|
||||||
runServer {
|
runServer {
|
||||||
minecraftVersion("1.21.6")
|
minecraftVersion("1.21.8")
|
||||||
|
|
||||||
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://download.luckperms.net/1593/bukkit/loader/LuckPerms-Bukkit-5.5.8.jar")
|
||||||
|
github("Test-Account666", "PlugManX", "2.4.1", "PlugManX-2.4.1.jar")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -302,4 +304,4 @@ fun getGitCommitHash(): String {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,6 +11,8 @@ 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;
|
||||||
@@ -29,6 +31,7 @@ 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;
|
||||||
@@ -64,7 +67,12 @@ 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()) saveResource("menus/defaultmenu.yml", false);
|
if (!Path.of(getDataFolder().getPath() + "/menus/").toFile().exists()) {
|
||||||
|
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();
|
||||||
@@ -105,6 +113,11 @@ 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
|
||||||
|
|||||||
@@ -12,7 +12,6 @@ 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;
|
||||||
@@ -21,7 +20,6 @@ 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.
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
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;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ 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;
|
||||||
@@ -329,7 +330,7 @@ public class CosmeticCommand implements CommandExecutor {
|
|||||||
}
|
}
|
||||||
user.addCosmetic(cosmetic, color); // #FFFFFF
|
user.addCosmetic(cosmetic, color); // #FFFFFF
|
||||||
} else {
|
} else {
|
||||||
DyeMenu.openMenu(user, cosmetic);
|
DyeMenuProvider.openMenu(player, user, cosmetic);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case ("setwardrobesetting") -> {
|
case ("setwardrobesetting") -> {
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import org.bukkit.ChatColor;
|
|||||||
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.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;
|
||||||
|
|
||||||
@@ -56,8 +57,12 @@ 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();
|
||||||
@@ -135,4 +140,14 @@ 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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,12 +2,10 @@ 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;
|
||||||
@@ -24,8 +22,6 @@ 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)
|
||||||
|
|||||||
@@ -48,9 +48,11 @@ public class CosmeticArmorType extends Cosmetic {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public ItemStack getItem(@NotNull CosmeticUser user, ItemStack cosmeticItem) {
|
public ItemStack getItem(@NotNull CosmeticUser user, ItemStack cosmeticItem) {
|
||||||
if (!(user.getEntity() instanceof HumanEntity humanEntity)) return null;
|
Player player = user.getPlayer();
|
||||||
|
if (player == null) return null;
|
||||||
|
|
||||||
if (Settings.getSlotOption(equipSlot).isAddEnchantments()) {
|
if (Settings.getSlotOption(equipSlot).isAddEnchantments()) {
|
||||||
ItemStack equippedItem = humanEntity.getInventory().getItem(equipSlot);
|
ItemStack equippedItem = player.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
|
||||||
|
|||||||
@@ -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,7 +22,6 @@ 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 {
|
||||||
|
|
||||||
@@ -65,6 +64,14 @@ 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());
|
||||||
|
|||||||
@@ -1,23 +0,0 @@
|
|||||||
package com.hibiscusmc.hmccosmetics.cosmetic.types;
|
|
||||||
|
|
||||||
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
|
|
||||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
|
||||||
import com.hibiscusmc.hmccosmetics.util.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()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,6 +1,5 @@
|
|||||||
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;
|
||||||
@@ -9,7 +8,6 @@ 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;
|
||||||
@@ -87,7 +85,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 -> {
|
case EMOTE, NONE, GAMEMODE, WORLD, DISABLED, POTION -> {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
default -> {
|
default -> {
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ 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;
|
||||||
|
|||||||
@@ -14,21 +14,18 @@ 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;
|
||||||
@@ -185,18 +182,25 @@ 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.getPluginManager().callEvent(event));
|
Bukkit.getScheduler().runTask(HMCCosmeticsPlugin.getInstance(), () -> {
|
||||||
if (event.isCancelled()) return;
|
Bukkit.getPluginManager().callEvent(event);
|
||||||
|
if (!event.isCancelled()) {
|
||||||
|
openGuiTask.run();
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
// Internal
|
// Internal
|
||||||
|
else {
|
||||||
Bukkit.getScheduler().runTask(HMCCosmeticsPlugin.getInstance(), () -> {
|
Bukkit.getScheduler().runTask(HMCCosmeticsPlugin.getInstance(), 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
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateMenu(Player viewer, CosmeticHolder cosmeticHolder, Gui gui) {
|
private void updateMenu(Player viewer, CosmeticHolder cosmeticHolder, Gui gui) {
|
||||||
|
|||||||
@@ -3,8 +3,6 @@ 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;
|
||||||
|
|||||||
@@ -1,67 +1,20 @@
|
|||||||
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 class DyeMenu {
|
public interface 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);
|
/**
|
||||||
gui.updateTitle(AdventureUtils.MINI_MESSAGE.deserialize(Hooks.processPlaceholders(viewer, Settings.getDyeMenuName())));
|
* Overrideable method that is called when a player wishing to dye a menu.
|
||||||
gui.setItem(Settings.getDyeMenuInputSlot(), new GuiItem(originalItem));
|
* After the method is called, the menu plugin itself is supposed to handle everything else, including adding the cosmetic to the CosmeticHolder
|
||||||
gui.setDefaultTopClickAction(event -> {
|
*
|
||||||
if (event.getSlot() == Settings.getDyeMenuOutputSlot()) {
|
* @param viewer The player that is viewing the menu
|
||||||
ItemStack item = event.getInventory().getItem(Settings.getDyeMenuOutputSlot());
|
* @param cosmeticHolder The CosmeticHolder that is being dyed (Can be different from the viewer)
|
||||||
if (item == null) return;
|
* @param cosmetic (The cosmetic that is wished to be dyed)
|
||||||
|
*/
|
||||||
|
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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,42 @@
|
|||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,58 @@
|
|||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -8,6 +8,7 @@ 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;
|
||||||
@@ -102,9 +103,11 @@ 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 && Hooks.isActiveHook("HMCColor")) {
|
if (cosmetic.isDyeable() && isDyeClick && DyeMenuProvider.hasMenuProvider()) {
|
||||||
DyeMenu.openMenu(viewer, cosmeticHolder, cosmetic);
|
DyeMenuProvider.openMenu(viewer, cosmeticHolder, cosmetic);
|
||||||
} else if (isRequiredClick) {
|
} else if (isRequiredClick) {
|
||||||
cosmeticHolder.addCosmetic(cosmetic);
|
cosmeticHolder.addCosmetic(cosmetic);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ 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;
|
||||||
|
|||||||
@@ -20,7 +20,6 @@ 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;
|
||||||
|
|
||||||
|
|||||||
@@ -8,9 +8,11 @@ import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticArmorType;
|
|||||||
import com.hibiscusmc.hmccosmetics.gui.Menu;
|
import com.hibiscusmc.hmccosmetics.gui.Menu;
|
||||||
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.user.manager.UserBackpackManager;
|
||||||
import com.hibiscusmc.hmccosmetics.user.manager.UserWardrobeManager;
|
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 me.lojosho.hibiscuscommons.packets.PacketAction;
|
import me.lojosho.hibiscuscommons.packets.PacketAction;
|
||||||
import me.lojosho.hibiscuscommons.packets.PacketInterface;
|
import me.lojosho.hibiscuscommons.packets.PacketInterface;
|
||||||
import me.lojosho.hibiscuscommons.packets.wrapper.*;
|
import me.lojosho.hibiscuscommons.packets.wrapper.*;
|
||||||
@@ -25,29 +27,34 @@ import java.util.*;
|
|||||||
public class CosmeticPacketInterface implements PacketInterface {
|
public class CosmeticPacketInterface implements PacketInterface {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PacketAction writeContainerContent(@NotNull Player player, @NotNull ContainerContentWrapper wrapper) {
|
public @NotNull PacketAction writeContainerContent(@NotNull Player player, @NotNull ContainerContentWrapper wrapper) {
|
||||||
int windowId = wrapper.getWindowId();
|
int windowId = wrapper.getWindowId();
|
||||||
|
MessagesUtil.sendDebugMessages("writeContainerContent (windowid: " + windowId + " )");
|
||||||
if (windowId != 0) return PacketAction.NOTHING;
|
if (windowId != 0) return PacketAction.NOTHING;
|
||||||
List<ItemStack> slotData = wrapper.getSlotData();
|
List<ItemStack> slotData = wrapper.getSlotData();
|
||||||
|
|
||||||
CosmeticUser user = CosmeticUsers.getUser(player);
|
CosmeticUser user = CosmeticUsers.getUser(player);
|
||||||
if (user == null) return PacketAction.NOTHING;
|
if (user == null) return PacketAction.NOTHING;
|
||||||
|
|
||||||
HashMap<Integer, ItemStack> items = new HashMap<>();
|
HashMap<Integer, ItemStack> cosmeticItems = new HashMap<>();
|
||||||
|
|
||||||
if (!user.isInWardrobe()) for (Cosmetic cosmetic : user.getCosmetics()) if (cosmetic instanceof CosmeticArmorType armorType) {
|
if (!user.isInWardrobe()) {
|
||||||
boolean requireEmpty = Settings.getSlotOption(armorType.getEquipSlot()).isRequireEmpty();
|
for (Cosmetic cosmetic : user.getCosmetics()) {
|
||||||
boolean isAir = user.getPlayer().getInventory().getItem(armorType.getEquipSlot()).getType().isAir();
|
if (cosmetic instanceof CosmeticArmorType armorType) {
|
||||||
MessagesUtil.sendDebugMessages("Menu Fired (Checks) - " + armorType.getId() + " - " + requireEmpty + " - " + isAir);
|
boolean requireEmpty = Settings.getSlotOption(armorType.getEquipSlot()).isRequireEmpty();
|
||||||
if (requireEmpty && !isAir) continue;
|
boolean isAir = user.getPlayer().getInventory().getItem(armorType.getEquipSlot()).getType().isAir();
|
||||||
items.put(HMCCInventoryUtils.getPacketArmorSlot(armorType.getEquipSlot()), user.getUserCosmeticItem(armorType));
|
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++) {
|
for (int slot = 0; slot < 46; slot++) {
|
||||||
if ((slot >= 5 && slot <= 8) || slot == 45) {
|
if ((slot >= 5 && slot <= 8) || slot == 45) {
|
||||||
if (!items.containsKey(slot)) continue;
|
if (!cosmeticItems.containsKey(slot)) continue;
|
||||||
slotData.set(slot, items.get(slot));
|
slotData.set(slot, cosmeticItems.get(slot));
|
||||||
if (Settings.isDebugMode()) MessagesUtil.sendDebugMessages("Set " + slot + " as " + items.get(slot));
|
if (Settings.isDebugMode()) MessagesUtil.sendDebugMessages("Set " + slot + " as " + cosmeticItems.get(slot));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -57,7 +64,7 @@ public class CosmeticPacketInterface implements PacketInterface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PacketAction writeSlotContent(@NotNull Player player, @NotNull SlotContentWrapper wrapper) {
|
public @NotNull PacketAction writeSlotContent(@NotNull Player player, @NotNull SlotContentWrapper wrapper) {
|
||||||
int windowId = wrapper.getWindowId();
|
int windowId = wrapper.getWindowId();
|
||||||
int slot = wrapper.getSlot();
|
int slot = wrapper.getSlot();
|
||||||
ItemStack itemStack = wrapper.getItemStack();
|
ItemStack itemStack = wrapper.getItemStack();
|
||||||
@@ -81,7 +88,7 @@ public class CosmeticPacketInterface implements PacketInterface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PacketAction writeEquipmentContent(@NotNull Player player, @NotNull EntityEquipmentWrapper wrapper) {
|
public @NotNull PacketAction writeEquipmentContent(@NotNull Player player, @NotNull EntityEquipmentWrapper wrapper) {
|
||||||
if (player.getEntityId() != wrapper.getEntityId()) return PacketAction.NOTHING;
|
if (player.getEntityId() != wrapper.getEntityId()) return PacketAction.NOTHING;
|
||||||
CosmeticUser user = CosmeticUsers.getUser(player);
|
CosmeticUser user = CosmeticUsers.getUser(player);
|
||||||
if (user == null || user.isInWardrobe()) return PacketAction.NOTHING;
|
if (user == null || user.isInWardrobe()) return PacketAction.NOTHING;
|
||||||
@@ -116,35 +123,58 @@ public class CosmeticPacketInterface implements PacketInterface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PacketAction writePassengerContent(@NotNull Player player, @NotNull PassengerWrapper wrapper) {
|
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);
|
CosmeticUser viewerUser = CosmeticUsers.getUser(player);
|
||||||
if (viewerUser == null || viewerUser.isInWardrobe()) return PacketAction.NOTHING;
|
if (viewerUser == null || viewerUser.isInWardrobe()) return PacketAction.NOTHING;
|
||||||
|
|
||||||
int ownerId = wrapper.getOwner();
|
int ownerId = wrapper.getOwner();
|
||||||
List<Integer> originalPassengers = wrapper.getPassengers();
|
List<Integer> originalPassengers = wrapper.getPassengers();
|
||||||
|
|
||||||
MessagesUtil.sendDebugMessages("Mount Packet Sent - Read - EntityID: " + ownerId);
|
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();
|
Optional<CosmeticUser> optionalCosmeticUser = CosmeticUsers.values().stream().filter(user -> user.getPlayer() != null).filter(user -> ownerId == user.getPlayer().getEntityId()).findFirst();
|
||||||
if (optionalCosmeticUser.isEmpty()) return PacketAction.NOTHING;
|
if (optionalCosmeticUser.isEmpty()) return PacketAction.NOTHING;
|
||||||
Player entity = optionalCosmeticUser.get().getPlayer();
|
CosmeticUser user = optionalCosmeticUser.get();
|
||||||
|
|
||||||
CosmeticUser user = CosmeticUsers.getUser(entity.getUniqueId());
|
|
||||||
if (user == null) return PacketAction.NOTHING;
|
|
||||||
MessagesUtil.sendDebugMessages("Mount Packet Sent - " + user.getUniqueId());
|
MessagesUtil.sendDebugMessages("Mount Packet Sent - " + user.getUniqueId());
|
||||||
|
|
||||||
if (!user.hasCosmeticInSlot(CosmeticSlot.BACKPACK)) return PacketAction.NOTHING;
|
if (!user.hasCosmeticInSlot(CosmeticSlot.BACKPACK)) return PacketAction.NOTHING;
|
||||||
if (user.getUserBackpackManager() == null) return PacketAction.NOTHING;
|
if (user.getUserBackpackManager() == null) return PacketAction.NOTHING;
|
||||||
|
|
||||||
List<Integer> passengers = new ArrayList<>(user.getUserBackpackManager().getEntityManager().getIds());
|
List<Integer> passengers = new ArrayList<>(user.getUserBackpackManager().getEntityManager().getIds());
|
||||||
for (int passenger : originalPassengers) passengers.add(passenger);
|
passengers.addAll(originalPassengers);
|
||||||
|
|
||||||
wrapper.setPassengers(passengers);
|
wrapper.setPassengers(passengers);
|
||||||
return PacketAction.CHANGED;
|
return PacketAction.CHANGED;
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PacketAction readInventoryClick(@NotNull Player player, @NotNull InventoryClickWrapper wrapper) {
|
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 clickType = wrapper.getClickType();
|
||||||
int slotNumber = wrapper.getSlotNumber();
|
int slotNumber = wrapper.getSlotNumber();
|
||||||
if (clickType != 0 || slotNumber == -999) return PacketAction.NOTHING;
|
if (clickType != 0 || slotNumber == -999) return PacketAction.NOTHING;
|
||||||
@@ -160,7 +190,7 @@ public class CosmeticPacketInterface implements PacketInterface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PacketAction readPlayerAction(@NotNull Player player, @NotNull PlayerActionWrapper wrapper) {
|
public @NotNull PacketAction readPlayerAction(@NotNull Player player, @NotNull PlayerActionWrapper wrapper) {
|
||||||
String actionType = wrapper.getActionType();
|
String actionType = wrapper.getActionType();
|
||||||
MessagesUtil.sendDebugMessages("EntityStatus Initial " + player.getEntityId() + " - " + actionType);
|
MessagesUtil.sendDebugMessages("EntityStatus Initial " + player.getEntityId() + " - " + actionType);
|
||||||
// If it's not SWAP_ITEM_WITH_OFFHAND, ignore
|
// If it's not SWAP_ITEM_WITH_OFFHAND, ignore
|
||||||
@@ -176,7 +206,7 @@ public class CosmeticPacketInterface implements PacketInterface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PacketAction readPlayerArm(@NotNull Player player) {
|
public @NotNull PacketAction readPlayerArm(@NotNull Player player, @NotNull PlayerSwingWrapper wrapper) {
|
||||||
CosmeticUser user = CosmeticUsers.getUser(player);
|
CosmeticUser user = CosmeticUsers.getUser(player);
|
||||||
if (user == null || !user.isInWardrobe() || !user.getWardrobeManager().getWardrobeStatus().equals(UserWardrobeManager.WardrobeStatus.RUNNING)) return PacketAction.NOTHING;
|
if (user == null || !user.isInWardrobe() || !user.getWardrobeManager().getWardrobeStatus().equals(UserWardrobeManager.WardrobeStatus.RUNNING)) return PacketAction.NOTHING;
|
||||||
|
|
||||||
@@ -187,7 +217,7 @@ public class CosmeticPacketInterface implements PacketInterface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PacketAction readEntityHandle(@NotNull Player player) {
|
public @NotNull PacketAction readEntityHandle(@NotNull Player player, @NotNull PlayerInteractWrapper wrapper) {
|
||||||
CosmeticUser user = CosmeticUsers.getUser(player);
|
CosmeticUser user = CosmeticUsers.getUser(player);
|
||||||
if (user == null || !user.isInWardrobe()) return PacketAction.NOTHING;
|
if (user == null || !user.isInWardrobe()) return PacketAction.NOTHING;
|
||||||
else return PacketAction.CANCELLED;
|
else return PacketAction.CANCELLED;
|
||||||
|
|||||||
@@ -13,7 +13,6 @@ 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;
|
||||||
@@ -22,7 +21,6 @@ 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;
|
||||||
@@ -30,7 +28,6 @@ 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;
|
||||||
@@ -39,6 +36,7 @@ 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;
|
||||||
@@ -151,6 +149,11 @@ public class CosmeticUser implements CosmeticHolder {
|
|||||||
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);
|
||||||
}
|
}
|
||||||
@@ -345,7 +348,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 || cosmetic instanceof CosmeticMainhandType) {
|
if (cosmetic instanceof CosmeticBackpackType) {
|
||||||
item = cosmetic.getItem();
|
item = cosmetic.getItem();
|
||||||
}
|
}
|
||||||
if (cosmetic instanceof CosmeticBalloonType) {
|
if (cosmetic instanceof CosmeticBalloonType) {
|
||||||
|
|||||||
@@ -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,7 +20,6 @@ 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 {
|
||||||
|
|
||||||
@@ -59,6 +58,13 @@ 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];
|
||||||
|
|||||||
@@ -99,7 +99,12 @@ public class UserBalloonManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void remove() {
|
public void remove() {
|
||||||
pufferfish.destroyPufferfish();
|
// This code is like a brick road, always bumpy.
|
||||||
|
// 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) {
|
||||||
|
|||||||
@@ -1,17 +1,12 @@
|
|||||||
package com.hibiscusmc.hmccosmetics.user.manager;
|
package com.hibiscusmc.hmccosmetics.user.manager;
|
||||||
|
|
||||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
|
||||||
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;
|
||||||
|
|
||||||
@@ -45,6 +40,12 @@ 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
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ package com.hibiscusmc.hmccosmetics.user.manager;
|
|||||||
import com.hibiscusmc.hmccosmetics.config.Settings;
|
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;
|
||||||
@@ -80,7 +79,7 @@ public class UserEntity {
|
|||||||
if (this.getLocation() != null && this.getLocation().getWorld() == location.getWorld()) {
|
if (this.getLocation() != null && this.getLocation().getWorld() == location.getWorld()) {
|
||||||
// Was thinking about using schedulers to just send the packet later... but that would be a lot of tasks and
|
// Was thinking about using schedulers to just send the packet later... but that would be a lot of tasks and
|
||||||
// would probably cause more lag. Furthermore, the server "ticks" the cosmetics every second by defualt. So it's fine like this.
|
// would probably cause more lag. Furthermore, the server "ticks" the cosmetics every second by defualt. So it's fine like this.
|
||||||
if (System.currentTimeMillis() - getLastPositionUpdate() <= Settings.getPacketEntityTeleportCooldown()) return;
|
//if (System.currentTimeMillis() - getLastPositionUpdate() <= Settings.getPacketEntityTeleportCooldown()) return;
|
||||||
}
|
}
|
||||||
this.location = location;
|
this.location = location;
|
||||||
for (Integer entity : ids) {
|
for (Integer entity : ids) {
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
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;
|
||||||
|
|||||||
@@ -121,11 +121,7 @@ public class HMCCPacketManager extends PacketManager {
|
|||||||
boolean onGround,
|
boolean onGround,
|
||||||
@NotNull List<Player> sendTo
|
@NotNull List<Player> sendTo
|
||||||
) {
|
) {
|
||||||
float ROTATION_FACTOR = 256.0F / 360.0F;
|
NMSHandlers.getHandler().getPacketHandler().sendRotationPacket(entityId, location.getYaw(), location.getPitch(), onGround, sendTo);
|
||||||
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(
|
||||||
@@ -134,8 +130,7 @@ public class HMCCPacketManager extends PacketManager {
|
|||||||
boolean onGround,
|
boolean onGround,
|
||||||
@NotNull List<Player> sendTo
|
@NotNull List<Player> sendTo
|
||||||
) {
|
) {
|
||||||
float ROTATION_FACTOR = 256.0F / 360.0F;
|
NMSHandlers.getHandler().getPacketHandler().sendRotationPacket(entityId, yaw, 0, onGround, sendTo);
|
||||||
NMSHandlers.getHandler().getPacketHandler().sendRotationPacket(entityId, yaw * ROTATION_FACTOR, 0, onGround, sendTo);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -276,6 +271,14 @@ 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(
|
||||||
|
int entityId,
|
||||||
|
double scale,
|
||||||
|
List<Player> sendTo
|
||||||
|
) {
|
||||||
|
NMSHandlers.getHandler().getPacketHandler().sendEntityScalePacket(entityId, scale, sendTo);
|
||||||
|
}
|
||||||
|
|
||||||
// For future transition to display entities
|
// For future transition to display entities
|
||||||
public static void sendDisplayEntityMetadataPacket(
|
public static void sendDisplayEntityMetadataPacket(
|
||||||
int entityid,
|
int entityid,
|
||||||
|
|||||||
@@ -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: false
|
backpack-force-riding-packet: true
|
||||||
# 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.
|
||||||
@@ -95,7 +95,7 @@ menu-settings:
|
|||||||
# Below is the shading mechanism behind cosmetic items. This is a bit complicated, but it allows for a lot of customization.
|
# Below is the shading mechanism behind cosmetic items. This is a bit complicated, but it allows for a lot of customization.
|
||||||
# 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: true # 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:-153>" # Nexo: "<shift:-153>"
|
||||||
sequent-row-shift: " <shift:-153>" # Nexo: " <shift:-153>" (Space is important here!)
|
sequent-row-shift: " <shift:-153>" # Nexo: " <shift:-153>" (Space is important here!)
|
||||||
individual-column-shift: "<shift:-3>" # Nexo: "<shift:-3>"
|
individual-column-shift: "<shift:-3>" # Nexo: "<shift:-3>"
|
||||||
|
|||||||
Reference in New Issue
Block a user