mirror of
https://github.com/HibiscusMC/HMCCosmetics.git
synced 2025-12-20 07:29:15 +00:00
Compare commits
38 Commits
display-en
...
v2.7.4
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1ef2c6b631 | ||
|
|
c7667b2dc2 | ||
|
|
e4c4933d46 | ||
|
|
1f94192772 | ||
|
|
8ebcea5465 | ||
|
|
4c7ccc06ca | ||
|
|
667f58ff4b | ||
|
|
69d318c4b0 | ||
|
|
0414f3be90 | ||
|
|
402203b4c2 | ||
|
|
6dcaf06ebe | ||
|
|
1b6adca00e | ||
|
|
0dce5822e3 | ||
|
|
0f1b75f09e | ||
|
|
19192c46a5 | ||
|
|
62a9e7d1ac | ||
|
|
06077201f9 | ||
|
|
b2795a705e | ||
|
|
1e6734bf6f | ||
|
|
ad382e5d9e | ||
|
|
6458a1e316 | ||
|
|
279d6edc34 | ||
|
|
439dc85aa3 | ||
|
|
60e23411dc | ||
|
|
33fb680c22 | ||
|
|
536b7ebdec | ||
|
|
5da95f2f5b | ||
|
|
30f4a84241 | ||
|
|
f34e126c85 | ||
|
|
d7d0f27e49 | ||
|
|
f42937a6d0 | ||
|
|
c8b7430998 | ||
|
|
42de76d84d | ||
|
|
5102fd77b7 | ||
|
|
9c66d4ee81 | ||
|
|
7ade2d9227 | ||
|
|
7b43b42740 | ||
|
|
25f050f387 |
@@ -2,13 +2,13 @@ import net.minecrell.pluginyml.bukkit.BukkitPluginDescription
|
|||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
id("java")
|
id("java")
|
||||||
id("com.github.johnrengelman.shadow") version "8.1.1"
|
id("com.gradleup.shadow") version "8.3.2"
|
||||||
id("xyz.jpenilla.run-paper") version "2.0.0"
|
id("xyz.jpenilla.run-paper") version "2.3.1"
|
||||||
id("net.minecrell.plugin-yml.bukkit") version "0.6.0"
|
id("net.minecrell.plugin-yml.bukkit") version "0.6.0"
|
||||||
}
|
}
|
||||||
|
|
||||||
group = "com.hibiscusmc"
|
group = "com.hibiscusmc"
|
||||||
version = "2.7.3-DEV"
|
version = "2.7.4${getGitCommitHash()}"
|
||||||
|
|
||||||
allprojects {
|
allprojects {
|
||||||
apply(plugin = "java")
|
apply(plugin = "java")
|
||||||
@@ -49,9 +49,6 @@ allprojects {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// UpdateChecker
|
|
||||||
maven("https://hub.jeff-media.com/nexus/repository/jeff-media-public/")
|
|
||||||
|
|
||||||
// ParticleHelper
|
// ParticleHelper
|
||||||
maven("https://repo.bytecode.space/repository/maven-public/")
|
maven("https://repo.bytecode.space/repository/maven-public/")
|
||||||
|
|
||||||
@@ -75,15 +72,15 @@ allprojects {
|
|||||||
compileOnly(fileTree("${project.rootDir}/lib") { include("*.jar") })
|
compileOnly(fileTree("${project.rootDir}/lib") { include("*.jar") })
|
||||||
compileOnly("com.mojang:authlib:1.5.25")
|
compileOnly("com.mojang:authlib:1.5.25")
|
||||||
//compileOnly("org.spigotmc:spigot-api:1.18.2-R0.1-SNAPSHOT")
|
//compileOnly("org.spigotmc:spigot-api:1.18.2-R0.1-SNAPSHOT")
|
||||||
compileOnly("io.papermc.paper:paper-api:1.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("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("me.clip:placeholderapi:2.11.6")
|
||||||
compileOnly("com.ticxo.modelengine:ModelEngine:R4.0.2")
|
compileOnly("com.ticxo.modelengine:ModelEngine:R4.0.6")
|
||||||
compileOnly("com.sk89q.worldguard:worldguard-bukkit:7.1.0-SNAPSHOT")
|
compileOnly("com.sk89q.worldguard:worldguard-bukkit:7.0.12")
|
||||||
compileOnly("it.unimi.dsi:fastutil:8.5.13")
|
//compileOnly("it.unimi.dsi:fastutil:8.5.14")
|
||||||
compileOnly("org.projectlombok:lombok:1.18.34")
|
compileOnly("org.projectlombok:lombok:1.18.34")
|
||||||
compileOnly("me.lojosho:HibiscusCommons:0.4.1")
|
compileOnly("me.lojosho:HibiscusCommons:0.5.1")
|
||||||
|
|
||||||
// Handled by Spigot Library Loader
|
// Handled by Spigot Library Loader
|
||||||
compileOnly("net.kyori:adventure-api:4.17.0")
|
compileOnly("net.kyori:adventure-api:4.17.0")
|
||||||
@@ -123,15 +120,21 @@ tasks {
|
|||||||
}
|
}
|
||||||
|
|
||||||
runServer {
|
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 {
|
shadowJar {
|
||||||
mergeServiceFiles()
|
mergeServiceFiles()
|
||||||
|
|
||||||
relocate("dev.triumphteam.gui", "com.hisbiscusmc.hmccosmetics.gui")
|
relocate("dev.triumphteam.gui", "com.hibiscusmc.hmccosmetics.shaded.gui")
|
||||||
relocate("com.owen1212055.particlehelper", "com.hisbiscusmc.hmccosmetics.particlehelper")
|
relocate("com.owen1212055.particlehelper", "com.hibiscusmc.hmccosmetics.shaded.particlehelper")
|
||||||
relocate("com.ticxo.playeranimator", "com.hisbiscusmc.hmccosmetics.playeranimator")
|
relocate("com.ticxo.playeranimator", "com.hibiscusmc.hmccosmetics.shaded.playeranimator")
|
||||||
archiveFileName.set("HMCCosmeticsRemapped-${project.version}.jar")
|
archiveFileName.set("HMCCosmeticsRemapped-${project.version}.jar")
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
@@ -156,7 +159,7 @@ tasks {
|
|||||||
bukkit {
|
bukkit {
|
||||||
load = BukkitPluginDescription.PluginLoadOrder.POSTWORLD
|
load = BukkitPluginDescription.PluginLoadOrder.POSTWORLD
|
||||||
main = "com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin"
|
main = "com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin"
|
||||||
apiVersion = "1.19"
|
apiVersion = "1.20"
|
||||||
authors = listOf("LoJoSho")
|
authors = listOf("LoJoSho")
|
||||||
depend = listOf("HibiscusCommons", "ProtocolLib")
|
depend = listOf("HibiscusCommons", "ProtocolLib")
|
||||||
softDepend = listOf("ModelEngine", "Oraxen", "ItemsAdder", "Geary", "HMCColor", "WorldGuard", "MythicMobs", "PlaceholderAPI", "SuperVanish", "PremiumVanish", "LibsDisguises", "Denizen", "MMOItems", "Eco")
|
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
|
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 ""
|
||||||
|
}
|
||||||
@@ -4,7 +4,7 @@ plugins {
|
|||||||
}
|
}
|
||||||
|
|
||||||
java {
|
java {
|
||||||
toolchain.languageVersion.set(JavaLanguageVersion.of(17
|
toolchain.languageVersion.set(JavaLanguageVersion.of(21
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ import com.hibiscusmc.hmccosmetics.hooks.worldguard.WGListener;
|
|||||||
import com.hibiscusmc.hmccosmetics.listener.PaperPlayerGameListener;
|
import com.hibiscusmc.hmccosmetics.listener.PaperPlayerGameListener;
|
||||||
import com.hibiscusmc.hmccosmetics.listener.PlayerConnectionListener;
|
import com.hibiscusmc.hmccosmetics.listener.PlayerConnectionListener;
|
||||||
import com.hibiscusmc.hmccosmetics.listener.PlayerGameListener;
|
import com.hibiscusmc.hmccosmetics.listener.PlayerGameListener;
|
||||||
|
import com.hibiscusmc.hmccosmetics.listener.ServerListener;
|
||||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUsers;
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUsers;
|
||||||
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||||
@@ -94,6 +95,7 @@ public final class HMCCosmeticsPlugin extends HibiscusPlugin {
|
|||||||
// Listener
|
// Listener
|
||||||
getServer().getPluginManager().registerEvents(new PlayerConnectionListener(), this);
|
getServer().getPluginManager().registerEvents(new PlayerConnectionListener(), this);
|
||||||
getServer().getPluginManager().registerEvents(new PlayerGameListener(), this);
|
getServer().getPluginManager().registerEvents(new PlayerGameListener(), this);
|
||||||
|
getServer().getPluginManager().registerEvents(new ServerListener(), this);
|
||||||
// Taken from PaperLib
|
// Taken from PaperLib
|
||||||
if (HibiscusCommonsPlugin.isOnPaper()) {
|
if (HibiscusCommonsPlugin.isOnPaper()) {
|
||||||
getServer().getPluginManager().registerEvents(new PaperPlayerGameListener(), this);
|
getServer().getPluginManager().registerEvents(new PaperPlayerGameListener(), this);
|
||||||
|
|||||||
@@ -43,10 +43,14 @@ public class CosmeticCommand implements CommandExecutor {
|
|||||||
@Override
|
@Override
|
||||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String @NotNull [] args) {
|
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String @NotNull [] args) {
|
||||||
boolean silent = false;
|
boolean silent = false;
|
||||||
|
boolean console = false;
|
||||||
|
|
||||||
|
if (!(sender instanceof Player)) {
|
||||||
|
console = true;
|
||||||
|
}
|
||||||
|
|
||||||
if (args.length == 0) {
|
if (args.length == 0) {
|
||||||
if (!(sender instanceof Player)) {
|
if (console) {
|
||||||
// Console
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (!sender.hasPermission("hmccosmetics.cmd.default")) {
|
if (!sender.hasPermission("hmccosmetics.cmd.default")) {
|
||||||
@@ -140,7 +144,7 @@ public class CosmeticCommand implements CommandExecutor {
|
|||||||
|
|
||||||
CosmeticUser user = CosmeticUsers.getUser(player);
|
CosmeticUser user = CosmeticUsers.getUser(player);
|
||||||
|
|
||||||
if (!user.canEquipCosmetic(cosmetic)) {
|
if (!user.canEquipCosmetic(cosmetic) && !console) {
|
||||||
if (!silent) MessagesUtil.sendMessage(player, "no-cosmetic-permission");
|
if (!silent) MessagesUtil.sendMessage(player, "no-cosmetic-permission");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -247,12 +251,16 @@ public class CosmeticCommand implements CommandExecutor {
|
|||||||
}
|
}
|
||||||
// cosmetic menu exampleMenu playerName
|
// cosmetic menu exampleMenu playerName
|
||||||
case ("menu") -> {
|
case ("menu") -> {
|
||||||
if (args.length == 1) return true;
|
|
||||||
if (!sender.hasPermission("hmccosmetics.cmd.menu")) {
|
if (!sender.hasPermission("hmccosmetics.cmd.menu")) {
|
||||||
if (!silent) MessagesUtil.sendMessage(sender, "no-permission");
|
if (!silent) MessagesUtil.sendMessage(sender, "no-permission");
|
||||||
return true;
|
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 instanceof Player) player = ((Player) sender).getPlayer();
|
||||||
if (sender.hasPermission("hmccosmetics.cmd.menu.other")) {
|
if (sender.hasPermission("hmccosmetics.cmd.menu.other")) {
|
||||||
@@ -334,7 +342,7 @@ public class CosmeticCommand implements CommandExecutor {
|
|||||||
}
|
}
|
||||||
Wardrobe wardrobe = WardrobeSettings.getWardrobe(args[1]);
|
Wardrobe wardrobe = WardrobeSettings.getWardrobe(args[1]);
|
||||||
if (wardrobe == null) {
|
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);
|
WardrobeSettings.addWardrobe(wardrobe);
|
||||||
//MessagesUtil.sendMessage(player, "no-wardrobes");
|
//MessagesUtil.sendMessage(player, "no-wardrobes");
|
||||||
//return true;
|
//return true;
|
||||||
|
|||||||
@@ -30,11 +30,15 @@ public class Settings {
|
|||||||
private static final String UNAPPLY_DEATH_PATH = "unapply-on-death";
|
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_PERMISSION_JOIN_PATH = "force-permission-join";
|
||||||
private static final String FORCE_SHOW_COSMETICS_PATH = "force-show-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_PATH = "disabled-gamemode";
|
||||||
private static final String DISABLED_GAMEMODE_GAMEMODES_PATH = "gamemodes";
|
private static final String DISABLED_GAMEMODE_GAMEMODES_PATH = "gamemodes";
|
||||||
private static final String EMOTE_DISTANCE_PATH = "emote-distance";
|
private static final String EMOTE_DISTANCE_PATH = "emote-distance";
|
||||||
private static final String HOOK_SETTING_PATH = "hook-settings";
|
private static final String HOOK_SETTING_PATH = "hook-settings";
|
||||||
private static final String HOOK_ITEMADDER_PATH = "itemsadder";
|
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_RELOAD_CHANGE_PATH = "reload-on-change";
|
||||||
private static final String HOOK_WORLDGUARD_PATH = "worldguard";
|
private static final String HOOK_WORLDGUARD_PATH = "worldguard";
|
||||||
private static final String HOOK_WG_MOVE_CHECK_PATH = "player-move-check";
|
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_DISABLED_WORLDS_PATH = "disabled-worlds";
|
||||||
private static final String COSMETIC_PACKET_ENTITY_TELEPORT_COOLDOWN_PATH = "entity-cooldown-teleport-packet";
|
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_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_DESTROY_LOOSE_COSMETIC_PATH = "destroy-loose-cosmetics";
|
||||||
private static final String COSMETIC_BALLOON_HEAD_FORWARD_PATH = "balloon-head-forward";
|
private static final String COSMETIC_BALLOON_HEAD_FORWARD_PATH = "balloon-head-forward";
|
||||||
private static final String MENU_SETTINGS_PATH = "menu-settings";
|
private static final String MENU_SETTINGS_PATH = "menu-settings";
|
||||||
@@ -90,8 +92,14 @@ public class Settings {
|
|||||||
@Getter
|
@Getter
|
||||||
private static boolean forceShowOnJoin;
|
private static boolean forceShowOnJoin;
|
||||||
@Getter
|
@Getter
|
||||||
|
private static boolean itemProcessingDisplayName;
|
||||||
|
@Getter
|
||||||
|
private static boolean itemProcessingLore;
|
||||||
|
@Getter
|
||||||
private static boolean itemsAdderChangeReload;
|
private static boolean itemsAdderChangeReload;
|
||||||
@Getter
|
@Getter
|
||||||
|
private static boolean nexoChangeReload;
|
||||||
|
@Getter
|
||||||
private static boolean worldGuardMoveCheck;
|
private static boolean worldGuardMoveCheck;
|
||||||
@Getter
|
@Getter
|
||||||
private static boolean cosmeticEmoteBlockCheck;
|
private static boolean cosmeticEmoteBlockCheck;
|
||||||
@@ -107,10 +115,6 @@ public class Settings {
|
|||||||
@Getter
|
@Getter
|
||||||
private static boolean backpackForceRidingEnabled;
|
private static boolean backpackForceRidingEnabled;
|
||||||
@Getter
|
@Getter
|
||||||
private static boolean backpackLightEmination;
|
|
||||||
@Getter
|
|
||||||
private static boolean backpackBlockDetection;
|
|
||||||
@Getter
|
|
||||||
private static boolean emotesEnabled;
|
private static boolean emotesEnabled;
|
||||||
@Getter
|
@Getter
|
||||||
private static boolean disabledGamemodesEnabled;
|
private static boolean disabledGamemodesEnabled;
|
||||||
@@ -191,6 +195,10 @@ public class Settings {
|
|||||||
disabledWorlds = new ArrayList<>();
|
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);
|
unapplyOnDeath = cosmeticSettings.node(UNAPPLY_DEATH_PATH).getBoolean(false);
|
||||||
forcePermissionJoin = cosmeticSettings.node(FORCE_PERMISSION_JOIN_PATH).getBoolean(false);
|
forcePermissionJoin = cosmeticSettings.node(FORCE_PERMISSION_JOIN_PATH).getBoolean(false);
|
||||||
forceShowOnJoin = cosmeticSettings.node(FORCE_SHOW_COSMETICS_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);
|
emoteInvincible = cosmeticSettings.node(COSMETIC_EMOTE_INVINCIBLE_PATH).getBoolean(false);
|
||||||
destroyLooseCosmetics = cosmeticSettings.node(COSMETIC_DESTROY_LOOSE_COSMETIC_PATH).getBoolean(false);
|
destroyLooseCosmetics = cosmeticSettings.node(COSMETIC_DESTROY_LOOSE_COSMETIC_PATH).getBoolean(false);
|
||||||
backpackForceRidingEnabled = cosmeticSettings.node(COSMETIC_BACKPACK_FORCE_RIDING_PACKET_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) -> {
|
cosmeticSettings.node(SLOT_OPTIONS_PATH).childrenMap().forEach((key, value) -> {
|
||||||
EquipmentSlot slot = convertConfigToEquipment(key.toString().toLowerCase());
|
EquipmentSlot slot = convertConfigToEquipment(key.toString().toLowerCase());
|
||||||
@@ -254,9 +260,13 @@ public class Settings {
|
|||||||
dyeMenuOutputSlot = dyeMenuSettings.node(DYE_MENU_OUTPUT_SLOT).getInt(25);
|
dyeMenuOutputSlot = dyeMenuSettings.node(DYE_MENU_OUTPUT_SLOT).getInt(25);
|
||||||
|
|
||||||
ConfigurationNode hookSettings = source.node(HOOK_SETTING_PATH);
|
ConfigurationNode hookSettings = source.node(HOOK_SETTING_PATH);
|
||||||
|
|
||||||
ConfigurationNode itemsAdderSettings = hookSettings.node(HOOK_ITEMADDER_PATH);
|
ConfigurationNode itemsAdderSettings = hookSettings.node(HOOK_ITEMADDER_PATH);
|
||||||
itemsAdderChangeReload = itemsAdderSettings.node(HOOK_RELOAD_CHANGE_PATH).getBoolean(false);
|
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);
|
ConfigurationNode worldGuardSettings = hookSettings.node(HOOK_WORLDGUARD_PATH);
|
||||||
worldGuardMoveCheck = worldGuardSettings.node(HOOK_WG_MOVE_CHECK_PATH).getBoolean(true);
|
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.
|
// I messed up in release 2.2.6 and forgot to change player_move_check to player-move-check.
|
||||||
|
|||||||
@@ -14,10 +14,12 @@ public class Wardrobe {
|
|||||||
private final String id;
|
private final String id;
|
||||||
@Getter @Setter
|
@Getter @Setter
|
||||||
private int distance;
|
private int distance;
|
||||||
@Getter @Setter
|
@Getter @Setter @Nullable
|
||||||
private String permission;
|
private String permission;
|
||||||
@Getter @Setter
|
@Getter @Setter
|
||||||
private WardrobeLocation location;
|
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.
|
* 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 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 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 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.id = id;
|
||||||
this.location = location;
|
this.location = location;
|
||||||
this.distance = distance;
|
this.distance = distance;
|
||||||
if (permission != null) this.permission = permission;
|
if (permission != null) this.permission = permission;
|
||||||
|
if (defaultMenu != null) this.defaultMenu = defaultMenu;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -45,6 +45,7 @@ public class WardrobeSettings {
|
|||||||
private static final String WARDROBES_PATH = "wardrobes";
|
private static final String WARDROBES_PATH = "wardrobes";
|
||||||
private static final String PERMISSION_PATH = "permission";
|
private static final String PERMISSION_PATH = "permission";
|
||||||
private static final String DISTANCE_PATH = "distance";
|
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_PATH = "bossbar";
|
||||||
private static final String BOSSBAR_ENABLE_PATH = "enabled";
|
private static final String BOSSBAR_ENABLE_PATH = "enabled";
|
||||||
private static final String BOSSBAR_TEXT_PATH = "text";
|
private static final String BOSSBAR_TEXT_PATH = "text";
|
||||||
@@ -174,9 +175,10 @@ public class WardrobeSettings {
|
|||||||
WardrobeLocation wardrobeLocation = new WardrobeLocation(npcLocation, viewerLocation, leaveLocation);
|
WardrobeLocation wardrobeLocation = new WardrobeLocation(npcLocation, viewerLocation, leaveLocation);
|
||||||
|
|
||||||
String permission = wardrobesNode.node(PERMISSION_PATH).getString();
|
String permission = wardrobesNode.node(PERMISSION_PATH).getString();
|
||||||
|
String defaultMenu = wardrobesNode.node(WARDROBE_DEFAULT_MENU).getString();
|
||||||
int distance = wardrobesNode.node(DISTANCE_PATH).getInt(-1);
|
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);
|
addWardrobe(wardrobe);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
MessagesUtil.sendDebugMessages("Unable to create wardrobe " + id, Level.SEVERE);
|
MessagesUtil.sendDebugMessages("Unable to create wardrobe " + id, Level.SEVERE);
|
||||||
|
|||||||
@@ -22,7 +22,12 @@ public class CosmeticArmorType extends Cosmetic {
|
|||||||
public CosmeticArmorType(String id, ConfigurationNode config) {
|
public CosmeticArmorType(String id, ConfigurationNode config) {
|
||||||
super(id, 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
|
@Override
|
||||||
@@ -52,6 +57,7 @@ public class CosmeticArmorType extends Cosmetic {
|
|||||||
return cosmeticItem;
|
return cosmeticItem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
public EquipmentSlot getEquipSlot() {
|
public EquipmentSlot getEquipSlot() {
|
||||||
return this.equipSlot;
|
return this.equipSlot;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ package com.hibiscusmc.hmccosmetics.cosmetic.types;
|
|||||||
import com.hibiscusmc.hmccosmetics.config.Settings;
|
import com.hibiscusmc.hmccosmetics.config.Settings;
|
||||||
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
|
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
|
||||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||||
import com.hibiscusmc.hmccosmetics.user.manager.UserBackpackManager;
|
|
||||||
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||||
import com.hibiscusmc.hmccosmetics.util.packets.HMCCPacketManager;
|
import com.hibiscusmc.hmccosmetics.util.packets.HMCCPacketManager;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
@@ -11,7 +10,6 @@ import me.lojosho.hibiscuscommons.util.packets.PacketManager;
|
|||||||
import me.lojosho.shaded.configurate.ConfigurationNode;
|
import me.lojosho.shaded.configurate.ConfigurationNode;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.block.Block;
|
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.EntityType;
|
import org.bukkit.entity.EntityType;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@@ -58,21 +56,20 @@ public class CosmeticBackpackType extends Cosmetic {
|
|||||||
}
|
}
|
||||||
List<Player> outsideViewers = user.getUserBackpackManager().getEntityManager().refreshViewers(loc);
|
List<Player> outsideViewers = user.getUserBackpackManager().getEntityManager().refreshViewers(loc);
|
||||||
|
|
||||||
UserBackpackManager backpackManager = user.getUserBackpackManager();
|
user.getUserBackpackManager().getEntityManager().teleport(loc);
|
||||||
backpackManager.getEntityManager().teleport(loc);
|
user.getUserBackpackManager().getEntityManager().setRotation((int) loc.getYaw(), isFirstPersonCompadible());
|
||||||
backpackManager.getEntityManager().setRotation((int) loc.getYaw(), isFirstPersonCompadible());
|
|
||||||
|
|
||||||
HMCCPacketManager.sendEntitySpawnPacket(user.getEntity().getLocation(), backpackManager.getFirstArmorStandId(), EntityType.ARMOR_STAND, UUID.randomUUID(), outsideViewers);
|
HMCCPacketManager.sendEntitySpawnPacket(user.getEntity().getLocation(), user.getUserBackpackManager().getFirstArmorStandId(), EntityType.ARMOR_STAND, UUID.randomUUID(), outsideViewers);
|
||||||
//HMCCPacketManager.sendArmorstandMetadata(backpackManager.getFirstArmorStandId(), outsideViewers);
|
HMCCPacketManager.sendArmorstandMetadata(user.getUserBackpackManager().getFirstArmorStandId(), outsideViewers);
|
||||||
PacketManager.equipmentSlotUpdate(backpackManager.getFirstArmorStandId(), EquipmentSlot.HEAD, user.getUserCosmeticItem(this, getItem()), 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 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);
|
else HMCCPacketManager.sendRidingPacket(entity.getEntityId(), user.getUserBackpackManager().getFirstArmorStandId(), outsideViewers);
|
||||||
|
|
||||||
if (!user.isInWardrobe() && isFirstPersonCompadible() && user.getPlayer() != null) {
|
if (!user.isInWardrobe() && isFirstPersonCompadible() && user.getPlayer() != null) {
|
||||||
List<Player> owner = List.of(user.getPlayer());
|
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++) {
|
for (int i = 0; i < particleCloud.size(); i++) {
|
||||||
if (i == 0) {
|
if (i == 0) {
|
||||||
HMCCPacketManager.sendRidingPacket(entity.getEntityId(), particleCloud.get(i), owner);
|
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(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 (!user.isHidden()) {
|
||||||
//if (loc.getPitch() < -70) NMSHandlers.getHandler().equipmentSlotUpdate(user.getUserBackpackManager().getFirstArmorStandId(), EquipmentSlot.HEAD, new ItemStack(Material.AIR), owner);
|
//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);
|
//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()));
|
user.getUserBackpackManager().showBackpack();
|
||||||
backpackManager.showBackpack();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isFirstPersonCompadible() {
|
public boolean isFirstPersonCompadible() {
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import lombok.Getter;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
import java.util.concurrent.CompletableFuture;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
public class Database {
|
public class Database {
|
||||||
@@ -56,7 +57,7 @@ public class Database {
|
|||||||
data.save(CosmeticUsers.getUser(player));
|
data.save(CosmeticUsers.getUser(player));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static CosmeticUser get(UUID uniqueId) {
|
public static CompletableFuture<UserData> get(UUID uniqueId) {
|
||||||
return data.get(uniqueId);
|
return data.get(uniqueId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -5,6 +5,7 @@ import com.hibiscusmc.hmccosmetics.config.Settings;
|
|||||||
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
|
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
|
||||||
import com.hibiscusmc.hmccosmetics.cosmetic.CosmeticSlot;
|
import com.hibiscusmc.hmccosmetics.cosmetic.CosmeticSlot;
|
||||||
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetics;
|
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetics;
|
||||||
|
import com.hibiscusmc.hmccosmetics.database.UserData;
|
||||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||||
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||||
import org.apache.commons.lang3.EnumUtils;
|
import org.apache.commons.lang3.EnumUtils;
|
||||||
@@ -14,6 +15,7 @@ import org.jetbrains.annotations.NotNull;
|
|||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
|
||||||
public abstract class Data {
|
public abstract class Data {
|
||||||
|
|
||||||
@@ -22,7 +24,7 @@ public abstract class Data {
|
|||||||
public abstract void save(CosmeticUser user);
|
public abstract void save(CosmeticUser user);
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public abstract CosmeticUser get(UUID uniqueId);
|
public abstract CompletableFuture<UserData> get(UUID uniqueId);
|
||||||
|
|
||||||
public abstract void clear(UUID uniqueId);
|
public abstract void clear(UUID uniqueId);
|
||||||
|
|
||||||
@@ -48,13 +50,9 @@ public abstract class Data {
|
|||||||
return data.toString();
|
return data.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
public final Map<CosmeticSlot, Map<Cosmetic, Color>> deserializeData(CosmeticUser user, @NotNull String raw) {
|
|
||||||
return deserializeData(user, raw, Settings.isForcePermissionJoin());
|
|
||||||
}
|
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public final Map<CosmeticSlot, Map<Cosmetic, Color>> deserializeData(CosmeticUser user, @NotNull String raw, boolean permissionCheck) {
|
public final HashMap<CosmeticSlot, Map.Entry<Cosmetic, Integer>> deserializeData(@NotNull String raw) {
|
||||||
Map<CosmeticSlot, Map<Cosmetic, Color>> cosmetics = new HashMap<>();
|
HashMap<CosmeticSlot, Map.Entry<Cosmetic, Integer>> cosmetics = new HashMap<>();
|
||||||
|
|
||||||
String[] rawData = raw.split(",");
|
String[] rawData = raw.split(",");
|
||||||
ArrayList<CosmeticUser.HiddenReason> hiddenReason = new ArrayList<>();
|
ArrayList<CosmeticUser.HiddenReason> hiddenReason = new ArrayList<>();
|
||||||
@@ -76,59 +74,14 @@ public abstract class Data {
|
|||||||
String[] colorSplitData = splitData[1].split("&");
|
String[] colorSplitData = splitData[1].split("&");
|
||||||
if (Cosmetics.hasCosmetic(colorSplitData[0])) cosmetic = Cosmetics.getCosmetic(colorSplitData[0]);
|
if (Cosmetics.hasCosmetic(colorSplitData[0])) cosmetic = Cosmetics.getCosmetic(colorSplitData[0]);
|
||||||
if (slot == null || cosmetic == null) continue;
|
if (slot == null || cosmetic == null) continue;
|
||||||
if (permissionCheck && cosmetic.requiresPermission()) {
|
cosmetics.put(slot, Map.entry(cosmetic, Integer.parseInt(colorSplitData[1])));
|
||||||
if (user.getPlayer() != null && !user.getPlayer().hasPermission(cosmetic.getPermission())) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
cosmetics.put(slot, Map.of(cosmetic, Color.fromRGB(Integer.parseInt(colorSplitData[1]))));
|
|
||||||
} else {
|
} else {
|
||||||
if (Cosmetics.hasCosmetic(splitData[1])) cosmetic = Cosmetics.getCosmetic(splitData[1]);
|
if (Cosmetics.hasCosmetic(splitData[1])) cosmetic = Cosmetics.getCosmetic(splitData[1]);
|
||||||
if (slot == null || cosmetic == null) continue;
|
if (slot == null || cosmetic == null) continue;
|
||||||
if (permissionCheck && cosmetic.requiresPermission()) {
|
cosmetics.put(slot, Map.entry(cosmetic, -1));
|
||||||
if (user.getPlayer() != null && !user.getPlayer().hasPermission(cosmetic.getPermission())) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
HashMap<Cosmetic, Color> cosmeticColorHashMap = new HashMap<>();
|
|
||||||
cosmeticColorHashMap.put(cosmetic, null);
|
|
||||||
cosmetics.put(slot, cosmeticColorHashMap);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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;
|
return cosmetics;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,11 @@
|
|||||||
package com.hibiscusmc.hmccosmetics.database.types;
|
package com.hibiscusmc.hmccosmetics.database.types;
|
||||||
|
|
||||||
|
import com.hibiscusmc.hmccosmetics.database.UserData;
|
||||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
|
||||||
public class NoneData extends Data {
|
public class NoneData extends Data {
|
||||||
@Override
|
@Override
|
||||||
@@ -17,8 +19,8 @@ public class NoneData extends Data {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @Nullable CosmeticUser get(UUID uniqueId) {
|
public @Nullable CompletableFuture<UserData> get(UUID uniqueId) {
|
||||||
return new CosmeticUser(uniqueId);
|
return CompletableFuture.completedFuture(new UserData(uniqueId));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package com.hibiscusmc.hmccosmetics.database.types;
|
|||||||
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
|
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
|
||||||
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
|
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
|
||||||
import com.hibiscusmc.hmccosmetics.cosmetic.CosmeticSlot;
|
import com.hibiscusmc.hmccosmetics.cosmetic.CosmeticSlot;
|
||||||
|
import com.hibiscusmc.hmccosmetics.database.UserData;
|
||||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Color;
|
import org.bukkit.Color;
|
||||||
@@ -13,14 +14,15 @@ import java.sql.SQLException;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
|
||||||
public abstract class SQLData extends Data {
|
public abstract class SQLData extends Data {
|
||||||
@Override
|
@Override
|
||||||
@SuppressWarnings({"resource"}) // Duplicate is from deprecated InternalData
|
@SuppressWarnings({"resource"}) // Duplicate is from deprecated InternalData
|
||||||
public CosmeticUser get(UUID uniqueId) {
|
public CompletableFuture<UserData> get(UUID uniqueId) {
|
||||||
CosmeticUser user = new CosmeticUser(uniqueId);
|
return CompletableFuture.supplyAsync(() -> {
|
||||||
|
UserData data = new UserData(uniqueId);
|
||||||
|
|
||||||
Bukkit.getScheduler().runTaskAsynchronously(HMCCosmeticsPlugin.getInstance(), () -> {
|
|
||||||
PreparedStatement preparedStatement = null;
|
PreparedStatement preparedStatement = null;
|
||||||
try {
|
try {
|
||||||
preparedStatement = preparedStatement("SELECT * FROM COSMETICDATABASE WHERE UUID = ?;");
|
preparedStatement = preparedStatement("SELECT * FROM COSMETICDATABASE WHERE UUID = ?;");
|
||||||
@@ -28,21 +30,8 @@ public abstract class SQLData extends Data {
|
|||||||
ResultSet rs = preparedStatement.executeQuery();
|
ResultSet rs = preparedStatement.executeQuery();
|
||||||
if (rs.next()) {
|
if (rs.next()) {
|
||||||
String rawData = rs.getString("COSMETICS");
|
String rawData = rs.getString("COSMETICS");
|
||||||
Map<CosmeticSlot, Map<Cosmetic, Color>> cosmetics = deserializeData(user, rawData);
|
HashMap<CosmeticSlot, Map.Entry<Cosmetic, Integer>> cosmetics = deserializeData(rawData);
|
||||||
// Load cosmetics, put them into the addedCosmetic hashmap
|
data.setCosmetics(cosmetics);
|
||||||
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));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
@@ -51,9 +40,8 @@ public abstract class SQLData extends Data {
|
|||||||
if (preparedStatement != null) preparedStatement.close();
|
if (preparedStatement != null) preparedStatement.close();
|
||||||
} catch (SQLException e) {}
|
} catch (SQLException e) {}
|
||||||
}
|
}
|
||||||
|
return data;
|
||||||
});
|
});
|
||||||
|
|
||||||
return user;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -128,8 +128,9 @@ public class TypeCosmetic extends Type {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ItemStack setItem(CosmeticUser user, @NotNull ConfigurationNode config, ItemStack itemStack, int slot) {
|
public ItemStack setItem(@NotNull CosmeticUser user, @NotNull ConfigurationNode config, @NotNull ItemStack itemStack, int slot) {
|
||||||
itemStack.setItemMeta(processLoreLines(user, itemStack.getItemMeta()));
|
if (itemStack.hasItemMeta()) itemStack.setItemMeta(processLoreLines(user, itemStack.getItemMeta()));
|
||||||
|
else MessagesUtil.sendDebugMessages("ItemStack has no ItemMeta?");
|
||||||
|
|
||||||
if (config.node("cosmetic").virtual()) {
|
if (config.node("cosmetic").virtual()) {
|
||||||
return itemStack;
|
return itemStack;
|
||||||
@@ -153,7 +154,8 @@ public class TypeCosmetic extends Type {
|
|||||||
} catch (SerializationException e) {
|
} catch (SerializationException e) {
|
||||||
throw new RuntimeException(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;
|
return itemStack;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -170,7 +172,8 @@ public class TypeCosmetic extends Type {
|
|||||||
} catch (SerializationException e) {
|
} catch (SerializationException e) {
|
||||||
throw new RuntimeException(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;
|
||||||
}
|
}
|
||||||
return itemStack;
|
return itemStack;
|
||||||
@@ -193,7 +196,7 @@ public class TypeCosmetic extends Type {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (itemMeta instanceof SkullMeta skullMeta) {
|
if (itemMeta instanceof SkullMeta skullMeta) {
|
||||||
if (skullMeta.hasOwner()) {
|
if (skullMeta.hasOwner() && skullMeta.getOwner() != null) {
|
||||||
skullMeta.setOwner(Hooks.processPlaceholders(user.getPlayer(), skullMeta.getOwner()));
|
skullMeta.setOwner(Hooks.processPlaceholders(user.getPlayer(), skullMeta.getOwner()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ public class TypeEmpty extends Type {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (itemMeta instanceof SkullMeta skullMeta) {
|
if (itemMeta instanceof SkullMeta skullMeta) {
|
||||||
if (skullMeta.hasOwner()) {
|
if (skullMeta.hasOwner() && skullMeta.getOwner() != null) {
|
||||||
skullMeta.setOwner(Hooks.processPlaceholders(user.getPlayer(), skullMeta.getOwner()));
|
skullMeta.setOwner(Hooks.processPlaceholders(user.getPlayer(), skullMeta.getOwner()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,10 +39,9 @@ public class WGListener implements Listener {
|
|||||||
if (protectedRegion.getFlags().containsKey(WGHook.getCosmeticEnableFlag())) {
|
if (protectedRegion.getFlags().containsKey(WGHook.getCosmeticEnableFlag())) {
|
||||||
if (protectedRegion.getFlags().get(WGHook.getCosmeticEnableFlag()).toString().equalsIgnoreCase("ALLOW")) {
|
if (protectedRegion.getFlags().get(WGHook.getCosmeticEnableFlag()).toString().equalsIgnoreCase("ALLOW")) {
|
||||||
user.showCosmetics(CosmeticUser.HiddenReason.WORLDGUARD);
|
user.showCosmetics(CosmeticUser.HiddenReason.WORLDGUARD);
|
||||||
return;
|
} else {
|
||||||
}
|
|
||||||
user.hideCosmetics(CosmeticUser.HiddenReason.WORLDGUARD);
|
user.hideCosmetics(CosmeticUser.HiddenReason.WORLDGUARD);
|
||||||
return;
|
}
|
||||||
}
|
}
|
||||||
if (protectedRegion.getFlags().containsKey(WGHook.getCosmeticWardrobeFlag())) {
|
if (protectedRegion.getFlags().containsKey(WGHook.getCosmeticWardrobeFlag())) {
|
||||||
if (!WardrobeSettings.getWardrobeNames().contains(protectedRegion.getFlags().get(WGHook.getCosmeticWardrobeFlag()).toString())) return;
|
if (!WardrobeSettings.getWardrobeNames().contains(protectedRegion.getFlags().get(WGHook.getCosmeticWardrobeFlag()).toString())) return;
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
|
|||||||
import com.hibiscusmc.hmccosmetics.config.DatabaseSettings;
|
import com.hibiscusmc.hmccosmetics.config.DatabaseSettings;
|
||||||
import com.hibiscusmc.hmccosmetics.config.Settings;
|
import com.hibiscusmc.hmccosmetics.config.Settings;
|
||||||
import com.hibiscusmc.hmccosmetics.database.Database;
|
import com.hibiscusmc.hmccosmetics.database.Database;
|
||||||
|
import com.hibiscusmc.hmccosmetics.database.UserData;
|
||||||
import com.hibiscusmc.hmccosmetics.gui.Menus;
|
import com.hibiscusmc.hmccosmetics.gui.Menus;
|
||||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUsers;
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUsers;
|
||||||
@@ -17,6 +18,8 @@ import org.bukkit.event.player.PlayerJoinEvent;
|
|||||||
import org.bukkit.event.player.PlayerQuitEvent;
|
import org.bukkit.event.player.PlayerQuitEvent;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
public class PlayerConnectionListener implements Listener {
|
public class PlayerConnectionListener implements Listener {
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.MONITOR)
|
@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 = () -> {
|
Runnable run = () -> {
|
||||||
if (!event.getPlayer().isOnline()) return; // If a player is no longer online, don't run this.
|
if (!event.getPlayer().isOnline()) return; // If a player is no longer online, don't run this.
|
||||||
CosmeticUser user = Database.get(event.getPlayer().getUniqueId());
|
UUID uuid = event.getPlayer().getUniqueId();
|
||||||
CosmeticUsers.addUser(user);
|
Database.get(uuid).thenAccept(data -> {
|
||||||
MessagesUtil.sendDebugMessages("Run User Join");
|
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.
|
// And finally, launch an update for the cosmetics they have.
|
||||||
Bukkit.getScheduler().runTaskLater(HMCCosmeticsPlugin.getInstance(), () -> {
|
Bukkit.getScheduler().runTaskLater(HMCCosmeticsPlugin.getInstance(), () -> {
|
||||||
if (user.getPlayer() == null) return;
|
if (cosmeticUser.getPlayer() == null) return;
|
||||||
user.updateCosmetic();
|
cosmeticUser.updateCosmetic();
|
||||||
}, 4);
|
}, 4);
|
||||||
|
});
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
if (DatabaseSettings.isEnabledDelay()) {
|
if (DatabaseSettings.isEnabledDelay()) {
|
||||||
|
|||||||
@@ -25,10 +25,13 @@ import com.hibiscusmc.hmccosmetics.user.CosmeticUsers;
|
|||||||
import com.hibiscusmc.hmccosmetics.user.manager.UserEmoteManager;
|
import com.hibiscusmc.hmccosmetics.user.manager.UserEmoteManager;
|
||||||
import com.hibiscusmc.hmccosmetics.user.manager.UserWardrobeManager;
|
import com.hibiscusmc.hmccosmetics.user.manager.UserWardrobeManager;
|
||||||
import com.hibiscusmc.hmccosmetics.util.HMCCInventoryUtils;
|
import com.hibiscusmc.hmccosmetics.util.HMCCInventoryUtils;
|
||||||
|
import com.hibiscusmc.hmccosmetics.util.HMCCServerUtils;
|
||||||
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||||
import com.hibiscusmc.hmccosmetics.util.packets.HMCCPacketManager;
|
import com.hibiscusmc.hmccosmetics.util.packets.HMCCPacketManager;
|
||||||
import me.lojosho.hibiscuscommons.api.events.*;
|
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.HookItemAdder;
|
||||||
|
import me.lojosho.hibiscuscommons.hooks.items.HookNexo;
|
||||||
import me.lojosho.hibiscuscommons.util.packets.PacketManager;
|
import me.lojosho.hibiscuscommons.util.packets.PacketManager;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
@@ -66,6 +69,7 @@ public class PlayerGameListener implements Listener {
|
|||||||
registerPlayerArmListener();
|
registerPlayerArmListener();
|
||||||
registerEntityUseListener();
|
registerEntityUseListener();
|
||||||
registerSlotChangeListener();
|
registerSlotChangeListener();
|
||||||
|
registerPassengerSetListener();
|
||||||
|
|
||||||
//registerLookMovement();
|
//registerLookMovement();
|
||||||
//registerMoveListener();
|
//registerMoveListener();
|
||||||
@@ -379,6 +383,10 @@ public class PlayerGameListener implements Listener {
|
|||||||
public void onPlayerCosmeticEquip(PlayerCosmeticPostEquipEvent event) {
|
public void onPlayerCosmeticEquip(PlayerCosmeticPostEquipEvent event) {
|
||||||
CosmeticUser user = event.getUser();
|
CosmeticUser user = event.getUser();
|
||||||
if (user.isInWardrobe() && event.getCosmetic().getSlot().equals(CosmeticSlot.BALLOON)) {
|
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();
|
CosmeticBalloonType cosmetic = (CosmeticBalloonType) event.getCosmetic();
|
||||||
Location npclocation = user.getWardrobeManager().getNpcLocation().clone().add(cosmetic.getBalloonOffset());
|
Location npclocation = user.getWardrobeManager().getNpcLocation().clone().add(cosmetic.getBalloonOffset());
|
||||||
// We know that no other entity besides a regular player will be in the wardrobe
|
// 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);
|
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
|
// These emote mostly handles emotes from other plugins, such as ItemsAdder
|
||||||
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
||||||
public void onPlayerPlayEmote(HibiscusPlayerEmotePlayEvent event) {
|
public void onPlayerPlayEmote(HibiscusPlayerEmotePlayEvent event) {
|
||||||
@@ -455,6 +448,22 @@ public class PlayerGameListener implements Listener {
|
|||||||
user.showCosmetics(CosmeticUser.HiddenReason.EMOTE);
|
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() {
|
private void registerInventoryClickListener() {
|
||||||
ProtocolLibrary.getProtocolManager().addPacketListener(new PacketAdapter(HMCCosmeticsPlugin.getInstance(), ListenerPriority.NORMAL, PacketType.Play.Client.WINDOW_CLICK) {
|
ProtocolLibrary.getProtocolManager().addPacketListener(new PacketAdapter(HMCCosmeticsPlugin.getInstance(), ListenerPriority.NORMAL, PacketType.Play.Client.WINDOW_CLICK) {
|
||||||
@Override
|
@Override
|
||||||
@@ -585,6 +594,7 @@ public class PlayerGameListener implements Listener {
|
|||||||
switch (pair.getFirst()) {
|
switch (pair.getFirst()) {
|
||||||
case MAINHAND -> {
|
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() == 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()));
|
armor.set(i, new Pair<>(pair.getFirst(), user.getPlayer().getInventory().getItemInMainHand()));
|
||||||
}
|
}
|
||||||
default -> {
|
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() {
|
private void registerPlayerArmListener() {
|
||||||
ProtocolLibrary.getProtocolManager().addPacketListener(new PacketAdapter(HMCCosmeticsPlugin.getInstance(), ListenerPriority.NORMAL, PacketType.Play.Client.ARM_ANIMATION) {
|
ProtocolLibrary.getProtocolManager().addPacketListener(new PacketAdapter(HMCCosmeticsPlugin.getInstance(), ListenerPriority.NORMAL, PacketType.Play.Client.ARM_ANIMATION) {
|
||||||
@Override
|
@Override
|
||||||
@@ -719,10 +760,6 @@ public class PlayerGameListener implements Listener {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
private EquipmentSlot getArmorSlot(final Material material) {
|
private EquipmentSlot getArmorSlot(final Material material) {
|
||||||
for (final EquipmentSlot slot : EquipmentSlot.values()) {
|
for (final EquipmentSlot slot : EquipmentSlot.values()) {
|
||||||
|
|||||||
@@ -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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -13,6 +13,7 @@ import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticArmorType;
|
|||||||
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticBackpackType;
|
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticBackpackType;
|
||||||
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticBalloonType;
|
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticBalloonType;
|
||||||
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticMainhandType;
|
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticMainhandType;
|
||||||
|
import com.hibiscusmc.hmccosmetics.database.UserData;
|
||||||
import com.hibiscusmc.hmccosmetics.gui.Menus;
|
import com.hibiscusmc.hmccosmetics.gui.Menus;
|
||||||
import com.hibiscusmc.hmccosmetics.user.manager.UserBackpackManager;
|
import com.hibiscusmc.hmccosmetics.user.manager.UserBackpackManager;
|
||||||
import com.hibiscusmc.hmccosmetics.user.manager.UserBalloonManager;
|
import com.hibiscusmc.hmccosmetics.user.manager.UserBalloonManager;
|
||||||
@@ -38,6 +39,7 @@ import org.bukkit.inventory.ItemStack;
|
|||||||
import org.bukkit.inventory.meta.*;
|
import org.bukkit.inventory.meta.*;
|
||||||
import org.bukkit.persistence.PersistentDataType;
|
import org.bukkit.persistence.PersistentDataType;
|
||||||
import org.bukkit.scheduler.BukkitTask;
|
import org.bukkit.scheduler.BukkitTask;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
@@ -58,8 +60,9 @@ public class CosmeticUser {
|
|||||||
|
|
||||||
// Cosmetic Settings/Toggles
|
// Cosmetic Settings/Toggles
|
||||||
private final ArrayList<HiddenReason> hiddenReason = new ArrayList<>();
|
private final ArrayList<HiddenReason> hiddenReason = new ArrayList<>();
|
||||||
private final HashMap<CosmeticSlot, ItemStack> cachedCosmeticItems = new HashMap<>();
|
|
||||||
private final HashMap<CosmeticSlot, Color> colors = new HashMap<>();
|
private final HashMap<CosmeticSlot, Color> colors = new HashMap<>();
|
||||||
|
// Cosmetic caches
|
||||||
|
private final HashMap<String, ItemStack> cosmeticItems = new HashMap<>();
|
||||||
|
|
||||||
public CosmeticUser(UUID uuid) {
|
public CosmeticUser(UUID uuid) {
|
||||||
this.uniqueId = uuid;
|
this.uniqueId = uuid;
|
||||||
@@ -67,6 +70,13 @@ public class CosmeticUser {
|
|||||||
tick();
|
tick();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public CosmeticUser(UUID uuid, UserData data) {
|
||||||
|
this.uniqueId = uuid;
|
||||||
|
userEmoteManager = new UserEmoteManager(this);
|
||||||
|
loadData(data);
|
||||||
|
tick();
|
||||||
|
}
|
||||||
|
|
||||||
private void tick() {
|
private void tick() {
|
||||||
// Occasionally updates the entity cosmetics
|
// Occasionally updates the entity cosmetics
|
||||||
Runnable run = () -> {
|
Runnable run = () -> {
|
||||||
@@ -88,6 +98,54 @@ public class CosmeticUser {
|
|||||||
despawnBalloon();
|
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) {
|
public Cosmetic getCosmetic(CosmeticSlot slot) {
|
||||||
return playerCosmetics.get(slot);
|
return playerCosmetics.get(slot);
|
||||||
}
|
}
|
||||||
@@ -96,11 +154,11 @@ public class CosmeticUser {
|
|||||||
return ImmutableList.copyOf(playerCosmetics.values());
|
return ImmutableList.copyOf(playerCosmetics.values());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addPlayerCosmetic(Cosmetic cosmetic) {
|
public void addPlayerCosmetic(@NotNull Cosmetic cosmetic) {
|
||||||
addPlayerCosmetic(cosmetic, null);
|
addPlayerCosmetic(cosmetic, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addPlayerCosmetic(Cosmetic cosmetic, Color color) {
|
public void addPlayerCosmetic(@NotNull Cosmetic cosmetic, @Nullable Color color) {
|
||||||
// API
|
// API
|
||||||
PlayerCosmeticEquipEvent event = new PlayerCosmeticEquipEvent(this, cosmetic);
|
PlayerCosmeticEquipEvent event = new PlayerCosmeticEquipEvent(this, cosmetic);
|
||||||
Bukkit.getPluginManager().callEvent(event);
|
Bukkit.getPluginManager().callEvent(event);
|
||||||
@@ -157,7 +215,6 @@ public class CosmeticUser {
|
|||||||
if (slot == CosmeticSlot.EMOTE) {
|
if (slot == CosmeticSlot.EMOTE) {
|
||||||
if (getUserEmoteManager().isPlayingEmote()) getUserEmoteManager().stopEmote(UserEmoteManager.StopEmoteReason.UNEQUIP);
|
if (getUserEmoteManager().isPlayingEmote()) getUserEmoteManager().stopEmote(UserEmoteManager.StopEmoteReason.UNEQUIP);
|
||||||
}
|
}
|
||||||
cachedCosmeticItems.remove(slot);
|
|
||||||
colors.remove(slot);
|
colors.remove(slot);
|
||||||
playerCosmetics.remove(slot);
|
playerCosmetics.remove(slot);
|
||||||
removeArmor(slot);
|
removeArmor(slot);
|
||||||
@@ -223,16 +280,12 @@ public class CosmeticUser {
|
|||||||
return getUserCosmeticItem(cosmetic);
|
return getUserCosmeticItem(cosmetic);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ItemStack getUserCosmeticItem(Cosmetic cosmetic) {
|
public ItemStack getUserCosmeticItem(@NotNull Cosmetic cosmetic) {
|
||||||
ItemStack item = null;
|
ItemStack item = null;
|
||||||
if (!hiddenReason.isEmpty()) {
|
if (!hiddenReason.isEmpty()) {
|
||||||
if (cosmetic instanceof CosmeticBackpackType || cosmetic instanceof CosmeticBalloonType) return new ItemStack(Material.AIR);
|
if (cosmetic instanceof CosmeticBackpackType || cosmetic instanceof CosmeticBalloonType) return new ItemStack(Material.AIR);
|
||||||
return getPlayer().getInventory().getItem(HMCCInventoryUtils.getEquipmentSlot(cosmetic.getSlot()));
|
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) {
|
if (cosmetic instanceof CosmeticArmorType armorType) {
|
||||||
item = armorType.getItem(this, cosmetic.getItem());
|
item = armorType.getItem(this, cosmetic.getItem());
|
||||||
}
|
}
|
||||||
@@ -250,15 +303,11 @@ public class CosmeticUser {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
public ItemStack getUserCosmeticItem(Cosmetic cosmetic, ItemStack item) {
|
public ItemStack getUserCosmeticItem(@NotNull Cosmetic cosmetic, @Nullable ItemStack item) {
|
||||||
if (item == null) {
|
if (item == null) {
|
||||||
//MessagesUtil.sendDebugMessages("GetUserCosemticUser Item is null");
|
//MessagesUtil.sendDebugMessages("GetUserCosemticUser Item is null");
|
||||||
return new ItemStack(Material.AIR);
|
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()) {
|
if (item.hasItemMeta()) {
|
||||||
ItemMeta itemMeta = item.getItemMeta();
|
ItemMeta itemMeta = item.getItemMeta();
|
||||||
|
|
||||||
@@ -285,18 +334,22 @@ public class CosmeticUser {
|
|||||||
itemMeta = skullMeta;
|
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<>();
|
List<String> processedLore = new ArrayList<>();
|
||||||
|
|
||||||
if (itemMeta.hasLore()) {
|
if (itemMeta.hasLore()) {
|
||||||
for (String loreLine : itemMeta.getLore()) {
|
for (String loreLine : itemMeta.getLore()) {
|
||||||
processedLore.add(Hooks.processPlaceholders(getPlayer(), loreLine));
|
processedLore.add(Hooks.processPlaceholders(getPlayer(), loreLine));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (itemMeta.hasDisplayName()) {
|
|
||||||
String displayName = itemMeta.getDisplayName();
|
|
||||||
itemMeta.setDisplayName(Hooks.processPlaceholders(getPlayer(), displayName));
|
|
||||||
}
|
|
||||||
itemMeta.setLore(processedLore);
|
itemMeta.setLore(processedLore);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if (colors.containsKey(cosmetic.getSlot())) {
|
if (colors.containsKey(cosmetic.getSlot())) {
|
||||||
Color color = colors.get(cosmetic.getSlot());
|
Color color = colors.get(cosmetic.getSlot());
|
||||||
@@ -322,7 +375,6 @@ public class CosmeticUser {
|
|||||||
|
|
||||||
item.setItemMeta(itemMeta);
|
item.setItemMeta(itemMeta);
|
||||||
}
|
}
|
||||||
cachedCosmeticItems.put(cosmetic.getSlot(), item);
|
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -334,7 +386,7 @@ public class CosmeticUser {
|
|||||||
return userWardrobeManager;
|
return userWardrobeManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void enterWardrobe(boolean ignoreDistance, Wardrobe wardrobe) {
|
public void enterWardrobe(boolean ignoreDistance, @NotNull Wardrobe wardrobe) {
|
||||||
if (wardrobe.hasPermission() && !getPlayer().hasPermission(wardrobe.getPermission())) {
|
if (wardrobe.hasPermission() && !getPlayer().hasPermission(wardrobe.getPermission())) {
|
||||||
MessagesUtil.sendMessage(getPlayer(), "no-permission");
|
MessagesUtil.sendMessage(getPlayer(), "no-permission");
|
||||||
return;
|
return;
|
||||||
@@ -435,10 +487,6 @@ public class CosmeticUser {
|
|||||||
|
|
||||||
public void despawnBalloon() {
|
public void despawnBalloon() {
|
||||||
if (this.userBalloonManager == null) return;
|
if (this.userBalloonManager == null) return;
|
||||||
List<Player> sentTo = HMCCPlayerUtils.getNearbyPlayers(getEntity().getLocation());
|
|
||||||
|
|
||||||
HMCCPacketManager.sendEntityDestroyPacket(userBalloonManager.getPufferfishBalloonId(), sentTo);
|
|
||||||
|
|
||||||
this.userBalloonManager.remove();
|
this.userBalloonManager.remove();
|
||||||
this.userBalloonManager = null;
|
this.userBalloonManager = null;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
package com.hibiscusmc.hmccosmetics.user.manager;
|
package com.hibiscusmc.hmccosmetics.user.manager;
|
||||||
|
|
||||||
import com.hibiscusmc.hmccosmetics.config.Settings;
|
|
||||||
import com.hibiscusmc.hmccosmetics.cosmetic.CosmeticSlot;
|
import com.hibiscusmc.hmccosmetics.cosmetic.CosmeticSlot;
|
||||||
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticBackpackType;
|
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticBackpackType;
|
||||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
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.hibiscusmc.hmccosmetics.util.packets.HMCCPacketManager;
|
||||||
import com.ticxo.modelengine.api.ModelEngineAPI;
|
import com.ticxo.modelengine.api.ModelEngineAPI;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
|
||||||
import me.lojosho.hibiscuscommons.hooks.Hooks;
|
import me.lojosho.hibiscuscommons.hooks.Hooks;
|
||||||
import me.lojosho.hibiscuscommons.util.ServerUtils;
|
import me.lojosho.hibiscuscommons.util.ServerUtils;
|
||||||
import me.lojosho.hibiscuscommons.util.packets.PacketManager;
|
import me.lojosho.hibiscuscommons.util.packets.PacketManager;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.Block;
|
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.EntityType;
|
import org.bukkit.entity.EntityType;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@@ -36,13 +33,10 @@ public class UserBackpackManager {
|
|||||||
private final CosmeticUser user;
|
private final CosmeticUser user;
|
||||||
@Getter
|
@Getter
|
||||||
private UserEntity entityManager;
|
private UserEntity entityManager;
|
||||||
@Getter @Setter
|
|
||||||
private boolean inBlock;
|
|
||||||
|
|
||||||
public UserBackpackManager(CosmeticUser user) {
|
public UserBackpackManager(CosmeticUser user) {
|
||||||
this.user = user;
|
this.user = user;
|
||||||
this.backpackHidden = false;
|
this.backpackHidden = false;
|
||||||
this.inBlock = false;
|
|
||||||
this.invisibleArmorStand = ServerUtils.getNextEntityId();
|
this.invisibleArmorStand = ServerUtils.getNextEntityId();
|
||||||
this.entityManager = new UserEntity(user.getUniqueId());
|
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)
|
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());
|
getEntityManager().teleport(user.getEntity().getLocation());
|
||||||
List<Player> outsideViewers = getEntityManager().getViewers();
|
List<Player> outsideViewers = getEntityManager().getViewers();
|
||||||
HMCCPacketManager.sendEntitySpawnPacket(user.getEntity().getLocation(), getFirstArmorStandId(), EntityType.ARMOR_STAND, UUID.randomUUID(), getEntityManager().getViewers());
|
HMCCPacketManager.sendEntitySpawnPacket(user.getEntity().getLocation(), getFirstArmorStandId(), EntityType.ARMOR_STAND, UUID.randomUUID(), getEntityManager().getViewers());
|
||||||
if (Settings.isBackpackBlockDetection()) {
|
HMCCPacketManager.sendArmorstandMetadata(getFirstArmorStandId(), outsideViewers);
|
||||||
if (checkBlock()) {
|
|
||||||
setInBlock(true);
|
|
||||||
HMCCPacketManager.sendArmorstandMetadata(getFirstArmorStandId(), isInBlock(), outsideViewers);
|
|
||||||
} else {
|
|
||||||
HMCCPacketManager.sendArmorstandMetadata(getFirstArmorStandId(), isInBlock(), outsideViewers);
|
|
||||||
}
|
|
||||||
//refreshBlock(outsideViewers);
|
|
||||||
} else {
|
|
||||||
HMCCPacketManager.sendArmorstandMetadata(getFirstArmorStandId(), Settings.isBackpackLightEmination(), outsideViewers);
|
|
||||||
}
|
|
||||||
|
|
||||||
Entity entity = user.getEntity();
|
Entity entity = user.getEntity();
|
||||||
|
|
||||||
@@ -163,33 +147,4 @@ public class UserBackpackManager {
|
|||||||
ItemStack item = new ItemStack(Material.AIR);
|
ItemStack item = new ItemStack(Material.AIR);
|
||||||
PacketManager.equipmentSlotUpdate(getFirstArmorStandId(), EquipmentSlot.HEAD, item, getEntityManager().getViewers());
|
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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import com.ticxo.modelengine.api.ModelEngineAPI;
|
|||||||
import com.ticxo.modelengine.api.entity.data.BukkitEntityData;
|
import com.ticxo.modelengine.api.entity.data.BukkitEntityData;
|
||||||
import com.ticxo.modelengine.api.model.ActiveModel;
|
import com.ticxo.modelengine.api.model.ActiveModel;
|
||||||
import com.ticxo.modelengine.api.model.ModeledEntity;
|
import com.ticxo.modelengine.api.model.ModeledEntity;
|
||||||
|
import com.ticxo.modelengine.api.nms.RenderParsers;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import me.lojosho.hibiscuscommons.hooks.Hooks;
|
import me.lojosho.hibiscuscommons.hooks.Hooks;
|
||||||
import me.lojosho.hibiscuscommons.nms.NMSHandlers;
|
import me.lojosho.hibiscuscommons.nms.NMSHandlers;
|
||||||
@@ -30,16 +31,17 @@ import java.util.logging.Level;
|
|||||||
|
|
||||||
public class UserBalloonManager {
|
public class UserBalloonManager {
|
||||||
|
|
||||||
private CosmeticUser user;
|
private final CosmeticUser user;
|
||||||
@Getter
|
@Getter
|
||||||
private BalloonType balloonType;
|
private BalloonType balloonType;
|
||||||
private CosmeticBalloonType cosmeticBalloonType;
|
private CosmeticBalloonType cosmeticBalloonType;
|
||||||
@Getter
|
@Getter
|
||||||
private UserBalloonPufferfish pufferfish;
|
private UserBalloonPufferfish pufferfish;
|
||||||
private final ArmorStand modelEntity;
|
private final ArmorStand modelEntity;
|
||||||
|
|
||||||
public UserBalloonManager(CosmeticUser user, @NotNull Location location) {
|
public UserBalloonManager(CosmeticUser user, @NotNull Location location) {
|
||||||
this.user = user;
|
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) -> {
|
this.modelEntity = location.getWorld().spawn(location, ArmorStand.class, (e) -> {
|
||||||
e.setInvisible(true);
|
e.setInvisible(true);
|
||||||
e.setGravity(false);
|
e.setGravity(false);
|
||||||
@@ -82,7 +84,7 @@ public class UserBalloonManager {
|
|||||||
modeledEntity.getModels().forEach((d, singleModel) -> {
|
modeledEntity.getModels().forEach((d, singleModel) -> {
|
||||||
if (cosmeticBalloonType.isDyablePart(d)) {
|
if (cosmeticBalloonType.isDyablePart(d)) {
|
||||||
singleModel.setDefaultTint(color);
|
singleModel.setDefaultTint(color);
|
||||||
singleModel.getModelRenderer().sendToClient();
|
singleModel.getModelRenderer().sendToClient(ModelEngineAPI.getNMSHandler().createParsers());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -98,6 +100,7 @@ public class UserBalloonManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void remove() {
|
public void remove() {
|
||||||
|
pufferfish.destroyPufferfish();
|
||||||
if (balloonType == BalloonType.MODELENGINE) {
|
if (balloonType == BalloonType.MODELENGINE) {
|
||||||
final ModeledEntity entity = ModelEngineAPI.getModeledEntity(modelEntity);
|
final ModeledEntity entity = ModelEngineAPI.getModeledEntity(modelEntity);
|
||||||
if (entity == null) {
|
if (entity == null) {
|
||||||
@@ -156,6 +159,7 @@ public class UserBalloonManager {
|
|||||||
public int getPufferfishBalloonId() {
|
public int getPufferfishBalloonId() {
|
||||||
return pufferfish.getPufferFishEntityId();
|
return pufferfish.getPufferFishEntityId();
|
||||||
}
|
}
|
||||||
|
|
||||||
public UUID getPufferfishBalloonUniqueId() {
|
public UUID getPufferfishBalloonUniqueId() {
|
||||||
return pufferfish.getUuid();
|
return pufferfish.getUuid();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,10 @@ package com.hibiscusmc.hmccosmetics.user.manager;
|
|||||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUsers;
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUsers;
|
||||||
import com.hibiscusmc.hmccosmetics.util.HMCCPlayerUtils;
|
import com.hibiscusmc.hmccosmetics.util.HMCCPlayerUtils;
|
||||||
|
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||||
import com.hibiscusmc.hmccosmetics.util.packets.HMCCPacketManager;
|
import com.hibiscusmc.hmccosmetics.util.packets.HMCCPacketManager;
|
||||||
|
import lombok.Getter;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.entity.EntityType;
|
import org.bukkit.entity.EntityType;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@@ -14,8 +17,11 @@ import java.util.UUID;
|
|||||||
|
|
||||||
public class UserBalloonPufferfish extends UserEntity {
|
public class UserBalloonPufferfish extends UserEntity {
|
||||||
|
|
||||||
private int pufferFishEntityId;
|
@Getter
|
||||||
private UUID uuid;
|
private final int pufferFishEntityId;
|
||||||
|
@Getter
|
||||||
|
private final UUID uuid;
|
||||||
|
private boolean destroyed = false;
|
||||||
|
|
||||||
public UserBalloonPufferfish(UUID owner, int pufferFishEntityId, UUID uuid) {
|
public UserBalloonPufferfish(UUID owner, int pufferFishEntityId, UUID uuid) {
|
||||||
super(owner);
|
super(owner);
|
||||||
@@ -23,14 +29,6 @@ public class UserBalloonPufferfish extends UserEntity {
|
|||||||
this.uuid = uuid;
|
this.uuid = uuid;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getPufferFishEntityId() {
|
|
||||||
return pufferFishEntityId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public UUID getUuid() {
|
|
||||||
return uuid;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void hidePufferfish() {
|
public void hidePufferfish() {
|
||||||
HMCCPacketManager.sendEntityDestroyPacket(pufferFishEntityId, getViewers());
|
HMCCPacketManager.sendEntityDestroyPacket(pufferFishEntityId, getViewers());
|
||||||
getViewers().clear();
|
getViewers().clear();
|
||||||
@@ -41,35 +39,15 @@ public class UserBalloonPufferfish extends UserEntity {
|
|||||||
HMCCPacketManager.sendInvisibilityPacket(pufferFishEntityId, sendTo);
|
HMCCPacketManager.sendInvisibilityPacket(pufferFishEntityId, sendTo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void destroyPufferfish() {
|
||||||
|
HMCCPacketManager.sendEntityDestroyPacket(pufferFishEntityId, getViewers());
|
||||||
|
getViewers().clear();
|
||||||
|
destroyed = true;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Player> refreshViewers(Location location) {
|
public List<Player> refreshViewers(Location location) {
|
||||||
if (System.currentTimeMillis() - getViewerLastUpdate() <= 1000) return List.of(); //Prevents mass refreshes
|
if (destroyed) return List.of(); //Prevents refreshing a destroyed entity
|
||||||
ArrayList<Player> newPlayers = new ArrayList<>();
|
return super.refreshViewers(location);
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,9 +4,11 @@ import com.hibiscusmc.hmccosmetics.config.Settings;
|
|||||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUsers;
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUsers;
|
||||||
import com.hibiscusmc.hmccosmetics.util.HMCCPlayerUtils;
|
import com.hibiscusmc.hmccosmetics.util.HMCCPlayerUtils;
|
||||||
|
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||||
import com.hibiscusmc.hmccosmetics.util.packets.HMCCPacketManager;
|
import com.hibiscusmc.hmccosmetics.util.packets.HMCCPacketManager;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@@ -42,10 +44,15 @@ public class UserEntity {
|
|||||||
ArrayList<Player> newPlayers = new ArrayList<>();
|
ArrayList<Player> newPlayers = new ArrayList<>();
|
||||||
ArrayList<Player> removePlayers = new ArrayList<>();
|
ArrayList<Player> removePlayers = new ArrayList<>();
|
||||||
List<Player> players = HMCCPlayerUtils.getNearbyPlayers(location);
|
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) {
|
for (Player player : players) {
|
||||||
CosmeticUser user = CosmeticUsers.getUser(player);
|
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);
|
removePlayers.add(player);
|
||||||
HMCCPacketManager.sendEntityDestroyPacket(ids, List.of(player));
|
HMCCPacketManager.sendEntityDestroyPacket(ids, List.of(player));
|
||||||
continue;
|
continue;
|
||||||
|
|||||||
@@ -83,8 +83,11 @@ public class UserWardrobeManager {
|
|||||||
this.viewingLocation = wardrobeLocation.getViewerLocation();
|
this.viewingLocation = wardrobeLocation.getViewerLocation();
|
||||||
this.npcLocation = wardrobeLocation.getNpcLocation();
|
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;
|
wardrobeStatus = WardrobeStatus.SETUP;
|
||||||
this.lastOpenMenu = Menus.getDefaultMenu();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void start() {
|
public void start() {
|
||||||
@@ -129,7 +132,7 @@ public class UserWardrobeManager {
|
|||||||
HMCCPacketManager.sendFakePlayerSpawnPacket(npcLocation, WARDROBE_UUID, NPC_ID, viewer);
|
HMCCPacketManager.sendFakePlayerSpawnPacket(npcLocation, WARDROBE_UUID, NPC_ID, viewer);
|
||||||
HMCCPacketManager.sendPlayerOverlayPacket(NPC_ID, viewer);
|
HMCCPacketManager.sendPlayerOverlayPacket(NPC_ID, viewer);
|
||||||
MessagesUtil.sendDebugMessages("Spawned Fake Player on " + npcLocation);
|
MessagesUtil.sendDebugMessages("Spawned Fake Player on " + npcLocation);
|
||||||
NMSHandlers.getHandler().hideNPCName(player, npcName);
|
NMSHandlers.getHandler().getPacketHandler().sendScoreboardHideNamePacket(player, npcName);
|
||||||
}, 4);
|
}, 4);
|
||||||
|
|
||||||
// Location
|
// Location
|
||||||
|
|||||||
@@ -63,6 +63,7 @@ public class HMCCInventoryUtils {
|
|||||||
case FEET -> CosmeticSlot.BOOTS;
|
case FEET -> CosmeticSlot.BOOTS;
|
||||||
case OFFHAND -> CosmeticSlot.OFFHAND;
|
case OFFHAND -> CosmeticSlot.OFFHAND;
|
||||||
case MAINHAND -> CosmeticSlot.MAINHAND;
|
case MAINHAND -> CosmeticSlot.MAINHAND;
|
||||||
|
default -> null;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ public class HMCCServerUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static org.bukkit.entity.Entity getEntity(int entityId) {
|
public static org.bukkit.entity.Entity getEntity(int entityId) {
|
||||||
return NMSHandlers.getHandler().getEntity(entityId);
|
return NMSHandlers.getHandler().getUtilHandler().getEntity(entityId);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -100,26 +100,13 @@ public class HMCCPacketManager extends PacketManager {
|
|||||||
int entityId,
|
int entityId,
|
||||||
List<Player> sendTo
|
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);
|
PacketContainer packet = new PacketContainer(PacketType.Play.Server.ENTITY_METADATA);
|
||||||
packet.getModifier().writeDefaults();
|
packet.getModifier().writeDefaults();
|
||||||
packet.getIntegers().write(0, entityId);
|
packet.getIntegers().write(0, entityId);
|
||||||
final List<WrappedDataValue> wrappedDataValueList = Lists.newArrayList();
|
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));
|
wrappedDataValueList.add(new WrappedDataValue(15, WrappedDataWatcher.Registry.get(Byte.class), (byte) 0x10));
|
||||||
packet.getDataValueCollectionModifier().write(0, wrappedDataValueList);
|
packet.getDataValueCollectionModifier().write(0, wrappedDataValueList);
|
||||||
for (Player p : sendTo) sendPacket(p, packet);
|
for (Player p : sendTo) sendPacket(p, packet);
|
||||||
|
|||||||
@@ -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-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.
|
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.
|
# 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:
|
disabled-worlds:
|
||||||
- "disabledworld"
|
- "disabledworld"
|
||||||
@@ -45,17 +51,8 @@ cosmetic-settings:
|
|||||||
emote-camera: true
|
emote-camera: true
|
||||||
# If a player should be able to move in an emote. This option really only affects if "emote-camera" is false
|
# If a player should be able to move in an emote. This option really only affects if "emote-camera" is false
|
||||||
emote-move: 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.
|
# 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: 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 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.
|
# 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
|
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
|
# 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.
|
# could cause console spam as HMCCosmetics has to reload itself as well.
|
||||||
reload-on-change: false
|
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:
|
worldguard:
|
||||||
# Checks worldguard regions for HMCC flags. If set to false, flags will not work properly.
|
# Checks worldguard regions for HMCC flags. If set to false, flags will not work properly.
|
||||||
# Requires restart to apply changes.
|
# Requires restart to apply changes.
|
||||||
@@ -177,6 +177,7 @@ wardrobe:
|
|||||||
default:
|
default:
|
||||||
distance: -1 # Distance in blocks that a player can interact with the wardrobe. -1 to ignore.
|
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.
|
permission: "hmccosmetics.wardrobe.default" # Permission required to use the wardrobe.
|
||||||
|
default-menu: defaultmenu
|
||||||
npc-location:
|
npc-location:
|
||||||
world: "world"
|
world: "world"
|
||||||
x: 0
|
x: 0
|
||||||
|
|||||||
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Binary file not shown.
4
gradle/wrapper/gradle-wrapper.properties
vendored
4
gradle/wrapper/gradle-wrapper.properties
vendored
@@ -1,5 +1,7 @@
|
|||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
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
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
|
|||||||
51
gradlew
vendored
51
gradlew
vendored
@@ -1,7 +1,7 @@
|
|||||||
#!/bin/sh
|
#!/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");
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
# you may not use this file except in compliance with 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
|
# Busybox and similar reduced shells will NOT work, because this script
|
||||||
# requires all of these POSIX shell features:
|
# requires all of these POSIX shell features:
|
||||||
# * functions;
|
# * functions;
|
||||||
# * expansions <EFBFBD>$var<EFBFBD>, <EFBFBD>${var}<EFBFBD>, <EFBFBD>${var:-default}<EFBFBD>, <EFBFBD>${var+SET}<EFBFBD>,
|
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
|
||||||
# <EFBFBD>${var#prefix}<EFBFBD>, <EFBFBD>${var%suffix}<EFBFBD>, and <EFBFBD>$( cmd )<EFBFBD>;
|
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
|
||||||
# * compound commands having a testable exit status, especially <EFBFBD>case<EFBFBD>;
|
# * compound commands having a testable exit status, especially «case»;
|
||||||
# * various built-in commands including <EFBFBD>command<EFBFBD>, <EFBFBD>set<EFBFBD>, and <EFBFBD>ulimit<EFBFBD>.
|
# * various built-in commands including «command», «set», and «ulimit».
|
||||||
#
|
#
|
||||||
# Important for patching:
|
# Important for patching:
|
||||||
#
|
#
|
||||||
@@ -55,7 +55,7 @@
|
|||||||
# Darwin, MinGW, and NonStop.
|
# Darwin, MinGW, and NonStop.
|
||||||
#
|
#
|
||||||
# (3) This script is generated from the Groovy template
|
# (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.
|
# within the Gradle project.
|
||||||
#
|
#
|
||||||
# You can find Gradle at https://github.com/gradle/gradle/.
|
# You can find Gradle at https://github.com/gradle/gradle/.
|
||||||
@@ -80,13 +80,11 @@ do
|
|||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
|
# This is normally unused
|
||||||
|
# shellcheck disable=SC2034
|
||||||
APP_NAME="Gradle"
|
|
||||||
APP_BASE_NAME=${0##*/}
|
APP_BASE_NAME=${0##*/}
|
||||||
|
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
|
||||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
|
||||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
|
||||||
|
|
||||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||||
MAX_FD=maximum
|
MAX_FD=maximum
|
||||||
@@ -133,22 +131,29 @@ location of your Java installation."
|
|||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
JAVACMD=java
|
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
|
Please set the JAVA_HOME variable in your environment to match the
|
||||||
location of your Java installation."
|
location of your Java installation."
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Increase the maximum file descriptors if we can.
|
# Increase the maximum file descriptors if we can.
|
||||||
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
||||||
case $MAX_FD in #(
|
case $MAX_FD in #(
|
||||||
max*)
|
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 ) ||
|
MAX_FD=$( ulimit -H -n ) ||
|
||||||
warn "Could not query maximum file descriptor limit"
|
warn "Could not query maximum file descriptor limit"
|
||||||
esac
|
esac
|
||||||
case $MAX_FD in #(
|
case $MAX_FD in #(
|
||||||
'' | soft) :;; #(
|
'' | 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" ||
|
ulimit -n "$MAX_FD" ||
|
||||||
warn "Could not set maximum file descriptor limit to $MAX_FD"
|
warn "Could not set maximum file descriptor limit to $MAX_FD"
|
||||||
esac
|
esac
|
||||||
@@ -193,11 +198,15 @@ if "$cygwin" || "$msys" ; then
|
|||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Collect all arguments for the java command;
|
|
||||||
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
|
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||||
# shell script including quotes and variable substitutions, so put them in
|
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||||
# double quotes to make sure that they get re-expanded; and
|
|
||||||
# * put everything else in single quotes, so that it's not re-expanded.
|
# 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 -- \
|
set -- \
|
||||||
"-Dorg.gradle.appname=$APP_BASE_NAME" \
|
"-Dorg.gradle.appname=$APP_BASE_NAME" \
|
||||||
@@ -205,6 +214,12 @@ set -- \
|
|||||||
org.gradle.wrapper.GradleWrapperMain \
|
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.
|
# Use "xargs" to parse quoted args.
|
||||||
#
|
#
|
||||||
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
|
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
|
||||||
|
|||||||
15
gradlew.bat
vendored
15
gradlew.bat
vendored
@@ -14,7 +14,7 @@
|
|||||||
@rem limitations under the License.
|
@rem limitations under the License.
|
||||||
@rem
|
@rem
|
||||||
|
|
||||||
@if "%DEBUG%" == "" @echo off
|
@if "%DEBUG%"=="" @echo off
|
||||||
@rem ##########################################################################
|
@rem ##########################################################################
|
||||||
@rem
|
@rem
|
||||||
@rem Gradle startup script for Windows
|
@rem Gradle startup script for Windows
|
||||||
@@ -25,7 +25,8 @@
|
|||||||
if "%OS%"=="Windows_NT" setlocal
|
if "%OS%"=="Windows_NT" setlocal
|
||||||
|
|
||||||
set DIRNAME=%~dp0
|
set DIRNAME=%~dp0
|
||||||
if "%DIRNAME%" == "" set DIRNAME=.
|
if "%DIRNAME%"=="" set DIRNAME=.
|
||||||
|
@rem This is normally unused
|
||||||
set APP_BASE_NAME=%~n0
|
set APP_BASE_NAME=%~n0
|
||||||
set APP_HOME=%DIRNAME%
|
set APP_HOME=%DIRNAME%
|
||||||
|
|
||||||
@@ -40,7 +41,7 @@ if defined JAVA_HOME goto findJavaFromJavaHome
|
|||||||
|
|
||||||
set JAVA_EXE=java.exe
|
set JAVA_EXE=java.exe
|
||||||
%JAVA_EXE% -version >NUL 2>&1
|
%JAVA_EXE% -version >NUL 2>&1
|
||||||
if "%ERRORLEVEL%" == "0" goto execute
|
if %ERRORLEVEL% equ 0 goto execute
|
||||||
|
|
||||||
echo.
|
echo.
|
||||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
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
|
:end
|
||||||
@rem End local scope for the variables with windows NT shell
|
@rem End local scope for the variables with windows NT shell
|
||||||
if "%ERRORLEVEL%"=="0" goto mainEnd
|
if %ERRORLEVEL% equ 0 goto mainEnd
|
||||||
|
|
||||||
:fail
|
:fail
|
||||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||||
rem the _cmd.exe /c_ return code!
|
rem the _cmd.exe /c_ return code!
|
||||||
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
|
set EXIT_CODE=%ERRORLEVEL%
|
||||||
exit /b 1
|
if %EXIT_CODE% equ 0 set EXIT_CODE=1
|
||||||
|
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
|
||||||
|
exit /b %EXIT_CODE%
|
||||||
|
|
||||||
:mainEnd
|
:mainEnd
|
||||||
if "%OS%"=="Windows_NT" endlocal
|
if "%OS%"=="Windows_NT" endlocal
|
||||||
|
|||||||
Reference in New Issue
Block a user