mirror of
https://github.com/HibiscusMC/HMCCosmetics.git
synced 2025-12-24 01:19:14 +00:00
Compare commits
70 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f98614c4ee | ||
|
|
d28bb23f8c | ||
|
|
502cb533f8 | ||
|
|
b7fdc2087a | ||
|
|
10a42a3c96 | ||
|
|
51fc52e24b | ||
|
|
be632d8e8c | ||
|
|
a732a2b0a0 | ||
|
|
b14a0b5d16 | ||
|
|
50393c62b0 | ||
|
|
dbc4a07895 | ||
|
|
ab329e4fbf | ||
|
|
90ad700d0a | ||
|
|
56529d6111 | ||
|
|
b6a06007e8 | ||
|
|
edccc9ce4e | ||
|
|
e0b2f0f6b1 | ||
|
|
57f4d3703c | ||
|
|
8ef6692198 | ||
|
|
c48830f3ac | ||
|
|
734c04c1f4 | ||
|
|
b08b4019a9 | ||
|
|
cfb7876b6e | ||
|
|
6047d0e3c3 | ||
|
|
880c333df9 | ||
|
|
c4d7b657dd | ||
|
|
5be3ce8d21 | ||
|
|
33bba631fc | ||
|
|
775b9c299d | ||
|
|
6e02331c13 | ||
|
|
b7457cec9c | ||
|
|
e7288a1910 | ||
|
|
26b90bd8bb | ||
|
|
24a10b6838 | ||
|
|
af7bc0dc3f | ||
|
|
162d4a6ed6 | ||
|
|
41140f60c5 | ||
|
|
a6145a607c | ||
|
|
89c6951a93 | ||
|
|
28c466e342 | ||
|
|
90caa23cd7 | ||
|
|
910f223151 | ||
|
|
ac1b50a957 | ||
|
|
9cb9bad3c8 | ||
|
|
f68e2633a2 | ||
|
|
c8ad5c0881 | ||
|
|
c93a718799 | ||
|
|
b5f781e00f | ||
|
|
f6cd73f436 | ||
|
|
8b0fcc5da9 | ||
|
|
b5787f22bf | ||
|
|
c1c431d914 | ||
|
|
b41dc66508 | ||
|
|
cfbf74257b | ||
|
|
9b2083b90a | ||
|
|
33437cd387 | ||
|
|
9f4e4616d4 | ||
|
|
01c62bc94e | ||
|
|
3be4bdeb6f | ||
|
|
145aec9b7f | ||
|
|
4a2266bbfa | ||
|
|
7fa3cd6cb7 | ||
|
|
9c5fe9c426 | ||
|
|
0a9d750d3e | ||
|
|
da996fb146 | ||
|
|
006319a757 | ||
|
|
a8ff8e6a7a | ||
|
|
8b20207442 | ||
|
|
8bbe12ed84 | ||
|
|
d23f3e19d2 |
@@ -8,7 +8,7 @@ plugins {
|
|||||||
}
|
}
|
||||||
|
|
||||||
group = "com.hibiscusmc"
|
group = "com.hibiscusmc"
|
||||||
version = "2.6.1"
|
version = "2.6.5"
|
||||||
|
|
||||||
allprojects {
|
allprojects {
|
||||||
apply(plugin = "java")
|
apply(plugin = "java")
|
||||||
@@ -32,9 +32,6 @@ allprojects {
|
|||||||
// PlaceholderAPI
|
// PlaceholderAPI
|
||||||
maven("https://repo.extendedclip.com/content/repositories/placeholderapi/")
|
maven("https://repo.extendedclip.com/content/repositories/placeholderapi/")
|
||||||
|
|
||||||
//Hikari
|
|
||||||
maven("https://mvnrepository.com/artifact/com.zaxxer/HikariCP")
|
|
||||||
|
|
||||||
// Citizens & Denizen
|
// Citizens & Denizen
|
||||||
maven("https://maven.citizensnpcs.co/repo")
|
maven("https://maven.citizensnpcs.co/repo")
|
||||||
|
|
||||||
@@ -63,6 +60,9 @@ allprojects {
|
|||||||
|
|
||||||
// md-5 Repo
|
// md-5 Repo
|
||||||
maven("https://repo.md-5.net/content/groups/public/")
|
maven("https://repo.md-5.net/content/groups/public/")
|
||||||
|
|
||||||
|
// MMOItems
|
||||||
|
maven("https://nexus.phoenixdevt.fr/repository/maven-public/")
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
@@ -70,12 +70,12 @@ allprojects {
|
|||||||
compileOnly("com.mojang:authlib:1.5.25")
|
compileOnly("com.mojang:authlib:1.5.25")
|
||||||
compileOnly("org.spigotmc:spigot-api:1.18.2-R0.1-SNAPSHOT")
|
compileOnly("org.spigotmc:spigot-api:1.18.2-R0.1-SNAPSHOT")
|
||||||
compileOnly("org.jetbrains:annotations:23.0.0")
|
compileOnly("org.jetbrains:annotations:23.0.0")
|
||||||
compileOnly("com.comphenix.protocol:ProtocolLib:5.0.0")
|
compileOnly("com.comphenix.protocol:ProtocolLib:5.1.0")
|
||||||
compileOnly("me.clip:placeholderapi:2.11.3")
|
compileOnly("me.clip:placeholderapi:2.11.3")
|
||||||
compileOnly("com.ticxo:modelengine:R3.0.1")
|
compileOnly("com.ticxo.modelengine:ModelEngine:R4.0.2")
|
||||||
compileOnly("com.github.oraxen:oraxen:1.160.0")
|
compileOnly("com.github.oraxen:oraxen:1.160.0")
|
||||||
compileOnly("com.github.LoneDev6:API-ItemsAdder:3.2.5")
|
compileOnly("com.github.LoneDev6:API-ItemsAdder:3.2.5")
|
||||||
compileOnly("com.mineinabyss:geary-papermc:0.24.1")
|
compileOnly("com.mineinabyss:geary-papermc:0.27.0")
|
||||||
compileOnly("com.sk89q.worldguard:worldguard-bukkit:7.1.0-SNAPSHOT")
|
compileOnly("com.sk89q.worldguard:worldguard-bukkit:7.1.0-SNAPSHOT")
|
||||||
compileOnly("it.unimi.dsi:fastutil:8.5.11")
|
compileOnly("it.unimi.dsi:fastutil:8.5.11")
|
||||||
compileOnly("com.github.LeonMangler:SuperVanish:6.2.17")
|
compileOnly("com.github.LeonMangler:SuperVanish:6.2.17")
|
||||||
@@ -94,18 +94,19 @@ dependencies {
|
|||||||
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"))
|
implementation(project(path = ":v1_20_R1", configuration = "reobf"))
|
||||||
|
implementation(project(path = ":v1_20_R2", 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")
|
||||||
implementation("net.kyori:adventure-text-minimessage:4.11.0")
|
implementation("net.kyori:adventure-text-minimessage:4.11.0")
|
||||||
implementation("net.kyori:adventure-platform-bukkit:4.1.2")
|
implementation("net.kyori:adventure-platform-bukkit:4.1.2")
|
||||||
implementation("dev.triumphteam:triumph-gui:3.1.3")
|
implementation("dev.triumphteam:triumph-gui:3.1.3")
|
||||||
implementation("org.spongepowered:configurate-yaml:4.1.2")
|
implementation("org.spongepowered:configurate-yaml:4.2.0-SNAPSHOT")
|
||||||
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:PlayerAnimator:R1.2.7")
|
implementation("com.ticxo.playeranimator:PlayerAnimator:R1.2.7")
|
||||||
implementation("com.github.BG-Software-LLC:CommentedConfiguration:-SNAPSHOT")
|
implementation("com.github.BG-Software-LLC:CommentedConfiguration:bed3c46369")
|
||||||
//implementation("com.ticxo.playeranimator:PlayerAnimator:R1.2.5")
|
//implementation("com.ticxo.playeranimator:PlayerAnimator:R1.2.5")
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -126,7 +127,7 @@ tasks {
|
|||||||
}
|
}
|
||||||
|
|
||||||
runServer {
|
runServer {
|
||||||
minecraftVersion("1.20.1")
|
minecraftVersion("1.20.2")
|
||||||
}
|
}
|
||||||
|
|
||||||
shadowJar {
|
shadowJar {
|
||||||
@@ -135,6 +136,7 @@ tasks {
|
|||||||
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")
|
dependsOn(":v1_20_R1:reobfJar")
|
||||||
|
dependsOn(":v1_20_R2:reobfJar")
|
||||||
mergeServiceFiles()
|
mergeServiceFiles()
|
||||||
|
|
||||||
relocate("dev.triumphteam.gui", "com.hisbiscusmc.hmccosmetics.gui")
|
relocate("dev.triumphteam.gui", "com.hisbiscusmc.hmccosmetics.gui")
|
||||||
@@ -175,7 +177,7 @@ bukkit {
|
|||||||
apiVersion = "1.18"
|
apiVersion = "1.18"
|
||||||
authors = listOf("LoJoSho")
|
authors = listOf("LoJoSho")
|
||||||
depend = listOf("ProtocolLib")
|
depend = listOf("ProtocolLib")
|
||||||
softDepend = listOf("ModelEngine", "Oraxen", "ItemsAdder", "Geary", "HMCColor", "WorldGuard", "MythicMobs", "PlaceholderAPI", "SuperVanish", "PremiumVanish", "LibsDisguises", "Denizen")
|
softDepend = listOf("ModelEngine", "Oraxen", "ItemsAdder", "Geary", "HMCColor", "WorldGuard", "MythicMobs", "PlaceholderAPI", "SuperVanish", "PremiumVanish", "LibsDisguises", "Denizen", "MMOItems")
|
||||||
version = "${project.version}"
|
version = "${project.version}"
|
||||||
loadBefore = listOf(
|
loadBefore = listOf(
|
||||||
"Cosmin" // Fixes an issue with Cosmin loading before and taking /cosmetic, when messing with what we do.
|
"Cosmin" // Fixes an issue with Cosmin loading before and taking /cosmetic, when messing with what we do.
|
||||||
@@ -184,6 +186,7 @@ bukkit {
|
|||||||
commands {
|
commands {
|
||||||
register("cosmetic") {
|
register("cosmetic") {
|
||||||
description = "Base Cosmetic Command"
|
description = "Base Cosmetic Command"
|
||||||
|
aliases = listOf("hmccosmetics", "cosmetics")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
permissions {
|
permissions {
|
||||||
|
|||||||
@@ -7,9 +7,9 @@ dependencies {
|
|||||||
compileOnly("com.mojang:authlib:1.5.25")
|
compileOnly("com.mojang:authlib:1.5.25")
|
||||||
compileOnly("org.spigotmc:spigot-api:1.18.2-R0.1-SNAPSHOT")
|
compileOnly("org.spigotmc:spigot-api:1.18.2-R0.1-SNAPSHOT")
|
||||||
compileOnly("org.jetbrains:annotations:23.0.0")
|
compileOnly("org.jetbrains:annotations:23.0.0")
|
||||||
compileOnly("com.comphenix.protocol:ProtocolLib:5.0.0")
|
compileOnly("com.comphenix.protocol:ProtocolLib:5.1.0")
|
||||||
compileOnly("me.clip:placeholderapi:2.11.3")
|
compileOnly("me.clip:placeholderapi:2.11.3")
|
||||||
compileOnly("com.ticxo:modelengine:R3.0.1")
|
compileOnly("com.ticxo.modelengine:ModelEngine:R4.0.2")
|
||||||
compileOnly("com.github.oraxen:oraxen:1.160.0")
|
compileOnly("com.github.oraxen:oraxen:1.160.0")
|
||||||
compileOnly("com.github.LoneDev6:API-ItemsAdder:3.2.5")
|
compileOnly("com.github.LoneDev6:API-ItemsAdder:3.2.5")
|
||||||
compileOnly("com.mineinabyss:geary-papermc:0.24-SNAPSHOT")
|
compileOnly("com.mineinabyss:geary-papermc:0.24-SNAPSHOT")
|
||||||
@@ -19,6 +19,7 @@ dependencies {
|
|||||||
compileOnly("io.lumine:Mythic-Dist:5.2.1")
|
compileOnly("io.lumine:Mythic-Dist:5.2.1")
|
||||||
compileOnly("com.denizenscript:denizen:1.2.7-SNAPSHOT")
|
compileOnly("com.denizenscript:denizen:1.2.7-SNAPSHOT")
|
||||||
compileOnly("com.github.LeonMangler:SuperVanish:6.2.17")
|
compileOnly("com.github.LeonMangler:SuperVanish:6.2.17")
|
||||||
|
compileOnly("net.Indyuce:MMOItems-API:6.9.4-SNAPSHOT")
|
||||||
compileOnlyApi("LibsDisguises:LibsDisguises:10.0.21") {
|
compileOnlyApi("LibsDisguises:LibsDisguises:10.0.21") {
|
||||||
exclude("org.spigotmc", "spigot")
|
exclude("org.spigotmc", "spigot")
|
||||||
}
|
}
|
||||||
@@ -33,7 +34,7 @@ dependencies {
|
|||||||
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:PlayerAnimator:R1.2.7")
|
implementation("com.ticxo.playeranimator:PlayerAnimator:R1.2.7")
|
||||||
implementation("com.github.BG-Software-LLC:CommentedConfiguration:-SNAPSHOT")
|
implementation("com.github.BG-Software-LLC:CommentedConfiguration:bed3c46369")
|
||||||
//implementation("com.ticxo.playeranimator:PlayerAnimator:R1.2.5")
|
//implementation("com.ticxo.playeranimator:PlayerAnimator:R1.2.5")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ public final class HMCCosmeticsPlugin extends JavaPlugin {
|
|||||||
Metrics metrics = new Metrics(this, pluginId);
|
Metrics metrics = new Metrics(this, pluginId);
|
||||||
|
|
||||||
// NMS version check
|
// NMS version check
|
||||||
if (!NMSHandlers.getHandler().getSupported()) {
|
if (!NMSHandlers.isVersionSupported()) {
|
||||||
getLogger().severe("This version is not supported! Consider switching versions?");
|
getLogger().severe("This version is not supported! Consider switching versions?");
|
||||||
getServer().getPluginManager().disablePlugin(this);
|
getServer().getPluginManager().disablePlugin(this);
|
||||||
return;
|
return;
|
||||||
@@ -98,7 +98,7 @@ public final class HMCCosmeticsPlugin extends JavaPlugin {
|
|||||||
if (!emoteFile.exists()) emoteFile.mkdir();
|
if (!emoteFile.exists()) emoteFile.mkdir();
|
||||||
|
|
||||||
// Player Animator
|
// Player Animator
|
||||||
PlayerAnimatorImpl.initialize(this);
|
if (!NMSHandlers.getVersion().contains("v1_20_R2")) PlayerAnimatorImpl.initialize(this); // PlayerAnimator does not support 1.20.2 yet
|
||||||
|
|
||||||
// Configuration Sync
|
// Configuration Sync
|
||||||
final File configFile = Path.of(getInstance().getDataFolder().getPath(), "config.yml").toFile();
|
final File configFile = Path.of(getInstance().getDataFolder().getPath(), "config.yml").toFile();
|
||||||
@@ -106,7 +106,7 @@ public final class HMCCosmeticsPlugin extends JavaPlugin {
|
|||||||
final File translationFile = Path.of(getInstance().getDataFolder().getPath(), "translations.yml").toFile();
|
final File translationFile = Path.of(getInstance().getDataFolder().getPath(), "translations.yml").toFile();
|
||||||
try {
|
try {
|
||||||
CommentedConfiguration.loadConfiguration(configFile).syncWithConfig(configFile, getInstance().getResource("config.yml"),
|
CommentedConfiguration.loadConfiguration(configFile).syncWithConfig(configFile, getInstance().getResource("config.yml"),
|
||||||
"database-settings", "debug-mode", "wardrobe.viewer-location", "wardrobe.npc-location", "wardrobe.wardrobe-location", "wardrobe.leave-location");
|
"database-settings", "wardrobe.wardrobes", "debug-mode", "wardrobe.viewer-location", "wardrobe.npc-location", "wardrobe.wardrobe-location", "wardrobe.leave-location");
|
||||||
CommentedConfiguration.loadConfiguration(messageFile).syncWithConfig(messageFile, getInstance().getResource("messages.yml"));
|
CommentedConfiguration.loadConfiguration(messageFile).syncWithConfig(messageFile, getInstance().getResource("messages.yml"));
|
||||||
CommentedConfiguration.loadConfiguration(translationFile).syncWithConfig(translationFile, getInstance().getResource("translations.yml"));
|
CommentedConfiguration.loadConfiguration(translationFile).syncWithConfig(translationFile, getInstance().getResource("translations.yml"));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
@@ -252,7 +252,7 @@ public final class HMCCosmeticsPlugin extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
EmoteManager.loadEmotes();
|
if (Settings.isEmotesEnabled() && !NMSHandlers.getVersion().contains("v1_20_R2")) EmoteManager.loadEmotes(); // PlayerAnimator does not support 1.20.2 yet
|
||||||
|
|
||||||
getInstance().getLogger().info("Successfully Enabled HMCCosmetics");
|
getInstance().getLogger().info("Successfully Enabled HMCCosmetics");
|
||||||
getInstance().getLogger().info(Cosmetics.values().size() + " Cosmetics Successfully Setup");
|
getInstance().getLogger().info(Cosmetics.values().size() + " Cosmetics Successfully Setup");
|
||||||
|
|||||||
@@ -2,6 +2,8 @@ package com.hibiscusmc.hmccosmetics.api.events;
|
|||||||
|
|
||||||
import com.hibiscusmc.hmccosmetics.config.Wardrobe;
|
import com.hibiscusmc.hmccosmetics.config.Wardrobe;
|
||||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
import org.bukkit.event.Cancellable;
|
import org.bukkit.event.Cancellable;
|
||||||
import org.bukkit.event.HandlerList;
|
import org.bukkit.event.HandlerList;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
@@ -12,6 +14,7 @@ import org.jetbrains.annotations.NotNull;
|
|||||||
public class PlayerWardrobeEnterEvent extends PlayerCosmeticEvent implements Cancellable {
|
public class PlayerWardrobeEnterEvent extends PlayerCosmeticEvent implements Cancellable {
|
||||||
private static final HandlerList handlers = new HandlerList();
|
private static final HandlerList handlers = new HandlerList();
|
||||||
private boolean cancel = false;
|
private boolean cancel = false;
|
||||||
|
@Getter @Setter
|
||||||
private Wardrobe wardrobe;
|
private Wardrobe wardrobe;
|
||||||
|
|
||||||
public PlayerWardrobeEnterEvent(@NotNull CosmeticUser who, @NotNull Wardrobe wardrobe) {
|
public PlayerWardrobeEnterEvent(@NotNull CosmeticUser who, @NotNull Wardrobe wardrobe) {
|
||||||
@@ -48,12 +51,4 @@ public class PlayerWardrobeEnterEvent extends PlayerCosmeticEvent implements Can
|
|||||||
public static HandlerList getHandlerList() {
|
public static HandlerList getHandlerList() {
|
||||||
return handlers;
|
return handlers;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setWardrobe(Wardrobe wardrobe) {
|
|
||||||
this.wardrobe = wardrobe;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Wardrobe getWardrobe() {
|
|
||||||
return wardrobe;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -262,7 +262,6 @@ public class CosmeticCommand implements CommandExecutor {
|
|||||||
case ("dataclear") -> {
|
case ("dataclear") -> {
|
||||||
if (args.length == 1) return true;
|
if (args.length == 1) return true;
|
||||||
OfflinePlayer selectedPlayer = Bukkit.getOfflinePlayer(args[1]);
|
OfflinePlayer selectedPlayer = Bukkit.getOfflinePlayer(args[1]);
|
||||||
if (selectedPlayer == null) return true;
|
|
||||||
if (!sender.hasPermission("hmccosmetics.cmd.dataclear") && !sender.isOp()) {
|
if (!sender.hasPermission("hmccosmetics.cmd.dataclear") && !sender.isOp()) {
|
||||||
if (!silent) MessagesUtil.sendMessage(sender, "no-permission");
|
if (!silent) MessagesUtil.sendMessage(sender, "no-permission");
|
||||||
return true;
|
return true;
|
||||||
@@ -334,7 +333,7 @@ public class CosmeticCommand implements CommandExecutor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (args[2].equalsIgnoreCase("viewerlocation")) {
|
if (args[2].equalsIgnoreCase("viewerlocation")) {
|
||||||
WardrobeSettings.setViewerLocation(wardrobe, player.getLocation());
|
WardrobeSettings.setViewerLocation(wardrobe, player.getEyeLocation());
|
||||||
if (!silent) MessagesUtil.sendMessage(player, "set-wardrobe-viewing");
|
if (!silent) MessagesUtil.sendMessage(player, "set-wardrobe-viewing");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -352,7 +351,7 @@ public class CosmeticCommand implements CommandExecutor {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (args[2].equalsIgnoreCase("distance")) {
|
if (args[2].equalsIgnoreCase("distance")) {
|
||||||
WardrobeSettings.setWardrobeDistance(wardrobe, Integer.valueOf(args[3]));
|
WardrobeSettings.setWardrobeDistance(wardrobe, Integer.parseInt(args[3]));
|
||||||
if (!silent) MessagesUtil.sendMessage(player, "set-wardrobe-distance");
|
if (!silent) MessagesUtil.sendMessage(player, "set-wardrobe-distance");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,10 +3,13 @@ package com.hibiscusmc.hmccosmetics.config;
|
|||||||
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
|
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
|
||||||
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
import org.bukkit.GameMode;
|
||||||
import org.bukkit.inventory.EquipmentSlot;
|
import org.bukkit.inventory.EquipmentSlot;
|
||||||
import org.bukkit.util.Vector;
|
import org.bukkit.util.Vector;
|
||||||
import org.spongepowered.configurate.ConfigurationNode;
|
import org.spongepowered.configurate.ConfigurationNode;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
public class Settings {
|
public class Settings {
|
||||||
@@ -26,6 +29,8 @@ public class Settings {
|
|||||||
private static final String UNAPPLY_DEATH_PATH = "unapply-on-death";
|
private static final String UNAPPLY_DEATH_PATH = "unapply-on-death";
|
||||||
private static final String FORCE_PERMISSION_JOIN_PATH = "force-permission-join";
|
private static final String FORCE_PERMISSION_JOIN_PATH = "force-permission-join";
|
||||||
private static final String FORCE_SHOW_COSMETICS_PATH = "force-show-join";
|
private static final String FORCE_SHOW_COSMETICS_PATH = "force-show-join";
|
||||||
|
private static final String DISABLED_GAMEMODE_PATH = "disabled-gamemode";
|
||||||
|
private static final String DISABLED_GAMEMODE_GAMEMODES_PATH = "gamemodes";
|
||||||
private static final String EMOTE_DISTANCE_PATH = "emote-distance";
|
private static final String EMOTE_DISTANCE_PATH = "emote-distance";
|
||||||
private static final String HOOK_SETTING_PATH = "hook-settings";
|
private static final String HOOK_SETTING_PATH = "hook-settings";
|
||||||
private static final String HOOK_ITEMADDER_PATH = "itemsadder";
|
private static final String HOOK_ITEMADDER_PATH = "itemsadder";
|
||||||
@@ -33,13 +38,16 @@ public class Settings {
|
|||||||
private static final String HOOK_WORLDGUARD_PATH = "worldguard";
|
private static final String HOOK_WORLDGUARD_PATH = "worldguard";
|
||||||
private static final String HOOK_WG_MOVE_CHECK_PATH = "player-move-check";
|
private static final String HOOK_WG_MOVE_CHECK_PATH = "player-move-check";
|
||||||
private static final String HOOK_WG_MOVE_CHECK_PATH_LEGACY = "player_move_check";
|
private static final String HOOK_WG_MOVE_CHECK_PATH_LEGACY = "player_move_check";
|
||||||
|
private static final String COSMETIC_EMOTE_ENABLE = "emote-enable";
|
||||||
private static final String COSMETIC_EMOTE_CHECK_PATH = "emote-block-check";
|
private static final String COSMETIC_EMOTE_CHECK_PATH = "emote-block-check";
|
||||||
private static final String COSMETIC_EMOTE_AIR_CHECK_PATH = "emote-air-check";
|
private static final String COSMETIC_EMOTE_AIR_CHECK_PATH = "emote-air-check";
|
||||||
private static final String COSMETIC_EMOTE_DAMAGE_PATH = "emote-damage-leave";
|
private static final String COSMETIC_EMOTE_DAMAGE_PATH = "emote-damage-leave";
|
||||||
private static final String COSMETIC_EMOTE_INVINCIBLE_PATH = "emote-invincible";
|
private static final String COSMETIC_EMOTE_INVINCIBLE_PATH = "emote-invincible";
|
||||||
private static final String COSMETIC_EMOTE_CAMERA_PATH = "emote-camera";
|
private static final String COSMETIC_EMOTE_CAMERA_PATH = "emote-camera";
|
||||||
private static final String COSMETIC_EMOTE_MOVE_CHECK_PATH = "emote-move";
|
private static final String COSMETIC_EMOTE_MOVE_CHECK_PATH = "emote-move";
|
||||||
|
private static final String COSMETIC_PACKET_ENTITY_TELEPORT_COOLDOWN_PATH = "entity-cooldown-teleport-packet";
|
||||||
private static final String COSMETIC_BACKPACK_FORCE_RIDING_PACKET_PATH = "backpack-force-riding-packet";
|
private static final String COSMETIC_BACKPACK_FORCE_RIDING_PACKET_PATH = "backpack-force-riding-packet";
|
||||||
|
private static final String COSMETIC_FORCE_OFFHAND_COSMETIC_SHOW_PATH = "offhand-always-show";
|
||||||
private static final String COSMETIC_ADD_ENCHANTS_HELMET_PATH = "helmet-add-enchantments";
|
private static final String COSMETIC_ADD_ENCHANTS_HELMET_PATH = "helmet-add-enchantments";
|
||||||
private static final String COSMETIC_ADD_ENCHANTS_CHESTPLATE_PATH = "chest-add-enchantments";
|
private static final String COSMETIC_ADD_ENCHANTS_CHESTPLATE_PATH = "chest-add-enchantments";
|
||||||
private static final String COSMETIC_ADD_ENCHANTS_LEGGINGS_PATH = "leggings-add-enchantments";
|
private static final String COSMETIC_ADD_ENCHANTS_LEGGINGS_PATH = "leggings-add-enchantments";
|
||||||
@@ -103,10 +111,20 @@ public class Settings {
|
|||||||
@Getter
|
@Getter
|
||||||
private static boolean backpackForceRidingEnabled;
|
private static boolean backpackForceRidingEnabled;
|
||||||
@Getter
|
@Getter
|
||||||
|
private static boolean cosmeticForceOffhandCosmeticShow;
|
||||||
|
@Getter
|
||||||
|
private static boolean emotesEnabled;
|
||||||
|
@Getter
|
||||||
|
private static boolean disabledGamemodesEnabled;
|
||||||
|
@Getter
|
||||||
|
private static List<String> disabledGamemodes;
|
||||||
|
@Getter
|
||||||
private static int viewDistance;
|
private static int viewDistance;
|
||||||
@Getter
|
@Getter
|
||||||
private static int tickPeriod;
|
private static int tickPeriod;
|
||||||
@Getter
|
@Getter
|
||||||
|
private static int packetEntityTeleportCooldown;
|
||||||
|
@Getter
|
||||||
private static double emoteDistance;
|
private static double emoteDistance;
|
||||||
@Getter
|
@Getter
|
||||||
private static Vector balloonOffset;
|
private static Vector balloonOffset;
|
||||||
@@ -155,9 +173,18 @@ public class Settings {
|
|||||||
|
|
||||||
ConfigurationNode cosmeticSettings = source.node(COSMETIC_SETTINGS_PATH);
|
ConfigurationNode cosmeticSettings = source.node(COSMETIC_SETTINGS_PATH);
|
||||||
|
|
||||||
|
ConfigurationNode disabledGamemodeSettings = cosmeticSettings.node(DISABLED_GAMEMODE_PATH);
|
||||||
|
disabledGamemodesEnabled = disabledGamemodeSettings.node(ENABLED_PATH).getBoolean(true);
|
||||||
|
try {
|
||||||
|
disabledGamemodes = disabledGamemodeSettings.node(DISABLED_GAMEMODE_GAMEMODES_PATH).getList(String.class);
|
||||||
|
} catch (Exception e) {
|
||||||
|
disabledGamemodes = new ArrayList<>();
|
||||||
|
}
|
||||||
|
|
||||||
unapplyOnDeath = cosmeticSettings.node(UNAPPLY_DEATH_PATH).getBoolean(false);
|
unapplyOnDeath = cosmeticSettings.node(UNAPPLY_DEATH_PATH).getBoolean(false);
|
||||||
forcePermissionJoin = cosmeticSettings.node(FORCE_PERMISSION_JOIN_PATH).getBoolean(false);
|
forcePermissionJoin = cosmeticSettings.node(FORCE_PERMISSION_JOIN_PATH).getBoolean(false);
|
||||||
forceShowOnJoin = cosmeticSettings.node(FORCE_SHOW_COSMETICS_PATH).getBoolean(false);
|
forceShowOnJoin = cosmeticSettings.node(FORCE_SHOW_COSMETICS_PATH).getBoolean(false);
|
||||||
|
emotesEnabled = cosmeticSettings.node(COSMETIC_EMOTE_ENABLE).getBoolean(true);
|
||||||
emoteDistance = cosmeticSettings.node(EMOTE_DISTANCE_PATH).getDouble(-3);
|
emoteDistance = cosmeticSettings.node(EMOTE_DISTANCE_PATH).getDouble(-3);
|
||||||
cosmeticEmoteBlockCheck = cosmeticSettings.node(COSMETIC_EMOTE_CHECK_PATH).getBoolean(true);
|
cosmeticEmoteBlockCheck = cosmeticSettings.node(COSMETIC_EMOTE_CHECK_PATH).getBoolean(true);
|
||||||
emoteAirCheck = cosmeticSettings.node(COSMETIC_EMOTE_AIR_CHECK_PATH).getBoolean(true);
|
emoteAirCheck = cosmeticSettings.node(COSMETIC_EMOTE_AIR_CHECK_PATH).getBoolean(true);
|
||||||
@@ -173,6 +200,8 @@ public class Settings {
|
|||||||
viewDistance = cosmeticSettings.node(VIEW_DISTANCE_PATH).getInt(-3);
|
viewDistance = cosmeticSettings.node(VIEW_DISTANCE_PATH).getInt(-3);
|
||||||
emoteCameraEnabled = cosmeticSettings.node(COSMETIC_EMOTE_CAMERA_PATH).getBoolean(true);
|
emoteCameraEnabled = cosmeticSettings.node(COSMETIC_EMOTE_CAMERA_PATH).getBoolean(true);
|
||||||
emoteMoveCheck = cosmeticSettings.node(COSMETIC_EMOTE_MOVE_CHECK_PATH).getBoolean(false);
|
emoteMoveCheck = cosmeticSettings.node(COSMETIC_EMOTE_MOVE_CHECK_PATH).getBoolean(false);
|
||||||
|
packetEntityTeleportCooldown = cosmeticSettings.node(COSMETIC_PACKET_ENTITY_TELEPORT_COOLDOWN_PATH).getInt(-1);
|
||||||
|
cosmeticForceOffhandCosmeticShow = cosmeticSettings.node(COSMETIC_FORCE_OFFHAND_COSMETIC_SHOW_PATH).getBoolean(false);
|
||||||
|
|
||||||
ConfigurationNode menuSettings = source.node(MENU_SETTINGS_PATH);
|
ConfigurationNode menuSettings = source.node(MENU_SETTINGS_PATH);
|
||||||
|
|
||||||
|
|||||||
@@ -1,56 +1,52 @@
|
|||||||
package com.hibiscusmc.hmccosmetics.config;
|
package com.hibiscusmc.hmccosmetics.config;
|
||||||
|
|
||||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
public class Wardrobe {
|
public class Wardrobe {
|
||||||
|
|
||||||
private String id;
|
@Getter
|
||||||
private int distance = WardrobeSettings.getDisplayRadius();
|
private final String id;
|
||||||
|
@Getter @Setter
|
||||||
|
private int distance;
|
||||||
|
@Getter @Setter
|
||||||
private String permission;
|
private String permission;
|
||||||
|
@Getter @Setter
|
||||||
private WardrobeLocation location;
|
private WardrobeLocation location;
|
||||||
|
|
||||||
public Wardrobe(String id, WardrobeLocation location, @Nullable String permission, int distance) {
|
/**
|
||||||
|
* This creates a Wardrobe object with all the information that a user will need when entering.
|
||||||
|
* @param id The id of the wardrobe
|
||||||
|
* @param location The 3 locations of the Wardrobe, if any of these 3 locations are null, the wardrobe will not work
|
||||||
|
* @param permission The permission required to enter the wardrobe, if null, no permission is required
|
||||||
|
* @param distance The distance from the wardrobe that the player can be to enter, if -1, the player can enter from any distance
|
||||||
|
*/
|
||||||
|
public Wardrobe(@NotNull String id, @NotNull WardrobeLocation location, @Nullable String permission, int distance) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.location = location;
|
this.location = location;
|
||||||
if (permission != null) this.permission = permission;
|
|
||||||
if (distance != -1) this.distance = distance;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getId() {
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public WardrobeLocation getLocation() {
|
|
||||||
return location;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setDistance(int distance) {
|
|
||||||
this.distance = distance;
|
this.distance = distance;
|
||||||
|
if (permission != null) this.permission = permission;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPermission(String permission) {
|
/**
|
||||||
this.permission = permission;
|
* This checks if the wardrobe has a permission. If it's null, no permission is required and will return false. If it's not null, it will return true.
|
||||||
}
|
* @return if the wardrobe has a permission
|
||||||
|
*/
|
||||||
public boolean hasPermission() {
|
public boolean hasPermission() {
|
||||||
return permission != null;
|
return permission != null;
|
||||||
}
|
}
|
||||||
public int getDistance() {
|
|
||||||
return distance;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getPermission() {
|
/**
|
||||||
return permission;
|
* Calculates if a player can enter a wardrobe. Will return true if the player can enter, else false.
|
||||||
}
|
* @param user The user that is trying to enter the wardrobe
|
||||||
|
* @return if the player can enter the wardrobe
|
||||||
public void setLocation(WardrobeLocation location) {
|
*/
|
||||||
this.location = location;
|
public boolean canEnter(@NotNull CosmeticUser user) {
|
||||||
}
|
|
||||||
|
|
||||||
public boolean canEnter(CosmeticUser user) {
|
|
||||||
Location wardrobeLocation = location.getNpcLocation();
|
Location wardrobeLocation = location.getNpcLocation();
|
||||||
Location location = user.getEntity().getLocation();
|
Location location = user.getEntity().getLocation();
|
||||||
if (wardrobeLocation == null) return false;
|
if (wardrobeLocation == null) return false;
|
||||||
|
|||||||
@@ -1,37 +1,36 @@
|
|||||||
package com.hibiscusmc.hmccosmetics.config;
|
package com.hibiscusmc.hmccosmetics.config;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
public class WardrobeLocation {
|
public class WardrobeLocation {
|
||||||
|
|
||||||
@Setter
|
@Getter @Setter
|
||||||
private Location npcLocation;
|
private Location npcLocation;
|
||||||
@Setter
|
@Getter @Setter
|
||||||
private Location viewerLocation;
|
private Location viewerLocation;
|
||||||
@Setter
|
@Getter @Setter
|
||||||
private Location leaveLocation;
|
private Location leaveLocation;
|
||||||
|
|
||||||
public WardrobeLocation(Location npcLocation, Location viewerLocation, Location leaveLocation) {
|
/**
|
||||||
|
* This creates a WardrobeLocation object with the 3 locations that are required for a wardrobe to work
|
||||||
|
* @param npcLocation The location of the NPC
|
||||||
|
* @param viewerLocation The location of the viewer
|
||||||
|
* @param leaveLocation The location that the player will be teleported to when they leave the wardrobe if return-last-location in the config is false
|
||||||
|
*/
|
||||||
|
public WardrobeLocation(@Nullable Location npcLocation, @Nullable Location viewerLocation, @Nullable Location leaveLocation) {
|
||||||
this.npcLocation = npcLocation;
|
this.npcLocation = npcLocation;
|
||||||
this.viewerLocation = viewerLocation;
|
this.viewerLocation = viewerLocation;
|
||||||
this.leaveLocation = leaveLocation;
|
this.leaveLocation = leaveLocation;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Location getNpcLocation() {
|
/**
|
||||||
return npcLocation.clone();
|
* Checks if any of the locations are null
|
||||||
}
|
* @return true if all locations are not null, else false
|
||||||
|
*/
|
||||||
public Location getViewerLocation() {
|
|
||||||
return viewerLocation.clone();
|
|
||||||
}
|
|
||||||
|
|
||||||
public Location getLeaveLocation() {
|
|
||||||
return leaveLocation.clone();
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean hasAllLocations() {
|
public boolean hasAllLocations() {
|
||||||
if (npcLocation == null || viewerLocation == null || leaveLocation == null) return false;
|
return npcLocation != null && viewerLocation != null && leaveLocation != null;
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,7 +19,6 @@ import java.util.logging.Level;
|
|||||||
public class WardrobeSettings {
|
public class WardrobeSettings {
|
||||||
|
|
||||||
private static final String DISABLE_ON_DAMAGE_PATH = "disable-on-damage";
|
private static final String DISABLE_ON_DAMAGE_PATH = "disable-on-damage";
|
||||||
private static final String DISPLAY_RADIUS_PATH = "display-radius";
|
|
||||||
private static final String PORTABLE_PATH = "portable";
|
private static final String PORTABLE_PATH = "portable";
|
||||||
private static final String ALWAYS_DISPLAY_PATH = "always-display";
|
private static final String ALWAYS_DISPLAY_PATH = "always-display";
|
||||||
private static final String ROTATION_SPEED_PATH = "rotation-speed";
|
private static final String ROTATION_SPEED_PATH = "rotation-speed";
|
||||||
@@ -62,8 +61,6 @@ public class WardrobeSettings {
|
|||||||
@Getter
|
@Getter
|
||||||
private static boolean disableOnDamage;
|
private static boolean disableOnDamage;
|
||||||
@Getter
|
@Getter
|
||||||
private static int displayRadius;
|
|
||||||
@Getter
|
|
||||||
private static boolean portable;
|
private static boolean portable;
|
||||||
@Getter
|
@Getter
|
||||||
private static boolean alwaysDisplay;
|
private static boolean alwaysDisplay;
|
||||||
@@ -115,7 +112,6 @@ public class WardrobeSettings {
|
|||||||
configRoot = source;
|
configRoot = source;
|
||||||
|
|
||||||
disableOnDamage = source.node(DISABLE_ON_DAMAGE_PATH).getBoolean();
|
disableOnDamage = source.node(DISABLE_ON_DAMAGE_PATH).getBoolean();
|
||||||
displayRadius = source.node(DISPLAY_RADIUS_PATH).getInt();
|
|
||||||
portable = source.node(PORTABLE_PATH).getBoolean();
|
portable = source.node(PORTABLE_PATH).getBoolean();
|
||||||
alwaysDisplay = source.node(ALWAYS_DISPLAY_PATH).getBoolean();
|
alwaysDisplay = source.node(ALWAYS_DISPLAY_PATH).getBoolean();
|
||||||
rotationSpeed = source.node(ROTATION_SPEED_PATH).getInt();
|
rotationSpeed = source.node(ROTATION_SPEED_PATH).getInt();
|
||||||
@@ -169,10 +165,8 @@ public class WardrobeSettings {
|
|||||||
MessagesUtil.sendDebugMessages("Leave Location: " + leaveLocation);
|
MessagesUtil.sendDebugMessages("Leave Location: " + leaveLocation);
|
||||||
WardrobeLocation wardrobeLocation = new WardrobeLocation(npcLocation, viewerLocation, leaveLocation);
|
WardrobeLocation wardrobeLocation = new WardrobeLocation(npcLocation, viewerLocation, leaveLocation);
|
||||||
|
|
||||||
String permission = null;
|
String permission = wardrobesNode.node(PERMISSION_PATH).getString();
|
||||||
int distance = -1;
|
int distance = wardrobesNode.node(DISTANCE_PATH).getInt(-1);
|
||||||
if (!wardrobesNode.node(PERMISSION_PATH).virtual()) permission = wardrobesNode.node(PERMISSION_PATH).getString();
|
|
||||||
if (!wardrobesNode.node(DISTANCE_PATH).virtual()) distance = wardrobesNode.node(DISTANCE_PATH).getInt();
|
|
||||||
|
|
||||||
Wardrobe wardrobe = new Wardrobe(id, wardrobeLocation, permission, distance);
|
Wardrobe wardrobe = new Wardrobe(id, wardrobeLocation, permission, distance);
|
||||||
addWardrobe(wardrobe);
|
addWardrobe(wardrobe);
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import com.hibiscusmc.hmccosmetics.util.packets.PacketManager;
|
|||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.HumanEntity;
|
import org.bukkit.entity.HumanEntity;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.EquipmentSlot;
|
import org.bukkit.inventory.EquipmentSlot;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
@@ -31,16 +32,15 @@ public class CosmeticArmorType extends Cosmetic {
|
|||||||
if (user.getUserEmoteManager().isPlayingEmote()) return; // There has to be a better way of doing this...
|
if (user.getUserEmoteManager().isPlayingEmote()) return; // There has to be a better way of doing this...
|
||||||
ItemStack cosmeticItem = user.getUserCosmeticItem(this);
|
ItemStack cosmeticItem = user.getUserCosmeticItem(this);
|
||||||
if (!(entity instanceof HumanEntity humanEntity)) return;
|
if (!(entity instanceof HumanEntity humanEntity)) return;
|
||||||
if (equipSlot.equals(EquipmentSlot.OFF_HAND)) {
|
|
||||||
if (!humanEntity.getInventory().getItemInOffHand().getType().isAir()) return;
|
|
||||||
}
|
|
||||||
ItemStack equippedItem = humanEntity.getInventory().getItem(equipSlot);
|
ItemStack equippedItem = humanEntity.getInventory().getItem(equipSlot);
|
||||||
if (Settings.getShouldAddEnchants(equipSlot)) {
|
if (Settings.getShouldAddEnchants(equipSlot)) {
|
||||||
cosmeticItem.addUnsafeEnchantments(equippedItem.getEnchantments());
|
cosmeticItem.addUnsafeEnchantments(equippedItem.getEnchantments());
|
||||||
}
|
}
|
||||||
|
// Basically, if force offhand is off AND there is no item in an offhand slot, then the equipment packet to add the cosmetic
|
||||||
|
if (!Settings.isCosmeticForceOffhandCosmeticShow()
|
||||||
|
&& equipSlot.equals(EquipmentSlot.OFF_HAND)
|
||||||
|
&& ((entity instanceof Player) && !user.getPlayer().getInventory().getItemInOffHand().getType().isAir())) return;
|
||||||
NMSHandlers.getHandler().equipmentSlotUpdate(entity.getEntityId(), equipSlot, cosmeticItem, PacketManager.getViewers(entity.getLocation()));
|
NMSHandlers.getHandler().equipmentSlotUpdate(entity.getEntityId(), equipSlot, cosmeticItem, PacketManager.getViewers(entity.getLocation()));
|
||||||
//PacketManager.equipmentSlotUpdate(player, getSlot(), PacketManager.getViewers(player.getLocation())); Old method
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public EquipmentSlot getEquipSlot() {
|
public EquipmentSlot getEquipSlot() {
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ public class CosmeticBackpackType extends Cosmetic {
|
|||||||
List<Player> outsideViewers = user.getUserBackpackManager().getEntityManager().refreshViewers(loc);
|
List<Player> outsideViewers = user.getUserBackpackManager().getEntityManager().refreshViewers(loc);
|
||||||
|
|
||||||
user.getUserBackpackManager().getEntityManager().teleport(loc);
|
user.getUserBackpackManager().getEntityManager().teleport(loc);
|
||||||
user.getUserBackpackManager().getEntityManager().setRotation((int) loc.getYaw());
|
user.getUserBackpackManager().getEntityManager().setRotation((int) loc.getYaw(), isFirstPersonCompadible());
|
||||||
|
|
||||||
PacketManager.sendEntitySpawnPacket(user.getEntity().getLocation(), user.getUserBackpackManager().getFirstArmorStandId(), EntityType.ARMOR_STAND, UUID.randomUUID(), outsideViewers);
|
PacketManager.sendEntitySpawnPacket(user.getEntity().getLocation(), user.getUserBackpackManager().getFirstArmorStandId(), EntityType.ARMOR_STAND, UUID.randomUUID(), outsideViewers);
|
||||||
PacketManager.sendArmorstandMetadata(user.getUserBackpackManager().getFirstArmorStandId(), outsideViewers);
|
PacketManager.sendArmorstandMetadata(user.getUserBackpackManager().getFirstArmorStandId(), outsideViewers);
|
||||||
|
|||||||
@@ -91,8 +91,7 @@ public class CosmeticBalloonType extends Cosmetic {
|
|||||||
if (!user.getHidden() && showLead) {
|
if (!user.getHidden() && showLead) {
|
||||||
List<Player> sendTo = userBalloonManager.getPufferfish().refreshViewers(newLocation);
|
List<Player> sendTo = userBalloonManager.getPufferfish().refreshViewers(newLocation);
|
||||||
if (sendTo.isEmpty()) return;
|
if (sendTo.isEmpty()) return;
|
||||||
PacketManager.sendEntitySpawnPacket(newLocation, userBalloonManager.getPufferfishBalloonId(), EntityType.PUFFERFISH, userBalloonManager.getPufferfishBalloonUniqueId(), sendTo);
|
user.getBalloonManager().getPufferfish().spawnPufferfish(newLocation, sendTo);
|
||||||
PacketManager.sendInvisibilityPacket(userBalloonManager.getPufferfishBalloonId(), sendTo);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package com.hibiscusmc.hmccosmetics.gui.action.actions;
|
package com.hibiscusmc.hmccosmetics.gui.action.actions;
|
||||||
|
|
||||||
import com.hibiscusmc.hmccosmetics.gui.action.Action;
|
import com.hibiscusmc.hmccosmetics.gui.action.Action;
|
||||||
|
import com.hibiscusmc.hmccosmetics.hooks.Hooks;
|
||||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||||
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
@@ -13,6 +14,6 @@ public class ActionPlayerCommand extends Action {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run(@NotNull CosmeticUser user, String raw) {
|
public void run(@NotNull CosmeticUser user, String raw) {
|
||||||
user.getPlayer().performCommand(MessagesUtil.processStringNoKeyString(user.getPlayer(), raw));
|
user.getPlayer().performCommand(MessagesUtil.processStringNoKeyString(user.getPlayer(), Hooks.processPlaceholders(user.getPlayer(), raw)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -18,6 +18,7 @@ import org.bukkit.event.inventory.ClickType;
|
|||||||
import org.bukkit.inventory.EquipmentSlot;
|
import org.bukkit.inventory.EquipmentSlot;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.inventory.meta.ItemMeta;
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
|
import org.bukkit.inventory.meta.SkullMeta;
|
||||||
import org.jetbrains.annotations.Contract;
|
import org.jetbrains.annotations.Contract;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.spongepowered.configurate.ConfigurationNode;
|
import org.spongepowered.configurate.ConfigurationNode;
|
||||||
@@ -186,6 +187,12 @@ public class TypeCosmetic extends Type {
|
|||||||
processedLore.add(Hooks.processPlaceholders(user.getPlayer(), loreLine));
|
processedLore.add(Hooks.processPlaceholders(user.getPlayer(), loreLine));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (itemMeta instanceof SkullMeta skullMeta) {
|
||||||
|
if (skullMeta.hasOwner()) {
|
||||||
|
skullMeta.setOwner(Hooks.processPlaceholders(user.getPlayer(), skullMeta.getOwner()));
|
||||||
|
}
|
||||||
|
}
|
||||||
itemMeta.setLore(processedLore);
|
itemMeta.setLore(processedLore);
|
||||||
return itemMeta;
|
return itemMeta;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
|||||||
import org.bukkit.event.inventory.ClickType;
|
import org.bukkit.event.inventory.ClickType;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.inventory.meta.ItemMeta;
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
|
import org.bukkit.inventory.meta.SkullMeta;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.spongepowered.configurate.ConfigurationNode;
|
import org.spongepowered.configurate.ConfigurationNode;
|
||||||
import org.spongepowered.configurate.serialize.SerializationException;
|
import org.spongepowered.configurate.serialize.SerializationException;
|
||||||
@@ -72,6 +73,14 @@ public class TypeEmpty extends Type {
|
|||||||
processedLore.add(Hooks.processPlaceholders(user.getPlayer(), loreLine));
|
processedLore.add(Hooks.processPlaceholders(user.getPlayer(), loreLine));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (itemMeta instanceof SkullMeta skullMeta) {
|
||||||
|
if (skullMeta.hasOwner()) {
|
||||||
|
skullMeta.setOwner(Hooks.processPlaceholders(user.getPlayer(), skullMeta.getOwner()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
itemMeta.setLore(processedLore);
|
||||||
itemStack.setItemMeta(itemMeta);
|
itemStack.setItemMeta(itemMeta);
|
||||||
return itemStack;
|
return itemStack;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ public class Hooks {
|
|||||||
private static final HookCMI CMI_HOOK = new HookCMI();
|
private static final HookCMI CMI_HOOK = new HookCMI();
|
||||||
private static final HookLibsDisguises LIBS_DISGUISES_HOOK = new HookLibsDisguises();
|
private static final HookLibsDisguises LIBS_DISGUISES_HOOK = new HookLibsDisguises();
|
||||||
private static final HookModelEngine MODEL_ENGINE_HOOK = new HookModelEngine();
|
private static final HookModelEngine MODEL_ENGINE_HOOK = new HookModelEngine();
|
||||||
|
private static final HookMMOItems MMO_ITEMS_HOOK = new HookMMOItems();
|
||||||
|
|
||||||
public static Hook getHook(@NotNull String id) {
|
public static Hook getHook(@NotNull String id) {
|
||||||
return hooks.get(id.toLowerCase());
|
return hooks.get(id.toLowerCase());
|
||||||
|
|||||||
@@ -1,12 +1,8 @@
|
|||||||
package com.hibiscusmc.hmccosmetics.hooks.items;
|
package com.hibiscusmc.hmccosmetics.hooks.items;
|
||||||
|
|
||||||
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
|
|
||||||
import com.hibiscusmc.hmccosmetics.hooks.Hook;
|
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.papermc.tracking.items.ItemTrackingKt;
|
||||||
import com.mineinabyss.geary.prefabs.PrefabKey;
|
import com.mineinabyss.geary.prefabs.PrefabKey;
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
@@ -14,31 +10,19 @@ import org.jetbrains.annotations.NotNull;
|
|||||||
* A hook that integrates the plugin {@link com.mineinabyss.geary.papermc.GearyPlugin Geary} to provide custom items
|
* A hook that integrates the plugin {@link com.mineinabyss.geary.papermc.GearyPlugin Geary} to provide custom items
|
||||||
*/
|
*/
|
||||||
public class HookGeary extends Hook {
|
public class HookGeary extends Hook {
|
||||||
private boolean enabled = false;
|
|
||||||
|
|
||||||
public HookGeary() {
|
public HookGeary() {
|
||||||
super("geary");
|
super("geary");
|
||||||
setEnabledItemHook(true);
|
setEnabledItemHook(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void load() {
|
|
||||||
if (!enabled) GearyModuleKt.getGeary().getPipeline().intercept(GearyPhase.INIT_ENTITIES, () -> {
|
|
||||||
enabled = true;
|
|
||||||
HMCCosmeticsPlugin.setup();
|
|
||||||
return null;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets a cosmetic {@link ItemStack} that is associated with the provided id from the plugin {@link com.mineinabyss.geary.papermc.GearyPlugin Geary}
|
* Gets a cosmetic {@link ItemStack} that is associated with the provided id from the plugin {@link com.mineinabyss.geary.papermc.GearyPlugin Geary}
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public ItemStack getItem(@NotNull String itemId) {
|
public ItemStack getItem(@NotNull String itemId) {
|
||||||
if (enabled) {
|
PrefabKey prefabKey = PrefabKey.Companion.ofOrNull(itemId);
|
||||||
PrefabKey prefabKey = PrefabKey.Companion.ofOrNull(itemId);
|
if (prefabKey == null) return null;
|
||||||
if (prefabKey == null) return null;
|
return ItemTrackingKt.getGearyItems().createItem(prefabKey, null);
|
||||||
return ItemTrackingKt.getGearyItems().createItem(prefabKey, null);
|
|
||||||
} else return new ItemStack(Material.AIR);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,22 @@
|
|||||||
|
package com.hibiscusmc.hmccosmetics.hooks.items;
|
||||||
|
|
||||||
|
import com.hibiscusmc.hmccosmetics.hooks.Hook;
|
||||||
|
import net.Indyuce.mmoitems.MMOItems;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
public class HookMMOItems extends Hook {
|
||||||
|
public HookMMOItems() {
|
||||||
|
super("MMOItems");
|
||||||
|
setEnabledItemHook(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ItemStack getItem(@NotNull String itemId) {
|
||||||
|
String[] split = itemId.split(":", 2);
|
||||||
|
if (split.length == 2) {
|
||||||
|
return MMOItems.plugin.getItem(split[0], split[1]);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -54,18 +54,15 @@ public class HMCPlaceholderExpansion extends PlaceholderExpansion {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String onRequest(@NotNull OfflinePlayer player, @NotNull String params) {
|
public String onRequest(@NotNull OfflinePlayer player, @NotNull String params) {
|
||||||
if (!player.isOnline()) return null;
|
if (!player.isOnline()) return TranslationUtil.getTranslation("user-cosmetic", "offline");
|
||||||
CosmeticUser user = CosmeticUsers.getUser(player.getPlayer());
|
CosmeticUser user = CosmeticUsers.getUser(player.getPlayer());
|
||||||
if (user == null) return null;
|
if (user == null) return TranslationUtil.getTranslation("user-cosmetic", "invalid-user");
|
||||||
|
|
||||||
List<String> placeholderArgs = Arrays.asList(params.split("_", 3));
|
List<String> placeholderArgs = Arrays.asList(params.split("_", 3));
|
||||||
|
|
||||||
switch (placeholderArgs.get(0).toLowerCase()) {
|
switch (placeholderArgs.get(0).toLowerCase()) {
|
||||||
case "using":
|
case "using":
|
||||||
if (placeholderArgs == null) {
|
if (placeholderArgs.size() >= 2) {
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if (placeholderArgs.get(1) != null) {
|
|
||||||
Cosmetic cosmetic = Cosmetics.getCosmetic(placeholderArgs.get(1));
|
Cosmetic cosmetic = Cosmetics.getCosmetic(placeholderArgs.get(1));
|
||||||
if (cosmetic == null) return "INVALID_COSMETIC";
|
if (cosmetic == null) return "INVALID_COSMETIC";
|
||||||
Cosmetic currentCosmetic = user.getCosmetic(cosmetic.getSlot());
|
Cosmetic currentCosmetic = user.getCosmetic(cosmetic.getSlot());
|
||||||
@@ -74,13 +71,10 @@ public class HMCPlaceholderExpansion extends PlaceholderExpansion {
|
|||||||
return TranslationUtil.getTranslation("using-cosmetic", String.valueOf(false));
|
return TranslationUtil.getTranslation("using-cosmetic", String.valueOf(false));
|
||||||
}
|
}
|
||||||
case "current":
|
case "current":
|
||||||
if (placeholderArgs == null) {
|
if (placeholderArgs.size() >= 2) {
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if (placeholderArgs.get(1) != null) {
|
|
||||||
CosmeticSlot slot = CosmeticSlot.valueOf(placeholderArgs.get(1).toUpperCase());
|
CosmeticSlot slot = CosmeticSlot.valueOf(placeholderArgs.get(1).toUpperCase());
|
||||||
if (slot == null) return null;
|
if (slot == null) return null;
|
||||||
if (user.getCosmetic(slot) == null) return null;
|
if (user.getCosmetic(slot) == null) return TranslationUtil.getTranslation("current-cosmetic", "no-cosmetic");
|
||||||
if (placeholderArgs.size() == 2) return user.getCosmetic(slot).getId();
|
if (placeholderArgs.size() == 2) return user.getCosmetic(slot).getId();
|
||||||
|
|
||||||
String output;
|
String output;
|
||||||
@@ -104,13 +98,11 @@ public class HMCPlaceholderExpansion extends PlaceholderExpansion {
|
|||||||
output = user.getCosmetic(slot).getId();
|
output = user.getCosmetic(slot).getId();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return TranslationUtil.getTranslation("current-cosmetic", String.valueOf(output));
|
if (output == null) output = "none";
|
||||||
|
return TranslationUtil.getTranslation("current-cosmetic", output);
|
||||||
}
|
}
|
||||||
case "unlocked":
|
case "unlocked":
|
||||||
if (placeholderArgs == null) {
|
if (placeholderArgs.size() >= 2) {
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if (placeholderArgs.get(1) != null) {
|
|
||||||
Cosmetic cosmetic = Cosmetics.getCosmetic(placeholderArgs.get(1));
|
Cosmetic cosmetic = Cosmetics.getCosmetic(placeholderArgs.get(1));
|
||||||
if (cosmetic == null) {
|
if (cosmetic == null) {
|
||||||
if (placeholderArgs.size() >= 3) {
|
if (placeholderArgs.size() >= 3) {
|
||||||
@@ -127,10 +119,7 @@ public class HMCPlaceholderExpansion extends PlaceholderExpansion {
|
|||||||
return TranslationUtil.getTranslation("unlocked-cosmetic", String.valueOf(user.canEquipCosmetic(cosmetic, true)));
|
return TranslationUtil.getTranslation("unlocked-cosmetic", String.valueOf(user.canEquipCosmetic(cosmetic, true)));
|
||||||
}
|
}
|
||||||
case "equipped":
|
case "equipped":
|
||||||
if (placeholderArgs == null) {
|
if (placeholderArgs.size() >= 2) {
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if (placeholderArgs.get(1) != null) {
|
|
||||||
String args1 = placeholderArgs.get(1);
|
String args1 = placeholderArgs.get(1);
|
||||||
|
|
||||||
if (EnumUtils.isValidEnum(CosmeticSlot.class, args1.toUpperCase())) {
|
if (EnumUtils.isValidEnum(CosmeticSlot.class, args1.toUpperCase())) {
|
||||||
@@ -216,6 +205,7 @@ public class HMCPlaceholderExpansion extends PlaceholderExpansion {
|
|||||||
if (!item.hasItemMeta()) return null;
|
if (!item.hasItemMeta()) return null;
|
||||||
ItemMeta itemMeta = item.getItemMeta();
|
ItemMeta itemMeta = item.getItemMeta();
|
||||||
if (itemMeta == null) return null;
|
if (itemMeta == null) return null;
|
||||||
|
if (!itemMeta.hasDisplayName()) return null;
|
||||||
return itemMeta.getDisplayName();
|
return itemMeta.getDisplayName();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,8 +8,6 @@ import com.hibiscusmc.hmccosmetics.user.CosmeticUsers;
|
|||||||
import com.hibiscusmc.hmccosmetics.user.manager.UserEmoteManager;
|
import com.hibiscusmc.hmccosmetics.user.manager.UserEmoteManager;
|
||||||
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.entity.Entity;
|
|
||||||
import org.bukkit.entity.EntityType;
|
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
@@ -51,16 +49,7 @@ public class PlayerConnectionListener implements Listener {
|
|||||||
@EventHandler(priority = EventPriority.MONITOR)
|
@EventHandler(priority = EventPriority.MONITOR)
|
||||||
public void onPlayerQuit(@NotNull PlayerQuitEvent event) {
|
public void onPlayerQuit(@NotNull PlayerQuitEvent event) {
|
||||||
CosmeticUser user = CosmeticUsers.getUser(event.getPlayer());
|
CosmeticUser user = CosmeticUsers.getUser(event.getPlayer());
|
||||||
if (user == null) { // Remove any passengers if a user failed to initialize. Bugs can cause this to happen
|
if (user == null) return; // Player never initialized, don't do anything
|
||||||
if (!event.getPlayer().getPassengers().isEmpty()) {
|
|
||||||
for (Entity entity : event.getPlayer().getPassengers()) {
|
|
||||||
if (entity.getType() == EntityType.ARMOR_STAND) {
|
|
||||||
entity.remove();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (user.isInWardrobe()) user.leaveWardrobe();
|
if (user.isInWardrobe()) user.leaveWardrobe();
|
||||||
if (user.getUserEmoteManager().isPlayingEmote()) {
|
if (user.getUserEmoteManager().isPlayingEmote()) {
|
||||||
user.getUserEmoteManager().stopEmote(UserEmoteManager.StopEmoteReason.CONNECTION);
|
user.getUserEmoteManager().stopEmote(UserEmoteManager.StopEmoteReason.CONNECTION);
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticBalloonType;
|
|||||||
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticEmoteType;
|
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticEmoteType;
|
||||||
import com.hibiscusmc.hmccosmetics.gui.Menu;
|
import com.hibiscusmc.hmccosmetics.gui.Menu;
|
||||||
import com.hibiscusmc.hmccosmetics.gui.Menus;
|
import com.hibiscusmc.hmccosmetics.gui.Menus;
|
||||||
|
import com.hibiscusmc.hmccosmetics.nms.NMSHandlers;
|
||||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUsers;
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUsers;
|
||||||
import com.hibiscusmc.hmccosmetics.user.manager.UserEmoteManager;
|
import com.hibiscusmc.hmccosmetics.user.manager.UserEmoteManager;
|
||||||
@@ -56,6 +57,7 @@ public class PlayerGameListener implements Listener {
|
|||||||
public PlayerGameListener() {
|
public PlayerGameListener() {
|
||||||
registerInventoryClickListener();
|
registerInventoryClickListener();
|
||||||
registerMenuChangeListener();
|
registerMenuChangeListener();
|
||||||
|
registerEntityStatusListener();
|
||||||
registerPlayerEquipmentListener();
|
registerPlayerEquipmentListener();
|
||||||
registerPlayerArmListener();
|
registerPlayerArmListener();
|
||||||
registerEntityUseListener();
|
registerEntityUseListener();
|
||||||
@@ -161,7 +163,6 @@ public class PlayerGameListener implements Listener {
|
|||||||
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
||||||
public void onPlayerHit(EntityDamageByEntityEvent event) {
|
public void onPlayerHit(EntityDamageByEntityEvent event) {
|
||||||
Entity entity = event.getEntity();
|
Entity entity = event.getEntity();
|
||||||
if (event.getEntity().getEntityId() == event.getDamager().getEntityId()) event.setCancelled(true);
|
|
||||||
if (!entity.getPersistentDataContainer().has(new NamespacedKey(HMCCosmeticsPlugin.getInstance(), "cosmeticMob"), PersistentDataType.SHORT))
|
if (!entity.getPersistentDataContainer().has(new NamespacedKey(HMCCosmeticsPlugin.getInstance(), "cosmeticMob"), PersistentDataType.SHORT))
|
||||||
return;
|
return;
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
@@ -263,7 +264,13 @@ public class PlayerGameListener implements Listener {
|
|||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Bukkit.getScheduler().runTaskLater(HMCCosmeticsPlugin.getInstance(), () -> user.updateCosmetic(CosmeticSlot.OFFHAND), 2);
|
Bukkit.getScheduler().runTaskLater(HMCCosmeticsPlugin.getInstance(), () -> {
|
||||||
|
user.updateCosmetic(CosmeticSlot.OFFHAND);
|
||||||
|
List<Player> viewers = PacketManager.getViewers(user.getEntity().getLocation());
|
||||||
|
if (viewers.isEmpty()) return;
|
||||||
|
viewers.remove(user.getPlayer());
|
||||||
|
NMSHandlers.getHandler().equipmentSlotUpdate(user.getEntity().getEntityId(), EquipmentSlot.HAND, event.getPlayer().getInventory().getItemInMainHand(), viewers);
|
||||||
|
}, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.NORMAL)
|
@EventHandler(priority = EventPriority.NORMAL)
|
||||||
@@ -328,6 +335,16 @@ public class PlayerGameListener implements Listener {
|
|||||||
CosmeticUser user = CosmeticUsers.getUser(event.getPlayer());
|
CosmeticUser user = CosmeticUsers.getUser(event.getPlayer());
|
||||||
if (user == null) return;
|
if (user == null) return;
|
||||||
|
|
||||||
|
if (Settings.isDisabledGamemodesEnabled()) {
|
||||||
|
if (Settings.getDisabledGamemodes().contains(event.getNewGameMode().toString())) {
|
||||||
|
user.hideCosmetics(CosmeticUser.HiddenReason.GAMEMODE);
|
||||||
|
} else {
|
||||||
|
if (user.getHiddenReason() != null && user.getHiddenReason().equals(CosmeticUser.HiddenReason.GAMEMODE)) {
|
||||||
|
user.showCosmetics();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (Settings.isDestroyLooseCosmetics()) {
|
if (Settings.isDestroyLooseCosmetics()) {
|
||||||
ItemStack[] equippedArmor = event.getPlayer().getInventory().getArmorContents();
|
ItemStack[] equippedArmor = event.getPlayer().getInventory().getArmorContents();
|
||||||
if (equippedArmor.length == 0) return;
|
if (equippedArmor.length == 0) return;
|
||||||
@@ -341,11 +358,14 @@ public class PlayerGameListener implements Listener {
|
|||||||
public void onPlayerCosmeticEquip(PlayerCosmeticPostEquipEvent event) {
|
public void onPlayerCosmeticEquip(PlayerCosmeticPostEquipEvent event) {
|
||||||
CosmeticUser user = event.getUser();
|
CosmeticUser user = event.getUser();
|
||||||
if (user.isInWardrobe() && event.getCosmetic().getSlot().equals(CosmeticSlot.BALLOON)) {
|
if (user.isInWardrobe() && event.getCosmetic().getSlot().equals(CosmeticSlot.BALLOON)) {
|
||||||
Location NPCLocation = user.getWardrobeManager().getNpcLocation();
|
|
||||||
CosmeticBalloonType cosmetic = (CosmeticBalloonType) event.getCosmetic();
|
CosmeticBalloonType cosmetic = (CosmeticBalloonType) event.getCosmetic();
|
||||||
|
Location npclocation = user.getWardrobeManager().getNpcLocation().clone().add(cosmetic.getBalloonOffset());
|
||||||
// We know that no other entity besides a regular player will be in the wardrobe
|
// We know that no other entity besides a regular player will be in the wardrobe
|
||||||
PacketManager.sendTeleportPacket(user.getBalloonManager().getPufferfishBalloonId(), NPCLocation.add(cosmetic.getBalloonOffset()), false, List.of(user.getPlayer()));
|
List<Player> viewer = List.of(user.getPlayer());
|
||||||
user.getBalloonManager().getModelEntity().teleport(NPCLocation.add(cosmetic.getBalloonOffset()));
|
user.getBalloonManager().getPufferfish().spawnPufferfish(npclocation.clone().add(cosmetic.getBalloonOffset()), viewer);
|
||||||
|
PacketManager.sendLeashPacket(user.getBalloonManager().getPufferfishBalloonId(), user.getWardrobeManager().getNPC_ID(), viewer);
|
||||||
|
PacketManager.sendTeleportPacket(user.getBalloonManager().getPufferfishBalloonId(), npclocation, false, viewer);
|
||||||
|
user.getBalloonManager().getModelEntity().teleport(npclocation);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -479,14 +499,32 @@ public class PlayerGameListener implements Listener {
|
|||||||
if (user == null) {
|
if (user == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
List<com.comphenix.protocol.wrappers.Pair<EnumWrappers.ItemSlot, ItemStack>> armor = event.getPacket().getSlotStackPairLists().read(0);
|
List<com.comphenix.protocol.wrappers.Pair<EnumWrappers.ItemSlot, ItemStack>> armor = event.getPacket().getSlotStackPairLists().read(0);
|
||||||
|
|
||||||
for (EquipmentSlot equipmentSlot : EquipmentSlot.values()) {
|
for (int i = 0; i < armor.size(); i++) {
|
||||||
CosmeticArmorType cosmeticArmor = (CosmeticArmorType) user.getCosmetic(InventoryUtils.BukkitCosmeticSlot(equipmentSlot));
|
com.comphenix.protocol.wrappers.Pair<EnumWrappers.ItemSlot, ItemStack> pair = armor.get(i);
|
||||||
if (cosmeticArmor == null) continue;
|
switch (pair.getFirst()) {
|
||||||
Pair<EnumWrappers.ItemSlot, ItemStack> pair = new Pair<>(InventoryUtils.itemBukkitSlot(cosmeticArmor.getEquipSlot()), cosmeticArmor.getItem());
|
case MAINHAND -> {
|
||||||
armor.add(pair);
|
if (user.getPlayer() == event.getPlayer()) continue; // When a player scrolls real fast, it messes up the mainhand. This fixes it
|
||||||
|
armor.set(i, new Pair<>(pair.getFirst(), user.getPlayer().getInventory().getItemInMainHand()));
|
||||||
|
}
|
||||||
|
case OFFHAND -> {
|
||||||
|
if (Settings.isCosmeticForceOffhandCosmeticShow() && user.hasCosmeticInSlot(CosmeticSlot.OFFHAND)) {
|
||||||
|
ItemStack item = user.getUserCosmeticItem(CosmeticSlot.OFFHAND);
|
||||||
|
if (item == null) continue;
|
||||||
|
Pair<EnumWrappers.ItemSlot, ItemStack> offhandPair = new Pair<>(EnumWrappers.ItemSlot.OFFHAND, item);
|
||||||
|
armor.set(i, offhandPair);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
default -> {
|
||||||
|
CosmeticArmorType cosmeticArmor = (CosmeticArmorType) user.getCosmetic(InventoryUtils.getItemSlotToCosmeticSlot(pair.getFirst()));
|
||||||
|
if (cosmeticArmor == null) continue;
|
||||||
|
ItemStack item = user.getUserCosmeticItem(cosmeticArmor);
|
||||||
|
if (item == null) continue;
|
||||||
|
Pair<EnumWrappers.ItemSlot, ItemStack> armorPair = new Pair<>(InventoryUtils.itemBukkitSlot(cosmeticArmor.getEquipSlot()), item);
|
||||||
|
armor.set(i, armorPair);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
event.getPacket().getSlotStackPairLists().write(0, armor);
|
event.getPacket().getSlotStackPairLists().write(0, armor);
|
||||||
@@ -495,6 +533,27 @@ public class PlayerGameListener implements Listener {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void registerEntityStatusListener() {
|
||||||
|
ProtocolLibrary.getProtocolManager().addPacketListener(new PacketAdapter(HMCCosmeticsPlugin.getInstance(), ListenerPriority.NORMAL, PacketType.Play.Server.ENTITY_STATUS) {
|
||||||
|
@Override
|
||||||
|
public void onPacketSending(PacketEvent event) {
|
||||||
|
int entityid = event.getPacket().getIntegers().read(0);
|
||||||
|
byte status = event.getPacket().getBytes().read(0);
|
||||||
|
|
||||||
|
MessagesUtil.sendDebugMessages("EntityStatus Initial " + entityid + " - " + status);
|
||||||
|
if (status != 55) return;
|
||||||
|
|
||||||
|
CosmeticUser user = CosmeticUsers.getUser(entityid);
|
||||||
|
if (user == null) {
|
||||||
|
MessagesUtil.sendDebugMessages("EntityStatus User is null");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!user.hasCosmeticInSlot(CosmeticSlot.OFFHAND)) return;
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
private void registerPlayerArmListener() {
|
private void registerPlayerArmListener() {
|
||||||
ProtocolLibrary.getProtocolManager().addPacketListener(new PacketAdapter(HMCCosmeticsPlugin.getInstance(), ListenerPriority.NORMAL, PacketType.Play.Client.ARM_ANIMATION) {
|
ProtocolLibrary.getProtocolManager().addPacketListener(new PacketAdapter(HMCCosmeticsPlugin.getInstance(), ListenerPriority.NORMAL, PacketType.Play.Client.ARM_ANIMATION) {
|
||||||
@Override
|
@Override
|
||||||
@@ -538,7 +597,11 @@ public class PlayerGameListener implements Listener {
|
|||||||
MessagesUtil.sendDebugMessages("Look Packet ");
|
MessagesUtil.sendDebugMessages("Look Packet ");
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
if (event.getPlayer() == null) return;
|
if (event.getPlayer() == null) return;
|
||||||
if (!(event.getPlayer() instanceof Player)) return;
|
CosmeticUser user = CosmeticUsers.getUser(player);
|
||||||
|
if (user == null) return;
|
||||||
|
if (user.isBackpackSpawned()) {
|
||||||
|
user.getUserBackpackManager().getEntityManager().setRotation(Math.round(event.getPacket().getFloat().read(0)));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -551,20 +614,29 @@ public class PlayerGameListener implements Listener {
|
|||||||
MessagesUtil.sendDebugMessages("Position Packet ");
|
MessagesUtil.sendDebugMessages("Position Packet ");
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
if (event.getPlayer() == null) return;
|
if (event.getPlayer() == null) return;
|
||||||
if (!(event.getPlayer() instanceof Player)) return;
|
CosmeticUser user = CosmeticUsers.getUser(player);
|
||||||
|
if (user == null) return;
|
||||||
|
if (user.isBackpackSpawned()) {
|
||||||
|
// The yaw follows the head, which makes it look weird and do weird things when moving around
|
||||||
|
user.getUserBackpackManager().getEntityManager().teleport(new Location(player.getWorld(), event.getPacket().getDoubles().read(0), event.getPacket().getDoubles().read(1), event.getPacket().getDoubles().read(2), event.getPacket().getFloat().read(0), event.getPacket().getFloat().read(1)));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void registerTeleportMovement() {
|
private void registerTeleportMovement() {
|
||||||
ProtocolLibrary.getProtocolManager().addPacketListener(new PacketAdapter(HMCCosmeticsPlugin.getInstance(), ListenerPriority.NORMAL, PacketType.Play.Client.TELEPORT_ACCEPT) {
|
ProtocolLibrary.getProtocolManager().addPacketListener(new PacketAdapter(HMCCosmeticsPlugin.getInstance(), ListenerPriority.NORMAL, PacketType.Play.Client.POSITION_LOOK) {
|
||||||
@Override
|
@Override
|
||||||
public void onPacketReceiving(PacketEvent event) {
|
public void onPacketReceiving(PacketEvent event) {
|
||||||
// TODO: Finish
|
// TODO: Finish
|
||||||
MessagesUtil.sendDebugMessages("Teleport Packet ");
|
MessagesUtil.sendDebugMessages("Teleport Packet ");
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
if (event.getPlayer() == null) return;
|
if (event.getPlayer() == null) return;
|
||||||
if (!(event.getPlayer() instanceof Player)) return;
|
CosmeticUser user = CosmeticUsers.getUser(player);
|
||||||
|
if (user == null) return;
|
||||||
|
if (user.isBackpackSpawned()) {
|
||||||
|
Bukkit.getScheduler().runTask(HMCCosmeticsPlugin.getInstance(), () -> user.updateCosmetic(CosmeticSlot.BACKPACK));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
package com.hibiscusmc.hmccosmetics.nms;
|
package com.hibiscusmc.hmccosmetics.nms;
|
||||||
|
|
||||||
import com.hibiscusmc.hmccosmetics.cosmetic.CosmeticSlot;
|
|
||||||
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticBackpackType;
|
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticBackpackType;
|
||||||
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticBalloonType;
|
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticBalloonType;
|
||||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||||
@@ -19,24 +18,12 @@ public interface NMSHandler {
|
|||||||
|
|
||||||
Entity getEntity(int entityId);
|
Entity getEntity(int entityId);
|
||||||
|
|
||||||
Entity getHMCArmorStand(Location loc);
|
|
||||||
|
|
||||||
ArmorStand getMEGEntity(Location loc);
|
ArmorStand getMEGEntity(Location loc);
|
||||||
|
|
||||||
Entity spawnBackpack(CosmeticUser user, CosmeticBackpackType cosmeticBackpackType);
|
|
||||||
|
|
||||||
Entity spawnDisplayEntity(Location location, String text);
|
Entity spawnDisplayEntity(Location location, String text);
|
||||||
|
|
||||||
UserBalloonManager spawnBalloon(CosmeticUser user, CosmeticBalloonType cosmeticBalloonType);
|
UserBalloonManager spawnBalloon(CosmeticUser user, CosmeticBalloonType cosmeticBalloonType);
|
||||||
|
|
||||||
@Deprecated(since = "2.6.0")
|
|
||||||
void equipmentSlotUpdate(
|
|
||||||
int entityId,
|
|
||||||
CosmeticUser user,
|
|
||||||
CosmeticSlot cosmeticSlot,
|
|
||||||
List<Player> sendTo
|
|
||||||
);
|
|
||||||
|
|
||||||
void slotUpdate(
|
void slotUpdate(
|
||||||
Player player,
|
Player player,
|
||||||
int slot
|
int slot
|
||||||
|
|||||||
@@ -3,17 +3,19 @@ package com.hibiscusmc.hmccosmetics.nms;
|
|||||||
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
|
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
|
||||||
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
public class NMSHandlers {
|
public class NMSHandlers {
|
||||||
|
|
||||||
private static final String[] SUPPORTED_VERSION = new String[]{"v1_18_R2", "v1_19_R1", "v1_19_R2", "v1_19_R3", "v1_20_R1"};
|
private static final String[] SUPPORTED_VERSION = new String[]{"v1_18_R2", "v1_19_R1", "v1_19_R2", "v1_19_R3", "v1_20_R1", "v1_20_R2"};
|
||||||
private static NMSHandler handler;
|
private static NMSHandler handler;
|
||||||
@Getter
|
@Getter
|
||||||
private static String version;
|
private static String version;
|
||||||
|
|
||||||
|
@Nullable
|
||||||
public static NMSHandler getHandler() {
|
public static NMSHandler getHandler() {
|
||||||
if (handler != null) {
|
if (handler != null) {
|
||||||
return handler;
|
return handler;
|
||||||
@@ -23,6 +25,11 @@ public class NMSHandlers {
|
|||||||
return handler;
|
return handler;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean isVersionSupported() {
|
||||||
|
if (getHandler() == null) return false;
|
||||||
|
return getHandler().getSupported();
|
||||||
|
}
|
||||||
|
|
||||||
public static void setup() {
|
public static void setup() {
|
||||||
if (handler != null) return;
|
if (handler != null) return;
|
||||||
final String packageName = HMCCosmeticsPlugin.getInstance().getServer().getClass().getPackage().getName();
|
final String packageName = HMCCosmeticsPlugin.getInstance().getServer().getClass().getPackage().getName();
|
||||||
|
|||||||
@@ -218,15 +218,15 @@ public class CosmeticUser {
|
|||||||
item = cosmetic.getItem();
|
item = cosmetic.getItem();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (item == null) {
|
|
||||||
MessagesUtil.sendDebugMessages("GetUserCosemticUser Item is null");
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return getUserCosmeticItem(cosmetic, item);
|
return getUserCosmeticItem(cosmetic, item);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
public ItemStack getUserCosmeticItem(Cosmetic cosmetic, ItemStack item) {
|
public ItemStack getUserCosmeticItem(Cosmetic cosmetic, ItemStack item) {
|
||||||
|
if (item == null) {
|
||||||
|
MessagesUtil.sendDebugMessages("GetUserCosemticUser Item is null");
|
||||||
|
return new ItemStack(Material.AIR);
|
||||||
|
}
|
||||||
if (item.hasItemMeta()) {
|
if (item.hasItemMeta()) {
|
||||||
ItemMeta itemMeta = item.getItemMeta();
|
ItemMeta itemMeta = item.getItemMeta();
|
||||||
|
|
||||||
@@ -527,6 +527,7 @@ public class CosmeticUser {
|
|||||||
POTION,
|
POTION,
|
||||||
ACTION,
|
ACTION,
|
||||||
COMMAND,
|
COMMAND,
|
||||||
EMOTE
|
EMOTE,
|
||||||
|
GAMEMODE
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ package com.hibiscusmc.hmccosmetics.user;
|
|||||||
import com.google.common.collect.HashBiMap;
|
import com.google.common.collect.HashBiMap;
|
||||||
import com.hibiscusmc.hmccosmetics.util.ServerUtils;
|
import com.hibiscusmc.hmccosmetics.util.ServerUtils;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.EntityType;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
@@ -41,8 +40,8 @@ public class CosmeticUsers {
|
|||||||
public static CosmeticUser getUser(int entityId) {
|
public static CosmeticUser getUser(int entityId) {
|
||||||
Entity entity = ServerUtils.getEntity(entityId);
|
Entity entity = ServerUtils.getEntity(entityId);
|
||||||
if (entity == null) return null;
|
if (entity == null) return null;
|
||||||
if (entity.getType().equals(EntityType.PLAYER)) return null;
|
if (!(entity instanceof Player player)) return null;
|
||||||
return COSMETIC_USERS.get(entity.getUniqueId());
|
return COSMETIC_USERS.get(player.getUniqueId());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Set<CosmeticUser> values() {
|
public static Set<CosmeticUser> values() {
|
||||||
|
|||||||
@@ -91,7 +91,7 @@ public class UserBackpackManager {
|
|||||||
|
|
||||||
// No one should be using ME because it barely works but some still use it, so it's here
|
// No one should be using ME because it barely works but some still use it, so it's here
|
||||||
if (cosmeticBackpackType.getModelName() != null && Hooks.isActiveHook("ModelEngine")) {
|
if (cosmeticBackpackType.getModelName() != null && Hooks.isActiveHook("ModelEngine")) {
|
||||||
if (ModelEngineAPI.api.getModelRegistry().getBlueprint(cosmeticBackpackType.getModelName()) == null) {
|
if (ModelEngineAPI.getBlueprint(cosmeticBackpackType.getModelName()) == null) {
|
||||||
MessagesUtil.sendDebugMessages("Invalid Model Engine Blueprint " + cosmeticBackpackType.getModelName(), Level.SEVERE);
|
MessagesUtil.sendDebugMessages("Invalid Model Engine Blueprint " + cosmeticBackpackType.getModelName(), Level.SEVERE);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,14 +1,19 @@
|
|||||||
package com.hibiscusmc.hmccosmetics.user.manager;
|
package com.hibiscusmc.hmccosmetics.user.manager;
|
||||||
|
|
||||||
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
|
|
||||||
import com.hibiscusmc.hmccosmetics.config.Settings;
|
import com.hibiscusmc.hmccosmetics.config.Settings;
|
||||||
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticBalloonType;
|
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticBalloonType;
|
||||||
import com.hibiscusmc.hmccosmetics.hooks.Hooks;
|
import com.hibiscusmc.hmccosmetics.hooks.Hooks;
|
||||||
import com.hibiscusmc.hmccosmetics.nms.NMSHandlers;
|
import com.hibiscusmc.hmccosmetics.nms.NMSHandlers;
|
||||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||||
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUsers;
|
||||||
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||||
import com.hibiscusmc.hmccosmetics.util.packets.PacketManager;
|
import com.hibiscusmc.hmccosmetics.util.packets.PacketManager;
|
||||||
import com.ticxo.modelengine.api.ModelEngineAPI;
|
import com.ticxo.modelengine.api.ModelEngineAPI;
|
||||||
|
import com.ticxo.modelengine.api.entity.BaseEntity;
|
||||||
|
import com.ticxo.modelengine.api.entity.BukkitEntity;
|
||||||
|
import com.ticxo.modelengine.api.entity.Dummy;
|
||||||
|
import com.ticxo.modelengine.api.entity.EntityDataTracker;
|
||||||
|
import com.ticxo.modelengine.api.entity.data.BukkitEntityData;
|
||||||
import com.ticxo.modelengine.api.model.ActiveModel;
|
import com.ticxo.modelengine.api.model.ActiveModel;
|
||||||
import com.ticxo.modelengine.api.model.ModeledEntity;
|
import com.ticxo.modelengine.api.model.ModeledEntity;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
@@ -20,19 +25,23 @@ import org.bukkit.entity.Player;
|
|||||||
import org.bukkit.util.Vector;
|
import org.bukkit.util.Vector;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
public class UserBalloonManager {
|
public class UserBalloonManager {
|
||||||
|
|
||||||
|
private CosmeticUser user;
|
||||||
|
@Getter
|
||||||
private BalloonType balloonType;
|
private BalloonType balloonType;
|
||||||
private CosmeticBalloonType cosmeticBalloonType;
|
private CosmeticBalloonType cosmeticBalloonType;
|
||||||
@Getter
|
@Getter
|
||||||
private UserBalloonPufferfish pufferfish;
|
private UserBalloonPufferfish pufferfish;
|
||||||
private final ArmorStand modelEntity;
|
private final ArmorStand modelEntity;
|
||||||
|
|
||||||
public UserBalloonManager(CosmeticUser user, @NotNull Location location) {
|
public UserBalloonManager(CosmeticUser user, @NotNull Location location) {
|
||||||
|
this.user = user;
|
||||||
this.pufferfish = new UserBalloonPufferfish(user.getUniqueId(), NMSHandlers.getHandler().getNextEntityId(), UUID.randomUUID());
|
this.pufferfish = new UserBalloonPufferfish(user.getUniqueId(), NMSHandlers.getHandler().getNextEntityId(), UUID.randomUUID());
|
||||||
this.modelEntity = NMSHandlers.getHandler().getMEGEntity(location.add(Settings.getBalloonOffset()));
|
this.modelEntity = NMSHandlers.getHandler().getMEGEntity(location.add(Settings.getBalloonOffset()));
|
||||||
}
|
}
|
||||||
@@ -54,7 +63,7 @@ public class UserBalloonManager {
|
|||||||
if (balloonType == BalloonType.MODELENGINE) {
|
if (balloonType == BalloonType.MODELENGINE) {
|
||||||
String id = cosmeticBalloonType.getModelName();
|
String id = cosmeticBalloonType.getModelName();
|
||||||
MessagesUtil.sendDebugMessages("Attempting Spawning for " + id);
|
MessagesUtil.sendDebugMessages("Attempting Spawning for " + id);
|
||||||
if (ModelEngineAPI.api.getModelRegistry().getBlueprint(id) == null) {
|
if (ModelEngineAPI.getBlueprint(id) == null) {
|
||||||
MessagesUtil.sendDebugMessages("Invalid Model Engine Blueprint " + id, Level.SEVERE);
|
MessagesUtil.sendDebugMessages("Invalid Model Engine Blueprint " + id, Level.SEVERE);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -62,14 +71,19 @@ public class UserBalloonManager {
|
|||||||
ActiveModel model = ModelEngineAPI.createActiveModel(ModelEngineAPI.getBlueprint(id));
|
ActiveModel model = ModelEngineAPI.createActiveModel(ModelEngineAPI.getBlueprint(id));
|
||||||
model.setCanHurt(false);
|
model.setCanHurt(false);
|
||||||
modeledEntity.addModel(model, false);
|
modeledEntity.addModel(model, false);
|
||||||
|
|
||||||
if (color != null) {
|
if (color != null) {
|
||||||
modeledEntity.getModels().forEach((d, singleModel) -> {
|
modeledEntity.getModels().forEach((d, singleModel) -> {
|
||||||
if (cosmeticBalloonType.isDyablePart(d)) {
|
if (cosmeticBalloonType.isDyablePart(d)) {
|
||||||
singleModel.getRendererHandler().setColor(color);
|
singleModel.setDefaultTint(color);
|
||||||
singleModel.getRendererHandler().update();
|
singleModel.getModelRenderer().sendToClient();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BukkitEntityData data = (BukkitEntityData) modeledEntity.getBase().getData();
|
||||||
|
data.setBlockedCullIgnoreRadius((double) Settings.getViewDistance());
|
||||||
|
data.getTracked().setPlayerPredicate(this::playerCheck);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (balloonType == BalloonType.ITEM) {
|
if (balloonType == BalloonType.ITEM) {
|
||||||
@@ -79,18 +93,19 @@ public class UserBalloonManager {
|
|||||||
|
|
||||||
public void remove() {
|
public void remove() {
|
||||||
if (balloonType == BalloonType.MODELENGINE) {
|
if (balloonType == BalloonType.MODELENGINE) {
|
||||||
final ModeledEntity entity = ModelEngineAPI.api.getModeledEntity(modelEntity.getUniqueId());
|
final ModeledEntity entity = ModelEngineAPI.getModeledEntity(modelEntity);
|
||||||
|
if (entity == null) {
|
||||||
if (entity == null) return;
|
MessagesUtil.sendDebugMessages("Balloon Removal Failed - Model Entity is Null");
|
||||||
|
return;
|
||||||
for (final Player player : entity.getRangeManager().getPlayerInRange()) {
|
|
||||||
entity.hideFromPlayer(player);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
entity.destroy();
|
entity.destroy();
|
||||||
|
MessagesUtil.sendDebugMessages("Balloon Model Engine Removal");
|
||||||
}
|
}
|
||||||
|
|
||||||
modelEntity.remove();
|
modelEntity.remove();
|
||||||
cosmeticBalloonType = null;
|
cosmeticBalloonType = null;
|
||||||
|
MessagesUtil.sendDebugMessages("Balloon Entity Removed");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addPlayerToModel(final CosmeticUser user, final CosmeticBalloonType cosmeticBalloonType) {
|
public void addPlayerToModel(final CosmeticUser user, final CosmeticBalloonType cosmeticBalloonType) {
|
||||||
@@ -99,14 +114,13 @@ public class UserBalloonManager {
|
|||||||
|
|
||||||
public void addPlayerToModel(final CosmeticUser user, final CosmeticBalloonType cosmeticBalloonType, Color color) {
|
public void addPlayerToModel(final CosmeticUser user, final CosmeticBalloonType cosmeticBalloonType, Color color) {
|
||||||
if (balloonType == BalloonType.MODELENGINE) {
|
if (balloonType == BalloonType.MODELENGINE) {
|
||||||
final ModeledEntity model = ModelEngineAPI.api.getModeledEntity(modelEntity.getUniqueId());
|
final ModeledEntity model = ModelEngineAPI.getModeledEntity(modelEntity);
|
||||||
if (model == null) {
|
if (model == null) {
|
||||||
spawnModel(cosmeticBalloonType, color);
|
spawnModel(cosmeticBalloonType, color);
|
||||||
MessagesUtil.sendDebugMessages("model is null");
|
MessagesUtil.sendDebugMessages("model is null");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
//if (model.getRangeManager().getPlayerInRange().contains(player)) return;
|
|
||||||
model.showToPlayer(user.getPlayer());
|
|
||||||
MessagesUtil.sendDebugMessages("Show to player");
|
MessagesUtil.sendDebugMessages("Show to player");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -114,13 +128,11 @@ public class UserBalloonManager {
|
|||||||
modelEntity.getEquipment().setHelmet(user.getUserCosmeticItem(cosmeticBalloonType));
|
modelEntity.getEquipment().setHelmet(user.getUserCosmeticItem(cosmeticBalloonType));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public void removePlayerFromModel(final Player player) {
|
public void removePlayerFromModel(final Player viewer) {
|
||||||
if (balloonType == BalloonType.MODELENGINE) {
|
if (balloonType == BalloonType.MODELENGINE) {
|
||||||
final ModeledEntity model = ModelEngineAPI.api.getModeledEntity(modelEntity.getUniqueId());
|
final ModeledEntity model = ModelEngineAPI.getModeledEntity(modelEntity);
|
||||||
|
|
||||||
if (model == null) return;
|
if (model == null) return;
|
||||||
|
|
||||||
model.hideFromPlayer(player);
|
|
||||||
MessagesUtil.sendDebugMessages("Hidden from player");
|
MessagesUtil.sendDebugMessages("Hidden from player");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -136,7 +148,7 @@ public class UserBalloonManager {
|
|||||||
|
|
||||||
|
|
||||||
public int getPufferfishBalloonId() {
|
public int getPufferfishBalloonId() {
|
||||||
return pufferfish.getId();
|
return pufferfish.getPufferFishEntityId();
|
||||||
}
|
}
|
||||||
public UUID getPufferfishBalloonUniqueId() {
|
public UUID getPufferfishBalloonUniqueId() {
|
||||||
return pufferfish.getUuid();
|
return pufferfish.getUuid();
|
||||||
@@ -171,7 +183,6 @@ public class UserBalloonManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void sendLeashPacket(int entityId) {
|
public void sendLeashPacket(int entityId) {
|
||||||
if (cosmeticBalloonType == null) return;
|
|
||||||
if (cosmeticBalloonType.isShowLead()) {
|
if (cosmeticBalloonType.isShowLead()) {
|
||||||
PacketManager.sendLeashPacket(getPufferfishBalloonId(), entityId, getLocation());
|
PacketManager.sendLeashPacket(getPufferfishBalloonId(), entityId, getLocation());
|
||||||
}
|
}
|
||||||
@@ -182,4 +193,21 @@ public class UserBalloonManager {
|
|||||||
ITEM,
|
ITEM,
|
||||||
NONE
|
NONE
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean playerCheck(final Player player) {
|
||||||
|
MessagesUtil.sendDebugMessages("playerCheck");
|
||||||
|
CosmeticUser viewer = CosmeticUsers.getUser(player.getUniqueId());
|
||||||
|
|
||||||
|
if (user.getPlayer() == player) {
|
||||||
|
return (!user.getHidden());
|
||||||
|
} else {
|
||||||
|
if (user.isInWardrobe()) return false;
|
||||||
|
MessagesUtil.sendDebugMessages("playerCheck - Not Same Player");
|
||||||
|
if (viewer != null && viewer.isInWardrobe()) {
|
||||||
|
MessagesUtil.sendDebugMessages("playerCheck - Viewer in Wardrobe");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return (!user.getHidden());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,12 @@
|
|||||||
package com.hibiscusmc.hmccosmetics.user.manager;
|
package com.hibiscusmc.hmccosmetics.user.manager;
|
||||||
|
|
||||||
|
import com.comphenix.protocol.PacketType;
|
||||||
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||||
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUsers;
|
||||||
import com.hibiscusmc.hmccosmetics.util.PlayerUtils;
|
import com.hibiscusmc.hmccosmetics.util.PlayerUtils;
|
||||||
import com.hibiscusmc.hmccosmetics.util.packets.PacketManager;
|
import com.hibiscusmc.hmccosmetics.util.packets.PacketManager;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.entity.EntityType;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -11,17 +15,17 @@ import java.util.UUID;
|
|||||||
|
|
||||||
public class UserBalloonPufferfish extends UserEntity {
|
public class UserBalloonPufferfish extends UserEntity {
|
||||||
|
|
||||||
private int id;
|
private int pufferFishEntityId;
|
||||||
private UUID uuid;
|
private UUID uuid;
|
||||||
|
|
||||||
public UserBalloonPufferfish(UUID owner, int id, UUID uuid) {
|
public UserBalloonPufferfish(UUID owner, int pufferFishEntityId, UUID uuid) {
|
||||||
super(owner);
|
super(owner);
|
||||||
this.id = id;
|
this.pufferFishEntityId = pufferFishEntityId;
|
||||||
this.uuid = uuid;
|
this.uuid = uuid;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getId() {
|
public int getPufferFishEntityId() {
|
||||||
return id;
|
return pufferFishEntityId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public UUID getUuid() {
|
public UUID getUuid() {
|
||||||
@@ -29,7 +33,44 @@ public class UserBalloonPufferfish extends UserEntity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void hidePufferfish() {
|
public void hidePufferfish() {
|
||||||
PacketManager.sendEntityDestroyPacket(id, getViewers());
|
PacketManager.sendEntityDestroyPacket(pufferFishEntityId, getViewers());
|
||||||
getViewers().clear();
|
getViewers().clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void spawnPufferfish(Location location, List<Player> sendTo) {
|
||||||
|
PacketManager.sendEntitySpawnPacket(location, pufferFishEntityId, EntityType.PUFFERFISH, uuid, sendTo);
|
||||||
|
PacketManager.sendInvisibilityPacket(pufferFishEntityId, sendTo);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Player> refreshViewers(Location location) {
|
||||||
|
if (System.currentTimeMillis() - getViewerLastUpdate() <= 1000) return List.of(); //Prevents mass refreshes
|
||||||
|
ArrayList<Player> newPlayers = new ArrayList<>();
|
||||||
|
ArrayList<Player> removePlayers = new ArrayList<>();
|
||||||
|
List<Player> players = PlayerUtils.getNearbyPlayers(location);
|
||||||
|
|
||||||
|
for (Player player : players) {
|
||||||
|
CosmeticUser user = CosmeticUsers.getUser(player);
|
||||||
|
if (user != null && getOwner() != user.getUniqueId() && user.isInWardrobe()) { // Fixes issue where players in wardrobe would see other players cosmetics if they were not in wardrobe
|
||||||
|
removePlayers.add(player);
|
||||||
|
PacketManager.sendEntityDestroyPacket(getPufferFishEntityId(), List.of(player));
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (!getViewers().contains(player)) {
|
||||||
|
getViewers().add(player);
|
||||||
|
newPlayers.add(player);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
// bad loopdy loops
|
||||||
|
for (Player viewerPlayer : getViewers()) {
|
||||||
|
if (!players.contains(viewerPlayer)) {
|
||||||
|
removePlayers.add(viewerPlayer);
|
||||||
|
PacketManager.sendEntityDestroyPacket(getPufferFishEntityId(), List.of(viewerPlayer));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
getViewers().removeAll(removePlayers);
|
||||||
|
setViewerLastUpdate(System.currentTimeMillis());
|
||||||
|
return newPlayers;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package com.hibiscusmc.hmccosmetics.user.manager;
|
package com.hibiscusmc.hmccosmetics.user.manager;
|
||||||
|
|
||||||
|
import com.hibiscusmc.hmccosmetics.config.Settings;
|
||||||
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.PlayerUtils;
|
import com.hibiscusmc.hmccosmetics.util.PlayerUtils;
|
||||||
@@ -20,7 +21,9 @@ public class UserEntity {
|
|||||||
@Getter
|
@Getter
|
||||||
private List<Player> viewers = new ArrayList<>();
|
private List<Player> viewers = new ArrayList<>();
|
||||||
@Getter @Setter
|
@Getter @Setter
|
||||||
private Long lastUpdate = 0L;
|
private Long viewerLastUpdate = 0L;
|
||||||
|
@Getter @Setter
|
||||||
|
private Long lastPositionUpdate = 0L;
|
||||||
@Getter @Setter
|
@Getter @Setter
|
||||||
private List<Integer> ids = new ArrayList<>();
|
private List<Integer> ids = new ArrayList<>();
|
||||||
@Getter
|
@Getter
|
||||||
@@ -35,7 +38,7 @@ public class UserEntity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public List<Player> refreshViewers(Location location) {
|
public List<Player> refreshViewers(Location location) {
|
||||||
if (System.currentTimeMillis() - lastUpdate <= 1000) return List.of(); //Prevents mass refreshes
|
if (System.currentTimeMillis() - viewerLastUpdate <= 1000) return List.of(); //Prevents mass refreshes
|
||||||
ArrayList<Player> newPlayers = new ArrayList<>();
|
ArrayList<Player> newPlayers = new ArrayList<>();
|
||||||
ArrayList<Player> removePlayers = new ArrayList<>();
|
ArrayList<Player> removePlayers = new ArrayList<>();
|
||||||
List<Player> players = PlayerUtils.getNearbyPlayers(location);
|
List<Player> players = PlayerUtils.getNearbyPlayers(location);
|
||||||
@@ -61,20 +64,33 @@ public class UserEntity {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
viewers.removeAll(removePlayers);
|
viewers.removeAll(removePlayers);
|
||||||
lastUpdate = System.currentTimeMillis();
|
setViewerLastUpdate(System.currentTimeMillis());
|
||||||
return newPlayers;
|
return newPlayers;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void teleport(Location location) {
|
public void teleport(Location location) {
|
||||||
|
if (this.getLocation() != null && this.getLocation().getWorld() == location.getWorld()) {
|
||||||
|
// Was thinking about using schedulers to just send the packet later... but that would be a lot of tasks and
|
||||||
|
// would probably cause more lag. Furthermore, the server "ticks" the cosmetics every second by defualt. So it's fine like this.
|
||||||
|
if (System.currentTimeMillis() - getLastPositionUpdate() <= Settings.getPacketEntityTeleportCooldown()) return;
|
||||||
|
}
|
||||||
this.location = location;
|
this.location = location;
|
||||||
for (Integer entity : ids) {
|
for (Integer entity : ids) {
|
||||||
PacketManager.sendTeleportPacket(entity, location, false, getViewers());
|
PacketManager.sendTeleportPacket(entity, location, false, getViewers());
|
||||||
}
|
}
|
||||||
|
setLastPositionUpdate(System.currentTimeMillis());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setRotation(int yaw) {
|
public void setRotation(int yaw) {
|
||||||
|
setRotation(yaw, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRotation(int yaw, boolean additonalPacket) {
|
||||||
location.setYaw(yaw);
|
location.setYaw(yaw);
|
||||||
for (Integer entity : ids) {
|
for (Integer entity : ids) {
|
||||||
|
// First person backpacks need both packets to rotate properly, otherwise they look off
|
||||||
|
// Regular backpacks just need the look packet
|
||||||
|
if (additonalPacket) PacketManager.sendRotationPacket(entity, yaw, false, getViewers());
|
||||||
PacketManager.sendLookPacket(entity, location, getViewers());
|
PacketManager.sendLookPacket(entity, location, getViewers());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -145,6 +145,7 @@ public class UserWardrobeManager {
|
|||||||
Location balloonLocation = npcLocation.clone().add(cosmetic.getBalloonOffset());
|
Location balloonLocation = npcLocation.clone().add(cosmetic.getBalloonOffset());
|
||||||
PacketManager.sendTeleportPacket(user.getBalloonManager().getPufferfishBalloonId(), balloonLocation , false, viewer);
|
PacketManager.sendTeleportPacket(user.getBalloonManager().getPufferfishBalloonId(), balloonLocation , false, viewer);
|
||||||
user.getBalloonManager().getModelEntity().teleport(balloonLocation);
|
user.getBalloonManager().getModelEntity().teleport(balloonLocation);
|
||||||
|
user.getBalloonManager().setLocation(balloonLocation);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (WardrobeSettings.isEnabledBossbar()) {
|
if (WardrobeSettings.isEnabledBossbar()) {
|
||||||
@@ -234,7 +235,7 @@ public class UserWardrobeManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (user.hasCosmeticInSlot(CosmeticSlot.BALLOON)) {
|
if (user.hasCosmeticInSlot(CosmeticSlot.BALLOON)) {
|
||||||
user.respawnBalloon();
|
//user.respawnBalloon();
|
||||||
//PacketManager.sendLeashPacket(VIEWER.getBalloonEntity().getPufferfishBalloonId(), player.getEntityId(), viewer);
|
//PacketManager.sendLeashPacket(VIEWER.getBalloonEntity().getPufferfishBalloonId(), player.getEntityId(), viewer);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -300,7 +301,9 @@ public class UserWardrobeManager {
|
|||||||
//PacketManager.sendTeleportPacket(user.getBalloonManager().getPufferfishBalloonId(), npcLocation.add(Settings.getBalloonOffset()), false, viewer);
|
//PacketManager.sendTeleportPacket(user.getBalloonManager().getPufferfishBalloonId(), npcLocation.add(Settings.getBalloonOffset()), false, viewer);
|
||||||
//user.getBalloonManager().getModelEntity().teleport(npcLocation.add(Settings.getBalloonOffset()));
|
//user.getBalloonManager().getModelEntity().teleport(npcLocation.add(Settings.getBalloonOffset()));
|
||||||
user.getBalloonManager().sendRemoveLeashPacket(outsideViewers);
|
user.getBalloonManager().sendRemoveLeashPacket(outsideViewers);
|
||||||
PacketManager.sendEntityDestroyPacket(user.getBalloonManager().getModelId(), outsideViewers);
|
if (user.getBalloonManager().getBalloonType() != UserBalloonManager.BalloonType.MODELENGINE) {
|
||||||
|
PacketManager.sendEntityDestroyPacket(user.getBalloonManager().getModelId(), outsideViewers);
|
||||||
|
}
|
||||||
user.getBalloonManager().sendLeashPacket(NPC_ID);
|
user.getBalloonManager().sendLeashPacket(NPC_ID);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -52,6 +52,17 @@ public class InventoryUtils {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static CosmeticSlot getItemSlotToCosmeticSlot(final EnumWrappers.ItemSlot slot) {
|
||||||
|
return switch (slot) {
|
||||||
|
case HEAD -> CosmeticSlot.HELMET;
|
||||||
|
case CHEST -> CosmeticSlot.CHESTPLATE;
|
||||||
|
case LEGS -> CosmeticSlot.LEGGINGS;
|
||||||
|
case FEET -> CosmeticSlot.BOOTS;
|
||||||
|
case OFFHAND -> CosmeticSlot.OFFHAND;
|
||||||
|
case MAINHAND -> CosmeticSlot.MAINHAND;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
public static CosmeticSlot BukkitCosmeticSlot(EquipmentSlot slot) {
|
public static CosmeticSlot BukkitCosmeticSlot(EquipmentSlot slot) {
|
||||||
return switch (slot) {
|
return switch (slot) {
|
||||||
case HAND -> CosmeticSlot.MAINHAND;
|
case HAND -> CosmeticSlot.MAINHAND;
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ package com.hibiscusmc.hmccosmetics.util;
|
|||||||
|
|
||||||
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
|
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
|
||||||
import com.hibiscusmc.hmccosmetics.config.Settings;
|
import com.hibiscusmc.hmccosmetics.config.Settings;
|
||||||
import com.hibiscusmc.hmccosmetics.config.WardrobeSettings;
|
|
||||||
import com.hibiscusmc.hmccosmetics.hooks.Hooks;
|
import com.hibiscusmc.hmccosmetics.hooks.Hooks;
|
||||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||||
import com.hibiscusmc.hmccosmetics.util.misc.Adventure;
|
import com.hibiscusmc.hmccosmetics.util.misc.Adventure;
|
||||||
|
|||||||
@@ -1,13 +0,0 @@
|
|||||||
package com.hibiscusmc.hmccosmetics.util.packets;
|
|
||||||
|
|
||||||
import com.comphenix.protocol.ProtocolLibrary;
|
|
||||||
import com.comphenix.protocol.events.PacketContainer;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
public class BasePacket {
|
|
||||||
|
|
||||||
public static void sendPacket(Player player, PacketContainer packet) {
|
|
||||||
if (player == null) return;
|
|
||||||
ProtocolLibrary.getProtocolManager().sendServerPacket(player, packet, false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
package com.hibiscusmc.hmccosmetics.util.packets;
|
package com.hibiscusmc.hmccosmetics.util.packets;
|
||||||
|
|
||||||
import com.comphenix.protocol.PacketType;
|
import com.comphenix.protocol.PacketType;
|
||||||
|
import com.comphenix.protocol.ProtocolLibrary;
|
||||||
import com.comphenix.protocol.events.PacketContainer;
|
import com.comphenix.protocol.events.PacketContainer;
|
||||||
import com.comphenix.protocol.wrappers.*;
|
import com.comphenix.protocol.wrappers.*;
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
@@ -18,8 +19,6 @@ import com.hibiscusmc.hmccosmetics.util.packets.wrappers.WrapperPlayServerRelEnt
|
|||||||
import it.unimi.dsi.fastutil.ints.IntArrayList;
|
import it.unimi.dsi.fastutil.ints.IntArrayList;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.Particle;
|
|
||||||
import org.bukkit.entity.Entity;
|
|
||||||
import org.bukkit.entity.EntityType;
|
import org.bukkit.entity.EntityType;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.EquipmentSlot;
|
import org.bukkit.inventory.EquipmentSlot;
|
||||||
@@ -31,7 +30,7 @@ import java.util.Collections;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public class PacketManager extends BasePacket {
|
public class PacketManager {
|
||||||
|
|
||||||
public static void sendEntitySpawnPacket(
|
public static void sendEntitySpawnPacket(
|
||||||
final @NotNull Location location,
|
final @NotNull Location location,
|
||||||
@@ -138,7 +137,7 @@ public class PacketManager extends BasePacket {
|
|||||||
} else {
|
} else {
|
||||||
final List<WrappedDataValue> wrappedDataValueList = Lists.newArrayList();
|
final List<WrappedDataValue> wrappedDataValueList = Lists.newArrayList();
|
||||||
wrappedDataValueList.add(new WrappedDataValue(0, WrappedDataWatcher.Registry.get(Byte.class), (byte) 0x20));
|
wrappedDataValueList.add(new WrappedDataValue(0, WrappedDataWatcher.Registry.get(Byte.class), (byte) 0x20));
|
||||||
wrapper.setObject(new WrappedDataWatcher.WrappedDataWatcherObject(15, WrappedDataWatcher.Registry.get(Byte.class)), (byte) 0x10);
|
wrappedDataValueList.add(new WrappedDataValue(15, WrappedDataWatcher.Registry.get(Byte.class), (byte) 0x10));
|
||||||
packet.getDataValueCollectionModifier().write(0, wrappedDataValueList);
|
packet.getDataValueCollectionModifier().write(0, wrappedDataValueList);
|
||||||
}
|
}
|
||||||
for (Player p : sendTo) sendPacket(p, packet);
|
for (Player p : sendTo) sendPacket(p, packet);
|
||||||
@@ -338,13 +337,17 @@ public class PacketManager extends BasePacket {
|
|||||||
final int entityId,
|
final int entityId,
|
||||||
final @NotNull List<Player> sendTo
|
final @NotNull List<Player> sendTo
|
||||||
) {
|
) {
|
||||||
WrapperPlayServerNamedEntitySpawn wrapper = new WrapperPlayServerNamedEntitySpawn();
|
if (NMSHandlers.getVersion().contains("v1_18_R2") || NMSHandlers.getVersion().contains("v1_19_R1") || NMSHandlers.getVersion().contains("v1_19_R2") || NMSHandlers.getVersion().contains("v1_19_R3") || NMSHandlers.getVersion().contains("v1_20_R1")) {
|
||||||
wrapper.setEntityID(entityId);
|
WrapperPlayServerNamedEntitySpawn wrapper = new WrapperPlayServerNamedEntitySpawn();
|
||||||
wrapper.setPlayerUUID(uuid);
|
wrapper.setEntityID(entityId);
|
||||||
wrapper.setPosition(location.toVector());
|
wrapper.setPlayerUUID(uuid);
|
||||||
wrapper.setPitch(location.getPitch());
|
wrapper.setPosition(location.toVector());
|
||||||
wrapper.setYaw(location.getYaw());
|
wrapper.setPitch(location.getPitch());
|
||||||
for (final Player p : sendTo) sendPacket(p, wrapper.getHandle());
|
wrapper.setYaw(location.getYaw());
|
||||||
|
for (final Player p : sendTo) sendPacket(p, wrapper.getHandle());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
sendEntitySpawnPacket(location, entityId, EntityType.PLAYER, uuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -552,4 +555,9 @@ public class PacketManager extends BasePacket {
|
|||||||
}
|
}
|
||||||
return viewers;
|
return viewers;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void sendPacket(Player player, PacketContainer packet) {
|
||||||
|
if (player == null) return;
|
||||||
|
ProtocolLibrary.getProtocolManager().sendServerPacket(player, packet, null,false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,6 +24,14 @@ cosmetic-settings:
|
|||||||
force-permission-join: true # Checks a player permission if they can have a cosmetic when they join the server.
|
force-permission-join: true # Checks a player permission if they can have a cosmetic when they join the server.
|
||||||
force-show-join: false # If the plugin should force show a player's cosmetics when they join the server.
|
force-show-join: false # If the plugin should force show a player's cosmetics when they join the server.
|
||||||
|
|
||||||
|
disabled-gamemode:
|
||||||
|
enabled: true
|
||||||
|
# Which gamemodes should cosmetics be disabled for. This is useful for servers that have a creative world. All options are here, https://hub.spigotmc.org/javadocs/spigot/org/bukkit/GameMode.html
|
||||||
|
gamemodes:
|
||||||
|
- "SPECTATOR"
|
||||||
|
|
||||||
|
# This disables the entire internal emote system within the plugin. This option requires a restart.
|
||||||
|
emote-enable: true
|
||||||
emote-distance: -3 # This shows how far away the camera should be while a player is doing an emote. Negative is behind player.
|
emote-distance: -3 # This shows how far away the camera should be while a player is doing an emote. Negative is behind player.
|
||||||
emote-block-check: true # If the server should check if the block is open where the camera is placed (prevents players viewing through blocks)
|
emote-block-check: true # If the server should check if the block is open where the camera is placed (prevents players viewing through blocks)
|
||||||
emote-air-check: true # Check if there is air under a player, if there is, don't play emote
|
emote-air-check: true # Check if there is air under a player, if there is, don't play emote
|
||||||
@@ -35,6 +43,12 @@ cosmetic-settings:
|
|||||||
emote-move: false
|
emote-move: false
|
||||||
# This make it so it always sends the riding packets for the backpack. This sends more packets but is more reliable for servers which modify player passengers.
|
# This make it so it always sends the riding packets for the backpack. This sends more packets but is more reliable for servers which modify player passengers.
|
||||||
backpack-force-riding-packet: false
|
backpack-force-riding-packet: false
|
||||||
|
# This helps reduce the amount of packets sent for packet entities, but reduces accuracy of the entity. This is in milliseconds. -1 to disable.
|
||||||
|
# This is useful for servers with a lot of backpacks, as they are passengers, which means the client will update their position automatically within an area where the entity is located.
|
||||||
|
entity-cooldown-teleport-packet: 500
|
||||||
|
# This forces the offhand to always show the cosmetic. False means it will only show when the slot is empty.
|
||||||
|
# There is a small visual blip for a tick when you put a new item in the offhand slot, hence why its disabled by default.
|
||||||
|
offhand-always-show: false
|
||||||
|
|
||||||
helmet-add-enchantments: false # If the plugin should keep enchants on helmets. This is useful as some enchantments are client side only.
|
helmet-add-enchantments: false # If the plugin should keep enchants on helmets. This is useful as some enchantments are client side only.
|
||||||
chest-add-enchantments: false # If the plugin should keep enchants on chestplate. This is useful as some enchantments are client side only.
|
chest-add-enchantments: false # If the plugin should keep enchants on chestplate. This is useful as some enchantments are client side only.
|
||||||
@@ -123,6 +137,8 @@ wardrobe:
|
|||||||
title-fade-out: 1000 # milliseconds
|
title-fade-out: 1000 # milliseconds
|
||||||
wardrobes:
|
wardrobes:
|
||||||
default:
|
default:
|
||||||
|
distance: -1 # Distance in blocks that a player can interact with the wardrobe. -1 to ignore.
|
||||||
|
permission: "hmccosmetics.wardrobe.default" # Permission required to use the wardrobe.
|
||||||
npc-location:
|
npc-location:
|
||||||
world: "world"
|
world: "world"
|
||||||
x: 0
|
x: 0
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ jetpack:
|
|||||||
amount: 1
|
amount: 1
|
||||||
firstperson-item:
|
firstperson-item:
|
||||||
material: PAPER
|
material: PAPER
|
||||||
model-data: 14
|
model-data: 15
|
||||||
name: "<white>Jetpack"
|
name: "<white>Jetpack"
|
||||||
amount: 1
|
amount: 1
|
||||||
hammer:
|
hammer:
|
||||||
@@ -155,6 +155,6 @@ hibiscus_flower:
|
|||||||
permission: "hmccosmetics.hibiscus_flower"
|
permission: "hmccosmetics.hibiscus_flower"
|
||||||
item:
|
item:
|
||||||
material: PAPER
|
material: PAPER
|
||||||
model-data: 15
|
model-data: 16
|
||||||
name: "<#d24c9f>Hibiscus Flower"
|
name: "<#d24c9f>Hibiscus Flower"
|
||||||
amount: 1
|
amount: 1
|
||||||
|
|||||||
@@ -1,3 +1,6 @@
|
|||||||
|
user-cosmetic:
|
||||||
|
offline: "Offline"
|
||||||
|
invalid-user: "Invalid User"
|
||||||
unlocked-cosmetic:
|
unlocked-cosmetic:
|
||||||
true: "true"
|
true: "true"
|
||||||
false: "false"
|
false: "false"
|
||||||
@@ -11,5 +14,5 @@ using-cosmetic:
|
|||||||
true: "true"
|
true: "true"
|
||||||
false: "false"
|
false: "false"
|
||||||
current-cosmetic:
|
current-cosmetic:
|
||||||
true: "true"
|
no-cosmetic: "No Cosmetic"
|
||||||
false: "false"
|
none: "none"
|
||||||
|
|||||||
@@ -13,4 +13,5 @@ include(
|
|||||||
"v1_19_R2",
|
"v1_19_R2",
|
||||||
"v1_19_R3",
|
"v1_19_R3",
|
||||||
"v1_20_R1",
|
"v1_20_R1",
|
||||||
|
"v1_20_R2"
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,24 +0,0 @@
|
|||||||
package com.hibiscusmc.hmccosmetics.nms.v1_18_R2;
|
|
||||||
|
|
||||||
import net.minecraft.world.entity.decoration.ArmorStand;
|
|
||||||
import net.minecraft.world.level.Level;
|
|
||||||
import org.bukkit.Location;
|
|
||||||
import org.bukkit.craftbukkit.v1_18_R2.CraftWorld;
|
|
||||||
|
|
||||||
public class HMCArmorStand extends ArmorStand {
|
|
||||||
|
|
||||||
public HMCArmorStand(Level world, double x, double y, double z) {
|
|
||||||
super(world, x, y, z);
|
|
||||||
}
|
|
||||||
|
|
||||||
public HMCArmorStand(Location loc) {
|
|
||||||
super(((CraftWorld) loc.getWorld()).getHandle(), loc.getX(), loc.getY(), loc.getZ());
|
|
||||||
this.setPos(loc.getX(), loc.getY(), loc.getZ());
|
|
||||||
setInvisible(true);
|
|
||||||
setInvulnerable(true);
|
|
||||||
setMarker(true);
|
|
||||||
setSilent(true);
|
|
||||||
getBukkitLivingEntity().setCollidable(false);
|
|
||||||
persist = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,15 +1,8 @@
|
|||||||
package com.hibiscusmc.hmccosmetics.nms.v1_18_R2;
|
package com.hibiscusmc.hmccosmetics.nms.v1_18_R2;
|
||||||
|
|
||||||
import com.hibiscusmc.hmccosmetics.config.Settings;
|
|
||||||
import com.hibiscusmc.hmccosmetics.cosmetic.CosmeticSlot;
|
|
||||||
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticArmorType;
|
|
||||||
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticBackpackType;
|
|
||||||
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticBalloonType;
|
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticBalloonType;
|
||||||
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticMainhandType;
|
|
||||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||||
import com.hibiscusmc.hmccosmetics.user.manager.UserBalloonManager;
|
import com.hibiscusmc.hmccosmetics.user.manager.UserBalloonManager;
|
||||||
import com.hibiscusmc.hmccosmetics.util.InventoryUtils;
|
|
||||||
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
|
||||||
import com.mojang.datafixers.util.Pair;
|
import com.mojang.datafixers.util.Pair;
|
||||||
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;
|
||||||
@@ -26,13 +19,11 @@ import org.bukkit.Bukkit;
|
|||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.craftbukkit.v1_18_R2.CraftEquipmentSlot;
|
import org.bukkit.craftbukkit.v1_18_R2.CraftEquipmentSlot;
|
||||||
import org.bukkit.craftbukkit.v1_18_R2.CraftServer;
|
import org.bukkit.craftbukkit.v1_18_R2.CraftServer;
|
||||||
import org.bukkit.craftbukkit.v1_18_R2.CraftWorld;
|
|
||||||
import org.bukkit.craftbukkit.v1_18_R2.entity.CraftPlayer;
|
import org.bukkit.craftbukkit.v1_18_R2.entity.CraftPlayer;
|
||||||
import org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack;
|
import org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack;
|
||||||
import org.bukkit.craftbukkit.v1_18_R2.scoreboard.CraftScoreboard;
|
import org.bukkit.craftbukkit.v1_18_R2.scoreboard.CraftScoreboard;
|
||||||
import org.bukkit.entity.ArmorStand;
|
import org.bukkit.entity.ArmorStand;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.entity.CreatureSpawnEvent;
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -55,37 +46,17 @@ public class NMSHandler implements com.hibiscusmc.hmccosmetics.nms.NMSHandler {
|
|||||||
private net.minecraft.world.entity.Entity getNMSEntity(int entityId) {
|
private net.minecraft.world.entity.Entity getNMSEntity(int entityId) {
|
||||||
for (ServerLevel world : ((CraftServer) Bukkit.getServer()).getHandle().getServer().getAllLevels()) {
|
for (ServerLevel world : ((CraftServer) Bukkit.getServer()).getHandle().getServer().getAllLevels()) {
|
||||||
net.minecraft.world.entity.Entity entity = world.getEntity(entityId);
|
net.minecraft.world.entity.Entity entity = world.getEntity(entityId);
|
||||||
if (entity == null) return null;
|
if (entity == null) continue;
|
||||||
return entity;
|
return entity;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public org.bukkit.entity.Entity getHMCArmorStand(Location loc) {
|
|
||||||
HMCArmorStand hmcArmorStand = new HMCArmorStand(loc);
|
|
||||||
return hmcArmorStand.getBukkitEntity();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ArmorStand getMEGEntity(Location loc) {
|
public ArmorStand getMEGEntity(Location loc) {
|
||||||
return (ArmorStand) new MEGEntity(loc).getBukkitEntity();
|
return (ArmorStand) new MEGEntity(loc).getBukkitEntity();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public org.bukkit.entity.Entity spawnBackpack(CosmeticUser user, CosmeticBackpackType cosmeticBackpackType) {
|
|
||||||
HMCArmorStand invisibleArmorstand = new HMCArmorStand(user.getEntity().getLocation());
|
|
||||||
|
|
||||||
ItemStack item = user.getUserCosmeticItem(cosmeticBackpackType);
|
|
||||||
|
|
||||||
invisibleArmorstand.setItemSlot(EquipmentSlot.HEAD, CraftItemStack.asNMSCopy(item));
|
|
||||||
((CraftWorld) user.getEntity().getWorld()).getHandle().addFreshEntity(invisibleArmorstand, CreatureSpawnEvent.SpawnReason.CUSTOM);
|
|
||||||
|
|
||||||
MessagesUtil.sendDebugMessages("spawnBackpack NMS");
|
|
||||||
|
|
||||||
return invisibleArmorstand.getBukkitLivingEntity();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public org.bukkit.entity.Entity spawnDisplayEntity(Location location, String text) {
|
public org.bukkit.entity.Entity spawnDisplayEntity(Location location, String text) {
|
||||||
return null;
|
return null;
|
||||||
@@ -105,54 +76,6 @@ public class NMSHandler implements com.hibiscusmc.hmccosmetics.nms.NMSHandler {
|
|||||||
return userBalloonManager1;
|
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
|
@Override
|
||||||
public void equipmentSlotUpdate(
|
public void equipmentSlotUpdate(
|
||||||
|
|||||||
@@ -1,24 +0,0 @@
|
|||||||
package com.hibiscusmc.hmccosmetics.nms.v1_19_R1;
|
|
||||||
|
|
||||||
import net.minecraft.world.entity.decoration.ArmorStand;
|
|
||||||
import net.minecraft.world.level.Level;
|
|
||||||
import org.bukkit.Location;
|
|
||||||
import org.bukkit.craftbukkit.v1_19_R1.CraftWorld;
|
|
||||||
|
|
||||||
public class HMCArmorStand extends ArmorStand {
|
|
||||||
|
|
||||||
public HMCArmorStand(Level world, double x, double y, double z) {
|
|
||||||
super(world, x, y, z);
|
|
||||||
}
|
|
||||||
|
|
||||||
public HMCArmorStand(Location loc) {
|
|
||||||
super(((CraftWorld) loc.getWorld()).getHandle(), loc.getX(), loc.getY(), loc.getZ());
|
|
||||||
this.setPos(loc.getX(), loc.getY(), loc.getZ());
|
|
||||||
setInvisible(true);
|
|
||||||
setInvulnerable(true);
|
|
||||||
setMarker(true);
|
|
||||||
setSilent(true);
|
|
||||||
getBukkitLivingEntity().setCollidable(false);
|
|
||||||
persist = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,15 +1,8 @@
|
|||||||
package com.hibiscusmc.hmccosmetics.nms.v1_19_R1;
|
package com.hibiscusmc.hmccosmetics.nms.v1_19_R1;
|
||||||
|
|
||||||
import com.hibiscusmc.hmccosmetics.config.Settings;
|
|
||||||
import com.hibiscusmc.hmccosmetics.cosmetic.CosmeticSlot;
|
|
||||||
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticArmorType;
|
|
||||||
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticBackpackType;
|
|
||||||
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticBalloonType;
|
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticBalloonType;
|
||||||
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticMainhandType;
|
|
||||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||||
import com.hibiscusmc.hmccosmetics.user.manager.UserBalloonManager;
|
import com.hibiscusmc.hmccosmetics.user.manager.UserBalloonManager;
|
||||||
import com.hibiscusmc.hmccosmetics.util.InventoryUtils;
|
|
||||||
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
|
||||||
import com.mojang.datafixers.util.Pair;
|
import com.mojang.datafixers.util.Pair;
|
||||||
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;
|
||||||
@@ -26,13 +19,11 @@ import org.bukkit.Bukkit;
|
|||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.craftbukkit.v1_19_R1.CraftEquipmentSlot;
|
import org.bukkit.craftbukkit.v1_19_R1.CraftEquipmentSlot;
|
||||||
import org.bukkit.craftbukkit.v1_19_R1.CraftServer;
|
import org.bukkit.craftbukkit.v1_19_R1.CraftServer;
|
||||||
import org.bukkit.craftbukkit.v1_19_R1.CraftWorld;
|
|
||||||
import org.bukkit.craftbukkit.v1_19_R1.entity.CraftPlayer;
|
import org.bukkit.craftbukkit.v1_19_R1.entity.CraftPlayer;
|
||||||
import org.bukkit.craftbukkit.v1_19_R1.inventory.CraftItemStack;
|
import org.bukkit.craftbukkit.v1_19_R1.inventory.CraftItemStack;
|
||||||
import org.bukkit.craftbukkit.v1_19_R1.scoreboard.CraftScoreboard;
|
import org.bukkit.craftbukkit.v1_19_R1.scoreboard.CraftScoreboard;
|
||||||
import org.bukkit.entity.ArmorStand;
|
import org.bukkit.entity.ArmorStand;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.entity.CreatureSpawnEvent;
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -55,45 +46,22 @@ public class NMSHandler implements com.hibiscusmc.hmccosmetics.nms.NMSHandler {
|
|||||||
private net.minecraft.world.entity.Entity getNMSEntity(int entityId) {
|
private net.minecraft.world.entity.Entity getNMSEntity(int entityId) {
|
||||||
for (ServerLevel world : ((CraftServer) Bukkit.getServer()).getHandle().getServer().getAllLevels()) {
|
for (ServerLevel world : ((CraftServer) Bukkit.getServer()).getHandle().getServer().getAllLevels()) {
|
||||||
net.minecraft.world.entity.Entity entity = world.getEntity(entityId);
|
net.minecraft.world.entity.Entity entity = world.getEntity(entityId);
|
||||||
if (entity == null) return null;
|
if (entity == null) continue;
|
||||||
return entity;
|
return entity;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public org.bukkit.entity.Entity getHMCArmorStand(Location loc) {
|
|
||||||
HMCArmorStand hmcArmorStand = new HMCArmorStand(loc);
|
|
||||||
return hmcArmorStand.getBukkitEntity();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ArmorStand getMEGEntity(Location loc) {
|
public ArmorStand getMEGEntity(Location loc) {
|
||||||
return (ArmorStand) new MEGEntity(loc).getBukkitEntity();
|
return (ArmorStand) new MEGEntity(loc).getBukkitEntity();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public org.bukkit.entity.Entity spawnBackpack(CosmeticUser user, CosmeticBackpackType cosmeticBackpackType) {
|
|
||||||
HMCArmorStand invisibleArmorstand = new HMCArmorStand(user.getEntity().getLocation());
|
|
||||||
|
|
||||||
ItemStack item = user.getUserCosmeticItem(cosmeticBackpackType);
|
|
||||||
|
|
||||||
invisibleArmorstand.setItemSlot(EquipmentSlot.HEAD, CraftItemStack.asNMSCopy(item));
|
|
||||||
((CraftWorld) user.getEntity().getWorld()).getHandle().addFreshEntity(invisibleArmorstand, CreatureSpawnEvent.SpawnReason.CUSTOM);
|
|
||||||
|
|
||||||
MessagesUtil.sendDebugMessages("spawnBackpack NMS");
|
|
||||||
|
|
||||||
return invisibleArmorstand.getBukkitLivingEntity();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public org.bukkit.entity.Entity spawnDisplayEntity(Location location, String text) {
|
public org.bukkit.entity.Entity spawnDisplayEntity(Location location, String text) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public UserBalloonManager spawnBalloon(CosmeticUser user, CosmeticBalloonType cosmeticBalloonType) {
|
public UserBalloonManager spawnBalloon(CosmeticUser user, CosmeticBalloonType cosmeticBalloonType) {
|
||||||
org.bukkit.entity.Entity entity = user.getEntity();
|
org.bukkit.entity.Entity entity = user.getEntity();
|
||||||
@@ -107,54 +75,6 @@ public class NMSHandler implements com.hibiscusmc.hmccosmetics.nms.NMSHandler {
|
|||||||
return userBalloonManager1;
|
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
|
@Override
|
||||||
public void equipmentSlotUpdate(
|
public void equipmentSlotUpdate(
|
||||||
|
|||||||
@@ -1,24 +0,0 @@
|
|||||||
package com.hibiscusmc.hmccosmetics.nms.v1_19_R2;
|
|
||||||
|
|
||||||
import net.minecraft.world.entity.decoration.ArmorStand;
|
|
||||||
import net.minecraft.world.level.Level;
|
|
||||||
import org.bukkit.Location;
|
|
||||||
import org.bukkit.craftbukkit.v1_19_R2.CraftWorld;
|
|
||||||
|
|
||||||
public class HMCArmorStand extends ArmorStand {
|
|
||||||
|
|
||||||
public HMCArmorStand(Level world, double x, double y, double z) {
|
|
||||||
super(world, x, y, z);
|
|
||||||
}
|
|
||||||
|
|
||||||
public HMCArmorStand(Location loc) {
|
|
||||||
super(((CraftWorld) loc.getWorld()).getHandle(), loc.getX(), loc.getY(), loc.getZ());
|
|
||||||
this.setPos(loc.getX(), loc.getY(), loc.getZ());
|
|
||||||
setInvisible(true);
|
|
||||||
setInvulnerable(true);
|
|
||||||
setMarker(true);
|
|
||||||
setSilent(true);
|
|
||||||
getBukkitLivingEntity().setCollidable(false);
|
|
||||||
persist = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,15 +1,8 @@
|
|||||||
package com.hibiscusmc.hmccosmetics.nms.v1_19_R2;
|
package com.hibiscusmc.hmccosmetics.nms.v1_19_R2;
|
||||||
|
|
||||||
import com.hibiscusmc.hmccosmetics.config.Settings;
|
|
||||||
import com.hibiscusmc.hmccosmetics.cosmetic.CosmeticSlot;
|
|
||||||
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticArmorType;
|
|
||||||
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticBackpackType;
|
|
||||||
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticBalloonType;
|
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticBalloonType;
|
||||||
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticMainhandType;
|
|
||||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||||
import com.hibiscusmc.hmccosmetics.user.manager.UserBalloonManager;
|
import com.hibiscusmc.hmccosmetics.user.manager.UserBalloonManager;
|
||||||
import com.hibiscusmc.hmccosmetics.util.InventoryUtils;
|
|
||||||
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
|
||||||
import com.mojang.datafixers.util.Pair;
|
import com.mojang.datafixers.util.Pair;
|
||||||
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;
|
||||||
@@ -26,13 +19,11 @@ import org.bukkit.Bukkit;
|
|||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.craftbukkit.v1_19_R2.CraftEquipmentSlot;
|
import org.bukkit.craftbukkit.v1_19_R2.CraftEquipmentSlot;
|
||||||
import org.bukkit.craftbukkit.v1_19_R2.CraftServer;
|
import org.bukkit.craftbukkit.v1_19_R2.CraftServer;
|
||||||
import org.bukkit.craftbukkit.v1_19_R2.CraftWorld;
|
|
||||||
import org.bukkit.craftbukkit.v1_19_R2.entity.CraftPlayer;
|
import org.bukkit.craftbukkit.v1_19_R2.entity.CraftPlayer;
|
||||||
import org.bukkit.craftbukkit.v1_19_R2.inventory.CraftItemStack;
|
import org.bukkit.craftbukkit.v1_19_R2.inventory.CraftItemStack;
|
||||||
import org.bukkit.craftbukkit.v1_19_R2.scoreboard.CraftScoreboard;
|
import org.bukkit.craftbukkit.v1_19_R2.scoreboard.CraftScoreboard;
|
||||||
import org.bukkit.entity.ArmorStand;
|
import org.bukkit.entity.ArmorStand;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.entity.CreatureSpawnEvent;
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -55,37 +46,17 @@ public class NMSHandler implements com.hibiscusmc.hmccosmetics.nms.NMSHandler {
|
|||||||
private net.minecraft.world.entity.Entity getNMSEntity(int entityId) {
|
private net.minecraft.world.entity.Entity getNMSEntity(int entityId) {
|
||||||
for (ServerLevel world : ((CraftServer) Bukkit.getServer()).getHandle().getServer().getAllLevels()) {
|
for (ServerLevel world : ((CraftServer) Bukkit.getServer()).getHandle().getServer().getAllLevels()) {
|
||||||
net.minecraft.world.entity.Entity entity = world.getEntity(entityId);
|
net.minecraft.world.entity.Entity entity = world.getEntity(entityId);
|
||||||
if (entity == null) return null;
|
if (entity == null) continue;
|
||||||
return entity;
|
return entity;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public org.bukkit.entity.Entity getHMCArmorStand(Location loc) {
|
|
||||||
HMCArmorStand hmcArmorStand = new HMCArmorStand(loc);
|
|
||||||
return hmcArmorStand.getBukkitEntity();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ArmorStand getMEGEntity(Location loc) {
|
public ArmorStand getMEGEntity(Location loc) {
|
||||||
return (ArmorStand) new MEGEntity(loc).getBukkitEntity();
|
return (ArmorStand) new MEGEntity(loc).getBukkitEntity();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public org.bukkit.entity.Entity spawnBackpack(CosmeticUser user, CosmeticBackpackType cosmeticBackpackType) {
|
|
||||||
HMCArmorStand invisibleArmorstand = new HMCArmorStand(user.getEntity().getLocation());
|
|
||||||
|
|
||||||
ItemStack item = user.getUserCosmeticItem(cosmeticBackpackType);
|
|
||||||
|
|
||||||
invisibleArmorstand.setItemSlot(EquipmentSlot.HEAD, CraftItemStack.asNMSCopy(item));
|
|
||||||
((CraftWorld) user.getEntity().getWorld()).getHandle().addFreshEntity(invisibleArmorstand, CreatureSpawnEvent.SpawnReason.CUSTOM);
|
|
||||||
|
|
||||||
MessagesUtil.sendDebugMessages("spawnBackpack NMS");
|
|
||||||
|
|
||||||
return invisibleArmorstand.getBukkitLivingEntity();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public org.bukkit.entity.Entity spawnDisplayEntity(Location location, String text) {
|
public org.bukkit.entity.Entity spawnDisplayEntity(Location location, String text) {
|
||||||
return null;
|
return null;
|
||||||
@@ -106,55 +77,6 @@ public class NMSHandler implements com.hibiscusmc.hmccosmetics.nms.NMSHandler {
|
|||||||
return userBalloonManager1;
|
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
|
@Override
|
||||||
public void equipmentSlotUpdate(
|
public void equipmentSlotUpdate(
|
||||||
int entityId,
|
int entityId,
|
||||||
|
|||||||
@@ -1,24 +0,0 @@
|
|||||||
package com.hibiscusmc.hmccosmetics.nms.v1_19_R3;
|
|
||||||
|
|
||||||
import net.minecraft.world.entity.decoration.ArmorStand;
|
|
||||||
import net.minecraft.world.level.Level;
|
|
||||||
import org.bukkit.Location;
|
|
||||||
import org.bukkit.craftbukkit.v1_19_R3.CraftWorld;
|
|
||||||
|
|
||||||
public class HMCArmorStand extends ArmorStand {
|
|
||||||
|
|
||||||
public HMCArmorStand(Level world, double x, double y, double z) {
|
|
||||||
super(world, x, y, z);
|
|
||||||
}
|
|
||||||
|
|
||||||
public HMCArmorStand(Location loc) {
|
|
||||||
super(((CraftWorld) loc.getWorld()).getHandle(), loc.getX(), loc.getY(), loc.getZ());
|
|
||||||
this.setPos(loc.getX(), loc.getY(), loc.getZ());
|
|
||||||
setInvisible(true);
|
|
||||||
setInvulnerable(true);
|
|
||||||
setMarker(true);
|
|
||||||
setSilent(true);
|
|
||||||
getBukkitLivingEntity().setCollidable(false);
|
|
||||||
persist = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,14 +1,8 @@
|
|||||||
package com.hibiscusmc.hmccosmetics.nms.v1_19_R3;
|
package com.hibiscusmc.hmccosmetics.nms.v1_19_R3;
|
||||||
|
|
||||||
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.CosmeticBalloonType;
|
||||||
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticMainhandType;
|
|
||||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||||
import com.hibiscusmc.hmccosmetics.user.manager.UserBalloonManager;
|
import com.hibiscusmc.hmccosmetics.user.manager.UserBalloonManager;
|
||||||
import com.hibiscusmc.hmccosmetics.util.InventoryUtils;
|
|
||||||
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||||
import com.mojang.datafixers.util.Pair;
|
import com.mojang.datafixers.util.Pair;
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.network.chat.Component;
|
||||||
@@ -58,37 +52,17 @@ public class NMSHandler implements com.hibiscusmc.hmccosmetics.nms.NMSHandler {
|
|||||||
private net.minecraft.world.entity.Entity getNMSEntity(int entityId) {
|
private net.minecraft.world.entity.Entity getNMSEntity(int entityId) {
|
||||||
for (ServerLevel world : ((CraftServer) Bukkit.getServer()).getHandle().getServer().getAllLevels()) {
|
for (ServerLevel world : ((CraftServer) Bukkit.getServer()).getHandle().getServer().getAllLevels()) {
|
||||||
net.minecraft.world.entity.Entity entity = world.getEntity(entityId);
|
net.minecraft.world.entity.Entity entity = world.getEntity(entityId);
|
||||||
if (entity == null) return null;
|
if (entity == null) continue;
|
||||||
return entity;
|
return entity;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public org.bukkit.entity.Entity getHMCArmorStand(Location loc) {
|
|
||||||
HMCArmorStand hmcArmorStand = new HMCArmorStand(loc);
|
|
||||||
return hmcArmorStand.getBukkitEntity();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ArmorStand getMEGEntity(Location loc) {
|
public ArmorStand getMEGEntity(Location loc) {
|
||||||
return (ArmorStand) new MEGEntity(loc).getBukkitEntity();
|
return (ArmorStand) new MEGEntity(loc).getBukkitEntity();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public org.bukkit.entity.Entity spawnBackpack(CosmeticUser user, CosmeticBackpackType cosmeticBackpackType) {
|
|
||||||
HMCArmorStand invisibleArmorstand = new HMCArmorStand(user.getEntity().getLocation());
|
|
||||||
|
|
||||||
ItemStack item = user.getUserCosmeticItem(cosmeticBackpackType);
|
|
||||||
|
|
||||||
invisibleArmorstand.setItemSlot(EquipmentSlot.HEAD, CraftItemStack.asNMSCopy(item));
|
|
||||||
((CraftWorld) user.getEntity().getWorld()).getHandle().addFreshEntity(invisibleArmorstand, CreatureSpawnEvent.SpawnReason.CUSTOM);
|
|
||||||
|
|
||||||
MessagesUtil.sendDebugMessages("spawnBackpack NMS");
|
|
||||||
|
|
||||||
return invisibleArmorstand.getBukkitLivingEntity();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public org.bukkit.entity.Entity spawnDisplayEntity(Location location, String text) {
|
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());
|
Display.TextDisplay entity = new Display.TextDisplay(net.minecraft.world.entity.EntityType.TEXT_DISPLAY, ((CraftWorld) location.getWorld()).getHandle());
|
||||||
@@ -115,54 +89,6 @@ public class NMSHandler implements com.hibiscusmc.hmccosmetics.nms.NMSHandler {
|
|||||||
return userBalloonManager1;
|
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
|
@Override
|
||||||
public void equipmentSlotUpdate(
|
public void equipmentSlotUpdate(
|
||||||
|
|||||||
@@ -1,24 +0,0 @@
|
|||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,14 +1,8 @@
|
|||||||
package com.hibiscusmc.hmccosmetics.nms.v1_20_R1;
|
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.CosmeticBalloonType;
|
||||||
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticMainhandType;
|
|
||||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||||
import com.hibiscusmc.hmccosmetics.user.manager.UserBalloonManager;
|
import com.hibiscusmc.hmccosmetics.user.manager.UserBalloonManager;
|
||||||
import com.hibiscusmc.hmccosmetics.util.InventoryUtils;
|
|
||||||
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||||
import com.mojang.datafixers.util.Pair;
|
import com.mojang.datafixers.util.Pair;
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.network.chat.Component;
|
||||||
@@ -57,39 +51,17 @@ public class NMSHandler implements com.hibiscusmc.hmccosmetics.nms.NMSHandler {
|
|||||||
private net.minecraft.world.entity.Entity getNMSEntity(int entityId) {
|
private net.minecraft.world.entity.Entity getNMSEntity(int entityId) {
|
||||||
for (ServerLevel world : ((CraftServer) Bukkit.getServer()).getHandle().getServer().getAllLevels()) {
|
for (ServerLevel world : ((CraftServer) Bukkit.getServer()).getHandle().getServer().getAllLevels()) {
|
||||||
net.minecraft.world.entity.Entity entity = world.getEntity(entityId);
|
net.minecraft.world.entity.Entity entity = world.getEntity(entityId);
|
||||||
if (entity == null) return null;
|
if (entity == null) continue;
|
||||||
return entity;
|
return entity;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public org.bukkit.entity.Entity getHMCArmorStand(Location loc) {
|
|
||||||
HMCArmorStand hmcArmorStand = new HMCArmorStand(loc);
|
|
||||||
return hmcArmorStand.getBukkitEntity();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ArmorStand getMEGEntity(Location loc) {
|
public ArmorStand getMEGEntity(Location loc) {
|
||||||
return (ArmorStand) new MEGEntity(loc).getBukkitEntity();
|
return (ArmorStand) new MEGEntity(loc).getBukkitEntity();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public org.bukkit.entity.Entity spawnBackpack(CosmeticUser user, CosmeticBackpackType cosmeticBackpackType) {
|
|
||||||
HMCArmorStand invisibleArmorstand = new HMCArmorStand(user.getEntity().getLocation());
|
|
||||||
|
|
||||||
ItemStack item = user.getUserCosmeticItem(cosmeticBackpackType);
|
|
||||||
|
|
||||||
invisibleArmorstand.setItemSlot(EquipmentSlot.HEAD, CraftItemStack.asNMSCopy(item));
|
|
||||||
((CraftWorld) user.getEntity().getWorld()).getHandle().addFreshEntity(invisibleArmorstand, CreatureSpawnEvent.SpawnReason.CUSTOM);
|
|
||||||
|
|
||||||
MessagesUtil.sendDebugMessages("spawnBackpack NMS");
|
|
||||||
|
|
||||||
return invisibleArmorstand.getBukkitLivingEntity();
|
|
||||||
//PacketManager.armorStandMetaPacket(invisibleArmorstand.getBukkitEntity(), sentTo);
|
|
||||||
//PacketManager.ridingMountPacket(player.getEntityId(), invisibleArmorstand.getId(), sentTo);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public org.bukkit.entity.Entity spawnDisplayEntity(Location location, String text) {
|
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());
|
Display.TextDisplay entity = new Display.TextDisplay(net.minecraft.world.entity.EntityType.TEXT_DISPLAY, ((CraftWorld) location.getWorld()).getHandle());
|
||||||
@@ -116,54 +88,6 @@ public class NMSHandler implements com.hibiscusmc.hmccosmetics.nms.NMSHandler {
|
|||||||
return userBalloonManager1;
|
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
|
@Override
|
||||||
public void equipmentSlotUpdate(
|
public void equipmentSlotUpdate(
|
||||||
|
|||||||
27
v1_20_R2/build.gradle.kts
Normal file
27
v1_20_R2/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.2-R0.1-SNAPSHOT")
|
||||||
|
implementation(project(":common"))
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks {
|
||||||
|
|
||||||
|
build {
|
||||||
|
dependsOn(reobfJar)
|
||||||
|
}
|
||||||
|
|
||||||
|
compileJava {
|
||||||
|
options.encoding = Charsets.UTF_8.name()
|
||||||
|
options.release.set(17)
|
||||||
|
}
|
||||||
|
javadoc {
|
||||||
|
options.encoding = Charsets.UTF_8.name()
|
||||||
|
}
|
||||||
|
processResources {
|
||||||
|
filteringCharset = Charsets.UTF_8.name()
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
package com.hibiscusmc.hmccosmetics.nms.v1_20_R2;
|
||||||
|
|
||||||
|
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
|
||||||
|
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||||
|
import net.minecraft.world.entity.EntityType;
|
||||||
|
import net.minecraft.world.entity.decoration.ArmorStand;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.NamespacedKey;
|
||||||
|
import org.bukkit.craftbukkit.v1_20_R2.CraftWorld;
|
||||||
|
import org.bukkit.persistence.PersistentDataType;
|
||||||
|
|
||||||
|
public class MEGEntity extends ArmorStand {
|
||||||
|
public MEGEntity(Location loc) {
|
||||||
|
super(EntityType.ARMOR_STAND, ((CraftWorld) loc.getWorld()).getHandle());
|
||||||
|
this.setPos(loc.getX(), loc.getY(), loc.getZ());
|
||||||
|
|
||||||
|
MessagesUtil.sendDebugMessages("Spawned MEGEntity at " + loc);
|
||||||
|
setInvisible(true);
|
||||||
|
setNoGravity(true);
|
||||||
|
setSilent(true);
|
||||||
|
setInvulnerable(true);
|
||||||
|
setSmall(true);
|
||||||
|
setMarker(true);
|
||||||
|
|
||||||
|
persist = false;
|
||||||
|
getBukkitEntity().getPersistentDataContainer().set(new NamespacedKey(HMCCosmeticsPlugin.getInstance(), "cosmeticMob"), PersistentDataType.SHORT, Short.valueOf("1"));
|
||||||
|
|
||||||
|
((CraftWorld) loc.getWorld()).getHandle().addFreshEntity(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,170 @@
|
|||||||
|
package com.hibiscusmc.hmccosmetics.nms.v1_20_R2;
|
||||||
|
|
||||||
|
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticBalloonType;
|
||||||
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||||
|
import com.hibiscusmc.hmccosmetics.user.manager.UserBalloonManager;
|
||||||
|
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||||
|
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.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_R2.CraftEquipmentSlot;
|
||||||
|
import org.bukkit.craftbukkit.v1_20_R2.CraftServer;
|
||||||
|
import org.bukkit.craftbukkit.v1_20_R2.CraftWorld;
|
||||||
|
import org.bukkit.craftbukkit.v1_20_R2.entity.CraftPlayer;
|
||||||
|
import org.bukkit.craftbukkit.v1_20_R2.inventory.CraftItemStack;
|
||||||
|
import org.bukkit.craftbukkit.v1_20_R2.scoreboard.CraftScoreboard;
|
||||||
|
import org.bukkit.entity.ArmorStand;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.entity.CreatureSpawnEvent;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class NMSHandler implements com.hibiscusmc.hmccosmetics.nms.NMSHandler {
|
||||||
|
@Override
|
||||||
|
public int getNextEntityId() {
|
||||||
|
return net.minecraft.world.entity.Entity.nextEntityId();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public org.bukkit.entity.Entity getEntity(int entityId) {
|
||||||
|
net.minecraft.world.entity.Entity entity = getNMSEntity(entityId);
|
||||||
|
if (entity == null) return null;
|
||||||
|
return entity.getBukkitEntity();
|
||||||
|
}
|
||||||
|
|
||||||
|
private net.minecraft.world.entity.Entity getNMSEntity(int entityId) {
|
||||||
|
for (ServerLevel world : ((CraftServer) Bukkit.getServer()).getHandle().getServer().getAllLevels()) {
|
||||||
|
net.minecraft.world.entity.Entity entity = world.getEntity(entityId);
|
||||||
|
if (entity == null) continue;
|
||||||
|
return entity;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ArmorStand getMEGEntity(Location loc) {
|
||||||
|
return (ArmorStand) new MEGEntity(loc).getBukkitEntity();
|
||||||
|
}
|
||||||
|
|
||||||
|
@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) {
|
||||||
|
org.bukkit.entity.Entity entity = user.getEntity();
|
||||||
|
|
||||||
|
UserBalloonManager userBalloonManager1 = new UserBalloonManager(user, entity.getLocation());
|
||||||
|
userBalloonManager1.getModelEntity().teleport(entity.getLocation().add(cosmeticBalloonType.getBalloonOffset()));
|
||||||
|
|
||||||
|
userBalloonManager1.spawnModel(cosmeticBalloonType, user.getCosmeticColor(cosmeticBalloonType.getSlot()));
|
||||||
|
userBalloonManager1.addPlayerToModel(user, cosmeticBalloonType, user.getCosmeticColor(cosmeticBalloonType.getSlot()));
|
||||||
|
|
||||||
|
return userBalloonManager1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@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