mirror of
https://github.com/HibiscusMC/HMCCosmetics.git
synced 2025-12-23 17:09:24 +00:00
Compare commits
68 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
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 |
@@ -8,7 +8,7 @@ plugins {
|
|||||||
}
|
}
|
||||||
|
|
||||||
group = "com.hibiscusmc"
|
group = "com.hibiscusmc"
|
||||||
version = "2.3.0"
|
version = "2.4.3"
|
||||||
|
|
||||||
allprojects {
|
allprojects {
|
||||||
apply(plugin = "java")
|
apply(plugin = "java")
|
||||||
@@ -27,6 +27,7 @@ allprojects {
|
|||||||
// ProtocolLib repo
|
// ProtocolLib repo
|
||||||
maven("https://repo.dmulloy2.net/repository/public/") //ProtocolLib Repo, constantly down
|
maven("https://repo.dmulloy2.net/repository/public/") //ProtocolLib Repo, constantly down
|
||||||
maven("https://repo.mineinabyss.com/releases/")
|
maven("https://repo.mineinabyss.com/releases/")
|
||||||
|
maven("https://repo.mineinabyss.com/snapshots/")
|
||||||
|
|
||||||
// PlaceholderAPI
|
// PlaceholderAPI
|
||||||
maven("https://repo.extendedclip.com/content/repositories/placeholderapi/")
|
maven("https://repo.extendedclip.com/content/repositories/placeholderapi/")
|
||||||
@@ -69,14 +70,12 @@ allprojects {
|
|||||||
compileOnly("com.mojang:authlib:1.5.25")
|
compileOnly("com.mojang:authlib:1.5.25")
|
||||||
compileOnly("org.spigotmc:spigot-api:1.17.1-R0.1-SNAPSHOT")
|
compileOnly("org.spigotmc:spigot-api:1.17.1-R0.1-SNAPSHOT")
|
||||||
compileOnly("org.jetbrains:annotations:23.0.0")
|
compileOnly("org.jetbrains:annotations:23.0.0")
|
||||||
compileOnly("com.comphenix.protocol:ProtocolLib:5.0.0-SNAPSHOT")
|
compileOnly("com.comphenix.protocol:ProtocolLib:5.0.0")
|
||||||
compileOnly("me.clip:placeholderapi:2.11.1")
|
compileOnly("me.clip:placeholderapi:2.11.1")
|
||||||
compileOnly("com.ticxo.modelengine:api:R3.0.1")
|
compileOnly("com.ticxo:modelengine:R3.0.1")
|
||||||
compileOnly("com.github.oraxen:oraxen:-SNAPSHOT")
|
compileOnly("com.github.oraxen:oraxen:-SNAPSHOT")
|
||||||
compileOnly("com.github.LoneDev6:API-ItemsAdder:3.2.5")
|
compileOnly("com.github.LoneDev6:API-ItemsAdder:3.2.5")
|
||||||
compileOnly("com.mineinabyss:idofront:0.12.111")
|
compileOnly("com.mineinabyss:geary-papermc:0.24-SNAPSHOT")
|
||||||
compileOnly("com.mineinabyss:geary-papermc-core:0.19.113")
|
|
||||||
compileOnly("com.mineinabyss:looty:0.8.67")
|
|
||||||
compileOnly("com.sk89q.worldguard:worldguard-bukkit:7.1.0-SNAPSHOT")
|
compileOnly("com.sk89q.worldguard:worldguard-bukkit:7.1.0-SNAPSHOT")
|
||||||
compileOnly("it.unimi.dsi:fastutil:8.5.11")
|
compileOnly("it.unimi.dsi:fastutil:8.5.11")
|
||||||
compileOnly("com.github.LeonMangler:SuperVanish:6.2.6-4")
|
compileOnly("com.github.LeonMangler:SuperVanish:6.2.6-4")
|
||||||
@@ -90,6 +89,7 @@ dependencies {
|
|||||||
implementation(project(path = ":v1_19_R1", configuration = "reobf"))
|
implementation(project(path = ":v1_19_R1", configuration = "reobf"))
|
||||||
implementation(project(path = ":v1_19_R2", configuration = "reobf"))
|
implementation(project(path = ":v1_19_R2", configuration = "reobf"))
|
||||||
implementation(project(path = ":v1_19_R3", 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")
|
//compileOnly("com.github.Fisher2911:FisherLib:master-SNAPSHOT")
|
||||||
implementation("net.kyori:adventure-api:4.11.0")
|
implementation("net.kyori:adventure-api:4.11.0")
|
||||||
@@ -100,7 +100,8 @@ dependencies {
|
|||||||
implementation("org.bstats:bstats-bukkit:3.0.0")
|
implementation("org.bstats:bstats-bukkit:3.0.0")
|
||||||
implementation("com.jeff_media:SpigotUpdateChecker:3.0.0")
|
implementation("com.jeff_media:SpigotUpdateChecker:3.0.0")
|
||||||
implementation("com.owen1212055:particlehelper:1.0.0-SNAPSHOT")
|
implementation("com.owen1212055:particlehelper:1.0.0-SNAPSHOT")
|
||||||
implementation("com.ticxo:PlayerAnimator:R1.2.6")
|
implementation("com.ticxo.playeranimator:PlayerAnimator:R1.2.7")
|
||||||
|
implementation("com.github.BG-Software-LLC:CommentedConfiguration:-SNAPSHOT")
|
||||||
//implementation("com.ticxo.playeranimator:PlayerAnimator:R1.2.5")
|
//implementation("com.ticxo.playeranimator:PlayerAnimator:R1.2.5")
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -130,6 +131,7 @@ tasks {
|
|||||||
dependsOn(":v1_19_R1:reobfJar")
|
dependsOn(":v1_19_R1:reobfJar")
|
||||||
dependsOn(":v1_19_R2:reobfJar")
|
dependsOn(":v1_19_R2:reobfJar")
|
||||||
dependsOn(":v1_19_R3:reobfJar")
|
dependsOn(":v1_19_R3:reobfJar")
|
||||||
|
dependsOn(":v1_20_R1:reobfJar")
|
||||||
mergeServiceFiles()
|
mergeServiceFiles()
|
||||||
|
|
||||||
relocate("dev.triumphteam.gui", "com.hisbiscusmc.hmccosmetics.gui")
|
relocate("dev.triumphteam.gui", "com.hisbiscusmc.hmccosmetics.gui")
|
||||||
@@ -142,6 +144,7 @@ tasks {
|
|||||||
relocate("com.jeff_media.updatechecker", "com.hisbiscusmc.hmccosmetics.updatechecker")
|
relocate("com.jeff_media.updatechecker", "com.hisbiscusmc.hmccosmetics.updatechecker")
|
||||||
relocate("com.owen1212055.particlehelper", "com.hisbiscusmc.hmccosmetics.particlehelper")
|
relocate("com.owen1212055.particlehelper", "com.hisbiscusmc.hmccosmetics.particlehelper")
|
||||||
relocate("com.ticxo.playeranimator", "com.hisbiscusmc.hmccosmetics.playeranimator")
|
relocate("com.ticxo.playeranimator", "com.hisbiscusmc.hmccosmetics.playeranimator")
|
||||||
|
relocate("com.bgsoftware", "com.hisbiscusmc.hmccosmetics.configupdater")
|
||||||
archiveFileName.set("HMCCosmeticsRemapped-${project.version}.jar")
|
archiveFileName.set("HMCCosmeticsRemapped-${project.version}.jar")
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
@@ -169,7 +172,7 @@ bukkit {
|
|||||||
apiVersion = "1.17"
|
apiVersion = "1.17"
|
||||||
authors = listOf("LoJoSho")
|
authors = listOf("LoJoSho")
|
||||||
depend = listOf("ProtocolLib")
|
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}"
|
version = "${project.version}"
|
||||||
|
|
||||||
commands {
|
commands {
|
||||||
@@ -211,7 +214,7 @@ bukkit {
|
|||||||
register("hmccosmetics.cmd.emote.other") {
|
register("hmccosmetics.cmd.emote.other") {
|
||||||
default = BukkitPluginDescription.Permission.Default.OP
|
default = BukkitPluginDescription.Permission.Default.OP
|
||||||
}
|
}
|
||||||
register("hmccosmetics.cmd.setlocation") {
|
register("hmccosmetics.cmd.setwardrobesetting") {
|
||||||
default = BukkitPluginDescription.Permission.Default.OP
|
default = BukkitPluginDescription.Permission.Default.OP
|
||||||
}
|
}
|
||||||
register("hmccosmetics.cmd.dataclear") {
|
register("hmccosmetics.cmd.dataclear") {
|
||||||
@@ -256,4 +259,4 @@ bukkit {
|
|||||||
java {
|
java {
|
||||||
toolchain.languageVersion.set(JavaLanguageVersion.of(17
|
toolchain.languageVersion.set(JavaLanguageVersion.of(17
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,13 +7,12 @@ dependencies {
|
|||||||
compileOnly("com.mojang:authlib:1.5.25")
|
compileOnly("com.mojang:authlib:1.5.25")
|
||||||
compileOnly("org.spigotmc:spigot-api:1.17.1-R0.1-SNAPSHOT")
|
compileOnly("org.spigotmc:spigot-api:1.17.1-R0.1-SNAPSHOT")
|
||||||
compileOnly("org.jetbrains:annotations:23.0.0")
|
compileOnly("org.jetbrains:annotations:23.0.0")
|
||||||
compileOnly("com.comphenix.protocol:ProtocolLib:5.0.0-SNAPSHOT")
|
compileOnly("com.comphenix.protocol:ProtocolLib:5.0.0")
|
||||||
compileOnly("me.clip:placeholderapi:2.11.1")
|
compileOnly("me.clip:placeholderapi:2.11.1")
|
||||||
compileOnly("com.ticxo.modelengine:api:R3.0.1")
|
compileOnly("com.ticxo:modelengine:R3.0.1")
|
||||||
compileOnly("com.github.oraxen:oraxen:-SNAPSHOT")
|
compileOnly("com.github.oraxen:oraxen:-SNAPSHOT")
|
||||||
compileOnly("com.github.LoneDev6:API-ItemsAdder:3.2.5")
|
compileOnly("com.github.LoneDev6:API-ItemsAdder:3.2.5")
|
||||||
compileOnly("com.mineinabyss:geary-papermc-core:0.19.113")
|
compileOnly("com.mineinabyss:geary-papermc:0.24-SNAPSHOT")
|
||||||
compileOnly("com.mineinabyss:looty:0.8.67")
|
|
||||||
compileOnly("com.hibiscus:hmccolor:0.3-SNAPSHOT")
|
compileOnly("com.hibiscus:hmccolor:0.3-SNAPSHOT")
|
||||||
compileOnly("com.sk89q.worldguard:worldguard-bukkit:7.1.0-SNAPSHOT")
|
compileOnly("com.sk89q.worldguard:worldguard-bukkit:7.1.0-SNAPSHOT")
|
||||||
compileOnly("it.unimi.dsi:fastutil:8.5.11")
|
compileOnly("it.unimi.dsi:fastutil:8.5.11")
|
||||||
@@ -33,7 +32,8 @@ dependencies {
|
|||||||
implementation("org.bstats:bstats-bukkit:3.0.0")
|
implementation("org.bstats:bstats-bukkit:3.0.0")
|
||||||
implementation("com.jeff_media:SpigotUpdateChecker:3.0.0")
|
implementation("com.jeff_media:SpigotUpdateChecker:3.0.0")
|
||||||
implementation("com.owen1212055:particlehelper:1.0.0-SNAPSHOT")
|
implementation("com.owen1212055:particlehelper:1.0.0-SNAPSHOT")
|
||||||
implementation("com.ticxo:PlayerAnimator:R1.2.6")
|
implementation("com.ticxo.playeranimator:PlayerAnimator:R1.2.7")
|
||||||
|
implementation("com.github.BG-Software-LLC:CommentedConfiguration:-SNAPSHOT")
|
||||||
//implementation("com.ticxo.playeranimator:PlayerAnimator:R1.2.5")
|
//implementation("com.ticxo.playeranimator:PlayerAnimator:R1.2.5")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package com.hibiscusmc.hmccosmetics;
|
package com.hibiscusmc.hmccosmetics;
|
||||||
|
|
||||||
|
import com.bgsoftware.common.config.CommentedConfiguration;
|
||||||
import com.hibiscusmc.hmccosmetics.api.HMCCosmeticSetupEvent;
|
import com.hibiscusmc.hmccosmetics.api.HMCCosmeticSetupEvent;
|
||||||
import com.hibiscusmc.hmccosmetics.command.CosmeticCommand;
|
import com.hibiscusmc.hmccosmetics.command.CosmeticCommand;
|
||||||
import com.hibiscusmc.hmccosmetics.command.CosmeticCommandTabComplete;
|
import com.hibiscusmc.hmccosmetics.command.CosmeticCommandTabComplete;
|
||||||
@@ -12,6 +13,7 @@ import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
|
|||||||
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetics;
|
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetics;
|
||||||
import com.hibiscusmc.hmccosmetics.database.Database;
|
import com.hibiscusmc.hmccosmetics.database.Database;
|
||||||
import com.hibiscusmc.hmccosmetics.emotes.EmoteManager;
|
import com.hibiscusmc.hmccosmetics.emotes.EmoteManager;
|
||||||
|
import com.hibiscusmc.hmccosmetics.gui.Menu;
|
||||||
import com.hibiscusmc.hmccosmetics.gui.Menus;
|
import com.hibiscusmc.hmccosmetics.gui.Menus;
|
||||||
import com.hibiscusmc.hmccosmetics.hooks.Hooks;
|
import com.hibiscusmc.hmccosmetics.hooks.Hooks;
|
||||||
import com.hibiscusmc.hmccosmetics.hooks.worldguard.WGHook;
|
import com.hibiscusmc.hmccosmetics.hooks.worldguard.WGHook;
|
||||||
@@ -86,13 +88,12 @@ public final class HMCCosmeticsPlugin extends JavaPlugin {
|
|||||||
.checkNow();
|
.checkNow();
|
||||||
onLatestVersion = checker.isUsingLatestVersion();
|
onLatestVersion = checker.isUsingLatestVersion();
|
||||||
// File setup
|
// File setup
|
||||||
if (!getDataFolder().exists()) {
|
saveDefaultConfig();
|
||||||
saveDefaultConfig();
|
//saveResource("translations.yml", false);
|
||||||
saveResource("translations.yml", false);
|
if (!Path.of(getDataFolder().getPath(), "messages.yml").toFile().exists()) saveResource("messages.yml", false);
|
||||||
saveResource("messages.yml", false);
|
if (!Path.of(getDataFolder().getPath() + "/cosmetics/").toFile().exists()) saveResource("cosmetics/defaultcosmetics.yml", false);
|
||||||
saveResource("cosmetics/defaultcosmetics.yml", false);
|
if (!Path.of(getDataFolder().getPath() + "/menus/").toFile().exists()) saveResource("menus/defaultmenu.yml", false);
|
||||||
saveResource("menus/defaultmenu.yml", false);
|
|
||||||
}
|
|
||||||
// Emote folder setup
|
// Emote folder setup
|
||||||
File emoteFile = new File(getDataFolder().getPath() + "/emotes");
|
File emoteFile = new File(getDataFolder().getPath() + "/emotes");
|
||||||
if (!emoteFile.exists()) emoteFile.mkdir();
|
if (!emoteFile.exists()) emoteFile.mkdir();
|
||||||
@@ -100,6 +101,16 @@ public final class HMCCosmeticsPlugin extends JavaPlugin {
|
|||||||
// Player Animator
|
// Player Animator
|
||||||
PlayerAnimatorImpl.initialize(this);
|
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();
|
||||||
|
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"));
|
||||||
|
} catch (Exception e) {}
|
||||||
|
|
||||||
|
// Setup
|
||||||
setup();
|
setup();
|
||||||
|
|
||||||
// Commands
|
// Commands
|
||||||
@@ -170,7 +181,7 @@ public final class HMCCosmeticsPlugin extends JavaPlugin {
|
|||||||
WardrobeSettings.load(loader.load().node("wardrobe"));
|
WardrobeSettings.load(loader.load().node("wardrobe"));
|
||||||
DatabaseSettings.load(loader.load().node("database-settings"));
|
DatabaseSettings.load(loader.load().node("database-settings"));
|
||||||
configLoader = loader;
|
configLoader = loader;
|
||||||
} catch (ConfigurateException e) {
|
} catch (Exception e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -236,12 +247,19 @@ public final class HMCCosmeticsPlugin extends JavaPlugin {
|
|||||||
getInstance().getServer().getPluginManager().addPermission(new Permission(cosmetic.getPermission()));
|
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();
|
EmoteManager.loadEmotes();
|
||||||
|
|
||||||
getInstance().getLogger().info("Successfully Enabled HMCCosmetics");
|
getInstance().getLogger().info("Successfully Enabled HMCCosmetics");
|
||||||
getInstance().getLogger().info(Cosmetics.values().size() + " Cosmetics Successfully Setup");
|
getInstance().getLogger().info(Cosmetics.values().size() + " Cosmetics Successfully Setup");
|
||||||
getInstance().getLogger().info(Menus.getMenuNames().size() + " Menus 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());
|
getInstance().getLogger().info("Data storage is set to " + DatabaseSettings.getDatabaseType());
|
||||||
|
|
||||||
Bukkit.getPluginManager().callEvent(new HMCCosmeticSetupEvent());
|
Bukkit.getPluginManager().callEvent(new HMCCosmeticSetupEvent());
|
||||||
|
|||||||
@@ -0,0 +1,46 @@
|
|||||||
|
package com.hibiscusmc.hmccosmetics.api;
|
||||||
|
|
||||||
|
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,5 +1,7 @@
|
|||||||
package com.hibiscusmc.hmccosmetics.api;
|
package com.hibiscusmc.hmccosmetics.api;
|
||||||
|
|
||||||
|
import com.hibiscusmc.hmccosmetics.config.Wardrobe;
|
||||||
|
import com.hibiscusmc.hmccosmetics.config.WardrobeLocation;
|
||||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||||
import org.bukkit.event.Cancellable;
|
import org.bukkit.event.Cancellable;
|
||||||
import org.bukkit.event.HandlerList;
|
import org.bukkit.event.HandlerList;
|
||||||
@@ -11,9 +13,11 @@ import org.jetbrains.annotations.NotNull;
|
|||||||
public class PlayerWardrobeEnterEvent extends PlayerCosmeticEvent implements Cancellable {
|
public class PlayerWardrobeEnterEvent extends PlayerCosmeticEvent implements Cancellable {
|
||||||
private static final HandlerList handlers = new HandlerList();
|
private static final HandlerList handlers = new HandlerList();
|
||||||
private boolean cancel = false;
|
private boolean cancel = false;
|
||||||
|
private Wardrobe wardrobe;
|
||||||
|
|
||||||
public PlayerWardrobeEnterEvent(@NotNull CosmeticUser who) {
|
public PlayerWardrobeEnterEvent(@NotNull CosmeticUser who, @NotNull Wardrobe wardrobe) {
|
||||||
super(who);
|
super(who);
|
||||||
|
this.wardrobe = wardrobe;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -45,4 +49,12 @@ public class PlayerWardrobeEnterEvent extends PlayerCosmeticEvent implements Can
|
|||||||
public static HandlerList getHandlerList() {
|
public static HandlerList getHandlerList() {
|
||||||
return handlers;
|
return handlers;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setWardrobe(Wardrobe wardrobe) {
|
||||||
|
this.wardrobe = wardrobe;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Wardrobe getWardrobe() {
|
||||||
|
return wardrobe;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,8 @@ package com.hibiscusmc.hmccosmetics.command;
|
|||||||
|
|
||||||
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
|
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
|
||||||
import com.hibiscusmc.hmccosmetics.config.Settings;
|
import com.hibiscusmc.hmccosmetics.config.Settings;
|
||||||
|
import com.hibiscusmc.hmccosmetics.config.Wardrobe;
|
||||||
|
import com.hibiscusmc.hmccosmetics.config.WardrobeLocation;
|
||||||
import com.hibiscusmc.hmccosmetics.config.WardrobeSettings;
|
import com.hibiscusmc.hmccosmetics.config.WardrobeSettings;
|
||||||
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
|
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
|
||||||
import com.hibiscusmc.hmccosmetics.cosmetic.CosmeticSlot;
|
import com.hibiscusmc.hmccosmetics.cosmetic.CosmeticSlot;
|
||||||
@@ -194,8 +196,14 @@ public class CosmeticCommand implements CommandExecutor {
|
|||||||
}
|
}
|
||||||
case ("wardrobe") -> {
|
case ("wardrobe") -> {
|
||||||
if (sender instanceof Player) player = ((Player) sender).getPlayer();
|
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 (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")) {
|
if (!sender.hasPermission("hmccosmetics.cmd.wardrobe")) {
|
||||||
@@ -208,9 +216,19 @@ public class CosmeticCommand implements CommandExecutor {
|
|||||||
return true;
|
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);
|
CosmeticUser user = CosmeticUsers.getUser(player);
|
||||||
|
|
||||||
user.toggleWardrobe();
|
if (user.isInWardrobe()) {
|
||||||
|
user.leaveWardrobe();
|
||||||
|
} else {
|
||||||
|
user.enterWardrobe(false, wardrobe);
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
// cosmetic menu exampleMenu playerName
|
// cosmetic menu exampleMenu playerName
|
||||||
@@ -289,36 +307,56 @@ public class CosmeticCommand implements CommandExecutor {
|
|||||||
DyeMenu.openMenu(user, cosmetic);
|
DyeMenu.openMenu(user, cosmetic);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case ("setlocation") -> {
|
case ("setwardrobesetting") -> {
|
||||||
if (!sender.hasPermission("hmccosmetics.cmd.setlocation")) {
|
if (!sender.hasPermission("hmccosmetics.cmd.setwardrobesetting")) {
|
||||||
if (!silent) MessagesUtil.sendMessage(sender, "no-permission");
|
if (!silent) MessagesUtil.sendMessage(sender, "no-permission");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (player == null) return true;
|
if (player == null) return true;
|
||||||
|
|
||||||
if (args.length < 2) {
|
if (args.length < 3) {
|
||||||
if (!silent) MessagesUtil.sendMessage(player, "not-enough-args");
|
if (!silent) MessagesUtil.sendMessage(player, "not-enough-args");
|
||||||
return true;
|
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")) {
|
if (args[2].equalsIgnoreCase("npclocation")) {
|
||||||
WardrobeSettings.setWardrobeLocation(player.getLocation());
|
WardrobeSettings.setNPCLocation(wardrobe, player.getLocation());
|
||||||
if (!silent) MessagesUtil.sendMessage(player, "set-wardrobe-location");
|
if (!silent) MessagesUtil.sendMessage(player, "set-wardrobe-location");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args[1].equalsIgnoreCase("viewerlocation")) {
|
if (args[2].equalsIgnoreCase("viewerlocation")) {
|
||||||
WardrobeSettings.setViewerLocation(player.getLocation());
|
WardrobeSettings.setViewerLocation(wardrobe, player.getLocation());
|
||||||
if (!silent) MessagesUtil.sendMessage(player, "set-wardrobe-viewing");
|
if (!silent) MessagesUtil.sendMessage(player, "set-wardrobe-viewing");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args[1].equalsIgnoreCase("leavelocation")) {
|
if (args[2].equalsIgnoreCase("leavelocation")) {
|
||||||
WardrobeSettings.setLeaveLocation(player.getLocation());
|
WardrobeSettings.setLeaveLocation(wardrobe, player.getLocation());
|
||||||
if (!silent) MessagesUtil.sendMessage(player, "set-wardrobe-leaving");
|
if (!silent) MessagesUtil.sendMessage(player, "set-wardrobe-leaving");
|
||||||
return true;
|
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") -> {
|
case ("dump") -> {
|
||||||
if (player == null) return true;
|
if (player == null) return true;
|
||||||
@@ -442,7 +480,7 @@ public class CosmeticCommand implements CommandExecutor {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
CosmeticUser user = CosmeticUsers.getUser(player);
|
CosmeticUser user = CosmeticUsers.getUser(player);
|
||||||
user.getUserEmoteManager().playEmote(EmoteManager.get(args[1]));
|
user.getUserEmoteManager().playEmote(args[1]);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
package com.hibiscusmc.hmccosmetics.command;
|
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.Cosmetic;
|
||||||
import com.hibiscusmc.hmccosmetics.cosmetic.CosmeticSlot;
|
import com.hibiscusmc.hmccosmetics.cosmetic.CosmeticSlot;
|
||||||
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetics;
|
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetics;
|
||||||
@@ -36,7 +38,7 @@ public class CosmeticCommandTabComplete implements TabCompleter {
|
|||||||
if (hasPermission(sender, "hmccosmetics.cmd.wardrobe")) completions.add("wardrobe");
|
if (hasPermission(sender, "hmccosmetics.cmd.wardrobe")) completions.add("wardrobe");
|
||||||
if (hasPermission(sender, "hmccosmetics.cmd.dataclear")) completions.add("dataclear");
|
if (hasPermission(sender, "hmccosmetics.cmd.dataclear")) completions.add("dataclear");
|
||||||
if (hasPermission(sender, "hmccosmetics.cmd.dye")) completions.add("dye");
|
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.hide")) completions.add("hide");
|
||||||
if (hasPermission(sender, "hmccosmetics.cmd.show")) completions.add("show");
|
if (hasPermission(sender, "hmccosmetics.cmd.show")) completions.add("show");
|
||||||
if (hasPermission(sender, "hmccosmetics.cmd.debug")) completions.add("debug");
|
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());
|
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()) {
|
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||||
completions.add(player.getName());
|
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" -> {
|
case "dye" -> {
|
||||||
for (CosmeticSlot slot : user.getDyeableSlots()) {
|
for (CosmeticSlot slot : user.getDyeableSlots()) {
|
||||||
completions.add(slot.name());
|
completions.add(slot.name());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case "setlocation" -> {
|
case "setwardrobesetting" -> {
|
||||||
completions.add("wardrobelocation");
|
for (Wardrobe wardrobe : WardrobeSettings.getWardrobes()) {
|
||||||
completions.add("viewerlocation");
|
completions.add(wardrobe.getId());
|
||||||
completions.add("leavelocation");
|
}
|
||||||
}
|
}
|
||||||
case "playemote" -> completions.addAll(EmoteManager.getAllNames());
|
case "playemote" -> completions.addAll(EmoteManager.getAllNames());
|
||||||
}
|
}
|
||||||
@@ -91,11 +102,18 @@ public class CosmeticCommandTabComplete implements TabCompleter {
|
|||||||
case "dye" -> {
|
case "dye" -> {
|
||||||
completions.add("#FFFFFF");
|
completions.add("#FFFFFF");
|
||||||
}
|
}
|
||||||
case "menu", "apply", "unapply", "playemote" -> {
|
case "menu", "wardrobe", "apply", "unapply", "playemote" -> {
|
||||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||||
completions.add(player.getName());
|
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);
|
StringUtil.copyPartialMatches(args[2], completions, finalCompletions);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -42,6 +42,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 = "player-move-check";
|
||||||
private static final String HOOK_WG_MOVE_CHECK_PATH_LEGACY = "player_move_check";
|
private static final String HOOK_WG_MOVE_CHECK_PATH_LEGACY = "player_move_check";
|
||||||
private static final String COSMETIC_EMOTE_CHECK_PATH = "emote-block-check";
|
private static final String COSMETIC_EMOTE_CHECK_PATH = "emote-block-check";
|
||||||
|
private static final String COSMETIC_EMOTE_AIR_CHECK_PATH = "emote-air-check";
|
||||||
private static final String COSMETIC_EMOTE_DAMAGE_PATH = "emote-damage-leave";
|
private static final String COSMETIC_EMOTE_DAMAGE_PATH = "emote-damage-leave";
|
||||||
private static final String COSMETIC_EMOTE_INVINCIBLE_PATH = "emote-invincible";
|
private static final String COSMETIC_EMOTE_INVINCIBLE_PATH = "emote-invincible";
|
||||||
private static final String COSMETIC_ADD_ENCHANTS_HELMET_PATH = "helmet-add-enchantments";
|
private static final String COSMETIC_ADD_ENCHANTS_HELMET_PATH = "helmet-add-enchantments";
|
||||||
@@ -70,6 +71,7 @@ public class Settings {
|
|||||||
private static boolean addChestplateEnchants;
|
private static boolean addChestplateEnchants;
|
||||||
private static boolean addLeggingEnchants;
|
private static boolean addLeggingEnchants;
|
||||||
private static boolean addBootsEnchants;
|
private static boolean addBootsEnchants;
|
||||||
|
private static boolean emoteAirCheck;
|
||||||
private static boolean emoteDamageLeave;
|
private static boolean emoteDamageLeave;
|
||||||
private static boolean emoteInvincible;
|
private static boolean emoteInvincible;
|
||||||
private static boolean destroyLooseCosmetics;
|
private static boolean destroyLooseCosmetics;
|
||||||
@@ -105,6 +107,7 @@ public class Settings {
|
|||||||
forcePermissionJoin = cosmeticSettings.node(FORCE_PERMISSION_JOIN_PATH).getBoolean(false);
|
forcePermissionJoin = cosmeticSettings.node(FORCE_PERMISSION_JOIN_PATH).getBoolean(false);
|
||||||
emoteDistance = cosmeticSettings.node(EMOTE_DISTANCE_PATH).getDouble(-3);
|
emoteDistance = cosmeticSettings.node(EMOTE_DISTANCE_PATH).getDouble(-3);
|
||||||
cosmeticEmoteBlockCheck = cosmeticSettings.node(COSMETIC_EMOTE_CHECK_PATH).getBoolean(true);
|
cosmeticEmoteBlockCheck = cosmeticSettings.node(COSMETIC_EMOTE_CHECK_PATH).getBoolean(true);
|
||||||
|
emoteAirCheck = cosmeticSettings.node(COSMETIC_EMOTE_AIR_CHECK_PATH).getBoolean(true);
|
||||||
emoteDamageLeave = cosmeticSettings.node(COSMETIC_EMOTE_DAMAGE_PATH).getBoolean(false);
|
emoteDamageLeave = cosmeticSettings.node(COSMETIC_EMOTE_DAMAGE_PATH).getBoolean(false);
|
||||||
emoteInvincible = cosmeticSettings.node(COSMETIC_EMOTE_INVINCIBLE_PATH).getBoolean(false);
|
emoteInvincible = cosmeticSettings.node(COSMETIC_EMOTE_INVINCIBLE_PATH).getBoolean(false);
|
||||||
destroyLooseCosmetics = cosmeticSettings.node(COSMETIC_DESTROY_LOOSE_COSMETIC_PATH).getBoolean(false);
|
destroyLooseCosmetics = cosmeticSettings.node(COSMETIC_DESTROY_LOOSE_COSMETIC_PATH).getBoolean(false);
|
||||||
@@ -263,6 +266,10 @@ public class Settings {
|
|||||||
return cosmeticEmoteBlockCheck;
|
return cosmeticEmoteBlockCheck;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean getEmoteAirCheck() {
|
||||||
|
return emoteAirCheck;
|
||||||
|
}
|
||||||
|
|
||||||
public static boolean isEmoteDamageLeave() {
|
public static boolean isEmoteDamageLeave() {
|
||||||
return emoteDamageLeave;
|
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.getPlayer().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,9 @@ import org.apache.commons.lang3.EnumUtils;
|
|||||||
import org.bukkit.GameMode;
|
import org.bukkit.GameMode;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.spongepowered.configurate.ConfigurationNode;
|
import org.spongepowered.configurate.ConfigurationNode;
|
||||||
import org.spongepowered.configurate.serialize.SerializationException;
|
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
|
||||||
public class WardrobeSettings {
|
public class WardrobeSettings {
|
||||||
|
|
||||||
@@ -25,14 +27,18 @@ public class WardrobeSettings {
|
|||||||
private static final String APPLY_COSMETICS_ON_CLOSE = "apply-cosmetics-on-close";
|
private static final String APPLY_COSMETICS_ON_CLOSE = "apply-cosmetics-on-close";
|
||||||
private static final String OPEN_SOUND = "open-sound";
|
private static final String OPEN_SOUND = "open-sound";
|
||||||
private static final String CLOSE_SOUND = "close-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 VIEWER_LOCATION_PATH = "viewer-location";
|
||||||
private static final String LEAVE_LOCATION_PATH = "leave-location";
|
private static final String LEAVE_LOCATION_PATH = "leave-location";
|
||||||
private static final String EQUIP_PUMPKIN_WARDROBE = "equip-pumpkin";
|
private static final String EQUIP_PUMPKIN_WARDROBE = "equip-pumpkin";
|
||||||
|
private static final String TRY_COSMETICS_WARDROBE = "unchecked-wardrobe-cosmetics";
|
||||||
private static final String RETURN_LAST_LOCATION = "return-last-location";
|
private static final String RETURN_LAST_LOCATION = "return-last-location";
|
||||||
private static final String GAMEMODE_OPTIONS_PATH = "gamemode-options";
|
private static final String GAMEMODE_OPTIONS_PATH = "gamemode-options";
|
||||||
private static final String FORCE_EXIT_GAMEMODE_PATH = "exit-gamemode-enabled";
|
private static final String FORCE_EXIT_GAMEMODE_PATH = "exit-gamemode-enabled";
|
||||||
private static final String EXIT_GAMEMODE_PATH = "exit-gamemode";
|
private static final String EXIT_GAMEMODE_PATH = "exit-gamemode";
|
||||||
|
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_PATH = "bossbar";
|
||||||
private static final String BOSSBAR_ENABLE_PATH = "enabled";
|
private static final String BOSSBAR_ENABLE_PATH = "enabled";
|
||||||
private static final String BOSSBAR_TEXT_PATH = "text";
|
private static final String BOSSBAR_TEXT_PATH = "text";
|
||||||
@@ -58,14 +64,13 @@ public class WardrobeSettings {
|
|||||||
private static int despawnDelay;
|
private static int despawnDelay;
|
||||||
private static float bossbarProgress;
|
private static float bossbarProgress;
|
||||||
private static boolean applyCosmeticsOnClose;
|
private static boolean applyCosmeticsOnClose;
|
||||||
|
private static boolean tryCosmeticsInWardrobe;
|
||||||
private static boolean equipPumpkin;
|
private static boolean equipPumpkin;
|
||||||
private static boolean returnLastLocation;
|
private static boolean returnLastLocation;
|
||||||
private static boolean enabledBossbar;
|
private static boolean enabledBossbar;
|
||||||
private static boolean forceExitGamemode;
|
private static boolean forceExitGamemode;
|
||||||
private static GameMode exitGamemode;
|
private static GameMode exitGamemode;
|
||||||
private static Location wardrobeLocation;
|
private static HashMap<String, Wardrobe> wardrobes;
|
||||||
private static Location viewerLocation;
|
|
||||||
private static Location leaveLocation;
|
|
||||||
private static String bossbarMessage;
|
private static String bossbarMessage;
|
||||||
private static BossBar.Overlay bossbarOverlay;
|
private static BossBar.Overlay bossbarOverlay;
|
||||||
private static BossBar.Color bossbarColor;
|
private static BossBar.Color bossbarColor;
|
||||||
@@ -90,6 +95,7 @@ public class WardrobeSettings {
|
|||||||
applyCosmeticsOnClose = source.node(APPLY_COSMETICS_ON_CLOSE).getBoolean();
|
applyCosmeticsOnClose = source.node(APPLY_COSMETICS_ON_CLOSE).getBoolean();
|
||||||
equipPumpkin = source.node(EQUIP_PUMPKIN_WARDROBE).getBoolean();
|
equipPumpkin = source.node(EQUIP_PUMPKIN_WARDROBE).getBoolean();
|
||||||
returnLastLocation = source.node(RETURN_LAST_LOCATION).getBoolean(false);
|
returnLastLocation = source.node(RETURN_LAST_LOCATION).getBoolean(false);
|
||||||
|
tryCosmeticsInWardrobe = source.node(TRY_COSMETICS_WARDROBE).getBoolean(false);
|
||||||
|
|
||||||
ConfigurationNode gamemodeNode = source.node(GAMEMODE_OPTIONS_PATH);
|
ConfigurationNode gamemodeNode = source.node(GAMEMODE_OPTIONS_PATH);
|
||||||
forceExitGamemode = gamemodeNode.node(FORCE_EXIT_GAMEMODE_PATH).getBoolean(false);
|
forceExitGamemode = gamemodeNode.node(FORCE_EXIT_GAMEMODE_PATH).getBoolean(false);
|
||||||
@@ -119,15 +125,35 @@ public class WardrobeSettings {
|
|||||||
transitionStay = transitionNode.node(TRANSITION_STAY_PATH).getInt(2000);
|
transitionStay = transitionNode.node(TRANSITION_STAY_PATH).getInt(2000);
|
||||||
transitionFadeOut = transitionNode.node(TRANSITION_FADE_OUT_PATH).getInt(2000);
|
transitionFadeOut = transitionNode.node(TRANSITION_FADE_OUT_PATH).getInt(2000);
|
||||||
|
|
||||||
try {
|
wardrobes = new HashMap<>();
|
||||||
wardrobeLocation = LocationSerializer.INSTANCE.deserialize(Location.class, source.node(STATIC_LOCATION_PATH));
|
for (ConfigurationNode wardrobesNode : source.node(WARDROBES_PATH).childrenMap().values()) {
|
||||||
MessagesUtil.sendDebugMessages("Wardrobe Location: " + wardrobeLocation);
|
String id = wardrobesNode.key().toString();
|
||||||
viewerLocation = LocationSerializer.INSTANCE.deserialize(Location.class, source.node(VIEWER_LOCATION_PATH));
|
try {
|
||||||
MessagesUtil.sendDebugMessages("Viewer Location: " + viewerLocation);
|
Location npcLocation = LocationSerializer.INSTANCE.deserialize(Location.class, wardrobesNode.node(NPC_LOCATION_PATH));
|
||||||
leaveLocation = Utils.replaceIfNull(LocationSerializer.INSTANCE.deserialize(Location.class, source.node(LEAVE_LOCATION_PATH)), viewerLocation);
|
MessagesUtil.sendDebugMessages("Wardrobe Location: " + npcLocation);
|
||||||
} catch (SerializationException e) {
|
Location viewerLocation = LocationSerializer.INSTANCE.deserialize(Location.class, wardrobesNode.node(VIEWER_LOCATION_PATH));
|
||||||
throw new RuntimeException(e);
|
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() {
|
public static boolean getDisableOnDamage() {
|
||||||
@@ -172,25 +198,36 @@ public class WardrobeSettings {
|
|||||||
return returnLastLocation;
|
return returnLastLocation;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Location getWardrobeLocation() {
|
public static Wardrobe getWardrobe(String key) {
|
||||||
return wardrobeLocation.clone();
|
return wardrobes.get(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Location getViewerLocation() {
|
public static Set<String> getWardrobeNames() {
|
||||||
return viewerLocation;
|
return wardrobes.keySet();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Location getLeaveLocation() {
|
public static Collection<Wardrobe> getWardrobes() {
|
||||||
return leaveLocation;
|
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) {
|
public static boolean inDistanceOfWardrobe(final Location wardrobeLocation, final Location playerLocation) {
|
||||||
if (displayRadius == -1) return true;
|
if (displayRadius == -1) return true;
|
||||||
if (!wardrobeLocation.getWorld().equals(playerLocation.getWorld())) return false;
|
if (!wardrobeLocation.getWorld().equals(playerLocation.getWorld())) return false;
|
||||||
return playerLocation.distanceSquared(wardrobeLocation) <= displayRadius * displayRadius;
|
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 (wardrobeLocation == null) return false;
|
||||||
if (staticRadius == -1) return true;
|
if (staticRadius == -1) return true;
|
||||||
if (!wardrobeLocation.getWorld().equals(location.getWorld())) return false;
|
if (!wardrobeLocation.getWorld().equals(location.getWorld())) return false;
|
||||||
@@ -245,57 +282,84 @@ public class WardrobeSettings {
|
|||||||
return exitGamemode;
|
return exitGamemode;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setWardrobeLocation(Location newLocation) {
|
public static boolean isTryCosmeticsInWardrobe() {
|
||||||
wardrobeLocation = newLocation;
|
return tryCosmeticsInWardrobe;
|
||||||
|
|
||||||
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 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();
|
HMCCosmeticsPlugin plugin = HMCCosmeticsPlugin.getInstance();
|
||||||
|
|
||||||
plugin.getConfig().set("wardrobe.viewer-location." + "world", newLocation.getWorld().getName());
|
plugin.getConfig().set("wardrobe.wardrobes." + wardrobe.getId() + ".npc-location." + "world", newLocation.getWorld().getName());
|
||||||
plugin.getConfig().set("wardrobe.viewer-location." + "x", newLocation.getX());
|
plugin.getConfig().set("wardrobe.wardrobes." + wardrobe.getId() + ".npc-location." + "x", newLocation.getX());
|
||||||
plugin.getConfig().set("wardrobe.viewer-location." + "y", newLocation.getY());
|
plugin.getConfig().set("wardrobe.wardrobes." + wardrobe.getId() + ".npc-location." + "y", newLocation.getY());
|
||||||
plugin.getConfig().set("wardrobe.viewer-location." + "z", newLocation.getZ());
|
plugin.getConfig().set("wardrobe.wardrobes." + wardrobe.getId() + ".npc-location." + "z", newLocation.getZ());
|
||||||
plugin.getConfig().set("wardrobe.viewer-location." + "yaw", newLocation.getYaw());
|
plugin.getConfig().set("wardrobe.wardrobes." + wardrobe.getId() + ".npc-location." + "yaw", newLocation.getYaw());
|
||||||
plugin.getConfig().set("wardrobe.viewer-location." + "pitch", newLocation.getPitch());
|
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();
|
HMCCosmeticsPlugin plugin = HMCCosmeticsPlugin.getInstance();
|
||||||
|
|
||||||
plugin.getConfig().set("wardrobe.leave-location." + "world", newLocation.getWorld().getName());
|
plugin.getConfig().set("wardrobe.wardrobes." + wardrobe.getId() + ".viewer-location.world", newLocation.getWorld().getName());
|
||||||
plugin.getConfig().set("wardrobe.leave-location." + "x", newLocation.getX());
|
plugin.getConfig().set("wardrobe.wardrobes." + wardrobe.getId() + ".viewer-location.x", newLocation.getX());
|
||||||
plugin.getConfig().set("wardrobe.leave-location." + "y", newLocation.getY());
|
plugin.getConfig().set("wardrobe.wardrobes." + wardrobe.getId() + ".viewer-location.y", newLocation.getY());
|
||||||
plugin.getConfig().set("wardrobe.leave-location." + "z", newLocation.getZ());
|
plugin.getConfig().set("wardrobe.wardrobes." + wardrobe.getId() + ".viewer-location.z", newLocation.getZ());
|
||||||
plugin.getConfig().set("wardrobe.leave-location." + "yaw", newLocation.getYaw());
|
plugin.getConfig().set("wardrobe.wardrobes." + wardrobe.getId() + ".viewer-location.yaw", newLocation.getYaw());
|
||||||
plugin.getConfig().set("wardrobe.leave-location." + "pitch", newLocation.getPitch());
|
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();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ public class CosmeticArmorType extends Cosmetic {
|
|||||||
public void update(@NotNull CosmeticUser user) {
|
public void update(@NotNull CosmeticUser user) {
|
||||||
Player player = Bukkit.getPlayer(user.getUniqueId());
|
Player player = Bukkit.getPlayer(user.getUniqueId());
|
||||||
if (player == null) return;
|
if (player == null) return;
|
||||||
|
if (user.getUserEmoteManager().isPlayingEmote()) return; // There has to be a better way of doing this...
|
||||||
ItemStack cosmeticItem = user.getUserCosmeticItem(this);
|
ItemStack cosmeticItem = user.getUserCosmeticItem(this);
|
||||||
if (equipSlot.equals(EquipmentSlot.OFF_HAND)) {
|
if (equipSlot.equals(EquipmentSlot.OFF_HAND)) {
|
||||||
if (!player.getInventory().getItemInOffHand().getType().isAir()) return;
|
if (!player.getInventory().getItemInOffHand().getType().isAir()) return;
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ public class CosmeticBackpackType extends Cosmetic {
|
|||||||
|
|
||||||
if (user.isInWardrobe() || !user.isBackpackSpawned()) return;
|
if (user.isInWardrobe() || !user.isBackpackSpawned()) return;
|
||||||
if (!user.getUserBackpackManager().getArmorStand().isValid()) {
|
if (!user.getUserBackpackManager().getArmorStand().isValid()) {
|
||||||
MessagesUtil.sendDebugMessages("Invalid Backpack detected! Respawning backpack, report this on the discord if this happens often!", Level.WARNING);
|
MessagesUtil.sendDebugMessages("Invalid Backpack Entity[owner=" + user.getUniqueId() + ",player_location=" + loc + "]!", Level.WARNING);
|
||||||
user.respawnBackpack();
|
user.respawnBackpack();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,11 +9,13 @@ import org.spongepowered.configurate.ConfigurationNode;
|
|||||||
public class CosmeticEmoteType extends Cosmetic {
|
public class CosmeticEmoteType extends Cosmetic {
|
||||||
|
|
||||||
private final String animationId;
|
private final String animationId;
|
||||||
|
private final String text;
|
||||||
|
|
||||||
public CosmeticEmoteType(String id, ConfigurationNode config) {
|
public CosmeticEmoteType(String id, ConfigurationNode config) {
|
||||||
super(id, config);
|
super(id, config);
|
||||||
|
|
||||||
animationId = config.node("animation").getString();
|
animationId = config.node("animation").getString();
|
||||||
|
text = config.node("text").getString();
|
||||||
MessagesUtil.sendDebugMessages("CosmeticEmoteType Animation id " + animationId);
|
MessagesUtil.sendDebugMessages("CosmeticEmoteType Animation id " + animationId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -29,4 +31,8 @@ public class CosmeticEmoteType extends Cosmetic {
|
|||||||
public String getAnimationId() {
|
public String getAnimationId() {
|
||||||
return animationId;
|
return animationId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getText() {
|
||||||
|
return text;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -77,26 +77,21 @@ public class Menu {
|
|||||||
|
|
||||||
gui.setDefaultClickAction(event -> event.setCancelled(true));
|
gui.setDefaultClickAction(event -> event.setCancelled(true));
|
||||||
|
|
||||||
|
// TODO: Redo this whole gui creation process to allow for all items, possibly implement caching
|
||||||
gui = getItems(user, gui);
|
gui = getItems(user, gui);
|
||||||
|
final Gui finalGui = gui; // Need to make it final for the runtask
|
||||||
|
|
||||||
Gui finalGui = gui;
|
// API
|
||||||
|
|
||||||
PlayerMenuOpenEvent event = new PlayerMenuOpenEvent(user, this);
|
PlayerMenuOpenEvent event = new PlayerMenuOpenEvent(user, this);
|
||||||
|
|
||||||
Bukkit.getScheduler().runTask(HMCCosmeticsPlugin.getInstance(), () -> {
|
Bukkit.getScheduler().runTask(HMCCosmeticsPlugin.getInstance(), () -> {
|
||||||
Bukkit.getPluginManager().callEvent(event);
|
Bukkit.getPluginManager().callEvent(event);
|
||||||
});
|
});
|
||||||
|
if (event.isCancelled()) return;
|
||||||
if (event.isCancelled()) {
|
// Internal
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Bukkit.getScheduler().runTask(HMCCosmeticsPlugin.getInstance(), () -> {
|
Bukkit.getScheduler().runTask(HMCCosmeticsPlugin.getInstance(), () -> {
|
||||||
finalGui.open(player);
|
finalGui.open(player);
|
||||||
});
|
});
|
||||||
|
|
||||||
//gui.open(player);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Contract("_, _ -> param2")
|
@Contract("_, _ -> param2")
|
||||||
@@ -105,7 +100,7 @@ public class Menu {
|
|||||||
|
|
||||||
for (ConfigurationNode config : config.node("items").childrenMap().values()) {
|
for (ConfigurationNode config : config.node("items").childrenMap().values()) {
|
||||||
|
|
||||||
List<String> slotString = null;
|
List<String> slotString;
|
||||||
try {
|
try {
|
||||||
slotString = config.node("slots").getList(String.class);
|
slotString = config.node("slots").getList(String.class);
|
||||||
} catch (SerializationException e) {
|
} catch (SerializationException e) {
|
||||||
@@ -126,7 +121,6 @@ public class Menu {
|
|||||||
ItemStack item;
|
ItemStack item;
|
||||||
try {
|
try {
|
||||||
item = ItemSerializer.INSTANCE.deserialize(ItemStack.class, config.node("item"));
|
item = ItemSerializer.INSTANCE.deserialize(ItemStack.class, config.node("item"));
|
||||||
//item = config.node("item").get(ItemStack.class);
|
|
||||||
} catch (SerializationException e) {
|
} catch (SerializationException e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
@@ -144,17 +138,17 @@ public class Menu {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (int slot : slots) {
|
for (int slot : slots) {
|
||||||
ItemStack originalItem = updateItem(user, item, type, config, slot).clone();
|
ItemStack modifiedItem = getMenuItem(user, type, config, item.clone(), slot).clone();
|
||||||
GuiItem guiItem = ItemBuilder.from(originalItem).asGuiItem();
|
GuiItem guiItem = ItemBuilder.from(modifiedItem).asGuiItem();
|
||||||
|
|
||||||
Type finalType = type;
|
Type finalType = type;
|
||||||
guiItem.setAction(event -> {
|
guiItem.setAction(event -> {
|
||||||
MessagesUtil.sendDebugMessages("Selected slot " + slot);
|
MessagesUtil.sendDebugMessages("Selected slot " + slot);
|
||||||
final ClickType clickType = event.getClick();
|
final ClickType clickType = event.getClick();
|
||||||
if (finalType != null) finalType.run(user, config, clickType);
|
if (finalType != null) finalType.run(user, config, clickType);
|
||||||
|
// Need to delay the update by a tick so it will actually update with new values
|
||||||
for (int guiSlot : slots) {
|
for (int guiSlot : slots) {
|
||||||
gui.updateItem(guiSlot, updateItem(user, originalItem.clone(), finalType, config, guiSlot));
|
gui.updateItem(guiSlot, getMenuItem(user, finalType, config, item.clone(), guiSlot));
|
||||||
}
|
}
|
||||||
MessagesUtil.sendDebugMessages("Updated slot " + slot);
|
MessagesUtil.sendDebugMessages("Updated slot " + slot);
|
||||||
});
|
});
|
||||||
@@ -194,11 +188,9 @@ public class Menu {
|
|||||||
|
|
||||||
@Contract("_, _, _, _ -> param2")
|
@Contract("_, _, _, _ -> param2")
|
||||||
@NotNull
|
@NotNull
|
||||||
private ItemStack updateItem(CosmeticUser user, @NotNull ItemStack itemStack, Type type, ConfigurationNode config, int slot) {
|
private ItemStack getMenuItem(CosmeticUser user, Type type, ConfigurationNode config, ItemStack itemStack, int slot) {
|
||||||
if (itemStack.hasItemMeta()) {
|
if (!itemStack.hasItemMeta()) return itemStack;
|
||||||
itemStack = type.setItem(user, config, itemStack, slot);
|
return type.setItem(user, config, itemStack, slot);
|
||||||
}
|
|
||||||
return itemStack;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getPermissionNode() {
|
public String getPermissionNode() {
|
||||||
|
|||||||
@@ -56,6 +56,10 @@ public class Menus {
|
|||||||
return names;
|
return names;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Collection<Menu> values() {
|
||||||
|
return MENUS.values();
|
||||||
|
}
|
||||||
|
|
||||||
public static void setup() {
|
public static void setup() {
|
||||||
MENUS.clear();
|
MENUS.clear();
|
||||||
|
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ public class TypeCosmetic extends Type {
|
|||||||
if (!actionConfig.node("on-equip").virtual()) actionStrings.addAll(actionConfig.node("on-equip").getList(String.class));
|
if (!actionConfig.node("on-equip").virtual()) actionStrings.addAll(actionConfig.node("on-equip").getList(String.class));
|
||||||
MessagesUtil.sendDebugMessages("on-equip");
|
MessagesUtil.sendDebugMessages("on-equip");
|
||||||
// TODO: Redo this
|
// TODO: Redo this
|
||||||
if (cosmetic.isDyable()) {
|
if (cosmetic.isDyable() && Hooks.isActiveHook("HMCColor")) {
|
||||||
DyeMenu.openMenu(user, cosmetic);
|
DyeMenu.openMenu(user, cosmetic);
|
||||||
} else {
|
} else {
|
||||||
user.addPlayerCosmetic(cosmetic);
|
user.addPlayerCosmetic(cosmetic);
|
||||||
@@ -92,7 +92,6 @@ public class TypeCosmetic extends Type {
|
|||||||
if (cosmetic instanceof CosmeticArmorType) {
|
if (cosmetic instanceof CosmeticArmorType) {
|
||||||
if (((CosmeticArmorType) cosmetic).getEquipSlot().equals(EquipmentSlot.OFF_HAND)) {
|
if (((CosmeticArmorType) cosmetic).getEquipSlot().equals(EquipmentSlot.OFF_HAND)) {
|
||||||
Bukkit.getScheduler().runTaskLater(HMCCosmeticsPlugin.getInstance(), run, 1);
|
Bukkit.getScheduler().runTaskLater(HMCCosmeticsPlugin.getInstance(), run, 1);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
run.run();
|
run.run();
|
||||||
@@ -100,20 +99,19 @@ public class TypeCosmetic extends Type {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ItemStack setItem(CosmeticUser user, @NotNull ConfigurationNode config, ItemStack itemStack, int slot) {
|
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()) {
|
if (config.node("cosmetic").virtual()) {
|
||||||
itemStack.setItemMeta(processLoreLines(user, itemMeta));
|
|
||||||
return itemStack;
|
return itemStack;
|
||||||
};
|
}
|
||||||
String cosmeticName = config.node("cosmetic").getString();
|
String cosmeticName = config.node("cosmetic").getString();
|
||||||
Cosmetic cosmetic = Cosmetics.getCosmetic(cosmeticName);
|
Cosmetic cosmetic = Cosmetics.getCosmetic(cosmeticName);
|
||||||
if (cosmetic == null) {
|
if (cosmetic == null) {
|
||||||
itemStack.setItemMeta(processLoreLines(user, itemMeta));
|
|
||||||
return itemStack;
|
return itemStack;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (user.hasCosmeticInSlot(cosmetic) && !config.node("equipped-item").virtual()) {
|
if (user.hasCosmeticInSlot(cosmetic) && !config.node("equipped-item").virtual()) {
|
||||||
|
MessagesUtil.sendDebugMessages("GUI Equipped Item");
|
||||||
ConfigurationNode equippedItem = config.node("equipped-item");
|
ConfigurationNode equippedItem = config.node("equipped-item");
|
||||||
try {
|
try {
|
||||||
if (equippedItem.node("material").virtual()) equippedItem.node("material").set(config.node("item", "material").getString());
|
if (equippedItem.node("material").virtual()) equippedItem.node("material").set(config.node("item", "material").getString());
|
||||||
@@ -125,10 +123,12 @@ public class TypeCosmetic extends Type {
|
|||||||
} catch (SerializationException e) {
|
} catch (SerializationException e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
|
itemStack.setItemMeta(processLoreLines(user, itemStack.getItemMeta()));
|
||||||
return itemStack;
|
return itemStack;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!user.canEquipCosmetic(cosmetic) && !config.node("locked-item").virtual()) {
|
if (!user.canEquipCosmetic(cosmetic) && !config.node("locked-item").virtual()) {
|
||||||
|
MessagesUtil.sendDebugMessages("GUI Locked Item");
|
||||||
ConfigurationNode lockedItem = config.node("locked-item");
|
ConfigurationNode lockedItem = config.node("locked-item");
|
||||||
try {
|
try {
|
||||||
if (lockedItem.node("material").virtual()) lockedItem.node("material").set(config.node("item", "material").getString());
|
if (lockedItem.node("material").virtual()) lockedItem.node("material").set(config.node("item", "material").getString());
|
||||||
@@ -137,10 +137,10 @@ public class TypeCosmetic extends Type {
|
|||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
itemStack = ItemSerializer.INSTANCE.deserialize(ItemStack.class, lockedItem);
|
itemStack = ItemSerializer.INSTANCE.deserialize(ItemStack.class, lockedItem);
|
||||||
//item = config.node("item").get(ItemStack.class);
|
|
||||||
} catch (SerializationException e) {
|
} catch (SerializationException e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
|
itemStack.setItemMeta(processLoreLines(user, itemStack.getItemMeta()));
|
||||||
return itemStack;
|
return itemStack;
|
||||||
}
|
}
|
||||||
return itemStack;
|
return itemStack;
|
||||||
@@ -154,12 +154,10 @@ public class TypeCosmetic extends Type {
|
|||||||
|
|
||||||
if (itemMeta.hasLore()) {
|
if (itemMeta.hasLore()) {
|
||||||
for (String loreLine : itemMeta.getLore()) {
|
for (String loreLine : itemMeta.getLore()) {
|
||||||
if (Hooks.isActiveHook("PlaceholderAPI"))
|
if (Hooks.isActiveHook("PlaceholderAPI")) loreLine = PlaceholderAPI.setPlaceholders(user.getPlayer(), loreLine);
|
||||||
loreLine = PlaceholderAPI.setPlaceholders(user.getPlayer(), loreLine);
|
|
||||||
processedLore.add(loreLine);
|
processedLore.add(loreLine);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
itemMeta.setLore(processedLore);
|
itemMeta.setLore(processedLore);
|
||||||
return itemMeta;
|
return itemMeta;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ public class Hooks {
|
|||||||
private static final HashMap<String, Hook> hooks = new HashMap<>();
|
private static final HashMap<String, Hook> hooks = new HashMap<>();
|
||||||
private static HookOraxen ORAXEN_HOOK = new HookOraxen();
|
private static HookOraxen ORAXEN_HOOK = new HookOraxen();
|
||||||
private static HookItemAdder ITEMADDER_HOOK = new HookItemAdder();
|
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 HookMythic MYTHIC_HOOK = new HookMythic();
|
||||||
private static HookDenizen DENIZEN_HOOK = new HookDenizen();
|
private static HookDenizen DENIZEN_HOOK = new HookDenizen();
|
||||||
private static HookHMCCosmetics HMCCOSMETIC_HOOK = new HookHMCCosmetics();
|
private static HookHMCCosmetics HMCCOSMETIC_HOOK = new HookHMCCosmetics();
|
||||||
|
|||||||
@@ -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.getItemTracking().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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -110,11 +110,15 @@ public class HMCPlaceholderExpansion extends PlaceholderExpansion {
|
|||||||
if (placeholderArgs.get(1) != null) {
|
if (placeholderArgs.get(1) != null) {
|
||||||
Cosmetic cosmetic = Cosmetics.getCosmetic(placeholderArgs.get(1));
|
Cosmetic cosmetic = Cosmetics.getCosmetic(placeholderArgs.get(1));
|
||||||
if (cosmetic == null) {
|
if (cosmetic == null) {
|
||||||
Cosmetic secondAttemptCosmetic = Cosmetics.getCosmetic(placeholderArgs.get(1) + "_" + placeholderArgs.get(2));
|
if (placeholderArgs.size() >= 3) {
|
||||||
if (secondAttemptCosmetic == null) {
|
Cosmetic secondAttemptCosmetic = Cosmetics.getCosmetic(placeholderArgs.get(1) + "_" + placeholderArgs.get(2));
|
||||||
return "INVALID_COSMETIC";
|
if (secondAttemptCosmetic == null) {
|
||||||
|
return "INVALID_COSMETIC";
|
||||||
|
} else {
|
||||||
|
cosmetic = secondAttemptCosmetic;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
cosmetic = secondAttemptCosmetic;
|
return "INVALID_COSMETIC";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return TranslationUtil.getTranslation("unlockedCosmetic", String.valueOf(user.canEquipCosmetic(cosmetic)));
|
return TranslationUtil.getTranslation("unlockedCosmetic", String.valueOf(user.canEquipCosmetic(cosmetic)));
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
|||||||
import com.sk89q.worldguard.WorldGuard;
|
import com.sk89q.worldguard.WorldGuard;
|
||||||
import com.sk89q.worldguard.protection.flags.Flag;
|
import com.sk89q.worldguard.protection.flags.Flag;
|
||||||
import com.sk89q.worldguard.protection.flags.StateFlag;
|
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.FlagConflictException;
|
||||||
import com.sk89q.worldguard.protection.flags.registry.FlagRegistry;
|
import com.sk89q.worldguard.protection.flags.registry.FlagRegistry;
|
||||||
|
|
||||||
@@ -21,13 +22,13 @@ public class WGHook {
|
|||||||
/**
|
/**
|
||||||
* @implNote Please use {@link #getCosmeticWardrobeFlag()} instead
|
* @implNote Please use {@link #getCosmeticWardrobeFlag()} instead
|
||||||
*/
|
*/
|
||||||
public static StateFlag COSMETIC_WARDROBE_FLAG;
|
public static StringFlag COSMETIC_WARDROBE_FLAG;
|
||||||
|
|
||||||
public WGHook() {
|
public WGHook() {
|
||||||
FlagRegistry registry = WorldGuard.getInstance().getFlagRegistry();
|
FlagRegistry registry = WorldGuard.getInstance().getFlagRegistry();
|
||||||
try {
|
try {
|
||||||
StateFlag cosmeticFlag = new StateFlag("cosmetic-enable", false);
|
StateFlag cosmeticFlag = new StateFlag("cosmetic-enable", false);
|
||||||
StateFlag wardrobeFlag = new StateFlag("cosmetic-wardrobe", false);
|
StringFlag wardrobeFlag = new StringFlag("cosmetic-wardrobe");
|
||||||
registry.register(cosmeticFlag);
|
registry.register(cosmeticFlag);
|
||||||
registry.register(wardrobeFlag);
|
registry.register(wardrobeFlag);
|
||||||
COSMETIC_ENABLE_FLAG = cosmeticFlag;
|
COSMETIC_ENABLE_FLAG = cosmeticFlag;
|
||||||
@@ -56,7 +57,7 @@ public class WGHook {
|
|||||||
* Gets the cosmetic wardrobe {@link StateFlag}
|
* Gets the cosmetic wardrobe {@link StateFlag}
|
||||||
* @return The cosmetic wardrobe {@link StateFlag}
|
* @return The cosmetic wardrobe {@link StateFlag}
|
||||||
*/
|
*/
|
||||||
public static StateFlag getCosmeticWardrobeFlag() {
|
public static StringFlag getCosmeticWardrobeFlag() {
|
||||||
return COSMETIC_WARDROBE_FLAG;
|
return COSMETIC_WARDROBE_FLAG;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,10 @@
|
|||||||
package com.hibiscusmc.hmccosmetics.hooks.worldguard;
|
package com.hibiscusmc.hmccosmetics.hooks.worldguard;
|
||||||
|
|
||||||
|
import com.hibiscusmc.hmccosmetics.config.Wardrobe;
|
||||||
|
import com.hibiscusmc.hmccosmetics.config.WardrobeSettings;
|
||||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUsers;
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUsers;
|
||||||
|
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||||
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
||||||
import com.sk89q.worldguard.WorldGuard;
|
import com.sk89q.worldguard.WorldGuard;
|
||||||
import com.sk89q.worldguard.protection.ApplicableRegionSet;
|
import com.sk89q.worldguard.protection.ApplicableRegionSet;
|
||||||
@@ -34,13 +37,17 @@ public class WGListener implements Listener {
|
|||||||
}
|
}
|
||||||
for (ProtectedRegion protectedRegion : set.getRegions()) {
|
for (ProtectedRegion protectedRegion : set.getRegions()) {
|
||||||
if (protectedRegion.getFlags().containsKey(WGHook.getCosmeticEnableFlag())) {
|
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);
|
user.hideCosmetics(CosmeticUser.HiddenReason.WORLDGUARD);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (protectedRegion.getFlags().containsKey(WGHook.getCosmeticWardrobeFlag())) {
|
if (protectedRegion.getFlags().containsKey(WGHook.getCosmeticWardrobeFlag())) {
|
||||||
if (!protectedRegion.getFlags().get(WGHook.getCosmeticWardrobeFlag()).toString().equalsIgnoreCase("ALLOW")) return;
|
if (!WardrobeSettings.getWardrobeNames().contains(protectedRegion.getFlags().get(WGHook.getCosmeticWardrobeFlag()).toString())) return;
|
||||||
user.enterWardrobe();
|
Wardrobe wardrobe = WardrobeSettings.getWardrobe(protectedRegion.getFlags().get(WGHook.getCosmeticWardrobeFlag()).toString());
|
||||||
|
user.enterWardrobe(true, wardrobe);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,8 @@ import com.comphenix.protocol.events.PacketEvent;
|
|||||||
import com.comphenix.protocol.wrappers.EnumWrappers;
|
import com.comphenix.protocol.wrappers.EnumWrappers;
|
||||||
import com.comphenix.protocol.wrappers.Pair;
|
import com.comphenix.protocol.wrappers.Pair;
|
||||||
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
|
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
|
||||||
|
import com.hibiscusmc.hmccosmetics.api.PlayerCosmeticEquipEvent;
|
||||||
|
import com.hibiscusmc.hmccosmetics.api.PlayerCosmeticPostEquipEvent;
|
||||||
import com.hibiscusmc.hmccosmetics.config.Settings;
|
import com.hibiscusmc.hmccosmetics.config.Settings;
|
||||||
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
|
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
|
||||||
import com.hibiscusmc.hmccosmetics.cosmetic.CosmeticSlot;
|
import com.hibiscusmc.hmccosmetics.cosmetic.CosmeticSlot;
|
||||||
@@ -23,7 +25,9 @@ import com.hibiscusmc.hmccosmetics.user.CosmeticUsers;
|
|||||||
import com.hibiscusmc.hmccosmetics.user.manager.UserEmoteManager;
|
import com.hibiscusmc.hmccosmetics.user.manager.UserEmoteManager;
|
||||||
import com.hibiscusmc.hmccosmetics.util.InventoryUtils;
|
import com.hibiscusmc.hmccosmetics.util.InventoryUtils;
|
||||||
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||||
|
import com.hibiscusmc.hmccosmetics.util.packets.PacketManager;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.NamespacedKey;
|
import org.bukkit.NamespacedKey;
|
||||||
import org.bukkit.enchantments.Enchantment;
|
import org.bukkit.enchantments.Enchantment;
|
||||||
@@ -112,13 +116,10 @@ public class PlayerGameListener implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (user.hasCosmeticInSlot(CosmeticSlot.BACKPACK) && user.getUserBackpackManager() != null) {
|
if (user.hasCosmeticInSlot(CosmeticSlot.BACKPACK) && user.getUserBackpackManager() != null) {
|
||||||
user.getUserBackpackManager().hideBackpack();
|
|
||||||
|
|
||||||
user.getUserBackpackManager().getArmorStand().teleport(event.getTo());
|
|
||||||
|
|
||||||
Bukkit.getScheduler().runTaskLater(HMCCosmeticsPlugin.getInstance(), () -> {
|
Bukkit.getScheduler().runTaskLater(HMCCosmeticsPlugin.getInstance(), () -> {
|
||||||
|
user.respawnBackpack();
|
||||||
user.updateCosmetic();
|
user.updateCosmetic();
|
||||||
}, 2);
|
}, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (event.getCause().equals(PlayerTeleportEvent.TeleportCause.NETHER_PORTAL) || event.getCause().equals(PlayerTeleportEvent.TeleportCause.END_PORTAL)) return;
|
if (event.getCause().equals(PlayerTeleportEvent.TeleportCause.NETHER_PORTAL) || event.getCause().equals(PlayerTeleportEvent.TeleportCause.END_PORTAL)) return;
|
||||||
@@ -349,6 +350,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() {
|
private void registerInventoryClickListener() {
|
||||||
ProtocolLibrary.getProtocolManager().addPacketListener(new PacketAdapter(HMCCosmeticsPlugin.getInstance(), ListenerPriority.NORMAL, PacketType.Play.Client.WINDOW_CLICK) {
|
ProtocolLibrary.getProtocolManager().addPacketListener(new PacketAdapter(HMCCosmeticsPlugin.getInstance(), ListenerPriority.NORMAL, PacketType.Play.Client.WINDOW_CLICK) {
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticBackpackType;
|
|||||||
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticBalloonType;
|
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticBalloonType;
|
||||||
import com.hibiscusmc.hmccosmetics.user.manager.UserBalloonManager;
|
import com.hibiscusmc.hmccosmetics.user.manager.UserBalloonManager;
|
||||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||||
|
import net.kyori.adventure.text.Component;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.entity.ArmorStand;
|
import org.bukkit.entity.ArmorStand;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
@@ -27,6 +28,8 @@ public interface NMSHandler {
|
|||||||
|
|
||||||
Entity spawnHMCParticleCloud(Location location);
|
Entity spawnHMCParticleCloud(Location location);
|
||||||
|
|
||||||
|
Entity spawnDisplayEntity(Location location, String text);
|
||||||
|
|
||||||
UserBalloonManager spawnBalloon(CosmeticUser user, CosmeticBalloonType cosmeticBalloonType);
|
UserBalloonManager spawnBalloon(CosmeticUser user, CosmeticBalloonType cosmeticBalloonType);
|
||||||
|
|
||||||
void equipmentSlotUpdate(
|
void equipmentSlotUpdate(
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import java.util.logging.Level;
|
|||||||
|
|
||||||
public class NMSHandlers {
|
public class NMSHandlers {
|
||||||
|
|
||||||
private static final String[] SUPPORTED_VERSION = new String[]{"v1_17_R1", "v1_18_R2", "v1_19_R1", "v1_19_R2", "v1_19_R3"};
|
private static final String[] SUPPORTED_VERSION = new String[]{"v1_17_R1", "v1_18_R2", "v1_19_R1", "v1_19_R2", "v1_19_R3", "v1_20_R1"};
|
||||||
private static NMSHandler handler;
|
private static NMSHandler handler;
|
||||||
private static String version;
|
private static String version;
|
||||||
|
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import com.google.common.collect.ImmutableList;
|
|||||||
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
|
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
|
||||||
import com.hibiscusmc.hmccosmetics.api.*;
|
import com.hibiscusmc.hmccosmetics.api.*;
|
||||||
import com.hibiscusmc.hmccosmetics.config.Settings;
|
import com.hibiscusmc.hmccosmetics.config.Settings;
|
||||||
|
import com.hibiscusmc.hmccosmetics.config.Wardrobe;
|
||||||
import com.hibiscusmc.hmccosmetics.config.WardrobeSettings;
|
import com.hibiscusmc.hmccosmetics.config.WardrobeSettings;
|
||||||
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
|
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
|
||||||
import com.hibiscusmc.hmccosmetics.cosmetic.CosmeticSlot;
|
import com.hibiscusmc.hmccosmetics.cosmetic.CosmeticSlot;
|
||||||
@@ -30,7 +31,7 @@ import java.util.logging.Level;
|
|||||||
|
|
||||||
public class CosmeticUser {
|
public class CosmeticUser {
|
||||||
|
|
||||||
private UUID uniqueId;
|
private final UUID uniqueId;
|
||||||
private int taskId;
|
private int taskId;
|
||||||
private HashMap<CosmeticSlot, Cosmetic> playerCosmetics = new HashMap<>();
|
private HashMap<CosmeticSlot, Cosmetic> playerCosmetics = new HashMap<>();
|
||||||
private UserWardrobeManager userWardrobeManager;
|
private UserWardrobeManager userWardrobeManager;
|
||||||
@@ -115,6 +116,9 @@ public class CosmeticUser {
|
|||||||
CosmeticBalloonType balloonType = (CosmeticBalloonType) cosmetic;
|
CosmeticBalloonType balloonType = (CosmeticBalloonType) cosmetic;
|
||||||
spawnBalloon(balloonType);
|
spawnBalloon(balloonType);
|
||||||
}
|
}
|
||||||
|
// API
|
||||||
|
PlayerCosmeticPostEquipEvent postEquipEvent = new PlayerCosmeticPostEquipEvent(this, cosmetic);
|
||||||
|
Bukkit.getPluginManager().callEvent(postEquipEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removeCosmetics() {
|
public void removeCosmetics() {
|
||||||
@@ -140,7 +144,7 @@ public class CosmeticUser {
|
|||||||
despawnBalloon();
|
despawnBalloon();
|
||||||
}
|
}
|
||||||
if (slot == CosmeticSlot.EMOTE) {
|
if (slot == CosmeticSlot.EMOTE) {
|
||||||
|
if (getUserEmoteManager().isPlayingEmote()) getUserEmoteManager().stopEmote(UserEmoteManager.StopEmoteReason.UNEQUIP);
|
||||||
}
|
}
|
||||||
colors.remove(slot);
|
colors.remove(slot);
|
||||||
playerCosmetics.remove(slot);
|
playerCosmetics.remove(slot);
|
||||||
@@ -158,10 +162,7 @@ public class CosmeticUser {
|
|||||||
|
|
||||||
public boolean hasCosmeticInSlot(Cosmetic cosmetic) {
|
public boolean hasCosmeticInSlot(Cosmetic cosmetic) {
|
||||||
if (getCosmetic(cosmetic.getSlot()) == null) return false;
|
if (getCosmetic(cosmetic.getSlot()) == null) return false;
|
||||||
if (cosmetic.getId() == getCosmetic(cosmetic.getSlot()).getId()) {
|
return Objects.equals(cosmetic.getId(), getCosmetic(cosmetic.getSlot()).getId());
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Set<CosmeticSlot> getSlotsWithCosmetics() {
|
public Set<CosmeticSlot> getSlotsWithCosmetics() {
|
||||||
@@ -181,7 +182,7 @@ public class CosmeticUser {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void updateCosmetic() {
|
public void updateCosmetic() {
|
||||||
for (Cosmetic cosmetic : playerCosmetics.values()) {
|
for (Cosmetic cosmetic : getCosmetics()) {
|
||||||
updateCosmetic(cosmetic.getSlot());
|
updateCosmetic(cosmetic.getSlot());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -242,27 +243,28 @@ public class CosmeticUser {
|
|||||||
return userEmoteManager;
|
return userEmoteManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void enterWardrobe() {
|
public void enterWardrobe(boolean ignoreDistance, Wardrobe wardrobe) {
|
||||||
enterWardrobe(false);
|
if (wardrobe.hasPermission() && !getPlayer().hasPermission(wardrobe.getPermission())) {
|
||||||
}
|
MessagesUtil.sendMessage(getPlayer(), "no-permission");
|
||||||
|
return;
|
||||||
public void enterWardrobe(boolean ignoreDistance) {
|
}
|
||||||
enterWardrobe(ignoreDistance, WardrobeSettings.getLeaveLocation(), WardrobeSettings.getViewerLocation(), WardrobeSettings.getWardrobeLocation());
|
if (!wardrobe.canEnter(this) && !ignoreDistance) {
|
||||||
}
|
|
||||||
|
|
||||||
public void enterWardrobe(boolean ignoreDistance, Location exitLocation, Location viewingLocation, Location npcLocation) {
|
|
||||||
if (!WardrobeSettings.inDistanceOfStatic(getPlayer().getLocation()) && !ignoreDistance) {
|
|
||||||
MessagesUtil.sendMessage(getPlayer(), "not-near-wardrobe");
|
MessagesUtil.sendMessage(getPlayer(), "not-near-wardrobe");
|
||||||
return;
|
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);
|
Bukkit.getPluginManager().callEvent(event);
|
||||||
if (event.isCancelled()) {
|
if (event.isCancelled()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
wardrobe = event.getWardrobe();
|
||||||
|
|
||||||
if (userWardrobeManager == null) {
|
if (userWardrobeManager == null) {
|
||||||
userWardrobeManager = new UserWardrobeManager(this, exitLocation, viewingLocation, npcLocation);
|
userWardrobeManager = new UserWardrobeManager(this, wardrobe);
|
||||||
userWardrobeManager.start();
|
userWardrobeManager.start();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -297,16 +299,7 @@ public class CosmeticUser {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean isInWardrobe() {
|
public boolean isInWardrobe() {
|
||||||
if (userWardrobeManager == null) return false;
|
return userWardrobeManager != null;
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void toggleWardrobe() {
|
|
||||||
if (isInWardrobe()) {
|
|
||||||
leaveWardrobe();
|
|
||||||
} else {
|
|
||||||
enterWardrobe();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void spawnBackpack(CosmeticBackpackType cosmeticBackpackType) {
|
public void spawnBackpack(CosmeticBackpackType cosmeticBackpackType) {
|
||||||
@@ -322,8 +315,7 @@ public class CosmeticUser {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean isBackpackSpawned() {
|
public boolean isBackpackSpawned() {
|
||||||
if (this.userBackpackManager == null) return false;
|
return this.userBackpackManager != null;
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void spawnBalloon(CosmeticBalloonType cosmeticBalloonType) {
|
public void spawnBalloon(CosmeticBalloonType cosmeticBalloonType) {
|
||||||
@@ -374,7 +366,7 @@ public class CosmeticUser {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public List<CosmeticSlot> getDyeableSlots() {
|
public List<CosmeticSlot> getDyeableSlots() {
|
||||||
ArrayList<CosmeticSlot> dyableSlots = new ArrayList();
|
ArrayList<CosmeticSlot> dyableSlots = new ArrayList<>();
|
||||||
|
|
||||||
for (Cosmetic cosmetic : getCosmetics()) {
|
for (Cosmetic cosmetic : getCosmetics()) {
|
||||||
if (cosmetic.isDyable()) dyableSlots.add(cosmetic.getSlot());
|
if (cosmetic.isDyable()) dyableSlots.add(cosmetic.getSlot());
|
||||||
@@ -385,8 +377,10 @@ public class CosmeticUser {
|
|||||||
|
|
||||||
public boolean canEquipCosmetic(Cosmetic cosmetic) {
|
public boolean canEquipCosmetic(Cosmetic cosmetic) {
|
||||||
if (!cosmetic.requiresPermission()) return true;
|
if (!cosmetic.requiresPermission()) return true;
|
||||||
if (getPlayer().hasPermission(cosmetic.getPermission())) return true;
|
if (isInWardrobe()) {
|
||||||
return false;
|
if (WardrobeSettings.isTryCosmeticsInWardrobe() && userWardrobeManager.getWardrobeStatus().equals(UserWardrobeManager.WardrobeStatus.RUNNING)) return true;
|
||||||
|
}
|
||||||
|
return getPlayer().hasPermission(cosmetic.getPermission());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void hidePlayer() {
|
public void hidePlayer() {
|
||||||
@@ -408,7 +402,7 @@ public class CosmeticUser {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void hideCosmetics(HiddenReason reason) {
|
public void hideCosmetics(HiddenReason reason) {
|
||||||
if (hideCosmetics == true) return;
|
if (hideCosmetics) return;
|
||||||
PlayerCosmeticHideEvent event = new PlayerCosmeticHideEvent(this, reason);
|
PlayerCosmeticHideEvent event = new PlayerCosmeticHideEvent(this, reason);
|
||||||
Bukkit.getPluginManager().callEvent(event);
|
Bukkit.getPluginManager().callEvent(event);
|
||||||
if (event.isCancelled()) {
|
if (event.isCancelled()) {
|
||||||
|
|||||||
@@ -3,30 +3,39 @@ package com.hibiscusmc.hmccosmetics.user.manager;
|
|||||||
import com.hibiscusmc.hmccosmetics.api.PlayerEmoteStartEvent;
|
import com.hibiscusmc.hmccosmetics.api.PlayerEmoteStartEvent;
|
||||||
import com.hibiscusmc.hmccosmetics.api.PlayerEmoteStopEvent;
|
import com.hibiscusmc.hmccosmetics.api.PlayerEmoteStopEvent;
|
||||||
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticEmoteType;
|
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticEmoteType;
|
||||||
|
import com.hibiscusmc.hmccosmetics.emotes.EmoteManager;
|
||||||
|
import com.hibiscusmc.hmccosmetics.nms.NMSHandlers;
|
||||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||||
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.entity.Entity;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
public class UserEmoteManager {
|
public class UserEmoteManager {
|
||||||
|
|
||||||
CosmeticUser user;
|
private CosmeticUser user;
|
||||||
private UserEmoteModel model;
|
private UserEmoteModel model;
|
||||||
|
private Entity textEntity;
|
||||||
|
|
||||||
public UserEmoteManager(CosmeticUser user) {
|
public UserEmoteManager(CosmeticUser user) {
|
||||||
this.user = user;
|
this.user = user;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void playEmote(@NotNull CosmeticEmoteType cosmeticEmoteType) {
|
public void playEmote(String animationId) {
|
||||||
MessagesUtil.sendDebugMessages("playEmote " + cosmeticEmoteType.getAnimationId());
|
MessagesUtil.sendDebugMessages("playEmote " + animationId);
|
||||||
playEmote(cosmeticEmoteType.getAnimationId());
|
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 (isPlayingEmote()) return;
|
||||||
if (user.isInWardrobe()) return;
|
if (user.isInWardrobe()) return;
|
||||||
// API
|
// API
|
||||||
PlayerEmoteStartEvent event = new PlayerEmoteStartEvent(user, animationId);
|
PlayerEmoteStartEvent event = new PlayerEmoteStartEvent(user, emoteAnimation);
|
||||||
Bukkit.getPluginManager().callEvent(event);
|
Bukkit.getPluginManager().callEvent(event);
|
||||||
if (event.isCancelled()) {
|
if (event.isCancelled()) {
|
||||||
return;
|
return;
|
||||||
@@ -34,7 +43,14 @@ public class UserEmoteManager {
|
|||||||
// Internal
|
// Internal
|
||||||
try {
|
try {
|
||||||
model = new UserEmoteModel(user);
|
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) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
@@ -55,12 +71,24 @@ public class UserEmoteManager {
|
|||||||
}
|
}
|
||||||
// Internal
|
// Internal
|
||||||
model.stopAnimation();
|
model.stopAnimation();
|
||||||
|
if (textEntity != null) {
|
||||||
|
textEntity.remove();
|
||||||
|
textEntity = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void despawnTextEntity() {
|
||||||
|
if (textEntity != null) {
|
||||||
|
textEntity.remove();
|
||||||
|
textEntity = null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum StopEmoteReason {
|
public enum StopEmoteReason {
|
||||||
SNEAK,
|
SNEAK,
|
||||||
DAMAGE,
|
DAMAGE,
|
||||||
CONNECTION,
|
CONNECTION,
|
||||||
TELEPORT
|
TELEPORT,
|
||||||
|
UNEQUIP
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,9 +36,6 @@ public class UserEmoteModel extends PlayerModel {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void playAnimation(@NotNull String id) {
|
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);
|
super.playAnimation(id);
|
||||||
|
|
||||||
emotePlaying = id;
|
emotePlaying = id;
|
||||||
@@ -67,6 +64,11 @@ public class UserEmoteModel extends PlayerModel {
|
|||||||
MessagesUtil.sendMessage(player, "emote-blocked");
|
MessagesUtil.sendMessage(player, "emote-blocked");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
// Check if block below player is an air block
|
||||||
|
if (Settings.getEmoteAirCheck() && newLocation.clone().subtract(0, 1, 0).getBlock().getType().isAir()) {
|
||||||
|
stopAnimation();
|
||||||
|
MessagesUtil.sendMessage(player, "emote-blocked");
|
||||||
|
}
|
||||||
|
|
||||||
user.getPlayer().setInvisible(true);
|
user.getPlayer().setInvisible(true);
|
||||||
user.hideCosmetics(CosmeticUser.HiddenReason.EMOTE);
|
user.hideCosmetics(CosmeticUser.HiddenReason.EMOTE);
|
||||||
@@ -117,6 +119,7 @@ public class UserEmoteModel extends PlayerModel {
|
|||||||
|
|
||||||
if (user.getPlayer() != null) player.setInvisible(false);
|
if (user.getPlayer() != null) player.setInvisible(false);
|
||||||
PacketManager.equipmentSlotUpdate(player, false, outsideViewers);
|
PacketManager.equipmentSlotUpdate(player, false, outsideViewers);
|
||||||
|
user.getUserEmoteManager().despawnTextEntity();
|
||||||
user.showPlayer();
|
user.showPlayer();
|
||||||
user.showCosmetics();
|
user.showCosmetics();
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -2,6 +2,8 @@ package com.hibiscusmc.hmccosmetics.user.manager;
|
|||||||
|
|
||||||
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
|
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
|
||||||
import com.hibiscusmc.hmccosmetics.config.Settings;
|
import com.hibiscusmc.hmccosmetics.config.Settings;
|
||||||
|
import com.hibiscusmc.hmccosmetics.config.Wardrobe;
|
||||||
|
import com.hibiscusmc.hmccosmetics.config.WardrobeLocation;
|
||||||
import com.hibiscusmc.hmccosmetics.config.WardrobeSettings;
|
import com.hibiscusmc.hmccosmetics.config.WardrobeSettings;
|
||||||
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
|
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
|
||||||
import com.hibiscusmc.hmccosmetics.cosmetic.CosmeticSlot;
|
import com.hibiscusmc.hmccosmetics.cosmetic.CosmeticSlot;
|
||||||
@@ -38,6 +40,8 @@ public class UserWardrobeManager {
|
|||||||
private String npcName;
|
private String npcName;
|
||||||
private GameMode originalGamemode;
|
private GameMode originalGamemode;
|
||||||
private final CosmeticUser user;
|
private final CosmeticUser user;
|
||||||
|
private final Wardrobe wardrobe;
|
||||||
|
private final WardrobeLocation wardrobeLocation;
|
||||||
private final Location viewingLocation;
|
private final Location viewingLocation;
|
||||||
private final Location npcLocation;
|
private final Location npcLocation;
|
||||||
private Location exitLocation;
|
private Location exitLocation;
|
||||||
@@ -45,15 +49,18 @@ public class UserWardrobeManager {
|
|||||||
private boolean active;
|
private boolean active;
|
||||||
private WardrobeStatus wardrobeStatus;
|
private WardrobeStatus wardrobeStatus;
|
||||||
|
|
||||||
public UserWardrobeManager(CosmeticUser user, Location exitLocation, Location viewingLocation, Location npcLocation) {
|
public UserWardrobeManager(CosmeticUser user, Wardrobe wardrobe) {
|
||||||
NPC_ID = NMSHandlers.getHandler().getNextEntityId();
|
NPC_ID = NMSHandlers.getHandler().getNextEntityId();
|
||||||
ARMORSTAND_ID = NMSHandlers.getHandler().getNextEntityId();
|
ARMORSTAND_ID = NMSHandlers.getHandler().getNextEntityId();
|
||||||
WARDROBE_UUID = UUID.randomUUID();
|
WARDROBE_UUID = UUID.randomUUID();
|
||||||
this.user = user;
|
this.user = user;
|
||||||
|
|
||||||
this.exitLocation = exitLocation;
|
this.wardrobe = wardrobe;
|
||||||
this.viewingLocation = viewingLocation;
|
this.wardrobeLocation = wardrobe.getLocation();
|
||||||
this.npcLocation = npcLocation;
|
|
||||||
|
this.exitLocation = wardrobeLocation.getLeaveLocation();
|
||||||
|
this.viewingLocation = wardrobeLocation.getViewerLocation();
|
||||||
|
this.npcLocation = wardrobeLocation.getNpcLocation();
|
||||||
|
|
||||||
wardrobeStatus = WardrobeStatus.SETUP;
|
wardrobeStatus = WardrobeStatus.SETUP;
|
||||||
}
|
}
|
||||||
@@ -113,8 +120,9 @@ public class UserWardrobeManager {
|
|||||||
user.getBalloonManager().sendLeashPacket(NPC_ID);
|
user.getBalloonManager().sendLeashPacket(NPC_ID);
|
||||||
//PacketManager.sendLeashPacket(VIEWER.getBalloonEntity().getModelId(), NPC_ID, viewer);
|
//PacketManager.sendLeashPacket(VIEWER.getBalloonEntity().getModelId(), NPC_ID, viewer);
|
||||||
|
|
||||||
PacketManager.sendTeleportPacket(user.getBalloonManager().getPufferfishBalloonId(), npcLocation.clone().add(Settings.getBalloonOffset()), false, viewer);
|
Location balloonLocation = npcLocation.clone().add(Settings.getBalloonOffset());
|
||||||
user.getBalloonManager().getModelEntity().teleport(npcLocation.clone().add(Settings.getBalloonOffset()));
|
PacketManager.sendTeleportPacket(user.getBalloonManager().getPufferfishBalloonId(), balloonLocation , false, viewer);
|
||||||
|
user.getBalloonManager().getModelEntity().teleport(balloonLocation);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (WardrobeSettings.getEnabledBossbar()) {
|
if (WardrobeSettings.getEnabledBossbar()) {
|
||||||
@@ -161,6 +169,15 @@ public class UserWardrobeManager {
|
|||||||
Runnable run = () -> {
|
Runnable run = () -> {
|
||||||
this.active = false;
|
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
|
// NPC
|
||||||
if (user.hasCosmeticInSlot(CosmeticSlot.BALLOON)) user.getBalloonManager().sendRemoveLeashPacket();
|
if (user.hasCosmeticInSlot(CosmeticSlot.BALLOON)) user.getBalloonManager().sendRemoveLeashPacket();
|
||||||
PacketManager.sendEntityDestroyPacket(NPC_ID, viewer); // Success
|
PacketManager.sendEntityDestroyPacket(NPC_ID, viewer); // Success
|
||||||
@@ -206,13 +223,6 @@ public class UserWardrobeManager {
|
|||||||
target.hideBossBar(bossBar);
|
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();
|
user.updateCosmetic();
|
||||||
};
|
};
|
||||||
run.run();
|
run.run();
|
||||||
@@ -230,12 +240,12 @@ public class UserWardrobeManager {
|
|||||||
this.cancel();
|
this.cancel();
|
||||||
return;
|
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> viewer = Collections.singletonList(player);
|
||||||
List<Player> outsideViewers = PacketManager.getViewers(viewingLocation);
|
List<Player> outsideViewers = PacketManager.getViewers(viewingLocation);
|
||||||
outsideViewers.remove(player);
|
outsideViewers.remove(player);
|
||||||
|
|
||||||
Location location = WardrobeSettings.getWardrobeLocation().clone();
|
Location location = npcLocation;
|
||||||
int yaw = data.get();
|
int yaw = data.get();
|
||||||
location.setYaw(yaw);
|
location.setYaw(yaw);
|
||||||
|
|
||||||
@@ -259,8 +269,9 @@ public class UserWardrobeManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (user.hasCosmeticInSlot(CosmeticSlot.BALLOON)) {
|
if (user.hasCosmeticInSlot(CosmeticSlot.BALLOON)) {
|
||||||
PacketManager.sendTeleportPacket(user.getBalloonManager().getPufferfishBalloonId(), WardrobeSettings.getWardrobeLocation().add(Settings.getBalloonOffset()), false, viewer);
|
// The two lines below broke, solved by listening to PlayerCosmeticPostEquipEvent
|
||||||
user.getBalloonManager().getModelEntity().teleport(WardrobeSettings.getWardrobeLocation().add(Settings.getBalloonOffset()));
|
//PacketManager.sendTeleportPacket(user.getBalloonManager().getPufferfishBalloonId(), npcLocation.add(Settings.getBalloonOffset()), false, viewer);
|
||||||
|
//user.getBalloonManager().getModelEntity().teleport(npcLocation.add(Settings.getBalloonOffset()));
|
||||||
user.getBalloonManager().sendRemoveLeashPacket(outsideViewers);
|
user.getBalloonManager().sendRemoveLeashPacket(outsideViewers);
|
||||||
PacketManager.sendEntityDestroyPacket(user.getBalloonManager().getModelId(), outsideViewers);
|
PacketManager.sendEntityDestroyPacket(user.getBalloonManager().getModelId(), outsideViewers);
|
||||||
user.getBalloonManager().sendLeashPacket(NPC_ID);
|
user.getBalloonManager().sendLeashPacket(NPC_ID);
|
||||||
@@ -293,4 +304,8 @@ public class UserWardrobeManager {
|
|||||||
RUNNING,
|
RUNNING,
|
||||||
STOPPING,
|
STOPPING,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Location getNpcLocation() {
|
||||||
|
return npcLocation;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ cosmetic-settings:
|
|||||||
|
|
||||||
emote-distance: -3 # This shows how far away the camera should be while a player is doing an emote. Negative is behind player.
|
emote-distance: -3 # This shows how far away the camera should be while a player is doing an emote. Negative is behind player.
|
||||||
emote-block-check: true # If the server should check if the block is open where the camera is placed (prevents players viewing through blocks)
|
emote-block-check: true # If the server should check if the block is open where the camera is placed (prevents players viewing through blocks)
|
||||||
|
emote-air-check: true # Check if there is air under a player, if there is, don't play emote
|
||||||
emote-damage-leave: true # If the player should leave the emote when they take damage
|
emote-damage-leave: true # If the player should leave the emote when they take damage
|
||||||
emote-invincible: false # If the player should not take damage while doing an emote
|
emote-invincible: false # If the player should not take damage while doing an emote
|
||||||
|
|
||||||
@@ -70,6 +71,8 @@ wardrobe:
|
|||||||
equip-pumpkin: false
|
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
|
# 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
|
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
|
||||||
|
|
||||||
gamemode-options:
|
gamemode-options:
|
||||||
exit-gamemode-enabled: false # Setting this to false will set the gamemode the player came in as. True sets to exit-gamemode gamemode
|
exit-gamemode-enabled: false # Setting this to false will set the gamemode the player came in as. True sets to exit-gamemode gamemode
|
||||||
@@ -91,24 +94,26 @@ wardrobe:
|
|||||||
title-fade-in: 1000 # milliseconds
|
title-fade-in: 1000 # milliseconds
|
||||||
title-stay: 500 # milliseconds
|
title-stay: 500 # milliseconds
|
||||||
title-fade-out: 1000 # milliseconds
|
title-fade-out: 1000 # milliseconds
|
||||||
wardrobe-location:
|
wardrobes:
|
||||||
world: "World"
|
default:
|
||||||
x: 0
|
npc-location:
|
||||||
y: 0
|
world: "world"
|
||||||
z: 0
|
x: 0
|
||||||
yaw: 0
|
y: 0
|
||||||
pitch: 0
|
z: 0
|
||||||
viewer-location:
|
yaw: 0
|
||||||
world: "World"
|
pitch: 0
|
||||||
x: 5
|
viewer-location:
|
||||||
y: 0
|
world: "world"
|
||||||
z: 5
|
x: 5
|
||||||
yaw: 0
|
y: 0
|
||||||
pitch: 0
|
z: 5
|
||||||
leave-location:
|
yaw: 0
|
||||||
world: "World"
|
pitch: 0
|
||||||
x: 5
|
leave-location:
|
||||||
y: 5
|
world: "world"
|
||||||
z: 5
|
x: 5
|
||||||
yaw: 0
|
y: 5
|
||||||
pitch: 0
|
z: 5
|
||||||
|
yaw: 0
|
||||||
|
pitch: 0
|
||||||
|
|||||||
@@ -11,6 +11,10 @@ not-near-wardrobe: "%prefix% <red>You are not near the wardrobe!"
|
|||||||
set-wardrobe-location: "%prefix% <gradient:#6D9DC5:#45CDE9>Set new wardrobe location!"
|
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-viewing: "%prefix% <gradient:#6D9DC5:#45CDE9>Set new wardrobe viewing location!"
|
||||||
set-wardrobe-leaving: "%prefix% <gradient:#6D9DC5:#45CDE9>Set new wardrobe leaving 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>!"
|
equip-cosmetic: "%prefix% <gradient:#6D9DC5:#45CDE9>You have equipped <cosmetic>!"
|
||||||
unequip-cosmetic: "%prefix% <gradient:#6D9DC5:#45CDE9>You have unequipped <cosmetic>!"
|
unequip-cosmetic: "%prefix% <gradient:#6D9DC5:#45CDE9>You have unequipped <cosmetic>!"
|
||||||
|
|||||||
@@ -13,4 +13,5 @@ include(
|
|||||||
"v1_19_R1",
|
"v1_19_R1",
|
||||||
"v1_19_R2",
|
"v1_19_R2",
|
||||||
"v1_19_R3",
|
"v1_19_R3",
|
||||||
|
"v1_20_R1",
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
|||||||
import com.hibiscusmc.hmccosmetics.util.PlayerUtils;
|
import com.hibiscusmc.hmccosmetics.util.PlayerUtils;
|
||||||
import com.hibiscusmc.hmccosmetics.util.packets.PacketManager;
|
import com.hibiscusmc.hmccosmetics.util.packets.PacketManager;
|
||||||
import com.mojang.datafixers.util.Pair;
|
import com.mojang.datafixers.util.Pair;
|
||||||
|
import net.kyori.adventure.text.Component;
|
||||||
import net.minecraft.network.protocol.Packet;
|
import net.minecraft.network.protocol.Packet;
|
||||||
import net.minecraft.network.protocol.game.ClientboundContainerSetSlotPacket;
|
import net.minecraft.network.protocol.game.ClientboundContainerSetSlotPacket;
|
||||||
import net.minecraft.network.protocol.game.ClientboundSetEquipmentPacket;
|
import net.minecraft.network.protocol.game.ClientboundSetEquipmentPacket;
|
||||||
@@ -97,6 +98,12 @@ public class NMSHandler implements com.hibiscusmc.hmccosmetics.nms.NMSHandler {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public org.bukkit.entity.Entity spawnDisplayEntity(Location location, String text) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
|||||||
import com.hibiscusmc.hmccosmetics.util.PlayerUtils;
|
import com.hibiscusmc.hmccosmetics.util.PlayerUtils;
|
||||||
import com.hibiscusmc.hmccosmetics.util.packets.PacketManager;
|
import com.hibiscusmc.hmccosmetics.util.packets.PacketManager;
|
||||||
import com.mojang.datafixers.util.Pair;
|
import com.mojang.datafixers.util.Pair;
|
||||||
|
import net.kyori.adventure.text.Component;
|
||||||
import net.minecraft.network.protocol.Packet;
|
import net.minecraft.network.protocol.Packet;
|
||||||
import net.minecraft.network.protocol.game.ClientboundContainerSetSlotPacket;
|
import net.minecraft.network.protocol.game.ClientboundContainerSetSlotPacket;
|
||||||
import net.minecraft.network.protocol.game.ClientboundSetEquipmentPacket;
|
import net.minecraft.network.protocol.game.ClientboundSetEquipmentPacket;
|
||||||
@@ -99,6 +100,12 @@ public class NMSHandler implements com.hibiscusmc.hmccosmetics.nms.NMSHandler {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public org.bukkit.entity.Entity spawnDisplayEntity(Location location, String text) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
|||||||
import com.hibiscusmc.hmccosmetics.util.PlayerUtils;
|
import com.hibiscusmc.hmccosmetics.util.PlayerUtils;
|
||||||
import com.hibiscusmc.hmccosmetics.util.packets.PacketManager;
|
import com.hibiscusmc.hmccosmetics.util.packets.PacketManager;
|
||||||
import com.mojang.datafixers.util.Pair;
|
import com.mojang.datafixers.util.Pair;
|
||||||
|
import net.kyori.adventure.text.Component;
|
||||||
import net.minecraft.network.protocol.Packet;
|
import net.minecraft.network.protocol.Packet;
|
||||||
import net.minecraft.network.protocol.game.ClientboundContainerSetSlotPacket;
|
import net.minecraft.network.protocol.game.ClientboundContainerSetSlotPacket;
|
||||||
import net.minecraft.network.protocol.game.ClientboundSetEquipmentPacket;
|
import net.minecraft.network.protocol.game.ClientboundSetEquipmentPacket;
|
||||||
@@ -99,6 +100,12 @@ public class NMSHandler implements com.hibiscusmc.hmccosmetics.nms.NMSHandler {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public org.bukkit.entity.Entity spawnDisplayEntity(Location location, String text) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
|||||||
import com.hibiscusmc.hmccosmetics.util.PlayerUtils;
|
import com.hibiscusmc.hmccosmetics.util.PlayerUtils;
|
||||||
import com.hibiscusmc.hmccosmetics.util.packets.PacketManager;
|
import com.hibiscusmc.hmccosmetics.util.packets.PacketManager;
|
||||||
import com.mojang.datafixers.util.Pair;
|
import com.mojang.datafixers.util.Pair;
|
||||||
|
import net.kyori.adventure.text.Component;
|
||||||
import net.minecraft.network.protocol.Packet;
|
import net.minecraft.network.protocol.Packet;
|
||||||
import net.minecraft.network.protocol.game.ClientboundContainerSetSlotPacket;
|
import net.minecraft.network.protocol.game.ClientboundContainerSetSlotPacket;
|
||||||
import net.minecraft.network.protocol.game.ClientboundSetEquipmentPacket;
|
import net.minecraft.network.protocol.game.ClientboundSetEquipmentPacket;
|
||||||
@@ -99,6 +100,11 @@ public class NMSHandler implements com.hibiscusmc.hmccosmetics.nms.NMSHandler {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public org.bukkit.entity.Entity spawnDisplayEntity(Location location, String text) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
|||||||
import com.hibiscusmc.hmccosmetics.util.PlayerUtils;
|
import com.hibiscusmc.hmccosmetics.util.PlayerUtils;
|
||||||
import com.hibiscusmc.hmccosmetics.util.packets.PacketManager;
|
import com.hibiscusmc.hmccosmetics.util.packets.PacketManager;
|
||||||
import com.mojang.datafixers.util.Pair;
|
import com.mojang.datafixers.util.Pair;
|
||||||
|
import net.minecraft.network.chat.Component;
|
||||||
import net.minecraft.network.protocol.Packet;
|
import net.minecraft.network.protocol.Packet;
|
||||||
import net.minecraft.network.protocol.game.ClientboundContainerSetSlotPacket;
|
import net.minecraft.network.protocol.game.ClientboundContainerSetSlotPacket;
|
||||||
import net.minecraft.network.protocol.game.ClientboundSetEquipmentPacket;
|
import net.minecraft.network.protocol.game.ClientboundSetEquipmentPacket;
|
||||||
@@ -20,6 +21,7 @@ import net.minecraft.network.protocol.game.ClientboundSetPlayerTeamPacket;
|
|||||||
import net.minecraft.server.level.ServerLevel;
|
import net.minecraft.server.level.ServerLevel;
|
||||||
import net.minecraft.server.level.ServerPlayer;
|
import net.minecraft.server.level.ServerPlayer;
|
||||||
import net.minecraft.server.network.ServerPlayerConnection;
|
import net.minecraft.server.network.ServerPlayerConnection;
|
||||||
|
import net.minecraft.world.entity.Display;
|
||||||
import net.minecraft.world.entity.Entity;
|
import net.minecraft.world.entity.Entity;
|
||||||
import net.minecraft.world.entity.EquipmentSlot;
|
import net.minecraft.world.entity.EquipmentSlot;
|
||||||
import net.minecraft.world.entity.player.Inventory;
|
import net.minecraft.world.entity.player.Inventory;
|
||||||
@@ -96,10 +98,20 @@ public class NMSHandler implements com.hibiscusmc.hmccosmetics.nms.NMSHandler {
|
|||||||
return invisibleArmorstand.getBukkitLivingEntity();
|
return invisibleArmorstand.getBukkitLivingEntity();
|
||||||
//PacketManager.armorStandMetaPacket(invisibleArmorstand.getBukkitEntity(), sentTo);
|
//PacketManager.armorStandMetaPacket(invisibleArmorstand.getBukkitEntity(), sentTo);
|
||||||
//PacketManager.ridingMountPacket(player.getEntityId(), invisibleArmorstand.getId(), 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
|
@Override
|
||||||
public UserBalloonManager spawnBalloon(CosmeticUser user, CosmeticBalloonType cosmeticBalloonType) {
|
public UserBalloonManager spawnBalloon(CosmeticUser user, CosmeticBalloonType cosmeticBalloonType) {
|
||||||
|
|||||||
27
v1_20_R1/build.gradle.kts
Normal file
27
v1_20_R1/build.gradle.kts
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
plugins {
|
||||||
|
id("java")
|
||||||
|
id("io.papermc.paperweight.userdev") version "1.5.1"
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
paperDevBundle("1.20-R0.1-SNAPSHOT")
|
||||||
|
implementation(project(":common"))
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks {
|
||||||
|
|
||||||
|
build {
|
||||||
|
dependsOn(reobfJar)
|
||||||
|
}
|
||||||
|
|
||||||
|
compileJava {
|
||||||
|
options.encoding = Charsets.UTF_8.name()
|
||||||
|
options.release.set(17)
|
||||||
|
}
|
||||||
|
javadoc {
|
||||||
|
options.encoding = Charsets.UTF_8.name()
|
||||||
|
}
|
||||||
|
processResources {
|
||||||
|
filteringCharset = Charsets.UTF_8.name()
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
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_20_R1.CraftWorld;
|
||||||
|
|
||||||
|
public class HMCArmorStand extends ArmorStand {
|
||||||
|
|
||||||
|
public HMCArmorStand(Level world, double x, double y, double z) {
|
||||||
|
super(world, x, y, z);
|
||||||
|
}
|
||||||
|
|
||||||
|
public HMCArmorStand(Location loc) {
|
||||||
|
super(((CraftWorld) loc.getWorld()).getHandle(), loc.getX(), loc.getY(), loc.getZ());
|
||||||
|
this.setPos(loc.getX(), loc.getY(), loc.getZ());
|
||||||
|
setInvisible(true);
|
||||||
|
setInvulnerable(true);
|
||||||
|
setMarker(true);
|
||||||
|
setSilent(true);
|
||||||
|
getBukkitLivingEntity().setCollidable(false);
|
||||||
|
persist = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
package com.hibiscusmc.hmccosmetics.nms.v1_20_R1;
|
||||||
|
|
||||||
|
|
||||||
|
import net.minecraft.world.entity.AreaEffectCloud;
|
||||||
|
import net.minecraft.world.level.Level;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.craftbukkit.v1_20_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;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,262 @@
|
|||||||
|
package com.hibiscusmc.hmccosmetics.nms.v1_20_R1;
|
||||||
|
|
||||||
|
import com.hibiscusmc.hmccosmetics.config.Settings;
|
||||||
|
import com.hibiscusmc.hmccosmetics.cosmetic.CosmeticSlot;
|
||||||
|
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticArmorType;
|
||||||
|
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticBackpackType;
|
||||||
|
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticBalloonType;
|
||||||
|
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticMainhandType;
|
||||||
|
import com.hibiscusmc.hmccosmetics.user.manager.UserBalloonManager;
|
||||||
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||||
|
import com.hibiscusmc.hmccosmetics.util.InventoryUtils;
|
||||||
|
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||||
|
import com.hibiscusmc.hmccosmetics.util.PlayerUtils;
|
||||||
|
import com.hibiscusmc.hmccosmetics.util.packets.PacketManager;
|
||||||
|
import com.mojang.datafixers.util.Pair;
|
||||||
|
import net.minecraft.network.chat.Component;
|
||||||
|
import net.minecraft.network.protocol.Packet;
|
||||||
|
import net.minecraft.network.protocol.game.ClientboundContainerSetSlotPacket;
|
||||||
|
import net.minecraft.network.protocol.game.ClientboundSetEquipmentPacket;
|
||||||
|
import net.minecraft.network.protocol.game.ClientboundSetPlayerTeamPacket;
|
||||||
|
import net.minecraft.server.level.ServerLevel;
|
||||||
|
import net.minecraft.server.level.ServerPlayer;
|
||||||
|
import net.minecraft.server.network.ServerPlayerConnection;
|
||||||
|
import net.minecraft.world.entity.Display;
|
||||||
|
import net.minecraft.world.entity.Entity;
|
||||||
|
import net.minecraft.world.entity.EquipmentSlot;
|
||||||
|
import net.minecraft.world.entity.player.Inventory;
|
||||||
|
import net.minecraft.world.scores.PlayerTeam;
|
||||||
|
import net.minecraft.world.scores.Team;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.craftbukkit.v1_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();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public org.bukkit.entity.Entity getEntity(int entityId) {
|
||||||
|
net.minecraft.world.entity.Entity entity = getNMSEntity(entityId);
|
||||||
|
if (entity == null) return null;
|
||||||
|
return entity.getBukkitEntity();
|
||||||
|
}
|
||||||
|
|
||||||
|
private net.minecraft.world.entity.Entity getNMSEntity(int entityId) {
|
||||||
|
for (ServerLevel world : ((CraftServer) Bukkit.getServer()).getHandle().getServer().getAllLevels()) {
|
||||||
|
net.minecraft.world.entity.Entity entity = world.getEntity(entityId);
|
||||||
|
if (entity == null) return null;
|
||||||
|
return entity;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public org.bukkit.entity.Entity getHMCArmorStand(Location loc) {
|
||||||
|
HMCArmorStand hmcArmorStand = new HMCArmorStand(loc);
|
||||||
|
return hmcArmorStand.getBukkitEntity();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public org.bukkit.entity.Entity spawnHMCParticleCloud(Location location) {
|
||||||
|
HMCParticleCloud hmcParticleCloud = new HMCParticleCloud(location);
|
||||||
|
return hmcParticleCloud.getBukkitEntity();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ArmorStand getMEGEntity(Location loc) {
|
||||||
|
return (ArmorStand) new MEGEntity(loc).getBukkitEntity();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public org.bukkit.entity.Entity spawnBackpack(CosmeticUser user, CosmeticBackpackType cosmeticBackpackType) {
|
||||||
|
HMCArmorStand invisibleArmorstand = new HMCArmorStand(user.getPlayer().getLocation());
|
||||||
|
|
||||||
|
ItemStack item = user.getUserCosmeticItem(cosmeticBackpackType);
|
||||||
|
|
||||||
|
invisibleArmorstand.setItemSlot(EquipmentSlot.HEAD, CraftItemStack.asNMSCopy(item));
|
||||||
|
((CraftWorld) user.getPlayer().getWorld()).getHandle().addFreshEntity(invisibleArmorstand, 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());
|
||||||
|
|
||||||
|
UserBalloonManager userBalloonManager1 = new UserBalloonManager(user.getPlayer().getLocation());
|
||||||
|
List<Player> sentTo = PlayerUtils.getNearbyPlayers(player.getLocation());
|
||||||
|
userBalloonManager1.getModelEntity().teleport(user.getPlayer().getLocation().add(Settings.getBalloonOffset()));
|
||||||
|
|
||||||
|
userBalloonManager1.spawnModel(cosmeticBalloonType, user.getCosmeticColor(cosmeticBalloonType.getSlot()));
|
||||||
|
userBalloonManager1.addPlayerToModel(user, cosmeticBalloonType, user.getCosmeticColor(cosmeticBalloonType.getSlot()));
|
||||||
|
|
||||||
|
PacketManager.sendEntitySpawnPacket(newLoc, userBalloonManager1.getPufferfishBalloonId(), EntityType.PUFFERFISH, userBalloonManager1.getPufferfishBalloonUniqueId(), sentTo);
|
||||||
|
PacketManager.sendInvisibilityPacket(userBalloonManager1.getPufferfishBalloonId(), sentTo);
|
||||||
|
userBalloonManager1.sendLeashPacket(player.getEntityId());
|
||||||
|
|
||||||
|
return userBalloonManager1;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void equipmentSlotUpdate(
|
||||||
|
int entityId,
|
||||||
|
CosmeticUser user,
|
||||||
|
CosmeticSlot cosmeticSlot,
|
||||||
|
List<Player> sendTo
|
||||||
|
) {
|
||||||
|
|
||||||
|
EquipmentSlot nmsSlot = null;
|
||||||
|
net.minecraft.world.item.ItemStack nmsItem = null;
|
||||||
|
|
||||||
|
if (!(user.getCosmetic(cosmeticSlot) instanceof CosmeticArmorType)) {
|
||||||
|
|
||||||
|
if (user.getCosmetic(cosmeticSlot) instanceof CosmeticMainhandType) {
|
||||||
|
CosmeticMainhandType cosmeticMainhandType = (CosmeticMainhandType) user.getCosmetic(CosmeticSlot.MAINHAND);
|
||||||
|
nmsItem = CraftItemStack.asNMSCopy(user.getUserCosmeticItem(cosmeticMainhandType));
|
||||||
|
} else {
|
||||||
|
nmsItem = CraftItemStack.asNMSCopy(user.getPlayer().getInventory().getItem(InventoryUtils.getEquipmentSlot(cosmeticSlot)));
|
||||||
|
}
|
||||||
|
|
||||||
|
nmsSlot = CraftEquipmentSlot.getNMS(InventoryUtils.getEquipmentSlot(cosmeticSlot));
|
||||||
|
|
||||||
|
if (nmsSlot == null) return;
|
||||||
|
|
||||||
|
Pair<EquipmentSlot, net.minecraft.world.item.ItemStack> pair = new Pair<>(nmsSlot, nmsItem);
|
||||||
|
|
||||||
|
List<Pair<EquipmentSlot, net.minecraft.world.item.ItemStack>> pairs = Collections.singletonList(pair);
|
||||||
|
|
||||||
|
ClientboundSetEquipmentPacket packet = new ClientboundSetEquipmentPacket(entityId, pairs);
|
||||||
|
for (Player p : sendTo) sendPacket(p, packet);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
CosmeticArmorType cosmeticArmor = (CosmeticArmorType) user.getCosmetic(cosmeticSlot);
|
||||||
|
|
||||||
|
// Converting EquipmentSlot and ItemStack to NMS ones.
|
||||||
|
nmsSlot = CraftEquipmentSlot.getNMS(cosmeticArmor.getEquipSlot());
|
||||||
|
nmsItem = CraftItemStack.asNMSCopy(user.getUserCosmeticItem(cosmeticArmor));
|
||||||
|
|
||||||
|
if (nmsSlot == null) return;
|
||||||
|
|
||||||
|
Pair<EquipmentSlot, net.minecraft.world.item.ItemStack> pair = new Pair<>(nmsSlot, nmsItem);
|
||||||
|
|
||||||
|
List<Pair<EquipmentSlot, net.minecraft.world.item.ItemStack>> pairs = Collections.singletonList(pair);
|
||||||
|
|
||||||
|
ClientboundSetEquipmentPacket packet = new ClientboundSetEquipmentPacket(entityId, pairs);
|
||||||
|
for (Player p : sendTo) sendPacket(p, packet);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void equipmentSlotUpdate(
|
||||||
|
int entityId,
|
||||||
|
org.bukkit.inventory.EquipmentSlot slot,
|
||||||
|
ItemStack item,
|
||||||
|
List<Player> sendTo
|
||||||
|
) {
|
||||||
|
|
||||||
|
EquipmentSlot nmsSlot = null;
|
||||||
|
net.minecraft.world.item.ItemStack nmsItem = null;
|
||||||
|
|
||||||
|
// Converting EquipmentSlot and ItemStack to NMS ones.
|
||||||
|
nmsSlot = CraftEquipmentSlot.getNMS(slot);
|
||||||
|
nmsItem = CraftItemStack.asNMSCopy(item);
|
||||||
|
|
||||||
|
if (nmsSlot == null) return;
|
||||||
|
|
||||||
|
Pair<EquipmentSlot, net.minecraft.world.item.ItemStack> pair = new Pair<>(nmsSlot, nmsItem);
|
||||||
|
|
||||||
|
List<Pair<EquipmentSlot, net.minecraft.world.item.ItemStack>> pairs = Collections.singletonList(pair);
|
||||||
|
|
||||||
|
ClientboundSetEquipmentPacket packet = new ClientboundSetEquipmentPacket(entityId, pairs);
|
||||||
|
for (Player p : sendTo) sendPacket(p, packet);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void slotUpdate(
|
||||||
|
Player player,
|
||||||
|
int slot
|
||||||
|
) {
|
||||||
|
int index = 0;
|
||||||
|
|
||||||
|
ServerPlayer player1 = ((CraftPlayer) player).getHandle();
|
||||||
|
|
||||||
|
if (index < Inventory.getSelectionSize()) {
|
||||||
|
index += 36;
|
||||||
|
} else if (index > 39) {
|
||||||
|
index += 5; // Off hand
|
||||||
|
} else if (index > 35) {
|
||||||
|
index = 8 - (index - 36);
|
||||||
|
}
|
||||||
|
ItemStack item = player.getInventory().getItem(slot);
|
||||||
|
|
||||||
|
Packet packet = new ClientboundContainerSetSlotPacket(player1.inventoryMenu.containerId, player1.inventoryMenu.incrementStateId(), index, CraftItemStack.asNMSCopy(item));
|
||||||
|
sendPacket(player, packet);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void hideNPCName(Player player, String NPCName) {
|
||||||
|
//Creating the team
|
||||||
|
PlayerTeam team = new PlayerTeam(((CraftScoreboard) Bukkit.getScoreboardManager().getMainScoreboard()).getHandle(), NPCName);
|
||||||
|
|
||||||
|
//Setting name visibility
|
||||||
|
team.setNameTagVisibility(Team.Visibility.NEVER);
|
||||||
|
|
||||||
|
//Remove the Team (i assume so if it exists)
|
||||||
|
ClientboundSetPlayerTeamPacket removeTeamPacket = ClientboundSetPlayerTeamPacket.createRemovePacket(team);
|
||||||
|
sendPacket(player, removeTeamPacket);
|
||||||
|
//Creating the Team
|
||||||
|
ClientboundSetPlayerTeamPacket createTeamPacket = ClientboundSetPlayerTeamPacket.createAddOrModifyPacket(team, true);
|
||||||
|
sendPacket(player, createTeamPacket);
|
||||||
|
//Adding players to the team (You have to use the NPC's name, and add it to a list)
|
||||||
|
ClientboundSetPlayerTeamPacket createPlayerTeamPacket = ClientboundSetPlayerTeamPacket.createMultiplePlayerPacket(team, new ArrayList<String>() {{
|
||||||
|
add(NPCName);
|
||||||
|
}}, ClientboundSetPlayerTeamPacket.Action.ADD);
|
||||||
|
sendPacket(player, createPlayerTeamPacket);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void sendPacket(Player player, Packet packet) {
|
||||||
|
ServerPlayer serverPlayer = ((CraftPlayer) player).getHandle();
|
||||||
|
ServerPlayerConnection connection = serverPlayer.connection;
|
||||||
|
connection.send(packet);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean getSupported() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user