mirror of
https://github.com/HibiscusMC/HMCCosmetics.git
synced 2025-12-28 19:39:14 +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"
|
group = "com.hibiscusmc"
|
||||||
version = "2.2.7"
|
version = "2.2.8"
|
||||||
|
|
||||||
allprojects {
|
allprojects {
|
||||||
apply(plugin = "java")
|
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);
|
item.setItemMeta(itemMeta);
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -48,6 +48,7 @@ public class DyeMenu {
|
|||||||
if (color == null) return;
|
if (color == null) return;
|
||||||
|
|
||||||
addCosmetic(user, cosmetic, color);
|
addCosmetic(user, cosmetic, color);
|
||||||
|
event.setCancelled(true);
|
||||||
} else event.setCancelled(true);
|
} else event.setCancelled(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -47,6 +47,11 @@ public class HMCPlaceholderExpansion extends PlaceholderExpansion {
|
|||||||
return HMCCosmeticsPlugin.getInstance().getDescription().getVersion();
|
return HMCCosmeticsPlugin.getInstance().getDescription().getVersion();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean persist() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String onRequest(@NotNull OfflinePlayer player, @NotNull String params) {
|
public String onRequest(@NotNull OfflinePlayer player, @NotNull String params) {
|
||||||
if (!player.isOnline()) return null;
|
if (!player.isOnline()) return null;
|
||||||
@@ -62,8 +67,9 @@ public class HMCPlaceholderExpansion extends PlaceholderExpansion {
|
|||||||
}
|
}
|
||||||
if (placeholderArgs.get(1) != null) {
|
if (placeholderArgs.get(1) != null) {
|
||||||
Cosmetic cosmetic = Cosmetics.getCosmetic(placeholderArgs.get(1));
|
Cosmetic cosmetic = Cosmetics.getCosmetic(placeholderArgs.get(1));
|
||||||
|
if (cosmetic == null) return "INVALID_COSMETIC";
|
||||||
Cosmetic currentCosmetic = user.getCosmetic(cosmetic.getSlot());
|
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";
|
if (currentCosmetic.getId() == cosmetic.getId()) return "true";
|
||||||
return "false";
|
return "false";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -328,11 +328,27 @@ public class PlayerGameListener implements Listener {
|
|||||||
CosmeticUser user = CosmeticUsers.getUser(event.getEntity());
|
CosmeticUser user = CosmeticUsers.getUser(event.getEntity());
|
||||||
if (user == null) return;
|
if (user == null) return;
|
||||||
|
|
||||||
|
if (user.isInWardrobe()) user.leaveWardrobe();
|
||||||
|
|
||||||
if (Settings.getUnapplyOnDeath() && !event.getEntity().hasPermission("hmccosmetics.unapplydeath.bypass")) {
|
if (Settings.getUnapplyOnDeath() && !event.getEntity().hasPermission("hmccosmetics.unapplydeath.bypass")) {
|
||||||
user.removeCosmetics();
|
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() {
|
private void registerInventoryClickListener() {
|
||||||
ProtocolLibrary.getProtocolManager().addPacketListener(new PacketAdapter(HMCCosmeticsPlugin.getInstance(), ListenerPriority.NORMAL, PacketType.Play.Client.WINDOW_CLICK) {
|
ProtocolLibrary.getProtocolManager().addPacketListener(new PacketAdapter(HMCCosmeticsPlugin.getInstance(), ListenerPriority.NORMAL, PacketType.Play.Client.WINDOW_CLICK) {
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ public class CosmeticUser {
|
|||||||
private void tick() {
|
private void tick() {
|
||||||
// Occasionally updates the entity cosmetics
|
// Occasionally updates the entity cosmetics
|
||||||
Runnable run = () -> {
|
Runnable run = () -> {
|
||||||
MessagesUtil.sendDebugMessages("tick " + uniqueId, Level.INFO);
|
MessagesUtil.sendDebugMessages("Tick[" + uniqueId + "]", Level.INFO);
|
||||||
updateCosmetic();
|
updateCosmetic();
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -105,11 +105,11 @@ public class CosmeticUser {
|
|||||||
|
|
||||||
playerCosmetics.put(cosmetic.getSlot(), cosmetic);
|
playerCosmetics.put(cosmetic.getSlot(), cosmetic);
|
||||||
if (color != null) colors.put(cosmetic.getSlot(), color);
|
if (color != null) colors.put(cosmetic.getSlot(), color);
|
||||||
MessagesUtil.sendDebugMessages("addPlayerCosmetic " + cosmetic.getId());
|
MessagesUtil.sendDebugMessages("addPlayerCosmetic[id=" + cosmetic.getId() + "]");
|
||||||
if (cosmetic.getSlot() == CosmeticSlot.BACKPACK) {
|
if (cosmetic.getSlot() == CosmeticSlot.BACKPACK) {
|
||||||
CosmeticBackpackType backpackType = (CosmeticBackpackType) cosmetic;
|
CosmeticBackpackType backpackType = (CosmeticBackpackType) cosmetic;
|
||||||
spawnBackpack(backpackType);
|
spawnBackpack(backpackType);
|
||||||
MessagesUtil.sendDebugMessages("addPlayerCosmetic spawnBackpack " + cosmetic.getId());
|
MessagesUtil.sendDebugMessages("addPlayerCosmetic[spawnBackpack,id=" + cosmetic.getId() + "]");
|
||||||
}
|
}
|
||||||
if (cosmetic.getSlot() == CosmeticSlot.BALLOON) {
|
if (cosmetic.getSlot() == CosmeticSlot.BALLOON) {
|
||||||
CosmeticBalloonType balloonType = (CosmeticBalloonType) cosmetic;
|
CosmeticBalloonType balloonType = (CosmeticBalloonType) cosmetic;
|
||||||
@@ -210,7 +210,8 @@ public class CosmeticUser {
|
|||||||
mapMeta.setColor(color);
|
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);
|
item.setItemMeta(itemMeta);
|
||||||
}
|
}
|
||||||
@@ -264,6 +265,7 @@ public class CosmeticUser {
|
|||||||
if (event.isCancelled()) {
|
if (event.isCancelled()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
MessagesUtil.sendDebugMessages("Leaving Wardrobe");
|
||||||
if (!getWardrobeManager().getWardrobeStatus().equals(UserWardrobeManager.WardrobeStatus.RUNNING)) return;
|
if (!getWardrobeManager().getWardrobeStatus().equals(UserWardrobeManager.WardrobeStatus.RUNNING)) return;
|
||||||
|
|
||||||
getWardrobeManager().setWardrobeStatus(UserWardrobeManager.WardrobeStatus.STOPPING);
|
getWardrobeManager().setWardrobeStatus(UserWardrobeManager.WardrobeStatus.STOPPING);
|
||||||
@@ -280,6 +282,9 @@ public class CosmeticUser {
|
|||||||
userWardrobeManager.end();
|
userWardrobeManager.end();
|
||||||
userWardrobeManager = null;
|
userWardrobeManager = null;
|
||||||
}, WardrobeSettings.getTransitionDelay());
|
}, WardrobeSettings.getTransitionDelay());
|
||||||
|
} else {
|
||||||
|
userWardrobeManager.end();
|
||||||
|
userWardrobeManager = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -226,11 +226,11 @@ public class UserWardrobeManager {
|
|||||||
public void run() {
|
public void run() {
|
||||||
Player player = user.getPlayer();
|
Player player = user.getPlayer();
|
||||||
if (!active || player == null) {
|
if (!active || player == null) {
|
||||||
MessagesUtil.sendDebugMessages("Active is false");
|
MessagesUtil.sendDebugMessages("WardrobeEnd[user=" + user.getUniqueId() + ",reason=Active is false]");
|
||||||
this.cancel();
|
this.cancel();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
MessagesUtil.sendDebugMessages("Update ");
|
MessagesUtil.sendDebugMessages("WardrobeUpdate[user= " + user.getUniqueId() + ",status=" + getWardrobeStatus() + "]");
|
||||||
List<Player> viewer = Collections.singletonList(player);
|
List<Player> viewer = Collections.singletonList(player);
|
||||||
List<Player> outsideViewers = PacketManager.getViewers(viewingLocation);
|
List<Player> outsideViewers = PacketManager.getViewers(viewingLocation);
|
||||||
outsideViewers.remove(player);
|
outsideViewers.remove(player);
|
||||||
|
|||||||
@@ -143,12 +143,17 @@ public class InventoryUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isCosmeticItem(ItemStack itemStack) {
|
public static boolean isCosmeticItem(ItemStack itemStack) {
|
||||||
|
if (itemStack == null) return false;
|
||||||
itemStack = itemStack.clone();
|
itemStack = itemStack.clone();
|
||||||
if (!itemStack.hasItemMeta()) return false;
|
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");
|
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);
|
WrappedGameProfile wrappedGameProfile = new WrappedGameProfile(uuid, name);
|
||||||
WrappedSignedProperty skinData = PlayerUtils.getSkin(skinnedPlayer);
|
WrappedSignedProperty skinData = PlayerUtils.getSkin(skinnedPlayer);
|
||||||
if (skinData != null) wrappedGameProfile.getProperties().put("textures", skinData);
|
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")) {
|
// For sor some reason 1.19.2 handles it on the 0 field index, every other verison handles it on the 1
|
||||||
info.getHandle().getPlayerInfoDataLists().write(1, Collections.singletonList(new PlayerInfoData(
|
if (NMSHandlers.getVersion().contains("v1_19_R1")) {
|
||||||
|
info.getHandle().getPlayerInfoDataLists().write(0, Collections.singletonList(new PlayerInfoData(
|
||||||
wrappedGameProfile,
|
wrappedGameProfile,
|
||||||
0,
|
0,
|
||||||
EnumWrappers.NativeGameMode.CREATIVE,
|
EnumWrappers.NativeGameMode.CREATIVE,
|
||||||
WrappedChatComponent.fromText(name)
|
WrappedChatComponent.fromText(name)
|
||||||
)));
|
)));
|
||||||
} else {
|
} 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());
|
for (final Player p : sendTo) sendPacket(p, info.getHandle());
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user