9
0
mirror of https://github.com/HibiscusMC/HMCCosmetics.git synced 2025-12-29 03:49:19 +00:00

Compare commits

...

28 Commits

Author SHA1 Message Date
Logan
1ef7f4759f fix: balloon lead not properly disappearing when you unapply a balloon cosmetic 2025-08-17 16:22:32 -05:00
Logan
937f66e8c5 version bump (2.8.1) 2025-08-17 14:43:59 -05:00
Logan
158f3afdec chore: update test server 2025-08-17 14:43:44 -05:00
Logan
38bdc01e9f Merge remote-tracking branch 'origin/remapped' into remapped 2025-08-16 13:30:16 -05:00
Logan
797992362a feat: allow custom dye menu implementations 2025-08-16 13:30:10 -05:00
Logan
9716a079be Merge pull request #189 from Catnies/dev
fix PlayerMenuOpenEvent can't cancel
2025-08-06 16:30:24 -05:00
LoJoSho
dfe51ba5b8 fix: user initialization not checking potion effects 2025-08-06 16:27:27 -05:00
Catnies
f5e81446a6 fix PlayerMenuOpenEvent can't cancel 2025-08-05 14:34:07 +08:00
LoJoSho
c99a57a6bf chore: update adventure dependencies 2025-08-01 22:01:31 -05:00
LoJoSho
79630263f2 chore: exclude lin-bus from worldguard depend 2025-08-01 21:59:30 -05:00
LoJoSho
478c4280c1 feat: finally fully remove mainhand cosmetic 2025-07-19 15:36:11 -05:00
LoJoSho
4fd439acc4 chore: backpack force riding backpack set on by default 2025-07-12 10:32:38 -05:00
LoJoSho
58c955a00f feat: expose the config for a cosmetic if available 2025-07-09 18:06:22 -05:00
Oak
2f9325b2fb Added scale attribute support to backpacks (#186) 2025-07-05 16:15:01 -05:00
LoJoSho
823270648b Merge remote-tracking branch 'origin/remapped' into remapped 2025-07-04 11:59:44 -05:00
LoJoSho
d5e988261b chore: update to 1.21.7 on test server 2025-07-04 11:59:35 -05:00
Logan
13303096ec chore: shading should be off by default 2025-07-04 10:27:20 -05:00
LoJoSho
3ee79e8443 fix: passenger packet interceptor appears to cause instability, disabling for now 2025-07-01 14:50:42 -05:00
LoJoSho
7785556967 chore: remove unused variable 2025-07-01 14:49:39 -05:00
LoJoSho
1296ca6e92 fix: calculating yaw twice causing bad yaw to be sent in rotations 2025-07-01 13:47:50 -05:00
LoJoSho
f56d5c9093 chore: more debug messages on equip 2025-06-28 17:59:23 -05:00
LoJoSho
bae04fba3f chore: update to latest hibiscus commons 2025-06-28 15:30:47 -05:00
LoJoSho
cbe5404399 fix: hibiscus commons version 2025-06-27 15:47:49 -05:00
LoJoSho
dc4098782a fix: latest crash fixes (with latest hibiscus commons) 2025-06-27 15:44:17 -05:00
LoJoSho
2eb0b26fb3 fix: plugin not properly saving resources 2025-06-27 15:15:48 -05:00
LoJoSho
22159fa9f4 fix: duplicate entity ids in passengers 2025-06-27 10:18:35 -05:00
LoJoSho
539c09801c chore: remove cooldown on teleport packet 2025-06-27 08:53:58 -05:00
Logan
bed5cd7bbb Merge pull request #185 from HibiscusMC/commons07
feat: overhaul to new Hibiscus commons packet system
2025-06-26 15:43:12 -05:00
29 changed files with 283 additions and 174 deletions

View File

@@ -8,7 +8,7 @@ plugins {
}
group = "com.hibiscusmc"
version = "2.8.0${getGitCommitHash()}"
version = "2.8.1${getGitCommitHash()}"
allprojects {
apply(plugin = "java")
@@ -85,18 +85,19 @@ allprojects {
exclude(group = "com.google.code.gson")
exclude(group = "it.unimi.dsi")
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-bukkit-api:1.12") //Platform api
compileOnly("io.github.toxicity188:BetterCommand:1.3") //BetterCommand library
//compileOnly("it.unimi.dsi:fastutil:8.5.14")
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
compileOnly("net.kyori:adventure-api:4.23.0")
compileOnly("net.kyori:adventure-text-minimessage:4.23.0")
compileOnly("net.kyori:adventure-platform-bukkit:4.4.0")
compileOnly("net.kyori:adventure-api:4.24.0")
compileOnly("net.kyori:adventure-text-minimessage:4.24.0")
compileOnly("net.kyori:adventure-platform-bukkit:4.4.1")
annotationProcessor("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
}
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 {
@@ -139,11 +140,12 @@ tasks {
}
runServer {
minecraftVersion("1.21.6")
minecraftVersion("1.21.8")
downloadPlugins {
hangar("PlaceholderAPI", "2.11.6")
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 ""
}
}

View File

@@ -11,6 +11,8 @@ import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetics;
import com.hibiscusmc.hmccosmetics.database.Database;
import com.hibiscusmc.hmccosmetics.gui.Menu;
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.misc.HookBetterHud;
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.config.serializer.ItemSerializer;
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.configurate.ConfigurateException;
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(), "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() + "/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
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()) {
getServer().getPluginManager().registerEvents(new WGListener(), this);
}
// HMCColor
if (Hooks.isActiveHook("HMCColor")) {
DyeMenuProvider.setDyeMenuProvider(new HMCColorDyeMenu());
}
}
@Override

View File

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

View File

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

View File

@@ -14,6 +14,7 @@ import com.hibiscusmc.hmccosmetics.database.Database;
import com.hibiscusmc.hmccosmetics.gui.Menu;
import com.hibiscusmc.hmccosmetics.gui.Menus;
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.CosmeticUsers;
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
@@ -329,7 +330,7 @@ public class CosmeticCommand implements CommandExecutor {
}
user.addCosmetic(cosmetic, color); // #FFFFFF
} else {
DyeMenu.openMenu(user, cosmetic);
DyeMenuProvider.openMenu(player, user, cosmetic);
}
}
case ("setwardrobesetting") -> {

View File

@@ -12,6 +12,7 @@ import org.bukkit.ChatColor;
import org.bukkit.Material;
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.Nullable;
@@ -56,8 +57,12 @@ public abstract class Cosmetic {
/** Whether the cosmetic is dyeable or not. */
private boolean dyeable;
/** The config for the cosmetic */
private ConfigurationNode config;
protected Cosmetic(@NotNull String id, @NotNull ConfigurationNode config) {
this.id = id;
this.config = config;
if (!config.node("permission").virtual()) {
this.permission = config.node("permission").getString();
@@ -135,4 +140,14 @@ public abstract class Cosmetic {
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,12 +2,10 @@ package com.hibiscusmc.hmccosmetics.cosmetic;
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
import com.hibiscusmc.hmccosmetics.cosmetic.types.*;
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
import lombok.extern.slf4j.Slf4j;
import me.lojosho.shaded.configurate.ConfigurationNode;
import org.bukkit.plugin.Plugin;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.Map;
import java.util.function.BiFunction;
@@ -24,8 +22,6 @@ public abstract class CosmeticProvider {
Map.entry(CosmeticSlot.BOOTS, CosmeticArmorType::new),
Map.entry(CosmeticSlot.OFFHAND, CosmeticArmorType::new),
Map.entry(CosmeticSlot.MAINHAND, CosmeticMainhandType::new),
Map.entry(CosmeticSlot.BACKPACK, CosmeticBackpackType::new),
Map.entry(CosmeticSlot.BALLOON, CosmeticBalloonType::new)

View File

@@ -48,9 +48,11 @@ public class CosmeticArmorType extends Cosmetic {
}
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()) {
ItemStack equippedItem = humanEntity.getInventory().getItem(equipSlot);
ItemStack equippedItem = player.getInventory().getItem(equipSlot);
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

View File

@@ -5,13 +5,13 @@ import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
import com.hibiscusmc.hmccosmetics.user.manager.UserBackpackManager;
import com.hibiscusmc.hmccosmetics.user.manager.UserEntity;
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
import com.hibiscusmc.hmccosmetics.util.packets.HMCCPacketManager;
import lombok.Getter;
import me.lojosho.hibiscuscommons.util.packets.PacketManager;
import me.lojosho.shaded.configurate.ConfigurationNode;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.attribute.Attribute;
import org.bukkit.attribute.AttributeInstance;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
@@ -22,7 +22,6 @@ import org.jetbrains.annotations.NotNull;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import java.util.logging.Level;
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.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);
// 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());

View File

@@ -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()));
}
}

View File

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

View File

@@ -6,7 +6,6 @@ import com.hibiscusmc.hmccosmetics.cosmetic.CosmeticSlot;
import com.hibiscusmc.hmccosmetics.database.UserData;
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
import org.bukkit.Bukkit;
import org.bukkit.Color;
import java.sql.PreparedStatement;
import java.sql.ResultSet;

View File

@@ -14,21 +14,18 @@ import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
import dev.triumphteam.gui.builder.item.ItemBuilder;
import dev.triumphteam.gui.components.GuiType;
import dev.triumphteam.gui.components.InventoryProvider;
import dev.triumphteam.gui.guis.Gui;
import dev.triumphteam.gui.guis.GuiItem;
import lombok.Getter;
import me.lojosho.hibiscuscommons.config.serializer.ItemSerializer;
import me.lojosho.hibiscuscommons.hooks.Hooks;
import me.lojosho.hibiscuscommons.util.AdventureUtils;
import me.lojosho.hibiscuscommons.util.StringUtils;
import me.lojosho.shaded.configurate.ConfigurationNode;
import me.lojosho.shaded.configurate.serialize.SerializationException;
import net.kyori.adventure.text.Component;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType;
import org.bukkit.event.inventory.InventoryType;
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull;
@@ -185,18 +182,25 @@ public class Menu {
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
if (cosmeticHolder instanceof CosmeticUser user) {
PlayerMenuOpenEvent event = new PlayerMenuOpenEvent(user, this);
Bukkit.getScheduler().runTask(HMCCosmeticsPlugin.getInstance(), () -> Bukkit.getPluginManager().callEvent(event));
if (event.isCancelled()) return;
Bukkit.getScheduler().runTask(HMCCosmeticsPlugin.getInstance(), () -> {
Bukkit.getPluginManager().callEvent(event);
if (!event.isCancelled()) {
openGuiTask.run();
}
});
}
// Internal
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
});
else {
Bukkit.getScheduler().runTask(HMCCosmeticsPlugin.getInstance(), openGuiTask);
}
}
private void updateMenu(Player viewer, CosmeticHolder cosmeticHolder, Gui gui) {

View File

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

View File

@@ -1,67 +1,20 @@
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.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.inventory.ItemStack;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
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;
public interface DyeMenu {
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;
/**
* Overrideable method that is called when a player wishing to dye a menu.
* After the method is called, the menu plugin itself is supposed to handle everything else, including adding the cosmetic to the CosmeticHolder
*
* @param viewer The player that is viewing the menu
* @param cosmeticHolder The CosmeticHolder that is being dyed (Can be different from the viewer)
* @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);
}
}

View File

@@ -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;
}
}

View File

@@ -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);
}
}

View File

@@ -8,6 +8,7 @@ import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetics;
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticArmorType;
import com.hibiscusmc.hmccosmetics.gui.action.Actions;
import com.hibiscusmc.hmccosmetics.gui.special.DyeMenu;
import com.hibiscusmc.hmccosmetics.gui.special.DyeMenuProvider;
import com.hibiscusmc.hmccosmetics.gui.type.Type;
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
@@ -102,9 +103,11 @@ public class TypeCosmetic extends Type {
} else {
if (!actionConfig.node("on-equip").virtual()) actionStrings.addAll(actionConfig.node("on-equip").getList(String.class));
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
if (cosmetic.isDyeable() && isDyeClick && Hooks.isActiveHook("HMCColor")) {
DyeMenu.openMenu(viewer, cosmeticHolder, cosmetic);
if (cosmetic.isDyeable() && isDyeClick && DyeMenuProvider.hasMenuProvider()) {
DyeMenuProvider.openMenu(viewer, cosmeticHolder, cosmetic);
} else if (isRequiredClick) {
cosmeticHolder.addCosmetic(cosmetic);
}

View File

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

View File

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

View File

@@ -8,9 +8,11 @@ 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.*;
@@ -25,29 +27,34 @@ import java.util.*;
public class CosmeticPacketInterface implements PacketInterface {
@Override
public PacketAction writeContainerContent(@NotNull Player player, @NotNull ContainerContentWrapper wrapper) {
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> items = new HashMap<>();
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;
items.put(HMCCInventoryUtils.getPacketArmorSlot(armorType.getEquipSlot()), user.getUserCosmeticItem(armorType));
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 (!items.containsKey(slot)) continue;
slotData.set(slot, items.get(slot));
if (Settings.isDebugMode()) MessagesUtil.sendDebugMessages("Set " + slot + " as " + items.get(slot));
if (!cosmeticItems.containsKey(slot)) continue;
slotData.set(slot, cosmeticItems.get(slot));
if (Settings.isDebugMode()) MessagesUtil.sendDebugMessages("Set " + slot + " as " + cosmeticItems.get(slot));
}
}
@@ -57,7 +64,7 @@ public class CosmeticPacketInterface implements PacketInterface {
}
@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 slot = wrapper.getSlot();
ItemStack itemStack = wrapper.getItemStack();
@@ -81,7 +88,7 @@ public class CosmeticPacketInterface implements PacketInterface {
}
@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;
CosmeticUser user = CosmeticUsers.getUser(player);
if (user == null || user.isInWardrobe()) return PacketAction.NOTHING;
@@ -116,35 +123,58 @@ public class CosmeticPacketInterface implements PacketInterface {
}
@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);
if (viewerUser == null || viewerUser.isInWardrobe()) return PacketAction.NOTHING;
int ownerId = wrapper.getOwner();
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();
if (optionalCosmeticUser.isEmpty()) return PacketAction.NOTHING;
Player entity = optionalCosmeticUser.get().getPlayer();
CosmeticUser user = CosmeticUsers.getUser(entity.getUniqueId());
if (user == null) 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;
if (user.getUserBackpackManager() == null) return PacketAction.NOTHING;
List<Integer> passengers = new ArrayList<>(user.getUserBackpackManager().getEntityManager().getIds());
for (int passenger : originalPassengers) passengers.add(passenger);
passengers.addAll(originalPassengers);
wrapper.setPassengers(passengers);
return PacketAction.CHANGED;
*/
}
@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 slotNumber = wrapper.getSlotNumber();
if (clickType != 0 || slotNumber == -999) return PacketAction.NOTHING;
@@ -160,7 +190,7 @@ public class CosmeticPacketInterface implements PacketInterface {
}
@Override
public PacketAction readPlayerAction(@NotNull Player player, @NotNull PlayerActionWrapper wrapper) {
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
@@ -176,7 +206,7 @@ public class CosmeticPacketInterface implements PacketInterface {
}
@Override
public PacketAction readPlayerArm(@NotNull Player player) {
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;
@@ -187,7 +217,7 @@ public class CosmeticPacketInterface implements PacketInterface {
}
@Override
public PacketAction readEntityHandle(@NotNull Player player) {
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,7 +13,6 @@ import com.hibiscusmc.hmccosmetics.cosmetic.CosmeticSlot;
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticArmorType;
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticBackpackType;
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticBalloonType;
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticMainhandType;
import com.hibiscusmc.hmccosmetics.database.UserData;
import com.hibiscusmc.hmccosmetics.gui.Menus;
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.MessagesUtil;
import com.hibiscusmc.hmccosmetics.util.packets.HMCCPacketManager;
import com.ticxo.modelengine.api.nms.NMSHandler;
import lombok.Getter;
import me.lojosho.hibiscuscommons.hooks.Hooks;
import me.lojosho.hibiscuscommons.nms.NMSHandlers;
@@ -30,7 +28,6 @@ import me.lojosho.hibiscuscommons.util.InventoryUtils;
import me.lojosho.hibiscuscommons.util.packets.PacketManager;
import org.bukkit.Bukkit;
import org.bukkit.Color;
import org.bukkit.FireworkEffect;
import org.bukkit.Material;
import org.bukkit.entity.Entity;
import org.bukkit.entity.HumanEntity;
@@ -39,6 +36,7 @@ import org.bukkit.inventory.EquipmentSlot;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.*;
import org.bukkit.persistence.PersistentDataType;
import org.bukkit.potion.PotionEffectType;
import org.bukkit.scheduler.BukkitTask;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -151,6 +149,11 @@ public class CosmeticUser implements CosmeticHolder {
MessagesUtil.sendDebugMessages("Showing Cosmetics due to world");
showCosmetics(HiddenReason.WORLD);
}
if (bukkitPlayer != null && bukkitPlayer.hasPotionEffect(PotionEffectType.INVISIBILITY)) {
hideCosmetics(HiddenReason.POTION);
}
if (Settings.isAllPlayersHidden()) {
hideCosmetics(HiddenReason.DISABLED);
}
@@ -345,7 +348,7 @@ public class CosmeticUser implements CosmeticHolder {
if (cosmetic instanceof CosmeticArmorType armorType) {
item = armorType.getItem(this, cosmetic.getItem());
}
if (cosmetic instanceof CosmeticBackpackType || cosmetic instanceof CosmeticMainhandType) {
if (cosmetic instanceof CosmeticBackpackType) {
item = cosmetic.getItem();
}
if (cosmetic instanceof CosmeticBalloonType) {

View File

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

View File

@@ -99,7 +99,12 @@ public class UserBalloonManager {
}
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) {
final ModeledEntity entity = ModelEngineAPI.getModeledEntity(modelEntity);
if (entity == null) {

View File

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

View File

@@ -3,7 +3,6 @@ package com.hibiscusmc.hmccosmetics.user.manager;
import com.hibiscusmc.hmccosmetics.config.Settings;
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 lombok.Getter;
@@ -80,7 +79,7 @@ public class UserEntity {
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
// 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;
for (Integer entity : ids) {

View File

@@ -1,6 +1,5 @@
package com.hibiscusmc.hmccosmetics.util;
import me.lojosho.hibiscuscommons.util.StringUtils;
import me.lojosho.shaded.configurate.ConfigurationNode;
import java.util.ArrayList;

View File

@@ -121,11 +121,7 @@ public class HMCCPacketManager extends PacketManager {
boolean onGround,
@NotNull List<Player> 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);
NMSHandlers.getHandler().getPacketHandler().sendRotationPacket(entityId, location.getYaw(), location.getPitch(), onGround, sendTo);
}
public static void sendRotationPacket(
@@ -134,8 +130,7 @@ public class HMCCPacketManager extends PacketManager {
boolean onGround,
@NotNull List<Player> sendTo
) {
float ROTATION_FACTOR = 256.0F / 360.0F;
NMSHandlers.getHandler().getPacketHandler().sendRotationPacket(entityId, yaw * ROTATION_FACTOR, 0, onGround, sendTo);
NMSHandlers.getHandler().getPacketHandler().sendRotationPacket(entityId, yaw, 0, onGround, sendTo);
}
/**
@@ -276,6 +271,14 @@ public class HMCCPacketManager extends PacketManager {
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
public static void sendDisplayEntityMetadataPacket(
int entityid,

View File

@@ -41,7 +41,7 @@ cosmetic-settings:
- "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.
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
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.
@@ -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.
# 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)
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>"
sequent-row-shift: " <shift:-153>" # Nexo: " <shift:-153>" (Space is important here!)
individual-column-shift: "<shift:-3>" # Nexo: "<shift:-3>"