mirror of
https://github.com/HibiscusMC/HMCCosmetics.git
synced 2025-12-22 16:39:21 +00:00
Compare commits
185 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
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 | ||
|
|
33437cd387 | ||
|
|
9f4e4616d4 | ||
|
|
01c62bc94e | ||
|
|
3be4bdeb6f | ||
|
|
145aec9b7f | ||
|
|
4a2266bbfa | ||
|
|
7fa3cd6cb7 | ||
|
|
9c5fe9c426 | ||
|
|
0a9d750d3e | ||
|
|
da996fb146 | ||
|
|
c051b267cf | ||
|
|
d1fc84b5bc | ||
|
|
b47b9d8235 | ||
|
|
edccc844c9 | ||
|
|
5788b2cce0 | ||
|
|
627ebafb79 | ||
|
|
ef3bf3fc19 | ||
|
|
97c02883b8 | ||
|
|
ad516e80d1 | ||
|
|
317ee261db | ||
|
|
5f8fb642a4 | ||
|
|
7f4a1bc3f2 | ||
|
|
e2a727864e | ||
|
|
c0014476fd | ||
|
|
8ec6a87b94 | ||
|
|
97cf079b63 | ||
|
|
82f13c349f | ||
|
|
f91c174b20 | ||
|
|
3ae6a11626 | ||
|
|
f2fab91916 | ||
|
|
55890fa4ac | ||
|
|
fa2aa2c6dc | ||
|
|
0b5f986cfc | ||
|
|
26361b833f | ||
|
|
28a37848c8 | ||
|
|
7131a45d9c | ||
|
|
6d9325ed18 | ||
|
|
0640b33d50 | ||
|
|
8b944b8e29 | ||
|
|
4481fa1c12 | ||
|
|
de133fa288 | ||
|
|
20da7797c9 | ||
|
|
2aed727832 | ||
|
|
b6731ba21a | ||
|
|
d333527664 | ||
|
|
a82bb8183b | ||
|
|
1eaeb8ecea | ||
|
|
7a9d2f0041 | ||
|
|
6d11deb9aa | ||
|
|
f5f33f5fe7 | ||
|
|
62a1d04040 | ||
|
|
17db498e18 | ||
|
|
0c11e1b1e5 | ||
|
|
d20eb11f45 | ||
|
|
51e19d3c36 | ||
|
|
8e8d86b94c | ||
|
|
c0caea2447 | ||
|
|
33356ea81d | ||
|
|
a486b13e7e | ||
|
|
938a561d25 | ||
|
|
1c61b72624 | ||
|
|
46d82b01f0 | ||
|
|
006319a757 | ||
|
|
a8ff8e6a7a | ||
|
|
8b20207442 | ||
|
|
8bbe12ed84 | ||
|
|
d23f3e19d2 |
@@ -8,7 +8,7 @@ plugins {
|
|||||||
}
|
}
|
||||||
|
|
||||||
group = "com.hibiscusmc"
|
group = "com.hibiscusmc"
|
||||||
version = "2.5.2"
|
version = "2.7.0"
|
||||||
|
|
||||||
allprojects {
|
allprojects {
|
||||||
apply(plugin = "java")
|
apply(plugin = "java")
|
||||||
@@ -32,9 +32,6 @@ allprojects {
|
|||||||
// PlaceholderAPI
|
// PlaceholderAPI
|
||||||
maven("https://repo.extendedclip.com/content/repositories/placeholderapi/")
|
maven("https://repo.extendedclip.com/content/repositories/placeholderapi/")
|
||||||
|
|
||||||
//Hikari
|
|
||||||
maven("https://mvnrepository.com/artifact/com.zaxxer/HikariCP")
|
|
||||||
|
|
||||||
// Citizens & Denizen
|
// Citizens & Denizen
|
||||||
maven("https://maven.citizensnpcs.co/repo")
|
maven("https://maven.citizensnpcs.co/repo")
|
||||||
|
|
||||||
@@ -63,45 +60,50 @@ allprojects {
|
|||||||
|
|
||||||
// md-5 Repo
|
// md-5 Repo
|
||||||
maven("https://repo.md-5.net/content/groups/public/")
|
maven("https://repo.md-5.net/content/groups/public/")
|
||||||
|
|
||||||
|
// 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 {
|
dependencies {
|
||||||
compileOnly(fileTree("${project.rootDir}/lib") { include("*.jar") })
|
compileOnly(fileTree("${project.rootDir}/lib") { include("*.jar") })
|
||||||
compileOnly("com.mojang:authlib:1.5.25")
|
compileOnly("com.mojang:authlib:1.5.25")
|
||||||
compileOnly("org.spigotmc:spigot-api:1.18.2-R0.1-SNAPSHOT")
|
//compileOnly("org.spigotmc:spigot-api:1.18.2-R0.1-SNAPSHOT")
|
||||||
|
compileOnly("io.papermc.paper:paper-api:1.18.2-R0.1-SNAPSHOT")
|
||||||
compileOnly("org.jetbrains:annotations:23.0.0")
|
compileOnly("org.jetbrains:annotations:23.0.0")
|
||||||
compileOnly("com.comphenix.protocol:ProtocolLib:5.0.0")
|
compileOnly("com.comphenix.protocol:ProtocolLib:5.1.0")
|
||||||
compileOnly("me.clip:placeholderapi:2.11.3")
|
compileOnly("me.clip:placeholderapi:2.11.3")
|
||||||
compileOnly("com.ticxo:modelengine:R3.0.1")
|
compileOnly("com.ticxo.modelengine:ModelEngine:R4.0.2")
|
||||||
compileOnly("com.github.oraxen:oraxen:-SNAPSHOT")
|
|
||||||
compileOnly("com.github.LoneDev6:API-ItemsAdder:3.2.5")
|
|
||||||
compileOnly("com.mineinabyss:geary-papermc:0.24-SNAPSHOT")
|
|
||||||
compileOnly("com.sk89q.worldguard:worldguard-bukkit:7.1.0-SNAPSHOT")
|
compileOnly("com.sk89q.worldguard:worldguard-bukkit:7.1.0-SNAPSHOT")
|
||||||
compileOnly("it.unimi.dsi:fastutil:8.5.11")
|
compileOnly("it.unimi.dsi:fastutil:8.5.11")
|
||||||
compileOnly("com.github.LeonMangler:SuperVanish:6.2.17")
|
compileOnly("org.projectlombok:lombok:1.18.2")
|
||||||
|
compileOnly("me.lojosho:HibiscusCommons:0.2.2")
|
||||||
|
|
||||||
|
// Handled by Spigot Library Loader
|
||||||
|
compileOnly("net.kyori:adventure-api:4.15.0")
|
||||||
|
compileOnly("net.kyori:adventure-text-minimessage:4.15.0")
|
||||||
|
compileOnly("net.kyori:adventure-platform-bukkit:4.3.2")
|
||||||
|
|
||||||
|
annotationProcessor("org.projectlombok:lombok:1.18.28")
|
||||||
|
testCompileOnly("org.projectlombok:lombok:1.18.28")
|
||||||
|
testAnnotationProcessor("org.projectlombok:lombok:1.18.28")
|
||||||
|
|
||||||
|
implementation("dev.triumphteam:triumph-gui:3.1.7") {
|
||||||
|
exclude("net.kyori") // Already have adventure API
|
||||||
|
}
|
||||||
|
implementation("com.owen1212055:particlehelper:1.0.0-SNAPSHOT")
|
||||||
|
implementation("com.ticxo.playeranimator:PlayerAnimator:R1.2.7")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation(project(path = ":common"))
|
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 {
|
tasks {
|
||||||
@@ -121,28 +123,15 @@ tasks {
|
|||||||
}
|
}
|
||||||
|
|
||||||
runServer {
|
runServer {
|
||||||
minecraftVersion("1.20.1")
|
minecraftVersion("1.20.4")
|
||||||
}
|
}
|
||||||
|
|
||||||
shadowJar {
|
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()
|
mergeServiceFiles()
|
||||||
|
|
||||||
relocate("dev.triumphteam.gui", "com.hisbiscusmc.hmccosmetics.gui")
|
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.owen1212055.particlehelper", "com.hisbiscusmc.hmccosmetics.particlehelper")
|
||||||
relocate("com.ticxo.playeranimator", "com.hisbiscusmc.hmccosmetics.playeranimator")
|
relocate("com.ticxo.playeranimator", "com.hisbiscusmc.hmccosmetics.playeranimator")
|
||||||
relocate("com.bgsoftware", "com.hisbiscusmc.hmccosmetics.configupdater")
|
|
||||||
archiveFileName.set("HMCCosmeticsRemapped-${project.version}.jar")
|
archiveFileName.set("HMCCosmeticsRemapped-${project.version}.jar")
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
@@ -169,8 +158,8 @@ bukkit {
|
|||||||
main = "com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin"
|
main = "com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin"
|
||||||
apiVersion = "1.18"
|
apiVersion = "1.18"
|
||||||
authors = listOf("LoJoSho")
|
authors = listOf("LoJoSho")
|
||||||
depend = listOf("ProtocolLib")
|
depend = listOf("HibiscusCommons", "ProtocolLib")
|
||||||
softDepend = listOf("ModelEngine", "Oraxen", "ItemsAdder", "Geary", "HMCColor", "WorldGuard", "MythicMobs", "PlaceholderAPI", "SuperVanish", "PremiumVanish", "LibsDisguises", "Denizen")
|
softDepend = listOf("ModelEngine", "Oraxen", "ItemsAdder", "Geary", "HMCColor", "WorldGuard", "MythicMobs", "PlaceholderAPI", "SuperVanish", "PremiumVanish", "LibsDisguises", "Denizen", "MMOItems", "Eco")
|
||||||
version = "${project.version}"
|
version = "${project.version}"
|
||||||
loadBefore = listOf(
|
loadBefore = listOf(
|
||||||
"Cosmin" // Fixes an issue with Cosmin loading before and taking /cosmetic, when messing with what we do.
|
"Cosmin" // Fixes an issue with Cosmin loading before and taking /cosmetic, when messing with what we do.
|
||||||
@@ -179,6 +168,7 @@ bukkit {
|
|||||||
commands {
|
commands {
|
||||||
register("cosmetic") {
|
register("cosmetic") {
|
||||||
description = "Base Cosmetic Command"
|
description = "Base Cosmetic Command"
|
||||||
|
aliases = listOf("hmccosmetics", "cosmetics")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
permissions {
|
permissions {
|
||||||
|
|||||||
@@ -3,40 +3,6 @@ plugins {
|
|||||||
id("maven-publish")
|
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:-SNAPSHOT")
|
|
||||||
compileOnly("com.github.LoneDev6:API-ItemsAdder:3.2.5")
|
|
||||||
compileOnly("com.mineinabyss:geary-papermc:0.24-SNAPSHOT")
|
|
||||||
compileOnly("com.hibiscus:hmccolor:0.3-SNAPSHOT")
|
|
||||||
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")
|
|
||||||
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 {
|
java {
|
||||||
toolchain.languageVersion.set(JavaLanguageVersion.of(17
|
toolchain.languageVersion.set(JavaLanguageVersion.of(17
|
||||||
))
|
))
|
||||||
|
|||||||
@@ -1,8 +0,0 @@
|
|||||||
pluginManagement {
|
|
||||||
repositories {
|
|
||||||
gradlePluginPortal()
|
|
||||||
maven("https://repo.papermc.io/repository/maven-public/")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
rootProject.name = "HMCCosmetics"
|
|
||||||
@@ -1,91 +1,63 @@
|
|||||||
package com.hibiscusmc.hmccosmetics;
|
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.api.events.HMCCosmeticSetupEvent;
|
||||||
import com.hibiscusmc.hmccosmetics.command.CosmeticCommand;
|
import com.hibiscusmc.hmccosmetics.command.CosmeticCommand;
|
||||||
import com.hibiscusmc.hmccosmetics.command.CosmeticCommandTabComplete;
|
import com.hibiscusmc.hmccosmetics.command.CosmeticCommandTabComplete;
|
||||||
import com.hibiscusmc.hmccosmetics.config.DatabaseSettings;
|
import com.hibiscusmc.hmccosmetics.config.DatabaseSettings;
|
||||||
import com.hibiscusmc.hmccosmetics.config.Settings;
|
import com.hibiscusmc.hmccosmetics.config.Settings;
|
||||||
import com.hibiscusmc.hmccosmetics.config.WardrobeSettings;
|
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.Cosmetic;
|
||||||
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetics;
|
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetics;
|
||||||
import com.hibiscusmc.hmccosmetics.database.Database;
|
import com.hibiscusmc.hmccosmetics.database.Database;
|
||||||
import com.hibiscusmc.hmccosmetics.emotes.EmoteManager;
|
import com.hibiscusmc.hmccosmetics.emotes.EmoteManager;
|
||||||
import com.hibiscusmc.hmccosmetics.gui.Menu;
|
import com.hibiscusmc.hmccosmetics.gui.Menu;
|
||||||
import com.hibiscusmc.hmccosmetics.gui.Menus;
|
import com.hibiscusmc.hmccosmetics.gui.Menus;
|
||||||
import com.hibiscusmc.hmccosmetics.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.WGHook;
|
||||||
import com.hibiscusmc.hmccosmetics.hooks.worldguard.WGListener;
|
import com.hibiscusmc.hmccosmetics.hooks.worldguard.WGListener;
|
||||||
|
import com.hibiscusmc.hmccosmetics.listener.PaperPlayerGameListener;
|
||||||
import com.hibiscusmc.hmccosmetics.listener.PlayerConnectionListener;
|
import com.hibiscusmc.hmccosmetics.listener.PlayerConnectionListener;
|
||||||
import com.hibiscusmc.hmccosmetics.listener.PlayerGameListener;
|
import com.hibiscusmc.hmccosmetics.listener.PlayerGameListener;
|
||||||
import com.hibiscusmc.hmccosmetics.nms.NMSHandlers;
|
|
||||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUsers;
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUsers;
|
||||||
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||||
import com.hibiscusmc.hmccosmetics.util.TranslationUtil;
|
import com.hibiscusmc.hmccosmetics.util.TranslationUtil;
|
||||||
import com.jeff_media.updatechecker.UpdateCheckSource;
|
|
||||||
import com.jeff_media.updatechecker.UpdateChecker;
|
|
||||||
import com.ticxo.playeranimator.PlayerAnimatorImpl;
|
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.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.permissions.Permission;
|
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.io.File;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
|
|
||||||
public final class HMCCosmeticsPlugin extends JavaPlugin {
|
public final class HMCCosmeticsPlugin extends HibiscusPlugin {
|
||||||
|
|
||||||
private static HMCCosmeticsPlugin instance;
|
private static HMCCosmeticsPlugin instance;
|
||||||
private static boolean disable = false;
|
|
||||||
private static YamlConfigurationLoader configLoader;
|
private static YamlConfigurationLoader configLoader;
|
||||||
private static final int pluginId = 13873;
|
|
||||||
private static boolean onLatestVersion = true;
|
public HMCCosmeticsPlugin() {
|
||||||
private static String latestVersion = "";
|
super(13873, 1879);
|
||||||
|
new HookHMCCosmetics();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onEnable() {
|
public void onStart() {
|
||||||
// Plugin startup logic
|
// Plugin startup logic
|
||||||
instance = this;
|
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
|
// File setup
|
||||||
saveDefaultConfig();
|
saveDefaultConfig();
|
||||||
if (!Path.of(getDataFolder().getPath(), "messages.yml").toFile().exists()) saveResource("messages.yml", false);
|
if (!Path.of(getDataFolder().getPath(), "messages.yml").toFile().exists()) saveResource("messages.yml", false);
|
||||||
@@ -98,7 +70,7 @@ public final class HMCCosmeticsPlugin extends JavaPlugin {
|
|||||||
if (!emoteFile.exists()) emoteFile.mkdir();
|
if (!emoteFile.exists()) emoteFile.mkdir();
|
||||||
|
|
||||||
// Player Animator
|
// Player Animator
|
||||||
PlayerAnimatorImpl.initialize(this);
|
if (!HMCCosmeticsAPI.getNMSVersion().contains("v1_20_R2") && !HMCCosmeticsAPI.getNMSVersion().contains("v1_20_R3")) PlayerAnimatorImpl.initialize(this); // PlayerAnimator does not support 1.20.2 yet
|
||||||
|
|
||||||
// Configuration Sync
|
// Configuration Sync
|
||||||
final File configFile = Path.of(getInstance().getDataFolder().getPath(), "config.yml").toFile();
|
final File configFile = Path.of(getInstance().getDataFolder().getPath(), "config.yml").toFile();
|
||||||
@@ -106,13 +78,16 @@ public final class HMCCosmeticsPlugin extends JavaPlugin {
|
|||||||
final File translationFile = Path.of(getInstance().getDataFolder().getPath(), "translations.yml").toFile();
|
final File translationFile = Path.of(getInstance().getDataFolder().getPath(), "translations.yml").toFile();
|
||||||
try {
|
try {
|
||||||
CommentedConfiguration.loadConfiguration(configFile).syncWithConfig(configFile, getInstance().getResource("config.yml"),
|
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(messageFile).syncWithConfig(messageFile, getInstance().getResource("messages.yml"));
|
||||||
CommentedConfiguration.loadConfiguration(translationFile).syncWithConfig(translationFile, getInstance().getResource("translations.yml"));
|
CommentedConfiguration.loadConfiguration(translationFile).syncWithConfig(translationFile, getInstance().getResource("translations.yml"));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Move this over to Hibiscus Commons later
|
||||||
|
if (Bukkit.getPluginManager().getPlugin("PlaceholderAPI") != null) new HMCPlaceholderExpansion().register();
|
||||||
|
|
||||||
// Setup
|
// Setup
|
||||||
setup();
|
setup();
|
||||||
|
|
||||||
@@ -123,12 +98,15 @@ public final class HMCCosmeticsPlugin extends JavaPlugin {
|
|||||||
// Listener
|
// Listener
|
||||||
getServer().getPluginManager().registerEvents(new PlayerConnectionListener(), this);
|
getServer().getPluginManager().registerEvents(new PlayerConnectionListener(), this);
|
||||||
getServer().getPluginManager().registerEvents(new PlayerGameListener(), this);
|
getServer().getPluginManager().registerEvents(new PlayerGameListener(), this);
|
||||||
|
// Taken from PaperLib
|
||||||
|
if (HibiscusCommonsPlugin.isOnPaper()) {
|
||||||
|
getServer().getPluginManager().registerEvents(new PaperPlayerGameListener(), this);
|
||||||
|
}
|
||||||
// Database
|
// Database
|
||||||
new Database();
|
new Database();
|
||||||
|
|
||||||
// WorldGuard
|
// WorldGuard
|
||||||
if (Bukkit.getPluginManager().getPlugin("WorldGuard") != null && Settings.isWorldGuardMoveCheckEnabled()) {
|
if (Bukkit.getPluginManager().getPlugin("WorldGuard") != null && Settings.isWorldGuardMoveCheck()) {
|
||||||
getServer().getPluginManager().registerEvents(new WGListener(), this);
|
getServer().getPluginManager().registerEvents(new WGListener(), this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -142,15 +120,17 @@ public final class HMCCosmeticsPlugin extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDisable() {
|
public void onEnd() {
|
||||||
// Plugin shutdown logic
|
// Plugin shutdown logic
|
||||||
disable = true;
|
|
||||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||||
CosmeticUser user = CosmeticUsers.getUser(player);
|
CosmeticUser user = CosmeticUsers.getUser(player);
|
||||||
if (user == null) continue;
|
if (user == null) continue;
|
||||||
if (user.getUserEmoteManager().isPlayingEmote()) {
|
if (user.getUserEmoteManager().isPlayingEmote()) {
|
||||||
player.setInvisible(false);
|
player.setInvisible(false);
|
||||||
}
|
}
|
||||||
|
if (user.isInWardrobe()) {
|
||||||
|
user.leaveWardrobe(true);
|
||||||
|
}
|
||||||
Database.save(user);
|
Database.save(user);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -214,9 +194,6 @@ public final class HMCCosmeticsPlugin extends JavaPlugin {
|
|||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Misc Hooks setup (like items)
|
|
||||||
Hooks.setup();
|
|
||||||
|
|
||||||
// Cosmetics setup
|
// Cosmetics setup
|
||||||
Cosmetics.setup();
|
Cosmetics.setup();
|
||||||
|
|
||||||
@@ -252,7 +229,7 @@ public final class HMCCosmeticsPlugin extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
EmoteManager.loadEmotes();
|
if (Settings.isEmotesEnabled() && !HMCCosmeticsAPI.getNMSVersion().contains("v1_20_R2") && !HMCCosmeticsAPI.getNMSVersion().contains("v1_20_R3")) EmoteManager.loadEmotes(); // PlayerAnimator does not support 1.20.2 yet
|
||||||
|
|
||||||
getInstance().getLogger().info("Successfully Enabled HMCCosmetics");
|
getInstance().getLogger().info("Successfully Enabled HMCCosmetics");
|
||||||
getInstance().getLogger().info(Cosmetics.values().size() + " Cosmetics Successfully Setup");
|
getInstance().getLogger().info(Cosmetics.values().size() + " Cosmetics Successfully Setup");
|
||||||
@@ -262,28 +239,4 @@ public final class HMCCosmeticsPlugin extends JavaPlugin {
|
|||||||
|
|
||||||
Bukkit.getPluginManager().callEvent(new HMCCosmeticSetupEvent());
|
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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package com.hibiscusmc.hmccosmetics.api;
|
package com.hibiscusmc.hmccosmetics.api;
|
||||||
|
|
||||||
|
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
|
||||||
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
|
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
|
||||||
import com.hibiscusmc.hmccosmetics.cosmetic.CosmeticSlot;
|
import com.hibiscusmc.hmccosmetics.cosmetic.CosmeticSlot;
|
||||||
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetics;
|
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetics;
|
||||||
@@ -7,6 +8,7 @@ import com.hibiscusmc.hmccosmetics.gui.Menu;
|
|||||||
import com.hibiscusmc.hmccosmetics.gui.Menus;
|
import com.hibiscusmc.hmccosmetics.gui.Menus;
|
||||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUsers;
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUsers;
|
||||||
|
import me.lojosho.hibiscuscommons.nms.NMSHandlers;
|
||||||
import org.bukkit.Color;
|
import org.bukkit.Color;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
@@ -94,4 +96,22 @@ public class HMCCosmeticsAPI {
|
|||||||
public static List<CosmeticUser> getAllCosmeticUsers() {
|
public static List<CosmeticUser> getAllCosmeticUsers() {
|
||||||
return List.copyOf(CosmeticUsers.values());
|
return List.copyOf(CosmeticUsers.values());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This returns the NMS version of the server as recognized by HMCCosmetics. This will be null until HMCC setup has been completed.
|
||||||
|
* @return The NMS version of the server in String format
|
||||||
|
*/
|
||||||
|
@Nullable
|
||||||
|
public static String getNMSVersion() {
|
||||||
|
return NMSHandlers.getVersion();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This returns the HMCCosmetics version.
|
||||||
|
* @return The HMCCosmetics version in String format
|
||||||
|
*/
|
||||||
|
@NotNull
|
||||||
|
public static String getHMCCVersion() {
|
||||||
|
return HMCCosmeticsPlugin.getInstance().getDescription().getVersion();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,8 @@ package com.hibiscusmc.hmccosmetics.api.events;
|
|||||||
|
|
||||||
import com.hibiscusmc.hmccosmetics.config.Wardrobe;
|
import com.hibiscusmc.hmccosmetics.config.Wardrobe;
|
||||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
import org.bukkit.event.Cancellable;
|
import org.bukkit.event.Cancellable;
|
||||||
import org.bukkit.event.HandlerList;
|
import org.bukkit.event.HandlerList;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
@@ -12,6 +14,7 @@ import org.jetbrains.annotations.NotNull;
|
|||||||
public class PlayerWardrobeEnterEvent extends PlayerCosmeticEvent implements Cancellable {
|
public class PlayerWardrobeEnterEvent extends PlayerCosmeticEvent implements Cancellable {
|
||||||
private static final HandlerList handlers = new HandlerList();
|
private static final HandlerList handlers = new HandlerList();
|
||||||
private boolean cancel = false;
|
private boolean cancel = false;
|
||||||
|
@Getter @Setter
|
||||||
private Wardrobe wardrobe;
|
private Wardrobe wardrobe;
|
||||||
|
|
||||||
public PlayerWardrobeEnterEvent(@NotNull CosmeticUser who, @NotNull Wardrobe wardrobe) {
|
public PlayerWardrobeEnterEvent(@NotNull CosmeticUser who, @NotNull Wardrobe wardrobe) {
|
||||||
@@ -48,12 +51,4 @@ public class PlayerWardrobeEnterEvent extends PlayerCosmeticEvent implements Can
|
|||||||
public static HandlerList getHandlerList() {
|
public static HandlerList getHandlerList() {
|
||||||
return handlers;
|
return handlers;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setWardrobe(Wardrobe wardrobe) {
|
|
||||||
this.wardrobe = wardrobe;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Wardrobe getWardrobe() {
|
|
||||||
return wardrobe;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
package com.hibiscusmc.hmccosmetics.command;
|
package com.hibiscusmc.hmccosmetics.command;
|
||||||
|
|
||||||
|
import com.hibiscusmc.hmccolor.HMCColorConfig;
|
||||||
|
import com.hibiscusmc.hmccolor.HMCColorContextKt;
|
||||||
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
|
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
|
||||||
import com.hibiscusmc.hmccosmetics.config.Settings;
|
import com.hibiscusmc.hmccosmetics.config.Settings;
|
||||||
import com.hibiscusmc.hmccosmetics.config.Wardrobe;
|
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.CosmeticUser;
|
||||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUsers;
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUsers;
|
||||||
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||||
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.Placeholder;
|
||||||
import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver;
|
import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver;
|
||||||
import org.apache.commons.lang3.EnumUtils;
|
import org.apache.commons.lang3.EnumUtils;
|
||||||
@@ -104,7 +107,20 @@ public class CosmeticCommand implements CommandExecutor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (sender.hasPermission("hmccosmetics.cmd.apply.color")) {
|
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) {
|
||||||
|
String hmccolor = colors.getBaseColor().getColor();
|
||||||
|
if (hmccolor.contains("#")) color = HMCCServerUtils.hex2Rgb(hmccolor);
|
||||||
|
else color = HMCCServerUtils.rgbToRgb(hmccolor);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
color = HMCCServerUtils.hex2Rgb(textColor);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args.length == 1) {
|
if (args.length == 1) {
|
||||||
@@ -262,7 +278,6 @@ public class CosmeticCommand implements CommandExecutor {
|
|||||||
case ("dataclear") -> {
|
case ("dataclear") -> {
|
||||||
if (args.length == 1) return true;
|
if (args.length == 1) return true;
|
||||||
OfflinePlayer selectedPlayer = Bukkit.getOfflinePlayer(args[1]);
|
OfflinePlayer selectedPlayer = Bukkit.getOfflinePlayer(args[1]);
|
||||||
if (selectedPlayer == null) return true;
|
|
||||||
if (!sender.hasPermission("hmccosmetics.cmd.dataclear") && !sender.isOp()) {
|
if (!sender.hasPermission("hmccosmetics.cmd.dataclear") && !sender.isOp()) {
|
||||||
if (!silent) MessagesUtil.sendMessage(sender, "no-permission");
|
if (!silent) MessagesUtil.sendMessage(sender, "no-permission");
|
||||||
return true;
|
return true;
|
||||||
@@ -297,7 +312,7 @@ public class CosmeticCommand implements CommandExecutor {
|
|||||||
if (!silent) MessagesUtil.sendMessage(player, "invalid-color");
|
if (!silent) MessagesUtil.sendMessage(player, "invalid-color");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
Color color = ServerUtils.hex2Rgb(args[2]);
|
Color color = HMCCServerUtils.hex2Rgb(args[2]);
|
||||||
if (color == null) {
|
if (color == null) {
|
||||||
if (!silent) MessagesUtil.sendMessage(player, "invalid-color");
|
if (!silent) MessagesUtil.sendMessage(player, "invalid-color");
|
||||||
return true;
|
return true;
|
||||||
@@ -334,7 +349,7 @@ public class CosmeticCommand implements CommandExecutor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (args[2].equalsIgnoreCase("viewerlocation")) {
|
if (args[2].equalsIgnoreCase("viewerlocation")) {
|
||||||
WardrobeSettings.setViewerLocation(wardrobe, player.getLocation());
|
WardrobeSettings.setViewerLocation(wardrobe, player.getEyeLocation());
|
||||||
if (!silent) MessagesUtil.sendMessage(player, "set-wardrobe-viewing");
|
if (!silent) MessagesUtil.sendMessage(player, "set-wardrobe-viewing");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -352,7 +367,7 @@ public class CosmeticCommand implements CommandExecutor {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (args[2].equalsIgnoreCase("distance")) {
|
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");
|
if (!silent) MessagesUtil.sendMessage(player, "set-wardrobe-distance");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -368,7 +383,7 @@ public class CosmeticCommand implements CommandExecutor {
|
|||||||
}
|
}
|
||||||
player.sendMessage("Passengers -> " + player.getPassengers());
|
player.sendMessage("Passengers -> " + player.getPassengers());
|
||||||
if (user.hasCosmeticInSlot(CosmeticSlot.BACKPACK)) {
|
if (user.hasCosmeticInSlot(CosmeticSlot.BACKPACK)) {
|
||||||
player.sendMessage("Backpack Location -> " + user.getUserBackpackManager().getArmorStand().getLocation());
|
player.sendMessage("Backpack Location -> " + user.getUserBackpackManager().getEntityManager().getLocation());
|
||||||
}
|
}
|
||||||
player.sendMessage("Cosmetics -> " + user.getCosmetics());
|
player.sendMessage("Cosmetics -> " + user.getCosmetics());
|
||||||
player.sendMessage("EntityId -> " + player.getEntityId());
|
player.sendMessage("EntityId -> " + player.getEntityId());
|
||||||
@@ -423,7 +438,7 @@ public class CosmeticCommand implements CommandExecutor {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Settings.getDebugMode()) {
|
if (Settings.isDebugMode()) {
|
||||||
Settings.setDebugMode(false);
|
Settings.setDebugMode(false);
|
||||||
if (!silent) MessagesUtil.sendMessage(sender, "debug-disabled");
|
if (!silent) MessagesUtil.sendMessage(sender, "debug-disabled");
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package com.hibiscusmc.hmccosmetics.command;
|
package com.hibiscusmc.hmccosmetics.command;
|
||||||
|
|
||||||
|
import com.hibiscusmc.hmccolor.HMCColorContextKt;
|
||||||
import com.hibiscusmc.hmccosmetics.config.Wardrobe;
|
import com.hibiscusmc.hmccosmetics.config.Wardrobe;
|
||||||
import com.hibiscusmc.hmccosmetics.config.WardrobeSettings;
|
import com.hibiscusmc.hmccosmetics.config.WardrobeSettings;
|
||||||
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
|
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.gui.Menus;
|
||||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUsers;
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUsers;
|
||||||
|
import me.lojosho.hibiscuscommons.hooks.Hooks;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
@@ -122,6 +124,7 @@ public class CosmeticCommandTabComplete implements TabCompleter {
|
|||||||
String subcommand = args[0].toLowerCase();
|
String subcommand = args[0].toLowerCase();
|
||||||
switch (subcommand) {
|
switch (subcommand) {
|
||||||
case "apply" -> {
|
case "apply" -> {
|
||||||
|
if (Hooks.isActiveHook("HMCColor")) completions.addAll(HMCColorContextKt.getHmcColor().getConfig().getColors().keySet());
|
||||||
completions.add("#FFFFFF");
|
completions.add("#FFFFFF");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
package com.hibiscusmc.hmccosmetics.config;
|
package com.hibiscusmc.hmccosmetics.config;
|
||||||
|
|
||||||
import org.spongepowered.configurate.ConfigurationNode;
|
import lombok.Getter;
|
||||||
|
import me.lojosho.shaded.configurate.ConfigurationNode;
|
||||||
|
|
||||||
public class DatabaseSettings {
|
public class DatabaseSettings {
|
||||||
|
|
||||||
//private static final String DATABASE_SETTINGS_PATH = "cosmetic-settings";
|
|
||||||
private static final String DATABASE_TYPE_PATH = "type";
|
private static final String DATABASE_TYPE_PATH = "type";
|
||||||
private static final String MYSQL_DATABASE_SETTINGS = "mysql";
|
private static final String MYSQL_DATABASE_SETTINGS = "mysql";
|
||||||
|
|
||||||
@@ -17,18 +17,24 @@ public class DatabaseSettings {
|
|||||||
private static final String ENABLE_DELAY = "enabled";
|
private static final String ENABLE_DELAY = "enabled";
|
||||||
private static final String DELAY_LENGTH = "delay";
|
private static final String DELAY_LENGTH = "delay";
|
||||||
|
|
||||||
|
@Getter
|
||||||
private static String databaseType;
|
private static String databaseType;
|
||||||
|
@Getter
|
||||||
private static String database;
|
private static String database;
|
||||||
|
@Getter
|
||||||
private static String password;
|
private static String password;
|
||||||
|
@Getter
|
||||||
private static String host;
|
private static String host;
|
||||||
|
@Getter
|
||||||
private static String username;
|
private static String username;
|
||||||
|
@Getter
|
||||||
private static int port;
|
private static int port;
|
||||||
|
@Getter
|
||||||
private static boolean enabledDelay;
|
private static boolean enabledDelay;
|
||||||
|
@Getter
|
||||||
private static int delayLength;
|
private static int delayLength;
|
||||||
|
|
||||||
public static void load(ConfigurationNode source) {
|
public static void load(ConfigurationNode source) {
|
||||||
//ConfigurationNode databaseSettings = source.node(DATABASE_SETTINGS_PATH);
|
|
||||||
|
|
||||||
databaseType = source.node(DATABASE_TYPE_PATH).getString();
|
databaseType = source.node(DATABASE_TYPE_PATH).getString();
|
||||||
|
|
||||||
ConfigurationNode mySql = source.node(MYSQL_DATABASE_SETTINGS);
|
ConfigurationNode mySql = source.node(MYSQL_DATABASE_SETTINGS);
|
||||||
@@ -44,36 +50,4 @@ public class DatabaseSettings {
|
|||||||
enabledDelay = delay.node(ENABLE_DELAY).getBoolean(false);
|
enabledDelay = delay.node(ENABLE_DELAY).getBoolean(false);
|
||||||
delayLength = delay.node(DELAY_LENGTH).getInt(2);
|
delayLength = delay.node(DELAY_LENGTH).getInt(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getDatabaseType() {
|
|
||||||
return databaseType;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String getDatabase() {
|
|
||||||
return database;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String getPassword() {
|
|
||||||
return password;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String getHost() {
|
|
||||||
return host;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String getUsername() {
|
|
||||||
return username;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static int getPort() {
|
|
||||||
return port;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean isEnabledDelay() {
|
|
||||||
return enabledDelay;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static int getDelayLength() {
|
|
||||||
return delayLength;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,12 +1,14 @@
|
|||||||
package com.hibiscusmc.hmccosmetics.config;
|
package com.hibiscusmc.hmccosmetics.config;
|
||||||
|
|
||||||
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
|
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
|
||||||
import com.hibiscusmc.hmccosmetics.cosmetic.CosmeticSlot;
|
|
||||||
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||||
|
import lombok.Getter;
|
||||||
|
import me.lojosho.shaded.configurate.ConfigurationNode;
|
||||||
import org.bukkit.inventory.EquipmentSlot;
|
import org.bukkit.inventory.EquipmentSlot;
|
||||||
import org.bukkit.util.Vector;
|
import org.bukkit.util.Vector;
|
||||||
import org.spongepowered.configurate.ConfigurationNode;
|
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
public class Settings {
|
public class Settings {
|
||||||
@@ -15,11 +17,6 @@ public class Settings {
|
|||||||
private static final String DEFAULT_MENU = "default-menu";
|
private static final String DEFAULT_MENU = "default-menu";
|
||||||
private static final String CONFIG_VERSION = "config-version";
|
private static final String CONFIG_VERSION = "config-version";
|
||||||
private static final String COSMETIC_SETTINGS_PATH = "cosmetic-settings";
|
private static final String COSMETIC_SETTINGS_PATH = "cosmetic-settings";
|
||||||
private static final String REQUIRE_EMPTY_HELMET_PATH = "require-empty-helmet";
|
|
||||||
private static final String REQUIRE_EMPTY_OFF_HAND_PATH = "require-empty-off-hand";
|
|
||||||
private static final String REQUIRE_EMPTY_CHEST_PLATE_PATH = "require-empty-chest-plate";
|
|
||||||
private static final String REQUIRE_EMPTY_PANTS_PATH = "require-empty-pants";
|
|
||||||
private static final String REQUIRE_EMPTY_BOOTS_PATH = "require-empty-boots";
|
|
||||||
private static final String BALLOON_OFFSET = "balloon-offset";
|
private static final String BALLOON_OFFSET = "balloon-offset";
|
||||||
private static final String VIEW_DISTANCE_PATH = "view-distance";
|
private static final String VIEW_DISTANCE_PATH = "view-distance";
|
||||||
private static final String DYE_MENU_PATH = "dye-menu";
|
private static final String DYE_MENU_PATH = "dye-menu";
|
||||||
@@ -31,6 +28,8 @@ public class Settings {
|
|||||||
private static final String UNAPPLY_DEATH_PATH = "unapply-on-death";
|
private static final String UNAPPLY_DEATH_PATH = "unapply-on-death";
|
||||||
private static final String FORCE_PERMISSION_JOIN_PATH = "force-permission-join";
|
private static final String FORCE_PERMISSION_JOIN_PATH = "force-permission-join";
|
||||||
private static final String FORCE_SHOW_COSMETICS_PATH = "force-show-join";
|
private static final String FORCE_SHOW_COSMETICS_PATH = "force-show-join";
|
||||||
|
private static final String 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 EMOTE_DISTANCE_PATH = "emote-distance";
|
||||||
private static final String HOOK_SETTING_PATH = "hook-settings";
|
private static final String HOOK_SETTING_PATH = "hook-settings";
|
||||||
private static final String HOOK_ITEMADDER_PATH = "itemsadder";
|
private static final String HOOK_ITEMADDER_PATH = "itemsadder";
|
||||||
@@ -38,10 +37,17 @@ public class Settings {
|
|||||||
private static final String HOOK_WORLDGUARD_PATH = "worldguard";
|
private static final String HOOK_WORLDGUARD_PATH = "worldguard";
|
||||||
private static final String HOOK_WG_MOVE_CHECK_PATH = "player-move-check";
|
private static final String HOOK_WG_MOVE_CHECK_PATH = "player-move-check";
|
||||||
private static final String HOOK_WG_MOVE_CHECK_PATH_LEGACY = "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_CHECK_PATH = "emote-block-check";
|
||||||
private static final String COSMETIC_EMOTE_AIR_CHECK_PATH = "emote-air-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_DAMAGE_PATH = "emote-damage-leave";
|
||||||
private static final String COSMETIC_EMOTE_INVINCIBLE_PATH = "emote-invincible";
|
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_FORCE_OFFHAND_COSMETIC_SHOW_PATH = "offhand-always-show";
|
||||||
private static final String COSMETIC_ADD_ENCHANTS_HELMET_PATH = "helmet-add-enchantments";
|
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_CHESTPLATE_PATH = "chest-add-enchantments";
|
||||||
private static final String COSMETIC_ADD_ENCHANTS_LEGGINGS_PATH = "leggings-add-enchantments";
|
private static final String COSMETIC_ADD_ENCHANTS_LEGGINGS_PATH = "leggings-add-enchantments";
|
||||||
@@ -51,38 +57,106 @@ public class Settings {
|
|||||||
private static final String COSMETIC_TYPE_SETTINGS_PATH = "cosmetic-type";
|
private static final String COSMETIC_TYPE_SETTINGS_PATH = "cosmetic-type";
|
||||||
private static final String EQUIP_CLICK_TYPE = "equip-click";
|
private static final String EQUIP_CLICK_TYPE = "equip-click";
|
||||||
private static final String UNEQUIP_CLICK_TYPE = "unequip-click";
|
private static final String UNEQUIP_CLICK_TYPE = "unequip-click";
|
||||||
|
private static final String SHADING_PATH = "shading";
|
||||||
|
private static final String FIRST_ROW_SHIFT_PATH = "first-row-shift";
|
||||||
|
private static final String SEQUENT_ROW_SHIFT_PATH = "sequent-row-shift";
|
||||||
|
private static final String INDIVIDUAL_COLUMN_SHIFT_PATH = "individual-column-shift";
|
||||||
|
private static final String BACKGROUND_PATH = "background";
|
||||||
|
private static final String CLEAR_BACKGROUND_PATH = "clear-background";
|
||||||
|
private static final String EQUIPPED_COSMETIC_COLOR_PATH = "equipped-cosmetic-color";
|
||||||
|
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";
|
||||||
|
|
||||||
|
@Getter
|
||||||
private static String defaultMenu;
|
private static String defaultMenu;
|
||||||
|
@Getter
|
||||||
private static String dyeMenuName;
|
private static String dyeMenuName;
|
||||||
|
@Getter
|
||||||
private static int dyeMenuInputSlot;
|
private static int dyeMenuInputSlot;
|
||||||
|
@Getter
|
||||||
private static int dyeMenuOutputSlot;
|
private static int dyeMenuOutputSlot;
|
||||||
|
@Getter
|
||||||
private static int configVersion;
|
private static int configVersion;
|
||||||
private static boolean requireEmptyHelmet;
|
@Getter
|
||||||
private static boolean requireEmptyOffHand;
|
|
||||||
private static boolean requireEmptyChestPlate;
|
|
||||||
private static boolean requireEmptyPants;
|
|
||||||
private static boolean requireEmptyBoots;
|
|
||||||
private static boolean debugMode;
|
private static boolean debugMode;
|
||||||
|
@Getter
|
||||||
private static boolean unapplyOnDeath;
|
private static boolean unapplyOnDeath;
|
||||||
|
@Getter
|
||||||
private static boolean forcePermissionJoin;
|
private static boolean forcePermissionJoin;
|
||||||
|
@Getter
|
||||||
private static boolean forceShowOnJoin;
|
private static boolean forceShowOnJoin;
|
||||||
|
@Getter
|
||||||
private static boolean itemsAdderChangeReload;
|
private static boolean itemsAdderChangeReload;
|
||||||
|
@Getter
|
||||||
private static boolean worldGuardMoveCheck;
|
private static boolean worldGuardMoveCheck;
|
||||||
|
@Getter
|
||||||
private static boolean cosmeticEmoteBlockCheck;
|
private static boolean cosmeticEmoteBlockCheck;
|
||||||
|
@Getter
|
||||||
private static boolean addHelmetEnchants;
|
private static boolean addHelmetEnchants;
|
||||||
|
@Getter
|
||||||
private static boolean addChestplateEnchants;
|
private static boolean addChestplateEnchants;
|
||||||
|
@Getter
|
||||||
private static boolean addLeggingEnchants;
|
private static boolean addLeggingEnchants;
|
||||||
|
@Getter
|
||||||
private static boolean addBootsEnchants;
|
private static boolean addBootsEnchants;
|
||||||
|
@Getter
|
||||||
private static boolean emoteAirCheck;
|
private static boolean emoteAirCheck;
|
||||||
|
@Getter
|
||||||
private static boolean emoteDamageLeave;
|
private static boolean emoteDamageLeave;
|
||||||
|
@Getter
|
||||||
private static boolean emoteInvincible;
|
private static boolean emoteInvincible;
|
||||||
|
@Getter
|
||||||
private static boolean destroyLooseCosmetics;
|
private static boolean destroyLooseCosmetics;
|
||||||
|
@Getter
|
||||||
|
private static boolean backpackForceRidingEnabled;
|
||||||
|
@Getter
|
||||||
|
private static boolean cosmeticForceOffhandCosmeticShow;
|
||||||
|
@Getter
|
||||||
|
private static boolean emotesEnabled;
|
||||||
|
@Getter
|
||||||
|
private static boolean disabledGamemodesEnabled;
|
||||||
|
@Getter
|
||||||
|
private static List<String> disabledGamemodes;
|
||||||
|
@Getter
|
||||||
|
private static List<String> disabledWorlds;
|
||||||
|
@Getter
|
||||||
private static int viewDistance;
|
private static int viewDistance;
|
||||||
|
@Getter
|
||||||
private static int tickPeriod;
|
private static int tickPeriod;
|
||||||
|
@Getter
|
||||||
|
private static int packetEntityTeleportCooldown;
|
||||||
|
@Getter
|
||||||
private static double emoteDistance;
|
private static double emoteDistance;
|
||||||
|
@Getter
|
||||||
private static Vector balloonOffset;
|
private static Vector balloonOffset;
|
||||||
|
@Getter
|
||||||
private static String cosmeticEquipClickType;
|
private static String cosmeticEquipClickType;
|
||||||
|
@Getter
|
||||||
private static String cosmeticUnEquipClickType;
|
private static String cosmeticUnEquipClickType;
|
||||||
|
@Getter
|
||||||
|
private static boolean defaultShading;
|
||||||
|
@Getter
|
||||||
|
private static String firstRowShift;
|
||||||
|
@Getter
|
||||||
|
private static String sequentRowShift;
|
||||||
|
@Getter
|
||||||
|
private static String individualColumnShift;
|
||||||
|
@Getter
|
||||||
|
private static String background;
|
||||||
|
@Getter
|
||||||
|
private static String clearBackground;
|
||||||
|
@Getter
|
||||||
|
private static String equippedCosmeticColor;
|
||||||
|
@Getter
|
||||||
|
private static String equipableCosmeticColor;
|
||||||
|
@Getter
|
||||||
|
private static String lockedCosmeticColor;
|
||||||
|
@Getter
|
||||||
|
private static boolean emoteCameraEnabled;
|
||||||
|
@Getter
|
||||||
|
private static boolean emoteMoveCheck;
|
||||||
|
|
||||||
|
|
||||||
public static void load(ConfigurationNode source) {
|
public static void load(ConfigurationNode source) {
|
||||||
|
|
||||||
@@ -101,34 +175,56 @@ public class Settings {
|
|||||||
|
|
||||||
ConfigurationNode cosmeticSettings = source.node(COSMETIC_SETTINGS_PATH);
|
ConfigurationNode cosmeticSettings = source.node(COSMETIC_SETTINGS_PATH);
|
||||||
|
|
||||||
requireEmptyHelmet = cosmeticSettings.node(REQUIRE_EMPTY_HELMET_PATH).getBoolean();
|
ConfigurationNode disabledGamemodeSettings = cosmeticSettings.node(DISABLED_GAMEMODE_PATH);
|
||||||
requireEmptyOffHand = cosmeticSettings.node(REQUIRE_EMPTY_OFF_HAND_PATH).getBoolean();
|
disabledGamemodesEnabled = disabledGamemodeSettings.node(ENABLED_PATH).getBoolean(true);
|
||||||
requireEmptyChestPlate = cosmeticSettings.node(REQUIRE_EMPTY_CHEST_PLATE_PATH).getBoolean();
|
try {
|
||||||
requireEmptyPants = cosmeticSettings.node(REQUIRE_EMPTY_PANTS_PATH).getBoolean();
|
disabledGamemodes = disabledGamemodeSettings.node(DISABLED_GAMEMODE_GAMEMODES_PATH).getList(String.class);
|
||||||
requireEmptyBoots = cosmeticSettings.node(REQUIRE_EMPTY_BOOTS_PATH).getBoolean();
|
disabledWorlds = cosmeticSettings.node(COSMETIC_DISABLED_WORLDS_PATH).getList(String.class);
|
||||||
|
} catch (Exception e) {
|
||||||
|
disabledGamemodes = new ArrayList<>();
|
||||||
|
disabledWorlds = new ArrayList<>();
|
||||||
|
}
|
||||||
|
|
||||||
unapplyOnDeath = cosmeticSettings.node(UNAPPLY_DEATH_PATH).getBoolean(false);
|
unapplyOnDeath = cosmeticSettings.node(UNAPPLY_DEATH_PATH).getBoolean(false);
|
||||||
forcePermissionJoin = cosmeticSettings.node(FORCE_PERMISSION_JOIN_PATH).getBoolean(false);
|
forcePermissionJoin = cosmeticSettings.node(FORCE_PERMISSION_JOIN_PATH).getBoolean(false);
|
||||||
forceShowOnJoin = cosmeticSettings.node(FORCE_SHOW_COSMETICS_PATH).getBoolean(false);
|
forceShowOnJoin = cosmeticSettings.node(FORCE_SHOW_COSMETICS_PATH).getBoolean(false);
|
||||||
|
emotesEnabled = cosmeticSettings.node(COSMETIC_EMOTE_ENABLE).getBoolean(true);
|
||||||
emoteDistance = cosmeticSettings.node(EMOTE_DISTANCE_PATH).getDouble(-3);
|
emoteDistance = cosmeticSettings.node(EMOTE_DISTANCE_PATH).getDouble(-3);
|
||||||
cosmeticEmoteBlockCheck = cosmeticSettings.node(COSMETIC_EMOTE_CHECK_PATH).getBoolean(true);
|
cosmeticEmoteBlockCheck = cosmeticSettings.node(COSMETIC_EMOTE_CHECK_PATH).getBoolean(true);
|
||||||
emoteAirCheck = cosmeticSettings.node(COSMETIC_EMOTE_AIR_CHECK_PATH).getBoolean(true);
|
emoteAirCheck = cosmeticSettings.node(COSMETIC_EMOTE_AIR_CHECK_PATH).getBoolean(true);
|
||||||
emoteDamageLeave = cosmeticSettings.node(COSMETIC_EMOTE_DAMAGE_PATH).getBoolean(false);
|
emoteDamageLeave = cosmeticSettings.node(COSMETIC_EMOTE_DAMAGE_PATH).getBoolean(false);
|
||||||
emoteInvincible = cosmeticSettings.node(COSMETIC_EMOTE_INVINCIBLE_PATH).getBoolean(false);
|
emoteInvincible = cosmeticSettings.node(COSMETIC_EMOTE_INVINCIBLE_PATH).getBoolean(false);
|
||||||
destroyLooseCosmetics = cosmeticSettings.node(COSMETIC_DESTROY_LOOSE_COSMETIC_PATH).getBoolean(false);
|
destroyLooseCosmetics = cosmeticSettings.node(COSMETIC_DESTROY_LOOSE_COSMETIC_PATH).getBoolean(false);
|
||||||
|
backpackForceRidingEnabled = cosmeticSettings.node(COSMETIC_BACKPACK_FORCE_RIDING_PACKET_PATH).getBoolean(false);
|
||||||
addHelmetEnchants = cosmeticSettings.node(COSMETIC_ADD_ENCHANTS_HELMET_PATH).getBoolean(false);
|
addHelmetEnchants = cosmeticSettings.node(COSMETIC_ADD_ENCHANTS_HELMET_PATH).getBoolean(false);
|
||||||
addChestplateEnchants = cosmeticSettings.node(COSMETIC_ADD_ENCHANTS_CHESTPLATE_PATH).getBoolean(false);
|
addChestplateEnchants = cosmeticSettings.node(COSMETIC_ADD_ENCHANTS_CHESTPLATE_PATH).getBoolean(false);
|
||||||
addLeggingEnchants = cosmeticSettings.node(COSMETIC_ADD_ENCHANTS_LEGGINGS_PATH).getBoolean(false);
|
addLeggingEnchants = cosmeticSettings.node(COSMETIC_ADD_ENCHANTS_LEGGINGS_PATH).getBoolean(false);
|
||||||
addBootsEnchants = cosmeticSettings.node(COSMETIC_ADD_ENCHANTS_BOOTS_PATH).getBoolean(false);
|
addBootsEnchants = cosmeticSettings.node(COSMETIC_ADD_ENCHANTS_BOOTS_PATH).getBoolean(false);
|
||||||
tickPeriod = cosmeticSettings.node(TICK_PERIOD_PATH).getInt(-1);
|
tickPeriod = cosmeticSettings.node(TICK_PERIOD_PATH).getInt(-1);
|
||||||
viewDistance = cosmeticSettings.node(VIEW_DISTANCE_PATH).getInt();
|
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);
|
||||||
|
cosmeticForceOffhandCosmeticShow = cosmeticSettings.node(COSMETIC_FORCE_OFFHAND_COSMETIC_SHOW_PATH).getBoolean(false);
|
||||||
|
|
||||||
ConfigurationNode menuSettings = source.node(MENU_SETTINGS_PATH);
|
ConfigurationNode menuSettings = source.node(MENU_SETTINGS_PATH);
|
||||||
|
|
||||||
|
ConfigurationNode shadingSettings = menuSettings.node(SHADING_PATH);
|
||||||
|
defaultShading = shadingSettings.node(ENABLED_PATH).getBoolean();
|
||||||
|
firstRowShift = shadingSettings.node(FIRST_ROW_SHIFT_PATH).getString();
|
||||||
|
sequentRowShift = shadingSettings.node(SEQUENT_ROW_SHIFT_PATH).getString();
|
||||||
|
individualColumnShift = shadingSettings.node(INDIVIDUAL_COLUMN_SHIFT_PATH).getString();
|
||||||
|
background = shadingSettings.node(BACKGROUND_PATH).getString();
|
||||||
|
clearBackground = shadingSettings.node(CLEAR_BACKGROUND_PATH).getString();
|
||||||
|
equippedCosmeticColor = shadingSettings.node(EQUIPPED_COSMETIC_COLOR_PATH).getString();
|
||||||
|
equipableCosmeticColor = shadingSettings.node(EQUIPABLE_COSMETIC_COLOR_PATH).getString();
|
||||||
|
lockedCosmeticColor = shadingSettings.node(LOCKED_COSMETIC_COLOR_PATH).getString();
|
||||||
|
|
||||||
ConfigurationNode cosmeticTypeSettings = menuSettings.node(COSMETIC_TYPE_SETTINGS_PATH);
|
ConfigurationNode cosmeticTypeSettings = menuSettings.node(COSMETIC_TYPE_SETTINGS_PATH);
|
||||||
cosmeticEquipClickType = cosmeticTypeSettings.node(EQUIP_CLICK_TYPE).getString("ALL");
|
cosmeticEquipClickType = cosmeticTypeSettings.node(EQUIP_CLICK_TYPE).getString("ALL");
|
||||||
cosmeticUnEquipClickType = cosmeticTypeSettings.node(UNEQUIP_CLICK_TYPE).getString("ALL");
|
cosmeticUnEquipClickType = cosmeticTypeSettings.node(UNEQUIP_CLICK_TYPE).getString("ALL");
|
||||||
|
|
||||||
final var balloonSection = cosmeticSettings.node(BALLOON_OFFSET);
|
final var balloonSection = cosmeticSettings.node(BALLOON_OFFSET);
|
||||||
|
|
||||||
balloonOffset = loadVector(balloonSection);
|
balloonOffset = loadVector(balloonSection);
|
||||||
|
|
||||||
ConfigurationNode dyeMenuSettings = source.node(DYE_MENU_PATH);
|
ConfigurationNode dyeMenuSettings = source.node(DYE_MENU_PATH);
|
||||||
@@ -150,149 +246,10 @@ public class Settings {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Vector loadVector(final ConfigurationNode config) {
|
public static Vector loadVector(final ConfigurationNode config) {
|
||||||
return new Vector(config.node("x").getDouble(), config.node("y").getDouble(), config.node("z").getDouble());
|
return new Vector(config.node("x").getDouble(), config.node("y").getDouble(), config.node("z").getDouble());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isRequireEmptyHelmet() {
|
|
||||||
return requireEmptyHelmet;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean isRequireEmptyOffHand() {
|
|
||||||
return requireEmptyOffHand;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public static boolean isRequireEmptyChestPlate() {
|
|
||||||
return requireEmptyChestPlate;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean isRequireEmptyPants() {
|
|
||||||
return requireEmptyPants;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean isRequireEmptyBoots() {
|
|
||||||
return requireEmptyBoots;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean getRequireEmpty(CosmeticSlot slot) {
|
|
||||||
switch (slot) {
|
|
||||||
case HELMET -> {
|
|
||||||
return requireEmptyHelmet;
|
|
||||||
}
|
|
||||||
case CHESTPLATE -> {
|
|
||||||
return requireEmptyChestPlate;
|
|
||||||
}
|
|
||||||
case LEGGINGS -> {
|
|
||||||
return requireEmptyPants;
|
|
||||||
}
|
|
||||||
case BOOTS -> {
|
|
||||||
return requireEmptyBoots;
|
|
||||||
}
|
|
||||||
case OFFHAND -> {
|
|
||||||
return requireEmptyOffHand;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean getRequireEmpty(EquipmentSlot slot) {
|
|
||||||
switch (slot) {
|
|
||||||
case HEAD -> {
|
|
||||||
return requireEmptyHelmet;
|
|
||||||
}
|
|
||||||
case CHEST -> {
|
|
||||||
return requireEmptyChestPlate;
|
|
||||||
}
|
|
||||||
case LEGS -> {
|
|
||||||
return requireEmptyPants;
|
|
||||||
}
|
|
||||||
case FEET -> {
|
|
||||||
return requireEmptyBoots;
|
|
||||||
}
|
|
||||||
case OFF_HAND -> {
|
|
||||||
return requireEmptyOffHand;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Vector getBalloonOffset() {
|
|
||||||
if (balloonOffset == null) HMCCosmeticsPlugin.getInstance().getLogger().info("Shits null");
|
|
||||||
return balloonOffset;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static int getViewDistance() {
|
|
||||||
return viewDistance;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String getDefaultMenu() {
|
|
||||||
return defaultMenu;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static int getConfigVersion() {
|
|
||||||
return configVersion;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String getDyeMenuName() {
|
|
||||||
return dyeMenuName;
|
|
||||||
}
|
|
||||||
public static int getDyeMenuInputSlot() { return dyeMenuInputSlot; }
|
|
||||||
public static int getDyeMenuOutputSlot() { return dyeMenuOutputSlot; }
|
|
||||||
|
|
||||||
public static boolean isDebugEnabled() {
|
|
||||||
return debugMode;
|
|
||||||
}
|
|
||||||
public static boolean getItemsAdderReloadChange() {
|
|
||||||
return itemsAdderChangeReload;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static int getTickPeriod() {
|
|
||||||
return tickPeriod;
|
|
||||||
}
|
|
||||||
public static boolean getUnapplyOnDeath() {
|
|
||||||
return unapplyOnDeath;
|
|
||||||
}
|
|
||||||
public static boolean getForcePermissionJoin() {
|
|
||||||
return forcePermissionJoin;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean isForceShowOnJoin() {
|
|
||||||
return forceShowOnJoin;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean getDebugMode() {
|
|
||||||
return debugMode;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static double getEmoteDistance() {
|
|
||||||
return emoteDistance;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean getCosmeticEmoteBlockCheck() {
|
|
||||||
return cosmeticEmoteBlockCheck;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean getEmoteAirCheck() {
|
|
||||||
return emoteAirCheck;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean isEmoteDamageLeave() {
|
|
||||||
return emoteDamageLeave;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean isEmoteInvincible() {
|
|
||||||
return emoteInvincible;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean isWorldGuardMoveCheckEnabled() {
|
|
||||||
return worldGuardMoveCheck;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean isDestroyLooseCosmetics() {
|
|
||||||
return destroyLooseCosmetics;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean getShouldAddEnchants(EquipmentSlot slot) {
|
public static boolean getShouldAddEnchants(EquipmentSlot slot) {
|
||||||
switch (slot) {
|
switch (slot) {
|
||||||
case HEAD -> {
|
case HEAD -> {
|
||||||
@@ -322,12 +279,4 @@ public class Settings {
|
|||||||
|
|
||||||
plugin.saveConfig();
|
plugin.saveConfig();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getCosmeticEquipClickType() {
|
|
||||||
return cosmeticEquipClickType;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String getCosmeticUnEquipClickType() {
|
|
||||||
return cosmeticUnEquipClickType;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,56 +1,52 @@
|
|||||||
package com.hibiscusmc.hmccosmetics.config;
|
package com.hibiscusmc.hmccosmetics.config;
|
||||||
|
|
||||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
public class Wardrobe {
|
public class Wardrobe {
|
||||||
|
|
||||||
private String id;
|
@Getter
|
||||||
private int distance = WardrobeSettings.getDefaultDistance();
|
private final String id;
|
||||||
|
@Getter @Setter
|
||||||
|
private int distance;
|
||||||
|
@Getter @Setter
|
||||||
private String permission;
|
private String permission;
|
||||||
|
@Getter @Setter
|
||||||
private WardrobeLocation location;
|
private WardrobeLocation location;
|
||||||
|
|
||||||
public Wardrobe(String id, WardrobeLocation location, @Nullable String permission, int distance) {
|
/**
|
||||||
|
* This creates a Wardrobe object with all the information that a user will need when entering.
|
||||||
|
* @param id The id of the 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
|
||||||
|
*/
|
||||||
|
public Wardrobe(@NotNull String id, @NotNull WardrobeLocation location, @Nullable String permission, int distance) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.location = location;
|
this.location = location;
|
||||||
if (permission != null) this.permission = permission;
|
|
||||||
if (distance != -1) this.distance = distance;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getId() {
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public WardrobeLocation getLocation() {
|
|
||||||
return location;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setDistance(int distance) {
|
|
||||||
this.distance = distance;
|
this.distance = distance;
|
||||||
|
if (permission != null) this.permission = permission;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPermission(String permission) {
|
/**
|
||||||
this.permission = permission;
|
* This checks if the wardrobe has a permission. If it's null, no permission is required and will return false. If it's not null, it will return true.
|
||||||
}
|
* @return if the wardrobe has a permission
|
||||||
|
*/
|
||||||
public boolean hasPermission() {
|
public boolean hasPermission() {
|
||||||
return permission != null;
|
return permission != null;
|
||||||
}
|
}
|
||||||
public int getDistance() {
|
|
||||||
return distance;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getPermission() {
|
/**
|
||||||
return permission;
|
* Calculates if a player can enter a wardrobe. Will return true if the player can enter, else false.
|
||||||
}
|
* @param user The user that is trying to enter the wardrobe
|
||||||
|
* @return if the player can enter the wardrobe
|
||||||
public void setLocation(WardrobeLocation location) {
|
*/
|
||||||
this.location = location;
|
public boolean canEnter(@NotNull CosmeticUser user) {
|
||||||
}
|
|
||||||
|
|
||||||
public boolean canEnter(CosmeticUser user) {
|
|
||||||
Location wardrobeLocation = location.getNpcLocation();
|
Location wardrobeLocation = location.getNpcLocation();
|
||||||
Location location = user.getEntity().getLocation();
|
Location location = user.getEntity().getLocation();
|
||||||
if (wardrobeLocation == null) return false;
|
if (wardrobeLocation == null) return false;
|
||||||
|
|||||||
@@ -1,45 +1,36 @@
|
|||||||
package com.hibiscusmc.hmccosmetics.config;
|
package com.hibiscusmc.hmccosmetics.config;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
public class WardrobeLocation {
|
public class WardrobeLocation {
|
||||||
|
|
||||||
|
@Getter @Setter
|
||||||
private Location npcLocation;
|
private Location npcLocation;
|
||||||
|
@Getter @Setter
|
||||||
private Location viewerLocation;
|
private Location viewerLocation;
|
||||||
|
@Getter @Setter
|
||||||
private Location leaveLocation;
|
private Location leaveLocation;
|
||||||
|
|
||||||
public WardrobeLocation(Location npcLocation, Location viewerLocation, Location leaveLocation) {
|
/**
|
||||||
|
* This creates a WardrobeLocation object with the 3 locations that are required for a wardrobe to work
|
||||||
|
* @param npcLocation The location of the NPC
|
||||||
|
* @param viewerLocation The location of the viewer
|
||||||
|
* @param leaveLocation The location that the player will be teleported to when they leave the wardrobe if return-last-location in the config is false
|
||||||
|
*/
|
||||||
|
public WardrobeLocation(@Nullable Location npcLocation, @Nullable Location viewerLocation, @Nullable Location leaveLocation) {
|
||||||
this.npcLocation = npcLocation;
|
this.npcLocation = npcLocation;
|
||||||
this.viewerLocation = viewerLocation;
|
this.viewerLocation = viewerLocation;
|
||||||
this.leaveLocation = leaveLocation;
|
this.leaveLocation = leaveLocation;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Location getNpcLocation() {
|
/**
|
||||||
return npcLocation.clone();
|
* Checks if any of the locations are null
|
||||||
}
|
* @return true if all locations are not null, else false
|
||||||
|
*/
|
||||||
public Location getViewerLocation() {
|
|
||||||
return viewerLocation.clone();
|
|
||||||
}
|
|
||||||
|
|
||||||
public Location getLeaveLocation() {
|
|
||||||
return leaveLocation.clone();
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean hasAllLocations() {
|
public boolean hasAllLocations() {
|
||||||
if (npcLocation == null || viewerLocation == null || leaveLocation == null) return false;
|
return npcLocation != null && viewerLocation != null && leaveLocation != null;
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setNPCLocation(Location wardrobeLocation) {
|
|
||||||
this.npcLocation = wardrobeLocation;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setViewerLocation(Location viewerLocation) {
|
|
||||||
this.viewerLocation = viewerLocation;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setLeaveLocation(Location leaveLocation) {
|
|
||||||
this.leaveLocation = leaveLocation;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,14 +1,15 @@
|
|||||||
package com.hibiscusmc.hmccosmetics.config;
|
package com.hibiscusmc.hmccosmetics.config;
|
||||||
|
|
||||||
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
|
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
|
||||||
import com.hibiscusmc.hmccosmetics.config.serializer.LocationSerializer;
|
|
||||||
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||||
import com.hibiscusmc.hmccosmetics.util.misc.Utils;
|
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 net.kyori.adventure.bossbar.BossBar;
|
||||||
import org.apache.commons.lang3.EnumUtils;
|
import org.apache.commons.lang3.EnumUtils;
|
||||||
import org.bukkit.GameMode;
|
import org.bukkit.GameMode;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.spongepowered.configurate.ConfigurationNode;
|
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@@ -17,12 +18,9 @@ import java.util.logging.Level;
|
|||||||
|
|
||||||
public class WardrobeSettings {
|
public class WardrobeSettings {
|
||||||
|
|
||||||
private static final String WARDROBE_PATH = "wardrobe";
|
|
||||||
private static final String DISABLE_ON_DAMAGE_PATH = "disable-on-damage";
|
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 PORTABLE_PATH = "portable";
|
||||||
private static final String ALWAYS_DISPLAY_PATH = "always-display";
|
private static final String ALWAYS_DISPLAY_PATH = "always-display";
|
||||||
private static final String STATIC_RADIUS_PATH = "static-radius";
|
|
||||||
private static final String ROTATION_SPEED_PATH = "rotation-speed";
|
private static final String ROTATION_SPEED_PATH = "rotation-speed";
|
||||||
private static final String SPAWN_DELAY_PATH = "spawn-delay";
|
private static final String SPAWN_DELAY_PATH = "spawn-delay";
|
||||||
private static final String DESPAWN_DELAY_PATH = "despawn-delay";
|
private static final String DESPAWN_DELAY_PATH = "despawn-delay";
|
||||||
@@ -60,41 +58,61 @@ public class WardrobeSettings {
|
|||||||
private static final String TRANSITION_FADE_OUT_PATH = "title-fade-out";
|
private static final String TRANSITION_FADE_OUT_PATH = "title-fade-out";
|
||||||
|
|
||||||
private static ConfigurationNode configRoot;
|
private static ConfigurationNode configRoot;
|
||||||
|
@Getter
|
||||||
private static boolean disableOnDamage;
|
private static boolean disableOnDamage;
|
||||||
private static int displayRadius;
|
@Getter
|
||||||
private static boolean portable;
|
private static boolean portable;
|
||||||
|
@Getter
|
||||||
private static boolean alwaysDisplay;
|
private static boolean alwaysDisplay;
|
||||||
private static int staticRadius;
|
@Getter
|
||||||
private static int rotationSpeed;
|
private static int rotationSpeed;
|
||||||
|
@Getter
|
||||||
private static int spawnDelay;
|
private static int spawnDelay;
|
||||||
|
@Getter
|
||||||
private static int despawnDelay;
|
private static int despawnDelay;
|
||||||
|
@Getter
|
||||||
private static float bossbarProgress;
|
private static float bossbarProgress;
|
||||||
|
@Getter
|
||||||
private static boolean applyCosmeticsOnClose;
|
private static boolean applyCosmeticsOnClose;
|
||||||
|
@Getter
|
||||||
private static boolean tryCosmeticsInWardrobe;
|
private static boolean tryCosmeticsInWardrobe;
|
||||||
|
@Getter
|
||||||
private static boolean equipPumpkin;
|
private static boolean equipPumpkin;
|
||||||
|
@Getter
|
||||||
private static boolean returnLastLocation;
|
private static boolean returnLastLocation;
|
||||||
|
@Getter
|
||||||
private static boolean enabledBossbar;
|
private static boolean enabledBossbar;
|
||||||
|
@Getter
|
||||||
private static boolean enterOpenMenu;
|
private static boolean enterOpenMenu;
|
||||||
|
@Getter
|
||||||
private static boolean forceExitGamemode;
|
private static boolean forceExitGamemode;
|
||||||
|
@Getter
|
||||||
private static GameMode exitGamemode;
|
private static GameMode exitGamemode;
|
||||||
private static HashMap<String, Wardrobe> wardrobes;
|
private static HashMap<String, Wardrobe> wardrobes;
|
||||||
|
@Getter
|
||||||
private static String bossbarMessage;
|
private static String bossbarMessage;
|
||||||
|
@Getter
|
||||||
private static BossBar.Overlay bossbarOverlay;
|
private static BossBar.Overlay bossbarOverlay;
|
||||||
|
@Getter
|
||||||
private static BossBar.Color bossbarColor;
|
private static BossBar.Color bossbarColor;
|
||||||
|
@Getter
|
||||||
private static boolean enabledTransition;
|
private static boolean enabledTransition;
|
||||||
|
@Getter
|
||||||
private static String transitionText;
|
private static String transitionText;
|
||||||
|
@Getter
|
||||||
private static int transitionDelay;
|
private static int transitionDelay;
|
||||||
|
@Getter
|
||||||
private static int transitionFadeIn;
|
private static int transitionFadeIn;
|
||||||
|
@Getter
|
||||||
private static int transitionStay;
|
private static int transitionStay;
|
||||||
|
@Getter
|
||||||
private static int transitionFadeOut;
|
private static int transitionFadeOut;
|
||||||
|
|
||||||
public static void load(ConfigurationNode source) {
|
public static void load(ConfigurationNode source) {
|
||||||
configRoot = source;
|
configRoot = source;
|
||||||
|
|
||||||
disableOnDamage = source.node(DISABLE_ON_DAMAGE_PATH).getBoolean();
|
disableOnDamage = source.node(DISABLE_ON_DAMAGE_PATH).getBoolean();
|
||||||
displayRadius = source.node(DISPLAY_RADIUS_PATH).getInt();
|
|
||||||
portable = source.node(PORTABLE_PATH).getBoolean();
|
portable = source.node(PORTABLE_PATH).getBoolean();
|
||||||
staticRadius = source.node(STATIC_RADIUS_PATH).getInt();
|
|
||||||
alwaysDisplay = source.node(ALWAYS_DISPLAY_PATH).getBoolean();
|
alwaysDisplay = source.node(ALWAYS_DISPLAY_PATH).getBoolean();
|
||||||
rotationSpeed = source.node(ROTATION_SPEED_PATH).getInt();
|
rotationSpeed = source.node(ROTATION_SPEED_PATH).getInt();
|
||||||
spawnDelay = source.node(SPAWN_DELAY_PATH).getInt();
|
spawnDelay = source.node(SPAWN_DELAY_PATH).getInt();
|
||||||
@@ -147,10 +165,8 @@ public class WardrobeSettings {
|
|||||||
MessagesUtil.sendDebugMessages("Leave Location: " + leaveLocation);
|
MessagesUtil.sendDebugMessages("Leave Location: " + leaveLocation);
|
||||||
WardrobeLocation wardrobeLocation = new WardrobeLocation(npcLocation, viewerLocation, leaveLocation);
|
WardrobeLocation wardrobeLocation = new WardrobeLocation(npcLocation, viewerLocation, leaveLocation);
|
||||||
|
|
||||||
String permission = null;
|
String permission = wardrobesNode.node(PERMISSION_PATH).getString();
|
||||||
int distance = -1;
|
int distance = wardrobesNode.node(DISTANCE_PATH).getInt(-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();
|
|
||||||
|
|
||||||
Wardrobe wardrobe = new Wardrobe(id, wardrobeLocation, permission, distance);
|
Wardrobe wardrobe = new Wardrobe(id, wardrobeLocation, permission, distance);
|
||||||
addWardrobe(wardrobe);
|
addWardrobe(wardrobe);
|
||||||
@@ -158,54 +174,6 @@ public class WardrobeSettings {
|
|||||||
MessagesUtil.sendDebugMessages("Unable to create wardrobe " + id, Level.SEVERE);
|
MessagesUtil.sendDebugMessages("Unable to create wardrobe " + id, Level.SEVERE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//throw new RuntimeException(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static int getDefaultDistance() {
|
|
||||||
return staticRadius;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean getDisableOnDamage() {
|
|
||||||
return disableOnDamage;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static int getDisplayRadius() {
|
|
||||||
return displayRadius;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean isPortable() {
|
|
||||||
return portable;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean isAlwaysDisplay() {
|
|
||||||
return alwaysDisplay;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static int getStaticRadius() {
|
|
||||||
return staticRadius;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static int getRotationSpeed() {
|
|
||||||
return rotationSpeed;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static int getSpawnDelay() {
|
|
||||||
return spawnDelay;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static int getDespawnDelay() {
|
|
||||||
return despawnDelay;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean isApplyCosmeticsOnClose() {
|
|
||||||
return applyCosmeticsOnClose;
|
|
||||||
}
|
|
||||||
public static boolean isEquipPumpkin() {
|
|
||||||
return equipPumpkin;
|
|
||||||
}
|
|
||||||
public static boolean isReturnLastLocation() {
|
|
||||||
return returnLastLocation;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Wardrobe getWardrobe(String key) {
|
public static Wardrobe getWardrobe(String key) {
|
||||||
@@ -228,84 +196,12 @@ public class WardrobeSettings {
|
|||||||
wardrobes.remove(id);
|
wardrobes.remove(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated
|
|
||||||
public static boolean inDistanceOfWardrobe(final Location wardrobeLocation, final Location playerLocation) {
|
|
||||||
if (displayRadius == -1) return true;
|
|
||||||
if (!wardrobeLocation.getWorld().equals(playerLocation.getWorld())) return false;
|
|
||||||
return playerLocation.distanceSquared(wardrobeLocation) <= displayRadius * displayRadius;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Deprecated
|
|
||||||
public static boolean inDistanceOfStatic(Wardrobe wardrobe, final Location location) {
|
|
||||||
Location wardrobeLocation = wardrobe.getLocation().getNpcLocation();
|
|
||||||
if (wardrobeLocation == null) return false;
|
|
||||||
if (staticRadius == -1) return true;
|
|
||||||
if (!wardrobeLocation.getWorld().equals(location.getWorld())) return false;
|
|
||||||
return wardrobeLocation.distanceSquared(location) <= staticRadius * staticRadius;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean getEnabledBossbar() {
|
|
||||||
return enabledBossbar;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static float getBossbarProgress() {
|
|
||||||
return bossbarProgress;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String getBossbarText() {
|
|
||||||
return bossbarMessage;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static BossBar.Overlay getBossbarOverlay() {
|
|
||||||
return bossbarOverlay;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static BossBar.Color getBossbarColor() {
|
|
||||||
return bossbarColor;
|
|
||||||
}
|
|
||||||
public static boolean isEnabledTransition() {
|
|
||||||
return enabledTransition;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String getTransitionText() {
|
|
||||||
return transitionText;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static int getTransitionDelay() {
|
|
||||||
return transitionDelay;
|
|
||||||
}
|
|
||||||
public static int getTransitionFadeIn() {
|
|
||||||
return transitionFadeIn;
|
|
||||||
}
|
|
||||||
public static int getTransitionStay() {
|
|
||||||
return transitionStay;
|
|
||||||
}
|
|
||||||
public static int getTransitionFadeOut() {
|
|
||||||
return transitionFadeOut;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean isEnterOpenMenu() {
|
|
||||||
return enterOpenMenu;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean isForceExitGamemode() {
|
|
||||||
return forceExitGamemode;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static GameMode getExitGamemode() {
|
|
||||||
return exitGamemode;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean isTryCosmeticsInWardrobe() {
|
|
||||||
return tryCosmeticsInWardrobe;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets where the NPC/Mannequin will spawn in the wardrobe
|
* Sets where the NPC/Mannequin will spawn in the wardrobe
|
||||||
* @param newLocation
|
* @param newLocation
|
||||||
*/
|
*/
|
||||||
public static void setNPCLocation(Wardrobe wardrobe, Location newLocation) {
|
public static void setNPCLocation(Wardrobe wardrobe, Location newLocation) {
|
||||||
wardrobe.getLocation().setNPCLocation(newLocation);
|
wardrobe.getLocation().setNpcLocation(newLocation);
|
||||||
|
|
||||||
HMCCosmeticsPlugin plugin = HMCCosmeticsPlugin.getInstance();
|
HMCCosmeticsPlugin plugin = HMCCosmeticsPlugin.getInstance();
|
||||||
|
|
||||||
|
|||||||
@@ -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,24 +1,31 @@
|
|||||||
package com.hibiscusmc.hmccosmetics.cosmetic;
|
package com.hibiscusmc.hmccosmetics.cosmetic;
|
||||||
|
|
||||||
import com.hibiscusmc.hmccosmetics.config.serializer.ItemSerializer;
|
|
||||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||||
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||||
|
import 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.Material;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
import org.spongepowered.configurate.ConfigurationNode;
|
|
||||||
import org.spongepowered.configurate.serialize.SerializationException;
|
|
||||||
|
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
public abstract class Cosmetic {
|
public abstract class Cosmetic {
|
||||||
|
|
||||||
|
@Getter @Setter
|
||||||
private String id;
|
private String id;
|
||||||
|
@Getter @Setter
|
||||||
private String permission;
|
private String permission;
|
||||||
private ItemStack item;
|
private ItemStack item;
|
||||||
|
@Getter @Setter
|
||||||
private String material;
|
private String material;
|
||||||
|
@Getter @Setter
|
||||||
private CosmeticSlot slot;
|
private CosmeticSlot slot;
|
||||||
|
@Getter @Setter
|
||||||
private boolean dyable;
|
private boolean dyable;
|
||||||
|
|
||||||
protected Cosmetic(String id, @NotNull ConfigurationNode config) {
|
protected Cosmetic(String id, @NotNull ConfigurationNode config) {
|
||||||
@@ -44,46 +51,10 @@ public abstract class Cosmetic {
|
|||||||
Cosmetics.addCosmetic(this);
|
Cosmetics.addCosmetic(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getId() {
|
|
||||||
return this.id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setId(String id) {
|
|
||||||
this.id = id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public CosmeticSlot getSlot() {
|
|
||||||
return this.slot;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setSlot(CosmeticSlot slot) {
|
|
||||||
this.slot = slot;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getPermission() {
|
|
||||||
return this.permission;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setPermission(String permission) {
|
|
||||||
this.permission = permission;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean requiresPermission() {
|
public boolean requiresPermission() {
|
||||||
return permission != null;
|
return permission != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDyable(boolean dyable) {
|
|
||||||
this.dyable = dyable;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isDyable() {
|
|
||||||
return this.dyable;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getMaterial() {
|
|
||||||
return material;
|
|
||||||
}
|
|
||||||
|
|
||||||
public abstract void update(CosmeticUser user);
|
public abstract void update(CosmeticUser user);
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
|
|||||||
@@ -5,14 +5,14 @@ import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
|
|||||||
import com.hibiscusmc.hmccosmetics.config.Settings;
|
import com.hibiscusmc.hmccosmetics.config.Settings;
|
||||||
import com.hibiscusmc.hmccosmetics.cosmetic.types.*;
|
import com.hibiscusmc.hmccosmetics.cosmetic.types.*;
|
||||||
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
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.apache.commons.lang3.EnumUtils;
|
||||||
import org.jetbrains.annotations.Contract;
|
import org.jetbrains.annotations.Contract;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
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.io.File;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
@@ -113,7 +113,7 @@ public class Cosmetics {
|
|||||||
default -> new CosmeticArmorType(id, cosmeticConfig);
|
default -> new CosmeticArmorType(id, cosmeticConfig);
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
if (Settings.isDebugEnabled()) e.printStackTrace();
|
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.config.Settings;
|
||||||
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
|
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
|
||||||
import com.hibiscusmc.hmccosmetics.nms.NMSHandlers;
|
|
||||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||||
import com.hibiscusmc.hmccosmetics.util.InventoryUtils;
|
import com.hibiscusmc.hmccosmetics.util.HMCCInventoryUtils;
|
||||||
import com.hibiscusmc.hmccosmetics.util.packets.PacketManager;
|
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.Bukkit;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.HumanEntity;
|
import org.bukkit.entity.HumanEntity;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.EquipmentSlot;
|
import org.bukkit.inventory.EquipmentSlot;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.spongepowered.configurate.ConfigurationNode;
|
|
||||||
|
|
||||||
public class CosmeticArmorType extends Cosmetic {
|
public class CosmeticArmorType extends Cosmetic {
|
||||||
|
|
||||||
@@ -21,26 +22,34 @@ public class CosmeticArmorType extends Cosmetic {
|
|||||||
public CosmeticArmorType(String id, ConfigurationNode config) {
|
public CosmeticArmorType(String id, ConfigurationNode config) {
|
||||||
super(id, config);
|
super(id, config);
|
||||||
|
|
||||||
this.equipSlot = InventoryUtils.getEquipmentSlot(getSlot());
|
this.equipSlot = HMCCInventoryUtils.getEquipmentSlot(getSlot());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update(@NotNull CosmeticUser user) {
|
public void update(@NotNull CosmeticUser user) {
|
||||||
|
if (user.getUserEmoteManager().isPlayingEmote() || user.isInWardrobe()) return;
|
||||||
Entity entity = Bukkit.getEntity(user.getUniqueId());
|
Entity entity = Bukkit.getEntity(user.getUniqueId());
|
||||||
if (entity == null) return;
|
if (entity == null) return;
|
||||||
if (user.getUserEmoteManager().isPlayingEmote()) return; // There has to be a better way of doing this...
|
if (!Settings.isCosmeticForceOffhandCosmeticShow()
|
||||||
ItemStack cosmeticItem = user.getUserCosmeticItem(this);
|
&& equipSlot.equals(EquipmentSlot.OFF_HAND)
|
||||||
if (!(entity instanceof HumanEntity humanEntity)) return;
|
&& ((user.getEntity() instanceof Player) && !user.getPlayer().getInventory().getItemInOffHand().getType().isAir())) return;
|
||||||
if (equipSlot.equals(EquipmentSlot.OFF_HAND)) {
|
ItemStack item = getItem(user);
|
||||||
if (!humanEntity.getInventory().getItemInOffHand().getType().isAir()) return;
|
if (item == null) return;
|
||||||
}
|
PacketManager.equipmentSlotUpdate(entity.getEntityId(), equipSlot, item, HMCCPacketManager.getViewers(entity.getLocation()));
|
||||||
ItemStack equippedItem = humanEntity.getInventory().getItem(equipSlot);
|
}
|
||||||
|
|
||||||
|
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.getShouldAddEnchants(equipSlot)) {
|
if (Settings.getShouldAddEnchants(equipSlot)) {
|
||||||
|
ItemStack equippedItem = humanEntity.getInventory().getItem(equipSlot);
|
||||||
cosmeticItem.addUnsafeEnchantments(equippedItem.getEnchantments());
|
cosmeticItem.addUnsafeEnchantments(equippedItem.getEnchantments());
|
||||||
}
|
}
|
||||||
|
// Basically, if force offhand is off AND there is no item in an offhand slot, then the equipment packet to add the cosmetic
|
||||||
NMSHandlers.getHandler().equipmentSlotUpdate(entity.getEntityId(), equipSlot, cosmeticItem, PacketManager.getViewers(entity.getLocation()));
|
return cosmeticItem;
|
||||||
//PacketManager.equipmentSlotUpdate(player, getSlot(), PacketManager.getViewers(player.getLocation())); Old method
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public EquipmentSlot getEquipSlot() {
|
public EquipmentSlot getEquipSlot() {
|
||||||
|
|||||||
@@ -1,28 +1,33 @@
|
|||||||
package com.hibiscusmc.hmccosmetics.cosmetic.types;
|
package com.hibiscusmc.hmccosmetics.cosmetic.types;
|
||||||
|
|
||||||
|
import com.hibiscusmc.hmccosmetics.config.Settings;
|
||||||
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
|
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
|
||||||
import com.hibiscusmc.hmccosmetics.nms.NMSHandlers;
|
|
||||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||||
import com.hibiscusmc.hmccosmetics.user.manager.UserBackpackManager;
|
|
||||||
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||||
import com.hibiscusmc.hmccosmetics.util.packets.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.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.entity.AreaEffectCloud;
|
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
|
import org.bukkit.entity.EntityType;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.EquipmentSlot;
|
import org.bukkit.inventory.EquipmentSlot;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.spongepowered.configurate.ConfigurationNode;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.UUID;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
public class CosmeticBackpackType extends Cosmetic {
|
public class CosmeticBackpackType extends Cosmetic {
|
||||||
|
|
||||||
|
@Getter
|
||||||
private final String modelName;
|
private final String modelName;
|
||||||
|
@Getter
|
||||||
|
private int height = -1;
|
||||||
private ItemStack firstPersonBackpack;
|
private ItemStack firstPersonBackpack;
|
||||||
|
|
||||||
public CosmeticBackpackType(String id, ConfigurationNode config) {
|
public CosmeticBackpackType(String id, ConfigurationNode config) {
|
||||||
@@ -32,8 +37,8 @@ public class CosmeticBackpackType extends Cosmetic {
|
|||||||
|
|
||||||
if (!config.node("firstperson-item").virtual()) {
|
if (!config.node("firstperson-item").virtual()) {
|
||||||
this.firstPersonBackpack = generateItemStack(config.node("firstperson-item"));
|
this.firstPersonBackpack = generateItemStack(config.node("firstperson-item"));
|
||||||
|
this.height = config.node("height").getInt(5);
|
||||||
}
|
}
|
||||||
//backpackType = UserBackpackManager.BackpackType.valueOf(config.node("type").getString("NORMAL").toUpperCase());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -45,43 +50,41 @@ public class CosmeticBackpackType extends Cosmetic {
|
|||||||
|
|
||||||
if (user.isInWardrobe() || !user.isBackpackSpawned()) return;
|
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.
|
// 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.getUserBackpackManager().IsValidBackpackEntity()) {
|
List<Player> outsideViewers = user.getUserBackpackManager().getEntityManager().refreshViewers(loc);
|
||||||
MessagesUtil.sendDebugMessages("Invalid Backpack Entity[owner=" + user.getUniqueId() + ",player_location=" + loc + "]!");
|
|
||||||
user.respawnBackpack();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (loc.getWorld() != user.getUserBackpackManager().getArmorStand().getWorld()) {
|
|
||||||
user.getUserBackpackManager().getArmorStand().teleport(loc);
|
|
||||||
}
|
|
||||||
|
|
||||||
user.getUserBackpackManager().getArmorStand().teleport(loc);
|
user.getUserBackpackManager().getEntityManager().teleport(loc);
|
||||||
user.getUserBackpackManager().getArmorStand().setRotation(loc.getYaw(), loc.getPitch());
|
user.getUserBackpackManager().getEntityManager().setRotation((int) loc.getYaw(), isFirstPersonCompadible());
|
||||||
|
|
||||||
|
HMCCPacketManager.sendEntitySpawnPacket(user.getEntity().getLocation(), user.getUserBackpackManager().getFirstArmorStandId(), EntityType.ARMOR_STAND, UUID.randomUUID(), outsideViewers);
|
||||||
|
HMCCPacketManager.sendArmorstandMetadata(user.getUserBackpackManager().getFirstArmorStandId(), outsideViewers);
|
||||||
|
PacketManager.equipmentSlotUpdate(user.getUserBackpackManager().getFirstArmorStandId(), EquipmentSlot.HEAD, user.getUserCosmeticItem(this, getItem()), outsideViewers);
|
||||||
|
// If true, it will send the riding packet to all players. If false, it will send the riding packet only to new players
|
||||||
|
if (Settings.isBackpackForceRidingEnabled()) HMCCPacketManager.sendRidingPacket(entity.getEntityId(), user.getUserBackpackManager().getFirstArmorStandId(), user.getUserBackpackManager().getEntityManager().getViewers());
|
||||||
|
else HMCCPacketManager.sendRidingPacket(entity.getEntityId(), user.getUserBackpackManager().getFirstArmorStandId(), outsideViewers);
|
||||||
|
|
||||||
List<Player> outsideViewers = user.getUserBackpackManager().getCloudManager().refreshViewers(loc);
|
|
||||||
if (!user.isInWardrobe() && isFirstPersonCompadible() && user.getPlayer() != null) {
|
if (!user.isInWardrobe() && isFirstPersonCompadible() && user.getPlayer() != null) {
|
||||||
List<Player> owner = List.of(user.getPlayer());
|
List<Player> owner = List.of(user.getPlayer());
|
||||||
|
|
||||||
ArrayList<Integer> particleCloud = user.getUserBackpackManager().getAreaEffectEntityId();
|
ArrayList<Integer> particleCloud = user.getUserBackpackManager().getAreaEffectEntityId();
|
||||||
for (int i = 0; i < particleCloud.size(); i++) {
|
for (int i = 0; i < particleCloud.size(); i++) {
|
||||||
if (i == 0) {
|
if (i == 0) {
|
||||||
PacketManager.sendRidingPacket(entity.getEntityId(), particleCloud.get(i), owner);
|
HMCCPacketManager.sendRidingPacket(entity.getEntityId(), particleCloud.get(i), owner);
|
||||||
} else {
|
} 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);
|
HMCCPacketManager.sendRidingPacket(particleCloud.get(particleCloud.size() - 1), user.getUserBackpackManager().getFirstArmorStandId(), owner);
|
||||||
if (!user.getHidden()) NMSHandlers.getHandler().equipmentSlotUpdate(user.getUserBackpackManager().getFirstArmorStandId(), EquipmentSlot.HEAD, firstPersonBackpack, owner);
|
if (!user.getHidden()) {
|
||||||
|
//if (loc.getPitch() < -70) NMSHandlers.getHandler().equipmentSlotUpdate(user.getUserBackpackManager().getFirstArmorStandId(), EquipmentSlot.HEAD, new ItemStack(Material.AIR), owner);
|
||||||
|
//else NMSHandlers.getHandler().equipmentSlotUpdate(user.getUserBackpackManager().getFirstArmorStandId(), EquipmentSlot.HEAD, firstPersonBackpack, owner);
|
||||||
|
PacketManager.equipmentSlotUpdate(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);
|
||||||
}
|
}
|
||||||
PacketManager.sendRidingPacket(entity.getEntityId(), user.getUserBackpackManager().getFirstArmorStandId(), outsideViewers);
|
|
||||||
|
|
||||||
user.getUserBackpackManager().showBackpack();
|
user.getUserBackpackManager().showBackpack();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getModelName() {
|
|
||||||
return modelName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isFirstPersonCompadible() {
|
public boolean isFirstPersonCompadible() {
|
||||||
return firstPersonBackpack != null;
|
return firstPersonBackpack != null;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,32 +4,42 @@ import com.hibiscusmc.hmccosmetics.config.Settings;
|
|||||||
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
|
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
|
||||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||||
import com.hibiscusmc.hmccosmetics.user.manager.UserBalloonManager;
|
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.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.EntityType;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.util.Vector;
|
import org.bukkit.util.Vector;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.spongepowered.configurate.ConfigurationNode;
|
|
||||||
import org.spongepowered.configurate.serialize.SerializationException;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class CosmeticBalloonType extends Cosmetic {
|
public class CosmeticBalloonType extends Cosmetic {
|
||||||
|
|
||||||
|
@Getter
|
||||||
private final String modelName;
|
private final String modelName;
|
||||||
|
@Getter
|
||||||
private List<String> dyableParts;
|
private List<String> dyableParts;
|
||||||
|
@Getter
|
||||||
private final boolean showLead;
|
private final boolean showLead;
|
||||||
|
@Getter
|
||||||
|
private Vector balloonOffset;
|
||||||
|
|
||||||
public CosmeticBalloonType(String id, ConfigurationNode config) {
|
public CosmeticBalloonType(String id, ConfigurationNode config) {
|
||||||
super(id, config);
|
super(id, config);
|
||||||
|
|
||||||
String modelId = config.node("model").getString();
|
String modelId = config.node("model").getString();
|
||||||
|
|
||||||
showLead = config.node("show-lead").getBoolean(true);
|
showLead = config.node("show-lead").getBoolean(true);
|
||||||
|
|
||||||
|
ConfigurationNode balloonOffsetNode = config.node("balloon-offset");
|
||||||
|
if (balloonOffsetNode.virtual())
|
||||||
|
balloonOffset = Settings.getBalloonOffset();
|
||||||
|
else
|
||||||
|
balloonOffset = Settings.loadVector(balloonOffsetNode);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (!config.node("dyable-parts").virtual()) {
|
if (!config.node("dyable-parts").virtual()) {
|
||||||
dyableParts = config.node("dyable-parts").getList(String.class);
|
dyableParts = config.node("dyable-parts").getList(String.class);
|
||||||
@@ -57,13 +67,13 @@ public class CosmeticBalloonType extends Cosmetic {
|
|||||||
|
|
||||||
Location newLocation = entity.getLocation();
|
Location newLocation = entity.getLocation();
|
||||||
Location currentLocation = user.getBalloonManager().getLocation();
|
Location currentLocation = user.getBalloonManager().getLocation();
|
||||||
newLocation = newLocation.clone().add(Settings.getBalloonOffset());
|
newLocation = newLocation.clone().add(getBalloonOffset());
|
||||||
|
|
||||||
List<Player> viewer = PacketManager.getViewers(entity.getLocation());
|
List<Player> viewer = HMCCPacketManager.getViewers(entity.getLocation());
|
||||||
|
|
||||||
if (entity.getLocation().getWorld() != userBalloonManager.getLocation().getWorld()) {
|
if (entity.getLocation().getWorld() != userBalloonManager.getLocation().getWorld()) {
|
||||||
userBalloonManager.getModelEntity().teleport(newLocation);
|
userBalloonManager.getModelEntity().teleport(newLocation);
|
||||||
PacketManager.sendTeleportPacket(userBalloonManager.getPufferfishBalloonId(), newLocation, false, viewer);
|
HMCCPacketManager.sendTeleportPacket(userBalloonManager.getPufferfishBalloonId(), newLocation, false, viewer);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -71,8 +81,8 @@ public class CosmeticBalloonType extends Cosmetic {
|
|||||||
userBalloonManager.setVelocity(velocity.multiply(1.1));
|
userBalloonManager.setVelocity(velocity.multiply(1.1));
|
||||||
userBalloonManager.setLocation(newLocation);
|
userBalloonManager.setLocation(newLocation);
|
||||||
|
|
||||||
PacketManager.sendTeleportPacket(userBalloonManager.getPufferfishBalloonId(), newLocation, false, viewer);
|
HMCCPacketManager.sendTeleportPacket(userBalloonManager.getPufferfishBalloonId(), newLocation, false, viewer);
|
||||||
PacketManager.sendLeashPacket(userBalloonManager.getPufferfishBalloonId(), entity.getEntityId(), viewer);
|
HMCCPacketManager.sendLeashPacket(userBalloonManager.getPufferfishBalloonId(), entity.getEntityId(), viewer);
|
||||||
if (user.getHidden()) {
|
if (user.getHidden()) {
|
||||||
userBalloonManager.getPufferfish().hidePufferfish();
|
userBalloonManager.getPufferfish().hidePufferfish();
|
||||||
return;
|
return;
|
||||||
@@ -80,27 +90,14 @@ public class CosmeticBalloonType extends Cosmetic {
|
|||||||
if (!user.getHidden() && showLead) {
|
if (!user.getHidden() && showLead) {
|
||||||
List<Player> sendTo = userBalloonManager.getPufferfish().refreshViewers(newLocation);
|
List<Player> sendTo = userBalloonManager.getPufferfish().refreshViewers(newLocation);
|
||||||
if (sendTo.isEmpty()) return;
|
if (sendTo.isEmpty()) return;
|
||||||
PacketManager.sendEntitySpawnPacket(newLocation, userBalloonManager.getPufferfishBalloonId(), EntityType.PUFFERFISH, userBalloonManager.getPufferfishBalloonUniqueId(), sendTo);
|
user.getBalloonManager().getPufferfish().spawnPufferfish(newLocation, sendTo);
|
||||||
PacketManager.sendInvisibilityPacket(userBalloonManager.getPufferfishBalloonId(), sendTo);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getModelName() {
|
|
||||||
return this.modelName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<String> getDyableParts() {
|
|
||||||
return dyableParts;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isDyablePart(String name) {
|
public boolean isDyablePart(String name) {
|
||||||
// If player does not define parts, dye whole model
|
// If player does not define parts, dye whole model
|
||||||
if (dyableParts == null) return true;
|
if (dyableParts == null) return true;
|
||||||
if (dyableParts.isEmpty()) return true;
|
if (dyableParts.isEmpty()) return true;
|
||||||
return dyableParts.contains(name);
|
return dyableParts.contains(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isShowLead() {
|
|
||||||
return showLead;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,8 +3,8 @@ package com.hibiscusmc.hmccosmetics.cosmetic.types;
|
|||||||
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
|
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
|
||||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||||
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||||
|
import me.lojosho.shaded.configurate.ConfigurationNode;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.spongepowered.configurate.ConfigurationNode;
|
|
||||||
|
|
||||||
public class CosmeticEmoteType extends Cosmetic {
|
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.cosmetic.Cosmetic;
|
||||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||||
import com.hibiscusmc.hmccosmetics.util.PlayerUtils;
|
import com.hibiscusmc.hmccosmetics.util.HMCCPlayerUtils;
|
||||||
import com.hibiscusmc.hmccosmetics.util.packets.PacketManager;
|
import com.hibiscusmc.hmccosmetics.util.packets.HMCCPacketManager;
|
||||||
|
import me.lojosho.shaded.configurate.ConfigurationNode;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.spongepowered.configurate.ConfigurationNode;
|
|
||||||
|
|
||||||
public class CosmeticMainhandType extends Cosmetic {
|
public class CosmeticMainhandType extends Cosmetic {
|
||||||
|
|
||||||
@@ -18,6 +18,6 @@ public class CosmeticMainhandType extends Cosmetic {
|
|||||||
public void update(@NotNull CosmeticUser user) {
|
public void update(@NotNull CosmeticUser user) {
|
||||||
Player player = user.getPlayer();
|
Player player = user.getPlayer();
|
||||||
|
|
||||||
PacketManager.equipmentSlotUpdate(player.getEntityId(), user, getSlot(), PlayerUtils.getNearbyPlayers(player));
|
HMCCPacketManager.equipmentSlotUpdate(player.getEntityId(), user, getSlot(), HMCCPlayerUtils.getNearbyPlayers(player));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,14 +7,15 @@ import com.hibiscusmc.hmccosmetics.database.types.SQLiteData;
|
|||||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUsers;
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUsers;
|
||||||
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||||
|
import lombok.Getter;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public class Database {
|
public class Database {
|
||||||
|
|
||||||
|
@Getter
|
||||||
private static Data data;
|
private static Data data;
|
||||||
|
|
||||||
private static final MySQLData MYSQL_DATA = new MySQLData();
|
private static final MySQLData MYSQL_DATA = new MySQLData();
|
||||||
private static final SQLiteData SQLITE_DATA = new SQLiteData();
|
private static final SQLiteData SQLITE_DATA = new SQLiteData();
|
||||||
|
|
||||||
@@ -50,10 +51,6 @@ public class Database {
|
|||||||
return data.get(uniqueId);
|
return data.get(uniqueId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Data getData() {
|
|
||||||
return data;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void clearData(UUID uniqueId) {
|
public static void clearData(UUID uniqueId) {
|
||||||
data.clear(uniqueId);
|
data.clear(uniqueId);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,27 +31,27 @@ public abstract class Data {
|
|||||||
// BACKPACK=colorfulbackpack&RRGGBB,HELMET=niftyhat,BALLOON=colorfulballoon,CHESTPLATE=niftychestplate
|
// BACKPACK=colorfulbackpack&RRGGBB,HELMET=niftyhat,BALLOON=colorfulballoon,CHESTPLATE=niftychestplate
|
||||||
@NotNull
|
@NotNull
|
||||||
public final String serializeData(@NotNull CosmeticUser user) {
|
public final String serializeData(@NotNull CosmeticUser user) {
|
||||||
String data = "";
|
StringBuilder data = new StringBuilder();
|
||||||
if (user.getHidden()) {
|
if (user.getHidden()) {
|
||||||
if (shouldHiddenSave(user.getHiddenReason())) {
|
if (shouldHiddenSave(user.getHiddenReason())) {
|
||||||
data = "HIDDEN=" + user.getHiddenReason();
|
data.append("HIDDEN=").append(user.getHiddenReason());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (Cosmetic cosmetic : user.getCosmetics()) {
|
for (Cosmetic cosmetic : user.getCosmetics()) {
|
||||||
Color color = user.getCosmeticColor(cosmetic.getSlot());
|
Color color = user.getCosmeticColor(cosmetic.getSlot());
|
||||||
String input = cosmetic.getSlot() + "=" + cosmetic.getId();
|
String input = cosmetic.getSlot() + "=" + cosmetic.getId();
|
||||||
if (color != null) input = input + "&" + color.asRGB();
|
if (color != null) input = input + "&" + color.asRGB();
|
||||||
if (data.length() == 0) {
|
if (data.isEmpty()) {
|
||||||
data = input;
|
data.append(input);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
data = data + "," + input;
|
data.append(",").append(input);
|
||||||
}
|
}
|
||||||
return data;
|
return data.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
public final Map<CosmeticSlot, Map<Cosmetic, Color>> deserializeData(CosmeticUser user, @NotNull String raw) {
|
public final Map<CosmeticSlot, Map<Cosmetic, Color>> deserializeData(CosmeticUser user, @NotNull String raw) {
|
||||||
return deserializeData(user, raw, Settings.getForcePermissionJoin());
|
return deserializeData(user, raw, Settings.isForcePermissionJoin());
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@@ -101,9 +101,9 @@ public abstract class Data {
|
|||||||
return cosmetics;
|
return cosmetics;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean shouldHiddenSave(CosmeticUser.@NotNull HiddenReason reason) {
|
private boolean shouldHiddenSave(CosmeticUser.HiddenReason reason) {
|
||||||
switch (reason) {
|
switch (reason) {
|
||||||
case EMOTE, NONE -> {
|
case EMOTE, NONE, GAMEMODE, WORLD -> {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
default -> {
|
default -> {
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package com.hibiscusmc.hmccosmetics.database.types;
|
|||||||
|
|
||||||
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
|
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
|
||||||
import com.hibiscusmc.hmccosmetics.config.DatabaseSettings;
|
import com.hibiscusmc.hmccosmetics.config.DatabaseSettings;
|
||||||
|
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
@@ -126,9 +127,7 @@ public class MySQLData extends SQLData {
|
|||||||
public PreparedStatement preparedStatement(String query) {
|
public PreparedStatement preparedStatement(String query) {
|
||||||
PreparedStatement ps = null;
|
PreparedStatement ps = null;
|
||||||
|
|
||||||
if (!isConnectionOpen()) {
|
if (!isConnectionOpen()) MessagesUtil.sendDebugMessages("Connection is not open");
|
||||||
HMCCosmeticsPlugin.getInstance().getLogger().info("Connection is not open");
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (connection == null) throw new NullPointerException("Connection is null");
|
if (connection == null) throw new NullPointerException("Connection is null");
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ public abstract class SQLData extends Data {
|
|||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
if (!HMCCosmeticsPlugin.isDisable()) {
|
if (!HMCCosmeticsPlugin.getInstance().isDisabled()) {
|
||||||
Bukkit.getScheduler().runTaskAsynchronously(HMCCosmeticsPlugin.getInstance(), run);
|
Bukkit.getScheduler().runTaskAsynchronously(HMCCosmeticsPlugin.getInstance(), run);
|
||||||
} else {
|
} else {
|
||||||
run.run();
|
run.run();
|
||||||
|
|||||||
@@ -74,7 +74,7 @@ public class SQLiteData extends SQLData {
|
|||||||
Class.forName("org.sqlite.JDBC");
|
Class.forName("org.sqlite.JDBC");
|
||||||
connection = DriverManager.getConnection("jdbc:sqlite:" + dataFolder);
|
connection = DriverManager.getConnection("jdbc:sqlite:" + dataFolder);
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
System.out.println(e.getMessage());
|
e.printStackTrace();
|
||||||
} catch (ClassNotFoundException e) {
|
} catch (ClassNotFoundException e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
@@ -83,9 +83,7 @@ public class SQLiteData extends SQLData {
|
|||||||
@Override
|
@Override
|
||||||
public PreparedStatement preparedStatement(String query) {
|
public PreparedStatement preparedStatement(String query) {
|
||||||
PreparedStatement ps = null;
|
PreparedStatement ps = null;
|
||||||
if (!isConnectionOpen()) {
|
if (!isConnectionOpen()) MessagesUtil.sendDebugMessages("Connection is not open");
|
||||||
HMCCosmeticsPlugin.getInstance().getLogger().info("Connection is not open");
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
ps = connection.prepareStatement(query);
|
ps = connection.prepareStatement(query);
|
||||||
|
|||||||
@@ -3,41 +3,51 @@ package com.hibiscusmc.hmccosmetics.gui;
|
|||||||
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
|
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
|
||||||
import com.hibiscusmc.hmccosmetics.api.events.PlayerMenuOpenEvent;
|
import com.hibiscusmc.hmccosmetics.api.events.PlayerMenuOpenEvent;
|
||||||
import com.hibiscusmc.hmccosmetics.config.Settings;
|
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.Type;
|
||||||
import com.hibiscusmc.hmccosmetics.gui.type.Types;
|
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.user.CosmeticUser;
|
||||||
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||||
import com.hibiscusmc.hmccosmetics.util.misc.Adventure;
|
|
||||||
import dev.triumphteam.gui.builder.item.ItemBuilder;
|
import dev.triumphteam.gui.builder.item.ItemBuilder;
|
||||||
import dev.triumphteam.gui.guis.Gui;
|
import dev.triumphteam.gui.guis.Gui;
|
||||||
import dev.triumphteam.gui.guis.GuiItem;
|
import dev.triumphteam.gui.guis.GuiItem;
|
||||||
|
import lombok.Getter;
|
||||||
|
import 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 net.kyori.adventure.text.Component;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.inventory.ClickType;
|
import org.bukkit.event.inventory.ClickType;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.jetbrains.annotations.Contract;
|
import org.jetbrains.annotations.Contract;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.spongepowered.configurate.ConfigurationNode;
|
|
||||||
import org.spongepowered.configurate.serialize.SerializationException;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
|
||||||
public class Menu {
|
public class Menu {
|
||||||
|
|
||||||
|
@Getter
|
||||||
private final String id;
|
private final String id;
|
||||||
|
@Getter
|
||||||
private final String title;
|
private final String title;
|
||||||
|
@Getter
|
||||||
private final int rows;
|
private final int rows;
|
||||||
|
@Getter
|
||||||
private final ConfigurationNode config;
|
private final ConfigurationNode config;
|
||||||
|
@Getter
|
||||||
private final String permissionNode;
|
private final String permissionNode;
|
||||||
private final ArrayList<MenuItem> items;
|
private final HashMap<Integer, List<MenuItem>> items;
|
||||||
|
@Getter
|
||||||
private final int refreshRate;
|
private final int refreshRate;
|
||||||
|
@Getter
|
||||||
|
private final boolean shading;
|
||||||
|
|
||||||
public Menu(String id, @NotNull ConfigurationNode config) {
|
public Menu(String id, @NotNull ConfigurationNode config) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
@@ -47,8 +57,9 @@ public class Menu {
|
|||||||
rows = config.node("rows").getInt(1);
|
rows = config.node("rows").getInt(1);
|
||||||
permissionNode = config.node("permission").getString("");
|
permissionNode = config.node("permission").getString("");
|
||||||
refreshRate = config.node("refresh-rate").getInt(-1);
|
refreshRate = config.node("refresh-rate").getInt(-1);
|
||||||
|
shading = config.node("shading").getBoolean(Settings.isDefaultShading());
|
||||||
|
|
||||||
items = new ArrayList<>();
|
items = new HashMap<>();
|
||||||
setupItems();
|
setupItems();
|
||||||
|
|
||||||
Menus.addMenu(this);
|
Menus.addMenu(this);
|
||||||
@@ -70,8 +81,8 @@ public class Menu {
|
|||||||
|
|
||||||
List<Integer> slots = getSlots(slotString);
|
List<Integer> slots = getSlots(slotString);
|
||||||
|
|
||||||
if (slots == null) {
|
if (slots.isEmpty()) {
|
||||||
MessagesUtil.sendDebugMessages("Slot is null for " + config.key().toString());
|
MessagesUtil.sendDebugMessages("Slot is empty for " + config.key().toString());
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -83,33 +94,33 @@ public class Menu {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (item == null) {
|
if (item == null) {
|
||||||
MessagesUtil.sendDebugMessages("something went wrong! " + item);
|
MessagesUtil.sendDebugMessages("Something went wrong with the item creation for " + config.key().toString());
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int priority = config.node("priority").getInt(1);
|
||||||
|
|
||||||
Type type = null;
|
Type type = null;
|
||||||
|
|
||||||
if (!config.node("type").virtual()) {
|
if (!config.node("type").virtual()) {
|
||||||
String typeId = config.node("type").getString();
|
String typeId = config.node("type").getString("");
|
||||||
if (Types.isType(typeId)) type = Types.getType(typeId);
|
if (Types.isType(typeId)) type = Types.getType(typeId);
|
||||||
}
|
}
|
||||||
|
|
||||||
items.add(new MenuItem(slots, item, type, config));
|
for (Integer slot : slots) {
|
||||||
|
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)));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getId() {
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getTitle() {
|
|
||||||
return this.title;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getRows() {
|
|
||||||
return this.getRows();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void openMenu(CosmeticUser user) {
|
public void openMenu(CosmeticUser user) {
|
||||||
openMenu(user, false);
|
openMenu(user, false);
|
||||||
}
|
}
|
||||||
@@ -123,25 +134,22 @@ public class Menu {
|
|||||||
return;
|
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().
|
Gui gui = Gui.gui()
|
||||||
title(component).
|
.title(component)
|
||||||
rows(this.rows).
|
.rows(this.rows)
|
||||||
create();
|
.create();
|
||||||
|
|
||||||
gui.setDefaultClickAction(event -> event.setCancelled(true));
|
gui.setDefaultClickAction(event -> event.setCancelled(true));
|
||||||
|
|
||||||
AtomicInteger taskid = new AtomicInteger(-1);
|
AtomicInteger taskid = new AtomicInteger(-1);
|
||||||
gui.setOpenGuiAction(event -> {
|
gui.setOpenGuiAction(event -> {
|
||||||
Runnable run = new Runnable() {
|
Runnable run = () -> {
|
||||||
@Override
|
if (gui.getInventory().getViewers().isEmpty() && taskid.get() != -1) {
|
||||||
public void run() {
|
Bukkit.getScheduler().cancelTask(taskid.get());
|
||||||
if (gui.getInventory().getViewers().size() == 0 && taskid.get() != -1) {
|
|
||||||
Bukkit.getScheduler().cancelTask(taskid.get());
|
|
||||||
}
|
|
||||||
|
|
||||||
updateMenu(user, gui);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
updateMenu(user, gui);
|
||||||
};
|
};
|
||||||
|
|
||||||
if (refreshRate != -1) {
|
if (refreshRate != -1) {
|
||||||
@@ -157,33 +165,94 @@ public class Menu {
|
|||||||
|
|
||||||
// API
|
// API
|
||||||
PlayerMenuOpenEvent event = new PlayerMenuOpenEvent(user, this);
|
PlayerMenuOpenEvent event = new PlayerMenuOpenEvent(user, this);
|
||||||
Bukkit.getScheduler().runTask(HMCCosmeticsPlugin.getInstance(), () -> {
|
Bukkit.getScheduler().runTask(HMCCosmeticsPlugin.getInstance(), () -> Bukkit.getPluginManager().callEvent(event));
|
||||||
Bukkit.getPluginManager().callEvent(event);
|
|
||||||
});
|
|
||||||
if (event.isCancelled()) return;
|
if (event.isCancelled()) return;
|
||||||
// Internal
|
// Internal
|
||||||
|
|
||||||
Bukkit.getScheduler().runTask(HMCCosmeticsPlugin.getInstance(), () -> {
|
Bukkit.getScheduler().runTask(HMCCosmeticsPlugin.getInstance(), () -> {
|
||||||
gui.open(player);
|
gui.open(player);
|
||||||
|
updateMenu(user, gui); // fixes shading? I know I do this twice but it's easier than writing a whole new class to deal with this shit
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateMenu(CosmeticUser user, Gui gui) {
|
private void updateMenu(CosmeticUser user, Gui gui) {
|
||||||
for (MenuItem item : items) {
|
StringBuilder title = new StringBuilder(this.title);
|
||||||
Type type = item.getType();
|
|
||||||
for (int slot : item.getSlots()) {
|
|
||||||
ItemStack modifiedItem = getMenuItem(user, type, item.getItemConfig(), item.getItem().clone(), slot);
|
|
||||||
GuiItem guiItem = ItemBuilder.from(modifiedItem).asGuiItem();
|
|
||||||
guiItem.setAction(event -> {
|
|
||||||
MessagesUtil.sendDebugMessages("Selected slot " + slot);
|
|
||||||
final ClickType clickType = event.getClick();
|
|
||||||
if (type != null) type.run(user, item.getItemConfig(), clickType);
|
|
||||||
updateMenu(user, gui);
|
|
||||||
});
|
|
||||||
|
|
||||||
MessagesUtil.sendDebugMessages("Added " + slot + " as " + guiItem + " in the menu");
|
int row = 0;
|
||||||
gui.updateItem(slot, guiItem);
|
if (shading) {
|
||||||
|
for (int i = 0; i < gui.getInventory().getSize(); i++) {
|
||||||
|
// Handles the title
|
||||||
|
if (i % 9 == 0) {
|
||||||
|
if (row == 0) {
|
||||||
|
title.append(Settings.getFirstRowShift()); // Goes back to the start of the gui
|
||||||
|
} else {
|
||||||
|
title.append(Settings.getSequentRowShift());
|
||||||
|
}
|
||||||
|
row += 1;
|
||||||
|
} else {
|
||||||
|
title.append(Settings.getIndividualColumnShift()); // Goes to the next slot
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean occupied = false;
|
||||||
|
|
||||||
|
if (items.containsKey(i)) {
|
||||||
|
// Handles the items
|
||||||
|
List<MenuItem> menuItems = items.get(i);
|
||||||
|
MenuItem item = menuItems.get(0);
|
||||||
|
updateItem(user, gui, i);
|
||||||
|
|
||||||
|
if (item.type() instanceof TypeCosmetic) {
|
||||||
|
Cosmetic cosmetic = Cosmetics.getCosmetic(item.itemConfig().node("cosmetic").getString(""));
|
||||||
|
if (cosmetic == null) continue;
|
||||||
|
if (user.hasCosmeticInSlot(cosmetic)) {
|
||||||
|
title.append(Settings.getEquippedCosmeticColor());
|
||||||
|
} else {
|
||||||
|
if (user.canEquipCosmetic(cosmetic, true)) {
|
||||||
|
title.append(Settings.getEquipableCosmeticColor());
|
||||||
|
} else {
|
||||||
|
title.append(Settings.getLockedCosmeticColor());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
occupied = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (occupied) {
|
||||||
|
title.append(Settings.getBackground().replaceAll("<row>", String.valueOf(row)));
|
||||||
|
} else {
|
||||||
|
title.append(Settings.getClearBackground().replaceAll("<row>", String.valueOf(row)));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
MessagesUtil.sendDebugMessages("Updated menu with title " + title);
|
||||||
|
gui.updateTitle(StringUtils.parseStringToString(Hooks.processPlaceholders(user.getPlayer(), title.toString())));
|
||||||
|
} else {
|
||||||
|
for (int i = 0; i < gui.getInventory().getSize(); i++) {
|
||||||
|
if (items.containsKey(i)) {
|
||||||
|
updateItem(user, gui, i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
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");
|
||||||
|
gui.updateItem(slot, guiItem);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -194,8 +263,8 @@ public class Menu {
|
|||||||
for (String a : slotString) {
|
for (String a : slotString) {
|
||||||
if (a.contains("-")) {
|
if (a.contains("-")) {
|
||||||
String[] split = a.split("-");
|
String[] split = a.split("-");
|
||||||
int min = Integer.valueOf(split[0]);
|
int min = Integer.parseInt(split[0]);
|
||||||
int max = Integer.valueOf(split[1]);
|
int max = Integer.parseInt(split[1]);
|
||||||
slots.addAll(getSlots(min, max));
|
slots.addAll(getSlots(min, max));
|
||||||
} else {
|
} else {
|
||||||
slots.add(Integer.valueOf(a));
|
slots.add(Integer.valueOf(a));
|
||||||
@@ -213,19 +282,17 @@ public class Menu {
|
|||||||
return slots;
|
return slots;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Contract("_, _, _, _ -> param2")
|
@Contract("_, _, _, _, _ -> param2")
|
||||||
@NotNull
|
@NotNull
|
||||||
private ItemStack getMenuItem(CosmeticUser user, Type type, ConfigurationNode config, ItemStack itemStack, int slot) {
|
private ItemStack getMenuItem(CosmeticUser user, Type type, ConfigurationNode config, ItemStack itemStack, int slot) {
|
||||||
if (!itemStack.hasItemMeta()) return itemStack;
|
if (!itemStack.hasItemMeta()) return itemStack;
|
||||||
return type.setItem(user, config, itemStack, slot);
|
return type.setItem(user, config, itemStack, slot);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getPermissionNode() {
|
|
||||||
return permissionNode;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean canOpen(Player player) {
|
public boolean canOpen(Player player) {
|
||||||
if (permissionNode.isEmpty()) return true;
|
if (permissionNode.isEmpty()) return true;
|
||||||
return player.isOp() || player.hasPermission(permissionNode);
|
return player.isOp() || player.hasPermission(permissionNode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Comparator<MenuItem> priorityCompare = Comparator.comparing(MenuItem::priority).reversed();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,39 +1,11 @@
|
|||||||
package com.hibiscusmc.hmccosmetics.gui;
|
package com.hibiscusmc.hmccosmetics.gui;
|
||||||
|
|
||||||
import com.hibiscusmc.hmccosmetics.gui.type.Type;
|
import com.hibiscusmc.hmccosmetics.gui.type.Type;
|
||||||
|
import me.lojosho.shaded.configurate.ConfigurationNode;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.spongepowered.configurate.ConfigurationNode;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class MenuItem {
|
public record MenuItem(List<Integer> slots, ItemStack item, Type type, int priority, ConfigurationNode itemConfig) {
|
||||||
|
|
||||||
private List<Integer> slots;
|
|
||||||
private ItemStack item;
|
|
||||||
private Type type;
|
|
||||||
private ConfigurationNode itemConfig;
|
|
||||||
|
|
||||||
public MenuItem(List<Integer> slots, ItemStack item, Type type, ConfigurationNode itemConfig) {
|
|
||||||
this.slots = slots;
|
|
||||||
this.item = item;
|
|
||||||
this.type = type;
|
|
||||||
this.itemConfig = itemConfig;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<Integer> getSlots() {
|
|
||||||
return slots;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ItemStack getItem() {
|
|
||||||
return item;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Type getType() {
|
|
||||||
return type;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ConfigurationNode getItemConfig() {
|
|
||||||
return itemConfig;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,12 +3,12 @@ package com.hibiscusmc.hmccosmetics.gui;
|
|||||||
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
|
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
|
||||||
import com.hibiscusmc.hmccosmetics.config.Settings;
|
import com.hibiscusmc.hmccosmetics.config.Settings;
|
||||||
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||||
|
import 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.apache.commons.io.FilenameUtils;
|
||||||
import org.jetbrains.annotations.Contract;
|
import org.jetbrains.annotations.Contract;
|
||||||
import org.jetbrains.annotations.NotNull;
|
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.io.File;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
@@ -86,7 +86,7 @@ public class Menus {
|
|||||||
new Menu(FilenameUtils.removeExtension(child.getFileName().toString()), root);
|
new Menu(FilenameUtils.removeExtension(child.getFileName().toString()), root);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
MessagesUtil.sendDebugMessages("Unable to create menu in " + child.getFileName().toString(), Level.WARNING);
|
MessagesUtil.sendDebugMessages("Unable to create menu in " + child.getFileName().toString(), Level.WARNING);
|
||||||
if (Settings.isDebugEnabled()) e.printStackTrace();
|
if (Settings.isDebugMode()) e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -3,6 +3,8 @@ package com.hibiscusmc.hmccosmetics.gui.action.actions;
|
|||||||
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
|
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
|
||||||
import com.hibiscusmc.hmccosmetics.gui.action.Action;
|
import com.hibiscusmc.hmccosmetics.gui.action.Action;
|
||||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||||
|
import me.lojosho.hibiscuscommons.hooks.Hooks;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
public class ActionConsoleCommand extends Action {
|
public class ActionConsoleCommand extends Action {
|
||||||
@@ -13,6 +15,6 @@ public class ActionConsoleCommand extends Action {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run(@NotNull CosmeticUser user, String raw) {
|
public void run(@NotNull CosmeticUser user, String raw) {
|
||||||
HMCCosmeticsPlugin.getInstance().getServer().dispatchCommand(user.getPlayer(), raw);
|
HMCCosmeticsPlugin.getInstance().getServer().dispatchCommand(Bukkit.getConsoleSender(), Hooks.processPlaceholders(user.getPlayer(), raw));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,8 +3,8 @@ package com.hibiscusmc.hmccosmetics.gui.action.actions;
|
|||||||
import com.hibiscusmc.hmccosmetics.gui.action.Action;
|
import com.hibiscusmc.hmccosmetics.gui.action.Action;
|
||||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||||
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||||
import com.hibiscusmc.hmccosmetics.util.ServerUtils;
|
import com.hibiscusmc.hmccosmetics.util.HMCCServerUtils;
|
||||||
import com.hibiscusmc.hmccosmetics.util.packets.PacketManager;
|
import com.hibiscusmc.hmccosmetics.util.packets.HMCCPacketManager;
|
||||||
import com.owen1212055.particlehelper.api.particle.types.BlockDataParticle;
|
import com.owen1212055.particlehelper.api.particle.types.BlockDataParticle;
|
||||||
import com.owen1212055.particlehelper.api.particle.types.DestinationParticle;
|
import com.owen1212055.particlehelper.api.particle.types.DestinationParticle;
|
||||||
import com.owen1212055.particlehelper.api.particle.types.velocity.VelocityParticle;
|
import com.owen1212055.particlehelper.api.particle.types.velocity.VelocityParticle;
|
||||||
@@ -42,9 +42,9 @@ public class ActionParticle extends Action {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
particle = ServerUtils.addParticleValues(particle, rawString);
|
particle = HMCCServerUtils.addParticleValues(particle, rawString);
|
||||||
Location location = user.getPlayer().getLocation();
|
Location location = user.getPlayer().getLocation();
|
||||||
for (Player player : PacketManager.getViewers(location)) {
|
for (Player player : HMCCPacketManager.getViewers(location)) {
|
||||||
particle.compile().send(player, 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.gui.action.Action;
|
||||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||||
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||||
|
import me.lojosho.hibiscuscommons.hooks.Hooks;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
public class ActionPlayerCommand extends Action {
|
public class ActionPlayerCommand extends Action {
|
||||||
@@ -13,6 +14,6 @@ public class ActionPlayerCommand extends Action {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run(@NotNull CosmeticUser user, String raw) {
|
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)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,13 +1,13 @@
|
|||||||
package com.hibiscusmc.hmccosmetics.gui.special;
|
package com.hibiscusmc.hmccosmetics.gui.special;
|
||||||
|
|
||||||
import com.hibiscusmc.hmccolor.HMCColorApi;
|
import com.hibiscusmc.hmccolor.HMCColorApi;
|
||||||
import com.hibiscusmc.hmccolor.gui.guis.Gui;
|
import com.hibiscusmc.hmccolor.shaded.gui.guis.Gui;
|
||||||
import com.hibiscusmc.hmccolor.gui.guis.GuiItem;
|
import com.hibiscusmc.hmccolor.shaded.gui.guis.GuiItem;
|
||||||
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
|
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
|
||||||
import com.hibiscusmc.hmccosmetics.config.Settings;
|
import com.hibiscusmc.hmccosmetics.config.Settings;
|
||||||
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
|
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
|
||||||
import com.hibiscusmc.hmccosmetics.hooks.Hooks;
|
|
||||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||||
|
import me.lojosho.hibiscuscommons.hooks.Hooks;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Color;
|
import org.bukkit.Color;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
@@ -31,7 +31,7 @@ public class DyeMenu {
|
|||||||
ItemStack originalItem = user.getUserCosmeticItem(cosmetic);
|
ItemStack originalItem = user.getUserCosmeticItem(cosmetic);
|
||||||
if (originalItem == null || !cosmetic.isDyable()) return;
|
if (originalItem == null || !cosmetic.isDyable()) return;
|
||||||
|
|
||||||
Gui gui = HMCColorApi.INSTANCE.colorMenu();
|
Gui gui = HMCColorApi.INSTANCE.colorMenu(player);
|
||||||
gui.updateTitle(Hooks.processPlaceholders(player, Settings.getDyeMenuName()));
|
gui.updateTitle(Hooks.processPlaceholders(player, Settings.getDyeMenuName()));
|
||||||
gui.setItem(Settings.getDyeMenuInputSlot(), new GuiItem(originalItem));
|
gui.setItem(Settings.getDyeMenuInputSlot(), new GuiItem(originalItem));
|
||||||
gui.setDefaultTopClickAction(event -> {
|
gui.setDefaultTopClickAction(event -> {
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
package com.hibiscusmc.hmccosmetics.gui.type;
|
package com.hibiscusmc.hmccosmetics.gui.type;
|
||||||
|
|
||||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||||
|
import me.lojosho.shaded.configurate.ConfigurationNode;
|
||||||
import org.bukkit.event.inventory.ClickType;
|
import org.bukkit.event.inventory.ClickType;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.spongepowered.configurate.ConfigurationNode;
|
|
||||||
|
|
||||||
public abstract class Type {
|
public abstract class Type {
|
||||||
|
|
||||||
|
|||||||
@@ -2,32 +2,37 @@ package com.hibiscusmc.hmccosmetics.gui.type.types;
|
|||||||
|
|
||||||
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
|
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
|
||||||
import com.hibiscusmc.hmccosmetics.config.Settings;
|
import com.hibiscusmc.hmccosmetics.config.Settings;
|
||||||
import com.hibiscusmc.hmccosmetics.config.serializer.ItemSerializer;
|
|
||||||
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
|
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
|
||||||
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetics;
|
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetics;
|
||||||
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticArmorType;
|
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticArmorType;
|
||||||
import com.hibiscusmc.hmccosmetics.gui.action.Actions;
|
import com.hibiscusmc.hmccosmetics.gui.action.Actions;
|
||||||
import com.hibiscusmc.hmccosmetics.gui.special.DyeMenu;
|
import com.hibiscusmc.hmccosmetics.gui.special.DyeMenu;
|
||||||
import com.hibiscusmc.hmccosmetics.gui.type.Type;
|
import com.hibiscusmc.hmccosmetics.gui.type.Type;
|
||||||
import com.hibiscusmc.hmccosmetics.hooks.Hooks;
|
|
||||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||||
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||||
|
import 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.Bukkit;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.inventory.ClickType;
|
import org.bukkit.event.inventory.ClickType;
|
||||||
import org.bukkit.inventory.EquipmentSlot;
|
import org.bukkit.inventory.EquipmentSlot;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.inventory.meta.ItemMeta;
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
|
import org.bukkit.inventory.meta.SkullMeta;
|
||||||
import org.jetbrains.annotations.Contract;
|
import org.jetbrains.annotations.Contract;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.spongepowered.configurate.ConfigurationNode;
|
|
||||||
import org.spongepowered.configurate.serialize.SerializationException;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class TypeCosmetic extends Type {
|
public class TypeCosmetic extends Type {
|
||||||
|
|
||||||
|
public TypeCosmetic(String id) {
|
||||||
|
super(id);
|
||||||
|
}
|
||||||
|
|
||||||
public TypeCosmetic() {
|
public TypeCosmetic() {
|
||||||
super("cosmetic");
|
super("cosmetic");
|
||||||
}
|
}
|
||||||
@@ -83,6 +88,12 @@ public class TypeCosmetic extends Type {
|
|||||||
if (clickType.isRightClick()) {
|
if (clickType.isRightClick()) {
|
||||||
if (!actionConfig.node("right-click").virtual()) actionStrings.addAll(actionConfig.node("right-click").getList(String.class));
|
if (!actionConfig.node("right-click").virtual()) actionStrings.addAll(actionConfig.node("right-click").getList(String.class));
|
||||||
}
|
}
|
||||||
|
if (clickType.equals(ClickType.SHIFT_LEFT)) {
|
||||||
|
if (!actionConfig.node("shift-left-click").virtual()) actionStrings.addAll(actionConfig.node("shift-left-click").getList(String.class));
|
||||||
|
}
|
||||||
|
if (clickType.equals(ClickType.SHIFT_RIGHT)) {
|
||||||
|
if (!actionConfig.node("shift-right-click").virtual()) actionStrings.addAll(actionConfig.node("shift-right-click").getList(String.class));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isUnEquippingCosmetic) {
|
if (isUnEquippingCosmetic) {
|
||||||
@@ -146,7 +157,7 @@ public class TypeCosmetic extends Type {
|
|||||||
return itemStack;
|
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");
|
MessagesUtil.sendDebugMessages("GUI Locked Item");
|
||||||
ConfigurationNode lockedItem = config.node("locked-item");
|
ConfigurationNode lockedItem = config.node("locked-item");
|
||||||
try {
|
try {
|
||||||
@@ -180,6 +191,12 @@ public class TypeCosmetic extends Type {
|
|||||||
processedLore.add(Hooks.processPlaceholders(user.getPlayer(), loreLine));
|
processedLore.add(Hooks.processPlaceholders(user.getPlayer(), loreLine));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (itemMeta instanceof SkullMeta skullMeta) {
|
||||||
|
if (skullMeta.hasOwner()) {
|
||||||
|
skullMeta.setOwner(Hooks.processPlaceholders(user.getPlayer(), skullMeta.getOwner()));
|
||||||
|
}
|
||||||
|
}
|
||||||
itemMeta.setLore(processedLore);
|
itemMeta.setLore(processedLore);
|
||||||
return itemMeta;
|
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.action.Actions;
|
||||||
import com.hibiscusmc.hmccosmetics.gui.type.Type;
|
import com.hibiscusmc.hmccosmetics.gui.type.Type;
|
||||||
import com.hibiscusmc.hmccosmetics.hooks.Hooks;
|
|
||||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
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.event.inventory.ClickType;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.inventory.meta.ItemMeta;
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
|
import org.bukkit.inventory.meta.SkullMeta;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.spongepowered.configurate.ConfigurationNode;
|
|
||||||
import org.spongepowered.configurate.serialize.SerializationException;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -42,6 +43,12 @@ public class TypeEmpty extends Type {
|
|||||||
if (clickType.isRightClick()) {
|
if (clickType.isRightClick()) {
|
||||||
if (!actionConfig.node("right-click").virtual()) actionStrings.addAll(actionConfig.node("right-click").getList(String.class));
|
if (!actionConfig.node("right-click").virtual()) actionStrings.addAll(actionConfig.node("right-click").getList(String.class));
|
||||||
}
|
}
|
||||||
|
if (clickType.equals(ClickType.SHIFT_LEFT)) {
|
||||||
|
if (!actionConfig.node("shift-left-click").virtual()) actionStrings.addAll(actionConfig.node("shift-left-click").getList(String.class));
|
||||||
|
}
|
||||||
|
if (clickType.equals(ClickType.SHIFT_RIGHT)) {
|
||||||
|
if (!actionConfig.node("shift-right-click").virtual()) actionStrings.addAll(actionConfig.node("shift-right-click").getList(String.class));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// We run the actions once we got the raw strings from the config.
|
// We run the actions once we got the raw strings from the config.
|
||||||
@@ -66,6 +73,14 @@ public class TypeEmpty extends Type {
|
|||||||
processedLore.add(Hooks.processPlaceholders(user.getPlayer(), loreLine));
|
processedLore.add(Hooks.processPlaceholders(user.getPlayer(), loreLine));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (itemMeta instanceof SkullMeta skullMeta) {
|
||||||
|
if (skullMeta.hasOwner()) {
|
||||||
|
skullMeta.setOwner(Hooks.processPlaceholders(user.getPlayer(), skullMeta.getOwner()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
itemMeta.setLore(processedLore);
|
||||||
itemStack.setItemMeta(itemMeta);
|
itemStack.setItemMeta(itemMeta);
|
||||||
return itemStack;
|
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,87 +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 HookOraxen ORAXEN_HOOK = new HookOraxen();
|
|
||||||
private static HookItemAdder ITEMADDER_HOOK = new HookItemAdder();
|
|
||||||
private static HookGeary GEARY_HOOK = new HookGeary();
|
|
||||||
private static HookMythic MYTHIC_HOOK = new HookMythic();
|
|
||||||
private static HookDenizen DENIZEN_HOOK = new HookDenizen();
|
|
||||||
private static HookHMCCosmetics HMCCOSMETIC_HOOK = new HookHMCCosmetics();
|
|
||||||
private static HookPlaceholderAPI PAPI_HOOK = new HookPlaceholderAPI();
|
|
||||||
private static HookPremiumVanish PREMIUM_VANISH_HOOK = new HookPremiumVanish();
|
|
||||||
private static HookSuperVanish SUPER_VANISH_HOOK = new HookSuperVanish();
|
|
||||||
private static HookHMCColor HMC_COLOR_HOOK = new HookHMCColor();
|
|
||||||
private static HookCMI CMI_HOOK = new HookCMI();
|
|
||||||
private static HookLibsDisguises LIBS_DISGUISES_HOOK = new HookLibsDisguises();
|
|
||||||
private static HookModelEngine MODEL_ENGINE_HOOK = new HookModelEngine();
|
|
||||||
|
|
||||||
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,45 +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
|
|
||||||
*/
|
|
||||||
@SuppressWarnings("SpellCheckingInspection")
|
|
||||||
public class HookGeary extends Hook {
|
|
||||||
private boolean enabled = false;
|
|
||||||
|
|
||||||
public HookGeary() {
|
|
||||||
super("geary");
|
|
||||||
setEnabledItemHook(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void load() {
|
|
||||||
GearyModuleKt.getGeary().getPipeline().intercept(GearyPhase.ENABLE, () -> {
|
|
||||||
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.Cosmetic;
|
||||||
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetics;
|
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.bukkit.inventory.ItemStack;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
@@ -11,8 +12,7 @@ import org.jetbrains.annotations.NotNull;
|
|||||||
*/
|
*/
|
||||||
public class HookHMCCosmetics extends Hook {
|
public class HookHMCCosmetics extends Hook {
|
||||||
public HookHMCCosmetics() {
|
public HookHMCCosmetics() {
|
||||||
super("HMCCosmetics");
|
super("HMCCosmetics", HookFlag.ITEM_SUPPORT);
|
||||||
setEnabledItemHook(true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -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.getItemsAdderReloadChange()) return;
|
|
||||||
this.enabled = true;
|
|
||||||
HMCCosmeticsPlugin.setup();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -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
|
@Override
|
||||||
public String onRequest(@NotNull OfflinePlayer player, @NotNull String params) {
|
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());
|
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));
|
List<String> placeholderArgs = Arrays.asList(params.split("_", 3));
|
||||||
|
|
||||||
switch (placeholderArgs.get(0).toLowerCase()) {
|
switch (placeholderArgs.get(0).toLowerCase()) {
|
||||||
case "using":
|
case "using":
|
||||||
if (placeholderArgs == null) {
|
if (placeholderArgs.size() >= 2) {
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if (placeholderArgs.get(1) != null) {
|
|
||||||
Cosmetic cosmetic = Cosmetics.getCosmetic(placeholderArgs.get(1));
|
Cosmetic cosmetic = Cosmetics.getCosmetic(placeholderArgs.get(1));
|
||||||
if (cosmetic == null) return "INVALID_COSMETIC";
|
if (cosmetic == null) return "INVALID_COSMETIC";
|
||||||
Cosmetic currentCosmetic = user.getCosmetic(cosmetic.getSlot());
|
Cosmetic currentCosmetic = user.getCosmetic(cosmetic.getSlot());
|
||||||
@@ -74,13 +71,10 @@ public class HMCPlaceholderExpansion extends PlaceholderExpansion {
|
|||||||
return TranslationUtil.getTranslation("using-cosmetic", String.valueOf(false));
|
return TranslationUtil.getTranslation("using-cosmetic", String.valueOf(false));
|
||||||
}
|
}
|
||||||
case "current":
|
case "current":
|
||||||
if (placeholderArgs == null) {
|
if (placeholderArgs.size() >= 2) {
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if (placeholderArgs.get(1) != null) {
|
|
||||||
CosmeticSlot slot = CosmeticSlot.valueOf(placeholderArgs.get(1).toUpperCase());
|
CosmeticSlot slot = CosmeticSlot.valueOf(placeholderArgs.get(1).toUpperCase());
|
||||||
if (slot == null) return null;
|
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();
|
if (placeholderArgs.size() == 2) return user.getCosmetic(slot).getId();
|
||||||
|
|
||||||
String output;
|
String output;
|
||||||
@@ -104,13 +98,11 @@ public class HMCPlaceholderExpansion extends PlaceholderExpansion {
|
|||||||
output = user.getCosmetic(slot).getId();
|
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":
|
case "unlocked":
|
||||||
if (placeholderArgs == null) {
|
if (placeholderArgs.size() >= 2) {
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if (placeholderArgs.get(1) != null) {
|
|
||||||
Cosmetic cosmetic = Cosmetics.getCosmetic(placeholderArgs.get(1));
|
Cosmetic cosmetic = Cosmetics.getCosmetic(placeholderArgs.get(1));
|
||||||
if (cosmetic == null) {
|
if (cosmetic == null) {
|
||||||
if (placeholderArgs.size() >= 3) {
|
if (placeholderArgs.size() >= 3) {
|
||||||
@@ -124,13 +116,10 @@ public class HMCPlaceholderExpansion extends PlaceholderExpansion {
|
|||||||
return "INVALID_COSMETIC";
|
return "INVALID_COSMETIC";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return TranslationUtil.getTranslation("unlocked-cosmetic", String.valueOf(user.canEquipCosmetic(cosmetic)));
|
return TranslationUtil.getTranslation("unlocked-cosmetic", String.valueOf(user.canEquipCosmetic(cosmetic, true)));
|
||||||
}
|
}
|
||||||
case "equipped":
|
case "equipped":
|
||||||
if (placeholderArgs == null) {
|
if (placeholderArgs.size() >= 2) {
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if (placeholderArgs.get(1) != null) {
|
|
||||||
String args1 = placeholderArgs.get(1);
|
String args1 = placeholderArgs.get(1);
|
||||||
|
|
||||||
if (EnumUtils.isValidEnum(CosmeticSlot.class, args1.toUpperCase())) {
|
if (EnumUtils.isValidEnum(CosmeticSlot.class, args1.toUpperCase())) {
|
||||||
@@ -152,8 +141,31 @@ public class HMCPlaceholderExpansion extends PlaceholderExpansion {
|
|||||||
return "INVALID_COSMETIC";
|
return "INVALID_COSMETIC";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (user.getCosmetic(cosmetic.getSlot()) == null) return "false";
|
Cosmetic equippedCosmetic = user.getCosmetic(cosmetic.getSlot());
|
||||||
return TranslationUtil.getTranslation("equipped-cosmetic", String.valueOf(cosmetic.getId() == user.getCosmetic(cosmetic.getSlot()).getId()));
|
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 "wardrobe-enabled":
|
case "wardrobe-enabled":
|
||||||
return TranslationUtil.getTranslation("in-wardrobe", String.valueOf(user.isInWardrobe()));
|
return TranslationUtil.getTranslation("in-wardrobe", String.valueOf(user.isInWardrobe()));
|
||||||
@@ -215,6 +227,7 @@ public class HMCPlaceholderExpansion extends PlaceholderExpansion {
|
|||||||
if (!item.hasItemMeta()) return null;
|
if (!item.hasItemMeta()) return null;
|
||||||
ItemMeta itemMeta = item.getItemMeta();
|
ItemMeta itemMeta = item.getItemMeta();
|
||||||
if (itemMeta == null) return null;
|
if (itemMeta == null) return null;
|
||||||
|
if (!itemMeta.hasDisplayName()) return null;
|
||||||
return itemMeta.getDisplayName();
|
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();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -31,7 +31,7 @@ public class WGListener implements Listener {
|
|||||||
Location location = event.getPlayer().getLocation();
|
Location location = event.getPlayer().getLocation();
|
||||||
ApplicableRegionSet set = getRegions(location);
|
ApplicableRegionSet set = getRegions(location);
|
||||||
if (user.getHidden()) {
|
if (user.getHidden()) {
|
||||||
if (user.getHiddenReason() == CosmeticUser.HiddenReason.WORLDGUARD && set.getRegions().size() == 0) {
|
if (user.getHiddenReason() == CosmeticUser.HiddenReason.WORLDGUARD && set.getRegions().isEmpty()) {
|
||||||
user.showCosmetics();
|
user.showCosmetics();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -59,7 +59,7 @@ public class WGListener implements Listener {
|
|||||||
Location location = event.getTo();
|
Location location = event.getTo();
|
||||||
ApplicableRegionSet set = getRegions(location);
|
ApplicableRegionSet set = getRegions(location);
|
||||||
if (user.getHidden()) {
|
if (user.getHidden()) {
|
||||||
if (user.getHiddenReason() == CosmeticUser.HiddenReason.WORLDGUARD && set.getRegions().size() == 0) {
|
if (user.getHiddenReason() == CosmeticUser.HiddenReason.WORLDGUARD && set.getRegions().isEmpty()) {
|
||||||
user.showCosmetics();
|
user.showCosmetics();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,30 @@
|
|||||||
|
package com.hibiscusmc.hmccosmetics.listener;
|
||||||
|
|
||||||
|
import com.destroystokyo.paper.event.player.PlayerArmorChangeEvent;
|
||||||
|
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()));
|
||||||
|
}
|
||||||
|
|
||||||
|
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,13 @@ package com.hibiscusmc.hmccosmetics.listener;
|
|||||||
|
|
||||||
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
|
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
|
||||||
import com.hibiscusmc.hmccosmetics.config.DatabaseSettings;
|
import com.hibiscusmc.hmccosmetics.config.DatabaseSettings;
|
||||||
|
import com.hibiscusmc.hmccosmetics.config.Settings;
|
||||||
import com.hibiscusmc.hmccosmetics.database.Database;
|
import com.hibiscusmc.hmccosmetics.database.Database;
|
||||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUsers;
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUsers;
|
||||||
import com.hibiscusmc.hmccosmetics.user.manager.UserEmoteManager;
|
import com.hibiscusmc.hmccosmetics.user.manager.UserEmoteManager;
|
||||||
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.entity.Entity;
|
|
||||||
import org.bukkit.entity.EntityType;
|
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
@@ -22,22 +21,44 @@ public class PlayerConnectionListener implements Listener {
|
|||||||
@EventHandler(priority = EventPriority.MONITOR)
|
@EventHandler(priority = EventPriority.MONITOR)
|
||||||
public void onPlayerJoin(@NotNull PlayerJoinEvent event) {
|
public void onPlayerJoin(@NotNull PlayerJoinEvent event) {
|
||||||
if (event.getPlayer().isOp() || event.getPlayer().hasPermission("hmccosmetics.notifyupdate")) {
|
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(
|
MessagesUtil.sendMessageNoKey(
|
||||||
event.getPlayer(),
|
event.getPlayer(),
|
||||||
"<br>" +
|
"<br>" +
|
||||||
"<GRAY>There is a new version of <light_purple><Bold>HMCCosmetics<reset><gray> available!<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>!" +
|
"<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>"
|
"<br>"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Runnable run = () -> {
|
Runnable run = () -> {
|
||||||
|
if (!event.getPlayer().isOnline()) return; // If a player is no longer online, don't run this.
|
||||||
CosmeticUser user = Database.get(event.getPlayer().getUniqueId());
|
CosmeticUser user = Database.get(event.getPlayer().getUniqueId());
|
||||||
CosmeticUsers.addUser(user);
|
CosmeticUsers.addUser(user);
|
||||||
MessagesUtil.sendDebugMessages("Run User Join");
|
MessagesUtil.sendDebugMessages("Run User Join");
|
||||||
Bukkit.getScheduler().runTaskLater(HMCCosmeticsPlugin.getInstance(), () -> user.updateCosmetic(), 4);
|
|
||||||
|
// Handle gamemode check
|
||||||
|
if (Settings.getDisabledGamemodes().contains(user.getPlayer().getGameMode().toString())) {
|
||||||
|
user.hideCosmetics(CosmeticUser.HiddenReason.GAMEMODE);
|
||||||
|
} else {
|
||||||
|
if (user.getHiddenReason() != null && user.getHiddenReason().equals(CosmeticUser.HiddenReason.GAMEMODE)) {
|
||||||
|
user.showCosmetics();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Handle world check
|
||||||
|
if (Settings.getDisabledWorlds().contains(user.getPlayer().getWorld().getName())) {
|
||||||
|
user.hideCosmetics(CosmeticUser.HiddenReason.WORLD);
|
||||||
|
} else {
|
||||||
|
if (user.getHiddenReason() != null && user.getHiddenReason().equals(CosmeticUser.HiddenReason.WORLD)) {
|
||||||
|
user.showCosmetics();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// And finally, launch an update for the cosmetics they have.
|
||||||
|
Bukkit.getScheduler().runTaskLater(HMCCosmeticsPlugin.getInstance(), () -> {
|
||||||
|
if (user.getPlayer() == null) return;
|
||||||
|
user.updateCosmetic();
|
||||||
|
}, 4);
|
||||||
};
|
};
|
||||||
|
|
||||||
if (DatabaseSettings.isEnabledDelay()) {
|
if (DatabaseSettings.isEnabledDelay()) {
|
||||||
@@ -51,17 +72,11 @@ public class PlayerConnectionListener implements Listener {
|
|||||||
@EventHandler(priority = EventPriority.MONITOR)
|
@EventHandler(priority = EventPriority.MONITOR)
|
||||||
public void onPlayerQuit(@NotNull PlayerQuitEvent event) {
|
public void onPlayerQuit(@NotNull PlayerQuitEvent event) {
|
||||||
CosmeticUser user = CosmeticUsers.getUser(event.getPlayer());
|
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 (user == null) return; // Player never initialized, don't do anything
|
||||||
if (!event.getPlayer().getPassengers().isEmpty()) {
|
if (user.isInWardrobe()) {
|
||||||
for (Entity entity : event.getPlayer().getPassengers()) {
|
user.leaveWardrobe(true);
|
||||||
if (entity.getType() == EntityType.ARMOR_STAND) {
|
user.getPlayer().setInvisible(false);
|
||||||
entity.remove();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
if (user.isInWardrobe()) user.leaveWardrobe();
|
|
||||||
if (user.getUserEmoteManager().isPlayingEmote()) {
|
if (user.getUserEmoteManager().isPlayingEmote()) {
|
||||||
user.getUserEmoteManager().stopEmote(UserEmoteManager.StopEmoteReason.CONNECTION);
|
user.getUserEmoteManager().stopEmote(UserEmoteManager.StopEmoteReason.CONNECTION);
|
||||||
event.getPlayer().setInvisible(false);
|
event.getPlayer().setInvisible(false);
|
||||||
|
|||||||
@@ -22,9 +22,15 @@ import com.hibiscusmc.hmccosmetics.gui.Menus;
|
|||||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUsers;
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUsers;
|
||||||
import com.hibiscusmc.hmccosmetics.user.manager.UserEmoteManager;
|
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.MessagesUtil;
|
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.HibiscusHookReload;
|
||||||
|
import me.lojosho.hibiscuscommons.api.events.HibiscusPlayerUnVanishEvent;
|
||||||
|
import me.lojosho.hibiscuscommons.api.events.HibiscusPlayerVanishEvent;
|
||||||
|
import me.lojosho.hibiscuscommons.hooks.items.HookItemAdder;
|
||||||
|
import me.lojosho.hibiscuscommons.util.packets.PacketManager;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
@@ -56,9 +62,11 @@ public class PlayerGameListener implements Listener {
|
|||||||
public PlayerGameListener() {
|
public PlayerGameListener() {
|
||||||
registerInventoryClickListener();
|
registerInventoryClickListener();
|
||||||
registerMenuChangeListener();
|
registerMenuChangeListener();
|
||||||
|
registerEntityStatusListener();
|
||||||
registerPlayerEquipmentListener();
|
registerPlayerEquipmentListener();
|
||||||
registerPlayerArmListener();
|
registerPlayerArmListener();
|
||||||
registerEntityUseListener();
|
registerEntityUseListener();
|
||||||
|
registerSlotChangeListener();
|
||||||
|
|
||||||
//registerLookMovement();
|
//registerLookMovement();
|
||||||
//registerMoveListener();
|
//registerMoveListener();
|
||||||
@@ -76,14 +84,14 @@ public class PlayerGameListener implements Listener {
|
|||||||
ItemStack item = event.getCurrentItem();
|
ItemStack item = event.getCurrentItem();
|
||||||
if (item == null) return;
|
if (item == null) return;
|
||||||
|
|
||||||
if (Settings.isDestroyLooseCosmetics() && InventoryUtils.isCosmeticItem(event.getCurrentItem())) {
|
if (Settings.isDestroyLooseCosmetics() && HMCCInventoryUtils.isCosmeticItem(event.getCurrentItem())) {
|
||||||
MessagesUtil.sendDebugMessages("remvoe item");
|
MessagesUtil.sendDebugMessages("remvoe item");
|
||||||
event.getWhoClicked().getInventory().removeItem(event.getCurrentItem());
|
event.getWhoClicked().getInventory().removeItem(event.getCurrentItem());
|
||||||
}
|
}
|
||||||
|
|
||||||
EquipmentSlot slot = getArmorSlot(item.getType());
|
EquipmentSlot slot = getArmorSlot(item.getType());
|
||||||
if (slot == null) return;
|
if (slot == null) return;
|
||||||
CosmeticSlot cosmeticSlot = InventoryUtils.BukkitCosmeticSlot(slot);
|
CosmeticSlot cosmeticSlot = HMCCInventoryUtils.BukkitCosmeticSlot(slot);
|
||||||
if (cosmeticSlot == null) return;
|
if (cosmeticSlot == null) return;
|
||||||
if (!user.hasCosmeticInSlot(cosmeticSlot)) return;
|
if (!user.hasCosmeticInSlot(cosmeticSlot)) return;
|
||||||
Bukkit.getScheduler().runTaskLater(HMCCosmeticsPlugin.getInstance(), () -> {
|
Bukkit.getScheduler().runTaskLater(HMCCosmeticsPlugin.getInstance(), () -> {
|
||||||
@@ -122,6 +130,14 @@ public class PlayerGameListener implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Bukkit.getScheduler().runTaskLater(HMCCosmeticsPlugin.getInstance(), () -> {
|
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 {
|
||||||
|
if (user.getHiddenReason() != null && user.getHiddenReason().equals(CosmeticUser.HiddenReason.WORLD)) {
|
||||||
|
user.showCosmetics();
|
||||||
|
}
|
||||||
|
}
|
||||||
if (user.hasCosmeticInSlot(CosmeticSlot.BACKPACK) && user.getUserBackpackManager() != null) {
|
if (user.hasCosmeticInSlot(CosmeticSlot.BACKPACK) && user.getUserBackpackManager() != null) {
|
||||||
user.respawnBackpack();
|
user.respawnBackpack();
|
||||||
}
|
}
|
||||||
@@ -138,7 +154,7 @@ public class PlayerGameListener implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.LOW)
|
@EventHandler(priority = EventPriority.LOW)
|
||||||
public void portalTeleport(PlayerPortalEvent event) {
|
public void onPortalTeleport(PlayerPortalEvent event) {
|
||||||
CosmeticUser user = CosmeticUsers.getUser(event.getPlayer().getUniqueId());
|
CosmeticUser user = CosmeticUsers.getUser(event.getPlayer().getUniqueId());
|
||||||
|
|
||||||
MessagesUtil.sendDebugMessages("Player Teleport Event");
|
MessagesUtil.sendDebugMessages("Player Teleport Event");
|
||||||
@@ -157,19 +173,16 @@ public class PlayerGameListener implements Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.NORMAL)
|
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
||||||
public void onPlayerHit(EntityDamageByEntityEvent event) {
|
public void onPlayerHit(EntityDamageByEntityEvent event) {
|
||||||
if (event.isCancelled()) return;
|
|
||||||
Entity entity = event.getEntity();
|
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))
|
if (!entity.getPersistentDataContainer().has(new NamespacedKey(HMCCosmeticsPlugin.getInstance(), "cosmeticMob"), PersistentDataType.SHORT))
|
||||||
return;
|
return;
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.LOW)
|
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
||||||
public void onPlayerDamaged(EntityDamageEvent event) {
|
public void onPlayerDamaged(EntityDamageEvent event) {
|
||||||
if (event.isCancelled()) return;
|
|
||||||
if (!(event.getEntity() instanceof Player player)) return;
|
if (!(event.getEntity() instanceof Player player)) return;
|
||||||
CosmeticUser user = CosmeticUsers.getUser(player);
|
CosmeticUser user = CosmeticUsers.getUser(player);
|
||||||
if (user == null) return;
|
if (user == null) return;
|
||||||
@@ -186,22 +199,24 @@ public class PlayerGameListener implements Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.MONITOR)
|
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
||||||
public void onPlayerLook(PlayerMoveEvent event) {
|
public void onPlayerLook(PlayerMoveEvent event) {
|
||||||
if (event.isCancelled()) return;
|
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
CosmeticUser user = CosmeticUsers.getUser(player);
|
CosmeticUser user = CosmeticUsers.getUser(player);
|
||||||
if (user == null) return;
|
if (user == null) return;
|
||||||
// Really need to look into optimization of this
|
if (!Settings.isEmoteMoveCheck() && user.getUserEmoteManager().isPlayingEmote()) {
|
||||||
|
event.setCancelled(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
user.updateCosmetic(CosmeticSlot.BACKPACK);
|
user.updateCosmetic(CosmeticSlot.BACKPACK);
|
||||||
user.updateCosmetic(CosmeticSlot.BALLOON);
|
user.updateCosmetic(CosmeticSlot.BALLOON);
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.MONITOR)
|
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||||
public void onPlayerPoseChange(EntityPoseChangeEvent event) {
|
public void onPlayerPoseChange(EntityPoseChangeEvent event) {
|
||||||
if (!(event.getEntity() instanceof Player player)) return;
|
if (!(event.getEntity() instanceof Player player)) return;
|
||||||
CosmeticUser user = CosmeticUsers.getUser(player);
|
CosmeticUser user = CosmeticUsers.getUser(player);
|
||||||
if (user == null) return;
|
if (user == null || user.isInWardrobe()) return;
|
||||||
if (!user.hasCosmeticInSlot(CosmeticSlot.BACKPACK)) return;
|
if (!user.hasCosmeticInSlot(CosmeticSlot.BACKPACK)) return;
|
||||||
Pose pose = event.getPose();
|
Pose pose = event.getPose();
|
||||||
if (pose.equals(Pose.STANDING)) {
|
if (pose.equals(Pose.STANDING)) {
|
||||||
@@ -218,10 +233,9 @@ public class PlayerGameListener implements Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.LOW)
|
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
||||||
public void onPlayerArmorDamage(PlayerItemDamageEvent event) {
|
public void onPlayerArmorDamage(PlayerItemDamageEvent event) {
|
||||||
// Possibly look into cancelling the event, then handling the damage on our own.
|
// Possibly look into cancelling the event, then handling the damage on our own.
|
||||||
if (event.isCancelled()) return;
|
|
||||||
MessagesUtil.sendDebugMessages("PlayerItemDamageEvent");
|
MessagesUtil.sendDebugMessages("PlayerItemDamageEvent");
|
||||||
|
|
||||||
int slot = -1;
|
int slot = -1;
|
||||||
@@ -239,7 +253,7 @@ public class PlayerGameListener implements Listener {
|
|||||||
|
|
||||||
CosmeticUser user = CosmeticUsers.getUser(event.getPlayer().getUniqueId());
|
CosmeticUser user = CosmeticUsers.getUser(event.getPlayer().getUniqueId());
|
||||||
if (user == null) return;
|
if (user == null) return;
|
||||||
CosmeticSlot cosmeticSlot = InventoryUtils.BukkitCosmeticSlot(slot);
|
CosmeticSlot cosmeticSlot = HMCCInventoryUtils.BukkitCosmeticSlot(slot);
|
||||||
|
|
||||||
if (!user.hasCosmeticInSlot(cosmeticSlot)) {
|
if (!user.hasCosmeticInSlot(cosmeticSlot)) {
|
||||||
MessagesUtil.sendDebugMessages("No cosmetic in " + cosmeticSlot);
|
MessagesUtil.sendDebugMessages("No cosmetic in " + cosmeticSlot);
|
||||||
@@ -253,7 +267,7 @@ public class PlayerGameListener implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.LOW)
|
@EventHandler(priority = EventPriority.LOW)
|
||||||
public void playerOffhandSwap(PlayerSwapHandItemsEvent event) {
|
public void onPlayerOffhandSwap(PlayerSwapHandItemsEvent event) {
|
||||||
CosmeticUser user = CosmeticUsers.getUser(event.getPlayer().getUniqueId());
|
CosmeticUser user = CosmeticUsers.getUser(event.getPlayer().getUniqueId());
|
||||||
if (user == null) return;
|
if (user == null) return;
|
||||||
// Really need to look into optimization of this
|
// Really need to look into optimization of this
|
||||||
@@ -265,6 +279,10 @@ public class PlayerGameListener implements Listener {
|
|||||||
}
|
}
|
||||||
Bukkit.getScheduler().runTaskLater(HMCCosmeticsPlugin.getInstance(), () -> {
|
Bukkit.getScheduler().runTaskLater(HMCCosmeticsPlugin.getInstance(), () -> {
|
||||||
user.updateCosmetic(CosmeticSlot.OFFHAND);
|
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);
|
}, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -276,9 +294,8 @@ public class PlayerGameListener implements Listener {
|
|||||||
if (user.isInWardrobe()) event.setCancelled(true);
|
if (user.isInWardrobe()) event.setCancelled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.MONITOR)
|
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||||
public void playerInvisibility(EntityPotionEffectEvent event) {
|
public void onPlayerPotionEffect(EntityPotionEffectEvent event) {
|
||||||
if (event.isCancelled()) return;
|
|
||||||
if (!event.getModifiedType().equals(PotionEffectType.INVISIBILITY)) return;
|
if (!event.getModifiedType().equals(PotionEffectType.INVISIBILITY)) return;
|
||||||
if (!event.getEntityType().equals(EntityType.PLAYER)) return;
|
if (!event.getEntityType().equals(EntityType.PLAYER)) return;
|
||||||
Player player = (Player) event.getEntity();
|
Player player = (Player) event.getEntity();
|
||||||
@@ -303,7 +320,6 @@ public class PlayerGameListener implements Listener {
|
|||||||
//NMSHandlers.getHandler().slotUpdate(event.getPlayer(), event.getPreviousSlot());
|
//NMSHandlers.getHandler().slotUpdate(event.getPlayer(), event.getPreviousSlot());
|
||||||
Bukkit.getScheduler().runTaskLater(HMCCosmeticsPlugin.getInstance(), () -> {
|
Bukkit.getScheduler().runTaskLater(HMCCosmeticsPlugin.getInstance(), () -> {
|
||||||
user.updateCosmetic(CosmeticSlot.MAINHAND);
|
user.updateCosmetic(CosmeticSlot.MAINHAND);
|
||||||
user.updateCosmetic(CosmeticSlot.OFFHAND);
|
|
||||||
}, 2);
|
}, 2);
|
||||||
|
|
||||||
// #84, Riptides mess with backpacks
|
// #84, Riptides mess with backpacks
|
||||||
@@ -322,7 +338,7 @@ public class PlayerGameListener implements Listener {
|
|||||||
|
|
||||||
if (user.isInWardrobe()) user.leaveWardrobe();
|
if (user.isInWardrobe()) user.leaveWardrobe();
|
||||||
|
|
||||||
if (Settings.getUnapplyOnDeath() && !event.getEntity().hasPermission("hmccosmetics.unapplydeath.bypass")) {
|
if (Settings.isUnapplyOnDeath() && !event.getEntity().hasPermission("hmccosmetics.unapplydeath.bypass")) {
|
||||||
user.removeCosmetics();
|
user.removeCosmetics();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -331,51 +347,92 @@ public class PlayerGameListener implements Listener {
|
|||||||
public void onPlayerGamemodeSwitch(PlayerGameModeChangeEvent event) {
|
public void onPlayerGamemodeSwitch(PlayerGameModeChangeEvent event) {
|
||||||
CosmeticUser user = CosmeticUsers.getUser(event.getPlayer());
|
CosmeticUser user = CosmeticUsers.getUser(event.getPlayer());
|
||||||
if (user == null) return;
|
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 {
|
||||||
|
if (user.getHiddenReason() != null && user.getHiddenReason().equals(CosmeticUser.HiddenReason.GAMEMODE)) {
|
||||||
|
user.showCosmetics();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (Settings.isDestroyLooseCosmetics()) {
|
if (Settings.isDestroyLooseCosmetics()) {
|
||||||
ItemStack[] equippedArmor = event.getPlayer().getInventory().getArmorContents();
|
ItemStack[] equippedArmor = event.getPlayer().getInventory().getArmorContents();
|
||||||
if (equippedArmor.length == 0) return;
|
if (equippedArmor.length == 0) return;
|
||||||
for (ItemStack armor : equippedArmor) {
|
for (ItemStack armor : equippedArmor) {
|
||||||
if (InventoryUtils.isCosmeticItem(armor)) armor.setAmount(0);
|
if (HMCCInventoryUtils.isCosmeticItem(armor)) armor.setAmount(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.LOW)
|
@EventHandler(priority = EventPriority.LOW)
|
||||||
public void onPlayerCosemticEquip(PlayerCosmeticPostEquipEvent event) {
|
public void onPlayerCosmeticEquip(PlayerCosmeticPostEquipEvent event) {
|
||||||
CosmeticUser user = event.getUser();
|
CosmeticUser user = event.getUser();
|
||||||
if (user.isInWardrobe() && event.getCosmetic().getSlot().equals(CosmeticSlot.BALLOON)) {
|
if (user.isInWardrobe() && event.getCosmetic().getSlot().equals(CosmeticSlot.BALLOON)) {
|
||||||
Location NPCLocation = user.getWardrobeManager().getNpcLocation();
|
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
|
// We know that no other entity besides a regular player will be in the wardrobe
|
||||||
PacketManager.sendTeleportPacket(user.getBalloonManager().getPufferfishBalloonId(), NPCLocation.add(Settings.getBalloonOffset()), false, List.of(user.getPlayer()));
|
List<Player> viewer = List.of(user.getPlayer());
|
||||||
user.getBalloonManager().getModelEntity().teleport(NPCLocation.add(Settings.getBalloonOffset()));
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||||
public void onPlayerMounted(EntityMountEvent event) {
|
public void onPlayerMounted(EntityMountEvent event) {
|
||||||
if (!event.isCancelled() && event.getEntity() instanceof Player player) {
|
if (event.getEntity() instanceof Player player) {
|
||||||
CosmeticUser user = CosmeticUsers.getUser(player);
|
CosmeticUser user = CosmeticUsers.getUser(player);
|
||||||
if (user == null) return;
|
if (user == null) return;
|
||||||
|
|
||||||
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(HMCCosmeticsPlugin.getInstance(), ()->{
|
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(HMCCosmeticsPlugin.getInstance(), user::respawnBackpack, 1);
|
||||||
user.respawnBackpack();
|
|
||||||
}, 1);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||||
public void onPlayerDismounted(EntityDismountEvent event) {
|
public void onPlayerDismounted(EntityDismountEvent event) {
|
||||||
if (!event.isCancelled() && event.getDismounted() instanceof Player player) {
|
if (event.getDismounted() instanceof Player player) {
|
||||||
CosmeticUser user = CosmeticUsers.getUser(player);
|
CosmeticUser user = CosmeticUsers.getUser(player);
|
||||||
if (user == null) return;
|
if (user == null) return;
|
||||||
|
|
||||||
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(HMCCosmeticsPlugin.getInstance(), ()->{
|
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(HMCCosmeticsPlugin.getInstance(), user::respawnBackpack, 1);
|
||||||
user.respawnBackpack();
|
|
||||||
}, 1);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@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.getHidden()) return;
|
||||||
|
if (user.getHiddenReason().equals(CosmeticUser.HiddenReason.PLUGIN)) user.showCosmetics();
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||||
|
public void onHookReload(HibiscusHookReload event) {
|
||||||
|
if (event.getHook() instanceof HookItemAdder hook) {
|
||||||
|
switch (event.getReloadType()) {
|
||||||
|
case INITIAL -> {
|
||||||
|
HMCCosmeticsPlugin.setup();
|
||||||
|
}
|
||||||
|
case RELOAD -> {
|
||||||
|
if (!Settings.isItemsAdderChangeReload()) return;
|
||||||
|
HMCCosmeticsPlugin.setup();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void registerInventoryClickListener() {
|
private void registerInventoryClickListener() {
|
||||||
ProtocolLibrary.getProtocolManager().addPacketListener(new PacketAdapter(HMCCosmeticsPlugin.getInstance(), ListenerPriority.NORMAL, PacketType.Play.Client.WINDOW_CLICK) {
|
ProtocolLibrary.getProtocolManager().addPacketListener(new PacketAdapter(HMCCosmeticsPlugin.getInstance(), ListenerPriority.NORMAL, PacketType.Play.Client.WINDOW_CLICK) {
|
||||||
@Override
|
@Override
|
||||||
@@ -392,7 +449,8 @@ public class PlayerGameListener implements Listener {
|
|||||||
|
|
||||||
CosmeticUser user = CosmeticUsers.getUser(player);
|
CosmeticUser user = CosmeticUsers.getUser(player);
|
||||||
if (user == null) return;
|
if (user == null) return;
|
||||||
CosmeticSlot cosmeticSlot = InventoryUtils.NMSCosmeticSlot(slotClicked);
|
if (user.isInWardrobe()) return;
|
||||||
|
CosmeticSlot cosmeticSlot = HMCCInventoryUtils.NMSCosmeticSlot(slotClicked);
|
||||||
if (cosmeticSlot == null) return;
|
if (cosmeticSlot == null) return;
|
||||||
if (!user.hasCosmeticInSlot(cosmeticSlot)) return;
|
if (!user.hasCosmeticInSlot(cosmeticSlot)) return;
|
||||||
Bukkit.getScheduler().runTaskLater(HMCCosmeticsPlugin.getInstance(), () -> user.updateCosmetic(cosmeticSlot), 1);
|
Bukkit.getScheduler().runTaskLater(HMCCosmeticsPlugin.getInstance(), () -> user.updateCosmetic(cosmeticSlot), 1);
|
||||||
@@ -418,9 +476,11 @@ public class PlayerGameListener implements Listener {
|
|||||||
|
|
||||||
HashMap<Integer, ItemStack> items = new HashMap<>();
|
HashMap<Integer, ItemStack> items = new HashMap<>();
|
||||||
|
|
||||||
for (Cosmetic cosmetic : user.getCosmetics()) {
|
if (!user.isInWardrobe()) {
|
||||||
if ((cosmetic instanceof CosmeticArmorType cosmeticArmorType)) {
|
for (Cosmetic cosmetic : user.getCosmetics()) {
|
||||||
items.put(InventoryUtils.getPacketArmorSlot(cosmeticArmorType.getEquipSlot()), user.getUserCosmeticItem(cosmeticArmorType));
|
if ((cosmetic instanceof CosmeticArmorType cosmeticArmorType)) {
|
||||||
|
items.put(HMCCInventoryUtils.getPacketArmorSlot(cosmeticArmorType.getEquipSlot()), user.getUserCosmeticItem(cosmeticArmorType));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -451,6 +511,31 @@ public class PlayerGameListener implements Listener {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void registerSlotChangeListener() {
|
||||||
|
ProtocolLibrary.getProtocolManager().addPacketListener(new PacketAdapter(HMCCosmeticsPlugin.getInstance(), ListenerPriority.NORMAL, PacketType.Play.Server.SET_SLOT) {
|
||||||
|
@Override
|
||||||
|
public void onPacketSending(PacketEvent event) {
|
||||||
|
MessagesUtil.sendDebugMessages("SetSlot Initial ");
|
||||||
|
|
||||||
|
Player player = event.getPlayer();
|
||||||
|
if (event.getPlayer() == null) return;
|
||||||
|
|
||||||
|
int windowID = event.getPacket().getIntegers().read(0);
|
||||||
|
if (windowID != 0) return;
|
||||||
|
|
||||||
|
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));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
private void registerPlayerEquipmentListener() {
|
private void registerPlayerEquipmentListener() {
|
||||||
ProtocolLibrary.getProtocolManager().addPacketListener(new PacketAdapter(HMCCosmeticsPlugin.getInstance(), ListenerPriority.NORMAL, PacketType.Play.Server.ENTITY_EQUIPMENT) {
|
ProtocolLibrary.getProtocolManager().addPacketListener(new PacketAdapter(HMCCosmeticsPlugin.getInstance(), ListenerPriority.NORMAL, PacketType.Play.Server.ENTITY_EQUIPMENT) {
|
||||||
@Override
|
@Override
|
||||||
@@ -459,17 +544,35 @@ public class PlayerGameListener implements Listener {
|
|||||||
int entityID = event.getPacket().getIntegers().read(0);
|
int entityID = event.getPacket().getIntegers().read(0);
|
||||||
// User
|
// User
|
||||||
CosmeticUser user = CosmeticUsers.getUser(entityID);
|
CosmeticUser user = CosmeticUsers.getUser(entityID);
|
||||||
if (user == null) {
|
if (user == null) return;
|
||||||
return;
|
if (user.isInWardrobe()) return;
|
||||||
}
|
|
||||||
|
|
||||||
List<com.comphenix.protocol.wrappers.Pair<EnumWrappers.ItemSlot, ItemStack>> armor = event.getPacket().getSlotStackPairLists().read(0);
|
List<com.comphenix.protocol.wrappers.Pair<EnumWrappers.ItemSlot, ItemStack>> armor = event.getPacket().getSlotStackPairLists().read(0);
|
||||||
|
|
||||||
for (EquipmentSlot equipmentSlot : EquipmentSlot.values()) {
|
for (int i = 0; i < armor.size(); i++) {
|
||||||
CosmeticArmorType cosmeticArmor = (CosmeticArmorType) user.getCosmetic(InventoryUtils.BukkitCosmeticSlot(equipmentSlot));
|
com.comphenix.protocol.wrappers.Pair<EnumWrappers.ItemSlot, ItemStack> pair = armor.get(i);
|
||||||
if (cosmeticArmor == null) continue;
|
switch (pair.getFirst()) {
|
||||||
Pair<EnumWrappers.ItemSlot, ItemStack> pair = new Pair<>(InventoryUtils.itemBukkitSlot(cosmeticArmor.getEquipSlot()), cosmeticArmor.getItem());
|
case MAINHAND -> {
|
||||||
armor.add(pair);
|
if (user.getPlayer() == event.getPlayer()) continue; // When a player scrolls real fast, it messes up the mainhand. This fixes it
|
||||||
|
armor.set(i, new Pair<>(pair.getFirst(), user.getPlayer().getInventory().getItemInMainHand()));
|
||||||
|
}
|
||||||
|
case OFFHAND -> {
|
||||||
|
if (Settings.isCosmeticForceOffhandCosmeticShow() && user.hasCosmeticInSlot(CosmeticSlot.OFFHAND)) {
|
||||||
|
ItemStack item = user.getUserCosmeticItem(CosmeticSlot.OFFHAND);
|
||||||
|
if (item == null) continue;
|
||||||
|
Pair<EnumWrappers.ItemSlot, ItemStack> offhandPair = new Pair<>(EnumWrappers.ItemSlot.OFFHAND, item);
|
||||||
|
armor.set(i, offhandPair);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
default -> {
|
||||||
|
CosmeticArmorType cosmeticArmor = (CosmeticArmorType) user.getCosmetic(HMCCInventoryUtils.getItemSlotToCosmeticSlot(pair.getFirst()));
|
||||||
|
if (cosmeticArmor == null) continue;
|
||||||
|
ItemStack item = user.getUserCosmeticItem(cosmeticArmor);
|
||||||
|
if (item == null) continue;
|
||||||
|
Pair<EnumWrappers.ItemSlot, ItemStack> armorPair = new Pair<>(HMCCInventoryUtils.itemBukkitSlot(cosmeticArmor.getEquipSlot()), item);
|
||||||
|
armor.set(i, armorPair);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
event.getPacket().getSlotStackPairLists().write(0, armor);
|
event.getPacket().getSlotStackPairLists().write(0, armor);
|
||||||
@@ -478,6 +581,27 @@ public class PlayerGameListener implements Listener {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void registerEntityStatusListener() {
|
||||||
|
ProtocolLibrary.getProtocolManager().addPacketListener(new PacketAdapter(HMCCosmeticsPlugin.getInstance(), ListenerPriority.NORMAL, PacketType.Play.Server.ENTITY_STATUS) {
|
||||||
|
@Override
|
||||||
|
public void onPacketSending(PacketEvent event) {
|
||||||
|
int entityid = event.getPacket().getIntegers().read(0);
|
||||||
|
byte status = event.getPacket().getBytes().read(0);
|
||||||
|
|
||||||
|
MessagesUtil.sendDebugMessages("EntityStatus Initial " + entityid + " - " + status);
|
||||||
|
if (status != 55) return;
|
||||||
|
|
||||||
|
CosmeticUser user = CosmeticUsers.getUser(entityid);
|
||||||
|
if (user == null) {
|
||||||
|
MessagesUtil.sendDebugMessages("EntityStatus User is null");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!user.hasCosmeticInSlot(CosmeticSlot.OFFHAND)) return;
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
private void registerPlayerArmListener() {
|
private void registerPlayerArmListener() {
|
||||||
ProtocolLibrary.getProtocolManager().addPacketListener(new PacketAdapter(HMCCosmeticsPlugin.getInstance(), ListenerPriority.NORMAL, PacketType.Play.Client.ARM_ANIMATION) {
|
ProtocolLibrary.getProtocolManager().addPacketListener(new PacketAdapter(HMCCosmeticsPlugin.getInstance(), ListenerPriority.NORMAL, PacketType.Play.Client.ARM_ANIMATION) {
|
||||||
@Override
|
@Override
|
||||||
@@ -491,6 +615,7 @@ public class PlayerGameListener implements Listener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!user.isInWardrobe()) return;
|
if (!user.isInWardrobe()) return;
|
||||||
|
if (!user.getWardrobeManager().getWardrobeStatus().equals(UserWardrobeManager.WardrobeStatus.RUNNING)) return;
|
||||||
Menu menu = Menus.getDefaultMenu();
|
Menu menu = Menus.getDefaultMenu();
|
||||||
if (menu == null) return;
|
if (menu == null) return;
|
||||||
menu.openMenu(user);
|
menu.openMenu(user);
|
||||||
@@ -521,7 +646,11 @@ public class PlayerGameListener implements Listener {
|
|||||||
MessagesUtil.sendDebugMessages("Look Packet ");
|
MessagesUtil.sendDebugMessages("Look Packet ");
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
if (event.getPlayer() == null) return;
|
if (event.getPlayer() == null) return;
|
||||||
if (!(event.getPlayer() instanceof Player)) return;
|
CosmeticUser user = CosmeticUsers.getUser(player);
|
||||||
|
if (user == null) return;
|
||||||
|
if (user.isBackpackSpawned()) {
|
||||||
|
user.getUserBackpackManager().getEntityManager().setRotation(Math.round(event.getPacket().getFloat().read(0)));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -534,20 +663,29 @@ public class PlayerGameListener implements Listener {
|
|||||||
MessagesUtil.sendDebugMessages("Position Packet ");
|
MessagesUtil.sendDebugMessages("Position Packet ");
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
if (event.getPlayer() == null) return;
|
if (event.getPlayer() == null) return;
|
||||||
if (!(event.getPlayer() instanceof Player)) return;
|
CosmeticUser user = CosmeticUsers.getUser(player);
|
||||||
|
if (user == null) return;
|
||||||
|
if (user.isBackpackSpawned()) {
|
||||||
|
// The yaw follows the head, which makes it look weird and do weird things when moving around
|
||||||
|
user.getUserBackpackManager().getEntityManager().teleport(new Location(player.getWorld(), event.getPacket().getDoubles().read(0), event.getPacket().getDoubles().read(1), event.getPacket().getDoubles().read(2), event.getPacket().getFloat().read(0), event.getPacket().getFloat().read(1)));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void registerTeleportMovement() {
|
private void registerTeleportMovement() {
|
||||||
ProtocolLibrary.getProtocolManager().addPacketListener(new PacketAdapter(HMCCosmeticsPlugin.getInstance(), ListenerPriority.NORMAL, PacketType.Play.Client.TELEPORT_ACCEPT) {
|
ProtocolLibrary.getProtocolManager().addPacketListener(new PacketAdapter(HMCCosmeticsPlugin.getInstance(), ListenerPriority.NORMAL, PacketType.Play.Client.POSITION_LOOK) {
|
||||||
@Override
|
@Override
|
||||||
public void onPacketReceiving(PacketEvent event) {
|
public void onPacketReceiving(PacketEvent event) {
|
||||||
// TODO: Finish
|
// TODO: Finish
|
||||||
MessagesUtil.sendDebugMessages("Teleport Packet ");
|
MessagesUtil.sendDebugMessages("Teleport Packet ");
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
if (event.getPlayer() == null) return;
|
if (event.getPlayer() == null) return;
|
||||||
if (!(event.getPlayer() instanceof Player)) return;
|
CosmeticUser user = CosmeticUsers.getUser(player);
|
||||||
|
if (user == null) return;
|
||||||
|
if (user.isBackpackSpawned()) {
|
||||||
|
Bukkit.getScheduler().runTask(HMCCosmeticsPlugin.getInstance(), () -> user.updateCosmetic(CosmeticSlot.BACKPACK));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,58 +0,0 @@
|
|||||||
package com.hibiscusmc.hmccosmetics.nms;
|
|
||||||
|
|
||||||
import com.hibiscusmc.hmccosmetics.cosmetic.CosmeticSlot;
|
|
||||||
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);
|
|
||||||
|
|
||||||
Entity getHMCArmorStand(Location loc);
|
|
||||||
|
|
||||||
ArmorStand getMEGEntity(Location loc);
|
|
||||||
|
|
||||||
Entity spawnBackpack(CosmeticUser user, CosmeticBackpackType cosmeticBackpackType);
|
|
||||||
|
|
||||||
Entity spawnDisplayEntity(Location location, String text);
|
|
||||||
|
|
||||||
UserBalloonManager spawnBalloon(CosmeticUser user, CosmeticBalloonType cosmeticBalloonType);
|
|
||||||
|
|
||||||
void equipmentSlotUpdate(
|
|
||||||
int entityId,
|
|
||||||
CosmeticUser user,
|
|
||||||
CosmeticSlot cosmeticSlot,
|
|
||||||
List<Player> sendTo
|
|
||||||
);
|
|
||||||
|
|
||||||
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,48 +0,0 @@
|
|||||||
package com.hibiscusmc.hmccosmetics.nms;
|
|
||||||
|
|
||||||
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
|
|
||||||
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
|
||||||
|
|
||||||
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;
|
|
||||||
private static String version;
|
|
||||||
|
|
||||||
public static NMSHandler getHandler() {
|
|
||||||
if (handler != null) {
|
|
||||||
return handler;
|
|
||||||
} else {
|
|
||||||
setup();
|
|
||||||
}
|
|
||||||
return handler;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String getVersion() {
|
|
||||||
return version;
|
|
||||||
}
|
|
||||||
|
|
||||||
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,21 +13,24 @@ import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticArmorType;
|
|||||||
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticBackpackType;
|
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticBackpackType;
|
||||||
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticBalloonType;
|
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticBalloonType;
|
||||||
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticMainhandType;
|
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticMainhandType;
|
||||||
import com.hibiscusmc.hmccosmetics.hooks.Hooks;
|
|
||||||
import com.hibiscusmc.hmccosmetics.nms.NMSHandlers;
|
|
||||||
import com.hibiscusmc.hmccosmetics.user.manager.UserBackpackManager;
|
import com.hibiscusmc.hmccosmetics.user.manager.UserBackpackManager;
|
||||||
import com.hibiscusmc.hmccosmetics.user.manager.UserBalloonManager;
|
import com.hibiscusmc.hmccosmetics.user.manager.UserBalloonManager;
|
||||||
import com.hibiscusmc.hmccosmetics.user.manager.UserEmoteManager;
|
import com.hibiscusmc.hmccosmetics.user.manager.UserEmoteManager;
|
||||||
import com.hibiscusmc.hmccosmetics.user.manager.UserWardrobeManager;
|
import com.hibiscusmc.hmccosmetics.user.manager.UserWardrobeManager;
|
||||||
import com.hibiscusmc.hmccosmetics.util.InventoryUtils;
|
import com.hibiscusmc.hmccosmetics.util.HMCCInventoryUtils;
|
||||||
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||||
import com.hibiscusmc.hmccosmetics.util.PlayerUtils;
|
import com.hibiscusmc.hmccosmetics.util.HMCCPlayerUtils;
|
||||||
import com.hibiscusmc.hmccosmetics.util.packets.PacketManager;
|
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.Bukkit;
|
||||||
import org.bukkit.Color;
|
import org.bukkit.Color;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.inventory.EquipmentSlot;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.inventory.meta.*;
|
import org.bukkit.inventory.meta.*;
|
||||||
import org.bukkit.persistence.PersistentDataType;
|
import org.bukkit.persistence.PersistentDataType;
|
||||||
@@ -39,18 +42,22 @@ import java.util.logging.Level;
|
|||||||
|
|
||||||
public class CosmeticUser {
|
public class CosmeticUser {
|
||||||
|
|
||||||
|
@Getter
|
||||||
private final UUID uniqueId;
|
private final UUID uniqueId;
|
||||||
private int taskId;
|
private int taskId;
|
||||||
private HashMap<CosmeticSlot, Cosmetic> playerCosmetics = new HashMap<>();
|
private final HashMap<CosmeticSlot, Cosmetic> playerCosmetics = new HashMap<>();
|
||||||
private UserWardrobeManager userWardrobeManager;
|
private UserWardrobeManager userWardrobeManager;
|
||||||
private UserBalloonManager userBalloonManager;
|
private UserBalloonManager userBalloonManager;
|
||||||
|
@Getter
|
||||||
private UserBackpackManager userBackpackManager;
|
private UserBackpackManager userBackpackManager;
|
||||||
private UserEmoteManager userEmoteManager;
|
@Getter
|
||||||
|
private final UserEmoteManager userEmoteManager;
|
||||||
|
|
||||||
// Cosmetic Settings/Toggles
|
// Cosmetic Settings/Toggles
|
||||||
private boolean hideCosmetics;
|
private boolean hideCosmetics;
|
||||||
|
@Getter
|
||||||
private HiddenReason hiddenReason;
|
private HiddenReason hiddenReason;
|
||||||
private HashMap<CosmeticSlot, Color> colors = new HashMap<>();
|
private final HashMap<CosmeticSlot, Color> colors = new HashMap<>();
|
||||||
|
|
||||||
public CosmeticUser(UUID uuid) {
|
public CosmeticUser(UUID uuid) {
|
||||||
this.uniqueId = uuid;
|
this.uniqueId = uuid;
|
||||||
@@ -79,19 +86,10 @@ public class CosmeticUser {
|
|||||||
despawnBalloon();
|
despawnBalloon();
|
||||||
}
|
}
|
||||||
|
|
||||||
public UUID getUniqueId() {
|
|
||||||
return this.uniqueId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Cosmetic getCosmetic(CosmeticSlot slot) {
|
public Cosmetic getCosmetic(CosmeticSlot slot) {
|
||||||
return playerCosmetics.get(slot);
|
return playerCosmetics.get(slot);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated
|
|
||||||
public Collection<Cosmetic> getCosmetic() {
|
|
||||||
return playerCosmetics.values();
|
|
||||||
}
|
|
||||||
|
|
||||||
public ImmutableCollection<Cosmetic> getCosmetics() {
|
public ImmutableCollection<Cosmetic> getCosmetics() {
|
||||||
return ImmutableList.copyOf(playerCosmetics.values());
|
return ImmutableList.copyOf(playerCosmetics.values());
|
||||||
}
|
}
|
||||||
@@ -191,18 +189,41 @@ public class CosmeticUser {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void updateCosmetic() {
|
public void updateCosmetic() {
|
||||||
|
MessagesUtil.sendDebugMessages("updateCosmetic (All) - start");
|
||||||
|
HashMap<EquipmentSlot, ItemStack> items = new HashMap<>();
|
||||||
|
|
||||||
for (Cosmetic cosmetic : getCosmetics()) {
|
for (Cosmetic cosmetic : getCosmetics()) {
|
||||||
|
if (cosmetic instanceof CosmeticArmorType armorType) {
|
||||||
|
if (getUserEmoteManager().isPlayingEmote() || isInWardrobe()) return;
|
||||||
|
if (!Settings.isCosmeticForceOffhandCosmeticShow()
|
||||||
|
&& armorType.getEquipSlot().equals(EquipmentSlot.OFF_HAND)
|
||||||
|
&& !getPlayer().getInventory().getItemInOffHand().getType().isAir()) continue;
|
||||||
|
items.put(HMCCInventoryUtils.getEquipmentSlot(armorType.getSlot()), armorType.getItem(this));
|
||||||
|
continue;
|
||||||
|
}
|
||||||
updateCosmetic(cosmetic.getSlot());
|
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) {
|
||||||
|
Cosmetic cosmetic = getCosmetic(slot);
|
||||||
|
if (cosmetic == null) return new ItemStack(Material.AIR);
|
||||||
|
return getUserCosmeticItem(cosmetic);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ItemStack getUserCosmeticItem(Cosmetic cosmetic) {
|
public ItemStack getUserCosmeticItem(Cosmetic cosmetic) {
|
||||||
ItemStack item = null;
|
ItemStack item = null;
|
||||||
if (hideCosmetics) {
|
if (hideCosmetics) {
|
||||||
if (cosmetic instanceof CosmeticBackpackType || cosmetic instanceof CosmeticBalloonType) return new ItemStack(Material.AIR);
|
if (cosmetic instanceof CosmeticBackpackType || cosmetic instanceof CosmeticBalloonType) return new ItemStack(Material.AIR);
|
||||||
return getPlayer().getInventory().getItem(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();
|
item = cosmetic.getItem();
|
||||||
}
|
}
|
||||||
if (cosmetic instanceof CosmeticBalloonType) {
|
if (cosmetic instanceof CosmeticBalloonType) {
|
||||||
@@ -212,9 +233,14 @@ public class CosmeticUser {
|
|||||||
item = cosmetic.getItem();
|
item = cosmetic.getItem();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return getUserCosmeticItem(cosmetic, item);
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
|
public ItemStack getUserCosmeticItem(Cosmetic cosmetic, ItemStack item) {
|
||||||
if (item == null) {
|
if (item == null) {
|
||||||
MessagesUtil.sendDebugMessages("GetUserCosemticUser Item is null");
|
//MessagesUtil.sendDebugMessages("GetUserCosemticUser Item is null");
|
||||||
return null;
|
return new ItemStack(Material.AIR);
|
||||||
}
|
}
|
||||||
if (item.hasItemMeta()) {
|
if (item.hasItemMeta()) {
|
||||||
ItemMeta itemMeta = item.getItemMeta();
|
ItemMeta itemMeta = item.getItemMeta();
|
||||||
@@ -265,7 +291,7 @@ public class CosmeticUser {
|
|||||||
mapMeta.setColor(color);
|
mapMeta.setColor(color);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
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());
|
itemMeta.getPersistentDataContainer().set(InventoryUtils.getOwnerKey(), PersistentDataType.STRING, getEntity().getUniqueId().toString());
|
||||||
|
|
||||||
item.setItemMeta(itemMeta);
|
item.setItemMeta(itemMeta);
|
||||||
@@ -273,10 +299,6 @@ public class CosmeticUser {
|
|||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
||||||
public UserBackpackManager getUserBackpackManager() {
|
|
||||||
return userBackpackManager;
|
|
||||||
}
|
|
||||||
|
|
||||||
public UserBalloonManager getBalloonManager() {
|
public UserBalloonManager getBalloonManager() {
|
||||||
return this.userBalloonManager;
|
return this.userBalloonManager;
|
||||||
}
|
}
|
||||||
@@ -285,10 +307,6 @@ public class CosmeticUser {
|
|||||||
return userWardrobeManager;
|
return userWardrobeManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
public UserEmoteManager getUserEmoteManager() {
|
|
||||||
return userEmoteManager;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void enterWardrobe(boolean ignoreDistance, Wardrobe wardrobe) {
|
public void enterWardrobe(boolean ignoreDistance, Wardrobe wardrobe) {
|
||||||
if (wardrobe.hasPermission() && !getPlayer().hasPermission(wardrobe.getPermission())) {
|
if (wardrobe.hasPermission() && !getPlayer().hasPermission(wardrobe.getPermission())) {
|
||||||
MessagesUtil.sendMessage(getPlayer(), "no-permission");
|
MessagesUtil.sendMessage(getPlayer(), "no-permission");
|
||||||
@@ -316,6 +334,10 @@ public class CosmeticUser {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void leaveWardrobe() {
|
public void leaveWardrobe() {
|
||||||
|
leaveWardrobe(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void leaveWardrobe(boolean ejected) {
|
||||||
PlayerWardrobeLeaveEvent event = new PlayerWardrobeLeaveEvent(this);
|
PlayerWardrobeLeaveEvent event = new PlayerWardrobeLeaveEvent(this);
|
||||||
Bukkit.getPluginManager().callEvent(event);
|
Bukkit.getPluginManager().callEvent(event);
|
||||||
if (event.isCancelled()) {
|
if (event.isCancelled()) {
|
||||||
@@ -326,7 +348,7 @@ public class CosmeticUser {
|
|||||||
|
|
||||||
getWardrobeManager().setWardrobeStatus(UserWardrobeManager.WardrobeStatus.STOPPING);
|
getWardrobeManager().setWardrobeStatus(UserWardrobeManager.WardrobeStatus.STOPPING);
|
||||||
|
|
||||||
if (WardrobeSettings.isEnabledTransition()) {
|
if (WardrobeSettings.isEnabledTransition() && !ejected) {
|
||||||
MessagesUtil.sendTitle(
|
MessagesUtil.sendTitle(
|
||||||
getPlayer(),
|
getPlayer(),
|
||||||
WardrobeSettings.getTransitionText(),
|
WardrobeSettings.getTransitionText(),
|
||||||
@@ -350,7 +372,7 @@ public class CosmeticUser {
|
|||||||
|
|
||||||
public void spawnBackpack(CosmeticBackpackType cosmeticBackpackType) {
|
public void spawnBackpack(CosmeticBackpackType cosmeticBackpackType) {
|
||||||
if (this.userBackpackManager != null) return;
|
if (this.userBackpackManager != null) return;
|
||||||
this.userBackpackManager = new UserBackpackManager(this, cosmeticBackpackType.isFirstPersonCompadible());
|
this.userBackpackManager = new UserBackpackManager(this);
|
||||||
userBackpackManager.spawnBackpack(cosmeticBackpackType);
|
userBackpackManager.spawnBackpack(cosmeticBackpackType);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -364,17 +386,30 @@ public class CosmeticUser {
|
|||||||
return this.userBackpackManager != null;
|
return this.userBackpackManager != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isBalloonSpawned() {
|
||||||
|
return this.userBalloonManager != null;
|
||||||
|
}
|
||||||
|
|
||||||
public void spawnBalloon(CosmeticBalloonType cosmeticBalloonType) {
|
public void spawnBalloon(CosmeticBalloonType cosmeticBalloonType) {
|
||||||
if (this.userBalloonManager != null) return;
|
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() {
|
public void despawnBalloon() {
|
||||||
if (this.userBalloonManager == null) return;
|
if (this.userBalloonManager == null) return;
|
||||||
List<Player> sentTo = PlayerUtils.getNearbyPlayers(getEntity().getLocation());
|
List<Player> sentTo = HMCCPlayerUtils.getNearbyPlayers(getEntity().getLocation());
|
||||||
|
|
||||||
PacketManager.sendEntityDestroyPacket(userBalloonManager.getPufferfishBalloonId(), sentTo);
|
HMCCPacketManager.sendEntityDestroyPacket(userBalloonManager.getPufferfishBalloonId(), sentTo);
|
||||||
|
|
||||||
this.userBalloonManager.remove();
|
this.userBalloonManager.remove();
|
||||||
this.userBalloonManager = null;
|
this.userBalloonManager = null;
|
||||||
@@ -384,18 +419,28 @@ public class CosmeticUser {
|
|||||||
if (!hasCosmeticInSlot(CosmeticSlot.BACKPACK)) return;
|
if (!hasCosmeticInSlot(CosmeticSlot.BACKPACK)) return;
|
||||||
final Cosmetic cosmetic = getCosmetic(CosmeticSlot.BACKPACK);
|
final Cosmetic cosmetic = getCosmetic(CosmeticSlot.BACKPACK);
|
||||||
despawnBackpack();
|
despawnBackpack();
|
||||||
|
if (hideCosmetics) return;
|
||||||
spawnBackpack((CosmeticBackpackType) cosmetic);
|
spawnBackpack((CosmeticBackpackType) cosmetic);
|
||||||
|
MessagesUtil.sendDebugMessages("Respawned Backpack for " + getEntity().getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void respawnBalloon() {
|
public void respawnBalloon() {
|
||||||
if (!hasCosmeticInSlot(CosmeticSlot.BALLOON)) return;
|
if (!hasCosmeticInSlot(CosmeticSlot.BALLOON)) return;
|
||||||
final Cosmetic cosmetic = getCosmetic(CosmeticSlot.BALLOON);
|
final Cosmetic cosmetic = getCosmetic(CosmeticSlot.BALLOON);
|
||||||
despawnBalloon();
|
despawnBalloon();
|
||||||
|
if (hideCosmetics) return;
|
||||||
spawnBalloon((CosmeticBalloonType) cosmetic);
|
spawnBalloon((CosmeticBalloonType) cosmetic);
|
||||||
|
MessagesUtil.sendDebugMessages("Respawned Balloon for " + getEntity().getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removeArmor(CosmeticSlot slot) {
|
public void removeArmor(CosmeticSlot slot) {
|
||||||
PacketManager.equipmentSlotUpdate(getEntity().getEntityId(), this, slot, PlayerUtils.getNearbyPlayers(getEntity().getLocation()));
|
EquipmentSlot equipmentSlot = HMCCInventoryUtils.getEquipmentSlot(slot);
|
||||||
|
if (equipmentSlot == null) return;
|
||||||
|
if (getPlayer() != null) {
|
||||||
|
PacketManager.equipmentSlotUpdate(getEntity().getEntityId(), equipmentSlot, getPlayer().getInventory().getItem(equipmentSlot), HMCCPlayerUtils.getNearbyPlayers(getEntity().getLocation()));
|
||||||
|
} else {
|
||||||
|
HMCCPacketManager.equipmentSlotUpdate(getEntity().getEntityId(), this, slot, HMCCPlayerUtils.getNearbyPlayers(getEntity().getLocation()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -431,8 +476,12 @@ public class CosmeticUser {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean canEquipCosmetic(Cosmetic cosmetic) {
|
public boolean canEquipCosmetic(Cosmetic cosmetic) {
|
||||||
|
return canEquipCosmetic(cosmetic, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean canEquipCosmetic(Cosmetic cosmetic, boolean ignoreWardrobe) {
|
||||||
if (!cosmetic.requiresPermission()) return true;
|
if (!cosmetic.requiresPermission()) return true;
|
||||||
if (isInWardrobe()) {
|
if (isInWardrobe() && !ignoreWardrobe) {
|
||||||
if (WardrobeSettings.isTryCosmeticsInWardrobe() && userWardrobeManager.getWardrobeStatus().equals(UserWardrobeManager.WardrobeStatus.RUNNING)) return true;
|
if (WardrobeSettings.isTryCosmeticsInWardrobe() && userWardrobeManager.getWardrobeStatus().equals(UserWardrobeManager.WardrobeStatus.RUNNING)) return true;
|
||||||
}
|
}
|
||||||
return getPlayer().hasPermission(cosmetic.getPermission());
|
return getPlayer().hasPermission(cosmetic.getPermission());
|
||||||
@@ -467,11 +516,12 @@ public class CosmeticUser {
|
|||||||
hideCosmetics = true;
|
hideCosmetics = true;
|
||||||
hiddenReason = reason;
|
hiddenReason = reason;
|
||||||
if (hasCosmeticInSlot(CosmeticSlot.BALLOON)) {
|
if (hasCosmeticInSlot(CosmeticSlot.BALLOON)) {
|
||||||
getBalloonManager().removePlayerFromModel(getPlayer());
|
despawnBalloon();
|
||||||
getBalloonManager().sendRemoveLeashPacket();
|
//getBalloonManager().removePlayerFromModel(getPlayer());
|
||||||
|
//getBalloonManager().sendRemoveLeashPacket();
|
||||||
}
|
}
|
||||||
if (hasCosmeticInSlot(CosmeticSlot.BACKPACK)) {
|
if (hasCosmeticInSlot(CosmeticSlot.BACKPACK)) {
|
||||||
userBackpackManager.clearItems();
|
despawnBackpack();
|
||||||
}
|
}
|
||||||
updateCosmetic();
|
updateCosmetic();
|
||||||
MessagesUtil.sendDebugMessages("HideCosmetics");
|
MessagesUtil.sendDebugMessages("HideCosmetics");
|
||||||
@@ -489,12 +539,14 @@ public class CosmeticUser {
|
|||||||
hideCosmetics = false;
|
hideCosmetics = false;
|
||||||
hiddenReason = HiddenReason.NONE;
|
hiddenReason = HiddenReason.NONE;
|
||||||
if (hasCosmeticInSlot(CosmeticSlot.BALLOON)) {
|
if (hasCosmeticInSlot(CosmeticSlot.BALLOON)) {
|
||||||
|
if (!isBalloonSpawned()) respawnBalloon();
|
||||||
CosmeticBalloonType balloonType = (CosmeticBalloonType) getCosmetic(CosmeticSlot.BALLOON);
|
CosmeticBalloonType balloonType = (CosmeticBalloonType) getCosmetic(CosmeticSlot.BALLOON);
|
||||||
getBalloonManager().addPlayerToModel(this, balloonType);
|
getBalloonManager().addPlayerToModel(this, balloonType);
|
||||||
List<Player> viewer = PlayerUtils.getNearbyPlayers(getPlayer());
|
List<Player> viewer = HMCCPlayerUtils.getNearbyPlayers(getEntity().getLocation());
|
||||||
PacketManager.sendLeashPacket(getBalloonManager().getPufferfishBalloonId(), getPlayer().getEntityId(), viewer);
|
HMCCPacketManager.sendLeashPacket(getBalloonManager().getPufferfishBalloonId(), getPlayer().getEntityId(), viewer);
|
||||||
}
|
}
|
||||||
if (hasCosmeticInSlot(CosmeticSlot.BACKPACK)) {
|
if (hasCosmeticInSlot(CosmeticSlot.BACKPACK)) {
|
||||||
|
if (!isBackpackSpawned()) respawnBackpack();
|
||||||
CosmeticBackpackType cosmeticBackpackType = (CosmeticBackpackType) getCosmetic(CosmeticSlot.BACKPACK);
|
CosmeticBackpackType cosmeticBackpackType = (CosmeticBackpackType) getCosmetic(CosmeticSlot.BACKPACK);
|
||||||
ItemStack item = getUserCosmeticItem(cosmeticBackpackType);
|
ItemStack item = getUserCosmeticItem(cosmeticBackpackType);
|
||||||
userBackpackManager.setItem(item);
|
userBackpackManager.setItem(item);
|
||||||
@@ -507,10 +559,6 @@ public class CosmeticUser {
|
|||||||
return this.hideCosmetics;
|
return this.hideCosmetics;
|
||||||
}
|
}
|
||||||
|
|
||||||
public HiddenReason getHiddenReason() {
|
|
||||||
return hiddenReason;
|
|
||||||
}
|
|
||||||
|
|
||||||
public enum HiddenReason {
|
public enum HiddenReason {
|
||||||
NONE,
|
NONE,
|
||||||
WORLDGUARD,
|
WORLDGUARD,
|
||||||
@@ -518,6 +566,8 @@ public class CosmeticUser {
|
|||||||
POTION,
|
POTION,
|
||||||
ACTION,
|
ACTION,
|
||||||
COMMAND,
|
COMMAND,
|
||||||
EMOTE
|
EMOTE,
|
||||||
|
GAMEMODE,
|
||||||
|
WORLD
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,8 @@
|
|||||||
package com.hibiscusmc.hmccosmetics.user;
|
package com.hibiscusmc.hmccosmetics.user;
|
||||||
|
|
||||||
import com.google.common.collect.HashBiMap;
|
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.Entity;
|
||||||
import org.bukkit.entity.EntityType;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
@@ -39,10 +38,10 @@ public class CosmeticUsers {
|
|||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public static CosmeticUser getUser(int entityId) {
|
public static CosmeticUser getUser(int entityId) {
|
||||||
Entity entity = ServerUtils.getEntity(entityId);
|
Entity entity = HMCCServerUtils.getEntity(entityId);
|
||||||
if (entity == null) return null;
|
if (entity == null) return null;
|
||||||
if (entity.getType().equals(EntityType.PLAYER)) return null;
|
if (!(entity instanceof Player player)) return null;
|
||||||
return COSMETIC_USERS.get(entity.getUniqueId());
|
return COSMETIC_USERS.get(player.getUniqueId());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Set<CosmeticUser> values() {
|
public static Set<CosmeticUser> values() {
|
||||||
|
|||||||
@@ -1,68 +0,0 @@
|
|||||||
package com.hibiscusmc.hmccosmetics.user.manager;
|
|
||||||
|
|
||||||
import com.hibiscusmc.hmccosmetics.util.PlayerUtils;
|
|
||||||
import com.hibiscusmc.hmccosmetics.util.packets.PacketManager;
|
|
||||||
import org.bukkit.Location;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
public class UserBackpackCloudManager {
|
|
||||||
|
|
||||||
private ArrayList<Integer> ids;
|
|
||||||
private UUID owner;
|
|
||||||
private List<Player> viewers = new ArrayList<>();
|
|
||||||
private Long lastUpdate;
|
|
||||||
|
|
||||||
public UserBackpackCloudManager(UUID owner) {
|
|
||||||
this.ids = new ArrayList<>();
|
|
||||||
this.owner = owner;
|
|
||||||
this.lastUpdate = 0L;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ArrayList<Integer> getId() {
|
|
||||||
return ids;
|
|
||||||
}
|
|
||||||
|
|
||||||
public UUID getOwner() {
|
|
||||||
return owner;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<Player> refreshViewers(Location location) {
|
|
||||||
if (System.currentTimeMillis() - lastUpdate <= 1000) return List.of(); //Prevents mass refreshes
|
|
||||||
ArrayList<Player> newPlayers = new ArrayList<>();
|
|
||||||
ArrayList<Player> removePlayers = new ArrayList<>();
|
|
||||||
List<Player> players = PlayerUtils.getNearbyPlayers(location);
|
|
||||||
|
|
||||||
for (Player player : players) {
|
|
||||||
//if (player.getUniqueId().toString().equalsIgnoreCase(owner.toString())) continue;
|
|
||||||
if (!viewers.contains(player)) {
|
|
||||||
viewers.add(player);
|
|
||||||
newPlayers.add(player);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
// bad loopdy loops
|
|
||||||
for (Player viewerPlayer : viewers) {
|
|
||||||
if (!players.contains(viewerPlayer)) {
|
|
||||||
removePlayers.add(viewerPlayer);
|
|
||||||
PacketManager.sendEntityDestroyPacket(ids, List.of(viewerPlayer)); // prevents random leashes
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
viewers.removeAll(removePlayers);
|
|
||||||
lastUpdate = System.currentTimeMillis();
|
|
||||||
return newPlayers;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void hideEffects() {
|
|
||||||
PacketManager.sendEntityDestroyPacket(ids, viewers);
|
|
||||||
viewers.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<Player> getViewers() {
|
|
||||||
return viewers;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -2,16 +2,15 @@ package com.hibiscusmc.hmccosmetics.user.manager;
|
|||||||
|
|
||||||
import com.hibiscusmc.hmccosmetics.cosmetic.CosmeticSlot;
|
import com.hibiscusmc.hmccosmetics.cosmetic.CosmeticSlot;
|
||||||
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticBackpackType;
|
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticBackpackType;
|
||||||
import com.hibiscusmc.hmccosmetics.hooks.Hooks;
|
|
||||||
import com.hibiscusmc.hmccosmetics.nms.NMSHandlers;
|
|
||||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||||
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||||
import com.hibiscusmc.hmccosmetics.util.packets.PacketManager;
|
import com.hibiscusmc.hmccosmetics.util.packets.HMCCPacketManager;
|
||||||
import com.ticxo.modelengine.api.ModelEngineAPI;
|
import com.ticxo.modelengine.api.ModelEngineAPI;
|
||||||
import com.ticxo.modelengine.api.model.ActiveModel;
|
import lombok.Getter;
|
||||||
import com.ticxo.modelengine.api.model.ModeledEntity;
|
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.Material;
|
||||||
import org.bukkit.entity.ArmorStand;
|
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.EntityType;
|
import org.bukkit.entity.EntityType;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@@ -19,43 +18,34 @@ import org.bukkit.inventory.EquipmentSlot;
|
|||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
public class UserBackpackManager {
|
public class UserBackpackManager {
|
||||||
|
|
||||||
private boolean hideBackpack;
|
@Getter
|
||||||
private ArmorStand invisibleArmorStand;
|
private boolean backpackHidden;
|
||||||
|
@Getter
|
||||||
|
private int invisibleArmorStand;
|
||||||
private ArrayList<Integer> particleCloud = new ArrayList<>();
|
private ArrayList<Integer> particleCloud = new ArrayList<>();
|
||||||
|
@Getter
|
||||||
private final CosmeticUser user;
|
private final CosmeticUser user;
|
||||||
private boolean firstPerson;
|
@Getter
|
||||||
private UserBackpackCloudManager cloudManager;
|
private UserEntity entityManager;
|
||||||
|
|
||||||
public UserBackpackManager(CosmeticUser user, boolean firstPersonView) {
|
public UserBackpackManager(CosmeticUser user) {
|
||||||
this.user = user;
|
this.user = user;
|
||||||
this.hideBackpack = false;
|
this.backpackHidden = false;
|
||||||
this.firstPerson = firstPersonView;
|
this.invisibleArmorStand = ServerUtils.getNextEntityId();
|
||||||
this.cloudManager = new UserBackpackCloudManager(user.getUniqueId());
|
this.entityManager = new UserEntity(user.getUniqueId());
|
||||||
|
this.entityManager.refreshViewers(user.getEntity().getLocation());
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getFirstArmorStandId() {
|
public int getFirstArmorStandId() {
|
||||||
return invisibleArmorStand.getEntityId();
|
|
||||||
}
|
|
||||||
|
|
||||||
public ArmorStand getArmorStand() {
|
|
||||||
return invisibleArmorStand;
|
return invisibleArmorStand;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean IsValidBackpackEntity() {
|
|
||||||
if (invisibleArmorStand == null) {
|
|
||||||
MessagesUtil.sendDebugMessages("InvisibleArmorStand is Null!");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return getArmorStand().isValid();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void spawnBackpack(CosmeticBackpackType cosmeticBackpackType) {
|
public void spawnBackpack(CosmeticBackpackType cosmeticBackpackType) {
|
||||||
MessagesUtil.sendDebugMessages("spawnBackpack Bukkit - Start");
|
MessagesUtil.sendDebugMessages("spawnBackpack Bukkit - Start");
|
||||||
|
|
||||||
@@ -63,8 +53,11 @@ public class UserBackpackManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void spawn(CosmeticBackpackType cosmeticBackpackType) {
|
private void spawn(CosmeticBackpackType cosmeticBackpackType) {
|
||||||
if (this.invisibleArmorStand != null) return;
|
getEntityManager().setIds(List.of(invisibleArmorStand));
|
||||||
this.invisibleArmorStand = (ArmorStand) NMSHandlers.getHandler().spawnBackpack(user, cosmeticBackpackType);
|
getEntityManager().teleport(user.getEntity().getLocation());
|
||||||
|
List<Player> outsideViewers = getEntityManager().getViewers();
|
||||||
|
HMCCPacketManager.sendEntitySpawnPacket(user.getEntity().getLocation(), getFirstArmorStandId(), EntityType.ARMOR_STAND, UUID.randomUUID(), getEntityManager().getViewers());
|
||||||
|
HMCCPacketManager.sendArmorstandMetadata(getFirstArmorStandId(), outsideViewers);
|
||||||
|
|
||||||
Entity entity = user.getEntity();
|
Entity entity = user.getEntity();
|
||||||
|
|
||||||
@@ -76,53 +69,49 @@ public class UserBackpackManager {
|
|||||||
|
|
||||||
passengerIDs[passengerIDs.length - 1] = this.getFirstArmorStandId();
|
passengerIDs[passengerIDs.length - 1] = this.getFirstArmorStandId();
|
||||||
|
|
||||||
List<Player> outsideViewers = user.getUserBackpackManager().getCloudManager().refreshViewers(user.getEntity().getLocation());
|
|
||||||
PacketManager.sendRidingPacket(user.getEntity().getEntityId(), passengerIDs, outsideViewers);
|
|
||||||
|
|
||||||
ArrayList<Player> owner = new ArrayList<>();
|
ArrayList<Player> owner = new ArrayList<>();
|
||||||
if (user.getPlayer() != null) owner.add(user.getPlayer());
|
if (user.getPlayer() != null) owner.add(user.getPlayer());
|
||||||
|
|
||||||
if (cosmeticBackpackType.isFirstPersonCompadible()) {
|
if (cosmeticBackpackType.isFirstPersonCompadible()) {
|
||||||
for (int i = particleCloud.size(); i < 5; i++) {
|
for (int i = particleCloud.size(); i < cosmeticBackpackType.getHeight(); i++) {
|
||||||
int entityId = NMSHandlers.getHandler().getNextEntityId();
|
int entityId = ServerUtils.getNextEntityId();
|
||||||
PacketManager.sendEntitySpawnPacket(user.getEntity().getLocation(), entityId, EntityType.AREA_EFFECT_CLOUD, UUID.randomUUID());
|
HMCCPacketManager.sendEntitySpawnPacket(user.getEntity().getLocation(), entityId, EntityType.AREA_EFFECT_CLOUD, UUID.randomUUID());
|
||||||
PacketManager.sendCloudEffect(entityId, PacketManager.getViewers(user.getEntity().getLocation()));
|
HMCCPacketManager.sendCloudEffect(entityId, HMCCPacketManager.getViewers(user.getEntity().getLocation()));
|
||||||
this.particleCloud.add(entityId);
|
this.particleCloud.add(entityId);
|
||||||
}
|
}
|
||||||
// Copied code from updating the backpack
|
// Copied code from updating the backpack
|
||||||
for (int i = 0; i < particleCloud.size(); i++) {
|
for (int i = 0; i < particleCloud.size(); i++) {
|
||||||
if (i == 0) PacketManager.sendRidingPacket(entity.getEntityId(), particleCloud.get(i), owner);
|
if (i == 0) HMCCPacketManager.sendRidingPacket(entity.getEntityId(), particleCloud.get(i), owner);
|
||||||
else PacketManager.sendRidingPacket(particleCloud.get(i - 1), 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);
|
HMCCPacketManager.sendRidingPacket(particleCloud.get(particleCloud.size() - 1), user.getUserBackpackManager().getFirstArmorStandId(), owner);
|
||||||
if (!user.getHidden()) NMSHandlers.getHandler().equipmentSlotUpdate(user.getUserBackpackManager().getFirstArmorStandId(), EquipmentSlot.HEAD, cosmeticBackpackType.getFirstPersonBackpack(), owner);
|
if (!user.getHidden()) PacketManager.equipmentSlotUpdate(user.getUserBackpackManager().getFirstArmorStandId(), EquipmentSlot.HEAD, user.getUserCosmeticItem(cosmeticBackpackType, cosmeticBackpackType.getFirstPersonBackpack()), owner);
|
||||||
}
|
}
|
||||||
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
|
// 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 (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);
|
MessagesUtil.sendDebugMessages("Invalid Model Engine Blueprint " + cosmeticBackpackType.getModelName(), Level.SEVERE);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ModeledEntity modeledEntity = ModelEngineAPI.getOrCreateModeledEntity(invisibleArmorStand);
|
/* TODO: Readd ModelEngine support
|
||||||
|
ModeledEntity modeledEntity = ModelEngineAPI.createModeledEntity(new PacketBaseEntity(getFirstArmorStandId(), UUID.randomUUID(), entity.getLocation()));
|
||||||
ActiveModel model = ModelEngineAPI.createActiveModel(ModelEngineAPI.getBlueprint(cosmeticBackpackType.getModelName()));
|
ActiveModel model = ModelEngineAPI.createActiveModel(ModelEngineAPI.getBlueprint(cosmeticBackpackType.getModelName()));
|
||||||
model.setCanHurt(false);
|
model.setCanHurt(false);
|
||||||
modeledEntity.addModel(model, false);
|
modeledEntity.addModel(model, false);
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
MessagesUtil.sendDebugMessages("spawnBackpack Bukkit - Finish");
|
MessagesUtil.sendDebugMessages("spawnBackpack Bukkit - Finish");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void despawnBackpack() {
|
public void despawnBackpack() {
|
||||||
if (invisibleArmorStand != null) {
|
HMCCPacketManager.sendEntityDestroyPacket(invisibleArmorStand, getEntityManager().getViewers());
|
||||||
invisibleArmorStand.setHealth(0);
|
|
||||||
invisibleArmorStand.remove();
|
|
||||||
this.invisibleArmorStand = null;
|
|
||||||
}
|
|
||||||
if (particleCloud != null) {
|
if (particleCloud != null) {
|
||||||
for (Integer entityId : particleCloud) {
|
for (Integer entityId : particleCloud) {
|
||||||
PacketManager.sendEntityDestroyPacket(entityId, getCloudManager().getViewers());
|
HMCCPacketManager.sendEntityDestroyPacket(entityId, getEntityManager().getViewers());
|
||||||
}
|
}
|
||||||
this.particleCloud = null;
|
this.particleCloud = null;
|
||||||
}
|
}
|
||||||
@@ -130,20 +119,20 @@ public class UserBackpackManager {
|
|||||||
|
|
||||||
public void hideBackpack() {
|
public void hideBackpack() {
|
||||||
if (user.getHidden()) return;
|
if (user.getHidden()) return;
|
||||||
getArmorStand().getEquipment().clear();
|
//getArmorStand().getEquipment().clear();
|
||||||
hideBackpack = true;
|
backpackHidden = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void showBackpack() {
|
public void showBackpack() {
|
||||||
if (!hideBackpack) return;
|
if (!backpackHidden) return;
|
||||||
CosmeticBackpackType cosmeticBackpackType = (CosmeticBackpackType) user.getCosmetic(CosmeticSlot.BACKPACK);
|
CosmeticBackpackType cosmeticBackpackType = (CosmeticBackpackType) user.getCosmetic(CosmeticSlot.BACKPACK);
|
||||||
ItemStack item = user.getUserCosmeticItem(cosmeticBackpackType);
|
ItemStack item = user.getUserCosmeticItem(cosmeticBackpackType);
|
||||||
getArmorStand().getEquipment().setHelmet(item);
|
//getArmorStand().getEquipment().setHelmet(item);
|
||||||
hideBackpack = false;
|
backpackHidden = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setVisibility(boolean shown) {
|
public void setVisibility(boolean shown) {
|
||||||
hideBackpack = shown;
|
backpackHidden = shown;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ArrayList<Integer> getAreaEffectEntityId() {
|
public ArrayList<Integer> getAreaEffectEntityId() {
|
||||||
@@ -151,15 +140,11 @@ public class UserBackpackManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setItem(ItemStack item) {
|
public void setItem(ItemStack item) {
|
||||||
getArmorStand().getEquipment().setHelmet(item);
|
PacketManager.equipmentSlotUpdate(getFirstArmorStandId(), EquipmentSlot.HEAD, item, getEntityManager().getViewers());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void clearItems() {
|
public void clearItems() {
|
||||||
ItemStack item = new ItemStack(Material.AIR);
|
ItemStack item = new ItemStack(Material.AIR);
|
||||||
getArmorStand().getEquipment().setHelmet(item);
|
PacketManager.equipmentSlotUpdate(getFirstArmorStandId(), EquipmentSlot.HEAD, item, getEntityManager().getViewers());
|
||||||
}
|
|
||||||
|
|
||||||
public UserBackpackCloudManager getCloudManager() {
|
|
||||||
return cloudManager;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,19 +3,24 @@ package com.hibiscusmc.hmccosmetics.user.manager;
|
|||||||
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
|
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
|
||||||
import com.hibiscusmc.hmccosmetics.config.Settings;
|
import com.hibiscusmc.hmccosmetics.config.Settings;
|
||||||
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticBalloonType;
|
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.CosmeticUser;
|
||||||
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUsers;
|
||||||
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
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.ModelEngineAPI;
|
||||||
|
import com.ticxo.modelengine.api.entity.data.BukkitEntityData;
|
||||||
import com.ticxo.modelengine.api.model.ActiveModel;
|
import com.ticxo.modelengine.api.model.ActiveModel;
|
||||||
import com.ticxo.modelengine.api.model.ModeledEntity;
|
import com.ticxo.modelengine.api.model.ModeledEntity;
|
||||||
|
import lombok.Getter;
|
||||||
|
import me.lojosho.hibiscuscommons.hooks.Hooks;
|
||||||
|
import me.lojosho.hibiscuscommons.nms.NMSHandlers;
|
||||||
import org.bukkit.Color;
|
import org.bukkit.Color;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.NamespacedKey;
|
||||||
import org.bukkit.entity.ArmorStand;
|
import org.bukkit.entity.ArmorStand;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.persistence.PersistentDataType;
|
||||||
import org.bukkit.util.Vector;
|
import org.bukkit.util.Vector;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
@@ -25,14 +30,26 @@ import java.util.logging.Level;
|
|||||||
|
|
||||||
public class UserBalloonManager {
|
public class UserBalloonManager {
|
||||||
|
|
||||||
|
private CosmeticUser user;
|
||||||
|
@Getter
|
||||||
private BalloonType balloonType;
|
private BalloonType balloonType;
|
||||||
private CosmeticBalloonType cosmeticBalloonType;
|
private CosmeticBalloonType cosmeticBalloonType;
|
||||||
|
@Getter
|
||||||
private UserBalloonPufferfish pufferfish;
|
private UserBalloonPufferfish pufferfish;
|
||||||
private final ArmorStand modelEntity;
|
private final ArmorStand modelEntity;
|
||||||
|
public UserBalloonManager(CosmeticUser user, @NotNull Location location) {
|
||||||
public UserBalloonManager(@NotNull Location location) {
|
this.user = user;
|
||||||
this.pufferfish = new UserBalloonPufferfish(NMSHandlers.getHandler().getNextEntityId(), UUID.randomUUID());
|
this.pufferfish = new UserBalloonPufferfish(user.getUniqueId(), NMSHandlers.getHandler().getNextEntityId(), UUID.randomUUID());
|
||||||
this.modelEntity = NMSHandlers.getHandler().getMEGEntity(location.add(Settings.getBalloonOffset()));
|
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) {
|
public void spawnModel(@NotNull CosmeticBalloonType cosmeticBalloonType, Color color) {
|
||||||
@@ -52,7 +69,7 @@ public class UserBalloonManager {
|
|||||||
if (balloonType == BalloonType.MODELENGINE) {
|
if (balloonType == BalloonType.MODELENGINE) {
|
||||||
String id = cosmeticBalloonType.getModelName();
|
String id = cosmeticBalloonType.getModelName();
|
||||||
MessagesUtil.sendDebugMessages("Attempting Spawning for " + id);
|
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);
|
MessagesUtil.sendDebugMessages("Invalid Model Engine Blueprint " + id, Level.SEVERE);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -60,14 +77,19 @@ public class UserBalloonManager {
|
|||||||
ActiveModel model = ModelEngineAPI.createActiveModel(ModelEngineAPI.getBlueprint(id));
|
ActiveModel model = ModelEngineAPI.createActiveModel(ModelEngineAPI.getBlueprint(id));
|
||||||
model.setCanHurt(false);
|
model.setCanHurt(false);
|
||||||
modeledEntity.addModel(model, false);
|
modeledEntity.addModel(model, false);
|
||||||
|
|
||||||
if (color != null) {
|
if (color != null) {
|
||||||
modeledEntity.getModels().forEach((d, singleModel) -> {
|
modeledEntity.getModels().forEach((d, singleModel) -> {
|
||||||
if (cosmeticBalloonType.isDyablePart(d)) {
|
if (cosmeticBalloonType.isDyablePart(d)) {
|
||||||
singleModel.getRendererHandler().setColor(color);
|
singleModel.setDefaultTint(color);
|
||||||
singleModel.getRendererHandler().update();
|
singleModel.getModelRenderer().sendToClient();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BukkitEntityData data = (BukkitEntityData) modeledEntity.getBase().getData();
|
||||||
|
data.setBlockedCullIgnoreRadius((double) Settings.getViewDistance());
|
||||||
|
data.getTracked().setPlayerPredicate(this::playerCheck);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (balloonType == BalloonType.ITEM) {
|
if (balloonType == BalloonType.ITEM) {
|
||||||
@@ -77,18 +99,19 @@ public class UserBalloonManager {
|
|||||||
|
|
||||||
public void remove() {
|
public void remove() {
|
||||||
if (balloonType == BalloonType.MODELENGINE) {
|
if (balloonType == BalloonType.MODELENGINE) {
|
||||||
final ModeledEntity entity = ModelEngineAPI.api.getModeledEntity(modelEntity.getUniqueId());
|
final ModeledEntity entity = ModelEngineAPI.getModeledEntity(modelEntity);
|
||||||
|
if (entity == null) {
|
||||||
if (entity == null) return;
|
MessagesUtil.sendDebugMessages("Balloon Removal Failed - Model Entity is Null");
|
||||||
|
return;
|
||||||
for (final Player player : entity.getRangeManager().getPlayerInRange()) {
|
|
||||||
entity.hideFromPlayer(player);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
entity.destroy();
|
entity.destroy();
|
||||||
|
MessagesUtil.sendDebugMessages("Balloon Model Engine Removal");
|
||||||
}
|
}
|
||||||
|
|
||||||
modelEntity.remove();
|
modelEntity.remove();
|
||||||
cosmeticBalloonType = null;
|
cosmeticBalloonType = null;
|
||||||
|
MessagesUtil.sendDebugMessages("Balloon Entity Removed");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addPlayerToModel(final CosmeticUser user, final CosmeticBalloonType cosmeticBalloonType) {
|
public void addPlayerToModel(final CosmeticUser user, final CosmeticBalloonType cosmeticBalloonType) {
|
||||||
@@ -97,14 +120,13 @@ public class UserBalloonManager {
|
|||||||
|
|
||||||
public void addPlayerToModel(final CosmeticUser user, final CosmeticBalloonType cosmeticBalloonType, Color color) {
|
public void addPlayerToModel(final CosmeticUser user, final CosmeticBalloonType cosmeticBalloonType, Color color) {
|
||||||
if (balloonType == BalloonType.MODELENGINE) {
|
if (balloonType == BalloonType.MODELENGINE) {
|
||||||
final ModeledEntity model = ModelEngineAPI.api.getModeledEntity(modelEntity.getUniqueId());
|
final ModeledEntity model = ModelEngineAPI.getModeledEntity(modelEntity);
|
||||||
if (model == null) {
|
if (model == null) {
|
||||||
spawnModel(cosmeticBalloonType, color);
|
spawnModel(cosmeticBalloonType, color);
|
||||||
MessagesUtil.sendDebugMessages("model is null");
|
MessagesUtil.sendDebugMessages("model is null");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
//if (model.getRangeManager().getPlayerInRange().contains(player)) return;
|
|
||||||
model.showToPlayer(user.getPlayer());
|
|
||||||
MessagesUtil.sendDebugMessages("Show to player");
|
MessagesUtil.sendDebugMessages("Show to player");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -112,13 +134,11 @@ public class UserBalloonManager {
|
|||||||
modelEntity.getEquipment().setHelmet(user.getUserCosmeticItem(cosmeticBalloonType));
|
modelEntity.getEquipment().setHelmet(user.getUserCosmeticItem(cosmeticBalloonType));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public void removePlayerFromModel(final Player player) {
|
public void removePlayerFromModel(final Player viewer) {
|
||||||
if (balloonType == BalloonType.MODELENGINE) {
|
if (balloonType == BalloonType.MODELENGINE) {
|
||||||
final ModeledEntity model = ModelEngineAPI.api.getModeledEntity(modelEntity.getUniqueId());
|
final ModeledEntity model = ModelEngineAPI.getModeledEntity(modelEntity);
|
||||||
|
|
||||||
if (model == null) return;
|
if (model == null) return;
|
||||||
|
|
||||||
model.hideFromPlayer(player);
|
|
||||||
MessagesUtil.sendDebugMessages("Hidden from player");
|
MessagesUtil.sendDebugMessages("Hidden from player");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -134,7 +154,7 @@ public class UserBalloonManager {
|
|||||||
|
|
||||||
|
|
||||||
public int getPufferfishBalloonId() {
|
public int getPufferfishBalloonId() {
|
||||||
return pufferfish.getId();
|
return pufferfish.getPufferFishEntityId();
|
||||||
}
|
}
|
||||||
public UUID getPufferfishBalloonUniqueId() {
|
public UUID getPufferfishBalloonUniqueId() {
|
||||||
return pufferfish.getUuid();
|
return pufferfish.getUuid();
|
||||||
@@ -161,27 +181,39 @@ public class UserBalloonManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void sendRemoveLeashPacket(List<Player> viewer) {
|
public void sendRemoveLeashPacket(List<Player> viewer) {
|
||||||
PacketManager.sendLeashPacket(getPufferfishBalloonId(), -1, viewer);
|
HMCCPacketManager.sendLeashPacket(getPufferfishBalloonId(), -1, viewer);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void sendRemoveLeashPacket() {
|
public void sendRemoveLeashPacket() {
|
||||||
PacketManager.sendLeashPacket(getPufferfishBalloonId(), -1, getLocation());
|
HMCCPacketManager.sendLeashPacket(getPufferfishBalloonId(), -1, getLocation());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void sendLeashPacket(int entityId) {
|
public void sendLeashPacket(int entityId) {
|
||||||
if (cosmeticBalloonType == null) return;
|
|
||||||
if (cosmeticBalloonType.isShowLead()) {
|
if (cosmeticBalloonType.isShowLead()) {
|
||||||
PacketManager.sendLeashPacket(getPufferfishBalloonId(), entityId, getLocation());
|
HMCCPacketManager.sendLeashPacket(getPufferfishBalloonId(), entityId, getLocation());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public UserBalloonPufferfish getPufferfish() {
|
|
||||||
return pufferfish;
|
|
||||||
}
|
|
||||||
|
|
||||||
public enum BalloonType {
|
public enum BalloonType {
|
||||||
MODELENGINE,
|
MODELENGINE,
|
||||||
ITEM,
|
ITEM,
|
||||||
NONE
|
NONE
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean playerCheck(final Player player) {
|
||||||
|
MessagesUtil.sendDebugMessages("playerCheck");
|
||||||
|
CosmeticUser viewer = CosmeticUsers.getUser(player.getUniqueId());
|
||||||
|
|
||||||
|
if (user.getPlayer() == player) {
|
||||||
|
return (!user.getHidden());
|
||||||
|
} 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.getHidden());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,62 +1,75 @@
|
|||||||
package com.hibiscusmc.hmccosmetics.user.manager;
|
package com.hibiscusmc.hmccosmetics.user.manager;
|
||||||
|
|
||||||
import com.hibiscusmc.hmccosmetics.util.PlayerUtils;
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||||
import com.hibiscusmc.hmccosmetics.util.packets.PacketManager;
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUsers;
|
||||||
|
import com.hibiscusmc.hmccosmetics.util.HMCCPlayerUtils;
|
||||||
|
import com.hibiscusmc.hmccosmetics.util.packets.HMCCPacketManager;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.entity.EntityType;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public class UserBalloonPufferfish {
|
public class UserBalloonPufferfish extends UserEntity {
|
||||||
|
|
||||||
private int id;
|
private int pufferFishEntityId;
|
||||||
private UUID uuid;
|
private UUID uuid;
|
||||||
private List<Player> viewers = new ArrayList<>();
|
|
||||||
private Long lastUpdate;
|
|
||||||
|
|
||||||
public UserBalloonPufferfish(int id, UUID uuid) {
|
public UserBalloonPufferfish(UUID owner, int pufferFishEntityId, UUID uuid) {
|
||||||
this.id = id;
|
super(owner);
|
||||||
|
this.pufferFishEntityId = pufferFishEntityId;
|
||||||
this.uuid = uuid;
|
this.uuid = uuid;
|
||||||
this.lastUpdate = 0L;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getId() {
|
public int getPufferFishEntityId() {
|
||||||
return id;
|
return pufferFishEntityId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public UUID getUuid() {
|
public UUID getUuid() {
|
||||||
return uuid;
|
return uuid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void hidePufferfish() {
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public List<Player> refreshViewers(Location location) {
|
public List<Player> refreshViewers(Location location) {
|
||||||
if (System.currentTimeMillis() - lastUpdate <= 1000) return List.of(); //Prevents mass refreshes
|
if (System.currentTimeMillis() - getViewerLastUpdate() <= 1000) return List.of(); //Prevents mass refreshes
|
||||||
ArrayList<Player> newPlayers = new ArrayList<>();
|
ArrayList<Player> newPlayers = new ArrayList<>();
|
||||||
ArrayList<Player> removePlayers = new ArrayList<>();
|
ArrayList<Player> removePlayers = new ArrayList<>();
|
||||||
List<Player> players = PlayerUtils.getNearbyPlayers(location);
|
List<Player> players = HMCCPlayerUtils.getNearbyPlayers(location);
|
||||||
|
|
||||||
for (Player player : players) {
|
for (Player player : players) {
|
||||||
if (!viewers.contains(player)) {
|
CosmeticUser user = CosmeticUsers.getUser(player);
|
||||||
viewers.add(player);
|
if (user != null && getOwner() != user.getUniqueId() && user.isInWardrobe()) { // Fixes issue where players in wardrobe would see other players cosmetics if they were not in wardrobe
|
||||||
|
removePlayers.add(player);
|
||||||
|
HMCCPacketManager.sendEntityDestroyPacket(getPufferFishEntityId(), List.of(player));
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (!getViewers().contains(player)) {
|
||||||
|
getViewers().add(player);
|
||||||
newPlayers.add(player);
|
newPlayers.add(player);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
// bad loopdy loops
|
// bad loopdy loops
|
||||||
for (Player viewerPlayer : viewers) {
|
for (Player viewerPlayer : getViewers()) {
|
||||||
if (!players.contains(viewerPlayer)) {
|
if (!players.contains(viewerPlayer)) {
|
||||||
removePlayers.add(viewerPlayer);
|
removePlayers.add(viewerPlayer);
|
||||||
PacketManager.sendEntityDestroyPacket(id, List.of(viewerPlayer)); // prevents random leashes
|
HMCCPacketManager.sendEntityDestroyPacket(getPufferFishEntityId(), List.of(viewerPlayer));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
viewers.removeAll(removePlayers);
|
getViewers().removeAll(removePlayers);
|
||||||
lastUpdate = System.currentTimeMillis();
|
setViewerLastUpdate(System.currentTimeMillis());
|
||||||
return newPlayers;
|
return newPlayers;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void hidePufferfish() {
|
|
||||||
PacketManager.sendEntityDestroyPacket(id, viewers);
|
|
||||||
viewers.clear();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ import com.hibiscusmc.hmccosmetics.api.events.PlayerEmoteStartEvent;
|
|||||||
import com.hibiscusmc.hmccosmetics.api.events.PlayerEmoteStopEvent;
|
import com.hibiscusmc.hmccosmetics.api.events.PlayerEmoteStopEvent;
|
||||||
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticEmoteType;
|
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticEmoteType;
|
||||||
import com.hibiscusmc.hmccosmetics.emotes.EmoteManager;
|
import com.hibiscusmc.hmccosmetics.emotes.EmoteManager;
|
||||||
import com.hibiscusmc.hmccosmetics.nms.NMSHandlers;
|
|
||||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||||
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
@@ -49,7 +48,8 @@ public class UserEmoteManager {
|
|||||||
}
|
}
|
||||||
// Show the text
|
// Show the text
|
||||||
if (text != null && textEntity == null) {
|
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) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|||||||
@@ -2,12 +2,12 @@ package com.hibiscusmc.hmccosmetics.user.manager;
|
|||||||
|
|
||||||
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
|
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
|
||||||
import com.hibiscusmc.hmccosmetics.config.Settings;
|
import com.hibiscusmc.hmccosmetics.config.Settings;
|
||||||
import com.hibiscusmc.hmccosmetics.nms.NMSHandlers;
|
|
||||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||||
|
import com.hibiscusmc.hmccosmetics.util.HMCCServerUtils;
|
||||||
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||||
import com.hibiscusmc.hmccosmetics.util.ServerUtils;
|
import com.hibiscusmc.hmccosmetics.util.packets.HMCCPacketManager;
|
||||||
import com.hibiscusmc.hmccosmetics.util.packets.PacketManager;
|
|
||||||
import com.ticxo.playeranimator.api.model.player.PlayerModel;
|
import com.ticxo.playeranimator.api.model.player.PlayerModel;
|
||||||
|
import me.lojosho.hibiscuscommons.util.ServerUtils;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.GameMode;
|
import org.bukkit.GameMode;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
@@ -29,7 +29,7 @@ public class UserEmoteModel extends PlayerModel {
|
|||||||
public UserEmoteModel(@NotNull CosmeticUser user) {
|
public UserEmoteModel(@NotNull CosmeticUser user) {
|
||||||
super(user.getPlayer());
|
super(user.getPlayer());
|
||||||
this.user = user;
|
this.user = user;
|
||||||
armorStandId = NMSHandlers.getHandler().getNextEntityId();
|
armorStandId = ServerUtils.getNextEntityId();
|
||||||
getRangeManager().setRenderDistance(Settings.getViewDistance());
|
getRangeManager().setRenderDistance(Settings.getViewDistance());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -42,44 +42,47 @@ public class UserEmoteModel extends PlayerModel {
|
|||||||
// Add config option that either allows player to move or forces them into a spot.
|
// Add config option that either allows player to move or forces them into a spot.
|
||||||
Player player = user.getPlayer();
|
Player player = user.getPlayer();
|
||||||
List<Player> viewer = Collections.singletonList(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)
|
// 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);
|
outsideViewers.remove(player);
|
||||||
|
|
||||||
Location newLocation = player.getLocation().clone();
|
|
||||||
newLocation.setPitch(0);
|
|
||||||
|
|
||||||
double DISTANCE = Settings.getEmoteDistance();
|
|
||||||
|
|
||||||
Location thirdPersonLocation = newLocation.add(newLocation.getDirection().normalize().multiply(DISTANCE));
|
|
||||||
if (DISTANCE > 0) {
|
|
||||||
MessagesUtil.sendDebugMessages("Yaw " + (int) thirdPersonLocation.getYaw());
|
|
||||||
MessagesUtil.sendDebugMessages("New Yaw " + ServerUtils.getNextYaw((int) thirdPersonLocation.getYaw(), 180));
|
|
||||||
thirdPersonLocation.setYaw(ServerUtils.getNextYaw((int) thirdPersonLocation.getYaw(), 180));
|
|
||||||
}
|
|
||||||
if (Settings.getCosmeticEmoteBlockCheck() && thirdPersonLocation.getBlock().getType().isOccluding()) {
|
|
||||||
stopAnimation();
|
|
||||||
MessagesUtil.sendMessage(player, "emote-blocked");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
// Check if block below player is an air block
|
|
||||||
if (Settings.getEmoteAirCheck() && newLocation.clone().subtract(0, 1, 0).getBlock().getType().isAir()) {
|
|
||||||
stopAnimation();
|
|
||||||
MessagesUtil.sendMessage(player, "emote-blocked");
|
|
||||||
}
|
|
||||||
|
|
||||||
user.getPlayer().setInvisible(true);
|
user.getPlayer().setInvisible(true);
|
||||||
user.hideCosmetics(CosmeticUser.HiddenReason.EMOTE);
|
user.hideCosmetics(CosmeticUser.HiddenReason.EMOTE);
|
||||||
|
|
||||||
originalGamemode = player.getGameMode();
|
originalGamemode = player.getGameMode();
|
||||||
|
|
||||||
PacketManager.sendEntitySpawnPacket(thirdPersonLocation, armorStandId, EntityType.ARMOR_STAND, UUID.randomUUID(), viewer);
|
if (Settings.isEmoteCameraEnabled()) {
|
||||||
PacketManager.sendInvisibilityPacket(armorStandId, viewer);
|
Location newLocation = player.getLocation().clone();
|
||||||
PacketManager.sendLookPacket(armorStandId, thirdPersonLocation, viewer);
|
newLocation.setPitch(0);
|
||||||
|
|
||||||
|
double DISTANCE = Settings.getEmoteDistance();
|
||||||
|
|
||||||
|
Location thirdPersonLocation = newLocation.add(newLocation.getDirection().normalize().multiply(DISTANCE));
|
||||||
|
if (DISTANCE > 0) {
|
||||||
|
MessagesUtil.sendDebugMessages("Yaw " + (int) thirdPersonLocation.getYaw());
|
||||||
|
MessagesUtil.sendDebugMessages("New Yaw " + ServerUtils.getNextYaw((int) thirdPersonLocation.getYaw(), 180));
|
||||||
|
thirdPersonLocation.setYaw(ServerUtils.getNextYaw((int) thirdPersonLocation.getYaw(), 180));
|
||||||
|
}
|
||||||
|
if (Settings.isCosmeticEmoteBlockCheck() && thirdPersonLocation.getBlock().getType().isOccluding()) {
|
||||||
|
stopAnimation();
|
||||||
|
MessagesUtil.sendMessage(player, "emote-blocked");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// Check if block below player is an air block
|
||||||
|
if (Settings.isEmoteAirCheck() && newLocation.clone().subtract(0, 1, 0).getBlock().getType().isAir()) {
|
||||||
|
stopAnimation();
|
||||||
|
MessagesUtil.sendMessage(player, "emote-blocked");
|
||||||
|
}
|
||||||
|
|
||||||
|
HMCCPacketManager.sendEntitySpawnPacket(thirdPersonLocation, armorStandId, EntityType.ARMOR_STAND, UUID.randomUUID(), viewer);
|
||||||
|
HMCCPacketManager.sendInvisibilityPacket(armorStandId, viewer);
|
||||||
|
HMCCPacketManager.sendLookPacket(armorStandId, thirdPersonLocation, viewer);
|
||||||
|
|
||||||
|
HMCCPacketManager.gamemodeChangePacket(player, 3);
|
||||||
|
HMCCPacketManager.sendCameraPacket(armorStandId, viewer);
|
||||||
|
}
|
||||||
|
|
||||||
PacketManager.gamemodeChangePacket(player, 3);
|
|
||||||
PacketManager.sendCameraPacket(armorStandId, viewer);
|
|
||||||
|
|
||||||
MessagesUtil.sendDebugMessages("playAnimation run");
|
MessagesUtil.sendDebugMessages("playAnimation run");
|
||||||
}
|
}
|
||||||
@@ -105,16 +108,16 @@ public class UserEmoteModel extends PlayerModel {
|
|||||||
if (player == null) return;
|
if (player == null) return;
|
||||||
|
|
||||||
List<Player> viewer = Collections.singletonList(player);
|
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)
|
// Send Equipment packet to all (Fixes Optifine Issue)
|
||||||
PacketManager.equipmentSlotUpdate(player, false, outsideViewers);
|
HMCCPacketManager.equipmentSlotUpdate(player, false, outsideViewers);
|
||||||
outsideViewers.remove(player);
|
outsideViewers.remove(player);
|
||||||
|
|
||||||
int entityId = player.getEntityId();
|
int entityId = player.getEntityId();
|
||||||
PacketManager.sendCameraPacket(entityId, viewer);
|
HMCCPacketManager.sendCameraPacket(entityId, viewer);
|
||||||
PacketManager.sendEntityDestroyPacket(armorStandId, viewer);
|
HMCCPacketManager.sendEntityDestroyPacket(armorStandId, viewer);
|
||||||
if (this.originalGamemode != null) {
|
if (this.originalGamemode != null) {
|
||||||
PacketManager.gamemodeChangePacket(player, ServerUtils.convertGamemode(this.originalGamemode));
|
HMCCPacketManager.gamemodeChangePacket(player, HMCCServerUtils.convertGamemode(this.originalGamemode));
|
||||||
player.setGameMode(this.originalGamemode);
|
player.setGameMode(this.originalGamemode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,97 @@
|
|||||||
|
package com.hibiscusmc.hmccosmetics.user.manager;
|
||||||
|
|
||||||
|
import com.hibiscusmc.hmccosmetics.config.Settings;
|
||||||
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||||
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUsers;
|
||||||
|
import com.hibiscusmc.hmccosmetics.util.HMCCPlayerUtils;
|
||||||
|
import com.hibiscusmc.hmccosmetics.util.packets.HMCCPacketManager;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
public class UserEntity {
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
private UUID owner;
|
||||||
|
@Getter
|
||||||
|
private List<Player> viewers = new ArrayList<>();
|
||||||
|
@Getter @Setter
|
||||||
|
private Long viewerLastUpdate = 0L;
|
||||||
|
@Getter @Setter
|
||||||
|
private Long lastPositionUpdate = 0L;
|
||||||
|
@Getter @Setter
|
||||||
|
private List<Integer> ids = new ArrayList<>();
|
||||||
|
@Getter
|
||||||
|
private Location location;
|
||||||
|
|
||||||
|
public UserEntity(UUID owner) {
|
||||||
|
this.owner = owner;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Player> refreshViewers() {
|
||||||
|
return refreshViewers(location);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Player> refreshViewers(Location location) {
|
||||||
|
if (System.currentTimeMillis() - viewerLastUpdate <= 1000) return List.of(); //Prevents mass refreshes
|
||||||
|
ArrayList<Player> newPlayers = new ArrayList<>();
|
||||||
|
ArrayList<Player> removePlayers = new ArrayList<>();
|
||||||
|
List<Player> players = HMCCPlayerUtils.getNearbyPlayers(location);
|
||||||
|
|
||||||
|
for (Player player : players) {
|
||||||
|
CosmeticUser user = CosmeticUsers.getUser(player);
|
||||||
|
if (user != null && owner != user.getUniqueId() && user.isInWardrobe()) { // Fixes issue where players in wardrobe would see other players cosmetics if they were not in wardrobe
|
||||||
|
removePlayers.add(player);
|
||||||
|
HMCCPacketManager.sendEntityDestroyPacket(ids, List.of(player));
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (!viewers.contains(player)) {
|
||||||
|
viewers.add(player);
|
||||||
|
newPlayers.add(player);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
// bad loopdy loops
|
||||||
|
for (Player viewerPlayer : viewers) {
|
||||||
|
if (!players.contains(viewerPlayer)) {
|
||||||
|
removePlayers.add(viewerPlayer);
|
||||||
|
HMCCPacketManager.sendEntityDestroyPacket(ids, List.of(viewerPlayer));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
viewers.removeAll(removePlayers);
|
||||||
|
setViewerLastUpdate(System.currentTimeMillis());
|
||||||
|
return newPlayers;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void teleport(Location location) {
|
||||||
|
if (this.getLocation() != null && this.getLocation().getWorld() == location.getWorld()) {
|
||||||
|
// Was thinking about using schedulers to just send the packet later... but that would be a lot of tasks and
|
||||||
|
// would probably cause more lag. Furthermore, the server "ticks" the cosmetics every second by defualt. So it's fine like this.
|
||||||
|
if (System.currentTimeMillis() - getLastPositionUpdate() <= Settings.getPacketEntityTeleportCooldown()) return;
|
||||||
|
}
|
||||||
|
this.location = location;
|
||||||
|
for (Integer entity : ids) {
|
||||||
|
HMCCPacketManager.sendTeleportPacket(entity, location, false, getViewers());
|
||||||
|
}
|
||||||
|
setLastPositionUpdate(System.currentTimeMillis());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRotation(int yaw) {
|
||||||
|
setRotation(yaw, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRotation(int yaw, boolean additonalPacket) {
|
||||||
|
location.setYaw(yaw);
|
||||||
|
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) HMCCPacketManager.sendRotationPacket(entity, yaw, false, getViewers());
|
||||||
|
HMCCPacketManager.sendLookPacket(entity, location, getViewers());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,19 +1,21 @@
|
|||||||
package com.hibiscusmc.hmccosmetics.user.manager;
|
package com.hibiscusmc.hmccosmetics.user.manager;
|
||||||
|
|
||||||
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
|
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
|
||||||
import com.hibiscusmc.hmccosmetics.config.Settings;
|
|
||||||
import com.hibiscusmc.hmccosmetics.config.Wardrobe;
|
import com.hibiscusmc.hmccosmetics.config.Wardrobe;
|
||||||
import com.hibiscusmc.hmccosmetics.config.WardrobeLocation;
|
import com.hibiscusmc.hmccosmetics.config.WardrobeLocation;
|
||||||
import com.hibiscusmc.hmccosmetics.config.WardrobeSettings;
|
import com.hibiscusmc.hmccosmetics.config.WardrobeSettings;
|
||||||
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
|
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
|
||||||
import com.hibiscusmc.hmccosmetics.cosmetic.CosmeticSlot;
|
import com.hibiscusmc.hmccosmetics.cosmetic.CosmeticSlot;
|
||||||
|
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticBalloonType;
|
||||||
import com.hibiscusmc.hmccosmetics.gui.Menu;
|
import com.hibiscusmc.hmccosmetics.gui.Menu;
|
||||||
import com.hibiscusmc.hmccosmetics.gui.Menus;
|
import com.hibiscusmc.hmccosmetics.gui.Menus;
|
||||||
import com.hibiscusmc.hmccosmetics.nms.NMSHandlers;
|
|
||||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||||
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||||
import com.hibiscusmc.hmccosmetics.util.ServerUtils;
|
import com.hibiscusmc.hmccosmetics.util.HMCCServerUtils;
|
||||||
import com.hibiscusmc.hmccosmetics.util.packets.PacketManager;
|
import com.hibiscusmc.hmccosmetics.util.packets.HMCCPacketManager;
|
||||||
|
import lombok.Getter;
|
||||||
|
import me.lojosho.hibiscuscommons.nms.NMSHandlers;
|
||||||
|
import me.lojosho.hibiscuscommons.util.packets.PacketManager;
|
||||||
import net.kyori.adventure.audience.Audience;
|
import net.kyori.adventure.audience.Audience;
|
||||||
import net.kyori.adventure.bossbar.BossBar;
|
import net.kyori.adventure.bossbar.BossBar;
|
||||||
import net.kyori.adventure.platform.bukkit.BukkitAudiences;
|
import net.kyori.adventure.platform.bukkit.BukkitAudiences;
|
||||||
@@ -24,6 +26,7 @@ import org.bukkit.Location;
|
|||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.entity.EntityType;
|
import org.bukkit.entity.EntityType;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.player.PlayerTeleportEvent;
|
||||||
import org.bukkit.inventory.EquipmentSlot;
|
import org.bukkit.inventory.EquipmentSlot;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.scheduler.BukkitRunnable;
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
@@ -36,24 +39,38 @@ import java.util.concurrent.atomic.AtomicInteger;
|
|||||||
|
|
||||||
public class UserWardrobeManager {
|
public class UserWardrobeManager {
|
||||||
|
|
||||||
|
@Getter
|
||||||
private final int NPC_ID;
|
private final int NPC_ID;
|
||||||
|
@Getter
|
||||||
private final int ARMORSTAND_ID;
|
private final int ARMORSTAND_ID;
|
||||||
|
@Getter
|
||||||
private final UUID WARDROBE_UUID;
|
private final UUID WARDROBE_UUID;
|
||||||
|
@Getter
|
||||||
private String npcName;
|
private String npcName;
|
||||||
|
@Getter
|
||||||
private GameMode originalGamemode;
|
private GameMode originalGamemode;
|
||||||
|
@Getter
|
||||||
private final CosmeticUser user;
|
private final CosmeticUser user;
|
||||||
|
@Getter
|
||||||
private final Wardrobe wardrobe;
|
private final Wardrobe wardrobe;
|
||||||
|
@Getter
|
||||||
private final WardrobeLocation wardrobeLocation;
|
private final WardrobeLocation wardrobeLocation;
|
||||||
|
@Getter
|
||||||
private final Location viewingLocation;
|
private final Location viewingLocation;
|
||||||
|
@Getter
|
||||||
private final Location npcLocation;
|
private final Location npcLocation;
|
||||||
|
@Getter
|
||||||
private Location exitLocation;
|
private Location exitLocation;
|
||||||
|
@Getter
|
||||||
private BossBar bossBar;
|
private BossBar bossBar;
|
||||||
|
@Getter
|
||||||
private boolean active;
|
private boolean active;
|
||||||
|
@Getter
|
||||||
private WardrobeStatus wardrobeStatus;
|
private WardrobeStatus wardrobeStatus;
|
||||||
|
|
||||||
public UserWardrobeManager(CosmeticUser user, Wardrobe wardrobe) {
|
public UserWardrobeManager(CosmeticUser user, Wardrobe wardrobe) {
|
||||||
NPC_ID = NMSHandlers.getHandler().getNextEntityId();
|
NPC_ID = me.lojosho.hibiscuscommons.util.ServerUtils.getNextEntityId();
|
||||||
ARMORSTAND_ID = NMSHandlers.getHandler().getNextEntityId();
|
ARMORSTAND_ID = me.lojosho.hibiscuscommons.util.ServerUtils.getNextEntityId();
|
||||||
WARDROBE_UUID = UUID.randomUUID();
|
WARDROBE_UUID = UUID.randomUUID();
|
||||||
this.user = user;
|
this.user = user;
|
||||||
|
|
||||||
@@ -78,62 +95,72 @@ public class UserWardrobeManager {
|
|||||||
|
|
||||||
user.hidePlayer();
|
user.hidePlayer();
|
||||||
List<Player> viewer = Collections.singletonList(player);
|
List<Player> viewer = Collections.singletonList(player);
|
||||||
List<Player> outsideViewers = PacketManager.getViewers(viewingLocation);
|
List<Player> outsideViewers = HMCCPacketManager.getViewers(viewingLocation);
|
||||||
outsideViewers.remove(player);
|
outsideViewers.remove(player);
|
||||||
|
|
||||||
MessagesUtil.sendMessage(player, "opened-wardrobe");
|
MessagesUtil.sendMessage(player, "opened-wardrobe");
|
||||||
|
|
||||||
Runnable run = () -> {
|
Runnable run = () -> {
|
||||||
// Armorstand
|
// Armorstand
|
||||||
PacketManager.sendEntitySpawnPacket(viewingLocation, ARMORSTAND_ID, EntityType.ARMOR_STAND, UUID.randomUUID(), viewer);
|
HMCCPacketManager.sendEntitySpawnPacket(viewingLocation, ARMORSTAND_ID, EntityType.ARMOR_STAND, UUID.randomUUID(), viewer);
|
||||||
PacketManager.sendInvisibilityPacket(ARMORSTAND_ID, viewer);
|
HMCCPacketManager.sendArmorstandMetadata(ARMORSTAND_ID, viewer);
|
||||||
PacketManager.sendLookPacket(ARMORSTAND_ID, viewingLocation, viewer);
|
HMCCPacketManager.sendLookPacket(ARMORSTAND_ID, viewingLocation, viewer);
|
||||||
|
|
||||||
// Player
|
// Player
|
||||||
PacketManager.gamemodeChangePacket(player, 3);
|
user.getPlayer().teleport(viewingLocation, PlayerTeleportEvent.TeleportCause.PLUGIN);
|
||||||
PacketManager.sendCameraPacket(ARMORSTAND_ID, viewer);
|
user.getPlayer().setInvisible(true);
|
||||||
|
HMCCPacketManager.gamemodeChangePacket(player, 3);
|
||||||
|
HMCCPacketManager.sendCameraPacket(ARMORSTAND_ID, viewer);
|
||||||
|
|
||||||
// NPC
|
// NPC
|
||||||
npcName = "WardrobeNPC-" + NPC_ID;
|
npcName = "WardrobeNPC-" + NPC_ID;
|
||||||
while (npcName.length() > 16) {
|
while (npcName.length() > 16) {
|
||||||
npcName = npcName.substring(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
|
// NPC 2
|
||||||
Bukkit.getScheduler().runTaskLater(HMCCosmeticsPlugin.getInstance(), () -> {
|
Bukkit.getScheduler().runTaskLater(HMCCosmeticsPlugin.getInstance(), () -> {
|
||||||
PacketManager.sendFakePlayerSpawnPacket(npcLocation, WARDROBE_UUID, NPC_ID, viewer);
|
if (!user.isInWardrobe()) return; // If a player exits the wardrobe right away, no need to spawn the NPC
|
||||||
PacketManager.sendPlayerOverlayPacket(NPC_ID, viewer);
|
HMCCPacketManager.sendFakePlayerSpawnPacket(npcLocation, WARDROBE_UUID, NPC_ID, viewer);
|
||||||
|
HMCCPacketManager.sendPlayerOverlayPacket(NPC_ID, viewer);
|
||||||
MessagesUtil.sendDebugMessages("Spawned Fake Player on " + npcLocation);
|
MessagesUtil.sendDebugMessages("Spawned Fake Player on " + npcLocation);
|
||||||
NMSHandlers.getHandler().hideNPCName(player, npcName);
|
NMSHandlers.getHandler().hideNPCName(player, npcName);
|
||||||
}, 4);
|
}, 4);
|
||||||
|
|
||||||
// Location
|
// Location
|
||||||
PacketManager.sendLookPacket(NPC_ID, npcLocation, viewer);
|
HMCCPacketManager.sendLookPacket(NPC_ID, npcLocation, viewer);
|
||||||
PacketManager.sendRotationPacket(NPC_ID, npcLocation, true, viewer);
|
HMCCPacketManager.sendRotationPacket(NPC_ID, npcLocation, true, viewer);
|
||||||
|
|
||||||
// Misc
|
// Misc
|
||||||
if (user.hasCosmeticInSlot(CosmeticSlot.BACKPACK)) {
|
if (user.hasCosmeticInSlot(CosmeticSlot.BACKPACK)) {
|
||||||
// Maybe null as backpack maybe despawned before entering
|
// Maybe null as backpack maybe despawned before entering
|
||||||
if (user.getUserBackpackManager() == null) user.respawnBackpack();
|
if (user.getUserBackpackManager() == null) user.respawnBackpack();
|
||||||
user.getUserBackpackManager().getArmorStand().teleport(npcLocation.clone().add(0, 2, 0));
|
if (user.isBackpackSpawned()) {
|
||||||
NMSHandlers.getHandler().equipmentSlotUpdate(user.getUserBackpackManager().getFirstArmorStandId(), EquipmentSlot.HEAD, user.getUserCosmeticItem(user.getCosmetic(CosmeticSlot.BACKPACK)), viewer);
|
user.getUserBackpackManager().getEntityManager().teleport(npcLocation.clone().add(0, 2, 0));
|
||||||
PacketManager.ridingMountPacket(NPC_ID, user.getUserBackpackManager().getFirstArmorStandId(), viewer);
|
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)) {
|
if (user.hasCosmeticInSlot(CosmeticSlot.BALLOON)) {
|
||||||
user.getBalloonManager().sendRemoveLeashPacket(viewer);
|
if (user.getBalloonManager() == null) user.respawnBalloon();
|
||||||
user.getBalloonManager().sendLeashPacket(NPC_ID);
|
if (user.isBalloonSpawned()) {
|
||||||
//PacketManager.sendLeashPacket(VIEWER.getBalloonEntity().getModelId(), NPC_ID, viewer);
|
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(Settings.getBalloonOffset());
|
Location balloonLocation = npcLocation.clone().add(cosmetic.getBalloonOffset());
|
||||||
PacketManager.sendTeleportPacket(user.getBalloonManager().getPufferfishBalloonId(), balloonLocation , false, viewer);
|
HMCCPacketManager.sendTeleportPacket(user.getBalloonManager().getPufferfishBalloonId(), balloonLocation, false, viewer);
|
||||||
user.getBalloonManager().getModelEntity().teleport(balloonLocation);
|
user.getBalloonManager().getModelEntity().teleport(balloonLocation);
|
||||||
|
user.getBalloonManager().setLocation(balloonLocation);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (WardrobeSettings.getEnabledBossbar()) {
|
if (WardrobeSettings.isEnabledBossbar()) {
|
||||||
float progress = WardrobeSettings.getBossbarProgress();
|
float progress = WardrobeSettings.getBossbarProgress();
|
||||||
Component message = MessagesUtil.processStringNoKey(WardrobeSettings.getBossbarText());
|
Component message = MessagesUtil.processStringNoKey(WardrobeSettings.getBossbarMessage());
|
||||||
|
|
||||||
bossBar = BossBar.bossBar(message, progress, WardrobeSettings.getBossbarColor(), WardrobeSettings.getBossbarOverlay());
|
bossBar = BossBar.bossBar(message, progress, WardrobeSettings.getBossbarColor(), WardrobeSettings.getBossbarOverlay());
|
||||||
Audience target = BukkitAudiences.create(HMCCosmeticsPlugin.getInstance()).player(player);
|
Audience target = BukkitAudiences.create(HMCCosmeticsPlugin.getInstance()).player(player);
|
||||||
@@ -172,7 +199,7 @@ public class UserWardrobeManager {
|
|||||||
Player player = user.getPlayer();
|
Player player = user.getPlayer();
|
||||||
|
|
||||||
List<Player> viewer = Collections.singletonList(player);
|
List<Player> viewer = Collections.singletonList(player);
|
||||||
List<Player> outsideViewers = PacketManager.getViewers(viewingLocation);
|
List<Player> outsideViewers = HMCCPacketManager.getViewers(viewingLocation);
|
||||||
outsideViewers.remove(player);
|
outsideViewers.remove(player);
|
||||||
|
|
||||||
if (player != null) MessagesUtil.sendMessage(player, "closed-wardrobe");
|
if (player != null) MessagesUtil.sendMessage(player, "closed-wardrobe");
|
||||||
@@ -190,25 +217,26 @@ public class UserWardrobeManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// NPC
|
// NPC
|
||||||
if (user.hasCosmeticInSlot(CosmeticSlot.BALLOON)) user.getBalloonManager().sendRemoveLeashPacket();
|
if (user.isBalloonSpawned()) user.getBalloonManager().sendRemoveLeashPacket();
|
||||||
PacketManager.sendEntityDestroyPacket(NPC_ID, viewer); // Success
|
HMCCPacketManager.sendEntityDestroyPacket(NPC_ID, viewer); // Success
|
||||||
PacketManager.sendRemovePlayerPacket(player, WARDROBE_UUID, viewer); // Success
|
HMCCPacketManager.sendRemovePlayerPacket(player, WARDROBE_UUID, viewer); // Success
|
||||||
|
|
||||||
// Player
|
// Player
|
||||||
PacketManager.sendCameraPacket(player.getEntityId(), viewer);
|
HMCCPacketManager.sendCameraPacket(player.getEntityId(), viewer);
|
||||||
|
user.getPlayer().setInvisible(false);
|
||||||
|
|
||||||
// Armorstand
|
// Armorstand
|
||||||
PacketManager.sendEntityDestroyPacket(ARMORSTAND_ID, viewer); // Sucess
|
HMCCPacketManager.sendEntityDestroyPacket(ARMORSTAND_ID, viewer); // Sucess
|
||||||
|
|
||||||
//PacketManager.sendEntityDestroyPacket(player.getEntityId(), viewer); // Success
|
//PacketManager.sendEntityDestroyPacket(player.getEntityId(), viewer); // Success
|
||||||
if (WardrobeSettings.isForceExitGamemode()) {
|
if (WardrobeSettings.isForceExitGamemode()) {
|
||||||
MessagesUtil.sendDebugMessages("Force Exit Gamemode " + WardrobeSettings.getExitGamemode());
|
MessagesUtil.sendDebugMessages("Force Exit Gamemode " + WardrobeSettings.getExitGamemode());
|
||||||
player.setGameMode(WardrobeSettings.getExitGamemode());
|
player.setGameMode(WardrobeSettings.getExitGamemode());
|
||||||
PacketManager.gamemodeChangePacket(player, ServerUtils.convertGamemode(WardrobeSettings.getExitGamemode())); // Success
|
HMCCPacketManager.gamemodeChangePacket(player, HMCCServerUtils.convertGamemode(WardrobeSettings.getExitGamemode())); // Success
|
||||||
} else {
|
} else {
|
||||||
MessagesUtil.sendDebugMessages("Original Gamemode " + this.originalGamemode);
|
MessagesUtil.sendDebugMessages("Original Gamemode " + this.originalGamemode);
|
||||||
player.setGameMode(this.originalGamemode);
|
player.setGameMode(this.originalGamemode);
|
||||||
PacketManager.gamemodeChangePacket(player, ServerUtils.convertGamemode(this.originalGamemode)); // Success
|
HMCCPacketManager.gamemodeChangePacket(player, HMCCServerUtils.convertGamemode(this.originalGamemode)); // Success
|
||||||
}
|
}
|
||||||
user.showPlayer();
|
user.showPlayer();
|
||||||
|
|
||||||
@@ -218,17 +246,17 @@ public class UserWardrobeManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (user.hasCosmeticInSlot(CosmeticSlot.BALLOON)) {
|
if (user.hasCosmeticInSlot(CosmeticSlot.BALLOON)) {
|
||||||
user.respawnBalloon();
|
//user.respawnBalloon();
|
||||||
//PacketManager.sendLeashPacket(VIEWER.getBalloonEntity().getPufferfishBalloonId(), player.getEntityId(), viewer);
|
//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()) {
|
if (WardrobeSettings.isEquipPumpkin()) {
|
||||||
NMSHandlers.getHandler().equipmentSlotUpdate(user.getPlayer().getEntityId(), EquipmentSlot.HEAD, player.getInventory().getHelmet(), viewer);
|
PacketManager.equipmentSlotUpdate(user.getPlayer().getEntityId(), EquipmentSlot.HEAD, player.getInventory().getHelmet(), viewer);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (WardrobeSettings.getEnabledBossbar()) {
|
if (WardrobeSettings.isEnabledBossbar()) {
|
||||||
Audience target = BukkitAudiences.create(HMCCosmeticsPlugin.getInstance()).player(player);
|
Audience target = BukkitAudiences.create(HMCCosmeticsPlugin.getInstance()).player(player);
|
||||||
|
|
||||||
target.hideBossBar(bossBar);
|
target.hideBossBar(bossBar);
|
||||||
@@ -253,43 +281,47 @@ public class UserWardrobeManager {
|
|||||||
}
|
}
|
||||||
MessagesUtil.sendDebugMessages("WardrobeUpdate[user=" + user.getUniqueId() + ",status=" + getWardrobeStatus() + "]");
|
MessagesUtil.sendDebugMessages("WardrobeUpdate[user=" + user.getUniqueId() + ",status=" + getWardrobeStatus() + "]");
|
||||||
List<Player> viewer = Collections.singletonList(player);
|
List<Player> viewer = Collections.singletonList(player);
|
||||||
List<Player> outsideViewers = PacketManager.getViewers(viewingLocation);
|
List<Player> outsideViewers = HMCCPacketManager.getViewers(viewingLocation);
|
||||||
outsideViewers.remove(player);
|
outsideViewers.remove(player);
|
||||||
|
|
||||||
Location location = npcLocation;
|
Location location = npcLocation;
|
||||||
int yaw = data.get();
|
int yaw = data.get();
|
||||||
location.setYaw(yaw);
|
location.setYaw(yaw);
|
||||||
|
|
||||||
PacketManager.sendLookPacket(NPC_ID, location, viewer);
|
HMCCPacketManager.sendLookPacket(NPC_ID, location, viewer);
|
||||||
user.hidePlayer();
|
user.hidePlayer();
|
||||||
int rotationSpeed = WardrobeSettings.getRotationSpeed();
|
int rotationSpeed = WardrobeSettings.getRotationSpeed();
|
||||||
location.setYaw(ServerUtils.getNextYaw(yaw - 30, rotationSpeed));
|
location.setYaw(HMCCServerUtils.getNextYaw(yaw - 30, rotationSpeed));
|
||||||
PacketManager.sendRotationPacket(NPC_ID, location, true, viewer);
|
HMCCPacketManager.sendRotationPacket(NPC_ID, location, true, viewer);
|
||||||
int nextyaw = ServerUtils.getNextYaw(yaw, rotationSpeed);
|
int nextyaw = HMCCServerUtils.getNextYaw(yaw, rotationSpeed);
|
||||||
data.set(nextyaw);
|
data.set(nextyaw);
|
||||||
|
|
||||||
for (CosmeticSlot slot : CosmeticSlot.values()) {
|
for (CosmeticSlot slot : CosmeticSlot.values()) {
|
||||||
PacketManager.equipmentSlotUpdate(NPC_ID, user, slot, viewer);
|
HMCCPacketManager.equipmentSlotUpdate(NPC_ID, user, slot, viewer);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (user.hasCosmeticInSlot(CosmeticSlot.BACKPACK)) {
|
if (user.hasCosmeticInSlot(CosmeticSlot.BACKPACK) && user.getUserBackpackManager() != null) {
|
||||||
PacketManager.sendTeleportPacket(user.getUserBackpackManager().getFirstArmorStandId(), location, false, viewer);
|
HMCCPacketManager.sendTeleportPacket(user.getUserBackpackManager().getFirstArmorStandId(), location, false, viewer);
|
||||||
PacketManager.ridingMountPacket(NPC_ID, user.getUserBackpackManager().getFirstArmorStandId(), viewer);
|
HMCCPacketManager.ridingMountPacket(NPC_ID, user.getUserBackpackManager().getFirstArmorStandId(), viewer);
|
||||||
user.getUserBackpackManager().getArmorStand().setRotation(nextyaw, 0);
|
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
|
// The two lines below broke, solved by listening to PlayerCosmeticPostEquipEvent
|
||||||
//PacketManager.sendTeleportPacket(user.getBalloonManager().getPufferfishBalloonId(), npcLocation.add(Settings.getBalloonOffset()), false, viewer);
|
//PacketManager.sendTeleportPacket(user.getBalloonManager().getPufferfishBalloonId(), npcLocation.add(Settings.getBalloonOffset()), false, viewer);
|
||||||
//user.getBalloonManager().getModelEntity().teleport(npcLocation.add(Settings.getBalloonOffset()));
|
//user.getBalloonManager().getModelEntity().teleport(npcLocation.add(Settings.getBalloonOffset()));
|
||||||
user.getBalloonManager().sendRemoveLeashPacket(outsideViewers);
|
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);
|
user.getBalloonManager().sendLeashPacket(NPC_ID);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (WardrobeSettings.isEquipPumpkin()) {
|
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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -297,14 +329,6 @@ public class UserWardrobeManager {
|
|||||||
runnable.runTaskTimer(HMCCosmeticsPlugin.getInstance(), 0, 2);
|
runnable.runTaskTimer(HMCCosmeticsPlugin.getInstance(), 0, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getCameraId() {
|
|
||||||
return ARMORSTAND_ID;
|
|
||||||
}
|
|
||||||
|
|
||||||
public WardrobeStatus getWardrobeStatus() {
|
|
||||||
return wardrobeStatus;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setWardrobeStatus(WardrobeStatus status) {
|
public void setWardrobeStatus(WardrobeStatus status) {
|
||||||
this.wardrobeStatus = status;
|
this.wardrobeStatus = status;
|
||||||
}
|
}
|
||||||
@@ -316,7 +340,4 @@ public class UserWardrobeManager {
|
|||||||
STOPPING,
|
STOPPING,
|
||||||
}
|
}
|
||||||
|
|
||||||
public Location getNpcLocation() {
|
|
||||||
return npcLocation;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import org.jetbrains.annotations.Contract;
|
|||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
public class InventoryUtils {
|
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
|
* 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 +52,17 @@ 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;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
public static CosmeticSlot BukkitCosmeticSlot(EquipmentSlot slot) {
|
public static CosmeticSlot BukkitCosmeticSlot(EquipmentSlot slot) {
|
||||||
return switch (slot) {
|
return switch (slot) {
|
||||||
case HAND -> CosmeticSlot.MAINHAND;
|
case HAND -> CosmeticSlot.MAINHAND;
|
||||||
@@ -152,16 +163,4 @@ public class InventoryUtils {
|
|||||||
public static NamespacedKey getCosmeticKey() {
|
public static NamespacedKey getCosmeticKey() {
|
||||||
return new NamespacedKey(HMCCosmeticsPlugin.getInstance(), "cosmetic");
|
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");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -3,16 +3,15 @@ package com.hibiscusmc.hmccosmetics.util;
|
|||||||
import com.comphenix.protocol.wrappers.WrappedGameProfile;
|
import com.comphenix.protocol.wrappers.WrappedGameProfile;
|
||||||
import com.comphenix.protocol.wrappers.WrappedSignedProperty;
|
import com.comphenix.protocol.wrappers.WrappedSignedProperty;
|
||||||
import com.hibiscusmc.hmccosmetics.config.Settings;
|
import com.hibiscusmc.hmccosmetics.config.Settings;
|
||||||
|
import me.lojosho.hibiscuscommons.util.packets.PacketManager;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.entity.Entity;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class PlayerUtils {
|
public class HMCCPlayerUtils {
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public static WrappedSignedProperty getSkin(Player player) {
|
public static WrappedSignedProperty getSkin(Player player) {
|
||||||
@@ -32,13 +31,6 @@ public class PlayerUtils {
|
|||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public static List<Player> getNearbyPlayers(@NotNull Location location) {
|
public static List<Player> getNearbyPlayers(@NotNull Location location) {
|
||||||
List<Player> players = new ArrayList<>();
|
return PacketManager.getViewers(location, Settings.getViewDistance());
|
||||||
int viewDistance = Settings.getViewDistance();
|
|
||||||
for (Entity entity : location.getWorld().getNearbyEntities(location, viewDistance, viewDistance, viewDistance)) {
|
|
||||||
if (entity instanceof Player) {
|
|
||||||
players.add((Player) entity);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return players;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,11 +1,11 @@
|
|||||||
package com.hibiscusmc.hmccosmetics.util;
|
package com.hibiscusmc.hmccosmetics.util;
|
||||||
|
|
||||||
import com.hibiscusmc.hmccosmetics.nms.NMSHandlers;
|
|
||||||
import com.owen1212055.particlehelper.api.particle.MultiParticle;
|
import com.owen1212055.particlehelper.api.particle.MultiParticle;
|
||||||
import com.owen1212055.particlehelper.api.particle.Particle;
|
import com.owen1212055.particlehelper.api.particle.Particle;
|
||||||
import com.owen1212055.particlehelper.api.particle.types.*;
|
import com.owen1212055.particlehelper.api.particle.types.*;
|
||||||
import com.owen1212055.particlehelper.api.particle.types.dust.transition.TransitionDustParticle;
|
import com.owen1212055.particlehelper.api.particle.types.dust.transition.TransitionDustParticle;
|
||||||
import com.owen1212055.particlehelper.api.particle.types.note.MultiNoteParticle;
|
import com.owen1212055.particlehelper.api.particle.types.note.MultiNoteParticle;
|
||||||
|
import me.lojosho.hibiscuscommons.nms.NMSHandlers;
|
||||||
import org.bukkit.Color;
|
import org.bukkit.Color;
|
||||||
import org.bukkit.GameMode;
|
import org.bukkit.GameMode;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
@@ -14,7 +14,7 @@ import org.jetbrains.annotations.Nullable;
|
|||||||
import java.math.BigInteger;
|
import java.math.BigInteger;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
|
||||||
public class ServerUtils {
|
public class HMCCServerUtils {
|
||||||
|
|
||||||
private static String COLOR_CHAR = "&";
|
private static String COLOR_CHAR = "&";
|
||||||
|
|
||||||
@@ -36,6 +36,11 @@ public class ServerUtils {
|
|||||||
return NMSHandlers.getHandler().getEntity(entityId);
|
return NMSHandlers.getHandler().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) {
|
public static Color hex2Rgb(String colorStr) {
|
||||||
if (colorStr.startsWith("#")) return Color.fromRGB(Integer.valueOf(colorStr.substring(1), 16));
|
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));
|
if (colorStr.startsWith("0x")) return Color.fromRGB(Integer.valueOf(colorStr.substring(2), 16));
|
||||||
@@ -48,6 +53,22 @@ public class ServerUtils {
|
|||||||
return Color.WHITE;
|
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
|
// particle amount offsetxyz
|
||||||
// Ex. HEART 10 0.1 0.1 0.1
|
// Ex. HEART 10 0.1 0.1 0.1
|
||||||
public static Particle addParticleValues(Particle particle, String[] split) {
|
public static Particle addParticleValues(Particle particle, String[] split) {
|
||||||
@@ -136,4 +157,13 @@ public class ServerUtils {
|
|||||||
}
|
}
|
||||||
return nextYaw;
|
return nextYaw;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean hasClass(String className) {
|
||||||
|
try {
|
||||||
|
Class.forName(className);
|
||||||
|
return true;
|
||||||
|
} catch (ClassNotFoundException e) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -2,10 +2,10 @@ package com.hibiscusmc.hmccosmetics.util;
|
|||||||
|
|
||||||
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
|
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
|
||||||
import com.hibiscusmc.hmccosmetics.config.Settings;
|
import com.hibiscusmc.hmccosmetics.config.Settings;
|
||||||
import com.hibiscusmc.hmccosmetics.config.WardrobeSettings;
|
|
||||||
import com.hibiscusmc.hmccosmetics.hooks.Hooks;
|
|
||||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
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.audience.Audience;
|
||||||
import net.kyori.adventure.platform.bukkit.BukkitAudiences;
|
import net.kyori.adventure.platform.bukkit.BukkitAudiences;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
@@ -15,7 +15,6 @@ import org.bukkit.command.CommandSender;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
import org.spongepowered.configurate.ConfigurationNode;
|
|
||||||
|
|
||||||
import java.time.Duration;
|
import java.time.Duration;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@@ -106,9 +105,9 @@ public class MessagesUtil {
|
|||||||
if (player != null) message = Hooks.processPlaceholders(player, message);
|
if (player != null) message = Hooks.processPlaceholders(player, message);
|
||||||
message = message.replaceAll("%prefix%", prefix);
|
message = message.replaceAll("%prefix%", prefix);
|
||||||
if (placeholders != null ) {
|
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
|
@NotNull
|
||||||
@@ -126,9 +125,9 @@ public class MessagesUtil {
|
|||||||
message = message.replaceAll("%prefix%", prefix);
|
message = message.replaceAll("%prefix%", prefix);
|
||||||
if (player != null) message = Hooks.processPlaceholders(player, message);
|
if (player != null) message = Hooks.processPlaceholders(player, message);
|
||||||
if (placeholders != null ) {
|
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) {
|
public static String processStringNoKeyString(Player player, String message) {
|
||||||
@@ -142,7 +141,7 @@ public class MessagesUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void sendDebugMessages(String message, Level level) {
|
public static void sendDebugMessages(String message, Level level) {
|
||||||
if (!Settings.isDebugEnabled() && level == Level.INFO) return;
|
if (!Settings.isDebugMode() && level == Level.INFO) return;
|
||||||
HMCCosmeticsPlugin.getInstance().getLogger().log(level, message);
|
HMCCosmeticsPlugin.getInstance().getLogger().log(level, message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package com.hibiscusmc.hmccosmetics.util;
|
package com.hibiscusmc.hmccosmetics.util;
|
||||||
|
|
||||||
import com.hibiscusmc.hmccosmetics.util.misc.StringUtils;
|
import me.lojosho.hibiscuscommons.util.StringUtils;
|
||||||
import org.spongepowered.configurate.ConfigurationNode;
|
import me.lojosho.shaded.configurate.ConfigurationNode;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
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,36 +1,32 @@
|
|||||||
package com.hibiscusmc.hmccosmetics.util.packets;
|
package com.hibiscusmc.hmccosmetics.util.packets;
|
||||||
|
|
||||||
import com.comphenix.protocol.PacketType;
|
import com.comphenix.protocol.PacketType;
|
||||||
|
import com.comphenix.protocol.ProtocolLibrary;
|
||||||
import com.comphenix.protocol.events.PacketContainer;
|
import com.comphenix.protocol.events.PacketContainer;
|
||||||
import com.comphenix.protocol.wrappers.*;
|
import com.comphenix.protocol.wrappers.*;
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
|
import com.hibiscusmc.hmccosmetics.api.HMCCosmeticsAPI;
|
||||||
import com.hibiscusmc.hmccosmetics.config.Settings;
|
import com.hibiscusmc.hmccosmetics.config.Settings;
|
||||||
import com.hibiscusmc.hmccosmetics.cosmetic.CosmeticSlot;
|
import com.hibiscusmc.hmccosmetics.cosmetic.CosmeticSlot;
|
||||||
import com.hibiscusmc.hmccosmetics.nms.NMSHandlers;
|
|
||||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUsers;
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUsers;
|
||||||
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
import com.hibiscusmc.hmccosmetics.util.HMCCInventoryUtils;
|
||||||
import com.hibiscusmc.hmccosmetics.util.PlayerUtils;
|
import com.hibiscusmc.hmccosmetics.util.HMCCPlayerUtils;
|
||||||
import com.hibiscusmc.hmccosmetics.util.packets.wrappers.WrapperPlayServerNamedEntitySpawn;
|
import com.hibiscusmc.hmccosmetics.util.packets.wrappers.WrapperPlayServerNamedEntitySpawn;
|
||||||
import com.hibiscusmc.hmccosmetics.util.packets.wrappers.WrapperPlayServerPlayerInfo;
|
import com.hibiscusmc.hmccosmetics.util.packets.wrappers.WrapperPlayServerPlayerInfo;
|
||||||
import com.hibiscusmc.hmccosmetics.util.packets.wrappers.WrapperPlayServerRelEntityMove;
|
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.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.Particle;
|
|
||||||
import org.bukkit.entity.Entity;
|
|
||||||
import org.bukkit.entity.EntityType;
|
import org.bukkit.entity.EntityType;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.EquipmentSlot;
|
import org.bukkit.inventory.EquipmentSlot;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
public class PacketManager extends BasePacket {
|
public class HMCCPacketManager extends PacketManager {
|
||||||
|
|
||||||
public static void sendEntitySpawnPacket(
|
public static void sendEntitySpawnPacket(
|
||||||
final @NotNull Location location,
|
final @NotNull Location location,
|
||||||
@@ -60,39 +56,18 @@ public class PacketManager extends BasePacket {
|
|||||||
for (Player p : sendTo) sendPacket(p, packet);
|
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(
|
public static void equipmentSlotUpdate(
|
||||||
Player player,
|
Player player,
|
||||||
boolean empty,
|
boolean empty,
|
||||||
List<Player> sendTo
|
List<Player> sendTo
|
||||||
) {
|
) {
|
||||||
|
HashMap<EquipmentSlot, ItemStack> items = new HashMap<>();
|
||||||
for (EquipmentSlot slot : EquipmentSlot.values()) {
|
for (EquipmentSlot slot : EquipmentSlot.values()) {
|
||||||
ItemStack item = player.getInventory().getItem(slot);
|
ItemStack item = player.getInventory().getItem(slot);
|
||||||
if (empty) item = new ItemStack(Material.AIR);
|
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(
|
public static void equipmentSlotUpdate(
|
||||||
@NotNull Player player,
|
@NotNull Player player,
|
||||||
@@ -118,22 +93,28 @@ public class PacketManager extends BasePacket {
|
|||||||
) {
|
) {
|
||||||
if (cosmeticSlot == CosmeticSlot.BACKPACK || cosmeticSlot == CosmeticSlot.BALLOON || cosmeticSlot == CosmeticSlot.EMOTE) return;
|
if (cosmeticSlot == CosmeticSlot.BACKPACK || cosmeticSlot == CosmeticSlot.BALLOON || cosmeticSlot == CosmeticSlot.EMOTE) return;
|
||||||
|
|
||||||
NMSHandlers.getHandler().equipmentSlotUpdate(entityId, user, cosmeticSlot, sendTo);
|
equipmentSlotUpdate(entityId, HMCCInventoryUtils.getEquipmentSlot(cosmeticSlot), user.getUserCosmeticItem(cosmeticSlot), sendTo);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void armorStandMetaPacket(
|
public static void sendArmorstandMetadata(
|
||||||
@NotNull Entity entity,
|
int entityId,
|
||||||
List<Player> sendTo
|
List<Player> sendTo
|
||||||
) {
|
) {
|
||||||
PacketContainer packet = new PacketContainer(PacketType.Play.Server.ENTITY_METADATA);
|
PacketContainer packet = new PacketContainer(PacketType.Play.Server.ENTITY_METADATA);
|
||||||
packet.getModifier().writeDefaults();
|
packet.getModifier().writeDefaults();
|
||||||
packet.getIntegers().write(0, entity.getEntityId());
|
packet.getIntegers().write(0, entityId);
|
||||||
WrappedDataWatcher metadata = new WrappedDataWatcher();
|
WrappedDataWatcher wrapper = new WrappedDataWatcher();
|
||||||
if (metadata == null) return;
|
|
||||||
// 0x10 & 0x20
|
if (HMCCosmeticsAPI.getNMSVersion().contains("v1_18_R2") || HMCCosmeticsAPI.getNMSVersion().contains("v1_19_R1")) {
|
||||||
metadata.setObject(new WrappedDataWatcher.WrappedDataWatcherObject(0, WrappedDataWatcher.Registry.get(Byte.class)), (byte) 0x20);
|
wrapper.setObject(new WrappedDataWatcher.WrappedDataWatcherObject(0, WrappedDataWatcher.Registry.get(Byte.class)), (byte) 0x20);
|
||||||
metadata.setObject(new WrappedDataWatcher.WrappedDataWatcherObject(15, WrappedDataWatcher.Registry.get(Byte.class)), (byte) 0x10);
|
wrapper.setObject(new WrappedDataWatcher.WrappedDataWatcherObject(15, WrappedDataWatcher.Registry.get(Byte.class)), (byte) 0x10);
|
||||||
packet.getWatchableCollectionModifier().write(0, metadata.getWatchableObjects());
|
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);
|
||||||
|
}
|
||||||
for (Player p : sendTo) sendPacket(p, packet);
|
for (Player p : sendTo) sendPacket(p, packet);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -146,7 +127,7 @@ public class PacketManager extends BasePacket {
|
|||||||
packet.getIntegers().write(0, entityId);
|
packet.getIntegers().write(0, entityId);
|
||||||
WrappedDataWatcher wrapper = new WrappedDataWatcher();
|
WrappedDataWatcher wrapper = new WrappedDataWatcher();
|
||||||
|
|
||||||
if (NMSHandlers.getVersion().contains("v1_18_R2") || NMSHandlers.getVersion().contains("v1_19_R1")) {
|
if (HMCCosmeticsAPI.getNMSVersion().contains("v1_18_R2") || HMCCosmeticsAPI.getNMSVersion().contains("v1_19_R1")) {
|
||||||
wrapper.setObject(new WrappedDataWatcher.WrappedDataWatcherObject(0, WrappedDataWatcher.Registry.get(Byte.class)), (byte) 0x20);
|
wrapper.setObject(new WrappedDataWatcher.WrappedDataWatcherObject(0, WrappedDataWatcher.Registry.get(Byte.class)), (byte) 0x20);
|
||||||
packet.getWatchableCollectionModifier().write(0, wrapper.getWatchableObjects());
|
packet.getWatchableCollectionModifier().write(0, wrapper.getWatchableObjects());
|
||||||
} else {
|
} else {
|
||||||
@@ -166,7 +147,7 @@ public class PacketManager extends BasePacket {
|
|||||||
packet.getIntegers().write(0, entityId);
|
packet.getIntegers().write(0, entityId);
|
||||||
WrappedDataWatcher wrapper = new WrappedDataWatcher();
|
WrappedDataWatcher wrapper = new WrappedDataWatcher();
|
||||||
|
|
||||||
if (NMSHandlers.getVersion().contains("v1_18_R2") || NMSHandlers.getVersion().contains("v1_19_R1")) {
|
if (HMCCosmeticsAPI.getNMSVersion().contains("v1_18_R2") || HMCCosmeticsAPI.getNMSVersion().contains("v1_19_R1")) {
|
||||||
wrapper.setObject(new WrappedDataWatcher.WrappedDataWatcherObject(0, WrappedDataWatcher.Registry.get(Byte.class)), (byte) 0x20);
|
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);
|
wrapper.setObject(new WrappedDataWatcher.WrappedDataWatcherObject(8, WrappedDataWatcher.Registry.get(Float.class)), 0f);
|
||||||
packet.getWatchableCollectionModifier().write(0, wrapper.getWatchableObjects());
|
packet.getWatchableCollectionModifier().write(0, wrapper.getWatchableObjects());
|
||||||
@@ -180,17 +161,6 @@ public class PacketManager extends BasePacket {
|
|||||||
for (Player p : sendTo) sendPacket(p, packet);
|
for (Player p : sendTo) sendPacket(p, packet);
|
||||||
}
|
}
|
||||||
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void sendRotationPacket(
|
public static void sendRotationPacket(
|
||||||
int entityId,
|
int entityId,
|
||||||
Location location,
|
Location location,
|
||||||
@@ -283,41 +253,6 @@ public class PacketManager extends BasePacket {
|
|||||||
sendRidingPacket(mountId, new int[] {passengerId}, sendTo);
|
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.
|
* @param location Location of the fake player.
|
||||||
@@ -331,13 +266,17 @@ public class PacketManager extends BasePacket {
|
|||||||
final int entityId,
|
final int entityId,
|
||||||
final @NotNull List<Player> sendTo
|
final @NotNull List<Player> sendTo
|
||||||
) {
|
) {
|
||||||
WrapperPlayServerNamedEntitySpawn wrapper = new WrapperPlayServerNamedEntitySpawn();
|
if (HMCCosmeticsAPI.getNMSVersion().contains("v1_18_R2") || HMCCosmeticsAPI.getNMSVersion().contains("v1_19_R1") || HMCCosmeticsAPI.getNMSVersion().contains("v1_19_R2") || HMCCosmeticsAPI.getNMSVersion().contains("v1_19_R3") || HMCCosmeticsAPI.getNMSVersion().contains("v1_20_R1")) {
|
||||||
wrapper.setEntityID(entityId);
|
WrapperPlayServerNamedEntitySpawn wrapper = new WrapperPlayServerNamedEntitySpawn();
|
||||||
wrapper.setPlayerUUID(uuid);
|
wrapper.setEntityID(entityId);
|
||||||
wrapper.setPosition(location.toVector());
|
wrapper.setPlayerUUID(uuid);
|
||||||
wrapper.setPitch(location.getPitch());
|
wrapper.setPosition(location.toVector());
|
||||||
wrapper.setYaw(location.getYaw());
|
wrapper.setPitch(location.getPitch());
|
||||||
for (final Player p : sendTo) sendPacket(p, wrapper.getHandle());
|
wrapper.setYaw(location.getYaw());
|
||||||
|
for (final Player p : sendTo) sendPacket(p, wrapper.getHandle());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
sendEntitySpawnPacket(location, entityId, EntityType.PLAYER, uuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -362,10 +301,10 @@ public class PacketManager extends BasePacket {
|
|||||||
}
|
}
|
||||||
|
|
||||||
WrappedGameProfile wrappedGameProfile = new WrappedGameProfile(uuid, name);
|
WrappedGameProfile wrappedGameProfile = new WrappedGameProfile(uuid, name);
|
||||||
WrappedSignedProperty skinData = PlayerUtils.getSkin(skinnedPlayer);
|
WrappedSignedProperty skinData = HMCCPlayerUtils.getSkin(skinnedPlayer);
|
||||||
if (skinData != null) wrappedGameProfile.getProperties().put("textures", skinData);
|
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
|
// 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")) {
|
if (HMCCosmeticsAPI.getNMSVersion().contains("v1_18_R2") || HMCCosmeticsAPI.getNMSVersion().contains("v1_19_R1")) {
|
||||||
info.getHandle().getPlayerInfoDataLists().write(0, Collections.singletonList(new PlayerInfoData(
|
info.getHandle().getPlayerInfoDataLists().write(0, Collections.singletonList(new PlayerInfoData(
|
||||||
wrappedGameProfile,
|
wrappedGameProfile,
|
||||||
0,
|
0,
|
||||||
@@ -409,7 +348,7 @@ public class PacketManager extends BasePacket {
|
|||||||
packet.getIntegers().write(0, playerId);
|
packet.getIntegers().write(0, playerId);
|
||||||
WrappedDataWatcher wrapper = new WrappedDataWatcher();
|
WrappedDataWatcher wrapper = new WrappedDataWatcher();
|
||||||
|
|
||||||
if (NMSHandlers.getVersion().contains("v1_18_R2") || NMSHandlers.getVersion().contains("v1_19_R1")) {
|
if (HMCCosmeticsAPI.getNMSVersion().contains("v1_18_R2") || HMCCosmeticsAPI.getNMSVersion().contains("v1_19_R1")) {
|
||||||
wrapper.setObject(new WrappedDataWatcher.WrappedDataWatcherObject(17, WrappedDataWatcher.Registry.get(Byte.class)), mask);
|
wrapper.setObject(new WrappedDataWatcher.WrappedDataWatcherObject(17, WrappedDataWatcher.Registry.get(Byte.class)), mask);
|
||||||
packet.getWatchableCollectionModifier().write(0, wrapper.getWatchableObjects());
|
packet.getWatchableCollectionModifier().write(0, wrapper.getWatchableObjects());
|
||||||
} else {
|
} else {
|
||||||
@@ -435,7 +374,7 @@ public class PacketManager extends BasePacket {
|
|||||||
final UUID uuid,
|
final UUID uuid,
|
||||||
final List<Player> sendTo
|
final List<Player> sendTo
|
||||||
) {
|
) {
|
||||||
if (NMSHandlers.getVersion().contains("v1_18_R2") || NMSHandlers.getVersion().contains("v1_19_R1")) {
|
if (HMCCosmeticsAPI.getNMSVersion().contains("v1_18_R2") || HMCCosmeticsAPI.getNMSVersion().contains("v1_19_R1")) {
|
||||||
WrapperPlayServerPlayerInfo info = new WrapperPlayServerPlayerInfo();
|
WrapperPlayServerPlayerInfo info = new WrapperPlayServerPlayerInfo();
|
||||||
// Remove player is deprecated on 1.19.3+, but we still need to support 1.18.2
|
// Remove player is deprecated on 1.19.3+, but we still need to support 1.18.2
|
||||||
info.setAction(EnumWrappers.PlayerInfoAction.REMOVE_PLAYER);
|
info.setAction(EnumWrappers.PlayerInfoAction.REMOVE_PLAYER);
|
||||||
@@ -463,51 +402,6 @@ public class PacketManager extends BasePacket {
|
|||||||
sendLeashPacket(leashedEntity, entityId, getViewers(location));
|
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
|
* Sends a movement packet from one location to another
|
||||||
* @param entityId Entity this will affect
|
* @param entityId Entity this will affect
|
||||||
@@ -541,8 +435,13 @@ public class PacketManager extends BasePacket {
|
|||||||
if (Settings.getViewDistance() <= 0) {
|
if (Settings.getViewDistance() <= 0) {
|
||||||
viewers.addAll(location.getWorld().getPlayers());
|
viewers.addAll(location.getWorld().getPlayers());
|
||||||
} else {
|
} else {
|
||||||
viewers.addAll(PlayerUtils.getNearbyPlayers(location));
|
viewers.addAll(HMCCPlayerUtils.getNearbyPlayers(location));
|
||||||
}
|
}
|
||||||
return viewers;
|
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.events.PacketContainer;
|
||||||
import com.comphenix.protocol.wrappers.EnumWrappers.PlayerInfoAction;
|
import com.comphenix.protocol.wrappers.EnumWrappers.PlayerInfoAction;
|
||||||
import com.comphenix.protocol.wrappers.PlayerInfoData;
|
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.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
@@ -26,7 +26,7 @@ public class WrapperPlayServerPlayerInfo extends AbstractPacket {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setAction(PlayerInfoAction value) {
|
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);
|
handle.getPlayerInfoAction().write(0, value);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,11 +24,35 @@ cosmetic-settings:
|
|||||||
force-permission-join: true # Checks a player permission if they can have a cosmetic when they join the server.
|
force-permission-join: true # Checks a player permission if they can have a cosmetic when they join the server.
|
||||||
force-show-join: false # If the plugin should force show a player's cosmetics when they join the server.
|
force-show-join: false # If the plugin should force show a player's cosmetics when they join the server.
|
||||||
|
|
||||||
|
# This 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-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-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
|
emote-air-check: true # Check if there is air under a player, if there is, don't play emote
|
||||||
emote-damage-leave: true # If the player should leave the emote when they take damage
|
emote-damage-leave: true # If the player should leave the emote when they take damage
|
||||||
emote-invincible: false # If the player should not take damage while doing an emote
|
emote-invincible: false # If the player should not take damage while doing an emote
|
||||||
|
# If a player should be put into camera mode when looking at an emote. Highly recommend keeping it as true.
|
||||||
|
emote-camera: true
|
||||||
|
# If a player should be able to move in an emote. This option really only affects if "emote-camera" is false
|
||||||
|
emote-move: false
|
||||||
|
# This make it so it always sends the riding packets for the backpack. This sends more packets but is more reliable for servers which modify player passengers.
|
||||||
|
backpack-force-riding-packet: false
|
||||||
|
# This 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.
|
||||||
|
# There is a small visual blip for a tick when you put a new item in the offhand slot, hence why its disabled by default.
|
||||||
|
offhand-always-show: false
|
||||||
|
|
||||||
helmet-add-enchantments: false # If the plugin should keep enchants on helmets. This is useful as some enchantments are client side only.
|
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.
|
chest-add-enchantments: false # If the plugin should keep enchants on chestplate. This is useful as some enchantments are client side only.
|
||||||
@@ -49,6 +73,20 @@ cosmetic-settings:
|
|||||||
y: 3
|
y: 3
|
||||||
z: 0.5
|
z: 0.5
|
||||||
menu-settings:
|
menu-settings:
|
||||||
|
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.
|
||||||
|
# Only Oraxen is support by default. Vanilla can't properly handle it without a lot of unicodes and ItemsAdder adds weird offsets and decolors it. (This is why it is disabled by default)
|
||||||
|
enabled: false # Default of menus having shading. This can be toggled individually in menus with "shading: true/false"
|
||||||
|
first-row-shift: "<s:-169>" # Oraxen: "<s:-169>"
|
||||||
|
sequent-row-shift: " <s:-169>" # Oraxen: " <s:-169>" (Space is important here!)
|
||||||
|
individual-column-shift: "<s:-3>" # Oraxen: "<s:-3>"
|
||||||
|
background: "<g:shade_row_<row>:colorable> " # Oraxen: "<g:shade_row_<row>:colorable>
|
||||||
|
clear-background: "<g:clear_row_<row>:colorable> " # Oraxen: "<g:clear_row_<row>:colorable> "
|
||||||
|
#These use MiniMessage for color! https://docs.advntr.dev/minimessage/format.html#color
|
||||||
|
equipped-cosmetic-color: "<yellow>"
|
||||||
|
equipable-cosmetic-color: "<green>"
|
||||||
|
locked-cosmetic-color: "<red>"
|
||||||
cosmetic-type:
|
cosmetic-type:
|
||||||
# This allows you to specify if it should require a special click type for the interaction to work.
|
# This allows you to specify if it should require a special click type for the interaction to work.
|
||||||
equip-click: "ANY" # ANY or ClickType, https://jd.papermc.io/paper/1.20/org/bukkit/event/inventory/ClickType.html
|
equip-click: "ANY" # ANY or ClickType, https://jd.papermc.io/paper/1.20/org/bukkit/event/inventory/ClickType.html
|
||||||
@@ -69,8 +107,6 @@ hook-settings:
|
|||||||
# Requires restart to apply changes.
|
# Requires restart to apply changes.
|
||||||
player-move-check: true
|
player-move-check: true
|
||||||
wardrobe:
|
wardrobe:
|
||||||
# spawn static wardrobe if in this radius of wardrobe-location
|
|
||||||
static-radius: 10
|
|
||||||
# how much yaw should change per tick, set to 0 for none
|
# how much yaw should change per tick, set to 0 for none
|
||||||
rotation-speed: 3
|
rotation-speed: 3
|
||||||
# Applies a pumpkin for an overlay of the player while in the wardrobe.
|
# Applies a pumpkin for an overlay of the player while in the wardrobe.
|
||||||
@@ -105,6 +141,8 @@ wardrobe:
|
|||||||
title-fade-out: 1000 # milliseconds
|
title-fade-out: 1000 # milliseconds
|
||||||
wardrobes:
|
wardrobes:
|
||||||
default:
|
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.
|
||||||
npc-location:
|
npc-location:
|
||||||
world: "world"
|
world: "world"
|
||||||
x: 0
|
x: 0
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ jetpack:
|
|||||||
amount: 1
|
amount: 1
|
||||||
firstperson-item:
|
firstperson-item:
|
||||||
material: PAPER
|
material: PAPER
|
||||||
model-data: 14
|
model-data: 15
|
||||||
name: "<white>Jetpack"
|
name: "<white>Jetpack"
|
||||||
amount: 1
|
amount: 1
|
||||||
hammer:
|
hammer:
|
||||||
@@ -155,6 +155,6 @@ hibiscus_flower:
|
|||||||
permission: "hmccosmetics.hibiscus_flower"
|
permission: "hmccosmetics.hibiscus_flower"
|
||||||
item:
|
item:
|
||||||
material: PAPER
|
material: PAPER
|
||||||
model-data: 15
|
model-data: 16
|
||||||
name: "<#d24c9f>Hibiscus Flower"
|
name: "<#d24c9f>Hibiscus Flower"
|
||||||
amount: 1
|
amount: 1
|
||||||
|
|||||||
@@ -1,3 +1,6 @@
|
|||||||
|
user-cosmetic:
|
||||||
|
offline: "Offline"
|
||||||
|
invalid-user: "Invalid User"
|
||||||
unlocked-cosmetic:
|
unlocked-cosmetic:
|
||||||
true: "true"
|
true: "true"
|
||||||
false: "false"
|
false: "false"
|
||||||
@@ -11,5 +14,8 @@ using-cosmetic:
|
|||||||
true: "true"
|
true: "true"
|
||||||
false: "false"
|
false: "false"
|
||||||
current-cosmetic:
|
current-cosmetic:
|
||||||
true: "true"
|
no-cosmetic: "No Cosmetic"
|
||||||
false: "false"
|
none: "none"
|
||||||
|
amount-cosmetic:
|
||||||
|
1: "1"
|
||||||
|
10: "10"
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
BIN
lib/HMCColor-0.8.5-all.jar
Normal file
BIN
lib/HMCColor-0.8.5-all.jar
Normal file
Binary file not shown.
@@ -7,10 +7,5 @@ pluginManagement {
|
|||||||
|
|
||||||
rootProject.name = "HMCCosmetics"
|
rootProject.name = "HMCCosmetics"
|
||||||
include(
|
include(
|
||||||
"common",
|
"common"
|
||||||
"v1_18_R2",
|
|
||||||
"v1_19_R1",
|
|
||||||
"v1_19_R2",
|
|
||||||
"v1_19_R3",
|
|
||||||
"v1_20_R1",
|
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,27 +0,0 @@
|
|||||||
plugins {
|
|
||||||
id("java")
|
|
||||||
id("io.papermc.paperweight.userdev") version "1.5.1"
|
|
||||||
}
|
|
||||||
|
|
||||||
dependencies {
|
|
||||||
paperDevBundle("1.18.2-R0.1-SNAPSHOT")
|
|
||||||
implementation(project(":common"))
|
|
||||||
}
|
|
||||||
|
|
||||||
tasks {
|
|
||||||
|
|
||||||
build {
|
|
||||||
dependsOn(reobfJar)
|
|
||||||
}
|
|
||||||
|
|
||||||
compileJava {
|
|
||||||
options.encoding = Charsets.UTF_8.name()
|
|
||||||
options.release.set(17)
|
|
||||||
}
|
|
||||||
javadoc {
|
|
||||||
options.encoding = Charsets.UTF_8.name()
|
|
||||||
}
|
|
||||||
processResources {
|
|
||||||
filteringCharset = Charsets.UTF_8.name()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,24 +0,0 @@
|
|||||||
package com.hibiscusmc.hmccosmetics.nms.v1_18_R2;
|
|
||||||
|
|
||||||
import net.minecraft.world.entity.decoration.ArmorStand;
|
|
||||||
import net.minecraft.world.level.Level;
|
|
||||||
import org.bukkit.Location;
|
|
||||||
import org.bukkit.craftbukkit.v1_18_R2.CraftWorld;
|
|
||||||
|
|
||||||
public class HMCArmorStand extends ArmorStand {
|
|
||||||
|
|
||||||
public HMCArmorStand(Level world, double x, double y, double z) {
|
|
||||||
super(world, x, y, z);
|
|
||||||
}
|
|
||||||
|
|
||||||
public HMCArmorStand(Location loc) {
|
|
||||||
super(((CraftWorld) loc.getWorld()).getHandle(), loc.getX(), loc.getY(), loc.getZ());
|
|
||||||
this.setPos(loc.getX(), loc.getY(), loc.getZ());
|
|
||||||
setInvisible(true);
|
|
||||||
setInvulnerable(true);
|
|
||||||
setMarker(true);
|
|
||||||
setSilent(true);
|
|
||||||
getBukkitLivingEntity().setCollidable(false);
|
|
||||||
persist = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,31 +0,0 @@
|
|||||||
package com.hibiscusmc.hmccosmetics.nms.v1_18_R2;
|
|
||||||
|
|
||||||
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
|
|
||||||
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
|
||||||
import net.minecraft.world.entity.EntityType;
|
|
||||||
import net.minecraft.world.entity.decoration.ArmorStand;
|
|
||||||
import org.bukkit.Location;
|
|
||||||
import org.bukkit.NamespacedKey;
|
|
||||||
import org.bukkit.craftbukkit.v1_18_R2.CraftWorld;
|
|
||||||
import org.bukkit.persistence.PersistentDataType;
|
|
||||||
|
|
||||||
public class MEGEntity extends ArmorStand {
|
|
||||||
|
|
||||||
public MEGEntity(Location loc) {
|
|
||||||
super(EntityType.ARMOR_STAND, ((CraftWorld) loc.getWorld()).getHandle());
|
|
||||||
this.setPos(loc.getX(), loc.getY(), loc.getZ());
|
|
||||||
|
|
||||||
MessagesUtil.sendDebugMessages("Spawned MEGEntity at " + loc);
|
|
||||||
setInvisible(true);
|
|
||||||
setNoGravity(true);
|
|
||||||
setSilent(true);
|
|
||||||
setInvulnerable(true);
|
|
||||||
setSmall(true);
|
|
||||||
setMarker(true);
|
|
||||||
|
|
||||||
persist = false;
|
|
||||||
getBukkitEntity().getPersistentDataContainer().set(new NamespacedKey(HMCCosmeticsPlugin.getInstance(), "cosmeticMob"), PersistentDataType.SHORT, Short.valueOf("1"));
|
|
||||||
|
|
||||||
((CraftWorld) loc.getWorld()).getHandle().addFreshEntity(this);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,235 +0,0 @@
|
|||||||
package com.hibiscusmc.hmccosmetics.nms.v1_18_R2;
|
|
||||||
|
|
||||||
import com.hibiscusmc.hmccosmetics.config.Settings;
|
|
||||||
import com.hibiscusmc.hmccosmetics.cosmetic.CosmeticSlot;
|
|
||||||
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticArmorType;
|
|
||||||
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticBackpackType;
|
|
||||||
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticBalloonType;
|
|
||||||
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticMainhandType;
|
|
||||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
|
||||||
import com.hibiscusmc.hmccosmetics.user.manager.UserBalloonManager;
|
|
||||||
import com.hibiscusmc.hmccosmetics.util.InventoryUtils;
|
|
||||||
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
|
||||||
import com.mojang.datafixers.util.Pair;
|
|
||||||
import net.minecraft.network.protocol.Packet;
|
|
||||||
import net.minecraft.network.protocol.game.ClientboundContainerSetSlotPacket;
|
|
||||||
import net.minecraft.network.protocol.game.ClientboundSetEquipmentPacket;
|
|
||||||
import net.minecraft.network.protocol.game.ClientboundSetPlayerTeamPacket;
|
|
||||||
import net.minecraft.server.level.ServerLevel;
|
|
||||||
import net.minecraft.server.level.ServerPlayer;
|
|
||||||
import net.minecraft.server.network.ServerPlayerConnection;
|
|
||||||
import net.minecraft.world.entity.EquipmentSlot;
|
|
||||||
import net.minecraft.world.entity.player.Inventory;
|
|
||||||
import net.minecraft.world.scores.PlayerTeam;
|
|
||||||
import net.minecraft.world.scores.Team;
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.Location;
|
|
||||||
import org.bukkit.craftbukkit.v1_18_R2.CraftEquipmentSlot;
|
|
||||||
import org.bukkit.craftbukkit.v1_18_R2.CraftServer;
|
|
||||||
import org.bukkit.craftbukkit.v1_18_R2.CraftWorld;
|
|
||||||
import org.bukkit.craftbukkit.v1_18_R2.entity.CraftPlayer;
|
|
||||||
import org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack;
|
|
||||||
import org.bukkit.craftbukkit.v1_18_R2.scoreboard.CraftScoreboard;
|
|
||||||
import org.bukkit.entity.ArmorStand;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.event.entity.CreatureSpawnEvent;
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class NMSHandler implements com.hibiscusmc.hmccosmetics.nms.NMSHandler {
|
|
||||||
@Override
|
|
||||||
public int getNextEntityId() {
|
|
||||||
return net.minecraft.world.entity.Entity.nextEntityId();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public org.bukkit.entity.Entity getEntity(int entityId) {
|
|
||||||
net.minecraft.world.entity.Entity entity = getNMSEntity(entityId);
|
|
||||||
if (entity == null) return null;
|
|
||||||
return entity.getBukkitEntity();
|
|
||||||
}
|
|
||||||
|
|
||||||
private net.minecraft.world.entity.Entity getNMSEntity(int entityId) {
|
|
||||||
for (ServerLevel world : ((CraftServer) Bukkit.getServer()).getHandle().getServer().getAllLevels()) {
|
|
||||||
net.minecraft.world.entity.Entity entity = world.getEntity(entityId);
|
|
||||||
if (entity == null) return null;
|
|
||||||
return entity;
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public org.bukkit.entity.Entity getHMCArmorStand(Location loc) {
|
|
||||||
HMCArmorStand hmcArmorStand = new HMCArmorStand(loc);
|
|
||||||
return hmcArmorStand.getBukkitEntity();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ArmorStand getMEGEntity(Location loc) {
|
|
||||||
return (ArmorStand) new MEGEntity(loc).getBukkitEntity();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public org.bukkit.entity.Entity spawnBackpack(CosmeticUser user, CosmeticBackpackType cosmeticBackpackType) {
|
|
||||||
HMCArmorStand invisibleArmorstand = new HMCArmorStand(user.getEntity().getLocation());
|
|
||||||
|
|
||||||
ItemStack item = user.getUserCosmeticItem(cosmeticBackpackType);
|
|
||||||
|
|
||||||
invisibleArmorstand.setItemSlot(EquipmentSlot.HEAD, CraftItemStack.asNMSCopy(item));
|
|
||||||
((CraftWorld) user.getEntity().getWorld()).getHandle().addFreshEntity(invisibleArmorstand, CreatureSpawnEvent.SpawnReason.CUSTOM);
|
|
||||||
|
|
||||||
MessagesUtil.sendDebugMessages("spawnBackpack NMS");
|
|
||||||
|
|
||||||
return invisibleArmorstand.getBukkitLivingEntity();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public org.bukkit.entity.Entity spawnDisplayEntity(Location location, String text) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public UserBalloonManager spawnBalloon(CosmeticUser user, CosmeticBalloonType cosmeticBalloonType) {
|
|
||||||
org.bukkit.entity.Entity entity = user.getEntity();
|
|
||||||
|
|
||||||
UserBalloonManager userBalloonManager1 = new UserBalloonManager(entity.getLocation());
|
|
||||||
userBalloonManager1.getModelEntity().teleport(entity.getLocation().add(Settings.getBalloonOffset()));
|
|
||||||
|
|
||||||
userBalloonManager1.spawnModel(cosmeticBalloonType, user.getCosmeticColor(cosmeticBalloonType.getSlot()));
|
|
||||||
userBalloonManager1.addPlayerToModel(user, cosmeticBalloonType, user.getCosmeticColor(cosmeticBalloonType.getSlot()));
|
|
||||||
|
|
||||||
return userBalloonManager1;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void equipmentSlotUpdate(
|
|
||||||
int entityId,
|
|
||||||
CosmeticUser user,
|
|
||||||
CosmeticSlot cosmeticSlot,
|
|
||||||
List<Player> sendTo
|
|
||||||
) {
|
|
||||||
|
|
||||||
EquipmentSlot nmsSlot = null;
|
|
||||||
net.minecraft.world.item.ItemStack nmsItem = null;
|
|
||||||
|
|
||||||
if (!(user.getCosmetic(cosmeticSlot) instanceof CosmeticArmorType)) {
|
|
||||||
|
|
||||||
if (user.getCosmetic(cosmeticSlot) instanceof CosmeticMainhandType) {
|
|
||||||
CosmeticMainhandType cosmeticMainhandType = (CosmeticMainhandType) user.getCosmetic(CosmeticSlot.MAINHAND);
|
|
||||||
nmsItem = CraftItemStack.asNMSCopy(user.getUserCosmeticItem(cosmeticMainhandType));
|
|
||||||
} else {
|
|
||||||
nmsItem = CraftItemStack.asNMSCopy(user.getPlayer().getInventory().getItem(InventoryUtils.getEquipmentSlot(cosmeticSlot)));
|
|
||||||
}
|
|
||||||
|
|
||||||
nmsSlot = CraftEquipmentSlot.getNMS(InventoryUtils.getEquipmentSlot(cosmeticSlot));
|
|
||||||
|
|
||||||
if (nmsSlot == null) return;
|
|
||||||
|
|
||||||
Pair<EquipmentSlot, net.minecraft.world.item.ItemStack> pair = new Pair<>(nmsSlot, nmsItem);
|
|
||||||
|
|
||||||
List<Pair<EquipmentSlot, net.minecraft.world.item.ItemStack>> pairs = Collections.singletonList(pair);
|
|
||||||
|
|
||||||
ClientboundSetEquipmentPacket packet = new ClientboundSetEquipmentPacket(entityId, pairs);
|
|
||||||
for (Player p : sendTo) sendPacket(p, packet);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
CosmeticArmorType cosmeticArmor = (CosmeticArmorType) user.getCosmetic(cosmeticSlot);
|
|
||||||
|
|
||||||
// Converting EquipmentSlot and ItemStack to NMS ones.
|
|
||||||
nmsSlot = CraftEquipmentSlot.getNMS(cosmeticArmor.getEquipSlot());
|
|
||||||
nmsItem = CraftItemStack.asNMSCopy(user.getUserCosmeticItem(cosmeticArmor));
|
|
||||||
|
|
||||||
if (nmsSlot == null) return;
|
|
||||||
|
|
||||||
Pair<EquipmentSlot, net.minecraft.world.item.ItemStack> pair = new Pair<>(nmsSlot, nmsItem);
|
|
||||||
|
|
||||||
List<Pair<EquipmentSlot, net.minecraft.world.item.ItemStack>> pairs = Collections.singletonList(pair);
|
|
||||||
|
|
||||||
ClientboundSetEquipmentPacket packet = new ClientboundSetEquipmentPacket(entityId, pairs);
|
|
||||||
for (Player p : sendTo) sendPacket(p, packet);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void equipmentSlotUpdate(
|
|
||||||
int entityId,
|
|
||||||
org.bukkit.inventory.EquipmentSlot slot,
|
|
||||||
ItemStack item,
|
|
||||||
List<Player> sendTo
|
|
||||||
) {
|
|
||||||
|
|
||||||
EquipmentSlot nmsSlot = null;
|
|
||||||
net.minecraft.world.item.ItemStack nmsItem = null;
|
|
||||||
|
|
||||||
// Converting EquipmentSlot and ItemStack to NMS ones.
|
|
||||||
nmsSlot = CraftEquipmentSlot.getNMS(slot);
|
|
||||||
nmsItem = CraftItemStack.asNMSCopy(item);
|
|
||||||
|
|
||||||
if (nmsSlot == null) return;
|
|
||||||
|
|
||||||
Pair<EquipmentSlot, net.minecraft.world.item.ItemStack> pair = new Pair<>(nmsSlot, nmsItem);
|
|
||||||
|
|
||||||
List<Pair<EquipmentSlot, net.minecraft.world.item.ItemStack>> pairs = Collections.singletonList(pair);
|
|
||||||
|
|
||||||
ClientboundSetEquipmentPacket packet = new ClientboundSetEquipmentPacket(entityId, pairs);
|
|
||||||
for (Player p : sendTo) sendPacket(p, packet);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void slotUpdate(
|
|
||||||
Player player,
|
|
||||||
int slot
|
|
||||||
) {
|
|
||||||
int index = 0;
|
|
||||||
|
|
||||||
ServerPlayer player1 = ((CraftPlayer) player).getHandle();
|
|
||||||
|
|
||||||
if (index < Inventory.getSelectionSize()) {
|
|
||||||
index += 36;
|
|
||||||
} else if (index > 39) {
|
|
||||||
index += 5; // Off hand
|
|
||||||
} else if (index > 35) {
|
|
||||||
index = 8 - (index - 36);
|
|
||||||
}
|
|
||||||
ItemStack item = player.getInventory().getItem(slot);
|
|
||||||
|
|
||||||
Packet packet = new ClientboundContainerSetSlotPacket(player1.inventoryMenu.containerId, player1.inventoryMenu.incrementStateId(), index, CraftItemStack.asNMSCopy(item));
|
|
||||||
sendPacket(player, packet);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void hideNPCName(Player player, String NPCName) {
|
|
||||||
//Creating the team
|
|
||||||
PlayerTeam team = new PlayerTeam(((CraftScoreboard) Bukkit.getScoreboardManager().getMainScoreboard()).getHandle(), NPCName);
|
|
||||||
|
|
||||||
//Setting name visibility
|
|
||||||
team.setNameTagVisibility(Team.Visibility.NEVER);
|
|
||||||
|
|
||||||
//Remove the Team (i assume so if it exists)
|
|
||||||
ClientboundSetPlayerTeamPacket removeTeamPacket = ClientboundSetPlayerTeamPacket.createRemovePacket(team);
|
|
||||||
sendPacket(player, removeTeamPacket);
|
|
||||||
//Creating the Team
|
|
||||||
ClientboundSetPlayerTeamPacket createTeamPacket = ClientboundSetPlayerTeamPacket.createAddOrModifyPacket(team, true);
|
|
||||||
sendPacket(player, createTeamPacket);
|
|
||||||
//Adding players to the team (You have to use the NPC's name, and add it to a list)
|
|
||||||
ClientboundSetPlayerTeamPacket createPlayerTeamPacket = ClientboundSetPlayerTeamPacket.createMultiplePlayerPacket(team, new ArrayList<String>() {{
|
|
||||||
add(NPCName);
|
|
||||||
}}, ClientboundSetPlayerTeamPacket.Action.ADD);
|
|
||||||
sendPacket(player, createPlayerTeamPacket);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void sendPacket(Player player, Packet packet) {
|
|
||||||
ServerPlayer serverPlayer = ((CraftPlayer) player).getHandle();
|
|
||||||
ServerPlayerConnection connection = serverPlayer.connection;
|
|
||||||
connection.send(packet);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean getSupported() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,27 +0,0 @@
|
|||||||
plugins {
|
|
||||||
id("java")
|
|
||||||
id("io.papermc.paperweight.userdev") version "1.5.1"
|
|
||||||
}
|
|
||||||
|
|
||||||
dependencies {
|
|
||||||
paperDevBundle("1.19.2-R0.1-SNAPSHOT")
|
|
||||||
implementation(project(":common"))
|
|
||||||
}
|
|
||||||
|
|
||||||
tasks {
|
|
||||||
|
|
||||||
build {
|
|
||||||
dependsOn(reobfJar)
|
|
||||||
}
|
|
||||||
|
|
||||||
compileJava {
|
|
||||||
options.encoding = Charsets.UTF_8.name()
|
|
||||||
options.release.set(17)
|
|
||||||
}
|
|
||||||
javadoc {
|
|
||||||
options.encoding = Charsets.UTF_8.name()
|
|
||||||
}
|
|
||||||
processResources {
|
|
||||||
filteringCharset = Charsets.UTF_8.name()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,24 +0,0 @@
|
|||||||
package com.hibiscusmc.hmccosmetics.nms.v1_19_R1;
|
|
||||||
|
|
||||||
import net.minecraft.world.entity.decoration.ArmorStand;
|
|
||||||
import net.minecraft.world.level.Level;
|
|
||||||
import org.bukkit.Location;
|
|
||||||
import org.bukkit.craftbukkit.v1_19_R1.CraftWorld;
|
|
||||||
|
|
||||||
public class HMCArmorStand extends ArmorStand {
|
|
||||||
|
|
||||||
public HMCArmorStand(Level world, double x, double y, double z) {
|
|
||||||
super(world, x, y, z);
|
|
||||||
}
|
|
||||||
|
|
||||||
public HMCArmorStand(Location loc) {
|
|
||||||
super(((CraftWorld) loc.getWorld()).getHandle(), loc.getX(), loc.getY(), loc.getZ());
|
|
||||||
this.setPos(loc.getX(), loc.getY(), loc.getZ());
|
|
||||||
setInvisible(true);
|
|
||||||
setInvulnerable(true);
|
|
||||||
setMarker(true);
|
|
||||||
setSilent(true);
|
|
||||||
getBukkitLivingEntity().setCollidable(false);
|
|
||||||
persist = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,31 +0,0 @@
|
|||||||
package com.hibiscusmc.hmccosmetics.nms.v1_19_R1;
|
|
||||||
|
|
||||||
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
|
|
||||||
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
|
||||||
import net.minecraft.world.entity.EntityType;
|
|
||||||
import net.minecraft.world.entity.decoration.ArmorStand;
|
|
||||||
import org.bukkit.Location;
|
|
||||||
import org.bukkit.NamespacedKey;
|
|
||||||
import org.bukkit.craftbukkit.v1_19_R1.CraftWorld;
|
|
||||||
import org.bukkit.persistence.PersistentDataType;
|
|
||||||
|
|
||||||
public class MEGEntity extends ArmorStand {
|
|
||||||
|
|
||||||
public MEGEntity(Location loc) {
|
|
||||||
super(EntityType.ARMOR_STAND, ((CraftWorld) loc.getWorld()).getHandle());
|
|
||||||
this.setPos(loc.getX(), loc.getY(), loc.getZ());
|
|
||||||
|
|
||||||
MessagesUtil.sendDebugMessages("Spawned MEGEntity at " + loc);
|
|
||||||
setInvisible(true);
|
|
||||||
setNoGravity(true);
|
|
||||||
setSilent(true);
|
|
||||||
setInvulnerable(true);
|
|
||||||
setSmall(true);
|
|
||||||
setMarker(true);
|
|
||||||
|
|
||||||
persist = false;
|
|
||||||
getBukkitEntity().getPersistentDataContainer().set(new NamespacedKey(HMCCosmeticsPlugin.getInstance(), "cosmeticMob"), PersistentDataType.SHORT, Short.valueOf("1"));
|
|
||||||
|
|
||||||
((CraftWorld) loc.getWorld()).getHandle().addFreshEntity(this);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,237 +0,0 @@
|
|||||||
package com.hibiscusmc.hmccosmetics.nms.v1_19_R1;
|
|
||||||
|
|
||||||
import com.hibiscusmc.hmccosmetics.config.Settings;
|
|
||||||
import com.hibiscusmc.hmccosmetics.cosmetic.CosmeticSlot;
|
|
||||||
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticArmorType;
|
|
||||||
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticBackpackType;
|
|
||||||
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticBalloonType;
|
|
||||||
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticMainhandType;
|
|
||||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
|
||||||
import com.hibiscusmc.hmccosmetics.user.manager.UserBalloonManager;
|
|
||||||
import com.hibiscusmc.hmccosmetics.util.InventoryUtils;
|
|
||||||
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
|
||||||
import com.mojang.datafixers.util.Pair;
|
|
||||||
import net.minecraft.network.protocol.Packet;
|
|
||||||
import net.minecraft.network.protocol.game.ClientboundContainerSetSlotPacket;
|
|
||||||
import net.minecraft.network.protocol.game.ClientboundSetEquipmentPacket;
|
|
||||||
import net.minecraft.network.protocol.game.ClientboundSetPlayerTeamPacket;
|
|
||||||
import net.minecraft.server.level.ServerLevel;
|
|
||||||
import net.minecraft.server.level.ServerPlayer;
|
|
||||||
import net.minecraft.server.network.ServerPlayerConnection;
|
|
||||||
import net.minecraft.world.entity.EquipmentSlot;
|
|
||||||
import net.minecraft.world.entity.player.Inventory;
|
|
||||||
import net.minecraft.world.scores.PlayerTeam;
|
|
||||||
import net.minecraft.world.scores.Team;
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.Location;
|
|
||||||
import org.bukkit.craftbukkit.v1_19_R1.CraftEquipmentSlot;
|
|
||||||
import org.bukkit.craftbukkit.v1_19_R1.CraftServer;
|
|
||||||
import org.bukkit.craftbukkit.v1_19_R1.CraftWorld;
|
|
||||||
import org.bukkit.craftbukkit.v1_19_R1.entity.CraftPlayer;
|
|
||||||
import org.bukkit.craftbukkit.v1_19_R1.inventory.CraftItemStack;
|
|
||||||
import org.bukkit.craftbukkit.v1_19_R1.scoreboard.CraftScoreboard;
|
|
||||||
import org.bukkit.entity.ArmorStand;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.event.entity.CreatureSpawnEvent;
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class NMSHandler implements com.hibiscusmc.hmccosmetics.nms.NMSHandler {
|
|
||||||
@Override
|
|
||||||
public int getNextEntityId() {
|
|
||||||
return net.minecraft.world.entity.Entity.nextEntityId();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public org.bukkit.entity.Entity getEntity(int entityId) {
|
|
||||||
net.minecraft.world.entity.Entity entity = getNMSEntity(entityId);
|
|
||||||
if (entity == null) return null;
|
|
||||||
return entity.getBukkitEntity();
|
|
||||||
}
|
|
||||||
|
|
||||||
private net.minecraft.world.entity.Entity getNMSEntity(int entityId) {
|
|
||||||
for (ServerLevel world : ((CraftServer) Bukkit.getServer()).getHandle().getServer().getAllLevels()) {
|
|
||||||
net.minecraft.world.entity.Entity entity = world.getEntity(entityId);
|
|
||||||
if (entity == null) return null;
|
|
||||||
return entity;
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public org.bukkit.entity.Entity getHMCArmorStand(Location loc) {
|
|
||||||
HMCArmorStand hmcArmorStand = new HMCArmorStand(loc);
|
|
||||||
return hmcArmorStand.getBukkitEntity();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ArmorStand getMEGEntity(Location loc) {
|
|
||||||
return (ArmorStand) new MEGEntity(loc).getBukkitEntity();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public org.bukkit.entity.Entity spawnBackpack(CosmeticUser user, CosmeticBackpackType cosmeticBackpackType) {
|
|
||||||
HMCArmorStand invisibleArmorstand = new HMCArmorStand(user.getEntity().getLocation());
|
|
||||||
|
|
||||||
ItemStack item = user.getUserCosmeticItem(cosmeticBackpackType);
|
|
||||||
|
|
||||||
invisibleArmorstand.setItemSlot(EquipmentSlot.HEAD, CraftItemStack.asNMSCopy(item));
|
|
||||||
((CraftWorld) user.getEntity().getWorld()).getHandle().addFreshEntity(invisibleArmorstand, CreatureSpawnEvent.SpawnReason.CUSTOM);
|
|
||||||
|
|
||||||
MessagesUtil.sendDebugMessages("spawnBackpack NMS");
|
|
||||||
|
|
||||||
return invisibleArmorstand.getBukkitLivingEntity();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public org.bukkit.entity.Entity spawnDisplayEntity(Location location, String text) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public UserBalloonManager spawnBalloon(CosmeticUser user, CosmeticBalloonType cosmeticBalloonType) {
|
|
||||||
org.bukkit.entity.Entity entity = user.getEntity();
|
|
||||||
|
|
||||||
UserBalloonManager userBalloonManager1 = new UserBalloonManager(entity.getLocation());
|
|
||||||
userBalloonManager1.getModelEntity().teleport(entity.getLocation().add(Settings.getBalloonOffset()));
|
|
||||||
|
|
||||||
userBalloonManager1.spawnModel(cosmeticBalloonType, user.getCosmeticColor(cosmeticBalloonType.getSlot()));
|
|
||||||
userBalloonManager1.addPlayerToModel(user, cosmeticBalloonType, user.getCosmeticColor(cosmeticBalloonType.getSlot()));
|
|
||||||
|
|
||||||
return userBalloonManager1;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void equipmentSlotUpdate(
|
|
||||||
int entityId,
|
|
||||||
CosmeticUser user,
|
|
||||||
CosmeticSlot cosmeticSlot,
|
|
||||||
List<Player> sendTo
|
|
||||||
) {
|
|
||||||
|
|
||||||
EquipmentSlot nmsSlot = null;
|
|
||||||
net.minecraft.world.item.ItemStack nmsItem = null;
|
|
||||||
|
|
||||||
if (!(user.getCosmetic(cosmeticSlot) instanceof CosmeticArmorType)) {
|
|
||||||
|
|
||||||
if (user.getCosmetic(cosmeticSlot) instanceof CosmeticMainhandType) {
|
|
||||||
CosmeticMainhandType cosmeticMainhandType = (CosmeticMainhandType) user.getCosmetic(CosmeticSlot.MAINHAND);
|
|
||||||
nmsItem = CraftItemStack.asNMSCopy(user.getUserCosmeticItem(cosmeticMainhandType));
|
|
||||||
} else {
|
|
||||||
nmsItem = CraftItemStack.asNMSCopy(user.getPlayer().getInventory().getItem(InventoryUtils.getEquipmentSlot(cosmeticSlot)));
|
|
||||||
}
|
|
||||||
|
|
||||||
nmsSlot = CraftEquipmentSlot.getNMS(InventoryUtils.getEquipmentSlot(cosmeticSlot));
|
|
||||||
|
|
||||||
if (nmsSlot == null) return;
|
|
||||||
|
|
||||||
Pair<EquipmentSlot, net.minecraft.world.item.ItemStack> pair = new Pair<>(nmsSlot, nmsItem);
|
|
||||||
|
|
||||||
List<Pair<EquipmentSlot, net.minecraft.world.item.ItemStack>> pairs = Collections.singletonList(pair);
|
|
||||||
|
|
||||||
ClientboundSetEquipmentPacket packet = new ClientboundSetEquipmentPacket(entityId, pairs);
|
|
||||||
for (Player p : sendTo) sendPacket(p, packet);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
CosmeticArmorType cosmeticArmor = (CosmeticArmorType) user.getCosmetic(cosmeticSlot);
|
|
||||||
|
|
||||||
// Converting EquipmentSlot and ItemStack to NMS ones.
|
|
||||||
nmsSlot = CraftEquipmentSlot.getNMS(cosmeticArmor.getEquipSlot());
|
|
||||||
nmsItem = CraftItemStack.asNMSCopy(user.getUserCosmeticItem(cosmeticArmor));
|
|
||||||
|
|
||||||
if (nmsSlot == null) return;
|
|
||||||
|
|
||||||
Pair<EquipmentSlot, net.minecraft.world.item.ItemStack> pair = new Pair<>(nmsSlot, nmsItem);
|
|
||||||
|
|
||||||
List<Pair<EquipmentSlot, net.minecraft.world.item.ItemStack>> pairs = Collections.singletonList(pair);
|
|
||||||
|
|
||||||
ClientboundSetEquipmentPacket packet = new ClientboundSetEquipmentPacket(entityId, pairs);
|
|
||||||
for (Player p : sendTo) sendPacket(p, packet);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void equipmentSlotUpdate(
|
|
||||||
int entityId,
|
|
||||||
org.bukkit.inventory.EquipmentSlot slot,
|
|
||||||
ItemStack item,
|
|
||||||
List<Player> sendTo
|
|
||||||
) {
|
|
||||||
|
|
||||||
EquipmentSlot nmsSlot = null;
|
|
||||||
net.minecraft.world.item.ItemStack nmsItem = null;
|
|
||||||
|
|
||||||
// Converting EquipmentSlot and ItemStack to NMS ones.
|
|
||||||
nmsSlot = CraftEquipmentSlot.getNMS(slot);
|
|
||||||
nmsItem = CraftItemStack.asNMSCopy(item);
|
|
||||||
|
|
||||||
if (nmsSlot == null) return;
|
|
||||||
|
|
||||||
Pair<EquipmentSlot, net.minecraft.world.item.ItemStack> pair = new Pair<>(nmsSlot, nmsItem);
|
|
||||||
|
|
||||||
List<Pair<EquipmentSlot, net.minecraft.world.item.ItemStack>> pairs = Collections.singletonList(pair);
|
|
||||||
|
|
||||||
ClientboundSetEquipmentPacket packet = new ClientboundSetEquipmentPacket(entityId, pairs);
|
|
||||||
for (Player p : sendTo) sendPacket(p, packet);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void slotUpdate(
|
|
||||||
Player player,
|
|
||||||
int slot
|
|
||||||
) {
|
|
||||||
int index = 0;
|
|
||||||
|
|
||||||
ServerPlayer player1 = ((CraftPlayer) player).getHandle();
|
|
||||||
|
|
||||||
if (index < Inventory.getSelectionSize()) {
|
|
||||||
index += 36;
|
|
||||||
} else if (index > 39) {
|
|
||||||
index += 5; // Off hand
|
|
||||||
} else if (index > 35) {
|
|
||||||
index = 8 - (index - 36);
|
|
||||||
}
|
|
||||||
ItemStack item = player.getInventory().getItem(slot);
|
|
||||||
|
|
||||||
Packet packet = new ClientboundContainerSetSlotPacket(player1.inventoryMenu.containerId, player1.inventoryMenu.incrementStateId(), index, CraftItemStack.asNMSCopy(item));
|
|
||||||
sendPacket(player, packet);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void hideNPCName(Player player, String NPCName) {
|
|
||||||
//Creating the team
|
|
||||||
PlayerTeam team = new PlayerTeam(((CraftScoreboard) Bukkit.getScoreboardManager().getMainScoreboard()).getHandle(), NPCName);
|
|
||||||
|
|
||||||
//Setting name visibility
|
|
||||||
team.setNameTagVisibility(Team.Visibility.NEVER);
|
|
||||||
|
|
||||||
//Remove the Team (i assume so if it exists)
|
|
||||||
ClientboundSetPlayerTeamPacket removeTeamPacket = ClientboundSetPlayerTeamPacket.createRemovePacket(team);
|
|
||||||
sendPacket(player, removeTeamPacket);
|
|
||||||
//Creating the Team
|
|
||||||
ClientboundSetPlayerTeamPacket createTeamPacket = ClientboundSetPlayerTeamPacket.createAddOrModifyPacket(team, true);
|
|
||||||
sendPacket(player, createTeamPacket);
|
|
||||||
//Adding players to the team (You have to use the NPC's name, and add it to a list)
|
|
||||||
ClientboundSetPlayerTeamPacket createPlayerTeamPacket = ClientboundSetPlayerTeamPacket.createMultiplePlayerPacket(team, new ArrayList<String>() {{
|
|
||||||
add(NPCName);
|
|
||||||
}}, ClientboundSetPlayerTeamPacket.Action.ADD);
|
|
||||||
sendPacket(player, createPlayerTeamPacket);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void sendPacket(Player player, Packet packet) {
|
|
||||||
ServerPlayer serverPlayer = ((CraftPlayer) player).getHandle();
|
|
||||||
ServerPlayerConnection connection = serverPlayer.connection;
|
|
||||||
connection.send(packet);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean getSupported() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,27 +0,0 @@
|
|||||||
plugins {
|
|
||||||
id("java")
|
|
||||||
id("io.papermc.paperweight.userdev") version "1.5.1"
|
|
||||||
}
|
|
||||||
|
|
||||||
dependencies {
|
|
||||||
paperDevBundle("1.19.3-R0.1-SNAPSHOT")
|
|
||||||
implementation(project(":common"))
|
|
||||||
}
|
|
||||||
|
|
||||||
tasks {
|
|
||||||
|
|
||||||
build {
|
|
||||||
dependsOn(reobfJar)
|
|
||||||
}
|
|
||||||
|
|
||||||
compileJava {
|
|
||||||
options.encoding = Charsets.UTF_8.name()
|
|
||||||
options.release.set(17)
|
|
||||||
}
|
|
||||||
javadoc {
|
|
||||||
options.encoding = Charsets.UTF_8.name()
|
|
||||||
}
|
|
||||||
processResources {
|
|
||||||
filteringCharset = Charsets.UTF_8.name()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,24 +0,0 @@
|
|||||||
package com.hibiscusmc.hmccosmetics.nms.v1_19_R2;
|
|
||||||
|
|
||||||
import net.minecraft.world.entity.decoration.ArmorStand;
|
|
||||||
import net.minecraft.world.level.Level;
|
|
||||||
import org.bukkit.Location;
|
|
||||||
import org.bukkit.craftbukkit.v1_19_R2.CraftWorld;
|
|
||||||
|
|
||||||
public class HMCArmorStand extends ArmorStand {
|
|
||||||
|
|
||||||
public HMCArmorStand(Level world, double x, double y, double z) {
|
|
||||||
super(world, x, y, z);
|
|
||||||
}
|
|
||||||
|
|
||||||
public HMCArmorStand(Location loc) {
|
|
||||||
super(((CraftWorld) loc.getWorld()).getHandle(), loc.getX(), loc.getY(), loc.getZ());
|
|
||||||
this.setPos(loc.getX(), loc.getY(), loc.getZ());
|
|
||||||
setInvisible(true);
|
|
||||||
setInvulnerable(true);
|
|
||||||
setMarker(true);
|
|
||||||
setSilent(true);
|
|
||||||
getBukkitLivingEntity().setCollidable(false);
|
|
||||||
persist = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,30 +0,0 @@
|
|||||||
package com.hibiscusmc.hmccosmetics.nms.v1_19_R2;
|
|
||||||
|
|
||||||
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
|
|
||||||
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
|
||||||
import net.minecraft.world.entity.EntityType;
|
|
||||||
import net.minecraft.world.entity.decoration.ArmorStand;
|
|
||||||
import org.bukkit.Location;
|
|
||||||
import org.bukkit.NamespacedKey;
|
|
||||||
import org.bukkit.craftbukkit.v1_19_R2.CraftWorld;
|
|
||||||
import org.bukkit.persistence.PersistentDataType;
|
|
||||||
|
|
||||||
public class MEGEntity extends ArmorStand {
|
|
||||||
public MEGEntity(Location loc) {
|
|
||||||
super(EntityType.ARMOR_STAND, ((CraftWorld) loc.getWorld()).getHandle());
|
|
||||||
this.setPos(loc.getX(), loc.getY(), loc.getZ());
|
|
||||||
|
|
||||||
MessagesUtil.sendDebugMessages("Spawned MEGEntity at " + loc);
|
|
||||||
setInvisible(true);
|
|
||||||
setNoGravity(true);
|
|
||||||
setSilent(true);
|
|
||||||
setInvulnerable(true);
|
|
||||||
setSmall(true);
|
|
||||||
setMarker(true);
|
|
||||||
|
|
||||||
persist = false;
|
|
||||||
getBukkitEntity().getPersistentDataContainer().set(new NamespacedKey(HMCCosmeticsPlugin.getInstance(), "cosmeticMob"), PersistentDataType.SHORT, Short.valueOf("1"));
|
|
||||||
|
|
||||||
((CraftWorld) loc.getWorld()).getHandle().addFreshEntity(this);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,236 +0,0 @@
|
|||||||
package com.hibiscusmc.hmccosmetics.nms.v1_19_R2;
|
|
||||||
|
|
||||||
import com.hibiscusmc.hmccosmetics.config.Settings;
|
|
||||||
import com.hibiscusmc.hmccosmetics.cosmetic.CosmeticSlot;
|
|
||||||
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticArmorType;
|
|
||||||
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticBackpackType;
|
|
||||||
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticBalloonType;
|
|
||||||
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticMainhandType;
|
|
||||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
|
||||||
import com.hibiscusmc.hmccosmetics.user.manager.UserBalloonManager;
|
|
||||||
import com.hibiscusmc.hmccosmetics.util.InventoryUtils;
|
|
||||||
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
|
||||||
import com.mojang.datafixers.util.Pair;
|
|
||||||
import net.minecraft.network.protocol.Packet;
|
|
||||||
import net.minecraft.network.protocol.game.ClientboundContainerSetSlotPacket;
|
|
||||||
import net.minecraft.network.protocol.game.ClientboundSetEquipmentPacket;
|
|
||||||
import net.minecraft.network.protocol.game.ClientboundSetPlayerTeamPacket;
|
|
||||||
import net.minecraft.server.level.ServerLevel;
|
|
||||||
import net.minecraft.server.level.ServerPlayer;
|
|
||||||
import net.minecraft.server.network.ServerPlayerConnection;
|
|
||||||
import net.minecraft.world.entity.EquipmentSlot;
|
|
||||||
import net.minecraft.world.entity.player.Inventory;
|
|
||||||
import net.minecraft.world.scores.PlayerTeam;
|
|
||||||
import net.minecraft.world.scores.Team;
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.Location;
|
|
||||||
import org.bukkit.craftbukkit.v1_19_R2.CraftEquipmentSlot;
|
|
||||||
import org.bukkit.craftbukkit.v1_19_R2.CraftServer;
|
|
||||||
import org.bukkit.craftbukkit.v1_19_R2.CraftWorld;
|
|
||||||
import org.bukkit.craftbukkit.v1_19_R2.entity.CraftPlayer;
|
|
||||||
import org.bukkit.craftbukkit.v1_19_R2.inventory.CraftItemStack;
|
|
||||||
import org.bukkit.craftbukkit.v1_19_R2.scoreboard.CraftScoreboard;
|
|
||||||
import org.bukkit.entity.ArmorStand;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.event.entity.CreatureSpawnEvent;
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class NMSHandler implements com.hibiscusmc.hmccosmetics.nms.NMSHandler {
|
|
||||||
@Override
|
|
||||||
public int getNextEntityId() {
|
|
||||||
return net.minecraft.world.entity.Entity.nextEntityId();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public org.bukkit.entity.Entity getEntity(int entityId) {
|
|
||||||
net.minecraft.world.entity.Entity entity = getNMSEntity(entityId);
|
|
||||||
if (entity == null) return null;
|
|
||||||
return entity.getBukkitEntity();
|
|
||||||
}
|
|
||||||
|
|
||||||
private net.minecraft.world.entity.Entity getNMSEntity(int entityId) {
|
|
||||||
for (ServerLevel world : ((CraftServer) Bukkit.getServer()).getHandle().getServer().getAllLevels()) {
|
|
||||||
net.minecraft.world.entity.Entity entity = world.getEntity(entityId);
|
|
||||||
if (entity == null) return null;
|
|
||||||
return entity;
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public org.bukkit.entity.Entity getHMCArmorStand(Location loc) {
|
|
||||||
HMCArmorStand hmcArmorStand = new HMCArmorStand(loc);
|
|
||||||
return hmcArmorStand.getBukkitEntity();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ArmorStand getMEGEntity(Location loc) {
|
|
||||||
return (ArmorStand) new MEGEntity(loc).getBukkitEntity();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public org.bukkit.entity.Entity spawnBackpack(CosmeticUser user, CosmeticBackpackType cosmeticBackpackType) {
|
|
||||||
HMCArmorStand invisibleArmorstand = new HMCArmorStand(user.getEntity().getLocation());
|
|
||||||
|
|
||||||
ItemStack item = user.getUserCosmeticItem(cosmeticBackpackType);
|
|
||||||
|
|
||||||
invisibleArmorstand.setItemSlot(EquipmentSlot.HEAD, CraftItemStack.asNMSCopy(item));
|
|
||||||
((CraftWorld) user.getEntity().getWorld()).getHandle().addFreshEntity(invisibleArmorstand, CreatureSpawnEvent.SpawnReason.CUSTOM);
|
|
||||||
|
|
||||||
MessagesUtil.sendDebugMessages("spawnBackpack NMS");
|
|
||||||
|
|
||||||
return invisibleArmorstand.getBukkitLivingEntity();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public org.bukkit.entity.Entity spawnDisplayEntity(Location location, String text) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public UserBalloonManager spawnBalloon(CosmeticUser user, CosmeticBalloonType cosmeticBalloonType) {
|
|
||||||
org.bukkit.entity.Entity entity = user.getEntity();
|
|
||||||
|
|
||||||
UserBalloonManager userBalloonManager1 = new UserBalloonManager(entity.getLocation());
|
|
||||||
userBalloonManager1.getModelEntity().teleport(entity.getLocation().add(Settings.getBalloonOffset()));
|
|
||||||
|
|
||||||
userBalloonManager1.spawnModel(cosmeticBalloonType, user.getCosmeticColor(cosmeticBalloonType.getSlot()));
|
|
||||||
userBalloonManager1.addPlayerToModel(user, cosmeticBalloonType, user.getCosmeticColor(cosmeticBalloonType.getSlot()));
|
|
||||||
|
|
||||||
return userBalloonManager1;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void equipmentSlotUpdate(
|
|
||||||
int entityId,
|
|
||||||
CosmeticUser user,
|
|
||||||
CosmeticSlot cosmeticSlot,
|
|
||||||
List<Player> sendTo
|
|
||||||
) {
|
|
||||||
|
|
||||||
EquipmentSlot nmsSlot = null;
|
|
||||||
net.minecraft.world.item.ItemStack nmsItem = null;
|
|
||||||
|
|
||||||
if (!(user.getCosmetic(cosmeticSlot) instanceof CosmeticArmorType)) {
|
|
||||||
|
|
||||||
if (user.getCosmetic(cosmeticSlot) instanceof CosmeticMainhandType) {
|
|
||||||
CosmeticMainhandType cosmeticMainhandType = (CosmeticMainhandType) user.getCosmetic(CosmeticSlot.MAINHAND);
|
|
||||||
nmsItem = CraftItemStack.asNMSCopy(user.getUserCosmeticItem(cosmeticMainhandType));
|
|
||||||
} else {
|
|
||||||
nmsItem = CraftItemStack.asNMSCopy(user.getPlayer().getInventory().getItem(InventoryUtils.getEquipmentSlot(cosmeticSlot)));
|
|
||||||
}
|
|
||||||
|
|
||||||
nmsSlot = CraftEquipmentSlot.getNMS(InventoryUtils.getEquipmentSlot(cosmeticSlot));
|
|
||||||
|
|
||||||
if (nmsSlot == null) return;
|
|
||||||
|
|
||||||
Pair<EquipmentSlot, net.minecraft.world.item.ItemStack> pair = new Pair<>(nmsSlot, nmsItem);
|
|
||||||
|
|
||||||
List<Pair<EquipmentSlot, net.minecraft.world.item.ItemStack>> pairs = Collections.singletonList(pair);
|
|
||||||
|
|
||||||
ClientboundSetEquipmentPacket packet = new ClientboundSetEquipmentPacket(entityId, pairs);
|
|
||||||
for (Player p : sendTo) sendPacket(p, packet);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
CosmeticArmorType cosmeticArmor = (CosmeticArmorType) user.getCosmetic(cosmeticSlot);
|
|
||||||
|
|
||||||
// Converting EquipmentSlot and ItemStack to NMS ones.
|
|
||||||
nmsSlot = CraftEquipmentSlot.getNMS(cosmeticArmor.getEquipSlot());
|
|
||||||
nmsItem = CraftItemStack.asNMSCopy(user.getUserCosmeticItem(cosmeticArmor));
|
|
||||||
|
|
||||||
if (nmsSlot == null) return;
|
|
||||||
|
|
||||||
Pair<EquipmentSlot, net.minecraft.world.item.ItemStack> pair = new Pair<>(nmsSlot, nmsItem);
|
|
||||||
|
|
||||||
List<Pair<EquipmentSlot, net.minecraft.world.item.ItemStack>> pairs = Collections.singletonList(pair);
|
|
||||||
|
|
||||||
ClientboundSetEquipmentPacket packet = new ClientboundSetEquipmentPacket(entityId, pairs);
|
|
||||||
for (Player p : sendTo) sendPacket(p, packet);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void equipmentSlotUpdate(
|
|
||||||
int entityId,
|
|
||||||
org.bukkit.inventory.EquipmentSlot slot,
|
|
||||||
ItemStack item,
|
|
||||||
List<Player> sendTo
|
|
||||||
) {
|
|
||||||
|
|
||||||
EquipmentSlot nmsSlot = null;
|
|
||||||
net.minecraft.world.item.ItemStack nmsItem = null;
|
|
||||||
|
|
||||||
// Converting EquipmentSlot and ItemStack to NMS ones.
|
|
||||||
nmsSlot = CraftEquipmentSlot.getNMS(slot);
|
|
||||||
nmsItem = CraftItemStack.asNMSCopy(item);
|
|
||||||
|
|
||||||
if (nmsSlot == null) return;
|
|
||||||
|
|
||||||
Pair<EquipmentSlot, net.minecraft.world.item.ItemStack> pair = new Pair<>(nmsSlot, nmsItem);
|
|
||||||
|
|
||||||
List<Pair<EquipmentSlot, net.minecraft.world.item.ItemStack>> pairs = Collections.singletonList(pair);
|
|
||||||
|
|
||||||
ClientboundSetEquipmentPacket packet = new ClientboundSetEquipmentPacket(entityId, pairs);
|
|
||||||
for (Player p : sendTo) sendPacket(p, packet);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void slotUpdate(
|
|
||||||
Player player,
|
|
||||||
int slot
|
|
||||||
) {
|
|
||||||
int index = 0;
|
|
||||||
|
|
||||||
ServerPlayer player1 = ((CraftPlayer) player).getHandle();
|
|
||||||
|
|
||||||
if (index < Inventory.getSelectionSize()) {
|
|
||||||
index += 36;
|
|
||||||
} else if (index > 39) {
|
|
||||||
index += 5; // Off hand
|
|
||||||
} else if (index > 35) {
|
|
||||||
index = 8 - (index - 36);
|
|
||||||
}
|
|
||||||
ItemStack item = player.getInventory().getItem(slot);
|
|
||||||
|
|
||||||
Packet packet = new ClientboundContainerSetSlotPacket(player1.inventoryMenu.containerId, player1.inventoryMenu.incrementStateId(), index, CraftItemStack.asNMSCopy(item));
|
|
||||||
sendPacket(player, packet);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void hideNPCName(Player player, String NPCName) {
|
|
||||||
//Creating the team
|
|
||||||
PlayerTeam team = new PlayerTeam(((CraftScoreboard) Bukkit.getScoreboardManager().getMainScoreboard()).getHandle(), NPCName);
|
|
||||||
|
|
||||||
//Setting name visibility
|
|
||||||
team.setNameTagVisibility(Team.Visibility.NEVER);
|
|
||||||
|
|
||||||
//Remove the Team (i assume so if it exists)
|
|
||||||
ClientboundSetPlayerTeamPacket removeTeamPacket = ClientboundSetPlayerTeamPacket.createRemovePacket(team);
|
|
||||||
sendPacket(player, removeTeamPacket);
|
|
||||||
//Creating the Team
|
|
||||||
ClientboundSetPlayerTeamPacket createTeamPacket = ClientboundSetPlayerTeamPacket.createAddOrModifyPacket(team, true);
|
|
||||||
sendPacket(player, createTeamPacket);
|
|
||||||
//Adding players to the team (You have to use the NPC's name, and add it to a list)
|
|
||||||
ClientboundSetPlayerTeamPacket createPlayerTeamPacket = ClientboundSetPlayerTeamPacket.createMultiplePlayerPacket(team, new ArrayList<String>() {{
|
|
||||||
add(NPCName);
|
|
||||||
}}, ClientboundSetPlayerTeamPacket.Action.ADD);
|
|
||||||
sendPacket(player, createPlayerTeamPacket);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void sendPacket(Player player, Packet packet) {
|
|
||||||
ServerPlayer serverPlayer = ((CraftPlayer) player).getHandle();
|
|
||||||
ServerPlayerConnection connection = serverPlayer.connection;
|
|
||||||
connection.send(packet);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean getSupported() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,27 +0,0 @@
|
|||||||
plugins {
|
|
||||||
id("java")
|
|
||||||
id("io.papermc.paperweight.userdev") version "1.5.1"
|
|
||||||
}
|
|
||||||
|
|
||||||
dependencies {
|
|
||||||
paperDevBundle("1.19.4-R0.1-SNAPSHOT")
|
|
||||||
implementation(project(":common"))
|
|
||||||
}
|
|
||||||
|
|
||||||
tasks {
|
|
||||||
|
|
||||||
build {
|
|
||||||
dependsOn(reobfJar)
|
|
||||||
}
|
|
||||||
|
|
||||||
compileJava {
|
|
||||||
options.encoding = Charsets.UTF_8.name()
|
|
||||||
options.release.set(17)
|
|
||||||
}
|
|
||||||
javadoc {
|
|
||||||
options.encoding = Charsets.UTF_8.name()
|
|
||||||
}
|
|
||||||
processResources {
|
|
||||||
filteringCharset = Charsets.UTF_8.name()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user