9
0
mirror of https://github.com/HibiscusMC/HMCCosmetics.git synced 2025-12-26 18:39:07 +00:00

Compare commits

...

5 Commits

Author SHA1 Message Date
LoJoSho
69de2fa178 version bump (2.3.1) 2023-05-09 14:20:23 -05:00
LoJoSho
cdcf904ac8 fix: cosmetic tpe gui items not processing placeholders 2023-05-08 12:23:20 -05:00
LoJoSho
80f9100bf0 fix: translation file generating 2023-05-08 12:22:57 -05:00
LoJoSho
751509ece4 version bump (2.3.1-DEV) 2023-05-08 12:22:46 -05:00
LoJoSho
f36d558e13 clean: updateCosmetic use proper method 2023-05-06 10:40:15 -05:00
5 changed files with 14 additions and 11 deletions

View File

@@ -8,7 +8,7 @@ plugins {
} }
group = "com.hibiscusmc" group = "com.hibiscusmc"
version = "2.3.0" version = "2.3.1"
allprojects { allprojects {
apply(plugin = "java") apply(plugin = "java")

View File

@@ -88,7 +88,7 @@ public final class HMCCosmeticsPlugin extends JavaPlugin {
// File setup // File setup
if (!getDataFolder().exists()) { if (!getDataFolder().exists()) {
saveDefaultConfig(); saveDefaultConfig();
saveResource("translations.yml", false); //saveResource("translations.yml", false);
saveResource("messages.yml", false); saveResource("messages.yml", false);
saveResource("cosmetics/defaultcosmetics.yml", false); saveResource("cosmetics/defaultcosmetics.yml", false);
saveResource("menus/defaultmenu.yml", false); saveResource("menus/defaultmenu.yml", false);

View File

@@ -152,10 +152,12 @@ public class Menu {
MessagesUtil.sendDebugMessages("Selected slot " + slot); MessagesUtil.sendDebugMessages("Selected slot " + slot);
final ClickType clickType = event.getClick(); final ClickType clickType = event.getClick();
if (finalType != null) finalType.run(user, config, clickType); if (finalType != null) finalType.run(user, config, clickType);
// Need to delay the update by a tick so it will actually update with new values
for (int guiSlot : slots) { Bukkit.getScheduler().runTaskLater(HMCCosmeticsPlugin.getInstance(), () -> {
gui.updateItem(guiSlot, updateItem(user, originalItem.clone(), finalType, config, guiSlot)); for (int guiSlot : slots) {
} gui.updateItem(guiSlot, updateItem(user, originalItem, finalType, config, guiSlot));
}
}, 1);
MessagesUtil.sendDebugMessages("Updated slot " + slot); MessagesUtil.sendDebugMessages("Updated slot " + slot);
}); });

View File

@@ -92,7 +92,6 @@ public class TypeCosmetic extends Type {
if (cosmetic instanceof CosmeticArmorType) { if (cosmetic instanceof CosmeticArmorType) {
if (((CosmeticArmorType) cosmetic).getEquipSlot().equals(EquipmentSlot.OFF_HAND)) { if (((CosmeticArmorType) cosmetic).getEquipSlot().equals(EquipmentSlot.OFF_HAND)) {
Bukkit.getScheduler().runTaskLater(HMCCosmeticsPlugin.getInstance(), run, 1); Bukkit.getScheduler().runTaskLater(HMCCosmeticsPlugin.getInstance(), run, 1);
return;
} }
} }
run.run(); run.run();
@@ -101,19 +100,19 @@ public class TypeCosmetic extends Type {
@Override @Override
public ItemStack setItem(CosmeticUser user, @NotNull ConfigurationNode config, ItemStack itemStack, int slot) { public ItemStack setItem(CosmeticUser user, @NotNull ConfigurationNode config, ItemStack itemStack, int slot) {
ItemMeta itemMeta = itemStack.getItemMeta(); ItemMeta itemMeta = itemStack.getItemMeta();
itemStack.setItemMeta(processLoreLines(user, itemMeta));
if (config.node("cosmetic").virtual()) { if (config.node("cosmetic").virtual()) {
itemStack.setItemMeta(processLoreLines(user, itemMeta));
return itemStack; return itemStack;
}; };
String cosmeticName = config.node("cosmetic").getString(); String cosmeticName = config.node("cosmetic").getString();
Cosmetic cosmetic = Cosmetics.getCosmetic(cosmeticName); Cosmetic cosmetic = Cosmetics.getCosmetic(cosmeticName);
if (cosmetic == null) { if (cosmetic == null) {
itemStack.setItemMeta(processLoreLines(user, itemMeta));
return itemStack; return itemStack;
} }
if (user.hasCosmeticInSlot(cosmetic) && !config.node("equipped-item").virtual()) { if (user.hasCosmeticInSlot(cosmetic) && !config.node("equipped-item").virtual()) {
MessagesUtil.sendDebugMessages("GUI Equipped Item");
ConfigurationNode equippedItem = config.node("equipped-item"); ConfigurationNode equippedItem = config.node("equipped-item");
try { try {
if (equippedItem.node("material").virtual()) equippedItem.node("material").set(config.node("item", "material").getString()); if (equippedItem.node("material").virtual()) equippedItem.node("material").set(config.node("item", "material").getString());
@@ -125,10 +124,12 @@ public class TypeCosmetic extends Type {
} catch (SerializationException e) { } catch (SerializationException e) {
throw new RuntimeException(e); throw new RuntimeException(e);
} }
itemStack.setItemMeta(processLoreLines(user, itemStack.getItemMeta()));
return itemStack; return itemStack;
} }
if (!user.canEquipCosmetic(cosmetic) && !config.node("locked-item").virtual()) { if (!user.canEquipCosmetic(cosmetic) && !config.node("locked-item").virtual()) {
MessagesUtil.sendDebugMessages("GUI Locked Item");
ConfigurationNode lockedItem = config.node("locked-item"); ConfigurationNode lockedItem = config.node("locked-item");
try { try {
if (lockedItem.node("material").virtual()) lockedItem.node("material").set(config.node("item", "material").getString()); if (lockedItem.node("material").virtual()) lockedItem.node("material").set(config.node("item", "material").getString());
@@ -137,10 +138,10 @@ public class TypeCosmetic extends Type {
} }
try { try {
itemStack = ItemSerializer.INSTANCE.deserialize(ItemStack.class, lockedItem); itemStack = ItemSerializer.INSTANCE.deserialize(ItemStack.class, lockedItem);
//item = config.node("item").get(ItemStack.class);
} catch (SerializationException e) { } catch (SerializationException e) {
throw new RuntimeException(e); throw new RuntimeException(e);
} }
itemStack.setItemMeta(processLoreLines(user, itemStack.getItemMeta()));
return itemStack; return itemStack;
} }
return itemStack; return itemStack;

View File

@@ -181,7 +181,7 @@ public class CosmeticUser {
} }
public void updateCosmetic() { public void updateCosmetic() {
for (Cosmetic cosmetic : playerCosmetics.values()) { for (Cosmetic cosmetic : getCosmetics()) {
updateCosmetic(cosmetic.getSlot()); updateCosmetic(cosmetic.getSlot());
} }
} }