mirror of
https://github.com/HibiscusMC/HMCCosmetics.git
synced 2025-12-23 17:09:24 +00:00
Compare commits
37 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
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.4"
|
||||||
|
|
||||||
allprojects {
|
allprojects {
|
||||||
apply(plugin = "java")
|
apply(plugin = "java")
|
||||||
@@ -63,6 +63,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 {
|
||||||
@@ -175,7 +178,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 +187,7 @@ bukkit {
|
|||||||
commands {
|
commands {
|
||||||
register("cosmetic") {
|
register("cosmetic") {
|
||||||
description = "Base Cosmetic Command"
|
description = "Base Cosmetic Command"
|
||||||
|
aliases = listOf("hmccosmetics", "cosmetics")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
permissions {
|
permissions {
|
||||||
|
|||||||
@@ -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")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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) {
|
||||||
|
|||||||
@@ -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;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,7 +39,9 @@ public class Settings {
|
|||||||
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 +105,14 @@ public class Settings {
|
|||||||
@Getter
|
@Getter
|
||||||
private static boolean backpackForceRidingEnabled;
|
private static boolean backpackForceRidingEnabled;
|
||||||
@Getter
|
@Getter
|
||||||
|
private static boolean cosmeticForceOffhandCosmeticShow;
|
||||||
|
@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;
|
||||||
@@ -173,6 +179,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);
|
||||||
|
|||||||
@@ -31,16 +31,12 @@ 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());
|
||||||
}
|
}
|
||||||
|
|
||||||
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);
|
||||||
|
|||||||
@@ -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)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -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());
|
||||||
|
|||||||
@@ -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;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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();
|
||||||
@@ -263,7 +265,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)
|
||||||
@@ -479,14 +487,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 +521,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 +585,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 +602,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
|
||||||
|
|||||||
@@ -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();
|
||||||
|
|
||||||
|
|||||||
@@ -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() {
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
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;
|
||||||
@@ -136,7 +135,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();
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
package com.hibiscusmc.hmccosmetics.user.manager;
|
package com.hibiscusmc.hmccosmetics.user.manager;
|
||||||
|
|
||||||
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||||
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUsers;
|
||||||
import com.hibiscusmc.hmccosmetics.util.PlayerUtils;
|
import com.hibiscusmc.hmccosmetics.util.PlayerUtils;
|
||||||
import com.hibiscusmc.hmccosmetics.util.packets.PacketManager;
|
import com.hibiscusmc.hmccosmetics.util.packets.PacketManager;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
@@ -11,17 +13,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 +31,39 @@ public class UserBalloonPufferfish extends UserEntity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void hidePufferfish() {
|
public void hidePufferfish() {
|
||||||
PacketManager.sendEntityDestroyPacket(id, getViewers());
|
PacketManager.sendEntityDestroyPacket(pufferFishEntityId, getViewers());
|
||||||
getViewers().clear();
|
getViewers().clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@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());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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);
|
||||||
@@ -552,4 +551,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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,6 +35,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 +129,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
|
||||||
|
|||||||
@@ -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(
|
||||||
|
|||||||
Reference in New Issue
Block a user