mirror of
https://github.com/HibiscusMC/HMCCosmetics.git
synced 2025-12-24 01:19:14 +00:00
Compare commits
27 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 | ||
|
|
006319a757 | ||
|
|
a8ff8e6a7a | ||
|
|
8b20207442 | ||
|
|
8bbe12ed84 | ||
|
|
d23f3e19d2 |
@@ -8,7 +8,7 @@ plugins {
|
|||||||
}
|
}
|
||||||
|
|
||||||
group = "com.hibiscusmc"
|
group = "com.hibiscusmc"
|
||||||
version = "2.6.2"
|
version = "2.6.4"
|
||||||
|
|
||||||
allprojects {
|
allprojects {
|
||||||
apply(plugin = "java")
|
apply(plugin = "java")
|
||||||
@@ -187,6 +187,7 @@ bukkit {
|
|||||||
commands {
|
commands {
|
||||||
register("cosmetic") {
|
register("cosmetic") {
|
||||||
description = "Base Cosmetic Command"
|
description = "Base Cosmetic Command"
|
||||||
|
aliases = listOf("hmccosmetics", "cosmetics")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
permissions {
|
permissions {
|
||||||
|
|||||||
@@ -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) {
|
||||||
|
|||||||
@@ -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;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,6 +41,7 @@ public class Settings {
|
|||||||
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_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";
|
||||||
@@ -104,6 +105,8 @@ 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;
|
||||||
@@ -177,6 +180,7 @@ public class Settings {
|
|||||||
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);
|
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);
|
||||||
|
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ public class Wardrobe {
|
|||||||
@Getter
|
@Getter
|
||||||
private final String id;
|
private final String id;
|
||||||
@Getter @Setter
|
@Getter @Setter
|
||||||
private int distance = WardrobeSettings.getDisplayRadius();
|
private int distance;
|
||||||
@Getter @Setter
|
@Getter @Setter
|
||||||
private String permission;
|
private String permission;
|
||||||
@Getter @Setter
|
@Getter @Setter
|
||||||
@@ -29,8 +29,8 @@ public class Wardrobe {
|
|||||||
public Wardrobe(@NotNull String id, @NotNull WardrobeLocation location, @Nullable String permission, int 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;
|
||||||
|
this.distance = distance;
|
||||||
if (permission != null) this.permission = permission;
|
if (permission != null) this.permission = permission;
|
||||||
if (distance != -1) this.distance = distance;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -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);
|
||||||
|
|||||||
@@ -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)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -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;
|
||||||
@@ -264,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)
|
||||||
@@ -480,30 +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++) {
|
||||||
if (equipmentSlot.equals(EquipmentSlot.HAND)) {
|
com.comphenix.protocol.wrappers.Pair<EnumWrappers.ItemSlot, ItemStack> pair = armor.get(i);
|
||||||
Pair<EnumWrappers.ItemSlot, ItemStack> pair = new Pair<>(EnumWrappers.ItemSlot.MAINHAND, user.getPlayer().getInventory().getItemInMainHand());
|
switch (pair.getFirst()) {
|
||||||
armor.add(pair);
|
case MAINHAND -> {
|
||||||
continue;
|
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()));
|
||||||
if (equipmentSlot.equals(EquipmentSlot.OFF_HAND)) {
|
}
|
||||||
ItemStack item = null;
|
case OFFHAND -> {
|
||||||
if (user.getPlayer().getInventory().getItemInOffHand().getType().isAir()) {
|
if (Settings.isCosmeticForceOffhandCosmeticShow() && user.hasCosmeticInSlot(CosmeticSlot.OFFHAND)) {
|
||||||
if (user.hasCosmeticInSlot(CosmeticSlot.OFFHAND)) item = user.getUserCosmeticItem(CosmeticSlot.OFFHAND);
|
ItemStack item = user.getUserCosmeticItem(CosmeticSlot.OFFHAND);
|
||||||
} else {
|
if (item == null) continue;
|
||||||
item = user.getPlayer().getInventory().getItemInOffHand();
|
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);
|
||||||
}
|
}
|
||||||
Pair<EnumWrappers.ItemSlot, ItemStack> pair = new Pair<>(EnumWrappers.ItemSlot.OFFHAND, item);
|
|
||||||
armor.add(pair);
|
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
CosmeticArmorType cosmeticArmor = (CosmeticArmorType) user.getCosmetic(InventoryUtils.BukkitCosmeticSlot(equipmentSlot));
|
|
||||||
if (cosmeticArmor == null) continue;
|
|
||||||
Pair<EnumWrappers.ItemSlot, ItemStack> pair = new Pair<>(InventoryUtils.itemBukkitSlot(cosmeticArmor.getEquipSlot()), cosmeticArmor.getItem());
|
|
||||||
armor.add(pair);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
event.getPacket().getSlotStackPairLists().write(0, armor);
|
event.getPacket().getSlotStackPairLists().write(0, armor);
|
||||||
|
|||||||
@@ -20,8 +20,6 @@ public interface NMSHandler {
|
|||||||
|
|
||||||
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);
|
||||||
|
|||||||
@@ -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();
|
||||||
|
|
||||||
|
|||||||
@@ -135,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,22 +1,29 @@
|
|||||||
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.packets.PacketManager;
|
import com.hibiscusmc.hmccosmetics.util.packets.PacketManager;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
import java.util.UUID;
|
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() {
|
||||||
@@ -24,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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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;
|
||||||
|
|||||||
@@ -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;
|
||||||
@@ -29,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,
|
||||||
@@ -550,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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,6 +38,9 @@ cosmetic-settings:
|
|||||||
# 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 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.
|
# 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
|
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.
|
||||||
@@ -126,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,10 +1,8 @@
|
|||||||
package com.hibiscusmc.hmccosmetics.nms.v1_18_R2;
|
package com.hibiscusmc.hmccosmetics.nms.v1_18_R2;
|
||||||
|
|
||||||
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;
|
||||||
import com.hibiscusmc.hmccosmetics.user.manager.UserBalloonManager;
|
import com.hibiscusmc.hmccosmetics.user.manager.UserBalloonManager;
|
||||||
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;
|
||||||
@@ -21,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;
|
||||||
@@ -61,20 +57,6 @@ public class NMSHandler implements com.hibiscusmc.hmccosmetics.nms.NMSHandler {
|
|||||||
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;
|
||||||
|
|||||||
@@ -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,10 +1,8 @@
|
|||||||
package com.hibiscusmc.hmccosmetics.nms.v1_19_R1;
|
package com.hibiscusmc.hmccosmetics.nms.v1_19_R1;
|
||||||
|
|
||||||
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;
|
||||||
import com.hibiscusmc.hmccosmetics.user.manager.UserBalloonManager;
|
import com.hibiscusmc.hmccosmetics.user.manager.UserBalloonManager;
|
||||||
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;
|
||||||
@@ -21,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;
|
||||||
@@ -61,28 +57,11 @@ public class NMSHandler implements com.hibiscusmc.hmccosmetics.nms.NMSHandler {
|
|||||||
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();
|
||||||
|
|||||||
@@ -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,10 +1,8 @@
|
|||||||
package com.hibiscusmc.hmccosmetics.nms.v1_19_R2;
|
package com.hibiscusmc.hmccosmetics.nms.v1_19_R2;
|
||||||
|
|
||||||
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;
|
||||||
import com.hibiscusmc.hmccosmetics.user.manager.UserBalloonManager;
|
import com.hibiscusmc.hmccosmetics.user.manager.UserBalloonManager;
|
||||||
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;
|
||||||
@@ -21,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;
|
||||||
@@ -61,20 +57,6 @@ public class NMSHandler implements com.hibiscusmc.hmccosmetics.nms.NMSHandler {
|
|||||||
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;
|
||||||
|
|||||||
@@ -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,6 +1,5 @@
|
|||||||
package com.hibiscusmc.hmccosmetics.nms.v1_19_R3;
|
package com.hibiscusmc.hmccosmetics.nms.v1_19_R3;
|
||||||
|
|
||||||
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;
|
||||||
import com.hibiscusmc.hmccosmetics.user.manager.UserBalloonManager;
|
import com.hibiscusmc.hmccosmetics.user.manager.UserBalloonManager;
|
||||||
@@ -64,20 +63,6 @@ public class NMSHandler implements com.hibiscusmc.hmccosmetics.nms.NMSHandler {
|
|||||||
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());
|
||||||
|
|||||||
@@ -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,6 +1,5 @@
|
|||||||
package com.hibiscusmc.hmccosmetics.nms.v1_20_R1;
|
package com.hibiscusmc.hmccosmetics.nms.v1_20_R1;
|
||||||
|
|
||||||
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;
|
||||||
import com.hibiscusmc.hmccosmetics.user.manager.UserBalloonManager;
|
import com.hibiscusmc.hmccosmetics.user.manager.UserBalloonManager;
|
||||||
@@ -63,22 +62,6 @@ public class NMSHandler implements com.hibiscusmc.hmccosmetics.nms.NMSHandler {
|
|||||||
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());
|
||||||
|
|||||||
Reference in New Issue
Block a user