9
0
mirror of https://github.com/HibiscusMC/HMCCosmetics.git synced 2025-12-20 07:29:15 +00:00

Compare commits

...

38 Commits

Author SHA1 Message Date
LoJoSho
1ef2c6b631 chore: update gradle (8.12) & run-paper (2.3.1) 2024-12-28 19:49:48 -06:00
LoJoSho
c7667b2dc2 chore: improve version handling 2024-12-28 18:20:09 -06:00
LoJoSho
e4c4933d46 chore: more debug in passenger listener 2024-12-16 13:27:13 -06:00
LoJoSho
1f94192772 chore: update LP in runServer 2024-12-16 13:26:45 -06:00
LoJoSho
8ebcea5465 feat: if player is hidden from another player, their cosmetics are no longer seen 2024-12-06 13:36:49 -06:00
LoJoSho
4c7ccc06ca feat: version now has commit hash with it 2024-12-04 08:55:39 -06:00
LoJoSho
667f58ff4b fix: mount packet has bad if test 2024-11-25 13:22:58 -06:00
LoJoSho
69d318c4b0 feat: add Nexo support 2024-11-23 20:35:19 -06:00
LoJoSho
0414f3be90 clean: remove first person backpack update message (it is spammy) 2024-11-23 20:27:21 -06:00
LoJoSho
402203b4c2 feat: add passenger listener to better ensure backpacks stay on 2024-11-23 20:26:57 -06:00
LoJoSho
6dcaf06ebe feat: add defaultmenu to specific wardrobes 2024-11-19 20:43:31 -06:00
LoJoSho
1b6adca00e fix: balloon pufferfish getting wrong viewers 2024-11-16 10:57:31 -06:00
LoJoSho
0dce5822e3 feat: overhaul of getting player data 2024-11-15 21:59:32 -06:00
LoJoSho
0f1b75f09e feat: update to Hibiscus Commons 0.5 2024-11-15 20:21:04 -06:00
LoJoSho
19192c46a5 feat: add config options to avoid certain item processing if desired 2024-10-30 10:14:29 -05:00
LoJoSho
62a9e7d1ac chore: define variable nullability for getUserCosmeticItem 2024-10-30 09:21:27 -05:00
LoJoSho
06077201f9 fix: not checking if a null variable is null before usage in balloon handling in the wardrobe 2024-10-30 09:15:14 -05:00
LoJoSho
b2795a705e fix: not checking if itemstack has meta data before modification of meta data 2024-10-27 19:54:55 -05:00
LoJoSho
1e6734bf6f feat: console can now apply any cosmetic to a player 2024-10-24 20:34:17 -05:00
LoJoSho
ad382e5d9e chore: update ProtocolLib to newest version 2024-10-21 12:28:39 -05:00
LoJoSho
6458a1e316 chore: add downloadPlugins to runServer task 2024-10-13 17:38:11 -05:00
LoJoSho
279d6edc34 fix: mainhand showing even if invisible 2024-10-12 12:34:17 -05:00
LoJoSho
439dc85aa3 feat: add Hibiscus Commons / GSit compatibility 2024-10-10 22:50:58 -05:00
LoJoSho
60e23411dc fix: fixed cosmetic applying owner skull npe? (Should have already been checked but is now fully checked) 2024-10-02 22:24:04 -05:00
LoJoSho
33fb680c22 fix: Possible null in getEquipSlot 2024-10-01 23:58:44 -05:00
LoJoSho
536b7ebdec clean: remove jeff repo (moved to Hibiscus Commons) 2024-09-20 17:54:23 -05:00
LoJoSho
5da95f2f5b fix: finish the full update to Java 21 2024-09-20 17:50:51 -05:00
LoJoSho
30f4a84241 feat: menu command not having menu id will now open default menu 2024-09-20 17:13:54 -05:00
LoJoSho
f34e126c85 chore: bring test-server to 1.21.1 2024-09-20 17:11:49 -05:00
LoJoSho
d7d0f27e49 chore: fix misspelled relocated paths 2024-08-26 13:16:33 -05:00
LoJoSho
f42937a6d0 fix: Model Engine coloring throwing class not found (version bump 2.7.4-DEV) 2024-08-26 12:57:23 -05:00
LoJoSho
c8b7430998 clean: update gradle wrapper 2024-08-16 10:11:33 -05:00
LoJoSho
42de76d84d version bump (2.7.3) 2024-08-16 09:33:26 -05:00
LoJoSho
5102fd77b7 Merge remote-tracking branch 'origin/remapped' into remapped 2024-08-09 10:03:11 -05:00
LoJoSho
9c66d4ee81 fix: entering wardrobe not activating if allow cosmetics set to allow 2024-08-09 10:02:59 -05:00
LoJoSho
7ade2d9227 fix: ProtocolLib body part changed in newest versions 2024-08-05 21:27:13 -05:00
LoJoSho
7b43b42740 Revert "feat: customize backpack light emination"
This reverts commit 3cf265f231.
2024-08-01 18:31:05 -05:00
LoJoSho
25f050f387 Revert "feat: add user cosmetic item caching"
This reverts commit 34b02574b2.
2024-08-01 18:27:38 -05:00
34 changed files with 459 additions and 333 deletions

View File

