mirror of
https://github.com/HibiscusMC/HMCCosmetics.git
synced 2025-12-25 01:49:24 +00:00
Compare commits
15 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9b34ffebb8 | ||
|
|
3eaaf75bfb | ||
|
|
c1bae96ad9 | ||
|
|
ddb6f53655 | ||
|
|
c37f52bbb1 | ||
|
|
dd805f1860 | ||
|
|
d9551f2827 | ||
|
|
1750a1bf5f | ||
|
|
d42f5ef5af | ||
|
|
2ca940a929 | ||
|
|
36f33b54af | ||
|
|
d0b4be6db8 | ||
|
|
4afa0bb538 | ||
|
|
201bcceaab | ||
|
|
92ad314ce1 |
@@ -8,7 +8,7 @@ plugins {
|
||||
}
|
||||
|
||||
group = "com.hibiscusmc"
|
||||
version = "2.2.7"
|
||||
version = "2.2.8"
|
||||
|
||||
allprojects {
|
||||
apply(plugin = "java")
|
||||
|
||||
@@ -143,9 +143,6 @@ public class ItemSerializer implements TypeSerializer<ItemStack> {
|
||||
}
|
||||
}
|
||||
|
||||
NamespacedKey key = new NamespacedKey(HMCCosmeticsPlugin.getInstance(), source.key().toString());
|
||||
itemMeta.getPersistentDataContainer().set(key, PersistentDataType.STRING, source.key().toString());
|
||||
|
||||
item.setItemMeta(itemMeta);
|
||||
return item;
|
||||
}
|
||||
|
||||
@@ -48,6 +48,7 @@ public class DyeMenu {
|
||||
if (color == null) return;
|
||||
|
||||
addCosmetic(user, cosmetic, color);
|
||||
event.setCancelled(true);
|
||||
} else event.setCancelled(true);
|
||||
});
|
||||
|
||||
|
||||
@@ -47,6 +47,11 @@ public class HMCPlaceholderExpansion extends PlaceholderExpansion {
|
||||
return HMCCosmeticsPlugin.getInstance().getDescription().getVersion();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean persist() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String onRequest(@NotNull OfflinePlayer player, @NotNull String params) {
|
||||
if (!player.isOnline()) return null;
|
||||
@@ -62,8 +67,9 @@ public class HMCPlaceholderExpansion extends PlaceholderExpansion {
|
||||
}
|
||||
if (placeholderArgs.get(1) != null) {
|
||||
Cosmetic cosmetic = Cosmetics.getCosmetic(placeholderArgs.get(1));
|
||||
if (cosmetic == null) return "INVALID_COSMETIC";
|
||||
Cosmetic currentCosmetic = user.getCosmetic(cosmetic.getSlot());
|
||||
if (cosmetic == null || currentCosmetic == null) return "false";
|
||||
if (currentCosmetic == null) return "false";
|
||||
if (currentCosmetic.getId() == cosmetic.getId()) return "true";
|
||||
return "false";
|
||||
}
|
||||
|
||||
@@ -328,11 +328,27 @@ public class PlayerGameListener implements Listener {
|
||||
CosmeticUser user = CosmeticUsers.getUser(event.getEntity());
|
||||
if (user == null) return;
|
||||
|
||||
if (user.isInWardrobe()) user.leaveWardrobe();
|
||||
|
||||
if (Settings.getUnapplyOnDeath() && !event.getEntity().hasPermission("hmccosmetics.unapplydeath.bypass")) {
|
||||
user.removeCosmetics();
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerGamemodeSwitch(PlayerGameModeChangeEvent event) {
|
||||
CosmeticUser user = CosmeticUsers.getUser(event.getPlayer());
|
||||
if (user == null) return;
|
||||
|
||||
if (Settings.isDestroyLooseCosmetics()) {
|
||||
ItemStack[] equippedArmor = event.getPlayer().getInventory().getArmorContents();
|
||||
if (equippedArmor.length == 0) return;
|
||||
for (ItemStack armor : equippedArmor) {
|
||||
if (InventoryUtils.isCosmeticItem(armor)) armor.setAmount(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void registerInventoryClickListener() {
|
||||
ProtocolLibrary.getProtocolManager().addPacketListener(new PacketAdapter(HMCCosmeticsPlugin.getInstance(), ListenerPriority.NORMAL, PacketType.Play.Client.WINDOW_CLICK) {
|
||||
@Override
|
||||
|
||||
@@ -52,7 +52,7 @@ public class CosmeticUser {
|
||||
private void tick() {
|
||||
// Occasionally updates the entity cosmetics
|
||||
Runnable run = () -> {
|
||||
MessagesUtil.sendDebugMessages("tick " + uniqueId, Level.INFO);
|
||||
MessagesUtil.sendDebugMessages("Tick[" + uniqueId + "]", Level.INFO);
|
||||
updateCosmetic();
|
||||
};
|
||||
|
||||
@@ -105,11 +105,11 @@ public class CosmeticUser {
|
||||
|
||||
playerCosmetics.put(cosmetic.getSlot(), cosmetic);
|
||||
if (color != null) colors.put(cosmetic.getSlot(), color);
|
||||
MessagesUtil.sendDebugMessages("addPlayerCosmetic " + cosmetic.getId());
|
||||
MessagesUtil.sendDebugMessages("addPlayerCosmetic[id=" + cosmetic.getId() + "]");
|
||||
if (cosmetic.getSlot() == CosmeticSlot.BACKPACK) {
|
||||
CosmeticBackpackType backpackType = (CosmeticBackpackType) cosmetic;
|
||||
spawnBackpack(backpackType);
|
||||
MessagesUtil.sendDebugMessages("addPlayerCosmetic spawnBackpack " + cosmetic.getId());
|
||||
MessagesUtil.sendDebugMessages("addPlayerCosmetic[spawnBackpack,id=" + cosmetic.getId() + "]");
|
||||
}
|
||||
if (cosmetic.getSlot() == CosmeticSlot.BALLOON) {
|
||||
CosmeticBalloonType balloonType = (CosmeticBalloonType) cosmetic;
|
||||
@@ -210,7 +210,8 @@ public class CosmeticUser {
|
||||
mapMeta.setColor(color);
|
||||
}
|
||||
}
|
||||
itemMeta.getPersistentDataContainer().set(InventoryUtils.getKey(), PersistentDataType.STRING, "true");
|
||||
itemMeta.getPersistentDataContainer().set(InventoryUtils.getCosmeticKey(), PersistentDataType.STRING, cosmetic.getId());
|
||||
itemMeta.getPersistentDataContainer().set(InventoryUtils.getOwnerKey(), PersistentDataType.STRING, getPlayer().getUniqueId().toString());
|
||||
|
||||
item.setItemMeta(itemMeta);
|
||||
}
|
||||
@@ -264,6 +265,7 @@ public class CosmeticUser {
|
||||
if (event.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
MessagesUtil.sendDebugMessages("Leaving Wardrobe");
|
||||
if (!getWardrobeManager().getWardrobeStatus().equals(UserWardrobeManager.WardrobeStatus.RUNNING)) return;
|
||||
|
||||
getWardrobeManager().setWardrobeStatus(UserWardrobeManager.WardrobeStatus.STOPPING);
|
||||
@@ -280,6 +282,9 @@ public class CosmeticUser {
|
||||
userWardrobeManager.end();
|
||||
userWardrobeManager = null;
|
||||
}, WardrobeSettings.getTransitionDelay());
|
||||
} else {
|
||||
userWardrobeManager.end();
|
||||
userWardrobeManager = null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -226,11 +226,11 @@ public class UserWardrobeManager {
|
||||
public void run() {
|
||||
Player player = user.getPlayer();
|
||||
if (!active || player == null) {
|
||||
MessagesUtil.sendDebugMessages("Active is false");
|
||||
MessagesUtil.sendDebugMessages("WardrobeEnd[user=" + user.getUniqueId() + ",reason=Active is false]");
|
||||
this.cancel();
|
||||
return;
|
||||
}
|
||||
MessagesUtil.sendDebugMessages("Update ");
|
||||
MessagesUtil.sendDebugMessages("WardrobeUpdate[user= " + user.getUniqueId() + ",status=" + getWardrobeStatus() + "]");
|
||||
List<Player> viewer = Collections.singletonList(player);
|
||||
List<Player> outsideViewers = PacketManager.getViewers(viewingLocation);
|
||||
outsideViewers.remove(player);
|
||||
|
||||
@@ -143,12 +143,17 @@ public class InventoryUtils {
|
||||
}
|
||||
|
||||
public static boolean isCosmeticItem(ItemStack itemStack) {
|
||||
if (itemStack == null) return false;
|
||||
itemStack = itemStack.clone();
|
||||
if (!itemStack.hasItemMeta()) return false;
|
||||
return itemStack.getItemMeta().getPersistentDataContainer().has(getKey(), PersistentDataType.STRING);
|
||||
return itemStack.getItemMeta().getPersistentDataContainer().has(getCosmeticKey(), PersistentDataType.STRING);
|
||||
}
|
||||
|
||||
public static NamespacedKey getKey() {
|
||||
public static NamespacedKey getCosmeticKey() {
|
||||
return new NamespacedKey(HMCCosmeticsPlugin.getInstance(), "cosmetic");
|
||||
}
|
||||
|
||||
public static NamespacedKey getOwnerKey() {
|
||||
return new NamespacedKey(HMCCosmeticsPlugin.getInstance(), "owner");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -306,15 +306,21 @@ public class PacketManager extends BasePacket {
|
||||
WrappedGameProfile wrappedGameProfile = new WrappedGameProfile(uuid, name);
|
||||
WrappedSignedProperty skinData = PlayerUtils.getSkin(skinnedPlayer);
|
||||
if (skinData != null) wrappedGameProfile.getProperties().put("textures", skinData);
|
||||
if (NMSHandlers.getVersion().contains("v1_17_R1") || NMSHandlers.getVersion().contains("v1_18_R2") || NMSHandlers.getVersion().contains("v1_19_R1") || NMSHandlers.getVersion().contains("v1_19_R3")) {
|
||||
info.getHandle().getPlayerInfoDataLists().write(1, Collections.singletonList(new PlayerInfoData(
|
||||
// For sor some reason 1.19.2 handles it on the 0 field index, every other verison handles it on the 1
|
||||
if (NMSHandlers.getVersion().contains("v1_19_R1")) {
|
||||
info.getHandle().getPlayerInfoDataLists().write(0, Collections.singletonList(new PlayerInfoData(
|
||||
wrappedGameProfile,
|
||||
0,
|
||||
EnumWrappers.NativeGameMode.CREATIVE,
|
||||
WrappedChatComponent.fromText(name)
|
||||
)));
|
||||
} else {
|
||||
info.setData(List.of(new PlayerInfoData(wrappedGameProfile, 0, EnumWrappers.NativeGameMode.CREATIVE, WrappedChatComponent.fromText(name))));
|
||||
info.getHandle().getPlayerInfoDataLists().write(1, Collections.singletonList(new PlayerInfoData(
|
||||
wrappedGameProfile,
|
||||
0,
|
||||
EnumWrappers.NativeGameMode.CREATIVE,
|
||||
WrappedChatComponent.fromText(name)
|
||||
)));
|
||||
}
|
||||
for (final Player p : sendTo) sendPacket(p, info.getHandle());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user