mirror of
https://github.com/HibiscusMC/HMCCosmetics.git
synced 2025-12-19 15:09:19 +00:00
Merge pull request #176 from HibiscusMC/le-epic-minor-tweaks-again-we-love-it
feat: dyeable click-type & color changes
This commit is contained in:
@@ -69,6 +69,8 @@ allprojects {
|
||||
|
||||
// Hibiscus Commons
|
||||
maven("https://repo.hibiscusmc.com/releases")
|
||||
|
||||
mavenLocal()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
@@ -86,7 +88,7 @@ allprojects {
|
||||
compileOnly("io.github.toxicity188:BetterCommand:1.3") //BetterCommand library
|
||||
//compileOnly("it.unimi.dsi:fastutil:8.5.14")
|
||||
compileOnly("org.projectlombok:lombok:1.18.34")
|
||||
compileOnly("me.lojosho:HibiscusCommons:0.6.3-d97e5686")
|
||||
compileOnly("me.lojosho:HibiscusCommons:0.6.3-7ef40c1")
|
||||
|
||||
// Handled by Spigot Library Loader
|
||||
compileOnly("net.kyori:adventure-api:4.19.0")
|
||||
|
||||
@@ -53,6 +53,7 @@ public class Settings {
|
||||
private static final String COSMETIC_TYPE_SETTINGS_PATH = "cosmetic-type";
|
||||
private static final String EQUIP_CLICK_TYPE = "equip-click";
|
||||
private static final String UNEQUIP_CLICK_TYPE = "unequip-click";
|
||||
private static final String DYE_CLICK_TYPE = "dye-click";
|
||||
private static final String SHADING_PATH = "shading";
|
||||
private static final String FIRST_ROW_SHIFT_PATH = "first-row-shift";
|
||||
private static final String SEQUENT_ROW_SHIFT_PATH = "sequent-row-shift";
|
||||
@@ -130,6 +131,8 @@ public class Settings {
|
||||
@Getter
|
||||
private static String cosmeticUnEquipClickType;
|
||||
@Getter
|
||||
private static String cosmeticDyeClickType;
|
||||
@Getter
|
||||
private static boolean defaultShading;
|
||||
@Getter
|
||||
private static String firstRowShift;
|
||||
@@ -227,6 +230,7 @@ public class Settings {
|
||||
ConfigurationNode cosmeticTypeSettings = menuSettings.node(COSMETIC_TYPE_SETTINGS_PATH);
|
||||
cosmeticEquipClickType = cosmeticTypeSettings.node(EQUIP_CLICK_TYPE).getString("ALL");
|
||||
cosmeticUnEquipClickType = cosmeticTypeSettings.node(UNEQUIP_CLICK_TYPE).getString("ALL");
|
||||
cosmeticDyeClickType = cosmeticTypeSettings.node(DYE_CLICK_TYPE).getString("ALL");
|
||||
|
||||
final var balloonSection = cosmeticSettings.node(BALLOON_OFFSET);
|
||||
balloonOffset = loadVector(balloonSection);
|
||||
|
||||
@@ -26,7 +26,7 @@ public abstract class Cosmetic {
|
||||
@Getter @Setter
|
||||
private CosmeticSlot slot;
|
||||
@Getter @Setter
|
||||
private boolean dyable;
|
||||
private boolean dyeable;
|
||||
|
||||
protected Cosmetic(String id, @NotNull ConfigurationNode config) {
|
||||
this.id = id;
|
||||
@@ -45,9 +45,9 @@ public abstract class Cosmetic {
|
||||
MessagesUtil.sendDebugMessages("Slot: " + config.node("slot").getString());
|
||||
|
||||
setSlot(CosmeticSlot.valueOf(config.node("slot").getString()));
|
||||
setDyable(config.node("dyeable").getBoolean(false));
|
||||
setDyeable(config.node("dyeable").getBoolean(false));
|
||||
|
||||
MessagesUtil.sendDebugMessages("Dyeable " + dyable);
|
||||
MessagesUtil.sendDebugMessages("Dyeable " + dyeable);
|
||||
Cosmetics.addCosmetic(this);
|
||||
}
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ public class CosmeticBalloonType extends Cosmetic {
|
||||
@Getter
|
||||
private final String modelName;
|
||||
@Getter
|
||||
private List<String> dyableParts;
|
||||
private List<String> dyeableParts;
|
||||
@Getter
|
||||
private final boolean showLead;
|
||||
@Getter
|
||||
@@ -42,8 +42,8 @@ public class CosmeticBalloonType extends Cosmetic {
|
||||
balloonOffset = Settings.loadVector(balloonOffsetNode);
|
||||
|
||||
try {
|
||||
if (!config.node("dyable-parts").virtual()) {
|
||||
dyableParts = config.node("dyable-parts").getList(String.class);
|
||||
if (!config.node("dyeable-parts").virtual()) {
|
||||
dyeableParts = config.node("dyeable-parts").getList(String.class);
|
||||
}
|
||||
} catch (SerializationException e) {
|
||||
// Seriously?
|
||||
@@ -101,10 +101,10 @@ public class CosmeticBalloonType extends Cosmetic {
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isDyablePart(String name) {
|
||||
public boolean isDyeablePart(String name) {
|
||||
// If player does not define parts, dye whole model
|
||||
if (dyableParts == null) return true;
|
||||
if (dyableParts.isEmpty()) return true;
|
||||
return dyableParts.contains(name);
|
||||
if (dyeableParts == null) return true;
|
||||
if (dyeableParts.isEmpty()) return true;
|
||||
return dyeableParts.contains(name);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,12 +9,14 @@ import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
|
||||
import com.hibiscusmc.hmccosmetics.cosmetic.CosmeticHolder;
|
||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||
import me.lojosho.hibiscuscommons.hooks.Hooks;
|
||||
import me.lojosho.hibiscuscommons.util.ColorBuilder;
|
||||
import me.lojosho.hibiscuscommons.nms.NMSHandlers;
|
||||
import me.lojosho.hibiscuscommons.util.AdventureUtils;
|
||||
import me.lojosho.hibiscuscommons.util.StringUtils;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Color;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.*;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -25,31 +27,17 @@ public class DyeMenu {
|
||||
return;
|
||||
}
|
||||
ItemStack originalItem = cosmetic.getItem();
|
||||
if (originalItem == null || !cosmetic.isDyable()) return;
|
||||
if (originalItem == null || !cosmetic.isDyeable()) return;
|
||||
|
||||
Gui gui = HMCColorApi.createColorMenu(viewer);
|
||||
gui.updateTitle(Hooks.processPlaceholders(viewer, StringUtils.parseStringToString(Settings.getDyeMenuName())));
|
||||
gui.updateTitle(AdventureUtils.MINI_MESSAGE.deserialize(Hooks.processPlaceholders(viewer, StringUtils.parseStringToString(Settings.getDyeMenuName()))));
|
||||
gui.setItem(Settings.getDyeMenuInputSlot(), new GuiItem(originalItem));
|
||||
gui.setDefaultTopClickAction(event -> {
|
||||
if (event.getSlot() == Settings.getDyeMenuOutputSlot()) {
|
||||
ItemStack item = event.getInventory().getItem(Settings.getDyeMenuOutputSlot());
|
||||
if (item == null) return;
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
if (meta == null) return;
|
||||
|
||||
Color color = null;
|
||||
if (meta instanceof LeatherArmorMeta leatherMeta) {
|
||||
color = leatherMeta.getColor();
|
||||
} else if (meta instanceof PotionMeta potionMeta) {
|
||||
color = potionMeta.getColor();
|
||||
} else if (meta instanceof MapMeta mapMeta) {
|
||||
color = mapMeta.getColor();
|
||||
} else if (meta instanceof FireworkEffectMeta fireworkEffectMeta) {
|
||||
FireworkEffect effect = fireworkEffectMeta.getEffect();
|
||||
if (effect != null) {
|
||||
color = effect.getColors().stream().findFirst().isPresent() ? effect.getColors().stream().findFirst().get() : null;
|
||||
}
|
||||
}
|
||||
Color color = NMSHandlers.getHandler().getUtilHandler().getColor(item);
|
||||
if (color == null) return;
|
||||
|
||||
addCosmetic(viewer, cosmeticHolder, cosmetic, color);
|
||||
|
||||
@@ -59,17 +59,22 @@ public class TypeCosmetic extends Type {
|
||||
boolean isUnEquippingCosmetic = false;
|
||||
if (cosmeticHolder.getCosmetic(cosmetic.getSlot()) == cosmetic) isUnEquippingCosmetic = true;
|
||||
|
||||
String dyeClick = Settings.getCosmeticDyeClickType();
|
||||
String requiredClick;
|
||||
if (isUnEquippingCosmetic) requiredClick = Settings.getCosmeticUnEquipClickType();
|
||||
else requiredClick = Settings.getCosmeticEquipClickType();
|
||||
|
||||
MessagesUtil.sendDebugMessages("Required click type: " + requiredClick);
|
||||
MessagesUtil.sendDebugMessages("Click type: " + clickType.name());
|
||||
if (!requiredClick.equalsIgnoreCase("ANY") && !requiredClick.equalsIgnoreCase(clickType.name())) {
|
||||
boolean isRequiredClick = requiredClick.equalsIgnoreCase("ANY") || requiredClick.equalsIgnoreCase(clickType.name());
|
||||
boolean isDyeClick = dyeClick.equalsIgnoreCase("ANY") || dyeClick.equalsIgnoreCase(clickType.name());
|
||||
if (!isRequiredClick && !isDyeClick) {
|
||||
MessagesUtil.sendMessage(viewer.getPlayer(), "invalid-click-type");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!isRequiredClick && isDyeClick) isUnEquippingCosmetic = false;
|
||||
|
||||
List<String> actionStrings = new ArrayList<>();
|
||||
ConfigurationNode actionConfig = config.node("actions");
|
||||
|
||||
@@ -101,9 +106,9 @@ public class TypeCosmetic extends Type {
|
||||
if (!actionConfig.node("on-equip").virtual()) actionStrings.addAll(actionConfig.node("on-equip").getList(String.class));
|
||||
MessagesUtil.sendDebugMessages("on-equip");
|
||||
// TODO: Redo this
|
||||
if (cosmetic.isDyable() && Hooks.isActiveHook("HMCColor")) {
|
||||
if (cosmetic.isDyeable() && isDyeClick && Hooks.isActiveHook("HMCColor")) {
|
||||
DyeMenu.openMenu(viewer, cosmeticHolder, cosmetic);
|
||||
} else {
|
||||
} else if (isRequiredClick) {
|
||||
cosmeticHolder.addCosmetic(cosmetic);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,8 +22,10 @@ import com.hibiscusmc.hmccosmetics.user.manager.UserWardrobeManager;
|
||||
import com.hibiscusmc.hmccosmetics.util.HMCCInventoryUtils;
|
||||
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||
import com.hibiscusmc.hmccosmetics.util.packets.HMCCPacketManager;
|
||||
import com.ticxo.modelengine.api.nms.NMSHandler;
|
||||
import lombok.Getter;
|
||||
import me.lojosho.hibiscuscommons.hooks.Hooks;
|
||||
import me.lojosho.hibiscuscommons.nms.NMSHandlers;
|
||||
import me.lojosho.hibiscuscommons.util.InventoryUtils;
|
||||
import me.lojosho.hibiscuscommons.util.packets.PacketManager;
|
||||
import org.bukkit.Bukkit;
|
||||
@@ -405,29 +407,15 @@ public class CosmeticUser implements CosmeticHolder {
|
||||
}
|
||||
|
||||
|
||||
if (colors.containsKey(cosmetic.getSlot())) {
|
||||
Color color = colors.get(cosmetic.getSlot());
|
||||
if (itemMeta instanceof LeatherArmorMeta leatherMeta) {
|
||||
leatherMeta.setColor(color);
|
||||
} else if (itemMeta instanceof PotionMeta potionMeta) {
|
||||
potionMeta.setColor(color);
|
||||
} else if (itemMeta instanceof MapMeta mapMeta) {
|
||||
mapMeta.setColor(color);
|
||||
} else if (itemMeta instanceof FireworkEffectMeta fireworkMeta) {
|
||||
fireworkMeta.setEffect(
|
||||
FireworkEffect.builder()
|
||||
.with(FireworkEffect.Type.BALL)
|
||||
.withColor(color)
|
||||
.trail(false)
|
||||
.flicker(false)
|
||||
.build()
|
||||
);
|
||||
}
|
||||
}
|
||||
itemMeta.getPersistentDataContainer().set(HMCCInventoryUtils.getCosmeticKey(), PersistentDataType.STRING, cosmetic.getId());
|
||||
itemMeta.getPersistentDataContainer().set(InventoryUtils.getOwnerKey(), PersistentDataType.STRING, getEntity().getUniqueId().toString());
|
||||
|
||||
item.setItemMeta(itemMeta);
|
||||
|
||||
if (colors.containsKey(cosmetic.getSlot())) {
|
||||
Color color = colors.get(cosmetic.getSlot());
|
||||
NMSHandlers.getHandler().getUtilHandler().setColor(item, color);
|
||||
}
|
||||
}
|
||||
return item;
|
||||
}
|
||||
@@ -623,13 +611,13 @@ public class CosmeticUser implements CosmeticHolder {
|
||||
}
|
||||
|
||||
public List<CosmeticSlot> getDyeableSlots() {
|
||||
ArrayList<CosmeticSlot> dyableSlots = new ArrayList<>();
|
||||
ArrayList<CosmeticSlot> dyeableSlots = new ArrayList<>();
|
||||
|
||||
for (Cosmetic cosmetic : playerCosmetics.values()) {
|
||||
if (cosmetic.isDyable()) dyableSlots.add(cosmetic.getSlot());
|
||||
if (cosmetic.isDyeable()) dyeableSlots.add(cosmetic.getSlot());
|
||||
}
|
||||
|
||||
return dyableSlots;
|
||||
return dyeableSlots;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -11,7 +11,6 @@ import com.ticxo.modelengine.api.ModelEngineAPI;
|
||||
import com.ticxo.modelengine.api.entity.data.BukkitEntityData;
|
||||
import com.ticxo.modelengine.api.model.ActiveModel;
|
||||
import com.ticxo.modelengine.api.model.ModeledEntity;
|
||||
import com.ticxo.modelengine.api.nms.RenderParsers;
|
||||
import lombok.Getter;
|
||||
import me.lojosho.hibiscuscommons.hooks.Hooks;
|
||||
import me.lojosho.hibiscuscommons.nms.NMSHandlers;
|
||||
@@ -82,7 +81,7 @@ public class UserBalloonManager {
|
||||
|
||||
if (color != null) {
|
||||
modeledEntity.getModels().forEach((d, singleModel) -> {
|
||||
if (cosmeticBalloonType.isDyablePart(d)) {
|
||||
if (cosmeticBalloonType.isDyeablePart(d)) {
|
||||
singleModel.setDefaultTint(color);
|
||||
singleModel.getModelRenderer().sendToClient(ModelEngineAPI.getNMSHandler().createParsers());
|
||||
}
|
||||
|
||||
Binary file not shown.
BIN
lib/HMCColor-2.4-all.jar
Normal file
BIN
lib/HMCColor-2.4-all.jar
Normal file
Binary file not shown.
Reference in New Issue
Block a user