@@ -2,13 +2,13 @@ import net.minecrell.pluginyml.bukkit.BukkitPluginDescription
plugins {
id("java")
id("com.github.johnrengelman.shadow") version "8.1.1"
id("xyz.jpenilla.run-paper") version "2.0.0"
id("com.gradleup.shadow") version "8.3.2"
id("xyz.jpenilla.run-paper") version "2.3.1"
id("net.minecrell.plugin-yml.bukkit") version "0.6.0"
}
group = "com.hibiscusmc"
version = "2.7.3-DEV"
version = "2.7.4${getGitCommitHash()}"
allprojects {
apply(plugin = "java")
@@ -49,9 +49,6 @@ allprojects {
}
}
// UpdateChecker
maven("https://hub.jeff-media.com/nexus/repository/jeff-media-public/")
// ParticleHelper
maven("https://repo.bytecode.space/repository/maven-public/")
@@ -75,15 +72,15 @@ allprojects {
compileOnly(fileTree("${project.rootDir}/lib") { include("*.jar") })
compileOnly("com.mojang:authlib:1.5.25")
//compileOnly("org.spigotmc:spigot-api:1.18.2-R0.1-SNAPSHOT")
compileOnly("io.papermc.paper:paper-api:1.19.4-R0.1-SNAPSHOT")
compileOnly("io.papermc.paper:paper-api:1.20.1-R0.1-SNAPSHOT")
compileOnly("org.jetbrains:annotations:24.1.0")
compileOnly("com.comphenix.protocol:ProtocolLib:5.1.0")
compileOnly("com.comphenix.protocol:ProtocolLib:5.3.0")
compileOnly("me.clip:placeholderapi:2.11.6")
compileOnly("com.ticxo.modelengine:ModelEngine:R4.0.2")
compileOnly("com.sk89q.worldguard:worldguard-bukkit:7.1.0-SNAPSHOT")
compileOnly("it.unimi.dsi:fastutil:8.5.13")
compileOnly("com.ticxo.modelengine:ModelEngine:R4.0.6")
compileOnly("com.sk89q.worldguard:worldguard-bukkit:7.0.12")
//compileOnly("it.unimi.dsi:fastutil:8.5.14")
compileOnly("org.projectlombok:lombok:1.18.34")
compileOnly("me.lojosho:HibiscusCommons:0.4.1")
compileOnly("me.lojosho:HibiscusCommons:0.5.1")
// Handled by Spigot Library Loader
compileOnly("net.kyori:adventure-api:4.17.0")
@@ -123,15 +120,21 @@ tasks {
}
runServer {
minecraftVersion("1.20.6")
minecraftVersion("1.21.1")
downloadPlugins {
hangar("PlaceholderAPI", "2.11.6")
url("https://ci.dmulloy2.net/job/ProtocolLib/lastSuccessfulBuild/artifact/build/libs/ProtocolLib.jar")
url("https://download.luckperms.net/1567/bukkit/loader/LuckPerms-Bukkit-5.4.150.jar")
}
}
shadowJar {
mergeServiceFiles()
relocate("dev.triumphteam.gui", "com.hisbiscusmc.hmccosmetics.gui")
relocate("com.owen1212055.particlehelper", "com.hisbiscusmc.hmccosmetics.particlehelper")
relocate("com.ticxo.playeranimator", "com.hisbiscusmc.hmccosmetics.playeranimator")
relocate("dev.triumphteam.gui", "com.hibiscusmc.hmccosmetics.shaded.gui")
relocate("com.owen1212055.particlehelper", "com.hibiscusmc.hmccosmetics.shaded.particlehelper")
relocate("com.ticxo.playeranimator", "com.hibiscusmc.hmccosmetics.shaded.playeranimator")
archiveFileName.set("HMCCosmeticsRemapped-${project.version}.jar")
dependencies {
@@ -156,7 +159,7 @@ tasks {
bukkit {
load = BukkitPluginDescription.PluginLoadOrder.POSTWORLD
main = "com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin"
apiVersion = "1.19"
apiVersion = "1.20"
authors = listOf("LoJoSho")
depend = listOf("HibiscusCommons", "ProtocolLib")
softDepend = listOf("ModelEngine", "Oraxen", "ItemsAdder", "Geary", "HMCColor", "WorldGuard", "MythicMobs", "PlaceholderAPI", "SuperVanish", "PremiumVanish", "LibsDisguises", "Denizen", "MMOItems", "Eco")
@@ -260,3 +263,23 @@ java {
toolchain.languageVersion.set(JavaLanguageVersion.of(21
))
}
fun getGitCommitHash(): String {
var includeHash = true
val includeHashVariable = System.getenv("HMCC_INCLUDE_HASH")
if (!includeHashVariable.isNullOrEmpty()) includeHash = includeHashVariable.toBoolean()
if (includeHash) {
return try {
val process = ProcessBuilder("git", "rev-parse", "--short", "HEAD")
.redirectErrorStream(true)
.start()
process.inputStream.bufferedReader().use { "-" + it.readLine().trim() }
} catch (e: Exception) {
"-unknown" // Fallback if Git is not available or an error occurs
}
}
return ""
}

View File

@@ -4,7 +4,7 @@ plugins {
}
java {
toolchain.languageVersion.set(JavaLanguageVersion.of(17
toolchain.languageVersion.set(JavaLanguageVersion.of(21
))
}

View File

@@ -20,6 +20,7 @@ import com.hibiscusmc.hmccosmetics.hooks.worldguard.WGListener;
import com.hibiscusmc.hmccosmetics.listener.PaperPlayerGameListener;
import com.hibiscusmc.hmccosmetics.listener.PlayerConnectionListener;
import com.hibiscusmc.hmccosmetics.listener.PlayerGameListener;
import com.hibiscusmc.hmccosmetics.listener.ServerListener;
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
import com.hibiscusmc.hmccosmetics.user.CosmeticUsers;
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
@@ -94,6 +95,7 @@ public final class HMCCosmeticsPlugin extends HibiscusPlugin {
// Listener
getServer().getPluginManager().registerEvents(new PlayerConnectionListener(), this);
getServer().getPluginManager().registerEvents(new PlayerGameListener(), this);
getServer().getPluginManager().registerEvents(new ServerListener(), this);
// Taken from PaperLib
if (HibiscusCommonsPlugin.isOnPaper()) {
getServer().getPluginManager().registerEvents(new PaperPlayerGameListener(), this);

View File

@@ -43,10 +43,14 @@ public class CosmeticCommand implements CommandExecutor {
@Override
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String @NotNull [] args) {
boolean silent = false;
boolean console = false;
if (!(sender instanceof Player)) {
console = true;
}
if (args.length == 0) {
if (!(sender instanceof Player)) {
// Console
if (console) {
return true;
}
if (!sender.hasPermission("hmccosmetics.cmd.default")) {
@@ -140,7 +144,7 @@ public class CosmeticCommand implements CommandExecutor {
CosmeticUser user = CosmeticUsers.getUser(player);
if (!user.canEquipCosmetic(cosmetic)) {
if (!user.canEquipCosmetic(cosmetic) && !console) {
if (!silent) MessagesUtil.sendMessage(player, "no-cosmetic-permission");
return true;
}
@@ -247,12 +251,16 @@ public class CosmeticCommand implements CommandExecutor {
}
// cosmetic menu exampleMenu playerName
case ("menu") -> {
if (args.length == 1) return true;
if (!sender.hasPermission("hmccosmetics.cmd.menu")) {
if (!silent) MessagesUtil.sendMessage(sender, "no-permission");
return true;
}
Menu menu = Menus.getMenu(args[1]);
Menu menu;
if (args.length == 1) {
menu = Menus.getDefaultMenu();
} else {
menu = Menus.getMenu(args[1]);
}
if (sender instanceof Player) player = ((Player) sender).getPlayer();
if (sender.hasPermission("hmccosmetics.cmd.menu.other")) {
@@ -334,7 +342,7 @@ public class CosmeticCommand implements CommandExecutor {
}
Wardrobe wardrobe = WardrobeSettings.getWardrobe(args[1]);
if (wardrobe == null) {
wardrobe = new Wardrobe(args[1], new WardrobeLocation(null, null, null), null, -1);
wardrobe = new Wardrobe(args[1], new WardrobeLocation(null, null, null), null, -1, null);
WardrobeSettings.addWardrobe(wardrobe);
//MessagesUtil.sendMessage(player, "no-wardrobes");
//return true;

View File

@@ -30,11 +30,15 @@ public class Settings {
private static final String UNAPPLY_DEATH_PATH = "unapply-on-death";
private static final String FORCE_PERMISSION_JOIN_PATH = "force-permission-join";
private static final String FORCE_SHOW_COSMETICS_PATH = "force-show-join";
private static final String ITEM_PROCESSING_PATH = "item-processing";
private static final String ITEM_PROCESS_DISPLAY_NAME_PATH = "display-name";
private static final String ITEM_PROCESS_LORE_PATH = "lore";
private static final String DISABLED_GAMEMODE_PATH = "disabled-gamemode";
private static final String DISABLED_GAMEMODE_GAMEMODES_PATH = "gamemodes";
private static final String EMOTE_DISTANCE_PATH = "emote-distance";
private static final String HOOK_SETTING_PATH = "hook-settings";
private static final String HOOK_ITEMADDER_PATH = "itemsadder";
private static final String HOOK_NEXO_PATH = "nexo";
private static final String HOOK_RELOAD_CHANGE_PATH = "reload-on-change";
private static final String HOOK_WORLDGUARD_PATH = "worldguard";
private static final String HOOK_WG_MOVE_CHECK_PATH = "player-move-check";
@@ -49,8 +53,6 @@ public class Settings {
private static final String COSMETIC_DISABLED_WORLDS_PATH = "disabled-worlds";
private static final String COSMETIC_PACKET_ENTITY_TELEPORT_COOLDOWN_PATH = "entity-cooldown-teleport-packet";
private static final String COSMETIC_BACKPACK_FORCE_RIDING_PACKET_PATH = "backpack-force-riding-packet";
private static final String COSMETIC_BACKPACK_LIGHT_EMINATION_PATH = "backpack-light-emination";
private static final String COSMETIC_BACKPACK_LIGHT_BLOCK_DETECTION = "backpack-block-detection";
private static final String COSMETIC_DESTROY_LOOSE_COSMETIC_PATH = "destroy-loose-cosmetics";
private static final String COSMETIC_BALLOON_HEAD_FORWARD_PATH = "balloon-head-forward";
private static final String MENU_SETTINGS_PATH = "menu-settings";
@@ -90,8 +92,14 @@ public class Settings {
@Getter
private static boolean forceShowOnJoin;
@Getter
private static boolean itemProcessingDisplayName;
@Getter
private static boolean itemProcessingLore;
@Getter
private static boolean itemsAdderChangeReload;
@Getter
private static boolean nexoChangeReload;
@Getter
private static boolean worldGuardMoveCheck;
@Getter
private static boolean cosmeticEmoteBlockCheck;
@@ -107,10 +115,6 @@ public class Settings {
@Getter
private static boolean backpackForceRidingEnabled;
@Getter
private static boolean backpackLightEmination;
@Getter
private static boolean backpackBlockDetection;
@Getter
private static boolean emotesEnabled;
@Getter
private static boolean disabledGamemodesEnabled;
@@ -191,6 +195,10 @@ public class Settings {
disabledWorlds = new ArrayList<>();
}
ConfigurationNode itemProcessingSettings = cosmeticSettings.node(ITEM_PROCESSING_PATH);
itemProcessingDisplayName = itemProcessingSettings.node(ITEM_PROCESS_DISPLAY_NAME_PATH).getBoolean(true);
itemProcessingLore = itemProcessingSettings.node(ITEM_PROCESS_LORE_PATH).getBoolean(true);
unapplyOnDeath = cosmeticSettings.node(UNAPPLY_DEATH_PATH).getBoolean(false);
forcePermissionJoin = cosmeticSettings.node(FORCE_PERMISSION_JOIN_PATH).getBoolean(false);
forceShowOnJoin = cosmeticSettings.node(FORCE_SHOW_COSMETICS_PATH).getBoolean(false);
@@ -202,8 +210,6 @@ public class Settings {
emoteInvincible = cosmeticSettings.node(COSMETIC_EMOTE_INVINCIBLE_PATH).getBoolean(false);
destroyLooseCosmetics = cosmeticSettings.node(COSMETIC_DESTROY_LOOSE_COSMETIC_PATH).getBoolean(false);
backpackForceRidingEnabled = cosmeticSettings.node(COSMETIC_BACKPACK_FORCE_RIDING_PACKET_PATH).getBoolean(false);
backpackLightEmination = cosmeticSettings.node(COSMETIC_BACKPACK_LIGHT_EMINATION_PATH).getBoolean(true);
backpackBlockDetection = cosmeticSettings.node(COSMETIC_BACKPACK_LIGHT_BLOCK_DETECTION).getBoolean(true);
cosmeticSettings.node(SLOT_OPTIONS_PATH).childrenMap().forEach((key, value) -> {
EquipmentSlot slot = convertConfigToEquipment(key.toString().toLowerCase());
@@ -254,9 +260,13 @@ public class Settings {
dyeMenuOutputSlot = dyeMenuSettings.node(DYE_MENU_OUTPUT_SLOT).getInt(25);
ConfigurationNode hookSettings = source.node(HOOK_SETTING_PATH);
ConfigurationNode itemsAdderSettings = hookSettings.node(HOOK_ITEMADDER_PATH);
itemsAdderChangeReload = itemsAdderSettings.node(HOOK_RELOAD_CHANGE_PATH).getBoolean(false);
ConfigurationNode nexoSettings = hookSettings.node(HOOK_NEXO_PATH);
nexoChangeReload = nexoSettings.node(HOOK_RELOAD_CHANGE_PATH).getBoolean(true);
ConfigurationNode worldGuardSettings = hookSettings.node(HOOK_WORLDGUARD_PATH);
worldGuardMoveCheck = worldGuardSettings.node(HOOK_WG_MOVE_CHECK_PATH).getBoolean(true);
// I messed up in release 2.2.6 and forgot to change player_move_check to player-move-check.

View File

@@ -14,10 +14,12 @@ public class Wardrobe {
private final String id;
@Getter @Setter
private int distance;
@Getter @Setter
@Getter @Setter @Nullable
private String permission;
@Getter @Setter
private WardrobeLocation location;
@Getter @Setter @Nullable
private String defaultMenu;
/**
* This creates a Wardrobe object with all the information that a user will need when entering.
@@ -25,12 +27,14 @@ public class Wardrobe {
* @param location The 3 locations of the Wardrobe, if any of these 3 locations are null, the wardrobe will not work
* @param permission The permission required to enter the wardrobe, if null, no permission is required
* @param distance The distance from the wardrobe that the player can be to enter, if -1, the player can enter from any distance
* @param defaultMenu The default menu that the player will open when entering the wardrobe.
*/
public Wardrobe(@NotNull String id, @NotNull WardrobeLocation location, @Nullable String permission, int distance) {
public Wardrobe(@NotNull String id, @NotNull WardrobeLocation location, @Nullable String permission, int distance, @Nullable String defaultMenu) {
this.id = id;
this.location = location;
this.distance = distance;
if (permission != null) this.permission = permission;
if (defaultMenu != null) this.defaultMenu = defaultMenu;
}
/**

View File

@@ -45,6 +45,7 @@ public class WardrobeSettings {
private static final String WARDROBES_PATH = "wardrobes";
private static final String PERMISSION_PATH = "permission";
private static final String DISTANCE_PATH = "distance";
private static final String WARDROBE_DEFAULT_MENU = "default-menu";
private static final String BOSSBAR_PATH = "bossbar";
private static final String BOSSBAR_ENABLE_PATH = "enabled";
private static final String BOSSBAR_TEXT_PATH = "text";
@@ -174,9 +175,10 @@ public class WardrobeSettings {
WardrobeLocation wardrobeLocation = new WardrobeLocation(npcLocation, viewerLocation, leaveLocation);
String permission = wardrobesNode.node(PERMISSION_PATH).getString();
String defaultMenu = wardrobesNode.node(WARDROBE_DEFAULT_MENU).getString();
int distance = wardrobesNode.node(DISTANCE_PATH).getInt(-1);
Wardrobe wardrobe = new Wardrobe(id, wardrobeLocation, permission, distance);
Wardrobe wardrobe = new Wardrobe(id, wardrobeLocation, permission, distance, defaultMenu);
addWardrobe(wardrobe);
} catch (Exception e) {
MessagesUtil.sendDebugMessages("Unable to create wardrobe " + id, Level.SEVERE);

View File

@@ -22,7 +22,12 @@ public class CosmeticArmorType extends Cosmetic {
public CosmeticArmorType(String id, ConfigurationNode config) {
super(id, config);
this.equipSlot = HMCCInventoryUtils.getEquipmentSlot(getSlot());
EquipmentSlot slot = HMCCInventoryUtils.getEquipmentSlot(getSlot());
if (slot == null) {
// Hypothetically it shouldn't be null, but it was happening on some random servers? Adding this just in case
throw new IllegalArgumentException("Invalid slot for cosmetic armor type: " + getSlot() + " in " + id + " cosmetic config.");
}
this.equipSlot = slot;
}
@Override
@@ -52,6 +57,7 @@ public class CosmeticArmorType extends Cosmetic {
return cosmeticItem;
}
@NotNull
public EquipmentSlot getEquipSlot() {
return this.equipSlot;
}

View File

@@ -3,7 +3,6 @@ package com.hibiscusmc.hmccosmetics.cosmetic.types;
import com.hibiscusmc.hmccosmetics.config.Settings;
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
import com.hibiscusmc.hmccosmetics.user.manager.UserBackpackManager;
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
import com.hibiscusmc.hmccosmetics.util.packets.HMCCPacketManager;
import lombok.Getter;
@@ -11,7 +10,6 @@ import me.lojosho.hibiscuscommons.util.packets.PacketManager;
import me.lojosho.shaded.configurate.ConfigurationNode;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.block.Block;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
@@ -58,21 +56,20 @@ public class CosmeticBackpackType extends Cosmetic {
}
List<Player> outsideViewers = user.getUserBackpackManager().getEntityManager().refreshViewers(loc);
UserBackpackManager backpackManager = user.getUserBackpackManager();
backpackManager.getEntityManager().teleport(loc);
backpackManager.getEntityManager().setRotation((int) loc.getYaw(), isFirstPersonCompadible());
user.getUserBackpackManager().getEntityManager().teleport(loc);
user.getUserBackpackManager().getEntityManager().setRotation((int) loc.getYaw(), isFirstPersonCompadible());
HMCCPacketManager.sendEntitySpawnPacket(user.getEntity().getLocation(), backpackManager.getFirstArmorStandId(), EntityType.ARMOR_STAND, UUID.randomUUID(), outsideViewers);
//HMCCPacketManager.sendArmorstandMetadata(backpackManager.getFirstArmorStandId(), outsideViewers);
PacketManager.equipmentSlotUpdate(backpackManager.getFirstArmorStandId(), EquipmentSlot.HEAD, user.getUserCosmeticItem(this, getItem()), outsideViewers);
HMCCPacketManager.sendEntitySpawnPacket(user.getEntity().getLocation(), user.getUserBackpackManager().getFirstArmorStandId(), EntityType.ARMOR_STAND, UUID.randomUUID(), outsideViewers);
HMCCPacketManager.sendArmorstandMetadata(user.getUserBackpackManager().getFirstArmorStandId(), outsideViewers);
PacketManager.equipmentSlotUpdate(user.getUserBackpackManager().getFirstArmorStandId(), EquipmentSlot.HEAD, user.getUserCosmeticItem(this, getItem()), outsideViewers);
// If true, it will send the riding packet to all players. If false, it will send the riding packet only to new players
if (Settings.isBackpackForceRidingEnabled()) HMCCPacketManager.sendRidingPacket(entity.getEntityId(), backpackManager.getFirstArmorStandId(), backpackManager.getEntityManager().getViewers());
if (Settings.isBackpackForceRidingEnabled()) HMCCPacketManager.sendRidingPacket(entity.getEntityId(), user.getUserBackpackManager().getFirstArmorStandId(), user.getUserBackpackManager().getEntityManager().getViewers());
else HMCCPacketManager.sendRidingPacket(entity.getEntityId(), user.getUserBackpackManager().getFirstArmorStandId(), outsideViewers);
if (!user.isInWardrobe() && isFirstPersonCompadible() && user.getPlayer() != null) {
List<Player> owner = List.of(user.getPlayer());
ArrayList<Integer> particleCloud = backpackManager.getAreaEffectEntityId();
ArrayList<Integer> particleCloud = user.getUserBackpackManager().getAreaEffectEntityId();
for (int i = 0; i < particleCloud.size(); i++) {
if (i == 0) {
HMCCPacketManager.sendRidingPacket(entity.getEntityId(), particleCloud.get(i), owner);
@@ -80,17 +77,16 @@ public class CosmeticBackpackType extends Cosmetic {
HMCCPacketManager.sendRidingPacket(particleCloud.get(i - 1), particleCloud.get(i) , owner);
}
}
HMCCPacketManager.sendRidingPacket(particleCloud.get(particleCloud.size() - 1), backpackManager.getFirstArmorStandId(), owner);
HMCCPacketManager.sendRidingPacket(particleCloud.get(particleCloud.size() - 1), user.getUserBackpackManager().getFirstArmorStandId(), owner);
if (!user.isHidden()) {
//if (loc.getPitch() < -70) NMSHandlers.getHandler().equipmentSlotUpdate(user.getUserBackpackManager().getFirstArmorStandId(), EquipmentSlot.HEAD, new ItemStack(Material.AIR), owner);
//else NMSHandlers.getHandler().equipmentSlotUpdate(user.getUserBackpackManager().getFirstArmorStandId(), EquipmentSlot.HEAD, firstPersonBackpack, owner);
PacketManager.equipmentSlotUpdate(backpackManager.getFirstArmorStandId(), EquipmentSlot.HEAD, user.getUserCosmeticItem(this, firstPersonBackpack), owner);
PacketManager.equipmentSlotUpdate(user.getUserBackpackManager().getFirstArmorStandId(), EquipmentSlot.HEAD, user.getUserCosmeticItem(this, firstPersonBackpack), owner);
}
MessagesUtil.sendDebugMessages("First Person Backpack Update[owner=" + user.getUniqueId() + ",player_location=" + loc + "]!", Level.INFO);
//MessagesUtil.sendDebugMessages("First Person Backpack Update[owner=" + user.getUniqueId() + ",player_location=" + loc + "]!", Level.INFO);
}
MessagesUtil.sendDebugMessages("TTTTTTT " + backpackManager.refreshBlock(backpackManager.getEntityManager().getViewers()));
backpackManager.showBackpack();
user.getUserBackpackManager().showBackpack();
}
public boolean isFirstPersonCompadible() {

View File

@@ -12,6 +12,7 @@ import lombok.Getter;
import org.bukkit.entity.Player;
import java.util.UUID;
import java.util.concurrent.CompletableFuture;
import java.util.logging.Level;
public class Database {
@@ -56,7 +57,7 @@ public class Database {
data.save(CosmeticUsers.getUser(player));
}
public static CosmeticUser get(UUID uniqueId) {
public static CompletableFuture<UserData> get(UUID uniqueId) {
return data.get(uniqueId);
}

View File

@@ -0,0 +1,37 @@
package com.hibiscusmc.hmccosmetics.database;
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
import com.hibiscusmc.hmccosmetics.cosmetic.CosmeticSlot;
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
import lombok.Getter;
import lombok.Setter;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
public class UserData {
@Getter
private UUID owner;
@Setter
@Getter
private HashMap<CosmeticSlot, Map.Entry<Cosmetic, Integer>> cosmetics;
@Getter
private ArrayList<CosmeticUser.HiddenReason> hiddenReasons;
public UserData(UUID owner) {
this.owner = owner;
this.cosmetics = new HashMap<>();
this.hiddenReasons = new ArrayList<>();
}
public void addCosmetic(CosmeticSlot slot, Cosmetic cosmetic, Integer color) {
cosmetics.put(slot, Map.entry(cosmetic, color));
}
public void addHiddenReason(CosmeticUser.HiddenReason reason) {
hiddenReasons.add(reason);
}
}

View File

@@ -5,6 +5,7 @@ import com.hibiscusmc.hmccosmetics.config.Settings;
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
import com.hibiscusmc.hmccosmetics.cosmetic.CosmeticSlot;
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetics;
import com.hibiscusmc.hmccosmetics.database.UserData;
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
import org.apache.commons.lang3.EnumUtils;
@@ -14,6 +15,7 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.*;
import java.util.concurrent.CompletableFuture;
public abstract class Data {
@@ -22,7 +24,7 @@ public abstract class Data {
public abstract void save(CosmeticUser user);
@Nullable
public abstract CosmeticUser get(UUID uniqueId);
public abstract CompletableFuture<UserData> get(UUID uniqueId);
public abstract void clear(UUID uniqueId);
@@ -48,13 +50,9 @@ public abstract class Data {
return data.toString();
}
public final Map<CosmeticSlot, Map<Cosmetic, Color>> deserializeData(CosmeticUser user, @NotNull String raw) {
return deserializeData(user, raw, Settings.isForcePermissionJoin());
}
@NotNull
public final Map<CosmeticSlot, Map<Cosmetic, Color>> deserializeData(CosmeticUser user, @NotNull String raw, boolean permissionCheck) {
Map<CosmeticSlot, Map<Cosmetic, Color>> cosmetics = new HashMap<>();
public final HashMap<CosmeticSlot, Map.Entry<Cosmetic, Integer>> deserializeData(@NotNull String raw) {
HashMap<CosmeticSlot, Map.Entry<Cosmetic, Integer>> cosmetics = new HashMap<>();
String[] rawData = raw.split(",");
ArrayList<CosmeticUser.HiddenReason> hiddenReason = new ArrayList<>();
@@ -76,59 +74,14 @@ public abstract class Data {
String[] colorSplitData = splitData[1].split("&");
if (Cosmetics.hasCosmetic(colorSplitData[0])) cosmetic = Cosmetics.getCosmetic(colorSplitData[0]);
if (slot == null || cosmetic == null) continue;
if (permissionCheck && cosmetic.requiresPermission()) {
if (user.getPlayer() != null && !user.getPlayer().hasPermission(cosmetic.getPermission())) {
continue;
}
}
cosmetics.put(slot, Map.of(cosmetic, Color.fromRGB(Integer.parseInt(colorSplitData[1]))));
cosmetics.put(slot, Map.entry(cosmetic, Integer.parseInt(colorSplitData[1])));
} else {
if (Cosmetics.hasCosmetic(splitData[1])) cosmetic = Cosmetics.getCosmetic(splitData[1]);
if (slot == null || cosmetic == null) continue;
if (permissionCheck && cosmetic.requiresPermission()) {
if (user.getPlayer() != null && !user.getPlayer().hasPermission(cosmetic.getPermission())) {
continue;
}
}
HashMap<Cosmetic, Color> cosmeticColorHashMap = new HashMap<>();
cosmeticColorHashMap.put(cosmetic, null);
cosmetics.put(slot, cosmeticColorHashMap);
cosmetics.put(slot, Map.entry(cosmetic, -1));
}
}
MessagesUtil.sendDebugMessages("Hidden Reason: " + hiddenReason);
// if else this, if else that, if else I got to deal with this anymore i'll lose my mind
if (!hiddenReason.isEmpty()) {
for (CosmeticUser.HiddenReason reason : hiddenReason) user.silentlyAddHideFlag(reason);
} else {
Bukkit.getScheduler().runTask(HMCCosmeticsPlugin.getInstance(), () -> {
// Handle gamemode check
if (user.getPlayer() != null && Settings.isDisabledGamemodesEnabled() && Settings.getDisabledGamemodes().contains(user.getPlayer().getGameMode().toString())) {
MessagesUtil.sendDebugMessages("Hiding Cosmetics due to gamemode");
user.hideCosmetics(CosmeticUser.HiddenReason.GAMEMODE);
return;
} else {
if (user.isHidden(CosmeticUser.HiddenReason.GAMEMODE)) {
MessagesUtil.sendDebugMessages("Join Gamemode Check: Showing Cosmetics");
user.showCosmetics(CosmeticUser.HiddenReason.GAMEMODE);
return;
}
}
// Handle world check
if (user.getPlayer() != null && Settings.getDisabledWorlds().contains(user.getPlayer().getWorld().getName())) {
MessagesUtil.sendDebugMessages("Hiding Cosmetics due to world");
user.hideCosmetics(CosmeticUser.HiddenReason.WORLD);
} else {
if (user.isHidden(CosmeticUser.HiddenReason.WORLD)) {
MessagesUtil.sendDebugMessages("Join World Check: Showing Cosmetics");
user.showCosmetics(CosmeticUser.HiddenReason.WORLD);
}
}
if (Settings.isAllPlayersHidden()) {
user.hideCosmetics(CosmeticUser.HiddenReason.DISABLED);
}
});
}
return cosmetics;
}

View File

@@ -1,9 +1,11 @@
package com.hibiscusmc.hmccosmetics.database.types;
import com.hibiscusmc.hmccosmetics.database.UserData;
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
import org.jetbrains.annotations.Nullable;
import java.util.UUID;
import java.util.concurrent.CompletableFuture;
public class NoneData extends Data {
@Override
@@ -17,8 +19,8 @@ public class NoneData extends Data {
}
@Override
public @Nullable CosmeticUser get(UUID uniqueId) {
return new CosmeticUser(uniqueId);
public @Nullable CompletableFuture<UserData> get(UUID uniqueId) {
return CompletableFuture.completedFuture(new UserData(uniqueId));
}
@Override

View File

@@ -3,6 +3,7 @@ package com.hibiscusmc.hmccosmetics.database.types;
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
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;
@@ -13,14 +14,15 @@ import java.sql.SQLException;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
import java.util.concurrent.CompletableFuture;
public abstract class SQLData extends Data {
@Override
@SuppressWarnings({"resource"}) // Duplicate is from deprecated InternalData
public CosmeticUser get(UUID uniqueId) {
CosmeticUser user = new CosmeticUser(uniqueId);
public CompletableFuture<UserData> get(UUID uniqueId) {
return CompletableFuture.supplyAsync(() -> {
UserData data = new UserData(uniqueId);
Bukkit.getScheduler().runTaskAsynchronously(HMCCosmeticsPlugin.getInstance(), () -> {
PreparedStatement preparedStatement = null;
try {
preparedStatement = preparedStatement("SELECT * FROM COSMETICDATABASE WHERE UUID = ?;");
@@ -28,21 +30,8 @@ public abstract class SQLData extends Data {
ResultSet rs = preparedStatement.executeQuery();
if (rs.next()) {
String rawData = rs.getString("COSMETICS");
Map<CosmeticSlot, Map<Cosmetic, Color>> cosmetics = deserializeData(user, rawData);
// Load cosmetics, put them into the addedCosmetic hashmap
HashMap<Cosmetic, Color> addedCosmetics = new HashMap<>();
for (Map<Cosmetic, Color> cosmeticColors : cosmetics.values()) {
for (Cosmetic cosmetic : cosmeticColors.keySet()) {
addedCosmetics.put(cosmetic, cosmeticColors.get(cosmetic));
}
}
// Run a task on the main thread, adding the cosmetics to the player
Bukkit.getScheduler().runTask(HMCCosmeticsPlugin.getInstance(), () -> {
// This can not be async.
for (Cosmetic cosmetic : addedCosmetics.keySet()) {
user.addPlayerCosmetic(cosmetic, addedCosmetics.get(cosmetic));
}
});
HashMap<CosmeticSlot, Map.Entry<Cosmetic, Integer>> cosmetics = deserializeData(rawData);
data.setCosmetics(cosmetics);
}
} catch (SQLException e) {
e.printStackTrace();
@@ -51,9 +40,8 @@ public abstract class SQLData extends Data {
if (preparedStatement != null) preparedStatement.close();
} catch (SQLException e) {}
}
return data;
});
return user;
}
@Override

View File

@@ -128,8 +128,9 @@ public class TypeCosmetic extends Type {
}
@Override
public ItemStack setItem(CosmeticUser user, @NotNull ConfigurationNode config, ItemStack itemStack, int slot) {
itemStack.setItemMeta(processLoreLines(user, itemStack.getItemMeta()));
public ItemStack setItem(@NotNull CosmeticUser user, @NotNull ConfigurationNode config, @NotNull ItemStack itemStack, int slot) {
if (itemStack.hasItemMeta()) itemStack.setItemMeta(processLoreLines(user, itemStack.getItemMeta()));
else MessagesUtil.sendDebugMessages("ItemStack has no ItemMeta?");
if (config.node("cosmetic").virtual()) {
return itemStack;
@@ -153,7 +154,8 @@ public class TypeCosmetic extends Type {
} catch (SerializationException e) {
throw new RuntimeException(e);
}
itemStack.setItemMeta(processLoreLines(user, itemStack.getItemMeta()));
if (itemStack.hasItemMeta()) itemStack.setItemMeta(processLoreLines(user, itemStack.getItemMeta()));
else MessagesUtil.sendDebugMessages("ItemStack has no ItemMeta in equipped item?");
return itemStack;
}
@@ -170,7 +172,8 @@ public class TypeCosmetic extends Type {
} catch (SerializationException e) {
throw new RuntimeException(e);
}
itemStack.setItemMeta(processLoreLines(user, itemStack.getItemMeta()));
if (itemStack.hasItemMeta()) itemStack.setItemMeta(processLoreLines(user, itemStack.getItemMeta()));
else MessagesUtil.sendDebugMessages("ItemStack has no ItemMeta in locked item?");
return itemStack;
}
return itemStack;
@@ -193,7 +196,7 @@ public class TypeCosmetic extends Type {
}
if (itemMeta instanceof SkullMeta skullMeta) {
if (skullMeta.hasOwner()) {
if (skullMeta.hasOwner() && skullMeta.getOwner() != null) {
skullMeta.setOwner(Hooks.processPlaceholders(user.getPlayer(), skullMeta.getOwner()));
}
}

View File

@@ -75,7 +75,7 @@ public class TypeEmpty extends Type {
}
if (itemMeta instanceof SkullMeta skullMeta) {
if (skullMeta.hasOwner()) {
if (skullMeta.hasOwner() && skullMeta.getOwner() != null) {
skullMeta.setOwner(Hooks.processPlaceholders(user.getPlayer(), skullMeta.getOwner()));
}
}

View File

@@ -39,10 +39,9 @@ public class WGListener implements Listener {
if (protectedRegion.getFlags().containsKey(WGHook.getCosmeticEnableFlag())) {
if (protectedRegion.getFlags().get(WGHook.getCosmeticEnableFlag()).toString().equalsIgnoreCase("ALLOW")) {
user.showCosmetics(CosmeticUser.HiddenReason.WORLDGUARD);
return;
}
} else {
user.hideCosmetics(CosmeticUser.HiddenReason.WORLDGUARD);
return;
}
}
if (protectedRegion.getFlags().containsKey(WGHook.getCosmeticWardrobeFlag())) {
if (!WardrobeSettings.getWardrobeNames().contains(protectedRegion.getFlags().get(WGHook.getCosmeticWardrobeFlag()).toString())) return;

View File

@@ -4,6 +4,7 @@ import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
import com.hibiscusmc.hmccosmetics.config.DatabaseSettings;
import com.hibiscusmc.hmccosmetics.config.Settings;
import com.hibiscusmc.hmccosmetics.database.Database;
import com.hibiscusmc.hmccosmetics.database.UserData;
import com.hibiscusmc.hmccosmetics.gui.Menus;
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
import com.hibiscusmc.hmccosmetics.user.CosmeticUsers;
@@ -17,6 +18,8 @@ import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.jetbrains.annotations.NotNull;
import java.util.UUID;
public class PlayerConnectionListener implements Listener {
@EventHandler(priority = EventPriority.MONITOR)
@@ -33,17 +36,24 @@ public class PlayerConnectionListener implements Listener {
);
}
// This literally makes me want to end it all but I can't do that so I'll just cry instead
Runnable run = () -> {
if (!event.getPlayer().isOnline()) return; // If a player is no longer online, don't run this.
CosmeticUser user = Database.get(event.getPlayer().getUniqueId());
CosmeticUsers.addUser(user);
MessagesUtil.sendDebugMessages("Run User Join");
UUID uuid = event.getPlayer().getUniqueId();
Database.get(uuid).thenAccept(data -> {
if (data == null) return;
Bukkit.getScheduler().runTask(HMCCosmeticsPlugin.getInstance(), () -> {
CosmeticUser cosmeticUser = new CosmeticUser(uuid, data);
CosmeticUsers.addUser(cosmeticUser);
MessagesUtil.sendDebugMessages("Run User Join for " + uuid);
// And finally, launch an update for the cosmetics they have.
Bukkit.getScheduler().runTaskLater(HMCCosmeticsPlugin.getInstance(), () -> {
if (user.getPlayer() == null) return;
user.updateCosmetic();
if (cosmeticUser.getPlayer() == null) return;
cosmeticUser.updateCosmetic();
}, 4);
});
});
};
if (DatabaseSettings.isEnabledDelay()) {

View File

@@ -25,10 +25,13 @@ import com.hibiscusmc.hmccosmetics.user.CosmeticUsers;
import com.hibiscusmc.hmccosmetics.user.manager.UserEmoteManager;
import com.hibiscusmc.hmccosmetics.user.manager.UserWardrobeManager;
import com.hibiscusmc.hmccosmetics.util.HMCCInventoryUtils;
import com.hibiscusmc.hmccosmetics.util.HMCCServerUtils;
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
import com.hibiscusmc.hmccosmetics.util.packets.HMCCPacketManager;
import me.lojosho.hibiscuscommons.api.events.*;
import me.lojosho.hibiscuscommons.hooks.Hook;
import me.lojosho.hibiscuscommons.hooks.items.HookItemAdder;
import me.lojosho.hibiscuscommons.hooks.items.HookNexo;
import me.lojosho.hibiscuscommons.util.packets.PacketManager;
import org.bukkit.Bukkit;
import org.bukkit.Location;
@@ -66,6 +69,7 @@ public class PlayerGameListener implements Listener {
registerPlayerArmListener();
registerEntityUseListener();
registerSlotChangeListener();
registerPassengerSetListener();
//registerLookMovement();
//registerMoveListener();
@@ -379,6 +383,10 @@ public class PlayerGameListener implements Listener {
public void onPlayerCosmeticEquip(PlayerCosmeticPostEquipEvent event) {
CosmeticUser user = event.getUser();
if (user.isInWardrobe() && event.getCosmetic().getSlot().equals(CosmeticSlot.BALLOON)) {
if (user.getBalloonManager() == null) {
MessagesUtil.sendDebugMessages("Balloon Manager is null? " + user.getEntity().getName());
return;
}
CosmeticBalloonType cosmetic = (CosmeticBalloonType) event.getCosmetic();
Location npclocation = user.getWardrobeManager().getNpcLocation().clone().add(cosmetic.getBalloonOffset());
// We know that no other entity besides a regular player will be in the wardrobe
@@ -425,21 +433,6 @@ public class PlayerGameListener implements Listener {
user.showCosmetics(CosmeticUser.HiddenReason.PLUGIN);
}
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onHookReload(HibiscusHookReload event) {
if (event.getHook() instanceof HookItemAdder hook) {
switch (event.getReloadType()) {
case INITIAL -> {
HMCCosmeticsPlugin.setup();
}
case RELOAD -> {
if (!Settings.isItemsAdderChangeReload()) return;
HMCCosmeticsPlugin.setup();
}
}
}
}
// These emote mostly handles emotes from other plugins, such as ItemsAdder
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onPlayerPlayEmote(HibiscusPlayerEmotePlayEvent event) {
@@ -455,6 +448,22 @@ public class PlayerGameListener implements Listener {
user.showCosmetics(CosmeticUser.HiddenReason.EMOTE);
}
@EventHandler(priority = EventPriority.LOW)
public void onPlayerHibiscusPose(HibiscusPlayerPoseEvent event) {
if (event.isGettingUp()) return;
CosmeticUser user = CosmeticUsers.getUser(event.getPlayer());
if (user == null) return;
user.hideCosmetics(CosmeticUser.HiddenReason.PLUGIN);
}
@EventHandler(priority = EventPriority.LOW)
public void onPlayerHibiscusGetUpPose(HibiscusPlayerPoseEvent event) {
if (!event.isGettingUp()) return;
CosmeticUser user = CosmeticUsers.getUser(event.getPlayer());
if (user == null) return;
user.showCosmetics(CosmeticUser.HiddenReason.PLUGIN);
}
private void registerInventoryClickListener() {
ProtocolLibrary.getProtocolManager().addPacketListener(new PacketAdapter(HMCCosmeticsPlugin.getInstance(), ListenerPriority.NORMAL, PacketType.Play.Client.WINDOW_CLICK) {
@Override
@@ -585,6 +594,7 @@ public class PlayerGameListener implements Listener {
switch (pair.getFirst()) {
case MAINHAND -> {
if (user.getPlayer() == event.getPlayer()) continue; // When a player scrolls real fast, it messes up the mainhand. This fixes it
if (user.getPlayer() != null && user.getPlayer().isInvisible()) continue; // Fixes integration with GSit still showing mainhand even when hidden
armor.set(i, new Pair<>(pair.getFirst(), user.getPlayer().getInventory().getItemInMainHand()));
}
default -> {
@@ -630,6 +640,37 @@ public class PlayerGameListener implements Listener {
});
}
private void registerPassengerSetListener() {
ProtocolLibrary.getProtocolManager().addPacketListener(new PacketAdapter(HMCCosmeticsPlugin.getInstance(), ListenerPriority.NORMAL, PacketType.Play.Server.MOUNT) {
@Override
public void onPacketSending(PacketEvent event) {
CosmeticUser viewerUser = CosmeticUsers.getUser(event.getPlayer().getUniqueId());
if (viewerUser == null) return;
if (viewerUser.isInWardrobe()) return;
int ownerId = event.getPacket().getIntegers().read(0);
MessagesUtil.sendDebugMessages("Mount Packet Sent - Read - EntityID: " + ownerId);
Entity entity = HMCCServerUtils.getEntity(ownerId);
if (entity == null) return;
CosmeticUser user = CosmeticUsers.getUser(entity.getUniqueId());
if (user == null) return;
MessagesUtil.sendDebugMessages("Mount Packet Sent - " + user.getUniqueId());
if (!user.hasCosmeticInSlot(CosmeticSlot.BACKPACK)) return;
if (user.getUserBackpackManager() == null) return;
// Basically, take the original passengers and "bump" them to the end of the list
int[] originalPassengers = event.getPacket().getIntegerArrays().read(0);
List<Integer> passengers = new ArrayList<>(user.getUserBackpackManager().getEntityManager().getIds());
passengers.addAll(Arrays.stream(originalPassengers).boxed().toList());
event.getPacket().getIntegerArrays().write(0, passengers.stream().mapToInt(Integer::intValue).toArray());
}
});
}
private void registerPlayerArmListener() {
ProtocolLibrary.getProtocolManager().addPacketListener(new PacketAdapter(HMCCosmeticsPlugin.getInstance(), ListenerPriority.NORMAL, PacketType.Play.Client.ARM_ANIMATION) {
@Override
@@ -719,10 +760,6 @@ public class PlayerGameListener implements Listener {
});
}
@Nullable
private EquipmentSlot getArmorSlot(final Material material) {
for (final EquipmentSlot slot : EquipmentSlot.values()) {

View File

@@ -0,0 +1,41 @@
package com.hibiscusmc.hmccosmetics.listener;
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
import com.hibiscusmc.hmccosmetics.config.Settings;
import me.lojosho.hibiscuscommons.api.events.HibiscusHookReload;
import me.lojosho.hibiscuscommons.hooks.Hook;
import me.lojosho.hibiscuscommons.hooks.items.HookItemAdder;
import me.lojosho.hibiscuscommons.hooks.items.HookNexo;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
public class ServerListener implements Listener {
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onHookReload(HibiscusHookReload event) {
Hook hook = event.getHook();
if (hook instanceof HookItemAdder) {
switch (event.getReloadType()) {
case INITIAL -> {
HMCCosmeticsPlugin.setup();
}
case RELOAD -> {
if (!Settings.isItemsAdderChangeReload()) return;
HMCCosmeticsPlugin.setup();
}
}
}
if (hook instanceof HookNexo) {
switch (event.getReloadType()) {
case INITIAL -> {
HMCCosmeticsPlugin.setup();
}
case RELOAD -> {
if (!Settings.isNexoChangeReload()) return;
HMCCosmeticsPlugin.setup();
}
}
}
}
}

View File

@@ -13,6 +13,7 @@ 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;
import com.hibiscusmc.hmccosmetics.user.manager.UserBalloonManager;
@@ -38,6 +39,7 @@ import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.*;
import org.bukkit.persistence.PersistentDataType;
import org.bukkit.scheduler.BukkitTask;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.*;
@@ -58,8 +60,9 @@ public class CosmeticUser {
// Cosmetic Settings/Toggles
private final ArrayList<HiddenReason> hiddenReason = new ArrayList<>();
private final HashMap<CosmeticSlot, ItemStack> cachedCosmeticItems = new HashMap<>();
private final HashMap<CosmeticSlot, Color> colors = new HashMap<>();
// Cosmetic caches
private final HashMap<String, ItemStack> cosmeticItems = new HashMap<>();
public CosmeticUser(UUID uuid) {
this.uniqueId = uuid;
@@ -67,6 +70,13 @@ public class CosmeticUser {
tick();
}
public CosmeticUser(UUID uuid, UserData data) {
this.uniqueId = uuid;
userEmoteManager = new UserEmoteManager(this);
loadData(data);
tick();
}
private void tick() {
// Occasionally updates the entity cosmetics
Runnable run = () -> {
@@ -88,6 +98,54 @@ public class CosmeticUser {
despawnBalloon();
}
public void loadData(@NotNull UserData data) {
boolean permissionCheck = Settings.isForcePermissionJoin();
for (Map.Entry<CosmeticSlot, Map.Entry<Cosmetic, Integer>> entry : data.getCosmetics().entrySet()) {
Cosmetic cosmetic = entry.getValue().getKey();
Color color = entry.getValue().getValue() == -1 ? null : Color.fromRGB(entry.getValue().getValue());
if (permissionCheck && cosmetic.requiresPermission()) {
if (getPlayer() != null && !getPlayer().hasPermission(cosmetic.getPermission())) {
continue;
}
}
addPlayerCosmetic(cosmetic, color);
}
if (!hiddenReason.isEmpty()) {
for (CosmeticUser.HiddenReason reason : hiddenReason) silentlyAddHideFlag(reason);
} else {
for (HiddenReason reason : data.getHiddenReasons()) {
if (getPlayer() != null && Settings.isDisabledGamemodesEnabled() && Settings.getDisabledGamemodes().contains(getPlayer().getGameMode().toString())) {
MessagesUtil.sendDebugMessages("Hiding Cosmetics due to gamemode");
hideCosmetics(CosmeticUser.HiddenReason.GAMEMODE);
return;
} else {
if (isHidden(CosmeticUser.HiddenReason.GAMEMODE)) {
MessagesUtil.sendDebugMessages("Join Gamemode Check: Showing Cosmetics");
showCosmetics(CosmeticUser.HiddenReason.GAMEMODE);
return;
}
}
// Handle world check
if (getPlayer() != null && Settings.getDisabledWorlds().contains(getPlayer().getWorld().getName())) {
MessagesUtil.sendDebugMessages("Hiding Cosmetics due to world");
hideCosmetics(CosmeticUser.HiddenReason.WORLD);
} else {
if (isHidden(CosmeticUser.HiddenReason.WORLD)) {
MessagesUtil.sendDebugMessages("Join World Check: Showing Cosmetics");
showCosmetics(CosmeticUser.HiddenReason.WORLD);
}
}
if (Settings.isAllPlayersHidden()) {
hideCosmetics(CosmeticUser.HiddenReason.DISABLED);
}
silentlyAddHideFlag(reason);
}
}
}
public Cosmetic getCosmetic(CosmeticSlot slot) {
return playerCosmetics.get(slot);
}
@@ -96,11 +154,11 @@ public class CosmeticUser {
return ImmutableList.copyOf(playerCosmetics.values());
}
public void addPlayerCosmetic(Cosmetic cosmetic) {
public void addPlayerCosmetic(@NotNull Cosmetic cosmetic) {
addPlayerCosmetic(cosmetic, null);
}
public void addPlayerCosmetic(Cosmetic cosmetic, Color color) {
public void addPlayerCosmetic(@NotNull Cosmetic cosmetic, @Nullable Color color) {
// API
PlayerCosmeticEquipEvent event = new PlayerCosmeticEquipEvent(this, cosmetic);
Bukkit.getPluginManager().callEvent(event);
@@ -157,7 +215,6 @@ public class CosmeticUser {
if (slot == CosmeticSlot.EMOTE) {
if (getUserEmoteManager().isPlayingEmote()) getUserEmoteManager().stopEmote(UserEmoteManager.StopEmoteReason.UNEQUIP);
}
cachedCosmeticItems.remove(slot);
colors.remove(slot);
playerCosmetics.remove(slot);
removeArmor(slot);
@@ -223,16 +280,12 @@ public class CosmeticUser {
return getUserCosmeticItem(cosmetic);
}
public ItemStack getUserCosmeticItem(Cosmetic cosmetic) {
public ItemStack getUserCosmeticItem(@NotNull Cosmetic cosmetic) {
ItemStack item = null;
if (!hiddenReason.isEmpty()) {
if (cosmetic instanceof CosmeticBackpackType || cosmetic instanceof CosmeticBalloonType) return new ItemStack(Material.AIR);
return getPlayer().getInventory().getItem(HMCCInventoryUtils.getEquipmentSlot(cosmetic.getSlot()));
}
// Check if the item is cached. This helps with performance as we don't need to keep recreating the item
if (cachedCosmeticItems.containsKey(cosmetic.getSlot())) {
return cachedCosmeticItems.get(cosmetic.getSlot());
}
if (cosmetic instanceof CosmeticArmorType armorType) {
item = armorType.getItem(this, cosmetic.getItem());
}
@@ -250,15 +303,11 @@ public class CosmeticUser {
}
@SuppressWarnings("deprecation")
public ItemStack getUserCosmeticItem(Cosmetic cosmetic, ItemStack item) {
public ItemStack getUserCosmeticItem(@NotNull Cosmetic cosmetic, @Nullable ItemStack item) {
if (item == null) {
//MessagesUtil.sendDebugMessages("GetUserCosemticUser Item is null");
return new ItemStack(Material.AIR);
}
// Check if the item is cached. This helps with performance as we don't need to keep recreating the item
if (cachedCosmeticItems.containsKey(cosmetic.getSlot())) {
return cachedCosmeticItems.get(cosmetic.getSlot());
}
if (item.hasItemMeta()) {
ItemMeta itemMeta = item.getItemMeta();
@@ -285,18 +334,22 @@ public class CosmeticUser {
itemMeta = skullMeta;
}
if (Settings.isItemProcessingDisplayName()) {
if (itemMeta.hasDisplayName()) {
String displayName = itemMeta.getDisplayName();
itemMeta.setDisplayName(Hooks.processPlaceholders(getPlayer(), displayName));
}
}
if (Settings.isItemProcessingLore()) {
List<String> processedLore = new ArrayList<>();
if (itemMeta.hasLore()) {
for (String loreLine : itemMeta.getLore()) {
processedLore.add(Hooks.processPlaceholders(getPlayer(), loreLine));
}
}
if (itemMeta.hasDisplayName()) {
String displayName = itemMeta.getDisplayName();
itemMeta.setDisplayName(Hooks.processPlaceholders(getPlayer(), displayName));
}
itemMeta.setLore(processedLore);
}
if (colors.containsKey(cosmetic.getSlot())) {
Color color = colors.get(cosmetic.getSlot());
@@ -322,7 +375,6 @@ public class CosmeticUser {
item.setItemMeta(itemMeta);
}
cachedCosmeticItems.put(cosmetic.getSlot(), item);
return item;
}
@@ -334,7 +386,7 @@ public class CosmeticUser {
return userWardrobeManager;
}
public void enterWardrobe(boolean ignoreDistance, Wardrobe wardrobe) {
public void enterWardrobe(boolean ignoreDistance, @NotNull Wardrobe wardrobe) {
if (wardrobe.hasPermission() && !getPlayer().hasPermission(wardrobe.getPermission())) {
MessagesUtil.sendMessage(getPlayer(), "no-permission");
return;
@@ -435,10 +487,6 @@ public class CosmeticUser {
public void despawnBalloon() {
if (this.userBalloonManager == null) return;
List<Player> sentTo = HMCCPlayerUtils.getNearbyPlayers(getEntity().getLocation());
HMCCPacketManager.sendEntityDestroyPacket(userBalloonManager.getPufferfishBalloonId(), sentTo);
this.userBalloonManager.remove();
this.userBalloonManager = null;
}

View File

@@ -1,6 +1,5 @@
package com.hibiscusmc.hmccosmetics.user.manager;
import com.hibiscusmc.hmccosmetics.config.Settings;
import com.hibiscusmc.hmccosmetics.cosmetic.CosmeticSlot;
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticBackpackType;
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
@@ -8,12 +7,10 @@ import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
import com.hibiscusmc.hmccosmetics.util.packets.HMCCPacketManager;
import com.ticxo.modelengine.api.ModelEngineAPI;
import lombok.Getter;
import lombok.Setter;
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.block.Block;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
@@ -36,13 +33,10 @@ public class UserBackpackManager {
private final CosmeticUser user;
@Getter
private UserEntity entityManager;
@Getter @Setter
private boolean inBlock;
public UserBackpackManager(CosmeticUser user) {
this.user = user;
this.backpackHidden = false;
this.inBlock = false;
this.invisibleArmorStand = ServerUtils.getNextEntityId();
this.entityManager = new UserEntity(user.getUniqueId());
if (user.getEntity() != null) this.entityManager.refreshViewers(user.getEntity().getLocation()); // Fixes an issue where a player, who somehow removes their potions, but doesn't have an entity produces an NPE (it's dumb)
@@ -63,17 +57,7 @@ public class UserBackpackManager {
getEntityManager().teleport(user.getEntity().getLocation());
List<Player> outsideViewers = getEntityManager().getViewers();
HMCCPacketManager.sendEntitySpawnPacket(user.getEntity().getLocation(), getFirstArmorStandId(), EntityType.ARMOR_STAND, UUID.randomUUID(), getEntityManager().getViewers());
if (Settings.isBackpackBlockDetection()) {
if (checkBlock()) {
setInBlock(true);
HMCCPacketManager.sendArmorstandMetadata(getFirstArmorStandId(), isInBlock(), outsideViewers);
} else {
HMCCPacketManager.sendArmorstandMetadata(getFirstArmorStandId(), isInBlock(), outsideViewers);
}
//refreshBlock(outsideViewers);
} else {
HMCCPacketManager.sendArmorstandMetadata(getFirstArmorStandId(), Settings.isBackpackLightEmination(), outsideViewers);
}
HMCCPacketManager.sendArmorstandMetadata(getFirstArmorStandId(), outsideViewers);
Entity entity = user.getEntity();
@@ -163,33 +147,4 @@ public class UserBackpackManager {
ItemStack item = new ItemStack(Material.AIR);
PacketManager.equipmentSlotUpdate(getFirstArmorStandId(), EquipmentSlot.HEAD, item, getEntityManager().getViewers());
}
/**
* Refreshes the block detection for the backpack
* @param outsideViewers
* @return true if the entity was updated, false if not
*/
public boolean refreshBlock(List<Player> outsideViewers) {
if (Settings.isBackpackBlockDetection()) {
if (isInBlock() && checkBlock()) {
HMCCPacketManager.sendArmorstandMetadata(getFirstArmorStandId(), false, outsideViewers);
setInBlock(false);
return true;
}
if (!isInBlock() && !checkBlock()) {
HMCCPacketManager.sendArmorstandMetadata(getFirstArmorStandId(), true, outsideViewers);
setInBlock(true);
return true;
}
}
return false;
}
public boolean checkBlock() {
if (Settings.isBackpackBlockDetection()) {
Block block = getEntityManager().getLocation().clone().add(0, 1.5, 0).getBlock();
return block.getType().isAir();
}
return false;
}
}

View File

@@ -11,6 +11,7 @@ import com.ticxo.modelengine.api.ModelEngineAPI;
import com.ticxo.modelengine.api.entity.data.BukkitEntityData;
import com.ticxo.modelengine.api.model.ActiveModel;
import com.ticxo.modelengine.api.model.ModeledEntity;
import com.ticxo.modelengine.api.nms.RenderParsers;
import lombok.Getter;
import me.lojosho.hibiscuscommons.hooks.Hooks;
import me.lojosho.hibiscuscommons.nms.NMSHandlers;
@@ -30,16 +31,17 @@ import java.util.logging.Level;
public class UserBalloonManager {
private CosmeticUser user;
private final CosmeticUser user;
@Getter
private BalloonType balloonType;
private CosmeticBalloonType cosmeticBalloonType;
@Getter
private UserBalloonPufferfish pufferfish;
private final ArmorStand modelEntity;
public UserBalloonManager(CosmeticUser user, @NotNull Location location) {
this.user = user;
this.pufferfish = new UserBalloonPufferfish(user.getUniqueId(), NMSHandlers.getHandler().getNextEntityId(), UUID.randomUUID());
this.pufferfish = new UserBalloonPufferfish(user.getUniqueId(), NMSHandlers.getHandler().getUtilHandler().getNextEntityId(), UUID.randomUUID());
this.modelEntity = location.getWorld().spawn(location, ArmorStand.class, (e) -> {
e.setInvisible(true);
e.setGravity(false);
@@ -82,7 +84,7 @@ public class UserBalloonManager {
modeledEntity.getModels().forEach((d, singleModel) -> {
if (cosmeticBalloonType.isDyablePart(d)) {
singleModel.setDefaultTint(color);
singleModel.getModelRenderer().sendToClient();
singleModel.getModelRenderer().sendToClient(ModelEngineAPI.getNMSHandler().createParsers());
}
});
}
@@ -98,6 +100,7 @@ public class UserBalloonManager {
}
public void remove() {
pufferfish.destroyPufferfish();
if (balloonType == BalloonType.MODELENGINE) {
final ModeledEntity entity = ModelEngineAPI.getModeledEntity(modelEntity);
if (entity == null) {
@@ -156,6 +159,7 @@ public class UserBalloonManager {
public int getPufferfishBalloonId() {
return pufferfish.getPufferFishEntityId();
}
public UUID getPufferfishBalloonUniqueId() {
return pufferfish.getUuid();
}

View File

@@ -3,7 +3,10 @@ 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.util.packets.HMCCPacketManager;
import lombok.Getter;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
@@ -14,8 +17,11 @@ import java.util.UUID;
public class UserBalloonPufferfish extends UserEntity {
private int pufferFishEntityId;
private UUID uuid;
@Getter
private final int pufferFishEntityId;
@Getter
private final UUID uuid;
private boolean destroyed = false;
public UserBalloonPufferfish(UUID owner, int pufferFishEntityId, UUID uuid) {
super(owner);
@@ -23,14 +29,6 @@ public class UserBalloonPufferfish extends UserEntity {
this.uuid = uuid;
}
public int getPufferFishEntityId() {
return pufferFishEntityId;
}
public UUID getUuid() {
return uuid;
}
public void hidePufferfish() {
HMCCPacketManager.sendEntityDestroyPacket(pufferFishEntityId, getViewers());
getViewers().clear();
@@ -41,35 +39,15 @@ public class UserBalloonPufferfish extends UserEntity {
HMCCPacketManager.sendInvisibilityPacket(pufferFishEntityId, sendTo);
}
public void destroyPufferfish() {
HMCCPacketManager.sendEntityDestroyPacket(pufferFishEntityId, getViewers());
getViewers().clear();
destroyed = true;
}
@Override
public List<Player> refreshViewers(Location location) {
if (System.currentTimeMillis() - getViewerLastUpdate() <= 1000) return List.of(); //Prevents mass refreshes
ArrayList<Player> newPlayers = new ArrayList<>();
ArrayList<Player> removePlayers = new ArrayList<>();
List<Player> players = HMCCPlayerUtils.getNearbyPlayers(location);
for (Player player : players) {
CosmeticUser user = CosmeticUsers.getUser(player);
if (user != null && getOwner() != user.getUniqueId() && user.isInWardrobe()) { // Fixes issue where players in wardrobe would see other players cosmetics if they were not in wardrobe
removePlayers.add(player);
HMCCPacketManager.sendEntityDestroyPacket(getPufferFishEntityId(), List.of(player));
continue;
}
if (!getViewers().contains(player)) {
getViewers().add(player);
newPlayers.add(player);
continue;
}
// bad loopdy loops
for (Player viewerPlayer : getViewers()) {
if (!players.contains(viewerPlayer)) {
removePlayers.add(viewerPlayer);
HMCCPacketManager.sendEntityDestroyPacket(getPufferFishEntityId(), List.of(viewerPlayer));
}
}
}
getViewers().removeAll(removePlayers);
setViewerLastUpdate(System.currentTimeMillis());
return newPlayers;
if (destroyed) return List.of(); //Prevents refreshing a destroyed entity
return super.refreshViewers(location);
}
}

View File

@@ -4,9 +4,11 @@ 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;
import lombok.Setter;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.entity.Player;
@@ -42,10 +44,15 @@ public class UserEntity {
ArrayList<Player> newPlayers = new ArrayList<>();
ArrayList<Player> removePlayers = new ArrayList<>();
List<Player> players = HMCCPlayerUtils.getNearbyPlayers(location);
Player ownerPlayer = Bukkit.getPlayer(owner);
if (ownerPlayer == null) {
MessagesUtil.sendDebugMessages("Owner is null (refreshViewers), returning empty list");
return List.of();
}
for (Player player : players) {
CosmeticUser user = CosmeticUsers.getUser(player);
if (user != null && owner != user.getUniqueId() && user.isInWardrobe()) { // Fixes issue where players in wardrobe would see other players cosmetics if they were not in wardrobe
if (user != null && owner != user.getUniqueId() && user.isInWardrobe() && !player.canSee(ownerPlayer)) { // Fixes issue where players in wardrobe would see other players cosmetics if they were not in wardrobe
removePlayers.add(player);
HMCCPacketManager.sendEntityDestroyPacket(ids, List.of(player));
continue;

View File

@@ -83,8 +83,11 @@ public class UserWardrobeManager {
this.viewingLocation = wardrobeLocation.getViewerLocation();
this.npcLocation = wardrobeLocation.getNpcLocation();
String defaultMenu = wardrobe.getDefaultMenu();
if (defaultMenu != null && Menus.hasMenu(defaultMenu)) this.lastOpenMenu = Menus.getMenu(defaultMenu);
else this.lastOpenMenu = Menus.getDefaultMenu();
wardrobeStatus = WardrobeStatus.SETUP;
this.lastOpenMenu = Menus.getDefaultMenu();
}
public void start() {
@@ -129,7 +132,7 @@ public class UserWardrobeManager {
HMCCPacketManager.sendFakePlayerSpawnPacket(npcLocation, WARDROBE_UUID, NPC_ID, viewer);
HMCCPacketManager.sendPlayerOverlayPacket(NPC_ID, viewer);
MessagesUtil.sendDebugMessages("Spawned Fake Player on " + npcLocation);
NMSHandlers.getHandler().hideNPCName(player, npcName);
NMSHandlers.getHandler().getPacketHandler().sendScoreboardHideNamePacket(player, npcName);
}, 4);
// Location

View File

@@ -63,6 +63,7 @@ public class HMCCInventoryUtils {
case FEET -> CosmeticSlot.BOOTS;
case OFFHAND -> CosmeticSlot.OFFHAND;
case MAINHAND -> CosmeticSlot.MAINHAND;
default -> null;
};
}

View File

@@ -33,7 +33,7 @@ public class HMCCServerUtils {
}
public static org.bukkit.entity.Entity getEntity(int entityId) {
return NMSHandlers.getHandler().getEntity(entityId);
return NMSHandlers.getHandler().getUtilHandler().getEntity(entityId);
}
/**

View File

@@ -100,26 +100,13 @@ public class HMCCPacketManager extends PacketManager {
int entityId,
List<Player> sendTo
) {
sendArmorstandMetadata(entityId, false, sendTo);
}
public static void sendArmorstandMetadata(
int entityId,
boolean onFire,
List<Player> sendTo
) {
byte mask = 0x20;
if (onFire) {
// 0x21 = Invisible + Fire (Aka, burns to make it not take the light of the block its in, avoiding turning it black)
mask = 0x21;
}
PacketContainer packet = new PacketContainer(PacketType.Play.Server.ENTITY_METADATA);
packet.getModifier().writeDefaults();
packet.getIntegers().write(0, entityId);
final List<WrappedDataValue> wrappedDataValueList = Lists.newArrayList();
wrappedDataValueList.add(new WrappedDataValue(0, WrappedDataWatcher.Registry.get(Byte.class), mask));
// 0x21 = Invisible + Fire (Aka, burns to make it not take the light of the block its in, avoiding turning it black)
wrappedDataValueList.add(new WrappedDataValue(0, WrappedDataWatcher.Registry.get(Byte.class), (byte) 0x21));
wrappedDataValueList.add(new WrappedDataValue(15, WrappedDataWatcher.Registry.get(Byte.class), (byte) 0x10));
packet.getDataValueCollectionModifier().write(0, wrappedDataValueList);
for (Player p : sendTo) sendPacket(p, packet);

View File

@@ -24,6 +24,12 @@ cosmetic-settings:
force-permission-join: true # Checks a player permission if they can have a cosmetic when they join the server.
force-show-join: false # If the plugin should force show a player's cosmetics when they join the server.
# This determines what to process what areas to process placeholders when displaying the item to the user.
# This can be heavy on servers with a lot of players, so if experiencing lag issues relating to setting display/lores of items, disable this.
item-processing:
display-name: true
lore: true
# This is a list of worlds that cosmetics are hidden in. When a player enters one of these worlds, their cosmetics will be hidden.
disabled-worlds:
- "disabledworld"
@@ -45,17 +51,8 @@ cosmetic-settings:
emote-camera: true
# If a player should be able to move in an emote. This option really only affects if "emote-camera" is false
emote-move: false
# 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
# This makes the plugin either (true) always have the backpack eminate light to avoid the black backpack bug or (false) turns it off.
backpack-light-emination: true
# This activates the block detection for the backpack. This allows backpacks to not appear completely black when in a block.
# Requires backpack-light-emination to be true.
backpack-block-detection: 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 is useful for servers with a lot of backpacks, as they are passengers, which means the client will update their position automatically within an area where the entity is located.
entity-cooldown-teleport-packet: 500
@@ -132,6 +129,9 @@ hook-settings:
# This causes the plugin to reload itself after any ItemsAdder change. This keeps the plugin fully up to date with IA, but
# could cause console spam as HMCCosmetics has to reload itself as well.
reload-on-change: false
nexo:
# This causes the plugin to reload itself after any Nexo change. This keeps the plugin fully up to date with Nexo
reload-on-change: true
worldguard:
# Checks worldguard regions for HMCC flags. If set to false, flags will not work properly.
# Requires restart to apply changes.
@@ -177,6 +177,7 @@ wardrobe:
default:
distance: -1 # Distance in blocks that a player can interact with the wardrobe. -1 to ignore.
permission: "hmccosmetics.wardrobe.default" # Permission required to use the wardrobe.
default-menu: defaultmenu
npc-location:
world: "world"
x: 0

Binary file not shown.

View File

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

51
gradlew vendored
View File

@@ -1,7 +1,7 @@
#!/bin/sh
#
# Copyright <EFBFBD> 2015-2021 the original authors.
# Copyright © 2015-2021 the original authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -32,10 +32,10 @@
# Busybox and similar reduced shells will NOT work, because this script
# requires all of these POSIX shell features:
# * functions;
# * expansions <EFBFBD>$var<EFBFBD>, <EFBFBD>${var}<EFBFBD>, <EFBFBD>${var:-default}<EFBFBD>, <EFBFBD>${var+SET}<EFBFBD>,
# <EFBFBD>${var#prefix}<EFBFBD>, <EFBFBD>${var%suffix}<EFBFBD>, and <EFBFBD>$( cmd )<EFBFBD>;
# * compound commands having a testable exit status, especially <EFBFBD>case<EFBFBD>;
# * various built-in commands including <EFBFBD>command<EFBFBD>, <EFBFBD>set<EFBFBD>, and <EFBFBD>ulimit<EFBFBD>.
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
# * compound commands having a testable exit status, especially «case»;
# * various built-in commands including «command», «set», and «ulimit».
#
# Important for patching:
#
@@ -55,7 +55,7 @@
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#
# You can find Gradle at https://github.com/gradle/gradle/.
@@ -80,13 +80,11 @@ do
esac
done
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
APP_NAME="Gradle"
# This is normally unused
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
@@ -133,22 +131,29 @@ location of your Java installation."
fi
else
JAVACMD=java
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
if ! command -v java >/dev/null 2>&1
then
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
fi
# Increase the maximum file descriptors if we can.
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
case $MAX_FD in #(
max*)
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC2039,SC3045
MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit"
esac
case $MAX_FD in #(
'' | soft) :;; #(
*)
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC2039,SC3045
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
@@ -193,11 +198,15 @@ if "$cygwin" || "$msys" ; then
done
fi
# Collect all arguments for the java command;
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
# shell script including quotes and variable substitutions, so put them in
# double quotes to make sure that they get re-expanded; and
# * put everything else in single quotes, so that it's not re-expanded.
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Collect all arguments for the java command:
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
# and any embedded shellness will be escaped.
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
# treated as '${Hostname}' itself on the command line.
set -- \
"-Dorg.gradle.appname=$APP_BASE_NAME" \
@@ -205,6 +214,12 @@ set -- \
org.gradle.wrapper.GradleWrapperMain \
"$@"
# Stop when "xargs" is not available.
if ! command -v xargs >/dev/null 2>&1
then
die "xargs is not available"
fi
# Use "xargs" to parse quoted args.
#
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.

15
gradlew.bat vendored
View File

@@ -14,7 +14,7 @@
@rem limitations under the License.
@rem
@if "%DEBUG%" == "" @echo off
@if "%DEBUG%"=="" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@@ -25,7 +25,8 @@
if "%OS%"=="Windows_NT" setlocal
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
if "%DIRNAME%"=="" set DIRNAME=.
@rem This is normally unused
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@@ -40,7 +41,7 @@ if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto execute
if %ERRORLEVEL% equ 0 goto execute
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
@@ -75,13 +76,15 @@ set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd
if %ERRORLEVEL% equ 0 goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1
set EXIT_CODE=%ERRORLEVEL%
if %EXIT_CODE% equ 0 set EXIT_CODE=1
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
exit /b %EXIT_CODE%
:mainEnd
if "%OS%"=="Windows_NT" endlocal