mirror of
https://github.com/HibiscusMC/HMCCosmetics.git
synced 2025-12-19 15:09:19 +00:00
Latest Commit
This commit is contained in:
@@ -180,22 +180,34 @@ public class CosmeticFixListener implements Listener {
|
||||
);
|
||||
if (cosmetic != null && cosmetic.getType() != Material.AIR) equipment.setItem(slot, cosmetic);
|
||||
|
||||
final List<Equipment> items =
|
||||
final Equipment items =
|
||||
userManager.getItemList(user, equipment, Collections.emptySet());
|
||||
items.removeIf(e -> {
|
||||
for (EquipmentSlot e : items.keys()) {
|
||||
//final EquipmentSlot s = e.getSlot();
|
||||
final ArmorItem.Type t = ArmorItem.Type.fromWrapper(slot);
|
||||
if (t == null) return false;
|
||||
final ArmorItem.Type t = ArmorItem.Type.fromWrapper(e);
|
||||
ItemStack air = new ItemStack(Material.AIR);
|
||||
if (t == null) {
|
||||
equipment.setItem(e, air);
|
||||
return;
|
||||
}
|
||||
final ArmorItem armorItem = user.getPlayerArmor().getItem(t);
|
||||
final ItemStack i = e.getItem(slot);
|
||||
if (i == null) return false;
|
||||
return armorItem.isEmpty() && i.equals(equipment.getItem(t.getSlot()));
|
||||
});
|
||||
final ItemStack i = equipment.getItem(e);
|
||||
if (i == null) {
|
||||
equipment.setItem(e, air);
|
||||
return;
|
||||
}
|
||||
Boolean remove = armorItem.isEmpty() && i.equals(equipment.getItem(t.getSlot()));
|
||||
if (remove) {
|
||||
equipment.setItem(e, air);
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
for (final Player other : Bukkit.getOnlinePlayers()) {
|
||||
if (!settings.isInViewDistance(location, other.getLocation())) continue;
|
||||
userManager.sendUpdatePacket(
|
||||
user,
|
||||
user.getEquipment()
|
||||
equipment
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -67,4 +67,12 @@ public class Equipment {
|
||||
public Set<EquipmentSlot> keys() {
|
||||
return equipment.keySet();
|
||||
}
|
||||
|
||||
public void removeSlot(EquipmentSlot slot) {
|
||||
equipment.remove(slot);
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
equipment.clear();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -144,18 +144,21 @@ public class UserManager {
|
||||
return itemStack;
|
||||
}
|
||||
|
||||
public List<Equipment> getItemList(
|
||||
public Equipment getItemList(
|
||||
final BaseUser<?> user,
|
||||
final Equipment equipment,
|
||||
final Set<ArmorItem.Type> ignored
|
||||
) {
|
||||
final PlayerArmor armor = user.getPlayerArmor();
|
||||
final List<Equipment> items = new ArrayList<>();
|
||||
//final List<Equipment> items = new ArrayList<>();
|
||||
//Equipment equip = new Equipment();
|
||||
for (final ArmorItem.Type type : ArmorItem.Type.values()) {
|
||||
final EquipmentSlot slot = type.getSlot();
|
||||
if (slot == null) continue;
|
||||
if (ignored.contains(type)) {
|
||||
items.add(PacketManager.getEquipment(equipment.getItem(slot), slot));
|
||||
Equipment item = PacketManager.getEquipment(equipment.getItem(slot), slot);
|
||||
equipment.setItem(slot, item.getItem(slot));
|
||||
//items.add(PacketManager.getEquipment(equipment.getItem(slot), slot));
|
||||
continue;
|
||||
}
|
||||
final ItemStack wearing = Utils.replaceIfNull(equipment.getItem(slot), new ItemStack(Material.AIR));
|
||||
@@ -165,9 +168,9 @@ public class UserManager {
|
||||
ArmorItem.Status.APPLIED,
|
||||
slot
|
||||
);
|
||||
items.add(PacketManager.getEquipment(itemStack, slot));
|
||||
equipment.setItem(slot, itemStack);
|
||||
}
|
||||
return items;
|
||||
return equipment;
|
||||
}
|
||||
|
||||
public List<Equipment> getEmptyItemList() {
|
||||
@@ -282,9 +285,10 @@ public class UserManager {
|
||||
final ArmorItem.Type type) {
|
||||
final EquipmentSlot slot = type.getSlot();
|
||||
final ItemStack itemStack = this.getCosmeticItem(armorItem, wearing, ArmorItem.Status.APPLIED, slot);
|
||||
final List<Equipment> itemList = new ArrayList<>();
|
||||
itemList.add(PacketManager.getEquipment(itemStack, slot));
|
||||
//final List<Equipment> itemList = new ArrayList<>();
|
||||
//itemList.add(PacketManager.getEquipment(itemStack, slot));
|
||||
Equipment equip = Equipment.fromEntityEquipment(user);
|
||||
equip.setItem(slot, itemStack);
|
||||
this.sendUpdatePacket(user, equip);
|
||||
}
|
||||
|
||||
@@ -304,14 +308,7 @@ public class UserManager {
|
||||
if (!user.shouldShow(other)) continue;
|
||||
if (!this.settings.getCosmeticSettings().isInViewDistance(location, other.getLocation())) continue;
|
||||
user.updateBackpack(other, this.settings);
|
||||
PacketManager.sendEquipmentPacket(user.getEquipment(), entityId, other);
|
||||
/*
|
||||
PacketManager.sendEquipmentPacket(
|
||||
items,
|
||||
entityId,
|
||||
other
|
||||
);
|
||||
*/
|
||||
PacketManager.sendEquipmentPacket(items, entityId, other);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -329,12 +326,5 @@ public class UserManager {
|
||||
if (!user.shouldShow(other)) return;
|
||||
if (!this.settings.getCosmeticSettings().isInViewDistance(location, other.getLocation())) return;
|
||||
PacketManager.sendEquipmentPacket(items, entityId, other);
|
||||
/*
|
||||
PacketManager.sendEquipmentPacket(
|
||||
items,
|
||||
entityId,
|
||||
other
|
||||
);
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
copyJar=true
|
||||
copyJar=false
|
||||
hibiscusmc_plugin_path=""
|
||||
|
||||
Reference in New Issue
Block a user