mirror of
https://github.com/HibiscusMC/HMCCosmetics.git
synced 2025-12-20 07:29:15 +00:00
Compare commits
156 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
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 | ||
|
|
c98f132871 | ||
|
|
554bdf91bd | ||
|
|
fced771953 | ||
|
|
6ec47c3f08 | ||
|
|
2df2646622 | ||
|
|
e8d1dd1798 | ||
|
|
59479fc474 | ||
|
|
14b27abe92 | ||
|
|
8c2c6db81b | ||
|
|
5696039799 | ||
|
|
3068ce5a03 | ||
|
|
548d0c3e9a | ||
|
|
a37d6d984b | ||
|
|
d41b385b2a | ||
|
|
2ab59dd2b2 | ||
|
|
450083baf0 | ||
|
|
0d3129bc3f | ||
|
|
fe68c43c1f | ||
|
|
4aa1f412fe | ||
|
|
e53e0110f9 | ||
|
|
f645907ed5 | ||
|
|
af465180c0 | ||
|
|
210e6f61d6 | ||
|
|
14288479f4 | ||
|
|
8453a8b20d | ||
|
|
e59ee03ac7 | ||
|
|
01155f40dd | ||
|
|
fa9f81e5e2 | ||
|
|
54bcef1a45 | ||
|
|
8e14899397 | ||
|
|
061718a3b6 | ||
|
|
2eea426460 | ||
|
|
b0136d6076 | ||
|
|
d0b45b951c | ||
|
|
e42f5c8c7d | ||
|
|
5d4fb85fec | ||
|
|
04b11a0830 | ||
|
|
353086b9c1 | ||
|
|
4e40a7cc96 | ||
|
|
e2715fe631 | ||
|
|
c7deb756db | ||
|
|
11f26f8f0a | ||
|
|
6d814d86b3 | ||
|
|
12f8b05469 | ||
|
|
b5322bc10b | ||
|
|
7a4fd9a98b | ||
|
|
239e13fab2 | ||
|
|
94b5a1bb3b | ||
|
|
71ed820917 | ||
|
|
20532fbaf2 | ||
|
|
4068af98d2 | ||
|
|
95e83992de | ||
|
|
96817d7279 | ||
|
|
ba7a99247a | ||
|
|
f1da6105c0 | ||
|
|
c06a4fcede | ||
|
|
afb20ea0bb | ||
|
|
774caf8d91 | ||
|
|
a0c2c8a9aa | ||
|
|
5b7f75f7a0 | ||
|
|
3f7d010dfa | ||
|
|
4d84bd681d | ||
|
|
0daff3044d | ||
|
|
ee87338cd4 | ||
|
|
2b467e63ce | ||
|
|
6000cf9c1b | ||
|
|
f2b0fb29d3 | ||
|
|
d2962ba5ed | ||
|
|
b37083a298 | ||
|
|
e35a29a13b | ||
|
|
344aaf32e0 | ||
|
|
6498cb43ea | ||
|
|
0120720cc3 | ||
|
|
d1bfa5abbc | ||
|
|
71a080a3d5 | ||
|
|
78f48703db | ||
|
|
b9e5096d33 | ||
|
|
d7603b5108 | ||
|
|
756e3390a1 | ||
|
|
8054a35f43 | ||
|
|
3b863e6dde | ||
|
|
b682dd7c42 | ||
|
|
f34f5f01aa | ||
|
|
cb9248db7a | ||
|
|
61ee228990 | ||
|
|
14e061e487 | ||
|
|
9dc2c23d04 | ||
|
|
684f8a4790 | ||
|
|
5d782bb6a3 | ||
|
|
988ec04a2e | ||
|
|
ebf87f01b8 | ||
|
|
6032eb0782 | ||
|
|
6d8c46783f | ||
|
|
407061d125 | ||
|
|
f8192d734b | ||
|
|
190f8f776d | ||
|
|
cd80bc746e | ||
|
|
d96a8e5622 | ||
|
|
53091f102e | ||
|
|
1d24881df1 | ||
|
|
ae0dc7bd14 | ||
|
|
b9a57fc48f | ||
|
|
1e2db05e45 | ||
|
|
4e2291d16f | ||
|
|
2e95a9bf58 | ||
|
|
0de6c1416c | ||
|
|
f8c2e0e605 | ||
|
|
23ad3eaf65 | ||
|
|
97887961db |
@@ -2,13 +2,13 @@ import net.minecrell.pluginyml.bukkit.BukkitPluginDescription
|
|||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
id("java")
|
id("java")
|
||||||
id("com.github.johnrengelman.shadow") version "7.1.2"
|
id("com.github.johnrengelman.shadow") version "8.1.1"
|
||||||
id("xyz.jpenilla.run-paper") version "2.0.0"
|
id("xyz.jpenilla.run-paper") version "2.0.0"
|
||||||
id("net.minecrell.plugin-yml.bukkit") version "0.5.2"
|
id("net.minecrell.plugin-yml.bukkit") version "0.6.0"
|
||||||
}
|
}
|
||||||
|
|
||||||
group = "com.hibiscusmc"
|
group = "com.hibiscusmc"
|
||||||
version = "2.4.1"
|
version = "2.6.0"
|
||||||
|
|
||||||
allprojects {
|
allprojects {
|
||||||
apply(plugin = "java")
|
apply(plugin = "java")
|
||||||
@@ -68,23 +68,27 @@ allprojects {
|
|||||||
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.17.1-R0.1-SNAPSHOT")
|
compileOnly("org.spigotmc:spigot-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.0.0")
|
||||||
compileOnly("me.clip:placeholderapi:2.11.1")
|
compileOnly("me.clip:placeholderapi:2.11.3")
|
||||||
compileOnly("com.ticxo:modelengine:R3.0.1")
|
compileOnly("com.ticxo:modelengine:R3.0.1")
|
||||||
compileOnly("com.github.oraxen:oraxen:-SNAPSHOT")
|
compileOnly("com.github.oraxen:oraxen:1.160.0")
|
||||||
compileOnly("com.github.LoneDev6:API-ItemsAdder:3.2.5")
|
compileOnly("com.github.LoneDev6:API-ItemsAdder:3.2.5")
|
||||||
compileOnly("com.mineinabyss:geary-papermc:0.24-SNAPSHOT")
|
compileOnly("com.mineinabyss:geary-papermc:0.24.1")
|
||||||
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.6-4")
|
compileOnly("com.github.LeonMangler:SuperVanish:6.2.17")
|
||||||
|
compileOnly("org.projectlombok:lombok:1.18.2")
|
||||||
|
|
||||||
|
annotationProcessor("org.projectlombok:lombok:1.18.28")
|
||||||
|
testCompileOnly("org.projectlombok:lombok:1.18.28")
|
||||||
|
testAnnotationProcessor("org.projectlombok:lombok:1.18.28")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation(project(path = ":common"))
|
implementation(project(path = ":common"))
|
||||||
implementation(project(path = ":v1_17_R1", configuration = "reobf"))
|
|
||||||
implementation(project(path = ":v1_18_R2", configuration = "reobf"))
|
implementation(project(path = ":v1_18_R2", configuration = "reobf"))
|
||||||
implementation(project(path = ":v1_19_R1", configuration = "reobf"))
|
implementation(project(path = ":v1_19_R1", configuration = "reobf"))
|
||||||
implementation(project(path = ":v1_19_R2", configuration = "reobf"))
|
implementation(project(path = ":v1_19_R2", configuration = "reobf"))
|
||||||
@@ -100,7 +104,7 @@ dependencies {
|
|||||||
implementation("org.bstats:bstats-bukkit:3.0.0")
|
implementation("org.bstats:bstats-bukkit:3.0.0")
|
||||||
implementation("com.jeff_media:SpigotUpdateChecker:3.0.0")
|
implementation("com.jeff_media:SpigotUpdateChecker:3.0.0")
|
||||||
implementation("com.owen1212055:particlehelper:1.0.0-SNAPSHOT")
|
implementation("com.owen1212055:particlehelper:1.0.0-SNAPSHOT")
|
||||||
implementation("com.ticxo:PlayerAnimator:R1.2.6")
|
implementation("com.ticxo.playeranimator:PlayerAnimator:R1.2.7")
|
||||||
implementation("com.github.BG-Software-LLC:CommentedConfiguration:-SNAPSHOT")
|
implementation("com.github.BG-Software-LLC:CommentedConfiguration:-SNAPSHOT")
|
||||||
//implementation("com.ticxo.playeranimator:PlayerAnimator:R1.2.5")
|
//implementation("com.ticxo.playeranimator:PlayerAnimator:R1.2.5")
|
||||||
}
|
}
|
||||||
@@ -122,11 +126,10 @@ tasks {
|
|||||||
}
|
}
|
||||||
|
|
||||||
runServer {
|
runServer {
|
||||||
minecraftVersion("1.19.4")
|
minecraftVersion("1.20.1")
|
||||||
}
|
}
|
||||||
|
|
||||||
shadowJar {
|
shadowJar {
|
||||||
dependsOn(":v1_17_R1:reobfJar")
|
|
||||||
dependsOn(":v1_18_R2:reobfJar")
|
dependsOn(":v1_18_R2:reobfJar")
|
||||||
dependsOn(":v1_19_R1:reobfJar")
|
dependsOn(":v1_19_R1:reobfJar")
|
||||||
dependsOn(":v1_19_R2:reobfJar")
|
dependsOn(":v1_19_R2:reobfJar")
|
||||||
@@ -169,11 +172,14 @@ tasks {
|
|||||||
bukkit {
|
bukkit {
|
||||||
load = BukkitPluginDescription.PluginLoadOrder.POSTWORLD
|
load = BukkitPluginDescription.PluginLoadOrder.POSTWORLD
|
||||||
main = "com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin"
|
main = "com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin"
|
||||||
apiVersion = "1.17"
|
apiVersion = "1.18"
|
||||||
authors = listOf("LoJoSho")
|
authors = listOf("LoJoSho")
|
||||||
depend = listOf("ProtocolLib")
|
depend = listOf("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")
|
||||||
version = "${project.version}"
|
version = "${project.version}"
|
||||||
|
loadBefore = listOf(
|
||||||
|
"Cosmin" // Fixes an issue with Cosmin loading before and taking /cosmetic, when messing with what we do.
|
||||||
|
)
|
||||||
|
|
||||||
commands {
|
commands {
|
||||||
register("cosmetic") {
|
register("cosmetic") {
|
||||||
|
|||||||
@@ -5,20 +5,20 @@ plugins {
|
|||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compileOnly("com.mojang:authlib:1.5.25")
|
compileOnly("com.mojang:authlib:1.5.25")
|
||||||
compileOnly("org.spigotmc:spigot-api:1.17.1-R0.1-SNAPSHOT")
|
compileOnly("org.spigotmc:spigot-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.0.0")
|
||||||
compileOnly("me.clip:placeholderapi:2.11.1")
|
compileOnly("me.clip:placeholderapi:2.11.3")
|
||||||
compileOnly("com.ticxo:modelengine:R3.0.1")
|
compileOnly("com.ticxo:modelengine:R3.0.1")
|
||||||
compileOnly("com.github.oraxen:oraxen:-SNAPSHOT")
|
compileOnly("com.github.oraxen:oraxen:1.160.0")
|
||||||
compileOnly("com.github.LoneDev6:API-ItemsAdder:3.2.5")
|
compileOnly("com.github.LoneDev6:API-ItemsAdder:3.2.5")
|
||||||
compileOnly("com.mineinabyss:geary-papermc:0.24-SNAPSHOT")
|
compileOnly("com.mineinabyss:geary-papermc:0.24-SNAPSHOT")
|
||||||
compileOnly("com.hibiscus:hmccolor:0.3-SNAPSHOT")
|
//compileOnly("com.hibiscus:hmccolor:0.3-SNAPSHOT") USE LIB PROVIDED FILE
|
||||||
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("io.lumine:Mythic-Dist:5.2.1")
|
compileOnly("io.lumine:Mythic-Dist:5.2.1")
|
||||||
compileOnly("com.denizenscript:denizen:1.2.7-SNAPSHOT")
|
compileOnly("com.denizenscript:denizen:1.2.7-SNAPSHOT")
|
||||||
compileOnly("com.github.LeonMangler:SuperVanish:6.2.6-4")
|
compileOnly("com.github.LeonMangler:SuperVanish:6.2.17")
|
||||||
compileOnlyApi("LibsDisguises:LibsDisguises:10.0.21") {
|
compileOnlyApi("LibsDisguises:LibsDisguises:10.0.21") {
|
||||||
exclude("org.spigotmc", "spigot")
|
exclude("org.spigotmc", "spigot")
|
||||||
}
|
}
|
||||||
@@ -32,7 +32,7 @@ dependencies {
|
|||||||
implementation("org.bstats:bstats-bukkit:3.0.0")
|
implementation("org.bstats:bstats-bukkit:3.0.0")
|
||||||
implementation("com.jeff_media:SpigotUpdateChecker:3.0.0")
|
implementation("com.jeff_media:SpigotUpdateChecker:3.0.0")
|
||||||
implementation("com.owen1212055:particlehelper:1.0.0-SNAPSHOT")
|
implementation("com.owen1212055:particlehelper:1.0.0-SNAPSHOT")
|
||||||
implementation("com.ticxo:PlayerAnimator:R1.2.6")
|
implementation("com.ticxo.playeranimator:PlayerAnimator:R1.2.7")
|
||||||
implementation("com.github.BG-Software-LLC:CommentedConfiguration:-SNAPSHOT")
|
implementation("com.github.BG-Software-LLC:CommentedConfiguration:-SNAPSHOT")
|
||||||
//implementation("com.ticxo.playeranimator:PlayerAnimator:R1.2.5")
|
//implementation("com.ticxo.playeranimator:PlayerAnimator:R1.2.5")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package com.hibiscusmc.hmccosmetics;
|
package com.hibiscusmc.hmccosmetics;
|
||||||
|
|
||||||
import com.bgsoftware.common.config.CommentedConfiguration;
|
import com.bgsoftware.common.config.CommentedConfiguration;
|
||||||
import com.hibiscusmc.hmccosmetics.api.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;
|
||||||
@@ -50,7 +50,6 @@ public final class HMCCosmeticsPlugin extends JavaPlugin {
|
|||||||
private static boolean disable = false;
|
private static boolean disable = false;
|
||||||
private static YamlConfigurationLoader configLoader;
|
private static YamlConfigurationLoader configLoader;
|
||||||
private static final int pluginId = 13873;
|
private static final int pluginId = 13873;
|
||||||
private static boolean hasModelEngine = false;
|
|
||||||
private static boolean onLatestVersion = true;
|
private static boolean onLatestVersion = true;
|
||||||
private static String latestVersion = "";
|
private static String latestVersion = "";
|
||||||
|
|
||||||
@@ -89,8 +88,8 @@ public final class HMCCosmeticsPlugin extends JavaPlugin {
|
|||||||
onLatestVersion = checker.isUsingLatestVersion();
|
onLatestVersion = checker.isUsingLatestVersion();
|
||||||
// File setup
|
// File setup
|
||||||
saveDefaultConfig();
|
saveDefaultConfig();
|
||||||
//saveResource("translations.yml", false);
|
|
||||||
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);
|
||||||
|
if (!Path.of(getDataFolder().getPath(), "translations.yml").toFile().exists()) saveResource("translations.yml", false);
|
||||||
if (!Path.of(getDataFolder().getPath() + "/cosmetics/").toFile().exists()) saveResource("cosmetics/defaultcosmetics.yml", false);
|
if (!Path.of(getDataFolder().getPath() + "/cosmetics/").toFile().exists()) saveResource("cosmetics/defaultcosmetics.yml", false);
|
||||||
if (!Path.of(getDataFolder().getPath() + "/menus/").toFile().exists()) saveResource("menus/defaultmenu.yml", false);
|
if (!Path.of(getDataFolder().getPath() + "/menus/").toFile().exists()) saveResource("menus/defaultmenu.yml", false);
|
||||||
|
|
||||||
@@ -104,11 +103,15 @@ public final class HMCCosmeticsPlugin extends JavaPlugin {
|
|||||||
// 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();
|
||||||
final File messageFile = Path.of(getInstance().getDataFolder().getPath(), "messages.yml").toFile();
|
final File messageFile = Path.of(getInstance().getDataFolder().getPath(), "messages.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", "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"));
|
||||||
} catch (Exception e) {}
|
CommentedConfiguration.loadConfiguration(translationFile).syncWithConfig(translationFile, getInstance().getResource("translations.yml"));
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
// Setup
|
// Setup
|
||||||
setup();
|
setup();
|
||||||
@@ -124,13 +127,8 @@ public final class HMCCosmeticsPlugin extends JavaPlugin {
|
|||||||
// Database
|
// Database
|
||||||
new Database();
|
new Database();
|
||||||
|
|
||||||
// ModelEngine
|
|
||||||
if (Bukkit.getPluginManager().getPlugin("ModelEngine") != null) {
|
|
||||||
hasModelEngine = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -282,9 +280,6 @@ public final class HMCCosmeticsPlugin extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean hasModelEngine() {
|
|
||||||
return hasModelEngine;
|
|
||||||
}
|
|
||||||
public static boolean isOnLatestVersion() {
|
public static boolean isOnLatestVersion() {
|
||||||
return onLatestVersion;
|
return onLatestVersion;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,117 @@
|
|||||||
|
package com.hibiscusmc.hmccosmetics.api;
|
||||||
|
|
||||||
|
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
|
||||||
|
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
|
||||||
|
import com.hibiscusmc.hmccosmetics.cosmetic.CosmeticSlot;
|
||||||
|
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetics;
|
||||||
|
import com.hibiscusmc.hmccosmetics.gui.Menu;
|
||||||
|
import com.hibiscusmc.hmccosmetics.gui.Menus;
|
||||||
|
import com.hibiscusmc.hmccosmetics.nms.NMSHandlers;
|
||||||
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||||
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUsers;
|
||||||
|
import org.bukkit.Color;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
public class HMCCosmeticsAPI {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Attempts to get a cosmetic from HMCCosmetics
|
||||||
|
*
|
||||||
|
* @param cosmetic Cosmetic Id
|
||||||
|
* @return A {@link Cosmetic} if exists or null if it does not
|
||||||
|
*/
|
||||||
|
@Nullable
|
||||||
|
public static Cosmetic getCosmetic(@NotNull String cosmetic) {
|
||||||
|
return Cosmetics.getCosmetic(cosmetic);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Attempts to get the CosmeticUser from an online user. If a player is offline it will return null.
|
||||||
|
* A player maybe online but not have a CosmeticUser attached to them, either from delay specified in the config
|
||||||
|
* or from a /reload. Always check if it's null!
|
||||||
|
*
|
||||||
|
* @param uuid Player Unique ID
|
||||||
|
* @return A {@link CosmeticUser} if exists or null if it does not
|
||||||
|
*/
|
||||||
|
@Nullable
|
||||||
|
public static CosmeticUser getUser(@NotNull UUID uuid) {
|
||||||
|
return CosmeticUsers.getUser(uuid);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Attempts to get a HMCCosmetics Menu. Returns null if no menu exists under that id.
|
||||||
|
*
|
||||||
|
* @param id Menu ID
|
||||||
|
* @return A {@link Menu} if exists or null if it does not
|
||||||
|
*/
|
||||||
|
@Nullable
|
||||||
|
public static Menu getMenu(@NotNull String id) {
|
||||||
|
return Menus.getMenu(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Equips a cosmetic to a player. You can use getUser and getCosmetic to get the CosmeticUser and Cosmetic to equip.
|
||||||
|
* @param user CosmeticUser to equip cosmetic to
|
||||||
|
* @param cosmetic Cosmetic to equip
|
||||||
|
*/
|
||||||
|
public static void equipCosmetic(@NotNull CosmeticUser user, @NotNull Cosmetic cosmetic) {
|
||||||
|
equipCosmetic(user, cosmetic, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Equips a cosmetic to a player with a color. You can use getUser and getCosmetic to get the CosmeticUser and Cosmetic to equip.
|
||||||
|
* @param user CosmeticUser to equip cosmetic to
|
||||||
|
* @param cosmetic Cosmetic to equip
|
||||||
|
* @param color Color to apply to cosmetic
|
||||||
|
*/
|
||||||
|
public static void equipCosmetic(@NotNull CosmeticUser user, @NotNull Cosmetic cosmetic, @Nullable Color color) {
|
||||||
|
user.addPlayerCosmetic(cosmetic, color);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Removes a cosmetic in cosmeticslot.
|
||||||
|
* @param user The user to remove the cosmetic from
|
||||||
|
* @param slot The slot to remove the cosmetic from
|
||||||
|
*/
|
||||||
|
public static void unequipCosmetic(@NotNull CosmeticUser user, @NotNull CosmeticSlot slot) {
|
||||||
|
user.removeCosmeticSlot(slot);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets all Cosmetics that are currently registered with HMCC. This list is immutable!
|
||||||
|
* @return A list of all registered cosmetics
|
||||||
|
*/
|
||||||
|
public static List<Cosmetic> getAllCosmetics() {
|
||||||
|
return List.copyOf(Cosmetics.values());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets all CosmeticUsers that are currently registered with HMCC. This list is immutable!
|
||||||
|
* @return A list of all registered CosmeticUsers
|
||||||
|
*/
|
||||||
|
public static List<CosmeticUser> getAllCosmeticUsers() {
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package com.hibiscusmc.hmccosmetics.api;
|
package com.hibiscusmc.hmccosmetics.api.events;
|
||||||
|
|
||||||
import org.bukkit.event.Event;
|
import org.bukkit.event.Event;
|
||||||
import org.bukkit.event.HandlerList;
|
import org.bukkit.event.HandlerList;
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package com.hibiscusmc.hmccosmetics.api;
|
package com.hibiscusmc.hmccosmetics.api.events;
|
||||||
|
|
||||||
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
|
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
|
||||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package com.hibiscusmc.hmccosmetics.api;
|
package com.hibiscusmc.hmccosmetics.api.events;
|
||||||
|
|
||||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||||
import org.bukkit.event.Event;
|
import org.bukkit.event.Event;
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package com.hibiscusmc.hmccosmetics.api;
|
package com.hibiscusmc.hmccosmetics.api.events;
|
||||||
|
|
||||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||||
import org.bukkit.event.Cancellable;
|
import org.bukkit.event.Cancellable;
|
||||||
@@ -0,0 +1,46 @@
|
|||||||
|
package com.hibiscusmc.hmccosmetics.api.events;
|
||||||
|
|
||||||
|
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
|
||||||
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||||
|
import org.bukkit.event.HandlerList;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
public class PlayerCosmeticPostEquipEvent extends PlayerCosmeticEvent {
|
||||||
|
private static final HandlerList handlers = new HandlerList();
|
||||||
|
private Cosmetic cosmetic;
|
||||||
|
|
||||||
|
public PlayerCosmeticPostEquipEvent(@NotNull CosmeticUser who, @NotNull Cosmetic cosmetic) {
|
||||||
|
super(who);
|
||||||
|
this.cosmetic = cosmetic;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the {@link Cosmetic} being equipped in this event
|
||||||
|
*
|
||||||
|
* @return The {@link Cosmetic} which is being equipped in this event
|
||||||
|
*/
|
||||||
|
@NotNull
|
||||||
|
public Cosmetic getCosmetic() {
|
||||||
|
return cosmetic;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the {@link Cosmetic} that the player will equip
|
||||||
|
*
|
||||||
|
* @param cosmetic The {@link Cosmetic} that the player will equip
|
||||||
|
*/
|
||||||
|
public void setCosmetic(@NotNull Cosmetic cosmetic) {
|
||||||
|
this.cosmetic = cosmetic;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@NotNull
|
||||||
|
public HandlerList getHandlers() {
|
||||||
|
return handlers;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
public static HandlerList getHandlerList() {
|
||||||
|
return handlers;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package com.hibiscusmc.hmccosmetics.api;
|
package com.hibiscusmc.hmccosmetics.api.events;
|
||||||
|
|
||||||
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
|
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
|
||||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package com.hibiscusmc.hmccosmetics.api;
|
package com.hibiscusmc.hmccosmetics.api.events;
|
||||||
|
|
||||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||||
import org.bukkit.event.Cancellable;
|
import org.bukkit.event.Cancellable;
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package com.hibiscusmc.hmccosmetics.api;
|
package com.hibiscusmc.hmccosmetics.api.events;
|
||||||
|
|
||||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||||
import org.bukkit.event.Cancellable;
|
import org.bukkit.event.Cancellable;
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package com.hibiscusmc.hmccosmetics.api;
|
package com.hibiscusmc.hmccosmetics.api.events;
|
||||||
|
|
||||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||||
import com.hibiscusmc.hmccosmetics.user.manager.UserEmoteManager;
|
import com.hibiscusmc.hmccosmetics.user.manager.UserEmoteManager;
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package com.hibiscusmc.hmccosmetics.api;
|
package com.hibiscusmc.hmccosmetics.api.events;
|
||||||
|
|
||||||
import com.hibiscusmc.hmccosmetics.gui.Menu;
|
import com.hibiscusmc.hmccosmetics.gui.Menu;
|
||||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package com.hibiscusmc.hmccosmetics.api;
|
package com.hibiscusmc.hmccosmetics.api.events;
|
||||||
|
|
||||||
import com.hibiscusmc.hmccosmetics.gui.Menu;
|
import com.hibiscusmc.hmccosmetics.gui.Menu;
|
||||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package com.hibiscusmc.hmccosmetics.api;
|
package com.hibiscusmc.hmccosmetics.api.events;
|
||||||
|
|
||||||
import com.hibiscusmc.hmccosmetics.gui.Menu;
|
import com.hibiscusmc.hmccosmetics.gui.Menu;
|
||||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||||
@@ -1,7 +1,6 @@
|
|||||||
package com.hibiscusmc.hmccosmetics.api;
|
package com.hibiscusmc.hmccosmetics.api.events;
|
||||||
|
|
||||||
import com.hibiscusmc.hmccosmetics.config.Wardrobe;
|
import com.hibiscusmc.hmccosmetics.config.Wardrobe;
|
||||||
import com.hibiscusmc.hmccosmetics.config.WardrobeLocation;
|
|
||||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||||
import org.bukkit.event.Cancellable;
|
import org.bukkit.event.Cancellable;
|
||||||
import org.bukkit.event.HandlerList;
|
import org.bukkit.event.HandlerList;
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package com.hibiscusmc.hmccosmetics.api;
|
package com.hibiscusmc.hmccosmetics.api.events;
|
||||||
|
|
||||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||||
import org.bukkit.event.Cancellable;
|
import org.bukkit.event.Cancellable;
|
||||||
@@ -368,7 +368,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 +423,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,10 +1,10 @@
|
|||||||
package com.hibiscusmc.hmccosmetics.config;
|
package com.hibiscusmc.hmccosmetics.config;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
import org.spongepowered.configurate.ConfigurationNode;
|
import org.spongepowered.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,8 +1,8 @@
|
|||||||
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 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 org.spongepowered.configurate.ConfigurationNode;
|
||||||
@@ -15,17 +15,8 @@ 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 FIRST_PERSON_BACKPACK_MODE = "first-person-backpack-mode";
|
|
||||||
|
|
||||||
private static final transient String LOOK_DOWN_PITCH_PATH = "look-down-backpack-remove";
|
|
||||||
private static final String VIEW_DISTANCE_PATH = "view-distance";
|
private static final String VIEW_DISTANCE_PATH = "view-distance";
|
||||||
private static final String PARTICLE_COUNT = "particle-count";
|
|
||||||
private static final String DYE_MENU_PATH = "dye-menu";
|
private static final String DYE_MENU_PATH = "dye-menu";
|
||||||
private static final String DYE_MENU_NAME = "title";
|
private static final String DYE_MENU_NAME = "title";
|
||||||
private static final String DYE_MENU_INPUT_SLOT = "input-slot";
|
private static final String DYE_MENU_INPUT_SLOT = "input-slot";
|
||||||
@@ -34,6 +25,7 @@ public class Settings {
|
|||||||
private static final String TICK_PERIOD_PATH = "tick-period";
|
private static final String TICK_PERIOD_PATH = "tick-period";
|
||||||
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 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";
|
||||||
@@ -45,41 +37,106 @@ public class Settings {
|
|||||||
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_BACKPACK_FORCE_RIDING_PACKET_PATH = "backpack-force-riding-packet";
|
||||||
private static final String COSMETIC_ADD_ENCHANTS_HELMET_PATH = "helmet-add-enchantments";
|
private static final String COSMETIC_ADD_ENCHANTS_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";
|
||||||
private static final String COSMETIC_ADD_ENCHANTS_BOOTS_PATH = "boots-add-enchantments";
|
private static final String COSMETIC_ADD_ENCHANTS_BOOTS_PATH = "boots-add-enchantments";
|
||||||
private static final String COSMETIC_DESTROY_LOOSE_COSMETIC_PATH = "destroy-loose-cosmetics";
|
private static final String COSMETIC_DESTROY_LOOSE_COSMETIC_PATH = "destroy-loose-cosmetics";
|
||||||
|
private static final String MENU_SETTINGS_PATH = "menu-settings";
|
||||||
|
private static final String COSMETIC_TYPE_SETTINGS_PATH = "cosmetic-type";
|
||||||
|
private static final String EQUIP_CLICK_TYPE = "equip-click";
|
||||||
|
private static final String UNEQUIP_CLICK_TYPE = "unequip-click";
|
||||||
|
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;
|
||||||
|
@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;
|
||||||
private static int lookDownPitch;
|
@Getter
|
||||||
|
private static boolean backpackForceRidingEnabled;
|
||||||
|
@Getter
|
||||||
private static int viewDistance;
|
private static int viewDistance;
|
||||||
|
@Getter
|
||||||
private static int tickPeriod;
|
private static int tickPeriod;
|
||||||
|
@Getter
|
||||||
private static double emoteDistance;
|
private static double emoteDistance;
|
||||||
|
@Getter
|
||||||
private static Vector balloonOffset;
|
private static Vector balloonOffset;
|
||||||
|
@Getter
|
||||||
|
private static String cosmeticEquipClickType;
|
||||||
|
@Getter
|
||||||
|
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) {
|
||||||
|
|
||||||
@@ -98,30 +155,43 @@ 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();
|
|
||||||
requireEmptyOffHand = cosmeticSettings.node(REQUIRE_EMPTY_OFF_HAND_PATH).getBoolean();
|
|
||||||
requireEmptyChestPlate = cosmeticSettings.node(REQUIRE_EMPTY_CHEST_PLATE_PATH).getBoolean();
|
|
||||||
requireEmptyPants = cosmeticSettings.node(REQUIRE_EMPTY_PANTS_PATH).getBoolean();
|
|
||||||
requireEmptyBoots = cosmeticSettings.node(REQUIRE_EMPTY_BOOTS_PATH).getBoolean();
|
|
||||||
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);
|
||||||
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);
|
||||||
lookDownPitch = cosmeticSettings.node(LOOK_DOWN_PITCH_PATH).getInt();
|
viewDistance = cosmeticSettings.node(VIEW_DISTANCE_PATH).getInt(-3);
|
||||||
viewDistance = cosmeticSettings.node(VIEW_DISTANCE_PATH).getInt();
|
emoteCameraEnabled = cosmeticSettings.node(COSMETIC_EMOTE_CAMERA_PATH).getBoolean(true);
|
||||||
|
emoteMoveCheck = cosmeticSettings.node(COSMETIC_EMOTE_MOVE_CHECK_PATH).getBoolean(false);
|
||||||
|
|
||||||
|
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);
|
||||||
|
cosmeticEquipClickType = cosmeticTypeSettings.node(EQUIP_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);
|
||||||
@@ -143,149 +213,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 getLookDownPitch() {
|
|
||||||
return lookDownPitch;
|
|
||||||
}
|
|
||||||
|
|
||||||
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 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 -> {
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import javax.annotation.Nullable;
|
|||||||
public class Wardrobe {
|
public class Wardrobe {
|
||||||
|
|
||||||
private String id;
|
private String id;
|
||||||
private int distance = WardrobeSettings.getDefaultDistance();
|
private int distance = WardrobeSettings.getDisplayRadius();
|
||||||
private String permission;
|
private String permission;
|
||||||
private WardrobeLocation location;
|
private WardrobeLocation location;
|
||||||
|
|
||||||
@@ -52,7 +52,7 @@ public class Wardrobe {
|
|||||||
|
|
||||||
public boolean canEnter(CosmeticUser user) {
|
public boolean canEnter(CosmeticUser user) {
|
||||||
Location wardrobeLocation = location.getNpcLocation();
|
Location wardrobeLocation = location.getNpcLocation();
|
||||||
Location location = user.getPlayer().getLocation();
|
Location location = user.getEntity().getLocation();
|
||||||
if (wardrobeLocation == null) return false;
|
if (wardrobeLocation == null) return false;
|
||||||
if (distance == -1) return true;
|
if (distance == -1) return true;
|
||||||
if (!wardrobeLocation.getWorld().equals(location.getWorld())) return false;
|
if (!wardrobeLocation.getWorld().equals(location.getWorld())) return false;
|
||||||
|
|||||||
@@ -1,11 +1,15 @@
|
|||||||
package com.hibiscusmc.hmccosmetics.config;
|
package com.hibiscusmc.hmccosmetics.config;
|
||||||
|
|
||||||
|
import lombok.Setter;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
|
|
||||||
public class WardrobeLocation {
|
public class WardrobeLocation {
|
||||||
|
|
||||||
|
@Setter
|
||||||
private Location npcLocation;
|
private Location npcLocation;
|
||||||
|
@Setter
|
||||||
private Location viewerLocation;
|
private Location viewerLocation;
|
||||||
|
@Setter
|
||||||
private Location leaveLocation;
|
private Location leaveLocation;
|
||||||
|
|
||||||
public WardrobeLocation(Location npcLocation, Location viewerLocation, Location leaveLocation) {
|
public WardrobeLocation(Location npcLocation, Location viewerLocation, Location leaveLocation) {
|
||||||
@@ -30,16 +34,4 @@ public class WardrobeLocation {
|
|||||||
if (npcLocation == null || viewerLocation == null || leaveLocation == null) return false;
|
if (npcLocation == null || viewerLocation == null || leaveLocation == null) return false;
|
||||||
return true;
|
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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,18 +4,20 @@ import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
|
|||||||
import com.hibiscusmc.hmccosmetics.config.serializer.LocationSerializer;
|
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 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 org.spongepowered.configurate.ConfigurationNode;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.Collection;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Set;
|
||||||
import java.util.logging.Level;
|
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 DISPLAY_RADIUS_PATH = "display-radius";
|
||||||
private static final String PORTABLE_PATH = "portable";
|
private static final String PORTABLE_PATH = "portable";
|
||||||
@@ -33,6 +35,10 @@ public class WardrobeSettings {
|
|||||||
private static final String EQUIP_PUMPKIN_WARDROBE = "equip-pumpkin";
|
private static final String EQUIP_PUMPKIN_WARDROBE = "equip-pumpkin";
|
||||||
private static final String TRY_COSMETICS_WARDROBE = "unchecked-wardrobe-cosmetics";
|
private static final String TRY_COSMETICS_WARDROBE = "unchecked-wardrobe-cosmetics";
|
||||||
private static final String RETURN_LAST_LOCATION = "return-last-location";
|
private static final String RETURN_LAST_LOCATION = "return-last-location";
|
||||||
|
|
||||||
|
private static final String WARDROBE_MENU_OPTIONS = "menu-options";
|
||||||
|
private static final String WARDROBE_ENTER_OPEN_MENU_PATH = "enter-open-menu";
|
||||||
|
|
||||||
private static final String GAMEMODE_OPTIONS_PATH = "gamemode-options";
|
private static final String GAMEMODE_OPTIONS_PATH = "gamemode-options";
|
||||||
private static final String FORCE_EXIT_GAMEMODE_PATH = "exit-gamemode-enabled";
|
private static final String FORCE_EXIT_GAMEMODE_PATH = "exit-gamemode-enabled";
|
||||||
private static final String EXIT_GAMEMODE_PATH = "exit-gamemode";
|
private static final String EXIT_GAMEMODE_PATH = "exit-gamemode";
|
||||||
@@ -54,31 +60,58 @@ 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;
|
||||||
|
@Getter
|
||||||
private static int displayRadius;
|
private static int displayRadius;
|
||||||
|
@Getter
|
||||||
private static boolean portable;
|
private static boolean portable;
|
||||||
|
@Getter
|
||||||
private static boolean alwaysDisplay;
|
private static boolean alwaysDisplay;
|
||||||
|
@Getter
|
||||||
private static int staticRadius;
|
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;
|
||||||
|
@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) {
|
||||||
@@ -97,6 +130,9 @@ public class WardrobeSettings {
|
|||||||
returnLastLocation = source.node(RETURN_LAST_LOCATION).getBoolean(false);
|
returnLastLocation = source.node(RETURN_LAST_LOCATION).getBoolean(false);
|
||||||
tryCosmeticsInWardrobe = source.node(TRY_COSMETICS_WARDROBE).getBoolean(false);
|
tryCosmeticsInWardrobe = source.node(TRY_COSMETICS_WARDROBE).getBoolean(false);
|
||||||
|
|
||||||
|
ConfigurationNode menuOptionsNode = source.node(WARDROBE_MENU_OPTIONS);
|
||||||
|
enterOpenMenu = menuOptionsNode.node(WARDROBE_ENTER_OPEN_MENU_PATH).getBoolean(false);
|
||||||
|
|
||||||
ConfigurationNode gamemodeNode = source.node(GAMEMODE_OPTIONS_PATH);
|
ConfigurationNode gamemodeNode = source.node(GAMEMODE_OPTIONS_PATH);
|
||||||
forceExitGamemode = gamemodeNode.node(FORCE_EXIT_GAMEMODE_PATH).getBoolean(false);
|
forceExitGamemode = gamemodeNode.node(FORCE_EXIT_GAMEMODE_PATH).getBoolean(false);
|
||||||
exitGamemode = GameMode.valueOf(gamemodeNode.node(EXIT_GAMEMODE_PATH).getString("SURVIVAL"));
|
exitGamemode = GameMode.valueOf(gamemodeNode.node(EXIT_GAMEMODE_PATH).getString("SURVIVAL"));
|
||||||
@@ -148,54 +184,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) {
|
||||||
@@ -234,64 +222,12 @@ public class WardrobeSettings {
|
|||||||
return wardrobeLocation.distanceSquared(location) <= staticRadius * staticRadius;
|
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 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();
|
||||||
|
|
||||||
|
|||||||
@@ -2,16 +2,14 @@ package com.hibiscusmc.hmccosmetics.config.serializer;
|
|||||||
|
|
||||||
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
|
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
|
||||||
import com.hibiscusmc.hmccosmetics.hooks.Hooks;
|
import com.hibiscusmc.hmccosmetics.hooks.Hooks;
|
||||||
|
import com.hibiscusmc.hmccosmetics.util.InventoryUtils;
|
||||||
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||||
import com.hibiscusmc.hmccosmetics.util.ServerUtils;
|
import com.hibiscusmc.hmccosmetics.util.ServerUtils;
|
||||||
import com.hibiscusmc.hmccosmetics.util.builder.ColorBuilder;
|
import com.hibiscusmc.hmccosmetics.util.builder.ColorBuilder;
|
||||||
import com.hibiscusmc.hmccosmetics.util.misc.StringUtils;
|
import com.hibiscusmc.hmccosmetics.util.misc.StringUtils;
|
||||||
import com.hibiscusmc.hmccosmetics.util.misc.Utils;
|
import com.hibiscusmc.hmccosmetics.util.misc.Utils;
|
||||||
import org.apache.commons.lang3.EnumUtils;
|
import org.apache.commons.lang3.EnumUtils;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.*;
|
||||||
import org.bukkit.Color;
|
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.NamespacedKey;
|
|
||||||
import org.bukkit.enchantments.Enchantment;
|
import org.bukkit.enchantments.Enchantment;
|
||||||
import org.bukkit.inventory.ItemFlag;
|
import org.bukkit.inventory.ItemFlag;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
@@ -123,12 +121,25 @@ public class ItemSerializer implements TypeSerializer<ItemStack> {
|
|||||||
if (item.getType() == Material.PLAYER_HEAD) {
|
if (item.getType() == Material.PLAYER_HEAD) {
|
||||||
SkullMeta skullMeta = (SkullMeta) itemMeta;
|
SkullMeta skullMeta = (SkullMeta) itemMeta;
|
||||||
if (!ownerNode.virtual()) {
|
if (!ownerNode.virtual()) {
|
||||||
skullMeta.setOwningPlayer(Bukkit.getOfflinePlayer(ownerNode.getString()));
|
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()) {
|
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:\""
|
Bukkit.getUnsafe().modifyItemStack(item, "{SkullOwner:{Id:[I;0,0,0,0],Properties:{textures:[{Value:\""
|
||||||
+ textureNode.getString() + "\"}]}}}");
|
+ textureString + "\"}]}}}");
|
||||||
|
|
||||||
|
|
||||||
itemMeta = skullMeta;
|
itemMeta = skullMeta;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,8 @@ package com.hibiscusmc.hmccosmetics.cosmetic;
|
|||||||
import com.hibiscusmc.hmccosmetics.config.serializer.ItemSerializer;
|
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 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;
|
||||||
@@ -14,11 +16,16 @@ 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
|
||||||
|
|||||||
@@ -15,8 +15,11 @@ import org.spongepowered.configurate.ConfigurationNode;
|
|||||||
import org.spongepowered.configurate.yaml.YamlConfigurationLoader;
|
import org.spongepowered.configurate.yaml.YamlConfigurationLoader;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Path;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
public class Cosmetics {
|
public class Cosmetics {
|
||||||
|
|
||||||
@@ -68,19 +71,23 @@ public class Cosmetics {
|
|||||||
File[] directoryListing = cosmeticFolder.listFiles();
|
File[] directoryListing = cosmeticFolder.listFiles();
|
||||||
if (directoryListing == null) return;
|
if (directoryListing == null) return;
|
||||||
|
|
||||||
for (File child : directoryListing) {
|
try (Stream<Path> walkStream = Files.walk(cosmeticFolder.toPath())) {
|
||||||
if (child.toString().contains(".yml") || child.toString().contains(".yaml")) {
|
walkStream.filter(p -> p.toFile().isFile()).forEach(child -> {
|
||||||
MessagesUtil.sendDebugMessages("Scanning " + child);
|
if (child.toString().contains(".yml") || child.toString().contains(".yaml")) {
|
||||||
// Loads file
|
MessagesUtil.sendDebugMessages("Scanning " + child);
|
||||||
YamlConfigurationLoader loader = YamlConfigurationLoader.builder().path(child.toPath()).build();
|
// Loads file
|
||||||
CommentedConfigurationNode root;
|
YamlConfigurationLoader loader = YamlConfigurationLoader.builder().path(child).build();
|
||||||
try {
|
CommentedConfigurationNode root;
|
||||||
root = loader.load();
|
try {
|
||||||
} catch (ConfigurateException e) {
|
root = loader.load();
|
||||||
throw new RuntimeException(e);
|
} catch (ConfigurateException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
setupCosmetics(root);
|
||||||
}
|
}
|
||||||
setupCosmetics(root);
|
});
|
||||||
}
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -106,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();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,10 +5,10 @@ import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
|
|||||||
import com.hibiscusmc.hmccosmetics.nms.NMSHandlers;
|
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.InventoryUtils;
|
||||||
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
|
||||||
import com.hibiscusmc.hmccosmetics.util.packets.PacketManager;
|
import com.hibiscusmc.hmccosmetics.util.packets.PacketManager;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Entity;
|
||||||
|
import org.bukkit.entity.HumanEntity;
|
||||||
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;
|
||||||
@@ -26,19 +26,20 @@ public class CosmeticArmorType extends Cosmetic {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update(@NotNull CosmeticUser user) {
|
public void update(@NotNull CosmeticUser user) {
|
||||||
Player player = Bukkit.getPlayer(user.getUniqueId());
|
Entity entity = Bukkit.getEntity(user.getUniqueId());
|
||||||
if (player == null) return;
|
if (entity == null) return;
|
||||||
if (user.getUserEmoteManager().isPlayingEmote()) return; // There has to be a better way of doing this...
|
if (user.getUserEmoteManager().isPlayingEmote()) return; // There has to be a better way of doing this...
|
||||||
ItemStack cosmeticItem = user.getUserCosmeticItem(this);
|
ItemStack cosmeticItem = user.getUserCosmeticItem(this);
|
||||||
|
if (!(entity instanceof HumanEntity humanEntity)) return;
|
||||||
if (equipSlot.equals(EquipmentSlot.OFF_HAND)) {
|
if (equipSlot.equals(EquipmentSlot.OFF_HAND)) {
|
||||||
if (!player.getInventory().getItemInOffHand().getType().isAir()) return;
|
if (!humanEntity.getInventory().getItemInOffHand().getType().isAir()) return;
|
||||||
}
|
}
|
||||||
ItemStack equippedItem = player.getInventory().getItem(equipSlot);
|
ItemStack equippedItem = humanEntity.getInventory().getItem(equipSlot);
|
||||||
if (Settings.getShouldAddEnchants(equipSlot)) {
|
if (Settings.getShouldAddEnchants(equipSlot)) {
|
||||||
cosmeticItem.addUnsafeEnchantments(equippedItem.getEnchantments());
|
cosmeticItem.addUnsafeEnchantments(equippedItem.getEnchantments());
|
||||||
}
|
}
|
||||||
|
|
||||||
NMSHandlers.getHandler().equipmentSlotUpdate(player.getEntityId(), equipSlot, cosmeticItem, PacketManager.getViewers(player.getLocation()));
|
NMSHandlers.getHandler().equipmentSlotUpdate(entity.getEntityId(), equipSlot, cosmeticItem, PacketManager.getViewers(entity.getLocation()));
|
||||||
//PacketManager.equipmentSlotUpdate(player, getSlot(), PacketManager.getViewers(player.getLocation())); Old method
|
//PacketManager.equipmentSlotUpdate(player, getSlot(), PacketManager.getViewers(player.getLocation())); Old method
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,66 +1,95 @@
|
|||||||
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.PacketManager;
|
||||||
|
import lombok.Getter;
|
||||||
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.EntityType;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.inventory.EquipmentSlot;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.spongepowered.configurate.ConfigurationNode;
|
import org.spongepowered.configurate.ConfigurationNode;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
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;
|
||||||
private UserBackpackManager.BackpackType backpackType;
|
@Getter
|
||||||
|
private int height = -1;
|
||||||
|
private ItemStack firstPersonBackpack;
|
||||||
|
|
||||||
public CosmeticBackpackType(String id, ConfigurationNode config) {
|
public CosmeticBackpackType(String id, ConfigurationNode config) {
|
||||||
super(id, config);
|
super(id, config);
|
||||||
|
|
||||||
modelName = config.node("model").getString();
|
modelName = config.node("model").getString();
|
||||||
backpackType = UserBackpackManager.BackpackType.valueOf(config.node("type").getString("NORMAL").toUpperCase());
|
|
||||||
|
if (!config.node("firstperson-item").virtual()) {
|
||||||
|
this.firstPersonBackpack = generateItemStack(config.node("firstperson-item"));
|
||||||
|
this.height = config.node("height").getInt(5);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update(@NotNull CosmeticUser user) {
|
public void update(@NotNull CosmeticUser user) {
|
||||||
Player player = Bukkit.getPlayer(user.getUniqueId());
|
Entity entity = Bukkit.getEntity(user.getUniqueId());
|
||||||
if (player == null) return;
|
if (entity == null) return;
|
||||||
|
|
||||||
Location loc = player.getLocation().clone().add(0, 2, 0);
|
Location loc = entity.getLocation().clone().add(0, 2, 0);
|
||||||
|
|
||||||
if (user.isInWardrobe() || !user.isBackpackSpawned()) return;
|
if (user.isInWardrobe() || !user.isBackpackSpawned()) return;
|
||||||
if (!user.getUserBackpackManager().getArmorStand().isValid()) {
|
// 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.
|
||||||
MessagesUtil.sendDebugMessages("Invalid Backpack Entity[owner=" + user.getUniqueId() + ",player_location=" + loc + "]!", Level.WARNING);
|
List<Player> outsideViewers = user.getUserBackpackManager().getEntityManager().refreshViewers(loc);
|
||||||
user.respawnBackpack();
|
|
||||||
return;
|
user.getUserBackpackManager().getEntityManager().teleport(loc);
|
||||||
}
|
user.getUserBackpackManager().getEntityManager().setRotation((int) loc.getYaw());
|
||||||
if (loc.getWorld() != user.getUserBackpackManager().getArmorStand().getWorld()) {
|
|
||||||
user.getUserBackpackManager().getArmorStand().teleport(loc);
|
PacketManager.sendEntitySpawnPacket(user.getEntity().getLocation(), user.getUserBackpackManager().getFirstArmorStandId(), EntityType.ARMOR_STAND, UUID.randomUUID(), outsideViewers);
|
||||||
|
PacketManager.sendInvisibilityPacket(user.getUserBackpackManager().getFirstArmorStandId(), outsideViewers);
|
||||||
|
NMSHandlers.getHandler().equipmentSlotUpdate(user.getUserBackpackManager().getFirstArmorStandId(), EquipmentSlot.HEAD, user.getUserCosmeticItem(this, getItem()), outsideViewers);
|
||||||
|
// If true, it will send the riding packet to all players. If false, it will send the riding packet only to new players
|
||||||
|
if (Settings.isBackpackForceRidingEnabled()) PacketManager.sendRidingPacket(entity.getEntityId(), user.getUserBackpackManager().getFirstArmorStandId(), user.getUserBackpackManager().getEntityManager().getViewers());
|
||||||
|
else PacketManager.sendRidingPacket(entity.getEntityId(), user.getUserBackpackManager().getFirstArmorStandId(), outsideViewers);
|
||||||
|
|
||||||
|
if (!user.isInWardrobe() && isFirstPersonCompadible() && user.getPlayer() != null) {
|
||||||
|
List<Player> owner = List.of(user.getPlayer());
|
||||||
|
|
||||||
|
ArrayList<Integer> particleCloud = user.getUserBackpackManager().getAreaEffectEntityId();
|
||||||
|
for (int i = 0; i < particleCloud.size(); i++) {
|
||||||
|
if (i == 0) {
|
||||||
|
PacketManager.sendRidingPacket(entity.getEntityId(), particleCloud.get(i), owner);
|
||||||
|
} else {
|
||||||
|
PacketManager.sendRidingPacket(particleCloud.get(i - 1), particleCloud.get(i) , owner);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
PacketManager.sendRidingPacket(particleCloud.get(particleCloud.size() - 1), user.getUserBackpackManager().getFirstArmorStandId(), 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);
|
||||||
|
NMSHandlers.getHandler().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);
|
||||||
}
|
}
|
||||||
|
|
||||||
user.getUserBackpackManager().getArmorStand().teleport(loc);
|
|
||||||
|
|
||||||
if (user.getUserBackpackManager().getBackpackType().equals(UserBackpackManager.BackpackType.FIRST_PERSON)) {
|
|
||||||
user.getUserBackpackManager().teleportEffectEntity(loc);
|
|
||||||
PacketManager.sendRidingPacket(player.getEntityId(), user.getUserBackpackManager().getAreaEffectEntityId(), loc);
|
|
||||||
PacketManager.sendRidingPacket(user.getUserBackpackManager().getAreaEffectEntityId(), user.getUserBackpackManager().getFirstArmorStandId(), loc);
|
|
||||||
} else {
|
|
||||||
PacketManager.sendRidingPacket(player.getEntityId(), user.getUserBackpackManager().getFirstArmorStandId(), loc);
|
|
||||||
}
|
|
||||||
|
|
||||||
user.getUserBackpackManager().getArmorStand().setRotation(loc.getYaw(), loc.getPitch());
|
|
||||||
user.getUserBackpackManager().showBackpack();
|
user.getUserBackpackManager().showBackpack();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getModelName() {
|
public boolean isFirstPersonCompadible() {
|
||||||
return modelName;
|
return firstPersonBackpack != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public UserBackpackManager.BackpackType getBackpackType() {
|
public ItemStack getFirstPersonBackpack() {
|
||||||
return backpackType;
|
return firstPersonBackpack;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,11 +2,14 @@ package com.hibiscusmc.hmccosmetics.cosmetic.types;
|
|||||||
|
|
||||||
import com.hibiscusmc.hmccosmetics.config.Settings;
|
import com.hibiscusmc.hmccosmetics.config.Settings;
|
||||||
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
|
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
|
||||||
import com.hibiscusmc.hmccosmetics.user.manager.UserBalloonManager;
|
|
||||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||||
|
import com.hibiscusmc.hmccosmetics.user.manager.UserBalloonManager;
|
||||||
import com.hibiscusmc.hmccosmetics.util.packets.PacketManager;
|
import com.hibiscusmc.hmccosmetics.util.packets.PacketManager;
|
||||||
|
import lombok.Getter;
|
||||||
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.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;
|
||||||
@@ -17,17 +20,27 @@ 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;
|
||||||
private boolean showLead;
|
@Getter
|
||||||
|
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);
|
||||||
@@ -36,16 +49,16 @@ public class CosmeticBalloonType extends Cosmetic {
|
|||||||
// Seriously?
|
// Seriously?
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
|
if (modelId != null) modelId = modelId.toLowerCase(); // ME only accepts lowercase
|
||||||
this.modelName = modelId;
|
this.modelName = modelId;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update(@NotNull CosmeticUser user) {
|
public void update(@NotNull CosmeticUser user) {
|
||||||
Player player = Bukkit.getPlayer(user.getUniqueId());
|
Entity entity = Bukkit.getEntity(user.getUniqueId());
|
||||||
UserBalloonManager userBalloonManager = user.getBalloonManager();
|
UserBalloonManager userBalloonManager = user.getBalloonManager();
|
||||||
|
|
||||||
if (player == null || userBalloonManager == null) return;
|
if (entity == null || userBalloonManager == null) return;
|
||||||
if (user.isInWardrobe()) return;
|
if (user.isInWardrobe()) return;
|
||||||
|
|
||||||
if (!userBalloonManager.getModelEntity().isValid()) {
|
if (!userBalloonManager.getModelEntity().isValid()) {
|
||||||
@@ -53,14 +66,13 @@ public class CosmeticBalloonType extends Cosmetic {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Location newLocation = player.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(player.getLocation());
|
List<Player> viewer = PacketManager.getViewers(entity.getLocation());
|
||||||
viewer.add(player);
|
|
||||||
|
|
||||||
if (player.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);
|
PacketManager.sendTeleportPacket(userBalloonManager.getPufferfishBalloonId(), newLocation, false, viewer);
|
||||||
return;
|
return;
|
||||||
@@ -71,15 +83,17 @@ public class CosmeticBalloonType extends Cosmetic {
|
|||||||
userBalloonManager.setLocation(newLocation);
|
userBalloonManager.setLocation(newLocation);
|
||||||
|
|
||||||
PacketManager.sendTeleportPacket(userBalloonManager.getPufferfishBalloonId(), newLocation, false, viewer);
|
PacketManager.sendTeleportPacket(userBalloonManager.getPufferfishBalloonId(), newLocation, false, viewer);
|
||||||
if (!user.getHidden() && showLead) PacketManager.sendLeashPacket(userBalloonManager.getPufferfishBalloonId(), player.getEntityId(), viewer);
|
PacketManager.sendLeashPacket(userBalloonManager.getPufferfishBalloonId(), entity.getEntityId(), viewer);
|
||||||
}
|
if (user.getHidden()) {
|
||||||
|
userBalloonManager.getPufferfish().hidePufferfish();
|
||||||
public String getModelName() {
|
return;
|
||||||
return this.modelName;
|
}
|
||||||
}
|
if (!user.getHidden() && showLead) {
|
||||||
|
List<Player> sendTo = userBalloonManager.getPufferfish().refreshViewers(newLocation);
|
||||||
public List<String> getDyableParts() {
|
if (sendTo.isEmpty()) return;
|
||||||
return dyableParts;
|
PacketManager.sendEntitySpawnPacket(newLocation, userBalloonManager.getPufferfishBalloonId(), EntityType.PUFFERFISH, userBalloonManager.getPufferfishBalloonUniqueId(), sendTo);
|
||||||
|
PacketManager.sendInvisibilityPacket(userBalloonManager.getPufferfishBalloonId(), sendTo);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isDyablePart(String name) {
|
public boolean isDyablePart(String name) {
|
||||||
@@ -88,8 +102,4 @@ public class CosmeticBalloonType extends Cosmetic {
|
|||||||
if (dyableParts.isEmpty()) return true;
|
if (dyableParts.isEmpty()) return true;
|
||||||
return dyableParts.contains(name);
|
return dyableParts.contains(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isShowLead() {
|
|
||||||
return showLead;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,23 +2,20 @@ package com.hibiscusmc.hmccosmetics.database;
|
|||||||
|
|
||||||
import com.hibiscusmc.hmccosmetics.config.DatabaseSettings;
|
import com.hibiscusmc.hmccosmetics.config.DatabaseSettings;
|
||||||
import com.hibiscusmc.hmccosmetics.database.types.Data;
|
import com.hibiscusmc.hmccosmetics.database.types.Data;
|
||||||
import com.hibiscusmc.hmccosmetics.database.types.InternalData;
|
|
||||||
import com.hibiscusmc.hmccosmetics.database.types.MySQLData;
|
import com.hibiscusmc.hmccosmetics.database.types.MySQLData;
|
||||||
import com.hibiscusmc.hmccosmetics.database.types.SQLiteData;
|
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;
|
||||||
|
|
||||||
@Deprecated
|
|
||||||
private static InternalData INTERNAL_DATA = new InternalData();
|
|
||||||
|
|
||||||
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();
|
||||||
|
|
||||||
@@ -54,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,29 +31,32 @@ 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) {
|
||||||
|
return deserializeData(user, raw, Settings.isForcePermissionJoin());
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
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, boolean permissionCheck) {
|
||||||
Map<CosmeticSlot, Map<Cosmetic, Color>> cosmetics = new HashMap<>();
|
Map<CosmeticSlot, Map<Cosmetic, Color>> cosmetics = new HashMap<>();
|
||||||
boolean checkPermission = Settings.getForcePermissionJoin();
|
|
||||||
|
|
||||||
String[] rawData = raw.split(",");
|
String[] rawData = raw.split(",");
|
||||||
for (String a : rawData) {
|
for (String a : rawData) {
|
||||||
@@ -64,6 +67,7 @@ public abstract class Data {
|
|||||||
MessagesUtil.sendDebugMessages("First split (suppose slot) " + splitData[0]);
|
MessagesUtil.sendDebugMessages("First split (suppose slot) " + splitData[0]);
|
||||||
if (splitData[0].equalsIgnoreCase("HIDDEN")) {
|
if (splitData[0].equalsIgnoreCase("HIDDEN")) {
|
||||||
if (EnumUtils.isValidEnum(CosmeticUser.HiddenReason.class, splitData[1])) {
|
if (EnumUtils.isValidEnum(CosmeticUser.HiddenReason.class, splitData[1])) {
|
||||||
|
if (Settings.isForceShowOnJoin()) continue;
|
||||||
Bukkit.getScheduler().runTask(HMCCosmeticsPlugin.getInstance(), () -> {
|
Bukkit.getScheduler().runTask(HMCCosmeticsPlugin.getInstance(), () -> {
|
||||||
user.hideCosmetics(CosmeticUser.HiddenReason.valueOf(splitData[1]));
|
user.hideCosmetics(CosmeticUser.HiddenReason.valueOf(splitData[1]));
|
||||||
});
|
});
|
||||||
@@ -75,8 +79,8 @@ public abstract class Data {
|
|||||||
String[] colorSplitData = splitData[1].split("&");
|
String[] colorSplitData = splitData[1].split("&");
|
||||||
if (Cosmetics.hasCosmetic(colorSplitData[0])) cosmetic = Cosmetics.getCosmetic(colorSplitData[0]);
|
if (Cosmetics.hasCosmetic(colorSplitData[0])) cosmetic = Cosmetics.getCosmetic(colorSplitData[0]);
|
||||||
if (slot == null || cosmetic == null) continue;
|
if (slot == null || cosmetic == null) continue;
|
||||||
if (cosmetic.requiresPermission() && checkPermission) {
|
if (permissionCheck && cosmetic.requiresPermission()) {
|
||||||
if (!user.getPlayer().hasPermission(cosmetic.getPermission())) {
|
if (user.getPlayer() != null && !user.getPlayer().hasPermission(cosmetic.getPermission())) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -84,8 +88,8 @@ public abstract class Data {
|
|||||||
} else {
|
} else {
|
||||||
if (Cosmetics.hasCosmetic(splitData[1])) cosmetic = Cosmetics.getCosmetic(splitData[1]);
|
if (Cosmetics.hasCosmetic(splitData[1])) cosmetic = Cosmetics.getCosmetic(splitData[1]);
|
||||||
if (slot == null || cosmetic == null) continue;
|
if (slot == null || cosmetic == null) continue;
|
||||||
if (cosmetic.requiresPermission() && checkPermission) {
|
if (permissionCheck && cosmetic.requiresPermission()) {
|
||||||
if (!user.getPlayer().hasPermission(cosmetic.getPermission())) {
|
if (user.getPlayer() != null && !user.getPlayer().hasPermission(cosmetic.getPermission())) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -97,7 +101,7 @@ 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 -> {
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -1,66 +0,0 @@
|
|||||||
package com.hibiscusmc.hmccosmetics.database.types;
|
|
||||||
|
|
||||||
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
|
|
||||||
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
|
|
||||||
import com.hibiscusmc.hmccosmetics.cosmetic.CosmeticSlot;
|
|
||||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.Color;
|
|
||||||
import org.bukkit.NamespacedKey;
|
|
||||||
import org.bukkit.OfflinePlayer;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.persistence.PersistentDataType;
|
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
@Deprecated
|
|
||||||
public class InternalData extends Data {
|
|
||||||
|
|
||||||
NamespacedKey key = new NamespacedKey(HMCCosmeticsPlugin.getInstance(), "cosmetics");
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setup() {
|
|
||||||
// Nothing
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void save(CosmeticUser user) {
|
|
||||||
Player player = Bukkit.getPlayer(user.getUniqueId());
|
|
||||||
|
|
||||||
player.getPersistentDataContainer().set(key, PersistentDataType.STRING, serializeData(user));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public CosmeticUser get(UUID uniqueId) {
|
|
||||||
Player player = Bukkit.getPlayer(uniqueId);
|
|
||||||
CosmeticUser user = new CosmeticUser(uniqueId);
|
|
||||||
|
|
||||||
if (!player.getPersistentDataContainer().has(key, PersistentDataType.STRING)) return user;
|
|
||||||
String rawData = player.getPersistentDataContainer().get(key, PersistentDataType.STRING);
|
|
||||||
|
|
||||||
Map<CosmeticSlot, Map<Cosmetic, Color>> a = deserializeData(user, rawData);
|
|
||||||
for (Map<Cosmetic, Color> cosmeticColors : a.values()) {
|
|
||||||
for (Cosmetic cosmetic : cosmeticColors.keySet()) {
|
|
||||||
Bukkit.getScheduler().runTask(HMCCosmeticsPlugin.getInstance(), () -> {
|
|
||||||
// This can not be async.
|
|
||||||
user.addPlayerCosmetic(cosmetic, cosmeticColors.get(cosmetic));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return user;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void clear(UUID uniqueId) {
|
|
||||||
OfflinePlayer player = Bukkit.getOfflinePlayer(uniqueId);
|
|
||||||
|
|
||||||
if (player.isOnline()) {
|
|
||||||
Player onlinePlayer = player.getPlayer();
|
|
||||||
if (onlinePlayer.getPersistentDataContainer().has(key, PersistentDataType.STRING)) {
|
|
||||||
onlinePlayer.getPersistentDataContainer().remove(key);
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -2,11 +2,15 @@ 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;
|
||||||
|
|
||||||
import java.sql.*;
|
import java.sql.Connection;
|
||||||
|
import java.sql.DriverManager;
|
||||||
|
import java.sql.PreparedStatement;
|
||||||
|
import java.sql.SQLException;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
@@ -123,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");
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ import java.util.UUID;
|
|||||||
|
|
||||||
public abstract class SQLData extends Data {
|
public abstract class SQLData extends Data {
|
||||||
@Override
|
@Override
|
||||||
@SuppressWarnings({"Duplicates", "resource"}) // Duplicate is from deprecated InternalData
|
@SuppressWarnings({"resource"}) // Duplicate is from deprecated InternalData
|
||||||
public CosmeticUser get(UUID uniqueId) {
|
public CosmeticUser get(UUID uniqueId) {
|
||||||
CosmeticUser user = new CosmeticUser(uniqueId);
|
CosmeticUser user = new CosmeticUser(uniqueId);
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,10 @@ import org.bukkit.Bukkit;
|
|||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.sql.*;
|
import java.sql.Connection;
|
||||||
|
import java.sql.DriverManager;
|
||||||
|
import java.sql.PreparedStatement;
|
||||||
|
import java.sql.SQLException;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
@@ -71,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);
|
||||||
}
|
}
|
||||||
@@ -80,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);
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ import java.util.Set;
|
|||||||
*/
|
*/
|
||||||
@SuppressWarnings("SpellCheckingInspection")
|
@SuppressWarnings("SpellCheckingInspection")
|
||||||
public class EmoteManager {
|
public class EmoteManager {
|
||||||
private static final @NotNull Map<@NotNull String, @NotNull String> emotes = new HashMap<>();
|
private static final @NotNull Map<String, String> emotes = new HashMap<>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Loads all BlockBench animations from the emotes folder and puts it into the animation manager registry and local registry
|
* Loads all BlockBench animations from the emotes folder and puts it into the animation manager registry and local registry
|
||||||
|
|||||||
@@ -1,17 +1,22 @@
|
|||||||
package com.hibiscusmc.hmccosmetics.gui;
|
package com.hibiscusmc.hmccosmetics.gui;
|
||||||
|
|
||||||
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
|
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
|
||||||
import com.hibiscusmc.hmccosmetics.api.PlayerMenuOpenEvent;
|
import com.hibiscusmc.hmccosmetics.api.events.PlayerMenuOpenEvent;
|
||||||
|
import com.hibiscusmc.hmccosmetics.config.Settings;
|
||||||
import com.hibiscusmc.hmccosmetics.config.serializer.ItemSerializer;
|
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.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 com.hibiscusmc.hmccosmetics.util.misc.Adventure;
|
||||||
import com.hibiscusmc.hmccosmetics.util.misc.Placeholder;
|
import com.hibiscusmc.hmccosmetics.util.misc.StringUtils;
|
||||||
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 net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@@ -23,15 +28,27 @@ import org.spongepowered.configurate.ConfigurationNode;
|
|||||||
import org.spongepowered.configurate.serialize.SerializationException;
|
import org.spongepowered.configurate.serialize.SerializationException;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
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 HashMap<Integer, MenuItem> items;
|
||||||
|
@Getter
|
||||||
|
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;
|
||||||
@@ -40,69 +57,16 @@ public class Menu {
|
|||||||
title = config.node("title").getString("chest");
|
title = config.node("title").getString("chest");
|
||||||
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);
|
||||||
|
shading = config.node("shading").getBoolean(Settings.isDefaultShading());
|
||||||
|
|
||||||
|
items = new HashMap<>();
|
||||||
|
setupItems();
|
||||||
|
|
||||||
Menus.addMenu(this);
|
Menus.addMenu(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getId() {
|
private void setupItems() {
|
||||||
return id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getTitle() {
|
|
||||||
return this.title;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getRows() {
|
|
||||||
return this.getRows();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void openMenu(CosmeticUser user) {
|
|
||||||
openMenu(user, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void openMenu(@NotNull CosmeticUser user, boolean ignorePermission) {
|
|
||||||
Player player = user.getPlayer();
|
|
||||||
if (player == null) return;
|
|
||||||
if (!ignorePermission && !permissionNode.isEmpty()) {
|
|
||||||
if (!player.hasPermission(permissionNode) && !player.isOp()) {
|
|
||||||
MessagesUtil.sendMessage(player, "no-permission");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
final Component component = Adventure.MINI_MESSAGE.deserialize(Placeholder.applyPapiPlaceholders(player, this.title));
|
|
||||||
Gui gui = Gui.gui().
|
|
||||||
title(component).
|
|
||||||
rows(this.rows).
|
|
||||||
create();
|
|
||||||
|
|
||||||
gui.setDefaultClickAction(event -> event.setCancelled(true));
|
|
||||||
|
|
||||||
gui = getItems(user, gui);
|
|
||||||
|
|
||||||
Gui finalGui = gui;
|
|
||||||
|
|
||||||
PlayerMenuOpenEvent event = new PlayerMenuOpenEvent(user, this);
|
|
||||||
|
|
||||||
Bukkit.getScheduler().runTask(HMCCosmeticsPlugin.getInstance(), () -> {
|
|
||||||
Bukkit.getPluginManager().callEvent(event);
|
|
||||||
});
|
|
||||||
|
|
||||||
if (event.isCancelled()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Bukkit.getScheduler().runTask(HMCCosmeticsPlugin.getInstance(), () -> {
|
|
||||||
finalGui.open(player);
|
|
||||||
});
|
|
||||||
|
|
||||||
//gui.open(player);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Contract("_, _ -> param2")
|
|
||||||
private Gui getItems(@NotNull CosmeticUser user, Gui gui) {
|
|
||||||
Player player = user.getPlayer();
|
|
||||||
|
|
||||||
for (ConfigurationNode config : config.node("items").childrenMap().values()) {
|
for (ConfigurationNode config : config.node("items").childrenMap().values()) {
|
||||||
|
|
||||||
List<String> slotString;
|
List<String> slotString;
|
||||||
@@ -118,8 +82,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;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -131,38 +95,147 @@ 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int slot : slots) {
|
for (Integer slot : slots) {
|
||||||
ItemStack modifiedItem = getMenuItem(user, type, config, item.clone(), slot).clone();
|
items.put(slot, new MenuItem(slots, item, type, config));
|
||||||
GuiItem guiItem = ItemBuilder.from(modifiedItem).asGuiItem();
|
|
||||||
|
|
||||||
Type finalType = type;
|
|
||||||
guiItem.setAction(event -> {
|
|
||||||
MessagesUtil.sendDebugMessages("Selected slot " + slot);
|
|
||||||
final ClickType clickType = event.getClick();
|
|
||||||
if (finalType != null) finalType.run(user, config, clickType);
|
|
||||||
// Need to delay the update by a tick so it will actually update with new values
|
|
||||||
for (int guiSlot : slots) {
|
|
||||||
gui.updateItem(guiSlot, getMenuItem(user, finalType, config, item.clone(), guiSlot));
|
|
||||||
}
|
|
||||||
MessagesUtil.sendDebugMessages("Updated slot " + slot);
|
|
||||||
});
|
|
||||||
|
|
||||||
MessagesUtil.sendDebugMessages("Added " + slots + " as " + guiItem + " in the menu");
|
|
||||||
gui.setItem(slot, guiItem);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return gui;
|
}
|
||||||
|
|
||||||
|
public void openMenu(CosmeticUser user) {
|
||||||
|
openMenu(user, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void openMenu(@NotNull CosmeticUser user, boolean ignorePermission) {
|
||||||
|
Player player = user.getPlayer();
|
||||||
|
if (player == null) return;
|
||||||
|
if (!ignorePermission && !permissionNode.isEmpty()) {
|
||||||
|
if (!player.hasPermission(permissionNode) && !player.isOp()) {
|
||||||
|
MessagesUtil.sendMessage(player, "no-permission");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
final Component component = Adventure.MINI_MESSAGE.deserialize(Hooks.processPlaceholders(player, this.title));
|
||||||
|
Gui gui = Gui.gui()
|
||||||
|
.title(component)
|
||||||
|
.rows(this.rows)
|
||||||
|
.create();
|
||||||
|
|
||||||
|
gui.setDefaultClickAction(event -> event.setCancelled(true));
|
||||||
|
|
||||||
|
AtomicInteger taskid = new AtomicInteger(-1);
|
||||||
|
gui.setOpenGuiAction(event -> {
|
||||||
|
Runnable run = () -> {
|
||||||
|
if (gui.getInventory().getViewers().isEmpty() && taskid.get() != -1) {
|
||||||
|
Bukkit.getScheduler().cancelTask(taskid.get());
|
||||||
|
}
|
||||||
|
|
||||||
|
updateMenu(user, gui);
|
||||||
|
};
|
||||||
|
|
||||||
|
if (refreshRate != -1) {
|
||||||
|
taskid.set(Bukkit.getScheduler().scheduleSyncRepeatingTask(HMCCosmeticsPlugin.getInstance(), run, 0, refreshRate));
|
||||||
|
} else {
|
||||||
|
run.run();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
gui.setCloseGuiAction(event -> {
|
||||||
|
if (taskid.get() != -1) Bukkit.getScheduler().cancelTask(taskid.get());
|
||||||
|
});
|
||||||
|
|
||||||
|
// API
|
||||||
|
PlayerMenuOpenEvent event = new PlayerMenuOpenEvent(user, this);
|
||||||
|
Bukkit.getScheduler().runTask(HMCCosmeticsPlugin.getInstance(), () -> Bukkit.getPluginManager().callEvent(event));
|
||||||
|
if (event.isCancelled()) return;
|
||||||
|
// Internal
|
||||||
|
|
||||||
|
Bukkit.getScheduler().runTask(HMCCosmeticsPlugin.getInstance(), () -> {
|
||||||
|
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) {
|
||||||
|
StringBuilder title = new StringBuilder(this.title);
|
||||||
|
|
||||||
|
int row = 0;
|
||||||
|
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
|
||||||
|
MenuItem item = items.get(i);
|
||||||
|
updateItem(user, gui, item);
|
||||||
|
|
||||||
|
if (item.type().getId().equalsIgnoreCase("cosmetic")) {
|
||||||
|
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 (MenuItem item : items.values()) {
|
||||||
|
updateItem(user, gui, item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateItem(CosmeticUser user, Gui gui, MenuItem item) {
|
||||||
|
Type type = item.type();
|
||||||
|
for (int slot : item.slots()) {
|
||||||
|
ItemStack modifiedItem = getMenuItem(user, type, item.itemConfig(), item.item().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.itemConfig(), clickType);
|
||||||
|
updateMenu(user, gui);
|
||||||
|
});
|
||||||
|
|
||||||
|
MessagesUtil.sendDebugMessages("Added " + slot + " as " + guiItem + " in the menu");
|
||||||
|
gui.updateItem(slot, guiItem);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@@ -172,8 +245,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));
|
||||||
@@ -191,17 +264,13 @@ 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);
|
||||||
|
|||||||
@@ -0,0 +1,11 @@
|
|||||||
|
package com.hibiscusmc.hmccosmetics.gui;
|
||||||
|
|
||||||
|
import com.hibiscusmc.hmccosmetics.gui.type.Type;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.spongepowered.configurate.ConfigurationNode;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public record MenuItem(List<Integer> slots, ItemStack item, Type type, ConfigurationNode itemConfig) {
|
||||||
|
|
||||||
|
}
|
||||||
@@ -11,11 +11,14 @@ import org.spongepowered.configurate.ConfigurateException;
|
|||||||
import org.spongepowered.configurate.yaml.YamlConfigurationLoader;
|
import org.spongepowered.configurate.yaml.YamlConfigurationLoader;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Path;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
public class Menus {
|
public class Menus {
|
||||||
|
|
||||||
@@ -66,27 +69,29 @@ public class Menus {
|
|||||||
File cosmeticFolder = new File(HMCCosmeticsPlugin.getInstance().getDataFolder() + "/menus");
|
File cosmeticFolder = new File(HMCCosmeticsPlugin.getInstance().getDataFolder() + "/menus");
|
||||||
if (!cosmeticFolder.exists()) cosmeticFolder.mkdir();
|
if (!cosmeticFolder.exists()) cosmeticFolder.mkdir();
|
||||||
|
|
||||||
File[] directoryListing = cosmeticFolder.listFiles();
|
// Recursive file lookup
|
||||||
if (directoryListing == null) return;
|
try (Stream<Path> walkStream = Files.walk(cosmeticFolder.toPath())) {
|
||||||
|
walkStream.filter(p -> p.toFile().isFile()).forEach(child -> {
|
||||||
for (File child : directoryListing) {
|
if (child.toString().endsWith("yml") || child.toString().endsWith("yaml")) {
|
||||||
if (child.toString().contains(".yml") || child.toString().contains(".yaml")) {
|
MessagesUtil.sendDebugMessages("Scanning " + child);
|
||||||
MessagesUtil.sendDebugMessages("Scanning " + child);
|
// Loads file
|
||||||
// Loads file
|
YamlConfigurationLoader loader = YamlConfigurationLoader.builder().path(child).build();
|
||||||
YamlConfigurationLoader loader = YamlConfigurationLoader.builder().path(child.toPath()).build();
|
CommentedConfigurationNode root;
|
||||||
CommentedConfigurationNode root;
|
try {
|
||||||
try {
|
root = loader.load();
|
||||||
root = loader.load();
|
} catch (ConfigurateException e) {
|
||||||
} catch (ConfigurateException e) {
|
throw new RuntimeException(e);
|
||||||
throw new RuntimeException(e);
|
}
|
||||||
|
try {
|
||||||
|
new Menu(FilenameUtils.removeExtension(child.getFileName().toString()), root);
|
||||||
|
} catch (Exception e) {
|
||||||
|
MessagesUtil.sendDebugMessages("Unable to create menu in " + child.getFileName().toString(), Level.WARNING);
|
||||||
|
if (Settings.isDebugMode()) e.printStackTrace();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
try {
|
});
|
||||||
new Menu(FilenameUtils.removeExtension(child.getName()), root);
|
} catch (Exception e) {
|
||||||
} catch (Exception e) {
|
e.printStackTrace();
|
||||||
MessagesUtil.sendDebugMessages("Unable to create menu in " + child, Level.WARNING);
|
|
||||||
if (Settings.isDebugEnabled()) e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,9 @@ 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.hooks.Hooks;
|
||||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||||
|
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));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
package com.hibiscusmc.hmccosmetics.gui.action.actions;
|
package com.hibiscusmc.hmccosmetics.gui.action.actions;
|
||||||
|
|
||||||
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
|
|
||||||
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.gui.action.Action;
|
import com.hibiscusmc.hmccosmetics.gui.action.Action;
|
||||||
|
|||||||
@@ -1,14 +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.hooks.Hooks;
|
||||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||||
import com.hibiscusmc.hmccosmetics.util.misc.Placeholder;
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Color;
|
import org.bukkit.Color;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
@@ -33,7 +32,7 @@ public class DyeMenu {
|
|||||||
if (originalItem == null || !cosmetic.isDyable()) return;
|
if (originalItem == null || !cosmetic.isDyable()) return;
|
||||||
|
|
||||||
Gui gui = HMCColorApi.INSTANCE.colorMenu();
|
Gui gui = HMCColorApi.INSTANCE.colorMenu();
|
||||||
gui.updateTitle(Placeholder.applyPapiPlaceholders(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 -> {
|
||||||
if (event.getSlot() == Settings.getDyeMenuOutputSlot()) {
|
if (event.getSlot() == Settings.getDyeMenuOutputSlot()) {
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ package com.hibiscusmc.hmccosmetics.gui.type;
|
|||||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||||
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.spongepowered.configurate.ConfigurationNode;
|
import org.spongepowered.configurate.ConfigurationNode;
|
||||||
|
|
||||||
public abstract class Type {
|
public abstract class Type {
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package com.hibiscusmc.hmccosmetics.gui.type.types;
|
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.serializer.ItemSerializer;
|
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;
|
||||||
@@ -11,9 +12,6 @@ import com.hibiscusmc.hmccosmetics.gui.type.Type;
|
|||||||
import com.hibiscusmc.hmccosmetics.hooks.Hooks;
|
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 com.hibiscusmc.hmccosmetics.util.misc.StringUtils;
|
|
||||||
import com.hibiscusmc.hmccosmetics.util.misc.Utils;
|
|
||||||
import me.clip.placeholderapi.PlaceholderAPI;
|
|
||||||
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;
|
||||||
@@ -25,10 +23,8 @@ import org.jetbrains.annotations.NotNull;
|
|||||||
import org.spongepowered.configurate.ConfigurationNode;
|
import org.spongepowered.configurate.ConfigurationNode;
|
||||||
import org.spongepowered.configurate.serialize.SerializationException;
|
import org.spongepowered.configurate.serialize.SerializationException;
|
||||||
|
|
||||||
import java.lang.invoke.TypeDescriptor;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
public class TypeCosmetic extends Type {
|
public class TypeCosmetic extends Type {
|
||||||
|
|
||||||
@@ -38,23 +34,45 @@ public class TypeCosmetic extends Type {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run(CosmeticUser user, @NotNull ConfigurationNode config, ClickType clickType) {
|
public void run(CosmeticUser user, @NotNull ConfigurationNode config, ClickType clickType) {
|
||||||
if (config.node("cosmetic").virtual()) return;
|
MessagesUtil.sendDebugMessages("Running Cosmetic Click Type");
|
||||||
|
if (config.node("cosmetic").virtual()) {
|
||||||
|
MessagesUtil.sendDebugMessages("Cosmetic Config Field Virtual");
|
||||||
|
return;
|
||||||
|
}
|
||||||
String cosmeticName = config.node("cosmetic").getString();
|
String cosmeticName = config.node("cosmetic").getString();
|
||||||
Cosmetic cosmetic = Cosmetics.getCosmetic(cosmeticName);
|
Cosmetic cosmetic = Cosmetics.getCosmetic(cosmeticName);
|
||||||
Player player = user.getPlayer();
|
Player player = user.getPlayer();
|
||||||
if (cosmetic == null) {
|
if (cosmetic == null) {
|
||||||
|
MessagesUtil.sendDebugMessages("No Cosmetic Found");
|
||||||
MessagesUtil.sendMessage(player, "invalid-cosmetic");
|
MessagesUtil.sendMessage(player, "invalid-cosmetic");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!user.canEquipCosmetic(cosmetic)) {
|
if (!user.canEquipCosmetic(cosmetic)) {
|
||||||
|
MessagesUtil.sendDebugMessages("No Cosmetic Permission");
|
||||||
MessagesUtil.sendMessage(player, "no-cosmetic-permission");
|
MessagesUtil.sendMessage(player, "no-cosmetic-permission");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
boolean isUnEquippingCosmetic = false;
|
||||||
|
if (user.getCosmetic(cosmetic.getSlot()) == cosmetic) isUnEquippingCosmetic = true;
|
||||||
|
|
||||||
|
String requiredClick;
|
||||||
|
if (isUnEquippingCosmetic) requiredClick = Settings.getCosmeticUnEquipClickType();
|
||||||
|
else requiredClick = Settings.getCosmeticEquipClickType();
|
||||||
|
|
||||||
|
MessagesUtil.sendDebugMessages("Required click type: " + requiredClick);
|
||||||
|
MessagesUtil.sendDebugMessages("Click type: " + clickType.name());
|
||||||
|
if (!requiredClick.equalsIgnoreCase("ANY") && !requiredClick.equalsIgnoreCase(clickType.name())) {
|
||||||
|
MessagesUtil.sendMessage(user.getPlayer(), "invalid-click-type");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
List<String> actionStrings = new ArrayList<>();
|
List<String> actionStrings = new ArrayList<>();
|
||||||
ConfigurationNode actionConfig = config.node("actions");
|
ConfigurationNode actionConfig = config.node("actions");
|
||||||
|
|
||||||
|
MessagesUtil.sendDebugMessages("Running Actions");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (!actionConfig.node("any").virtual()) actionStrings.addAll(actionConfig.node("any").getList(String.class));
|
if (!actionConfig.node("any").virtual()) actionStrings.addAll(actionConfig.node("any").getList(String.class));
|
||||||
|
|
||||||
@@ -65,9 +83,15 @@ 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 (user.getCosmetic(cosmetic.getSlot()) == cosmetic) {
|
if (isUnEquippingCosmetic) {
|
||||||
if (!actionConfig.node("on-unequip").virtual()) actionStrings.addAll(actionConfig.node("on-unequip").getList(String.class));
|
if (!actionConfig.node("on-unequip").virtual()) actionStrings.addAll(actionConfig.node("on-unequip").getList(String.class));
|
||||||
MessagesUtil.sendDebugMessages("on-unequip");
|
MessagesUtil.sendDebugMessages("on-unequip");
|
||||||
user.removeCosmeticSlot(cosmetic);
|
user.removeCosmeticSlot(cosmetic);
|
||||||
@@ -85,7 +109,7 @@ public class TypeCosmetic extends Type {
|
|||||||
Actions.runActions(user, actionStrings);
|
Actions.runActions(user, actionStrings);
|
||||||
|
|
||||||
} catch (SerializationException e) {
|
} catch (SerializationException e) {
|
||||||
throw new RuntimeException(e);
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
// Fixes issue with offhand cosmetics not appearing. Yes, I know this is dumb
|
// Fixes issue with offhand cosmetics not appearing. Yes, I know this is dumb
|
||||||
Runnable run = () -> user.updateCosmetic(cosmetic.getSlot());
|
Runnable run = () -> user.updateCosmetic(cosmetic.getSlot());
|
||||||
@@ -95,6 +119,7 @@ public class TypeCosmetic extends Type {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
run.run();
|
run.run();
|
||||||
|
MessagesUtil.sendDebugMessages("Finished Type Click Run");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -152,10 +177,13 @@ public class TypeCosmetic extends Type {
|
|||||||
private ItemMeta processLoreLines(CosmeticUser user, @NotNull ItemMeta itemMeta) {
|
private ItemMeta processLoreLines(CosmeticUser user, @NotNull ItemMeta itemMeta) {
|
||||||
List<String> processedLore = new ArrayList<>();
|
List<String> processedLore = new ArrayList<>();
|
||||||
|
|
||||||
|
if (itemMeta.hasDisplayName()) {
|
||||||
|
itemMeta.setDisplayName(Hooks.processPlaceholders(user.getPlayer(), itemMeta.getDisplayName()));
|
||||||
|
}
|
||||||
|
|
||||||
if (itemMeta.hasLore()) {
|
if (itemMeta.hasLore()) {
|
||||||
for (String loreLine : itemMeta.getLore()) {
|
for (String loreLine : itemMeta.getLore()) {
|
||||||
if (Hooks.isActiveHook("PlaceholderAPI")) loreLine = PlaceholderAPI.setPlaceholders(user.getPlayer(), loreLine);
|
processedLore.add(Hooks.processPlaceholders(user.getPlayer(), loreLine));
|
||||||
processedLore.add(loreLine);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
itemMeta.setLore(processedLore);
|
itemMeta.setLore(processedLore);
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ 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.hooks.Hooks;
|
||||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||||
import me.clip.placeholderapi.PlaceholderAPI;
|
|
||||||
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;
|
||||||
@@ -43,6 +42,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.
|
||||||
@@ -58,11 +63,13 @@ public class TypeEmpty extends Type {
|
|||||||
List<String> processedLore = new ArrayList<>();
|
List<String> processedLore = new ArrayList<>();
|
||||||
ItemMeta itemMeta = itemStack.getItemMeta();
|
ItemMeta itemMeta = itemStack.getItemMeta();
|
||||||
|
|
||||||
|
if (itemMeta.hasDisplayName()) {
|
||||||
|
itemMeta.setDisplayName(Hooks.processPlaceholders(user.getPlayer(), itemMeta.getDisplayName()));
|
||||||
|
}
|
||||||
|
|
||||||
if (itemMeta.hasLore()) {
|
if (itemMeta.hasLore()) {
|
||||||
for (String loreLine : itemMeta.getLore()) {
|
for (String loreLine : itemMeta.getLore()) {
|
||||||
if (Hooks.isActiveHook("PlaceholderAPI"))
|
processedLore.add(Hooks.processPlaceholders(user.getPlayer(), loreLine));
|
||||||
loreLine = PlaceholderAPI.setPlaceholders(user.getPlayer(), loreLine);
|
|
||||||
processedLore.add(loreLine);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
itemStack.setItemMeta(itemMeta);
|
itemStack.setItemMeta(itemMeta);
|
||||||
|
|||||||
@@ -4,8 +4,10 @@ import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
|
|||||||
import com.hibiscusmc.hmccosmetics.hooks.items.*;
|
import com.hibiscusmc.hmccosmetics.hooks.items.*;
|
||||||
import com.hibiscusmc.hmccosmetics.hooks.misc.*;
|
import com.hibiscusmc.hmccosmetics.hooks.misc.*;
|
||||||
import com.hibiscusmc.hmccosmetics.hooks.placeholders.HookPlaceholderAPI;
|
import com.hibiscusmc.hmccosmetics.hooks.placeholders.HookPlaceholderAPI;
|
||||||
|
import me.clip.placeholderapi.PlaceholderAPI;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.OfflinePlayer;
|
||||||
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;
|
||||||
@@ -15,18 +17,19 @@ import java.util.HashMap;
|
|||||||
public class Hooks {
|
public class Hooks {
|
||||||
|
|
||||||
private static final HashMap<String, Hook> hooks = new HashMap<>();
|
private static final HashMap<String, Hook> hooks = new HashMap<>();
|
||||||
private static HookOraxen ORAXEN_HOOK = new HookOraxen();
|
private static final HookOraxen ORAXEN_HOOK = new HookOraxen();
|
||||||
private static HookItemAdder ITEMADDER_HOOK = new HookItemAdder();
|
private static final HookItemAdder ITEMADDER_HOOK = new HookItemAdder();
|
||||||
private static HookGeary GEARY_HOOK = new HookGeary();
|
private static final HookGeary GEARY_HOOK = new HookGeary();
|
||||||
private static HookMythic MYTHIC_HOOK = new HookMythic();
|
private static final HookMythic MYTHIC_HOOK = new HookMythic();
|
||||||
private static HookDenizen DENIZEN_HOOK = new HookDenizen();
|
private static final HookDenizen DENIZEN_HOOK = new HookDenizen();
|
||||||
private static HookHMCCosmetics HMCCOSMETIC_HOOK = new HookHMCCosmetics();
|
private static final HookHMCCosmetics HMCCOSMETIC_HOOK = new HookHMCCosmetics();
|
||||||
private static HookPlaceholderAPI PAPI_HOOK = new HookPlaceholderAPI();
|
private static final HookPlaceholderAPI PAPI_HOOK = new HookPlaceholderAPI();
|
||||||
private static HookPremiumVanish PREMIUM_VANISH_HOOK = new HookPremiumVanish();
|
private static final HookPremiumVanish PREMIUM_VANISH_HOOK = new HookPremiumVanish();
|
||||||
private static HookSuperVanish SUPER_VANISH_HOOK = new HookSuperVanish();
|
private static final HookSuperVanish SUPER_VANISH_HOOK = new HookSuperVanish();
|
||||||
private static HookHMCColor HMC_COLOR_HOOK = new HookHMCColor();
|
private static final HookHMCColor HMC_COLOR_HOOK = new HookHMCColor();
|
||||||
private static HookCMI CMI_HOOK = new HookCMI();
|
private static final HookCMI CMI_HOOK = new HookCMI();
|
||||||
private static HookLibsDisguises LIBS_DISGUISES_HOOK = new HookLibsDisguises();
|
private static final HookLibsDisguises LIBS_DISGUISES_HOOK = new HookLibsDisguises();
|
||||||
|
private static final HookModelEngine MODEL_ENGINE_HOOK = new HookModelEngine();
|
||||||
|
|
||||||
public static Hook getHook(@NotNull String id) {
|
public static Hook getHook(@NotNull String id) {
|
||||||
return hooks.get(id.toLowerCase());
|
return hooks.get(id.toLowerCase());
|
||||||
@@ -70,6 +73,12 @@ public class Hooks {
|
|||||||
return hook.getItem(split[1]);
|
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) {
|
public static boolean isActiveHook(String id) {
|
||||||
Hook hook = getHook(id);
|
Hook hook = getHook(id);
|
||||||
if (hook == null) return false;
|
if (hook == null) return false;
|
||||||
|
|||||||
@@ -13,7 +13,6 @@ import org.jetbrains.annotations.NotNull;
|
|||||||
/**
|
/**
|
||||||
* A hook that integrates the plugin {@link com.mineinabyss.geary.papermc.GearyPlugin Geary} to provide custom items
|
* A hook that integrates the plugin {@link com.mineinabyss.geary.papermc.GearyPlugin Geary} to provide custom items
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("SpellCheckingInspection")
|
|
||||||
public class HookGeary extends Hook {
|
public class HookGeary extends Hook {
|
||||||
private boolean enabled = false;
|
private boolean enabled = false;
|
||||||
|
|
||||||
@@ -24,7 +23,7 @@ public class HookGeary extends Hook {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void load() {
|
public void load() {
|
||||||
GearyModuleKt.getGeary().getPipeline().intercept(GearyPhase.ENABLE, () -> {
|
if (!enabled) GearyModuleKt.getGeary().getPipeline().intercept(GearyPhase.INIT_ENTITIES, () -> {
|
||||||
enabled = true;
|
enabled = true;
|
||||||
HMCCosmeticsPlugin.setup();
|
HMCCosmeticsPlugin.setup();
|
||||||
return null;
|
return null;
|
||||||
@@ -39,7 +38,7 @@ public class HookGeary extends Hook {
|
|||||||
if (enabled) {
|
if (enabled) {
|
||||||
PrefabKey prefabKey = PrefabKey.Companion.ofOrNull(itemId);
|
PrefabKey prefabKey = PrefabKey.Companion.ofOrNull(itemId);
|
||||||
if (prefabKey == null) return null;
|
if (prefabKey == null) return null;
|
||||||
return ItemTrackingKt.getItemTracking().createItem(prefabKey, null);
|
return ItemTrackingKt.getGearyItems().createItem(prefabKey, null);
|
||||||
} else return new ItemStack(Material.AIR);
|
} else return new ItemStack(Material.AIR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import dev.lone.itemsadder.api.CustomStack;
|
|||||||
import dev.lone.itemsadder.api.Events.ItemsAdderLoadDataEvent;
|
import dev.lone.itemsadder.api.Events.ItemsAdderLoadDataEvent;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.EventPriority;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
@@ -36,10 +37,10 @@ public class HookItemAdder extends Hook {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler(priority = EventPriority.MONITOR)
|
||||||
public void onItemAdderDataLoad(ItemsAdderLoadDataEvent event) {
|
public void onItemAdderDataLoad(ItemsAdderLoadDataEvent event) {
|
||||||
// By default, it will only run once at startup, if hook setting is enabled
|
// By default, it will only run once at startup, if hook setting is enabled
|
||||||
if (enabled && !Settings.getItemsAdderReloadChange()) return;
|
if (enabled && !Settings.isItemsAdderChangeReload()) return;
|
||||||
this.enabled = true;
|
this.enabled = true;
|
||||||
HMCCosmeticsPlugin.setup();
|
HMCCosmeticsPlugin.setup();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
|||||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUsers;
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUsers;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.EventPriority;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -17,7 +18,7 @@ public class HookCMI extends Hook {
|
|||||||
super("CMI");
|
super("CMI");
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler(priority = EventPriority.MONITOR)
|
||||||
public void onPlayerVanish(@NotNull CMIPlayerVanishEvent event) {
|
public void onPlayerVanish(@NotNull CMIPlayerVanishEvent event) {
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
CosmeticUser user = CosmeticUsers.getUser(player);
|
CosmeticUser user = CosmeticUsers.getUser(player);
|
||||||
@@ -25,7 +26,7 @@ public class HookCMI extends Hook {
|
|||||||
user.hideCosmetics(CosmeticUser.HiddenReason.PLUGIN);
|
user.hideCosmetics(CosmeticUser.HiddenReason.PLUGIN);
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler(priority = EventPriority.MONITOR)
|
||||||
public void onPlayerShow(@NotNull CMIPlayerUnVanishEvent event) {
|
public void onPlayerShow(@NotNull CMIPlayerUnVanishEvent event) {
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
CosmeticUser user = CosmeticUsers.getUser(player);
|
CosmeticUser user = CosmeticUsers.getUser(player);
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import me.libraryaddict.disguise.events.DisguiseEvent;
|
|||||||
import me.libraryaddict.disguise.events.UndisguiseEvent;
|
import me.libraryaddict.disguise.events.UndisguiseEvent;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.EventPriority;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
public class HookLibsDisguises extends Hook {
|
public class HookLibsDisguises extends Hook {
|
||||||
@@ -14,7 +15,7 @@ public class HookLibsDisguises extends Hook {
|
|||||||
super("LibsDisguises");
|
super("LibsDisguises");
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler(priority = EventPriority.MONITOR)
|
||||||
public void onPlayerVanish(@NotNull DisguiseEvent event) {
|
public void onPlayerVanish(@NotNull DisguiseEvent 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);
|
||||||
@@ -22,7 +23,7 @@ public class HookLibsDisguises extends Hook {
|
|||||||
user.hideCosmetics(CosmeticUser.HiddenReason.PLUGIN);
|
user.hideCosmetics(CosmeticUser.HiddenReason.PLUGIN);
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler(priority = EventPriority.MONITOR)
|
||||||
public void onPlayerShow(@NotNull UndisguiseEvent event) {
|
public void onPlayerShow(@NotNull UndisguiseEvent 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);
|
||||||
|
|||||||
@@ -0,0 +1,10 @@
|
|||||||
|
package com.hibiscusmc.hmccosmetics.hooks.misc;
|
||||||
|
|
||||||
|
import com.hibiscusmc.hmccosmetics.hooks.Hook;
|
||||||
|
|
||||||
|
public class HookModelEngine extends Hook {
|
||||||
|
|
||||||
|
public HookModelEngine() {
|
||||||
|
super("ModelEngine");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -7,6 +7,7 @@ import de.myzelyam.api.vanish.PlayerHideEvent;
|
|||||||
import de.myzelyam.api.vanish.PlayerShowEvent;
|
import de.myzelyam.api.vanish.PlayerShowEvent;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.EventPriority;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -19,7 +20,7 @@ public class HookPremiumVanish extends Hook {
|
|||||||
super("PremiumVanish");
|
super("PremiumVanish");
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler(priority = EventPriority.NORMAL)
|
||||||
public void onPlayerVanish(@NotNull PlayerHideEvent event) {
|
public void onPlayerVanish(@NotNull PlayerHideEvent event) {
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
CosmeticUser user = CosmeticUsers.getUser(player);
|
CosmeticUser user = CosmeticUsers.getUser(player);
|
||||||
@@ -27,7 +28,7 @@ public class HookPremiumVanish extends Hook {
|
|||||||
user.hideCosmetics(CosmeticUser.HiddenReason.PLUGIN);
|
user.hideCosmetics(CosmeticUser.HiddenReason.PLUGIN);
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler(priority = EventPriority.NORMAL)
|
||||||
public void onPlayerShow(@NotNull PlayerShowEvent event) {
|
public void onPlayerShow(@NotNull PlayerShowEvent event) {
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
CosmeticUser user = CosmeticUsers.getUser(player);
|
CosmeticUser user = CosmeticUsers.getUser(player);
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import de.myzelyam.api.vanish.PlayerHideEvent;
|
|||||||
import de.myzelyam.api.vanish.PlayerShowEvent;
|
import de.myzelyam.api.vanish.PlayerShowEvent;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.EventPriority;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -19,7 +20,7 @@ public class HookSuperVanish extends Hook {
|
|||||||
super("SuperVanish");
|
super("SuperVanish");
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler(priority = EventPriority.NORMAL)
|
||||||
public void onPlayerVanish(@NotNull PlayerHideEvent event) {
|
public void onPlayerVanish(@NotNull PlayerHideEvent event) {
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
CosmeticUser user = CosmeticUsers.getUser(player);
|
CosmeticUser user = CosmeticUsers.getUser(player);
|
||||||
@@ -27,7 +28,7 @@ public class HookSuperVanish extends Hook {
|
|||||||
user.hideCosmetics(CosmeticUser.HiddenReason.PLUGIN);
|
user.hideCosmetics(CosmeticUser.HiddenReason.PLUGIN);
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler(priority = EventPriority.NORMAL)
|
||||||
public void onPlayerShow(@NotNull PlayerShowEvent event) {
|
public void onPlayerShow(@NotNull PlayerShowEvent event) {
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
CosmeticUser user = CosmeticUsers.getUser(player);
|
CosmeticUser user = CosmeticUsers.getUser(player);
|
||||||
|
|||||||
@@ -69,9 +69,9 @@ public class HMCPlaceholderExpansion extends PlaceholderExpansion {
|
|||||||
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());
|
||||||
if (currentCosmetic == null) return "false";
|
if (currentCosmetic == null) return TranslationUtil.getTranslation("using-cosmetic", String.valueOf(false)); // I hate this way of handling translations
|
||||||
if (currentCosmetic.getId() == cosmetic.getId()) return "true";
|
if (currentCosmetic.getId() == cosmetic.getId()) return TranslationUtil.getTranslation("using-cosmetic", String.valueOf(true));
|
||||||
return "false";
|
return TranslationUtil.getTranslation("using-cosmetic", String.valueOf(false));
|
||||||
}
|
}
|
||||||
case "current":
|
case "current":
|
||||||
if (placeholderArgs == null) {
|
if (placeholderArgs == null) {
|
||||||
@@ -82,26 +82,29 @@ public class HMCPlaceholderExpansion extends PlaceholderExpansion {
|
|||||||
if (slot == null) return null;
|
if (slot == null) return null;
|
||||||
if (user.getCosmetic(slot) == null) return null;
|
if (user.getCosmetic(slot) == null) return null;
|
||||||
if (placeholderArgs.size() == 2) return user.getCosmetic(slot).getId();
|
if (placeholderArgs.size() == 2) return user.getCosmetic(slot).getId();
|
||||||
|
|
||||||
|
String output;
|
||||||
switch (placeholderArgs.get(2).toLowerCase()) {
|
switch (placeholderArgs.get(2).toLowerCase()) {
|
||||||
case "material" -> {
|
case "material" -> {
|
||||||
return getMaterialName(user.getCosmetic(slot));
|
output = getMaterialName(user.getCosmetic(slot));
|
||||||
}
|
}
|
||||||
case "custommodeldata" -> {
|
case "custommodeldata" -> {
|
||||||
return getModelData(user.getCosmetic(slot));
|
output = getModelData(user.getCosmetic(slot));
|
||||||
}
|
}
|
||||||
case "name" -> {
|
case "name" -> {
|
||||||
return getItemName(user.getCosmetic(slot));
|
output = getItemName(user.getCosmetic(slot));
|
||||||
}
|
}
|
||||||
case "lore" -> {
|
case "lore" -> {
|
||||||
return getItemLore(user.getCosmetic(slot));
|
output = getItemLore(user.getCosmetic(slot));
|
||||||
}
|
}
|
||||||
case "permission" -> {
|
case "permission" -> {
|
||||||
return user.getCosmetic(slot).getPermission();
|
output = user.getCosmetic(slot).getPermission();
|
||||||
}
|
}
|
||||||
default -> {
|
default -> {
|
||||||
return user.getCosmetic(slot).getId();
|
output = user.getCosmetic(slot).getId();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return TranslationUtil.getTranslation("current-cosmetic", String.valueOf(output));
|
||||||
}
|
}
|
||||||
case "unlocked":
|
case "unlocked":
|
||||||
if (placeholderArgs == null) {
|
if (placeholderArgs == null) {
|
||||||
@@ -121,7 +124,7 @@ public class HMCPlaceholderExpansion extends PlaceholderExpansion {
|
|||||||
return "INVALID_COSMETIC";
|
return "INVALID_COSMETIC";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return TranslationUtil.getTranslation("unlockedCosmetic", 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 == null) {
|
||||||
@@ -131,11 +134,7 @@ public class HMCPlaceholderExpansion extends PlaceholderExpansion {
|
|||||||
String args1 = placeholderArgs.get(1);
|
String args1 = placeholderArgs.get(1);
|
||||||
|
|
||||||
if (EnumUtils.isValidEnum(CosmeticSlot.class, args1.toUpperCase())) {
|
if (EnumUtils.isValidEnum(CosmeticSlot.class, args1.toUpperCase())) {
|
||||||
if (user.getCosmetic(CosmeticSlot.valueOf(args1.toUpperCase())) != null) {
|
return TranslationUtil.getTranslation("equipped-cosmetic", String.valueOf(user.getCosmetic(CosmeticSlot.valueOf(args1.toUpperCase())) != null));
|
||||||
return "true";
|
|
||||||
} else {
|
|
||||||
return "false";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
MessagesUtil.sendDebugMessages(args1);
|
MessagesUtil.sendDebugMessages(args1);
|
||||||
@@ -153,15 +152,12 @@ 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());
|
||||||
if (cosmetic.getId() == user.getCosmetic(cosmetic.getSlot()).getId()) {
|
if (equippedCosmetic == null) return TranslationUtil.getTranslation("equipped-cosmetic", "false");
|
||||||
return "true";
|
return TranslationUtil.getTranslation("equipped-cosmetic", String.valueOf(cosmetic.getId().equals(equippedCosmetic.getId())));
|
||||||
} else {
|
|
||||||
return "false";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
case "wardrobe-enabled":
|
case "wardrobe-enabled":
|
||||||
return String.valueOf(user.isInWardrobe());
|
return TranslationUtil.getTranslation("in-wardrobe", String.valueOf(user.isInWardrobe()));
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,21 +17,26 @@ public class WGHook {
|
|||||||
/**
|
/**
|
||||||
* @implNote Please use {@link #getCosmeticEnableFlag()} instead
|
* @implNote Please use {@link #getCosmeticEnableFlag()} instead
|
||||||
*/
|
*/
|
||||||
public static StateFlag COSMETIC_ENABLE_FLAG;
|
private static StateFlag COSMETIC_ENABLE_FLAG;
|
||||||
|
|
||||||
|
private static StateFlag EMOTES_ENABLE_FLAG;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @implNote Please use {@link #getCosmeticWardrobeFlag()} instead
|
* @implNote Please use {@link #getCosmeticWardrobeFlag()} instead
|
||||||
*/
|
*/
|
||||||
public static StringFlag COSMETIC_WARDROBE_FLAG;
|
private static StringFlag COSMETIC_WARDROBE_FLAG;
|
||||||
|
|
||||||
public WGHook() {
|
public WGHook() {
|
||||||
FlagRegistry registry = WorldGuard.getInstance().getFlagRegistry();
|
FlagRegistry registry = WorldGuard.getInstance().getFlagRegistry();
|
||||||
try {
|
try {
|
||||||
StateFlag cosmeticFlag = new StateFlag("cosmetic-enable", false);
|
StateFlag cosmeticFlag = new StateFlag("cosmetic-enable", false);
|
||||||
|
StateFlag emoteFlag = new StateFlag("emotes-enable", false);
|
||||||
StringFlag wardrobeFlag = new StringFlag("cosmetic-wardrobe");
|
StringFlag wardrobeFlag = new StringFlag("cosmetic-wardrobe");
|
||||||
registry.register(cosmeticFlag);
|
registry.register(cosmeticFlag);
|
||||||
|
registry.register(emoteFlag);
|
||||||
registry.register(wardrobeFlag);
|
registry.register(wardrobeFlag);
|
||||||
COSMETIC_ENABLE_FLAG = cosmeticFlag;
|
COSMETIC_ENABLE_FLAG = cosmeticFlag;
|
||||||
|
EMOTES_ENABLE_FLAG = emoteFlag;
|
||||||
COSMETIC_WARDROBE_FLAG = wardrobeFlag;
|
COSMETIC_WARDROBE_FLAG = wardrobeFlag;
|
||||||
} catch (FlagConflictException e) {
|
} catch (FlagConflictException e) {
|
||||||
Flag<?> existing = registry.get("cosmetic-enable");
|
Flag<?> existing = registry.get("cosmetic-enable");
|
||||||
@@ -53,6 +58,14 @@ public class WGHook {
|
|||||||
return COSMETIC_ENABLE_FLAG;
|
return COSMETIC_ENABLE_FLAG;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the emotes enable {@link StateFlag}
|
||||||
|
* @return The emotes enable {@link StateFlag}
|
||||||
|
*/
|
||||||
|
public static StateFlag getEmotesEnableFlag() {
|
||||||
|
return EMOTES_ENABLE_FLAG;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the cosmetic wardrobe {@link StateFlag}
|
* Gets the cosmetic wardrobe {@link StateFlag}
|
||||||
* @return The cosmetic wardrobe {@link StateFlag}
|
* @return The cosmetic wardrobe {@link StateFlag}
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
package com.hibiscusmc.hmccosmetics.hooks.worldguard;
|
package com.hibiscusmc.hmccosmetics.hooks.worldguard;
|
||||||
|
|
||||||
|
import com.hibiscusmc.hmccosmetics.api.events.PlayerEmoteStartEvent;
|
||||||
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.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.sk89q.worldedit.bukkit.BukkitAdapter;
|
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
||||||
import com.sk89q.worldguard.WorldGuard;
|
import com.sk89q.worldguard.WorldGuard;
|
||||||
import com.sk89q.worldguard.protection.ApplicableRegionSet;
|
import com.sk89q.worldguard.protection.ApplicableRegionSet;
|
||||||
@@ -12,26 +12,26 @@ import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
|||||||
import com.sk89q.worldguard.protection.regions.RegionContainer;
|
import com.sk89q.worldguard.protection.regions.RegionContainer;
|
||||||
import com.sk89q.worldguard.protection.regions.RegionQuery;
|
import com.sk89q.worldguard.protection.regions.RegionQuery;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.EventPriority;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.player.PlayerMoveEvent;
|
import org.bukkit.event.player.PlayerMoveEvent;
|
||||||
|
import org.bukkit.event.player.PlayerTeleportEvent;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Contains {@link com.sk89q.worldguard.WorldGuard WorldGuard} related event listeners
|
* Contains {@link com.sk89q.worldguard.WorldGuard WorldGuard} related event listeners
|
||||||
*/
|
*/
|
||||||
public class WGListener implements Listener {
|
public class WGListener implements Listener {
|
||||||
@EventHandler
|
@EventHandler(priority = EventPriority.MONITOR)
|
||||||
public void onPlayerMove(@NotNull PlayerMoveEvent event) {
|
public void onPlayerMove(@NotNull PlayerMoveEvent event) {
|
||||||
CosmeticUser user = CosmeticUsers.getUser(event.getPlayer());
|
CosmeticUser user = CosmeticUsers.getUser(event.getPlayer());
|
||||||
if (user == null) return;
|
if (user == null) return;
|
||||||
Location location = event.getPlayer().getLocation();
|
Location location = event.getPlayer().getLocation();
|
||||||
com.sk89q.worldedit.util.Location loc = BukkitAdapter.adapt(location);
|
ApplicableRegionSet set = getRegions(location);
|
||||||
RegionContainer region = WorldGuard.getInstance().getPlatform().getRegionContainer();
|
|
||||||
RegionQuery query = region.createQuery();
|
|
||||||
ApplicableRegionSet set = query.getApplicableRegions(loc);
|
|
||||||
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();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -51,4 +51,56 @@ public class WGListener implements Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.MONITOR)
|
||||||
|
public void onPlayerTeleport(PlayerTeleportEvent event) {
|
||||||
|
CosmeticUser user = CosmeticUsers.getUser(event.getPlayer());
|
||||||
|
if (user == null) return;
|
||||||
|
Location location = event.getTo();
|
||||||
|
ApplicableRegionSet set = getRegions(location);
|
||||||
|
if (user.getHidden()) {
|
||||||
|
if (user.getHiddenReason() == CosmeticUser.HiddenReason.WORLDGUARD && set.getRegions().isEmpty()) {
|
||||||
|
user.showCosmetics();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (ProtectedRegion protectedRegion : set.getRegions()) {
|
||||||
|
if (protectedRegion.getFlags().containsKey(WGHook.getCosmeticEnableFlag())) {
|
||||||
|
if (protectedRegion.getFlags().get(WGHook.getCosmeticEnableFlag()).toString().equalsIgnoreCase("ALLOW")) {
|
||||||
|
if (user.getHiddenReason() == CosmeticUser.HiddenReason.WORLDGUARD) user.showCosmetics();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
user.hideCosmetics(CosmeticUser.HiddenReason.WORLDGUARD);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (protectedRegion.getFlags().containsKey(WGHook.getCosmeticWardrobeFlag())) {
|
||||||
|
if (!WardrobeSettings.getWardrobeNames().contains(protectedRegion.getFlags().get(WGHook.getCosmeticWardrobeFlag()).toString())) return;
|
||||||
|
Wardrobe wardrobe = WardrobeSettings.getWardrobe(protectedRegion.getFlags().get(WGHook.getCosmeticWardrobeFlag()).toString());
|
||||||
|
user.enterWardrobe(true, wardrobe);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.NORMAL)
|
||||||
|
public void onPlayerEmote(PlayerEmoteStartEvent event) {
|
||||||
|
Player player = event.getUser().getPlayer();
|
||||||
|
if (player == null) return;
|
||||||
|
Location location = player.getLocation();
|
||||||
|
ApplicableRegionSet set = getRegions(location);
|
||||||
|
for (ProtectedRegion protectedRegion : set.getRegions()) {
|
||||||
|
if (protectedRegion.getFlags().containsKey(WGHook.getEmotesEnableFlag())) {
|
||||||
|
if (protectedRegion.getFlags().get(WGHook.getEmotesEnableFlag()).toString().equalsIgnoreCase("DENY")) {
|
||||||
|
event.setCancelled(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private ApplicableRegionSet getRegions(Location location) {
|
||||||
|
com.sk89q.worldedit.util.Location loc = BukkitAdapter.adapt(location);
|
||||||
|
RegionContainer region = WorldGuard.getInstance().getPlatform().getRegionContainer();
|
||||||
|
RegionQuery query = region.createQuery();
|
||||||
|
return query.getApplicableRegions(loc);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import org.bukkit.Bukkit;
|
|||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.EntityType;
|
import org.bukkit.entity.EntityType;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.EventPriority;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.player.PlayerJoinEvent;
|
import org.bukkit.event.player.PlayerJoinEvent;
|
||||||
import org.bukkit.event.player.PlayerQuitEvent;
|
import org.bukkit.event.player.PlayerQuitEvent;
|
||||||
@@ -18,10 +19,10 @@ import org.jetbrains.annotations.NotNull;
|
|||||||
|
|
||||||
public class PlayerConnectionListener implements Listener {
|
public class PlayerConnectionListener implements Listener {
|
||||||
|
|
||||||
@EventHandler
|
@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() != null)
|
if (!HMCCosmeticsPlugin.getLatestVersion().equalsIgnoreCase(HMCCosmeticsPlugin.getInstance().getDescription().getVersion()) && HMCCosmeticsPlugin.getLatestVersion().isEmpty())
|
||||||
MessagesUtil.sendMessageNoKey(
|
MessagesUtil.sendMessageNoKey(
|
||||||
event.getPlayer(),
|
event.getPlayer(),
|
||||||
"<br>" +
|
"<br>" +
|
||||||
@@ -47,7 +48,7 @@ public class PlayerConnectionListener implements Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@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) { // Remove any passengers if a user failed to initialize. Bugs can cause this to happen
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import com.comphenix.protocol.events.PacketEvent;
|
|||||||
import com.comphenix.protocol.wrappers.EnumWrappers;
|
import com.comphenix.protocol.wrappers.EnumWrappers;
|
||||||
import com.comphenix.protocol.wrappers.Pair;
|
import com.comphenix.protocol.wrappers.Pair;
|
||||||
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
|
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
|
||||||
|
import com.hibiscusmc.hmccosmetics.api.events.PlayerCosmeticPostEquipEvent;
|
||||||
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.cosmetic.CosmeticSlot;
|
import com.hibiscusmc.hmccosmetics.cosmetic.CosmeticSlot;
|
||||||
@@ -23,7 +24,9 @@ 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.util.InventoryUtils;
|
||||||
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||||
|
import com.hibiscusmc.hmccosmetics.util.packets.PacketManager;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.NamespacedKey;
|
import org.bukkit.NamespacedKey;
|
||||||
import org.bukkit.enchantments.Enchantment;
|
import org.bukkit.enchantments.Enchantment;
|
||||||
@@ -32,6 +35,7 @@ import org.bukkit.entity.EntityType;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.entity.Pose;
|
import org.bukkit.entity.Pose;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.EventPriority;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.entity.*;
|
import org.bukkit.event.entity.*;
|
||||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||||
@@ -42,6 +46,8 @@ import org.bukkit.persistence.PersistentDataType;
|
|||||||
import org.bukkit.potion.PotionEffectType;
|
import org.bukkit.potion.PotionEffectType;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
import org.spigotmc.event.entity.EntityDismountEvent;
|
||||||
|
import org.spigotmc.event.entity.EntityMountEvent;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
@@ -53,13 +59,14 @@ public class PlayerGameListener implements Listener {
|
|||||||
registerPlayerEquipmentListener();
|
registerPlayerEquipmentListener();
|
||||||
registerPlayerArmListener();
|
registerPlayerArmListener();
|
||||||
registerEntityUseListener();
|
registerEntityUseListener();
|
||||||
|
registerSlotChangeListener();
|
||||||
|
|
||||||
//registerLookMovement();
|
//registerLookMovement();
|
||||||
//registerMoveListener();
|
//registerMoveListener();
|
||||||
//registerTeleportMovement();
|
//registerTeleportMovement();
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler(priority = EventPriority.LOW)
|
||||||
public void onPlayerClick(@NotNull InventoryClickEvent event) {
|
public void onPlayerClick(@NotNull InventoryClickEvent event) {
|
||||||
// || !event.getClickedInventory().getType().equals(InventoryType.PLAYER)
|
// || !event.getClickedInventory().getType().equals(InventoryType.PLAYER)
|
||||||
if (event.getClick().isShiftClick()) return;
|
if (event.getClick().isShiftClick()) return;
|
||||||
@@ -86,7 +93,7 @@ public class PlayerGameListener implements Listener {
|
|||||||
MessagesUtil.sendDebugMessages("Event fired, updated cosmetic " + cosmeticSlot);
|
MessagesUtil.sendDebugMessages("Event fired, updated cosmetic " + cosmeticSlot);
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler(priority = EventPriority.LOW)
|
||||||
public void onPlayerShift(PlayerToggleSneakEvent event) {
|
public void onPlayerShift(PlayerToggleSneakEvent event) {
|
||||||
CosmeticUser user = CosmeticUsers.getUser(event.getPlayer().getUniqueId());
|
CosmeticUser user = CosmeticUsers.getUser(event.getPlayer().getUniqueId());
|
||||||
|
|
||||||
@@ -101,7 +108,7 @@ public class PlayerGameListener implements Listener {
|
|||||||
user.leaveWardrobe();
|
user.leaveWardrobe();
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler(priority = EventPriority.LOW)
|
||||||
public void onPlayerTeleport(PlayerTeleportEvent event) {
|
public void onPlayerTeleport(PlayerTeleportEvent event) {
|
||||||
CosmeticUser user = CosmeticUsers.getUser(event.getPlayer().getUniqueId());
|
CosmeticUser user = CosmeticUsers.getUser(event.getPlayer().getUniqueId());
|
||||||
|
|
||||||
@@ -111,29 +118,28 @@ public class PlayerGameListener implements Listener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (user.hasCosmeticInSlot(CosmeticSlot.BACKPACK) && user.getUserBackpackManager() != null) {
|
if (user.isInWardrobe()) {
|
||||||
Bukkit.getScheduler().runTaskLater(HMCCosmeticsPlugin.getInstance(), () -> {
|
user.leaveWardrobe();
|
||||||
user.respawnBackpack();
|
|
||||||
user.updateCosmetic();
|
|
||||||
}, 1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Bukkit.getScheduler().runTaskLater(HMCCosmeticsPlugin.getInstance(), () -> {
|
||||||
|
if (user.hasCosmeticInSlot(CosmeticSlot.BACKPACK) && user.getUserBackpackManager() != null) {
|
||||||
|
user.respawnBackpack();
|
||||||
|
}
|
||||||
|
if (user.hasCosmeticInSlot(CosmeticSlot.BALLOON)) {
|
||||||
|
user.respawnBalloon();
|
||||||
|
}
|
||||||
|
user.updateCosmetic();
|
||||||
|
}, 1);
|
||||||
|
|
||||||
if (event.getCause().equals(PlayerTeleportEvent.TeleportCause.NETHER_PORTAL) || event.getCause().equals(PlayerTeleportEvent.TeleportCause.END_PORTAL)) return;
|
if (event.getCause().equals(PlayerTeleportEvent.TeleportCause.NETHER_PORTAL) || event.getCause().equals(PlayerTeleportEvent.TeleportCause.END_PORTAL)) return;
|
||||||
|
|
||||||
if (user.hasCosmeticInSlot(CosmeticSlot.BALLOON)) {
|
|
||||||
final CosmeticBalloonType cosmeticBalloonType = (CosmeticBalloonType) user.getCosmetic(CosmeticSlot.BALLOON);
|
|
||||||
user.despawnBalloon();
|
|
||||||
Bukkit.getScheduler().runTaskLater(HMCCosmeticsPlugin.getInstance(), () -> {
|
|
||||||
user.spawnBalloon(cosmeticBalloonType);
|
|
||||||
}, 2);
|
|
||||||
}
|
|
||||||
if (user.getUserEmoteManager().isPlayingEmote()) {
|
if (user.getUserEmoteManager().isPlayingEmote()) {
|
||||||
user.getUserEmoteManager().stopEmote(UserEmoteManager.StopEmoteReason.TELEPORT);
|
user.getUserEmoteManager().stopEmote(UserEmoteManager.StopEmoteReason.TELEPORT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@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");
|
||||||
@@ -152,9 +158,8 @@ public class PlayerGameListener implements Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@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 (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))
|
||||||
@@ -162,11 +167,9 @@ public class PlayerGameListener implements Listener {
|
|||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@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)) return;
|
|
||||||
Player player = ((Player) event.getEntity()).getPlayer();
|
|
||||||
CosmeticUser user = CosmeticUsers.getUser(player);
|
CosmeticUser user = CosmeticUsers.getUser(player);
|
||||||
if (user == null) return;
|
if (user == null) return;
|
||||||
if (user.getUserEmoteManager().isPlayingEmote()) {
|
if (user.getUserEmoteManager().isPlayingEmote()) {
|
||||||
@@ -182,22 +185,22 @@ public class PlayerGameListener implements Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@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();
|
||||||
// TODO: Move to packets
|
|
||||||
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
|
@EventHandler(priority = EventPriority.MONITOR)
|
||||||
public void onPlayerPoseChange(EntityPoseChangeEvent event) {
|
public void onPlayerPoseChange(EntityPoseChangeEvent event) {
|
||||||
if (!(event.getEntity() instanceof Player)) return;
|
if (!(event.getEntity() instanceof Player player)) return;
|
||||||
Player player = ((Player) event.getEntity()).getPlayer();
|
|
||||||
CosmeticUser user = CosmeticUsers.getUser(player);
|
CosmeticUser user = CosmeticUsers.getUser(player);
|
||||||
if (user == null) return;
|
if (user == null) return;
|
||||||
if (!user.hasCosmeticInSlot(CosmeticSlot.BACKPACK)) return;
|
if (!user.hasCosmeticInSlot(CosmeticSlot.BACKPACK)) return;
|
||||||
@@ -205,14 +208,7 @@ public class PlayerGameListener implements Listener {
|
|||||||
if (pose.equals(Pose.STANDING)) {
|
if (pose.equals(Pose.STANDING)) {
|
||||||
// #84, Riptides mess with backpacks
|
// #84, Riptides mess with backpacks
|
||||||
ItemStack currentItem = player.getInventory().getItemInMainHand();
|
ItemStack currentItem = player.getInventory().getItemInMainHand();
|
||||||
if (currentItem != null) {
|
if (currentItem.containsEnchantment(Enchantment.RIPTIDE)) return;
|
||||||
if (currentItem.hasItemMeta()) {
|
|
||||||
if (currentItem.containsEnchantment(Enchantment.RIPTIDE)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!user.isBackpackSpawned()) {
|
if (!user.isBackpackSpawned()) {
|
||||||
user.spawnBackpack((CosmeticBackpackType) user.getCosmetic(CosmeticSlot.BACKPACK));
|
user.spawnBackpack((CosmeticBackpackType) user.getCosmetic(CosmeticSlot.BACKPACK));
|
||||||
}
|
}
|
||||||
@@ -223,11 +219,9 @@ public class PlayerGameListener implements Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@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;
|
||||||
@@ -244,6 +238,7 @@ public class PlayerGameListener implements Listener {
|
|||||||
if (slot == -1) return;
|
if (slot == -1) return;
|
||||||
|
|
||||||
CosmeticUser user = CosmeticUsers.getUser(event.getPlayer().getUniqueId());
|
CosmeticUser user = CosmeticUsers.getUser(event.getPlayer().getUniqueId());
|
||||||
|
if (user == null) return;
|
||||||
CosmeticSlot cosmeticSlot = InventoryUtils.BukkitCosmeticSlot(slot);
|
CosmeticSlot cosmeticSlot = InventoryUtils.BukkitCosmeticSlot(slot);
|
||||||
|
|
||||||
if (!user.hasCosmeticInSlot(cosmeticSlot)) {
|
if (!user.hasCosmeticInSlot(cosmeticSlot)) {
|
||||||
@@ -257,8 +252,8 @@ public class PlayerGameListener implements Listener {
|
|||||||
}, 2);
|
}, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@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
|
||||||
@@ -268,12 +263,10 @@ public class PlayerGameListener implements Listener {
|
|||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Bukkit.getScheduler().runTaskLater(HMCCosmeticsPlugin.getInstance(), () -> {
|
Bukkit.getScheduler().runTaskLater(HMCCosmeticsPlugin.getInstance(), () -> user.updateCosmetic(CosmeticSlot.OFFHAND), 2);
|
||||||
user.updateCosmetic(CosmeticSlot.OFFHAND);
|
|
||||||
}, 2);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler(priority = EventPriority.NORMAL)
|
||||||
public void onPlayerPickupItem(EntityPickupItemEvent event) {
|
public void onPlayerPickupItem(EntityPickupItemEvent event) {
|
||||||
if (!(event.getEntity() instanceof Player)) return;
|
if (!(event.getEntity() instanceof Player)) return;
|
||||||
CosmeticUser user = CosmeticUsers.getUser(event.getEntity().getUniqueId());
|
CosmeticUser user = CosmeticUsers.getUser(event.getEntity().getUniqueId());
|
||||||
@@ -281,9 +274,8 @@ public class PlayerGameListener implements Listener {
|
|||||||
if (user.isInWardrobe()) event.setCancelled(true);
|
if (user.isInWardrobe()) event.setCancelled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@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();
|
||||||
@@ -299,7 +291,7 @@ public class PlayerGameListener implements Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler(priority = EventPriority.LOW)
|
||||||
public void onMainHandSwitch(PlayerItemHeldEvent event) {
|
public void onMainHandSwitch(PlayerItemHeldEvent event) {
|
||||||
CosmeticUser user = CosmeticUsers.getUser(event.getPlayer());
|
CosmeticUser user = CosmeticUsers.getUser(event.getPlayer());
|
||||||
if (user == null) return;
|
if (user == null) return;
|
||||||
@@ -308,7 +300,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
|
||||||
@@ -320,19 +311,19 @@ public class PlayerGameListener implements Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler(priority = EventPriority.LOW)
|
||||||
public void onPlayerDeath(PlayerDeathEvent event) {
|
public void onPlayerDeath(PlayerDeathEvent event) {
|
||||||
CosmeticUser user = CosmeticUsers.getUser(event.getEntity());
|
CosmeticUser user = CosmeticUsers.getUser(event.getEntity());
|
||||||
if (user == null) return;
|
if (user == null) return;
|
||||||
|
|
||||||
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();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler(priority = EventPriority.LOW)
|
||||||
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;
|
||||||
@@ -346,6 +337,38 @@ public class PlayerGameListener implements Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.LOW)
|
||||||
|
public void onPlayerCosmeticEquip(PlayerCosmeticPostEquipEvent event) {
|
||||||
|
CosmeticUser user = event.getUser();
|
||||||
|
if (user.isInWardrobe() && event.getCosmetic().getSlot().equals(CosmeticSlot.BALLOON)) {
|
||||||
|
Location NPCLocation = user.getWardrobeManager().getNpcLocation();
|
||||||
|
CosmeticBalloonType cosmetic = (CosmeticBalloonType) event.getCosmetic();
|
||||||
|
// We know that no other entity besides a regular player will be in the wardrobe
|
||||||
|
PacketManager.sendTeleportPacket(user.getBalloonManager().getPufferfishBalloonId(), NPCLocation.add(cosmetic.getBalloonOffset()), false, List.of(user.getPlayer()));
|
||||||
|
user.getBalloonManager().getModelEntity().teleport(NPCLocation.add(cosmetic.getBalloonOffset()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||||
|
public void onPlayerMounted(EntityMountEvent event) {
|
||||||
|
if (event.getEntity() instanceof Player player) {
|
||||||
|
CosmeticUser user = CosmeticUsers.getUser(player);
|
||||||
|
if (user == null) return;
|
||||||
|
|
||||||
|
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(HMCCosmeticsPlugin.getInstance(), user::respawnBackpack, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||||
|
public void onPlayerDismounted(EntityDismountEvent event) {
|
||||||
|
if (event.getDismounted() instanceof Player player) {
|
||||||
|
CosmeticUser user = CosmeticUsers.getUser(player);
|
||||||
|
if (user == null) return;
|
||||||
|
|
||||||
|
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(HMCCosmeticsPlugin.getInstance(), user::respawnBackpack, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
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
|
||||||
@@ -358,7 +381,7 @@ public class PlayerGameListener implements Listener {
|
|||||||
if (invTypeClicked != 0) return;
|
if (invTypeClicked != 0) return;
|
||||||
// -999 is when a player clicks outside their inventory. https://wiki.vg/Inventory#Player_Inventory
|
// -999 is when a player clicks outside their inventory. https://wiki.vg/Inventory#Player_Inventory
|
||||||
if (slotClicked == -999) return;
|
if (slotClicked == -999) return;
|
||||||
if (!(event.getPlayer() instanceof Player)) return;
|
if (event.getPlayer() == null) return;
|
||||||
|
|
||||||
CosmeticUser user = CosmeticUsers.getUser(player);
|
CosmeticUser user = CosmeticUsers.getUser(player);
|
||||||
if (user == null) return;
|
if (user == null) return;
|
||||||
@@ -378,7 +401,6 @@ public class PlayerGameListener implements Listener {
|
|||||||
MessagesUtil.sendDebugMessages("Menu Initial ");
|
MessagesUtil.sendDebugMessages("Menu Initial ");
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
if (event.getPlayer() == null) return;
|
if (event.getPlayer() == null) return;
|
||||||
if (!(event.getPlayer() instanceof Player)) return;
|
|
||||||
|
|
||||||
int windowID = event.getPacket().getIntegers().read(0);
|
int windowID = event.getPacket().getIntegers().read(0);
|
||||||
List<ItemStack> slotData = event.getPacket().getItemListModifier().read(0);
|
List<ItemStack> slotData = event.getPacket().getItemListModifier().read(0);
|
||||||
@@ -422,6 +444,30 @@ 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;
|
||||||
|
|
||||||
|
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
|
||||||
@@ -453,7 +499,7 @@ public class PlayerGameListener implements Listener {
|
|||||||
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
|
||||||
public void onPacketReceiving(PacketEvent event) {
|
public void onPacketReceiving(PacketEvent event) {
|
||||||
if (!(event.getPlayer() instanceof Player)) return;
|
if (event.getPlayer() == null) 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;
|
||||||
@@ -474,9 +520,8 @@ public class PlayerGameListener implements Listener {
|
|||||||
ProtocolLibrary.getProtocolManager().addPacketListener(new PacketAdapter(HMCCosmeticsPlugin.getInstance(), ListenerPriority.NORMAL, PacketType.Play.Client.USE_ENTITY) {
|
ProtocolLibrary.getProtocolManager().addPacketListener(new PacketAdapter(HMCCosmeticsPlugin.getInstance(), ListenerPriority.NORMAL, PacketType.Play.Client.USE_ENTITY) {
|
||||||
@Override
|
@Override
|
||||||
public void onPacketReceiving(PacketEvent event) {
|
public void onPacketReceiving(PacketEvent event) {
|
||||||
if (!(event.getPlayer() instanceof Player)) return;
|
if (event.getPlayer() == null) return;
|
||||||
Player player = event.getPlayer();
|
CosmeticUser user = CosmeticUsers.getUser(event.getPlayer());
|
||||||
CosmeticUser user = CosmeticUsers.getUser(player);
|
|
||||||
if (user == null) return;
|
if (user == null) return;
|
||||||
if (user.getUserEmoteManager().isPlayingEmote() || user.isInWardrobe()) {
|
if (user.getUserEmoteManager().isPlayingEmote() || user.isInWardrobe()) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
|
|||||||
@@ -3,9 +3,8 @@ package com.hibiscusmc.hmccosmetics.nms;
|
|||||||
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.cosmetic.types.CosmeticBalloonType;
|
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticBalloonType;
|
||||||
import com.hibiscusmc.hmccosmetics.user.manager.UserBalloonManager;
|
|
||||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||||
import net.kyori.adventure.text.Component;
|
import com.hibiscusmc.hmccosmetics.user.manager.UserBalloonManager;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.entity.ArmorStand;
|
import org.bukkit.entity.ArmorStand;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
@@ -26,12 +25,11 @@ public interface NMSHandler {
|
|||||||
|
|
||||||
Entity spawnBackpack(CosmeticUser user, CosmeticBackpackType cosmeticBackpackType);
|
Entity spawnBackpack(CosmeticUser user, CosmeticBackpackType cosmeticBackpackType);
|
||||||
|
|
||||||
Entity spawnHMCParticleCloud(Location location);
|
|
||||||
|
|
||||||
Entity spawnDisplayEntity(Location location, String text);
|
Entity spawnDisplayEntity(Location location, String text);
|
||||||
|
|
||||||
UserBalloonManager spawnBalloon(CosmeticUser user, CosmeticBalloonType cosmeticBalloonType);
|
UserBalloonManager spawnBalloon(CosmeticUser user, CosmeticBalloonType cosmeticBalloonType);
|
||||||
|
|
||||||
|
@Deprecated(since = "2.6.0")
|
||||||
void equipmentSlotUpdate(
|
void equipmentSlotUpdate(
|
||||||
int entityId,
|
int entityId,
|
||||||
CosmeticUser user,
|
CosmeticUser user,
|
||||||
|
|||||||
@@ -2,14 +2,16 @@ package com.hibiscusmc.hmccosmetics.nms;
|
|||||||
|
|
||||||
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
|
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
|
||||||
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
public class NMSHandlers {
|
public class NMSHandlers {
|
||||||
|
|
||||||
private static final String[] SUPPORTED_VERSION = new String[]{"v1_17_R1", "v1_18_R2", "v1_19_R1", "v1_19_R2", "v1_19_R3", "v1_20_R1"};
|
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 NMSHandler handler;
|
||||||
|
@Getter
|
||||||
private static String version;
|
private static String version;
|
||||||
|
|
||||||
public static NMSHandler getHandler() {
|
public static NMSHandler getHandler() {
|
||||||
@@ -21,10 +23,6 @@ public class NMSHandlers {
|
|||||||
return handler;
|
return handler;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getVersion() {
|
|
||||||
return version;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void setup() {
|
public static void setup() {
|
||||||
if (handler != null) return;
|
if (handler != null) return;
|
||||||
final String packageName = HMCCosmeticsPlugin.getInstance().getServer().getClass().getPackage().getName();
|
final String packageName = HMCCosmeticsPlugin.getInstance().getServer().getClass().getPackage().getName();
|
||||||
|
|||||||
@@ -3,46 +3,60 @@ package com.hibiscusmc.hmccosmetics.user;
|
|||||||
import com.google.common.collect.ImmutableCollection;
|
import com.google.common.collect.ImmutableCollection;
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
|
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
|
||||||
import com.hibiscusmc.hmccosmetics.api.*;
|
import com.hibiscusmc.hmccosmetics.api.events.*;
|
||||||
import com.hibiscusmc.hmccosmetics.config.Settings;
|
import com.hibiscusmc.hmccosmetics.config.Settings;
|
||||||
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;
|
||||||
import com.hibiscusmc.hmccosmetics.cosmetic.CosmeticSlot;
|
import com.hibiscusmc.hmccosmetics.cosmetic.CosmeticSlot;
|
||||||
import com.hibiscusmc.hmccosmetics.cosmetic.types.*;
|
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticArmorType;
|
||||||
|
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticBackpackType;
|
||||||
|
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticBalloonType;
|
||||||
|
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticMainhandType;
|
||||||
|
import com.hibiscusmc.hmccosmetics.hooks.Hooks;
|
||||||
|
import com.hibiscusmc.hmccosmetics.nms.NMSHandlers;
|
||||||
import com.hibiscusmc.hmccosmetics.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.nms.NMSHandlers;
|
|
||||||
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.InventoryUtils;
|
||||||
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||||
import com.hibiscusmc.hmccosmetics.util.PlayerUtils;
|
import com.hibiscusmc.hmccosmetics.util.PlayerUtils;
|
||||||
import com.hibiscusmc.hmccosmetics.util.packets.PacketManager;
|
import com.hibiscusmc.hmccosmetics.util.packets.PacketManager;
|
||||||
import org.bukkit.*;
|
import lombok.Getter;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.Color;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
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;
|
||||||
import org.bukkit.scheduler.BukkitTask;
|
import org.bukkit.scheduler.BukkitTask;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.logging.Level;
|
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;
|
||||||
@@ -55,6 +69,7 @@ public class CosmeticUser {
|
|||||||
Runnable run = () -> {
|
Runnable run = () -> {
|
||||||
MessagesUtil.sendDebugMessages("Tick[uuid=" + uniqueId + "]", Level.INFO);
|
MessagesUtil.sendDebugMessages("Tick[uuid=" + uniqueId + "]", Level.INFO);
|
||||||
updateCosmetic();
|
updateCosmetic();
|
||||||
|
if (getHidden() && !getUserEmoteManager().isPlayingEmote()) MessagesUtil.sendActionBar(getPlayer(), "hidden-cosmetics");
|
||||||
};
|
};
|
||||||
|
|
||||||
int tickPeriod = Settings.getTickPeriod();
|
int tickPeriod = Settings.getTickPeriod();
|
||||||
@@ -70,10 +85,6 @@ 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);
|
||||||
}
|
}
|
||||||
@@ -116,6 +127,9 @@ public class CosmeticUser {
|
|||||||
CosmeticBalloonType balloonType = (CosmeticBalloonType) cosmetic;
|
CosmeticBalloonType balloonType = (CosmeticBalloonType) cosmetic;
|
||||||
spawnBalloon(balloonType);
|
spawnBalloon(balloonType);
|
||||||
}
|
}
|
||||||
|
// API
|
||||||
|
PlayerCosmeticPostEquipEvent postEquipEvent = new PlayerCosmeticPostEquipEvent(this, cosmetic);
|
||||||
|
Bukkit.getPluginManager().callEvent(postEquipEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removeCosmetics() {
|
public void removeCosmetics() {
|
||||||
@@ -141,7 +155,7 @@ public class CosmeticUser {
|
|||||||
despawnBalloon();
|
despawnBalloon();
|
||||||
}
|
}
|
||||||
if (slot == CosmeticSlot.EMOTE) {
|
if (slot == CosmeticSlot.EMOTE) {
|
||||||
|
if (getUserEmoteManager().isPlayingEmote()) getUserEmoteManager().stopEmote(UserEmoteManager.StopEmoteReason.UNEQUIP);
|
||||||
}
|
}
|
||||||
colors.remove(slot);
|
colors.remove(slot);
|
||||||
playerCosmetics.remove(slot);
|
playerCosmetics.remove(slot);
|
||||||
@@ -184,6 +198,10 @@ public class CosmeticUser {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ItemStack getUserCosmeticItem(CosmeticSlot slot) {
|
||||||
|
return getUserCosmeticItem(getCosmetic(slot));
|
||||||
|
}
|
||||||
|
|
||||||
public ItemStack getUserCosmeticItem(Cosmetic cosmetic) {
|
public ItemStack getUserCosmeticItem(Cosmetic cosmetic) {
|
||||||
ItemStack item = null;
|
ItemStack item = null;
|
||||||
if (hideCosmetics) {
|
if (hideCosmetics) {
|
||||||
@@ -204,8 +222,50 @@ public class CosmeticUser {
|
|||||||
MessagesUtil.sendDebugMessages("GetUserCosemticUser Item is null");
|
MessagesUtil.sendDebugMessages("GetUserCosemticUser Item is null");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
return getUserCosmeticItem(cosmetic, item);
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
|
public ItemStack getUserCosmeticItem(Cosmetic cosmetic, ItemStack item) {
|
||||||
if (item.hasItemMeta()) {
|
if (item.hasItemMeta()) {
|
||||||
ItemMeta itemMeta = item.getItemMeta();
|
ItemMeta itemMeta = item.getItemMeta();
|
||||||
|
|
||||||
|
if (item.getType() == Material.PLAYER_HEAD) {
|
||||||
|
SkullMeta skullMeta = (SkullMeta) itemMeta;
|
||||||
|
if (skullMeta.getPersistentDataContainer().has(InventoryUtils.getSkullOwner(), PersistentDataType.STRING)) {
|
||||||
|
String owner = skullMeta.getPersistentDataContainer().get(InventoryUtils.getSkullOwner(), PersistentDataType.STRING);
|
||||||
|
|
||||||
|
owner = Hooks.processPlaceholders(getPlayer(), owner);
|
||||||
|
|
||||||
|
skullMeta.setOwningPlayer(Bukkit.getOfflinePlayer(owner));
|
||||||
|
//skullMeta.getPersistentDataContainer().remove(InventoryUtils.getSkullOwner()); // Don't really need this?
|
||||||
|
}
|
||||||
|
if (skullMeta.getPersistentDataContainer().has(InventoryUtils.getSkullTexture(), PersistentDataType.STRING)) {
|
||||||
|
String texture = skullMeta.getPersistentDataContainer().get(InventoryUtils.getSkullTexture(), PersistentDataType.STRING);
|
||||||
|
|
||||||
|
texture = Hooks.processPlaceholders(getPlayer(), texture);
|
||||||
|
|
||||||
|
Bukkit.getUnsafe().modifyItemStack(item, "{SkullOwner:{Id:[I;0,0,0,0],Properties:{textures:[{Value:\""
|
||||||
|
+ texture + "\"}]}}}");
|
||||||
|
//skullMeta.getPersistentDataContainer().remove(InventoryUtils.getSkullTexture()); // Don't really need this?
|
||||||
|
}
|
||||||
|
|
||||||
|
itemMeta = skullMeta;
|
||||||
|
}
|
||||||
|
|
||||||
|
List<String> processedLore = new ArrayList<>();
|
||||||
|
|
||||||
|
if (itemMeta.hasLore()) {
|
||||||
|
for (String loreLine : itemMeta.getLore()) {
|
||||||
|
processedLore.add(Hooks.processPlaceholders(getPlayer(), loreLine));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (itemMeta.hasDisplayName()) {
|
||||||
|
String displayName = itemMeta.getDisplayName();
|
||||||
|
itemMeta.setDisplayName(Hooks.processPlaceholders(getPlayer(), displayName));
|
||||||
|
}
|
||||||
|
itemMeta.setLore(processedLore);
|
||||||
|
|
||||||
if (colors.containsKey(cosmetic.getSlot())) {
|
if (colors.containsKey(cosmetic.getSlot())) {
|
||||||
Color color = colors.get(cosmetic.getSlot());
|
Color color = colors.get(cosmetic.getSlot());
|
||||||
if (itemMeta instanceof LeatherArmorMeta leatherMeta) {
|
if (itemMeta instanceof LeatherArmorMeta leatherMeta) {
|
||||||
@@ -217,17 +277,13 @@ public class CosmeticUser {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
itemMeta.getPersistentDataContainer().set(InventoryUtils.getCosmeticKey(), PersistentDataType.STRING, cosmetic.getId());
|
itemMeta.getPersistentDataContainer().set(InventoryUtils.getCosmeticKey(), PersistentDataType.STRING, cosmetic.getId());
|
||||||
itemMeta.getPersistentDataContainer().set(InventoryUtils.getOwnerKey(), PersistentDataType.STRING, getPlayer().getUniqueId().toString());
|
itemMeta.getPersistentDataContainer().set(InventoryUtils.getOwnerKey(), PersistentDataType.STRING, getEntity().getUniqueId().toString());
|
||||||
|
|
||||||
item.setItemMeta(itemMeta);
|
item.setItemMeta(itemMeta);
|
||||||
}
|
}
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
||||||
public UserBackpackManager getUserBackpackManager() {
|
|
||||||
return userBackpackManager;
|
|
||||||
}
|
|
||||||
|
|
||||||
public UserBalloonManager getBalloonManager() {
|
public UserBalloonManager getBalloonManager() {
|
||||||
return this.userBalloonManager;
|
return this.userBalloonManager;
|
||||||
}
|
}
|
||||||
@@ -236,10 +292,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");
|
||||||
@@ -301,7 +353,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.getBackpackType());
|
this.userBackpackManager = new UserBackpackManager(this);
|
||||||
userBackpackManager.spawnBackpack(cosmeticBackpackType);
|
userBackpackManager.spawnBackpack(cosmeticBackpackType);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -316,19 +368,14 @@ public class CosmeticUser {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void spawnBalloon(CosmeticBalloonType cosmeticBalloonType) {
|
public void spawnBalloon(CosmeticBalloonType cosmeticBalloonType) {
|
||||||
Player player = Bukkit.getPlayer(getUniqueId());
|
|
||||||
|
|
||||||
if (this.userBalloonManager != null) return;
|
if (this.userBalloonManager != null) return;
|
||||||
|
|
||||||
this.userBalloonManager = NMSHandlers.getHandler().spawnBalloon(this, cosmeticBalloonType);
|
this.userBalloonManager = NMSHandlers.getHandler().spawnBalloon(this, cosmeticBalloonType);
|
||||||
|
//updateCosmetic(cosmeticBalloonType);
|
||||||
List<Player> viewer = PlayerUtils.getNearbyPlayers(player);
|
|
||||||
viewer.add(player);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void despawnBalloon() {
|
public void despawnBalloon() {
|
||||||
if (this.userBalloonManager == null) return;
|
if (this.userBalloonManager == null) return;
|
||||||
List<Player> sentTo = PlayerUtils.getNearbyPlayers(getPlayer().getLocation());
|
List<Player> sentTo = PlayerUtils.getNearbyPlayers(getEntity().getLocation());
|
||||||
|
|
||||||
PacketManager.sendEntityDestroyPacket(userBalloonManager.getPufferfishBalloonId(), sentTo);
|
PacketManager.sendEntityDestroyPacket(userBalloonManager.getPufferfishBalloonId(), sentTo);
|
||||||
|
|
||||||
@@ -351,13 +398,33 @@ public class CosmeticUser {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void removeArmor(CosmeticSlot slot) {
|
public void removeArmor(CosmeticSlot slot) {
|
||||||
PacketManager.equipmentSlotUpdate(getPlayer().getEntityId(), this, slot, PlayerUtils.getNearbyPlayers(getPlayer()));
|
EquipmentSlot equipmentSlot = InventoryUtils.getEquipmentSlot(slot);
|
||||||
|
if (equipmentSlot == null) return;
|
||||||
|
if (getPlayer() != null) {
|
||||||
|
NMSHandlers.getHandler().equipmentSlotUpdate(getEntity().getEntityId(), equipmentSlot, getPlayer().getInventory().getItem(equipmentSlot), PlayerUtils.getNearbyPlayers(getEntity().getLocation()));
|
||||||
|
} else {
|
||||||
|
PacketManager.equipmentSlotUpdate(getEntity().getEntityId(), this, slot, PlayerUtils.getNearbyPlayers(getEntity().getLocation()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This returns the player associated with the user. Some users may not have a player attached, ie, they are npcs
|
||||||
|
* wearing cosmetics through an addon. If you need to get locations, use getEntity instead.
|
||||||
|
* @return Player
|
||||||
|
*/
|
||||||
|
@Nullable
|
||||||
public Player getPlayer() {
|
public Player getPlayer() {
|
||||||
return Bukkit.getPlayer(uniqueId);
|
return Bukkit.getPlayer(uniqueId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This gets the entity associated with the user.
|
||||||
|
* @return Entity
|
||||||
|
*/
|
||||||
|
public Entity getEntity() {
|
||||||
|
return Bukkit.getEntity(uniqueId);
|
||||||
|
}
|
||||||
|
|
||||||
public Color getCosmeticColor(CosmeticSlot slot) {
|
public Color getCosmeticColor(CosmeticSlot slot) {
|
||||||
return colors.get(slot);
|
return colors.get(slot);
|
||||||
}
|
}
|
||||||
@@ -373,8 +440,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());
|
||||||
@@ -420,7 +491,7 @@ public class CosmeticUser {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void showCosmetics() {
|
public void showCosmetics() {
|
||||||
if (hideCosmetics == false) return;
|
if (!hideCosmetics) return;
|
||||||
|
|
||||||
PlayerCosmeticShowEvent event = new PlayerCosmeticShowEvent(this);
|
PlayerCosmeticShowEvent event = new PlayerCosmeticShowEvent(this);
|
||||||
Bukkit.getPluginManager().callEvent(event);
|
Bukkit.getPluginManager().callEvent(event);
|
||||||
@@ -433,10 +504,10 @@ public class CosmeticUser {
|
|||||||
if (hasCosmeticInSlot(CosmeticSlot.BALLOON)) {
|
if (hasCosmeticInSlot(CosmeticSlot.BALLOON)) {
|
||||||
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 = PlayerUtils.getNearbyPlayers(getEntity().getLocation());
|
||||||
PacketManager.sendLeashPacket(getBalloonManager().getPufferfishBalloonId(), getPlayer().getEntityId(), viewer);
|
PacketManager.sendLeashPacket(getBalloonManager().getPufferfishBalloonId(), getPlayer().getEntityId(), viewer);
|
||||||
}
|
}
|
||||||
if (hasCosmeticInSlot(CosmeticSlot.BACKPACK)) {
|
if (hasCosmeticInSlot(CosmeticSlot.BACKPACK) && isBackpackSpawned()) {
|
||||||
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);
|
||||||
@@ -449,10 +520,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,
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ 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;
|
||||||
|
|
||||||
|
import java.util.Set;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public class CosmeticUsers {
|
public class CosmeticUsers {
|
||||||
@@ -43,4 +44,8 @@ public class CosmeticUsers {
|
|||||||
if (entity.getType().equals(EntityType.PLAYER)) return null;
|
if (entity.getType().equals(EntityType.PLAYER)) return null;
|
||||||
return COSMETIC_USERS.get(entity.getUniqueId());
|
return COSMETIC_USERS.get(entity.getUniqueId());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Set<CosmeticUser> values() {
|
||||||
|
return COSMETIC_USERS.values();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,149 +1,149 @@
|
|||||||
package com.hibiscusmc.hmccosmetics.user.manager;
|
package com.hibiscusmc.hmccosmetics.user.manager;
|
||||||
|
|
||||||
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
|
|
||||||
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.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.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 org.bukkit.Location;
|
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.entity.AreaEffectCloud;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.ArmorStand;
|
import org.bukkit.entity.EntityType;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.inventory.EquipmentSlot;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
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;
|
||||||
private AreaEffectCloud particleCloud;
|
@Getter
|
||||||
|
private int invisibleArmorStand;
|
||||||
|
private ArrayList<Integer> particleCloud = new ArrayList<>();
|
||||||
|
@Getter
|
||||||
private final CosmeticUser user;
|
private final CosmeticUser user;
|
||||||
private BackpackType backpackType;
|
@Getter
|
||||||
|
private UserEntity entityManager;
|
||||||
|
|
||||||
public UserBackpackManager(CosmeticUser user, BackpackType backpackType) {
|
public UserBackpackManager(CosmeticUser user) {
|
||||||
this.user = user;
|
this.user = user;
|
||||||
hideBackpack = false;
|
this.backpackHidden = false;
|
||||||
this.backpackType = backpackType;
|
this.invisibleArmorStand = NMSHandlers.getHandler().getNextEntityId();
|
||||||
|
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 void spawnBackpack(CosmeticBackpackType cosmeticBackpackType) {
|
public void spawnBackpack(CosmeticBackpackType cosmeticBackpackType) {
|
||||||
MessagesUtil.sendDebugMessages("spawnBackpack Bukkit - Start");
|
MessagesUtil.sendDebugMessages("spawnBackpack Bukkit - Start");
|
||||||
|
|
||||||
if (getBackpackType().equals(BackpackType.NORMAL)) {
|
spawn(cosmeticBackpackType);
|
||||||
spawnNormalBackpack(cosmeticBackpackType);
|
|
||||||
}
|
|
||||||
if (getBackpackType().equals(BackpackType.FIRST_PERSON)) {
|
|
||||||
spawnFirstPersonBackpack(cosmeticBackpackType);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void spawnNormalBackpack(CosmeticBackpackType cosmeticBackpackType) {
|
private void spawn(CosmeticBackpackType cosmeticBackpackType) {
|
||||||
|
getEntityManager().setIds(List.of(invisibleArmorStand));
|
||||||
|
getEntityManager().teleport(user.getEntity().getLocation());
|
||||||
|
List<Player> outsideViewers = getEntityManager().getViewers();
|
||||||
|
PacketManager.sendEntitySpawnPacket(user.getEntity().getLocation(), getFirstArmorStandId(), EntityType.ARMOR_STAND, UUID.randomUUID(), getEntityManager().getViewers());
|
||||||
|
PacketManager.sendInvisibilityPacket(getFirstArmorStandId(), outsideViewers);
|
||||||
|
|
||||||
if (this.invisibleArmorStand != null) return;
|
Entity entity = user.getEntity();
|
||||||
|
|
||||||
this.invisibleArmorStand = (ArmorStand) NMSHandlers.getHandler().spawnBackpack(user, cosmeticBackpackType);
|
int[] passengerIDs = new int[entity.getPassengers().size() + 1];
|
||||||
|
|
||||||
if (cosmeticBackpackType.getModelName() != null && HMCCosmeticsPlugin.hasModelEngine()) {
|
for (int i = 0; i < entity.getPassengers().size(); i++) {
|
||||||
|
passengerIDs[i] = entity.getPassengers().get(i).getEntityId();
|
||||||
|
}
|
||||||
|
|
||||||
|
passengerIDs[passengerIDs.length - 1] = this.getFirstArmorStandId();
|
||||||
|
|
||||||
|
ArrayList<Player> owner = new ArrayList<>();
|
||||||
|
if (user.getPlayer() != null) owner.add(user.getPlayer());
|
||||||
|
|
||||||
|
if (cosmeticBackpackType.isFirstPersonCompadible()) {
|
||||||
|
for (int i = particleCloud.size(); i < cosmeticBackpackType.getHeight(); i++) {
|
||||||
|
int entityId = NMSHandlers.getHandler().getNextEntityId();
|
||||||
|
PacketManager.sendEntitySpawnPacket(user.getEntity().getLocation(), entityId, EntityType.AREA_EFFECT_CLOUD, UUID.randomUUID());
|
||||||
|
PacketManager.sendCloudEffect(entityId, PacketManager.getViewers(user.getEntity().getLocation()));
|
||||||
|
this.particleCloud.add(entityId);
|
||||||
|
}
|
||||||
|
// Copied code from updating the backpack
|
||||||
|
for (int i = 0; i < particleCloud.size(); i++) {
|
||||||
|
if (i == 0) PacketManager.sendRidingPacket(entity.getEntityId(), particleCloud.get(i), owner);
|
||||||
|
else PacketManager.sendRidingPacket(particleCloud.get(i - 1), particleCloud.get(i) , owner);
|
||||||
|
}
|
||||||
|
PacketManager.sendRidingPacket(particleCloud.get(particleCloud.size() - 1), user.getUserBackpackManager().getFirstArmorStandId(), owner);
|
||||||
|
if (!user.getHidden()) NMSHandlers.getHandler().equipmentSlotUpdate(user.getUserBackpackManager().getFirstArmorStandId(), EquipmentSlot.HEAD, user.getUserCosmeticItem(cosmeticBackpackType, cosmeticBackpackType.getFirstPersonBackpack()), owner);
|
||||||
|
}
|
||||||
|
NMSHandlers.getHandler().equipmentSlotUpdate(getFirstArmorStandId(), EquipmentSlot.HEAD, user.getUserCosmeticItem(cosmeticBackpackType), outsideViewers);
|
||||||
|
PacketManager.sendRidingPacket(entity.getEntityId(), passengerIDs, outsideViewers);
|
||||||
|
|
||||||
|
// No one should be using ME because it barely works but some still use it, so it's here
|
||||||
|
if (cosmeticBackpackType.getModelName() != null && Hooks.isActiveHook("ModelEngine")) {
|
||||||
if (ModelEngineAPI.api.getModelRegistry().getBlueprint(cosmeticBackpackType.getModelName()) == null) {
|
if (ModelEngineAPI.api.getModelRegistry().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
|
||||||
ActiveModel model = ModelEngineAPI.createActiveModel(ModelEngineAPI.getBlueprint(cosmeticBackpackType.getModelName()));
|
ModeledEntity modeledEntity = ModelEngineAPI.createModeledEntity(new PacketBaseEntity(getFirstArmorStandId(), UUID.randomUUID(), entity.getLocation()));
|
||||||
model.setCanHurt(false);
|
|
||||||
modeledEntity.addModel(model, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
MessagesUtil.sendDebugMessages("spawnBackpack Bukkit - Finish");
|
|
||||||
}
|
|
||||||
|
|
||||||
public void spawnFirstPersonBackpack(CosmeticBackpackType cosmeticBackpackType) {
|
|
||||||
|
|
||||||
if (this.invisibleArmorStand != null) return;
|
|
||||||
|
|
||||||
this.invisibleArmorStand = (ArmorStand) NMSHandlers.getHandler().spawnBackpack(user, cosmeticBackpackType);
|
|
||||||
this.particleCloud = (AreaEffectCloud) NMSHandlers.getHandler().spawnHMCParticleCloud(user.getPlayer().getLocation());
|
|
||||||
|
|
||||||
if (cosmeticBackpackType.getModelName() != null && HMCCosmeticsPlugin.hasModelEngine()) {
|
|
||||||
if (ModelEngineAPI.api.getModelRegistry().getBlueprint(cosmeticBackpackType.getModelName()) == null) {
|
|
||||||
MessagesUtil.sendDebugMessages("Invalid Model Engine Blueprint " + cosmeticBackpackType.getModelName(), Level.SEVERE);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
ModeledEntity modeledEntity = ModelEngineAPI.getOrCreateModeledEntity(invisibleArmorStand);
|
|
||||||
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) {
|
PacketManager.sendEntityDestroyPacket(invisibleArmorStand, getEntityManager().getViewers());
|
||||||
invisibleArmorStand.setHealth(0);
|
|
||||||
invisibleArmorStand.remove();
|
|
||||||
this.invisibleArmorStand = null;
|
|
||||||
}
|
|
||||||
if (particleCloud != null) {
|
if (particleCloud != null) {
|
||||||
particleCloud.remove();
|
for (Integer entityId : particleCloud) {
|
||||||
|
PacketManager.sendEntityDestroyPacket(entityId, getEntityManager().getViewers());
|
||||||
|
}
|
||||||
this.particleCloud = null;
|
this.particleCloud = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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 BackpackType getBackpackType() {
|
public ArrayList<Integer> getAreaEffectEntityId() {
|
||||||
return backpackType;
|
return particleCloud;
|
||||||
}
|
|
||||||
|
|
||||||
public int getAreaEffectEntityId() {
|
|
||||||
return particleCloud.getEntityId();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void teleportEffectEntity(Location location) {
|
|
||||||
particleCloud.teleport(location);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setItem(ItemStack item) {
|
public void setItem(ItemStack item) {
|
||||||
getArmorStand().getEquipment().setHelmet(item);
|
NMSHandlers.getHandler().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);
|
NMSHandlers.getHandler().equipmentSlotUpdate(getFirstArmorStandId(), EquipmentSlot.HEAD, item, getEntityManager().getViewers());
|
||||||
}
|
|
||||||
|
|
||||||
public enum BackpackType {
|
|
||||||
NORMAL,
|
|
||||||
FIRST_PERSON // First person not yet implemented
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,14 +3,15 @@ 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.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.PlayerUtils;
|
|
||||||
import com.hibiscusmc.hmccosmetics.util.packets.PacketManager;
|
import com.hibiscusmc.hmccosmetics.util.packets.PacketManager;
|
||||||
import com.ticxo.modelengine.api.ModelEngineAPI;
|
import com.ticxo.modelengine.api.ModelEngineAPI;
|
||||||
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 org.bukkit.Color;
|
import org.bukkit.Color;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.entity.ArmorStand;
|
import org.bukkit.entity.ArmorStand;
|
||||||
@@ -27,19 +28,18 @@ public class UserBalloonManager {
|
|||||||
|
|
||||||
private BalloonType balloonType;
|
private BalloonType balloonType;
|
||||||
private CosmeticBalloonType cosmeticBalloonType;
|
private CosmeticBalloonType cosmeticBalloonType;
|
||||||
private final int balloonID;
|
@Getter
|
||||||
private final UUID uniqueID;
|
private UserBalloonPufferfish pufferfish;
|
||||||
private final ArmorStand modelEntity;
|
private final ArmorStand modelEntity;
|
||||||
|
|
||||||
public UserBalloonManager(@NotNull Location location) {
|
public UserBalloonManager(CosmeticUser user, @NotNull Location location) {
|
||||||
this.uniqueID = UUID.randomUUID();
|
this.pufferfish = new UserBalloonPufferfish(user.getUniqueId(), NMSHandlers.getHandler().getNextEntityId(), UUID.randomUUID());
|
||||||
this.balloonID = NMSHandlers.getHandler().getNextEntityId();
|
|
||||||
this.modelEntity = NMSHandlers.getHandler().getMEGEntity(location.add(Settings.getBalloonOffset()));
|
this.modelEntity = NMSHandlers.getHandler().getMEGEntity(location.add(Settings.getBalloonOffset()));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void spawnModel(@NotNull CosmeticBalloonType cosmeticBalloonType, Color color) {
|
public void spawnModel(@NotNull CosmeticBalloonType cosmeticBalloonType, Color color) {
|
||||||
// redo this
|
// redo this
|
||||||
if (cosmeticBalloonType.getModelName() != null && HMCCosmeticsPlugin.hasModelEngine()) {
|
if (cosmeticBalloonType.getModelName() != null && Hooks.isActiveHook("ModelEngine")) {
|
||||||
balloonType = BalloonType.MODELENGINE;
|
balloonType = BalloonType.MODELENGINE;
|
||||||
} else {
|
} else {
|
||||||
if (cosmeticBalloonType.getItem() != null) {
|
if (cosmeticBalloonType.getItem() != null) {
|
||||||
@@ -136,10 +136,10 @@ public class UserBalloonManager {
|
|||||||
|
|
||||||
|
|
||||||
public int getPufferfishBalloonId() {
|
public int getPufferfishBalloonId() {
|
||||||
return balloonID;
|
return pufferfish.getId();
|
||||||
}
|
}
|
||||||
public UUID getPufferfishBalloonUniqueId() {
|
public UUID getPufferfishBalloonUniqueId() {
|
||||||
return uniqueID;
|
return pufferfish.getUuid();
|
||||||
}
|
}
|
||||||
|
|
||||||
public UUID getModelUnqiueId() {
|
public UUID getModelUnqiueId() {
|
||||||
@@ -172,7 +172,9 @@ public class UserBalloonManager {
|
|||||||
|
|
||||||
public void sendLeashPacket(int entityId) {
|
public void sendLeashPacket(int entityId) {
|
||||||
if (cosmeticBalloonType == null) return;
|
if (cosmeticBalloonType == null) return;
|
||||||
if (cosmeticBalloonType.isShowLead()) PacketManager.sendLeashPacket(getPufferfishBalloonId(), entityId, getLocation());
|
if (cosmeticBalloonType.isShowLead()) {
|
||||||
|
PacketManager.sendLeashPacket(getPufferfishBalloonId(), entityId, getLocation());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum BalloonType {
|
public enum BalloonType {
|
||||||
|
|||||||
@@ -0,0 +1,35 @@
|
|||||||
|
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 UserBalloonPufferfish extends UserEntity {
|
||||||
|
|
||||||
|
private int id;
|
||||||
|
private UUID uuid;
|
||||||
|
|
||||||
|
public UserBalloonPufferfish(UUID owner, int id, UUID uuid) {
|
||||||
|
super(owner);
|
||||||
|
this.id = id;
|
||||||
|
this.uuid = uuid;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public UUID getUuid() {
|
||||||
|
return uuid;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void hidePufferfish() {
|
||||||
|
PacketManager.sendEntityDestroyPacket(id, getViewers());
|
||||||
|
getViewers().clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
package com.hibiscusmc.hmccosmetics.user.manager;
|
package com.hibiscusmc.hmccosmetics.user.manager;
|
||||||
|
|
||||||
import com.hibiscusmc.hmccosmetics.api.PlayerEmoteStartEvent;
|
import com.hibiscusmc.hmccosmetics.api.events.PlayerEmoteStartEvent;
|
||||||
import com.hibiscusmc.hmccosmetics.api.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.nms.NMSHandlers;
|
||||||
@@ -88,6 +88,7 @@ public class UserEmoteManager {
|
|||||||
SNEAK,
|
SNEAK,
|
||||||
DAMAGE,
|
DAMAGE,
|
||||||
CONNECTION,
|
CONNECTION,
|
||||||
TELEPORT
|
TELEPORT,
|
||||||
|
UNEQUIP
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ import com.ticxo.playeranimator.api.model.player.PlayerModel;
|
|||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.GameMode;
|
import org.bukkit.GameMode;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
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.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
@@ -44,43 +43,46 @@ public class UserEmoteModel extends PlayerModel {
|
|||||||
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 = PacketManager.getViewers(player.getLocation());
|
||||||
outsideViewers.remove(player);
|
// Send equipment packet to the player as well (Fixes Optifine still rendering armor when emoting)
|
||||||
|
|
||||||
PacketManager.equipmentSlotUpdate(player, true, outsideViewers);
|
PacketManager.equipmentSlotUpdate(player, true, outsideViewers);
|
||||||
|
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");
|
||||||
|
}
|
||||||
|
|
||||||
|
PacketManager.sendEntitySpawnPacket(thirdPersonLocation, armorStandId, EntityType.ARMOR_STAND, UUID.randomUUID(), viewer);
|
||||||
|
PacketManager.sendInvisibilityPacket(armorStandId, viewer);
|
||||||
|
PacketManager.sendLookPacket(armorStandId, thirdPersonLocation, viewer);
|
||||||
|
|
||||||
|
PacketManager.gamemodeChangePacket(player, 3);
|
||||||
|
PacketManager.sendCameraPacket(armorStandId, viewer);
|
||||||
|
}
|
||||||
|
|
||||||
PacketManager.gamemodeChangePacket(player, 3);
|
|
||||||
PacketManager.sendCameraPacket(armorStandId, viewer);
|
|
||||||
|
|
||||||
MessagesUtil.sendDebugMessages("playAnimation run");
|
MessagesUtil.sendDebugMessages("playAnimation run");
|
||||||
}
|
}
|
||||||
@@ -107,6 +109,8 @@ public class UserEmoteModel extends PlayerModel {
|
|||||||
|
|
||||||
List<Player> viewer = Collections.singletonList(player);
|
List<Player> viewer = Collections.singletonList(player);
|
||||||
List<Player> outsideViewers = PacketManager.getViewers(player.getLocation());
|
List<Player> outsideViewers = PacketManager.getViewers(player.getLocation());
|
||||||
|
// Send Equipment packet to all (Fixes Optifine Issue)
|
||||||
|
PacketManager.equipmentSlotUpdate(player, false, outsideViewers);
|
||||||
outsideViewers.remove(player);
|
outsideViewers.remove(player);
|
||||||
|
|
||||||
int entityId = player.getEntityId();
|
int entityId = player.getEntityId();
|
||||||
@@ -118,7 +122,6 @@ public class UserEmoteModel extends PlayerModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (user.getPlayer() != null) player.setInvisible(false);
|
if (user.getPlayer() != null) player.setInvisible(false);
|
||||||
PacketManager.equipmentSlotUpdate(player, false, outsideViewers);
|
|
||||||
user.getUserEmoteManager().despawnTextEntity();
|
user.getUserEmoteManager().despawnTextEntity();
|
||||||
user.showPlayer();
|
user.showPlayer();
|
||||||
user.showCosmetics();
|
user.showCosmetics();
|
||||||
|
|||||||
@@ -0,0 +1,81 @@
|
|||||||
|
package com.hibiscusmc.hmccosmetics.user.manager;
|
||||||
|
|
||||||
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||||
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUsers;
|
||||||
|
import com.hibiscusmc.hmccosmetics.util.PlayerUtils;
|
||||||
|
import com.hibiscusmc.hmccosmetics.util.packets.PacketManager;
|
||||||
|
import 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 lastUpdate = 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() - 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) {
|
||||||
|
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);
|
||||||
|
PacketManager.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);
|
||||||
|
PacketManager.sendEntityDestroyPacket(ids, List.of(viewerPlayer));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
viewers.removeAll(removePlayers);
|
||||||
|
lastUpdate = System.currentTimeMillis();
|
||||||
|
return newPlayers;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void teleport(Location location) {
|
||||||
|
this.location = location;
|
||||||
|
for (Integer entity : ids) {
|
||||||
|
PacketManager.sendTeleportPacket(entity, location, false, getViewers());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRotation(int yaw) {
|
||||||
|
location.setYaw(yaw);
|
||||||
|
for (Integer entity : ids) {
|
||||||
|
PacketManager.sendLookPacket(entity, location, getViewers());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,17 +1,20 @@
|
|||||||
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.Menus;
|
||||||
import com.hibiscusmc.hmccosmetics.nms.NMSHandlers;
|
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.ServerUtils;
|
||||||
import com.hibiscusmc.hmccosmetics.util.packets.PacketManager;
|
import com.hibiscusmc.hmccosmetics.util.packets.PacketManager;
|
||||||
|
import lombok.Getter;
|
||||||
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;
|
||||||
@@ -34,19 +37,33 @@ 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) {
|
||||||
@@ -101,6 +118,7 @@ public class UserWardrobeManager {
|
|||||||
// NPC 2
|
// NPC 2
|
||||||
Bukkit.getScheduler().runTaskLater(HMCCosmeticsPlugin.getInstance(), () -> {
|
Bukkit.getScheduler().runTaskLater(HMCCosmeticsPlugin.getInstance(), () -> {
|
||||||
PacketManager.sendFakePlayerSpawnPacket(npcLocation, WARDROBE_UUID, NPC_ID, viewer);
|
PacketManager.sendFakePlayerSpawnPacket(npcLocation, WARDROBE_UUID, NPC_ID, viewer);
|
||||||
|
PacketManager.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);
|
||||||
@@ -111,22 +129,27 @@ public class UserWardrobeManager {
|
|||||||
|
|
||||||
// Misc
|
// Misc
|
||||||
if (user.hasCosmeticInSlot(CosmeticSlot.BACKPACK)) {
|
if (user.hasCosmeticInSlot(CosmeticSlot.BACKPACK)) {
|
||||||
user.getUserBackpackManager().getArmorStand().teleport(npcLocation.clone().add(0, 2, 0));
|
// Maybe null as backpack maybe despawned before entering
|
||||||
|
if (user.getUserBackpackManager() == null) user.respawnBackpack();
|
||||||
|
user.getUserBackpackManager().getEntityManager().teleport(npcLocation.clone().add(0, 2, 0));
|
||||||
|
NMSHandlers.getHandler().equipmentSlotUpdate(user.getUserBackpackManager().getFirstArmorStandId(), EquipmentSlot.HEAD, user.getUserCosmeticItem(user.getCosmetic(CosmeticSlot.BACKPACK)), viewer);
|
||||||
PacketManager.ridingMountPacket(NPC_ID, user.getUserBackpackManager().getFirstArmorStandId(), viewer);
|
PacketManager.ridingMountPacket(NPC_ID, user.getUserBackpackManager().getFirstArmorStandId(), viewer);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (user.hasCosmeticInSlot(CosmeticSlot.BALLOON)) {
|
if (user.hasCosmeticInSlot(CosmeticSlot.BALLOON)) {
|
||||||
|
CosmeticBalloonType cosmetic = (CosmeticBalloonType) user.getCosmetic(CosmeticSlot.BALLOON);
|
||||||
user.getBalloonManager().sendRemoveLeashPacket(viewer);
|
user.getBalloonManager().sendRemoveLeashPacket(viewer);
|
||||||
user.getBalloonManager().sendLeashPacket(NPC_ID);
|
user.getBalloonManager().sendLeashPacket(NPC_ID);
|
||||||
//PacketManager.sendLeashPacket(VIEWER.getBalloonEntity().getModelId(), NPC_ID, viewer);
|
//PacketManager.sendLeashPacket(VIEWER.getBalloonEntity().getModelId(), NPC_ID, viewer);
|
||||||
|
|
||||||
PacketManager.sendTeleportPacket(user.getBalloonManager().getPufferfishBalloonId(), npcLocation.clone().add(Settings.getBalloonOffset()), false, viewer);
|
Location balloonLocation = npcLocation.clone().add(cosmetic.getBalloonOffset());
|
||||||
user.getBalloonManager().getModelEntity().teleport(npcLocation.clone().add(Settings.getBalloonOffset()));
|
PacketManager.sendTeleportPacket(user.getBalloonManager().getPufferfishBalloonId(), balloonLocation , false, viewer);
|
||||||
|
user.getBalloonManager().getModelEntity().teleport(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);
|
||||||
@@ -134,6 +157,11 @@ public class UserWardrobeManager {
|
|||||||
target.showBossBar(bossBar);
|
target.showBossBar(bossBar);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (WardrobeSettings.isEnterOpenMenu()) {
|
||||||
|
Menu menu = Menus.getDefaultMenu();
|
||||||
|
if (menu != null) menu.openMenu(user);
|
||||||
|
}
|
||||||
|
|
||||||
this.active = true;
|
this.active = true;
|
||||||
update();
|
update();
|
||||||
setWardrobeStatus(WardrobeStatus.RUNNING);
|
setWardrobeStatus(WardrobeStatus.RUNNING);
|
||||||
@@ -216,7 +244,7 @@ public class UserWardrobeManager {
|
|||||||
NMSHandlers.getHandler().equipmentSlotUpdate(user.getPlayer().getEntityId(), EquipmentSlot.HEAD, player.getInventory().getHelmet(), viewer);
|
NMSHandlers.getHandler().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);
|
||||||
@@ -263,13 +291,14 @@ public class UserWardrobeManager {
|
|||||||
if (user.hasCosmeticInSlot(CosmeticSlot.BACKPACK)) {
|
if (user.hasCosmeticInSlot(CosmeticSlot.BACKPACK)) {
|
||||||
PacketManager.sendTeleportPacket(user.getUserBackpackManager().getFirstArmorStandId(), location, false, viewer);
|
PacketManager.sendTeleportPacket(user.getUserBackpackManager().getFirstArmorStandId(), location, false, viewer);
|
||||||
PacketManager.ridingMountPacket(NPC_ID, user.getUserBackpackManager().getFirstArmorStandId(), viewer);
|
PacketManager.ridingMountPacket(NPC_ID, user.getUserBackpackManager().getFirstArmorStandId(), viewer);
|
||||||
user.getUserBackpackManager().getArmorStand().setRotation(nextyaw, 0);
|
user.getUserBackpackManager().getEntityManager().setRotation(nextyaw);
|
||||||
PacketManager.sendEntityDestroyPacket(user.getUserBackpackManager().getFirstArmorStandId(), outsideViewers);
|
PacketManager.sendEntityDestroyPacket(user.getUserBackpackManager().getFirstArmorStandId(), outsideViewers);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (user.hasCosmeticInSlot(CosmeticSlot.BALLOON)) {
|
if (user.hasCosmeticInSlot(CosmeticSlot.BALLOON)) {
|
||||||
PacketManager.sendTeleportPacket(user.getBalloonManager().getPufferfishBalloonId(), npcLocation.add(Settings.getBalloonOffset()), false, viewer);
|
// The two lines below broke, solved by listening to PlayerCosmeticPostEquipEvent
|
||||||
user.getBalloonManager().getModelEntity().teleport(npcLocation.add(Settings.getBalloonOffset()));
|
//PacketManager.sendTeleportPacket(user.getBalloonManager().getPufferfishBalloonId(), npcLocation.add(Settings.getBalloonOffset()), false, viewer);
|
||||||
|
//user.getBalloonManager().getModelEntity().teleport(npcLocation.add(Settings.getBalloonOffset()));
|
||||||
user.getBalloonManager().sendRemoveLeashPacket(outsideViewers);
|
user.getBalloonManager().sendRemoveLeashPacket(outsideViewers);
|
||||||
PacketManager.sendEntityDestroyPacket(user.getBalloonManager().getModelId(), outsideViewers);
|
PacketManager.sendEntityDestroyPacket(user.getBalloonManager().getModelId(), outsideViewers);
|
||||||
user.getBalloonManager().sendLeashPacket(NPC_ID);
|
user.getBalloonManager().sendLeashPacket(NPC_ID);
|
||||||
@@ -284,14 +313,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;
|
||||||
}
|
}
|
||||||
@@ -302,4 +323,5 @@ public class UserWardrobeManager {
|
|||||||
RUNNING,
|
RUNNING,
|
||||||
STOPPING,
|
STOPPING,
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -156,4 +156,12 @@ public class InventoryUtils {
|
|||||||
public static NamespacedKey getOwnerKey() {
|
public static NamespacedKey getOwnerKey() {
|
||||||
return new NamespacedKey(HMCCosmeticsPlugin.getInstance(), "owner");
|
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");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,10 +4,8 @@ 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.config.WardrobeSettings;
|
||||||
import com.hibiscusmc.hmccosmetics.hooks.Hooks;
|
import com.hibiscusmc.hmccosmetics.hooks.Hooks;
|
||||||
import com.hibiscusmc.hmccosmetics.hooks.placeholders.HMCPlaceholderExpansion;
|
|
||||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||||
import com.hibiscusmc.hmccosmetics.util.misc.Adventure;
|
import com.hibiscusmc.hmccosmetics.util.misc.Adventure;
|
||||||
import me.clip.placeholderapi.PlaceholderAPI;
|
|
||||||
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;
|
||||||
@@ -26,14 +24,16 @@ import java.util.logging.Level;
|
|||||||
public class MessagesUtil {
|
public class MessagesUtil {
|
||||||
|
|
||||||
private static String prefix;
|
private static String prefix;
|
||||||
private static final HashMap<String, String> messages = new HashMap<>();
|
private static final HashMap<String, String> MESSAGES = new HashMap<>();
|
||||||
|
|
||||||
public static void setup(@NotNull ConfigurationNode config) {
|
public static void setup(@NotNull ConfigurationNode config) {
|
||||||
|
MESSAGES.clear();
|
||||||
|
|
||||||
prefix = config.node("prefix").getString("");
|
prefix = config.node("prefix").getString("");
|
||||||
for (ConfigurationNode node : config.childrenMap().values()) {
|
for (ConfigurationNode node : config.childrenMap().values()) {
|
||||||
if (node.virtual()) continue;
|
if (node.virtual()) continue;
|
||||||
if (node.empty()) continue;
|
if (node.empty()) continue;
|
||||||
messages.put(node.key().toString(), node.getString());
|
MESSAGES.put(node.key().toString(), node.getString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -43,6 +43,7 @@ public class MessagesUtil {
|
|||||||
|
|
||||||
public static void sendMessage(Player player, String key) {
|
public static void sendMessage(Player player, String key) {
|
||||||
Component finalMessage = processString(player, key);
|
Component finalMessage = processString(player, key);
|
||||||
|
if (finalMessage == null) return;
|
||||||
Audience target = BukkitAudiences.create(HMCCosmeticsPlugin.getInstance()).player(player);
|
Audience target = BukkitAudiences.create(HMCCosmeticsPlugin.getInstance()).player(player);
|
||||||
|
|
||||||
target.sendMessage(finalMessage);
|
target.sendMessage(finalMessage);
|
||||||
@@ -58,6 +59,7 @@ public class MessagesUtil {
|
|||||||
|
|
||||||
public static void sendMessage(Player player, String key, TagResolver placeholder) {
|
public static void sendMessage(Player player, String key, TagResolver placeholder) {
|
||||||
Component finalMessage = processString(player, key, placeholder);
|
Component finalMessage = processString(player, key, placeholder);
|
||||||
|
if (finalMessage == null) return;
|
||||||
Audience target = BukkitAudiences.create(HMCCosmeticsPlugin.getInstance()).player(player);
|
Audience target = BukkitAudiences.create(HMCCosmeticsPlugin.getInstance()).player(player);
|
||||||
|
|
||||||
target.sendMessage(finalMessage);
|
target.sendMessage(finalMessage);
|
||||||
@@ -65,6 +67,7 @@ public class MessagesUtil {
|
|||||||
|
|
||||||
public static void sendMessageNoKey(Player player, String message) {
|
public static void sendMessageNoKey(Player player, String message) {
|
||||||
Component finalMessage = processStringNoKey(player, message);
|
Component finalMessage = processStringNoKey(player, message);
|
||||||
|
if (finalMessage == null) return;
|
||||||
Audience target = BukkitAudiences.create(HMCCosmeticsPlugin.getInstance()).player(player);
|
Audience target = BukkitAudiences.create(HMCCosmeticsPlugin.getInstance()).player(player);
|
||||||
|
|
||||||
target.sendMessage(finalMessage);
|
target.sendMessage(finalMessage);
|
||||||
@@ -72,6 +75,7 @@ public class MessagesUtil {
|
|||||||
|
|
||||||
public static void sendActionBar(Player player, String key) {
|
public static void sendActionBar(Player player, String key) {
|
||||||
Component finalMessage = processString(player, key);
|
Component finalMessage = processString(player, key);
|
||||||
|
if (finalMessage == null) return;
|
||||||
Audience target = BukkitAudiences.create(HMCCosmeticsPlugin.getInstance()).player(player);
|
Audience target = BukkitAudiences.create(HMCCosmeticsPlugin.getInstance()).player(player);
|
||||||
|
|
||||||
target.sendActionBar(finalMessage);
|
target.sendActionBar(finalMessage);
|
||||||
@@ -84,7 +88,7 @@ public class MessagesUtil {
|
|||||||
public static void sendTitle(Player player, String message, int fadein, int stay, int fadeout) {
|
public static void sendTitle(Player player, String message, int fadein, int stay, int fadeout) {
|
||||||
Audience target = BukkitAudiences.create(HMCCosmeticsPlugin.getInstance()).player(player);
|
Audience target = BukkitAudiences.create(HMCCosmeticsPlugin.getInstance()).player(player);
|
||||||
|
|
||||||
Title.Times times = Title.Times.times(Duration.ofMillis(WardrobeSettings.getTransitionFadeIn()), Duration.ofMillis(3000), Duration.ofMillis(1000));
|
Title.Times times = Title.Times.times(Duration.ofMillis(fadein), Duration.ofMillis(stay), Duration.ofMillis(fadeout));
|
||||||
Title title = Title.title(processStringNoKey(player, message), Component.empty(), times);
|
Title title = Title.title(processStringNoKey(player, message), Component.empty(), times);
|
||||||
|
|
||||||
target.showTitle(title);
|
target.showTitle(title);
|
||||||
@@ -96,10 +100,10 @@ public class MessagesUtil {
|
|||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public static Component processString(Player player, String key, TagResolver placeholders) {
|
public static Component processString(Player player, String key, TagResolver placeholders) {
|
||||||
if (!messages.containsKey(key)) return null;
|
if (!MESSAGES.containsKey(key)) return null;
|
||||||
if (messages.get(key) == null) return null;
|
if (MESSAGES.get(key) == null) return null;
|
||||||
String message = messages.get(key);
|
String message = MESSAGES.get(key);
|
||||||
if (Hooks.isActiveHook("PlaceholderAPI") && player != null) message = PlaceholderAPI.setPlaceholders(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 Adventure.MINI_MESSAGE.deserialize(message, placeholders);
|
||||||
@@ -120,7 +124,7 @@ public class MessagesUtil {
|
|||||||
@NotNull
|
@NotNull
|
||||||
public static Component processStringNoKey(Player player, String message, TagResolver placeholders) {
|
public static Component processStringNoKey(Player player, String message, TagResolver placeholders) {
|
||||||
message = message.replaceAll("%prefix%", prefix);
|
message = message.replaceAll("%prefix%", prefix);
|
||||||
if (Hooks.isActiveHook("PlaceholderAPI") && player != null) message = PlaceholderAPI.setPlaceholders(player, message);
|
if (player != null) message = Hooks.processPlaceholders(player, message);
|
||||||
if (placeholders != null ) {
|
if (placeholders != null ) {
|
||||||
return Adventure.MINI_MESSAGE.deserialize(message, placeholders);
|
return Adventure.MINI_MESSAGE.deserialize(message, placeholders);
|
||||||
}
|
}
|
||||||
@@ -129,7 +133,7 @@ public class MessagesUtil {
|
|||||||
|
|
||||||
public static String processStringNoKeyString(Player player, String message) {
|
public static String processStringNoKeyString(Player player, String message) {
|
||||||
message = message.replaceAll("%prefix%", prefix);
|
message = message.replaceAll("%prefix%", prefix);
|
||||||
if (Hooks.isActiveHook("PlaceholderAPI") && player != null) message = PlaceholderAPI.setPlaceholders(player, message);
|
if (player != null) message = Hooks.processPlaceholders(player, message);
|
||||||
return message;
|
return message;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -138,7 +142,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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -46,16 +46,6 @@ public class ServerUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return Color.WHITE;
|
return Color.WHITE;
|
||||||
/* Old method
|
|
||||||
try {
|
|
||||||
return Color.fromRGB(
|
|
||||||
Integer.valueOf(colorStr.substring(1, 3), 16),
|
|
||||||
Integer.valueOf(colorStr.substring(3, 5), 16),
|
|
||||||
Integer.valueOf(colorStr.substring(5, 7), 16));
|
|
||||||
} catch (StringIndexOutOfBoundsException e) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// particle amount offsetxyz
|
// particle amount offsetxyz
|
||||||
|
|||||||
@@ -0,0 +1,5 @@
|
|||||||
|
package com.hibiscusmc.hmccosmetics.util;
|
||||||
|
|
||||||
|
public record TranslationPair(String key, String value) {
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,39 +1,40 @@
|
|||||||
package com.hibiscusmc.hmccosmetics.util;
|
package com.hibiscusmc.hmccosmetics.util;
|
||||||
|
|
||||||
|
import com.hibiscusmc.hmccosmetics.util.misc.StringUtils;
|
||||||
import org.spongepowered.configurate.ConfigurationNode;
|
import org.spongepowered.configurate.ConfigurationNode;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class TranslationUtil {
|
public class TranslationUtil {
|
||||||
|
|
||||||
private static HashMap<String, String> keys = new HashMap<>();
|
// unlocked-cosmetic -> true -> True
|
||||||
|
private static final HashMap<String, List<TranslationPair>> keys = new HashMap<>();
|
||||||
|
|
||||||
public static void setup(ConfigurationNode config) {
|
public static void setup(ConfigurationNode config) {
|
||||||
// TODO: Finish this
|
keys.clear();
|
||||||
/*
|
|
||||||
for (ConfigurationNode node : config.childrenMap().values()) {
|
for (ConfigurationNode node : config.childrenMap().values()) {
|
||||||
HashMap<Pair> translableMessages = new HashMap<>();
|
ArrayList<TranslationPair> pairs = new ArrayList<>();
|
||||||
for (ConfigurationNode translatableMessage : node.childrenMap().values()) {
|
for (ConfigurationNode translatableMessage : node.childrenMap().values()) {
|
||||||
translableMessages.put( new Pair<>(translatableMessage.key().toString(), translatableMessage.getString()))
|
String key = translatableMessage.key().toString();
|
||||||
|
key = key.replaceAll("'", ""); // Autoupdater adds ' to it? Removes it from the key
|
||||||
|
TranslationPair pair = new TranslationPair(key, translatableMessage.getString());
|
||||||
|
pairs.add(pair);
|
||||||
MessagesUtil.sendDebugMessages("setupTranslation key:" + node.key().toString() + " | " + node);
|
MessagesUtil.sendDebugMessages("setupTranslation key:" + node.key().toString() + " | " + node);
|
||||||
|
MessagesUtil.sendDebugMessages("Overall Key " + node.key().toString());
|
||||||
|
MessagesUtil.sendDebugMessages("Key '" + pair.key() + "' Value '" + pair.value() + "'");
|
||||||
}
|
}
|
||||||
keys.put(node.key().toString().toLowerCase(), HashMap);
|
keys.put(node.key().toString().toLowerCase(), pairs);
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getTranslation(String key, String message) {
|
public static String getTranslation(String key, String message) {
|
||||||
// TODO: Finish this
|
List<TranslationPair> pairs = keys.get(key);
|
||||||
return message;
|
for (TranslationPair pair : pairs) {
|
||||||
/*
|
if (pair.key().equals(message)) return StringUtils.parseStringToString(pair.value());
|
||||||
key = key.toLowerCase();
|
|
||||||
MessagesUtil.sendDebugMessages("getTranslation key:" + key + " | " + message);
|
|
||||||
if (!keys.containsKey(key)) return message;
|
|
||||||
List<Pair> config = keys.get(key);
|
|
||||||
if (config.getFirst() == message) {
|
|
||||||
return config.getSecond().toString();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return message;
|
return message;
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,215 +0,0 @@
|
|||||||
package com.hibiscusmc.hmccosmetics.util.builder;
|
|
||||||
|
|
||||||
import com.hibiscusmc.hmccosmetics.util.misc.Placeholder;
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.enchantments.Enchantment;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.inventory.ItemFlag;
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
|
||||||
import org.bukkit.inventory.meta.ItemMeta;
|
|
||||||
import org.jetbrains.annotations.Contract;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
public class ItemBuilder {
|
|
||||||
|
|
||||||
protected Material material;
|
|
||||||
protected int amount;
|
|
||||||
protected ItemMeta itemMeta;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param material builder material
|
|
||||||
*/
|
|
||||||
|
|
||||||
ItemBuilder(final Material material) {
|
|
||||||
this.material = material;
|
|
||||||
this.itemMeta = Bukkit.getItemFactory().getItemMeta(material);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param itemStack builder ItemStack
|
|
||||||
*/
|
|
||||||
|
|
||||||
ItemBuilder(final @NotNull ItemStack itemStack) {
|
|
||||||
this.material = itemStack.getType();
|
|
||||||
this.itemMeta = itemStack.hasItemMeta() ? itemStack.getItemMeta()
|
|
||||||
: Bukkit.getItemFactory().getItemMeta(this.material);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param material builder material
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
|
|
||||||
@Contract("_ -> new")
|
|
||||||
@NotNull
|
|
||||||
public static ItemBuilder from(final Material material) {
|
|
||||||
return new ItemBuilder(material);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param itemStack builder ItemStack
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@Contract("_ -> new")
|
|
||||||
@NotNull
|
|
||||||
public static ItemBuilder from(final ItemStack itemStack) {
|
|
||||||
return new ItemBuilder(itemStack);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param amount ItemStack amount
|
|
||||||
* @return this
|
|
||||||
*/
|
|
||||||
|
|
||||||
public ItemBuilder amount(final int amount) {
|
|
||||||
this.amount = Math.min(Math.max(1, amount), 64);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param name ItemStack name
|
|
||||||
* @return this
|
|
||||||
*/
|
|
||||||
|
|
||||||
public ItemBuilder name(final String name) {
|
|
||||||
if (this.itemMeta == null) {
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
this.itemMeta.setDisplayName(name);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param lore ItemStack lore
|
|
||||||
* @return this
|
|
||||||
*/
|
|
||||||
|
|
||||||
public ItemBuilder lore(final List<String> lore) {
|
|
||||||
if (this.itemMeta == null) {
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
this.itemMeta.setLore(lore);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ItemBuilder papiPlaceholders(final Player player) {
|
|
||||||
this.lorePapiPlaceholders(player);
|
|
||||||
this.namePapiPlaceholders(player);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void lorePapiPlaceholders(final Player player) {
|
|
||||||
if (this.itemMeta == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
final List<String> newLore = new ArrayList<>();
|
|
||||||
|
|
||||||
final List<String> lore = this.itemMeta.getLore();
|
|
||||||
|
|
||||||
if (lore == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (final String line : this.itemMeta.getLore()) {
|
|
||||||
newLore.add(Placeholder.applyPapiPlaceholders(player, line));
|
|
||||||
}
|
|
||||||
|
|
||||||
this.itemMeta.setLore(newLore);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void namePapiPlaceholders(final Player player) {
|
|
||||||
if (this.itemMeta == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.itemMeta.setDisplayName(
|
|
||||||
Placeholder.applyPapiPlaceholders(
|
|
||||||
player,
|
|
||||||
this.itemMeta.getDisplayName()
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param unbreakable whether the ItemStack is unbreakable
|
|
||||||
* @return this
|
|
||||||
*/
|
|
||||||
|
|
||||||
public ItemBuilder unbreakable(final boolean unbreakable) {
|
|
||||||
if (this.itemMeta == null) {
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
this.itemMeta.setUnbreakable(unbreakable);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ItemBuilder glow(final boolean glow) {
|
|
||||||
if (this.itemMeta == null) {
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
if (glow) {
|
|
||||||
this.itemMeta.addItemFlags(ItemFlag.HIDE_ENCHANTS);
|
|
||||||
this.itemMeta.addEnchant(Enchantment.LUCK, 1, true);
|
|
||||||
}
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param enchantments enchants to be added to the ItemStack
|
|
||||||
* @param ignoreLeveLRestrictions whether to ignore enchantment level restrictions
|
|
||||||
* @return this
|
|
||||||
*/
|
|
||||||
|
|
||||||
public ItemBuilder enchants(final Map<Enchantment, Integer> enchantments,
|
|
||||||
boolean ignoreLeveLRestrictions) {
|
|
||||||
if (this.itemMeta == null) {
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
enchantments.forEach((enchantment, level) -> this.itemMeta.addEnchant(enchantment, level,
|
|
||||||
ignoreLeveLRestrictions));
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param itemFlags ItemStack ItemFlags
|
|
||||||
* @return this
|
|
||||||
*/
|
|
||||||
|
|
||||||
public ItemBuilder itemFlags(final Set<ItemFlag> itemFlags) {
|
|
||||||
if (this.itemMeta == null) {
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
this.itemMeta.addItemFlags(itemFlags.toArray(new ItemFlag[0]));
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param modelData ItemStack modelData
|
|
||||||
* @return this
|
|
||||||
*/
|
|
||||||
|
|
||||||
public ItemBuilder modelData(final int modelData) {
|
|
||||||
if (this.itemMeta == null) {
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
this.itemMeta.setCustomModelData(modelData);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return built ItemStack
|
|
||||||
*/
|
|
||||||
|
|
||||||
public ItemStack build() {
|
|
||||||
final ItemStack itemStack = new ItemStack(this.material, Math.max(this.amount, 1));
|
|
||||||
itemStack.setItemMeta(itemMeta);
|
|
||||||
return itemStack;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,75 +0,0 @@
|
|||||||
package com.hibiscusmc.hmccosmetics.util.misc;
|
|
||||||
|
|
||||||
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
|
|
||||||
import org.bukkit.NamespacedKey;
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
|
||||||
import org.bukkit.inventory.meta.ItemMeta;
|
|
||||||
import org.bukkit.persistence.PersistentDataType;
|
|
||||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
|
|
||||||
public class Keys {
|
|
||||||
|
|
||||||
static HMCCosmeticsPlugin plugin = HMCCosmeticsPlugin.getInstance();
|
|
||||||
public static final NamespacedKey ITEM_KEY = new NamespacedKey(plugin, "cosmetic");
|
|
||||||
public static final NamespacedKey TOKEN_KEY = new NamespacedKey(plugin, "token-key");
|
|
||||||
|
|
||||||
public static void setKey(final @NotNull ItemStack itemStack) {
|
|
||||||
final ItemMeta itemMeta = itemStack.getItemMeta();
|
|
||||||
|
|
||||||
if (itemMeta == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
itemMeta.getPersistentDataContainer().set(ITEM_KEY, PersistentDataType.BYTE, (byte) 1);
|
|
||||||
|
|
||||||
itemStack.setItemMeta(itemMeta);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static <T, Z> void setKey(
|
|
||||||
final @NotNull ItemStack itemStack,
|
|
||||||
final NamespacedKey key,
|
|
||||||
final PersistentDataType<T, Z> type,
|
|
||||||
final Z value) {
|
|
||||||
final ItemMeta itemMeta = itemStack.getItemMeta();
|
|
||||||
|
|
||||||
if (itemMeta == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
itemMeta.getPersistentDataContainer().set(key, type, value);
|
|
||||||
|
|
||||||
itemStack.setItemMeta(itemMeta);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean hasKey(final @NotNull ItemStack itemStack) {
|
|
||||||
final ItemMeta itemMeta = itemStack.getItemMeta();
|
|
||||||
|
|
||||||
if (itemMeta == null) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return itemMeta.getPersistentDataContainer().has(ITEM_KEY, PersistentDataType.BYTE);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static <T, Z> boolean hasKey(final @NotNull ItemStack itemStack, final NamespacedKey key, final PersistentDataType<T, Z> type) {
|
|
||||||
final ItemMeta itemMeta = itemStack.getItemMeta();
|
|
||||||
|
|
||||||
if (itemMeta == null) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return itemMeta.getPersistentDataContainer().has(key, type);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nullable
|
|
||||||
public static <T, Z> Z getValue(final @NotNull ItemStack itemStack, final NamespacedKey key, final PersistentDataType<T, Z> type) {
|
|
||||||
final ItemMeta itemMeta = itemStack.getItemMeta();
|
|
||||||
|
|
||||||
if (itemMeta == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return itemMeta.getPersistentDataContainer().get(key, type);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,33 +0,0 @@
|
|||||||
package com.hibiscusmc.hmccosmetics.util.misc;
|
|
||||||
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.jetbrains.annotations.Nullable;
|
|
||||||
|
|
||||||
public class Placeholder {
|
|
||||||
|
|
||||||
public static final String PREFIX = "%prefix%";
|
|
||||||
public static final String TYPE = "%type%";
|
|
||||||
public static final String ITEM = "%item%";
|
|
||||||
public static final String FILE = "%file%";
|
|
||||||
|
|
||||||
public static final String PLAYER = "%player%";
|
|
||||||
public static final String ENABLED = "%enabled%";
|
|
||||||
public static final String ALLOWED = "%allowed%";
|
|
||||||
public static final String ID = "%id%";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return message with placeholders applied
|
|
||||||
*/
|
|
||||||
|
|
||||||
public static String applyPapiPlaceholders(@Nullable final Player player,
|
|
||||||
final String message) {
|
|
||||||
/*
|
|
||||||
if (HookManager.getInstance().isEnabled(PAPIHook.class)) {
|
|
||||||
return HookManager.getInstance().getPapiHook().parse(player, message);
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
return message;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -9,6 +9,7 @@ import com.hibiscusmc.hmccosmetics.cosmetic.CosmeticSlot;
|
|||||||
import com.hibiscusmc.hmccosmetics.nms.NMSHandlers;
|
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.InventoryUtils;
|
||||||
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||||
import com.hibiscusmc.hmccosmetics.util.PlayerUtils;
|
import com.hibiscusmc.hmccosmetics.util.PlayerUtils;
|
||||||
import com.hibiscusmc.hmccosmetics.util.packets.wrappers.WrapperPlayServerNamedEntitySpawn;
|
import com.hibiscusmc.hmccosmetics.util.packets.wrappers.WrapperPlayServerNamedEntitySpawn;
|
||||||
@@ -17,6 +18,7 @@ import com.hibiscusmc.hmccosmetics.util.packets.wrappers.WrapperPlayServerRelEnt
|
|||||||
import it.unimi.dsi.fastutil.ints.IntArrayList;
|
import it.unimi.dsi.fastutil.ints.IntArrayList;
|
||||||
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.Entity;
|
||||||
import org.bukkit.entity.EntityType;
|
import org.bukkit.entity.EntityType;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@@ -31,6 +33,15 @@ import java.util.UUID;
|
|||||||
|
|
||||||
public class PacketManager extends BasePacket {
|
public class PacketManager extends BasePacket {
|
||||||
|
|
||||||
|
public static void sendEntitySpawnPacket(
|
||||||
|
final @NotNull Location location,
|
||||||
|
final int entityId,
|
||||||
|
final EntityType entityType,
|
||||||
|
final UUID uuid
|
||||||
|
) {
|
||||||
|
sendEntitySpawnPacket(location, entityId, entityType, uuid, getViewers(location));
|
||||||
|
}
|
||||||
|
|
||||||
public static void sendEntitySpawnPacket(
|
public static void sendEntitySpawnPacket(
|
||||||
final @NotNull Location location,
|
final @NotNull Location location,
|
||||||
final int entityId,
|
final int entityId,
|
||||||
@@ -97,7 +108,7 @@ public class PacketManager extends BasePacket {
|
|||||||
CosmeticSlot cosmeticSlot,
|
CosmeticSlot cosmeticSlot,
|
||||||
List<Player> sendTo
|
List<Player> sendTo
|
||||||
) {
|
) {
|
||||||
equipmentSlotUpdate(user.getPlayer().getEntityId(), user, cosmeticSlot, sendTo);
|
equipmentSlotUpdate(user.getEntity().getEntityId(), user, cosmeticSlot, sendTo);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void equipmentSlotUpdate(
|
public static void equipmentSlotUpdate(
|
||||||
@@ -108,7 +119,7 @@ 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);
|
NMSHandlers.getHandler().equipmentSlotUpdate(entityId, InventoryUtils.getEquipmentSlot(cosmeticSlot), user.getUserCosmeticItem(cosmeticSlot), sendTo);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void armorStandMetaPacket(
|
public static void armorStandMetaPacket(
|
||||||
@@ -136,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_17_R1") || NMSHandlers.getVersion().contains("v1_18_R2") || NMSHandlers.getVersion().contains("v1_19_R1")) {
|
if (NMSHandlers.getVersion().contains("v1_18_R2") || NMSHandlers.getVersion().contains("v1_19_R1")) {
|
||||||
wrapper.setObject(new WrappedDataWatcher.WrappedDataWatcherObject(0, WrappedDataWatcher.Registry.get(Byte.class)), (byte) 0x20);
|
wrapper.setObject(new WrappedDataWatcher.WrappedDataWatcherObject(0, WrappedDataWatcher.Registry.get(Byte.class)), (byte) 0x20);
|
||||||
packet.getWatchableCollectionModifier().write(0, wrapper.getWatchableObjects());
|
packet.getWatchableCollectionModifier().write(0, wrapper.getWatchableObjects());
|
||||||
} else {
|
} else {
|
||||||
@@ -145,7 +156,29 @@ public class PacketManager extends BasePacket {
|
|||||||
packet.getDataValueCollectionModifier().write(0, wrappedDataValueList);
|
packet.getDataValueCollectionModifier().write(0, wrappedDataValueList);
|
||||||
}
|
}
|
||||||
for (Player p : sendTo) sendPacket(p, packet);
|
for (Player p : sendTo) sendPacket(p, packet);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void sendCloudEffect(
|
||||||
|
int entityId,
|
||||||
|
List<Player> sendTo
|
||||||
|
) {
|
||||||
|
PacketContainer packet = new PacketContainer(PacketType.Play.Server.ENTITY_METADATA);
|
||||||
|
packet.getModifier().writeDefaults();
|
||||||
|
packet.getIntegers().write(0, entityId);
|
||||||
|
WrappedDataWatcher wrapper = new WrappedDataWatcher();
|
||||||
|
|
||||||
|
if (NMSHandlers.getVersion().contains("v1_18_R2") || NMSHandlers.getVersion().contains("v1_19_R1")) {
|
||||||
|
wrapper.setObject(new WrappedDataWatcher.WrappedDataWatcherObject(0, WrappedDataWatcher.Registry.get(Byte.class)), (byte) 0x20);
|
||||||
|
wrapper.setObject(new WrappedDataWatcher.WrappedDataWatcherObject(8, WrappedDataWatcher.Registry.get(Float.class)), 0f);
|
||||||
|
packet.getWatchableCollectionModifier().write(0, wrapper.getWatchableObjects());
|
||||||
|
} else {
|
||||||
|
final List<WrappedDataValue> wrappedDataValueList = Lists.newArrayList();
|
||||||
|
wrappedDataValueList.add(new WrappedDataValue(0, WrappedDataWatcher.Registry.get(Byte.class), (byte) 0x20));
|
||||||
|
wrappedDataValueList.add(new WrappedDataValue(8, WrappedDataWatcher.Registry.get(Float.class), 0f));
|
||||||
|
//wrappedDataValueList.add(new WrappedDataValue(11, WrappedDataWatcher.Registry.get(Integer.class), 21));
|
||||||
|
packet.getDataValueCollectionModifier().write(0, wrappedDataValueList);
|
||||||
|
}
|
||||||
|
for (Player p : sendTo) sendPacket(p, packet);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void sendLookPacket(
|
public static void sendLookPacket(
|
||||||
@@ -218,6 +251,25 @@ public class PacketManager extends BasePacket {
|
|||||||
sendRidingPacket(mountId, passengerId, getViewers(location));
|
sendRidingPacket(mountId, passengerId, getViewers(location));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Mostly to deal with backpacks, this deals with entities riding other entities.
|
||||||
|
* @param mountId The entity that is the "mount", ex. a player
|
||||||
|
* @param passengerIds The entities that are riding the mount, ex. a armorstand for a backpack
|
||||||
|
* @param sendTo Whom to send the packet to
|
||||||
|
*/
|
||||||
|
public static void sendRidingPacket(
|
||||||
|
final int mountId,
|
||||||
|
final int[] passengerIds,
|
||||||
|
final @NotNull List<Player> sendTo
|
||||||
|
) {
|
||||||
|
PacketContainer packet = new PacketContainer(PacketType.Play.Server.MOUNT);
|
||||||
|
packet.getIntegers().write(0, mountId);
|
||||||
|
packet.getIntegerArrays().write(0, passengerIds);
|
||||||
|
for (final Player p : sendTo) {
|
||||||
|
sendPacket(p, packet);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Mostly to deal with backpacks, this deals with entities riding other entities.
|
* Mostly to deal with backpacks, this deals with entities riding other entities.
|
||||||
* @param mountId The entity that is the "mount", ex. a player
|
* @param mountId The entity that is the "mount", ex. a player
|
||||||
@@ -229,12 +281,7 @@ public class PacketManager extends BasePacket {
|
|||||||
final int passengerId,
|
final int passengerId,
|
||||||
final @NotNull List<Player> sendTo
|
final @NotNull List<Player> sendTo
|
||||||
) {
|
) {
|
||||||
PacketContainer packet = new PacketContainer(PacketType.Play.Server.MOUNT);
|
sendRidingPacket(mountId, new int[] {passengerId}, sendTo);
|
||||||
packet.getIntegers().write(0, mountId);
|
|
||||||
packet.getIntegerArrays().write(0, new int[]{passengerId});
|
|
||||||
for (final Player p : sendTo) {
|
|
||||||
sendPacket(p, packet);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -248,6 +295,18 @@ public class PacketManager extends BasePacket {
|
|||||||
for (final Player p : sendTo) sendPacket(p, packet);
|
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
|
* Sends a camera packet
|
||||||
* @param entityId The Entity ID that camera will go towards
|
* @param entityId The Entity ID that camera will go towards
|
||||||
@@ -306,8 +365,8 @@ public class PacketManager extends BasePacket {
|
|||||||
WrappedGameProfile wrappedGameProfile = new WrappedGameProfile(uuid, name);
|
WrappedGameProfile wrappedGameProfile = new WrappedGameProfile(uuid, name);
|
||||||
WrappedSignedProperty skinData = PlayerUtils.getSkin(skinnedPlayer);
|
WrappedSignedProperty skinData = PlayerUtils.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, every other verison 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_19_R1")) {
|
if (NMSHandlers.getVersion().contains("v1_18_R2") || NMSHandlers.getVersion().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,
|
||||||
@@ -350,9 +409,16 @@ public class PacketManager extends BasePacket {
|
|||||||
packet.getModifier().writeDefaults();
|
packet.getModifier().writeDefaults();
|
||||||
packet.getIntegers().write(0, playerId);
|
packet.getIntegers().write(0, playerId);
|
||||||
WrappedDataWatcher wrapper = new WrappedDataWatcher();
|
WrappedDataWatcher wrapper = new WrappedDataWatcher();
|
||||||
wrapper.setObject(new WrappedDataWatcher.WrappedDataWatcherObject(17, WrappedDataWatcher.Registry.get(Byte.class)), mask);
|
|
||||||
wrapper.setObject(new WrappedDataWatcher.WrappedDataWatcherObject(15, WrappedDataWatcher.Registry.get(Byte.class)), (byte) 0x10);
|
if (NMSHandlers.getVersion().contains("v1_18_R2") || NMSHandlers.getVersion().contains("v1_19_R1")) {
|
||||||
packet.getWatchableCollectionModifier().write(0, wrapper.getWatchableObjects());
|
wrapper.setObject(new WrappedDataWatcher.WrappedDataWatcherObject(17, WrappedDataWatcher.Registry.get(Byte.class)), mask);
|
||||||
|
packet.getWatchableCollectionModifier().write(0, wrapper.getWatchableObjects());
|
||||||
|
} else {
|
||||||
|
final List<WrappedDataValue> wrappedDataValueList = Lists.newArrayList();
|
||||||
|
wrappedDataValueList.add(new WrappedDataValue(17, WrappedDataWatcher.Registry.get(Byte.class), mask));
|
||||||
|
packet.getDataValueCollectionModifier().write(0, wrappedDataValueList);
|
||||||
|
}
|
||||||
|
|
||||||
for (final Player p : sendTo) {
|
for (final Player p : sendTo) {
|
||||||
sendPacket(p, packet);
|
sendPacket(p, packet);
|
||||||
}
|
}
|
||||||
@@ -364,13 +430,15 @@ public class PacketManager extends BasePacket {
|
|||||||
* @param uuid What is the fake player UUID
|
* @param uuid What is the fake player UUID
|
||||||
* @param sendTo Whom to send the packet to
|
* @param sendTo Whom to send the packet to
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
public static void sendRemovePlayerPacket(
|
public static void sendRemovePlayerPacket(
|
||||||
final Player player,
|
final Player player,
|
||||||
final UUID uuid,
|
final UUID uuid,
|
||||||
final List<Player> sendTo
|
final List<Player> sendTo
|
||||||
) {
|
) {
|
||||||
if (NMSHandlers.getVersion().contains("v1_17_R1") || NMSHandlers.getVersion().contains("v1_18_R2") || NMSHandlers.getVersion().contains("v1_19_R1")) {
|
if (NMSHandlers.getVersion().contains("v1_18_R2") || NMSHandlers.getVersion().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
|
||||||
info.setAction(EnumWrappers.PlayerInfoAction.REMOVE_PLAYER);
|
info.setAction(EnumWrappers.PlayerInfoAction.REMOVE_PLAYER);
|
||||||
|
|
||||||
String name = "Mannequin-" + player.getEntityId();
|
String name = "Mannequin-" + player.getEntityId();
|
||||||
@@ -468,18 +536,9 @@ public class PacketManager extends BasePacket {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void sendMovePacket(
|
|
||||||
final int entityId,
|
|
||||||
final Location from,
|
|
||||||
final Location to,
|
|
||||||
final boolean onGround
|
|
||||||
) {
|
|
||||||
sendMovePacket(entityId, from, to, onGround, getViewers(to));
|
|
||||||
}
|
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public static List<Player> getViewers(Location location) {
|
public static List<Player> getViewers(Location location) {
|
||||||
ArrayList<Player> viewers = new ArrayList();
|
ArrayList<Player> viewers = new ArrayList<>();
|
||||||
if (Settings.getViewDistance() <= 0) {
|
if (Settings.getViewDistance() <= 0) {
|
||||||
viewers.addAll(location.getWorld().getPlayers());
|
viewers.addAll(location.getWorld().getPlayers());
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ config-version: 1
|
|||||||
default-menu: defaultmenu
|
default-menu: defaultmenu
|
||||||
debug-mode: false
|
debug-mode: false
|
||||||
database-settings:
|
database-settings:
|
||||||
type: sqlite #MYSQL, SQLite, INTERNAL (not recommended!)
|
type: sqlite #MYSQL, SQLite
|
||||||
mysql:
|
mysql:
|
||||||
database: database
|
database: database
|
||||||
password: cherryBomb
|
password: cherryBomb
|
||||||
@@ -22,12 +22,19 @@ cosmetic-settings:
|
|||||||
|
|
||||||
unapply-on-death: false # If when a player dies, their cosmetics should be unapplied. If this is true, use hmccosmetics.unapplydeath.bypass to bypass
|
unapply-on-death: false # If when a player dies, their cosmetics should be unapplied. If this is true, use hmccosmetics.unapplydeath.bypass to bypass
|
||||||
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.
|
||||||
|
|
||||||
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
|
||||||
|
|
||||||
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.
|
||||||
@@ -47,6 +54,25 @@ cosmetic-settings:
|
|||||||
x: 0.5
|
x: 0.5
|
||||||
y: 3
|
y: 3
|
||||||
z: 0.5
|
z: 0.5
|
||||||
|
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:
|
||||||
|
# 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
|
||||||
|
unequip-click: "ANY" # ANY or ClickType, https://jd.papermc.io/paper/1.20/org/bukkit/event/inventory/ClickType.html
|
||||||
dye-menu:
|
dye-menu:
|
||||||
# If you use ItemsAdder, set this to "§f:offset_-8::dye_menu:"
|
# If you use ItemsAdder, set this to "§f:offset_-8::dye_menu:"
|
||||||
# If you use Oraxen, set this to "<glyph:neg_shift_8><glyph:dye_menu>"
|
# If you use Oraxen, set this to "<glyph:neg_shift_8><glyph:dye_menu>"
|
||||||
@@ -74,6 +100,9 @@ wardrobe:
|
|||||||
# If players in wardrobes should be able to equip any cosmetic, regardless of permission (Cosmetics they do not have access to will be removed when they leave the wardrobe)
|
# If players in wardrobes should be able to equip any cosmetic, regardless of permission (Cosmetics they do not have access to will be removed when they leave the wardrobe)
|
||||||
unchecked-wardrobe-cosmetics: false
|
unchecked-wardrobe-cosmetics: false
|
||||||
|
|
||||||
|
menu-options:
|
||||||
|
enter-open-menu: false # If the menu should open when a player enters a wardrobe
|
||||||
|
|
||||||
gamemode-options:
|
gamemode-options:
|
||||||
exit-gamemode-enabled: false # Setting this to false will set the gamemode the player came in as. True sets to exit-gamemode gamemode
|
exit-gamemode-enabled: false # Setting this to false will set the gamemode the player came in as. True sets to exit-gamemode gamemode
|
||||||
exit-gamemode: "SURVIVAL" # Only activates if exit-gamemode-enabled is true, find gamemodes here: https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/GameMode.html
|
exit-gamemode: "SURVIVAL" # Only activates if exit-gamemode-enabled is true, find gamemodes here: https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/GameMode.html
|
||||||
|
|||||||
@@ -15,6 +15,11 @@ backpack:
|
|||||||
model-data: 4
|
model-data: 4
|
||||||
name: "<blue>Backpack"
|
name: "<blue>Backpack"
|
||||||
amount: 1
|
amount: 1
|
||||||
|
firstperson-item:
|
||||||
|
material: PAPER
|
||||||
|
model-data: 8
|
||||||
|
name: "<white>Backpack"
|
||||||
|
amount: 1
|
||||||
future_wings:
|
future_wings:
|
||||||
slot: BACKPACK
|
slot: BACKPACK
|
||||||
permission: "hmccosmetics.future_wings"
|
permission: "hmccosmetics.future_wings"
|
||||||
@@ -23,6 +28,11 @@ future_wings:
|
|||||||
model-data: 9
|
model-data: 9
|
||||||
name: "<#d24c9f>Future Wings"
|
name: "<#d24c9f>Future Wings"
|
||||||
amount: 1
|
amount: 1
|
||||||
|
firstperson-item:
|
||||||
|
material: PAPER
|
||||||
|
model-data: 10
|
||||||
|
name: "<white>Future Wings"
|
||||||
|
amount: 1
|
||||||
lantern_cosmetic:
|
lantern_cosmetic:
|
||||||
slot: OFFHAND
|
slot: OFFHAND
|
||||||
permission: "hmccosmetics.lantern_cosmetic"
|
permission: "hmccosmetics.lantern_cosmetic"
|
||||||
@@ -55,6 +65,11 @@ jetpack:
|
|||||||
model-data: 12
|
model-data: 12
|
||||||
name: "<blue>Jetpack"
|
name: "<blue>Jetpack"
|
||||||
amount: 1
|
amount: 1
|
||||||
|
firstperson-item:
|
||||||
|
material: PAPER
|
||||||
|
model-data: 14
|
||||||
|
name: "<white>Jetpack"
|
||||||
|
amount: 1
|
||||||
hammer:
|
hammer:
|
||||||
slot: OFFHAND
|
slot: OFFHAND
|
||||||
permission: "hmccosmetics.hammer"
|
permission: "hmccosmetics.hammer"
|
||||||
@@ -111,6 +126,11 @@ explorer_backpack:
|
|||||||
model-data: 3
|
model-data: 3
|
||||||
name: "<white>Explorer's Backpack"
|
name: "<white>Explorer's Backpack"
|
||||||
amount: 1
|
amount: 1
|
||||||
|
firstperson-item:
|
||||||
|
material: LEATHER_HORSE_ARMOR
|
||||||
|
model-data: 5
|
||||||
|
name: "<white>Explorer's Backpack"
|
||||||
|
amount: 1
|
||||||
garbage_truck_balloon:
|
garbage_truck_balloon:
|
||||||
slot: BALLOON
|
slot: BALLOON
|
||||||
permission: "hmccosmetics.garbage_truck_balloon"
|
permission: "hmccosmetics.garbage_truck_balloon"
|
||||||
@@ -129,3 +149,12 @@ earth_day_grabber:
|
|||||||
model-data: 4
|
model-data: 4
|
||||||
name: "<green>Earth Day Grabber"
|
name: "<green>Earth Day Grabber"
|
||||||
amount: 1
|
amount: 1
|
||||||
|
hibiscus_flower:
|
||||||
|
slot: HELMET
|
||||||
|
dyeable: true
|
||||||
|
permission: "hmccosmetics.hibiscus_flower"
|
||||||
|
item:
|
||||||
|
material: PAPER
|
||||||
|
model-data: 15
|
||||||
|
name: "<#d24c9f>Hibiscus Flower"
|
||||||
|
amount: 1
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
title: "<white>"
|
title: "<white>"
|
||||||
rows: 6
|
rows: 6
|
||||||
|
refresh-rate: 20 # Set to -1 or remove to disable auto-updating, leading to it only using event-based updates.
|
||||||
items:
|
items:
|
||||||
beanie:
|
beanie:
|
||||||
slots:
|
slots:
|
||||||
@@ -190,3 +191,14 @@ items:
|
|||||||
- "<gray>Allowed: <#6D9DC5>%HMCCosmetics_unlocked_earth_day_grabber%"
|
- "<gray>Allowed: <#6D9DC5>%HMCCosmetics_unlocked_earth_day_grabber%"
|
||||||
type: cosmetic
|
type: cosmetic
|
||||||
cosmetic: earth_day_grabber
|
cosmetic: earth_day_grabber
|
||||||
|
hibiscus_flower:
|
||||||
|
slots:
|
||||||
|
- 18
|
||||||
|
item:
|
||||||
|
material: hmccosmetics:hibiscus_flower
|
||||||
|
lore:
|
||||||
|
- ""
|
||||||
|
- "<gray>Enabled: <#6D9DC5>%HMCCosmetics_equipped_hibiscus_flower%"
|
||||||
|
- "<gray>Allowed: <#6D9DC5>%HMCCosmetics_unlocked_hibiscus_flower%"
|
||||||
|
type: cosmetic
|
||||||
|
cosmetic: hibiscus_flower
|
||||||
@@ -1,3 +1,8 @@
|
|||||||
|
#
|
||||||
|
# Messages.yml File
|
||||||
|
# If you don't wish for a message to be sent, simply make it blank.
|
||||||
|
#
|
||||||
|
|
||||||
prefix: "<gradient:#f368ec:#f39cef>HMCCosmetics <GRAY>»<WHITE>"
|
prefix: "<gradient:#f368ec:#f39cef>HMCCosmetics <GRAY>»<WHITE>"
|
||||||
reloaded: "%prefix% <gradient:#6D9DC5:#45CDE9>Config files reloaded!"
|
reloaded: "%prefix% <gradient:#6D9DC5:#45CDE9>Config files reloaded!"
|
||||||
not-enough-args: "%prefix% <red>Improper amount of arguments"
|
not-enough-args: "%prefix% <red>Improper amount of arguments"
|
||||||
@@ -20,6 +25,7 @@ equip-cosmetic: "%prefix% <gradient:#6D9DC5:#45CDE9>You have equipped <cosmetic>
|
|||||||
unequip-cosmetic: "%prefix% <gradient:#6D9DC5:#45CDE9>You have unequipped <cosmetic>!"
|
unequip-cosmetic: "%prefix% <gradient:#6D9DC5:#45CDE9>You have unequipped <cosmetic>!"
|
||||||
hide-cosmetic: "%prefix% <gradient:#6D9DC5:#45CDE9>Hidden cosmetics"
|
hide-cosmetic: "%prefix% <gradient:#6D9DC5:#45CDE9>Hidden cosmetics"
|
||||||
show-cosmetic: "%prefix% <gradient:#6D9DC5:#45CDE9>Revealed cosmetics!"
|
show-cosmetic: "%prefix% <gradient:#6D9DC5:#45CDE9>Revealed cosmetics!"
|
||||||
|
hidden-cosmetics: "%prefix% <red>Your cosmetics are hidden!"
|
||||||
|
|
||||||
emote-blocked: "%prefix% <red>You can not use your emote here!"
|
emote-blocked: "%prefix% <red>You can not use your emote here!"
|
||||||
emote-none: "%prefix% <red>You have no emote equipped!"
|
emote-none: "%prefix% <red>You have no emote equipped!"
|
||||||
|
|||||||
@@ -1,3 +1,15 @@
|
|||||||
unlockedCosmetic:
|
unlocked-cosmetic:
|
||||||
true: "True"
|
true: "true"
|
||||||
|
false: "false"
|
||||||
|
equipped-cosmetic:
|
||||||
|
true: "true"
|
||||||
|
false: "false"
|
||||||
|
in-wardrobe:
|
||||||
|
true: "true"
|
||||||
|
false: "false"
|
||||||
|
using-cosmetic:
|
||||||
|
true: "true"
|
||||||
|
false: "false"
|
||||||
|
current-cosmetic:
|
||||||
|
true: "true"
|
||||||
false: "false"
|
false: "false"
|
||||||
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
@@ -1,5 +1,5 @@
|
|||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-8.2.1-bin.zip
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
|
|||||||
BIN
lib/HMCColor-0.8-all.jar
Normal file
BIN
lib/HMCColor-0.8-all.jar
Normal file
Binary file not shown.
@@ -8,7 +8,6 @@ pluginManagement {
|
|||||||
rootProject.name = "HMCCosmetics"
|
rootProject.name = "HMCCosmetics"
|
||||||
include(
|
include(
|
||||||
"common",
|
"common",
|
||||||
"v1_17_R1",
|
|
||||||
"v1_18_R2",
|
"v1_18_R2",
|
||||||
"v1_19_R1",
|
"v1_19_R1",
|
||||||
"v1_19_R2",
|
"v1_19_R2",
|
||||||
|
|||||||
@@ -1,27 +0,0 @@
|
|||||||
plugins {
|
|
||||||
id("java")
|
|
||||||
id("io.papermc.paperweight.userdev") version "1.5.1"
|
|
||||||
}
|
|
||||||
|
|
||||||
dependencies {
|
|
||||||
paperDevBundle("1.17.1-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_17_R1;
|
|
||||||
|
|
||||||
import net.minecraft.world.entity.decoration.ArmorStand;
|
|
||||||
import net.minecraft.world.level.Level;
|
|
||||||
import org.bukkit.Location;
|
|
||||||
import org.bukkit.craftbukkit.v1_17_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,24 +0,0 @@
|
|||||||
package com.hibiscusmc.hmccosmetics.nms.v1_17_R1;
|
|
||||||
|
|
||||||
|
|
||||||
import net.minecraft.world.entity.AreaEffectCloud;
|
|
||||||
import net.minecraft.world.level.Level;
|
|
||||||
import org.bukkit.Location;
|
|
||||||
import org.bukkit.craftbukkit.v1_17_R1.CraftWorld;
|
|
||||||
|
|
||||||
public class HMCParticleCloud extends AreaEffectCloud {
|
|
||||||
|
|
||||||
public HMCParticleCloud(Level world, double x, double y, double z) {
|
|
||||||
super(world, x, y, z);
|
|
||||||
}
|
|
||||||
|
|
||||||
public HMCParticleCloud(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);
|
|
||||||
setSilent(true);
|
|
||||||
setNoGravity(true);
|
|
||||||
persist = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,31 +0,0 @@
|
|||||||
package com.hibiscusmc.hmccosmetics.nms.v1_17_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_17_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,253 +0,0 @@
|
|||||||
package com.hibiscusmc.hmccosmetics.nms.v1_17_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.manager.UserBalloonManager;
|
|
||||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
|
||||||
import com.hibiscusmc.hmccosmetics.util.InventoryUtils;
|
|
||||||
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
|
||||||
import com.hibiscusmc.hmccosmetics.util.PlayerUtils;
|
|
||||||
import com.hibiscusmc.hmccosmetics.util.packets.PacketManager;
|
|
||||||
import com.mojang.datafixers.util.Pair;
|
|
||||||
import net.kyori.adventure.text.Component;
|
|
||||||
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.Entity;
|
|
||||||
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_17_R1.CraftEquipmentSlot;
|
|
||||||
import org.bukkit.craftbukkit.v1_17_R1.CraftServer;
|
|
||||||
import org.bukkit.craftbukkit.v1_17_R1.CraftWorld;
|
|
||||||
import org.bukkit.craftbukkit.v1_17_R1.entity.CraftPlayer;
|
|
||||||
import org.bukkit.craftbukkit.v1_17_R1.inventory.CraftItemStack;
|
|
||||||
import org.bukkit.craftbukkit.v1_17_R1.scoreboard.CraftScoreboard;
|
|
||||||
import org.bukkit.entity.ArmorStand;
|
|
||||||
import org.bukkit.entity.EntityType;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
|
||||||
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class NMSHandler implements com.hibiscusmc.hmccosmetics.nms.NMSHandler {
|
|
||||||
@Override
|
|
||||||
public int getNextEntityId() {
|
|
||||||
return 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 org.bukkit.entity.Entity spawnHMCParticleCloud(Location location) {
|
|
||||||
HMCParticleCloud hmcParticleCloud = new HMCParticleCloud(location);
|
|
||||||
return hmcParticleCloud.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.getPlayer().getLocation());
|
|
||||||
|
|
||||||
ItemStack item = user.getUserCosmeticItem(cosmeticBackpackType);
|
|
||||||
|
|
||||||
invisibleArmorstand.setItemSlot(EquipmentSlot.HEAD, CraftItemStack.asNMSCopy(item));
|
|
||||||
((CraftWorld) user.getPlayer().getWorld()).getHandle().addFreshEntity(invisibleArmorstand);
|
|
||||||
|
|
||||||
MessagesUtil.sendDebugMessages("spawnBackpack NMS");
|
|
||||||
|
|
||||||
return invisibleArmorstand.getBukkitLivingEntity();
|
|
||||||
//PacketManager.armorStandMetaPacket(invisibleArmorstand.getBukkitEntity(), sentTo);
|
|
||||||
//PacketManager.ridingMountPacket(player.getEntityId(), invisibleArmorstand.getId(), sentTo);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public org.bukkit.entity.Entity spawnDisplayEntity(Location location, String text) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public UserBalloonManager spawnBalloon(CosmeticUser user, CosmeticBalloonType cosmeticBalloonType) {
|
|
||||||
Player player = user.getPlayer();
|
|
||||||
Location newLoc = player.getLocation().clone().add(Settings.getBalloonOffset());
|
|
||||||
|
|
||||||
UserBalloonManager userBalloonManager1 = new UserBalloonManager(user.getPlayer().getLocation());
|
|
||||||
List<Player> sentTo = PlayerUtils.getNearbyPlayers(player.getLocation());
|
|
||||||
userBalloonManager1.getModelEntity().teleport(user.getPlayer().getLocation().add(Settings.getBalloonOffset()));
|
|
||||||
|
|
||||||
userBalloonManager1.spawnModel(cosmeticBalloonType, user.getCosmeticColor(cosmeticBalloonType.getSlot()));
|
|
||||||
userBalloonManager1.addPlayerToModel(user, cosmeticBalloonType, user.getCosmeticColor(cosmeticBalloonType.getSlot()));
|
|
||||||
|
|
||||||
PacketManager.sendEntitySpawnPacket(newLoc, userBalloonManager1.getPufferfishBalloonId(), EntityType.PUFFERFISH, userBalloonManager1.getPufferfishBalloonUniqueId(), sentTo);
|
|
||||||
PacketManager.sendInvisibilityPacket(userBalloonManager1.getPufferfishBalloonId(), sentTo);
|
|
||||||
userBalloonManager1.sendLeashPacket(player.getEntityId());
|
|
||||||
|
|
||||||
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.createPlayerPacket(team, 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,24 +0,0 @@
|
|||||||
package com.hibiscusmc.hmccosmetics.nms.v1_18_R2;
|
|
||||||
|
|
||||||
|
|
||||||
import net.minecraft.world.entity.AreaEffectCloud;
|
|
||||||
import net.minecraft.world.level.Level;
|
|
||||||
import org.bukkit.Location;
|
|
||||||
import org.bukkit.craftbukkit.v1_18_R2.CraftWorld;
|
|
||||||
|
|
||||||
public class HMCParticleCloud extends AreaEffectCloud {
|
|
||||||
|
|
||||||
public HMCParticleCloud(Level world, double x, double y, double z) {
|
|
||||||
super(world, x, y, z);
|
|
||||||
}
|
|
||||||
|
|
||||||
public HMCParticleCloud(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);
|
|
||||||
setSilent(true);
|
|
||||||
setNoGravity(true);
|
|
||||||
persist = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -6,14 +6,11 @@ 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.user.manager.UserBalloonManager;
|
|
||||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||||
|
import com.hibiscusmc.hmccosmetics.user.manager.UserBalloonManager;
|
||||||
import com.hibiscusmc.hmccosmetics.util.InventoryUtils;
|
import com.hibiscusmc.hmccosmetics.util.InventoryUtils;
|
||||||
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||||
import com.hibiscusmc.hmccosmetics.util.PlayerUtils;
|
|
||||||
import com.hibiscusmc.hmccosmetics.util.packets.PacketManager;
|
|
||||||
import com.mojang.datafixers.util.Pair;
|
import com.mojang.datafixers.util.Pair;
|
||||||
import net.kyori.adventure.text.Component;
|
|
||||||
import net.minecraft.network.protocol.Packet;
|
import net.minecraft.network.protocol.Packet;
|
||||||
import net.minecraft.network.protocol.game.ClientboundContainerSetSlotPacket;
|
import net.minecraft.network.protocol.game.ClientboundContainerSetSlotPacket;
|
||||||
import net.minecraft.network.protocol.game.ClientboundSetEquipmentPacket;
|
import net.minecraft.network.protocol.game.ClientboundSetEquipmentPacket;
|
||||||
@@ -21,7 +18,6 @@ import net.minecraft.network.protocol.game.ClientboundSetPlayerTeamPacket;
|
|||||||
import net.minecraft.server.level.ServerLevel;
|
import net.minecraft.server.level.ServerLevel;
|
||||||
import net.minecraft.server.level.ServerPlayer;
|
import net.minecraft.server.level.ServerPlayer;
|
||||||
import net.minecraft.server.network.ServerPlayerConnection;
|
import net.minecraft.server.network.ServerPlayerConnection;
|
||||||
import net.minecraft.world.entity.Entity;
|
|
||||||
import net.minecraft.world.entity.EquipmentSlot;
|
import net.minecraft.world.entity.EquipmentSlot;
|
||||||
import net.minecraft.world.entity.player.Inventory;
|
import net.minecraft.world.entity.player.Inventory;
|
||||||
import net.minecraft.world.scores.PlayerTeam;
|
import net.minecraft.world.scores.PlayerTeam;
|
||||||
@@ -35,7 +31,6 @@ 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.inventory.CraftItemStack;
|
||||||
import org.bukkit.craftbukkit.v1_18_R2.scoreboard.CraftScoreboard;
|
import org.bukkit.craftbukkit.v1_18_R2.scoreboard.CraftScoreboard;
|
||||||
import org.bukkit.entity.ArmorStand;
|
import org.bukkit.entity.ArmorStand;
|
||||||
import org.bukkit.entity.EntityType;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.entity.CreatureSpawnEvent;
|
import org.bukkit.event.entity.CreatureSpawnEvent;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
@@ -47,7 +42,7 @@ import java.util.List;
|
|||||||
public class NMSHandler implements com.hibiscusmc.hmccosmetics.nms.NMSHandler {
|
public class NMSHandler implements com.hibiscusmc.hmccosmetics.nms.NMSHandler {
|
||||||
@Override
|
@Override
|
||||||
public int getNextEntityId() {
|
public int getNextEntityId() {
|
||||||
return Entity.nextEntityId();
|
return net.minecraft.world.entity.Entity.nextEntityId();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -72,12 +67,6 @@ public class NMSHandler implements com.hibiscusmc.hmccosmetics.nms.NMSHandler {
|
|||||||
return hmcArmorStand.getBukkitEntity();
|
return hmcArmorStand.getBukkitEntity();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public org.bukkit.entity.Entity spawnHMCParticleCloud(Location location) {
|
|
||||||
HMCParticleCloud hmcParticleCloud = new HMCParticleCloud(location);
|
|
||||||
return hmcParticleCloud.getBukkitEntity();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ArmorStand getMEGEntity(Location loc) {
|
public ArmorStand getMEGEntity(Location loc) {
|
||||||
return (ArmorStand) new MEGEntity(loc).getBukkitEntity();
|
return (ArmorStand) new MEGEntity(loc).getBukkitEntity();
|
||||||
@@ -85,19 +74,16 @@ public class NMSHandler implements com.hibiscusmc.hmccosmetics.nms.NMSHandler {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public org.bukkit.entity.Entity spawnBackpack(CosmeticUser user, CosmeticBackpackType cosmeticBackpackType) {
|
public org.bukkit.entity.Entity spawnBackpack(CosmeticUser user, CosmeticBackpackType cosmeticBackpackType) {
|
||||||
HMCArmorStand invisibleArmorstand = new HMCArmorStand(user.getPlayer().getLocation());
|
HMCArmorStand invisibleArmorstand = new HMCArmorStand(user.getEntity().getLocation());
|
||||||
|
|
||||||
ItemStack item = user.getUserCosmeticItem(cosmeticBackpackType);
|
ItemStack item = user.getUserCosmeticItem(cosmeticBackpackType);
|
||||||
|
|
||||||
invisibleArmorstand.setItemSlot(EquipmentSlot.HEAD, CraftItemStack.asNMSCopy(item));
|
invisibleArmorstand.setItemSlot(EquipmentSlot.HEAD, CraftItemStack.asNMSCopy(item));
|
||||||
((CraftWorld) user.getPlayer().getWorld()).getHandle().addFreshEntity(invisibleArmorstand, CreatureSpawnEvent.SpawnReason.CUSTOM);
|
((CraftWorld) user.getEntity().getWorld()).getHandle().addFreshEntity(invisibleArmorstand, CreatureSpawnEvent.SpawnReason.CUSTOM);
|
||||||
|
|
||||||
MessagesUtil.sendDebugMessages("spawnBackpack NMS");
|
MessagesUtil.sendDebugMessages("spawnBackpack NMS");
|
||||||
|
|
||||||
return invisibleArmorstand.getBukkitLivingEntity();
|
return invisibleArmorstand.getBukkitLivingEntity();
|
||||||
//PacketManager.armorStandMetaPacket(invisibleArmorstand.getBukkitEntity(), sentTo);
|
|
||||||
//PacketManager.ridingMountPacket(player.getEntityId(), invisibleArmorstand.getId(), sentTo);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -106,24 +92,16 @@ public class NMSHandler implements com.hibiscusmc.hmccosmetics.nms.NMSHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public UserBalloonManager spawnBalloon(CosmeticUser user, CosmeticBalloonType cosmeticBalloonType) {
|
public UserBalloonManager spawnBalloon(CosmeticUser user, CosmeticBalloonType cosmeticBalloonType) {
|
||||||
Player player = user.getPlayer();
|
org.bukkit.entity.Entity entity = user.getEntity();
|
||||||
Location newLoc = player.getLocation().clone().add(Settings.getBalloonOffset());
|
|
||||||
|
|
||||||
UserBalloonManager userBalloonManager1 = new UserBalloonManager(user.getPlayer().getLocation());
|
UserBalloonManager userBalloonManager1 = new UserBalloonManager(user, entity.getLocation());
|
||||||
List<Player> sentTo = PlayerUtils.getNearbyPlayers(player.getLocation());
|
userBalloonManager1.getModelEntity().teleport(entity.getLocation().add(cosmeticBalloonType.getBalloonOffset()));
|
||||||
userBalloonManager1.getModelEntity().teleport(user.getPlayer().getLocation().add(Settings.getBalloonOffset()));
|
|
||||||
|
|
||||||
userBalloonManager1.spawnModel(cosmeticBalloonType, user.getCosmeticColor(cosmeticBalloonType.getSlot()));
|
userBalloonManager1.spawnModel(cosmeticBalloonType, user.getCosmeticColor(cosmeticBalloonType.getSlot()));
|
||||||
userBalloonManager1.addPlayerToModel(user, cosmeticBalloonType, user.getCosmeticColor(cosmeticBalloonType.getSlot()));
|
userBalloonManager1.addPlayerToModel(user, cosmeticBalloonType, user.getCosmeticColor(cosmeticBalloonType.getSlot()));
|
||||||
|
|
||||||
PacketManager.sendEntitySpawnPacket(newLoc, userBalloonManager1.getPufferfishBalloonId(), EntityType.PUFFERFISH, userBalloonManager1.getPufferfishBalloonUniqueId(), sentTo);
|
|
||||||
PacketManager.sendInvisibilityPacket(userBalloonManager1.getPufferfishBalloonId(), sentTo);
|
|
||||||
userBalloonManager1.sendLeashPacket(player.getEntityId());
|
|
||||||
|
|
||||||
return userBalloonManager1;
|
return userBalloonManager1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,24 +0,0 @@
|
|||||||
package com.hibiscusmc.hmccosmetics.nms.v1_19_R1;
|
|
||||||
|
|
||||||
|
|
||||||
import net.minecraft.world.entity.AreaEffectCloud;
|
|
||||||
import net.minecraft.world.level.Level;
|
|
||||||
import org.bukkit.Location;
|
|
||||||
import org.bukkit.craftbukkit.v1_19_R1.CraftWorld;
|
|
||||||
|
|
||||||
public class HMCParticleCloud extends AreaEffectCloud {
|
|
||||||
|
|
||||||
public HMCParticleCloud(Level world, double x, double y, double z) {
|
|
||||||
super(world, x, y, z);
|
|
||||||
}
|
|
||||||
|
|
||||||
public HMCParticleCloud(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);
|
|
||||||
setSilent(true);
|
|
||||||
setNoGravity(true);
|
|
||||||
persist = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -6,14 +6,11 @@ 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.user.manager.UserBalloonManager;
|
|
||||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||||
|
import com.hibiscusmc.hmccosmetics.user.manager.UserBalloonManager;
|
||||||
import com.hibiscusmc.hmccosmetics.util.InventoryUtils;
|
import com.hibiscusmc.hmccosmetics.util.InventoryUtils;
|
||||||
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||||
import com.hibiscusmc.hmccosmetics.util.PlayerUtils;
|
|
||||||
import com.hibiscusmc.hmccosmetics.util.packets.PacketManager;
|
|
||||||
import com.mojang.datafixers.util.Pair;
|
import com.mojang.datafixers.util.Pair;
|
||||||
import net.kyori.adventure.text.Component;
|
|
||||||
import net.minecraft.network.protocol.Packet;
|
import net.minecraft.network.protocol.Packet;
|
||||||
import net.minecraft.network.protocol.game.ClientboundContainerSetSlotPacket;
|
import net.minecraft.network.protocol.game.ClientboundContainerSetSlotPacket;
|
||||||
import net.minecraft.network.protocol.game.ClientboundSetEquipmentPacket;
|
import net.minecraft.network.protocol.game.ClientboundSetEquipmentPacket;
|
||||||
@@ -21,7 +18,6 @@ import net.minecraft.network.protocol.game.ClientboundSetPlayerTeamPacket;
|
|||||||
import net.minecraft.server.level.ServerLevel;
|
import net.minecraft.server.level.ServerLevel;
|
||||||
import net.minecraft.server.level.ServerPlayer;
|
import net.minecraft.server.level.ServerPlayer;
|
||||||
import net.minecraft.server.network.ServerPlayerConnection;
|
import net.minecraft.server.network.ServerPlayerConnection;
|
||||||
import net.minecraft.world.entity.Entity;
|
|
||||||
import net.minecraft.world.entity.EquipmentSlot;
|
import net.minecraft.world.entity.EquipmentSlot;
|
||||||
import net.minecraft.world.entity.player.Inventory;
|
import net.minecraft.world.entity.player.Inventory;
|
||||||
import net.minecraft.world.scores.PlayerTeam;
|
import net.minecraft.world.scores.PlayerTeam;
|
||||||
@@ -35,7 +31,6 @@ 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.inventory.CraftItemStack;
|
||||||
import org.bukkit.craftbukkit.v1_19_R1.scoreboard.CraftScoreboard;
|
import org.bukkit.craftbukkit.v1_19_R1.scoreboard.CraftScoreboard;
|
||||||
import org.bukkit.entity.ArmorStand;
|
import org.bukkit.entity.ArmorStand;
|
||||||
import org.bukkit.entity.EntityType;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.entity.CreatureSpawnEvent;
|
import org.bukkit.event.entity.CreatureSpawnEvent;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
@@ -47,7 +42,7 @@ import java.util.List;
|
|||||||
public class NMSHandler implements com.hibiscusmc.hmccosmetics.nms.NMSHandler {
|
public class NMSHandler implements com.hibiscusmc.hmccosmetics.nms.NMSHandler {
|
||||||
@Override
|
@Override
|
||||||
public int getNextEntityId() {
|
public int getNextEntityId() {
|
||||||
return Entity.nextEntityId();
|
return net.minecraft.world.entity.Entity.nextEntityId();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -72,12 +67,6 @@ public class NMSHandler implements com.hibiscusmc.hmccosmetics.nms.NMSHandler {
|
|||||||
return hmcArmorStand.getBukkitEntity();
|
return hmcArmorStand.getBukkitEntity();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public org.bukkit.entity.Entity spawnHMCParticleCloud(Location location) {
|
|
||||||
HMCParticleCloud hmcParticleCloud = new HMCParticleCloud(location);
|
|
||||||
return hmcParticleCloud.getBukkitEntity();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ArmorStand getMEGEntity(Location loc) {
|
public ArmorStand getMEGEntity(Location loc) {
|
||||||
return (ArmorStand) new MEGEntity(loc).getBukkitEntity();
|
return (ArmorStand) new MEGEntity(loc).getBukkitEntity();
|
||||||
@@ -85,19 +74,16 @@ public class NMSHandler implements com.hibiscusmc.hmccosmetics.nms.NMSHandler {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public org.bukkit.entity.Entity spawnBackpack(CosmeticUser user, CosmeticBackpackType cosmeticBackpackType) {
|
public org.bukkit.entity.Entity spawnBackpack(CosmeticUser user, CosmeticBackpackType cosmeticBackpackType) {
|
||||||
HMCArmorStand HMCArmorStand = new HMCArmorStand(user.getPlayer().getLocation());
|
HMCArmorStand invisibleArmorstand = new HMCArmorStand(user.getEntity().getLocation());
|
||||||
|
|
||||||
ItemStack item = user.getUserCosmeticItem(cosmeticBackpackType);
|
ItemStack item = user.getUserCosmeticItem(cosmeticBackpackType);
|
||||||
|
|
||||||
HMCArmorStand.setItemSlot(EquipmentSlot.HEAD, CraftItemStack.asNMSCopy(item));
|
invisibleArmorstand.setItemSlot(EquipmentSlot.HEAD, CraftItemStack.asNMSCopy(item));
|
||||||
((CraftWorld) user.getPlayer().getWorld()).getHandle().addFreshEntity(HMCArmorStand, CreatureSpawnEvent.SpawnReason.CUSTOM);
|
((CraftWorld) user.getEntity().getWorld()).getHandle().addFreshEntity(invisibleArmorstand, CreatureSpawnEvent.SpawnReason.CUSTOM);
|
||||||
|
|
||||||
MessagesUtil.sendDebugMessages("spawnBackpack NMS");
|
MessagesUtil.sendDebugMessages("spawnBackpack NMS");
|
||||||
|
|
||||||
return HMCArmorStand.getBukkitLivingEntity();
|
return invisibleArmorstand.getBukkitLivingEntity();
|
||||||
//PacketManager.armorStandMetaPacket(invisibleArmorstand.getBukkitEntity(), sentTo);
|
|
||||||
//PacketManager.ridingMountPacket(player.getEntityId(), invisibleArmorstand.getId(), sentTo);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -110,20 +96,14 @@ public class NMSHandler implements com.hibiscusmc.hmccosmetics.nms.NMSHandler {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public UserBalloonManager spawnBalloon(CosmeticUser user, CosmeticBalloonType cosmeticBalloonType) {
|
public UserBalloonManager spawnBalloon(CosmeticUser user, CosmeticBalloonType cosmeticBalloonType) {
|
||||||
Player player = user.getPlayer();
|
org.bukkit.entity.Entity entity = user.getEntity();
|
||||||
Location newLoc = player.getLocation().clone().add(Settings.getBalloonOffset());
|
|
||||||
|
|
||||||
UserBalloonManager userBalloonManager1 = new UserBalloonManager(user.getPlayer().getLocation());
|
UserBalloonManager userBalloonManager1 = new UserBalloonManager(user, entity.getLocation());
|
||||||
List<Player> sentTo = PlayerUtils.getNearbyPlayers(player.getLocation());
|
userBalloonManager1.getModelEntity().teleport(entity.getLocation().add(cosmeticBalloonType.getBalloonOffset()));
|
||||||
userBalloonManager1.getModelEntity().teleport(user.getPlayer().getLocation().add(Settings.getBalloonOffset()));
|
|
||||||
|
|
||||||
userBalloonManager1.spawnModel(cosmeticBalloonType, user.getCosmeticColor(cosmeticBalloonType.getSlot()));
|
userBalloonManager1.spawnModel(cosmeticBalloonType, user.getCosmeticColor(cosmeticBalloonType.getSlot()));
|
||||||
userBalloonManager1.addPlayerToModel(user, cosmeticBalloonType, user.getCosmeticColor(cosmeticBalloonType.getSlot()));
|
userBalloonManager1.addPlayerToModel(user, cosmeticBalloonType, user.getCosmeticColor(cosmeticBalloonType.getSlot()));
|
||||||
|
|
||||||
PacketManager.sendEntitySpawnPacket(newLoc, userBalloonManager1.getPufferfishBalloonId(), EntityType.PUFFERFISH, userBalloonManager1.getPufferfishBalloonUniqueId(), sentTo);
|
|
||||||
PacketManager.sendInvisibilityPacket(userBalloonManager1.getPufferfishBalloonId(), sentTo);
|
|
||||||
userBalloonManager1.sendLeashPacket(player.getEntityId());
|
|
||||||
|
|
||||||
return userBalloonManager1;
|
return userBalloonManager1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,24 +0,0 @@
|
|||||||
package com.hibiscusmc.hmccosmetics.nms.v1_19_R2;
|
|
||||||
|
|
||||||
|
|
||||||
import net.minecraft.world.entity.AreaEffectCloud;
|
|
||||||
import net.minecraft.world.level.Level;
|
|
||||||
import org.bukkit.Location;
|
|
||||||
import org.bukkit.craftbukkit.v1_19_R2.CraftWorld;
|
|
||||||
|
|
||||||
public class HMCParticleCloud extends AreaEffectCloud {
|
|
||||||
|
|
||||||
public HMCParticleCloud(Level world, double x, double y, double z) {
|
|
||||||
super(world, x, y, z);
|
|
||||||
}
|
|
||||||
|
|
||||||
public HMCParticleCloud(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);
|
|
||||||
setSilent(true);
|
|
||||||
setNoGravity(true);
|
|
||||||
persist = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -6,14 +6,11 @@ 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.user.manager.UserBalloonManager;
|
|
||||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||||
|
import com.hibiscusmc.hmccosmetics.user.manager.UserBalloonManager;
|
||||||
import com.hibiscusmc.hmccosmetics.util.InventoryUtils;
|
import com.hibiscusmc.hmccosmetics.util.InventoryUtils;
|
||||||
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||||
import com.hibiscusmc.hmccosmetics.util.PlayerUtils;
|
|
||||||
import com.hibiscusmc.hmccosmetics.util.packets.PacketManager;
|
|
||||||
import com.mojang.datafixers.util.Pair;
|
import com.mojang.datafixers.util.Pair;
|
||||||
import net.kyori.adventure.text.Component;
|
|
||||||
import net.minecraft.network.protocol.Packet;
|
import net.minecraft.network.protocol.Packet;
|
||||||
import net.minecraft.network.protocol.game.ClientboundContainerSetSlotPacket;
|
import net.minecraft.network.protocol.game.ClientboundContainerSetSlotPacket;
|
||||||
import net.minecraft.network.protocol.game.ClientboundSetEquipmentPacket;
|
import net.minecraft.network.protocol.game.ClientboundSetEquipmentPacket;
|
||||||
@@ -21,7 +18,6 @@ import net.minecraft.network.protocol.game.ClientboundSetPlayerTeamPacket;
|
|||||||
import net.minecraft.server.level.ServerLevel;
|
import net.minecraft.server.level.ServerLevel;
|
||||||
import net.minecraft.server.level.ServerPlayer;
|
import net.minecraft.server.level.ServerPlayer;
|
||||||
import net.minecraft.server.network.ServerPlayerConnection;
|
import net.minecraft.server.network.ServerPlayerConnection;
|
||||||
import net.minecraft.world.entity.Entity;
|
|
||||||
import net.minecraft.world.entity.EquipmentSlot;
|
import net.minecraft.world.entity.EquipmentSlot;
|
||||||
import net.minecraft.world.entity.player.Inventory;
|
import net.minecraft.world.entity.player.Inventory;
|
||||||
import net.minecraft.world.scores.PlayerTeam;
|
import net.minecraft.world.scores.PlayerTeam;
|
||||||
@@ -35,7 +31,6 @@ 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.inventory.CraftItemStack;
|
||||||
import org.bukkit.craftbukkit.v1_19_R2.scoreboard.CraftScoreboard;
|
import org.bukkit.craftbukkit.v1_19_R2.scoreboard.CraftScoreboard;
|
||||||
import org.bukkit.entity.ArmorStand;
|
import org.bukkit.entity.ArmorStand;
|
||||||
import org.bukkit.entity.EntityType;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.entity.CreatureSpawnEvent;
|
import org.bukkit.event.entity.CreatureSpawnEvent;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
@@ -47,7 +42,7 @@ import java.util.List;
|
|||||||
public class NMSHandler implements com.hibiscusmc.hmccosmetics.nms.NMSHandler {
|
public class NMSHandler implements com.hibiscusmc.hmccosmetics.nms.NMSHandler {
|
||||||
@Override
|
@Override
|
||||||
public int getNextEntityId() {
|
public int getNextEntityId() {
|
||||||
return Entity.nextEntityId();
|
return net.minecraft.world.entity.Entity.nextEntityId();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -72,12 +67,6 @@ public class NMSHandler implements com.hibiscusmc.hmccosmetics.nms.NMSHandler {
|
|||||||
return hmcArmorStand.getBukkitEntity();
|
return hmcArmorStand.getBukkitEntity();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public org.bukkit.entity.Entity spawnHMCParticleCloud(Location location) {
|
|
||||||
HMCParticleCloud hmcParticleCloud = new HMCParticleCloud(location);
|
|
||||||
return hmcParticleCloud.getBukkitEntity();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ArmorStand getMEGEntity(Location loc) {
|
public ArmorStand getMEGEntity(Location loc) {
|
||||||
return (ArmorStand) new MEGEntity(loc).getBukkitEntity();
|
return (ArmorStand) new MEGEntity(loc).getBukkitEntity();
|
||||||
@@ -85,19 +74,16 @@ public class NMSHandler implements com.hibiscusmc.hmccosmetics.nms.NMSHandler {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public org.bukkit.entity.Entity spawnBackpack(CosmeticUser user, CosmeticBackpackType cosmeticBackpackType) {
|
public org.bukkit.entity.Entity spawnBackpack(CosmeticUser user, CosmeticBackpackType cosmeticBackpackType) {
|
||||||
HMCArmorStand invisibleArmorstand = new HMCArmorStand(user.getPlayer().getLocation());
|
HMCArmorStand invisibleArmorstand = new HMCArmorStand(user.getEntity().getLocation());
|
||||||
|
|
||||||
ItemStack item = user.getUserCosmeticItem(cosmeticBackpackType);
|
ItemStack item = user.getUserCosmeticItem(cosmeticBackpackType);
|
||||||
|
|
||||||
invisibleArmorstand.setItemSlot(EquipmentSlot.HEAD, CraftItemStack.asNMSCopy(item));
|
invisibleArmorstand.setItemSlot(EquipmentSlot.HEAD, CraftItemStack.asNMSCopy(item));
|
||||||
((CraftWorld) user.getPlayer().getWorld()).getHandle().addFreshEntity(invisibleArmorstand, CreatureSpawnEvent.SpawnReason.CUSTOM);
|
((CraftWorld) user.getEntity().getWorld()).getHandle().addFreshEntity(invisibleArmorstand, CreatureSpawnEvent.SpawnReason.CUSTOM);
|
||||||
|
|
||||||
MessagesUtil.sendDebugMessages("spawnBackpack NMS");
|
MessagesUtil.sendDebugMessages("spawnBackpack NMS");
|
||||||
|
|
||||||
return invisibleArmorstand.getBukkitLivingEntity();
|
return invisibleArmorstand.getBukkitLivingEntity();
|
||||||
//PacketManager.armorStandMetaPacket(invisibleArmorstand.getBukkitEntity(), sentTo);
|
|
||||||
//PacketManager.ridingMountPacket(player.getEntityId(), invisibleArmorstand.getId(), sentTo);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -109,20 +95,14 @@ public class NMSHandler implements com.hibiscusmc.hmccosmetics.nms.NMSHandler {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public UserBalloonManager spawnBalloon(CosmeticUser user, CosmeticBalloonType cosmeticBalloonType) {
|
public UserBalloonManager spawnBalloon(CosmeticUser user, CosmeticBalloonType cosmeticBalloonType) {
|
||||||
Player player = user.getPlayer();
|
org.bukkit.entity.Entity entity = user.getEntity();
|
||||||
Location newLoc = player.getLocation().clone().add(Settings.getBalloonOffset());
|
|
||||||
|
|
||||||
UserBalloonManager userBalloonManager1 = new UserBalloonManager(user.getPlayer().getLocation());
|
UserBalloonManager userBalloonManager1 = new UserBalloonManager(user, entity.getLocation());
|
||||||
List<Player> sentTo = PlayerUtils.getNearbyPlayers(player.getLocation());
|
userBalloonManager1.getModelEntity().teleport(entity.getLocation().add(cosmeticBalloonType.getBalloonOffset()));
|
||||||
userBalloonManager1.getModelEntity().teleport(user.getPlayer().getLocation().add(Settings.getBalloonOffset()));
|
|
||||||
|
|
||||||
userBalloonManager1.spawnModel(cosmeticBalloonType, user.getCosmeticColor(cosmeticBalloonType.getSlot()));
|
userBalloonManager1.spawnModel(cosmeticBalloonType, user.getCosmeticColor(cosmeticBalloonType.getSlot()));
|
||||||
userBalloonManager1.addPlayerToModel(user, cosmeticBalloonType, user.getCosmeticColor(cosmeticBalloonType.getSlot()));
|
userBalloonManager1.addPlayerToModel(user, cosmeticBalloonType, user.getCosmeticColor(cosmeticBalloonType.getSlot()));
|
||||||
|
|
||||||
PacketManager.sendEntitySpawnPacket(newLoc, userBalloonManager1.getPufferfishBalloonId(), EntityType.PUFFERFISH, userBalloonManager1.getPufferfishBalloonUniqueId(), sentTo);
|
|
||||||
PacketManager.sendInvisibilityPacket(userBalloonManager1.getPufferfishBalloonId(), sentTo);
|
|
||||||
userBalloonManager1.sendLeashPacket(player.getEntityId());
|
|
||||||
|
|
||||||
return userBalloonManager1;
|
return userBalloonManager1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,24 +0,0 @@
|
|||||||
package com.hibiscusmc.hmccosmetics.nms.v1_19_R3;
|
|
||||||
|
|
||||||
|
|
||||||
import net.minecraft.world.entity.AreaEffectCloud;
|
|
||||||
import net.minecraft.world.level.Level;
|
|
||||||
import org.bukkit.Location;
|
|
||||||
import org.bukkit.craftbukkit.v1_19_R3.CraftWorld;
|
|
||||||
|
|
||||||
public class HMCParticleCloud extends AreaEffectCloud {
|
|
||||||
|
|
||||||
public HMCParticleCloud(Level world, double x, double y, double z) {
|
|
||||||
super(world, x, y, z);
|
|
||||||
}
|
|
||||||
|
|
||||||
public HMCParticleCloud(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);
|
|
||||||
setSilent(true);
|
|
||||||
setNoGravity(true);
|
|
||||||
persist = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -6,12 +6,10 @@ 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.user.manager.UserBalloonManager;
|
|
||||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||||
|
import com.hibiscusmc.hmccosmetics.user.manager.UserBalloonManager;
|
||||||
import com.hibiscusmc.hmccosmetics.util.InventoryUtils;
|
import com.hibiscusmc.hmccosmetics.util.InventoryUtils;
|
||||||
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||||
import com.hibiscusmc.hmccosmetics.util.PlayerUtils;
|
|
||||||
import com.hibiscusmc.hmccosmetics.util.packets.PacketManager;
|
|
||||||
import com.mojang.datafixers.util.Pair;
|
import com.mojang.datafixers.util.Pair;
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.network.chat.Component;
|
||||||
import net.minecraft.network.protocol.Packet;
|
import net.minecraft.network.protocol.Packet;
|
||||||
@@ -22,7 +20,6 @@ import net.minecraft.server.level.ServerLevel;
|
|||||||
import net.minecraft.server.level.ServerPlayer;
|
import net.minecraft.server.level.ServerPlayer;
|
||||||
import net.minecraft.server.network.ServerPlayerConnection;
|
import net.minecraft.server.network.ServerPlayerConnection;
|
||||||
import net.minecraft.world.entity.Display;
|
import net.minecraft.world.entity.Display;
|
||||||
import net.minecraft.world.entity.Entity;
|
|
||||||
import net.minecraft.world.entity.EquipmentSlot;
|
import net.minecraft.world.entity.EquipmentSlot;
|
||||||
import net.minecraft.world.entity.player.Inventory;
|
import net.minecraft.world.entity.player.Inventory;
|
||||||
import net.minecraft.world.scores.PlayerTeam;
|
import net.minecraft.world.scores.PlayerTeam;
|
||||||
@@ -36,7 +33,7 @@ import org.bukkit.craftbukkit.v1_19_R3.entity.CraftPlayer;
|
|||||||
import org.bukkit.craftbukkit.v1_19_R3.inventory.CraftItemStack;
|
import org.bukkit.craftbukkit.v1_19_R3.inventory.CraftItemStack;
|
||||||
import org.bukkit.craftbukkit.v1_19_R3.scoreboard.CraftScoreboard;
|
import org.bukkit.craftbukkit.v1_19_R3.scoreboard.CraftScoreboard;
|
||||||
import org.bukkit.entity.ArmorStand;
|
import org.bukkit.entity.ArmorStand;
|
||||||
import org.bukkit.entity.EntityType;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.entity.CreatureSpawnEvent;
|
import org.bukkit.event.entity.CreatureSpawnEvent;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
@@ -48,7 +45,7 @@ import java.util.List;
|
|||||||
public class NMSHandler implements com.hibiscusmc.hmccosmetics.nms.NMSHandler {
|
public class NMSHandler implements com.hibiscusmc.hmccosmetics.nms.NMSHandler {
|
||||||
@Override
|
@Override
|
||||||
public int getNextEntityId() {
|
public int getNextEntityId() {
|
||||||
return Entity.nextEntityId();
|
return net.minecraft.world.entity.Entity.nextEntityId();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -73,12 +70,6 @@ public class NMSHandler implements com.hibiscusmc.hmccosmetics.nms.NMSHandler {
|
|||||||
return hmcArmorStand.getBukkitEntity();
|
return hmcArmorStand.getBukkitEntity();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public org.bukkit.entity.Entity spawnHMCParticleCloud(Location location) {
|
|
||||||
HMCParticleCloud hmcParticleCloud = new HMCParticleCloud(location);
|
|
||||||
return hmcParticleCloud.getBukkitEntity();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ArmorStand getMEGEntity(Location loc) {
|
public ArmorStand getMEGEntity(Location loc) {
|
||||||
return (ArmorStand) new MEGEntity(loc).getBukkitEntity();
|
return (ArmorStand) new MEGEntity(loc).getBukkitEntity();
|
||||||
@@ -86,18 +77,16 @@ public class NMSHandler implements com.hibiscusmc.hmccosmetics.nms.NMSHandler {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public org.bukkit.entity.Entity spawnBackpack(CosmeticUser user, CosmeticBackpackType cosmeticBackpackType) {
|
public org.bukkit.entity.Entity spawnBackpack(CosmeticUser user, CosmeticBackpackType cosmeticBackpackType) {
|
||||||
HMCArmorStand invisibleArmorstand = new HMCArmorStand(user.getPlayer().getLocation());
|
HMCArmorStand invisibleArmorstand = new HMCArmorStand(user.getEntity().getLocation());
|
||||||
|
|
||||||
ItemStack item = user.getUserCosmeticItem(cosmeticBackpackType);
|
ItemStack item = user.getUserCosmeticItem(cosmeticBackpackType);
|
||||||
|
|
||||||
invisibleArmorstand.setItemSlot(EquipmentSlot.HEAD, CraftItemStack.asNMSCopy(item));
|
invisibleArmorstand.setItemSlot(EquipmentSlot.HEAD, CraftItemStack.asNMSCopy(item));
|
||||||
((CraftWorld) user.getPlayer().getWorld()).getHandle().addFreshEntity(invisibleArmorstand, CreatureSpawnEvent.SpawnReason.CUSTOM);
|
((CraftWorld) user.getEntity().getWorld()).getHandle().addFreshEntity(invisibleArmorstand, CreatureSpawnEvent.SpawnReason.CUSTOM);
|
||||||
|
|
||||||
MessagesUtil.sendDebugMessages("spawnBackpack NMS");
|
MessagesUtil.sendDebugMessages("spawnBackpack NMS");
|
||||||
|
|
||||||
return invisibleArmorstand.getBukkitLivingEntity();
|
return invisibleArmorstand.getBukkitLivingEntity();
|
||||||
//PacketManager.armorStandMetaPacket(invisibleArmorstand.getBukkitEntity(), sentTo);
|
|
||||||
//PacketManager.ridingMountPacket(player.getEntityId(), invisibleArmorstand.getId(), sentTo);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -115,20 +104,14 @@ public class NMSHandler implements com.hibiscusmc.hmccosmetics.nms.NMSHandler {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public UserBalloonManager spawnBalloon(CosmeticUser user, CosmeticBalloonType cosmeticBalloonType) {
|
public UserBalloonManager spawnBalloon(CosmeticUser user, CosmeticBalloonType cosmeticBalloonType) {
|
||||||
Player player = user.getPlayer();
|
Entity entity = user.getEntity();
|
||||||
Location newLoc = player.getLocation().clone().add(Settings.getBalloonOffset());
|
|
||||||
|
|
||||||
UserBalloonManager userBalloonManager1 = new UserBalloonManager(user.getPlayer().getLocation());
|
UserBalloonManager userBalloonManager1 = new UserBalloonManager(user, entity.getLocation());
|
||||||
List<Player> sentTo = PlayerUtils.getNearbyPlayers(player.getLocation());
|
userBalloonManager1.getModelEntity().teleport(entity.getLocation().add(cosmeticBalloonType.getBalloonOffset()));
|
||||||
userBalloonManager1.getModelEntity().teleport(user.getPlayer().getLocation().add(Settings.getBalloonOffset()));
|
|
||||||
|
|
||||||
userBalloonManager1.spawnModel(cosmeticBalloonType, user.getCosmeticColor(cosmeticBalloonType.getSlot()));
|
userBalloonManager1.spawnModel(cosmeticBalloonType, user.getCosmeticColor(cosmeticBalloonType.getSlot()));
|
||||||
userBalloonManager1.addPlayerToModel(user, cosmeticBalloonType, user.getCosmeticColor(cosmeticBalloonType.getSlot()));
|
userBalloonManager1.addPlayerToModel(user, cosmeticBalloonType, user.getCosmeticColor(cosmeticBalloonType.getSlot()));
|
||||||
|
|
||||||
PacketManager.sendEntitySpawnPacket(newLoc, userBalloonManager1.getPufferfishBalloonId(), EntityType.PUFFERFISH, userBalloonManager1.getPufferfishBalloonUniqueId(), sentTo);
|
|
||||||
PacketManager.sendInvisibilityPacket(userBalloonManager1.getPufferfishBalloonId(), sentTo);
|
|
||||||
userBalloonManager1.sendLeashPacket(player.getEntityId());
|
|
||||||
|
|
||||||
return userBalloonManager1;
|
return userBalloonManager1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user