mirror of
https://github.com/HibiscusMC/HMCCosmetics.git
synced 2025-12-23 08:59:20 +00:00
Compare commits
232 Commits
| 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 | ||
|
|
05c13e8990 | ||
|
|
34b02574b2 | ||
|
|
f81d350a2e | ||
|
|
be86314daf | ||
|
|
345f903113 | ||
|
|
3cf265f231 | ||
|
|
d26e7df2ca | ||
|
|
e5dc3f6774 | ||
|
|
fdc9893a60 | ||
|
|
e8694076b8 | ||
|
|
1acf536080 | ||
|
|
9d3ad0b54b | ||
|
|
0b2ade1598 | ||
|
|
83651b7250 | ||
|
|
6818c09a69 | ||
|
|
dc72b677de | ||
|
|
5ff1a63eaa | ||
|
|
8300a86225 | ||
|
|
9e8084194a | ||
|
|
c0ea4d5a5b | ||
|
|
5a963391f8 | ||
|
|
6c4586a6b9 | ||
|
|
4cc0a6f968 | ||
|
|
ab8656ad1a | ||
|
|
ca5e0f96c2 | ||
|
|
5cddd24097 | ||
|
|
656e539ae3 | ||
|
|
862b7c9ee6 | ||
|
|
c632174de8 | ||
|
|
1e96303765 | ||
|
|
1a6d587ee0 | ||
|
|
adcb6de5e4 | ||
|
|
c36e263a95 | ||
|
|
de1e5bf100 | ||
|
|
ea25dcf208 | ||
|
|
e3c73d0bfe | ||
|
|
91b24bfa82 | ||
|
|
28bf5ba2b6 | ||
|
|
0249d6abdb | ||
|
|
cb32f635d0 | ||
|
|
3bfdde4281 | ||
|
|
8daa2709f3 | ||
|
|
35260d4abb | ||
|
|
2d44435d53 | ||
|
|
3d785bd157 | ||
|
|
c33cfbd302 | ||
|
|
f5ed39e02c | ||
|
|
0c3af0e0cd | ||
|
|
f5a1a67e1e | ||
|
|
ddc0a504fd | ||
|
|
de108753d5 | ||
|
|
b31e8b7a4b | ||
|
|
383fdfa7f6 | ||
|
|
54e867ab0b | ||
|
|
068ed3eb70 | ||
|
|
a203c60df1 | ||
|
|
e13c3fccb4 | ||
|
|
add72e66c9 | ||
|
|
0e587feff0 | ||
|
|
27be86c419 | ||
|
|
3d940d8468 | ||
|
|
7515cdd137 | ||
|
|
8e92f3e689 | ||
|
|
7c4b833d80 | ||
|
|
b291dc4c9f | ||
|
|
60b91df843 | ||
|
|
56f380025d | ||
|
|
b3e0acbcbd | ||
|
|
e2d334db9d | ||
|
|
dffcf6213b | ||
|
|
485f5837f4 | ||
|
|
442cddb81e | ||
|
|
1f38d1aa46 | ||
|
|
ce7dc03350 | ||
|
|
9a75fcb55b | ||
|
|
5522eed2d1 | ||
|
|
1737330b87 | ||
|
|
eff25664f3 | ||
|
|
27d3a1df42 | ||
|
|
63bda02869 | ||
|
|
8c251a8c69 | ||
|
|
4b481ef3ea | ||
|
|
2d62c96d3d | ||
|
|
f8cb436c5b | ||
|
|
0de31fcd04 | ||
|
|
99edb501a5 | ||
|
|
66aaed009f | ||
|
|
4c0b86b127 | ||
|
|
155133a2a0 | ||
|
|
93062d47a8 | ||
|
|
1f0c67a805 | ||
|
|
74feb112f6 | ||
|
|
967349f5af | ||
|
|
d7fe2475ed | ||
|
|
f87bf93641 | ||
|
|
4b467b4644 | ||
|
|
15234a904f | ||
|
|
9ff6d3f60c | ||
|
|
aeba867e9e | ||
|
|
d21e148f39 | ||
|
|
51188fdeba | ||
|
|
dcf072f3de | ||
|
|
ebf09d8e0f | ||
|
|
ca5cb25331 | ||
|
|
65877bff5b | ||
|
|
4a75c7b333 | ||
|
|
be4f1d6675 | ||
|
|
55d4f9ae09 | ||
|
|
88691956ba | ||
|
|
a6133a2b45 | ||
|
|
0aa821e51a | ||
|
|
fb37ea8af9 | ||
|
|
0f36803026 | ||
|
|
2910540c26 | ||
|
|
93fb885195 | ||
|
|
2438d5385f | ||
|
|
73ce071427 | ||
|
|
e3485b7733 | ||
|
|
7ff4fbb3d7 | ||
|
|
de5b9be6ac | ||
|
|
0c6e8eb160 | ||
|
|
9b85fd2d8c | ||
|
|
a136b95451 | ||
|
|
cf5eb64029 | ||
|
|
c4591b030b | ||
|
|
9dc6eb1dfc | ||
|
|
d7c1bf39e2 | ||
|
|
ae1527fca3 | ||
|
|
d14698b282 | ||
|
|
800d3be25f | ||
|
|
27599030cf | ||
|
|
3ee959abd6 | ||
|
|
617df48cc2 | ||
|
|
9e290c2dfd | ||
|
|
f98614c4ee | ||
|
|
d28bb23f8c | ||
|
|
502cb533f8 | ||
|
|
b7fdc2087a | ||
|
|
10a42a3c96 | ||
|
|
51fc52e24b | ||
|
|
be632d8e8c | ||
|
|
a732a2b0a0 | ||
|
|
b14a0b5d16 | ||
|
|
50393c62b0 | ||
|
|
dbc4a07895 | ||
|
|
ab329e4fbf | ||
|
|
90ad700d0a | ||
|
|
56529d6111 | ||
|
|
b6a06007e8 | ||
|
|
edccc9ce4e | ||
|
|
e0b2f0f6b1 | ||
|
|
57f4d3703c | ||
|
|
8ef6692198 | ||
|
|
c48830f3ac | ||
|
|
734c04c1f4 | ||
|
|
b08b4019a9 | ||
|
|
cfb7876b6e | ||
|
|
6047d0e3c3 | ||
|
|
880c333df9 | ||
|
|
c4d7b657dd | ||
|
|
5be3ce8d21 | ||
|
|
33bba631fc | ||
|
|
775b9c299d | ||
|
|
6e02331c13 | ||
|
|
b7457cec9c | ||
|
|
e7288a1910 | ||
|
|
26b90bd8bb | ||
|
|
24a10b6838 | ||
|
|
af7bc0dc3f | ||
|
|
162d4a6ed6 | ||
|
|
41140f60c5 | ||
|
|
a6145a607c | ||
|
|
89c6951a93 | ||
|
|
28c466e342 | ||
|
|
90caa23cd7 | ||
|
|
910f223151 | ||
|
|
ac1b50a957 | ||
|
|
9cb9bad3c8 | ||
|
|
f68e2633a2 | ||
|
|
c8ad5c0881 | ||
|
|
c93a718799 | ||
|
|
b5f781e00f | ||
|
|
f6cd73f436 | ||
|
|
8b0fcc5da9 | ||
|
|
b5787f22bf | ||
|
|
c1c431d914 | ||
|
|
b41dc66508 | ||
|
|
cfbf74257b | ||
|
|
9b2083b90a | ||
|
|
006319a757 | ||
|
|
a8ff8e6a7a | ||
|
|
8b20207442 | ||
|
|
8bbe12ed84 | ||
|
|
d23f3e19d2 |
142
build.gradle.kts
142
build.gradle.kts
@@ -2,13 +2,13 @@ import net.minecrell.pluginyml.bukkit.BukkitPluginDescription
|
||||
|
||||
plugins {
|
||||
id("java")
|
||||
id("com.github.johnrengelman.shadow") version "8.1.1"
|
||||
id("xyz.jpenilla.run-paper") version "2.0.0"
|
||||
id("com.gradleup.shadow") version "8.3.2"
|
||||
id("xyz.jpenilla.run-paper") version "2.3.1"
|
||||
id("net.minecrell.plugin-yml.bukkit") version "0.6.0"
|
||||
}
|
||||
|
||||
group = "com.hibiscusmc"
|
||||
version = "2.6.2"
|
||||
version = "2.7.4${getGitCommitHash()}"
|
||||
|
||||
allprojects {
|
||||
apply(plugin = "java")
|
||||
@@ -32,9 +32,6 @@ allprojects {
|
||||
// PlaceholderAPI
|
||||
maven("https://repo.extendedclip.com/content/repositories/placeholderapi/")
|
||||
|
||||
//Hikari
|
||||
maven("https://mvnrepository.com/artifact/com.zaxxer/HikariCP")
|
||||
|
||||
// Citizens & Denizen
|
||||
maven("https://maven.citizensnpcs.co/repo")
|
||||
|
||||
@@ -52,9 +49,6 @@ allprojects {
|
||||
}
|
||||
}
|
||||
|
||||
// UpdateChecker
|
||||
maven("https://hub.jeff-media.com/nexus/repository/jeff-media-public/")
|
||||
|
||||
// ParticleHelper
|
||||
maven("https://repo.bytecode.space/repository/maven-public/")
|
||||
|
||||
@@ -66,57 +60,54 @@ allprojects {
|
||||
|
||||
// MMOItems
|
||||
maven("https://nexus.phoenixdevt.fr/repository/maven-public/")
|
||||
|
||||
// Eco-Suite/Auxilor Repo
|
||||
maven("https://repo.auxilor.io/repository/maven-public/")
|
||||
|
||||
// Hibiscus Commons
|
||||
maven("https://repo.hibiscusmc.com/releases")
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compileOnly(fileTree("${project.rootDir}/lib") { include("*.jar") })
|
||||
compileOnly("com.mojang:authlib:1.5.25")
|
||||
compileOnly("org.spigotmc:spigot-api:1.18.2-R0.1-SNAPSHOT")
|
||||
compileOnly("org.jetbrains:annotations:23.0.0")
|
||||
compileOnly("com.comphenix.protocol:ProtocolLib:5.0.0")
|
||||
compileOnly("me.clip:placeholderapi:2.11.3")
|
||||
compileOnly("com.ticxo:modelengine:R3.0.1")
|
||||
compileOnly("com.github.oraxen:oraxen:1.160.0")
|
||||
compileOnly("com.github.LoneDev6:API-ItemsAdder:3.2.5")
|
||||
compileOnly("com.mineinabyss:geary-papermc:0.24.1")
|
||||
compileOnly("com.sk89q.worldguard:worldguard-bukkit:7.1.0-SNAPSHOT")
|
||||
compileOnly("it.unimi.dsi:fastutil:8.5.11")
|
||||
compileOnly("com.github.LeonMangler:SuperVanish:6.2.17")
|
||||
compileOnly("org.projectlombok:lombok:1.18.2")
|
||||
//compileOnly("org.spigotmc:spigot-api:1.18.2-R0.1-SNAPSHOT")
|
||||
compileOnly("io.papermc.paper:paper-api:1.20.1-R0.1-SNAPSHOT")
|
||||
compileOnly("org.jetbrains:annotations:24.1.0")
|
||||
compileOnly("com.comphenix.protocol:ProtocolLib:5.3.0")
|
||||
compileOnly("me.clip:placeholderapi:2.11.6")
|
||||
compileOnly("com.ticxo.modelengine:ModelEngine:R4.0.6")
|
||||
compileOnly("com.sk89q.worldguard:worldguard-bukkit:7.0.12")
|
||||
//compileOnly("it.unimi.dsi:fastutil:8.5.14")
|
||||
compileOnly("org.projectlombok:lombok:1.18.34")
|
||||
compileOnly("me.lojosho:HibiscusCommons:0.5.1")
|
||||
|
||||
annotationProcessor("org.projectlombok:lombok:1.18.28")
|
||||
testCompileOnly("org.projectlombok:lombok:1.18.28")
|
||||
testAnnotationProcessor("org.projectlombok:lombok:1.18.28")
|
||||
// Handled by Spigot Library Loader
|
||||
compileOnly("net.kyori:adventure-api:4.17.0")
|
||||
compileOnly("net.kyori:adventure-text-minimessage:4.17.0")
|
||||
compileOnly("net.kyori:adventure-platform-bukkit:4.3.3")
|
||||
|
||||
annotationProcessor("org.projectlombok:lombok:1.18.34")
|
||||
testCompileOnly("org.projectlombok:lombok:1.18.34")
|
||||
testAnnotationProcessor("org.projectlombok:lombok:1.18.34")
|
||||
|
||||
implementation("dev.triumphteam:triumph-gui:3.1.10") {
|
||||
exclude("net.kyori") // Already have adventure API
|
||||
}
|
||||
implementation("com.owen1212055:particlehelper:1.0.0-SNAPSHOT")
|
||||
implementation("com.ticxo.playeranimator:PlayerAnimator:R1.2.7")
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation(project(path = ":common"))
|
||||
implementation(project(path = ":v1_18_R2", configuration = "reobf"))
|
||||
implementation(project(path = ":v1_19_R1", configuration = "reobf"))
|
||||
implementation(project(path = ":v1_19_R2", configuration = "reobf"))
|
||||
implementation(project(path = ":v1_19_R3", configuration = "reobf"))
|
||||
implementation(project(path = ":v1_20_R1", configuration = "reobf"))
|
||||
|
||||
//compileOnly("com.github.Fisher2911:FisherLib:master-SNAPSHOT")
|
||||
implementation("net.kyori:adventure-api:4.11.0")
|
||||
implementation("net.kyori:adventure-text-minimessage:4.11.0")
|
||||
implementation("net.kyori:adventure-platform-bukkit:4.1.2")
|
||||
implementation("dev.triumphteam:triumph-gui:3.1.3")
|
||||
implementation("org.spongepowered:configurate-yaml:4.1.2")
|
||||
implementation("org.bstats:bstats-bukkit:3.0.0")
|
||||
implementation("com.jeff_media:SpigotUpdateChecker:3.0.0")
|
||||
implementation("com.owen1212055:particlehelper:1.0.0-SNAPSHOT")
|
||||
implementation("com.ticxo.playeranimator:PlayerAnimator:R1.2.7")
|
||||
implementation("com.github.BG-Software-LLC:CommentedConfiguration:-SNAPSHOT")
|
||||
//implementation("com.ticxo.playeranimator:PlayerAnimator:R1.2.5")
|
||||
}
|
||||
|
||||
tasks {
|
||||
|
||||
compileJava {
|
||||
options.encoding = Charsets.UTF_8.name()
|
||||
options.release.set(17)
|
||||
options.release.set(21)
|
||||
}
|
||||
|
||||
javadoc {
|
||||
@@ -129,28 +120,21 @@ tasks {
|
||||
}
|
||||
|
||||
runServer {
|
||||
minecraftVersion("1.20.1")
|
||||
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 {
|
||||
dependsOn(":v1_18_R2:reobfJar")
|
||||
dependsOn(":v1_19_R1:reobfJar")
|
||||
dependsOn(":v1_19_R2:reobfJar")
|
||||
dependsOn(":v1_19_R3:reobfJar")
|
||||
dependsOn(":v1_20_R1:reobfJar")
|
||||
mergeServiceFiles()
|
||||
|
||||
relocate("dev.triumphteam.gui", "com.hisbiscusmc.hmccosmetics.gui")
|
||||
relocate("me.mattstudios.mf", "com.hisbiscusmc.hmccosmetics.mf")
|
||||
relocate("net.kyori.adventure", "com.hisbiscusmc.hmccosmetics.adventure")
|
||||
relocate("org.spongepowered.configurate", "com.hisbiscusmc.hmccosmetics.configurate")
|
||||
relocate("org.bstats", "com.hisbiscusmc.hmccosmetics.bstats")
|
||||
relocate("com.zaxxer.hikaricp", "com.hisbiscusmc.hmccosmetics.hikaricp")
|
||||
relocate("com.j256.ormlite", "com.hisbiscusmc.hmccosmetics.ormlite")
|
||||
relocate("com.jeff_media.updatechecker", "com.hisbiscusmc.hmccosmetics.updatechecker")
|
||||
relocate("com.owen1212055.particlehelper", "com.hisbiscusmc.hmccosmetics.particlehelper")
|
||||
relocate("com.ticxo.playeranimator", "com.hisbiscusmc.hmccosmetics.playeranimator")
|
||||
relocate("com.bgsoftware", "com.hisbiscusmc.hmccosmetics.configupdater")
|
||||
relocate("dev.triumphteam.gui", "com.hibiscusmc.hmccosmetics.shaded.gui")
|
||||
relocate("com.owen1212055.particlehelper", "com.hibiscusmc.hmccosmetics.shaded.particlehelper")
|
||||
relocate("com.ticxo.playeranimator", "com.hibiscusmc.hmccosmetics.shaded.playeranimator")
|
||||
archiveFileName.set("HMCCosmeticsRemapped-${project.version}.jar")
|
||||
|
||||
dependencies {
|
||||
@@ -175,10 +159,10 @@ tasks {
|
||||
bukkit {
|
||||
load = BukkitPluginDescription.PluginLoadOrder.POSTWORLD
|
||||
main = "com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin"
|
||||
apiVersion = "1.18"
|
||||
apiVersion = "1.20"
|
||||
authors = listOf("LoJoSho")
|
||||
depend = listOf("ProtocolLib")
|
||||
softDepend = listOf("ModelEngine", "Oraxen", "ItemsAdder", "Geary", "HMCColor", "WorldGuard", "MythicMobs", "PlaceholderAPI", "SuperVanish", "PremiumVanish", "LibsDisguises", "Denizen", "MMOItems")
|
||||
depend = listOf("HibiscusCommons", "ProtocolLib")
|
||||
softDepend = listOf("ModelEngine", "Oraxen", "ItemsAdder", "Geary", "HMCColor", "WorldGuard", "MythicMobs", "PlaceholderAPI", "SuperVanish", "PremiumVanish", "LibsDisguises", "Denizen", "MMOItems", "Eco")
|
||||
version = "${project.version}"
|
||||
loadBefore = listOf(
|
||||
"Cosmin" // Fixes an issue with Cosmin loading before and taking /cosmetic, when messing with what we do.
|
||||
@@ -187,6 +171,7 @@ bukkit {
|
||||
commands {
|
||||
register("cosmetic") {
|
||||
description = "Base Cosmetic Command"
|
||||
aliases = listOf("hmccosmetics", "cosmetics")
|
||||
}
|
||||
}
|
||||
permissions {
|
||||
@@ -262,10 +247,39 @@ bukkit {
|
||||
register("hmccosmetics.unapplydeath.bypass") {
|
||||
default = BukkitPluginDescription.Permission.Default.OP
|
||||
}
|
||||
register("hmccosmetics.cmd.disableall") {
|
||||
default = BukkitPluginDescription.Permission.Default.OP
|
||||
}
|
||||
register("hmccosmetics.cmd.hiddenreasons") {
|
||||
default = BukkitPluginDescription.Permission.Default.OP
|
||||
}
|
||||
register("hmccosmetics.cmd.clearhiddenreasons") {
|
||||
default = BukkitPluginDescription.Permission.Default.OP
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
java {
|
||||
toolchain.languageVersion.set(JavaLanguageVersion.of(17
|
||||
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 ""
|
||||
}
|
||||
@@ -3,43 +3,8 @@ plugins {
|
||||
id("maven-publish")
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compileOnly("com.mojang:authlib:1.5.25")
|
||||
compileOnly("org.spigotmc:spigot-api:1.18.2-R0.1-SNAPSHOT")
|
||||
compileOnly("org.jetbrains:annotations:23.0.0")
|
||||
compileOnly("com.comphenix.protocol:ProtocolLib:5.0.0")
|
||||
compileOnly("me.clip:placeholderapi:2.11.3")
|
||||
compileOnly("com.ticxo:modelengine:R3.0.1")
|
||||
compileOnly("com.github.oraxen:oraxen:1.160.0")
|
||||
compileOnly("com.github.LoneDev6:API-ItemsAdder:3.2.5")
|
||||
compileOnly("com.mineinabyss:geary-papermc:0.24-SNAPSHOT")
|
||||
//compileOnly("com.hibiscus:hmccolor:0.3-SNAPSHOT") USE LIB PROVIDED FILE
|
||||
compileOnly("com.sk89q.worldguard:worldguard-bukkit:7.1.0-SNAPSHOT")
|
||||
compileOnly("it.unimi.dsi:fastutil:8.5.11")
|
||||
compileOnly("io.lumine:Mythic-Dist:5.2.1")
|
||||
compileOnly("com.denizenscript:denizen:1.2.7-SNAPSHOT")
|
||||
compileOnly("com.github.LeonMangler:SuperVanish:6.2.17")
|
||||
compileOnly("net.Indyuce:MMOItems-API:6.9.4-SNAPSHOT")
|
||||
compileOnlyApi("LibsDisguises:LibsDisguises:10.0.21") {
|
||||
exclude("org.spigotmc", "spigot")
|
||||
}
|
||||
|
||||
//compileOnly("com.github.Fisher2911:FisherLib:master-SNAPSHOT")
|
||||
implementation("net.kyori:adventure-api:4.12.0")
|
||||
implementation("net.kyori:adventure-text-minimessage:4.12.0")
|
||||
implementation("net.kyori:adventure-platform-bukkit:4.2.0")
|
||||
implementation("dev.triumphteam:triumph-gui:3.1.3")
|
||||
implementation("org.spongepowered:configurate-yaml:4.1.2")
|
||||
implementation("org.bstats:bstats-bukkit:3.0.0")
|
||||
implementation("com.jeff_media:SpigotUpdateChecker:3.0.0")
|
||||
implementation("com.owen1212055:particlehelper:1.0.0-SNAPSHOT")
|
||||
implementation("com.ticxo.playeranimator:PlayerAnimator:R1.2.7")
|
||||
implementation("com.github.BG-Software-LLC:CommentedConfiguration:-SNAPSHOT")
|
||||
//implementation("com.ticxo.playeranimator:PlayerAnimator:R1.2.5")
|
||||
}
|
||||
|
||||
java {
|
||||
toolchain.languageVersion.set(JavaLanguageVersion.of(17
|
||||
toolchain.languageVersion.set(JavaLanguageVersion.of(21
|
||||
))
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
pluginManagement {
|
||||
repositories {
|
||||
gradlePluginPortal()
|
||||
maven("https://repo.papermc.io/repository/maven-public/")
|
||||
}
|
||||
}
|
||||
|
||||
rootProject.name = "HMCCosmetics"
|
||||
@@ -1,91 +1,64 @@
|
||||
package com.hibiscusmc.hmccosmetics;
|
||||
|
||||
import com.bgsoftware.common.config.CommentedConfiguration;
|
||||
import com.hibiscusmc.hmccosmetics.api.HMCCosmeticsAPI;
|
||||
import com.hibiscusmc.hmccosmetics.api.events.HMCCosmeticSetupEvent;
|
||||
import com.hibiscusmc.hmccosmetics.command.CosmeticCommand;
|
||||
import com.hibiscusmc.hmccosmetics.command.CosmeticCommandTabComplete;
|
||||
import com.hibiscusmc.hmccosmetics.config.DatabaseSettings;
|
||||
import com.hibiscusmc.hmccosmetics.config.Settings;
|
||||
import com.hibiscusmc.hmccosmetics.config.WardrobeSettings;
|
||||
import com.hibiscusmc.hmccosmetics.config.serializer.ItemSerializer;
|
||||
import com.hibiscusmc.hmccosmetics.config.serializer.LocationSerializer;
|
||||
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
|
||||
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetics;
|
||||
import com.hibiscusmc.hmccosmetics.database.Database;
|
||||
import com.hibiscusmc.hmccosmetics.emotes.EmoteManager;
|
||||
import com.hibiscusmc.hmccosmetics.gui.Menu;
|
||||
import com.hibiscusmc.hmccosmetics.gui.Menus;
|
||||
import com.hibiscusmc.hmccosmetics.hooks.Hooks;
|
||||
import com.hibiscusmc.hmccosmetics.hooks.items.HookHMCCosmetics;
|
||||
import com.hibiscusmc.hmccosmetics.hooks.placeholders.HMCPlaceholderExpansion;
|
||||
import com.hibiscusmc.hmccosmetics.hooks.worldguard.WGHook;
|
||||
import com.hibiscusmc.hmccosmetics.hooks.worldguard.WGListener;
|
||||
import com.hibiscusmc.hmccosmetics.listener.PaperPlayerGameListener;
|
||||
import com.hibiscusmc.hmccosmetics.listener.PlayerConnectionListener;
|
||||
import com.hibiscusmc.hmccosmetics.listener.PlayerGameListener;
|
||||
import com.hibiscusmc.hmccosmetics.nms.NMSHandlers;
|
||||
import com.hibiscusmc.hmccosmetics.listener.ServerListener;
|
||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUsers;
|
||||
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||
import com.hibiscusmc.hmccosmetics.util.TranslationUtil;
|
||||
import com.jeff_media.updatechecker.UpdateCheckSource;
|
||||
import com.jeff_media.updatechecker.UpdateChecker;
|
||||
import com.ticxo.playeranimator.PlayerAnimatorImpl;
|
||||
import org.bstats.bukkit.Metrics;
|
||||
import me.lojosho.hibiscuscommons.HibiscusCommonsPlugin;
|
||||
import me.lojosho.hibiscuscommons.HibiscusPlugin;
|
||||
import me.lojosho.hibiscuscommons.config.serializer.ItemSerializer;
|
||||
import me.lojosho.hibiscuscommons.config.serializer.LocationSerializer;
|
||||
import me.lojosho.shaded.configupdater.common.config.CommentedConfiguration;
|
||||
import me.lojosho.shaded.configurate.ConfigurateException;
|
||||
import me.lojosho.shaded.configurate.ConfigurationOptions;
|
||||
import me.lojosho.shaded.configurate.yaml.NodeStyle;
|
||||
import me.lojosho.shaded.configurate.yaml.YamlConfigurationLoader;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.permissions.Permission;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.spongepowered.configurate.ConfigurateException;
|
||||
import org.spongepowered.configurate.ConfigurationNode;
|
||||
import org.spongepowered.configurate.ConfigurationOptions;
|
||||
import org.spongepowered.configurate.yaml.NodeStyle;
|
||||
import org.spongepowered.configurate.yaml.YamlConfigurationLoader;
|
||||
|
||||
import java.io.File;
|
||||
import java.nio.file.Path;
|
||||
|
||||
public final class HMCCosmeticsPlugin extends JavaPlugin {
|
||||
public final class HMCCosmeticsPlugin extends HibiscusPlugin {
|
||||
|
||||
private static HMCCosmeticsPlugin instance;
|
||||
private static boolean disable = false;
|
||||
private static YamlConfigurationLoader configLoader;
|
||||
private static final int pluginId = 13873;
|
||||
private static boolean onLatestVersion = true;
|
||||
private static String latestVersion = "";
|
||||
|
||||
public HMCCosmeticsPlugin() {
|
||||
super(13873, 1879);
|
||||
new HookHMCCosmetics();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
public void onStart() {
|
||||
// Plugin startup logic
|
||||
instance = this;
|
||||
// bstats https://bstats.org/plugin/bukkit/HMCCosmetics/13873
|
||||
Metrics metrics = new Metrics(this, pluginId);
|
||||
|
||||
// NMS version check
|
||||
if (!NMSHandlers.getHandler().getSupported()) {
|
||||
getLogger().severe("This version is not supported! Consider switching versions?");
|
||||
getServer().getPluginManager().disablePlugin(this);
|
||||
return;
|
||||
}
|
||||
|
||||
// Update Checker
|
||||
UpdateChecker checker = new UpdateChecker(this, UpdateCheckSource.POLYMART, "1879")
|
||||
.onSuccess((commandSenders, latestVersion) -> {
|
||||
this.latestVersion = (String) latestVersion;
|
||||
if (!this.latestVersion.equalsIgnoreCase(getDescription().getVersion())) {
|
||||
getLogger().info("+++++++++++++++++++++++++++++++++++");
|
||||
getLogger().info("There is a new update for HMCCosmetics!");
|
||||
getLogger().info("Please download it as soon as possible for possible fixes and new features.");
|
||||
getLogger().info("Current Version " + getDescription().getVersion() + " | Latest Version " + latestVersion);
|
||||
getLogger().info("Spigot: https://www.spigotmc.org/resources/100107/");
|
||||
getLogger().info("Polymart: https://polymart.org/resource/1879");
|
||||
getLogger().info("+++++++++++++++++++++++++++++++++++");
|
||||
}
|
||||
})
|
||||
.setNotifyRequesters(false)
|
||||
.setNotifyOpsOnJoin(false)
|
||||
.checkEveryXHours(24)
|
||||
.checkNow();
|
||||
onLatestVersion = checker.isUsingLatestVersion();
|
||||
// File setup
|
||||
saveDefaultConfig();
|
||||
if (!Path.of(getDataFolder().getPath(), "messages.yml").toFile().exists()) saveResource("messages.yml", false);
|
||||
@@ -93,12 +66,8 @@ public final class HMCCosmeticsPlugin extends JavaPlugin {
|
||||
if (!Path.of(getDataFolder().getPath() + "/cosmetics/").toFile().exists()) saveResource("cosmetics/defaultcosmetics.yml", false);
|
||||
if (!Path.of(getDataFolder().getPath() + "/menus/").toFile().exists()) saveResource("menus/defaultmenu.yml", false);
|
||||
|
||||
// Emote folder setup
|
||||
File emoteFile = new File(getDataFolder().getPath() + "/emotes");
|
||||
if (!emoteFile.exists()) emoteFile.mkdir();
|
||||
|
||||
// Player Animator
|
||||
PlayerAnimatorImpl.initialize(this);
|
||||
if (HMCCosmeticsAPI.getNMSVersion().contains("v1_19_R3") || HMCCosmeticsAPI.getNMSVersion().contains("v1_20_R1")) PlayerAnimatorImpl.initialize(this); // PlayerAnimator does not support 1.20.2 yet
|
||||
|
||||
// Configuration Sync
|
||||
final File configFile = Path.of(getInstance().getDataFolder().getPath(), "config.yml").toFile();
|
||||
@@ -106,13 +75,16 @@ public final class HMCCosmeticsPlugin extends JavaPlugin {
|
||||
final File translationFile = Path.of(getInstance().getDataFolder().getPath(), "translations.yml").toFile();
|
||||
try {
|
||||
CommentedConfiguration.loadConfiguration(configFile).syncWithConfig(configFile, getInstance().getResource("config.yml"),
|
||||
"database-settings", "debug-mode", "wardrobe.viewer-location", "wardrobe.npc-location", "wardrobe.wardrobe-location", "wardrobe.leave-location");
|
||||
"database-settings", "wardrobe.wardrobes", "debug-mode", "wardrobe.viewer-location", "wardrobe.npc-location", "wardrobe.wardrobe-location", "wardrobe.leave-location");
|
||||
CommentedConfiguration.loadConfiguration(messageFile).syncWithConfig(messageFile, getInstance().getResource("messages.yml"));
|
||||
CommentedConfiguration.loadConfiguration(translationFile).syncWithConfig(translationFile, getInstance().getResource("translations.yml"));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
// Move this over to Hibiscus Commons later
|
||||
if (Bukkit.getPluginManager().getPlugin("PlaceholderAPI") != null) new HMCPlaceholderExpansion().register();
|
||||
|
||||
// Setup
|
||||
setup();
|
||||
|
||||
@@ -123,7 +95,11 @@ public final class HMCCosmeticsPlugin extends JavaPlugin {
|
||||
// Listener
|
||||
getServer().getPluginManager().registerEvents(new PlayerConnectionListener(), this);
|
||||
getServer().getPluginManager().registerEvents(new PlayerGameListener(), this);
|
||||
|
||||
getServer().getPluginManager().registerEvents(new ServerListener(), this);
|
||||
// Taken from PaperLib
|
||||
if (HibiscusCommonsPlugin.isOnPaper()) {
|
||||
getServer().getPluginManager().registerEvents(new PaperPlayerGameListener(), this);
|
||||
}
|
||||
// Database
|
||||
new Database();
|
||||
|
||||
@@ -142,15 +118,17 @@ public final class HMCCosmeticsPlugin extends JavaPlugin {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
public void onEnd() {
|
||||
// Plugin shutdown logic
|
||||
disable = true;
|
||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||
CosmeticUser user = CosmeticUsers.getUser(player);
|
||||
if (user == null) continue;
|
||||
if (user.getUserEmoteManager().isPlayingEmote()) {
|
||||
player.setInvisible(false);
|
||||
}
|
||||
if (user.isInWardrobe()) {
|
||||
user.leaveWardrobe(true);
|
||||
}
|
||||
Database.save(user);
|
||||
}
|
||||
}
|
||||
@@ -214,9 +192,6 @@ public final class HMCCosmeticsPlugin extends JavaPlugin {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
// Misc Hooks setup (like items)
|
||||
Hooks.setup();
|
||||
|
||||
// Cosmetics setup
|
||||
Cosmetics.setup();
|
||||
|
||||
@@ -252,7 +227,7 @@ public final class HMCCosmeticsPlugin extends JavaPlugin {
|
||||
}
|
||||
}
|
||||
|
||||
EmoteManager.loadEmotes();
|
||||
if (Settings.isEmotesEnabled() && (HMCCosmeticsAPI.getNMSVersion().contains("v1_19_R3") || HMCCosmeticsAPI.getNMSVersion().contains("v1_20_R1"))) EmoteManager.loadEmotes(); // PlayerAnimator does not support 1.20.2 yet
|
||||
|
||||
getInstance().getLogger().info("Successfully Enabled HMCCosmetics");
|
||||
getInstance().getLogger().info(Cosmetics.values().size() + " Cosmetics Successfully Setup");
|
||||
@@ -262,28 +237,4 @@ public final class HMCCosmeticsPlugin extends JavaPlugin {
|
||||
|
||||
Bukkit.getPluginManager().callEvent(new HMCCosmeticSetupEvent());
|
||||
}
|
||||
|
||||
public static boolean isDisable() {
|
||||
return disable;
|
||||
}
|
||||
|
||||
public static YamlConfigurationLoader getConfigLoader() {
|
||||
return configLoader;
|
||||
}
|
||||
|
||||
public static void saveConfig(ConfigurationNode node) {
|
||||
try {
|
||||
HMCCosmeticsPlugin.getConfigLoader().save(node);
|
||||
HMCCosmeticsPlugin.getInstance().getLogger().info("Set new location " + node.path());
|
||||
} catch (ConfigurateException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isOnLatestVersion() {
|
||||
return onLatestVersion;
|
||||
}
|
||||
public static String getLatestVersion() {
|
||||
return latestVersion;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,9 +6,9 @@ import com.hibiscusmc.hmccosmetics.cosmetic.CosmeticSlot;
|
||||
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetics;
|
||||
import com.hibiscusmc.hmccosmetics.gui.Menu;
|
||||
import com.hibiscusmc.hmccosmetics.gui.Menus;
|
||||
import com.hibiscusmc.hmccosmetics.nms.NMSHandlers;
|
||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUsers;
|
||||
import me.lojosho.hibiscuscommons.nms.NMSHandlers;
|
||||
import org.bukkit.Color;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
package com.hibiscusmc.hmccosmetics.api.events;
|
||||
|
||||
import me.lojosho.shaded.configurate.ConfigurationNode;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Called when a cosmetic type not registered with HMCC default cosmetics is attempted to be registered. So if someone puts "test" in the config slot, and it's not a default cosmetic, this event will be called.
|
||||
*/
|
||||
public class CosmeticTypeRegisterEvent extends Event {
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
private final String id;
|
||||
private final ConfigurationNode config;
|
||||
|
||||
public CosmeticTypeRegisterEvent(String id, ConfigurationNode config) {
|
||||
this.id = id;
|
||||
this.config = config;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the id of the cosmetic trying to be registered. For example, "beanie" or "test"
|
||||
* @return The id. This is the key in the cosmetic config
|
||||
*/
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
* This will already be in the nested node below the id in the config.
|
||||
* @return The cosmetic config node in the cosmetic config that was attempted to get registered
|
||||
*/
|
||||
public ConfigurationNode getConfig() {
|
||||
return config;
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.hibiscusmc.hmccosmetics.command;
|
||||
|
||||
import com.hibiscusmc.hmccolor.HMCColorConfig;
|
||||
import com.hibiscusmc.hmccolor.HMCColorContextKt;
|
||||
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
|
||||
import com.hibiscusmc.hmccosmetics.config.Settings;
|
||||
import com.hibiscusmc.hmccosmetics.config.Wardrobe;
|
||||
@@ -17,7 +19,8 @@ import com.hibiscusmc.hmccosmetics.gui.special.DyeMenu;
|
||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUsers;
|
||||
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||
import com.hibiscusmc.hmccosmetics.util.ServerUtils;
|
||||
import com.hibiscusmc.hmccosmetics.util.HMCCServerUtils;
|
||||
import me.lojosho.hibiscuscommons.hooks.Hooks;
|
||||
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
|
||||
import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver;
|
||||
import org.apache.commons.lang3.EnumUtils;
|
||||
@@ -40,10 +43,14 @@ public class CosmeticCommand implements CommandExecutor {
|
||||
@Override
|
||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String @NotNull [] args) {
|
||||
boolean silent = false;
|
||||
boolean console = false;
|
||||
|
||||
if (!(sender instanceof Player)) {
|
||||
console = true;
|
||||
}
|
||||
|
||||
if (args.length == 0) {
|
||||
if (!(sender instanceof Player)) {
|
||||
// Console
|
||||
if (console) {
|
||||
return true;
|
||||
}
|
||||
if (!sender.hasPermission("hmccosmetics.cmd.default")) {
|
||||
@@ -104,7 +111,18 @@ public class CosmeticCommand implements CommandExecutor {
|
||||
}
|
||||
|
||||
if (sender.hasPermission("hmccosmetics.cmd.apply.color")) {
|
||||
if (args.length >= 4) color = ServerUtils.hex2Rgb(args[3]);
|
||||
if (args.length >= 4) {
|
||||
// TODO: Add sub-color support somehow... (and make this neater)
|
||||
String textColor = args[3];
|
||||
if (!textColor.contains("#") && Hooks.isActiveHook("HMCColor")) {
|
||||
HMCColorConfig.Colors colors = HMCColorContextKt.getHmcColor().getConfig().getColors().get(textColor);
|
||||
if (colors != null) {
|
||||
color = colors.getBaseColor().getColor();
|
||||
}
|
||||
} else {
|
||||
color = HMCCServerUtils.hex2Rgb(textColor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (args.length == 1) {
|
||||
@@ -126,7 +144,7 @@ public class CosmeticCommand implements CommandExecutor {
|
||||
|
||||
CosmeticUser user = CosmeticUsers.getUser(player);
|
||||
|
||||
if (!user.canEquipCosmetic(cosmetic)) {
|
||||
if (!user.canEquipCosmetic(cosmetic) && !console) {
|
||||
if (!silent) MessagesUtil.sendMessage(player, "no-cosmetic-permission");
|
||||
return true;
|
||||
}
|
||||
@@ -233,12 +251,16 @@ public class CosmeticCommand implements CommandExecutor {
|
||||
}
|
||||
// cosmetic menu exampleMenu playerName
|
||||
case ("menu") -> {
|
||||
if (args.length == 1) return true;
|
||||
if (!sender.hasPermission("hmccosmetics.cmd.menu")) {
|
||||
if (!silent) MessagesUtil.sendMessage(sender, "no-permission");
|
||||
return true;
|
||||
}
|
||||
Menu menu = Menus.getMenu(args[1]);
|
||||
Menu menu;
|
||||
if (args.length == 1) {
|
||||
menu = Menus.getDefaultMenu();
|
||||
} else {
|
||||
menu = Menus.getMenu(args[1]);
|
||||
}
|
||||
|
||||
if (sender instanceof Player) player = ((Player) sender).getPlayer();
|
||||
if (sender.hasPermission("hmccosmetics.cmd.menu.other")) {
|
||||
@@ -262,7 +284,6 @@ public class CosmeticCommand implements CommandExecutor {
|
||||
case ("dataclear") -> {
|
||||
if (args.length == 1) return true;
|
||||
OfflinePlayer selectedPlayer = Bukkit.getOfflinePlayer(args[1]);
|
||||
if (selectedPlayer == null) return true;
|
||||
if (!sender.hasPermission("hmccosmetics.cmd.dataclear") && !sender.isOp()) {
|
||||
if (!silent) MessagesUtil.sendMessage(sender, "no-permission");
|
||||
return true;
|
||||
@@ -297,7 +318,7 @@ public class CosmeticCommand implements CommandExecutor {
|
||||
if (!silent) MessagesUtil.sendMessage(player, "invalid-color");
|
||||
return true;
|
||||
}
|
||||
Color color = ServerUtils.hex2Rgb(args[2]);
|
||||
Color color = HMCCServerUtils.hex2Rgb(args[2]);
|
||||
if (color == null) {
|
||||
if (!silent) MessagesUtil.sendMessage(player, "invalid-color");
|
||||
return true;
|
||||
@@ -321,7 +342,7 @@ public class CosmeticCommand implements CommandExecutor {
|
||||
}
|
||||
Wardrobe wardrobe = WardrobeSettings.getWardrobe(args[1]);
|
||||
if (wardrobe == null) {
|
||||
wardrobe = new Wardrobe(args[1], new WardrobeLocation(null, null, null), null, -1);
|
||||
wardrobe = new Wardrobe(args[1], new WardrobeLocation(null, null, null), null, -1, null);
|
||||
WardrobeSettings.addWardrobe(wardrobe);
|
||||
//MessagesUtil.sendMessage(player, "no-wardrobes");
|
||||
//return true;
|
||||
@@ -334,7 +355,7 @@ public class CosmeticCommand implements CommandExecutor {
|
||||
}
|
||||
|
||||
if (args[2].equalsIgnoreCase("viewerlocation")) {
|
||||
WardrobeSettings.setViewerLocation(wardrobe, player.getLocation());
|
||||
WardrobeSettings.setViewerLocation(wardrobe, player.getEyeLocation());
|
||||
if (!silent) MessagesUtil.sendMessage(player, "set-wardrobe-viewing");
|
||||
return true;
|
||||
}
|
||||
@@ -352,7 +373,7 @@ public class CosmeticCommand implements CommandExecutor {
|
||||
return true;
|
||||
}
|
||||
if (args[2].equalsIgnoreCase("distance")) {
|
||||
WardrobeSettings.setWardrobeDistance(wardrobe, Integer.valueOf(args[3]));
|
||||
WardrobeSettings.setWardrobeDistance(wardrobe, Integer.parseInt(args[3]));
|
||||
if (!silent) MessagesUtil.sendMessage(player, "set-wardrobe-distance");
|
||||
return true;
|
||||
}
|
||||
@@ -414,7 +435,7 @@ public class CosmeticCommand implements CommandExecutor {
|
||||
CosmeticUser user = CosmeticUsers.getUser(player);
|
||||
|
||||
if (!silent) MessagesUtil.sendMessage(sender, "show-cosmetic");
|
||||
user.showCosmetics();
|
||||
user.showCosmetics(CosmeticUser.HiddenReason.COMMAND);
|
||||
return true;
|
||||
}
|
||||
case ("debug") -> {
|
||||
@@ -483,6 +504,63 @@ public class CosmeticCommand implements CommandExecutor {
|
||||
user.getUserEmoteManager().playEmote(args[1]);
|
||||
return true;
|
||||
}
|
||||
|
||||
case "disableall" -> {
|
||||
if (!sender.hasPermission("hmccosmetics.cmd.disableall")) {
|
||||
if (!silent) MessagesUtil.sendMessage(sender, "no-permission");
|
||||
return true;
|
||||
}
|
||||
if (args.length == 1) {
|
||||
if (!silent) MessagesUtil.sendMessage(player, "not-enough-args");
|
||||
return true;
|
||||
}
|
||||
if (args[1].equalsIgnoreCase("true")) {
|
||||
Settings.setAllPlayersHidden(true);
|
||||
for (CosmeticUser user : CosmeticUsers.values()) user.hideCosmetics(CosmeticUser.HiddenReason.DISABLED);
|
||||
if (!silent) MessagesUtil.sendMessage(sender, "disabled-all");
|
||||
} else if (args[1].equalsIgnoreCase("false")) {
|
||||
Settings.setAllPlayersHidden(false);
|
||||
for (CosmeticUser user : CosmeticUsers.values()) user.showCosmetics(CosmeticUser.HiddenReason.DISABLED);
|
||||
if (!silent) MessagesUtil.sendMessage(sender, "enabled-all");
|
||||
} else {
|
||||
if (!silent) MessagesUtil.sendMessage(sender, "invalid-args");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
case "hiddenreasons" -> {
|
||||
if (!sender.hasPermission("hmccosmetics.cmd.hiddenreasons")) {
|
||||
if (!silent) MessagesUtil.sendMessage(sender, "no-permission");
|
||||
return true;
|
||||
}
|
||||
if (args.length >= 2) {
|
||||
player = Bukkit.getPlayer(args[1]);
|
||||
}
|
||||
if (player == null) {
|
||||
if (!silent) MessagesUtil.sendMessage(sender, "invalid-player");
|
||||
return true;
|
||||
}
|
||||
CosmeticUser user = CosmeticUsers.getUser(player);
|
||||
sender.sendMessage(user.getHiddenReasons().toString());
|
||||
return true;
|
||||
}
|
||||
|
||||
case "clearhiddenreasons" -> {
|
||||
if (!sender.hasPermission("hmccosmetics.cmd.clearhiddenreasons")) {
|
||||
if (!silent) MessagesUtil.sendMessage(sender, "no-permission");
|
||||
return true;
|
||||
}
|
||||
if (args.length >= 2) {
|
||||
player = Bukkit.getPlayer(args[1]);
|
||||
}
|
||||
if (player == null) {
|
||||
if (!silent) MessagesUtil.sendMessage(sender, "invalid-player");
|
||||
return true;
|
||||
}
|
||||
CosmeticUser user = CosmeticUsers.getUser(player);
|
||||
user.clearHiddenReasons();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.hibiscusmc.hmccosmetics.command;
|
||||
|
||||
import com.hibiscusmc.hmccolor.HMCColorContextKt;
|
||||
import com.hibiscusmc.hmccosmetics.config.Wardrobe;
|
||||
import com.hibiscusmc.hmccosmetics.config.WardrobeSettings;
|
||||
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
|
||||
@@ -10,6 +11,7 @@ import com.hibiscusmc.hmccosmetics.gui.Menu;
|
||||
import com.hibiscusmc.hmccosmetics.gui.Menus;
|
||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUsers;
|
||||
import me.lojosho.hibiscuscommons.hooks.Hooks;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@@ -44,12 +46,16 @@ public class CosmeticCommandTabComplete implements TabCompleter {
|
||||
if (hasPermission(sender, "hmccosmetics.cmd.debug")) completions.add("debug");
|
||||
if (hasPermission(sender, "hmccosmetics.cmd.emote")) completions.add("emote");
|
||||
if (hasPermission(sender, "hmccosmetics.cmd.playemote")) completions.add("playemote");
|
||||
if (hasPermission(sender, "hmccosmetics.cmd.disableall")) completions.add("disableall");
|
||||
if (hasPermission(sender, "hmccosmetics.cmd.hiddenreasons")) completions.add("hiddenreasons");
|
||||
if (hasPermission(sender, "hmccosmetics.cmd.clearhiddenreasons")) completions.add("clearhiddenreasons");
|
||||
|
||||
StringUtil.copyPartialMatches(args[0], completions, finalCompletions);
|
||||
}
|
||||
|
||||
if (!(sender instanceof Player)) return completions;
|
||||
CosmeticUser user = CosmeticUsers.getUser(((Player) sender).getUniqueId());
|
||||
if (user == null) return completions; // User hasn't loaded in yet, can't do proper checks
|
||||
|
||||
if (args.length == 2) {
|
||||
String subcommand = args[0].toLowerCase();
|
||||
@@ -68,11 +74,15 @@ public class CosmeticCommandTabComplete implements TabCompleter {
|
||||
if (menu.canOpen(user.getPlayer())) completions.add(menu.getId());
|
||||
}
|
||||
}
|
||||
case "dataclear", "hide", "show", "emote" -> {
|
||||
case "dataclear", "hide", "show", "emote", "hiddenreasons", "clearhiddenreasons" -> {
|
||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||
completions.add(player.getName());
|
||||
}
|
||||
}
|
||||
case "disableall" -> {
|
||||
completions.add("true");
|
||||
completions.add("false");
|
||||
}
|
||||
case "wardrobe" -> {
|
||||
for (Wardrobe wardrobe : WardrobeSettings.getWardrobes()) {
|
||||
if (wardrobe.hasPermission()) {
|
||||
@@ -122,6 +132,7 @@ public class CosmeticCommandTabComplete implements TabCompleter {
|
||||
String subcommand = args[0].toLowerCase();
|
||||
switch (subcommand) {
|
||||
case "apply" -> {
|
||||
if (Hooks.isActiveHook("HMCColor")) completions.addAll(HMCColorContextKt.getHmcColor().getConfig().getColors().keySet());
|
||||
completions.add("#FFFFFF");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.hibiscusmc.hmccosmetics.config;
|
||||
|
||||
import lombok.Getter;
|
||||
import org.spongepowered.configurate.ConfigurationNode;
|
||||
import me.lojosho.shaded.configurate.ConfigurationNode;
|
||||
|
||||
public class DatabaseSettings {
|
||||
|
||||
|
||||
@@ -3,10 +3,14 @@ package com.hibiscusmc.hmccosmetics.config;
|
||||
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
|
||||
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import me.lojosho.shaded.configurate.ConfigurationNode;
|
||||
import org.bukkit.inventory.EquipmentSlot;
|
||||
import org.bukkit.util.Vector;
|
||||
import org.spongepowered.configurate.ConfigurationNode;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class Settings {
|
||||
@@ -26,27 +30,34 @@ public class Settings {
|
||||
private static final String UNAPPLY_DEATH_PATH = "unapply-on-death";
|
||||
private static final String FORCE_PERMISSION_JOIN_PATH = "force-permission-join";
|
||||
private static final String FORCE_SHOW_COSMETICS_PATH = "force-show-join";
|
||||
private static final String ITEM_PROCESSING_PATH = "item-processing";
|
||||
private static final String ITEM_PROCESS_DISPLAY_NAME_PATH = "display-name";
|
||||
private static final String ITEM_PROCESS_LORE_PATH = "lore";
|
||||
private static final String DISABLED_GAMEMODE_PATH = "disabled-gamemode";
|
||||
private static final String DISABLED_GAMEMODE_GAMEMODES_PATH = "gamemodes";
|
||||
private static final String EMOTE_DISTANCE_PATH = "emote-distance";
|
||||
private static final String HOOK_SETTING_PATH = "hook-settings";
|
||||
private static final String HOOK_ITEMADDER_PATH = "itemsadder";
|
||||
private static final String HOOK_NEXO_PATH = "nexo";
|
||||
private static final String HOOK_RELOAD_CHANGE_PATH = "reload-on-change";
|
||||
private static final String HOOK_WORLDGUARD_PATH = "worldguard";
|
||||
private static final String HOOK_WG_MOVE_CHECK_PATH = "player-move-check";
|
||||
private static final String HOOK_WG_MOVE_CHECK_PATH_LEGACY = "player_move_check";
|
||||
private static final String COSMETIC_EMOTE_ENABLE = "emote-enable";
|
||||
private static final String COSMETIC_EMOTE_CHECK_PATH = "emote-block-check";
|
||||
private static final String COSMETIC_EMOTE_AIR_CHECK_PATH = "emote-air-check";
|
||||
private static final String COSMETIC_EMOTE_DAMAGE_PATH = "emote-damage-leave";
|
||||
private static final String COSMETIC_EMOTE_INVINCIBLE_PATH = "emote-invincible";
|
||||
private static final String COSMETIC_EMOTE_CAMERA_PATH = "emote-camera";
|
||||
private static final String COSMETIC_EMOTE_MOVE_CHECK_PATH = "emote-move";
|
||||
private static final String COSMETIC_DISABLED_WORLDS_PATH = "disabled-worlds";
|
||||
private static final String COSMETIC_PACKET_ENTITY_TELEPORT_COOLDOWN_PATH = "entity-cooldown-teleport-packet";
|
||||
private static final String COSMETIC_BACKPACK_FORCE_RIDING_PACKET_PATH = "backpack-force-riding-packet";
|
||||
private static final String COSMETIC_ADD_ENCHANTS_HELMET_PATH = "helmet-add-enchantments";
|
||||
private static final String COSMETIC_ADD_ENCHANTS_CHESTPLATE_PATH = "chest-add-enchantments";
|
||||
private static final String COSMETIC_ADD_ENCHANTS_LEGGINGS_PATH = "leggings-add-enchantments";
|
||||
private static final String COSMETIC_ADD_ENCHANTS_BOOTS_PATH = "boots-add-enchantments";
|
||||
private static final String COSMETIC_DESTROY_LOOSE_COSMETIC_PATH = "destroy-loose-cosmetics";
|
||||
private static final String COSMETIC_BALLOON_HEAD_FORWARD_PATH = "balloon-head-forward";
|
||||
private static final String MENU_SETTINGS_PATH = "menu-settings";
|
||||
private static final String MENU_CLICK_COOLDOWN_PATH = "click-cooldown";
|
||||
private static final String MENU_CLICK_COOLDOWN_TIME_PATH = "time";
|
||||
private static final String COSMETIC_TYPE_SETTINGS_PATH = "cosmetic-type";
|
||||
private static final String EQUIP_CLICK_TYPE = "equip-click";
|
||||
private static final String UNEQUIP_CLICK_TYPE = "unequip-click";
|
||||
@@ -60,6 +71,7 @@ public class Settings {
|
||||
private static final String EQUIPABLE_COSMETIC_COLOR_PATH = "equipable-cosmetic-color";
|
||||
private static final String LOCKED_COSMETIC_COLOR_PATH = "locked-cosmetic-color";
|
||||
private static final String ENABLED_PATH = "enabled";
|
||||
private static final String SLOT_OPTIONS_PATH = "slot-options";
|
||||
|
||||
@Getter
|
||||
private static String defaultMenu;
|
||||
@@ -80,19 +92,18 @@ public class Settings {
|
||||
@Getter
|
||||
private static boolean forceShowOnJoin;
|
||||
@Getter
|
||||
private static boolean itemProcessingDisplayName;
|
||||
@Getter
|
||||
private static boolean itemProcessingLore;
|
||||
@Getter
|
||||
private static boolean itemsAdderChangeReload;
|
||||
@Getter
|
||||
private static boolean nexoChangeReload;
|
||||
@Getter
|
||||
private static boolean worldGuardMoveCheck;
|
||||
@Getter
|
||||
private static boolean cosmeticEmoteBlockCheck;
|
||||
@Getter
|
||||
private static boolean addHelmetEnchants;
|
||||
@Getter
|
||||
private static boolean addChestplateEnchants;
|
||||
@Getter
|
||||
private static boolean addLeggingEnchants;
|
||||
@Getter
|
||||
private static boolean addBootsEnchants;
|
||||
private static final HashMap<EquipmentSlot, SlotOptionConfig> slotOptions = new HashMap<>();
|
||||
@Getter
|
||||
private static boolean emoteAirCheck;
|
||||
@Getter
|
||||
@@ -104,12 +115,26 @@ public class Settings {
|
||||
@Getter
|
||||
private static boolean backpackForceRidingEnabled;
|
||||
@Getter
|
||||
private static boolean emotesEnabled;
|
||||
@Getter
|
||||
private static boolean disabledGamemodesEnabled;
|
||||
@Getter
|
||||
private static boolean balloonHeadForward;
|
||||
@Getter
|
||||
private static List<String> disabledGamemodes;
|
||||
@Getter
|
||||
private static List<String> disabledWorlds;
|
||||
@Getter
|
||||
private static int viewDistance;
|
||||
@Getter
|
||||
private static int tickPeriod;
|
||||
@Getter
|
||||
private static int packetEntityTeleportCooldown;
|
||||
@Getter
|
||||
private static Long defaultMenuCooldown;
|
||||
@Getter
|
||||
private static boolean menuClickCooldown;
|
||||
@Getter
|
||||
private static double emoteDistance;
|
||||
@Getter
|
||||
private static Vector balloonOffset;
|
||||
@@ -139,6 +164,8 @@ public class Settings {
|
||||
private static boolean emoteCameraEnabled;
|
||||
@Getter
|
||||
private static boolean emoteMoveCheck;
|
||||
@Getter @Setter
|
||||
private static boolean allPlayersHidden;
|
||||
|
||||
|
||||
public static void load(ConfigurationNode source) {
|
||||
@@ -158,9 +185,24 @@ public class Settings {
|
||||
|
||||
ConfigurationNode cosmeticSettings = source.node(COSMETIC_SETTINGS_PATH);
|
||||
|
||||
ConfigurationNode disabledGamemodeSettings = cosmeticSettings.node(DISABLED_GAMEMODE_PATH);
|
||||
disabledGamemodesEnabled = disabledGamemodeSettings.node(ENABLED_PATH).getBoolean(true);
|
||||
try {
|
||||
disabledGamemodes = disabledGamemodeSettings.node(DISABLED_GAMEMODE_GAMEMODES_PATH).getList(String.class);
|
||||
disabledWorlds = cosmeticSettings.node(COSMETIC_DISABLED_WORLDS_PATH).getList(String.class);
|
||||
} catch (Exception e) {
|
||||
disabledGamemodes = 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);
|
||||
forcePermissionJoin = cosmeticSettings.node(FORCE_PERMISSION_JOIN_PATH).getBoolean(false);
|
||||
forceShowOnJoin = cosmeticSettings.node(FORCE_SHOW_COSMETICS_PATH).getBoolean(false);
|
||||
emotesEnabled = cosmeticSettings.node(COSMETIC_EMOTE_ENABLE).getBoolean(true);
|
||||
emoteDistance = cosmeticSettings.node(EMOTE_DISTANCE_PATH).getDouble(-3);
|
||||
cosmeticEmoteBlockCheck = cosmeticSettings.node(COSMETIC_EMOTE_CHECK_PATH).getBoolean(true);
|
||||
emoteAirCheck = cosmeticSettings.node(COSMETIC_EMOTE_AIR_CHECK_PATH).getBoolean(true);
|
||||
@@ -168,18 +210,31 @@ public class Settings {
|
||||
emoteInvincible = cosmeticSettings.node(COSMETIC_EMOTE_INVINCIBLE_PATH).getBoolean(false);
|
||||
destroyLooseCosmetics = cosmeticSettings.node(COSMETIC_DESTROY_LOOSE_COSMETIC_PATH).getBoolean(false);
|
||||
backpackForceRidingEnabled = cosmeticSettings.node(COSMETIC_BACKPACK_FORCE_RIDING_PACKET_PATH).getBoolean(false);
|
||||
addHelmetEnchants = cosmeticSettings.node(COSMETIC_ADD_ENCHANTS_HELMET_PATH).getBoolean(false);
|
||||
addChestplateEnchants = cosmeticSettings.node(COSMETIC_ADD_ENCHANTS_CHESTPLATE_PATH).getBoolean(false);
|
||||
addLeggingEnchants = cosmeticSettings.node(COSMETIC_ADD_ENCHANTS_LEGGINGS_PATH).getBoolean(false);
|
||||
addBootsEnchants = cosmeticSettings.node(COSMETIC_ADD_ENCHANTS_BOOTS_PATH).getBoolean(false);
|
||||
|
||||
cosmeticSettings.node(SLOT_OPTIONS_PATH).childrenMap().forEach((key, value) -> {
|
||||
EquipmentSlot slot = convertConfigToEquipment(key.toString().toLowerCase());
|
||||
if (slot == null) {
|
||||
MessagesUtil.sendDebugMessages("Invalid slot option: " + key, Level.WARNING);
|
||||
return;
|
||||
}
|
||||
boolean addEnchantments = value.node("add-enchantments").getBoolean(false);
|
||||
boolean requireEmpty = value.node("require-empty").getBoolean(false);
|
||||
slotOptions.put(slot, new SlotOptionConfig(slot, addEnchantments, requireEmpty));
|
||||
});
|
||||
|
||||
tickPeriod = cosmeticSettings.node(TICK_PERIOD_PATH).getInt(-1);
|
||||
viewDistance = cosmeticSettings.node(VIEW_DISTANCE_PATH).getInt(-3);
|
||||
emoteCameraEnabled = cosmeticSettings.node(COSMETIC_EMOTE_CAMERA_PATH).getBoolean(true);
|
||||
emoteMoveCheck = cosmeticSettings.node(COSMETIC_EMOTE_MOVE_CHECK_PATH).getBoolean(false);
|
||||
packetEntityTeleportCooldown = cosmeticSettings.node(COSMETIC_PACKET_ENTITY_TELEPORT_COOLDOWN_PATH).getInt(-1);
|
||||
balloonHeadForward = cosmeticSettings.node(COSMETIC_BALLOON_HEAD_FORWARD_PATH).getBoolean(false);
|
||||
|
||||
ConfigurationNode menuSettings = source.node(MENU_SETTINGS_PATH);
|
||||
|
||||
ConfigurationNode clickCooldownSettings = menuSettings.node(MENU_CLICK_COOLDOWN_PATH);
|
||||
menuClickCooldown = clickCooldownSettings.node(ENABLED_PATH).getBoolean(true);
|
||||
defaultMenuCooldown = clickCooldownSettings.node(MENU_CLICK_COOLDOWN_TIME_PATH).getLong(1000L);
|
||||
|
||||
ConfigurationNode shadingSettings = menuSettings.node(SHADING_PATH);
|
||||
defaultShading = shadingSettings.node(ENABLED_PATH).getBoolean();
|
||||
firstRowShift = shadingSettings.node(FIRST_ROW_SHIFT_PATH).getString();
|
||||
@@ -205,9 +260,13 @@ public class Settings {
|
||||
dyeMenuOutputSlot = dyeMenuSettings.node(DYE_MENU_OUTPUT_SLOT).getInt(25);
|
||||
|
||||
ConfigurationNode hookSettings = source.node(HOOK_SETTING_PATH);
|
||||
|
||||
ConfigurationNode itemsAdderSettings = hookSettings.node(HOOK_ITEMADDER_PATH);
|
||||
itemsAdderChangeReload = itemsAdderSettings.node(HOOK_RELOAD_CHANGE_PATH).getBoolean(false);
|
||||
|
||||
ConfigurationNode nexoSettings = hookSettings.node(HOOK_NEXO_PATH);
|
||||
nexoChangeReload = nexoSettings.node(HOOK_RELOAD_CHANGE_PATH).getBoolean(true);
|
||||
|
||||
ConfigurationNode worldGuardSettings = hookSettings.node(HOOK_WORLDGUARD_PATH);
|
||||
worldGuardMoveCheck = worldGuardSettings.node(HOOK_WG_MOVE_CHECK_PATH).getBoolean(true);
|
||||
// I messed up in release 2.2.6 and forgot to change player_move_check to player-move-check.
|
||||
@@ -221,24 +280,9 @@ public class Settings {
|
||||
return new Vector(config.node("x").getDouble(), config.node("y").getDouble(), config.node("z").getDouble());
|
||||
}
|
||||
|
||||
public static boolean getShouldAddEnchants(EquipmentSlot slot) {
|
||||
switch (slot) {
|
||||
case HEAD -> {
|
||||
return addHelmetEnchants;
|
||||
}
|
||||
case CHEST -> {
|
||||
return addChestplateEnchants;
|
||||
}
|
||||
case LEGS -> {
|
||||
return addLeggingEnchants;
|
||||
}
|
||||
case FEET -> {
|
||||
return addBootsEnchants;
|
||||
}
|
||||
default -> {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
public static SlotOptionConfig getSlotOption(EquipmentSlot slot) {
|
||||
if (!slotOptions.containsKey(slot)) slotOptions.put(slot, new SlotOptionConfig(slot, false, false));
|
||||
return slotOptions.get(slot);
|
||||
}
|
||||
|
||||
public static void setDebugMode(boolean newSetting) {
|
||||
@@ -250,4 +294,16 @@ public class Settings {
|
||||
|
||||
plugin.saveConfig();
|
||||
}
|
||||
|
||||
private static EquipmentSlot convertConfigToEquipment(String slot) {
|
||||
return switch (slot) {
|
||||
case "helmet" -> EquipmentSlot.HEAD;
|
||||
case "chestplate" -> EquipmentSlot.CHEST;
|
||||
case "leggings" -> EquipmentSlot.LEGS;
|
||||
case "boots" -> EquipmentSlot.FEET;
|
||||
case "offhand" -> EquipmentSlot.OFF_HAND;
|
||||
case "mainhand" -> EquipmentSlot.HAND;
|
||||
default -> null;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.hibiscusmc.hmccosmetics.config;
|
||||
|
||||
import lombok.Getter;
|
||||
import org.bukkit.inventory.EquipmentSlot;
|
||||
|
||||
public class SlotOptionConfig {
|
||||
|
||||
@Getter
|
||||
private final EquipmentSlot slot;
|
||||
@Getter
|
||||
private final boolean addEnchantments;
|
||||
@Getter
|
||||
private final boolean requireEmpty;
|
||||
|
||||
public SlotOptionConfig(EquipmentSlot slot, boolean addEnchantments, boolean requireEmpty) {
|
||||
this.slot = slot;
|
||||
this.addEnchantments = addEnchantments;
|
||||
this.requireEmpty = requireEmpty;
|
||||
}
|
||||
}
|
||||
@@ -13,11 +13,13 @@ public class Wardrobe {
|
||||
@Getter
|
||||
private final String id;
|
||||
@Getter @Setter
|
||||
private int distance = WardrobeSettings.getDisplayRadius();
|
||||
@Getter @Setter
|
||||
private int distance;
|
||||
@Getter @Setter @Nullable
|
||||
private String permission;
|
||||
@Getter @Setter
|
||||
private WardrobeLocation location;
|
||||
@Getter @Setter @Nullable
|
||||
private String defaultMenu;
|
||||
|
||||
/**
|
||||
* This creates a Wardrobe object with all the information that a user will need when entering.
|
||||
@@ -25,12 +27,14 @@ public class Wardrobe {
|
||||
* @param location The 3 locations of the Wardrobe, if any of these 3 locations are null, the wardrobe will not work
|
||||
* @param permission The permission required to enter the wardrobe, if null, no permission is required
|
||||
* @param distance The distance from the wardrobe that the player can be to enter, if -1, the player can enter from any distance
|
||||
* @param defaultMenu The default menu that the player will open when entering the wardrobe.
|
||||
*/
|
||||
public Wardrobe(@NotNull String id, @NotNull WardrobeLocation location, @Nullable String permission, int distance) {
|
||||
public Wardrobe(@NotNull String id, @NotNull WardrobeLocation location, @Nullable String permission, int distance, @Nullable String defaultMenu) {
|
||||
this.id = id;
|
||||
this.location = location;
|
||||
this.distance = distance;
|
||||
if (permission != null) this.permission = permission;
|
||||
if (distance != -1) this.distance = distance;
|
||||
if (defaultMenu != null) this.defaultMenu = defaultMenu;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
package com.hibiscusmc.hmccosmetics.config;
|
||||
|
||||
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
|
||||
import com.hibiscusmc.hmccosmetics.config.serializer.LocationSerializer;
|
||||
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||
import com.hibiscusmc.hmccosmetics.util.misc.Utils;
|
||||
import lombok.Getter;
|
||||
import me.lojosho.hibiscuscommons.config.serializer.LocationSerializer;
|
||||
import me.lojosho.shaded.configurate.ConfigurationNode;
|
||||
import net.kyori.adventure.bossbar.BossBar;
|
||||
import org.apache.commons.lang3.EnumUtils;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Location;
|
||||
import org.spongepowered.configurate.ConfigurationNode;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
@@ -19,7 +19,6 @@ import java.util.logging.Level;
|
||||
public class WardrobeSettings {
|
||||
|
||||
private static final String DISABLE_ON_DAMAGE_PATH = "disable-on-damage";
|
||||
private static final String DISPLAY_RADIUS_PATH = "display-radius";
|
||||
private static final String PORTABLE_PATH = "portable";
|
||||
private static final String ALWAYS_DISPLAY_PATH = "always-display";
|
||||
private static final String ROTATION_SPEED_PATH = "rotation-speed";
|
||||
@@ -34,6 +33,8 @@ public class WardrobeSettings {
|
||||
private static final String EQUIP_PUMPKIN_WARDROBE = "equip-pumpkin";
|
||||
private static final String TRY_COSMETICS_WARDROBE = "unchecked-wardrobe-cosmetics";
|
||||
private static final String RETURN_LAST_LOCATION = "return-last-location";
|
||||
private static final String DAMAGE_KICK_PATH = "damage-kicked";
|
||||
private static final String PREVENT_DAMAGE_PATH = "prevent-damage";
|
||||
|
||||
private static final String WARDROBE_MENU_OPTIONS = "menu-options";
|
||||
private static final String WARDROBE_ENTER_OPEN_MENU_PATH = "enter-open-menu";
|
||||
@@ -44,6 +45,7 @@ public class WardrobeSettings {
|
||||
private static final String WARDROBES_PATH = "wardrobes";
|
||||
private static final String PERMISSION_PATH = "permission";
|
||||
private static final String DISTANCE_PATH = "distance";
|
||||
private static final String WARDROBE_DEFAULT_MENU = "default-menu";
|
||||
private static final String BOSSBAR_PATH = "bossbar";
|
||||
private static final String BOSSBAR_ENABLE_PATH = "enabled";
|
||||
private static final String BOSSBAR_TEXT_PATH = "text";
|
||||
@@ -62,8 +64,6 @@ public class WardrobeSettings {
|
||||
@Getter
|
||||
private static boolean disableOnDamage;
|
||||
@Getter
|
||||
private static int displayRadius;
|
||||
@Getter
|
||||
private static boolean portable;
|
||||
@Getter
|
||||
private static boolean alwaysDisplay;
|
||||
@@ -90,6 +90,10 @@ public class WardrobeSettings {
|
||||
@Getter
|
||||
private static boolean forceExitGamemode;
|
||||
@Getter
|
||||
private static boolean damagedKicked;
|
||||
@Getter
|
||||
private static boolean preventDamage;
|
||||
@Getter
|
||||
private static GameMode exitGamemode;
|
||||
private static HashMap<String, Wardrobe> wardrobes;
|
||||
@Getter
|
||||
@@ -115,7 +119,6 @@ public class WardrobeSettings {
|
||||
configRoot = source;
|
||||
|
||||
disableOnDamage = source.node(DISABLE_ON_DAMAGE_PATH).getBoolean();
|
||||
displayRadius = source.node(DISPLAY_RADIUS_PATH).getInt();
|
||||
portable = source.node(PORTABLE_PATH).getBoolean();
|
||||
alwaysDisplay = source.node(ALWAYS_DISPLAY_PATH).getBoolean();
|
||||
rotationSpeed = source.node(ROTATION_SPEED_PATH).getInt();
|
||||
@@ -125,6 +128,8 @@ public class WardrobeSettings {
|
||||
equipPumpkin = source.node(EQUIP_PUMPKIN_WARDROBE).getBoolean();
|
||||
returnLastLocation = source.node(RETURN_LAST_LOCATION).getBoolean(false);
|
||||
tryCosmeticsInWardrobe = source.node(TRY_COSMETICS_WARDROBE).getBoolean(false);
|
||||
damagedKicked = source.node(DAMAGE_KICK_PATH).getBoolean(false);
|
||||
preventDamage = source.node(PREVENT_DAMAGE_PATH).getBoolean(true);
|
||||
|
||||
ConfigurationNode menuOptionsNode = source.node(WARDROBE_MENU_OPTIONS);
|
||||
enterOpenMenu = menuOptionsNode.node(WARDROBE_ENTER_OPEN_MENU_PATH).getBoolean(false);
|
||||
@@ -169,12 +174,11 @@ public class WardrobeSettings {
|
||||
MessagesUtil.sendDebugMessages("Leave Location: " + leaveLocation);
|
||||
WardrobeLocation wardrobeLocation = new WardrobeLocation(npcLocation, viewerLocation, leaveLocation);
|
||||
|
||||
String permission = null;
|
||||
int distance = -1;
|
||||
if (!wardrobesNode.node(PERMISSION_PATH).virtual()) permission = wardrobesNode.node(PERMISSION_PATH).getString();
|
||||
if (!wardrobesNode.node(DISTANCE_PATH).virtual()) distance = wardrobesNode.node(DISTANCE_PATH).getInt();
|
||||
String permission = wardrobesNode.node(PERMISSION_PATH).getString();
|
||||
String defaultMenu = wardrobesNode.node(WARDROBE_DEFAULT_MENU).getString();
|
||||
int distance = wardrobesNode.node(DISTANCE_PATH).getInt(-1);
|
||||
|
||||
Wardrobe wardrobe = new Wardrobe(id, wardrobeLocation, permission, distance);
|
||||
Wardrobe wardrobe = new Wardrobe(id, wardrobeLocation, permission, distance, defaultMenu);
|
||||
addWardrobe(wardrobe);
|
||||
} catch (Exception e) {
|
||||
MessagesUtil.sendDebugMessages("Unable to create wardrobe " + id, Level.SEVERE);
|
||||
|
||||
@@ -1,165 +0,0 @@
|
||||
package com.hibiscusmc.hmccosmetics.config.serializer;
|
||||
|
||||
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
|
||||
import com.hibiscusmc.hmccosmetics.hooks.Hooks;
|
||||
import com.hibiscusmc.hmccosmetics.util.InventoryUtils;
|
||||
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||
import com.hibiscusmc.hmccosmetics.util.ServerUtils;
|
||||
import com.hibiscusmc.hmccosmetics.util.builder.ColorBuilder;
|
||||
import com.hibiscusmc.hmccosmetics.util.misc.StringUtils;
|
||||
import com.hibiscusmc.hmccosmetics.util.misc.Utils;
|
||||
import org.apache.commons.lang3.EnumUtils;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.inventory.ItemFlag;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.bukkit.inventory.meta.SkullMeta;
|
||||
import org.bukkit.persistence.PersistentDataType;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
import org.spongepowered.configurate.ConfigurationNode;
|
||||
import org.spongepowered.configurate.serialize.SerializationException;
|
||||
import org.spongepowered.configurate.serialize.TypeSerializer;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.ArrayList;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class ItemSerializer implements TypeSerializer<ItemStack> {
|
||||
|
||||
public static final ItemSerializer INSTANCE = new ItemSerializer();
|
||||
private static final String MATERIAL = "material";
|
||||
private static final String AMOUNT = "amount";
|
||||
private static final String NAME = "name";
|
||||
private static final String UNBREAKABLE = "unbreakable";
|
||||
private static final String GLOWING = "glowing";
|
||||
private static final String LORE = "lore";
|
||||
private static final String MODEL_DATA = "model-data";
|
||||
private static final String NBT_TAGS = "nbt-tag";
|
||||
private static final String ENCHANTS = "enchants";
|
||||
private static final String ITEM_FLAGS = "item-flags";
|
||||
private static final String TEXTURE = "texture";
|
||||
private static final String OWNER = "owner";
|
||||
private static final String COLOR = "color";
|
||||
private static final String RED = "red";
|
||||
private static final String GREEN = "green";
|
||||
private static final String BLUE = "blue";
|
||||
|
||||
private ItemSerializer() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack deserialize(final Type type, final ConfigurationNode source)
|
||||
throws SerializationException {
|
||||
final ConfigurationNode materialNode = source.node(MATERIAL);
|
||||
final ConfigurationNode amountNode = source.node(AMOUNT);
|
||||
final ConfigurationNode nameNode = source.node(NAME);
|
||||
final ConfigurationNode unbreakableNode = source.node(UNBREAKABLE);
|
||||
final ConfigurationNode glowingNode = source.node(GLOWING);
|
||||
final ConfigurationNode loreNode = source.node(LORE);
|
||||
final ConfigurationNode modelDataNode = source.node(MODEL_DATA);
|
||||
final ConfigurationNode nbtNode = source.node(NBT_TAGS);
|
||||
final ConfigurationNode enchantsNode = source.node(ENCHANTS);
|
||||
final ConfigurationNode itemFlagsNode = source.node(ITEM_FLAGS);
|
||||
final ConfigurationNode textureNode = source.node(TEXTURE);
|
||||
final ConfigurationNode ownerNode = source.node(OWNER);
|
||||
final ConfigurationNode colorNode = source.node(COLOR);
|
||||
final ConfigurationNode redNode = colorNode.node(RED);
|
||||
final ConfigurationNode greenNode = colorNode.node(GREEN);
|
||||
final ConfigurationNode blueNode = colorNode.node(BLUE);
|
||||
|
||||
if (materialNode.virtual()) return null;
|
||||
|
||||
String material = materialNode.getString();
|
||||
|
||||
ItemStack item = Hooks.getItem(material);
|
||||
if (item == null) {
|
||||
HMCCosmeticsPlugin.getInstance().getLogger().severe("Invalid Material -> " + material);
|
||||
return new ItemStack(Material.AIR);
|
||||
}
|
||||
item.setAmount(amountNode.getInt(1));
|
||||
|
||||
ItemMeta itemMeta = item.getItemMeta();
|
||||
if (itemMeta == null) return item;
|
||||
if (!nameNode.virtual())
|
||||
itemMeta.setDisplayName(StringUtils.parseStringToString(Utils.replaceIfNull(nameNode.getString(), "")));
|
||||
if (!unbreakableNode.virtual()) itemMeta.setUnbreakable(unbreakableNode.getBoolean());
|
||||
if (!glowingNode.virtual()) {
|
||||
itemMeta.addItemFlags(ItemFlag.HIDE_ENCHANTS);
|
||||
itemMeta.addEnchant(Enchantment.LUCK, 1, true);
|
||||
}
|
||||
if (!loreNode.virtual()) itemMeta.setLore(Utils.replaceIfNull(loreNode.getList(String.class),
|
||||
new ArrayList<String>()).
|
||||
stream().map(StringUtils::parseStringToString).collect(Collectors.toList()));
|
||||
if (!modelDataNode.virtual()) itemMeta.setCustomModelData(modelDataNode.getInt());
|
||||
|
||||
if (!nbtNode.virtual()) {
|
||||
for (ConfigurationNode nbtNodes : nbtNode.childrenMap().values()) {
|
||||
itemMeta.getPersistentDataContainer().set(NamespacedKey.minecraft(nbtNodes.key().toString()), PersistentDataType.STRING, nbtNodes.getString());
|
||||
}
|
||||
}
|
||||
|
||||
if (!enchantsNode.virtual()) {
|
||||
for (ConfigurationNode enchantNode : enchantsNode.childrenMap().values()) {
|
||||
if (Enchantment.getByKey(NamespacedKey.minecraft(enchantNode.key().toString())) == null) continue;
|
||||
itemMeta.addEnchant(Enchantment.getByKey(NamespacedKey.minecraft(enchantNode.key().toString())), enchantNode.getInt(1), true);
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
if (!itemFlagsNode.virtual()) {
|
||||
for (String itemFlag : itemFlagsNode.getList(String.class)) {
|
||||
if (!EnumUtils.isValidEnum(ItemFlag.class, itemFlag)) continue;
|
||||
MessagesUtil.sendDebugMessages("Added " + itemFlag + " to the item!");
|
||||
itemMeta.addItemFlags(ItemFlag.valueOf(itemFlag));
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
if (item.getType() == Material.PLAYER_HEAD) {
|
||||
SkullMeta skullMeta = (SkullMeta) itemMeta;
|
||||
if (!ownerNode.virtual()) {
|
||||
String ownerString = ownerNode.getString();
|
||||
if (ownerString.contains("%")) {
|
||||
// This means it has PAPI placeholders in it
|
||||
skullMeta.getPersistentDataContainer().set(InventoryUtils.getSkullOwner(), PersistentDataType.STRING, ownerString);
|
||||
}
|
||||
OfflinePlayer player = Bukkit.getOfflinePlayer(ownerString);
|
||||
skullMeta.setOwningPlayer(player);
|
||||
}
|
||||
|
||||
if (!textureNode.virtual()) {
|
||||
String textureString = textureNode.getString();
|
||||
if (textureString.contains("%")) {
|
||||
// This means it has PAPI placeholders in it
|
||||
skullMeta.getPersistentDataContainer().set(InventoryUtils.getSkullTexture(), PersistentDataType.STRING, textureString);
|
||||
}
|
||||
Bukkit.getUnsafe().modifyItemStack(item, "{SkullOwner:{Id:[I;0,0,0,0],Properties:{textures:[{Value:\""
|
||||
+ textureString + "\"}]}}}");
|
||||
|
||||
|
||||
itemMeta = skullMeta;
|
||||
}
|
||||
}
|
||||
|
||||
if (!colorNode.virtual()) {
|
||||
if (ColorBuilder.canBeColored(item.getType())) {
|
||||
if (!redNode.virtual()) {
|
||||
itemMeta = ColorBuilder.color(itemMeta, Color.fromRGB(redNode.getInt(0), greenNode.getInt(0), blueNode.getInt(0)));
|
||||
} else {
|
||||
itemMeta = ColorBuilder.color(itemMeta, ServerUtils.hex2Rgb(colorNode.getString("#FFFFFF")));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
item.setItemMeta(itemMeta);
|
||||
return item;
|
||||
}
|
||||
@Override
|
||||
public void serialize(final Type type, @Nullable final ItemStack obj, final ConfigurationNode node) throws SerializationException {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,46 +0,0 @@
|
||||
package com.hibiscusmc.hmccosmetics.config.serializer;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
import org.spongepowered.configurate.ConfigurationNode;
|
||||
import org.spongepowered.configurate.serialize.SerializationException;
|
||||
import org.spongepowered.configurate.serialize.TypeSerializer;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
|
||||
public class LocationSerializer implements TypeSerializer<Location> {
|
||||
|
||||
public static final LocationSerializer INSTANCE = new LocationSerializer();
|
||||
|
||||
private static final String WORLD = "world";
|
||||
private static final String X = "x";
|
||||
private static final String Y = "y";
|
||||
private static final String Z = "z";
|
||||
private static final String PITCH = "pitch";
|
||||
private static final String YAW = "yaw";
|
||||
|
||||
|
||||
private LocationSerializer() {}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public Location deserialize(final Type type, final ConfigurationNode source) throws SerializationException {
|
||||
final World world = Bukkit.getWorld(source.node(WORLD).getString());
|
||||
if (world == null) return null;
|
||||
return new Location(
|
||||
world,
|
||||
source.node(X).getDouble(),
|
||||
source.node(Y).getDouble(),
|
||||
source.node(Z).getDouble(),
|
||||
source.node(YAW).getFloat(),
|
||||
source.node(PITCH).getFloat()
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serialize(final Type type, @Nullable final Location loc, final ConfigurationNode source) throws SerializationException {
|
||||
// Empty
|
||||
}
|
||||
}
|
||||
@@ -1,16 +1,16 @@
|
||||
package com.hibiscusmc.hmccosmetics.cosmetic;
|
||||
|
||||
import com.hibiscusmc.hmccosmetics.config.serializer.ItemSerializer;
|
||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import me.lojosho.hibiscuscommons.config.serializer.ItemSerializer;
|
||||
import me.lojosho.shaded.configurate.ConfigurationNode;
|
||||
import me.lojosho.shaded.configurate.serialize.SerializationException;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.spongepowered.configurate.ConfigurationNode;
|
||||
import org.spongepowered.configurate.serialize.SerializationException;
|
||||
|
||||
import java.util.logging.Level;
|
||||
|
||||
|
||||
@@ -9,5 +9,6 @@ public enum CosmeticSlot {
|
||||
OFFHAND,
|
||||
BACKPACK,
|
||||
BALLOON,
|
||||
EMOTE
|
||||
EMOTE,
|
||||
CUSTOM
|
||||
}
|
||||
|
||||
@@ -2,17 +2,18 @@ package com.hibiscusmc.hmccosmetics.cosmetic;
|
||||
|
||||
import com.google.common.collect.HashBiMap;
|
||||
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
|
||||
import com.hibiscusmc.hmccosmetics.api.events.CosmeticTypeRegisterEvent;
|
||||
import com.hibiscusmc.hmccosmetics.config.Settings;
|
||||
import com.hibiscusmc.hmccosmetics.cosmetic.types.*;
|
||||
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||
import me.lojosho.shaded.configurate.CommentedConfigurationNode;
|
||||
import me.lojosho.shaded.configurate.ConfigurateException;
|
||||
import me.lojosho.shaded.configurate.ConfigurationNode;
|
||||
import me.lojosho.shaded.configurate.yaml.YamlConfigurationLoader;
|
||||
import org.apache.commons.lang3.EnumUtils;
|
||||
import org.jetbrains.annotations.Contract;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.spongepowered.configurate.CommentedConfigurationNode;
|
||||
import org.spongepowered.configurate.ConfigurateException;
|
||||
import org.spongepowered.configurate.ConfigurationNode;
|
||||
import org.spongepowered.configurate.yaml.YamlConfigurationLoader;
|
||||
|
||||
import java.io.File;
|
||||
import java.nio.file.Files;
|
||||
@@ -105,12 +106,13 @@ public class Cosmetics {
|
||||
MessagesUtil.sendDebugMessages("Unable to create " + id + " because " + slotNode.getString() + " is not a valid slot!", Level.WARNING);
|
||||
continue;
|
||||
}
|
||||
switch (CosmeticSlot.valueOf(cosmeticConfig.node("slot").getString())) {
|
||||
switch (CosmeticSlot.valueOf(slotNode.getString())) {
|
||||
case BALLOON -> new CosmeticBalloonType(id, cosmeticConfig);
|
||||
case BACKPACK -> new CosmeticBackpackType(id, cosmeticConfig);
|
||||
case MAINHAND -> new CosmeticMainhandType(id, cosmeticConfig);
|
||||
case EMOTE -> new CosmeticEmoteType(id, cosmeticConfig);
|
||||
default -> new CosmeticArmorType(id, cosmeticConfig);
|
||||
case HELMET, CHESTPLATE, LEGGINGS, BOOTS, OFFHAND -> new CosmeticArmorType(id, cosmeticConfig);
|
||||
default -> new CosmeticTypeRegisterEvent(id, cosmeticConfig).callEvent();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
if (Settings.isDebugMode()) e.printStackTrace();
|
||||
|
||||
@@ -2,17 +2,18 @@ package com.hibiscusmc.hmccosmetics.cosmetic.types;
|
||||
|
||||
import com.hibiscusmc.hmccosmetics.config.Settings;
|
||||
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
|
||||
import com.hibiscusmc.hmccosmetics.nms.NMSHandlers;
|
||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||
import com.hibiscusmc.hmccosmetics.util.InventoryUtils;
|
||||
import com.hibiscusmc.hmccosmetics.util.packets.PacketManager;
|
||||
import com.hibiscusmc.hmccosmetics.util.HMCCInventoryUtils;
|
||||
import com.hibiscusmc.hmccosmetics.util.packets.HMCCPacketManager;
|
||||
import me.lojosho.hibiscuscommons.util.packets.PacketManager;
|
||||
import me.lojosho.shaded.configurate.ConfigurationNode;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.HumanEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.EquipmentSlot;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.spongepowered.configurate.ConfigurationNode;
|
||||
|
||||
public class CosmeticArmorType extends Cosmetic {
|
||||
|
||||
@@ -21,24 +22,42 @@ public class CosmeticArmorType extends Cosmetic {
|
||||
public CosmeticArmorType(String id, ConfigurationNode config) {
|
||||
super(id, config);
|
||||
|
||||
this.equipSlot = InventoryUtils.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
|
||||
public void update(@NotNull CosmeticUser user) {
|
||||
if (user.getUserEmoteManager().isPlayingEmote() || user.isInWardrobe()) return;
|
||||
Entity entity = Bukkit.getEntity(user.getUniqueId());
|
||||
if (entity == null) return;
|
||||
if (user.getUserEmoteManager().isPlayingEmote()) return; // There has to be a better way of doing this...
|
||||
ItemStack cosmeticItem = user.getUserCosmeticItem(this);
|
||||
if (!(entity instanceof HumanEntity humanEntity)) return;
|
||||
ItemStack equippedItem = humanEntity.getInventory().getItem(equipSlot);
|
||||
if (Settings.getShouldAddEnchants(equipSlot)) {
|
||||
cosmeticItem.addUnsafeEnchantments(equippedItem.getEnchantments());
|
||||
if (Settings.getSlotOption(equipSlot).isRequireEmpty() && entity instanceof HumanEntity humanEntity) {
|
||||
if (!humanEntity.getInventory().getItem(equipSlot).getType().isAir()) return;
|
||||
}
|
||||
|
||||
NMSHandlers.getHandler().equipmentSlotUpdate(entity.getEntityId(), equipSlot, cosmeticItem, PacketManager.getViewers(entity.getLocation()));
|
||||
ItemStack item = getItem(user);
|
||||
if (item == null) return;
|
||||
PacketManager.equipmentSlotUpdate(entity.getEntityId(), equipSlot, item, HMCCPacketManager.getViewers(entity.getLocation()));
|
||||
}
|
||||
|
||||
public ItemStack getItem(@NotNull CosmeticUser user) {
|
||||
return getItem(user, user.getUserCosmeticItem(this));
|
||||
}
|
||||
|
||||
public ItemStack getItem(@NotNull CosmeticUser user, ItemStack cosmeticItem) {
|
||||
if (!(user.getEntity() instanceof HumanEntity humanEntity)) return null;
|
||||
if (Settings.getSlotOption(equipSlot).isAddEnchantments()) {
|
||||
ItemStack equippedItem = humanEntity.getInventory().getItem(equipSlot);
|
||||
cosmeticItem.addUnsafeEnchantments(equippedItem.getEnchantments());
|
||||
}
|
||||
// Basically, if force offhand is off AND there is no item in an offhand slot, then the equipment packet to add the cosmetic
|
||||
return cosmeticItem;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public EquipmentSlot getEquipSlot() {
|
||||
return this.equipSlot;
|
||||
}
|
||||
|
||||
@@ -2,11 +2,12 @@ package com.hibiscusmc.hmccosmetics.cosmetic.types;
|
||||
|
||||
import com.hibiscusmc.hmccosmetics.config.Settings;
|
||||
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
|
||||
import com.hibiscusmc.hmccosmetics.nms.NMSHandlers;
|
||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||
import com.hibiscusmc.hmccosmetics.util.packets.PacketManager;
|
||||
import com.hibiscusmc.hmccosmetics.util.packets.HMCCPacketManager;
|
||||
import lombok.Getter;
|
||||
import me.lojosho.hibiscuscommons.util.packets.PacketManager;
|
||||
import me.lojosho.shaded.configurate.ConfigurationNode;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Entity;
|
||||
@@ -15,7 +16,6 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.EquipmentSlot;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.spongepowered.configurate.ConfigurationNode;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -49,18 +49,22 @@ public class CosmeticBackpackType extends Cosmetic {
|
||||
Location loc = entity.getLocation().clone().add(0, 2, 0);
|
||||
|
||||
if (user.isInWardrobe() || !user.isBackpackSpawned()) return;
|
||||
// This needs to be moved to purely packet based, there are far to many plugin doing dumb stuff that prevents spawning armorstands ignoring our spawn reason.
|
||||
if (user.isHidden()) {
|
||||
// Sometimes the backpack is not despawned when the player is hidden (weird ass logic happening somewhere)
|
||||
user.despawnBackpack();
|
||||
return;
|
||||
}
|
||||
List<Player> outsideViewers = user.getUserBackpackManager().getEntityManager().refreshViewers(loc);
|
||||
|
||||
user.getUserBackpackManager().getEntityManager().teleport(loc);
|
||||
user.getUserBackpackManager().getEntityManager().setRotation((int) loc.getYaw(), isFirstPersonCompadible());
|
||||
|
||||
PacketManager.sendEntitySpawnPacket(user.getEntity().getLocation(), user.getUserBackpackManager().getFirstArmorStandId(), EntityType.ARMOR_STAND, UUID.randomUUID(), outsideViewers);
|
||||
PacketManager.sendArmorstandMetadata(user.getUserBackpackManager().getFirstArmorStandId(), outsideViewers);
|
||||
NMSHandlers.getHandler().equipmentSlotUpdate(user.getUserBackpackManager().getFirstArmorStandId(), EquipmentSlot.HEAD, user.getUserCosmeticItem(this, getItem()), outsideViewers);
|
||||
HMCCPacketManager.sendEntitySpawnPacket(user.getEntity().getLocation(), user.getUserBackpackManager().getFirstArmorStandId(), EntityType.ARMOR_STAND, UUID.randomUUID(), outsideViewers);
|
||||
HMCCPacketManager.sendArmorstandMetadata(user.getUserBackpackManager().getFirstArmorStandId(), outsideViewers);
|
||||
PacketManager.equipmentSlotUpdate(user.getUserBackpackManager().getFirstArmorStandId(), EquipmentSlot.HEAD, user.getUserCosmeticItem(this, getItem()), outsideViewers);
|
||||
// If true, it will send the riding packet to all players. If false, it will send the riding packet only to new players
|
||||
if (Settings.isBackpackForceRidingEnabled()) PacketManager.sendRidingPacket(entity.getEntityId(), user.getUserBackpackManager().getFirstArmorStandId(), user.getUserBackpackManager().getEntityManager().getViewers());
|
||||
else PacketManager.sendRidingPacket(entity.getEntityId(), user.getUserBackpackManager().getFirstArmorStandId(), outsideViewers);
|
||||
if (Settings.isBackpackForceRidingEnabled()) HMCCPacketManager.sendRidingPacket(entity.getEntityId(), user.getUserBackpackManager().getFirstArmorStandId(), user.getUserBackpackManager().getEntityManager().getViewers());
|
||||
else HMCCPacketManager.sendRidingPacket(entity.getEntityId(), user.getUserBackpackManager().getFirstArmorStandId(), outsideViewers);
|
||||
|
||||
if (!user.isInWardrobe() && isFirstPersonCompadible() && user.getPlayer() != null) {
|
||||
List<Player> owner = List.of(user.getPlayer());
|
||||
@@ -68,18 +72,18 @@ public class CosmeticBackpackType extends Cosmetic {
|
||||
ArrayList<Integer> particleCloud = user.getUserBackpackManager().getAreaEffectEntityId();
|
||||
for (int i = 0; i < particleCloud.size(); i++) {
|
||||
if (i == 0) {
|
||||
PacketManager.sendRidingPacket(entity.getEntityId(), particleCloud.get(i), owner);
|
||||
HMCCPacketManager.sendRidingPacket(entity.getEntityId(), particleCloud.get(i), owner);
|
||||
} else {
|
||||
PacketManager.sendRidingPacket(particleCloud.get(i - 1), particleCloud.get(i) , owner);
|
||||
HMCCPacketManager.sendRidingPacket(particleCloud.get(i - 1), particleCloud.get(i) , owner);
|
||||
}
|
||||
}
|
||||
PacketManager.sendRidingPacket(particleCloud.get(particleCloud.size() - 1), user.getUserBackpackManager().getFirstArmorStandId(), owner);
|
||||
if (!user.getHidden()) {
|
||||
HMCCPacketManager.sendRidingPacket(particleCloud.get(particleCloud.size() - 1), user.getUserBackpackManager().getFirstArmorStandId(), owner);
|
||||
if (!user.isHidden()) {
|
||||
//if (loc.getPitch() < -70) NMSHandlers.getHandler().equipmentSlotUpdate(user.getUserBackpackManager().getFirstArmorStandId(), EquipmentSlot.HEAD, new ItemStack(Material.AIR), owner);
|
||||
//else NMSHandlers.getHandler().equipmentSlotUpdate(user.getUserBackpackManager().getFirstArmorStandId(), EquipmentSlot.HEAD, firstPersonBackpack, owner);
|
||||
NMSHandlers.getHandler().equipmentSlotUpdate(user.getUserBackpackManager().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);
|
||||
}
|
||||
|
||||
user.getUserBackpackManager().showBackpack();
|
||||
|
||||
@@ -4,17 +4,16 @@ import com.hibiscusmc.hmccosmetics.config.Settings;
|
||||
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
|
||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||
import com.hibiscusmc.hmccosmetics.user.manager.UserBalloonManager;
|
||||
import com.hibiscusmc.hmccosmetics.util.packets.PacketManager;
|
||||
import com.hibiscusmc.hmccosmetics.util.packets.HMCCPacketManager;
|
||||
import lombok.Getter;
|
||||
import me.lojosho.shaded.configurate.ConfigurationNode;
|
||||
import me.lojosho.shaded.configurate.serialize.SerializationException;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.util.Vector;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.spongepowered.configurate.ConfigurationNode;
|
||||
import org.spongepowered.configurate.serialize.SerializationException;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -69,12 +68,13 @@ public class CosmeticBalloonType extends Cosmetic {
|
||||
Location newLocation = entity.getLocation();
|
||||
Location currentLocation = user.getBalloonManager().getLocation();
|
||||
newLocation = newLocation.clone().add(getBalloonOffset());
|
||||
if (Settings.isBalloonHeadForward()) newLocation.setPitch(0);
|
||||
|
||||
List<Player> viewer = PacketManager.getViewers(entity.getLocation());
|
||||
List<Player> viewer = HMCCPacketManager.getViewers(entity.getLocation());
|
||||
|
||||
if (entity.getLocation().getWorld() != userBalloonManager.getLocation().getWorld()) {
|
||||
userBalloonManager.getModelEntity().teleport(newLocation);
|
||||
PacketManager.sendTeleportPacket(userBalloonManager.getPufferfishBalloonId(), newLocation, false, viewer);
|
||||
HMCCPacketManager.sendTeleportPacket(userBalloonManager.getPufferfishBalloonId(), newLocation, false, viewer);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -82,17 +82,16 @@ public class CosmeticBalloonType extends Cosmetic {
|
||||
userBalloonManager.setVelocity(velocity.multiply(1.1));
|
||||
userBalloonManager.setLocation(newLocation);
|
||||
|
||||
PacketManager.sendTeleportPacket(userBalloonManager.getPufferfishBalloonId(), newLocation, false, viewer);
|
||||
PacketManager.sendLeashPacket(userBalloonManager.getPufferfishBalloonId(), entity.getEntityId(), viewer);
|
||||
if (user.getHidden()) {
|
||||
HMCCPacketManager.sendTeleportPacket(userBalloonManager.getPufferfishBalloonId(), newLocation, false, viewer);
|
||||
HMCCPacketManager.sendLeashPacket(userBalloonManager.getPufferfishBalloonId(), entity.getEntityId(), viewer);
|
||||
if (user.isHidden()) {
|
||||
userBalloonManager.getPufferfish().hidePufferfish();
|
||||
return;
|
||||
}
|
||||
if (!user.getHidden() && showLead) {
|
||||
if (!user.isHidden() && showLead) {
|
||||
List<Player> sendTo = userBalloonManager.getPufferfish().refreshViewers(newLocation);
|
||||
if (sendTo.isEmpty()) return;
|
||||
PacketManager.sendEntitySpawnPacket(newLocation, userBalloonManager.getPufferfishBalloonId(), EntityType.PUFFERFISH, userBalloonManager.getPufferfishBalloonUniqueId(), sendTo);
|
||||
PacketManager.sendInvisibilityPacket(userBalloonManager.getPufferfishBalloonId(), sendTo);
|
||||
user.getBalloonManager().getPufferfish().spawnPufferfish(newLocation, sendTo);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -3,8 +3,8 @@ package com.hibiscusmc.hmccosmetics.cosmetic.types;
|
||||
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
|
||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||
import me.lojosho.shaded.configurate.ConfigurationNode;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.spongepowered.configurate.ConfigurationNode;
|
||||
|
||||
public class CosmeticEmoteType extends Cosmetic {
|
||||
|
||||
|
||||
@@ -2,11 +2,11 @@ package com.hibiscusmc.hmccosmetics.cosmetic.types;
|
||||
|
||||
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
|
||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||
import com.hibiscusmc.hmccosmetics.util.PlayerUtils;
|
||||
import com.hibiscusmc.hmccosmetics.util.packets.PacketManager;
|
||||
import com.hibiscusmc.hmccosmetics.util.HMCCPlayerUtils;
|
||||
import com.hibiscusmc.hmccosmetics.util.packets.HMCCPacketManager;
|
||||
import me.lojosho.shaded.configurate.ConfigurationNode;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.spongepowered.configurate.ConfigurationNode;
|
||||
|
||||
public class CosmeticMainhandType extends Cosmetic {
|
||||
|
||||
@@ -18,6 +18,6 @@ public class CosmeticMainhandType extends Cosmetic {
|
||||
public void update(@NotNull CosmeticUser user) {
|
||||
Player player = user.getPlayer();
|
||||
|
||||
PacketManager.equipmentSlotUpdate(player.getEntityId(), user, getSlot(), PlayerUtils.getNearbyPlayers(player));
|
||||
HMCCPacketManager.equipmentSlotUpdate(player.getEntityId(), user, getSlot(), HMCCPlayerUtils.getNearbyPlayers(player));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.hibiscusmc.hmccosmetics.database;
|
||||
import com.hibiscusmc.hmccosmetics.config.DatabaseSettings;
|
||||
import com.hibiscusmc.hmccosmetics.database.types.Data;
|
||||
import com.hibiscusmc.hmccosmetics.database.types.MySQLData;
|
||||
import com.hibiscusmc.hmccosmetics.database.types.NoneData;
|
||||
import com.hibiscusmc.hmccosmetics.database.types.SQLiteData;
|
||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUsers;
|
||||
@@ -11,6 +12,8 @@ import lombok.Getter;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class Database {
|
||||
|
||||
@@ -18,18 +21,25 @@ public class Database {
|
||||
private static Data data;
|
||||
private static final MySQLData MYSQL_DATA = new MySQLData();
|
||||
private static final SQLiteData SQLITE_DATA = new SQLiteData();
|
||||
private static final NoneData NONE_DATA = new NoneData();
|
||||
|
||||
public Database() {
|
||||
String databaseType = DatabaseSettings.getDatabaseType();
|
||||
data = SQLITE_DATA; // default
|
||||
if (databaseType.equalsIgnoreCase("MySQL")) {
|
||||
data = MYSQL_DATA;
|
||||
data = SQLITE_DATA; // default to SQLite, then check if it's anything different
|
||||
switch (databaseType.toLowerCase()) {
|
||||
case "mysql":
|
||||
data = MYSQL_DATA;
|
||||
break;
|
||||
case "sqlite":
|
||||
// already the default
|
||||
break;
|
||||
case "none":
|
||||
data = NONE_DATA;
|
||||
MessagesUtil.sendDebugMessages("Database is set to none. Data will not be saved.", Level.WARNING);
|
||||
break;
|
||||
default:
|
||||
MessagesUtil.sendDebugMessages("Invalid database type. Defaulting to SQLite.", Level.WARNING);
|
||||
}
|
||||
/* SQLite is the default database. Might change in the future, so keep code here in case.
|
||||
if (databaseType.equalsIgnoreCase("sqlite")) {
|
||||
data = SQLITE_DATA;
|
||||
}
|
||||
*/
|
||||
MessagesUtil.sendDebugMessages("Database is " + data);
|
||||
|
||||
setup();
|
||||
@@ -47,7 +57,7 @@ public class Database {
|
||||
data.save(CosmeticUsers.getUser(player));
|
||||
}
|
||||
|
||||
public static CosmeticUser get(UUID uniqueId) {
|
||||
public static CompletableFuture<UserData> get(UUID uniqueId) {
|
||||
return data.get(uniqueId);
|
||||
}
|
||||
|
||||
|
||||
@@ -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.CosmeticSlot;
|
||||
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetics;
|
||||
import com.hibiscusmc.hmccosmetics.database.UserData;
|
||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||
import org.apache.commons.lang3.EnumUtils;
|
||||
@@ -13,9 +14,8 @@ import org.bukkit.Color;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
public abstract class Data {
|
||||
|
||||
@@ -24,7 +24,7 @@ public abstract class Data {
|
||||
public abstract void save(CosmeticUser user);
|
||||
|
||||
@Nullable
|
||||
public abstract CosmeticUser get(UUID uniqueId);
|
||||
public abstract CompletableFuture<UserData> get(UUID uniqueId);
|
||||
|
||||
public abstract void clear(UUID uniqueId);
|
||||
|
||||
@@ -32,9 +32,9 @@ public abstract class Data {
|
||||
@NotNull
|
||||
public final String serializeData(@NotNull CosmeticUser user) {
|
||||
StringBuilder data = new StringBuilder();
|
||||
if (user.getHidden()) {
|
||||
if (shouldHiddenSave(user.getHiddenReason())) {
|
||||
data.append("HIDDEN=").append(user.getHiddenReason());
|
||||
if (user.isHidden()) {
|
||||
for (CosmeticUser.HiddenReason reason : user.getHiddenReasons()) {
|
||||
if (shouldHiddenSave(reason)) data.append("HIDDEN=").append(reason);
|
||||
}
|
||||
}
|
||||
for (Cosmetic cosmetic : user.getCosmetics()) {
|
||||
@@ -50,15 +50,12 @@ public abstract class Data {
|
||||
return data.toString();
|
||||
}
|
||||
|
||||
public final Map<CosmeticSlot, Map<Cosmetic, Color>> deserializeData(CosmeticUser user, @NotNull String raw) {
|
||||
return deserializeData(user, raw, Settings.isForcePermissionJoin());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public final Map<CosmeticSlot, Map<Cosmetic, Color>> deserializeData(CosmeticUser user, @NotNull String raw, boolean permissionCheck) {
|
||||
Map<CosmeticSlot, Map<Cosmetic, Color>> cosmetics = new HashMap<>();
|
||||
public final HashMap<CosmeticSlot, Map.Entry<Cosmetic, Integer>> deserializeData(@NotNull String raw) {
|
||||
HashMap<CosmeticSlot, Map.Entry<Cosmetic, Integer>> cosmetics = new HashMap<>();
|
||||
|
||||
String[] rawData = raw.split(",");
|
||||
ArrayList<CosmeticUser.HiddenReason> hiddenReason = new ArrayList<>();
|
||||
for (String a : rawData) {
|
||||
if (a == null || a.isEmpty()) continue;
|
||||
String[] splitData = a.split("=");
|
||||
@@ -68,9 +65,7 @@ public abstract class Data {
|
||||
if (splitData[0].equalsIgnoreCase("HIDDEN")) {
|
||||
if (EnumUtils.isValidEnum(CosmeticUser.HiddenReason.class, splitData[1])) {
|
||||
if (Settings.isForceShowOnJoin()) continue;
|
||||
Bukkit.getScheduler().runTask(HMCCosmeticsPlugin.getInstance(), () -> {
|
||||
user.hideCosmetics(CosmeticUser.HiddenReason.valueOf(splitData[1]));
|
||||
});
|
||||
hiddenReason.add(CosmeticUser.HiddenReason.valueOf(splitData[1]));
|
||||
}
|
||||
continue;
|
||||
}
|
||||
@@ -79,31 +74,20 @@ public abstract class Data {
|
||||
String[] colorSplitData = splitData[1].split("&");
|
||||
if (Cosmetics.hasCosmetic(colorSplitData[0])) cosmetic = Cosmetics.getCosmetic(colorSplitData[0]);
|
||||
if (slot == null || cosmetic == null) continue;
|
||||
if (permissionCheck && cosmetic.requiresPermission()) {
|
||||
if (user.getPlayer() != null && !user.getPlayer().hasPermission(cosmetic.getPermission())) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
cosmetics.put(slot, Map.of(cosmetic, Color.fromRGB(Integer.parseInt(colorSplitData[1]))));
|
||||
cosmetics.put(slot, Map.entry(cosmetic, Integer.parseInt(colorSplitData[1])));
|
||||
} else {
|
||||
if (Cosmetics.hasCosmetic(splitData[1])) cosmetic = Cosmetics.getCosmetic(splitData[1]);
|
||||
if (slot == null || cosmetic == null) continue;
|
||||
if (permissionCheck && cosmetic.requiresPermission()) {
|
||||
if (user.getPlayer() != null && !user.getPlayer().hasPermission(cosmetic.getPermission())) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
HashMap<Cosmetic, Color> cosmeticColorHashMap = new HashMap<>();
|
||||
cosmeticColorHashMap.put(cosmetic, null);
|
||||
cosmetics.put(slot, cosmeticColorHashMap);
|
||||
cosmetics.put(slot, Map.entry(cosmetic, -1));
|
||||
}
|
||||
}
|
||||
|
||||
return cosmetics;
|
||||
}
|
||||
|
||||
private boolean shouldHiddenSave(CosmeticUser.HiddenReason reason) {
|
||||
switch (reason) {
|
||||
case EMOTE, NONE -> {
|
||||
case EMOTE, NONE, GAMEMODE, WORLD, DISABLED -> {
|
||||
return false;
|
||||
}
|
||||
default -> {
|
||||
|
||||
@@ -13,6 +13,7 @@ import java.sql.PreparedStatement;
|
||||
import java.sql.SQLException;
|
||||
import java.util.Properties;
|
||||
import java.util.UUID;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class MySQLData extends SQLData {
|
||||
|
||||
@@ -59,12 +60,17 @@ public class MySQLData extends SQLData {
|
||||
@Override
|
||||
public void clear(UUID uniqueId) {
|
||||
Bukkit.getScheduler().runTaskAsynchronously(HMCCosmeticsPlugin.getInstance(), () -> {
|
||||
PreparedStatement preparedSt = null;
|
||||
try {
|
||||
PreparedStatement preparedSt = preparedStatement("DELETE FROM COSMETICDATABASE WHERE UUID=?;");
|
||||
preparedSt = preparedStatement("DELETE FROM COSMETICDATABASE WHERE UUID=?;");
|
||||
preparedSt.setString(1, uniqueId.toString());
|
||||
preparedSt.executeUpdate();
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
try {
|
||||
if (preparedSt != null) preparedSt.close();
|
||||
} catch (SQLException e) {}
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -127,7 +133,14 @@ public class MySQLData extends SQLData {
|
||||
public PreparedStatement preparedStatement(String query) {
|
||||
PreparedStatement ps = null;
|
||||
|
||||
if (!isConnectionOpen()) MessagesUtil.sendDebugMessages("Connection is not open");
|
||||
if (!isConnectionOpen()) {
|
||||
MessagesUtil.sendDebugMessages("The MySQL database connection is not open (Could the database been idle for to long?). Reconnecting...", Level.WARNING);
|
||||
try {
|
||||
openConnection();
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
if (connection == null) throw new NullPointerException("Connection is null");
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
package com.hibiscusmc.hmccosmetics.database.types;
|
||||
|
||||
import com.hibiscusmc.hmccosmetics.database.UserData;
|
||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
public class NoneData extends Data {
|
||||
@Override
|
||||
public void setup() {
|
||||
// Nothing
|
||||
}
|
||||
|
||||
@Override
|
||||
public void save(CosmeticUser user) {
|
||||
// Nothing
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable CompletableFuture<UserData> get(UUID uniqueId) {
|
||||
return CompletableFuture.completedFuture(new UserData(uniqueId));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clear(UUID uniqueId) {
|
||||
// Nothing
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,7 @@ package com.hibiscusmc.hmccosmetics.database.types;
|
||||
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
|
||||
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
|
||||
import com.hibiscusmc.hmccosmetics.cosmetic.CosmeticSlot;
|
||||
import com.hibiscusmc.hmccosmetics.database.UserData;
|
||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Color;
|
||||
@@ -10,54 +11,58 @@ import org.bukkit.Color;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
public abstract class SQLData extends Data {
|
||||
@Override
|
||||
@SuppressWarnings({"resource"}) // Duplicate is from deprecated InternalData
|
||||
public CosmeticUser get(UUID uniqueId) {
|
||||
CosmeticUser user = new CosmeticUser(uniqueId);
|
||||
public CompletableFuture<UserData> get(UUID uniqueId) {
|
||||
return CompletableFuture.supplyAsync(() -> {
|
||||
UserData data = new UserData(uniqueId);
|
||||
|
||||
Bukkit.getScheduler().runTaskAsynchronously(HMCCosmeticsPlugin.getInstance(), () -> {
|
||||
PreparedStatement preparedStatement = null;
|
||||
try {
|
||||
PreparedStatement preparedStatement = preparedStatement("SELECT * FROM COSMETICDATABASE WHERE UUID = ?;");
|
||||
preparedStatement = preparedStatement("SELECT * FROM COSMETICDATABASE WHERE UUID = ?;");
|
||||
preparedStatement.setString(1, uniqueId.toString());
|
||||
ResultSet rs = preparedStatement.executeQuery();
|
||||
if (rs.next()) {
|
||||
String rawData = rs.getString("COSMETICS");
|
||||
Map<CosmeticSlot, Map<Cosmetic, Color>> cosmetics = deserializeData(user, rawData);
|
||||
for (Map<Cosmetic, Color> cosmeticColors : cosmetics.values()) {
|
||||
for (Cosmetic cosmetic : cosmeticColors.keySet()) {
|
||||
Bukkit.getScheduler().runTask(HMCCosmeticsPlugin.getInstance(), () -> {
|
||||
// This can not be async.
|
||||
user.addPlayerCosmetic(cosmetic, cosmeticColors.get(cosmetic));
|
||||
});
|
||||
}
|
||||
}
|
||||
HashMap<CosmeticSlot, Map.Entry<Cosmetic, Integer>> cosmetics = deserializeData(rawData);
|
||||
data.setCosmetics(cosmetics);
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
try {
|
||||
if (preparedStatement != null) preparedStatement.close();
|
||||
} catch (SQLException e) {}
|
||||
}
|
||||
return data;
|
||||
});
|
||||
|
||||
return user;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("resource")
|
||||
public void save(CosmeticUser user) {
|
||||
Runnable run = () -> {
|
||||
PreparedStatement preparedSt = null;
|
||||
try {
|
||||
PreparedStatement preparedSt = preparedStatement("REPLACE INTO COSMETICDATABASE(UUID,COSMETICS) VALUES(?,?);");
|
||||
preparedSt = preparedStatement("REPLACE INTO COSMETICDATABASE(UUID,COSMETICS) VALUES(?,?);");
|
||||
preparedSt.setString(1, user.getUniqueId().toString());
|
||||
preparedSt.setString(2, serializeData(user));
|
||||
preparedSt.executeUpdate();
|
||||
} catch (SQLException e) {
|
||||
throw new RuntimeException(e);
|
||||
} finally {
|
||||
try {
|
||||
if (preparedSt != null) preparedSt.close();
|
||||
} catch (SQLException e) {}
|
||||
}
|
||||
};
|
||||
if (!HMCCosmeticsPlugin.isDisable()) {
|
||||
if (!HMCCosmeticsPlugin.getInstance().isDisabled()) {
|
||||
Bukkit.getScheduler().runTaskAsynchronously(HMCCosmeticsPlugin.getInstance(), run);
|
||||
} else {
|
||||
run.run();
|
||||
|
||||
@@ -48,12 +48,17 @@ public class SQLiteData extends SQLData {
|
||||
@SuppressWarnings("resource")
|
||||
public void clear(UUID uniqueId) {
|
||||
Bukkit.getScheduler().runTaskAsynchronously(HMCCosmeticsPlugin.getInstance(), () -> {
|
||||
PreparedStatement preparedSt = null;
|
||||
try {
|
||||
PreparedStatement preparedSt = preparedStatement("DELETE FROM COSMETICDATABASE WHERE UUID=?;");
|
||||
preparedSt = preparedStatement("DELETE FROM COSMETICDATABASE WHERE UUID=?;");
|
||||
preparedSt.setString(1, uniqueId.toString());
|
||||
preparedSt.executeUpdate();
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
try {
|
||||
if (preparedSt != null) preparedSt.close();
|
||||
} catch (SQLException e) {}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -3,20 +3,23 @@ package com.hibiscusmc.hmccosmetics.gui;
|
||||
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
|
||||
import com.hibiscusmc.hmccosmetics.api.events.PlayerMenuOpenEvent;
|
||||
import com.hibiscusmc.hmccosmetics.config.Settings;
|
||||
import com.hibiscusmc.hmccosmetics.config.serializer.ItemSerializer;
|
||||
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
|
||||
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetics;
|
||||
import com.hibiscusmc.hmccosmetics.gui.type.Type;
|
||||
import com.hibiscusmc.hmccosmetics.gui.type.Types;
|
||||
import com.hibiscusmc.hmccosmetics.hooks.Hooks;
|
||||
import com.hibiscusmc.hmccosmetics.gui.type.types.TypeCosmetic;
|
||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||
import com.hibiscusmc.hmccosmetics.util.misc.Adventure;
|
||||
import com.hibiscusmc.hmccosmetics.util.misc.StringUtils;
|
||||
import dev.triumphteam.gui.builder.item.ItemBuilder;
|
||||
import dev.triumphteam.gui.guis.Gui;
|
||||
import dev.triumphteam.gui.guis.GuiItem;
|
||||
import lombok.Getter;
|
||||
import me.lojosho.hibiscuscommons.config.serializer.ItemSerializer;
|
||||
import me.lojosho.hibiscuscommons.hooks.Hooks;
|
||||
import me.lojosho.hibiscuscommons.util.AdventureUtils;
|
||||
import me.lojosho.hibiscuscommons.util.StringUtils;
|
||||
import me.lojosho.shaded.configurate.ConfigurationNode;
|
||||
import me.lojosho.shaded.configurate.serialize.SerializationException;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -24,12 +27,8 @@ import org.bukkit.event.inventory.ClickType;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.Contract;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.spongepowered.configurate.ConfigurationNode;
|
||||
import org.spongepowered.configurate.serialize.SerializationException;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
public class Menu {
|
||||
@@ -41,10 +40,12 @@ public class Menu {
|
||||
@Getter
|
||||
private final int rows;
|
||||
@Getter
|
||||
private final Long cooldown;
|
||||
@Getter
|
||||
private final ConfigurationNode config;
|
||||
@Getter
|
||||
private final String permissionNode;
|
||||
private final HashMap<Integer, MenuItem> items;
|
||||
private final HashMap<Integer, List<MenuItem>> items;
|
||||
@Getter
|
||||
private final int refreshRate;
|
||||
@Getter
|
||||
@@ -56,6 +57,7 @@ public class Menu {
|
||||
|
||||
title = config.node("title").getString("chest");
|
||||
rows = config.node("rows").getInt(1);
|
||||
cooldown = config.node("click-cooldown").getLong(Settings.getDefaultMenuCooldown());
|
||||
permissionNode = config.node("permission").getString("");
|
||||
refreshRate = config.node("refresh-rate").getInt(-1);
|
||||
shading = config.node("shading").getBoolean(Settings.isDefaultShading());
|
||||
@@ -91,7 +93,8 @@ public class Menu {
|
||||
try {
|
||||
item = ItemSerializer.INSTANCE.deserialize(ItemStack.class, config.node("item"));
|
||||
} catch (SerializationException e) {
|
||||
throw new RuntimeException(e);
|
||||
MessagesUtil.sendDebugMessages("Unable to get valid item for " + config.key().toString() + " " + e.getMessage());
|
||||
continue;
|
||||
}
|
||||
|
||||
if (item == null) {
|
||||
@@ -99,6 +102,8 @@ public class Menu {
|
||||
continue;
|
||||
}
|
||||
|
||||
int priority = config.node("priority").getInt(1);
|
||||
|
||||
Type type = null;
|
||||
|
||||
if (!config.node("type").virtual()) {
|
||||
@@ -107,7 +112,15 @@ public class Menu {
|
||||
}
|
||||
|
||||
for (Integer slot : slots) {
|
||||
items.put(slot, new MenuItem(slots, item, type, config));
|
||||
MenuItem menuItem = new MenuItem(slots, item, type, priority, config);
|
||||
if (items.containsKey(slot)) {
|
||||
List<MenuItem> menuItems = items.get(slot);
|
||||
menuItems.add(menuItem);
|
||||
menuItems.sort(priorityCompare);
|
||||
items.put(slot, menuItems);
|
||||
} else {
|
||||
items.put(slot, new ArrayList<>(Arrays.asList(menuItem)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -125,7 +138,7 @@ public class Menu {
|
||||
return;
|
||||
}
|
||||
}
|
||||
final Component component = Adventure.MINI_MESSAGE.deserialize(Hooks.processPlaceholders(player, this.title));
|
||||
final Component component = AdventureUtils.MINI_MESSAGE.deserialize(Hooks.processPlaceholders(player, this.title));
|
||||
Gui gui = Gui.gui()
|
||||
.title(component)
|
||||
.rows(this.rows)
|
||||
@@ -188,10 +201,11 @@ public class Menu {
|
||||
|
||||
if (items.containsKey(i)) {
|
||||
// Handles the items
|
||||
MenuItem item = items.get(i);
|
||||
updateItem(user, gui, item);
|
||||
List<MenuItem> menuItems = items.get(i);
|
||||
MenuItem item = menuItems.get(0);
|
||||
updateItem(user, gui, i);
|
||||
|
||||
if (item.type().getId().equalsIgnoreCase("cosmetic")) {
|
||||
if (item.type() instanceof TypeCosmetic) {
|
||||
Cosmetic cosmetic = Cosmetics.getCosmetic(item.itemConfig().node("cosmetic").getString(""));
|
||||
if (cosmetic == null) continue;
|
||||
if (user.hasCosmeticInSlot(cosmetic)) {
|
||||
@@ -215,26 +229,45 @@ public class Menu {
|
||||
MessagesUtil.sendDebugMessages("Updated menu with title " + title);
|
||||
gui.updateTitle(StringUtils.parseStringToString(Hooks.processPlaceholders(user.getPlayer(), title.toString())));
|
||||
} else {
|
||||
for (MenuItem item : items.values()) {
|
||||
updateItem(user, gui, item);
|
||||
for (int i = 0; i < gui.getInventory().getSize(); i++) {
|
||||
if (items.containsKey(i)) {
|
||||
updateItem(user, gui, i);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void updateItem(CosmeticUser user, Gui gui, MenuItem item) {
|
||||
Type type = item.type();
|
||||
for (int slot : item.slots()) {
|
||||
private void updateItem(CosmeticUser user, Gui gui, int slot) {
|
||||
if (!items.containsKey(slot)) return;
|
||||
List<MenuItem> menuItems = items.get(slot);
|
||||
if (menuItems.isEmpty()) return;
|
||||
|
||||
for (MenuItem item : menuItems) {
|
||||
Type type = item.type();
|
||||
ItemStack modifiedItem = getMenuItem(user, type, item.itemConfig(), item.item().clone(), slot);
|
||||
if (modifiedItem.getType().isAir()) continue;
|
||||
GuiItem guiItem = ItemBuilder.from(modifiedItem).asGuiItem();
|
||||
guiItem.setAction(event -> {
|
||||
MessagesUtil.sendDebugMessages("Selected slot " + slot);
|
||||
UUID uuid = user.getUniqueId();
|
||||
if (Settings.isMenuClickCooldown()) {
|
||||
Long userCooldown = Menus.getCooldown(uuid);
|
||||
if (userCooldown != 0 && (System.currentTimeMillis() - Menus.getCooldown(uuid) <= getCooldown())) {
|
||||
MessagesUtil.sendDebugMessages("Cooldown for " + user.getUniqueId() + " System time: " + System.currentTimeMillis() + " Cooldown: " + Menus.getCooldown(user.getUniqueId()) + " Difference: " + (System.currentTimeMillis() - Menus.getCooldown(user.getUniqueId())));
|
||||
MessagesUtil.sendMessage(user.getPlayer(), "on-click-cooldown");
|
||||
return;
|
||||
} else {
|
||||
Menus.addCooldown(user.getUniqueId(), System.currentTimeMillis());
|
||||
}
|
||||
}
|
||||
MessagesUtil.sendDebugMessages("Updated Menu Item in slot number " + slot);
|
||||
final ClickType clickType = event.getClick();
|
||||
if (type != null) type.run(user, item.itemConfig(), clickType);
|
||||
updateMenu(user, gui);
|
||||
});
|
||||
|
||||
MessagesUtil.sendDebugMessages("Added " + slot + " as " + guiItem + " in the menu");
|
||||
MessagesUtil.sendDebugMessages("Set an item in slot " + slot + " in the menu of " + getId());
|
||||
gui.updateItem(slot, guiItem);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -275,4 +308,6 @@ public class Menu {
|
||||
if (permissionNode.isEmpty()) return true;
|
||||
return player.isOp() || player.hasPermission(permissionNode);
|
||||
}
|
||||
|
||||
public static Comparator<MenuItem> priorityCompare = Comparator.comparing(MenuItem::priority).reversed();
|
||||
}
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
package com.hibiscusmc.hmccosmetics.gui;
|
||||
|
||||
import com.hibiscusmc.hmccosmetics.gui.type.Type;
|
||||
import me.lojosho.shaded.configurate.ConfigurationNode;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.spongepowered.configurate.ConfigurationNode;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public record MenuItem(List<Integer> slots, ItemStack item, Type type, ConfigurationNode itemConfig) {
|
||||
public record MenuItem(List<Integer> slots, ItemStack item, Type type, int priority, ConfigurationNode itemConfig) {
|
||||
|
||||
}
|
||||
|
||||
@@ -3,26 +3,24 @@ package com.hibiscusmc.hmccosmetics.gui;
|
||||
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
|
||||
import com.hibiscusmc.hmccosmetics.config.Settings;
|
||||
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||
import me.lojosho.shaded.configurate.CommentedConfigurationNode;
|
||||
import me.lojosho.shaded.configurate.ConfigurateException;
|
||||
import me.lojosho.shaded.configurate.yaml.YamlConfigurationLoader;
|
||||
import org.apache.commons.io.FilenameUtils;
|
||||
import org.jetbrains.annotations.Contract;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.spongepowered.configurate.CommentedConfigurationNode;
|
||||
import org.spongepowered.configurate.ConfigurateException;
|
||||
import org.spongepowered.configurate.yaml.YamlConfigurationLoader;
|
||||
|
||||
import java.io.File;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
import java.util.logging.Level;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
public class Menus {
|
||||
|
||||
private static final HashMap<String, Menu> MENUS = new HashMap<>();
|
||||
private static final HashMap<UUID, Long> COOLDOWNS = new HashMap<>();
|
||||
|
||||
public static void addMenu(Menu menu) {
|
||||
MENUS.put(menu.getId().toUpperCase(), menu);
|
||||
@@ -63,8 +61,21 @@ public class Menus {
|
||||
return MENUS.values();
|
||||
}
|
||||
|
||||
public static void addCooldown(UUID uuid, long time) {
|
||||
COOLDOWNS.put(uuid, time);
|
||||
}
|
||||
|
||||
public static Long getCooldown(UUID uuid) {
|
||||
return COOLDOWNS.getOrDefault(uuid, 0L);
|
||||
}
|
||||
|
||||
public static void removeCooldown(UUID uuid) {
|
||||
COOLDOWNS.remove(uuid);
|
||||
}
|
||||
|
||||
public static void setup() {
|
||||
MENUS.clear();
|
||||
COOLDOWNS.clear();
|
||||
|
||||
File cosmeticFolder = new File(HMCCosmeticsPlugin.getInstance().getDataFolder() + "/menus");
|
||||
if (!cosmeticFolder.exists()) cosmeticFolder.mkdir();
|
||||
|
||||
@@ -3,7 +3,7 @@ package com.hibiscusmc.hmccosmetics.gui.action;
|
||||
import com.hibiscusmc.hmccosmetics.gui.action.actions.*;
|
||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
@@ -2,8 +2,8 @@ package com.hibiscusmc.hmccosmetics.gui.action.actions;
|
||||
|
||||
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
|
||||
import com.hibiscusmc.hmccosmetics.gui.action.Action;
|
||||
import com.hibiscusmc.hmccosmetics.hooks.Hooks;
|
||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||
import me.lojosho.hibiscuscommons.hooks.Hooks;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ public class ActionCosmeticHide extends Action {
|
||||
|
||||
@Override
|
||||
public void run(@NotNull CosmeticUser user, String raw) {
|
||||
if (user.getHidden()) return;
|
||||
if (user.isHidden()) return;
|
||||
user.hideCosmetics(CosmeticUser.HiddenReason.ACTION);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,10 +12,10 @@ public class ActionCosmeticShow extends Action {
|
||||
|
||||
@Override
|
||||
public void run(@NotNull CosmeticUser user, String raw) {
|
||||
if (!user.getHidden()) return;
|
||||
if (!user.isHidden()) return;
|
||||
|
||||
// Do not hide if it's already off for WG
|
||||
if (user.getHiddenReason() != CosmeticUser.HiddenReason.ACTION && user.getHiddenReason() != CosmeticUser.HiddenReason.COMMAND) return;
|
||||
user.showCosmetics();
|
||||
if (!user.isHidden(CosmeticUser.HiddenReason.ACTION) && !user.isHidden(CosmeticUser.HiddenReason.COMMAND)) return;
|
||||
user.showCosmetics(CosmeticUser.HiddenReason.ACTION);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,9 +12,9 @@ public class ActionCosmeticToggle extends Action {
|
||||
|
||||
@Override
|
||||
public void run(@NotNull CosmeticUser user, String raw) {
|
||||
if (user.getHidden()) {
|
||||
if (user.getHiddenReason() != CosmeticUser.HiddenReason.ACTION && user.getHiddenReason() != CosmeticUser.HiddenReason.COMMAND) return;
|
||||
user.showCosmetics();
|
||||
if (user.isHidden()) {
|
||||
if (!user.isHidden(CosmeticUser.HiddenReason.ACTION) && !user.isHidden(CosmeticUser.HiddenReason.COMMAND)) return;
|
||||
user.showCosmetics(CosmeticUser.HiddenReason.ACTION);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -3,8 +3,8 @@ package com.hibiscusmc.hmccosmetics.gui.action.actions;
|
||||
import com.hibiscusmc.hmccosmetics.gui.action.Action;
|
||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||
import com.hibiscusmc.hmccosmetics.util.ServerUtils;
|
||||
import com.hibiscusmc.hmccosmetics.util.packets.PacketManager;
|
||||
import com.hibiscusmc.hmccosmetics.util.HMCCServerUtils;
|
||||
import com.hibiscusmc.hmccosmetics.util.packets.HMCCPacketManager;
|
||||
import com.owen1212055.particlehelper.api.particle.types.BlockDataParticle;
|
||||
import com.owen1212055.particlehelper.api.particle.types.DestinationParticle;
|
||||
import com.owen1212055.particlehelper.api.particle.types.velocity.VelocityParticle;
|
||||
@@ -42,9 +42,9 @@ public class ActionParticle extends Action {
|
||||
return;
|
||||
}
|
||||
|
||||
particle = ServerUtils.addParticleValues(particle, rawString);
|
||||
particle = HMCCServerUtils.addParticleValues(particle, rawString);
|
||||
Location location = user.getPlayer().getLocation();
|
||||
for (Player player : PacketManager.getViewers(location)) {
|
||||
for (Player player : HMCCPacketManager.getViewers(location)) {
|
||||
particle.compile().send(player, location);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.hibiscusmc.hmccosmetics.gui.action.actions;
|
||||
import com.hibiscusmc.hmccosmetics.gui.action.Action;
|
||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||
import me.lojosho.hibiscuscommons.hooks.Hooks;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class ActionPlayerCommand extends Action {
|
||||
@@ -13,6 +14,6 @@ public class ActionPlayerCommand extends Action {
|
||||
|
||||
@Override
|
||||
public void run(@NotNull CosmeticUser user, String raw) {
|
||||
user.getPlayer().performCommand(MessagesUtil.processStringNoKeyString(user.getPlayer(), raw));
|
||||
user.getPlayer().performCommand(MessagesUtil.processStringNoKeyString(user.getPlayer(), Hooks.processPlaceholders(user.getPlayer(), raw)));
|
||||
}
|
||||
}
|
||||
@@ -6,19 +6,18 @@ import com.hibiscusmc.hmccolor.shaded.gui.guis.GuiItem;
|
||||
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
|
||||
import com.hibiscusmc.hmccosmetics.config.Settings;
|
||||
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
|
||||
import com.hibiscusmc.hmccosmetics.hooks.Hooks;
|
||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Color;
|
||||
import org.bukkit.Material;
|
||||
import me.lojosho.hibiscuscommons.hooks.Hooks;
|
||||
import me.lojosho.hibiscuscommons.util.ColorBuilder;
|
||||
import me.lojosho.hibiscuscommons.util.StringUtils;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.bukkit.inventory.meta.LeatherArmorMeta;
|
||||
import org.bukkit.inventory.meta.MapMeta;
|
||||
import org.bukkit.inventory.meta.PotionMeta;
|
||||
import org.bukkit.inventory.meta.*;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public class DyeMenu {
|
||||
|
||||
public static void openMenu(@NotNull CosmeticUser user, Cosmetic cosmetic) {
|
||||
@@ -31,8 +30,8 @@ public class DyeMenu {
|
||||
ItemStack originalItem = user.getUserCosmeticItem(cosmetic);
|
||||
if (originalItem == null || !cosmetic.isDyable()) return;
|
||||
|
||||
Gui gui = HMCColorApi.INSTANCE.colorMenu();
|
||||
gui.updateTitle(Hooks.processPlaceholders(player, Settings.getDyeMenuName()));
|
||||
Gui gui = HMCColorApi.createColorMenu(player);
|
||||
gui.updateTitle(Hooks.processPlaceholders(player, StringUtils.parseStringToString(Settings.getDyeMenuName())));
|
||||
gui.setItem(Settings.getDyeMenuInputSlot(), new GuiItem(originalItem));
|
||||
gui.setDefaultTopClickAction(event -> {
|
||||
if (event.getSlot() == Settings.getDyeMenuOutputSlot()) {
|
||||
@@ -41,9 +40,19 @@ public class DyeMenu {
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
if (meta == null) return;
|
||||
|
||||
Color color = meta instanceof LeatherArmorMeta leatherMeta ? leatherMeta.getColor() :
|
||||
meta instanceof PotionMeta potionMeta ? potionMeta.getColor() :
|
||||
meta instanceof MapMeta mapMeta ? mapMeta.getColor() : null;
|
||||
Color color = null;
|
||||
if (meta instanceof LeatherArmorMeta leatherMeta) {
|
||||
color = leatherMeta.getColor();
|
||||
} else if (meta instanceof PotionMeta potionMeta) {
|
||||
color = potionMeta.getColor();
|
||||
} else if (meta instanceof MapMeta mapMeta) {
|
||||
color = mapMeta.getColor();
|
||||
} else if (meta instanceof FireworkEffectMeta fireworkEffectMeta) {
|
||||
FireworkEffect effect = fireworkEffectMeta.getEffect();
|
||||
if (effect != null) {
|
||||
color = effect.getColors().stream().findFirst().isPresent() ? effect.getColors().stream().findFirst().get() : null;
|
||||
}
|
||||
}
|
||||
if (color == null) return;
|
||||
|
||||
addCosmetic(user, cosmetic, color);
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
package com.hibiscusmc.hmccosmetics.gui.type;
|
||||
|
||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||
import me.lojosho.shaded.configurate.ConfigurationNode;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.spongepowered.configurate.ConfigurationNode;
|
||||
|
||||
public abstract class Type {
|
||||
|
||||
|
||||
@@ -2,32 +2,37 @@ package com.hibiscusmc.hmccosmetics.gui.type.types;
|
||||
|
||||
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
|
||||
import com.hibiscusmc.hmccosmetics.config.Settings;
|
||||
import com.hibiscusmc.hmccosmetics.config.serializer.ItemSerializer;
|
||||
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
|
||||
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetics;
|
||||
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticArmorType;
|
||||
import com.hibiscusmc.hmccosmetics.gui.action.Actions;
|
||||
import com.hibiscusmc.hmccosmetics.gui.special.DyeMenu;
|
||||
import com.hibiscusmc.hmccosmetics.gui.type.Type;
|
||||
import com.hibiscusmc.hmccosmetics.hooks.Hooks;
|
||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||
import me.lojosho.hibiscuscommons.config.serializer.ItemSerializer;
|
||||
import me.lojosho.hibiscuscommons.hooks.Hooks;
|
||||
import me.lojosho.shaded.configurate.ConfigurationNode;
|
||||
import me.lojosho.shaded.configurate.serialize.SerializationException;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
import org.bukkit.inventory.EquipmentSlot;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.bukkit.inventory.meta.SkullMeta;
|
||||
import org.jetbrains.annotations.Contract;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.spongepowered.configurate.ConfigurationNode;
|
||||
import org.spongepowered.configurate.serialize.SerializationException;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class TypeCosmetic extends Type {
|
||||
|
||||
public TypeCosmetic(String id) {
|
||||
super(id);
|
||||
}
|
||||
|
||||
public TypeCosmetic() {
|
||||
super("cosmetic");
|
||||
}
|
||||
@@ -123,8 +128,9 @@ public class TypeCosmetic extends Type {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack setItem(CosmeticUser user, @NotNull ConfigurationNode config, ItemStack itemStack, int slot) {
|
||||
itemStack.setItemMeta(processLoreLines(user, itemStack.getItemMeta()));
|
||||
public ItemStack setItem(@NotNull CosmeticUser user, @NotNull ConfigurationNode config, @NotNull ItemStack itemStack, int slot) {
|
||||
if (itemStack.hasItemMeta()) itemStack.setItemMeta(processLoreLines(user, itemStack.getItemMeta()));
|
||||
else MessagesUtil.sendDebugMessages("ItemStack has no ItemMeta?");
|
||||
|
||||
if (config.node("cosmetic").virtual()) {
|
||||
return itemStack;
|
||||
@@ -135,9 +141,9 @@ public class TypeCosmetic extends Type {
|
||||
return itemStack;
|
||||
}
|
||||
|
||||
if (user.hasCosmeticInSlot(cosmetic) && !config.node("equipped-item").virtual()) {
|
||||
if (user.hasCosmeticInSlot(cosmetic) && (!config.node("equipped-item").virtual() || !config.node("locked-equipped-item").virtual())) {
|
||||
MessagesUtil.sendDebugMessages("GUI Equipped Item");
|
||||
ConfigurationNode equippedItem = config.node("equipped-item");
|
||||
ConfigurationNode equippedItem = config.node(user.canEquipCosmetic(cosmetic, true) && !config.node("equipped-item").virtual() ? "equipped-item" : "locked-equipped-item");
|
||||
try {
|
||||
if (equippedItem.node("material").virtual()) equippedItem.node("material").set(config.node("item", "material").getString());
|
||||
} catch (SerializationException e) {
|
||||
@@ -148,11 +154,12 @@ public class TypeCosmetic extends Type {
|
||||
} catch (SerializationException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
itemStack.setItemMeta(processLoreLines(user, itemStack.getItemMeta()));
|
||||
if (itemStack.hasItemMeta()) itemStack.setItemMeta(processLoreLines(user, itemStack.getItemMeta()));
|
||||
else MessagesUtil.sendDebugMessages("ItemStack has no ItemMeta in equipped item?");
|
||||
return itemStack;
|
||||
}
|
||||
|
||||
if (!user.canEquipCosmetic(cosmetic) && !config.node("locked-item").virtual()) {
|
||||
if (!user.canEquipCosmetic(cosmetic, true) && !config.node("locked-item").virtual()) {
|
||||
MessagesUtil.sendDebugMessages("GUI Locked Item");
|
||||
ConfigurationNode lockedItem = config.node("locked-item");
|
||||
try {
|
||||
@@ -165,7 +172,8 @@ public class TypeCosmetic extends Type {
|
||||
} catch (SerializationException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
itemStack.setItemMeta(processLoreLines(user, itemStack.getItemMeta()));
|
||||
if (itemStack.hasItemMeta()) itemStack.setItemMeta(processLoreLines(user, itemStack.getItemMeta()));
|
||||
else MessagesUtil.sendDebugMessages("ItemStack has no ItemMeta in locked item?");
|
||||
return itemStack;
|
||||
}
|
||||
return itemStack;
|
||||
@@ -186,6 +194,12 @@ public class TypeCosmetic extends Type {
|
||||
processedLore.add(Hooks.processPlaceholders(user.getPlayer(), loreLine));
|
||||
}
|
||||
}
|
||||
|
||||
if (itemMeta instanceof SkullMeta skullMeta) {
|
||||
if (skullMeta.hasOwner() && skullMeta.getOwner() != null) {
|
||||
skullMeta.setOwner(Hooks.processPlaceholders(user.getPlayer(), skullMeta.getOwner()));
|
||||
}
|
||||
}
|
||||
itemMeta.setLore(processedLore);
|
||||
return itemMeta;
|
||||
}
|
||||
|
||||
@@ -2,14 +2,15 @@ package com.hibiscusmc.hmccosmetics.gui.type.types;
|
||||
|
||||
import com.hibiscusmc.hmccosmetics.gui.action.Actions;
|
||||
import com.hibiscusmc.hmccosmetics.gui.type.Type;
|
||||
import com.hibiscusmc.hmccosmetics.hooks.Hooks;
|
||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||
import me.lojosho.hibiscuscommons.hooks.Hooks;
|
||||
import me.lojosho.shaded.configurate.ConfigurationNode;
|
||||
import me.lojosho.shaded.configurate.serialize.SerializationException;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.bukkit.inventory.meta.SkullMeta;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.spongepowered.configurate.ConfigurationNode;
|
||||
import org.spongepowered.configurate.serialize.SerializationException;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -72,6 +73,14 @@ public class TypeEmpty extends Type {
|
||||
processedLore.add(Hooks.processPlaceholders(user.getPlayer(), loreLine));
|
||||
}
|
||||
}
|
||||
|
||||
if (itemMeta instanceof SkullMeta skullMeta) {
|
||||
if (skullMeta.hasOwner() && skullMeta.getOwner() != null) {
|
||||
skullMeta.setOwner(Hooks.processPlaceholders(user.getPlayer(), skullMeta.getOwner()));
|
||||
}
|
||||
}
|
||||
|
||||
itemMeta.setLore(processedLore);
|
||||
itemStack.setItemMeta(itemMeta);
|
||||
return itemStack;
|
||||
}
|
||||
|
||||
@@ -1,93 +0,0 @@
|
||||
package com.hibiscusmc.hmccosmetics.hooks;
|
||||
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* Represents a hook into other minecraft plugins
|
||||
*/
|
||||
public abstract class Hook implements Listener {
|
||||
private final String id;
|
||||
private boolean active = false;
|
||||
private boolean itemHook = false;
|
||||
|
||||
public Hook(@NotNull String id) {
|
||||
this.id = id;
|
||||
Hooks.addHook(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads this hook
|
||||
*
|
||||
* @implNote By default, this method does nothing. It should be overridden by child classes to implement any necessary loading logic
|
||||
*/
|
||||
public void load() { }
|
||||
|
||||
/**
|
||||
* Gets an {@link ItemStack} that is associated with the provided id from the hooked plugin
|
||||
* @param itemId The id of the {@link ItemStack}
|
||||
* @return The {@link ItemStack} with the id provided. If an invalid id was provided or if the hook doesn't have any related {@link ItemStack}s then this will return null
|
||||
* @implNote By default, this method returns null. It should be overridden by child classes if you will to have your hook return a related {@link ItemStack}
|
||||
*/
|
||||
@Nullable
|
||||
public ItemStack getItem(@NotNull String itemId) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the id of this hook
|
||||
*
|
||||
* @return The unique id for this hook
|
||||
*/
|
||||
@NotNull
|
||||
public final String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets whether this hook has been activated
|
||||
* @return true if this hook is active, false otherwise
|
||||
* @deprecated As of release 2.2.5+, replaced by {@link #isActive()}
|
||||
*/
|
||||
@Deprecated
|
||||
public boolean getActive() {
|
||||
return this.active;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets whether this hook has been activated
|
||||
* @return true if this hook is active, false otherwise
|
||||
* @since 2.2.5
|
||||
*/
|
||||
public final boolean isActive() {
|
||||
return this.active;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets whether this hook is active
|
||||
* @param active true to activate the hook, false otherwise
|
||||
*/
|
||||
public final void setActive(boolean active) {
|
||||
this.active = active;
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether the method {@link #getItem(String)} should return a non-null value
|
||||
* @return true if {@link #getItem(String)} should return a non-null value, false otherwise
|
||||
*
|
||||
* @apiNote Even though this method returns true does not mean that {@link #getItem(String)} won't return null, rather if this returns false then {@link #getItem(String)} should return false everytime
|
||||
*/
|
||||
public final boolean hasEnabledItemHook() {
|
||||
return itemHook;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets whether the method {@link #getItem(String)} should return a non-null value
|
||||
* @param enabled true if {@link #getItem(String)} should return a non-null value, false otherwise
|
||||
*/
|
||||
public final void setEnabledItemHook(boolean enabled) {
|
||||
itemHook = enabled;
|
||||
}
|
||||
}
|
||||
@@ -1,88 +0,0 @@
|
||||
package com.hibiscusmc.hmccosmetics.hooks;
|
||||
|
||||
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
|
||||
import com.hibiscusmc.hmccosmetics.hooks.items.*;
|
||||
import com.hibiscusmc.hmccosmetics.hooks.misc.*;
|
||||
import com.hibiscusmc.hmccosmetics.hooks.placeholders.HookPlaceholderAPI;
|
||||
import me.clip.placeholderapi.PlaceholderAPI;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
public class Hooks {
|
||||
|
||||
private static final HashMap<String, Hook> hooks = new HashMap<>();
|
||||
private static final HookOraxen ORAXEN_HOOK = new HookOraxen();
|
||||
private static final HookItemAdder ITEMADDER_HOOK = new HookItemAdder();
|
||||
private static final HookGeary GEARY_HOOK = new HookGeary();
|
||||
private static final HookMythic MYTHIC_HOOK = new HookMythic();
|
||||
private static final HookDenizen DENIZEN_HOOK = new HookDenizen();
|
||||
private static final HookHMCCosmetics HMCCOSMETIC_HOOK = new HookHMCCosmetics();
|
||||
private static final HookPlaceholderAPI PAPI_HOOK = new HookPlaceholderAPI();
|
||||
private static final HookPremiumVanish PREMIUM_VANISH_HOOK = new HookPremiumVanish();
|
||||
private static final HookSuperVanish SUPER_VANISH_HOOK = new HookSuperVanish();
|
||||
private static final HookHMCColor HMC_COLOR_HOOK = new HookHMCColor();
|
||||
private static final HookCMI CMI_HOOK = new HookCMI();
|
||||
private static final HookLibsDisguises LIBS_DISGUISES_HOOK = new HookLibsDisguises();
|
||||
private static final HookModelEngine MODEL_ENGINE_HOOK = new HookModelEngine();
|
||||
private static final HookMMOItems MMO_ITEMS_HOOK = new HookMMOItems();
|
||||
|
||||
public static Hook getHook(@NotNull String id) {
|
||||
return hooks.get(id.toLowerCase());
|
||||
}
|
||||
|
||||
public static boolean isItemHook(@NotNull String id) {
|
||||
return hooks.containsKey(id.toLowerCase());
|
||||
}
|
||||
|
||||
public static void addHook(Hook hook) {
|
||||
hooks.put(hook.getId().toLowerCase(), hook);
|
||||
}
|
||||
|
||||
public static void setup() {
|
||||
for (Hook hook : hooks.values()) {
|
||||
if (Bukkit.getPluginManager().getPlugin(hook.getId()) != null) {
|
||||
HMCCosmeticsPlugin.getInstance().getServer().getPluginManager().registerEvents(hook, HMCCosmeticsPlugin.getInstance());
|
||||
hook.setActive(true);
|
||||
hook.load();
|
||||
HMCCosmeticsPlugin.getInstance().getLogger().info("Successfully hooked into " + hook.getId());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static ItemStack getItem(@NotNull String raw) {
|
||||
if (!raw.contains(":")) {
|
||||
Material mat = Material.getMaterial(raw.toUpperCase());
|
||||
if (mat == null) return null;
|
||||
return new ItemStack(mat);
|
||||
}
|
||||
// Ex. Oraxen:BigSword
|
||||
// split[0] is the plugin name
|
||||
// split[1] is the item name
|
||||
String[] split = raw.split(":", 2);
|
||||
|
||||
if (!isItemHook(split[0])) return null;
|
||||
Hook hook = getHook(split[0]);
|
||||
if (!hook.hasEnabledItemHook()) return null;
|
||||
if (!hook.isActive()) return null;
|
||||
return hook.getItem(split[1]);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static String processPlaceholders(OfflinePlayer player, String raw) {
|
||||
if (getHook("PlaceholderAPI").isActive()) return PlaceholderAPI.setPlaceholders(player, raw);
|
||||
return raw;
|
||||
}
|
||||
|
||||
public static boolean isActiveHook(String id) {
|
||||
Hook hook = getHook(id);
|
||||
if (hook == null) return false;
|
||||
return hook.isActive();
|
||||
}
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
package com.hibiscusmc.hmccosmetics.hooks.items;
|
||||
|
||||
import com.denizenscript.denizen.objects.ItemTag;
|
||||
import com.denizenscript.denizencore.utilities.CoreUtilities;
|
||||
import com.hibiscusmc.hmccosmetics.hooks.Hook;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* A hook that integrates the plugin {@link com.denizenscript.denizen.Denizen Denizen} to provide custom items
|
||||
*/
|
||||
@SuppressWarnings("SpellCheckingInspection")
|
||||
public class HookDenizen extends Hook {
|
||||
public HookDenizen() {
|
||||
super("denizen");
|
||||
setEnabledItemHook(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a cosmetic {@link ItemStack} that is associated with the provided id from the plugin {@link com.denizenscript.denizen.Denizen Denizen}
|
||||
*/
|
||||
@Override
|
||||
public ItemStack getItem(@NotNull String itemId) {
|
||||
ItemTag item = ItemTag.valueOf(itemId, CoreUtilities.noDebugContext);
|
||||
return item == null ? null : item.getItemStack();
|
||||
}
|
||||
}
|
||||
@@ -1,44 +0,0 @@
|
||||
package com.hibiscusmc.hmccosmetics.hooks.items;
|
||||
|
||||
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
|
||||
import com.hibiscusmc.hmccosmetics.hooks.Hook;
|
||||
import com.mineinabyss.geary.addons.GearyPhase;
|
||||
import com.mineinabyss.geary.modules.GearyModuleKt;
|
||||
import com.mineinabyss.geary.papermc.tracking.items.ItemTrackingKt;
|
||||
import com.mineinabyss.geary.prefabs.PrefabKey;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* A hook that integrates the plugin {@link com.mineinabyss.geary.papermc.GearyPlugin Geary} to provide custom items
|
||||
*/
|
||||
public class HookGeary extends Hook {
|
||||
private boolean enabled = false;
|
||||
|
||||
public HookGeary() {
|
||||
super("geary");
|
||||
setEnabledItemHook(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load() {
|
||||
if (!enabled) GearyModuleKt.getGeary().getPipeline().intercept(GearyPhase.INIT_ENTITIES, () -> {
|
||||
enabled = true;
|
||||
HMCCosmeticsPlugin.setup();
|
||||
return null;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a cosmetic {@link ItemStack} that is associated with the provided id from the plugin {@link com.mineinabyss.geary.papermc.GearyPlugin Geary}
|
||||
*/
|
||||
@Override
|
||||
public ItemStack getItem(@NotNull String itemId) {
|
||||
if (enabled) {
|
||||
PrefabKey prefabKey = PrefabKey.Companion.ofOrNull(itemId);
|
||||
if (prefabKey == null) return null;
|
||||
return ItemTrackingKt.getGearyItems().createItem(prefabKey, null);
|
||||
} else return new ItemStack(Material.AIR);
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,8 @@ package com.hibiscusmc.hmccosmetics.hooks.items;
|
||||
|
||||
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
|
||||
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetics;
|
||||
import com.hibiscusmc.hmccosmetics.hooks.Hook;
|
||||
import me.lojosho.hibiscuscommons.hooks.Hook;
|
||||
import me.lojosho.hibiscuscommons.hooks.HookFlag;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@@ -11,8 +12,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
*/
|
||||
public class HookHMCCosmetics extends Hook {
|
||||
public HookHMCCosmetics() {
|
||||
super("HMCCosmetics");
|
||||
setEnabledItemHook(true);
|
||||
super("HMCCosmetics", HookFlag.ITEM_SUPPORT);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,47 +0,0 @@
|
||||
package com.hibiscusmc.hmccosmetics.hooks.items;
|
||||
|
||||
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
|
||||
import com.hibiscusmc.hmccosmetics.config.Settings;
|
||||
import com.hibiscusmc.hmccosmetics.hooks.Hook;
|
||||
import dev.lone.itemsadder.api.CustomStack;
|
||||
import dev.lone.itemsadder.api.Events.ItemsAdderLoadDataEvent;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* A hook that integrates the plugin {@link dev.lone.itemsadder.api.ItemsAdder ItemsAdder} to provide custom items
|
||||
*/
|
||||
@SuppressWarnings("SpellCheckingInspection")
|
||||
public class HookItemAdder extends Hook {
|
||||
private boolean enabled = false;
|
||||
|
||||
public HookItemAdder() {
|
||||
super("itemsadder");
|
||||
setEnabledItemHook(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a cosmetic {@link ItemStack} that is associated with the provided id from the plugin {@link dev.lone.itemsadder.api.ItemsAdder ItemsAdder}
|
||||
*/
|
||||
@Override
|
||||
public ItemStack getItem(@NotNull String itemId) {
|
||||
if (enabled) {
|
||||
CustomStack stack = CustomStack.getInstance(itemId);
|
||||
if (stack == null) return null;
|
||||
return stack.getItemStack();
|
||||
} else {
|
||||
return new ItemStack(Material.AIR);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onItemAdderDataLoad(ItemsAdderLoadDataEvent event) {
|
||||
// By default, it will only run once at startup, if hook setting is enabled
|
||||
if (enabled && !Settings.isItemsAdderChangeReload()) return;
|
||||
this.enabled = true;
|
||||
HMCCosmeticsPlugin.setup();
|
||||
}
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
package com.hibiscusmc.hmccosmetics.hooks.items;
|
||||
|
||||
import com.hibiscusmc.hmccosmetics.hooks.Hook;
|
||||
import net.Indyuce.mmoitems.MMOItems;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class HookMMOItems extends Hook {
|
||||
public HookMMOItems() {
|
||||
super("MMOItems");
|
||||
setEnabledItemHook(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getItem(@NotNull String itemId) {
|
||||
String[] split = itemId.split(":", 2);
|
||||
if (split.length == 2) {
|
||||
return MMOItems.plugin.getItem(split[0], split[1]);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
package com.hibiscusmc.hmccosmetics.hooks.items;
|
||||
|
||||
import com.hibiscusmc.hmccosmetics.hooks.Hook;
|
||||
import io.lumine.mythic.bukkit.MythicBukkit;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* A hook that integrates the plugin {@link io.lumine.mythic.bukkit.MythicBukkit MythicBukkit} to provide custom items
|
||||
*/
|
||||
@SuppressWarnings("SpellCheckingInspection")
|
||||
public class HookMythic extends Hook {
|
||||
public HookMythic() {
|
||||
super("mythicmobs");
|
||||
setEnabledItemHook(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a cosmetic {@link ItemStack} that is associated with the provided id from the plugin {@link io.lumine.mythic.bukkit.MythicBukkit MythicBukkit}
|
||||
*/
|
||||
@Override
|
||||
public ItemStack getItem(@NotNull String itemId) {
|
||||
return MythicBukkit.inst().getItemManager().getItemStack(itemId);
|
||||
}
|
||||
}
|
||||
@@ -1,28 +0,0 @@
|
||||
package com.hibiscusmc.hmccosmetics.hooks.items;
|
||||
|
||||
import com.hibiscusmc.hmccosmetics.hooks.Hook;
|
||||
import io.th0rgal.oraxen.api.OraxenItems;
|
||||
import io.th0rgal.oraxen.items.ItemBuilder;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* A hook that integrates the plugin {@link io.th0rgal.oraxen.OraxenPlugin OraxenPlugin} to provide custom items
|
||||
*/
|
||||
@SuppressWarnings("SpellCheckingInspection")
|
||||
public class HookOraxen extends Hook {
|
||||
public HookOraxen() {
|
||||
super("oraxen");
|
||||
setEnabledItemHook(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a cosmetic {@link ItemStack} that is associated with the provided id from the plugin {@link io.th0rgal.oraxen.OraxenPlugin OraxenPlugin}
|
||||
*/
|
||||
@Override
|
||||
public ItemStack getItem(@NotNull String itemId) {
|
||||
ItemBuilder builder = OraxenItems.getItemById(itemId);
|
||||
if (builder == null) return null;
|
||||
return builder.build();
|
||||
}
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
package com.hibiscusmc.hmccosmetics.hooks.misc;
|
||||
|
||||
import com.Zrips.CMI.events.CMIPlayerUnVanishEvent;
|
||||
import com.Zrips.CMI.events.CMIPlayerVanishEvent;
|
||||
import com.hibiscusmc.hmccosmetics.hooks.Hook;
|
||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUsers;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* A hook that integrates the plugin {@link com.Zrips.CMI.CMI CMI}
|
||||
*/
|
||||
public class HookCMI extends Hook {
|
||||
public HookCMI() {
|
||||
super("CMI");
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPlayerVanish(@NotNull CMIPlayerVanishEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
CosmeticUser user = CosmeticUsers.getUser(player);
|
||||
if (user == null) return;
|
||||
user.hideCosmetics(CosmeticUser.HiddenReason.PLUGIN);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPlayerShow(@NotNull CMIPlayerUnVanishEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
CosmeticUser user = CosmeticUsers.getUser(player);
|
||||
if (user == null) return;
|
||||
user.showCosmetics();
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
package com.hibiscusmc.hmccosmetics.hooks.misc;
|
||||
|
||||
import com.hibiscusmc.hmccosmetics.hooks.Hook;
|
||||
|
||||
/**
|
||||
* A hook that integrates the plugin {@link com.hibiscusmc.hmccolor.HMCColor HMCColor}
|
||||
*/
|
||||
public class HookHMCColor extends Hook {
|
||||
public HookHMCColor() {
|
||||
super("HMCColor");
|
||||
}
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
package com.hibiscusmc.hmccosmetics.hooks.misc;
|
||||
|
||||
import com.hibiscusmc.hmccosmetics.hooks.Hook;
|
||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUsers;
|
||||
import me.libraryaddict.disguise.events.DisguiseEvent;
|
||||
import me.libraryaddict.disguise.events.UndisguiseEvent;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class HookLibsDisguises extends Hook {
|
||||
public HookLibsDisguises() {
|
||||
super("LibsDisguises");
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPlayerVanish(@NotNull DisguiseEvent event) {
|
||||
if (!(event.getEntity() instanceof Player player)) return;
|
||||
CosmeticUser user = CosmeticUsers.getUser(player);
|
||||
if (user == null) return;
|
||||
user.hideCosmetics(CosmeticUser.HiddenReason.PLUGIN);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPlayerShow(@NotNull UndisguiseEvent event) {
|
||||
if (!(event.getEntity() instanceof Player player)) return;
|
||||
CosmeticUser user = CosmeticUsers.getUser(player);
|
||||
if (user == null) return;
|
||||
user.showCosmetics();
|
||||
}
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
package com.hibiscusmc.hmccosmetics.hooks.misc;
|
||||
|
||||
import com.hibiscusmc.hmccosmetics.hooks.Hook;
|
||||
|
||||
public class HookModelEngine extends Hook {
|
||||
|
||||
public HookModelEngine() {
|
||||
super("ModelEngine");
|
||||
}
|
||||
}
|
||||
@@ -1,38 +0,0 @@
|
||||
package com.hibiscusmc.hmccosmetics.hooks.misc;
|
||||
|
||||
import com.hibiscusmc.hmccosmetics.hooks.Hook;
|
||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUsers;
|
||||
import de.myzelyam.api.vanish.PlayerHideEvent;
|
||||
import de.myzelyam.api.vanish.PlayerShowEvent;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* A hook that integrates the plugin {@link de.myzelyam.api.vanish.VanishAPI Supervanish}
|
||||
*
|
||||
* @implSpec Supervanish and Premium Vanish both use the same api
|
||||
*/
|
||||
public class HookPremiumVanish extends Hook {
|
||||
public HookPremiumVanish() {
|
||||
super("PremiumVanish");
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL)
|
||||
public void onPlayerVanish(@NotNull PlayerHideEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
CosmeticUser user = CosmeticUsers.getUser(player);
|
||||
if (user == null) return;
|
||||
user.hideCosmetics(CosmeticUser.HiddenReason.PLUGIN);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL)
|
||||
public void onPlayerShow(@NotNull PlayerShowEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
CosmeticUser user = CosmeticUsers.getUser(player);
|
||||
if (user == null) return;
|
||||
user.showCosmetics();
|
||||
}
|
||||
}
|
||||
@@ -1,38 +0,0 @@
|
||||
package com.hibiscusmc.hmccosmetics.hooks.misc;
|
||||
|
||||
import com.hibiscusmc.hmccosmetics.hooks.Hook;
|
||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUsers;
|
||||
import de.myzelyam.api.vanish.PlayerHideEvent;
|
||||
import de.myzelyam.api.vanish.PlayerShowEvent;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* A hook that integrates the plugin {@link de.myzelyam.api.vanish.VanishAPI Supervanish}
|
||||
*
|
||||
* @implSpec Supervanish and Premium Vanish both use the same api
|
||||
*/
|
||||
public class HookSuperVanish extends Hook {
|
||||
public HookSuperVanish() {
|
||||
super("SuperVanish");
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL)
|
||||
public void onPlayerVanish(@NotNull PlayerHideEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
CosmeticUser user = CosmeticUsers.getUser(player);
|
||||
if (user == null) return;
|
||||
user.hideCosmetics(CosmeticUser.HiddenReason.PLUGIN);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL)
|
||||
public void onPlayerShow(@NotNull PlayerShowEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
CosmeticUser user = CosmeticUsers.getUser(player);
|
||||
if (user == null) return;
|
||||
user.showCosmetics();
|
||||
}
|
||||
}
|
||||
@@ -54,18 +54,15 @@ public class HMCPlaceholderExpansion extends PlaceholderExpansion {
|
||||
|
||||
@Override
|
||||
public String onRequest(@NotNull OfflinePlayer player, @NotNull String params) {
|
||||
if (!player.isOnline()) return null;
|
||||
if (!player.isOnline()) return TranslationUtil.getTranslation("user-cosmetic", "offline");
|
||||
CosmeticUser user = CosmeticUsers.getUser(player.getPlayer());
|
||||
if (user == null) return null;
|
||||
if (user == null) return TranslationUtil.getTranslation("user-cosmetic", "invalid-user");
|
||||
|
||||
List<String> placeholderArgs = Arrays.asList(params.split("_", 3));
|
||||
|
||||
switch (placeholderArgs.get(0).toLowerCase()) {
|
||||
case "using":
|
||||
if (placeholderArgs == null) {
|
||||
return null;
|
||||
}
|
||||
if (placeholderArgs.get(1) != null) {
|
||||
if (placeholderArgs.size() >= 2) {
|
||||
Cosmetic cosmetic = Cosmetics.getCosmetic(placeholderArgs.get(1));
|
||||
if (cosmetic == null) return "INVALID_COSMETIC";
|
||||
Cosmetic currentCosmetic = user.getCosmetic(cosmetic.getSlot());
|
||||
@@ -74,13 +71,10 @@ public class HMCPlaceholderExpansion extends PlaceholderExpansion {
|
||||
return TranslationUtil.getTranslation("using-cosmetic", String.valueOf(false));
|
||||
}
|
||||
case "current":
|
||||
if (placeholderArgs == null) {
|
||||
return null;
|
||||
}
|
||||
if (placeholderArgs.get(1) != null) {
|
||||
if (placeholderArgs.size() >= 2) {
|
||||
CosmeticSlot slot = CosmeticSlot.valueOf(placeholderArgs.get(1).toUpperCase());
|
||||
if (slot == null) return null;
|
||||
if (user.getCosmetic(slot) == null) return null;
|
||||
if (user.getCosmetic(slot) == null) return TranslationUtil.getTranslation("current-cosmetic", "no-cosmetic");
|
||||
if (placeholderArgs.size() == 2) return user.getCosmetic(slot).getId();
|
||||
|
||||
String output;
|
||||
@@ -104,13 +98,11 @@ public class HMCPlaceholderExpansion extends PlaceholderExpansion {
|
||||
output = user.getCosmetic(slot).getId();
|
||||
}
|
||||
}
|
||||
return TranslationUtil.getTranslation("current-cosmetic", String.valueOf(output));
|
||||
if (output == null) output = "none";
|
||||
return TranslationUtil.getTranslation("current-cosmetic", output);
|
||||
}
|
||||
case "unlocked":
|
||||
if (placeholderArgs == null) {
|
||||
return null;
|
||||
}
|
||||
if (placeholderArgs.get(1) != null) {
|
||||
if (placeholderArgs.size() >= 2) {
|
||||
Cosmetic cosmetic = Cosmetics.getCosmetic(placeholderArgs.get(1));
|
||||
if (cosmetic == null) {
|
||||
if (placeholderArgs.size() >= 3) {
|
||||
@@ -127,10 +119,7 @@ public class HMCPlaceholderExpansion extends PlaceholderExpansion {
|
||||
return TranslationUtil.getTranslation("unlocked-cosmetic", String.valueOf(user.canEquipCosmetic(cosmetic, true)));
|
||||
}
|
||||
case "equipped":
|
||||
if (placeholderArgs == null) {
|
||||
return null;
|
||||
}
|
||||
if (placeholderArgs.get(1) != null) {
|
||||
if (placeholderArgs.size() >= 2) {
|
||||
String args1 = placeholderArgs.get(1);
|
||||
|
||||
if (EnumUtils.isValidEnum(CosmeticSlot.class, args1.toUpperCase())) {
|
||||
@@ -156,6 +145,30 @@ public class HMCPlaceholderExpansion extends PlaceholderExpansion {
|
||||
if (equippedCosmetic == null) return TranslationUtil.getTranslation("equipped-cosmetic", "false");
|
||||
return TranslationUtil.getTranslation("equipped-cosmetic", String.valueOf(cosmetic.getId().equals(equippedCosmetic.getId())));
|
||||
}
|
||||
// %hmccosmetics_amount_balloon_unlocked%
|
||||
case "amount":
|
||||
if (placeholderArgs.size() >= 2) {
|
||||
String args1 = placeholderArgs.get(1).toUpperCase(); // changes offhand to OFFHAND
|
||||
|
||||
if (!EnumUtils.isValidEnum(CosmeticSlot.class, args1)) return null;
|
||||
|
||||
CosmeticSlot slot = CosmeticSlot.valueOf(args1);
|
||||
int amount = 0;
|
||||
boolean checkUnlocked = false;
|
||||
if (placeholderArgs.size() >= 3) if (placeholderArgs.get(2).equalsIgnoreCase("unlocked")) checkUnlocked = true;
|
||||
|
||||
for (Cosmetic cosmetic : Cosmetics.values()) {
|
||||
if (cosmetic.getSlot() != slot) continue;
|
||||
if (checkUnlocked && !user.canEquipCosmetic(cosmetic)) continue;
|
||||
amount += 1;
|
||||
}
|
||||
return TranslationUtil.getTranslation("amount-cosmetic", String.valueOf(amount));
|
||||
|
||||
} else {
|
||||
return TranslationUtil.getTranslation("amount-cosmetic", String.valueOf(Cosmetics.values().size()));
|
||||
}
|
||||
case "hidden":
|
||||
return TranslationUtil.getTranslation("hidden", String.valueOf(user.isHidden()));
|
||||
case "wardrobe-enabled":
|
||||
return TranslationUtil.getTranslation("in-wardrobe", String.valueOf(user.isInWardrobe()));
|
||||
}
|
||||
@@ -216,6 +229,7 @@ public class HMCPlaceholderExpansion extends PlaceholderExpansion {
|
||||
if (!item.hasItemMeta()) return null;
|
||||
ItemMeta itemMeta = item.getItemMeta();
|
||||
if (itemMeta == null) return null;
|
||||
if (!itemMeta.hasDisplayName()) return null;
|
||||
return itemMeta.getDisplayName();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
package com.hibiscusmc.hmccosmetics.hooks.placeholders;
|
||||
|
||||
import com.hibiscusmc.hmccosmetics.hooks.Hook;
|
||||
|
||||
/**
|
||||
* A hook that integrates the plugin {@link me.clip.placeholderapi.PlaceholderAPI PlaceholderAPI}
|
||||
*/
|
||||
public class HookPlaceholderAPI extends Hook {
|
||||
public HookPlaceholderAPI() {
|
||||
super("PlaceholderAPI");
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers HMCCosmetics Placeholder Expansion
|
||||
*/
|
||||
@Override
|
||||
public void load() {
|
||||
new HMCPlaceholderExpansion().register();
|
||||
}
|
||||
}
|
||||
@@ -30,19 +30,18 @@ public class WGListener implements Listener {
|
||||
if (user == null) return;
|
||||
Location location = event.getPlayer().getLocation();
|
||||
ApplicableRegionSet set = getRegions(location);
|
||||
if (user.getHidden()) {
|
||||
if (user.getHiddenReason() == CosmeticUser.HiddenReason.WORLDGUARD && set.getRegions().isEmpty()) {
|
||||
user.showCosmetics();
|
||||
if (user.isHidden()) {
|
||||
if (set.getRegions().isEmpty()) {
|
||||
user.showCosmetics(CosmeticUser.HiddenReason.WORLDGUARD);
|
||||
}
|
||||
}
|
||||
for (ProtectedRegion protectedRegion : set.getRegions()) {
|
||||
if (protectedRegion.getFlags().containsKey(WGHook.getCosmeticEnableFlag())) {
|
||||
if (protectedRegion.getFlags().get(WGHook.getCosmeticEnableFlag()).toString().equalsIgnoreCase("ALLOW")) {
|
||||
if (user.getHiddenReason() == CosmeticUser.HiddenReason.WORLDGUARD) user.showCosmetics();
|
||||
return;
|
||||
user.showCosmetics(CosmeticUser.HiddenReason.WORLDGUARD);
|
||||
} else {
|
||||
user.hideCosmetics(CosmeticUser.HiddenReason.WORLDGUARD);
|
||||
}
|
||||
user.hideCosmetics(CosmeticUser.HiddenReason.WORLDGUARD);
|
||||
return;
|
||||
}
|
||||
if (protectedRegion.getFlags().containsKey(WGHook.getCosmeticWardrobeFlag())) {
|
||||
if (!WardrobeSettings.getWardrobeNames().contains(protectedRegion.getFlags().get(WGHook.getCosmeticWardrobeFlag()).toString())) return;
|
||||
@@ -58,15 +57,15 @@ public class WGListener implements Listener {
|
||||
if (user == null) return;
|
||||
Location location = event.getTo();
|
||||
ApplicableRegionSet set = getRegions(location);
|
||||
if (user.getHidden()) {
|
||||
if (user.getHiddenReason() == CosmeticUser.HiddenReason.WORLDGUARD && set.getRegions().isEmpty()) {
|
||||
user.showCosmetics();
|
||||
if (user.isHidden()) {
|
||||
if (set.getRegions().isEmpty()) {
|
||||
user.showCosmetics(CosmeticUser.HiddenReason.WORLDGUARD);
|
||||
}
|
||||
}
|
||||
for (ProtectedRegion protectedRegion : set.getRegions()) {
|
||||
if (protectedRegion.getFlags().containsKey(WGHook.getCosmeticEnableFlag())) {
|
||||
if (protectedRegion.getFlags().get(WGHook.getCosmeticEnableFlag()).toString().equalsIgnoreCase("ALLOW")) {
|
||||
if (user.getHiddenReason() == CosmeticUser.HiddenReason.WORLDGUARD) user.showCosmetics();
|
||||
user.showCosmetics(CosmeticUser.HiddenReason.WORLDGUARD);
|
||||
return;
|
||||
}
|
||||
user.hideCosmetics(CosmeticUser.HiddenReason.WORLDGUARD);
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
package com.hibiscusmc.hmccosmetics.listener;
|
||||
|
||||
import com.destroystokyo.paper.event.player.PlayerArmorChangeEvent;
|
||||
import com.destroystokyo.paper.event.player.PlayerPostRespawnEvent;
|
||||
import com.hibiscusmc.hmccosmetics.cosmetic.CosmeticSlot;
|
||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUsers;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
|
||||
public class PaperPlayerGameListener implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerArmorEquip(PlayerArmorChangeEvent event) {
|
||||
CosmeticUser user = CosmeticUsers.getUser(event.getPlayer());
|
||||
if (user == null) return;
|
||||
if (user.isInWardrobe()) return;
|
||||
user.updateCosmetic(slotTypeToCosmeticType(event.getSlotType()));
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerRespawn(PlayerPostRespawnEvent event) {
|
||||
CosmeticUser user = CosmeticUsers.getUser(event.getPlayer());
|
||||
if (user == null) return;
|
||||
if (user.isInWardrobe()) return;
|
||||
if (user.hasCosmeticInSlot(CosmeticSlot.BACKPACK)) user.respawnBackpack();
|
||||
}
|
||||
|
||||
private CosmeticSlot slotTypeToCosmeticType(PlayerArmorChangeEvent.SlotType slotType) {
|
||||
return switch (slotType) {
|
||||
case HEAD -> CosmeticSlot.HELMET;
|
||||
case FEET -> CosmeticSlot.BOOTS;
|
||||
case LEGS -> CosmeticSlot.LEGGINGS;
|
||||
case CHEST -> CosmeticSlot.CHESTPLATE;
|
||||
default -> null;
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
@@ -2,14 +2,15 @@ package com.hibiscusmc.hmccosmetics.listener;
|
||||
|
||||
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
|
||||
import com.hibiscusmc.hmccosmetics.config.DatabaseSettings;
|
||||
import com.hibiscusmc.hmccosmetics.config.Settings;
|
||||
import com.hibiscusmc.hmccosmetics.database.Database;
|
||||
import com.hibiscusmc.hmccosmetics.database.UserData;
|
||||
import com.hibiscusmc.hmccosmetics.gui.Menus;
|
||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUsers;
|
||||
import com.hibiscusmc.hmccosmetics.user.manager.UserEmoteManager;
|
||||
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
@@ -17,27 +18,42 @@ import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class PlayerConnectionListener implements Listener {
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPlayerJoin(@NotNull PlayerJoinEvent event) {
|
||||
if (event.getPlayer().isOp() || event.getPlayer().hasPermission("hmccosmetics.notifyupdate")) {
|
||||
if (!HMCCosmeticsPlugin.getLatestVersion().equalsIgnoreCase(HMCCosmeticsPlugin.getInstance().getDescription().getVersion()) && HMCCosmeticsPlugin.getLatestVersion().isEmpty())
|
||||
if (!HMCCosmeticsPlugin.getInstance().getLatestVersion().equalsIgnoreCase(HMCCosmeticsPlugin.getInstance().getDescription().getVersion()) && HMCCosmeticsPlugin.getInstance().getLatestVersion().isEmpty())
|
||||
MessagesUtil.sendMessageNoKey(
|
||||
event.getPlayer(),
|
||||
"<br>" +
|
||||
"<GRAY>There is a new version of <light_purple><Bold>HMCCosmetics<reset><gray> available!<br>" +
|
||||
"<GRAY>Current version: <red>" + HMCCosmeticsPlugin.getInstance().getDescription().getVersion() + " <GRAY>| Latest version: <light_purple>" + HMCCosmeticsPlugin.getLatestVersion() + "<br>" +
|
||||
"<GRAY>Current version: <red>" + HMCCosmeticsPlugin.getInstance().getDescription().getVersion() + " <GRAY>| Latest version: <light_purple>" + HMCCosmeticsPlugin.getInstance().getLatestVersion() + "<br>" +
|
||||
"<GRAY>Download it on <gold><click:OPEN_URL:'https://www.spigotmc.org/resources/100107/'>Spigot<reset> <gray>or <gold><click:OPEN_URL:'https://polymart.org/resource/1879'>Polymart<reset><gray>!" +
|
||||
"<br>"
|
||||
);
|
||||
}
|
||||
|
||||
// This literally makes me want to end it all but I can't do that so I'll just cry instead
|
||||
Runnable run = () -> {
|
||||
CosmeticUser user = Database.get(event.getPlayer().getUniqueId());
|
||||
CosmeticUsers.addUser(user);
|
||||
MessagesUtil.sendDebugMessages("Run User Join");
|
||||
Bukkit.getScheduler().runTaskLater(HMCCosmeticsPlugin.getInstance(), () -> user.updateCosmetic(), 4);
|
||||
if (!event.getPlayer().isOnline()) return; // If a player is no longer online, don't run this.
|
||||
UUID uuid = event.getPlayer().getUniqueId();
|
||||
Database.get(uuid).thenAccept(data -> {
|
||||
if (data == null) return;
|
||||
Bukkit.getScheduler().runTask(HMCCosmeticsPlugin.getInstance(), () -> {
|
||||
CosmeticUser cosmeticUser = new CosmeticUser(uuid, data);
|
||||
CosmeticUsers.addUser(cosmeticUser);
|
||||
MessagesUtil.sendDebugMessages("Run User Join for " + uuid);
|
||||
|
||||
// And finally, launch an update for the cosmetics they have.
|
||||
Bukkit.getScheduler().runTaskLater(HMCCosmeticsPlugin.getInstance(), () -> {
|
||||
if (cosmeticUser.getPlayer() == null) return;
|
||||
cosmeticUser.updateCosmetic();
|
||||
}, 4);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
if (DatabaseSettings.isEnabledDelay()) {
|
||||
@@ -51,21 +67,16 @@ public class PlayerConnectionListener implements Listener {
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPlayerQuit(@NotNull PlayerQuitEvent event) {
|
||||
CosmeticUser user = CosmeticUsers.getUser(event.getPlayer());
|
||||
if (user == null) { // Remove any passengers if a user failed to initialize. Bugs can cause this to happen
|
||||
if (!event.getPlayer().getPassengers().isEmpty()) {
|
||||
for (Entity entity : event.getPlayer().getPassengers()) {
|
||||
if (entity.getType() == EntityType.ARMOR_STAND) {
|
||||
entity.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
return;
|
||||
if (user == null) return; // Player never initialized, don't do anything
|
||||
if (user.isInWardrobe()) {
|
||||
user.leaveWardrobe(true);
|
||||
user.getPlayer().setInvisible(false);
|
||||
}
|
||||
if (user.isInWardrobe()) user.leaveWardrobe();
|
||||
if (user.getUserEmoteManager().isPlayingEmote()) {
|
||||
user.getUserEmoteManager().stopEmote(UserEmoteManager.StopEmoteReason.CONNECTION);
|
||||
event.getPlayer().setInvisible(false);
|
||||
}
|
||||
Menus.removeCooldown(event.getPlayer().getUniqueId()); // Removes any menu cooldowns a player might have
|
||||
Database.save(user);
|
||||
user.destroy();
|
||||
CosmeticUsers.removeUser(user.getUniqueId());
|
||||
|
||||
@@ -11,6 +11,7 @@ import com.comphenix.protocol.wrappers.Pair;
|
||||
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
|
||||
import com.hibiscusmc.hmccosmetics.api.events.PlayerCosmeticPostEquipEvent;
|
||||
import com.hibiscusmc.hmccosmetics.config.Settings;
|
||||
import com.hibiscusmc.hmccosmetics.config.WardrobeSettings;
|
||||
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
|
||||
import com.hibiscusmc.hmccosmetics.cosmetic.CosmeticSlot;
|
||||
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticArmorType;
|
||||
@@ -22,9 +23,16 @@ import com.hibiscusmc.hmccosmetics.gui.Menus;
|
||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUsers;
|
||||
import com.hibiscusmc.hmccosmetics.user.manager.UserEmoteManager;
|
||||
import com.hibiscusmc.hmccosmetics.util.InventoryUtils;
|
||||
import com.hibiscusmc.hmccosmetics.user.manager.UserWardrobeManager;
|
||||
import com.hibiscusmc.hmccosmetics.util.HMCCInventoryUtils;
|
||||
import com.hibiscusmc.hmccosmetics.util.HMCCServerUtils;
|
||||
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||
import com.hibiscusmc.hmccosmetics.util.packets.PacketManager;
|
||||
import com.hibiscusmc.hmccosmetics.util.packets.HMCCPacketManager;
|
||||
import me.lojosho.hibiscuscommons.api.events.*;
|
||||
import me.lojosho.hibiscuscommons.hooks.Hook;
|
||||
import me.lojosho.hibiscuscommons.hooks.items.HookItemAdder;
|
||||
import me.lojosho.hibiscuscommons.hooks.items.HookNexo;
|
||||
import me.lojosho.hibiscuscommons.util.packets.PacketManager;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
@@ -61,6 +69,7 @@ public class PlayerGameListener implements Listener {
|
||||
registerPlayerArmListener();
|
||||
registerEntityUseListener();
|
||||
registerSlotChangeListener();
|
||||
registerPassengerSetListener();
|
||||
|
||||
//registerLookMovement();
|
||||
//registerMoveListener();
|
||||
@@ -78,14 +87,14 @@ public class PlayerGameListener implements Listener {
|
||||
ItemStack item = event.getCurrentItem();
|
||||
if (item == null) return;
|
||||
|
||||
if (Settings.isDestroyLooseCosmetics() && InventoryUtils.isCosmeticItem(event.getCurrentItem())) {
|
||||
if (Settings.isDestroyLooseCosmetics() && HMCCInventoryUtils.isCosmeticItem(event.getCurrentItem())) {
|
||||
MessagesUtil.sendDebugMessages("remvoe item");
|
||||
event.getWhoClicked().getInventory().removeItem(event.getCurrentItem());
|
||||
}
|
||||
|
||||
EquipmentSlot slot = getArmorSlot(item.getType());
|
||||
if (slot == null) return;
|
||||
CosmeticSlot cosmeticSlot = InventoryUtils.BukkitCosmeticSlot(slot);
|
||||
CosmeticSlot cosmeticSlot = HMCCInventoryUtils.BukkitCosmeticSlot(slot);
|
||||
if (cosmeticSlot == null) return;
|
||||
if (!user.hasCosmeticInSlot(cosmeticSlot)) return;
|
||||
Bukkit.getScheduler().runTaskLater(HMCCosmeticsPlugin.getInstance(), () -> {
|
||||
@@ -109,7 +118,7 @@ public class PlayerGameListener implements Listener {
|
||||
user.leaveWardrobe();
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOW)
|
||||
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
||||
public void onPlayerTeleport(PlayerTeleportEvent event) {
|
||||
CosmeticUser user = CosmeticUsers.getUser(event.getPlayer().getUniqueId());
|
||||
|
||||
@@ -124,6 +133,12 @@ public class PlayerGameListener implements Listener {
|
||||
}
|
||||
|
||||
Bukkit.getScheduler().runTaskLater(HMCCosmeticsPlugin.getInstance(), () -> {
|
||||
if (user.getEntity() == null || user.isInWardrobe()) return; // fixes disconnecting when in wardrobe (the entity stuff)
|
||||
if (Settings.getDisabledWorlds().contains(user.getEntity().getLocation().getWorld().getName())) {
|
||||
user.hideCosmetics(CosmeticUser.HiddenReason.WORLD);
|
||||
} else {
|
||||
user.showCosmetics(CosmeticUser.HiddenReason.WORLD);
|
||||
}
|
||||
if (user.hasCosmeticInSlot(CosmeticSlot.BACKPACK) && user.getUserBackpackManager() != null) {
|
||||
user.respawnBackpack();
|
||||
}
|
||||
@@ -131,7 +146,7 @@ public class PlayerGameListener implements Listener {
|
||||
user.respawnBalloon();
|
||||
}
|
||||
user.updateCosmetic();
|
||||
}, 1);
|
||||
}, 2);
|
||||
|
||||
if (event.getCause().equals(PlayerTeleportEvent.TeleportCause.NETHER_PORTAL) || event.getCause().equals(PlayerTeleportEvent.TeleportCause.END_PORTAL)) return;
|
||||
if (user.getUserEmoteManager().isPlayingEmote()) {
|
||||
@@ -139,7 +154,7 @@ public class PlayerGameListener implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOW)
|
||||
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
||||
public void onPortalTeleport(PlayerPortalEvent event) {
|
||||
CosmeticUser user = CosmeticUsers.getUser(event.getPlayer().getUniqueId());
|
||||
|
||||
@@ -149,6 +164,12 @@ public class PlayerGameListener implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
if (Settings.getDisabledWorlds().contains(user.getEntity().getLocation().getWorld().getName())) {
|
||||
user.hideCosmetics(CosmeticUser.HiddenReason.WORLD);
|
||||
} else {
|
||||
user.showCosmetics(CosmeticUser.HiddenReason.WORLD);
|
||||
}
|
||||
|
||||
if (user.hasCosmeticInSlot(CosmeticSlot.BALLOON)) {
|
||||
user.despawnBalloon();
|
||||
|
||||
@@ -162,7 +183,6 @@ public class PlayerGameListener implements Listener {
|
||||
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
||||
public void onPlayerHit(EntityDamageByEntityEvent event) {
|
||||
Entity entity = event.getEntity();
|
||||
if (event.getEntity().getEntityId() == event.getDamager().getEntityId()) event.setCancelled(true);
|
||||
if (!entity.getPersistentDataContainer().has(new NamespacedKey(HMCCosmeticsPlugin.getInstance(), "cosmeticMob"), PersistentDataType.SHORT))
|
||||
return;
|
||||
event.setCancelled(true);
|
||||
@@ -182,12 +202,16 @@ public class PlayerGameListener implements Listener {
|
||||
}
|
||||
}
|
||||
if (user.isInWardrobe()) {
|
||||
user.leaveWardrobe();
|
||||
if (WardrobeSettings.isPreventDamage()) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
if (WardrobeSettings.isDamagedKicked()) user.leaveWardrobe();
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
||||
public void onPlayerLook(PlayerMoveEvent event) {
|
||||
public void onPlayerMove(PlayerMoveEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
CosmeticUser user = CosmeticUsers.getUser(player);
|
||||
if (user == null) return;
|
||||
@@ -199,11 +223,11 @@ public class PlayerGameListener implements Listener {
|
||||
user.updateCosmetic(CosmeticSlot.BALLOON);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onPlayerPoseChange(EntityPoseChangeEvent event) {
|
||||
if (!(event.getEntity() instanceof Player player)) return;
|
||||
CosmeticUser user = CosmeticUsers.getUser(player);
|
||||
if (user == null) return;
|
||||
if (user == null || user.isInWardrobe()) return;
|
||||
if (!user.hasCosmeticInSlot(CosmeticSlot.BACKPACK)) return;
|
||||
Pose pose = event.getPose();
|
||||
if (pose.equals(Pose.STANDING)) {
|
||||
@@ -240,7 +264,7 @@ public class PlayerGameListener implements Listener {
|
||||
|
||||
CosmeticUser user = CosmeticUsers.getUser(event.getPlayer().getUniqueId());
|
||||
if (user == null) return;
|
||||
CosmeticSlot cosmeticSlot = InventoryUtils.BukkitCosmeticSlot(slot);
|
||||
CosmeticSlot cosmeticSlot = HMCCInventoryUtils.BukkitCosmeticSlot(slot);
|
||||
|
||||
if (!user.hasCosmeticInSlot(cosmeticSlot)) {
|
||||
MessagesUtil.sendDebugMessages("No cosmetic in " + cosmeticSlot);
|
||||
@@ -264,7 +288,14 @@ public class PlayerGameListener implements Listener {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
Bukkit.getScheduler().runTaskLater(HMCCosmeticsPlugin.getInstance(), () -> user.updateCosmetic(CosmeticSlot.OFFHAND), 2);
|
||||
Bukkit.getScheduler().runTaskLater(HMCCosmeticsPlugin.getInstance(), () -> {
|
||||
if (user.getEntity() == null) return; // Player has likely logged off
|
||||
user.updateCosmetic(CosmeticSlot.OFFHAND);
|
||||
List<Player> viewers = HMCCPacketManager.getViewers(user.getEntity().getLocation());
|
||||
if (viewers.isEmpty()) return;
|
||||
viewers.remove(user.getPlayer());
|
||||
PacketManager.equipmentSlotUpdate(user.getEntity().getEntityId(), EquipmentSlot.HAND, event.getPlayer().getInventory().getItemInMainHand(), viewers);
|
||||
}, 2);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL)
|
||||
@@ -287,7 +318,7 @@ public class PlayerGameListener implements Listener {
|
||||
return;
|
||||
}
|
||||
if (event.getAction().equals(EntityPotionEffectEvent.Action.CLEARED) || event.getAction().equals(EntityPotionEffectEvent.Action.REMOVED)) {
|
||||
user.showCosmetics();
|
||||
user.showCosmetics(CosmeticUser.HiddenReason.POTION);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -297,11 +328,12 @@ public class PlayerGameListener implements Listener {
|
||||
CosmeticUser user = CosmeticUsers.getUser(event.getPlayer());
|
||||
if (user == null) return;
|
||||
|
||||
event.getPlayer().getInventory().setItem(event.getPreviousSlot(), event.getPlayer().getInventory().getItem(event.getPreviousSlot()));
|
||||
//NMSHandlers.getHandler().slotUpdate(event.getPlayer(), event.getPreviousSlot());
|
||||
Bukkit.getScheduler().runTaskLater(HMCCosmeticsPlugin.getInstance(), () -> {
|
||||
user.updateCosmetic(CosmeticSlot.MAINHAND);
|
||||
}, 2);
|
||||
if (user.hasCosmeticInSlot(CosmeticSlot.MAINHAND)) {
|
||||
Bukkit.getScheduler().runTaskLater(HMCCosmeticsPlugin.getInstance(), () -> {
|
||||
user.updateCosmetic(CosmeticSlot.MAINHAND);
|
||||
}, 2);
|
||||
}
|
||||
|
||||
// #84, Riptides mess with backpacks
|
||||
ItemStack currentItem = event.getPlayer().getInventory().getItem(event.getNewSlot());
|
||||
@@ -328,12 +360,21 @@ public class PlayerGameListener implements Listener {
|
||||
public void onPlayerGamemodeSwitch(PlayerGameModeChangeEvent event) {
|
||||
CosmeticUser user = CosmeticUsers.getUser(event.getPlayer());
|
||||
if (user == null) return;
|
||||
if (user.isInWardrobe()) user.leaveWardrobe(true);
|
||||
|
||||
if (Settings.isDisabledGamemodesEnabled()) {
|
||||
if (Settings.getDisabledGamemodes().contains(event.getNewGameMode().toString())) {
|
||||
user.hideCosmetics(CosmeticUser.HiddenReason.GAMEMODE);
|
||||
} else {
|
||||
user.showCosmetics(CosmeticUser.HiddenReason.GAMEMODE);
|
||||
}
|
||||
}
|
||||
|
||||
if (Settings.isDestroyLooseCosmetics()) {
|
||||
ItemStack[] equippedArmor = event.getPlayer().getInventory().getArmorContents();
|
||||
if (equippedArmor.length == 0) return;
|
||||
for (ItemStack armor : equippedArmor) {
|
||||
if (InventoryUtils.isCosmeticItem(armor)) armor.setAmount(0);
|
||||
if (HMCCInventoryUtils.isCosmeticItem(armor)) armor.setAmount(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -342,11 +383,18 @@ public class PlayerGameListener implements Listener {
|
||||
public void onPlayerCosmeticEquip(PlayerCosmeticPostEquipEvent event) {
|
||||
CosmeticUser user = event.getUser();
|
||||
if (user.isInWardrobe() && event.getCosmetic().getSlot().equals(CosmeticSlot.BALLOON)) {
|
||||
Location NPCLocation = user.getWardrobeManager().getNpcLocation();
|
||||
if (user.getBalloonManager() == null) {
|
||||
MessagesUtil.sendDebugMessages("Balloon Manager is null? " + user.getEntity().getName());
|
||||
return;
|
||||
}
|
||||
CosmeticBalloonType cosmetic = (CosmeticBalloonType) event.getCosmetic();
|
||||
Location npclocation = user.getWardrobeManager().getNpcLocation().clone().add(cosmetic.getBalloonOffset());
|
||||
// We know that no other entity besides a regular player will be in the wardrobe
|
||||
PacketManager.sendTeleportPacket(user.getBalloonManager().getPufferfishBalloonId(), NPCLocation.add(cosmetic.getBalloonOffset()), false, List.of(user.getPlayer()));
|
||||
user.getBalloonManager().getModelEntity().teleport(NPCLocation.add(cosmetic.getBalloonOffset()));
|
||||
List<Player> viewer = List.of(user.getPlayer());
|
||||
user.getBalloonManager().getPufferfish().spawnPufferfish(npclocation.clone().add(cosmetic.getBalloonOffset()), viewer);
|
||||
HMCCPacketManager.sendLeashPacket(user.getBalloonManager().getPufferfishBalloonId(), user.getWardrobeManager().getNPC_ID(), viewer);
|
||||
HMCCPacketManager.sendTeleportPacket(user.getBalloonManager().getPufferfishBalloonId(), npclocation, false, viewer);
|
||||
user.getBalloonManager().getModelEntity().teleport(npclocation);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -370,6 +418,52 @@ public class PlayerGameListener implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
||||
public void onPlayerVanish(HibiscusPlayerVanishEvent event) {
|
||||
CosmeticUser user = CosmeticUsers.getUser(event.getPlayer());
|
||||
if (user == null) return;
|
||||
user.hideCosmetics(CosmeticUser.HiddenReason.PLUGIN);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
||||
public void onPlayerUnVanish(HibiscusPlayerUnVanishEvent event) {
|
||||
CosmeticUser user = CosmeticUsers.getUser(event.getPlayer());
|
||||
if (user == null) return;
|
||||
if (!user.isHidden()) return;
|
||||
user.showCosmetics(CosmeticUser.HiddenReason.PLUGIN);
|
||||
}
|
||||
|
||||
// These emote mostly handles emotes from other plugins, such as ItemsAdder
|
||||
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
||||
public void onPlayerPlayEmote(HibiscusPlayerEmotePlayEvent event) {
|
||||
CosmeticUser user = CosmeticUsers.getUser(event.getPlayer());
|
||||
if (user == null) return;
|
||||
user.hideCosmetics(CosmeticUser.HiddenReason.EMOTE);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOW)
|
||||
public void onPlayerEndEmote(HibiscusPlayerEmoteEndEvent event) {
|
||||
CosmeticUser user = CosmeticUsers.getUser(event.getPlayer());
|
||||
if (user == null) return;
|
||||
user.showCosmetics(CosmeticUser.HiddenReason.EMOTE);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOW)
|
||||
public void onPlayerHibiscusPose(HibiscusPlayerPoseEvent event) {
|
||||
if (event.isGettingUp()) return;
|
||||
CosmeticUser user = CosmeticUsers.getUser(event.getPlayer());
|
||||
if (user == null) return;
|
||||
user.hideCosmetics(CosmeticUser.HiddenReason.PLUGIN);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOW)
|
||||
public void onPlayerHibiscusGetUpPose(HibiscusPlayerPoseEvent event) {
|
||||
if (!event.isGettingUp()) return;
|
||||
CosmeticUser user = CosmeticUsers.getUser(event.getPlayer());
|
||||
if (user == null) return;
|
||||
user.showCosmetics(CosmeticUser.HiddenReason.PLUGIN);
|
||||
}
|
||||
|
||||
private void registerInventoryClickListener() {
|
||||
ProtocolLibrary.getProtocolManager().addPacketListener(new PacketAdapter(HMCCosmeticsPlugin.getInstance(), ListenerPriority.NORMAL, PacketType.Play.Client.WINDOW_CLICK) {
|
||||
@Override
|
||||
@@ -386,7 +480,8 @@ public class PlayerGameListener implements Listener {
|
||||
|
||||
CosmeticUser user = CosmeticUsers.getUser(player);
|
||||
if (user == null) return;
|
||||
CosmeticSlot cosmeticSlot = InventoryUtils.NMSCosmeticSlot(slotClicked);
|
||||
if (user.isInWardrobe()) return;
|
||||
CosmeticSlot cosmeticSlot = HMCCInventoryUtils.NMSCosmeticSlot(slotClicked);
|
||||
if (cosmeticSlot == null) return;
|
||||
if (!user.hasCosmeticInSlot(cosmeticSlot)) return;
|
||||
Bukkit.getScheduler().runTaskLater(HMCCosmeticsPlugin.getInstance(), () -> user.updateCosmetic(cosmeticSlot), 1);
|
||||
@@ -412,9 +507,15 @@ public class PlayerGameListener implements Listener {
|
||||
|
||||
HashMap<Integer, ItemStack> items = new HashMap<>();
|
||||
|
||||
for (Cosmetic cosmetic : user.getCosmetics()) {
|
||||
if ((cosmetic instanceof CosmeticArmorType cosmeticArmorType)) {
|
||||
items.put(InventoryUtils.getPacketArmorSlot(cosmeticArmorType.getEquipSlot()), user.getUserCosmeticItem(cosmeticArmorType));
|
||||
if (!user.isInWardrobe()) {
|
||||
for (Cosmetic cosmetic : user.getCosmetics()) {
|
||||
if ((cosmetic instanceof CosmeticArmorType cosmeticArmorType)) {
|
||||
boolean requireEmpty = Settings.getSlotOption(cosmeticArmorType.getEquipSlot()).isRequireEmpty();
|
||||
boolean isAir = user.getPlayer().getInventory().getItem(cosmeticArmorType.getEquipSlot()).getType().isAir();
|
||||
MessagesUtil.sendDebugMessages("Menu Fired (Checks) - " + cosmeticArmorType.getId() + " - " + requireEmpty + " - " + isAir);
|
||||
if (requireEmpty && !isAir) continue;
|
||||
items.put(HMCCInventoryUtils.getPacketArmorSlot(cosmeticArmorType.getEquipSlot()), user.getUserCosmeticItem(cosmeticArmorType));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -459,12 +560,18 @@ public class PlayerGameListener implements Listener {
|
||||
|
||||
CosmeticUser user = CosmeticUsers.getUser(player);
|
||||
if (user == null) return;
|
||||
if (user.isInWardrobe()) return;
|
||||
|
||||
int slot = event.getPacket().getIntegers().read(2);
|
||||
MessagesUtil.sendDebugMessages("SetSlot Slot " + slot);
|
||||
if (slot == 45 && user.hasCosmeticInSlot(CosmeticSlot.OFFHAND) && player.getInventory().getItemInOffHand().getType().isAir()) {
|
||||
event.getPacket().getItemModifier().write(0, user.getUserCosmeticItem(CosmeticSlot.OFFHAND));
|
||||
CosmeticSlot cosmeticSlot = HMCCInventoryUtils.NMSCosmeticSlot(slot);
|
||||
EquipmentSlot equipmentSlot = HMCCInventoryUtils.getPacketArmorSlot(slot);
|
||||
if (cosmeticSlot == null || equipmentSlot == null) return;
|
||||
if (!user.hasCosmeticInSlot(cosmeticSlot)) return;
|
||||
if (Settings.getSlotOption(equipmentSlot).isRequireEmpty()) {
|
||||
if (!player.getInventory().getItem(equipmentSlot).getType().isAir()) return;
|
||||
}
|
||||
event.getPacket().getItemModifier().write(0, user.getUserCosmeticItem(cosmeticSlot));
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -477,33 +584,33 @@ public class PlayerGameListener implements Listener {
|
||||
int entityID = event.getPacket().getIntegers().read(0);
|
||||
// User
|
||||
CosmeticUser user = CosmeticUsers.getUser(entityID);
|
||||
if (user == null) {
|
||||
return;
|
||||
}
|
||||
if (user == null) return;
|
||||
if (user.isInWardrobe()) return;
|
||||
|
||||
List<com.comphenix.protocol.wrappers.Pair<EnumWrappers.ItemSlot, ItemStack>> armor = event.getPacket().getSlotStackPairLists().read(0);
|
||||
|
||||
for (EquipmentSlot equipmentSlot : EquipmentSlot.values()) {
|
||||
if (equipmentSlot.equals(EquipmentSlot.HAND)) {
|
||||
Pair<EnumWrappers.ItemSlot, ItemStack> pair = new Pair<>(EnumWrappers.ItemSlot.MAINHAND, user.getPlayer().getInventory().getItemInMainHand());
|
||||
armor.add(pair);
|
||||
continue;
|
||||
}
|
||||
if (equipmentSlot.equals(EquipmentSlot.OFF_HAND)) {
|
||||
ItemStack item = null;
|
||||
if (user.getPlayer().getInventory().getItemInOffHand().getType().isAir()) {
|
||||
if (user.hasCosmeticInSlot(CosmeticSlot.OFFHAND)) item = user.getUserCosmeticItem(CosmeticSlot.OFFHAND);
|
||||
} else {
|
||||
item = user.getPlayer().getInventory().getItemInOffHand();
|
||||
for (int i = 0; i < armor.size(); i++) {
|
||||
com.comphenix.protocol.wrappers.Pair<EnumWrappers.ItemSlot, ItemStack> pair = armor.get(i);
|
||||
switch (pair.getFirst()) {
|
||||
case MAINHAND -> {
|
||||
if (user.getPlayer() == event.getPlayer()) continue; // When a player scrolls real fast, it messes up the mainhand. This fixes it
|
||||
if (user.getPlayer() != null && user.getPlayer().isInvisible()) continue; // Fixes integration with GSit still showing mainhand even when hidden
|
||||
armor.set(i, new Pair<>(pair.getFirst(), user.getPlayer().getInventory().getItemInMainHand()));
|
||||
}
|
||||
default -> {
|
||||
EquipmentSlot slot = HMCCInventoryUtils.getEquipmentSlot(pair.getFirst());
|
||||
CosmeticSlot cosmeticSlot = HMCCInventoryUtils.getItemSlotToCosmeticSlot(pair.getFirst());
|
||||
if (slot == null || cosmeticSlot == null) continue;
|
||||
if (Settings.getSlotOption(slot).isRequireEmpty()
|
||||
&& !user.getPlayer().getInventory().getItem(slot).getType().isAir()) continue;
|
||||
CosmeticArmorType cosmeticArmor = (CosmeticArmorType) user.getCosmetic(cosmeticSlot);
|
||||
if (cosmeticArmor == null) continue;
|
||||
ItemStack item = user.getUserCosmeticItem(cosmeticArmor);
|
||||
if (item == null) continue;
|
||||
Pair<EnumWrappers.ItemSlot, ItemStack> armorPair = new Pair<>(HMCCInventoryUtils.itemBukkitSlot(slot), item);
|
||||
armor.set(i, armorPair);
|
||||
}
|
||||
Pair<EnumWrappers.ItemSlot, ItemStack> pair = new Pair<>(EnumWrappers.ItemSlot.OFFHAND, item);
|
||||
armor.add(pair);
|
||||
continue;
|
||||
}
|
||||
CosmeticArmorType cosmeticArmor = (CosmeticArmorType) user.getCosmetic(InventoryUtils.BukkitCosmeticSlot(equipmentSlot));
|
||||
if (cosmeticArmor == null) continue;
|
||||
Pair<EnumWrappers.ItemSlot, ItemStack> pair = new Pair<>(InventoryUtils.itemBukkitSlot(cosmeticArmor.getEquipSlot()), cosmeticArmor.getItem());
|
||||
armor.add(pair);
|
||||
}
|
||||
|
||||
event.getPacket().getSlotStackPairLists().write(0, armor);
|
||||
@@ -533,6 +640,37 @@ public class PlayerGameListener implements Listener {
|
||||
});
|
||||
}
|
||||
|
||||
private void registerPassengerSetListener() {
|
||||
ProtocolLibrary.getProtocolManager().addPacketListener(new PacketAdapter(HMCCosmeticsPlugin.getInstance(), ListenerPriority.NORMAL, PacketType.Play.Server.MOUNT) {
|
||||
@Override
|
||||
public void onPacketSending(PacketEvent event) {
|
||||
CosmeticUser viewerUser = CosmeticUsers.getUser(event.getPlayer().getUniqueId());
|
||||
if (viewerUser == null) return;
|
||||
if (viewerUser.isInWardrobe()) return;
|
||||
|
||||
int ownerId = event.getPacket().getIntegers().read(0);
|
||||
MessagesUtil.sendDebugMessages("Mount Packet Sent - Read - EntityID: " + ownerId);
|
||||
Entity entity = HMCCServerUtils.getEntity(ownerId);
|
||||
if (entity == null) return;
|
||||
|
||||
CosmeticUser user = CosmeticUsers.getUser(entity.getUniqueId());
|
||||
if (user == null) return;
|
||||
MessagesUtil.sendDebugMessages("Mount Packet Sent - " + user.getUniqueId());
|
||||
|
||||
if (!user.hasCosmeticInSlot(CosmeticSlot.BACKPACK)) return;
|
||||
if (user.getUserBackpackManager() == null) return;
|
||||
|
||||
// Basically, take the original passengers and "bump" them to the end of the list
|
||||
int[] originalPassengers = event.getPacket().getIntegerArrays().read(0);
|
||||
List<Integer> passengers = new ArrayList<>(user.getUserBackpackManager().getEntityManager().getIds());
|
||||
|
||||
passengers.addAll(Arrays.stream(originalPassengers).boxed().toList());
|
||||
|
||||
event.getPacket().getIntegerArrays().write(0, passengers.stream().mapToInt(Integer::intValue).toArray());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void registerPlayerArmListener() {
|
||||
ProtocolLibrary.getProtocolManager().addPacketListener(new PacketAdapter(HMCCosmeticsPlugin.getInstance(), ListenerPriority.NORMAL, PacketType.Play.Client.ARM_ANIMATION) {
|
||||
@Override
|
||||
@@ -546,7 +684,9 @@ public class PlayerGameListener implements Listener {
|
||||
return;
|
||||
}
|
||||
if (!user.isInWardrobe()) return;
|
||||
Menu menu = Menus.getDefaultMenu();
|
||||
if (!user.getWardrobeManager().getWardrobeStatus().equals(UserWardrobeManager.WardrobeStatus.RUNNING)) return;
|
||||
|
||||
Menu menu = user.getWardrobeManager().getLastOpenMenu();
|
||||
if (menu == null) return;
|
||||
menu.openMenu(user);
|
||||
event.setCancelled(true);
|
||||
@@ -620,10 +760,6 @@ public class PlayerGameListener implements Listener {
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@Nullable
|
||||
private EquipmentSlot getArmorSlot(final Material material) {
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,48 +0,0 @@
|
||||
package com.hibiscusmc.hmccosmetics.nms;
|
||||
|
||||
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticBackpackType;
|
||||
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticBalloonType;
|
||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||
import com.hibiscusmc.hmccosmetics.user.manager.UserBalloonManager;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.ArmorStand;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface NMSHandler {
|
||||
|
||||
int getNextEntityId();
|
||||
|
||||
Entity getEntity(int entityId);
|
||||
|
||||
ArmorStand getMEGEntity(Location loc);
|
||||
|
||||
Entity spawnBackpack(CosmeticUser user, CosmeticBackpackType cosmeticBackpackType);
|
||||
|
||||
Entity spawnDisplayEntity(Location location, String text);
|
||||
|
||||
UserBalloonManager spawnBalloon(CosmeticUser user, CosmeticBalloonType cosmeticBalloonType);
|
||||
|
||||
void slotUpdate(
|
||||
Player player,
|
||||
int slot
|
||||
);
|
||||
|
||||
void equipmentSlotUpdate(
|
||||
int entityId,
|
||||
org.bukkit.inventory.EquipmentSlot slot,
|
||||
ItemStack item,
|
||||
List<Player> sendTo
|
||||
);
|
||||
|
||||
void hideNPCName(
|
||||
Player player,
|
||||
String NPCName);
|
||||
|
||||
default boolean getSupported () {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -1,46 +0,0 @@
|
||||
package com.hibiscusmc.hmccosmetics.nms;
|
||||
|
||||
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
|
||||
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||
import lombok.Getter;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class NMSHandlers {
|
||||
|
||||
private static final String[] SUPPORTED_VERSION = new String[]{"v1_18_R2", "v1_19_R1", "v1_19_R2", "v1_19_R3", "v1_20_R1"};
|
||||
private static NMSHandler handler;
|
||||
@Getter
|
||||
private static String version;
|
||||
|
||||
public static NMSHandler getHandler() {
|
||||
if (handler != null) {
|
||||
return handler;
|
||||
} else {
|
||||
setup();
|
||||
}
|
||||
return handler;
|
||||
}
|
||||
|
||||
public static void setup() {
|
||||
if (handler != null) return;
|
||||
final String packageName = HMCCosmeticsPlugin.getInstance().getServer().getClass().getPackage().getName();
|
||||
String packageVersion = packageName.substring(packageName.lastIndexOf('.') + 1);
|
||||
|
||||
for (String selectedVersion : SUPPORTED_VERSION) {
|
||||
if (!selectedVersion.contains(packageVersion)) {
|
||||
continue;
|
||||
}
|
||||
MessagesUtil.sendDebugMessages(packageVersion + " has been detected.", Level.INFO);
|
||||
version = packageVersion;
|
||||
try {
|
||||
handler = (NMSHandler) Class.forName("com.hibiscusmc.hmccosmetics.nms." + packageVersion + ".NMSHandler").getConstructor().newInstance();
|
||||
return;
|
||||
} catch (ClassNotFoundException | InvocationTargetException | InstantiationException |
|
||||
IllegalAccessException | NoSuchMethodException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -13,27 +13,33 @@ import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticArmorType;
|
||||
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticBackpackType;
|
||||
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticBalloonType;
|
||||
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticMainhandType;
|
||||
import com.hibiscusmc.hmccosmetics.hooks.Hooks;
|
||||
import com.hibiscusmc.hmccosmetics.nms.NMSHandlers;
|
||||
import com.hibiscusmc.hmccosmetics.database.UserData;
|
||||
import com.hibiscusmc.hmccosmetics.gui.Menus;
|
||||
import com.hibiscusmc.hmccosmetics.user.manager.UserBackpackManager;
|
||||
import com.hibiscusmc.hmccosmetics.user.manager.UserBalloonManager;
|
||||
import com.hibiscusmc.hmccosmetics.user.manager.UserEmoteManager;
|
||||
import com.hibiscusmc.hmccosmetics.user.manager.UserWardrobeManager;
|
||||
import com.hibiscusmc.hmccosmetics.util.InventoryUtils;
|
||||
import com.hibiscusmc.hmccosmetics.util.HMCCInventoryUtils;
|
||||
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||
import com.hibiscusmc.hmccosmetics.util.PlayerUtils;
|
||||
import com.hibiscusmc.hmccosmetics.util.packets.PacketManager;
|
||||
import com.hibiscusmc.hmccosmetics.util.HMCCPlayerUtils;
|
||||
import com.hibiscusmc.hmccosmetics.util.packets.HMCCPacketManager;
|
||||
import lombok.Getter;
|
||||
import me.lojosho.hibiscuscommons.hooks.Hooks;
|
||||
import me.lojosho.hibiscuscommons.util.InventoryUtils;
|
||||
import me.lojosho.hibiscuscommons.util.packets.PacketManager;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Color;
|
||||
import org.bukkit.FireworkEffect;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.HumanEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.EquipmentSlot;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.*;
|
||||
import org.bukkit.persistence.PersistentDataType;
|
||||
import org.bukkit.scheduler.BukkitTask;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.*;
|
||||
@@ -53,10 +59,10 @@ public class CosmeticUser {
|
||||
private final UserEmoteManager userEmoteManager;
|
||||
|
||||
// Cosmetic Settings/Toggles
|
||||
private boolean hideCosmetics;
|
||||
@Getter
|
||||
private HiddenReason hiddenReason;
|
||||
private final ArrayList<HiddenReason> hiddenReason = new ArrayList<>();
|
||||
private final HashMap<CosmeticSlot, Color> colors = new HashMap<>();
|
||||
// Cosmetic caches
|
||||
private final HashMap<String, ItemStack> cosmeticItems = new HashMap<>();
|
||||
|
||||
public CosmeticUser(UUID uuid) {
|
||||
this.uniqueId = uuid;
|
||||
@@ -64,12 +70,19 @@ public class CosmeticUser {
|
||||
tick();
|
||||
}
|
||||
|
||||
public CosmeticUser(UUID uuid, UserData data) {
|
||||
this.uniqueId = uuid;
|
||||
userEmoteManager = new UserEmoteManager(this);
|
||||
loadData(data);
|
||||
tick();
|
||||
}
|
||||
|
||||
private void tick() {
|
||||
// Occasionally updates the entity cosmetics
|
||||
Runnable run = () -> {
|
||||
MessagesUtil.sendDebugMessages("Tick[uuid=" + uniqueId + "]", Level.INFO);
|
||||
updateCosmetic();
|
||||
if (getHidden() && !getUserEmoteManager().isPlayingEmote()) MessagesUtil.sendActionBar(getPlayer(), "hidden-cosmetics");
|
||||
if (isHidden() && !getUserEmoteManager().isPlayingEmote() && !getCosmetics().isEmpty()) MessagesUtil.sendActionBar(getPlayer(), "hidden-cosmetics");
|
||||
};
|
||||
|
||||
int tickPeriod = Settings.getTickPeriod();
|
||||
@@ -85,24 +98,67 @@ public class CosmeticUser {
|
||||
despawnBalloon();
|
||||
}
|
||||
|
||||
public Cosmetic getCosmetic(CosmeticSlot slot) {
|
||||
return playerCosmetics.get(slot);
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public Collection<Cosmetic> getCosmetic() {
|
||||
return playerCosmetics.values();
|
||||
public Cosmetic getCosmetic(CosmeticSlot slot) {
|
||||
return playerCosmetics.get(slot);
|
||||
}
|
||||
|
||||
public ImmutableCollection<Cosmetic> getCosmetics() {
|
||||
return ImmutableList.copyOf(playerCosmetics.values());
|
||||
}
|
||||
|
||||
public void addPlayerCosmetic(Cosmetic cosmetic) {
|
||||
public void addPlayerCosmetic(@NotNull Cosmetic cosmetic) {
|
||||
addPlayerCosmetic(cosmetic, null);
|
||||
}
|
||||
|
||||
public void addPlayerCosmetic(Cosmetic cosmetic, Color color) {
|
||||
public void addPlayerCosmetic(@NotNull Cosmetic cosmetic, @Nullable Color color) {
|
||||
// API
|
||||
PlayerCosmeticEquipEvent event = new PlayerCosmeticEquipEvent(this, cosmetic);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
@@ -118,14 +174,16 @@ public class CosmeticUser {
|
||||
playerCosmetics.put(cosmetic.getSlot(), cosmetic);
|
||||
if (color != null) colors.put(cosmetic.getSlot(), color);
|
||||
MessagesUtil.sendDebugMessages("addPlayerCosmetic[id=" + cosmetic.getId() + "]");
|
||||
if (cosmetic.getSlot() == CosmeticSlot.BACKPACK) {
|
||||
CosmeticBackpackType backpackType = (CosmeticBackpackType) cosmetic;
|
||||
spawnBackpack(backpackType);
|
||||
MessagesUtil.sendDebugMessages("addPlayerCosmetic[spawnBackpack,id=" + cosmetic.getId() + "]");
|
||||
}
|
||||
if (cosmetic.getSlot() == CosmeticSlot.BALLOON) {
|
||||
CosmeticBalloonType balloonType = (CosmeticBalloonType) cosmetic;
|
||||
spawnBalloon(balloonType);
|
||||
if (!isHidden()) {
|
||||
if (cosmetic.getSlot() == CosmeticSlot.BACKPACK) {
|
||||
CosmeticBackpackType backpackType = (CosmeticBackpackType) cosmetic;
|
||||
spawnBackpack(backpackType);
|
||||
MessagesUtil.sendDebugMessages("addPlayerCosmetic[spawnBackpack,id=" + cosmetic.getId() + "]");
|
||||
}
|
||||
if (cosmetic.getSlot() == CosmeticSlot.BALLOON) {
|
||||
CosmeticBalloonType balloonType = (CosmeticBalloonType) cosmetic;
|
||||
spawnBalloon(balloonType);
|
||||
}
|
||||
}
|
||||
// API
|
||||
PlayerCosmeticPostEquipEvent postEquipEvent = new PlayerCosmeticPostEquipEvent(this, cosmetic);
|
||||
@@ -193,22 +251,45 @@ public class CosmeticUser {
|
||||
}
|
||||
|
||||
public void updateCosmetic() {
|
||||
MessagesUtil.sendDebugMessages("updateCosmetic (All) - start");
|
||||
HashMap<EquipmentSlot, ItemStack> items = new HashMap<>();
|
||||
|
||||
for (Cosmetic cosmetic : getCosmetics()) {
|
||||
updateCosmetic(cosmetic.getSlot());
|
||||
if (cosmetic instanceof CosmeticArmorType armorType) {
|
||||
if (getUserEmoteManager().isPlayingEmote() || isInWardrobe()) return;
|
||||
if (!(getEntity() instanceof HumanEntity humanEntity)) return;
|
||||
|
||||
boolean requireEmpty = Settings.getSlotOption(armorType.getEquipSlot()).isRequireEmpty();
|
||||
boolean isAir = humanEntity.getInventory().getItem(armorType.getEquipSlot()).getType().isAir();
|
||||
MessagesUtil.sendDebugMessages("updateCosmetic (All) - " + armorType.getId() + " - " + requireEmpty + " - " + isAir);
|
||||
if (requireEmpty && !isAir) continue;
|
||||
|
||||
items.put(HMCCInventoryUtils.getEquipmentSlot(armorType.getSlot()), armorType.getItem(this));
|
||||
} else {
|
||||
updateCosmetic(cosmetic.getSlot());
|
||||
}
|
||||
}
|
||||
if (items.isEmpty() || getEntity() == null) return;
|
||||
PacketManager.equipmentSlotUpdate(getEntity().getEntityId(), items, HMCCPlayerUtils.getNearbyPlayers(getEntity().getLocation()));
|
||||
MessagesUtil.sendDebugMessages("updateCosmetic (All) - end - " + items.size());
|
||||
}
|
||||
|
||||
public ItemStack getUserCosmeticItem(CosmeticSlot slot) {
|
||||
return getUserCosmeticItem(getCosmetic(slot));
|
||||
Cosmetic cosmetic = getCosmetic(slot);
|
||||
if (cosmetic == null) return new ItemStack(Material.AIR);
|
||||
return getUserCosmeticItem(cosmetic);
|
||||
}
|
||||
|
||||
public ItemStack getUserCosmeticItem(Cosmetic cosmetic) {
|
||||
public ItemStack getUserCosmeticItem(@NotNull Cosmetic cosmetic) {
|
||||
ItemStack item = null;
|
||||
if (hideCosmetics) {
|
||||
if (!hiddenReason.isEmpty()) {
|
||||
if (cosmetic instanceof CosmeticBackpackType || cosmetic instanceof CosmeticBalloonType) return new ItemStack(Material.AIR);
|
||||
return getPlayer().getInventory().getItem(InventoryUtils.getEquipmentSlot(cosmetic.getSlot()));
|
||||
return getPlayer().getInventory().getItem(HMCCInventoryUtils.getEquipmentSlot(cosmetic.getSlot()));
|
||||
}
|
||||
if (cosmetic instanceof CosmeticArmorType || cosmetic instanceof CosmeticMainhandType || cosmetic instanceof CosmeticBackpackType) {
|
||||
if (cosmetic instanceof CosmeticArmorType armorType) {
|
||||
item = armorType.getItem(this, cosmetic.getItem());
|
||||
}
|
||||
if (cosmetic instanceof CosmeticBackpackType || cosmetic instanceof CosmeticMainhandType) {
|
||||
item = cosmetic.getItem();
|
||||
}
|
||||
if (cosmetic instanceof CosmeticBalloonType) {
|
||||
@@ -218,15 +299,15 @@ public class CosmeticUser {
|
||||
item = cosmetic.getItem();
|
||||
}
|
||||
}
|
||||
if (item == null) {
|
||||
MessagesUtil.sendDebugMessages("GetUserCosemticUser Item is null");
|
||||
return null;
|
||||
}
|
||||
return getUserCosmeticItem(cosmetic, item);
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public ItemStack getUserCosmeticItem(Cosmetic cosmetic, ItemStack item) {
|
||||
public ItemStack getUserCosmeticItem(@NotNull Cosmetic cosmetic, @Nullable ItemStack item) {
|
||||
if (item == null) {
|
||||
//MessagesUtil.sendDebugMessages("GetUserCosemticUser Item is null");
|
||||
return new ItemStack(Material.AIR);
|
||||
}
|
||||
if (item.hasItemMeta()) {
|
||||
ItemMeta itemMeta = item.getItemMeta();
|
||||
|
||||
@@ -253,18 +334,22 @@ public class CosmeticUser {
|
||||
itemMeta = skullMeta;
|
||||
}
|
||||
|
||||
List<String> processedLore = new ArrayList<>();
|
||||
|
||||
if (itemMeta.hasLore()) {
|
||||
for (String loreLine : itemMeta.getLore()) {
|
||||
processedLore.add(Hooks.processPlaceholders(getPlayer(), loreLine));
|
||||
if (Settings.isItemProcessingDisplayName()) {
|
||||
if (itemMeta.hasDisplayName()) {
|
||||
String displayName = itemMeta.getDisplayName();
|
||||
itemMeta.setDisplayName(Hooks.processPlaceholders(getPlayer(), displayName));
|
||||
}
|
||||
}
|
||||
if (itemMeta.hasDisplayName()) {
|
||||
String displayName = itemMeta.getDisplayName();
|
||||
itemMeta.setDisplayName(Hooks.processPlaceholders(getPlayer(), displayName));
|
||||
if (Settings.isItemProcessingLore()) {
|
||||
List<String> processedLore = new ArrayList<>();
|
||||
if (itemMeta.hasLore()) {
|
||||
for (String loreLine : itemMeta.getLore()) {
|
||||
processedLore.add(Hooks.processPlaceholders(getPlayer(), loreLine));
|
||||
}
|
||||
}
|
||||
itemMeta.setLore(processedLore);
|
||||
}
|
||||
itemMeta.setLore(processedLore);
|
||||
|
||||
|
||||
if (colors.containsKey(cosmetic.getSlot())) {
|
||||
Color color = colors.get(cosmetic.getSlot());
|
||||
@@ -274,9 +359,18 @@ public class CosmeticUser {
|
||||
potionMeta.setColor(color);
|
||||
} else if (itemMeta instanceof MapMeta mapMeta) {
|
||||
mapMeta.setColor(color);
|
||||
} else if (itemMeta instanceof FireworkEffectMeta fireworkMeta) {
|
||||
fireworkMeta.setEffect(
|
||||
FireworkEffect.builder()
|
||||
.with(FireworkEffect.Type.BALL)
|
||||
.withColor(color)
|
||||
.trail(false)
|
||||
.flicker(false)
|
||||
.build()
|
||||
);
|
||||
}
|
||||
}
|
||||
itemMeta.getPersistentDataContainer().set(InventoryUtils.getCosmeticKey(), PersistentDataType.STRING, cosmetic.getId());
|
||||
itemMeta.getPersistentDataContainer().set(HMCCInventoryUtils.getCosmeticKey(), PersistentDataType.STRING, cosmetic.getId());
|
||||
itemMeta.getPersistentDataContainer().set(InventoryUtils.getOwnerKey(), PersistentDataType.STRING, getEntity().getUniqueId().toString());
|
||||
|
||||
item.setItemMeta(itemMeta);
|
||||
@@ -292,7 +386,7 @@ public class CosmeticUser {
|
||||
return userWardrobeManager;
|
||||
}
|
||||
|
||||
public void enterWardrobe(boolean ignoreDistance, Wardrobe wardrobe) {
|
||||
public void enterWardrobe(boolean ignoreDistance, @NotNull Wardrobe wardrobe) {
|
||||
if (wardrobe.hasPermission() && !getPlayer().hasPermission(wardrobe.getPermission())) {
|
||||
MessagesUtil.sendMessage(getPlayer(), "no-permission");
|
||||
return;
|
||||
@@ -319,6 +413,10 @@ public class CosmeticUser {
|
||||
}
|
||||
|
||||
public void leaveWardrobe() {
|
||||
leaveWardrobe(false);
|
||||
}
|
||||
|
||||
public void leaveWardrobe(boolean ejected) {
|
||||
PlayerWardrobeLeaveEvent event = new PlayerWardrobeLeaveEvent(this);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
if (event.isCancelled()) {
|
||||
@@ -328,8 +426,9 @@ public class CosmeticUser {
|
||||
if (!getWardrobeManager().getWardrobeStatus().equals(UserWardrobeManager.WardrobeStatus.RUNNING)) return;
|
||||
|
||||
getWardrobeManager().setWardrobeStatus(UserWardrobeManager.WardrobeStatus.STOPPING);
|
||||
getWardrobeManager().setLastOpenMenu(Menus.getDefaultMenu());
|
||||
|
||||
if (WardrobeSettings.isEnabledTransition()) {
|
||||
if (WardrobeSettings.isEnabledTransition() && !ejected) {
|
||||
MessagesUtil.sendTitle(
|
||||
getPlayer(),
|
||||
WardrobeSettings.getTransitionText(),
|
||||
@@ -367,18 +466,27 @@ public class CosmeticUser {
|
||||
return this.userBackpackManager != null;
|
||||
}
|
||||
|
||||
public boolean isBalloonSpawned() {
|
||||
return this.userBalloonManager != null;
|
||||
}
|
||||
|
||||
public void spawnBalloon(CosmeticBalloonType cosmeticBalloonType) {
|
||||
if (this.userBalloonManager != null) return;
|
||||
this.userBalloonManager = NMSHandlers.getHandler().spawnBalloon(this, cosmeticBalloonType);
|
||||
//updateCosmetic(cosmeticBalloonType);
|
||||
|
||||
org.bukkit.entity.Entity entity = getEntity();
|
||||
|
||||
UserBalloonManager userBalloonManager1 = new UserBalloonManager(this, entity.getLocation());
|
||||
userBalloonManager1.getModelEntity().teleport(entity.getLocation().add(cosmeticBalloonType.getBalloonOffset()));
|
||||
|
||||
userBalloonManager1.spawnModel(cosmeticBalloonType, getCosmeticColor(cosmeticBalloonType.getSlot()));
|
||||
userBalloonManager1.addPlayerToModel(this, cosmeticBalloonType, getCosmeticColor(cosmeticBalloonType.getSlot()));
|
||||
|
||||
this.userBalloonManager = userBalloonManager1;
|
||||
//this.userBalloonManager = NMSHandlers.getHandler().spawnBalloon(this, cosmeticBalloonType);
|
||||
}
|
||||
|
||||
public void despawnBalloon() {
|
||||
if (this.userBalloonManager == null) return;
|
||||
List<Player> sentTo = PlayerUtils.getNearbyPlayers(getEntity().getLocation());
|
||||
|
||||
PacketManager.sendEntityDestroyPacket(userBalloonManager.getPufferfishBalloonId(), sentTo);
|
||||
|
||||
this.userBalloonManager.remove();
|
||||
this.userBalloonManager = null;
|
||||
}
|
||||
@@ -387,23 +495,27 @@ public class CosmeticUser {
|
||||
if (!hasCosmeticInSlot(CosmeticSlot.BACKPACK)) return;
|
||||
final Cosmetic cosmetic = getCosmetic(CosmeticSlot.BACKPACK);
|
||||
despawnBackpack();
|
||||
if (!hiddenReason.isEmpty()) return;
|
||||
spawnBackpack((CosmeticBackpackType) cosmetic);
|
||||
MessagesUtil.sendDebugMessages("Respawned Backpack for " + getEntity().getName());
|
||||
}
|
||||
|
||||
public void respawnBalloon() {
|
||||
if (!hasCosmeticInSlot(CosmeticSlot.BALLOON)) return;
|
||||
final Cosmetic cosmetic = getCosmetic(CosmeticSlot.BALLOON);
|
||||
despawnBalloon();
|
||||
if (!hiddenReason.isEmpty()) return;
|
||||
spawnBalloon((CosmeticBalloonType) cosmetic);
|
||||
MessagesUtil.sendDebugMessages("Respawned Balloon for " + getEntity().getName());
|
||||
}
|
||||
|
||||
public void removeArmor(CosmeticSlot slot) {
|
||||
EquipmentSlot equipmentSlot = InventoryUtils.getEquipmentSlot(slot);
|
||||
EquipmentSlot equipmentSlot = HMCCInventoryUtils.getEquipmentSlot(slot);
|
||||
if (equipmentSlot == null) return;
|
||||
if (getPlayer() != null) {
|
||||
NMSHandlers.getHandler().equipmentSlotUpdate(getEntity().getEntityId(), equipmentSlot, getPlayer().getInventory().getItem(equipmentSlot), PlayerUtils.getNearbyPlayers(getEntity().getLocation()));
|
||||
PacketManager.equipmentSlotUpdate(getEntity().getEntityId(), equipmentSlot, getPlayer().getInventory().getItem(equipmentSlot), HMCCPlayerUtils.getNearbyPlayers(getEntity().getLocation()));
|
||||
} else {
|
||||
PacketManager.equipmentSlotUpdate(getEntity().getEntityId(), this, slot, PlayerUtils.getNearbyPlayers(getEntity().getLocation()));
|
||||
HMCCPacketManager.equipmentSlotUpdate(getEntity().getEntityId(), this, slot, HMCCPlayerUtils.getNearbyPlayers(getEntity().getLocation()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -470,28 +582,35 @@ public class CosmeticUser {
|
||||
}
|
||||
|
||||
public void hideCosmetics(HiddenReason reason) {
|
||||
if (hideCosmetics) return;
|
||||
PlayerCosmeticHideEvent event = new PlayerCosmeticHideEvent(this, reason);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
if (event.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
hideCosmetics = true;
|
||||
hiddenReason = reason;
|
||||
if (!hiddenReason.contains(reason)) hiddenReason.add(reason);
|
||||
if (hasCosmeticInSlot(CosmeticSlot.BALLOON)) {
|
||||
getBalloonManager().removePlayerFromModel(getPlayer());
|
||||
getBalloonManager().sendRemoveLeashPacket();
|
||||
despawnBalloon();
|
||||
//getBalloonManager().removePlayerFromModel(getPlayer());
|
||||
//getBalloonManager().sendRemoveLeashPacket();
|
||||
}
|
||||
if (hasCosmeticInSlot(CosmeticSlot.BACKPACK)) {
|
||||
userBackpackManager.clearItems();
|
||||
despawnBackpack();
|
||||
}
|
||||
updateCosmetic();
|
||||
MessagesUtil.sendDebugMessages("HideCosmetics");
|
||||
}
|
||||
|
||||
public void showCosmetics() {
|
||||
if (!hideCosmetics) return;
|
||||
/**
|
||||
* This is used to silently add a hidden flag to the user. This will not trigger any events or checks, nor do anything else
|
||||
* @param reason
|
||||
*/
|
||||
public void silentlyAddHideFlag(HiddenReason reason) {
|
||||
if (!hiddenReason.contains(reason)) hiddenReason.add(reason);
|
||||
}
|
||||
|
||||
public void showCosmetics(HiddenReason reason) {
|
||||
if (hiddenReason.isEmpty()) return;
|
||||
|
||||
PlayerCosmeticShowEvent event = new PlayerCosmeticShowEvent(this);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
@@ -499,15 +618,17 @@ public class CosmeticUser {
|
||||
return;
|
||||
}
|
||||
|
||||
hideCosmetics = false;
|
||||
hiddenReason = HiddenReason.NONE;
|
||||
hiddenReason.remove(reason);
|
||||
if (isHidden()) return;
|
||||
if (hasCosmeticInSlot(CosmeticSlot.BALLOON)) {
|
||||
if (!isBalloonSpawned()) respawnBalloon();
|
||||
CosmeticBalloonType balloonType = (CosmeticBalloonType) getCosmetic(CosmeticSlot.BALLOON);
|
||||
getBalloonManager().addPlayerToModel(this, balloonType);
|
||||
List<Player> viewer = PlayerUtils.getNearbyPlayers(getEntity().getLocation());
|
||||
PacketManager.sendLeashPacket(getBalloonManager().getPufferfishBalloonId(), getPlayer().getEntityId(), viewer);
|
||||
List<Player> viewer = HMCCPlayerUtils.getNearbyPlayers(getEntity().getLocation());
|
||||
HMCCPacketManager.sendLeashPacket(getBalloonManager().getPufferfishBalloonId(), getPlayer().getEntityId(), viewer);
|
||||
}
|
||||
if (hasCosmeticInSlot(CosmeticSlot.BACKPACK) && isBackpackSpawned()) {
|
||||
if (hasCosmeticInSlot(CosmeticSlot.BACKPACK)) {
|
||||
if (!isBackpackSpawned()) respawnBackpack();
|
||||
CosmeticBackpackType cosmeticBackpackType = (CosmeticBackpackType) getCosmetic(CosmeticSlot.BACKPACK);
|
||||
ItemStack item = getUserCosmeticItem(cosmeticBackpackType);
|
||||
userBackpackManager.setItem(item);
|
||||
@@ -516,8 +637,30 @@ public class CosmeticUser {
|
||||
MessagesUtil.sendDebugMessages("ShowCosmetics");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This method is deprecated and will be removed in the future. Use {@link #isHidden()} instead.
|
||||
* @return
|
||||
*/
|
||||
@Deprecated(since = "2.7.2-DEV", forRemoval = true)
|
||||
public boolean getHidden() {
|
||||
return this.hideCosmetics;
|
||||
return !hiddenReason.isEmpty();
|
||||
}
|
||||
|
||||
public boolean isHidden() {
|
||||
return !hiddenReason.isEmpty();
|
||||
}
|
||||
|
||||
public boolean isHidden(HiddenReason reason) {
|
||||
return hiddenReason.contains(reason);
|
||||
}
|
||||
|
||||
public List<HiddenReason> getHiddenReasons() {
|
||||
return hiddenReason;
|
||||
}
|
||||
|
||||
public void clearHiddenReasons() {
|
||||
hiddenReason.clear();
|
||||
}
|
||||
|
||||
public enum HiddenReason {
|
||||
@@ -527,6 +670,9 @@ public class CosmeticUser {
|
||||
POTION,
|
||||
ACTION,
|
||||
COMMAND,
|
||||
EMOTE
|
||||
EMOTE,
|
||||
GAMEMODE,
|
||||
WORLD,
|
||||
DISABLED
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
package com.hibiscusmc.hmccosmetics.user;
|
||||
|
||||
import com.google.common.collect.HashBiMap;
|
||||
import com.hibiscusmc.hmccosmetics.util.ServerUtils;
|
||||
import com.hibiscusmc.hmccosmetics.util.HMCCServerUtils;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Set;
|
||||
@@ -11,39 +12,71 @@ import java.util.UUID;
|
||||
|
||||
public class CosmeticUsers {
|
||||
|
||||
private static HashBiMap<UUID, CosmeticUser> COSMETIC_USERS = HashBiMap.create();
|
||||
private static final HashBiMap<UUID, CosmeticUser> COSMETIC_USERS = HashBiMap.create();
|
||||
|
||||
public static void addUser(CosmeticUser user) {
|
||||
/**
|
||||
* Adds a user to the Hashmap of stored CosmeticUsers. This will not override an entry if it already exists. If you need to override, delete then add.
|
||||
* @param user The user to add to the HashMap.
|
||||
*/
|
||||
public static void addUser(@NotNull CosmeticUser user) {
|
||||
if (COSMETIC_USERS.containsKey(user.getUniqueId())) return; // do not add if already exists
|
||||
COSMETIC_USERS.put(user.getUniqueId(), user);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes a CosmeticUser from the Hashmap
|
||||
* @param uuid The UUID to remove.
|
||||
*/
|
||||
public static void removeUser(UUID uuid) {
|
||||
COSMETIC_USERS.remove(uuid);
|
||||
}
|
||||
|
||||
public static void removeUser(CosmeticUser user) {
|
||||
COSMETIC_USERS.remove(user);
|
||||
/**
|
||||
* Removes a CosmeticUser from the hashmap by their CosmeticUser method
|
||||
* @param user The user to be removed (will get their UUID from this class)
|
||||
*/
|
||||
public static void removeUser(@NotNull CosmeticUser user) {
|
||||
COSMETIC_USERS.remove(user.getUniqueId());
|
||||
}
|
||||
|
||||
/**
|
||||
* This method allows you to get a CosmeticUser from their UUID. If you are using not internally, HIGHLY recommend to use the API implementation of this.
|
||||
* @param uuid The UUID of the user that you wish to lookup.
|
||||
* @return Returns the user if there is a valid user, returns null if not.
|
||||
*/
|
||||
@Nullable
|
||||
public static CosmeticUser getUser(UUID uuid) {
|
||||
return COSMETIC_USERS.get(uuid);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method allows you to get a CosmeticUser from just using the player class. This just allows you to have a bit less boilerplate.
|
||||
* @param player The player to lookup (will take their UUID from the class)
|
||||
* @return Returns the user if there is a vlaid user, returns null if not.
|
||||
*/
|
||||
@Nullable
|
||||
public static CosmeticUser getUser(Player player) {
|
||||
public static CosmeticUser getUser(@NotNull Player player) {
|
||||
return COSMETIC_USERS.get(player.getUniqueId());
|
||||
}
|
||||
|
||||
/**
|
||||
* This method gets the CosmeticUser from an entity id (said entity must be a player). This is not ideal, as it requires the plugin to go through all entities, but it's a possibility.
|
||||
* @param entityId The entity ID in an integer.
|
||||
* @return The cosmetic user if there is an entity id associated with that.
|
||||
*/
|
||||
@Nullable
|
||||
public static CosmeticUser getUser(int entityId) {
|
||||
Entity entity = ServerUtils.getEntity(entityId);
|
||||
Entity entity = HMCCServerUtils.getEntity(entityId);
|
||||
if (entity == null) return null;
|
||||
if (!(entity instanceof Player player)) return null;
|
||||
return COSMETIC_USERS.get(player.getUniqueId());
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets all the values for CosmeticUsers to allow you to iterate over everyone.
|
||||
* @return CosmeticUsers in a set. This will never be null, but might be empty.
|
||||
*/
|
||||
@NotNull
|
||||
public static Set<CosmeticUser> values() {
|
||||
return COSMETIC_USERS.values();
|
||||
}
|
||||
|
||||
@@ -2,13 +2,14 @@ package com.hibiscusmc.hmccosmetics.user.manager;
|
||||
|
||||
import com.hibiscusmc.hmccosmetics.cosmetic.CosmeticSlot;
|
||||
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticBackpackType;
|
||||
import com.hibiscusmc.hmccosmetics.hooks.Hooks;
|
||||
import com.hibiscusmc.hmccosmetics.nms.NMSHandlers;
|
||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||
import com.hibiscusmc.hmccosmetics.util.packets.PacketManager;
|
||||
import com.hibiscusmc.hmccosmetics.util.packets.HMCCPacketManager;
|
||||
import com.ticxo.modelengine.api.ModelEngineAPI;
|
||||
import lombok.Getter;
|
||||
import me.lojosho.hibiscuscommons.hooks.Hooks;
|
||||
import me.lojosho.hibiscuscommons.util.ServerUtils;
|
||||
import me.lojosho.hibiscuscommons.util.packets.PacketManager;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
@@ -36,9 +37,9 @@ public class UserBackpackManager {
|
||||
public UserBackpackManager(CosmeticUser user) {
|
||||
this.user = user;
|
||||
this.backpackHidden = false;
|
||||
this.invisibleArmorStand = NMSHandlers.getHandler().getNextEntityId();
|
||||
this.invisibleArmorStand = ServerUtils.getNextEntityId();
|
||||
this.entityManager = new UserEntity(user.getUniqueId());
|
||||
this.entityManager.refreshViewers(user.getEntity().getLocation());
|
||||
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)
|
||||
}
|
||||
|
||||
public int getFirstArmorStandId() {
|
||||
@@ -55,8 +56,8 @@ public class UserBackpackManager {
|
||||
getEntityManager().setIds(List.of(invisibleArmorStand));
|
||||
getEntityManager().teleport(user.getEntity().getLocation());
|
||||
List<Player> outsideViewers = getEntityManager().getViewers();
|
||||
PacketManager.sendEntitySpawnPacket(user.getEntity().getLocation(), getFirstArmorStandId(), EntityType.ARMOR_STAND, UUID.randomUUID(), getEntityManager().getViewers());
|
||||
PacketManager.sendArmorstandMetadata(getFirstArmorStandId(), outsideViewers);
|
||||
HMCCPacketManager.sendEntitySpawnPacket(user.getEntity().getLocation(), getFirstArmorStandId(), EntityType.ARMOR_STAND, UUID.randomUUID(), getEntityManager().getViewers());
|
||||
HMCCPacketManager.sendArmorstandMetadata(getFirstArmorStandId(), outsideViewers);
|
||||
|
||||
Entity entity = user.getEntity();
|
||||
|
||||
@@ -73,25 +74,25 @@ public class UserBackpackManager {
|
||||
|
||||
if (cosmeticBackpackType.isFirstPersonCompadible()) {
|
||||
for (int i = particleCloud.size(); i < cosmeticBackpackType.getHeight(); i++) {
|
||||
int entityId = NMSHandlers.getHandler().getNextEntityId();
|
||||
PacketManager.sendEntitySpawnPacket(user.getEntity().getLocation(), entityId, EntityType.AREA_EFFECT_CLOUD, UUID.randomUUID());
|
||||
PacketManager.sendCloudEffect(entityId, PacketManager.getViewers(user.getEntity().getLocation()));
|
||||
int entityId = ServerUtils.getNextEntityId();
|
||||
HMCCPacketManager.sendEntitySpawnPacket(user.getEntity().getLocation(), entityId, EntityType.AREA_EFFECT_CLOUD, UUID.randomUUID());
|
||||
HMCCPacketManager.sendCloudEffect(entityId, HMCCPacketManager.getViewers(user.getEntity().getLocation()));
|
||||
this.particleCloud.add(entityId);
|
||||
}
|
||||
// Copied code from updating the backpack
|
||||
for (int i = 0; i < particleCloud.size(); i++) {
|
||||
if (i == 0) PacketManager.sendRidingPacket(entity.getEntityId(), particleCloud.get(i), owner);
|
||||
else PacketManager.sendRidingPacket(particleCloud.get(i - 1), particleCloud.get(i) , owner);
|
||||
if (i == 0) HMCCPacketManager.sendRidingPacket(entity.getEntityId(), particleCloud.get(i), owner);
|
||||
else HMCCPacketManager.sendRidingPacket(particleCloud.get(i - 1), particleCloud.get(i) , owner);
|
||||
}
|
||||
PacketManager.sendRidingPacket(particleCloud.get(particleCloud.size() - 1), user.getUserBackpackManager().getFirstArmorStandId(), owner);
|
||||
if (!user.getHidden()) NMSHandlers.getHandler().equipmentSlotUpdate(user.getUserBackpackManager().getFirstArmorStandId(), EquipmentSlot.HEAD, user.getUserCosmeticItem(cosmeticBackpackType, cosmeticBackpackType.getFirstPersonBackpack()), owner);
|
||||
HMCCPacketManager.sendRidingPacket(particleCloud.get(particleCloud.size() - 1), user.getUserBackpackManager().getFirstArmorStandId(), owner);
|
||||
if (!user.isHidden()) PacketManager.equipmentSlotUpdate(user.getUserBackpackManager().getFirstArmorStandId(), EquipmentSlot.HEAD, user.getUserCosmeticItem(cosmeticBackpackType, cosmeticBackpackType.getFirstPersonBackpack()), owner);
|
||||
}
|
||||
NMSHandlers.getHandler().equipmentSlotUpdate(getFirstArmorStandId(), EquipmentSlot.HEAD, user.getUserCosmeticItem(cosmeticBackpackType), outsideViewers);
|
||||
PacketManager.sendRidingPacket(entity.getEntityId(), passengerIDs, outsideViewers);
|
||||
PacketManager.equipmentSlotUpdate(getFirstArmorStandId(), EquipmentSlot.HEAD, user.getUserCosmeticItem(cosmeticBackpackType), outsideViewers);
|
||||
HMCCPacketManager.sendRidingPacket(entity.getEntityId(), passengerIDs, outsideViewers);
|
||||
|
||||
// No one should be using ME because it barely works but some still use it, so it's here
|
||||
if (cosmeticBackpackType.getModelName() != null && Hooks.isActiveHook("ModelEngine")) {
|
||||
if (ModelEngineAPI.api.getModelRegistry().getBlueprint(cosmeticBackpackType.getModelName()) == null) {
|
||||
if (ModelEngineAPI.getBlueprint(cosmeticBackpackType.getModelName()) == null) {
|
||||
MessagesUtil.sendDebugMessages("Invalid Model Engine Blueprint " + cosmeticBackpackType.getModelName(), Level.SEVERE);
|
||||
return;
|
||||
}
|
||||
@@ -107,17 +108,17 @@ public class UserBackpackManager {
|
||||
}
|
||||
|
||||
public void despawnBackpack() {
|
||||
PacketManager.sendEntityDestroyPacket(invisibleArmorStand, getEntityManager().getViewers());
|
||||
HMCCPacketManager.sendEntityDestroyPacket(invisibleArmorStand, getEntityManager().getViewers());
|
||||
if (particleCloud != null) {
|
||||
for (Integer entityId : particleCloud) {
|
||||
PacketManager.sendEntityDestroyPacket(entityId, getEntityManager().getViewers());
|
||||
HMCCPacketManager.sendEntityDestroyPacket(entityId, getEntityManager().getViewers());
|
||||
}
|
||||
this.particleCloud = null;
|
||||
}
|
||||
}
|
||||
|
||||
public void hideBackpack() {
|
||||
if (user.getHidden()) return;
|
||||
if (user.isHidden()) return;
|
||||
//getArmorStand().getEquipment().clear();
|
||||
backpackHidden = true;
|
||||
}
|
||||
@@ -139,11 +140,11 @@ public class UserBackpackManager {
|
||||
}
|
||||
|
||||
public void setItem(ItemStack item) {
|
||||
NMSHandlers.getHandler().equipmentSlotUpdate(getFirstArmorStandId(), EquipmentSlot.HEAD, item, getEntityManager().getViewers());
|
||||
PacketManager.equipmentSlotUpdate(getFirstArmorStandId(), EquipmentSlot.HEAD, item, getEntityManager().getViewers());
|
||||
}
|
||||
|
||||
public void clearItems() {
|
||||
ItemStack item = new ItemStack(Material.AIR);
|
||||
NMSHandlers.getHandler().equipmentSlotUpdate(getFirstArmorStandId(), EquipmentSlot.HEAD, item, getEntityManager().getViewers());
|
||||
PacketManager.equipmentSlotUpdate(getFirstArmorStandId(), EquipmentSlot.HEAD, item, getEntityManager().getViewers());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,21 +1,27 @@
|
||||
package com.hibiscusmc.hmccosmetics.user.manager;
|
||||
|
||||
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
|
||||
import com.hibiscusmc.hmccosmetics.config.Settings;
|
||||
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticBalloonType;
|
||||
import com.hibiscusmc.hmccosmetics.hooks.Hooks;
|
||||
import com.hibiscusmc.hmccosmetics.nms.NMSHandlers;
|
||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUsers;
|
||||
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||
import com.hibiscusmc.hmccosmetics.util.packets.PacketManager;
|
||||
import com.hibiscusmc.hmccosmetics.util.packets.HMCCPacketManager;
|
||||
import com.ticxo.modelengine.api.ModelEngineAPI;
|
||||
import com.ticxo.modelengine.api.entity.data.BukkitEntityData;
|
||||
import com.ticxo.modelengine.api.model.ActiveModel;
|
||||
import com.ticxo.modelengine.api.model.ModeledEntity;
|
||||
import com.ticxo.modelengine.api.nms.RenderParsers;
|
||||
import lombok.Getter;
|
||||
import me.lojosho.hibiscuscommons.hooks.Hooks;
|
||||
import me.lojosho.hibiscuscommons.nms.NMSHandlers;
|
||||
import org.bukkit.Color;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.entity.ArmorStand;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.persistence.PersistentDataType;
|
||||
import org.bukkit.util.Vector;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@@ -25,6 +31,8 @@ import java.util.logging.Level;
|
||||
|
||||
public class UserBalloonManager {
|
||||
|
||||
private final CosmeticUser user;
|
||||
@Getter
|
||||
private BalloonType balloonType;
|
||||
private CosmeticBalloonType cosmeticBalloonType;
|
||||
@Getter
|
||||
@@ -32,8 +40,18 @@ public class UserBalloonManager {
|
||||
private final ArmorStand modelEntity;
|
||||
|
||||
public UserBalloonManager(CosmeticUser user, @NotNull Location location) {
|
||||
this.pufferfish = new UserBalloonPufferfish(user.getUniqueId(), NMSHandlers.getHandler().getNextEntityId(), UUID.randomUUID());
|
||||
this.modelEntity = NMSHandlers.getHandler().getMEGEntity(location.add(Settings.getBalloonOffset()));
|
||||
this.user = user;
|
||||
this.pufferfish = new UserBalloonPufferfish(user.getUniqueId(), NMSHandlers.getHandler().getUtilHandler().getNextEntityId(), UUID.randomUUID());
|
||||
this.modelEntity = location.getWorld().spawn(location, ArmorStand.class, (e) -> {
|
||||
e.setInvisible(true);
|
||||
e.setGravity(false);
|
||||
e.setSilent(true);
|
||||
e.setInvulnerable(true);
|
||||
e.setSmall(true);
|
||||
e.setMarker(true);
|
||||
e.setPersistent(false);
|
||||
e.getPersistentDataContainer().set(new NamespacedKey(HMCCosmeticsPlugin.getInstance(), "cosmeticMob"), PersistentDataType.SHORT, Short.valueOf("1"));
|
||||
});
|
||||
}
|
||||
|
||||
public void spawnModel(@NotNull CosmeticBalloonType cosmeticBalloonType, Color color) {
|
||||
@@ -53,7 +71,7 @@ public class UserBalloonManager {
|
||||
if (balloonType == BalloonType.MODELENGINE) {
|
||||
String id = cosmeticBalloonType.getModelName();
|
||||
MessagesUtil.sendDebugMessages("Attempting Spawning for " + id);
|
||||
if (ModelEngineAPI.api.getModelRegistry().getBlueprint(id) == null) {
|
||||
if (ModelEngineAPI.getBlueprint(id) == null) {
|
||||
MessagesUtil.sendDebugMessages("Invalid Model Engine Blueprint " + id, Level.SEVERE);
|
||||
return;
|
||||
}
|
||||
@@ -61,14 +79,19 @@ public class UserBalloonManager {
|
||||
ActiveModel model = ModelEngineAPI.createActiveModel(ModelEngineAPI.getBlueprint(id));
|
||||
model.setCanHurt(false);
|
||||
modeledEntity.addModel(model, false);
|
||||
|
||||
if (color != null) {
|
||||
modeledEntity.getModels().forEach((d, singleModel) -> {
|
||||
if (cosmeticBalloonType.isDyablePart(d)) {
|
||||
singleModel.getRendererHandler().setColor(color);
|
||||
singleModel.getRendererHandler().update();
|
||||
singleModel.setDefaultTint(color);
|
||||
singleModel.getModelRenderer().sendToClient(ModelEngineAPI.getNMSHandler().createParsers());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
BukkitEntityData data = (BukkitEntityData) modeledEntity.getBase().getData();
|
||||
data.setBlockedCullIgnoreRadius((double) Settings.getViewDistance());
|
||||
data.getTracked().setPlayerPredicate(this::playerCheck);
|
||||
return;
|
||||
}
|
||||
if (balloonType == BalloonType.ITEM) {
|
||||
@@ -77,19 +100,21 @@ public class UserBalloonManager {
|
||||
}
|
||||
|
||||
public void remove() {
|
||||
pufferfish.destroyPufferfish();
|
||||
if (balloonType == BalloonType.MODELENGINE) {
|
||||
final ModeledEntity entity = ModelEngineAPI.api.getModeledEntity(modelEntity.getUniqueId());
|
||||
|
||||
if (entity == null) return;
|
||||
|
||||
for (final Player player : entity.getRangeManager().getPlayerInRange()) {
|
||||
entity.hideFromPlayer(player);
|
||||
final ModeledEntity entity = ModelEngineAPI.getModeledEntity(modelEntity);
|
||||
if (entity == null) {
|
||||
MessagesUtil.sendDebugMessages("Balloon Removal Failed - Model Entity is Null");
|
||||
return;
|
||||
}
|
||||
|
||||
entity.destroy();
|
||||
MessagesUtil.sendDebugMessages("Balloon Model Engine Removal");
|
||||
}
|
||||
|
||||
modelEntity.remove();
|
||||
cosmeticBalloonType = null;
|
||||
MessagesUtil.sendDebugMessages("Balloon Entity Removed");
|
||||
}
|
||||
|
||||
public void addPlayerToModel(final CosmeticUser user, final CosmeticBalloonType cosmeticBalloonType) {
|
||||
@@ -98,14 +123,13 @@ public class UserBalloonManager {
|
||||
|
||||
public void addPlayerToModel(final CosmeticUser user, final CosmeticBalloonType cosmeticBalloonType, Color color) {
|
||||
if (balloonType == BalloonType.MODELENGINE) {
|
||||
final ModeledEntity model = ModelEngineAPI.api.getModeledEntity(modelEntity.getUniqueId());
|
||||
final ModeledEntity model = ModelEngineAPI.getModeledEntity(modelEntity);
|
||||
if (model == null) {
|
||||
spawnModel(cosmeticBalloonType, color);
|
||||
MessagesUtil.sendDebugMessages("model is null");
|
||||
return;
|
||||
}
|
||||
//if (model.getRangeManager().getPlayerInRange().contains(player)) return;
|
||||
model.showToPlayer(user.getPlayer());
|
||||
|
||||
MessagesUtil.sendDebugMessages("Show to player");
|
||||
return;
|
||||
}
|
||||
@@ -113,13 +137,11 @@ public class UserBalloonManager {
|
||||
modelEntity.getEquipment().setHelmet(user.getUserCosmeticItem(cosmeticBalloonType));
|
||||
}
|
||||
}
|
||||
public void removePlayerFromModel(final Player player) {
|
||||
public void removePlayerFromModel(final Player viewer) {
|
||||
if (balloonType == BalloonType.MODELENGINE) {
|
||||
final ModeledEntity model = ModelEngineAPI.api.getModeledEntity(modelEntity.getUniqueId());
|
||||
|
||||
final ModeledEntity model = ModelEngineAPI.getModeledEntity(modelEntity);
|
||||
if (model == null) return;
|
||||
|
||||
model.hideFromPlayer(player);
|
||||
MessagesUtil.sendDebugMessages("Hidden from player");
|
||||
return;
|
||||
}
|
||||
@@ -135,8 +157,9 @@ public class UserBalloonManager {
|
||||
|
||||
|
||||
public int getPufferfishBalloonId() {
|
||||
return pufferfish.getId();
|
||||
return pufferfish.getPufferFishEntityId();
|
||||
}
|
||||
|
||||
public UUID getPufferfishBalloonUniqueId() {
|
||||
return pufferfish.getUuid();
|
||||
}
|
||||
@@ -162,17 +185,16 @@ public class UserBalloonManager {
|
||||
}
|
||||
|
||||
public void sendRemoveLeashPacket(List<Player> viewer) {
|
||||
PacketManager.sendLeashPacket(getPufferfishBalloonId(), -1, viewer);
|
||||
HMCCPacketManager.sendLeashPacket(getPufferfishBalloonId(), -1, viewer);
|
||||
}
|
||||
|
||||
public void sendRemoveLeashPacket() {
|
||||
PacketManager.sendLeashPacket(getPufferfishBalloonId(), -1, getLocation());
|
||||
HMCCPacketManager.sendLeashPacket(getPufferfishBalloonId(), -1, getLocation());
|
||||
}
|
||||
|
||||
public void sendLeashPacket(int entityId) {
|
||||
if (cosmeticBalloonType == null) return;
|
||||
if (cosmeticBalloonType.isShowLead()) {
|
||||
PacketManager.sendLeashPacket(getPufferfishBalloonId(), entityId, getLocation());
|
||||
HMCCPacketManager.sendLeashPacket(getPufferfishBalloonId(), entityId, getLocation());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -181,4 +203,21 @@ public class UserBalloonManager {
|
||||
ITEM,
|
||||
NONE
|
||||
}
|
||||
|
||||
private boolean playerCheck(final Player player) {
|
||||
MessagesUtil.sendDebugMessages("playerCheck");
|
||||
CosmeticUser viewer = CosmeticUsers.getUser(player.getUniqueId());
|
||||
|
||||
if (user.getPlayer() == player) {
|
||||
return (!user.isHidden());
|
||||
} else {
|
||||
if (user.isInWardrobe()) return false;
|
||||
MessagesUtil.sendDebugMessages("playerCheck - Not Same Player");
|
||||
if (viewer != null && viewer.isInWardrobe()) {
|
||||
MessagesUtil.sendDebugMessages("playerCheck - Viewer in Wardrobe");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return (!user.isHidden());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,30 +1,53 @@
|
||||
package com.hibiscusmc.hmccosmetics.user.manager;
|
||||
|
||||
import com.hibiscusmc.hmccosmetics.util.packets.PacketManager;
|
||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUsers;
|
||||
import com.hibiscusmc.hmccosmetics.util.HMCCPlayerUtils;
|
||||
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||
import com.hibiscusmc.hmccosmetics.util.packets.HMCCPacketManager;
|
||||
import lombok.Getter;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
public class UserBalloonPufferfish extends UserEntity {
|
||||
|
||||
private int id;
|
||||
private UUID uuid;
|
||||
@Getter
|
||||
private final int pufferFishEntityId;
|
||||
@Getter
|
||||
private final UUID uuid;
|
||||
private boolean destroyed = false;
|
||||
|
||||
public UserBalloonPufferfish(UUID owner, int id, UUID uuid) {
|
||||
public UserBalloonPufferfish(UUID owner, int pufferFishEntityId, UUID uuid) {
|
||||
super(owner);
|
||||
this.id = id;
|
||||
this.pufferFishEntityId = pufferFishEntityId;
|
||||
this.uuid = uuid;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public UUID getUuid() {
|
||||
return uuid;
|
||||
}
|
||||
|
||||
public void hidePufferfish() {
|
||||
PacketManager.sendEntityDestroyPacket(id, getViewers());
|
||||
HMCCPacketManager.sendEntityDestroyPacket(pufferFishEntityId, getViewers());
|
||||
getViewers().clear();
|
||||
}
|
||||
|
||||
public void spawnPufferfish(Location location, List<Player> sendTo) {
|
||||
HMCCPacketManager.sendEntitySpawnPacket(location, pufferFishEntityId, EntityType.PUFFERFISH, uuid, sendTo);
|
||||
HMCCPacketManager.sendInvisibilityPacket(pufferFishEntityId, sendTo);
|
||||
}
|
||||
|
||||
public void destroyPufferfish() {
|
||||
HMCCPacketManager.sendEntityDestroyPacket(pufferFishEntityId, getViewers());
|
||||
getViewers().clear();
|
||||
destroyed = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Player> refreshViewers(Location location) {
|
||||
if (destroyed) return List.of(); //Prevents refreshing a destroyed entity
|
||||
return super.refreshViewers(location);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,6 @@ import com.hibiscusmc.hmccosmetics.api.events.PlayerEmoteStartEvent;
|
||||
import com.hibiscusmc.hmccosmetics.api.events.PlayerEmoteStopEvent;
|
||||
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticEmoteType;
|
||||
import com.hibiscusmc.hmccosmetics.emotes.EmoteManager;
|
||||
import com.hibiscusmc.hmccosmetics.nms.NMSHandlers;
|
||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||
import org.bukkit.Bukkit;
|
||||
@@ -49,7 +48,8 @@ public class UserEmoteManager {
|
||||
}
|
||||
// Show the text
|
||||
if (text != null && textEntity == null) {
|
||||
textEntity = NMSHandlers.getHandler().spawnDisplayEntity(user.getPlayer().getLocation().add(0, 3, 0), text);
|
||||
// removed in 2.7.0
|
||||
//textEntity = HMCCNMSHandlers.getHandler().spawnDisplayEntity(user.getPlayer().getLocation().add(0, 3, 0), text);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
|
||||
@@ -2,12 +2,12 @@ package com.hibiscusmc.hmccosmetics.user.manager;
|
||||
|
||||
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
|
||||
import com.hibiscusmc.hmccosmetics.config.Settings;
|
||||
import com.hibiscusmc.hmccosmetics.nms.NMSHandlers;
|
||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||
import com.hibiscusmc.hmccosmetics.util.HMCCServerUtils;
|
||||
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||
import com.hibiscusmc.hmccosmetics.util.ServerUtils;
|
||||
import com.hibiscusmc.hmccosmetics.util.packets.PacketManager;
|
||||
import com.hibiscusmc.hmccosmetics.util.packets.HMCCPacketManager;
|
||||
import com.ticxo.playeranimator.api.model.player.PlayerModel;
|
||||
import me.lojosho.hibiscuscommons.util.ServerUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Location;
|
||||
@@ -29,7 +29,7 @@ public class UserEmoteModel extends PlayerModel {
|
||||
public UserEmoteModel(@NotNull CosmeticUser user) {
|
||||
super(user.getPlayer());
|
||||
this.user = user;
|
||||
armorStandId = NMSHandlers.getHandler().getNextEntityId();
|
||||
armorStandId = ServerUtils.getNextEntityId();
|
||||
getRangeManager().setRenderDistance(Settings.getViewDistance());
|
||||
}
|
||||
|
||||
@@ -42,9 +42,9 @@ public class UserEmoteModel extends PlayerModel {
|
||||
// Add config option that either allows player to move or forces them into a spot.
|
||||
Player player = user.getPlayer();
|
||||
List<Player> viewer = Collections.singletonList(user.getPlayer());
|
||||
List<Player> outsideViewers = PacketManager.getViewers(player.getLocation());
|
||||
List<Player> outsideViewers = HMCCPacketManager.getViewers(player.getLocation());
|
||||
// Send equipment packet to the player as well (Fixes Optifine still rendering armor when emoting)
|
||||
PacketManager.equipmentSlotUpdate(player, true, outsideViewers);
|
||||
HMCCPacketManager.equipmentSlotUpdate(player, true, outsideViewers);
|
||||
outsideViewers.remove(player);
|
||||
|
||||
user.getPlayer().setInvisible(true);
|
||||
@@ -75,12 +75,12 @@ public class UserEmoteModel extends PlayerModel {
|
||||
MessagesUtil.sendMessage(player, "emote-blocked");
|
||||
}
|
||||
|
||||
PacketManager.sendEntitySpawnPacket(thirdPersonLocation, armorStandId, EntityType.ARMOR_STAND, UUID.randomUUID(), viewer);
|
||||
PacketManager.sendInvisibilityPacket(armorStandId, viewer);
|
||||
PacketManager.sendLookPacket(armorStandId, thirdPersonLocation, viewer);
|
||||
HMCCPacketManager.sendEntitySpawnPacket(thirdPersonLocation, armorStandId, EntityType.ARMOR_STAND, UUID.randomUUID(), viewer);
|
||||
HMCCPacketManager.sendInvisibilityPacket(armorStandId, viewer);
|
||||
HMCCPacketManager.sendLookPacket(armorStandId, thirdPersonLocation, viewer);
|
||||
|
||||
PacketManager.gamemodeChangePacket(player, 3);
|
||||
PacketManager.sendCameraPacket(armorStandId, viewer);
|
||||
HMCCPacketManager.gamemodeChangePacket(player, 3);
|
||||
HMCCPacketManager.sendCameraPacket(armorStandId, viewer);
|
||||
}
|
||||
|
||||
|
||||
@@ -108,23 +108,23 @@ public class UserEmoteModel extends PlayerModel {
|
||||
if (player == null) return;
|
||||
|
||||
List<Player> viewer = Collections.singletonList(player);
|
||||
List<Player> outsideViewers = PacketManager.getViewers(player.getLocation());
|
||||
List<Player> outsideViewers = HMCCPacketManager.getViewers(player.getLocation());
|
||||
// Send Equipment packet to all (Fixes Optifine Issue)
|
||||
PacketManager.equipmentSlotUpdate(player, false, outsideViewers);
|
||||
HMCCPacketManager.equipmentSlotUpdate(player, false, outsideViewers);
|
||||
outsideViewers.remove(player);
|
||||
|
||||
int entityId = player.getEntityId();
|
||||
PacketManager.sendCameraPacket(entityId, viewer);
|
||||
PacketManager.sendEntityDestroyPacket(armorStandId, viewer);
|
||||
HMCCPacketManager.sendCameraPacket(entityId, viewer);
|
||||
HMCCPacketManager.sendEntityDestroyPacket(armorStandId, viewer);
|
||||
if (this.originalGamemode != null) {
|
||||
PacketManager.gamemodeChangePacket(player, ServerUtils.convertGamemode(this.originalGamemode));
|
||||
HMCCPacketManager.gamemodeChangePacket(player, HMCCServerUtils.convertGamemode(this.originalGamemode));
|
||||
player.setGameMode(this.originalGamemode);
|
||||
}
|
||||
|
||||
if (user.getPlayer() != null) player.setInvisible(false);
|
||||
user.getUserEmoteManager().despawnTextEntity();
|
||||
user.showPlayer();
|
||||
user.showCosmetics();
|
||||
user.showCosmetics(CosmeticUser.HiddenReason.EMOTE);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -3,10 +3,12 @@ package com.hibiscusmc.hmccosmetics.user.manager;
|
||||
import com.hibiscusmc.hmccosmetics.config.Settings;
|
||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUsers;
|
||||
import com.hibiscusmc.hmccosmetics.util.PlayerUtils;
|
||||
import com.hibiscusmc.hmccosmetics.util.packets.PacketManager;
|
||||
import com.hibiscusmc.hmccosmetics.util.HMCCPlayerUtils;
|
||||
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||
import com.hibiscusmc.hmccosmetics.util.packets.HMCCPacketManager;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@@ -41,13 +43,18 @@ public class UserEntity {
|
||||
if (System.currentTimeMillis() - viewerLastUpdate <= 1000) return List.of(); //Prevents mass refreshes
|
||||
ArrayList<Player> newPlayers = new ArrayList<>();
|
||||
ArrayList<Player> removePlayers = new ArrayList<>();
|
||||
List<Player> players = PlayerUtils.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) {
|
||||
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);
|
||||
PacketManager.sendEntityDestroyPacket(ids, List.of(player));
|
||||
HMCCPacketManager.sendEntityDestroyPacket(ids, List.of(player));
|
||||
continue;
|
||||
}
|
||||
if (!viewers.contains(player)) {
|
||||
@@ -59,7 +66,7 @@ public class UserEntity {
|
||||
for (Player viewerPlayer : viewers) {
|
||||
if (!players.contains(viewerPlayer)) {
|
||||
removePlayers.add(viewerPlayer);
|
||||
PacketManager.sendEntityDestroyPacket(ids, List.of(viewerPlayer));
|
||||
HMCCPacketManager.sendEntityDestroyPacket(ids, List.of(viewerPlayer));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -76,7 +83,7 @@ public class UserEntity {
|
||||
}
|
||||
this.location = location;
|
||||
for (Integer entity : ids) {
|
||||
PacketManager.sendTeleportPacket(entity, location, false, getViewers());
|
||||
HMCCPacketManager.sendTeleportPacket(entity, location, false, getViewers());
|
||||
}
|
||||
setLastPositionUpdate(System.currentTimeMillis());
|
||||
}
|
||||
@@ -90,8 +97,8 @@ public class UserEntity {
|
||||
for (Integer entity : ids) {
|
||||
// First person backpacks need both packets to rotate properly, otherwise they look off
|
||||
// Regular backpacks just need the look packet
|
||||
if (additonalPacket) PacketManager.sendRotationPacket(entity, yaw, false, getViewers());
|
||||
PacketManager.sendLookPacket(entity, location, getViewers());
|
||||
if (additonalPacket) HMCCPacketManager.sendRotationPacket(entity, yaw, false, getViewers());
|
||||
HMCCPacketManager.sendLookPacket(entity, location, getViewers());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,12 +9,15 @@ import com.hibiscusmc.hmccosmetics.cosmetic.CosmeticSlot;
|
||||
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticBalloonType;
|
||||
import com.hibiscusmc.hmccosmetics.gui.Menu;
|
||||
import com.hibiscusmc.hmccosmetics.gui.Menus;
|
||||
import com.hibiscusmc.hmccosmetics.nms.NMSHandlers;
|
||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||
import com.hibiscusmc.hmccosmetics.util.HMCCInventoryUtils;
|
||||
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||
import com.hibiscusmc.hmccosmetics.util.ServerUtils;
|
||||
import com.hibiscusmc.hmccosmetics.util.packets.PacketManager;
|
||||
import com.hibiscusmc.hmccosmetics.util.HMCCServerUtils;
|
||||
import com.hibiscusmc.hmccosmetics.util.packets.HMCCPacketManager;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import me.lojosho.hibiscuscommons.nms.NMSHandlers;
|
||||
import me.lojosho.hibiscuscommons.util.packets.PacketManager;
|
||||
import net.kyori.adventure.audience.Audience;
|
||||
import net.kyori.adventure.bossbar.BossBar;
|
||||
import net.kyori.adventure.platform.bukkit.BukkitAudiences;
|
||||
@@ -25,14 +28,12 @@ import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.player.PlayerTeleportEvent;
|
||||
import org.bukkit.inventory.EquipmentSlot;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.UUID;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
public class UserWardrobeManager {
|
||||
@@ -65,10 +66,13 @@ public class UserWardrobeManager {
|
||||
private boolean active;
|
||||
@Getter
|
||||
private WardrobeStatus wardrobeStatus;
|
||||
@Getter
|
||||
@Setter
|
||||
private Menu lastOpenMenu;
|
||||
|
||||
public UserWardrobeManager(CosmeticUser user, Wardrobe wardrobe) {
|
||||
NPC_ID = NMSHandlers.getHandler().getNextEntityId();
|
||||
ARMORSTAND_ID = NMSHandlers.getHandler().getNextEntityId();
|
||||
NPC_ID = me.lojosho.hibiscuscommons.util.ServerUtils.getNextEntityId();
|
||||
ARMORSTAND_ID = me.lojosho.hibiscuscommons.util.ServerUtils.getNextEntityId();
|
||||
WARDROBE_UUID = UUID.randomUUID();
|
||||
this.user = user;
|
||||
|
||||
@@ -79,6 +83,10 @@ public class UserWardrobeManager {
|
||||
this.viewingLocation = wardrobeLocation.getViewerLocation();
|
||||
this.npcLocation = wardrobeLocation.getNpcLocation();
|
||||
|
||||
String defaultMenu = wardrobe.getDefaultMenu();
|
||||
if (defaultMenu != null && Menus.hasMenu(defaultMenu)) this.lastOpenMenu = Menus.getMenu(defaultMenu);
|
||||
else this.lastOpenMenu = Menus.getDefaultMenu();
|
||||
|
||||
wardrobeStatus = WardrobeStatus.SETUP;
|
||||
}
|
||||
|
||||
@@ -92,64 +100,74 @@ public class UserWardrobeManager {
|
||||
}
|
||||
|
||||
user.hidePlayer();
|
||||
if (!Bukkit.getServer().getAllowFlight()) player.setAllowFlight(true);
|
||||
List<Player> viewer = Collections.singletonList(player);
|
||||
List<Player> outsideViewers = PacketManager.getViewers(viewingLocation);
|
||||
List<Player> outsideViewers = HMCCPacketManager.getViewers(viewingLocation);
|
||||
outsideViewers.remove(player);
|
||||
|
||||
MessagesUtil.sendMessage(player, "opened-wardrobe");
|
||||
|
||||
Runnable run = () -> {
|
||||
// Armorstand
|
||||
PacketManager.sendEntitySpawnPacket(viewingLocation, ARMORSTAND_ID, EntityType.ARMOR_STAND, UUID.randomUUID(), viewer);
|
||||
PacketManager.sendArmorstandMetadata(ARMORSTAND_ID, viewer);
|
||||
PacketManager.sendLookPacket(ARMORSTAND_ID, viewingLocation, viewer);
|
||||
HMCCPacketManager.sendEntitySpawnPacket(viewingLocation, ARMORSTAND_ID, EntityType.ARMOR_STAND, UUID.randomUUID(), viewer);
|
||||
HMCCPacketManager.sendArmorstandMetadata(ARMORSTAND_ID, viewer);
|
||||
HMCCPacketManager.sendLookPacket(ARMORSTAND_ID, viewingLocation, viewer);
|
||||
|
||||
// Player
|
||||
PacketManager.gamemodeChangePacket(player, 3);
|
||||
PacketManager.sendCameraPacket(ARMORSTAND_ID, viewer);
|
||||
user.getPlayer().teleport(viewingLocation, PlayerTeleportEvent.TeleportCause.PLUGIN);
|
||||
user.getPlayer().setInvisible(true);
|
||||
HMCCPacketManager.gamemodeChangePacket(player, 3);
|
||||
HMCCPacketManager.sendCameraPacket(ARMORSTAND_ID, viewer);
|
||||
|
||||
// NPC
|
||||
npcName = "WardrobeNPC-" + NPC_ID;
|
||||
while (npcName.length() > 16) {
|
||||
npcName = npcName.substring(16);
|
||||
}
|
||||
PacketManager.sendFakePlayerInfoPacket(player, NPC_ID, WARDROBE_UUID, npcName, viewer);
|
||||
HMCCPacketManager.sendFakePlayerInfoPacket(player, NPC_ID, WARDROBE_UUID, npcName, viewer);
|
||||
|
||||
// NPC 2
|
||||
Bukkit.getScheduler().runTaskLater(HMCCosmeticsPlugin.getInstance(), () -> {
|
||||
PacketManager.sendFakePlayerSpawnPacket(npcLocation, WARDROBE_UUID, NPC_ID, viewer);
|
||||
PacketManager.sendPlayerOverlayPacket(NPC_ID, viewer);
|
||||
if (!user.isInWardrobe()) return; // If a player exits the wardrobe right away, no need to spawn the NPC
|
||||
HMCCPacketManager.sendFakePlayerSpawnPacket(npcLocation, WARDROBE_UUID, NPC_ID, viewer);
|
||||
HMCCPacketManager.sendPlayerOverlayPacket(NPC_ID, viewer);
|
||||
MessagesUtil.sendDebugMessages("Spawned Fake Player on " + npcLocation);
|
||||
NMSHandlers.getHandler().hideNPCName(player, npcName);
|
||||
NMSHandlers.getHandler().getPacketHandler().sendScoreboardHideNamePacket(player, npcName);
|
||||
}, 4);
|
||||
|
||||
// Location
|
||||
PacketManager.sendLookPacket(NPC_ID, npcLocation, viewer);
|
||||
PacketManager.sendRotationPacket(NPC_ID, npcLocation, true, viewer);
|
||||
HMCCPacketManager.sendLookPacket(NPC_ID, npcLocation, viewer);
|
||||
HMCCPacketManager.sendRotationPacket(NPC_ID, npcLocation, true, viewer);
|
||||
|
||||
// Misc
|
||||
if (user.hasCosmeticInSlot(CosmeticSlot.BACKPACK)) {
|
||||
// Maybe null as backpack maybe despawned before entering
|
||||
if (user.getUserBackpackManager() == null) user.respawnBackpack();
|
||||
user.getUserBackpackManager().getEntityManager().teleport(npcLocation.clone().add(0, 2, 0));
|
||||
NMSHandlers.getHandler().equipmentSlotUpdate(user.getUserBackpackManager().getFirstArmorStandId(), EquipmentSlot.HEAD, user.getUserCosmeticItem(user.getCosmetic(CosmeticSlot.BACKPACK)), viewer);
|
||||
PacketManager.ridingMountPacket(NPC_ID, user.getUserBackpackManager().getFirstArmorStandId(), viewer);
|
||||
if (user.isBackpackSpawned()) {
|
||||
user.getUserBackpackManager().getEntityManager().teleport(npcLocation.clone().add(0, 2, 0));
|
||||
PacketManager.equipmentSlotUpdate(user.getUserBackpackManager().getFirstArmorStandId(), EquipmentSlot.HEAD, user.getUserCosmeticItem(user.getCosmetic(CosmeticSlot.BACKPACK)), viewer);
|
||||
HMCCPacketManager.ridingMountPacket(NPC_ID, user.getUserBackpackManager().getFirstArmorStandId(), viewer);
|
||||
}
|
||||
}
|
||||
|
||||
if (user.hasCosmeticInSlot(CosmeticSlot.BALLOON)) {
|
||||
CosmeticBalloonType cosmetic = (CosmeticBalloonType) user.getCosmetic(CosmeticSlot.BALLOON);
|
||||
user.getBalloonManager().sendRemoveLeashPacket(viewer);
|
||||
user.getBalloonManager().sendLeashPacket(NPC_ID);
|
||||
//PacketManager.sendLeashPacket(VIEWER.getBalloonEntity().getModelId(), NPC_ID, viewer);
|
||||
if (user.getBalloonManager() == null) user.respawnBalloon();
|
||||
if (user.isBalloonSpawned()) {
|
||||
CosmeticBalloonType cosmetic = (CosmeticBalloonType) user.getCosmetic(CosmeticSlot.BALLOON);
|
||||
user.getBalloonManager().sendRemoveLeashPacket(viewer);
|
||||
user.getBalloonManager().sendLeashPacket(NPC_ID);
|
||||
//PacketManager.sendLeashPacket(VIEWER.getBalloonEntity().getModelId(), NPC_ID, viewer);
|
||||
|
||||
Location balloonLocation = npcLocation.clone().add(cosmetic.getBalloonOffset());
|
||||
PacketManager.sendTeleportPacket(user.getBalloonManager().getPufferfishBalloonId(), balloonLocation , false, viewer);
|
||||
user.getBalloonManager().getModelEntity().teleport(balloonLocation);
|
||||
Location balloonLocation = npcLocation.clone().add(cosmetic.getBalloonOffset());
|
||||
HMCCPacketManager.sendTeleportPacket(user.getBalloonManager().getPufferfishBalloonId(), balloonLocation, false, viewer);
|
||||
user.getBalloonManager().getModelEntity().teleport(balloonLocation);
|
||||
user.getBalloonManager().setLocation(balloonLocation);
|
||||
}
|
||||
}
|
||||
|
||||
if (WardrobeSettings.isEnabledBossbar()) {
|
||||
float progress = WardrobeSettings.getBossbarProgress();
|
||||
Component message = MessagesUtil.processStringNoKey(WardrobeSettings.getBossbarMessage());
|
||||
Component message = MessagesUtil.processStringNoKey(player, WardrobeSettings.getBossbarMessage());
|
||||
|
||||
bossBar = BossBar.bossBar(message, progress, WardrobeSettings.getBossbarColor(), WardrobeSettings.getBossbarOverlay());
|
||||
Audience target = BukkitAudiences.create(HMCCosmeticsPlugin.getInstance()).player(player);
|
||||
@@ -188,10 +206,12 @@ public class UserWardrobeManager {
|
||||
Player player = user.getPlayer();
|
||||
|
||||
List<Player> viewer = Collections.singletonList(player);
|
||||
List<Player> outsideViewers = PacketManager.getViewers(viewingLocation);
|
||||
List<Player> outsideViewers = HMCCPacketManager.getViewers(viewingLocation);
|
||||
outsideViewers.remove(player);
|
||||
|
||||
if (player != null) MessagesUtil.sendMessage(player, "closed-wardrobe");
|
||||
if (player == null) return;
|
||||
if (!Bukkit.getServer().getAllowFlight()) player.setAllowFlight(false);
|
||||
MessagesUtil.sendMessage(player, "closed-wardrobe");
|
||||
|
||||
Runnable run = () -> {
|
||||
this.active = false;
|
||||
@@ -206,25 +226,26 @@ public class UserWardrobeManager {
|
||||
}
|
||||
|
||||
// NPC
|
||||
if (user.hasCosmeticInSlot(CosmeticSlot.BALLOON)) user.getBalloonManager().sendRemoveLeashPacket();
|
||||
PacketManager.sendEntityDestroyPacket(NPC_ID, viewer); // Success
|
||||
PacketManager.sendRemovePlayerPacket(player, WARDROBE_UUID, viewer); // Success
|
||||
if (user.isBalloonSpawned()) user.getBalloonManager().sendRemoveLeashPacket();
|
||||
HMCCPacketManager.sendEntityDestroyPacket(NPC_ID, viewer); // Success
|
||||
HMCCPacketManager.sendRemovePlayerPacket(player, WARDROBE_UUID, viewer); // Success
|
||||
|
||||
// Player
|
||||
PacketManager.sendCameraPacket(player.getEntityId(), viewer);
|
||||
HMCCPacketManager.sendCameraPacket(player.getEntityId(), viewer);
|
||||
user.getPlayer().setInvisible(false);
|
||||
|
||||
// Armorstand
|
||||
PacketManager.sendEntityDestroyPacket(ARMORSTAND_ID, viewer); // Sucess
|
||||
HMCCPacketManager.sendEntityDestroyPacket(ARMORSTAND_ID, viewer); // Sucess
|
||||
|
||||
//PacketManager.sendEntityDestroyPacket(player.getEntityId(), viewer); // Success
|
||||
if (WardrobeSettings.isForceExitGamemode()) {
|
||||
MessagesUtil.sendDebugMessages("Force Exit Gamemode " + WardrobeSettings.getExitGamemode());
|
||||
player.setGameMode(WardrobeSettings.getExitGamemode());
|
||||
PacketManager.gamemodeChangePacket(player, ServerUtils.convertGamemode(WardrobeSettings.getExitGamemode())); // Success
|
||||
HMCCPacketManager.gamemodeChangePacket(player, HMCCServerUtils.convertGamemode(WardrobeSettings.getExitGamemode())); // Success
|
||||
} else {
|
||||
MessagesUtil.sendDebugMessages("Original Gamemode " + this.originalGamemode);
|
||||
player.setGameMode(this.originalGamemode);
|
||||
PacketManager.gamemodeChangePacket(player, ServerUtils.convertGamemode(this.originalGamemode)); // Success
|
||||
HMCCPacketManager.gamemodeChangePacket(player, HMCCServerUtils.convertGamemode(this.originalGamemode)); // Success
|
||||
}
|
||||
user.showPlayer();
|
||||
|
||||
@@ -234,15 +255,23 @@ public class UserWardrobeManager {
|
||||
}
|
||||
|
||||
if (user.hasCosmeticInSlot(CosmeticSlot.BALLOON)) {
|
||||
user.respawnBalloon();
|
||||
//user.respawnBalloon();
|
||||
//PacketManager.sendLeashPacket(VIEWER.getBalloonEntity().getPufferfishBalloonId(), player.getEntityId(), viewer);
|
||||
}
|
||||
|
||||
player.teleport(Objects.requireNonNullElseGet(exitLocation, () -> player.getWorld().getSpawnLocation()));
|
||||
player.teleport(Objects.requireNonNullElseGet(exitLocation, () -> player.getWorld().getSpawnLocation()), PlayerTeleportEvent.TeleportCause.PLUGIN);
|
||||
|
||||
if (WardrobeSettings.isEquipPumpkin()) {
|
||||
NMSHandlers.getHandler().equipmentSlotUpdate(user.getPlayer().getEntityId(), EquipmentSlot.HEAD, player.getInventory().getHelmet(), viewer);
|
||||
HashMap<EquipmentSlot, ItemStack> items = new HashMap<>();
|
||||
for (EquipmentSlot slot : HMCCInventoryUtils.getPlayerArmorSlots()) {
|
||||
ItemStack item = player.getInventory().getItem(slot);
|
||||
items.put(slot, item);
|
||||
}
|
||||
/*
|
||||
if (WardrobeSettings.isEquipPumpkin()) {
|
||||
items.put(EquipmentSlot.HEAD, player.getInventory().getHelmet());
|
||||
}
|
||||
*/
|
||||
HMCCPacketManager.equipmentSlotUpdate(player.getEntityId(), items, viewer);
|
||||
|
||||
if (WardrobeSettings.isEnabledBossbar()) {
|
||||
Audience target = BukkitAudiences.create(HMCCosmeticsPlugin.getInstance()).player(player);
|
||||
@@ -269,43 +298,47 @@ public class UserWardrobeManager {
|
||||
}
|
||||
MessagesUtil.sendDebugMessages("WardrobeUpdate[user=" + user.getUniqueId() + ",status=" + getWardrobeStatus() + "]");
|
||||
List<Player> viewer = Collections.singletonList(player);
|
||||
List<Player> outsideViewers = PacketManager.getViewers(viewingLocation);
|
||||
List<Player> outsideViewers = HMCCPacketManager.getViewers(viewingLocation);
|
||||
outsideViewers.remove(player);
|
||||
|
||||
Location location = npcLocation;
|
||||
int yaw = data.get();
|
||||
location.setYaw(yaw);
|
||||
|
||||
PacketManager.sendLookPacket(NPC_ID, location, viewer);
|
||||
HMCCPacketManager.sendLookPacket(NPC_ID, location, viewer);
|
||||
user.hidePlayer();
|
||||
int rotationSpeed = WardrobeSettings.getRotationSpeed();
|
||||
location.setYaw(ServerUtils.getNextYaw(yaw - 30, rotationSpeed));
|
||||
PacketManager.sendRotationPacket(NPC_ID, location, true, viewer);
|
||||
int nextyaw = ServerUtils.getNextYaw(yaw, rotationSpeed);
|
||||
location.setYaw(HMCCServerUtils.getNextYaw(yaw - 30, rotationSpeed));
|
||||
HMCCPacketManager.sendRotationPacket(NPC_ID, location, true, viewer);
|
||||
int nextyaw = HMCCServerUtils.getNextYaw(yaw, rotationSpeed);
|
||||
data.set(nextyaw);
|
||||
|
||||
for (CosmeticSlot slot : CosmeticSlot.values()) {
|
||||
PacketManager.equipmentSlotUpdate(NPC_ID, user, slot, viewer);
|
||||
HMCCPacketManager.equipmentSlotUpdate(NPC_ID, user, slot, viewer);
|
||||
}
|
||||
|
||||
if (user.hasCosmeticInSlot(CosmeticSlot.BACKPACK)) {
|
||||
PacketManager.sendTeleportPacket(user.getUserBackpackManager().getFirstArmorStandId(), location, false, viewer);
|
||||
PacketManager.ridingMountPacket(NPC_ID, user.getUserBackpackManager().getFirstArmorStandId(), viewer);
|
||||
if (user.hasCosmeticInSlot(CosmeticSlot.BACKPACK) && user.getUserBackpackManager() != null) {
|
||||
HMCCPacketManager.sendTeleportPacket(user.getUserBackpackManager().getFirstArmorStandId(), location, false, viewer);
|
||||
HMCCPacketManager.ridingMountPacket(NPC_ID, user.getUserBackpackManager().getFirstArmorStandId(), viewer);
|
||||
user.getUserBackpackManager().getEntityManager().setRotation(nextyaw);
|
||||
PacketManager.sendEntityDestroyPacket(user.getUserBackpackManager().getFirstArmorStandId(), outsideViewers);
|
||||
HMCCPacketManager.sendEntityDestroyPacket(user.getUserBackpackManager().getFirstArmorStandId(), outsideViewers);
|
||||
}
|
||||
|
||||
if (user.hasCosmeticInSlot(CosmeticSlot.BALLOON)) {
|
||||
if (user.hasCosmeticInSlot(CosmeticSlot.BALLOON) && user.isBalloonSpawned()) {
|
||||
// The two lines below broke, solved by listening to PlayerCosmeticPostEquipEvent
|
||||
//PacketManager.sendTeleportPacket(user.getBalloonManager().getPufferfishBalloonId(), npcLocation.add(Settings.getBalloonOffset()), false, viewer);
|
||||
//user.getBalloonManager().getModelEntity().teleport(npcLocation.add(Settings.getBalloonOffset()));
|
||||
user.getBalloonManager().sendRemoveLeashPacket(outsideViewers);
|
||||
PacketManager.sendEntityDestroyPacket(user.getBalloonManager().getModelId(), outsideViewers);
|
||||
if (user.getBalloonManager().getBalloonType() != UserBalloonManager.BalloonType.MODELENGINE) {
|
||||
HMCCPacketManager.sendEntityDestroyPacket(user.getBalloonManager().getModelId(), outsideViewers);
|
||||
}
|
||||
user.getBalloonManager().sendLeashPacket(NPC_ID);
|
||||
}
|
||||
|
||||
if (WardrobeSettings.isEquipPumpkin()) {
|
||||
NMSHandlers.getHandler().equipmentSlotUpdate(user.getPlayer().getEntityId(), EquipmentSlot.HEAD, new ItemStack(Material.CARVED_PUMPKIN), viewer);
|
||||
PacketManager.equipmentSlotUpdate(user.getPlayer().getEntityId(), EquipmentSlot.HEAD, new ItemStack(Material.CARVED_PUMPKIN), viewer);
|
||||
} else {
|
||||
HMCCPacketManager.equipmentSlotUpdate(user.getPlayer(), true, viewer); // Optifine dumbassery
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -11,7 +11,10 @@ import org.jetbrains.annotations.Contract;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class InventoryUtils {
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class HMCCInventoryUtils {
|
||||
|
||||
/**
|
||||
* Converts from the Bukkit item slots to ProtocolLib item slots. Will produce a null if an improper bukkit item slot is sent through
|
||||
@@ -52,6 +55,18 @@ public class InventoryUtils {
|
||||
};
|
||||
}
|
||||
|
||||
public static CosmeticSlot getItemSlotToCosmeticSlot(final EnumWrappers.ItemSlot slot) {
|
||||
return switch (slot) {
|
||||
case HEAD -> CosmeticSlot.HELMET;
|
||||
case CHEST -> CosmeticSlot.CHESTPLATE;
|
||||
case LEGS -> CosmeticSlot.LEGGINGS;
|
||||
case FEET -> CosmeticSlot.BOOTS;
|
||||
case OFFHAND -> CosmeticSlot.OFFHAND;
|
||||
case MAINHAND -> CosmeticSlot.MAINHAND;
|
||||
default -> null;
|
||||
};
|
||||
}
|
||||
|
||||
public static CosmeticSlot BukkitCosmeticSlot(EquipmentSlot slot) {
|
||||
return switch (slot) {
|
||||
case HAND -> CosmeticSlot.MAINHAND;
|
||||
@@ -142,6 +157,32 @@ public class InventoryUtils {
|
||||
}
|
||||
}
|
||||
|
||||
public static EquipmentSlot getEquipmentSlot(@NotNull EnumWrappers.ItemSlot slot) {
|
||||
switch (slot) {
|
||||
case HEAD -> {
|
||||
return EquipmentSlot.HEAD;
|
||||
}
|
||||
case CHEST -> {
|
||||
return EquipmentSlot.CHEST;
|
||||
}
|
||||
case LEGS -> {
|
||||
return EquipmentSlot.LEGS;
|
||||
}
|
||||
case FEET -> {
|
||||
return EquipmentSlot.FEET;
|
||||
}
|
||||
case OFFHAND -> {
|
||||
return EquipmentSlot.OFF_HAND;
|
||||
}
|
||||
case MAINHAND -> {
|
||||
return EquipmentSlot.HAND;
|
||||
}
|
||||
default -> {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isCosmeticItem(ItemStack itemStack) {
|
||||
if (itemStack == null) return false;
|
||||
itemStack = itemStack.clone();
|
||||
@@ -153,15 +194,11 @@ public class InventoryUtils {
|
||||
return new NamespacedKey(HMCCosmeticsPlugin.getInstance(), "cosmetic");
|
||||
}
|
||||
|
||||
public static NamespacedKey getOwnerKey() {
|
||||
return new NamespacedKey(HMCCosmeticsPlugin.getInstance(), "owner");
|
||||
}
|
||||
|
||||
public static NamespacedKey getSkullOwner() {
|
||||
return new NamespacedKey(HMCCosmeticsPlugin.getInstance(), "skullowner");
|
||||
}
|
||||
|
||||
public static NamespacedKey getSkullTexture() {
|
||||
return new NamespacedKey(HMCCosmeticsPlugin.getInstance(), "skulltexture");
|
||||
/**
|
||||
* This returns all the slots a player can have on them. In 1.20.6+, the enum includes BODY, which is not a valid slot for a player.
|
||||
* @return A list of all the slots a player can have on them
|
||||
*/
|
||||
public static List<EquipmentSlot> getPlayerArmorSlots() {
|
||||
return Arrays.asList(EquipmentSlot.HEAD, EquipmentSlot.CHEST, EquipmentSlot.LEGS, EquipmentSlot.FEET, EquipmentSlot.OFF_HAND, EquipmentSlot.HAND);
|
||||
}
|
||||
}
|
||||
@@ -3,16 +3,15 @@ package com.hibiscusmc.hmccosmetics.util;
|
||||
import com.comphenix.protocol.wrappers.WrappedGameProfile;
|
||||
import com.comphenix.protocol.wrappers.WrappedSignedProperty;
|
||||
import com.hibiscusmc.hmccosmetics.config.Settings;
|
||||
import me.lojosho.hibiscuscommons.util.packets.PacketManager;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class PlayerUtils {
|
||||
public class HMCCPlayerUtils {
|
||||
|
||||
@Nullable
|
||||
public static WrappedSignedProperty getSkin(Player player) {
|
||||
@@ -32,13 +31,6 @@ public class PlayerUtils {
|
||||
|
||||
@NotNull
|
||||
public static List<Player> getNearbyPlayers(@NotNull Location location) {
|
||||
List<Player> players = new ArrayList<>();
|
||||
int viewDistance = Settings.getViewDistance();
|
||||
for (Entity entity : location.getWorld().getNearbyEntities(location, viewDistance, viewDistance, viewDistance)) {
|
||||
if (entity instanceof Player) {
|
||||
players.add((Player) entity);
|
||||
}
|
||||
}
|
||||
return players;
|
||||
return PacketManager.getViewers(location, Settings.getViewDistance());
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,11 @@
|
||||
package com.hibiscusmc.hmccosmetics.util;
|
||||
|
||||
import com.hibiscusmc.hmccosmetics.nms.NMSHandlers;
|
||||
import com.owen1212055.particlehelper.api.particle.MultiParticle;
|
||||
import com.owen1212055.particlehelper.api.particle.Particle;
|
||||
import com.owen1212055.particlehelper.api.particle.types.*;
|
||||
import com.owen1212055.particlehelper.api.particle.types.dust.transition.TransitionDustParticle;
|
||||
import com.owen1212055.particlehelper.api.particle.types.note.MultiNoteParticle;
|
||||
import me.lojosho.hibiscuscommons.nms.NMSHandlers;
|
||||
import org.bukkit.Color;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Material;
|
||||
@@ -14,7 +14,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
import java.math.BigInteger;
|
||||
import java.util.Arrays;
|
||||
|
||||
public class ServerUtils {
|
||||
public class HMCCServerUtils {
|
||||
|
||||
private static String COLOR_CHAR = "&";
|
||||
|
||||
@@ -33,9 +33,14 @@ public class ServerUtils {
|
||||
}
|
||||
|
||||
public static org.bukkit.entity.Entity getEntity(int entityId) {
|
||||
return NMSHandlers.getHandler().getEntity(entityId);
|
||||
return NMSHandlers.getHandler().getUtilHandler().getEntity(entityId);
|
||||
}
|
||||
|
||||
/**
|
||||
* This takes in a string like #FFFFFF to convert it into a Bukkit color
|
||||
* @param colorStr
|
||||
* @return
|
||||
*/
|
||||
public static Color hex2Rgb(String colorStr) {
|
||||
if (colorStr.startsWith("#")) return Color.fromRGB(Integer.valueOf(colorStr.substring(1), 16));
|
||||
if (colorStr.startsWith("0x")) return Color.fromRGB(Integer.valueOf(colorStr.substring(2), 16));
|
||||
@@ -48,6 +53,22 @@ public class ServerUtils {
|
||||
return Color.WHITE;
|
||||
}
|
||||
|
||||
/**
|
||||
* This takes in a string like 55,49,181 to convert it into a Bukkit Color
|
||||
* @param colorStr
|
||||
* @return
|
||||
*/
|
||||
public static Color rgbToRgb(String colorStr) {
|
||||
if (colorStr.contains(",")) {
|
||||
String[] colors = colorStr.split(",", 3);
|
||||
if (colors.length == 3) {
|
||||
return Color.fromRGB(Integer.parseInt(colors[0]), Integer.parseInt(colors[1]), Integer.parseInt(colors[2]));
|
||||
}
|
||||
}
|
||||
|
||||
return Color.WHITE;
|
||||
}
|
||||
|
||||
// particle amount offsetxyz
|
||||
// Ex. HEART 10 0.1 0.1 0.1
|
||||
public static Particle addParticleValues(Particle particle, String[] split) {
|
||||
@@ -136,4 +157,13 @@ public class ServerUtils {
|
||||
}
|
||||
return nextYaw;
|
||||
}
|
||||
|
||||
public static boolean hasClass(String className) {
|
||||
try {
|
||||
Class.forName(className);
|
||||
return true;
|
||||
} catch (ClassNotFoundException e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,9 +2,10 @@ package com.hibiscusmc.hmccosmetics.util;
|
||||
|
||||
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
|
||||
import com.hibiscusmc.hmccosmetics.config.Settings;
|
||||
import com.hibiscusmc.hmccosmetics.hooks.Hooks;
|
||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||
import com.hibiscusmc.hmccosmetics.util.misc.Adventure;
|
||||
import me.lojosho.hibiscuscommons.hooks.Hooks;
|
||||
import me.lojosho.hibiscuscommons.util.AdventureUtils;
|
||||
import me.lojosho.shaded.configurate.ConfigurationNode;
|
||||
import net.kyori.adventure.audience.Audience;
|
||||
import net.kyori.adventure.platform.bukkit.BukkitAudiences;
|
||||
import net.kyori.adventure.text.Component;
|
||||
@@ -14,7 +15,6 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.spongepowered.configurate.ConfigurationNode;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.util.HashMap;
|
||||
@@ -105,9 +105,9 @@ public class MessagesUtil {
|
||||
if (player != null) message = Hooks.processPlaceholders(player, message);
|
||||
message = message.replaceAll("%prefix%", prefix);
|
||||
if (placeholders != null ) {
|
||||
return Adventure.MINI_MESSAGE.deserialize(message, placeholders);
|
||||
return AdventureUtils.MINI_MESSAGE.deserialize(message, placeholders);
|
||||
}
|
||||
return Adventure.MINI_MESSAGE.deserialize(message);
|
||||
return AdventureUtils.MINI_MESSAGE.deserialize(message);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -125,9 +125,9 @@ public class MessagesUtil {
|
||||
message = message.replaceAll("%prefix%", prefix);
|
||||
if (player != null) message = Hooks.processPlaceholders(player, message);
|
||||
if (placeholders != null ) {
|
||||
return Adventure.MINI_MESSAGE.deserialize(message, placeholders);
|
||||
return AdventureUtils.MINI_MESSAGE.deserialize(message, placeholders);
|
||||
}
|
||||
return Adventure.MINI_MESSAGE.deserialize(message);
|
||||
return AdventureUtils.MINI_MESSAGE.deserialize(message);
|
||||
}
|
||||
|
||||
public static String processStringNoKeyString(Player player, String message) {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.hibiscusmc.hmccosmetics.util;
|
||||
|
||||
import com.hibiscusmc.hmccosmetics.util.misc.StringUtils;
|
||||
import org.spongepowered.configurate.ConfigurationNode;
|
||||
import me.lojosho.hibiscuscommons.util.StringUtils;
|
||||
import me.lojosho.shaded.configurate.ConfigurationNode;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
|
||||
@@ -1,39 +0,0 @@
|
||||
package com.hibiscusmc.hmccosmetics.util.builder;
|
||||
|
||||
import org.bukkit.Color;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.bukkit.inventory.meta.LeatherArmorMeta;
|
||||
import org.bukkit.inventory.meta.PotionMeta;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class ColorBuilder {
|
||||
|
||||
public static boolean canBeColored(final Material material) {
|
||||
return canBeColored(new ItemStack(material));
|
||||
}
|
||||
|
||||
public static boolean canBeColored(final @NotNull ItemStack itemStack) {
|
||||
final ItemMeta itemMeta = itemStack.getItemMeta();
|
||||
|
||||
return (itemMeta instanceof LeatherArmorMeta ||
|
||||
itemMeta instanceof PotionMeta);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param color armor color
|
||||
* @return this
|
||||
*/
|
||||
|
||||
public static ItemMeta color(ItemMeta itemMeta, final Color color) {
|
||||
if (itemMeta instanceof final PotionMeta meta) {
|
||||
meta.setColor(color);
|
||||
}
|
||||
if (itemMeta instanceof final LeatherArmorMeta meta) {
|
||||
meta.setColor(color);
|
||||
}
|
||||
return itemMeta;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
package com.hibiscusmc.hmccosmetics.util.misc;
|
||||
|
||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||
import net.kyori.adventure.text.minimessage.tag.standard.StandardTags;
|
||||
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
||||
|
||||
public class Adventure {
|
||||
|
||||
public static final LegacyComponentSerializer SERIALIZER = LegacyComponentSerializer.builder()
|
||||
.hexColors()
|
||||
.useUnusualXRepeatedCharacterHexFormat()
|
||||
.build();
|
||||
|
||||
public static final MiniMessage MINI_MESSAGE = MiniMessage.builder().tags(
|
||||
StandardTags.defaults()
|
||||
).
|
||||
build();
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
package com.hibiscusmc.hmccosmetics.util.misc;
|
||||
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class StringUtils {
|
||||
|
||||
/**
|
||||
* @param parsed message to be parsed
|
||||
* @return MiniMessage parsed string
|
||||
*/
|
||||
@NotNull
|
||||
public static Component parse(final String parsed) {
|
||||
return Adventure.MINI_MESSAGE.deserialize(parsed);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static String parseStringToString(final String parsed) {
|
||||
return Adventure.SERIALIZER.serialize(Adventure.MINI_MESSAGE.deserialize(parsed));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static String formatArmorItemType(String type) {
|
||||
type = type.toLowerCase();
|
||||
final String[] parts = type.split(" ");
|
||||
|
||||
final String firstPart = parts[0].substring(0, 1).toUpperCase() + parts[0].substring(1);
|
||||
|
||||
if (parts.length == 1) {
|
||||
return firstPart;
|
||||
}
|
||||
|
||||
return firstPart + parts[1].substring(0, 1).toUpperCase() + parts[1].substring(1);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
package com.hibiscusmc.hmccosmetics.util.packets;
|
||||
|
||||
import com.comphenix.protocol.ProtocolLibrary;
|
||||
import com.comphenix.protocol.events.PacketContainer;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class BasePacket {
|
||||
|
||||
public static void sendPacket(Player player, PacketContainer packet) {
|
||||
if (player == null) return;
|
||||
ProtocolLibrary.getProtocolManager().sendServerPacket(player, packet, false);
|
||||
}
|
||||
}
|
||||
@@ -1,21 +1,21 @@
|
||||
package com.hibiscusmc.hmccosmetics.util.packets;
|
||||
|
||||
import com.comphenix.protocol.PacketType;
|
||||
import com.comphenix.protocol.ProtocolLibrary;
|
||||
import com.comphenix.protocol.events.PacketContainer;
|
||||
import com.comphenix.protocol.wrappers.*;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.hibiscusmc.hmccosmetics.api.HMCCosmeticsAPI;
|
||||
import com.hibiscusmc.hmccosmetics.config.Settings;
|
||||
import com.hibiscusmc.hmccosmetics.cosmetic.CosmeticSlot;
|
||||
import com.hibiscusmc.hmccosmetics.nms.NMSHandlers;
|
||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUsers;
|
||||
import com.hibiscusmc.hmccosmetics.util.InventoryUtils;
|
||||
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||
import com.hibiscusmc.hmccosmetics.util.PlayerUtils;
|
||||
import com.hibiscusmc.hmccosmetics.util.HMCCInventoryUtils;
|
||||
import com.hibiscusmc.hmccosmetics.util.HMCCPlayerUtils;
|
||||
import com.hibiscusmc.hmccosmetics.util.packets.wrappers.WrapperPlayServerNamedEntitySpawn;
|
||||
import com.hibiscusmc.hmccosmetics.util.packets.wrappers.WrapperPlayServerPlayerInfo;
|
||||
import com.hibiscusmc.hmccosmetics.util.packets.wrappers.WrapperPlayServerRelEntityMove;
|
||||
import it.unimi.dsi.fastutil.ints.IntArrayList;
|
||||
import me.lojosho.hibiscuscommons.util.packets.PacketManager;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.EntityType;
|
||||
@@ -24,12 +24,9 @@ import org.bukkit.inventory.EquipmentSlot;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.*;
|
||||
|
||||
public class PacketManager extends BasePacket {
|
||||
public class HMCCPacketManager extends PacketManager {
|
||||
|
||||
public static void sendEntitySpawnPacket(
|
||||
final @NotNull Location location,
|
||||
@@ -59,39 +56,18 @@ public class PacketManager extends BasePacket {
|
||||
for (Player p : sendTo) sendPacket(p, packet);
|
||||
}
|
||||
|
||||
public static void gamemodeChangePacket(
|
||||
Player player,
|
||||
int gamemode
|
||||
) {
|
||||
PacketContainer packet = new PacketContainer(PacketType.Play.Server.GAME_STATE_CHANGE);
|
||||
packet.getGameStateIDs().write(0, 3);
|
||||
// Tells what event this is. This is a change gamemode event.
|
||||
packet.getFloat().write(0, (float) gamemode);
|
||||
sendPacket(player, packet);
|
||||
MessagesUtil.sendDebugMessages("Gamemode Change sent to " + player + " to be " + gamemode);
|
||||
}
|
||||
|
||||
public static void ridingMountPacket(
|
||||
int mountId,
|
||||
int passengerId,
|
||||
@NotNull List<Player> sendTo
|
||||
) {
|
||||
PacketContainer packet = new PacketContainer(PacketType.Play.Server.MOUNT);
|
||||
packet.getIntegers().write(0, mountId);
|
||||
packet.getIntegerArrays().write(0, new int[]{passengerId});
|
||||
for (Player p : sendTo) sendPacket(p, packet);
|
||||
}
|
||||
|
||||
public static void equipmentSlotUpdate(
|
||||
Player player,
|
||||
boolean empty,
|
||||
List<Player> sendTo
|
||||
) {
|
||||
for (EquipmentSlot slot : EquipmentSlot.values()) {
|
||||
HashMap<EquipmentSlot, ItemStack> items = new HashMap<>();
|
||||
for (EquipmentSlot slot : HMCCInventoryUtils.getPlayerArmorSlots()) {
|
||||
ItemStack item = player.getInventory().getItem(slot);
|
||||
if (empty) item = new ItemStack(Material.AIR);
|
||||
NMSHandlers.getHandler().equipmentSlotUpdate(player.getEntityId(), slot, item, sendTo);
|
||||
items.put(slot, item);
|
||||
}
|
||||
equipmentSlotUpdate(player.getEntityId(), items, sendTo);
|
||||
}
|
||||
public static void equipmentSlotUpdate(
|
||||
@NotNull Player player,
|
||||
@@ -115,9 +91,9 @@ public class PacketManager extends BasePacket {
|
||||
CosmeticSlot cosmeticSlot,
|
||||
List<Player> sendTo
|
||||
) {
|
||||
if (cosmeticSlot == CosmeticSlot.BACKPACK || cosmeticSlot == CosmeticSlot.BALLOON || cosmeticSlot == CosmeticSlot.EMOTE) return;
|
||||
if (cosmeticSlot == CosmeticSlot.BACKPACK || cosmeticSlot == CosmeticSlot.CUSTOM || cosmeticSlot == CosmeticSlot.BALLOON || cosmeticSlot == CosmeticSlot.EMOTE) return;
|
||||
|
||||
NMSHandlers.getHandler().equipmentSlotUpdate(entityId, InventoryUtils.getEquipmentSlot(cosmeticSlot), user.getUserCosmeticItem(cosmeticSlot), sendTo);
|
||||
equipmentSlotUpdate(entityId, HMCCInventoryUtils.getEquipmentSlot(cosmeticSlot), user.getUserCosmeticItem(cosmeticSlot), sendTo);
|
||||
}
|
||||
|
||||
public static void sendArmorstandMetadata(
|
||||
@@ -127,18 +103,12 @@ public class PacketManager extends BasePacket {
|
||||
PacketContainer packet = new PacketContainer(PacketType.Play.Server.ENTITY_METADATA);
|
||||
packet.getModifier().writeDefaults();
|
||||
packet.getIntegers().write(0, entityId);
|
||||
WrappedDataWatcher wrapper = new WrappedDataWatcher();
|
||||
final List<WrappedDataValue> wrappedDataValueList = Lists.newArrayList();
|
||||
|
||||
if (NMSHandlers.getVersion().contains("v1_18_R2") || NMSHandlers.getVersion().contains("v1_19_R1")) {
|
||||
wrapper.setObject(new WrappedDataWatcher.WrappedDataWatcherObject(0, WrappedDataWatcher.Registry.get(Byte.class)), (byte) 0x20);
|
||||
wrapper.setObject(new WrappedDataWatcher.WrappedDataWatcherObject(15, WrappedDataWatcher.Registry.get(Byte.class)), (byte) 0x10);
|
||||
packet.getWatchableCollectionModifier().write(0, wrapper.getWatchableObjects());
|
||||
} else {
|
||||
final List<WrappedDataValue> wrappedDataValueList = Lists.newArrayList();
|
||||
wrappedDataValueList.add(new WrappedDataValue(0, WrappedDataWatcher.Registry.get(Byte.class), (byte) 0x20));
|
||||
wrappedDataValueList.add(new WrappedDataValue(15, WrappedDataWatcher.Registry.get(Byte.class), (byte) 0x10));
|
||||
packet.getDataValueCollectionModifier().write(0, wrappedDataValueList);
|
||||
}
|
||||
// 0x21 = Invisible + Fire (Aka, burns to make it not take the light of the block its in, avoiding turning it black)
|
||||
wrappedDataValueList.add(new WrappedDataValue(0, WrappedDataWatcher.Registry.get(Byte.class), (byte) 0x21));
|
||||
wrappedDataValueList.add(new WrappedDataValue(15, WrappedDataWatcher.Registry.get(Byte.class), (byte) 0x10));
|
||||
packet.getDataValueCollectionModifier().write(0, wrappedDataValueList);
|
||||
for (Player p : sendTo) sendPacket(p, packet);
|
||||
}
|
||||
|
||||
@@ -149,16 +119,10 @@ public class PacketManager extends BasePacket {
|
||||
PacketContainer packet = new PacketContainer(PacketType.Play.Server.ENTITY_METADATA);
|
||||
packet.getModifier().writeDefaults();
|
||||
packet.getIntegers().write(0, entityId);
|
||||
WrappedDataWatcher wrapper = new WrappedDataWatcher();
|
||||
|
||||
if (NMSHandlers.getVersion().contains("v1_18_R2") || NMSHandlers.getVersion().contains("v1_19_R1")) {
|
||||
wrapper.setObject(new WrappedDataWatcher.WrappedDataWatcherObject(0, WrappedDataWatcher.Registry.get(Byte.class)), (byte) 0x20);
|
||||
packet.getWatchableCollectionModifier().write(0, wrapper.getWatchableObjects());
|
||||
} else {
|
||||
final List<WrappedDataValue> wrappedDataValueList = Lists.newArrayList();
|
||||
wrappedDataValueList.add(new WrappedDataValue(0, WrappedDataWatcher.Registry.get(Byte.class), (byte) 0x20));
|
||||
packet.getDataValueCollectionModifier().write(0, wrappedDataValueList);
|
||||
}
|
||||
final List<WrappedDataValue> wrappedDataValueList = Lists.newArrayList();
|
||||
wrappedDataValueList.add(new WrappedDataValue(0, WrappedDataWatcher.Registry.get(Byte.class), (byte) 0x20));
|
||||
packet.getDataValueCollectionModifier().write(0, wrappedDataValueList);
|
||||
for (Player p : sendTo) sendPacket(p, packet);
|
||||
}
|
||||
|
||||
@@ -169,30 +133,13 @@ public class PacketManager extends BasePacket {
|
||||
PacketContainer packet = new PacketContainer(PacketType.Play.Server.ENTITY_METADATA);
|
||||
packet.getModifier().writeDefaults();
|
||||
packet.getIntegers().write(0, entityId);
|
||||
WrappedDataWatcher wrapper = new WrappedDataWatcher();
|
||||
|
||||
if (NMSHandlers.getVersion().contains("v1_18_R2") || NMSHandlers.getVersion().contains("v1_19_R1")) {
|
||||
wrapper.setObject(new WrappedDataWatcher.WrappedDataWatcherObject(0, WrappedDataWatcher.Registry.get(Byte.class)), (byte) 0x20);
|
||||
wrapper.setObject(new WrappedDataWatcher.WrappedDataWatcherObject(8, WrappedDataWatcher.Registry.get(Float.class)), 0f);
|
||||
packet.getWatchableCollectionModifier().write(0, wrapper.getWatchableObjects());
|
||||
} else {
|
||||
final List<WrappedDataValue> wrappedDataValueList = Lists.newArrayList();
|
||||
wrappedDataValueList.add(new WrappedDataValue(0, WrappedDataWatcher.Registry.get(Byte.class), (byte) 0x20));
|
||||
wrappedDataValueList.add(new WrappedDataValue(8, WrappedDataWatcher.Registry.get(Float.class), 0f));
|
||||
//wrappedDataValueList.add(new WrappedDataValue(11, WrappedDataWatcher.Registry.get(Integer.class), 21));
|
||||
packet.getDataValueCollectionModifier().write(0, wrappedDataValueList);
|
||||
}
|
||||
for (Player p : sendTo) sendPacket(p, packet);
|
||||
}
|
||||
final List<WrappedDataValue> wrappedDataValueList = Lists.newArrayList();
|
||||
wrappedDataValueList.add(new WrappedDataValue(0, WrappedDataWatcher.Registry.get(Byte.class), (byte) 0x20));
|
||||
wrappedDataValueList.add(new WrappedDataValue(8, WrappedDataWatcher.Registry.get(Float.class), 0f));
|
||||
//wrappedDataValueList.add(new WrappedDataValue(11, WrappedDataWatcher.Registry.get(Integer.class), 21));
|
||||
packet.getDataValueCollectionModifier().write(0, wrappedDataValueList);
|
||||
|
||||
public static void sendLookPacket(
|
||||
int entityId,
|
||||
@NotNull Location location,
|
||||
@NotNull List<Player> sendTo
|
||||
) {
|
||||
PacketContainer packet = new PacketContainer(PacketType.Play.Server.ENTITY_HEAD_ROTATION);
|
||||
packet.getIntegers().write(0, entityId);
|
||||
packet.getBytes().write(0, (byte) (location.getYaw() * 256.0F / 360.0F));
|
||||
for (Player p : sendTo) sendPacket(p, packet);
|
||||
}
|
||||
|
||||
@@ -288,41 +235,6 @@ public class PacketManager extends BasePacket {
|
||||
sendRidingPacket(mountId, new int[] {passengerId}, sendTo);
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroys an entity from a player
|
||||
* @param entityId The entity to delete for a player
|
||||
* @param sendTo The players the packet should be sent to
|
||||
*/
|
||||
public static void sendEntityDestroyPacket(final int entityId, @NotNull List<Player> sendTo) {
|
||||
PacketContainer packet = new PacketContainer(PacketType.Play.Server.ENTITY_DESTROY);
|
||||
packet.getModifier().write(0, new IntArrayList(new int[]{entityId}));
|
||||
for (final Player p : sendTo) sendPacket(p, packet);
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroys an entity from a player
|
||||
* @param sendTo The players the packet should be sent to
|
||||
*/
|
||||
public static void sendEntityDestroyPacket(final List<Integer> ids, @NotNull List<Player> sendTo) {
|
||||
PacketContainer packet = new PacketContainer(PacketType.Play.Server.ENTITY_DESTROY);
|
||||
IntArrayList entities = new IntArrayList(new int[]{});
|
||||
for (int id : ids) entities.add(id);
|
||||
packet.getModifier().write(0, entities);
|
||||
for (final Player p : sendTo) sendPacket(p, packet);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends a camera packet
|
||||
* @param entityId The Entity ID that camera will go towards
|
||||
* @param sendTo The players that will be sent this packet
|
||||
*/
|
||||
public static void sendCameraPacket(final int entityId, @NotNull List<Player> sendTo) {
|
||||
PacketContainer packet = new PacketContainer(PacketType.Play.Server.CAMERA);
|
||||
packet.getIntegers().write(0, entityId);
|
||||
for (final Player p : sendTo) sendPacket(p, packet);
|
||||
MessagesUtil.sendDebugMessages(sendTo + " | " + entityId + " has had a camera packet on them!");
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param location Location of the fake player.
|
||||
@@ -336,13 +248,17 @@ public class PacketManager extends BasePacket {
|
||||
final int entityId,
|
||||
final @NotNull List<Player> sendTo
|
||||
) {
|
||||
WrapperPlayServerNamedEntitySpawn wrapper = new WrapperPlayServerNamedEntitySpawn();
|
||||
wrapper.setEntityID(entityId);
|
||||
wrapper.setPlayerUUID(uuid);
|
||||
wrapper.setPosition(location.toVector());
|
||||
wrapper.setPitch(location.getPitch());
|
||||
wrapper.setYaw(location.getYaw());
|
||||
for (final Player p : sendTo) sendPacket(p, wrapper.getHandle());
|
||||
if (HMCCosmeticsAPI.getNMSVersion().contains("v1_19_R3") || HMCCosmeticsAPI.getNMSVersion().contains("v1_20_R1")) {
|
||||
WrapperPlayServerNamedEntitySpawn wrapper = new WrapperPlayServerNamedEntitySpawn();
|
||||
wrapper.setEntityID(entityId);
|
||||
wrapper.setPlayerUUID(uuid);
|
||||
wrapper.setPosition(location.toVector());
|
||||
wrapper.setPitch(location.getPitch());
|
||||
wrapper.setYaw(location.getYaw());
|
||||
for (final Player p : sendTo) sendPacket(p, wrapper.getHandle());
|
||||
return;
|
||||
}
|
||||
sendEntitySpawnPacket(location, entityId, EntityType.PLAYER, uuid);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -367,24 +283,15 @@ public class PacketManager extends BasePacket {
|
||||
}
|
||||
|
||||
WrappedGameProfile wrappedGameProfile = new WrappedGameProfile(uuid, name);
|
||||
WrappedSignedProperty skinData = PlayerUtils.getSkin(skinnedPlayer);
|
||||
WrappedSignedProperty skinData = HMCCPlayerUtils.getSkin(skinnedPlayer);
|
||||
if (skinData != null) wrappedGameProfile.getProperties().put("textures", skinData);
|
||||
// For sor some reason <1.19.2 handles it on the 0 field index, newer versions handles it on the 1
|
||||
if (NMSHandlers.getVersion().contains("v1_18_R2") || NMSHandlers.getVersion().contains("v1_19_R1")) {
|
||||
info.getHandle().getPlayerInfoDataLists().write(0, Collections.singletonList(new PlayerInfoData(
|
||||
wrappedGameProfile,
|
||||
0,
|
||||
EnumWrappers.NativeGameMode.CREATIVE,
|
||||
WrappedChatComponent.fromText(name)
|
||||
)));
|
||||
} else {
|
||||
info.getHandle().getPlayerInfoDataLists().write(1, Collections.singletonList(new PlayerInfoData(
|
||||
wrappedGameProfile,
|
||||
0,
|
||||
EnumWrappers.NativeGameMode.CREATIVE,
|
||||
WrappedChatComponent.fromText(name)
|
||||
)));
|
||||
}
|
||||
|
||||
info.getHandle().getPlayerInfoDataLists().write(1, Collections.singletonList(new PlayerInfoData(
|
||||
wrappedGameProfile,
|
||||
0,
|
||||
EnumWrappers.NativeGameMode.CREATIVE,
|
||||
WrappedChatComponent.fromText(name)
|
||||
)));
|
||||
for (final Player p : sendTo) sendPacket(p, info.getHandle());
|
||||
}
|
||||
|
||||
@@ -412,20 +319,12 @@ public class PacketManager extends BasePacket {
|
||||
PacketContainer packet = new PacketContainer(PacketType.Play.Server.ENTITY_METADATA);
|
||||
packet.getModifier().writeDefaults();
|
||||
packet.getIntegers().write(0, playerId);
|
||||
WrappedDataWatcher wrapper = new WrappedDataWatcher();
|
||||
|
||||
if (NMSHandlers.getVersion().contains("v1_18_R2") || NMSHandlers.getVersion().contains("v1_19_R1")) {
|
||||
wrapper.setObject(new WrappedDataWatcher.WrappedDataWatcherObject(17, WrappedDataWatcher.Registry.get(Byte.class)), mask);
|
||||
packet.getWatchableCollectionModifier().write(0, wrapper.getWatchableObjects());
|
||||
} else {
|
||||
final List<WrappedDataValue> wrappedDataValueList = Lists.newArrayList();
|
||||
wrappedDataValueList.add(new WrappedDataValue(17, WrappedDataWatcher.Registry.get(Byte.class), mask));
|
||||
packet.getDataValueCollectionModifier().write(0, wrappedDataValueList);
|
||||
}
|
||||
final List<WrappedDataValue> wrappedDataValueList = Lists.newArrayList();
|
||||
wrappedDataValueList.add(new WrappedDataValue(17, WrappedDataWatcher.Registry.get(Byte.class), mask));
|
||||
packet.getDataValueCollectionModifier().write(0, wrappedDataValueList);
|
||||
|
||||
for (final Player p : sendTo) {
|
||||
sendPacket(p, packet);
|
||||
}
|
||||
for (final Player p : sendTo) sendPacket(p, packet);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -440,21 +339,6 @@ public class PacketManager extends BasePacket {
|
||||
final UUID uuid,
|
||||
final List<Player> sendTo
|
||||
) {
|
||||
if (NMSHandlers.getVersion().contains("v1_18_R2") || NMSHandlers.getVersion().contains("v1_19_R1")) {
|
||||
WrapperPlayServerPlayerInfo info = new WrapperPlayServerPlayerInfo();
|
||||
// Remove player is deprecated on 1.19.3+, but we still need to support 1.18.2
|
||||
info.setAction(EnumWrappers.PlayerInfoAction.REMOVE_PLAYER);
|
||||
|
||||
String name = "Mannequin-" + player.getEntityId();
|
||||
while (name.length() > 16) {
|
||||
name = name.substring(16);
|
||||
}
|
||||
|
||||
info.setData(List.of(new PlayerInfoData(new WrappedGameProfile(uuid, player.getName()), 0, EnumWrappers.NativeGameMode.CREATIVE, WrappedChatComponent.fromText(name))));
|
||||
for (final Player p : sendTo) sendPacket(p, info.getHandle());
|
||||
return;
|
||||
}
|
||||
|
||||
PacketContainer packet = new PacketContainer(PacketType.Play.Server.PLAYER_INFO_REMOVE);
|
||||
packet.getUUIDLists().write(0, List.of(uuid));
|
||||
for (final Player p : sendTo) sendPacket(p, packet);
|
||||
@@ -468,51 +352,6 @@ public class PacketManager extends BasePacket {
|
||||
sendLeashPacket(leashedEntity, entityId, getViewers(location));
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends a leash packet, useful for balloons!
|
||||
* @param leashedEntity Entity being leashed (ex. a horse)
|
||||
* @param entityId Entity this is affecting (ex. a player)
|
||||
* @param sendTo Whom to send the packet to
|
||||
*/
|
||||
public static void sendLeashPacket(
|
||||
final int leashedEntity,
|
||||
final int entityId,
|
||||
final @NotNull List<Player> sendTo
|
||||
) {
|
||||
PacketContainer packet = new PacketContainer(PacketType.Play.Server.ATTACH_ENTITY);
|
||||
packet.getIntegers().write(0, leashedEntity);
|
||||
packet.getIntegers().write(1, entityId);
|
||||
for (final Player p : sendTo) {
|
||||
sendPacket(p, packet);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Used when a player is sent 8+ blocks.
|
||||
* @param entityId Entity this affects
|
||||
* @param location Location a player is being teleported to
|
||||
* @param onGround If the packet is on the ground
|
||||
* @param sendTo Whom to send the packet to
|
||||
*/
|
||||
public static void sendTeleportPacket(
|
||||
final int entityId,
|
||||
final @NotNull Location location,
|
||||
boolean onGround,
|
||||
final @NotNull List<Player> sendTo
|
||||
) {
|
||||
PacketContainer packet = new PacketContainer(PacketType.Play.Server.ENTITY_TELEPORT);
|
||||
packet.getIntegers().write(0, entityId);
|
||||
packet.getDoubles().write(0, location.getX());
|
||||
packet.getDoubles().write(1, location.getY());
|
||||
packet.getDoubles().write(2, location.getZ());
|
||||
packet.getBytes().write(0, (byte) (location.getYaw() * 256.0F / 360.0F));
|
||||
packet.getBytes().write(1, (byte) (location.getPitch() * 256.0F / 360.0F));
|
||||
packet.getBooleans().write(0, onGround);
|
||||
for (final Player p : sendTo) {
|
||||
sendPacket(p, packet);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends a movement packet from one location to another
|
||||
* @param entityId Entity this will affect
|
||||
@@ -546,8 +385,13 @@ public class PacketManager extends BasePacket {
|
||||
if (Settings.getViewDistance() <= 0) {
|
||||
viewers.addAll(location.getWorld().getPlayers());
|
||||
} else {
|
||||
viewers.addAll(PlayerUtils.getNearbyPlayers(location));
|
||||
viewers.addAll(HMCCPlayerUtils.getNearbyPlayers(location));
|
||||
}
|
||||
return viewers;
|
||||
}
|
||||
|
||||
public static void sendPacket(Player player, PacketContainer packet) {
|
||||
if (player == null) return;
|
||||
ProtocolLibrary.getProtocolManager().sendServerPacket(player, packet, null,false);
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,7 @@ import com.comphenix.protocol.PacketType;
|
||||
import com.comphenix.protocol.events.PacketContainer;
|
||||
import com.comphenix.protocol.wrappers.EnumWrappers.PlayerInfoAction;
|
||||
import com.comphenix.protocol.wrappers.PlayerInfoData;
|
||||
import com.hibiscusmc.hmccosmetics.nms.NMSHandlers;
|
||||
import com.hibiscusmc.hmccosmetics.api.HMCCosmeticsAPI;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
@@ -26,7 +26,7 @@ public class WrapperPlayServerPlayerInfo extends AbstractPacket {
|
||||
}
|
||||
|
||||
public void setAction(PlayerInfoAction value) {
|
||||
if (NMSHandlers.getVersion().contains("v1_17_R1") || NMSHandlers.getVersion().contains("v1_18_R2") || NMSHandlers.getVersion().contains("v1_19_R1")) {
|
||||
if (HMCCosmeticsAPI.getNMSVersion().contains("v1_17_R1") || HMCCosmeticsAPI.getNMSVersion().contains("v1_18_R2") || HMCCosmeticsAPI.getNMSVersion().contains("v1_19_R1")) {
|
||||
handle.getPlayerInfoAction().write(0, value);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ config-version: 1
|
||||
default-menu: defaultmenu
|
||||
debug-mode: false
|
||||
database-settings:
|
||||
type: sqlite #MYSQL, SQLite
|
||||
type: sqlite # SQLite (Default), MYSQL, NONE
|
||||
mysql:
|
||||
database: database
|
||||
password: cherryBomb
|
||||
@@ -24,6 +24,24 @@ cosmetic-settings:
|
||||
force-permission-join: true # Checks a player permission if they can have a cosmetic when they join the server.
|
||||
force-show-join: false # If the plugin should force show a player's cosmetics when they join the server.
|
||||
|
||||
# This determines what to process what areas to process placeholders when displaying the item to the user.
|
||||
# This can be heavy on servers with a lot of players, so if experiencing lag issues relating to setting display/lores of items, disable this.
|
||||
item-processing:
|
||||
display-name: true
|
||||
lore: true
|
||||
|
||||
# This is a list of worlds that cosmetics are hidden in. When a player enters one of these worlds, their cosmetics will be hidden.
|
||||
disabled-worlds:
|
||||
- "disabledworld"
|
||||
|
||||
disabled-gamemode:
|
||||
enabled: true
|
||||
# Which gamemodes should cosmetics be disabled for. This is useful for servers that have a creative world. All options are here, https://hub.spigotmc.org/javadocs/spigot/org/bukkit/GameMode.html
|
||||
gamemodes:
|
||||
- "SPECTATOR"
|
||||
|
||||
# This disables the entire internal emote system within the plugin. This option requires a restart.
|
||||
emote-enable: true
|
||||
emote-distance: -3 # This shows how far away the camera should be while a player is doing an emote. Negative is behind player.
|
||||
emote-block-check: true # If the server should check if the block is open where the camera is placed (prevents players viewing through blocks)
|
||||
emote-air-check: true # Check if there is air under a player, if there is, don't play emote
|
||||
@@ -38,11 +56,27 @@ cosmetic-settings:
|
||||
# This helps reduce the amount of packets sent for packet entities, but reduces accuracy of the entity. This is in milliseconds. -1 to disable.
|
||||
# This is useful for servers with a lot of backpacks, as they are passengers, which means the client will update their position automatically within an area where the entity is located.
|
||||
entity-cooldown-teleport-packet: 500
|
||||
# This forces the offhand to always show the cosmetic. False means it will only show when the slot is empty.
|
||||
|
||||
helmet-add-enchantments: false # If the plugin should keep enchants on helmets. This is useful as some enchantments are client side only.
|
||||
chest-add-enchantments: false # If the plugin should keep enchants on chestplate. This is useful as some enchantments are client side only.
|
||||
leggings-add-enchantments: false # If the plugin should keep enchants on leggings. This is useful as some enchantments are client side only.
|
||||
boots-add-enchantments: false # If the plugin should keep enchants on boots. This is useful as some enchantments are client side only.
|
||||
slot-options:
|
||||
helmet:
|
||||
# If the plugin should keep enchants on helmets. This is useful as some enchantments are client side only.
|
||||
add-enchantments: false
|
||||
# Should the player slot be empty for the cosmetic to be applied? A cosmetic will be "hidden" if a player has an item equipped in the slot
|
||||
require-empty: false
|
||||
chestplate:
|
||||
add-enchantments: false
|
||||
require-empty: false
|
||||
leggings:
|
||||
add-enchantments: false
|
||||
require-empty: false
|
||||
boots:
|
||||
add-enchantments: false
|
||||
require-empty: false
|
||||
offhand:
|
||||
add-enchantments: false
|
||||
# There is a small visual blip for a tick when you put a new item in the offhand slot, hence why its enabled by default.
|
||||
require-empty: true
|
||||
|
||||
# This attempts to destroy cosmetics that get loose in the wild, such as through a player entering creative mode.
|
||||
# Most servers who don't use creative mode and have properly set up the plugin should have no need for this and can leave it disabled.
|
||||
@@ -52,12 +86,20 @@ cosmetic-settings:
|
||||
# setting this to lower than the server player view distance should fix the
|
||||
# bug where players see random backpacks. Put -1 to ignore and send packets to everyone.
|
||||
view-distance: 32
|
||||
# If the plugin should set the pitch of balloons to always be 0, to prevent players looking up affecting the balloon.
|
||||
# This only applies to models that have a "head" section to them. THIS DOES NOT IMPACT THE REST OF THE ENTITY.
|
||||
balloon-head-unmoving: false
|
||||
# how the balloon should be positioned relative to the player
|
||||
balloon-offset:
|
||||
x: 0.5
|
||||
y: 3
|
||||
z: 0.5
|
||||
menu-settings:
|
||||
click-cooldown:
|
||||
enabled: true
|
||||
# This is the cooldown in miliseconds for the menu. This is useful for servers that have a lot of players.
|
||||
# (So if a user clicks the menu, it won't spam the server with requesting it to refresh itself)
|
||||
time: 1000
|
||||
shading:
|
||||
# Below is the shading mechanism behind cosmetic items. This is a bit complicated, but it allows for a lot of customization.
|
||||
# The shading is done through the title and by shifting textures around. This is done by offsets.
|
||||
@@ -77,16 +119,19 @@ menu-settings:
|
||||
equip-click: "ANY" # ANY or ClickType, https://jd.papermc.io/paper/1.20/org/bukkit/event/inventory/ClickType.html
|
||||
unequip-click: "ANY" # ANY or ClickType, https://jd.papermc.io/paper/1.20/org/bukkit/event/inventory/ClickType.html
|
||||
dye-menu:
|
||||
# If you use ItemsAdder, set this to "§f:offset_-8::dye_menu:"
|
||||
# If you use Oraxen, set this to "<glyph:neg_shift_8><glyph:dye_menu>"
|
||||
title: "§f"
|
||||
input-slot: 19
|
||||
output-slot: 25
|
||||
# If you use ItemsAdder, set this to "<white>:img_offset_-8::img_dye_menu:"
|
||||
# If you use Oraxen, set this to "<white><s:-8><g:dye_menu>"
|
||||
title: "<white>"
|
||||
input-slot: 10
|
||||
output-slot: 16
|
||||
hook-settings:
|
||||
itemsadder:
|
||||
# This causes the plugin to reload itself after any ItemsAdder change. This keeps the plugin fully up to date with IA, but
|
||||
# could cause console spam as HMCCosmetics has to reload itself as well.
|
||||
reload-on-change: false
|
||||
nexo:
|
||||
# This causes the plugin to reload itself after any Nexo change. This keeps the plugin fully up to date with Nexo
|
||||
reload-on-change: true
|
||||
worldguard:
|
||||
# Checks worldguard regions for HMCC flags. If set to false, flags will not work properly.
|
||||
# Requires restart to apply changes.
|
||||
@@ -100,6 +145,10 @@ wardrobe:
|
||||
return-last-location: false
|
||||
# If players in wardrobes should be able to equip any cosmetic, regardless of permission (Cosmetics they do not have access to will be removed when they leave the wardrobe)
|
||||
unchecked-wardrobe-cosmetics: false
|
||||
# If HMCC should prevent a player from being damaged while being in the wardrobe
|
||||
prevent-damage: true
|
||||
# If a player is damaged in a wardrobe, and if it's set to true, it'll kick them from the wardrobe (prevent-damage must be false)
|
||||
damage-kicked: false
|
||||
|
||||
menu-options:
|
||||
enter-open-menu: false # If the menu should open when a player enters a wardrobe
|
||||
@@ -126,6 +175,9 @@ wardrobe:
|
||||
title-fade-out: 1000 # milliseconds
|
||||
wardrobes:
|
||||
default:
|
||||
distance: -1 # Distance in blocks that a player can interact with the wardrobe. -1 to ignore.
|
||||
permission: "hmccosmetics.wardrobe.default" # Permission required to use the wardrobe.
|
||||
default-menu: defaultmenu
|
||||
npc-location:
|
||||
world: "world"
|
||||
x: 0
|
||||
|
||||
@@ -67,7 +67,7 @@ jetpack:
|
||||
amount: 1
|
||||
firstperson-item:
|
||||
material: PAPER
|
||||
model-data: 14
|
||||
model-data: 15
|
||||
name: "<white>Jetpack"
|
||||
amount: 1
|
||||
hammer:
|
||||
@@ -155,6 +155,6 @@ hibiscus_flower:
|
||||
permission: "hmccosmetics.hibiscus_flower"
|
||||
item:
|
||||
material: PAPER
|
||||
model-data: 15
|
||||
model-data: 16
|
||||
name: "<#d24c9f>Hibiscus Flower"
|
||||
amount: 1
|
||||
|
||||
@@ -134,33 +134,34 @@ items:
|
||||
- "<gray>Allowed: <#6D9DC5>%HMCCosmetics_unlocked_kite%"
|
||||
type: cosmetic
|
||||
cosmetic: kite
|
||||
handstand:
|
||||
slots:
|
||||
- 12
|
||||
item:
|
||||
material: PAPER
|
||||
name: "<blue>Handstand Emote"
|
||||
type: cosmetic
|
||||
cosmetic: handstand
|
||||
meditate:
|
||||
slots:
|
||||
- 13
|
||||
item:
|
||||
material: PAPER
|
||||
name: "<blue>Meditate Emote"
|
||||
type: cosmetic
|
||||
cosmetic: meditate
|
||||
thinking:
|
||||
slots:
|
||||
- 14
|
||||
item:
|
||||
material: PAPER
|
||||
name: "<blue>Thinking Emote"
|
||||
type: cosmetic
|
||||
cosmetic: thinking
|
||||
# EMOTES DO NOT WORK IN RECENT HMCCOSMETICS VERSIONS.
|
||||
# handstand:
|
||||
# slots:
|
||||
# - 12
|
||||
# item:
|
||||
# material: PAPER
|
||||
# name: "<blue>Handstand Emote"
|
||||
# type: cosmetic
|
||||
# cosmetic: handstand
|
||||
# meditate:
|
||||
# slots:
|
||||
# - 13
|
||||
# item:
|
||||
# material: PAPER
|
||||
# name: "<blue>Meditate Emote"
|
||||
# type: cosmetic
|
||||
# cosmetic: meditate
|
||||
# thinking:
|
||||
# slots:
|
||||
# - 14
|
||||
# item:
|
||||
# material: PAPER
|
||||
# name: "<blue>Thinking Emote"
|
||||
# type: cosmetic
|
||||
# cosmetic: thinking
|
||||
explorer_backpack:
|
||||
slots:
|
||||
- 15
|
||||
- 12
|
||||
item:
|
||||
material: hmccosmetics:explorer_backpack
|
||||
lore:
|
||||
@@ -171,7 +172,7 @@ items:
|
||||
cosmetic: explorer_backpack
|
||||
garbage_truck_balloon:
|
||||
slots:
|
||||
- 16
|
||||
- 13
|
||||
item:
|
||||
material: hmccosmetics:garbage_truck_balloon
|
||||
lore:
|
||||
@@ -182,7 +183,7 @@ items:
|
||||
cosmetic: garbage_truck_balloon
|
||||
earth_day_grabber:
|
||||
slots:
|
||||
- 17
|
||||
- 14
|
||||
item:
|
||||
material: hmccosmetics:earth_day_grabber
|
||||
lore:
|
||||
@@ -193,7 +194,7 @@ items:
|
||||
cosmetic: earth_day_grabber
|
||||
hibiscus_flower:
|
||||
slots:
|
||||
- 18
|
||||
- 15
|
||||
item:
|
||||
material: hmccosmetics:hibiscus_flower
|
||||
lore:
|
||||
|
||||
@@ -9,6 +9,7 @@ not-enough-args: "%prefix% <red>Improper amount of arguments"
|
||||
no-permission: "%prefix% <red>No Permission!"
|
||||
no-cosmetic-permission: "%prefix% <red>You do not have permission for this cosmetic!"
|
||||
no-cosmetic-slot: "%prefix% <red>There are no cosmetics in that slot!"
|
||||
on-click-cooldown: "%prefix% <red>You are on cooldown!"
|
||||
|
||||
opened-wardrobe: "%prefix% <gradient:#6D9DC5:#45CDE9>Opened wardrobe!"
|
||||
closed-wardrobe: "%prefix% <gradient:#6D9DC5:#45CDE9>Closed wardrobe!"
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
user-cosmetic:
|
||||
offline: "Offline"
|
||||
invalid-user: "Invalid User"
|
||||
unlocked-cosmetic:
|
||||
true: "true"
|
||||
false: "false"
|
||||
@@ -10,6 +13,12 @@ in-wardrobe:
|
||||
using-cosmetic:
|
||||
true: "true"
|
||||
false: "false"
|
||||
current-cosmetic:
|
||||
hidden:
|
||||
true: "true"
|
||||
false: "false"
|
||||
current-cosmetic:
|
||||
no-cosmetic: "No Cosmetic"
|
||||
none: "none"
|
||||
amount-cosmetic:
|
||||
1: "1"
|
||||
10: "10"
|
||||
|
||||
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
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.2.1-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.12-bin.zip
|
||||
networkTimeout=10000
|
||||
validateDistributionUrl=true
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
|
||||
51
gradlew
vendored
51
gradlew
vendored
@@ -1,7 +1,7 @@
|
||||
#!/bin/sh
|
||||
|
||||
#
|
||||
# Copyright <EFBFBD> 2015-2021 the original authors.
|
||||
# Copyright © 2015-2021 the original authors.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
@@ -32,10 +32,10 @@
|
||||
# Busybox and similar reduced shells will NOT work, because this script
|
||||
# requires all of these POSIX shell features:
|
||||
# * functions;
|
||||
# * expansions <EFBFBD>$var<EFBFBD>, <EFBFBD>${var}<EFBFBD>, <EFBFBD>${var:-default}<EFBFBD>, <EFBFBD>${var+SET}<EFBFBD>,
|
||||
# <EFBFBD>${var#prefix}<EFBFBD>, <EFBFBD>${var%suffix}<EFBFBD>, and <EFBFBD>$( cmd )<EFBFBD>;
|
||||
# * compound commands having a testable exit status, especially <EFBFBD>case<EFBFBD>;
|
||||
# * various built-in commands including <EFBFBD>command<EFBFBD>, <EFBFBD>set<EFBFBD>, and <EFBFBD>ulimit<EFBFBD>.
|
||||
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
|
||||
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
|
||||
# * compound commands having a testable exit status, especially «case»;
|
||||
# * various built-in commands including «command», «set», and «ulimit».
|
||||
#
|
||||
# Important for patching:
|
||||
#
|
||||
@@ -55,7 +55,7 @@
|
||||
# Darwin, MinGW, and NonStop.
|
||||
#
|
||||
# (3) This script is generated from the Groovy template
|
||||
# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
||||
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
||||
# within the Gradle project.
|
||||
#
|
||||
# You can find Gradle at https://github.com/gradle/gradle/.
|
||||
@@ -80,13 +80,11 @@ do
|
||||
esac
|
||||
done
|
||||
|
||||
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
|
||||
|
||||
APP_NAME="Gradle"
|
||||
# This is normally unused
|
||||
# shellcheck disable=SC2034
|
||||
APP_BASE_NAME=${0##*/}
|
||||
|
||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
|
||||
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
|
||||
|
||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||
MAX_FD=maximum
|
||||
@@ -133,22 +131,29 @@ location of your Java installation."
|
||||
fi
|
||||
else
|
||||
JAVACMD=java
|
||||
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
if ! command -v java >/dev/null 2>&1
|
||||
then
|
||||
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
fi
|
||||
|
||||
# Increase the maximum file descriptors if we can.
|
||||
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
||||
case $MAX_FD in #(
|
||||
max*)
|
||||
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
|
||||
# shellcheck disable=SC2039,SC3045
|
||||
MAX_FD=$( ulimit -H -n ) ||
|
||||
warn "Could not query maximum file descriptor limit"
|
||||
esac
|
||||
case $MAX_FD in #(
|
||||
'' | soft) :;; #(
|
||||
*)
|
||||
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
|
||||
# shellcheck disable=SC2039,SC3045
|
||||
ulimit -n "$MAX_FD" ||
|
||||
warn "Could not set maximum file descriptor limit to $MAX_FD"
|
||||
esac
|
||||
@@ -193,11 +198,15 @@ if "$cygwin" || "$msys" ; then
|
||||
done
|
||||
fi
|
||||
|
||||
# Collect all arguments for the java command;
|
||||
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
|
||||
# shell script including quotes and variable substitutions, so put them in
|
||||
# double quotes to make sure that they get re-expanded; and
|
||||
# * put everything else in single quotes, so that it's not re-expanded.
|
||||
|
||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||
|
||||
# Collect all arguments for the java command:
|
||||
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
|
||||
# and any embedded shellness will be escaped.
|
||||
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
|
||||
# treated as '${Hostname}' itself on the command line.
|
||||
|
||||
set -- \
|
||||
"-Dorg.gradle.appname=$APP_BASE_NAME" \
|
||||
@@ -205,6 +214,12 @@ set -- \
|
||||
org.gradle.wrapper.GradleWrapperMain \
|
||||
"$@"
|
||||
|
||||
# Stop when "xargs" is not available.
|
||||
if ! command -v xargs >/dev/null 2>&1
|
||||
then
|
||||
die "xargs is not available"
|
||||
fi
|
||||
|
||||
# Use "xargs" to parse quoted args.
|
||||
#
|
||||
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
|
||||
|
||||
15
gradlew.bat
vendored
15
gradlew.bat
vendored
@@ -14,7 +14,7 @@
|
||||
@rem limitations under the License.
|
||||
@rem
|
||||
|
||||
@if "%DEBUG%" == "" @echo off
|
||||
@if "%DEBUG%"=="" @echo off
|
||||
@rem ##########################################################################
|
||||
@rem
|
||||
@rem Gradle startup script for Windows
|
||||
@@ -25,7 +25,8 @@
|
||||
if "%OS%"=="Windows_NT" setlocal
|
||||
|
||||
set DIRNAME=%~dp0
|
||||
if "%DIRNAME%" == "" set DIRNAME=.
|
||||
if "%DIRNAME%"=="" set DIRNAME=.
|
||||
@rem This is normally unused
|
||||
set APP_BASE_NAME=%~n0
|
||||
set APP_HOME=%DIRNAME%
|
||||
|
||||
@@ -40,7 +41,7 @@ if defined JAVA_HOME goto findJavaFromJavaHome
|
||||
|
||||
set JAVA_EXE=java.exe
|
||||
%JAVA_EXE% -version >NUL 2>&1
|
||||
if "%ERRORLEVEL%" == "0" goto execute
|
||||
if %ERRORLEVEL% equ 0 goto execute
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
@@ -75,13 +76,15 @@ set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||
|
||||
:end
|
||||
@rem End local scope for the variables with windows NT shell
|
||||
if "%ERRORLEVEL%"=="0" goto mainEnd
|
||||
if %ERRORLEVEL% equ 0 goto mainEnd
|
||||
|
||||
:fail
|
||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||
rem the _cmd.exe /c_ return code!
|
||||
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
|
||||
exit /b 1
|
||||
set EXIT_CODE=%ERRORLEVEL%
|
||||
if %EXIT_CODE% equ 0 set EXIT_CODE=1
|
||||
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
|
||||
exit /b %EXIT_CODE%
|
||||
|
||||
:mainEnd
|
||||
if "%OS%"=="Windows_NT" endlocal
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user