mirror of
https://github.com/HibiscusMC/HMCCosmetics.git
synced 2025-12-19 15:09:19 +00:00
Compare commits
145 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
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 | ||
|
|
e48dcf9150 | ||
|
|
0f65c20095 | ||
|
|
68b0955a1f | ||
|
|
1193bc43d7 | ||
|
|
f5105200de | ||
|
|
1b7fdd3dcf | ||
|
|
2e4130012f | ||
|
|
bf7517ab20 | ||
|
|
813642ee92 | ||
|
|
f266721781 | ||
|
|
9793114ea0 | ||
|
|
b00c79f67b | ||
|
|
0528ebfa84 | ||
|
|
1e0ffdc08b | ||
|
|
cc08cc6537 | ||
|
|
455b8cd1a1 | ||
|
|
5c6bb93e6c | ||
|
|
e9c7946319 | ||
|
|
fcde8e7f25 | ||
|
|
7fcbbd6b5a | ||
|
|
a92b4c15f5 | ||
|
|
7439aabfd1 | ||
|
|
50bda8343c | ||
|
|
c189424aa8 | ||
|
|
70b97667c3 | ||
|
|
128a33a21f | ||
|
|
538edb67dd | ||
|
|
9b607a099e | ||
|
|
f084d9e782 | ||
|
|
8ee1400f85 | ||
|
|
8e33b2022b | ||
|
|
a661ea09e1 | ||
|
|
9c2120d13d | ||
|
|
7ea4ccccef | ||
|
|
0b1ed0fbeb | ||
|
|
0aac0a2377 | ||
|
|
04810b91ef | ||
|
|
f072f0e044 | ||
|
|
6e2278f4f0 | ||
|
|
7c95d9614d | ||
|
|
54e8e5102a | ||
|
|
b270d022d4 | ||
|
|
f087933d48 | ||
|
|
ed1d1515bc | ||
|
|
aa364f5e77 | ||
|
|
5ae6d17ef3 | ||
|
|
4590bdcde1 | ||
|
|
f9465e8206 | ||
|
|
cd3a9f1af4 | ||
|
|
853668ff1b | ||
|
|
e2ee55bab4 | ||
|
|
7a13715897 | ||
|
|
d92e3e4616 | ||
|
|
49023ff701 | ||
|
|
1bd405d13e | ||
|
|
69de2fa178 | ||
|
|
cdcf904ac8 | ||
|
|
80f9100bf0 | ||
|
|
751509ece4 | ||
|
|
f36d558e13 |
@@ -2,13 +2,13 @@ import net.minecrell.pluginyml.bukkit.BukkitPluginDescription
|
||||
|
||||
plugins {
|
||||
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("net.minecrell.plugin-yml.bukkit") version "0.5.2"
|
||||
id("net.minecrell.plugin-yml.bukkit") version "0.6.0"
|
||||
}
|
||||
|
||||
group = "com.hibiscusmc"
|
||||
version = "2.3.0"
|
||||
version = "2.5.0"
|
||||
|
||||
allprojects {
|
||||
apply(plugin = "java")
|
||||
@@ -27,6 +27,7 @@ allprojects {
|
||||
// ProtocolLib repo
|
||||
maven("https://repo.dmulloy2.net/repository/public/") //ProtocolLib Repo, constantly down
|
||||
maven("https://repo.mineinabyss.com/releases/")
|
||||
maven("https://repo.mineinabyss.com/snapshots/")
|
||||
|
||||
// PlaceholderAPI
|
||||
maven("https://repo.extendedclip.com/content/repositories/placeholderapi/")
|
||||
@@ -67,29 +68,27 @@ allprojects {
|
||||
dependencies {
|
||||
compileOnly(fileTree("${project.rootDir}/lib") { include("*.jar") })
|
||||
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("com.comphenix.protocol:ProtocolLib:5.0.0-SNAPSHOT")
|
||||
compileOnly("me.clip:placeholderapi:2.11.1")
|
||||
compileOnly("com.ticxo.modelengine:api:R3.0.1")
|
||||
compileOnly("com.comphenix.protocol:ProtocolLib:5.0.0")
|
||||
compileOnly("me.clip:placeholderapi:2.11.3")
|
||||
compileOnly("com.ticxo:modelengine:R3.0.1")
|
||||
compileOnly("com.github.oraxen:oraxen:-SNAPSHOT")
|
||||
compileOnly("com.github.LoneDev6:API-ItemsAdder:3.2.5")
|
||||
compileOnly("com.mineinabyss:idofront:0.12.111")
|
||||
compileOnly("com.mineinabyss:geary-papermc-core:0.19.113")
|
||||
compileOnly("com.mineinabyss:looty:0.8.67")
|
||||
compileOnly("com.mineinabyss:geary-papermc:0.24-SNAPSHOT")
|
||||
compileOnly("com.sk89q.worldguard:worldguard-bukkit:7.1.0-SNAPSHOT")
|
||||
compileOnly("it.unimi.dsi:fastutil:8.5.11")
|
||||
compileOnly("com.github.LeonMangler:SuperVanish:6.2.6-4")
|
||||
compileOnly("com.github.LeonMangler:SuperVanish:6.2.17")
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation(project(path = ":common"))
|
||||
implementation(project(path = ":v1_17_R1", configuration = "reobf"))
|
||||
implementation(project(path = ":v1_18_R2", configuration = "reobf"))
|
||||
implementation(project(path = ":v1_19_R1", configuration = "reobf"))
|
||||
implementation(project(path = ":v1_19_R2", configuration = "reobf"))
|
||||
implementation(project(path = ":v1_19_R3", configuration = "reobf"))
|
||||
implementation(project(path = ":v1_20_R1", configuration = "reobf"))
|
||||
|
||||
//compileOnly("com.github.Fisher2911:FisherLib:master-SNAPSHOT")
|
||||
implementation("net.kyori:adventure-api:4.11.0")
|
||||
@@ -100,7 +99,8 @@ dependencies {
|
||||
implementation("org.bstats:bstats-bukkit:3.0.0")
|
||||
implementation("com.jeff_media:SpigotUpdateChecker:3.0.0")
|
||||
implementation("com.owen1212055:particlehelper:1.0.0-SNAPSHOT")
|
||||
implementation("com.ticxo:PlayerAnimator:R1.2.6")
|
||||
implementation("com.ticxo.playeranimator:PlayerAnimator:R1.2.7")
|
||||
implementation("com.github.BG-Software-LLC:CommentedConfiguration:-SNAPSHOT")
|
||||
//implementation("com.ticxo.playeranimator:PlayerAnimator:R1.2.5")
|
||||
}
|
||||
|
||||
@@ -121,15 +121,15 @@ tasks {
|
||||
}
|
||||
|
||||
runServer {
|
||||
minecraftVersion("1.19.4")
|
||||
minecraftVersion("1.20.1")
|
||||
}
|
||||
|
||||
shadowJar {
|
||||
dependsOn(":v1_17_R1:reobfJar")
|
||||
dependsOn(":v1_18_R2:reobfJar")
|
||||
dependsOn(":v1_19_R1:reobfJar")
|
||||
dependsOn(":v1_19_R2:reobfJar")
|
||||
dependsOn(":v1_19_R3:reobfJar")
|
||||
dependsOn(":v1_20_R1:reobfJar")
|
||||
mergeServiceFiles()
|
||||
|
||||
relocate("dev.triumphteam.gui", "com.hisbiscusmc.hmccosmetics.gui")
|
||||
@@ -142,6 +142,7 @@ tasks {
|
||||
relocate("com.jeff_media.updatechecker", "com.hisbiscusmc.hmccosmetics.updatechecker")
|
||||
relocate("com.owen1212055.particlehelper", "com.hisbiscusmc.hmccosmetics.particlehelper")
|
||||
relocate("com.ticxo.playeranimator", "com.hisbiscusmc.hmccosmetics.playeranimator")
|
||||
relocate("com.bgsoftware", "com.hisbiscusmc.hmccosmetics.configupdater")
|
||||
archiveFileName.set("HMCCosmeticsRemapped-${project.version}.jar")
|
||||
|
||||
dependencies {
|
||||
@@ -166,11 +167,14 @@ tasks {
|
||||
bukkit {
|
||||
load = BukkitPluginDescription.PluginLoadOrder.POSTWORLD
|
||||
main = "com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin"
|
||||
apiVersion = "1.17"
|
||||
apiVersion = "1.18"
|
||||
authors = listOf("LoJoSho")
|
||||
depend = listOf("ProtocolLib")
|
||||
softDepend = listOf("ModelEngine", "Oraxen", "ItemsAdder", "Looty", "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}"
|
||||
loadBefore = listOf(
|
||||
"Cosmin" // Fixes an issue with Cosmin loading before and taking /cosmetic, when messing with what we do.
|
||||
)
|
||||
|
||||
commands {
|
||||
register("cosmetic") {
|
||||
@@ -211,7 +215,7 @@ bukkit {
|
||||
register("hmccosmetics.cmd.emote.other") {
|
||||
default = BukkitPluginDescription.Permission.Default.OP
|
||||
}
|
||||
register("hmccosmetics.cmd.setlocation") {
|
||||
register("hmccosmetics.cmd.setwardrobesetting") {
|
||||
default = BukkitPluginDescription.Permission.Default.OP
|
||||
}
|
||||
register("hmccosmetics.cmd.dataclear") {
|
||||
@@ -256,4 +260,4 @@ bukkit {
|
||||
java {
|
||||
toolchain.languageVersion.set(JavaLanguageVersion.of(17
|
||||
))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,21 +5,20 @@ plugins {
|
||||
|
||||
dependencies {
|
||||
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("com.comphenix.protocol:ProtocolLib:5.0.0-SNAPSHOT")
|
||||
compileOnly("me.clip:placeholderapi:2.11.1")
|
||||
compileOnly("com.ticxo.modelengine:api:R3.0.1")
|
||||
compileOnly("com.comphenix.protocol:ProtocolLib:5.0.0")
|
||||
compileOnly("me.clip:placeholderapi:2.11.3")
|
||||
compileOnly("com.ticxo:modelengine:R3.0.1")
|
||||
compileOnly("com.github.oraxen:oraxen:-SNAPSHOT")
|
||||
compileOnly("com.github.LoneDev6:API-ItemsAdder:3.2.5")
|
||||
compileOnly("com.mineinabyss:geary-papermc-core:0.19.113")
|
||||
compileOnly("com.mineinabyss:looty:0.8.67")
|
||||
compileOnly("com.mineinabyss:geary-papermc:0.24-SNAPSHOT")
|
||||
compileOnly("com.hibiscus:hmccolor:0.3-SNAPSHOT")
|
||||
compileOnly("com.sk89q.worldguard:worldguard-bukkit:7.1.0-SNAPSHOT")
|
||||
compileOnly("it.unimi.dsi:fastutil:8.5.11")
|
||||
compileOnly("io.lumine:Mythic-Dist:5.2.1")
|
||||
compileOnly("com.denizenscript:denizen:1.2.7-SNAPSHOT")
|
||||
compileOnly("com.github.LeonMangler:SuperVanish:6.2.6-4")
|
||||
compileOnly("com.github.LeonMangler:SuperVanish:6.2.17")
|
||||
compileOnlyApi("LibsDisguises:LibsDisguises:10.0.21") {
|
||||
exclude("org.spigotmc", "spigot")
|
||||
}
|
||||
@@ -33,7 +32,8 @@ dependencies {
|
||||
implementation("org.bstats:bstats-bukkit:3.0.0")
|
||||
implementation("com.jeff_media:SpigotUpdateChecker:3.0.0")
|
||||
implementation("com.owen1212055:particlehelper:1.0.0-SNAPSHOT")
|
||||
implementation("com.ticxo:PlayerAnimator:R1.2.6")
|
||||
implementation("com.ticxo.playeranimator:PlayerAnimator:R1.2.7")
|
||||
implementation("com.github.BG-Software-LLC:CommentedConfiguration:-SNAPSHOT")
|
||||
//implementation("com.ticxo.playeranimator:PlayerAnimator:R1.2.5")
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.hibiscusmc.hmccosmetics;
|
||||
|
||||
import com.hibiscusmc.hmccosmetics.api.HMCCosmeticSetupEvent;
|
||||
import com.bgsoftware.common.config.CommentedConfiguration;
|
||||
import com.hibiscusmc.hmccosmetics.api.events.HMCCosmeticSetupEvent;
|
||||
import com.hibiscusmc.hmccosmetics.command.CosmeticCommand;
|
||||
import com.hibiscusmc.hmccosmetics.command.CosmeticCommandTabComplete;
|
||||
import com.hibiscusmc.hmccosmetics.config.DatabaseSettings;
|
||||
@@ -12,6 +13,7 @@ import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
|
||||
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetics;
|
||||
import com.hibiscusmc.hmccosmetics.database.Database;
|
||||
import com.hibiscusmc.hmccosmetics.emotes.EmoteManager;
|
||||
import com.hibiscusmc.hmccosmetics.gui.Menu;
|
||||
import com.hibiscusmc.hmccosmetics.gui.Menus;
|
||||
import com.hibiscusmc.hmccosmetics.hooks.Hooks;
|
||||
import com.hibiscusmc.hmccosmetics.hooks.worldguard.WGHook;
|
||||
@@ -48,7 +50,6 @@ public final class HMCCosmeticsPlugin extends JavaPlugin {
|
||||
private static boolean disable = false;
|
||||
private static YamlConfigurationLoader configLoader;
|
||||
private static final int pluginId = 13873;
|
||||
private static boolean hasModelEngine = false;
|
||||
private static boolean onLatestVersion = true;
|
||||
private static String latestVersion = "";
|
||||
|
||||
@@ -86,13 +87,12 @@ public final class HMCCosmeticsPlugin extends JavaPlugin {
|
||||
.checkNow();
|
||||
onLatestVersion = checker.isUsingLatestVersion();
|
||||
// File setup
|
||||
if (!getDataFolder().exists()) {
|
||||
saveDefaultConfig();
|
||||
saveResource("translations.yml", false);
|
||||
saveResource("messages.yml", false);
|
||||
saveResource("cosmetics/defaultcosmetics.yml", false);
|
||||
saveResource("menus/defaultmenu.yml", false);
|
||||
}
|
||||
saveDefaultConfig();
|
||||
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() + "/menus/").toFile().exists()) saveResource("menus/defaultmenu.yml", false);
|
||||
|
||||
// Emote folder setup
|
||||
File emoteFile = new File(getDataFolder().getPath() + "/emotes");
|
||||
if (!emoteFile.exists()) emoteFile.mkdir();
|
||||
@@ -100,6 +100,20 @@ public final class HMCCosmeticsPlugin extends JavaPlugin {
|
||||
// Player Animator
|
||||
PlayerAnimatorImpl.initialize(this);
|
||||
|
||||
// Configuration Sync
|
||||
final File configFile = Path.of(getInstance().getDataFolder().getPath(), "config.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 {
|
||||
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");
|
||||
CommentedConfiguration.loadConfiguration(messageFile).syncWithConfig(messageFile, getInstance().getResource("messages.yml"));
|
||||
CommentedConfiguration.loadConfiguration(translationFile).syncWithConfig(translationFile, getInstance().getResource("translations.yml"));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
// Setup
|
||||
setup();
|
||||
|
||||
// Commands
|
||||
@@ -113,11 +127,6 @@ public final class HMCCosmeticsPlugin extends JavaPlugin {
|
||||
// Database
|
||||
new Database();
|
||||
|
||||
// ModelEngine
|
||||
if (Bukkit.getPluginManager().getPlugin("ModelEngine") != null) {
|
||||
hasModelEngine = true;
|
||||
}
|
||||
|
||||
// WorldGuard
|
||||
if (Bukkit.getPluginManager().getPlugin("WorldGuard") != null && Settings.isWorldGuardMoveCheckEnabled()) {
|
||||
getServer().getPluginManager().registerEvents(new WGListener(), this);
|
||||
@@ -170,7 +179,7 @@ public final class HMCCosmeticsPlugin extends JavaPlugin {
|
||||
WardrobeSettings.load(loader.load().node("wardrobe"));
|
||||
DatabaseSettings.load(loader.load().node("database-settings"));
|
||||
configLoader = loader;
|
||||
} catch (ConfigurateException e) {
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
@@ -236,12 +245,19 @@ public final class HMCCosmeticsPlugin extends JavaPlugin {
|
||||
getInstance().getServer().getPluginManager().addPermission(new Permission(cosmetic.getPermission()));
|
||||
}
|
||||
}
|
||||
for (Menu menu : Menus.values()) {
|
||||
if (menu.getPermissionNode() != null) {
|
||||
if (getInstance().getServer().getPluginManager().getPermission(menu.getPermissionNode()) != null) continue;
|
||||
getInstance().getServer().getPluginManager().addPermission(new Permission(menu.getPermissionNode()));
|
||||
}
|
||||
}
|
||||
|
||||
EmoteManager.loadEmotes();
|
||||
|
||||
getInstance().getLogger().info("Successfully Enabled HMCCosmetics");
|
||||
getInstance().getLogger().info(Cosmetics.values().size() + " Cosmetics Successfully Setup");
|
||||
getInstance().getLogger().info(Menus.getMenuNames().size() + " Menus Successfully Setup");
|
||||
getInstance().getLogger().info(WardrobeSettings.getWardrobes().size() + " Wardrobes Successfully Setup");
|
||||
getInstance().getLogger().info("Data storage is set to " + DatabaseSettings.getDatabaseType());
|
||||
|
||||
Bukkit.getPluginManager().callEvent(new HMCCosmeticSetupEvent());
|
||||
@@ -264,9 +280,6 @@ public final class HMCCosmeticsPlugin extends JavaPlugin {
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean hasModelEngine() {
|
||||
return hasModelEngine;
|
||||
}
|
||||
public static boolean isOnLatestVersion() {
|
||||
return onLatestVersion;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,80 @@
|
||||
package com.hibiscusmc.hmccosmetics.api;
|
||||
|
||||
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.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.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(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(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(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(CosmeticUser user, CosmeticSlot slot) {
|
||||
user.removeCosmeticSlot(slot);
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.hibiscusmc.hmccosmetics.api;
|
||||
package com.hibiscusmc.hmccosmetics.api.events;
|
||||
|
||||
import org.bukkit.event.Event;
|
||||
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.user.CosmeticUser;
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.hibiscusmc.hmccosmetics.api;
|
||||
package com.hibiscusmc.hmccosmetics.api.events;
|
||||
|
||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||
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 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.user.CosmeticUser;
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.hibiscusmc.hmccosmetics.api;
|
||||
package com.hibiscusmc.hmccosmetics.api.events;
|
||||
|
||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||
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 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.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.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.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.user.CosmeticUser;
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.hibiscusmc.hmccosmetics.api;
|
||||
package com.hibiscusmc.hmccosmetics.api.events;
|
||||
|
||||
import com.hibiscusmc.hmccosmetics.config.Wardrobe;
|
||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.HandlerList;
|
||||
@@ -11,9 +12,11 @@ import org.jetbrains.annotations.NotNull;
|
||||
public class PlayerWardrobeEnterEvent extends PlayerCosmeticEvent implements Cancellable {
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
private boolean cancel = false;
|
||||
private Wardrobe wardrobe;
|
||||
|
||||
public PlayerWardrobeEnterEvent(@NotNull CosmeticUser who) {
|
||||
public PlayerWardrobeEnterEvent(@NotNull CosmeticUser who, @NotNull Wardrobe wardrobe) {
|
||||
super(who);
|
||||
this.wardrobe = wardrobe;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -45,4 +48,12 @@ public class PlayerWardrobeEnterEvent extends PlayerCosmeticEvent implements Can
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
public void setWardrobe(Wardrobe wardrobe) {
|
||||
this.wardrobe = wardrobe;
|
||||
}
|
||||
|
||||
public Wardrobe getWardrobe() {
|
||||
return wardrobe;
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.hibiscusmc.hmccosmetics.api;
|
||||
package com.hibiscusmc.hmccosmetics.api.events;
|
||||
|
||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||
import org.bukkit.event.Cancellable;
|
||||
@@ -2,6 +2,8 @@ package com.hibiscusmc.hmccosmetics.command;
|
||||
|
||||
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
|
||||
import com.hibiscusmc.hmccosmetics.config.Settings;
|
||||
import com.hibiscusmc.hmccosmetics.config.Wardrobe;
|
||||
import com.hibiscusmc.hmccosmetics.config.WardrobeLocation;
|
||||
import com.hibiscusmc.hmccosmetics.config.WardrobeSettings;
|
||||
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
|
||||
import com.hibiscusmc.hmccosmetics.cosmetic.CosmeticSlot;
|
||||
@@ -194,8 +196,14 @@ public class CosmeticCommand implements CommandExecutor {
|
||||
}
|
||||
case ("wardrobe") -> {
|
||||
if (sender instanceof Player) player = ((Player) sender).getPlayer();
|
||||
|
||||
if (args.length == 1) {
|
||||
if (!silent) MessagesUtil.sendMessage(player, "not-enough-args");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (sender.hasPermission("hmccosmetics.cmd.wardrobe.other")) {
|
||||
if (args.length >= 2) player = Bukkit.getPlayer(args[1]);
|
||||
if (args.length >= 3) player = Bukkit.getPlayer(args[2]);
|
||||
}
|
||||
|
||||
if (!sender.hasPermission("hmccosmetics.cmd.wardrobe")) {
|
||||
@@ -208,9 +216,19 @@ public class CosmeticCommand implements CommandExecutor {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!WardrobeSettings.getWardrobeNames().contains(args[1])) {
|
||||
if (!silent) MessagesUtil.sendMessage(sender, "no-wardrobes");
|
||||
return true;
|
||||
}
|
||||
Wardrobe wardrobe = WardrobeSettings.getWardrobe(args[1]);
|
||||
|
||||
CosmeticUser user = CosmeticUsers.getUser(player);
|
||||
|
||||
user.toggleWardrobe();
|
||||
if (user.isInWardrobe()) {
|
||||
user.leaveWardrobe();
|
||||
} else {
|
||||
user.enterWardrobe(false, wardrobe);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
// cosmetic menu exampleMenu playerName
|
||||
@@ -289,36 +307,56 @@ public class CosmeticCommand implements CommandExecutor {
|
||||
DyeMenu.openMenu(user, cosmetic);
|
||||
}
|
||||
}
|
||||
case ("setlocation") -> {
|
||||
if (!sender.hasPermission("hmccosmetics.cmd.setlocation")) {
|
||||
case ("setwardrobesetting") -> {
|
||||
if (!sender.hasPermission("hmccosmetics.cmd.setwardrobesetting")) {
|
||||
if (!silent) MessagesUtil.sendMessage(sender, "no-permission");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (player == null) return true;
|
||||
|
||||
if (args.length < 2) {
|
||||
if (args.length < 3) {
|
||||
if (!silent) MessagesUtil.sendMessage(player, "not-enough-args");
|
||||
return true;
|
||||
}
|
||||
Wardrobe wardrobe = WardrobeSettings.getWardrobe(args[1]);
|
||||
if (wardrobe == null) {
|
||||
wardrobe = new Wardrobe(args[1], new WardrobeLocation(null, null, null), null, -1);
|
||||
WardrobeSettings.addWardrobe(wardrobe);
|
||||
//MessagesUtil.sendMessage(player, "no-wardrobes");
|
||||
//return true;
|
||||
}
|
||||
|
||||
if (args[1].equalsIgnoreCase("wardrobelocation")) {
|
||||
WardrobeSettings.setWardrobeLocation(player.getLocation());
|
||||
if (args[2].equalsIgnoreCase("npclocation")) {
|
||||
WardrobeSettings.setNPCLocation(wardrobe, player.getLocation());
|
||||
if (!silent) MessagesUtil.sendMessage(player, "set-wardrobe-location");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (args[1].equalsIgnoreCase("viewerlocation")) {
|
||||
WardrobeSettings.setViewerLocation(player.getLocation());
|
||||
if (args[2].equalsIgnoreCase("viewerlocation")) {
|
||||
WardrobeSettings.setViewerLocation(wardrobe, player.getLocation());
|
||||
if (!silent) MessagesUtil.sendMessage(player, "set-wardrobe-viewing");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (args[1].equalsIgnoreCase("leavelocation")) {
|
||||
WardrobeSettings.setLeaveLocation(player.getLocation());
|
||||
if (args[2].equalsIgnoreCase("leavelocation")) {
|
||||
WardrobeSettings.setLeaveLocation(wardrobe, player.getLocation());
|
||||
if (!silent) MessagesUtil.sendMessage(player, "set-wardrobe-leaving");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (args.length >= 4) {
|
||||
if (args[2].equalsIgnoreCase("permission")) {
|
||||
WardrobeSettings.setWardrobePermission(wardrobe, args[3]);
|
||||
if (!silent) MessagesUtil.sendMessage(player, "set-wardrobe-permission");
|
||||
return true;
|
||||
}
|
||||
if (args[2].equalsIgnoreCase("distance")) {
|
||||
WardrobeSettings.setWardrobeDistance(wardrobe, Integer.valueOf(args[3]));
|
||||
if (!silent) MessagesUtil.sendMessage(player, "set-wardrobe-distance");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
case ("dump") -> {
|
||||
if (player == null) return true;
|
||||
@@ -442,7 +480,7 @@ public class CosmeticCommand implements CommandExecutor {
|
||||
return true;
|
||||
}
|
||||
CosmeticUser user = CosmeticUsers.getUser(player);
|
||||
user.getUserEmoteManager().playEmote(EmoteManager.get(args[1]));
|
||||
user.getUserEmoteManager().playEmote(args[1]);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.hibiscusmc.hmccosmetics.command;
|
||||
|
||||
import com.hibiscusmc.hmccosmetics.config.Wardrobe;
|
||||
import com.hibiscusmc.hmccosmetics.config.WardrobeSettings;
|
||||
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
|
||||
import com.hibiscusmc.hmccosmetics.cosmetic.CosmeticSlot;
|
||||
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetics;
|
||||
@@ -36,7 +38,7 @@ public class CosmeticCommandTabComplete implements TabCompleter {
|
||||
if (hasPermission(sender, "hmccosmetics.cmd.wardrobe")) completions.add("wardrobe");
|
||||
if (hasPermission(sender, "hmccosmetics.cmd.dataclear")) completions.add("dataclear");
|
||||
if (hasPermission(sender, "hmccosmetics.cmd.dye")) completions.add("dye");
|
||||
if (hasPermission(sender, "hmccosmetics.cmd.setlocation")) completions.add("setlocation");
|
||||
if (hasPermission(sender, "hmccosmetics.cmd.setwardrobesetting")) completions.add("setwardrobesetting");
|
||||
if (hasPermission(sender, "hmccosmetics.cmd.hide")) completions.add("hide");
|
||||
if (hasPermission(sender, "hmccosmetics.cmd.show")) completions.add("show");
|
||||
if (hasPermission(sender, "hmccosmetics.cmd.debug")) completions.add("debug");
|
||||
@@ -66,20 +68,29 @@ public class CosmeticCommandTabComplete implements TabCompleter {
|
||||
if (menu.canOpen(user.getPlayer())) completions.add(menu.getId());
|
||||
}
|
||||
}
|
||||
case "dataclear", "wardrobe", "hide", "show", "emote" -> {
|
||||
case "dataclear", "hide", "show", "emote" -> {
|
||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||
completions.add(player.getName());
|
||||
}
|
||||
}
|
||||
case "wardrobe" -> {
|
||||
for (Wardrobe wardrobe : WardrobeSettings.getWardrobes()) {
|
||||
if (wardrobe.hasPermission()) {
|
||||
if (user.getPlayer().hasPermission(wardrobe.getPermission())) completions.add(wardrobe.getId());
|
||||
} else {
|
||||
completions.add(wardrobe.getId());
|
||||
}
|
||||
}
|
||||
}
|
||||
case "dye" -> {
|
||||
for (CosmeticSlot slot : user.getDyeableSlots()) {
|
||||
completions.add(slot.name());
|
||||
}
|
||||
}
|
||||
case "setlocation" -> {
|
||||
completions.add("wardrobelocation");
|
||||
completions.add("viewerlocation");
|
||||
completions.add("leavelocation");
|
||||
case "setwardrobesetting" -> {
|
||||
for (Wardrobe wardrobe : WardrobeSettings.getWardrobes()) {
|
||||
completions.add(wardrobe.getId());
|
||||
}
|
||||
}
|
||||
case "playemote" -> completions.addAll(EmoteManager.getAllNames());
|
||||
}
|
||||
@@ -91,11 +102,18 @@ public class CosmeticCommandTabComplete implements TabCompleter {
|
||||
case "dye" -> {
|
||||
completions.add("#FFFFFF");
|
||||
}
|
||||
case "menu", "apply", "unapply", "playemote" -> {
|
||||
case "menu", "wardrobe", "apply", "unapply", "playemote" -> {
|
||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||
completions.add(player.getName());
|
||||
}
|
||||
}
|
||||
case "setwardrobesetting" -> {
|
||||
completions.add("npclocation");
|
||||
completions.add("viewerlocation");
|
||||
completions.add("leavelocation");
|
||||
completions.add("permission");
|
||||
completions.add("distance");
|
||||
}
|
||||
}
|
||||
StringUtil.copyPartialMatches(args[2], completions, finalCompletions);
|
||||
}
|
||||
|
||||
@@ -34,6 +34,7 @@ public class Settings {
|
||||
private static final String TICK_PERIOD_PATH = "tick-period";
|
||||
private static final String UNAPPLY_DEATH_PATH = "unapply-on-death";
|
||||
private static final String FORCE_PERMISSION_JOIN_PATH = "force-permission-join";
|
||||
private static final String FORCE_SHOW_COSMETICS_PATH = "force-show-join";
|
||||
private static final String EMOTE_DISTANCE_PATH = "emote-distance";
|
||||
private static final String HOOK_SETTING_PATH = "hook-settings";
|
||||
private static final String HOOK_ITEMADDER_PATH = "itemsadder";
|
||||
@@ -42,6 +43,7 @@ public class Settings {
|
||||
private static final String HOOK_WG_MOVE_CHECK_PATH = "player-move-check";
|
||||
private static final String HOOK_WG_MOVE_CHECK_PATH_LEGACY = "player_move_check";
|
||||
private static final String COSMETIC_EMOTE_CHECK_PATH = "emote-block-check";
|
||||
private static final String COSMETIC_EMOTE_AIR_CHECK_PATH = "emote-air-check";
|
||||
private static final String COSMETIC_EMOTE_DAMAGE_PATH = "emote-damage-leave";
|
||||
private static final String COSMETIC_EMOTE_INVINCIBLE_PATH = "emote-invincible";
|
||||
private static final String COSMETIC_ADD_ENCHANTS_HELMET_PATH = "helmet-add-enchantments";
|
||||
@@ -63,6 +65,7 @@ public class Settings {
|
||||
private static boolean debugMode;
|
||||
private static boolean unapplyOnDeath;
|
||||
private static boolean forcePermissionJoin;
|
||||
private static boolean forceShowOnJoin;
|
||||
private static boolean itemsAdderChangeReload;
|
||||
private static boolean worldGuardMoveCheck;
|
||||
private static boolean cosmeticEmoteBlockCheck;
|
||||
@@ -70,6 +73,7 @@ public class Settings {
|
||||
private static boolean addChestplateEnchants;
|
||||
private static boolean addLeggingEnchants;
|
||||
private static boolean addBootsEnchants;
|
||||
private static boolean emoteAirCheck;
|
||||
private static boolean emoteDamageLeave;
|
||||
private static boolean emoteInvincible;
|
||||
private static boolean destroyLooseCosmetics;
|
||||
@@ -103,8 +107,10 @@ public class Settings {
|
||||
requireEmptyBoots = cosmeticSettings.node(REQUIRE_EMPTY_BOOTS_PATH).getBoolean();
|
||||
unapplyOnDeath = cosmeticSettings.node(UNAPPLY_DEATH_PATH).getBoolean(false);
|
||||
forcePermissionJoin = cosmeticSettings.node(FORCE_PERMISSION_JOIN_PATH).getBoolean(false);
|
||||
forceShowOnJoin = cosmeticSettings.node(FORCE_SHOW_COSMETICS_PATH).getBoolean(false);
|
||||
emoteDistance = cosmeticSettings.node(EMOTE_DISTANCE_PATH).getDouble(-3);
|
||||
cosmeticEmoteBlockCheck = cosmeticSettings.node(COSMETIC_EMOTE_CHECK_PATH).getBoolean(true);
|
||||
emoteAirCheck = cosmeticSettings.node(COSMETIC_EMOTE_AIR_CHECK_PATH).getBoolean(true);
|
||||
emoteDamageLeave = cosmeticSettings.node(COSMETIC_EMOTE_DAMAGE_PATH).getBoolean(false);
|
||||
emoteInvincible = cosmeticSettings.node(COSMETIC_EMOTE_INVINCIBLE_PATH).getBoolean(false);
|
||||
destroyLooseCosmetics = cosmeticSettings.node(COSMETIC_DESTROY_LOOSE_COSMETIC_PATH).getBoolean(false);
|
||||
@@ -251,6 +257,10 @@ public class Settings {
|
||||
return forcePermissionJoin;
|
||||
}
|
||||
|
||||
public static boolean isForceShowOnJoin() {
|
||||
return forceShowOnJoin;
|
||||
}
|
||||
|
||||
public static boolean getDebugMode() {
|
||||
return debugMode;
|
||||
}
|
||||
@@ -263,6 +273,10 @@ public class Settings {
|
||||
return cosmeticEmoteBlockCheck;
|
||||
}
|
||||
|
||||
public static boolean getEmoteAirCheck() {
|
||||
return emoteAirCheck;
|
||||
}
|
||||
|
||||
public static boolean isEmoteDamageLeave() {
|
||||
return emoteDamageLeave;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
package com.hibiscusmc.hmccosmetics.config;
|
||||
|
||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||
import org.bukkit.Location;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class Wardrobe {
|
||||
|
||||
private String id;
|
||||
private int distance = WardrobeSettings.getDefaultDistance();
|
||||
private String permission;
|
||||
private WardrobeLocation location;
|
||||
|
||||
public Wardrobe(String id, WardrobeLocation location, @Nullable String permission, int distance) {
|
||||
this.id = id;
|
||||
this.location = location;
|
||||
if (permission != null) this.permission = permission;
|
||||
if (distance != -1) this.distance = distance;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public WardrobeLocation getLocation() {
|
||||
return location;
|
||||
}
|
||||
|
||||
public void setDistance(int distance) {
|
||||
this.distance = distance;
|
||||
}
|
||||
|
||||
public void setPermission(String permission) {
|
||||
this.permission = permission;
|
||||
}
|
||||
|
||||
public boolean hasPermission() {
|
||||
return permission != null;
|
||||
}
|
||||
public int getDistance() {
|
||||
return distance;
|
||||
}
|
||||
|
||||
public String getPermission() {
|
||||
return permission;
|
||||
}
|
||||
|
||||
public void setLocation(WardrobeLocation location) {
|
||||
this.location = location;
|
||||
}
|
||||
|
||||
public boolean canEnter(CosmeticUser user) {
|
||||
Location wardrobeLocation = location.getNpcLocation();
|
||||
Location location = user.getEntity().getLocation();
|
||||
if (wardrobeLocation == null) return false;
|
||||
if (distance == -1) return true;
|
||||
if (!wardrobeLocation.getWorld().equals(location.getWorld())) return false;
|
||||
return wardrobeLocation.distanceSquared(location) <= distance * distance;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package com.hibiscusmc.hmccosmetics.config;
|
||||
|
||||
import org.bukkit.Location;
|
||||
|
||||
public class WardrobeLocation {
|
||||
|
||||
private Location npcLocation;
|
||||
private Location viewerLocation;
|
||||
private Location leaveLocation;
|
||||
|
||||
public WardrobeLocation(Location npcLocation, Location viewerLocation, Location leaveLocation) {
|
||||
this.npcLocation = npcLocation;
|
||||
this.viewerLocation = viewerLocation;
|
||||
this.leaveLocation = leaveLocation;
|
||||
}
|
||||
|
||||
public Location getNpcLocation() {
|
||||
return npcLocation.clone();
|
||||
}
|
||||
|
||||
public Location getViewerLocation() {
|
||||
return viewerLocation.clone();
|
||||
}
|
||||
|
||||
public Location getLeaveLocation() {
|
||||
return leaveLocation.clone();
|
||||
}
|
||||
|
||||
public boolean hasAllLocations() {
|
||||
if (npcLocation == null || viewerLocation == null || leaveLocation == null) return false;
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -9,7 +9,11 @@ import org.apache.commons.lang3.EnumUtils;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Location;
|
||||
import org.spongepowered.configurate.ConfigurationNode;
|
||||
import org.spongepowered.configurate.serialize.SerializationException;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.Set;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class WardrobeSettings {
|
||||
|
||||
@@ -25,14 +29,22 @@ public class WardrobeSettings {
|
||||
private static final String APPLY_COSMETICS_ON_CLOSE = "apply-cosmetics-on-close";
|
||||
private static final String OPEN_SOUND = "open-sound";
|
||||
private static final String CLOSE_SOUND = "close-sound";
|
||||
private static final String STATIC_LOCATION_PATH = "wardrobe-location";
|
||||
private static final String NPC_LOCATION_PATH = "npc-location";
|
||||
private static final String VIEWER_LOCATION_PATH = "viewer-location";
|
||||
private static final String LEAVE_LOCATION_PATH = "leave-location";
|
||||
private static final String EQUIP_PUMPKIN_WARDROBE = "equip-pumpkin";
|
||||
private static final String TRY_COSMETICS_WARDROBE = "unchecked-wardrobe-cosmetics";
|
||||
private static final String RETURN_LAST_LOCATION = "return-last-location";
|
||||
|
||||
private static final String 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 FORCE_EXIT_GAMEMODE_PATH = "exit-gamemode-enabled";
|
||||
private static final String EXIT_GAMEMODE_PATH = "exit-gamemode";
|
||||
private static final String WARDROBES_PATH = "wardrobes";
|
||||
private static final String PERMISSION_PATH = "permission";
|
||||
private static final String DISTANCE_PATH = "distance";
|
||||
private static final String BOSSBAR_PATH = "bossbar";
|
||||
private static final String BOSSBAR_ENABLE_PATH = "enabled";
|
||||
private static final String BOSSBAR_TEXT_PATH = "text";
|
||||
@@ -58,14 +70,14 @@ public class WardrobeSettings {
|
||||
private static int despawnDelay;
|
||||
private static float bossbarProgress;
|
||||
private static boolean applyCosmeticsOnClose;
|
||||
private static boolean tryCosmeticsInWardrobe;
|
||||
private static boolean equipPumpkin;
|
||||
private static boolean returnLastLocation;
|
||||
private static boolean enabledBossbar;
|
||||
private static boolean enterOpenMenu;
|
||||
private static boolean forceExitGamemode;
|
||||
private static GameMode exitGamemode;
|
||||
private static Location wardrobeLocation;
|
||||
private static Location viewerLocation;
|
||||
private static Location leaveLocation;
|
||||
private static HashMap<String, Wardrobe> wardrobes;
|
||||
private static String bossbarMessage;
|
||||
private static BossBar.Overlay bossbarOverlay;
|
||||
private static BossBar.Color bossbarColor;
|
||||
@@ -90,6 +102,10 @@ public class WardrobeSettings {
|
||||
applyCosmeticsOnClose = source.node(APPLY_COSMETICS_ON_CLOSE).getBoolean();
|
||||
equipPumpkin = source.node(EQUIP_PUMPKIN_WARDROBE).getBoolean();
|
||||
returnLastLocation = source.node(RETURN_LAST_LOCATION).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);
|
||||
forceExitGamemode = gamemodeNode.node(FORCE_EXIT_GAMEMODE_PATH).getBoolean(false);
|
||||
@@ -119,15 +135,35 @@ public class WardrobeSettings {
|
||||
transitionStay = transitionNode.node(TRANSITION_STAY_PATH).getInt(2000);
|
||||
transitionFadeOut = transitionNode.node(TRANSITION_FADE_OUT_PATH).getInt(2000);
|
||||
|
||||
try {
|
||||
wardrobeLocation = LocationSerializer.INSTANCE.deserialize(Location.class, source.node(STATIC_LOCATION_PATH));
|
||||
MessagesUtil.sendDebugMessages("Wardrobe Location: " + wardrobeLocation);
|
||||
viewerLocation = LocationSerializer.INSTANCE.deserialize(Location.class, source.node(VIEWER_LOCATION_PATH));
|
||||
MessagesUtil.sendDebugMessages("Viewer Location: " + viewerLocation);
|
||||
leaveLocation = Utils.replaceIfNull(LocationSerializer.INSTANCE.deserialize(Location.class, source.node(LEAVE_LOCATION_PATH)), viewerLocation);
|
||||
} catch (SerializationException e) {
|
||||
throw new RuntimeException(e);
|
||||
wardrobes = new HashMap<>();
|
||||
for (ConfigurationNode wardrobesNode : source.node(WARDROBES_PATH).childrenMap().values()) {
|
||||
String id = wardrobesNode.key().toString();
|
||||
try {
|
||||
Location npcLocation = LocationSerializer.INSTANCE.deserialize(Location.class, wardrobesNode.node(NPC_LOCATION_PATH));
|
||||
MessagesUtil.sendDebugMessages("Wardrobe Location: " + npcLocation);
|
||||
Location viewerLocation = LocationSerializer.INSTANCE.deserialize(Location.class, wardrobesNode.node(VIEWER_LOCATION_PATH));
|
||||
MessagesUtil.sendDebugMessages("Viewer Location: " + viewerLocation);
|
||||
Location leaveLocation = Utils.replaceIfNull(LocationSerializer.INSTANCE.deserialize(Location.class, wardrobesNode.node(LEAVE_LOCATION_PATH)), viewerLocation);
|
||||
MessagesUtil.sendDebugMessages("Leave Location: " + leaveLocation);
|
||||
WardrobeLocation wardrobeLocation = new WardrobeLocation(npcLocation, viewerLocation, leaveLocation);
|
||||
|
||||
String permission = null;
|
||||
int distance = -1;
|
||||
if (!wardrobesNode.node(PERMISSION_PATH).virtual()) permission = wardrobesNode.node(PERMISSION_PATH).getString();
|
||||
if (!wardrobesNode.node(DISTANCE_PATH).virtual()) distance = wardrobesNode.node(DISTANCE_PATH).getInt();
|
||||
|
||||
Wardrobe wardrobe = new Wardrobe(id, wardrobeLocation, permission, distance);
|
||||
addWardrobe(wardrobe);
|
||||
} catch (Exception e) {
|
||||
MessagesUtil.sendDebugMessages("Unable to create wardrobe " + id, Level.SEVERE);
|
||||
}
|
||||
}
|
||||
|
||||
//throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
public static int getDefaultDistance() {
|
||||
return staticRadius;
|
||||
}
|
||||
|
||||
public static boolean getDisableOnDamage() {
|
||||
@@ -172,25 +208,36 @@ public class WardrobeSettings {
|
||||
return returnLastLocation;
|
||||
}
|
||||
|
||||
public static Location getWardrobeLocation() {
|
||||
return wardrobeLocation.clone();
|
||||
public static Wardrobe getWardrobe(String key) {
|
||||
return wardrobes.get(key);
|
||||
}
|
||||
|
||||
public static Location getViewerLocation() {
|
||||
return viewerLocation;
|
||||
public static Set<String> getWardrobeNames() {
|
||||
return wardrobes.keySet();
|
||||
}
|
||||
|
||||
public static Location getLeaveLocation() {
|
||||
return leaveLocation;
|
||||
public static Collection<Wardrobe> getWardrobes() {
|
||||
return wardrobes.values();
|
||||
}
|
||||
|
||||
public static void addWardrobe(Wardrobe wardrobe) {
|
||||
wardrobes.put(wardrobe.getId(), wardrobe);
|
||||
}
|
||||
|
||||
public static void removeWardrobe(String id) {
|
||||
wardrobes.remove(id);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static boolean inDistanceOfWardrobe(final Location wardrobeLocation, final Location playerLocation) {
|
||||
if (displayRadius == -1) return true;
|
||||
if (!wardrobeLocation.getWorld().equals(playerLocation.getWorld())) return false;
|
||||
return playerLocation.distanceSquared(wardrobeLocation) <= displayRadius * displayRadius;
|
||||
}
|
||||
|
||||
public static boolean inDistanceOfStatic(final Location location) {
|
||||
@Deprecated
|
||||
public static boolean inDistanceOfStatic(Wardrobe wardrobe, final Location location) {
|
||||
Location wardrobeLocation = wardrobe.getLocation().getNpcLocation();
|
||||
if (wardrobeLocation == null) return false;
|
||||
if (staticRadius == -1) return true;
|
||||
if (!wardrobeLocation.getWorld().equals(location.getWorld())) return false;
|
||||
@@ -237,6 +284,10 @@ public class WardrobeSettings {
|
||||
return transitionFadeOut;
|
||||
}
|
||||
|
||||
public static boolean isEnterOpenMenu() {
|
||||
return enterOpenMenu;
|
||||
}
|
||||
|
||||
public static boolean isForceExitGamemode() {
|
||||
return forceExitGamemode;
|
||||
}
|
||||
@@ -245,57 +296,84 @@ public class WardrobeSettings {
|
||||
return exitGamemode;
|
||||
}
|
||||
|
||||
public static void setWardrobeLocation(Location newLocation) {
|
||||
wardrobeLocation = newLocation;
|
||||
|
||||
HMCCosmeticsPlugin plugin = HMCCosmeticsPlugin.getInstance();
|
||||
|
||||
plugin.getConfig().set("wardrobe.wardrobe-location." + "world", newLocation.getWorld().getName());
|
||||
plugin.getConfig().set("wardrobe.wardrobe-location." + "x", newLocation.getX());
|
||||
plugin.getConfig().set("wardrobe.wardrobe-location." + "y", newLocation.getY());
|
||||
plugin.getConfig().set("wardrobe.wardrobe-location." + "z", newLocation.getZ());
|
||||
plugin.getConfig().set("wardrobe.wardrobe-location." + "yaw", newLocation.getYaw());
|
||||
plugin.getConfig().set("wardrobe.wardrobe-location." + "pitch", newLocation.getPitch());
|
||||
|
||||
/* Configuration sets suck
|
||||
source.node(WORLD).set(loc.getWorld().getName());
|
||||
source.node(X).set(loc.getX());
|
||||
source.node(Y).set(loc.getY());
|
||||
source.node(Z).set(loc.getZ());
|
||||
source.node(YAW).set(loc.getYaw());
|
||||
source.node(PITCH).set(loc.getPitch());
|
||||
*/
|
||||
|
||||
HMCCosmeticsPlugin.getInstance().saveConfig();
|
||||
public static boolean isTryCosmeticsInWardrobe() {
|
||||
return tryCosmeticsInWardrobe;
|
||||
}
|
||||
|
||||
public static void setViewerLocation(Location newLocation) {
|
||||
viewerLocation = newLocation;
|
||||
/**
|
||||
* Sets where the NPC/Mannequin will spawn in the wardrobe
|
||||
* @param newLocation
|
||||
*/
|
||||
public static void setNPCLocation(Wardrobe wardrobe, Location newLocation) {
|
||||
wardrobe.getLocation().setNPCLocation(newLocation);
|
||||
|
||||
HMCCosmeticsPlugin plugin = HMCCosmeticsPlugin.getInstance();
|
||||
|
||||
plugin.getConfig().set("wardrobe.viewer-location." + "world", newLocation.getWorld().getName());
|
||||
plugin.getConfig().set("wardrobe.viewer-location." + "x", newLocation.getX());
|
||||
plugin.getConfig().set("wardrobe.viewer-location." + "y", newLocation.getY());
|
||||
plugin.getConfig().set("wardrobe.viewer-location." + "z", newLocation.getZ());
|
||||
plugin.getConfig().set("wardrobe.viewer-location." + "yaw", newLocation.getYaw());
|
||||
plugin.getConfig().set("wardrobe.viewer-location." + "pitch", newLocation.getPitch());
|
||||
plugin.getConfig().set("wardrobe.wardrobes." + wardrobe.getId() + ".npc-location." + "world", newLocation.getWorld().getName());
|
||||
plugin.getConfig().set("wardrobe.wardrobes." + wardrobe.getId() + ".npc-location." + "x", newLocation.getX());
|
||||
plugin.getConfig().set("wardrobe.wardrobes." + wardrobe.getId() + ".npc-location." + "y", newLocation.getY());
|
||||
plugin.getConfig().set("wardrobe.wardrobes." + wardrobe.getId() + ".npc-location." + "z", newLocation.getZ());
|
||||
plugin.getConfig().set("wardrobe.wardrobes." + wardrobe.getId() + ".npc-location." + "yaw", newLocation.getYaw());
|
||||
plugin.getConfig().set("wardrobe.wardrobes." + wardrobe.getId() + ".npc-location." + "pitch", newLocation.getPitch());
|
||||
|
||||
HMCCosmeticsPlugin.getInstance().saveConfig();
|
||||
plugin.saveConfig();
|
||||
}
|
||||
|
||||
public static void setLeaveLocation(Location newLocation) {
|
||||
leaveLocation = newLocation;
|
||||
/**
|
||||
* Sets where the player will view the wardrobe
|
||||
* @param newLocation
|
||||
*/
|
||||
public static void setViewerLocation(Wardrobe wardrobe, Location newLocation) {
|
||||
wardrobe.getLocation().setViewerLocation(newLocation);
|
||||
|
||||
HMCCosmeticsPlugin plugin = HMCCosmeticsPlugin.getInstance();
|
||||
|
||||
plugin.getConfig().set("wardrobe.leave-location." + "world", newLocation.getWorld().getName());
|
||||
plugin.getConfig().set("wardrobe.leave-location." + "x", newLocation.getX());
|
||||
plugin.getConfig().set("wardrobe.leave-location." + "y", newLocation.getY());
|
||||
plugin.getConfig().set("wardrobe.leave-location." + "z", newLocation.getZ());
|
||||
plugin.getConfig().set("wardrobe.leave-location." + "yaw", newLocation.getYaw());
|
||||
plugin.getConfig().set("wardrobe.leave-location." + "pitch", newLocation.getPitch());
|
||||
plugin.getConfig().set("wardrobe.wardrobes." + wardrobe.getId() + ".viewer-location.world", newLocation.getWorld().getName());
|
||||
plugin.getConfig().set("wardrobe.wardrobes." + wardrobe.getId() + ".viewer-location.x", newLocation.getX());
|
||||
plugin.getConfig().set("wardrobe.wardrobes." + wardrobe.getId() + ".viewer-location.y", newLocation.getY());
|
||||
plugin.getConfig().set("wardrobe.wardrobes." + wardrobe.getId() + ".viewer-location.z", newLocation.getZ());
|
||||
plugin.getConfig().set("wardrobe.wardrobes." + wardrobe.getId() + ".viewer-location.yaw", newLocation.getYaw());
|
||||
plugin.getConfig().set("wardrobe.wardrobes." + wardrobe.getId() + ".viewer-location.pitch", newLocation.getPitch());
|
||||
|
||||
HMCCosmeticsPlugin.getInstance().saveConfig();
|
||||
plugin.saveConfig();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets where a player will leave the wardrobe from
|
||||
* @param newLocation
|
||||
*/
|
||||
public static void setLeaveLocation(Wardrobe wardrobe, Location newLocation) {
|
||||
wardrobe.getLocation().setLeaveLocation(newLocation);
|
||||
|
||||
HMCCosmeticsPlugin plugin = HMCCosmeticsPlugin.getInstance();
|
||||
|
||||
plugin.getConfig().set("wardrobe.wardrobes." + wardrobe.getId() + ".leave-location.world", newLocation.getWorld().getName());
|
||||
plugin.getConfig().set("wardrobe.wardrobes." + wardrobe.getId() + ".leave-location.x", newLocation.getX());
|
||||
plugin.getConfig().set("wardrobe.wardrobes." + wardrobe.getId() + ".leave-location.y", newLocation.getY());
|
||||
plugin.getConfig().set("wardrobe.wardrobes." + wardrobe.getId() + ".leave-location.z", newLocation.getZ());
|
||||
plugin.getConfig().set("wardrobe.wardrobes." + wardrobe.getId() + ".leave-location.yaw", newLocation.getYaw());
|
||||
plugin.getConfig().set("wardrobe.wardrobes." + wardrobe.getId() + ".leave-location.pitch", newLocation.getPitch());
|
||||
|
||||
plugin.saveConfig();
|
||||
}
|
||||
|
||||
public static void setWardrobePermission(Wardrobe wardrobe, String permission) {
|
||||
wardrobe.setPermission(permission);
|
||||
|
||||
HMCCosmeticsPlugin plugin = HMCCosmeticsPlugin.getInstance();
|
||||
|
||||
plugin.getConfig().set("wardrobe.wardrobes." + wardrobe.getId() + ".permission", permission);
|
||||
|
||||
plugin.saveConfig();
|
||||
}
|
||||
|
||||
public static void setWardrobeDistance(Wardrobe wardrobe, int distance) {
|
||||
wardrobe.setDistance(distance);
|
||||
|
||||
HMCCosmeticsPlugin plugin = HMCCosmeticsPlugin.getInstance();
|
||||
|
||||
plugin.getConfig().set("wardrobe.wardrobes." + wardrobe.getId() + ".distance", distance);
|
||||
|
||||
plugin.saveConfig();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,16 +2,14 @@ package com.hibiscusmc.hmccosmetics.config.serializer;
|
||||
|
||||
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
|
||||
import com.hibiscusmc.hmccosmetics.hooks.Hooks;
|
||||
import com.hibiscusmc.hmccosmetics.util.InventoryUtils;
|
||||
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||
import com.hibiscusmc.hmccosmetics.util.ServerUtils;
|
||||
import com.hibiscusmc.hmccosmetics.util.builder.ColorBuilder;
|
||||
import com.hibiscusmc.hmccosmetics.util.misc.StringUtils;
|
||||
import com.hibiscusmc.hmccosmetics.util.misc.Utils;
|
||||
import org.apache.commons.lang3.EnumUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Color;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.inventory.ItemFlag;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
@@ -123,12 +121,25 @@ public class ItemSerializer implements TypeSerializer<ItemStack> {
|
||||
if (item.getType() == Material.PLAYER_HEAD) {
|
||||
SkullMeta skullMeta = (SkullMeta) itemMeta;
|
||||
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()) {
|
||||
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:\""
|
||||
+ textureNode.getString() + "\"}]}}}");
|
||||
+ textureString + "\"}]}}}");
|
||||
|
||||
|
||||
itemMeta = skullMeta;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,8 +15,11 @@ import org.spongepowered.configurate.ConfigurationNode;
|
||||
import org.spongepowered.configurate.yaml.YamlConfigurationLoader;
|
||||
|
||||
import java.io.File;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.Set;
|
||||
import java.util.logging.Level;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
public class Cosmetics {
|
||||
|
||||
@@ -68,19 +71,23 @@ public class Cosmetics {
|
||||
File[] directoryListing = cosmeticFolder.listFiles();
|
||||
if (directoryListing == null) return;
|
||||
|
||||
for (File child : directoryListing) {
|
||||
if (child.toString().contains(".yml") || child.toString().contains(".yaml")) {
|
||||
MessagesUtil.sendDebugMessages("Scanning " + child);
|
||||
// Loads file
|
||||
YamlConfigurationLoader loader = YamlConfigurationLoader.builder().path(child.toPath()).build();
|
||||
CommentedConfigurationNode root;
|
||||
try {
|
||||
root = loader.load();
|
||||
} catch (ConfigurateException e) {
|
||||
throw new RuntimeException(e);
|
||||
try (Stream<Path> walkStream = Files.walk(cosmeticFolder.toPath())) {
|
||||
walkStream.filter(p -> p.toFile().isFile()).forEach(child -> {
|
||||
if (child.toString().contains(".yml") || child.toString().contains(".yaml")) {
|
||||
MessagesUtil.sendDebugMessages("Scanning " + child);
|
||||
// Loads file
|
||||
YamlConfigurationLoader loader = YamlConfigurationLoader.builder().path(child).build();
|
||||
CommentedConfigurationNode root;
|
||||
try {
|
||||
root = loader.load();
|
||||
} catch (ConfigurateException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
setupCosmetics(root);
|
||||
}
|
||||
setupCosmetics(root);
|
||||
}
|
||||
});
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -5,10 +5,10 @@ import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
|
||||
import com.hibiscusmc.hmccosmetics.nms.NMSHandlers;
|
||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||
import com.hibiscusmc.hmccosmetics.util.InventoryUtils;
|
||||
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||
import com.hibiscusmc.hmccosmetics.util.packets.PacketManager;
|
||||
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.ItemStack;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -26,18 +26,20 @@ public class CosmeticArmorType extends Cosmetic {
|
||||
|
||||
@Override
|
||||
public void update(@NotNull CosmeticUser user) {
|
||||
Player player = Bukkit.getPlayer(user.getUniqueId());
|
||||
if (player == null) return;
|
||||
Entity entity = Bukkit.getEntity(user.getUniqueId());
|
||||
if (entity == null) return;
|
||||
if (user.getUserEmoteManager().isPlayingEmote()) return; // There has to be a better way of doing this...
|
||||
ItemStack cosmeticItem = user.getUserCosmeticItem(this);
|
||||
if (!(entity instanceof HumanEntity humanEntity)) return;
|
||||
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)) {
|
||||
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
|
||||
}
|
||||
|
||||
|
||||
@@ -1,40 +1,51 @@
|
||||
package com.hibiscusmc.hmccosmetics.cosmetic.types;
|
||||
|
||||
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
|
||||
import com.hibiscusmc.hmccosmetics.nms.NMSHandlers;
|
||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||
import com.hibiscusmc.hmccosmetics.user.manager.UserBackpackManager;
|
||||
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||
import com.hibiscusmc.hmccosmetics.util.packets.PacketManager;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.AreaEffectCloud;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.EquipmentSlot;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.spongepowered.configurate.ConfigurationNode;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class CosmeticBackpackType extends Cosmetic {
|
||||
|
||||
private final String modelName;
|
||||
private UserBackpackManager.BackpackType backpackType;
|
||||
private ItemStack firstPersonBackpack;
|
||||
|
||||
public CosmeticBackpackType(String id, ConfigurationNode config) {
|
||||
super(id, config);
|
||||
|
||||
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"));
|
||||
}
|
||||
//backpackType = UserBackpackManager.BackpackType.valueOf(config.node("type").getString("NORMAL").toUpperCase());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(@NotNull CosmeticUser user) {
|
||||
Player player = Bukkit.getPlayer(user.getUniqueId());
|
||||
if (player == null) return;
|
||||
Entity entity = Bukkit.getEntity(user.getUniqueId());
|
||||
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.getUserBackpackManager().getArmorStand().isValid()) {
|
||||
MessagesUtil.sendDebugMessages("Invalid Backpack detected! Respawning backpack, report this on the discord if this happens often!", Level.WARNING);
|
||||
if (!user.getUserBackpackManager().IsValidBackpackEntity()) {
|
||||
MessagesUtil.sendDebugMessages("Invalid Backpack Entity[owner=" + user.getUniqueId() + ",player_location=" + loc + "]!", Level.WARNING);
|
||||
user.respawnBackpack();
|
||||
return;
|
||||
}
|
||||
@@ -43,16 +54,26 @@ public class CosmeticBackpackType extends Cosmetic {
|
||||
}
|
||||
|
||||
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());
|
||||
|
||||
List<Player> outsideViewers = user.getUserBackpackManager().getCloudManager().refreshViewers(loc);
|
||||
if (!user.isInWardrobe() && isFirstPersonCompadible()) {
|
||||
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()) NMSHandlers.getHandler().equipmentSlotUpdate(user.getUserBackpackManager().getFirstArmorStandId(), EquipmentSlot.HEAD, firstPersonBackpack, owner);
|
||||
MessagesUtil.sendDebugMessages("First Person Backpack Update[owner=" + user.getUniqueId() + ",player_location=" + loc + "]!", Level.INFO);
|
||||
}
|
||||
PacketManager.sendRidingPacket(entity.getEntityId(), user.getUserBackpackManager().getFirstArmorStandId(), outsideViewers);
|
||||
|
||||
user.getUserBackpackManager().showBackpack();
|
||||
}
|
||||
|
||||
@@ -60,7 +81,7 @@ public class CosmeticBackpackType extends Cosmetic {
|
||||
return modelName;
|
||||
}
|
||||
|
||||
public UserBackpackManager.BackpackType getBackpackType() {
|
||||
return backpackType;
|
||||
public boolean isFirstPersonCompadible() {
|
||||
return firstPersonBackpack != null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,11 +2,13 @@ package com.hibiscusmc.hmccosmetics.cosmetic.types;
|
||||
|
||||
import com.hibiscusmc.hmccosmetics.config.Settings;
|
||||
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
|
||||
import com.hibiscusmc.hmccosmetics.user.manager.UserBalloonManager;
|
||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||
import com.hibiscusmc.hmccosmetics.user.manager.UserBalloonManager;
|
||||
import com.hibiscusmc.hmccosmetics.util.packets.PacketManager;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.util.Vector;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -42,10 +44,10 @@ public class CosmeticBalloonType extends Cosmetic {
|
||||
|
||||
@Override
|
||||
public void update(@NotNull CosmeticUser user) {
|
||||
Player player = Bukkit.getPlayer(user.getUniqueId());
|
||||
Entity entity = Bukkit.getEntity(user.getUniqueId());
|
||||
UserBalloonManager userBalloonManager = user.getBalloonManager();
|
||||
|
||||
if (player == null || userBalloonManager == null) return;
|
||||
if (entity == null || userBalloonManager == null) return;
|
||||
if (user.isInWardrobe()) return;
|
||||
|
||||
if (!userBalloonManager.getModelEntity().isValid()) {
|
||||
@@ -53,14 +55,13 @@ public class CosmeticBalloonType extends Cosmetic {
|
||||
return;
|
||||
}
|
||||
|
||||
Location newLocation = player.getLocation();
|
||||
Location newLocation = entity.getLocation();
|
||||
Location currentLocation = user.getBalloonManager().getLocation();
|
||||
newLocation = newLocation.clone().add(Settings.getBalloonOffset());
|
||||
|
||||
List<Player> viewer = PacketManager.getViewers(player.getLocation());
|
||||
viewer.add(player);
|
||||
List<Player> viewer = PacketManager.getViewers(entity.getLocation());
|
||||
|
||||
if (player.getLocation().getWorld() != userBalloonManager.getLocation().getWorld()) {
|
||||
if (entity.getLocation().getWorld() != userBalloonManager.getLocation().getWorld()) {
|
||||
userBalloonManager.getModelEntity().teleport(newLocation);
|
||||
PacketManager.sendTeleportPacket(userBalloonManager.getPufferfishBalloonId(), newLocation, false, viewer);
|
||||
return;
|
||||
@@ -71,7 +72,17 @@ public class CosmeticBalloonType extends Cosmetic {
|
||||
userBalloonManager.setLocation(newLocation);
|
||||
|
||||
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();
|
||||
return;
|
||||
}
|
||||
if (!user.getHidden() && showLead) {
|
||||
List<Player> sendTo = userBalloonManager.getPufferfish().refreshViewers(newLocation);
|
||||
if (sendTo.isEmpty()) return;
|
||||
PacketManager.sendEntitySpawnPacket(newLocation, userBalloonManager.getPufferfishBalloonId(), EntityType.PUFFERFISH, userBalloonManager.getPufferfishBalloonUniqueId(), sendTo);
|
||||
PacketManager.sendInvisibilityPacket(userBalloonManager.getPufferfishBalloonId(), sendTo);
|
||||
}
|
||||
}
|
||||
|
||||
public String getModelName() {
|
||||
|
||||
@@ -9,11 +9,13 @@ import org.spongepowered.configurate.ConfigurationNode;
|
||||
public class CosmeticEmoteType extends Cosmetic {
|
||||
|
||||
private final String animationId;
|
||||
private final String text;
|
||||
|
||||
public CosmeticEmoteType(String id, ConfigurationNode config) {
|
||||
super(id, config);
|
||||
|
||||
animationId = config.node("animation").getString();
|
||||
text = config.node("text").getString();
|
||||
MessagesUtil.sendDebugMessages("CosmeticEmoteType Animation id " + animationId);
|
||||
}
|
||||
|
||||
@@ -29,4 +31,8 @@ public class CosmeticEmoteType extends Cosmetic {
|
||||
public String getAnimationId() {
|
||||
return animationId;
|
||||
}
|
||||
|
||||
public String getText() {
|
||||
return text;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@ package com.hibiscusmc.hmccosmetics.database;
|
||||
|
||||
import com.hibiscusmc.hmccosmetics.config.DatabaseSettings;
|
||||
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.SQLiteData;
|
||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||
@@ -16,9 +15,6 @@ public class Database {
|
||||
|
||||
private static Data data;
|
||||
|
||||
@Deprecated
|
||||
private static InternalData INTERNAL_DATA = new InternalData();
|
||||
|
||||
private static final MySQLData MYSQL_DATA = new MySQLData();
|
||||
private static final SQLiteData SQLITE_DATA = new SQLiteData();
|
||||
|
||||
|
||||
@@ -50,10 +50,13 @@ public abstract class Data {
|
||||
return data;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public final Map<CosmeticSlot, Map<Cosmetic, Color>> deserializeData(CosmeticUser user, @NotNull String raw) {
|
||||
return deserializeData(user, raw, Settings.getForcePermissionJoin());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public final Map<CosmeticSlot, Map<Cosmetic, Color>> deserializeData(CosmeticUser user, @NotNull String raw, boolean permissionCheck) {
|
||||
Map<CosmeticSlot, Map<Cosmetic, Color>> cosmetics = new HashMap<>();
|
||||
boolean checkPermission = Settings.getForcePermissionJoin();
|
||||
|
||||
String[] rawData = raw.split(",");
|
||||
for (String a : rawData) {
|
||||
@@ -64,6 +67,7 @@ public abstract class Data {
|
||||
MessagesUtil.sendDebugMessages("First split (suppose slot) " + splitData[0]);
|
||||
if (splitData[0].equalsIgnoreCase("HIDDEN")) {
|
||||
if (EnumUtils.isValidEnum(CosmeticUser.HiddenReason.class, splitData[1])) {
|
||||
if (Settings.isForceShowOnJoin()) continue;
|
||||
Bukkit.getScheduler().runTask(HMCCosmeticsPlugin.getInstance(), () -> {
|
||||
user.hideCosmetics(CosmeticUser.HiddenReason.valueOf(splitData[1]));
|
||||
});
|
||||
@@ -75,8 +79,8 @@ public abstract class Data {
|
||||
String[] colorSplitData = splitData[1].split("&");
|
||||
if (Cosmetics.hasCosmetic(colorSplitData[0])) cosmetic = Cosmetics.getCosmetic(colorSplitData[0]);
|
||||
if (slot == null || cosmetic == null) continue;
|
||||
if (cosmetic.requiresPermission() && checkPermission) {
|
||||
if (!user.getPlayer().hasPermission(cosmetic.getPermission())) {
|
||||
if (permissionCheck && cosmetic.requiresPermission()) {
|
||||
if (user.getPlayer() != null && !user.getPlayer().hasPermission(cosmetic.getPermission())) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
@@ -84,8 +88,8 @@ public abstract class Data {
|
||||
} else {
|
||||
if (Cosmetics.hasCosmetic(splitData[1])) cosmetic = Cosmetics.getCosmetic(splitData[1]);
|
||||
if (slot == null || cosmetic == null) continue;
|
||||
if (cosmetic.requiresPermission() && checkPermission) {
|
||||
if (!user.getPlayer().hasPermission(cosmetic.getPermission())) {
|
||||
if (permissionCheck && cosmetic.requiresPermission()) {
|
||||
if (user.getPlayer() != null && !user.getPlayer().hasPermission(cosmetic.getPermission())) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6,7 +6,10 @@ import org.bukkit.Bukkit;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
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.UUID;
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ import java.util.UUID;
|
||||
|
||||
public abstract class SQLData extends Data {
|
||||
@Override
|
||||
@SuppressWarnings({"Duplicates", "resource"}) // Duplicate is from deprecated InternalData
|
||||
@SuppressWarnings({"resource"}) // Duplicate is from deprecated InternalData
|
||||
public CosmeticUser get(UUID uniqueId) {
|
||||
CosmeticUser user = new CosmeticUser(uniqueId);
|
||||
|
||||
|
||||
@@ -6,7 +6,10 @@ import org.bukkit.Bukkit;
|
||||
|
||||
import java.io.File;
|
||||
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.logging.Level;
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ import java.util.Set;
|
||||
*/
|
||||
@SuppressWarnings("SpellCheckingInspection")
|
||||
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
|
||||
|
||||
@@ -1,19 +1,20 @@
|
||||
package com.hibiscusmc.hmccosmetics.gui;
|
||||
|
||||
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
|
||||
import com.hibiscusmc.hmccosmetics.api.PlayerMenuOpenEvent;
|
||||
import com.hibiscusmc.hmccosmetics.api.events.PlayerMenuOpenEvent;
|
||||
import com.hibiscusmc.hmccosmetics.config.serializer.ItemSerializer;
|
||||
import com.hibiscusmc.hmccosmetics.gui.type.Type;
|
||||
import com.hibiscusmc.hmccosmetics.gui.type.Types;
|
||||
import com.hibiscusmc.hmccosmetics.hooks.Hooks;
|
||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||
import com.hibiscusmc.hmccosmetics.util.misc.Adventure;
|
||||
import com.hibiscusmc.hmccosmetics.util.misc.Placeholder;
|
||||
import dev.triumphteam.gui.builder.item.ItemBuilder;
|
||||
import dev.triumphteam.gui.guis.Gui;
|
||||
import dev.triumphteam.gui.guis.GuiItem;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
@@ -23,7 +24,9 @@ import org.spongepowered.configurate.ConfigurationNode;
|
||||
import org.spongepowered.configurate.serialize.SerializationException;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
public class Menu {
|
||||
|
||||
@@ -32,6 +35,8 @@ public class Menu {
|
||||
private final int rows;
|
||||
private final ConfigurationNode config;
|
||||
private final String permissionNode;
|
||||
private final ArrayList<MenuItem> items;
|
||||
private final int refreshRate;
|
||||
|
||||
public Menu(String id, @NotNull ConfigurationNode config) {
|
||||
this.id = id;
|
||||
@@ -40,10 +45,58 @@ public class Menu {
|
||||
title = config.node("title").getString("chest");
|
||||
rows = config.node("rows").getInt(1);
|
||||
permissionNode = config.node("permission").getString("");
|
||||
refreshRate = config.node("refresh-rate").getInt(-1);
|
||||
|
||||
items = new ArrayList<>();
|
||||
setupItems();
|
||||
|
||||
Menus.addMenu(this);
|
||||
}
|
||||
|
||||
private void setupItems() {
|
||||
for (ConfigurationNode config : config.node("items").childrenMap().values()) {
|
||||
|
||||
List<String> slotString;
|
||||
try {
|
||||
slotString = config.node("slots").getList(String.class);
|
||||
} catch (SerializationException e) {
|
||||
continue;
|
||||
}
|
||||
if (slotString == null) {
|
||||
MessagesUtil.sendDebugMessages("Unable to get valid slot for " + config.key().toString());
|
||||
continue;
|
||||
}
|
||||
|
||||
List<Integer> slots = getSlots(slotString);
|
||||
|
||||
if (slots == null) {
|
||||
MessagesUtil.sendDebugMessages("Slot is null for " + config.key().toString());
|
||||
continue;
|
||||
}
|
||||
|
||||
ItemStack item;
|
||||
try {
|
||||
item = ItemSerializer.INSTANCE.deserialize(ItemStack.class, config.node("item"));
|
||||
} catch (SerializationException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
if (item == null) {
|
||||
MessagesUtil.sendDebugMessages("something went wrong! " + item);
|
||||
continue;
|
||||
}
|
||||
|
||||
Type type = null;
|
||||
|
||||
if (!config.node("type").virtual()) {
|
||||
String typeId = config.node("type").getString();
|
||||
if (Types.isType(typeId)) type = Types.getType(typeId);
|
||||
}
|
||||
|
||||
items.add(new MenuItem(slots, item, type, config));
|
||||
}
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
@@ -69,7 +122,7 @@ public class Menu {
|
||||
return;
|
||||
}
|
||||
}
|
||||
final Component component = Adventure.MINI_MESSAGE.deserialize(Placeholder.applyPapiPlaceholders(player, this.title));
|
||||
final Component component = Adventure.MINI_MESSAGE.deserialize(Hooks.processPlaceholders(player, this.title));
|
||||
Gui gui = Gui.gui().
|
||||
title(component).
|
||||
rows(this.rows).
|
||||
@@ -77,93 +130,60 @@ public class Menu {
|
||||
|
||||
gui.setDefaultClickAction(event -> event.setCancelled(true));
|
||||
|
||||
gui = getItems(user, gui);
|
||||
AtomicInteger taskid = new AtomicInteger(-1);
|
||||
gui.setOpenGuiAction(event -> {
|
||||
Runnable run = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (gui.getInventory().getViewers().size() == 0 && taskid.get() != -1) {
|
||||
Bukkit.getScheduler().cancelTask(taskid.get());
|
||||
}
|
||||
|
||||
Gui finalGui = gui;
|
||||
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;
|
||||
}
|
||||
if (event.isCancelled()) return;
|
||||
// Internal
|
||||
|
||||
Bukkit.getScheduler().runTask(HMCCosmeticsPlugin.getInstance(), () -> {
|
||||
finalGui.open(player);
|
||||
gui.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()) {
|
||||
|
||||
List<String> slotString = null;
|
||||
try {
|
||||
slotString = config.node("slots").getList(String.class);
|
||||
} catch (SerializationException e) {
|
||||
continue;
|
||||
}
|
||||
if (slotString == null) {
|
||||
MessagesUtil.sendDebugMessages("Unable to get valid slot for " + config.key().toString());
|
||||
continue;
|
||||
}
|
||||
|
||||
List<Integer> slots = getSlots(slotString);
|
||||
|
||||
if (slots == null) {
|
||||
MessagesUtil.sendDebugMessages("Slot is null for " + config.key().toString());
|
||||
continue;
|
||||
}
|
||||
|
||||
ItemStack item;
|
||||
try {
|
||||
item = ItemSerializer.INSTANCE.deserialize(ItemStack.class, config.node("item"));
|
||||
//item = config.node("item").get(ItemStack.class);
|
||||
} catch (SerializationException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
if (item == null) {
|
||||
MessagesUtil.sendDebugMessages("something went wrong! " + item);
|
||||
continue;
|
||||
}
|
||||
|
||||
Type type = null;
|
||||
|
||||
if (!config.node("type").virtual()) {
|
||||
String typeId = config.node("type").getString();
|
||||
if (Types.isType(typeId)) type = Types.getType(typeId);
|
||||
}
|
||||
|
||||
for (int slot : slots) {
|
||||
ItemStack originalItem = updateItem(user, item, type, config, slot).clone();
|
||||
GuiItem guiItem = ItemBuilder.from(originalItem).asGuiItem();
|
||||
|
||||
Type finalType = type;
|
||||
private void updateMenu(CosmeticUser user, Gui gui) {
|
||||
for (MenuItem item : items) {
|
||||
Type type = item.getType();
|
||||
for (int slot : item.getSlots()) {
|
||||
ItemStack modifiedItem = getMenuItem(user, type, item.getItemConfig(), item.getItem().clone(), slot);
|
||||
GuiItem guiItem = ItemBuilder.from(modifiedItem).asGuiItem();
|
||||
guiItem.setAction(event -> {
|
||||
MessagesUtil.sendDebugMessages("Selected slot " + slot);
|
||||
final ClickType clickType = event.getClick();
|
||||
if (finalType != null) finalType.run(user, config, clickType);
|
||||
|
||||
for (int guiSlot : slots) {
|
||||
gui.updateItem(guiSlot, updateItem(user, originalItem.clone(), finalType, config, guiSlot));
|
||||
}
|
||||
MessagesUtil.sendDebugMessages("Updated slot " + slot);
|
||||
if (type != null) type.run(user, item.getItemConfig(), clickType);
|
||||
updateMenu(user, gui);
|
||||
});
|
||||
|
||||
MessagesUtil.sendDebugMessages("Added " + slots + " as " + guiItem + " in the menu");
|
||||
gui.setItem(slot, guiItem);
|
||||
MessagesUtil.sendDebugMessages("Added " + slot + " as " + guiItem + " in the menu");
|
||||
gui.updateItem(slot, guiItem);
|
||||
}
|
||||
}
|
||||
return gui;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -194,11 +214,9 @@ public class Menu {
|
||||
|
||||
@Contract("_, _, _, _ -> param2")
|
||||
@NotNull
|
||||
private ItemStack updateItem(CosmeticUser user, @NotNull ItemStack itemStack, Type type, ConfigurationNode config, int slot) {
|
||||
if (itemStack.hasItemMeta()) {
|
||||
itemStack = type.setItem(user, config, itemStack, slot);
|
||||
}
|
||||
return itemStack;
|
||||
private ItemStack getMenuItem(CosmeticUser user, Type type, ConfigurationNode config, ItemStack itemStack, int slot) {
|
||||
if (!itemStack.hasItemMeta()) return itemStack;
|
||||
return type.setItem(user, config, itemStack, slot);
|
||||
}
|
||||
|
||||
public String getPermissionNode() {
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
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 class MenuItem {
|
||||
|
||||
private List<Integer> slots;
|
||||
private ItemStack item;
|
||||
private Type type;
|
||||
private ConfigurationNode itemConfig;
|
||||
|
||||
public MenuItem(List<Integer> slots, ItemStack item, Type type, ConfigurationNode itemConfig) {
|
||||
this.slots = slots;
|
||||
this.item = item;
|
||||
this.type = type;
|
||||
this.itemConfig = itemConfig;
|
||||
}
|
||||
|
||||
public List<Integer> getSlots() {
|
||||
return slots;
|
||||
}
|
||||
|
||||
public ItemStack getItem() {
|
||||
return item;
|
||||
}
|
||||
|
||||
public Type getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public ConfigurationNode getItemConfig() {
|
||||
return itemConfig;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -11,11 +11,14 @@ import org.spongepowered.configurate.ConfigurateException;
|
||||
import org.spongepowered.configurate.yaml.YamlConfigurationLoader;
|
||||
|
||||
import java.io.File;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
public class Menus {
|
||||
|
||||
@@ -56,33 +59,39 @@ public class Menus {
|
||||
return names;
|
||||
}
|
||||
|
||||
public static Collection<Menu> values() {
|
||||
return MENUS.values();
|
||||
}
|
||||
|
||||
public static void setup() {
|
||||
MENUS.clear();
|
||||
|
||||
File cosmeticFolder = new File(HMCCosmeticsPlugin.getInstance().getDataFolder() + "/menus");
|
||||
if (!cosmeticFolder.exists()) cosmeticFolder.mkdir();
|
||||
|
||||
File[] directoryListing = cosmeticFolder.listFiles();
|
||||
if (directoryListing == null) return;
|
||||
|
||||
for (File child : directoryListing) {
|
||||
if (child.toString().contains(".yml") || child.toString().contains(".yaml")) {
|
||||
MessagesUtil.sendDebugMessages("Scanning " + child);
|
||||
// Loads file
|
||||
YamlConfigurationLoader loader = YamlConfigurationLoader.builder().path(child.toPath()).build();
|
||||
CommentedConfigurationNode root;
|
||||
try {
|
||||
root = loader.load();
|
||||
} catch (ConfigurateException e) {
|
||||
throw new RuntimeException(e);
|
||||
// Recursive file lookup
|
||||
try (Stream<Path> walkStream = Files.walk(cosmeticFolder.toPath())) {
|
||||
walkStream.filter(p -> p.toFile().isFile()).forEach(child -> {
|
||||
if (child.toString().endsWith("yml") || child.toString().endsWith("yaml")) {
|
||||
MessagesUtil.sendDebugMessages("Scanning " + child);
|
||||
// Loads file
|
||||
YamlConfigurationLoader loader = YamlConfigurationLoader.builder().path(child).build();
|
||||
CommentedConfigurationNode root;
|
||||
try {
|
||||
root = loader.load();
|
||||
} catch (ConfigurateException 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.isDebugEnabled()) e.printStackTrace();
|
||||
}
|
||||
}
|
||||
try {
|
||||
new Menu(FilenameUtils.removeExtension(child.getName()), root);
|
||||
} catch (Exception e) {
|
||||
MessagesUtil.sendDebugMessages("Unable to create menu in " + child, Level.WARNING);
|
||||
if (Settings.isDebugEnabled()) e.printStackTrace();
|
||||
}
|
||||
}
|
||||
});
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.hibiscusmc.hmccosmetics.gui.action.actions;
|
||||
|
||||
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
|
||||
import com.hibiscusmc.hmccosmetics.gui.Menu;
|
||||
import com.hibiscusmc.hmccosmetics.gui.Menus;
|
||||
import com.hibiscusmc.hmccosmetics.gui.action.Action;
|
||||
|
||||
@@ -8,7 +8,6 @@ import com.hibiscusmc.hmccosmetics.config.Settings;
|
||||
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
|
||||
import com.hibiscusmc.hmccosmetics.hooks.Hooks;
|
||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||
import com.hibiscusmc.hmccosmetics.util.misc.Placeholder;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Color;
|
||||
import org.bukkit.Material;
|
||||
@@ -33,7 +32,7 @@ public class DyeMenu {
|
||||
if (originalItem == null || !cosmetic.isDyable()) return;
|
||||
|
||||
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.setDefaultTopClickAction(event -> {
|
||||
if (event.getSlot() == Settings.getDyeMenuOutputSlot()) {
|
||||
|
||||
@@ -3,7 +3,6 @@ package com.hibiscusmc.hmccosmetics.gui.type;
|
||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.spongepowered.configurate.ConfigurationNode;
|
||||
|
||||
public abstract class Type {
|
||||
|
||||
@@ -11,9 +11,6 @@ import com.hibiscusmc.hmccosmetics.gui.type.Type;
|
||||
import com.hibiscusmc.hmccosmetics.hooks.Hooks;
|
||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||
import 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.entity.Player;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
@@ -25,10 +22,8 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.spongepowered.configurate.ConfigurationNode;
|
||||
import org.spongepowered.configurate.serialize.SerializationException;
|
||||
|
||||
import java.lang.invoke.TypeDescriptor;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class TypeCosmetic extends Type {
|
||||
|
||||
@@ -38,16 +33,22 @@ public class TypeCosmetic extends Type {
|
||||
|
||||
@Override
|
||||
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();
|
||||
Cosmetic cosmetic = Cosmetics.getCosmetic(cosmeticName);
|
||||
Player player = user.getPlayer();
|
||||
if (cosmetic == null) {
|
||||
MessagesUtil.sendDebugMessages("No Cosmetic Found");
|
||||
MessagesUtil.sendMessage(player, "invalid-cosmetic");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!user.canEquipCosmetic(cosmetic)) {
|
||||
MessagesUtil.sendDebugMessages("No Cosmetic Permission");
|
||||
MessagesUtil.sendMessage(player, "no-cosmetic-permission");
|
||||
return;
|
||||
}
|
||||
@@ -55,6 +56,8 @@ public class TypeCosmetic extends Type {
|
||||
List<String> actionStrings = new ArrayList<>();
|
||||
ConfigurationNode actionConfig = config.node("actions");
|
||||
|
||||
MessagesUtil.sendDebugMessages("Running Actions");
|
||||
|
||||
try {
|
||||
if (!actionConfig.node("any").virtual()) actionStrings.addAll(actionConfig.node("any").getList(String.class));
|
||||
|
||||
@@ -75,7 +78,7 @@ public class TypeCosmetic extends Type {
|
||||
if (!actionConfig.node("on-equip").virtual()) actionStrings.addAll(actionConfig.node("on-equip").getList(String.class));
|
||||
MessagesUtil.sendDebugMessages("on-equip");
|
||||
// TODO: Redo this
|
||||
if (cosmetic.isDyable()) {
|
||||
if (cosmetic.isDyable() && Hooks.isActiveHook("HMCColor")) {
|
||||
DyeMenu.openMenu(user, cosmetic);
|
||||
} else {
|
||||
user.addPlayerCosmetic(cosmetic);
|
||||
@@ -85,35 +88,34 @@ public class TypeCosmetic extends Type {
|
||||
Actions.runActions(user, actionStrings);
|
||||
|
||||
} catch (SerializationException e) {
|
||||
throw new RuntimeException(e);
|
||||
e.printStackTrace();
|
||||
}
|
||||
// Fixes issue with offhand cosmetics not appearing. Yes, I know this is dumb
|
||||
Runnable run = () -> user.updateCosmetic(cosmetic.getSlot());
|
||||
if (cosmetic instanceof CosmeticArmorType) {
|
||||
if (((CosmeticArmorType) cosmetic).getEquipSlot().equals(EquipmentSlot.OFF_HAND)) {
|
||||
Bukkit.getScheduler().runTaskLater(HMCCosmeticsPlugin.getInstance(), run, 1);
|
||||
return;
|
||||
}
|
||||
}
|
||||
run.run();
|
||||
MessagesUtil.sendDebugMessages("Finished Type Click Run");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack setItem(CosmeticUser user, @NotNull ConfigurationNode config, ItemStack itemStack, int slot) {
|
||||
ItemMeta itemMeta = itemStack.getItemMeta();
|
||||
itemStack.setItemMeta(processLoreLines(user, itemStack.getItemMeta()));
|
||||
|
||||
if (config.node("cosmetic").virtual()) {
|
||||
itemStack.setItemMeta(processLoreLines(user, itemMeta));
|
||||
return itemStack;
|
||||
};
|
||||
}
|
||||
String cosmeticName = config.node("cosmetic").getString();
|
||||
Cosmetic cosmetic = Cosmetics.getCosmetic(cosmeticName);
|
||||
if (cosmetic == null) {
|
||||
itemStack.setItemMeta(processLoreLines(user, itemMeta));
|
||||
return itemStack;
|
||||
}
|
||||
|
||||
if (user.hasCosmeticInSlot(cosmetic) && !config.node("equipped-item").virtual()) {
|
||||
MessagesUtil.sendDebugMessages("GUI Equipped Item");
|
||||
ConfigurationNode equippedItem = config.node("equipped-item");
|
||||
try {
|
||||
if (equippedItem.node("material").virtual()) equippedItem.node("material").set(config.node("item", "material").getString());
|
||||
@@ -125,10 +127,12 @@ public class TypeCosmetic extends Type {
|
||||
} catch (SerializationException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
itemStack.setItemMeta(processLoreLines(user, itemStack.getItemMeta()));
|
||||
return itemStack;
|
||||
}
|
||||
|
||||
if (!user.canEquipCosmetic(cosmetic) && !config.node("locked-item").virtual()) {
|
||||
MessagesUtil.sendDebugMessages("GUI Locked Item");
|
||||
ConfigurationNode lockedItem = config.node("locked-item");
|
||||
try {
|
||||
if (lockedItem.node("material").virtual()) lockedItem.node("material").set(config.node("item", "material").getString());
|
||||
@@ -137,10 +141,10 @@ public class TypeCosmetic extends Type {
|
||||
}
|
||||
try {
|
||||
itemStack = ItemSerializer.INSTANCE.deserialize(ItemStack.class, lockedItem);
|
||||
//item = config.node("item").get(ItemStack.class);
|
||||
} catch (SerializationException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
itemStack.setItemMeta(processLoreLines(user, itemStack.getItemMeta()));
|
||||
return itemStack;
|
||||
}
|
||||
return itemStack;
|
||||
@@ -152,14 +156,15 @@ public class TypeCosmetic extends Type {
|
||||
private ItemMeta processLoreLines(CosmeticUser user, @NotNull ItemMeta itemMeta) {
|
||||
List<String> processedLore = new ArrayList<>();
|
||||
|
||||
if (itemMeta.hasLore()) {
|
||||
for (String loreLine : itemMeta.getLore()) {
|
||||
if (Hooks.isActiveHook("PlaceholderAPI"))
|
||||
loreLine = PlaceholderAPI.setPlaceholders(user.getPlayer(), loreLine);
|
||||
processedLore.add(loreLine);
|
||||
}
|
||||
if (itemMeta.hasDisplayName()) {
|
||||
itemMeta.setDisplayName(Hooks.processPlaceholders(user.getPlayer(), itemMeta.getDisplayName()));
|
||||
}
|
||||
|
||||
if (itemMeta.hasLore()) {
|
||||
for (String loreLine : itemMeta.getLore()) {
|
||||
processedLore.add(Hooks.processPlaceholders(user.getPlayer(), loreLine));
|
||||
}
|
||||
}
|
||||
itemMeta.setLore(processedLore);
|
||||
return itemMeta;
|
||||
}
|
||||
|
||||
@@ -4,7 +4,6 @@ import com.hibiscusmc.hmccosmetics.gui.action.Actions;
|
||||
import com.hibiscusmc.hmccosmetics.gui.type.Type;
|
||||
import com.hibiscusmc.hmccosmetics.hooks.Hooks;
|
||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||
import me.clip.placeholderapi.PlaceholderAPI;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
@@ -58,11 +57,13 @@ public class TypeEmpty extends Type {
|
||||
List<String> processedLore = new ArrayList<>();
|
||||
ItemMeta itemMeta = itemStack.getItemMeta();
|
||||
|
||||
if (itemMeta.hasDisplayName()) {
|
||||
itemMeta.setDisplayName(Hooks.processPlaceholders(user.getPlayer(), itemMeta.getDisplayName()));
|
||||
}
|
||||
|
||||
if (itemMeta.hasLore()) {
|
||||
for (String loreLine : itemMeta.getLore()) {
|
||||
if (Hooks.isActiveHook("PlaceholderAPI"))
|
||||
loreLine = PlaceholderAPI.setPlaceholders(user.getPlayer(), loreLine);
|
||||
processedLore.add(loreLine);
|
||||
processedLore.add(Hooks.processPlaceholders(user.getPlayer(), loreLine));
|
||||
}
|
||||
}
|
||||
itemStack.setItemMeta(itemMeta);
|
||||
|
||||
@@ -4,8 +4,10 @@ import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
|
||||
import com.hibiscusmc.hmccosmetics.hooks.items.*;
|
||||
import com.hibiscusmc.hmccosmetics.hooks.misc.*;
|
||||
import com.hibiscusmc.hmccosmetics.hooks.placeholders.HookPlaceholderAPI;
|
||||
import me.clip.placeholderapi.PlaceholderAPI;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -17,7 +19,7 @@ public class Hooks {
|
||||
private static final HashMap<String, Hook> hooks = new HashMap<>();
|
||||
private static HookOraxen ORAXEN_HOOK = new HookOraxen();
|
||||
private static HookItemAdder ITEMADDER_HOOK = new HookItemAdder();
|
||||
private static HookLooty LOOTY_HOOK = new HookLooty();
|
||||
private static HookGeary GEARY_HOOK = new HookGeary();
|
||||
private static HookMythic MYTHIC_HOOK = new HookMythic();
|
||||
private static HookDenizen DENIZEN_HOOK = new HookDenizen();
|
||||
private static HookHMCCosmetics HMCCOSMETIC_HOOK = new HookHMCCosmetics();
|
||||
@@ -27,6 +29,7 @@ public class Hooks {
|
||||
private static HookHMCColor HMC_COLOR_HOOK = new HookHMCColor();
|
||||
private static HookCMI CMI_HOOK = new HookCMI();
|
||||
private static HookLibsDisguises LIBS_DISGUISES_HOOK = new HookLibsDisguises();
|
||||
private static HookModelEngine MODEL_ENGINE_HOOK = new HookModelEngine();
|
||||
|
||||
public static Hook getHook(@NotNull String id) {
|
||||
return hooks.get(id.toLowerCase());
|
||||
@@ -70,6 +73,12 @@ public class Hooks {
|
||||
return hook.getItem(split[1]);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static String processPlaceholders(OfflinePlayer player, String raw) {
|
||||
if (getHook("PlaceholderAPI").isActive()) return PlaceholderAPI.setPlaceholders(player, raw);
|
||||
return raw;
|
||||
}
|
||||
|
||||
public static boolean isActiveHook(String id) {
|
||||
Hook hook = getHook(id);
|
||||
if (hook == null) return false;
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
package com.hibiscusmc.hmccosmetics.hooks.items;
|
||||
|
||||
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
|
||||
import com.hibiscusmc.hmccosmetics.hooks.Hook;
|
||||
import com.mineinabyss.geary.addons.GearyPhase;
|
||||
import com.mineinabyss.geary.modules.GearyModuleKt;
|
||||
import com.mineinabyss.geary.papermc.tracking.items.ItemTrackingKt;
|
||||
import com.mineinabyss.geary.prefabs.PrefabKey;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* A hook that integrates the plugin {@link com.mineinabyss.geary.papermc.GearyPlugin Geary} to provide custom items
|
||||
*/
|
||||
@SuppressWarnings("SpellCheckingInspection")
|
||||
public class HookGeary extends Hook {
|
||||
private boolean enabled = false;
|
||||
|
||||
public HookGeary() {
|
||||
super("geary");
|
||||
setEnabledItemHook(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load() {
|
||||
GearyModuleKt.getGeary().getPipeline().intercept(GearyPhase.ENABLE, () -> {
|
||||
enabled = true;
|
||||
HMCCosmeticsPlugin.setup();
|
||||
return null;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a cosmetic {@link ItemStack} that is associated with the provided id from the plugin {@link com.mineinabyss.geary.papermc.GearyPlugin Geary}
|
||||
*/
|
||||
@Override
|
||||
public ItemStack getItem(@NotNull String itemId) {
|
||||
if (enabled) {
|
||||
PrefabKey prefabKey = PrefabKey.Companion.ofOrNull(itemId);
|
||||
if (prefabKey == null) return null;
|
||||
return ItemTrackingKt.getGearyItems().createItem(prefabKey, null);
|
||||
} else return new ItemStack(Material.AIR);
|
||||
}
|
||||
}
|
||||
@@ -1,28 +0,0 @@
|
||||
package com.hibiscusmc.hmccosmetics.hooks.items;
|
||||
|
||||
import com.hibiscusmc.hmccosmetics.hooks.Hook;
|
||||
import com.mineinabyss.geary.prefabs.PrefabKey;
|
||||
import com.mineinabyss.looty.LootyFactory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* A hook that integrates the plugin {@link com.mineinabyss.looty.LootyPlugin Looty} to provide custom items
|
||||
*/
|
||||
@SuppressWarnings("SpellCheckingInspection")
|
||||
public class HookLooty extends Hook {
|
||||
public HookLooty() {
|
||||
super("looty");
|
||||
setEnabledItemHook(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a cosmetic {@link ItemStack} that is associated with the provided id from the plugin {@link com.mineinabyss.looty.LootyPlugin Looty}
|
||||
*/
|
||||
@Override
|
||||
public ItemStack getItem(@NotNull String itemId) {
|
||||
PrefabKey prefabKey = PrefabKey.Companion.ofOrNull(itemId);
|
||||
if (prefabKey == null) return null;
|
||||
return LootyFactory.INSTANCE.createFromPrefab(prefabKey);
|
||||
}
|
||||
}
|
||||
@@ -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");
|
||||
}
|
||||
}
|
||||
@@ -69,9 +69,9 @@ public class HMCPlaceholderExpansion extends PlaceholderExpansion {
|
||||
Cosmetic cosmetic = Cosmetics.getCosmetic(placeholderArgs.get(1));
|
||||
if (cosmetic == null) return "INVALID_COSMETIC";
|
||||
Cosmetic currentCosmetic = user.getCosmetic(cosmetic.getSlot());
|
||||
if (currentCosmetic == null) return "false";
|
||||
if (currentCosmetic.getId() == cosmetic.getId()) return "true";
|
||||
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 TranslationUtil.getTranslation("using-cosmetic", String.valueOf(true));
|
||||
return TranslationUtil.getTranslation("using-cosmetic", String.valueOf(false));
|
||||
}
|
||||
case "current":
|
||||
if (placeholderArgs == null) {
|
||||
@@ -82,26 +82,29 @@ public class HMCPlaceholderExpansion extends PlaceholderExpansion {
|
||||
if (slot == null) return null;
|
||||
if (user.getCosmetic(slot) == null) return null;
|
||||
if (placeholderArgs.size() == 2) return user.getCosmetic(slot).getId();
|
||||
|
||||
String output;
|
||||
switch (placeholderArgs.get(2).toLowerCase()) {
|
||||
case "material" -> {
|
||||
return getMaterialName(user.getCosmetic(slot));
|
||||
output = getMaterialName(user.getCosmetic(slot));
|
||||
}
|
||||
case "custommodeldata" -> {
|
||||
return getModelData(user.getCosmetic(slot));
|
||||
output = getModelData(user.getCosmetic(slot));
|
||||
}
|
||||
case "name" -> {
|
||||
return getItemName(user.getCosmetic(slot));
|
||||
output = getItemName(user.getCosmetic(slot));
|
||||
}
|
||||
case "lore" -> {
|
||||
return getItemLore(user.getCosmetic(slot));
|
||||
output = getItemLore(user.getCosmetic(slot));
|
||||
}
|
||||
case "permission" -> {
|
||||
return user.getCosmetic(slot).getPermission();
|
||||
output = user.getCosmetic(slot).getPermission();
|
||||
}
|
||||
default -> {
|
||||
return user.getCosmetic(slot).getId();
|
||||
output = user.getCosmetic(slot).getId();
|
||||
}
|
||||
}
|
||||
return TranslationUtil.getTranslation("current-cosmetic", String.valueOf(output));
|
||||
}
|
||||
case "unlocked":
|
||||
if (placeholderArgs == null) {
|
||||
@@ -110,14 +113,18 @@ public class HMCPlaceholderExpansion extends PlaceholderExpansion {
|
||||
if (placeholderArgs.get(1) != null) {
|
||||
Cosmetic cosmetic = Cosmetics.getCosmetic(placeholderArgs.get(1));
|
||||
if (cosmetic == null) {
|
||||
Cosmetic secondAttemptCosmetic = Cosmetics.getCosmetic(placeholderArgs.get(1) + "_" + placeholderArgs.get(2));
|
||||
if (secondAttemptCosmetic == null) {
|
||||
return "INVALID_COSMETIC";
|
||||
if (placeholderArgs.size() >= 3) {
|
||||
Cosmetic secondAttemptCosmetic = Cosmetics.getCosmetic(placeholderArgs.get(1) + "_" + placeholderArgs.get(2));
|
||||
if (secondAttemptCosmetic == null) {
|
||||
return "INVALID_COSMETIC";
|
||||
} else {
|
||||
cosmetic = secondAttemptCosmetic;
|
||||
}
|
||||
} else {
|
||||
cosmetic = secondAttemptCosmetic;
|
||||
return "INVALID_COSMETIC";
|
||||
}
|
||||
}
|
||||
return TranslationUtil.getTranslation("unlockedCosmetic", String.valueOf(user.canEquipCosmetic(cosmetic)));
|
||||
return TranslationUtil.getTranslation("unlocked-cosmetic", String.valueOf(user.canEquipCosmetic(cosmetic)));
|
||||
}
|
||||
case "equipped":
|
||||
if (placeholderArgs == null) {
|
||||
@@ -127,11 +134,7 @@ public class HMCPlaceholderExpansion extends PlaceholderExpansion {
|
||||
String args1 = placeholderArgs.get(1);
|
||||
|
||||
if (EnumUtils.isValidEnum(CosmeticSlot.class, args1.toUpperCase())) {
|
||||
if (user.getCosmetic(CosmeticSlot.valueOf(args1.toUpperCase())) != null) {
|
||||
return "true";
|
||||
} else {
|
||||
return "false";
|
||||
}
|
||||
return TranslationUtil.getTranslation("equipped-cosmetic", String.valueOf(user.getCosmetic(CosmeticSlot.valueOf(args1.toUpperCase())) != null));
|
||||
}
|
||||
|
||||
MessagesUtil.sendDebugMessages(args1);
|
||||
@@ -150,14 +153,10 @@ public class HMCPlaceholderExpansion extends PlaceholderExpansion {
|
||||
}
|
||||
}
|
||||
if (user.getCosmetic(cosmetic.getSlot()) == null) return "false";
|
||||
if (cosmetic.getId() == user.getCosmetic(cosmetic.getSlot()).getId()) {
|
||||
return "true";
|
||||
} else {
|
||||
return "false";
|
||||
}
|
||||
return TranslationUtil.getTranslation("equipped-cosmetic", String.valueOf(cosmetic.getId() == user.getCosmetic(cosmetic.getSlot()).getId()));
|
||||
}
|
||||
case "wardrobe-enabled":
|
||||
return String.valueOf(user.isInWardrobe());
|
||||
return TranslationUtil.getTranslation("in-wardrobe", String.valueOf(user.isInWardrobe()));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||
import com.sk89q.worldguard.WorldGuard;
|
||||
import com.sk89q.worldguard.protection.flags.Flag;
|
||||
import com.sk89q.worldguard.protection.flags.StateFlag;
|
||||
import com.sk89q.worldguard.protection.flags.StringFlag;
|
||||
import com.sk89q.worldguard.protection.flags.registry.FlagConflictException;
|
||||
import com.sk89q.worldguard.protection.flags.registry.FlagRegistry;
|
||||
|
||||
@@ -16,21 +17,26 @@ public class WGHook {
|
||||
/**
|
||||
* @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
|
||||
*/
|
||||
public static StateFlag COSMETIC_WARDROBE_FLAG;
|
||||
private static StringFlag COSMETIC_WARDROBE_FLAG;
|
||||
|
||||
public WGHook() {
|
||||
FlagRegistry registry = WorldGuard.getInstance().getFlagRegistry();
|
||||
try {
|
||||
StateFlag cosmeticFlag = new StateFlag("cosmetic-enable", false);
|
||||
StateFlag wardrobeFlag = new StateFlag("cosmetic-wardrobe", false);
|
||||
StateFlag emoteFlag = new StateFlag("emotes-enable", false);
|
||||
StringFlag wardrobeFlag = new StringFlag("cosmetic-wardrobe");
|
||||
registry.register(cosmeticFlag);
|
||||
registry.register(emoteFlag);
|
||||
registry.register(wardrobeFlag);
|
||||
COSMETIC_ENABLE_FLAG = cosmeticFlag;
|
||||
EMOTES_ENABLE_FLAG = emoteFlag;
|
||||
COSMETIC_WARDROBE_FLAG = wardrobeFlag;
|
||||
} catch (FlagConflictException e) {
|
||||
Flag<?> existing = registry.get("cosmetic-enable");
|
||||
@@ -52,11 +58,19 @@ public class WGHook {
|
||||
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}
|
||||
* @return The cosmetic wardrobe {@link StateFlag}
|
||||
*/
|
||||
public static StateFlag getCosmeticWardrobeFlag() {
|
||||
public static StringFlag getCosmeticWardrobeFlag() {
|
||||
return COSMETIC_WARDROBE_FLAG;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
package com.hibiscusmc.hmccosmetics.hooks.worldguard;
|
||||
|
||||
import com.hibiscusmc.hmccosmetics.api.events.PlayerEmoteStartEvent;
|
||||
import com.hibiscusmc.hmccosmetics.config.Wardrobe;
|
||||
import com.hibiscusmc.hmccosmetics.config.WardrobeSettings;
|
||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUsers;
|
||||
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
||||
@@ -9,9 +12,11 @@ import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
||||
import com.sk89q.worldguard.protection.regions.RegionContainer;
|
||||
import com.sk89q.worldguard.protection.regions.RegionQuery;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
import org.bukkit.event.player.PlayerTeleportEvent;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
@@ -23,10 +28,7 @@ public class WGListener implements Listener {
|
||||
CosmeticUser user = CosmeticUsers.getUser(event.getPlayer());
|
||||
if (user == null) return;
|
||||
Location location = event.getPlayer().getLocation();
|
||||
com.sk89q.worldedit.util.Location loc = BukkitAdapter.adapt(location);
|
||||
RegionContainer region = WorldGuard.getInstance().getPlatform().getRegionContainer();
|
||||
RegionQuery query = region.createQuery();
|
||||
ApplicableRegionSet set = query.getApplicableRegions(loc);
|
||||
ApplicableRegionSet set = getRegions(location);
|
||||
if (user.getHidden()) {
|
||||
if (user.getHiddenReason() == CosmeticUser.HiddenReason.WORLDGUARD && set.getRegions().size() == 0) {
|
||||
user.showCosmetics();
|
||||
@@ -34,14 +36,70 @@ public class WGListener implements Listener {
|
||||
}
|
||||
for (ProtectedRegion protectedRegion : set.getRegions()) {
|
||||
if (protectedRegion.getFlags().containsKey(WGHook.getCosmeticEnableFlag())) {
|
||||
if (protectedRegion.getFlags().get(WGHook.getCosmeticEnableFlag()).toString().equalsIgnoreCase("ALLOW")) return;
|
||||
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 (!protectedRegion.getFlags().get(WGHook.getCosmeticWardrobeFlag()).toString().equalsIgnoreCase("ALLOW")) return;
|
||||
user.enterWardrobe();
|
||||
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
|
||||
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().size() == 0) {
|
||||
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
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ import com.comphenix.protocol.events.PacketEvent;
|
||||
import com.comphenix.protocol.wrappers.EnumWrappers;
|
||||
import com.comphenix.protocol.wrappers.Pair;
|
||||
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
|
||||
import com.hibiscusmc.hmccosmetics.api.events.PlayerCosmeticPostEquipEvent;
|
||||
import com.hibiscusmc.hmccosmetics.config.Settings;
|
||||
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
|
||||
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.util.InventoryUtils;
|
||||
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||
import com.hibiscusmc.hmccosmetics.util.packets.PacketManager;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
@@ -111,25 +114,21 @@ public class PlayerGameListener implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
if (user.hasCosmeticInSlot(CosmeticSlot.BACKPACK) && user.getUserBackpackManager() != null) {
|
||||
user.getUserBackpackManager().hideBackpack();
|
||||
|
||||
user.getUserBackpackManager().getArmorStand().teleport(event.getTo());
|
||||
|
||||
Bukkit.getScheduler().runTaskLater(HMCCosmeticsPlugin.getInstance(), () -> {
|
||||
user.updateCosmetic();
|
||||
}, 2);
|
||||
if (user.isInWardrobe()) {
|
||||
user.leaveWardrobe();
|
||||
}
|
||||
|
||||
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 (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()) {
|
||||
user.getUserEmoteManager().stopEmote(UserEmoteManager.StopEmoteReason.TELEPORT);
|
||||
}
|
||||
@@ -349,6 +348,16 @@ public class PlayerGameListener implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerCosemticEquip(PlayerCosmeticPostEquipEvent event) {
|
||||
CosmeticUser user = event.getUser();
|
||||
if (user.isInWardrobe() && event.getCosmetic().getSlot().equals(CosmeticSlot.BALLOON)) {
|
||||
Location NPCLocation = user.getWardrobeManager().getNpcLocation();
|
||||
PacketManager.sendTeleportPacket(user.getBalloonManager().getPufferfishBalloonId(), NPCLocation.add(Settings.getBalloonOffset()), false, List.of(event.getUser().getPlayer()));
|
||||
user.getBalloonManager().getModelEntity().teleport(NPCLocation.add(Settings.getBalloonOffset()));
|
||||
}
|
||||
}
|
||||
|
||||
private void registerInventoryClickListener() {
|
||||
ProtocolLibrary.getProtocolManager().addPacketListener(new PacketAdapter(HMCCosmeticsPlugin.getInstance(), ListenerPriority.NORMAL, PacketType.Play.Client.WINDOW_CLICK) {
|
||||
@Override
|
||||
|
||||
@@ -3,8 +3,8 @@ package com.hibiscusmc.hmccosmetics.nms;
|
||||
import com.hibiscusmc.hmccosmetics.cosmetic.CosmeticSlot;
|
||||
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticBackpackType;
|
||||
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticBalloonType;
|
||||
import com.hibiscusmc.hmccosmetics.user.manager.UserBalloonManager;
|
||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||
import com.hibiscusmc.hmccosmetics.user.manager.UserBalloonManager;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.ArmorStand;
|
||||
import org.bukkit.entity.Entity;
|
||||
@@ -25,7 +25,7 @@ public interface NMSHandler {
|
||||
|
||||
Entity spawnBackpack(CosmeticUser user, CosmeticBackpackType cosmeticBackpackType);
|
||||
|
||||
Entity spawnHMCParticleCloud(Location location);
|
||||
Entity spawnDisplayEntity(Location location, String text);
|
||||
|
||||
UserBalloonManager spawnBalloon(CosmeticUser user, CosmeticBalloonType cosmeticBalloonType);
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ import java.util.logging.Level;
|
||||
|
||||
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"};
|
||||
private static final String[] SUPPORTED_VERSION = new String[]{"v1_18_R2", "v1_19_R1", "v1_19_R2", "v1_19_R3", "v1_20_R1"};
|
||||
private static NMSHandler handler;
|
||||
private static String version;
|
||||
|
||||
|
||||
@@ -3,34 +3,43 @@ package com.hibiscusmc.hmccosmetics.user;
|
||||
import com.google.common.collect.ImmutableCollection;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
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.Wardrobe;
|
||||
import com.hibiscusmc.hmccosmetics.config.WardrobeSettings;
|
||||
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
|
||||
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.UserBalloonManager;
|
||||
import com.hibiscusmc.hmccosmetics.nms.NMSHandlers;
|
||||
import com.hibiscusmc.hmccosmetics.user.manager.UserEmoteManager;
|
||||
import com.hibiscusmc.hmccosmetics.user.manager.UserWardrobeManager;
|
||||
import com.hibiscusmc.hmccosmetics.util.InventoryUtils;
|
||||
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||
import com.hibiscusmc.hmccosmetics.util.PlayerUtils;
|
||||
import com.hibiscusmc.hmccosmetics.util.packets.PacketManager;
|
||||
import org.bukkit.*;
|
||||
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.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.*;
|
||||
import org.bukkit.persistence.PersistentDataType;
|
||||
import org.bukkit.scheduler.BukkitTask;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class CosmeticUser {
|
||||
|
||||
private UUID uniqueId;
|
||||
private final UUID uniqueId;
|
||||
private int taskId;
|
||||
private HashMap<CosmeticSlot, Cosmetic> playerCosmetics = new HashMap<>();
|
||||
private UserWardrobeManager userWardrobeManager;
|
||||
@@ -54,6 +63,7 @@ public class CosmeticUser {
|
||||
Runnable run = () -> {
|
||||
MessagesUtil.sendDebugMessages("Tick[uuid=" + uniqueId + "]", Level.INFO);
|
||||
updateCosmetic();
|
||||
if (getHidden() && !getUserEmoteManager().isPlayingEmote()) MessagesUtil.sendActionBar(getPlayer(), "hidden-cosmetics");
|
||||
};
|
||||
|
||||
int tickPeriod = Settings.getTickPeriod();
|
||||
@@ -115,6 +125,9 @@ public class CosmeticUser {
|
||||
CosmeticBalloonType balloonType = (CosmeticBalloonType) cosmetic;
|
||||
spawnBalloon(balloonType);
|
||||
}
|
||||
// API
|
||||
PlayerCosmeticPostEquipEvent postEquipEvent = new PlayerCosmeticPostEquipEvent(this, cosmetic);
|
||||
Bukkit.getPluginManager().callEvent(postEquipEvent);
|
||||
}
|
||||
|
||||
public void removeCosmetics() {
|
||||
@@ -140,7 +153,7 @@ public class CosmeticUser {
|
||||
despawnBalloon();
|
||||
}
|
||||
if (slot == CosmeticSlot.EMOTE) {
|
||||
|
||||
if (getUserEmoteManager().isPlayingEmote()) getUserEmoteManager().stopEmote(UserEmoteManager.StopEmoteReason.UNEQUIP);
|
||||
}
|
||||
colors.remove(slot);
|
||||
playerCosmetics.remove(slot);
|
||||
@@ -158,10 +171,7 @@ public class CosmeticUser {
|
||||
|
||||
public boolean hasCosmeticInSlot(Cosmetic cosmetic) {
|
||||
if (getCosmetic(cosmetic.getSlot()) == null) return false;
|
||||
if (cosmetic.getId() == getCosmetic(cosmetic.getSlot()).getId()) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return Objects.equals(cosmetic.getId(), getCosmetic(cosmetic.getSlot()).getId());
|
||||
}
|
||||
|
||||
public Set<CosmeticSlot> getSlotsWithCosmetics() {
|
||||
@@ -181,7 +191,7 @@ public class CosmeticUser {
|
||||
}
|
||||
|
||||
public void updateCosmetic() {
|
||||
for (Cosmetic cosmetic : playerCosmetics.values()) {
|
||||
for (Cosmetic cosmetic : getCosmetics()) {
|
||||
updateCosmetic(cosmetic.getSlot());
|
||||
}
|
||||
}
|
||||
@@ -208,6 +218,43 @@ public class CosmeticUser {
|
||||
}
|
||||
if (item.hasItemMeta()) {
|
||||
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())) {
|
||||
Color color = colors.get(cosmetic.getSlot());
|
||||
if (itemMeta instanceof LeatherArmorMeta leatherMeta) {
|
||||
@@ -219,7 +266,7 @@ public class CosmeticUser {
|
||||
}
|
||||
}
|
||||
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);
|
||||
}
|
||||
@@ -242,27 +289,28 @@ public class CosmeticUser {
|
||||
return userEmoteManager;
|
||||
}
|
||||
|
||||
public void enterWardrobe() {
|
||||
enterWardrobe(false);
|
||||
}
|
||||
|
||||
public void enterWardrobe(boolean ignoreDistance) {
|
||||
enterWardrobe(ignoreDistance, WardrobeSettings.getLeaveLocation(), WardrobeSettings.getViewerLocation(), WardrobeSettings.getWardrobeLocation());
|
||||
}
|
||||
|
||||
public void enterWardrobe(boolean ignoreDistance, Location exitLocation, Location viewingLocation, Location npcLocation) {
|
||||
if (!WardrobeSettings.inDistanceOfStatic(getPlayer().getLocation()) && !ignoreDistance) {
|
||||
public void enterWardrobe(boolean ignoreDistance, Wardrobe wardrobe) {
|
||||
if (wardrobe.hasPermission() && !getPlayer().hasPermission(wardrobe.getPermission())) {
|
||||
MessagesUtil.sendMessage(getPlayer(), "no-permission");
|
||||
return;
|
||||
}
|
||||
if (!wardrobe.canEnter(this) && !ignoreDistance) {
|
||||
MessagesUtil.sendMessage(getPlayer(), "not-near-wardrobe");
|
||||
return;
|
||||
}
|
||||
PlayerWardrobeEnterEvent event = new PlayerWardrobeEnterEvent(this);
|
||||
if (!wardrobe.getLocation().hasAllLocations()) {
|
||||
MessagesUtil.sendMessage(getPlayer(), "wardrobe-not-setup");
|
||||
return;
|
||||
}
|
||||
PlayerWardrobeEnterEvent event = new PlayerWardrobeEnterEvent(this, wardrobe);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
if (event.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
wardrobe = event.getWardrobe();
|
||||
|
||||
if (userWardrobeManager == null) {
|
||||
userWardrobeManager = new UserWardrobeManager(this, exitLocation, viewingLocation, npcLocation);
|
||||
userWardrobeManager = new UserWardrobeManager(this, wardrobe);
|
||||
userWardrobeManager.start();
|
||||
}
|
||||
}
|
||||
@@ -297,21 +345,12 @@ public class CosmeticUser {
|
||||
}
|
||||
|
||||
public boolean isInWardrobe() {
|
||||
if (userWardrobeManager == null) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
public void toggleWardrobe() {
|
||||
if (isInWardrobe()) {
|
||||
leaveWardrobe();
|
||||
} else {
|
||||
enterWardrobe();
|
||||
}
|
||||
return userWardrobeManager != null;
|
||||
}
|
||||
|
||||
public void spawnBackpack(CosmeticBackpackType cosmeticBackpackType) {
|
||||
if (this.userBackpackManager != null) return;
|
||||
this.userBackpackManager = new UserBackpackManager(this, cosmeticBackpackType.getBackpackType());
|
||||
this.userBackpackManager = new UserBackpackManager(this, cosmeticBackpackType.isFirstPersonCompadible());
|
||||
userBackpackManager.spawnBackpack(cosmeticBackpackType);
|
||||
}
|
||||
|
||||
@@ -322,24 +361,18 @@ public class CosmeticUser {
|
||||
}
|
||||
|
||||
public boolean isBackpackSpawned() {
|
||||
if (this.userBackpackManager == null) return false;
|
||||
return true;
|
||||
return this.userBackpackManager != null;
|
||||
}
|
||||
|
||||
public void spawnBalloon(CosmeticBalloonType cosmeticBalloonType) {
|
||||
Player player = Bukkit.getPlayer(getUniqueId());
|
||||
|
||||
if (this.userBalloonManager != null) return;
|
||||
|
||||
this.userBalloonManager = NMSHandlers.getHandler().spawnBalloon(this, cosmeticBalloonType);
|
||||
|
||||
List<Player> viewer = PlayerUtils.getNearbyPlayers(player);
|
||||
viewer.add(player);
|
||||
updateCosmetic(cosmeticBalloonType);
|
||||
}
|
||||
|
||||
public void despawnBalloon() {
|
||||
if (this.userBalloonManager == null) return;
|
||||
List<Player> sentTo = PlayerUtils.getNearbyPlayers(getPlayer().getLocation());
|
||||
List<Player> sentTo = PlayerUtils.getNearbyPlayers(getEntity().getLocation());
|
||||
|
||||
PacketManager.sendEntityDestroyPacket(userBalloonManager.getPufferfishBalloonId(), sentTo);
|
||||
|
||||
@@ -362,19 +395,33 @@ public class CosmeticUser {
|
||||
}
|
||||
|
||||
public void removeArmor(CosmeticSlot slot) {
|
||||
PacketManager.equipmentSlotUpdate(getPlayer().getEntityId(), this, slot, PlayerUtils.getNearbyPlayers(getPlayer()));
|
||||
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() {
|
||||
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) {
|
||||
return colors.get(slot);
|
||||
}
|
||||
|
||||
public List<CosmeticSlot> getDyeableSlots() {
|
||||
ArrayList<CosmeticSlot> dyableSlots = new ArrayList();
|
||||
ArrayList<CosmeticSlot> dyableSlots = new ArrayList<>();
|
||||
|
||||
for (Cosmetic cosmetic : getCosmetics()) {
|
||||
if (cosmetic.isDyable()) dyableSlots.add(cosmetic.getSlot());
|
||||
@@ -385,8 +432,10 @@ public class CosmeticUser {
|
||||
|
||||
public boolean canEquipCosmetic(Cosmetic cosmetic) {
|
||||
if (!cosmetic.requiresPermission()) return true;
|
||||
if (getPlayer().hasPermission(cosmetic.getPermission())) return true;
|
||||
return false;
|
||||
if (isInWardrobe()) {
|
||||
if (WardrobeSettings.isTryCosmeticsInWardrobe() && userWardrobeManager.getWardrobeStatus().equals(UserWardrobeManager.WardrobeStatus.RUNNING)) return true;
|
||||
}
|
||||
return getPlayer().hasPermission(cosmetic.getPermission());
|
||||
}
|
||||
|
||||
public void hidePlayer() {
|
||||
@@ -408,7 +457,7 @@ public class CosmeticUser {
|
||||
}
|
||||
|
||||
public void hideCosmetics(HiddenReason reason) {
|
||||
if (hideCosmetics == true) return;
|
||||
if (hideCosmetics) return;
|
||||
PlayerCosmeticHideEvent event = new PlayerCosmeticHideEvent(this, reason);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
if (event.isCancelled()) {
|
||||
@@ -429,7 +478,7 @@ public class CosmeticUser {
|
||||
}
|
||||
|
||||
public void showCosmetics() {
|
||||
if (hideCosmetics == false) return;
|
||||
if (!hideCosmetics) return;
|
||||
|
||||
PlayerCosmeticShowEvent event = new PlayerCosmeticShowEvent(this);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
|
||||
@@ -0,0 +1,68 @@
|
||||
package com.hibiscusmc.hmccosmetics.user.manager;
|
||||
|
||||
import com.hibiscusmc.hmccosmetics.util.PlayerUtils;
|
||||
import com.hibiscusmc.hmccosmetics.util.packets.PacketManager;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
public class UserBackpackCloudManager {
|
||||
|
||||
private ArrayList<Integer> ids;
|
||||
private UUID owner;
|
||||
private List<Player> viewers = new ArrayList<>();
|
||||
private Long lastUpdate;
|
||||
|
||||
public UserBackpackCloudManager(UUID owner) {
|
||||
this.ids = new ArrayList<>();
|
||||
this.owner = owner;
|
||||
this.lastUpdate = 0L;
|
||||
}
|
||||
|
||||
public ArrayList<Integer> getId() {
|
||||
return ids;
|
||||
}
|
||||
|
||||
public UUID getOwner() {
|
||||
return owner;
|
||||
}
|
||||
|
||||
public List<Player> refreshViewers(Location location) {
|
||||
if (System.currentTimeMillis() - lastUpdate <= 1000) return List.of(); //Prevents mass refreshes
|
||||
ArrayList<Player> newPlayers = new ArrayList<>();
|
||||
ArrayList<Player> removePlayers = new ArrayList<>();
|
||||
List<Player> players = PlayerUtils.getNearbyPlayers(location);
|
||||
|
||||
for (Player player : players) {
|
||||
//if (player.getUniqueId().toString().equalsIgnoreCase(owner.toString())) continue;
|
||||
if (!viewers.contains(player)) {
|
||||
viewers.add(player);
|
||||
newPlayers.add(player);
|
||||
continue;
|
||||
}
|
||||
// bad loopdy loops
|
||||
for (Player viewerPlayer : viewers) {
|
||||
if (!players.contains(viewerPlayer)) {
|
||||
removePlayers.add(viewerPlayer);
|
||||
PacketManager.sendEntityDestroyPacket(ids, List.of(viewerPlayer)); // prevents random leashes
|
||||
}
|
||||
}
|
||||
}
|
||||
viewers.removeAll(removePlayers);
|
||||
lastUpdate = System.currentTimeMillis();
|
||||
return newPlayers;
|
||||
}
|
||||
|
||||
public void hideEffects() {
|
||||
PacketManager.sendEntityDestroyPacket(ids, viewers);
|
||||
viewers.clear();
|
||||
}
|
||||
|
||||
public List<Player> getViewers() {
|
||||
return viewers;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,34 +1,38 @@
|
||||
package com.hibiscusmc.hmccosmetics.user.manager;
|
||||
|
||||
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
|
||||
import com.hibiscusmc.hmccosmetics.cosmetic.CosmeticSlot;
|
||||
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticBackpackType;
|
||||
import com.hibiscusmc.hmccosmetics.hooks.Hooks;
|
||||
import com.hibiscusmc.hmccosmetics.nms.NMSHandlers;
|
||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||
import com.hibiscusmc.hmccosmetics.util.packets.PacketManager;
|
||||
import com.ticxo.modelengine.api.ModelEngineAPI;
|
||||
import com.ticxo.modelengine.api.model.ActiveModel;
|
||||
import com.ticxo.modelengine.api.model.ModeledEntity;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.AreaEffectCloud;
|
||||
import org.bukkit.entity.ArmorStand;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.UUID;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class UserBackpackManager {
|
||||
|
||||
private boolean hideBackpack;
|
||||
private ArmorStand invisibleArmorStand;
|
||||
private AreaEffectCloud particleCloud;
|
||||
private ArrayList<Integer> particleCloud = new ArrayList<>();
|
||||
private final CosmeticUser user;
|
||||
private BackpackType backpackType;
|
||||
private boolean firstPerson;
|
||||
private UserBackpackCloudManager cloudManager;
|
||||
|
||||
public UserBackpackManager(CosmeticUser user, BackpackType backpackType) {
|
||||
public UserBackpackManager(CosmeticUser user, boolean firstPersonView) {
|
||||
this.user = user;
|
||||
hideBackpack = false;
|
||||
this.backpackType = backpackType;
|
||||
this.hideBackpack = false;
|
||||
this.firstPerson = firstPersonView;
|
||||
this.cloudManager = new UserBackpackCloudManager(user.getUniqueId());
|
||||
}
|
||||
|
||||
public int getFirstArmorStandId() {
|
||||
@@ -39,24 +43,35 @@ public class UserBackpackManager {
|
||||
return invisibleArmorStand;
|
||||
}
|
||||
|
||||
public boolean IsValidBackpackEntity() {
|
||||
if (invisibleArmorStand == null) {
|
||||
MessagesUtil.sendDebugMessages("InvisibleArmorStand is Null!");
|
||||
return false;
|
||||
}
|
||||
return getArmorStand().isValid();
|
||||
}
|
||||
|
||||
public void spawnBackpack(CosmeticBackpackType cosmeticBackpackType) {
|
||||
MessagesUtil.sendDebugMessages("spawnBackpack Bukkit - Start");
|
||||
|
||||
if (getBackpackType().equals(BackpackType.NORMAL)) {
|
||||
spawnNormalBackpack(cosmeticBackpackType);
|
||||
}
|
||||
if (getBackpackType().equals(BackpackType.FIRST_PERSON)) {
|
||||
spawnFirstPersonBackpack(cosmeticBackpackType);
|
||||
}
|
||||
spawn(cosmeticBackpackType);
|
||||
}
|
||||
|
||||
private void spawnNormalBackpack(CosmeticBackpackType cosmeticBackpackType) {
|
||||
|
||||
private void spawn(CosmeticBackpackType cosmeticBackpackType) {
|
||||
if (this.invisibleArmorStand != null) return;
|
||||
|
||||
this.invisibleArmorStand = (ArmorStand) NMSHandlers.getHandler().spawnBackpack(user, cosmeticBackpackType);
|
||||
|
||||
if (cosmeticBackpackType.getModelName() != null && HMCCosmeticsPlugin.hasModelEngine()) {
|
||||
if (cosmeticBackpackType.isFirstPersonCompadible()) {
|
||||
for (int i = particleCloud.size(); i < 5; i++) {
|
||||
int entityId = NMSHandlers.getHandler().getNextEntityId();
|
||||
PacketManager.sendEntitySpawnPacket(user.getPlayer().getLocation(), entityId, EntityType.AREA_EFFECT_CLOUD, UUID.randomUUID());
|
||||
PacketManager.sendCloudEffect(entityId, PacketManager.getViewers(user.getPlayer().getLocation()));
|
||||
this.particleCloud.add(entityId);
|
||||
}
|
||||
}
|
||||
|
||||
// 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) {
|
||||
MessagesUtil.sendDebugMessages("Invalid Model Engine Blueprint " + cosmeticBackpackType.getModelName(), Level.SEVERE);
|
||||
return;
|
||||
@@ -67,26 +82,7 @@ public class UserBackpackManager {
|
||||
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()));
|
||||
model.setCanHurt(false);
|
||||
modeledEntity.addModel(model, false);
|
||||
}
|
||||
cosmeticBackpackType.update(user);
|
||||
|
||||
MessagesUtil.sendDebugMessages("spawnBackpack Bukkit - Finish");
|
||||
}
|
||||
@@ -98,7 +94,9 @@ public class UserBackpackManager {
|
||||
this.invisibleArmorStand = null;
|
||||
}
|
||||
if (particleCloud != null) {
|
||||
particleCloud.remove();
|
||||
for (int i = 0; i < particleCloud.size(); i++) {
|
||||
PacketManager.sendEntityDestroyPacket(particleCloud.get(i), getCloudManager().getViewers());
|
||||
}
|
||||
this.particleCloud = null;
|
||||
}
|
||||
}
|
||||
@@ -121,16 +119,8 @@ public class UserBackpackManager {
|
||||
hideBackpack = shown;
|
||||
}
|
||||
|
||||
public BackpackType getBackpackType() {
|
||||
return backpackType;
|
||||
}
|
||||
|
||||
public int getAreaEffectEntityId() {
|
||||
return particleCloud.getEntityId();
|
||||
}
|
||||
|
||||
public void teleportEffectEntity(Location location) {
|
||||
particleCloud.teleport(location);
|
||||
public ArrayList<Integer> getAreaEffectEntityId() {
|
||||
return particleCloud;
|
||||
}
|
||||
|
||||
public void setItem(ItemStack item) {
|
||||
@@ -142,8 +132,7 @@ public class UserBackpackManager {
|
||||
getArmorStand().getEquipment().setHelmet(item);
|
||||
}
|
||||
|
||||
public enum BackpackType {
|
||||
NORMAL,
|
||||
FIRST_PERSON // First person not yet implemented
|
||||
public UserBackpackCloudManager getCloudManager() {
|
||||
return cloudManager;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,10 +3,10 @@ package com.hibiscusmc.hmccosmetics.user.manager;
|
||||
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
|
||||
import com.hibiscusmc.hmccosmetics.config.Settings;
|
||||
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticBalloonType;
|
||||
import com.hibiscusmc.hmccosmetics.hooks.Hooks;
|
||||
import com.hibiscusmc.hmccosmetics.nms.NMSHandlers;
|
||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||
import com.hibiscusmc.hmccosmetics.util.PlayerUtils;
|
||||
import com.hibiscusmc.hmccosmetics.util.packets.PacketManager;
|
||||
import com.ticxo.modelengine.api.ModelEngineAPI;
|
||||
import com.ticxo.modelengine.api.model.ActiveModel;
|
||||
@@ -27,19 +27,17 @@ public class UserBalloonManager {
|
||||
|
||||
private BalloonType balloonType;
|
||||
private CosmeticBalloonType cosmeticBalloonType;
|
||||
private final int balloonID;
|
||||
private final UUID uniqueID;
|
||||
private UserBalloonPufferfish pufferfish;
|
||||
private final ArmorStand modelEntity;
|
||||
|
||||
public UserBalloonManager(@NotNull Location location) {
|
||||
this.uniqueID = UUID.randomUUID();
|
||||
this.balloonID = NMSHandlers.getHandler().getNextEntityId();
|
||||
this.pufferfish = new UserBalloonPufferfish(NMSHandlers.getHandler().getNextEntityId(), UUID.randomUUID());
|
||||
this.modelEntity = NMSHandlers.getHandler().getMEGEntity(location.add(Settings.getBalloonOffset()));
|
||||
}
|
||||
|
||||
public void spawnModel(@NotNull CosmeticBalloonType cosmeticBalloonType, Color color) {
|
||||
// redo this
|
||||
if (cosmeticBalloonType.getModelName() != null && HMCCosmeticsPlugin.hasModelEngine()) {
|
||||
if (cosmeticBalloonType.getModelName() != null && Hooks.isActiveHook("ModelEngine")) {
|
||||
balloonType = BalloonType.MODELENGINE;
|
||||
} else {
|
||||
if (cosmeticBalloonType.getItem() != null) {
|
||||
@@ -136,10 +134,10 @@ public class UserBalloonManager {
|
||||
|
||||
|
||||
public int getPufferfishBalloonId() {
|
||||
return balloonID;
|
||||
return pufferfish.getId();
|
||||
}
|
||||
public UUID getPufferfishBalloonUniqueId() {
|
||||
return uniqueID;
|
||||
return pufferfish.getUuid();
|
||||
}
|
||||
|
||||
public UUID getModelUnqiueId() {
|
||||
@@ -172,7 +170,13 @@ public class UserBalloonManager {
|
||||
|
||||
public void sendLeashPacket(int entityId) {
|
||||
if (cosmeticBalloonType == null) return;
|
||||
if (cosmeticBalloonType.isShowLead()) PacketManager.sendLeashPacket(getPufferfishBalloonId(), entityId, getLocation());
|
||||
if (cosmeticBalloonType.isShowLead()) {
|
||||
PacketManager.sendLeashPacket(getPufferfishBalloonId(), entityId, getLocation());
|
||||
}
|
||||
}
|
||||
|
||||
public UserBalloonPufferfish getPufferfish() {
|
||||
return pufferfish;
|
||||
}
|
||||
|
||||
public enum BalloonType {
|
||||
|
||||
@@ -0,0 +1,62 @@
|
||||
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 {
|
||||
|
||||
private int id;
|
||||
private UUID uuid;
|
||||
private List<Player> viewers = new ArrayList<>();
|
||||
private Long lastUpdate;
|
||||
|
||||
public UserBalloonPufferfish(int id, UUID uuid) {
|
||||
this.id = id;
|
||||
this.uuid = uuid;
|
||||
this.lastUpdate = 0L;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public UUID getUuid() {
|
||||
return uuid;
|
||||
}
|
||||
|
||||
public List<Player> refreshViewers(Location location) {
|
||||
if (System.currentTimeMillis() - lastUpdate <= 1000) return List.of(); //Prevents mass refreshes
|
||||
ArrayList<Player> newPlayers = new ArrayList<>();
|
||||
ArrayList<Player> removePlayers = new ArrayList<>();
|
||||
List<Player> players = PlayerUtils.getNearbyPlayers(location);
|
||||
|
||||
for (Player player : players) {
|
||||
if (!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(id, List.of(viewerPlayer)); // prevents random leashes
|
||||
}
|
||||
}
|
||||
}
|
||||
viewers.removeAll(removePlayers);
|
||||
lastUpdate = System.currentTimeMillis();
|
||||
return newPlayers;
|
||||
}
|
||||
|
||||
public void hidePufferfish() {
|
||||
PacketManager.sendEntityDestroyPacket(id, viewers);
|
||||
viewers.clear();
|
||||
}
|
||||
}
|
||||
@@ -1,32 +1,41 @@
|
||||
package com.hibiscusmc.hmccosmetics.user.manager;
|
||||
|
||||
import com.hibiscusmc.hmccosmetics.api.PlayerEmoteStartEvent;
|
||||
import com.hibiscusmc.hmccosmetics.api.PlayerEmoteStopEvent;
|
||||
import com.hibiscusmc.hmccosmetics.api.events.PlayerEmoteStartEvent;
|
||||
import com.hibiscusmc.hmccosmetics.api.events.PlayerEmoteStopEvent;
|
||||
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticEmoteType;
|
||||
import com.hibiscusmc.hmccosmetics.emotes.EmoteManager;
|
||||
import com.hibiscusmc.hmccosmetics.nms.NMSHandlers;
|
||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class UserEmoteManager {
|
||||
|
||||
CosmeticUser user;
|
||||
private CosmeticUser user;
|
||||
private UserEmoteModel model;
|
||||
private Entity textEntity;
|
||||
|
||||
public UserEmoteManager(CosmeticUser user) {
|
||||
this.user = user;
|
||||
}
|
||||
|
||||
public void playEmote(@NotNull CosmeticEmoteType cosmeticEmoteType) {
|
||||
MessagesUtil.sendDebugMessages("playEmote " + cosmeticEmoteType.getAnimationId());
|
||||
playEmote(cosmeticEmoteType.getAnimationId());
|
||||
public void playEmote(String animationId) {
|
||||
MessagesUtil.sendDebugMessages("playEmote " + animationId);
|
||||
playEmote(EmoteManager.get(animationId), null);
|
||||
}
|
||||
|
||||
public void playEmote(String animationId) {
|
||||
public void playEmote(@NotNull CosmeticEmoteType cosmeticEmoteType) {
|
||||
MessagesUtil.sendDebugMessages("playEmote " + cosmeticEmoteType.getAnimationId());
|
||||
playEmote(EmoteManager.get(cosmeticEmoteType.getAnimationId()), cosmeticEmoteType.getText());
|
||||
}
|
||||
|
||||
public void playEmote(String emoteAnimation, String text) {
|
||||
if (isPlayingEmote()) return;
|
||||
if (user.isInWardrobe()) return;
|
||||
// API
|
||||
PlayerEmoteStartEvent event = new PlayerEmoteStartEvent(user, animationId);
|
||||
PlayerEmoteStartEvent event = new PlayerEmoteStartEvent(user, emoteAnimation);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
if (event.isCancelled()) {
|
||||
return;
|
||||
@@ -34,7 +43,14 @@ public class UserEmoteManager {
|
||||
// Internal
|
||||
try {
|
||||
model = new UserEmoteModel(user);
|
||||
model.playAnimation(animationId);
|
||||
// Play animation id
|
||||
if (emoteAnimation != null) {
|
||||
model.playAnimation(emoteAnimation);
|
||||
}
|
||||
// Show the text
|
||||
if (text != null && textEntity == null) {
|
||||
textEntity = NMSHandlers.getHandler().spawnDisplayEntity(user.getPlayer().getLocation().add(0, 3, 0), text);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
@@ -55,12 +71,24 @@ public class UserEmoteManager {
|
||||
}
|
||||
// Internal
|
||||
model.stopAnimation();
|
||||
if (textEntity != null) {
|
||||
textEntity.remove();
|
||||
textEntity = null;
|
||||
}
|
||||
}
|
||||
|
||||
public void despawnTextEntity() {
|
||||
if (textEntity != null) {
|
||||
textEntity.remove();
|
||||
textEntity = null;
|
||||
}
|
||||
}
|
||||
|
||||
public enum StopEmoteReason {
|
||||
SNEAK,
|
||||
DAMAGE,
|
||||
CONNECTION,
|
||||
TELEPORT
|
||||
TELEPORT,
|
||||
UNEQUIP
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,7 +11,6 @@ import com.ticxo.playeranimator.api.model.player.PlayerModel;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -36,9 +35,6 @@ public class UserEmoteModel extends PlayerModel {
|
||||
|
||||
@Override
|
||||
public void playAnimation(@NotNull String id) {
|
||||
if (id.contains(":")) id = id.split(":", 2)[1]; // A:B -> B -> B.B.B
|
||||
if (!id.contains(".")) id = id + "." + id + "." + id; // Make into a format that playerAnimator works with. Requires 3 splits.
|
||||
|
||||
super.playAnimation(id);
|
||||
|
||||
emotePlaying = id;
|
||||
@@ -47,9 +43,9 @@ public class UserEmoteModel extends PlayerModel {
|
||||
Player player = user.getPlayer();
|
||||
List<Player> viewer = Collections.singletonList(user.getPlayer());
|
||||
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);
|
||||
outsideViewers.remove(player);
|
||||
|
||||
Location newLocation = player.getLocation().clone();
|
||||
newLocation.setPitch(0);
|
||||
@@ -67,6 +63,11 @@ public class UserEmoteModel extends PlayerModel {
|
||||
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.hideCosmetics(CosmeticUser.HiddenReason.EMOTE);
|
||||
@@ -105,6 +106,8 @@ public class UserEmoteModel extends PlayerModel {
|
||||
|
||||
List<Player> viewer = Collections.singletonList(player);
|
||||
List<Player> outsideViewers = PacketManager.getViewers(player.getLocation());
|
||||
// Send Equipment packet to all (Fixes Optifine Issue)
|
||||
PacketManager.equipmentSlotUpdate(player, false, outsideViewers);
|
||||
outsideViewers.remove(player);
|
||||
|
||||
int entityId = player.getEntityId();
|
||||
@@ -116,7 +119,7 @@ public class UserEmoteModel extends PlayerModel {
|
||||
}
|
||||
|
||||
if (user.getPlayer() != null) player.setInvisible(false);
|
||||
PacketManager.equipmentSlotUpdate(player, false, outsideViewers);
|
||||
user.getUserEmoteManager().despawnTextEntity();
|
||||
user.showPlayer();
|
||||
user.showCosmetics();
|
||||
});
|
||||
|
||||
@@ -2,9 +2,13 @@ package com.hibiscusmc.hmccosmetics.user.manager;
|
||||
|
||||
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
|
||||
import com.hibiscusmc.hmccosmetics.config.Settings;
|
||||
import com.hibiscusmc.hmccosmetics.config.Wardrobe;
|
||||
import com.hibiscusmc.hmccosmetics.config.WardrobeLocation;
|
||||
import com.hibiscusmc.hmccosmetics.config.WardrobeSettings;
|
||||
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
|
||||
import com.hibiscusmc.hmccosmetics.cosmetic.CosmeticSlot;
|
||||
import com.hibiscusmc.hmccosmetics.gui.Menu;
|
||||
import com.hibiscusmc.hmccosmetics.gui.Menus;
|
||||
import com.hibiscusmc.hmccosmetics.nms.NMSHandlers;
|
||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||
@@ -38,6 +42,8 @@ public class UserWardrobeManager {
|
||||
private String npcName;
|
||||
private GameMode originalGamemode;
|
||||
private final CosmeticUser user;
|
||||
private final Wardrobe wardrobe;
|
||||
private final WardrobeLocation wardrobeLocation;
|
||||
private final Location viewingLocation;
|
||||
private final Location npcLocation;
|
||||
private Location exitLocation;
|
||||
@@ -45,15 +51,18 @@ public class UserWardrobeManager {
|
||||
private boolean active;
|
||||
private WardrobeStatus wardrobeStatus;
|
||||
|
||||
public UserWardrobeManager(CosmeticUser user, Location exitLocation, Location viewingLocation, Location npcLocation) {
|
||||
public UserWardrobeManager(CosmeticUser user, Wardrobe wardrobe) {
|
||||
NPC_ID = NMSHandlers.getHandler().getNextEntityId();
|
||||
ARMORSTAND_ID = NMSHandlers.getHandler().getNextEntityId();
|
||||
WARDROBE_UUID = UUID.randomUUID();
|
||||
this.user = user;
|
||||
|
||||
this.exitLocation = exitLocation;
|
||||
this.viewingLocation = viewingLocation;
|
||||
this.npcLocation = npcLocation;
|
||||
this.wardrobe = wardrobe;
|
||||
this.wardrobeLocation = wardrobe.getLocation();
|
||||
|
||||
this.exitLocation = wardrobeLocation.getLeaveLocation();
|
||||
this.viewingLocation = wardrobeLocation.getViewerLocation();
|
||||
this.npcLocation = wardrobeLocation.getNpcLocation();
|
||||
|
||||
wardrobeStatus = WardrobeStatus.SETUP;
|
||||
}
|
||||
@@ -94,6 +103,7 @@ public class UserWardrobeManager {
|
||||
// NPC 2
|
||||
Bukkit.getScheduler().runTaskLater(HMCCosmeticsPlugin.getInstance(), () -> {
|
||||
PacketManager.sendFakePlayerSpawnPacket(npcLocation, WARDROBE_UUID, NPC_ID, viewer);
|
||||
PacketManager.sendPlayerOverlayPacket(NPC_ID, viewer);
|
||||
MessagesUtil.sendDebugMessages("Spawned Fake Player on " + npcLocation);
|
||||
NMSHandlers.getHandler().hideNPCName(player, npcName);
|
||||
}, 4);
|
||||
@@ -105,6 +115,7 @@ public class UserWardrobeManager {
|
||||
// Misc
|
||||
if (user.hasCosmeticInSlot(CosmeticSlot.BACKPACK)) {
|
||||
user.getUserBackpackManager().getArmorStand().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);
|
||||
}
|
||||
|
||||
@@ -113,8 +124,9 @@ public class UserWardrobeManager {
|
||||
user.getBalloonManager().sendLeashPacket(NPC_ID);
|
||||
//PacketManager.sendLeashPacket(VIEWER.getBalloonEntity().getModelId(), NPC_ID, viewer);
|
||||
|
||||
PacketManager.sendTeleportPacket(user.getBalloonManager().getPufferfishBalloonId(), npcLocation.clone().add(Settings.getBalloonOffset()), false, viewer);
|
||||
user.getBalloonManager().getModelEntity().teleport(npcLocation.clone().add(Settings.getBalloonOffset()));
|
||||
Location balloonLocation = npcLocation.clone().add(Settings.getBalloonOffset());
|
||||
PacketManager.sendTeleportPacket(user.getBalloonManager().getPufferfishBalloonId(), balloonLocation , false, viewer);
|
||||
user.getBalloonManager().getModelEntity().teleport(balloonLocation);
|
||||
}
|
||||
|
||||
if (WardrobeSettings.getEnabledBossbar()) {
|
||||
@@ -127,6 +139,11 @@ public class UserWardrobeManager {
|
||||
target.showBossBar(bossBar);
|
||||
}
|
||||
|
||||
if (WardrobeSettings.isEnterOpenMenu()) {
|
||||
Menu menu = Menus.getDefaultMenu();
|
||||
if (menu != null) menu.openMenu(user);
|
||||
}
|
||||
|
||||
this.active = true;
|
||||
update();
|
||||
setWardrobeStatus(WardrobeStatus.RUNNING);
|
||||
@@ -161,6 +178,15 @@ public class UserWardrobeManager {
|
||||
Runnable run = () -> {
|
||||
this.active = false;
|
||||
|
||||
// For Wardrobe Temp Cosmetics
|
||||
for (Cosmetic cosmetic : user.getCosmetics()) {
|
||||
MessagesUtil.sendDebugMessages("Checking... " + cosmetic.getId());
|
||||
if (!user.canEquipCosmetic(cosmetic)) {
|
||||
MessagesUtil.sendDebugMessages("Unable to keep " + cosmetic.getId());
|
||||
user.removeCosmeticSlot(cosmetic.getSlot());
|
||||
}
|
||||
}
|
||||
|
||||
// NPC
|
||||
if (user.hasCosmeticInSlot(CosmeticSlot.BALLOON)) user.getBalloonManager().sendRemoveLeashPacket();
|
||||
PacketManager.sendEntityDestroyPacket(NPC_ID, viewer); // Success
|
||||
@@ -206,13 +232,6 @@ public class UserWardrobeManager {
|
||||
target.hideBossBar(bossBar);
|
||||
}
|
||||
|
||||
// For Wardrobe Temp Cosmetics
|
||||
for (Cosmetic cosmetic : user.getCosmetics()) {
|
||||
if (cosmetic.requiresPermission()) {
|
||||
if (!player.hasPermission(cosmetic.getPermission())) user.removeCosmeticSlot(cosmetic.getSlot());
|
||||
}
|
||||
}
|
||||
|
||||
user.updateCosmetic();
|
||||
};
|
||||
run.run();
|
||||
@@ -230,12 +249,12 @@ public class UserWardrobeManager {
|
||||
this.cancel();
|
||||
return;
|
||||
}
|
||||
MessagesUtil.sendDebugMessages("WardrobeUpdate[user= " + user.getUniqueId() + ",status=" + getWardrobeStatus() + "]");
|
||||
MessagesUtil.sendDebugMessages("WardrobeUpdate[user=" + user.getUniqueId() + ",status=" + getWardrobeStatus() + "]");
|
||||
List<Player> viewer = Collections.singletonList(player);
|
||||
List<Player> outsideViewers = PacketManager.getViewers(viewingLocation);
|
||||
outsideViewers.remove(player);
|
||||
|
||||
Location location = WardrobeSettings.getWardrobeLocation().clone();
|
||||
Location location = npcLocation;
|
||||
int yaw = data.get();
|
||||
location.setYaw(yaw);
|
||||
|
||||
@@ -259,8 +278,9 @@ public class UserWardrobeManager {
|
||||
}
|
||||
|
||||
if (user.hasCosmeticInSlot(CosmeticSlot.BALLOON)) {
|
||||
PacketManager.sendTeleportPacket(user.getBalloonManager().getPufferfishBalloonId(), WardrobeSettings.getWardrobeLocation().add(Settings.getBalloonOffset()), false, viewer);
|
||||
user.getBalloonManager().getModelEntity().teleport(WardrobeSettings.getWardrobeLocation().add(Settings.getBalloonOffset()));
|
||||
// The two lines below broke, solved by listening to PlayerCosmeticPostEquipEvent
|
||||
//PacketManager.sendTeleportPacket(user.getBalloonManager().getPufferfishBalloonId(), npcLocation.add(Settings.getBalloonOffset()), false, viewer);
|
||||
//user.getBalloonManager().getModelEntity().teleport(npcLocation.add(Settings.getBalloonOffset()));
|
||||
user.getBalloonManager().sendRemoveLeashPacket(outsideViewers);
|
||||
PacketManager.sendEntityDestroyPacket(user.getBalloonManager().getModelId(), outsideViewers);
|
||||
user.getBalloonManager().sendLeashPacket(NPC_ID);
|
||||
@@ -293,4 +313,8 @@ public class UserWardrobeManager {
|
||||
RUNNING,
|
||||
STOPPING,
|
||||
}
|
||||
|
||||
public Location getNpcLocation() {
|
||||
return npcLocation;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -156,4 +156,12 @@ public class InventoryUtils {
|
||||
public static NamespacedKey getOwnerKey() {
|
||||
return new NamespacedKey(HMCCosmeticsPlugin.getInstance(), "owner");
|
||||
}
|
||||
|
||||
public static NamespacedKey getSkullOwner() {
|
||||
return new NamespacedKey(HMCCosmeticsPlugin.getInstance(), "skullowner");
|
||||
}
|
||||
|
||||
public static NamespacedKey getSkullTexture() {
|
||||
return new NamespacedKey(HMCCosmeticsPlugin.getInstance(), "skulltexture");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,10 +4,8 @@ import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
|
||||
import com.hibiscusmc.hmccosmetics.config.Settings;
|
||||
import com.hibiscusmc.hmccosmetics.config.WardrobeSettings;
|
||||
import com.hibiscusmc.hmccosmetics.hooks.Hooks;
|
||||
import com.hibiscusmc.hmccosmetics.hooks.placeholders.HMCPlaceholderExpansion;
|
||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||
import com.hibiscusmc.hmccosmetics.util.misc.Adventure;
|
||||
import me.clip.placeholderapi.PlaceholderAPI;
|
||||
import net.kyori.adventure.audience.Audience;
|
||||
import net.kyori.adventure.platform.bukkit.BukkitAudiences;
|
||||
import net.kyori.adventure.text.Component;
|
||||
@@ -26,14 +24,16 @@ import java.util.logging.Level;
|
||||
public class MessagesUtil {
|
||||
|
||||
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) {
|
||||
MESSAGES.clear();
|
||||
|
||||
prefix = config.node("prefix").getString("");
|
||||
for (ConfigurationNode node : config.childrenMap().values()) {
|
||||
if (node.virtual()) 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) {
|
||||
Component finalMessage = processString(player, key);
|
||||
if (finalMessage == null) return;
|
||||
Audience target = BukkitAudiences.create(HMCCosmeticsPlugin.getInstance()).player(player);
|
||||
|
||||
target.sendMessage(finalMessage);
|
||||
@@ -58,6 +59,7 @@ public class MessagesUtil {
|
||||
|
||||
public static void sendMessage(Player player, String key, TagResolver placeholder) {
|
||||
Component finalMessage = processString(player, key, placeholder);
|
||||
if (finalMessage == null) return;
|
||||
Audience target = BukkitAudiences.create(HMCCosmeticsPlugin.getInstance()).player(player);
|
||||
|
||||
target.sendMessage(finalMessage);
|
||||
@@ -65,6 +67,7 @@ public class MessagesUtil {
|
||||
|
||||
public static void sendMessageNoKey(Player player, String message) {
|
||||
Component finalMessage = processStringNoKey(player, message);
|
||||
if (finalMessage == null) return;
|
||||
Audience target = BukkitAudiences.create(HMCCosmeticsPlugin.getInstance()).player(player);
|
||||
|
||||
target.sendMessage(finalMessage);
|
||||
@@ -72,6 +75,7 @@ public class MessagesUtil {
|
||||
|
||||
public static void sendActionBar(Player player, String key) {
|
||||
Component finalMessage = processString(player, key);
|
||||
if (finalMessage == null) return;
|
||||
Audience target = BukkitAudiences.create(HMCCosmeticsPlugin.getInstance()).player(player);
|
||||
|
||||
target.sendActionBar(finalMessage);
|
||||
@@ -84,7 +88,7 @@ public class MessagesUtil {
|
||||
public static void sendTitle(Player player, String message, int fadein, int stay, int fadeout) {
|
||||
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);
|
||||
|
||||
target.showTitle(title);
|
||||
@@ -96,10 +100,10 @@ public class MessagesUtil {
|
||||
|
||||
@Nullable
|
||||
public static Component processString(Player player, String key, TagResolver placeholders) {
|
||||
if (!messages.containsKey(key)) return null;
|
||||
if (messages.get(key) == null) return null;
|
||||
String message = messages.get(key);
|
||||
if (Hooks.isActiveHook("PlaceholderAPI") && player != null) message = PlaceholderAPI.setPlaceholders(player, message);
|
||||
if (!MESSAGES.containsKey(key)) return null;
|
||||
if (MESSAGES.get(key) == null) return null;
|
||||
String message = MESSAGES.get(key);
|
||||
if (player != null) message = Hooks.processPlaceholders(player, message);
|
||||
message = message.replaceAll("%prefix%", prefix);
|
||||
if (placeholders != null ) {
|
||||
return Adventure.MINI_MESSAGE.deserialize(message, placeholders);
|
||||
@@ -120,7 +124,7 @@ public class MessagesUtil {
|
||||
@NotNull
|
||||
public static Component processStringNoKey(Player player, String message, TagResolver placeholders) {
|
||||
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 ) {
|
||||
return Adventure.MINI_MESSAGE.deserialize(message, placeholders);
|
||||
}
|
||||
@@ -129,7 +133,7 @@ public class MessagesUtil {
|
||||
|
||||
public static String processStringNoKeyString(Player player, String message) {
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
@@ -46,16 +46,6 @@ public class ServerUtils {
|
||||
}
|
||||
|
||||
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
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.hibiscusmc.hmccosmetics.util;
|
||||
|
||||
public class TranslationPair {
|
||||
|
||||
private String key;
|
||||
private String value;
|
||||
|
||||
public TranslationPair(String key, String value) {
|
||||
this.key = key;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public String getKey() {
|
||||
return key;
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
@@ -1,39 +1,39 @@
|
||||
package com.hibiscusmc.hmccosmetics.util;
|
||||
|
||||
import com.hibiscusmc.hmccosmetics.util.misc.StringUtils;
|
||||
import org.spongepowered.configurate.ConfigurationNode;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
public class TranslationUtil {
|
||||
|
||||
private static HashMap<String, String> keys = new HashMap<>();
|
||||
// unlocked-cosmetic -> true -> True
|
||||
private static HashMap<String, List<TranslationPair>> keys = new HashMap<>();
|
||||
|
||||
public static void setup(ConfigurationNode config) {
|
||||
// TODO: Finish this
|
||||
/*
|
||||
for (ConfigurationNode node : config.childrenMap().values()) {
|
||||
HashMap<Pair> translableMessages = new HashMap<>();
|
||||
ArrayList<TranslationPair> pairs = new ArrayList<>();
|
||||
for (ConfigurationNode translatableMessage : node.childrenMap().values()) {
|
||||
translableMessages.put( new Pair<>(translatableMessage.key().toString(), translatableMessage.getString()))
|
||||
String key = translatableMessage.key().toString();
|
||||
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("Overall Key " + node.key().toString());
|
||||
MessagesUtil.sendDebugMessages("Key '" + pair.getKey() + "' Value '" + pair.getValue() + "'");
|
||||
}
|
||||
keys.put(node.key().toString().toLowerCase(), HashMap);
|
||||
keys.put(node.key().toString().toLowerCase(), pairs);
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
public static String getTranslation(String key, String message) {
|
||||
// TODO: Finish this
|
||||
return message;
|
||||
/*
|
||||
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();
|
||||
List<TranslationPair> pairs = keys.get(key);
|
||||
for (TranslationPair pair : pairs) {
|
||||
if (pair.getKey() == message) return StringUtils.parseStringToString(pair.getValue());
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -17,6 +17,7 @@ import com.hibiscusmc.hmccosmetics.util.packets.wrappers.WrapperPlayServerRelEnt
|
||||
import it.unimi.dsi.fastutil.ints.IntArrayList;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Particle;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -31,6 +32,15 @@ import java.util.UUID;
|
||||
|
||||
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(
|
||||
final @NotNull Location location,
|
||||
final int entityId,
|
||||
@@ -97,7 +107,7 @@ public class PacketManager extends BasePacket {
|
||||
CosmeticSlot cosmeticSlot,
|
||||
List<Player> sendTo
|
||||
) {
|
||||
equipmentSlotUpdate(user.getPlayer().getEntityId(), user, cosmeticSlot, sendTo);
|
||||
equipmentSlotUpdate(user.getEntity().getEntityId(), user, cosmeticSlot, sendTo);
|
||||
}
|
||||
|
||||
public static void equipmentSlotUpdate(
|
||||
@@ -136,7 +146,7 @@ public class PacketManager extends BasePacket {
|
||||
packet.getIntegers().write(0, entityId);
|
||||
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);
|
||||
packet.getWatchableCollectionModifier().write(0, wrapper.getWatchableObjects());
|
||||
} else {
|
||||
@@ -145,7 +155,29 @@ public class PacketManager extends BasePacket {
|
||||
packet.getDataValueCollectionModifier().write(0, wrappedDataValueList);
|
||||
}
|
||||
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(
|
||||
@@ -248,6 +280,18 @@ public class PacketManager extends BasePacket {
|
||||
for (final Player p : sendTo) sendPacket(p, packet);
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroys an entity from a player
|
||||
* @param sendTo The players the packet should be sent to
|
||||
*/
|
||||
public static void sendEntityDestroyPacket(final List<Integer> ids, @NotNull List<Player> sendTo) {
|
||||
PacketContainer packet = new PacketContainer(PacketType.Play.Server.ENTITY_DESTROY);
|
||||
IntArrayList entities = new IntArrayList(new int[]{});
|
||||
for (int id : ids) entities.add(id);
|
||||
packet.getModifier().write(0, entities);
|
||||
for (final Player p : sendTo) sendPacket(p, packet);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends a camera packet
|
||||
* @param entityId The Entity ID that camera will go towards
|
||||
@@ -306,8 +350,8 @@ public class PacketManager extends BasePacket {
|
||||
WrappedGameProfile wrappedGameProfile = new WrappedGameProfile(uuid, name);
|
||||
WrappedSignedProperty skinData = PlayerUtils.getSkin(skinnedPlayer);
|
||||
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
|
||||
if (NMSHandlers.getVersion().contains("v1_19_R1")) {
|
||||
// For sor some reason <1.19.2 handles it on the 0 field index, newer versions handles it on the 1
|
||||
if (NMSHandlers.getVersion().contains("v1_18_R2") || NMSHandlers.getVersion().contains("v1_19_R1")) {
|
||||
info.getHandle().getPlayerInfoDataLists().write(0, Collections.singletonList(new PlayerInfoData(
|
||||
wrappedGameProfile,
|
||||
0,
|
||||
@@ -350,9 +394,16 @@ public class PacketManager extends BasePacket {
|
||||
packet.getModifier().writeDefaults();
|
||||
packet.getIntegers().write(0, playerId);
|
||||
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);
|
||||
packet.getWatchableCollectionModifier().write(0, wrapper.getWatchableObjects());
|
||||
|
||||
if (NMSHandlers.getVersion().contains("v1_18_R2") || NMSHandlers.getVersion().contains("v1_19_R1")) {
|
||||
wrapper.setObject(new WrappedDataWatcher.WrappedDataWatcherObject(17, WrappedDataWatcher.Registry.get(Byte.class)), mask);
|
||||
packet.getWatchableCollectionModifier().write(0, wrapper.getWatchableObjects());
|
||||
} else {
|
||||
final List<WrappedDataValue> wrappedDataValueList = Lists.newArrayList();
|
||||
wrappedDataValueList.add(new WrappedDataValue(17, WrappedDataWatcher.Registry.get(Byte.class), mask));
|
||||
packet.getDataValueCollectionModifier().write(0, wrappedDataValueList);
|
||||
}
|
||||
|
||||
for (final Player p : sendTo) {
|
||||
sendPacket(p, packet);
|
||||
}
|
||||
@@ -369,7 +420,7 @@ public class PacketManager extends BasePacket {
|
||||
final UUID uuid,
|
||||
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();
|
||||
info.setAction(EnumWrappers.PlayerInfoAction.REMOVE_PLAYER);
|
||||
|
||||
@@ -468,15 +519,6 @@ 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
|
||||
public static List<Player> getViewers(Location location) {
|
||||
ArrayList<Player> viewers = new ArrayList();
|
||||
|
||||
@@ -6,7 +6,7 @@ config-version: 1
|
||||
default-menu: defaultmenu
|
||||
debug-mode: false
|
||||
database-settings:
|
||||
type: sqlite #MYSQL, SQLite, INTERNAL (not recommended!)
|
||||
type: sqlite #MYSQL, SQLite
|
||||
mysql:
|
||||
database: database
|
||||
password: cherryBomb
|
||||
@@ -22,9 +22,11 @@ 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
|
||||
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-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-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
|
||||
|
||||
@@ -70,6 +72,11 @@ wardrobe:
|
||||
equip-pumpkin: false
|
||||
# Rather than having a set exit location, this will send the player back to where they entered the wardrobe. Not recommended for WG regions
|
||||
return-last-location: false
|
||||
# If players in wardrobes should be able to equip any cosmetic, regardless of permission (Cosmetics they do not have access to will be removed when they leave the wardrobe)
|
||||
unchecked-wardrobe-cosmetics: false
|
||||
|
||||
menu-options:
|
||||
enter-open-menu: false # If the menu should open when a player enters a wardrobe
|
||||
|
||||
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
|
||||
@@ -91,24 +98,26 @@ wardrobe:
|
||||
title-fade-in: 1000 # milliseconds
|
||||
title-stay: 500 # milliseconds
|
||||
title-fade-out: 1000 # milliseconds
|
||||
wardrobe-location:
|
||||
world: "World"
|
||||
x: 0
|
||||
y: 0
|
||||
z: 0
|
||||
yaw: 0
|
||||
pitch: 0
|
||||
viewer-location:
|
||||
world: "World"
|
||||
x: 5
|
||||
y: 0
|
||||
z: 5
|
||||
yaw: 0
|
||||
pitch: 0
|
||||
leave-location:
|
||||
world: "World"
|
||||
x: 5
|
||||
y: 5
|
||||
z: 5
|
||||
yaw: 0
|
||||
pitch: 0
|
||||
wardrobes:
|
||||
default:
|
||||
npc-location:
|
||||
world: "world"
|
||||
x: 0
|
||||
y: 0
|
||||
z: 0
|
||||
yaw: 0
|
||||
pitch: 0
|
||||
viewer-location:
|
||||
world: "world"
|
||||
x: 5
|
||||
y: 0
|
||||
z: 5
|
||||
yaw: 0
|
||||
pitch: 0
|
||||
leave-location:
|
||||
world: "world"
|
||||
x: 5
|
||||
y: 5
|
||||
z: 5
|
||||
yaw: 0
|
||||
pitch: 0
|
||||
|
||||
@@ -15,6 +15,11 @@ backpack:
|
||||
model-data: 4
|
||||
name: "<blue>Backpack"
|
||||
amount: 1
|
||||
firstperson-item:
|
||||
material: PAPER
|
||||
model-data: 8
|
||||
name: "<white>Backpack"
|
||||
amount: 1
|
||||
future_wings:
|
||||
slot: BACKPACK
|
||||
permission: "hmccosmetics.future_wings"
|
||||
@@ -23,6 +28,11 @@ future_wings:
|
||||
model-data: 9
|
||||
name: "<#d24c9f>Future Wings"
|
||||
amount: 1
|
||||
firstperson-item:
|
||||
material: PAPER
|
||||
model-data: 10
|
||||
name: "<white>Future Wings"
|
||||
amount: 1
|
||||
lantern_cosmetic:
|
||||
slot: OFFHAND
|
||||
permission: "hmccosmetics.lantern_cosmetic"
|
||||
@@ -55,6 +65,11 @@ jetpack:
|
||||
model-data: 12
|
||||
name: "<blue>Jetpack"
|
||||
amount: 1
|
||||
firstperson-item:
|
||||
material: PAPER
|
||||
model-data: 14
|
||||
name: "<white>Jetpack"
|
||||
amount: 1
|
||||
hammer:
|
||||
slot: OFFHAND
|
||||
permission: "hmccosmetics.hammer"
|
||||
@@ -111,6 +126,11 @@ explorer_backpack:
|
||||
model-data: 3
|
||||
name: "<white>Explorer's Backpack"
|
||||
amount: 1
|
||||
firstperson-item:
|
||||
material: LEATHER_HORSE_ARMOR
|
||||
model-data: 5
|
||||
name: "<white>Explorer's Backpack"
|
||||
amount: 1
|
||||
garbage_truck_balloon:
|
||||
slot: BALLOON
|
||||
permission: "hmccosmetics.garbage_truck_balloon"
|
||||
@@ -128,4 +148,13 @@ earth_day_grabber:
|
||||
material: LEATHER_HORSE_ARMOR
|
||||
model-data: 4
|
||||
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>"
|
||||
rows: 6
|
||||
refresh-rate: 20 # Set to -1 or remove to disable auto-updating, leading to it only using event-based updates.
|
||||
items:
|
||||
beanie:
|
||||
slots:
|
||||
@@ -189,4 +190,15 @@ items:
|
||||
- "<gray>Enabled: <#6D9DC5>%HMCCosmetics_equipped_earth_day_grabber%"
|
||||
- "<gray>Allowed: <#6D9DC5>%HMCCosmetics_unlocked_earth_day_grabber%"
|
||||
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>"
|
||||
reloaded: "%prefix% <gradient:#6D9DC5:#45CDE9>Config files reloaded!"
|
||||
not-enough-args: "%prefix% <red>Improper amount of arguments"
|
||||
@@ -11,11 +16,16 @@ not-near-wardrobe: "%prefix% <red>You are not near the wardrobe!"
|
||||
set-wardrobe-location: "%prefix% <gradient:#6D9DC5:#45CDE9>Set new wardrobe location!"
|
||||
set-wardrobe-viewing: "%prefix% <gradient:#6D9DC5:#45CDE9>Set new wardrobe viewing location!"
|
||||
set-wardrobe-leaving: "%prefix% <gradient:#6D9DC5:#45CDE9>Set new wardrobe leaving location!"
|
||||
set-wardrobe-permission: "%prefix% <gradient:#6D9DC5:#45CDE9>Set new wardrobe permission!"
|
||||
set-wardrobe-distance: "%prefix% <gradient:#6D9DC5:#45CDE9>Set new wardrobe distance!"
|
||||
no-wardrobes: "%prefix% <red>There are no wardrobes with that name!"
|
||||
wardrobe-not-setup: "%prefix% <red>This wardrobe does not have all required locations set!"
|
||||
|
||||
equip-cosmetic: "%prefix% <gradient:#6D9DC5:#45CDE9>You have equipped <cosmetic>!"
|
||||
unequip-cosmetic: "%prefix% <gradient:#6D9DC5:#45CDE9>You have unequipped <cosmetic>!"
|
||||
hide-cosmetic: "%prefix% <gradient:#6D9DC5:#45CDE9>Hidden 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-none: "%prefix% <red>You have no emote equipped!"
|
||||
|
||||
@@ -1,3 +1,15 @@
|
||||
unlockedCosmetic:
|
||||
true: "True"
|
||||
false: "false"
|
||||
unlocked-cosmetic:
|
||||
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"
|
||||
|
||||
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
@@ -1,5 +1,5 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
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
|
||||
zipStorePath=wrapper/dists
|
||||
|
||||
@@ -8,9 +8,9 @@ pluginManagement {
|
||||
rootProject.name = "HMCCosmetics"
|
||||
include(
|
||||
"common",
|
||||
"v1_17_R1",
|
||||
"v1_18_R2",
|
||||
"v1_19_R1",
|
||||
"v1_19_R2",
|
||||
"v1_19_R3",
|
||||
"v1_20_R1",
|
||||
)
|
||||
|
||||
@@ -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,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,12 +6,10 @@ 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.user.manager.UserBalloonManager;
|
||||
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.minecraft.network.protocol.Packet;
|
||||
import net.minecraft.network.protocol.game.ClientboundContainerSetSlotPacket;
|
||||
@@ -20,7 +18,6 @@ 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;
|
||||
@@ -34,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.scoreboard.CraftScoreboard;
|
||||
import org.bukkit.entity.ArmorStand;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.entity.CreatureSpawnEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
@@ -46,7 +42,7 @@ import java.util.List;
|
||||
public class NMSHandler implements com.hibiscusmc.hmccosmetics.nms.NMSHandler {
|
||||
@Override
|
||||
public int getNextEntityId() {
|
||||
return Entity.nextEntityId();
|
||||
return net.minecraft.world.entity.Entity.nextEntityId();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -71,12 +67,6 @@ public class NMSHandler implements com.hibiscusmc.hmccosmetics.nms.NMSHandler {
|
||||
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();
|
||||
@@ -84,39 +74,34 @@ public class NMSHandler implements com.hibiscusmc.hmccosmetics.nms.NMSHandler {
|
||||
|
||||
@Override
|
||||
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);
|
||||
|
||||
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");
|
||||
|
||||
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());
|
||||
org.bukkit.entity.Entity entity = user.getEntity();
|
||||
|
||||
UserBalloonManager userBalloonManager1 = new UserBalloonManager(user.getPlayer().getLocation());
|
||||
List<Player> sentTo = PlayerUtils.getNearbyPlayers(player.getLocation());
|
||||
userBalloonManager1.getModelEntity().teleport(user.getPlayer().getLocation().add(Settings.getBalloonOffset()));
|
||||
UserBalloonManager userBalloonManager1 = new UserBalloonManager(entity.getLocation());
|
||||
userBalloonManager1.getModelEntity().teleport(entity.getLocation().add(Settings.getBalloonOffset()));
|
||||
|
||||
userBalloonManager1.spawnModel(cosmeticBalloonType, user.getCosmeticColor(cosmeticBalloonType.getSlot()));
|
||||
userBalloonManager1.addPlayerToModel(user, cosmeticBalloonType, user.getCosmeticColor(cosmeticBalloonType.getSlot()));
|
||||
|
||||
PacketManager.sendEntitySpawnPacket(newLoc, userBalloonManager1.getPufferfishBalloonId(), EntityType.PUFFERFISH, userBalloonManager1.getPufferfishBalloonUniqueId(), sentTo);
|
||||
PacketManager.sendInvisibilityPacket(userBalloonManager1.getPufferfishBalloonId(), sentTo);
|
||||
userBalloonManager1.sendLeashPacket(player.getEntityId());
|
||||
|
||||
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,12 +6,10 @@ 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.user.manager.UserBalloonManager;
|
||||
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.minecraft.network.protocol.Packet;
|
||||
import net.minecraft.network.protocol.game.ClientboundContainerSetSlotPacket;
|
||||
@@ -20,7 +18,6 @@ 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;
|
||||
@@ -34,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.scoreboard.CraftScoreboard;
|
||||
import org.bukkit.entity.ArmorStand;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.entity.CreatureSpawnEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
@@ -46,7 +42,7 @@ import java.util.List;
|
||||
public class NMSHandler implements com.hibiscusmc.hmccosmetics.nms.NMSHandler {
|
||||
@Override
|
||||
public int getNextEntityId() {
|
||||
return Entity.nextEntityId();
|
||||
return net.minecraft.world.entity.Entity.nextEntityId();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -71,12 +67,6 @@ public class NMSHandler implements com.hibiscusmc.hmccosmetics.nms.NMSHandler {
|
||||
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();
|
||||
@@ -84,39 +74,36 @@ public class NMSHandler implements com.hibiscusmc.hmccosmetics.nms.NMSHandler {
|
||||
|
||||
@Override
|
||||
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);
|
||||
|
||||
HMCArmorStand.setItemSlot(EquipmentSlot.HEAD, CraftItemStack.asNMSCopy(item));
|
||||
((CraftWorld) user.getPlayer().getWorld()).getHandle().addFreshEntity(HMCArmorStand, CreatureSpawnEvent.SpawnReason.CUSTOM);
|
||||
invisibleArmorstand.setItemSlot(EquipmentSlot.HEAD, CraftItemStack.asNMSCopy(item));
|
||||
((CraftWorld) user.getEntity().getWorld()).getHandle().addFreshEntity(invisibleArmorstand, CreatureSpawnEvent.SpawnReason.CUSTOM);
|
||||
|
||||
MessagesUtil.sendDebugMessages("spawnBackpack NMS");
|
||||
|
||||
return HMCArmorStand.getBukkitLivingEntity();
|
||||
//PacketManager.armorStandMetaPacket(invisibleArmorstand.getBukkitEntity(), sentTo);
|
||||
//PacketManager.ridingMountPacket(player.getEntityId(), invisibleArmorstand.getId(), sentTo);
|
||||
|
||||
return invisibleArmorstand.getBukkitLivingEntity();
|
||||
}
|
||||
|
||||
@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());
|
||||
org.bukkit.entity.Entity entity = user.getEntity();
|
||||
|
||||
UserBalloonManager userBalloonManager1 = new UserBalloonManager(user.getPlayer().getLocation());
|
||||
List<Player> sentTo = PlayerUtils.getNearbyPlayers(player.getLocation());
|
||||
userBalloonManager1.getModelEntity().teleport(user.getPlayer().getLocation().add(Settings.getBalloonOffset()));
|
||||
UserBalloonManager userBalloonManager1 = new UserBalloonManager(entity.getLocation());
|
||||
userBalloonManager1.getModelEntity().teleport(entity.getLocation().add(Settings.getBalloonOffset()));
|
||||
|
||||
userBalloonManager1.spawnModel(cosmeticBalloonType, user.getCosmeticColor(cosmeticBalloonType.getSlot()));
|
||||
userBalloonManager1.addPlayerToModel(user, cosmeticBalloonType, user.getCosmeticColor(cosmeticBalloonType.getSlot()));
|
||||
|
||||
PacketManager.sendEntitySpawnPacket(newLoc, userBalloonManager1.getPufferfishBalloonId(), EntityType.PUFFERFISH, userBalloonManager1.getPufferfishBalloonUniqueId(), sentTo);
|
||||
PacketManager.sendInvisibilityPacket(userBalloonManager1.getPufferfishBalloonId(), sentTo);
|
||||
userBalloonManager1.sendLeashPacket(player.getEntityId());
|
||||
|
||||
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,12 +6,10 @@ 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.user.manager.UserBalloonManager;
|
||||
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.minecraft.network.protocol.Packet;
|
||||
import net.minecraft.network.protocol.game.ClientboundContainerSetSlotPacket;
|
||||
@@ -20,7 +18,6 @@ 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;
|
||||
@@ -34,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.scoreboard.CraftScoreboard;
|
||||
import org.bukkit.entity.ArmorStand;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.entity.CreatureSpawnEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
@@ -46,7 +42,7 @@ import java.util.List;
|
||||
public class NMSHandler implements com.hibiscusmc.hmccosmetics.nms.NMSHandler {
|
||||
@Override
|
||||
public int getNextEntityId() {
|
||||
return Entity.nextEntityId();
|
||||
return net.minecraft.world.entity.Entity.nextEntityId();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -71,12 +67,6 @@ public class NMSHandler implements com.hibiscusmc.hmccosmetics.nms.NMSHandler {
|
||||
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();
|
||||
@@ -84,39 +74,35 @@ public class NMSHandler implements com.hibiscusmc.hmccosmetics.nms.NMSHandler {
|
||||
|
||||
@Override
|
||||
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);
|
||||
|
||||
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");
|
||||
|
||||
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());
|
||||
org.bukkit.entity.Entity entity = user.getEntity();
|
||||
|
||||
UserBalloonManager userBalloonManager1 = new UserBalloonManager(user.getPlayer().getLocation());
|
||||
List<Player> sentTo = PlayerUtils.getNearbyPlayers(player.getLocation());
|
||||
userBalloonManager1.getModelEntity().teleport(user.getPlayer().getLocation().add(Settings.getBalloonOffset()));
|
||||
UserBalloonManager userBalloonManager1 = new UserBalloonManager(entity.getLocation());
|
||||
userBalloonManager1.getModelEntity().teleport(entity.getLocation().add(Settings.getBalloonOffset()));
|
||||
|
||||
userBalloonManager1.spawnModel(cosmeticBalloonType, user.getCosmeticColor(cosmeticBalloonType.getSlot()));
|
||||
userBalloonManager1.addPlayerToModel(user, cosmeticBalloonType, user.getCosmeticColor(cosmeticBalloonType.getSlot()));
|
||||
|
||||
PacketManager.sendEntitySpawnPacket(newLoc, userBalloonManager1.getPufferfishBalloonId(), EntityType.PUFFERFISH, userBalloonManager1.getPufferfishBalloonUniqueId(), sentTo);
|
||||
PacketManager.sendInvisibilityPacket(userBalloonManager1.getPufferfishBalloonId(), sentTo);
|
||||
userBalloonManager1.sendLeashPacket(player.getEntityId());
|
||||
|
||||
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,13 +6,12 @@ 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.user.manager.UserBalloonManager;
|
||||
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.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.protocol.Packet;
|
||||
import net.minecraft.network.protocol.game.ClientboundContainerSetSlotPacket;
|
||||
import net.minecraft.network.protocol.game.ClientboundSetEquipmentPacket;
|
||||
@@ -20,7 +19,7 @@ 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.Display;
|
||||
import net.minecraft.world.entity.EquipmentSlot;
|
||||
import net.minecraft.world.entity.player.Inventory;
|
||||
import net.minecraft.world.scores.PlayerTeam;
|
||||
@@ -34,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.scoreboard.CraftScoreboard;
|
||||
import org.bukkit.entity.ArmorStand;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.entity.CreatureSpawnEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
@@ -46,7 +45,7 @@ import java.util.List;
|
||||
public class NMSHandler implements com.hibiscusmc.hmccosmetics.nms.NMSHandler {
|
||||
@Override
|
||||
public int getNextEntityId() {
|
||||
return Entity.nextEntityId();
|
||||
return net.minecraft.world.entity.Entity.nextEntityId();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -71,12 +70,6 @@ public class NMSHandler implements com.hibiscusmc.hmccosmetics.nms.NMSHandler {
|
||||
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();
|
||||
@@ -84,39 +77,41 @@ public class NMSHandler implements com.hibiscusmc.hmccosmetics.nms.NMSHandler {
|
||||
|
||||
@Override
|
||||
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);
|
||||
|
||||
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");
|
||||
|
||||
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) {
|
||||
Display.TextDisplay entity = new Display.TextDisplay(net.minecraft.world.entity.EntityType.TEXT_DISPLAY, ((CraftWorld) location.getWorld()).getHandle());
|
||||
entity.setPos(location.getX(), location.getY(), location.getZ());
|
||||
entity.persist = false;
|
||||
//entity.setText(net.minecraft.network.chat.Component.literal("TEST!"));
|
||||
entity.setCustomNameVisible(true);
|
||||
entity.setCustomName(Component.literal(text));
|
||||
MessagesUtil.sendDebugMessages("spawnDisplayEntity - " + entity);
|
||||
((CraftWorld) location.getWorld()).getHandle().addFreshEntity(entity, CreatureSpawnEvent.SpawnReason.CUSTOM);
|
||||
return entity.getBukkitEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public UserBalloonManager spawnBalloon(CosmeticUser user, CosmeticBalloonType cosmeticBalloonType) {
|
||||
Player player = user.getPlayer();
|
||||
Location newLoc = player.getLocation().clone().add(Settings.getBalloonOffset());
|
||||
Entity entity = user.getEntity();
|
||||
|
||||
UserBalloonManager userBalloonManager1 = new UserBalloonManager(user.getPlayer().getLocation());
|
||||
List<Player> sentTo = PlayerUtils.getNearbyPlayers(player.getLocation());
|
||||
userBalloonManager1.getModelEntity().teleport(user.getPlayer().getLocation().add(Settings.getBalloonOffset()));
|
||||
UserBalloonManager userBalloonManager1 = new UserBalloonManager(entity.getLocation());
|
||||
userBalloonManager1.getModelEntity().teleport(entity.getLocation().add(Settings.getBalloonOffset()));
|
||||
|
||||
userBalloonManager1.spawnModel(cosmeticBalloonType, user.getCosmeticColor(cosmeticBalloonType.getSlot()));
|
||||
userBalloonManager1.addPlayerToModel(user, cosmeticBalloonType, user.getCosmeticColor(cosmeticBalloonType.getSlot()));
|
||||
|
||||
PacketManager.sendEntitySpawnPacket(newLoc, userBalloonManager1.getPufferfishBalloonId(), EntityType.PUFFERFISH, userBalloonManager1.getPufferfishBalloonUniqueId(), sentTo);
|
||||
PacketManager.sendInvisibilityPacket(userBalloonManager1.getPufferfishBalloonId(), sentTo);
|
||||
userBalloonManager1.sendLeashPacket(player.getEntityId());
|
||||
|
||||
return userBalloonManager1;
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ plugins {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
paperDevBundle("1.17.1-R0.1-SNAPSHOT")
|
||||
paperDevBundle("1.20-R0.1-SNAPSHOT")
|
||||
implementation(project(":common"))
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
package com.hibiscusmc.hmccosmetics.nms.v1_17_R1;
|
||||
package com.hibiscusmc.hmccosmetics.nms.v1_20_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;
|
||||
import org.bukkit.craftbukkit.v1_20_R1.CraftWorld;
|
||||
|
||||
public class HMCArmorStand extends ArmorStand {
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
package com.hibiscusmc.hmccosmetics.nms.v1_20_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_20_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,4 +1,4 @@
|
||||
package com.hibiscusmc.hmccosmetics.nms.v1_17_R1;
|
||||
package com.hibiscusmc.hmccosmetics.nms.v1_20_R1;
|
||||
|
||||
import com.hibiscusmc.hmccosmetics.config.Settings;
|
||||
import com.hibiscusmc.hmccosmetics.cosmetic.CosmeticSlot;
|
||||
@@ -6,13 +6,12 @@ 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.user.manager.UserBalloonManager;
|
||||
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.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.protocol.Packet;
|
||||
import net.minecraft.network.protocol.game.ClientboundContainerSetSlotPacket;
|
||||
import net.minecraft.network.protocol.game.ClientboundSetEquipmentPacket;
|
||||
@@ -20,31 +19,32 @@ 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.Display;
|
||||
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.craftbukkit.v1_20_R1.CraftEquipmentSlot;
|
||||
import org.bukkit.craftbukkit.v1_20_R1.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_20_R1.CraftWorld;
|
||||
import org.bukkit.craftbukkit.v1_20_R1.entity.CraftPlayer;
|
||||
import org.bukkit.craftbukkit.v1_20_R1.inventory.CraftItemStack;
|
||||
import org.bukkit.craftbukkit.v1_20_R1.scoreboard.CraftScoreboard;
|
||||
import org.bukkit.entity.ArmorStand;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.entity.CreatureSpawnEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class NMSHandler implements com.hibiscusmc.hmccosmetics.nms.NMSHandler {
|
||||
@Override
|
||||
public int getNextEntityId() {
|
||||
return Entity.nextEntityId();
|
||||
return net.minecraft.world.entity.Entity.nextEntityId();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -69,12 +69,6 @@ public class NMSHandler implements com.hibiscusmc.hmccosmetics.nms.NMSHandler {
|
||||
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();
|
||||
@@ -82,39 +76,43 @@ public class NMSHandler implements com.hibiscusmc.hmccosmetics.nms.NMSHandler {
|
||||
|
||||
@Override
|
||||
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);
|
||||
|
||||
invisibleArmorstand.setItemSlot(EquipmentSlot.HEAD, CraftItemStack.asNMSCopy(item));
|
||||
((CraftWorld) user.getPlayer().getWorld()).getHandle().addFreshEntity(invisibleArmorstand);
|
||||
((CraftWorld) user.getEntity().getWorld()).getHandle().addFreshEntity(invisibleArmorstand, CreatureSpawnEvent.SpawnReason.CUSTOM);
|
||||
|
||||
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) {
|
||||
Display.TextDisplay entity = new Display.TextDisplay(net.minecraft.world.entity.EntityType.TEXT_DISPLAY, ((CraftWorld) location.getWorld()).getHandle());
|
||||
entity.setPos(location.getX(), location.getY(), location.getZ());
|
||||
entity.persist = false;
|
||||
//entity.setText(net.minecraft.network.chat.Component.literal("TEST!"));
|
||||
entity.setCustomNameVisible(true);
|
||||
entity.setCustomName(Component.literal(text));
|
||||
MessagesUtil.sendDebugMessages("spawnDisplayEntity - " + entity);
|
||||
((CraftWorld) location.getWorld()).getHandle().addFreshEntity(entity, CreatureSpawnEvent.SpawnReason.CUSTOM);
|
||||
return entity.getBukkitEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public UserBalloonManager spawnBalloon(CosmeticUser user, CosmeticBalloonType cosmeticBalloonType) {
|
||||
Player player = user.getPlayer();
|
||||
Location newLoc = player.getLocation().clone().add(Settings.getBalloonOffset());
|
||||
org.bukkit.entity.Entity entity = user.getEntity();
|
||||
|
||||
UserBalloonManager userBalloonManager1 = new UserBalloonManager(user.getPlayer().getLocation());
|
||||
List<Player> sentTo = PlayerUtils.getNearbyPlayers(player.getLocation());
|
||||
userBalloonManager1.getModelEntity().teleport(user.getPlayer().getLocation().add(Settings.getBalloonOffset()));
|
||||
UserBalloonManager userBalloonManager1 = new UserBalloonManager(entity.getLocation());
|
||||
userBalloonManager1.getModelEntity().teleport(entity.getLocation().add(Settings.getBalloonOffset()));
|
||||
|
||||
userBalloonManager1.spawnModel(cosmeticBalloonType, user.getCosmeticColor(cosmeticBalloonType.getSlot()));
|
||||
userBalloonManager1.addPlayerToModel(user, cosmeticBalloonType, user.getCosmeticColor(cosmeticBalloonType.getSlot()));
|
||||
|
||||
PacketManager.sendEntitySpawnPacket(newLoc, userBalloonManager1.getPufferfishBalloonId(), EntityType.PUFFERFISH, userBalloonManager1.getPufferfishBalloonUniqueId(), sentTo);
|
||||
PacketManager.sendInvisibilityPacket(userBalloonManager1.getPufferfishBalloonId(), sentTo);
|
||||
userBalloonManager1.sendLeashPacket(player.getEntityId());
|
||||
|
||||
return userBalloonManager1;
|
||||
}
|
||||
|
||||
@@ -229,7 +227,9 @@ public class NMSHandler implements com.hibiscusmc.hmccosmetics.nms.NMSHandler {
|
||||
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);
|
||||
ClientboundSetPlayerTeamPacket createPlayerTeamPacket = ClientboundSetPlayerTeamPacket.createMultiplePlayerPacket(team, new ArrayList<String>() {{
|
||||
add(NPCName);
|
||||
}}, ClientboundSetPlayerTeamPacket.Action.ADD);
|
||||
sendPacket(player, createPlayerTeamPacket);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user