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);
|
if (cosmetic != null && cosmetic.getType() != Material.AIR) equipment.setItem(slot, cosmetic);
|
||||||
|
|
||||||
final List<Equipment> items =
|
final Equipment items =
|
||||||
userManager.getItemList(user, equipment, Collections.emptySet());
|
userManager.getItemList(user, equipment, Collections.emptySet());
|
||||||
items.removeIf(e -> {
|
for (EquipmentSlot e : items.keys()) {
|
||||||
//final EquipmentSlot s = e.getSlot();
|
//final EquipmentSlot s = e.getSlot();
|
||||||
final ArmorItem.Type t = ArmorItem.Type.fromWrapper(slot);
|
final ArmorItem.Type t = ArmorItem.Type.fromWrapper(e);
|
||||||
if (t == null) return false;
|
ItemStack air = new ItemStack(Material.AIR);
|
||||||
|
if (t == null) {
|
||||||
|
equipment.setItem(e, air);
|
||||||
|
return;
|
||||||
|
}
|
||||||
final ArmorItem armorItem = user.getPlayerArmor().getItem(t);
|
final ArmorItem armorItem = user.getPlayerArmor().getItem(t);
|
||||||
final ItemStack i = e.getItem(slot);
|
final ItemStack i = equipment.getItem(e);
|
||||||
if (i == null) return false;
|
if (i == null) {
|
||||||
return armorItem.isEmpty() && i.equals(equipment.getItem(t.getSlot()));
|
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()) {
|
for (final Player other : Bukkit.getOnlinePlayers()) {
|
||||||
if (!settings.isInViewDistance(location, other.getLocation())) continue;
|
if (!settings.isInViewDistance(location, other.getLocation())) continue;
|
||||||
userManager.sendUpdatePacket(
|
userManager.sendUpdatePacket(
|
||||||
user,
|
user,
|
||||||
user.getEquipment()
|
equipment
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -67,4 +67,12 @@ public class Equipment {
|
|||||||
public Set<EquipmentSlot> keys() {
|
public Set<EquipmentSlot> keys() {
|
||||||
return equipment.keySet();
|
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;
|
return itemStack;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Equipment> getItemList(
|
public Equipment getItemList(
|
||||||
final BaseUser<?> user,
|
final BaseUser<?> user,
|
||||||
final Equipment equipment,
|
final Equipment equipment,
|
||||||
final Set<ArmorItem.Type> ignored
|
final Set<ArmorItem.Type> ignored
|
||||||
) {
|
) {
|
||||||
final PlayerArmor armor = user.getPlayerArmor();
|
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()) {
|
for (final ArmorItem.Type type : ArmorItem.Type.values()) {
|
||||||
final EquipmentSlot slot = type.getSlot();
|
final EquipmentSlot slot = type.getSlot();
|
||||||
if (slot == null) continue;
|
if (slot == null) continue;
|
||||||
if (ignored.contains(type)) {
|
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;
|
continue;
|
||||||
}
|
}
|
||||||
final ItemStack wearing = Utils.replaceIfNull(equipment.getItem(slot), new ItemStack(Material.AIR));
|
final ItemStack wearing = Utils.replaceIfNull(equipment.getItem(slot), new ItemStack(Material.AIR));
|
||||||
@@ -165,9 +168,9 @@ public class UserManager {
|
|||||||
ArmorItem.Status.APPLIED,
|
ArmorItem.Status.APPLIED,
|
||||||
slot
|
slot
|
||||||
);
|
);
|
||||||
items.add(PacketManager.getEquipment(itemStack, slot));
|
equipment.setItem(slot, itemStack);
|
||||||
}
|
}
|
||||||
return items;
|
return equipment;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Equipment> getEmptyItemList() {
|
public List<Equipment> getEmptyItemList() {
|
||||||
@@ -282,9 +285,10 @@ public class UserManager {
|
|||||||
final ArmorItem.Type type) {
|
final ArmorItem.Type type) {
|
||||||
final EquipmentSlot slot = type.getSlot();
|
final EquipmentSlot slot = type.getSlot();
|
||||||
final ItemStack itemStack = this.getCosmeticItem(armorItem, wearing, ArmorItem.Status.APPLIED, slot);
|
final ItemStack itemStack = this.getCosmeticItem(armorItem, wearing, ArmorItem.Status.APPLIED, slot);
|
||||||
final List<Equipment> itemList = new ArrayList<>();
|
//final List<Equipment> itemList = new ArrayList<>();
|
||||||
itemList.add(PacketManager.getEquipment(itemStack, slot));
|
//itemList.add(PacketManager.getEquipment(itemStack, slot));
|
||||||
Equipment equip = Equipment.fromEntityEquipment(user);
|
Equipment equip = Equipment.fromEntityEquipment(user);
|
||||||
|
equip.setItem(slot, itemStack);
|
||||||
this.sendUpdatePacket(user, equip);
|
this.sendUpdatePacket(user, equip);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -304,14 +308,7 @@ public class UserManager {
|
|||||||
if (!user.shouldShow(other)) continue;
|
if (!user.shouldShow(other)) continue;
|
||||||
if (!this.settings.getCosmeticSettings().isInViewDistance(location, other.getLocation())) continue;
|
if (!this.settings.getCosmeticSettings().isInViewDistance(location, other.getLocation())) continue;
|
||||||
user.updateBackpack(other, this.settings);
|
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 (!user.shouldShow(other)) return;
|
||||||
if (!this.settings.getCosmeticSettings().isInViewDistance(location, other.getLocation())) return;
|
if (!this.settings.getCosmeticSettings().isInViewDistance(location, other.getLocation())) return;
|
||||||
PacketManager.sendEquipmentPacket(items, entityId, other);
|
PacketManager.sendEquipmentPacket(items, entityId, other);
|
||||||
/*
|
|
||||||
PacketManager.sendEquipmentPacket(
|
|
||||||
items,
|
|
||||||
entityId,
|
|
||||||
other
|
|
||||||
);
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,2 +1,2 @@
|
|||||||
copyJar=true
|
copyJar=false
|
||||||
hibiscusmc_plugin_path=""
|
hibiscusmc_plugin_path=""
|
||||||
|
|||||||
Reference in New Issue
Block a user