mirror of
https://github.com/HibiscusMC/HMCCosmetics.git
synced 2025-12-20 15:39:16 +00:00
Compare commits
7 Commits
display-en
...
v2.7.3
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c8b7430998 | ||
|
|
42de76d84d | ||
|
|
5102fd77b7 | ||
|
|
9c66d4ee81 | ||
|
|
7ade2d9227 | ||
|
|
7b43b42740 | ||
|
|
25f050f387 |
@@ -8,7 +8,7 @@ plugins {
|
||||
}
|
||||
|
||||
group = "com.hibiscusmc"
|
||||
version = "2.7.3-DEV"
|
||||
version = "2.7.3"
|
||||
|
||||
allprojects {
|
||||
apply(plugin = "java")
|
||||
@@ -69,7 +69,6 @@ allprojects {
|
||||
|
||||
// Hibiscus Commons
|
||||
maven("https://repo.hibiscusmc.com/releases")
|
||||
mavenLocal()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
@@ -78,13 +77,13 @@ allprojects {
|
||||
//compileOnly("org.spigotmc:spigot-api:1.18.2-R0.1-SNAPSHOT")
|
||||
compileOnly("io.papermc.paper:paper-api:1.19.4-R0.1-SNAPSHOT")
|
||||
compileOnly("org.jetbrains:annotations:24.1.0")
|
||||
compileOnly("com.comphenix.protocol:ProtocolLib:5.1.0")
|
||||
compileOnly("com.comphenix.protocol:ProtocolLib:5.3.0-SNAPSHOT")
|
||||
compileOnly("me.clip:placeholderapi:2.11.6")
|
||||
compileOnly("com.ticxo.modelengine:ModelEngine:R4.0.2")
|
||||
compileOnly("com.sk89q.worldguard:worldguard-bukkit:7.1.0-SNAPSHOT")
|
||||
compileOnly("it.unimi.dsi:fastutil:8.5.13")
|
||||
compileOnly("org.projectlombok:lombok:1.18.34")
|
||||
compileOnly("me.lojosho:HibiscusCommons:0.4.7")
|
||||
compileOnly("me.lojosho:HibiscusCommons:0.4.1")
|
||||
|
||||
// Handled by Spigot Library Loader
|
||||
compileOnly("net.kyori:adventure-api:4.17.0")
|
||||
@@ -140,7 +139,7 @@ tasks {
|
||||
}
|
||||
|
||||
doLast {
|
||||
archiveFile.get().asFile.copyTo(File("D:\\Server\\Paper1_21\\plugins\\${project.name}-${project.version}.jar"), true)
|
||||
archiveFile.get().asFile.copyTo(layout.projectDirectory.file("run/plugins/HMCCosmeticsRemapped.jar").asFile, true)
|
||||
println("If you use the plugin, consider buying it for: ")
|
||||
println("The custom resource pack, Oraxen + ItemAdder configurations, and Discord support!")
|
||||
println("Polymart: https://polymart.org/resource/1879")
|
||||
|
||||
@@ -49,8 +49,6 @@ public class Settings {
|
||||
private static final String COSMETIC_DISABLED_WORLDS_PATH = "disabled-worlds";
|
||||
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_LIGHT_EMINATION_PATH = "backpack-light-emination";
|
||||
private static final String COSMETIC_BACKPACK_LIGHT_BLOCK_DETECTION = "backpack-block-detection";
|
||||
private static final String COSMETIC_DESTROY_LOOSE_COSMETIC_PATH = "destroy-loose-cosmetics";
|
||||
private static final String COSMETIC_BALLOON_HEAD_FORWARD_PATH = "balloon-head-forward";
|
||||
private static final String MENU_SETTINGS_PATH = "menu-settings";
|
||||
@@ -107,10 +105,6 @@ public class Settings {
|
||||
@Getter
|
||||
private static boolean backpackForceRidingEnabled;
|
||||
@Getter
|
||||
private static boolean backpackLightEmination;
|
||||
@Getter
|
||||
private static boolean backpackBlockDetection;
|
||||
@Getter
|
||||
private static boolean emotesEnabled;
|
||||
@Getter
|
||||
private static boolean disabledGamemodesEnabled;
|
||||
@@ -202,8 +196,6 @@ public class Settings {
|
||||
emoteInvincible = cosmeticSettings.node(COSMETIC_EMOTE_INVINCIBLE_PATH).getBoolean(false);
|
||||
destroyLooseCosmetics = cosmeticSettings.node(COSMETIC_DESTROY_LOOSE_COSMETIC_PATH).getBoolean(false);
|
||||
backpackForceRidingEnabled = cosmeticSettings.node(COSMETIC_BACKPACK_FORCE_RIDING_PACKET_PATH).getBoolean(false);
|
||||
backpackLightEmination = cosmeticSettings.node(COSMETIC_BACKPACK_LIGHT_EMINATION_PATH).getBoolean(true);
|
||||
backpackBlockDetection = cosmeticSettings.node(COSMETIC_BACKPACK_LIGHT_BLOCK_DETECTION).getBoolean(true);
|
||||
|
||||
cosmeticSettings.node(SLOT_OPTIONS_PATH).childrenMap().forEach((key, value) -> {
|
||||
EquipmentSlot slot = convertConfigToEquipment(key.toString().toLowerCase());
|
||||
|
||||
@@ -2,23 +2,16 @@ package com.hibiscusmc.hmccosmetics.cosmetic;
|
||||
|
||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||
import com.hibiscusmc.hmccosmetics.util.misc.ItemDisplayMetadata;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import me.lojosho.hibiscuscommons.config.serializer.ItemSerializer;
|
||||
import me.lojosho.shaded.configurate.ConfigurationNode;
|
||||
import me.lojosho.shaded.configurate.serialize.SerializationException;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Display;
|
||||
import org.bukkit.entity.ItemDisplay;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.joml.Quaternionf;
|
||||
import org.joml.Vector3f;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public abstract class Cosmetic {
|
||||
@@ -83,52 +76,4 @@ public abstract class Cosmetic {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
protected ItemDisplayMetadata generateItemDisplayMetadata(ConfigurationNode config) {
|
||||
ItemDisplayMetadata metadata = new ItemDisplayMetadata();
|
||||
if (!config.virtual()) {
|
||||
ConfigurationNode translationNode = config.node("translation");
|
||||
ConfigurationNode scaleNode = config.node("scale");
|
||||
ConfigurationNode rotationLeftNode = config.node("rotation-left");
|
||||
ConfigurationNode rotationRightNode = config.node("rotation-right");
|
||||
ConfigurationNode skyLightNode = config.node("sky-light");
|
||||
ConfigurationNode viewRangeNode = config.node("viewrange");
|
||||
ConfigurationNode widthNode = config.node("width");
|
||||
ConfigurationNode heightNode = config.node("height");
|
||||
ConfigurationNode displayTransformNode = config.node("display-transform");
|
||||
ConfigurationNode itemstackNode = config.node("item");
|
||||
|
||||
if (!translationNode.virtual()) metadata.translation = stringToVector(translationNode.getString("0,0,0"));
|
||||
if (!scaleNode.virtual()) metadata.scale = stringToVector(scaleNode.getString("1,1,1"));
|
||||
if (!rotationLeftNode.virtual()) metadata.rotationLeft = stringToQuaternion(rotationLeftNode.getString("0,0,0,1"));
|
||||
if (!rotationRightNode.virtual()) metadata.rotationRight = stringToQuaternion(rotationRightNode.getString("0,0,0,1"));
|
||||
if (!skyLightNode.virtual()) metadata.skyLight = skyLightNode.getInt(15);
|
||||
if (!viewRangeNode.virtual()) metadata.viewRange = viewRangeNode.getFloat(1);
|
||||
if (!widthNode.virtual()) metadata.width = widthNode.getFloat(0);
|
||||
if (!heightNode.virtual()) metadata.height = heightNode.getFloat(0);
|
||||
if (!displayTransformNode.virtual()) try {
|
||||
metadata.displayTransform = ItemDisplay.ItemDisplayTransform.valueOf(displayTransformNode.getString());
|
||||
} catch (Exception ignored) {}
|
||||
if (!itemstackNode.virtual()) try {
|
||||
metadata.itemStack = ItemSerializer.INSTANCE.deserialize(ItemStack.class, itemstackNode);
|
||||
} catch (Exception ignored) {}
|
||||
}
|
||||
|
||||
return metadata;
|
||||
}
|
||||
|
||||
protected Vector3f stringToVector(String string) {
|
||||
List<String> vector = Arrays.stream(string.replace(" ", "").split(",", 3)).toList();
|
||||
while (vector.size() < 3) vector.add("0");
|
||||
float x = Float.parseFloat(vector.get(0)), y = Float.parseFloat(vector.get(1)), z = Float.parseFloat(vector.get(2));
|
||||
return new Vector3f(x, y, z);
|
||||
}
|
||||
|
||||
protected Quaternionf stringToQuaternion(String string) {
|
||||
List<String> vector = Arrays.stream(string.replace(" ", "").split(",", 4)).toList();
|
||||
while (vector.size() < 3) vector.add("0");
|
||||
if (vector.size() < 4) vector.add("1");
|
||||
float x = Float.parseFloat(vector.get(0)), y = Float.parseFloat(vector.get(1)), z = Float.parseFloat(vector.get(2)), w = Float.parseFloat(vector.get(3));
|
||||
return new Quaternionf(x, y, z, w);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,18 +3,17 @@ package com.hibiscusmc.hmccosmetics.cosmetic.types;
|
||||
import com.hibiscusmc.hmccosmetics.config.Settings;
|
||||
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
|
||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||
import com.hibiscusmc.hmccosmetics.user.manager.UserBackpackManager;
|
||||
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||
import com.hibiscusmc.hmccosmetics.util.misc.ItemDisplayMetadata;
|
||||
import com.hibiscusmc.hmccosmetics.util.packets.HMCCPacketManager;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import me.lojosho.hibiscuscommons.util.packets.PacketManager;
|
||||
import me.lojosho.shaded.configurate.ConfigurationNode;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.EquipmentSlot;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@@ -30,24 +29,16 @@ public class CosmeticBackpackType extends Cosmetic {
|
||||
@Getter
|
||||
private int height = -1;
|
||||
private ItemStack firstPersonBackpack;
|
||||
@Getter @Setter
|
||||
private ItemDisplayMetadata metadata;
|
||||
@Getter @Setter
|
||||
private ItemDisplayMetadata firstPersonMetadata;
|
||||
|
||||
public CosmeticBackpackType(String id, ConfigurationNode config) {
|
||||
super(id, config);
|
||||
|
||||
modelName = config.node("model").getString();
|
||||
|
||||
ConfigurationNode firstPersonNode = config.node("firstperson-item");
|
||||
if (!firstPersonNode.virtual()) {
|
||||
this.firstPersonBackpack = generateItemStack(firstPersonNode);
|
||||
if (!config.node("firstperson-item").virtual()) {
|
||||
this.firstPersonBackpack = generateItemStack(config.node("firstperson-item"));
|
||||
this.height = config.node("height").getInt(5);
|
||||
}
|
||||
|
||||
this.firstPersonMetadata = generateItemDisplayMetadata(config.node("firstperson-metadata")).setVertical();
|
||||
this.metadata = generateItemDisplayMetadata(config.node("metadata")).setFixed();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -55,7 +46,7 @@ public class CosmeticBackpackType extends Cosmetic {
|
||||
Entity entity = Bukkit.getEntity(user.getUniqueId());
|
||||
if (entity == null) return;
|
||||
|
||||
Location loc = entity.getLocation();
|
||||
Location loc = entity.getLocation().clone().add(0, 2, 0);
|
||||
|
||||
if (user.isInWardrobe() || !user.isBackpackSpawned()) return;
|
||||
if (user.isHidden()) {
|
||||
@@ -65,20 +56,20 @@ public class CosmeticBackpackType extends Cosmetic {
|
||||
}
|
||||
List<Player> outsideViewers = user.getUserBackpackManager().getEntityManager().refreshViewers(loc);
|
||||
|
||||
UserBackpackManager backpackManager = user.getUserBackpackManager();
|
||||
//backpackManager.getEntityManager().setRotation((int) loc.getYaw(), false);
|
||||
user.getUserBackpackManager().getEntityManager().teleport(loc);
|
||||
user.getUserBackpackManager().getEntityManager().setRotation((int) loc.getYaw(), isFirstPersonCompadible());
|
||||
|
||||
HMCCPacketManager.sendEntitySpawnPacket(user.getEntity().getLocation(), backpackManager.getFirstItemDisplayId(), EntityType.ITEM_DISPLAY, UUID.randomUUID(), outsideViewers);
|
||||
//metadata.rotationLeft.rotateY((float) Math.toRadians(loc.getYaw()));
|
||||
HMCCPacketManager.sendItemDisplayMetadata(backpackManager.getFirstItemDisplayId(), metadata, user.getUserCosmeticItem(this, getItem()), outsideViewers);
|
||||
HMCCPacketManager.sendEntitySpawnPacket(user.getEntity().getLocation(), user.getUserBackpackManager().getFirstArmorStandId(), EntityType.ARMOR_STAND, UUID.randomUUID(), outsideViewers);
|
||||
HMCCPacketManager.sendArmorstandMetadata(user.getUserBackpackManager().getFirstArmorStandId(), outsideViewers);
|
||||
PacketManager.equipmentSlotUpdate(user.getUserBackpackManager().getFirstArmorStandId(), EquipmentSlot.HEAD, user.getUserCosmeticItem(this, getItem()), outsideViewers);
|
||||
// If true, it will send the riding packet to all players. If false, it will send the riding packet only to new players
|
||||
if (Settings.isBackpackForceRidingEnabled()) HMCCPacketManager.sendRidingPacket(entity.getEntityId(), backpackManager.getFirstItemDisplayId(), backpackManager.getEntityManager().getViewers());
|
||||
else HMCCPacketManager.sendRidingPacket(entity.getEntityId(), user.getUserBackpackManager().getFirstItemDisplayId(), outsideViewers);
|
||||
if (Settings.isBackpackForceRidingEnabled()) HMCCPacketManager.sendRidingPacket(entity.getEntityId(), user.getUserBackpackManager().getFirstArmorStandId(), user.getUserBackpackManager().getEntityManager().getViewers());
|
||||
else HMCCPacketManager.sendRidingPacket(entity.getEntityId(), user.getUserBackpackManager().getFirstArmorStandId(), outsideViewers);
|
||||
|
||||
if (!user.isInWardrobe() && isFirstPersonCompatible() && user.getPlayer() != null) {
|
||||
if (!user.isInWardrobe() && isFirstPersonCompadible() && user.getPlayer() != null) {
|
||||
List<Player> owner = List.of(user.getPlayer());
|
||||
|
||||
ArrayList<Integer> particleCloud = backpackManager.getAreaEffectEntityId();
|
||||
ArrayList<Integer> particleCloud = user.getUserBackpackManager().getAreaEffectEntityId();
|
||||
for (int i = 0; i < particleCloud.size(); i++) {
|
||||
if (i == 0) {
|
||||
HMCCPacketManager.sendRidingPacket(entity.getEntityId(), particleCloud.get(i), owner);
|
||||
@@ -86,18 +77,19 @@ public class CosmeticBackpackType extends Cosmetic {
|
||||
HMCCPacketManager.sendRidingPacket(particleCloud.get(i - 1), particleCloud.get(i) , owner);
|
||||
}
|
||||
}
|
||||
HMCCPacketManager.sendRidingPacket(particleCloud.get(particleCloud.size() - 1), backpackManager.getFirstItemDisplayId(), owner);
|
||||
HMCCPacketManager.sendRidingPacket(particleCloud.get(particleCloud.size() - 1), user.getUserBackpackManager().getFirstArmorStandId(), owner);
|
||||
if (!user.isHidden()) {
|
||||
HMCCPacketManager.sendItemDisplayMetadata(backpackManager.getFirstItemDisplayId(), firstPersonMetadata, user.getUserCosmeticItem(this, firstPersonBackpack), owner);
|
||||
//if (loc.getPitch() < -70) NMSHandlers.getHandler().equipmentSlotUpdate(user.getUserBackpackManager().getFirstArmorStandId(), EquipmentSlot.HEAD, new ItemStack(Material.AIR), owner);
|
||||
//else NMSHandlers.getHandler().equipmentSlotUpdate(user.getUserBackpackManager().getFirstArmorStandId(), EquipmentSlot.HEAD, firstPersonBackpack, owner);
|
||||
PacketManager.equipmentSlotUpdate(user.getUserBackpackManager().getFirstArmorStandId(), EquipmentSlot.HEAD, user.getUserCosmeticItem(this, firstPersonBackpack), owner);
|
||||
}
|
||||
MessagesUtil.sendDebugMessages("First Person Backpack Update[owner=" + user.getUniqueId() + ",player_location=" + loc + "]!", Level.INFO);
|
||||
}
|
||||
|
||||
//MessagesUtil.sendDebugMessages("TTTTTTT " + backpackManager.refreshBlock(backpackManager.getEntityManager().getViewers()));
|
||||
backpackManager.showBackpack();
|
||||
user.getUserBackpackManager().showBackpack();
|
||||
}
|
||||
|
||||
public boolean isFirstPersonCompatible() {
|
||||
public boolean isFirstPersonCompadible() {
|
||||
return firstPersonBackpack != null;
|
||||
}
|
||||
|
||||
|
||||
@@ -39,10 +39,9 @@ public class WGListener implements Listener {
|
||||
if (protectedRegion.getFlags().containsKey(WGHook.getCosmeticEnableFlag())) {
|
||||
if (protectedRegion.getFlags().get(WGHook.getCosmeticEnableFlag()).toString().equalsIgnoreCase("ALLOW")) {
|
||||
user.showCosmetics(CosmeticUser.HiddenReason.WORLDGUARD);
|
||||
return;
|
||||
} else {
|
||||
user.hideCosmetics(CosmeticUser.HiddenReason.WORLDGUARD);
|
||||
}
|
||||
user.hideCosmetics(CosmeticUser.HiddenReason.WORLDGUARD);
|
||||
return;
|
||||
}
|
||||
if (protectedRegion.getFlags().containsKey(WGHook.getCosmeticWardrobeFlag())) {
|
||||
if (!WardrobeSettings.getWardrobeNames().contains(protectedRegion.getFlags().get(WGHook.getCosmeticWardrobeFlag()).toString())) return;
|
||||
|
||||
@@ -58,7 +58,6 @@ public class CosmeticUser {
|
||||
|
||||
// Cosmetic Settings/Toggles
|
||||
private final ArrayList<HiddenReason> hiddenReason = new ArrayList<>();
|
||||
private final HashMap<CosmeticSlot, ItemStack> cachedCosmeticItems = new HashMap<>();
|
||||
private final HashMap<CosmeticSlot, Color> colors = new HashMap<>();
|
||||
|
||||
public CosmeticUser(UUID uuid) {
|
||||
@@ -157,7 +156,6 @@ public class CosmeticUser {
|
||||
if (slot == CosmeticSlot.EMOTE) {
|
||||
if (getUserEmoteManager().isPlayingEmote()) getUserEmoteManager().stopEmote(UserEmoteManager.StopEmoteReason.UNEQUIP);
|
||||
}
|
||||
cachedCosmeticItems.remove(slot);
|
||||
colors.remove(slot);
|
||||
playerCosmetics.remove(slot);
|
||||
removeArmor(slot);
|
||||
@@ -229,10 +227,6 @@ public class CosmeticUser {
|
||||
if (cosmetic instanceof CosmeticBackpackType || cosmetic instanceof CosmeticBalloonType) return new ItemStack(Material.AIR);
|
||||
return getPlayer().getInventory().getItem(HMCCInventoryUtils.getEquipmentSlot(cosmetic.getSlot()));
|
||||
}
|
||||
// Check if the item is cached. This helps with performance as we don't need to keep recreating the item
|
||||
if (cachedCosmeticItems.containsKey(cosmetic.getSlot())) {
|
||||
return cachedCosmeticItems.get(cosmetic.getSlot());
|
||||
}
|
||||
if (cosmetic instanceof CosmeticArmorType armorType) {
|
||||
item = armorType.getItem(this, cosmetic.getItem());
|
||||
}
|
||||
@@ -255,10 +249,6 @@ public class CosmeticUser {
|
||||
//MessagesUtil.sendDebugMessages("GetUserCosemticUser Item is null");
|
||||
return new ItemStack(Material.AIR);
|
||||
}
|
||||
// Check if the item is cached. This helps with performance as we don't need to keep recreating the item
|
||||
if (cachedCosmeticItems.containsKey(cosmetic.getSlot())) {
|
||||
return cachedCosmeticItems.get(cosmetic.getSlot());
|
||||
}
|
||||
if (item.hasItemMeta()) {
|
||||
ItemMeta itemMeta = item.getItemMeta();
|
||||
|
||||
@@ -322,7 +312,6 @@ public class CosmeticUser {
|
||||
|
||||
item.setItemMeta(itemMeta);
|
||||
}
|
||||
cachedCosmeticItems.put(cosmetic.getSlot(), item);
|
||||
return item;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,28 +1,24 @@
|
||||
package com.hibiscusmc.hmccosmetics.user.manager;
|
||||
|
||||
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
|
||||
import com.hibiscusmc.hmccosmetics.cosmetic.CosmeticSlot;
|
||||
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticBackpackType;
|
||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||
import com.hibiscusmc.hmccosmetics.util.misc.ItemDisplayMetadata;
|
||||
import com.hibiscusmc.hmccosmetics.util.packets.HMCCPacketManager;
|
||||
import com.ticxo.modelengine.api.ModelEngineAPI;
|
||||
import it.unimi.dsi.fastutil.ints.IntArrayList;
|
||||
import it.unimi.dsi.fastutil.ints.IntList;
|
||||
import lombok.Getter;
|
||||
import me.lojosho.hibiscuscommons.hooks.Hooks;
|
||||
import me.lojosho.hibiscuscommons.util.ServerUtils;
|
||||
import org.bukkit.Location;
|
||||
import me.lojosho.hibiscuscommons.util.packets.PacketManager;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.EquipmentSlot;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
import java.util.logging.Level;
|
||||
|
||||
@@ -31,26 +27,23 @@ public class UserBackpackManager {
|
||||
@Getter
|
||||
private boolean backpackHidden;
|
||||
@Getter
|
||||
private int itemDisplayId;
|
||||
private int invisibleArmorStand;
|
||||
private ArrayList<Integer> particleCloud = new ArrayList<>();
|
||||
@Getter
|
||||
private final CosmeticUser user;
|
||||
@Getter
|
||||
private UserEntity entityManager;
|
||||
//@Getter @Setter
|
||||
//private boolean inBlock;
|
||||
|
||||
public UserBackpackManager(CosmeticUser user) {
|
||||
this.user = user;
|
||||
this.backpackHidden = false;
|
||||
//this.inBlock = false;
|
||||
this.itemDisplayId = ServerUtils.getNextEntityId();
|
||||
this.invisibleArmorStand = ServerUtils.getNextEntityId();
|
||||
this.entityManager = new UserEntity(user.getUniqueId());
|
||||
if (user.getEntity() != null) this.entityManager.refreshViewers(user.getEntity().getLocation()); // Fixes an issue where a player, who somehow removes their potions, but doesn't have an entity produces an NPE (it's dumb)
|
||||
}
|
||||
|
||||
public int getFirstItemDisplayId() {
|
||||
return itemDisplayId;
|
||||
public int getFirstArmorStandId() {
|
||||
return invisibleArmorStand;
|
||||
}
|
||||
|
||||
public void spawnBackpack(CosmeticBackpackType cosmeticBackpackType) {
|
||||
@@ -60,12 +53,11 @@ public class UserBackpackManager {
|
||||
}
|
||||
|
||||
private void spawn(CosmeticBackpackType cosmeticBackpackType) {
|
||||
Location entityLoc = user.getEntity().getLocation();
|
||||
entityLoc.setPitch(0f);
|
||||
getEntityManager().setIds(List.of(itemDisplayId));
|
||||
getEntityManager().teleport(entityLoc);
|
||||
getEntityManager().setIds(List.of(invisibleArmorStand));
|
||||
getEntityManager().teleport(user.getEntity().getLocation());
|
||||
List<Player> outsideViewers = getEntityManager().getViewers();
|
||||
HMCCPacketManager.sendEntitySpawnPacket(entityLoc, getFirstItemDisplayId(), EntityType.ITEM_DISPLAY, UUID.randomUUID(), getEntityManager().getViewers());
|
||||
HMCCPacketManager.sendEntitySpawnPacket(user.getEntity().getLocation(), getFirstArmorStandId(), EntityType.ARMOR_STAND, UUID.randomUUID(), getEntityManager().getViewers());
|
||||
HMCCPacketManager.sendArmorstandMetadata(getFirstArmorStandId(), outsideViewers);
|
||||
|
||||
Entity entity = user.getEntity();
|
||||
|
||||
@@ -75,12 +67,12 @@ public class UserBackpackManager {
|
||||
passengerIDs[i] = entity.getPassengers().get(i).getEntityId();
|
||||
}
|
||||
|
||||
passengerIDs[passengerIDs.length - 1] = this.getFirstItemDisplayId();
|
||||
passengerIDs[passengerIDs.length - 1] = this.getFirstArmorStandId();
|
||||
|
||||
ArrayList<Player> owner = new ArrayList<>();
|
||||
if (user.getPlayer() != null) owner.add(user.getPlayer());
|
||||
|
||||
if (cosmeticBackpackType.isFirstPersonCompatible()) {
|
||||
if (cosmeticBackpackType.isFirstPersonCompadible()) {
|
||||
for (int i = particleCloud.size(); i < cosmeticBackpackType.getHeight(); i++) {
|
||||
int entityId = ServerUtils.getNextEntityId();
|
||||
HMCCPacketManager.sendEntitySpawnPacket(user.getEntity().getLocation(), entityId, EntityType.AREA_EFFECT_CLOUD, UUID.randomUUID());
|
||||
@@ -92,11 +84,10 @@ public class UserBackpackManager {
|
||||
if (i == 0) HMCCPacketManager.sendRidingPacket(entity.getEntityId(), particleCloud.get(i), owner);
|
||||
else HMCCPacketManager.sendRidingPacket(particleCloud.get(i - 1), particleCloud.get(i) , owner);
|
||||
}
|
||||
HMCCPacketManager.sendRidingPacket(particleCloud.get(particleCloud.size() - 1),getFirstItemDisplayId(), owner);
|
||||
if (!user.isHidden()) HMCCPacketManager.sendItemDisplayMetadata(getFirstItemDisplayId(), cosmeticBackpackType.getFirstPersonMetadata(), user.getUserCosmeticItem(cosmeticBackpackType, cosmeticBackpackType.getFirstPersonBackpack()), outsideViewers);
|
||||
HMCCPacketManager.sendRidingPacket(particleCloud.get(particleCloud.size() - 1), user.getUserBackpackManager().getFirstArmorStandId(), owner);
|
||||
if (!user.isHidden()) PacketManager.equipmentSlotUpdate(user.getUserBackpackManager().getFirstArmorStandId(), EquipmentSlot.HEAD, user.getUserCosmeticItem(cosmeticBackpackType, cosmeticBackpackType.getFirstPersonBackpack()), owner);
|
||||
}
|
||||
|
||||
HMCCPacketManager.sendItemDisplayMetadata(getFirstItemDisplayId(), cosmeticBackpackType.getMetadata(), user.getUserCosmeticItem(cosmeticBackpackType), outsideViewers);
|
||||
PacketManager.equipmentSlotUpdate(getFirstArmorStandId(), EquipmentSlot.HEAD, user.getUserCosmeticItem(cosmeticBackpackType), outsideViewers);
|
||||
HMCCPacketManager.sendRidingPacket(entity.getEntityId(), passengerIDs, outsideViewers);
|
||||
|
||||
// No one should be using ME because it barely works but some still use it, so it's here
|
||||
@@ -117,13 +108,13 @@ public class UserBackpackManager {
|
||||
}
|
||||
|
||||
public void despawnBackpack() {
|
||||
IntList entityIds = IntArrayList.of(itemDisplayId);
|
||||
HMCCPacketManager.sendEntityDestroyPacket(invisibleArmorStand, getEntityManager().getViewers());
|
||||
if (particleCloud != null) {
|
||||
entityIds.addAll(particleCloud);
|
||||
for (Integer entityId : particleCloud) {
|
||||
HMCCPacketManager.sendEntityDestroyPacket(entityId, getEntityManager().getViewers());
|
||||
}
|
||||
this.particleCloud = null;
|
||||
}
|
||||
HMCCPacketManager.sendEntityDestroyPacket(entityIds, getEntityManager().getViewers());
|
||||
|
||||
}
|
||||
|
||||
public void hideBackpack() {
|
||||
@@ -149,42 +140,11 @@ public class UserBackpackManager {
|
||||
}
|
||||
|
||||
public void setItem(ItemStack item) {
|
||||
ItemDisplayMetadata metadata = Optional.ofNullable((CosmeticBackpackType) user.getCosmetic(CosmeticSlot.BACKPACK)).map(CosmeticBackpackType::getMetadata).orElse(new ItemDisplayMetadata());
|
||||
HMCCPacketManager.sendItemDisplayMetadata(getFirstItemDisplayId(), metadata, item, getEntityManager().getViewers());
|
||||
PacketManager.equipmentSlotUpdate(getFirstArmorStandId(), EquipmentSlot.HEAD, item, getEntityManager().getViewers());
|
||||
}
|
||||
|
||||
public void clearItems() {
|
||||
ItemStack item = new ItemStack(Material.AIR);
|
||||
//PacketManager.equipmentSlotUpdate(getFirstItemDisplayId(), EquipmentSlot.HEAD, item, getEntityManager().getViewers());
|
||||
HMCCPacketManager.sendItemDisplayMetadata(getFirstItemDisplayId(), item, getEntityManager().getViewers());
|
||||
PacketManager.equipmentSlotUpdate(getFirstArmorStandId(), EquipmentSlot.HEAD, item, getEntityManager().getViewers());
|
||||
}
|
||||
|
||||
/**
|
||||
* Refreshes the block detection for the backpack
|
||||
* @param outsideViewers
|
||||
* @return true if the entity was updated, false if not
|
||||
*//*
|
||||
public boolean refreshBlock(List<Player> outsideViewers) {
|
||||
if (Settings.isBackpackBlockDetection()) {
|
||||
if (isInBlock() && checkBlock()) {
|
||||
HMCCPacketManager.sendItemDisplayMetadata(getFirstItemDisplayId(), false, outsideViewers);
|
||||
setInBlock(false);
|
||||
return true;
|
||||
}
|
||||
if (!isInBlock() && !checkBlock()) {
|
||||
HMCCPacketManager.sendItemDisplayMetadata(getFirstItemDisplayId(), true, outsideViewers);
|
||||
setInBlock(true);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean checkBlock() {
|
||||
if (Settings.isBackpackBlockDetection()) {
|
||||
Block block = getEntityManager().getLocation().clone().add(0, 1.5, 0).getBlock();
|
||||
return block.getType().isAir();
|
||||
}
|
||||
return false;
|
||||
}*/
|
||||
}
|
||||
|
||||
@@ -23,13 +23,13 @@ public class UserEmoteModel extends PlayerModel {
|
||||
|
||||
private final CosmeticUser user;
|
||||
private String emotePlaying;
|
||||
private final int itemDisplayId;
|
||||
private final int armorStandId;
|
||||
private GameMode originalGamemode;
|
||||
|
||||
public UserEmoteModel(@NotNull CosmeticUser user) {
|
||||
super(user.getPlayer());
|
||||
this.user = user;
|
||||
itemDisplayId = ServerUtils.getNextEntityId();
|
||||
armorStandId = ServerUtils.getNextEntityId();
|
||||
getRangeManager().setRenderDistance(Settings.getViewDistance());
|
||||
}
|
||||
|
||||
@@ -75,12 +75,12 @@ public class UserEmoteModel extends PlayerModel {
|
||||
MessagesUtil.sendMessage(player, "emote-blocked");
|
||||
}
|
||||
|
||||
HMCCPacketManager.sendEntitySpawnPacket(thirdPersonLocation, itemDisplayId, EntityType.ITEM_DISPLAY, UUID.randomUUID(), viewer);
|
||||
//HMCCPacketManager.sendInvisibilityPacket(itemDisplayId, viewer);
|
||||
HMCCPacketManager.sendLookPacket(itemDisplayId, thirdPersonLocation, viewer);
|
||||
HMCCPacketManager.sendEntitySpawnPacket(thirdPersonLocation, armorStandId, EntityType.ARMOR_STAND, UUID.randomUUID(), viewer);
|
||||
HMCCPacketManager.sendInvisibilityPacket(armorStandId, viewer);
|
||||
HMCCPacketManager.sendLookPacket(armorStandId, thirdPersonLocation, viewer);
|
||||
|
||||
HMCCPacketManager.gamemodeChangePacket(player, 3);
|
||||
HMCCPacketManager.sendCameraPacket(itemDisplayId, viewer);
|
||||
HMCCPacketManager.sendCameraPacket(armorStandId, viewer);
|
||||
}
|
||||
|
||||
|
||||
@@ -115,7 +115,7 @@ public class UserEmoteModel extends PlayerModel {
|
||||
|
||||
int entityId = player.getEntityId();
|
||||
HMCCPacketManager.sendCameraPacket(entityId, viewer);
|
||||
HMCCPacketManager.sendEntityDestroyPacket(itemDisplayId, viewer);
|
||||
HMCCPacketManager.sendEntityDestroyPacket(armorStandId, viewer);
|
||||
if (this.originalGamemode != null) {
|
||||
HMCCPacketManager.gamemodeChangePacket(player, HMCCServerUtils.convertGamemode(this.originalGamemode));
|
||||
player.setGameMode(this.originalGamemode);
|
||||
|
||||
@@ -5,8 +5,6 @@ import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUsers;
|
||||
import com.hibiscusmc.hmccosmetics.util.HMCCPlayerUtils;
|
||||
import com.hibiscusmc.hmccosmetics.util.packets.HMCCPacketManager;
|
||||
import it.unimi.dsi.fastutil.ints.IntArrayList;
|
||||
import it.unimi.dsi.fastutil.ints.IntList;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.bukkit.Location;
|
||||
@@ -47,7 +45,6 @@ public class UserEntity {
|
||||
|
||||
for (Player player : players) {
|
||||
CosmeticUser user = CosmeticUsers.getUser(player);
|
||||
IntList ids = new IntArrayList(this.ids);
|
||||
if (user != null && owner != user.getUniqueId() && user.isInWardrobe()) { // Fixes issue where players in wardrobe would see other players cosmetics if they were not in wardrobe
|
||||
removePlayers.add(player);
|
||||
HMCCPacketManager.sendEntityDestroyPacket(ids, List.of(player));
|
||||
|
||||
@@ -6,7 +6,6 @@ import com.hibiscusmc.hmccosmetics.config.WardrobeLocation;
|
||||
import com.hibiscusmc.hmccosmetics.config.WardrobeSettings;
|
||||
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
|
||||
import com.hibiscusmc.hmccosmetics.cosmetic.CosmeticSlot;
|
||||
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticBackpackType;
|
||||
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticBalloonType;
|
||||
import com.hibiscusmc.hmccosmetics.gui.Menu;
|
||||
import com.hibiscusmc.hmccosmetics.gui.Menus;
|
||||
@@ -14,7 +13,6 @@ import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||
import com.hibiscusmc.hmccosmetics.util.HMCCInventoryUtils;
|
||||
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||
import com.hibiscusmc.hmccosmetics.util.HMCCServerUtils;
|
||||
import com.hibiscusmc.hmccosmetics.util.misc.ItemDisplayMetadata;
|
||||
import com.hibiscusmc.hmccosmetics.util.packets.HMCCPacketManager;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
@@ -43,7 +41,7 @@ public class UserWardrobeManager {
|
||||
@Getter
|
||||
private final int NPC_ID;
|
||||
@Getter
|
||||
private final int ITEM_DISPLAY_ID;
|
||||
private final int ARMORSTAND_ID;
|
||||
@Getter
|
||||
private final UUID WARDROBE_UUID;
|
||||
@Getter
|
||||
@@ -74,7 +72,7 @@ public class UserWardrobeManager {
|
||||
|
||||
public UserWardrobeManager(CosmeticUser user, Wardrobe wardrobe) {
|
||||
NPC_ID = me.lojosho.hibiscuscommons.util.ServerUtils.getNextEntityId();
|
||||
ITEM_DISPLAY_ID = me.lojosho.hibiscuscommons.util.ServerUtils.getNextEntityId();
|
||||
ARMORSTAND_ID = me.lojosho.hibiscuscommons.util.ServerUtils.getNextEntityId();
|
||||
WARDROBE_UUID = UUID.randomUUID();
|
||||
this.user = user;
|
||||
|
||||
@@ -107,16 +105,16 @@ public class UserWardrobeManager {
|
||||
MessagesUtil.sendMessage(player, "opened-wardrobe");
|
||||
|
||||
Runnable run = () -> {
|
||||
// ItemDisplay
|
||||
HMCCPacketManager.sendEntitySpawnPacket(viewingLocation, ITEM_DISPLAY_ID, EntityType.ITEM_DISPLAY, UUID.randomUUID(), viewer);
|
||||
HMCCPacketManager.sendItemDisplayMetadata(ITEM_DISPLAY_ID, new ItemStack(Material.AIR), viewer);
|
||||
HMCCPacketManager.sendLookPacket(ITEM_DISPLAY_ID, viewingLocation, viewer);
|
||||
// Armorstand
|
||||
HMCCPacketManager.sendEntitySpawnPacket(viewingLocation, ARMORSTAND_ID, EntityType.ARMOR_STAND, UUID.randomUUID(), viewer);
|
||||
HMCCPacketManager.sendArmorstandMetadata(ARMORSTAND_ID, viewer);
|
||||
HMCCPacketManager.sendLookPacket(ARMORSTAND_ID, viewingLocation, viewer);
|
||||
|
||||
// Player
|
||||
user.getPlayer().teleport(viewingLocation, PlayerTeleportEvent.TeleportCause.PLUGIN);
|
||||
user.getPlayer().setInvisible(true);
|
||||
HMCCPacketManager.gamemodeChangePacket(player, 3);
|
||||
HMCCPacketManager.sendCameraPacket(ITEM_DISPLAY_ID, viewer);
|
||||
HMCCPacketManager.sendCameraPacket(ARMORSTAND_ID, viewer);
|
||||
|
||||
// NPC
|
||||
npcName = "WardrobeNPC-" + NPC_ID;
|
||||
@@ -141,13 +139,11 @@ public class UserWardrobeManager {
|
||||
// Misc
|
||||
if (user.hasCosmeticInSlot(CosmeticSlot.BACKPACK)) {
|
||||
// Maybe null as backpack maybe despawned before entering
|
||||
UserBackpackManager userBackpackManager = user.getUserBackpackManager();
|
||||
if (userBackpackManager == null) user.respawnBackpack();
|
||||
if (user.getUserBackpackManager() == null) user.respawnBackpack();
|
||||
if (user.isBackpackSpawned()) {
|
||||
userBackpackManager.getEntityManager().teleport(npcLocation.clone());
|
||||
CosmeticBackpackType backpackCosmetic = (CosmeticBackpackType) user.getCosmetic(CosmeticSlot.BACKPACK);
|
||||
HMCCPacketManager.sendItemDisplayMetadata(ITEM_DISPLAY_ID, backpackCosmetic.getMetadata(), user.getUserCosmeticItem(backpackCosmetic), viewer);
|
||||
HMCCPacketManager.ridingMountPacket(NPC_ID, userBackpackManager.getFirstItemDisplayId(), viewer);
|
||||
user.getUserBackpackManager().getEntityManager().teleport(npcLocation.clone().add(0, 2, 0));
|
||||
PacketManager.equipmentSlotUpdate(user.getUserBackpackManager().getFirstArmorStandId(), EquipmentSlot.HEAD, user.getUserCosmeticItem(user.getCosmetic(CosmeticSlot.BACKPACK)), viewer);
|
||||
HMCCPacketManager.ridingMountPacket(NPC_ID, user.getUserBackpackManager().getFirstArmorStandId(), viewer);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -236,7 +232,7 @@ public class UserWardrobeManager {
|
||||
user.getPlayer().setInvisible(false);
|
||||
|
||||
// Armorstand
|
||||
HMCCPacketManager.sendEntityDestroyPacket(ITEM_DISPLAY_ID, viewer); // Sucess
|
||||
HMCCPacketManager.sendEntityDestroyPacket(ARMORSTAND_ID, viewer); // Sucess
|
||||
|
||||
//PacketManager.sendEntityDestroyPacket(player.getEntityId(), viewer); // Success
|
||||
if (WardrobeSettings.isForceExitGamemode()) {
|
||||
@@ -319,10 +315,10 @@ public class UserWardrobeManager {
|
||||
}
|
||||
|
||||
if (user.hasCosmeticInSlot(CosmeticSlot.BACKPACK) && user.getUserBackpackManager() != null) {
|
||||
HMCCPacketManager.sendTeleportPacket(user.getUserBackpackManager().getFirstItemDisplayId(), location, false, viewer);
|
||||
HMCCPacketManager.ridingMountPacket(NPC_ID, user.getUserBackpackManager().getFirstItemDisplayId(), viewer);
|
||||
HMCCPacketManager.sendTeleportPacket(user.getUserBackpackManager().getFirstArmorStandId(), location, false, viewer);
|
||||
HMCCPacketManager.ridingMountPacket(NPC_ID, user.getUserBackpackManager().getFirstArmorStandId(), viewer);
|
||||
user.getUserBackpackManager().getEntityManager().setRotation(nextyaw);
|
||||
HMCCPacketManager.sendEntityDestroyPacket(user.getUserBackpackManager().getFirstItemDisplayId(), outsideViewers);
|
||||
HMCCPacketManager.sendEntityDestroyPacket(user.getUserBackpackManager().getFirstArmorStandId(), outsideViewers);
|
||||
}
|
||||
|
||||
if (user.hasCosmeticInSlot(CosmeticSlot.BALLOON) && user.isBalloonSpawned()) {
|
||||
|
||||
@@ -63,6 +63,7 @@ public class HMCCInventoryUtils {
|
||||
case FEET -> CosmeticSlot.BOOTS;
|
||||
case OFFHAND -> CosmeticSlot.OFFHAND;
|
||||
case MAINHAND -> CosmeticSlot.MAINHAND;
|
||||
default -> null;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -1,49 +0,0 @@
|
||||
package com.hibiscusmc.hmccosmetics.util.misc;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Display;
|
||||
import org.bukkit.entity.ItemDisplay;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.joml.Quaternionf;
|
||||
import org.joml.Vector3f;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class ItemDisplayMetadata {
|
||||
|
||||
public Vector3f translation;
|
||||
public Vector3f scale;
|
||||
public Quaternionf rotationLeft;
|
||||
public Quaternionf rotationRight;
|
||||
public Display.Billboard billboard;
|
||||
public int skyLight;
|
||||
public float viewRange;
|
||||
public float width;
|
||||
public float height;
|
||||
public ItemDisplay.ItemDisplayTransform displayTransform;
|
||||
public ItemStack itemStack;
|
||||
|
||||
public ItemDisplayMetadata() {
|
||||
this.translation = new Vector3f();
|
||||
this.scale = new Vector3f(1.0f, 1.0f, 1.0f);
|
||||
this.rotationLeft = new Quaternionf();
|
||||
this.rotationRight = new Quaternionf();
|
||||
this.skyLight = 15;
|
||||
this.viewRange = 1.0f;
|
||||
this.width = 0.0f;
|
||||
this.height = 0.0f;
|
||||
this.displayTransform = ItemDisplay.ItemDisplayTransform.NONE;
|
||||
this.itemStack = new ItemStack(Material.AIR);
|
||||
}
|
||||
|
||||
public ItemDisplayMetadata setFixed() {
|
||||
this.billboard = Display.Billboard.FIXED;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ItemDisplayMetadata setVertical() {
|
||||
this.billboard = Display.Billboard.VERTICAL;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -12,22 +12,17 @@ import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUsers;
|
||||
import com.hibiscusmc.hmccosmetics.util.HMCCInventoryUtils;
|
||||
import com.hibiscusmc.hmccosmetics.util.HMCCPlayerUtils;
|
||||
import com.hibiscusmc.hmccosmetics.util.misc.ItemDisplayMetadata;
|
||||
import com.hibiscusmc.hmccosmetics.util.packets.wrappers.WrapperPlayServerNamedEntitySpawn;
|
||||
import com.hibiscusmc.hmccosmetics.util.packets.wrappers.WrapperPlayServerPlayerInfo;
|
||||
import com.hibiscusmc.hmccosmetics.util.packets.wrappers.WrapperPlayServerRelEntityMove;
|
||||
import me.lojosho.hibiscuscommons.util.packets.PacketManager;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Display;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.ItemDisplay;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.EquipmentSlot;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.joml.Quaternionf;
|
||||
import org.joml.Vector3f;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
@@ -38,7 +33,7 @@ public class HMCCPacketManager extends PacketManager {
|
||||
final int entityId,
|
||||
final EntityType entityType,
|
||||
final UUID uuid
|
||||
) {
|
||||
) {
|
||||
sendEntitySpawnPacket(location, entityId, entityType, uuid, getViewers(location));
|
||||
}
|
||||
|
||||
@@ -49,7 +44,16 @@ public class HMCCPacketManager extends PacketManager {
|
||||
final UUID uuid,
|
||||
final @NotNull List<Player> sendTo
|
||||
) {
|
||||
PacketManager.sendEntitySpawnPacket(location, entityId, entityType, uuid, sendTo);
|
||||
PacketContainer packet = new PacketContainer(PacketType.Play.Server.SPAWN_ENTITY);
|
||||
packet.getModifier().writeDefaults();
|
||||
packet.getUUIDs().write(0, uuid);
|
||||
packet.getIntegers().write(0, entityId);
|
||||
packet.getEntityTypeModifier().write(0, entityType);
|
||||
packet.getDoubles().
|
||||
write(0, location.getX()).
|
||||
write(1, location.getY()).
|
||||
write(2, location.getZ());
|
||||
for (Player p : sendTo) sendPacket(p, packet);
|
||||
}
|
||||
|
||||
public static void equipmentSlotUpdate(
|
||||
@@ -92,17 +96,20 @@ public class HMCCPacketManager extends PacketManager {
|
||||
equipmentSlotUpdate(entityId, HMCCInventoryUtils.getEquipmentSlot(cosmeticSlot), user.getUserCosmeticItem(cosmeticSlot), sendTo);
|
||||
}
|
||||
|
||||
public static void sendItemDisplayMetadata(int entityId, ItemStack itemStack, List<Player> sendTo) {
|
||||
ItemDisplayMetadata metadata = new ItemDisplayMetadata();
|
||||
PacketManager.sendItemDisplayMetadataPacket(entityId, metadata.translation, metadata.scale, metadata.rotationLeft, metadata.rotationRight, metadata.billboard, 0, metadata.skyLight, metadata.viewRange, metadata.width, metadata.height, metadata.displayTransform, itemStack, sendTo);
|
||||
}
|
||||
public static void sendArmorstandMetadata(
|
||||
int entityId,
|
||||
List<Player> sendTo
|
||||
) {
|
||||
PacketContainer packet = new PacketContainer(PacketType.Play.Server.ENTITY_METADATA);
|
||||
packet.getModifier().writeDefaults();
|
||||
packet.getIntegers().write(0, entityId);
|
||||
final List<WrappedDataValue> wrappedDataValueList = Lists.newArrayList();
|
||||
|
||||
public static void sendItemDisplayMetadata(int entityId, ItemDisplayMetadata metadata, List<Player> sendTo) {
|
||||
PacketManager.sendItemDisplayMetadataPacket(entityId, metadata.translation, metadata.scale, metadata.rotationLeft, metadata.rotationRight, metadata.billboard, 0, metadata.skyLight, metadata.viewRange, metadata.width, metadata.height, metadata.displayTransform, metadata.itemStack, sendTo);
|
||||
}
|
||||
|
||||
public static void sendItemDisplayMetadata(int entityId, ItemDisplayMetadata metadata, ItemStack itemStack, List<Player> sendTo) {
|
||||
PacketManager.sendItemDisplayMetadataPacket(entityId, metadata.translation, metadata.scale, metadata.rotationLeft, metadata.rotationRight, metadata.billboard, 0, metadata.skyLight, metadata.viewRange, metadata.width, metadata.height, metadata.displayTransform, itemStack, sendTo);
|
||||
// 0x21 = Invisible + Fire (Aka, burns to make it not take the light of the block its in, avoiding turning it black)
|
||||
wrappedDataValueList.add(new WrappedDataValue(0, WrappedDataWatcher.Registry.get(Byte.class), (byte) 0x21));
|
||||
wrappedDataValueList.add(new WrappedDataValue(15, WrappedDataWatcher.Registry.get(Byte.class), (byte) 0x10));
|
||||
packet.getDataValueCollectionModifier().write(0, wrappedDataValueList);
|
||||
for (Player p : sendTo) sendPacket(p, packet);
|
||||
}
|
||||
|
||||
public static void sendInvisibilityPacket(
|
||||
|
||||
@@ -45,17 +45,8 @@ cosmetic-settings:
|
||||
emote-camera: true
|
||||
# If a player should be able to move in an emote. This option really only affects if "emote-camera" is 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.
|
||||
backpack-force-riding-packet: false
|
||||
# This makes the plugin either (true) always have the backpack eminate light to avoid the black backpack bug or (false) turns it off.
|
||||
backpack-light-emination: true
|
||||
# This activates the block detection for the backpack. This allows backpacks to not appear completely black when in a block.
|
||||
# Requires backpack-light-emination to be true.
|
||||
backpack-block-detection: true
|
||||
|
||||
|
||||
# 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
|
||||
|
||||
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Binary file not shown.
4
gradle/wrapper/gradle-wrapper.properties
vendored
4
gradle/wrapper/gradle-wrapper.properties
vendored
@@ -1,5 +1,7 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.2.1-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
|
||||
networkTimeout=10000
|
||||
validateDistributionUrl=true
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
|
||||
51
gradlew
vendored
51
gradlew
vendored
@@ -1,7 +1,7 @@
|
||||
#!/bin/sh
|
||||
|
||||
#
|
||||
# Copyright <EFBFBD> 2015-2021 the original authors.
|
||||
# Copyright © 2015-2021 the original authors.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
@@ -32,10 +32,10 @@
|
||||
# Busybox and similar reduced shells will NOT work, because this script
|
||||
# requires all of these POSIX shell features:
|
||||
# * functions;
|
||||
# * expansions <EFBFBD>$var<EFBFBD>, <EFBFBD>${var}<EFBFBD>, <EFBFBD>${var:-default}<EFBFBD>, <EFBFBD>${var+SET}<EFBFBD>,
|
||||
# <EFBFBD>${var#prefix}<EFBFBD>, <EFBFBD>${var%suffix}<EFBFBD>, and <EFBFBD>$( cmd )<EFBFBD>;
|
||||
# * compound commands having a testable exit status, especially <EFBFBD>case<EFBFBD>;
|
||||
# * various built-in commands including <EFBFBD>command<EFBFBD>, <EFBFBD>set<EFBFBD>, and <EFBFBD>ulimit<EFBFBD>.
|
||||
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
|
||||
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
|
||||
# * compound commands having a testable exit status, especially «case»;
|
||||
# * various built-in commands including «command», «set», and «ulimit».
|
||||
#
|
||||
# Important for patching:
|
||||
#
|
||||
@@ -55,7 +55,7 @@
|
||||
# Darwin, MinGW, and NonStop.
|
||||
#
|
||||
# (3) This script is generated from the Groovy template
|
||||
# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
||||
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
||||
# within the Gradle project.
|
||||
#
|
||||
# You can find Gradle at https://github.com/gradle/gradle/.
|
||||
@@ -80,13 +80,11 @@ do
|
||||
esac
|
||||
done
|
||||
|
||||
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
|
||||
|
||||
APP_NAME="Gradle"
|
||||
# This is normally unused
|
||||
# shellcheck disable=SC2034
|
||||
APP_BASE_NAME=${0##*/}
|
||||
|
||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
|
||||
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
|
||||
|
||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||
MAX_FD=maximum
|
||||
@@ -133,22 +131,29 @@ location of your Java installation."
|
||||
fi
|
||||
else
|
||||
JAVACMD=java
|
||||
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
if ! command -v java >/dev/null 2>&1
|
||||
then
|
||||
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
fi
|
||||
|
||||
# Increase the maximum file descriptors if we can.
|
||||
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
||||
case $MAX_FD in #(
|
||||
max*)
|
||||
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
|
||||
# shellcheck disable=SC2039,SC3045
|
||||
MAX_FD=$( ulimit -H -n ) ||
|
||||
warn "Could not query maximum file descriptor limit"
|
||||
esac
|
||||
case $MAX_FD in #(
|
||||
'' | soft) :;; #(
|
||||
*)
|
||||
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
|
||||
# shellcheck disable=SC2039,SC3045
|
||||
ulimit -n "$MAX_FD" ||
|
||||
warn "Could not set maximum file descriptor limit to $MAX_FD"
|
||||
esac
|
||||
@@ -193,11 +198,15 @@ if "$cygwin" || "$msys" ; then
|
||||
done
|
||||
fi
|
||||
|
||||
# Collect all arguments for the java command;
|
||||
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
|
||||
# shell script including quotes and variable substitutions, so put them in
|
||||
# double quotes to make sure that they get re-expanded; and
|
||||
# * put everything else in single quotes, so that it's not re-expanded.
|
||||
|
||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||
|
||||
# Collect all arguments for the java command:
|
||||
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
|
||||
# and any embedded shellness will be escaped.
|
||||
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
|
||||
# treated as '${Hostname}' itself on the command line.
|
||||
|
||||
set -- \
|
||||
"-Dorg.gradle.appname=$APP_BASE_NAME" \
|
||||
@@ -205,6 +214,12 @@ set -- \
|
||||
org.gradle.wrapper.GradleWrapperMain \
|
||||
"$@"
|
||||
|
||||
# Stop when "xargs" is not available.
|
||||
if ! command -v xargs >/dev/null 2>&1
|
||||
then
|
||||
die "xargs is not available"
|
||||
fi
|
||||
|
||||
# Use "xargs" to parse quoted args.
|
||||
#
|
||||
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
|
||||
|
||||
15
gradlew.bat
vendored
15
gradlew.bat
vendored
@@ -14,7 +14,7 @@
|
||||
@rem limitations under the License.
|
||||
@rem
|
||||
|
||||
@if "%DEBUG%" == "" @echo off
|
||||
@if "%DEBUG%"=="" @echo off
|
||||
@rem ##########################################################################
|
||||
@rem
|
||||
@rem Gradle startup script for Windows
|
||||
@@ -25,7 +25,8 @@
|
||||
if "%OS%"=="Windows_NT" setlocal
|
||||
|
||||
set DIRNAME=%~dp0
|
||||
if "%DIRNAME%" == "" set DIRNAME=.
|
||||
if "%DIRNAME%"=="" set DIRNAME=.
|
||||
@rem This is normally unused
|
||||
set APP_BASE_NAME=%~n0
|
||||
set APP_HOME=%DIRNAME%
|
||||
|
||||
@@ -40,7 +41,7 @@ if defined JAVA_HOME goto findJavaFromJavaHome
|
||||
|
||||
set JAVA_EXE=java.exe
|
||||
%JAVA_EXE% -version >NUL 2>&1
|
||||
if "%ERRORLEVEL%" == "0" goto execute
|
||||
if %ERRORLEVEL% equ 0 goto execute
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
@@ -75,13 +76,15 @@ set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||
|
||||
:end
|
||||
@rem End local scope for the variables with windows NT shell
|
||||
if "%ERRORLEVEL%"=="0" goto mainEnd
|
||||
if %ERRORLEVEL% equ 0 goto mainEnd
|
||||
|
||||
:fail
|
||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||
rem the _cmd.exe /c_ return code!
|
||||
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
|
||||
exit /b 1
|
||||
set EXIT_CODE=%ERRORLEVEL%
|
||||
if %EXIT_CODE% equ 0 set EXIT_CODE=1
|
||||
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
|
||||
exit /b %EXIT_CODE%
|
||||
|
||||
:mainEnd
|
||||
if "%OS%"=="Windows_NT" endlocal
|
||||
|
||||
Reference in New Issue
Block a user