9
0
mirror of https://github.com/HibiscusMC/HMCCosmetics.git synced 2026-01-04 15:41:45 +00:00

feat: add config options to avoid certain item processing if desired

This commit is contained in:
LoJoSho
2024-10-30 10:14:29 -05:00
parent 62a9e7d1ac
commit 19192c46a5
3 changed files with 32 additions and 9 deletions

View File

@@ -30,6 +30,9 @@ public class Settings {
private static final String UNAPPLY_DEATH_PATH = "unapply-on-death";
private static final String FORCE_PERMISSION_JOIN_PATH = "force-permission-join";
private static final String FORCE_SHOW_COSMETICS_PATH = "force-show-join";
private static final String ITEM_PROCESSING_PATH = "item-processing";
private static final String ITEM_PROCESS_DISPLAY_NAME_PATH = "display-name";
private static final String ITEM_PROCESS_LORE_PATH = "lore";
private static final String DISABLED_GAMEMODE_PATH = "disabled-gamemode";
private static final String DISABLED_GAMEMODE_GAMEMODES_PATH = "gamemodes";
private static final String EMOTE_DISTANCE_PATH = "emote-distance";
@@ -88,6 +91,10 @@ public class Settings {
@Getter
private static boolean forceShowOnJoin;
@Getter
private static boolean itemProcessingDisplayName;
@Getter
private static boolean itemProcessingLore;
@Getter
private static boolean itemsAdderChangeReload;
@Getter
private static boolean worldGuardMoveCheck;
@@ -185,6 +192,10 @@ public class Settings {
disabledWorlds = new ArrayList<>();
}
ConfigurationNode itemProcessingSettings = cosmeticSettings.node(ITEM_PROCESSING_PATH);
itemProcessingDisplayName = itemProcessingSettings.node(ITEM_PROCESS_DISPLAY_NAME_PATH).getBoolean(true);
itemProcessingLore = itemProcessingSettings.node(ITEM_PROCESS_LORE_PATH).getBoolean(true);
unapplyOnDeath = cosmeticSettings.node(UNAPPLY_DEATH_PATH).getBoolean(false);
forcePermissionJoin = cosmeticSettings.node(FORCE_PERMISSION_JOIN_PATH).getBoolean(false);
forceShowOnJoin = cosmeticSettings.node(FORCE_SHOW_COSMETICS_PATH).getBoolean(false);

View File

@@ -60,6 +60,8 @@ public class CosmeticUser {
// Cosmetic Settings/Toggles
private final ArrayList<HiddenReason> hiddenReason = new ArrayList<>();
private final HashMap<CosmeticSlot, Color> colors = new HashMap<>();
// Cosmetic caches
private final HashMap<String, ItemStack> cosmeticItems = new HashMap<>();
public CosmeticUser(UUID uuid) {
this.uniqueId = uuid;
@@ -276,18 +278,22 @@ public class CosmeticUser {
itemMeta = skullMeta;
}
List<String> processedLore = new ArrayList<>();
if (itemMeta.hasLore()) {
for (String loreLine : itemMeta.getLore()) {
processedLore.add(Hooks.processPlaceholders(getPlayer(), loreLine));
if (Settings.isItemProcessingDisplayName()) {
if (itemMeta.hasDisplayName()) {
String displayName = itemMeta.getDisplayName();
itemMeta.setDisplayName(Hooks.processPlaceholders(getPlayer(), displayName));
}
}
if (itemMeta.hasDisplayName()) {
String displayName = itemMeta.getDisplayName();
itemMeta.setDisplayName(Hooks.processPlaceholders(getPlayer(), displayName));
if (Settings.isItemProcessingLore()) {
List<String> processedLore = new ArrayList<>();
if (itemMeta.hasLore()) {
for (String loreLine : itemMeta.getLore()) {
processedLore.add(Hooks.processPlaceholders(getPlayer(), loreLine));
}
}
itemMeta.setLore(processedLore);
}
itemMeta.setLore(processedLore);
if (colors.containsKey(cosmetic.getSlot())) {
Color color = colors.get(cosmetic.getSlot());

View File

@@ -24,6 +24,12 @@ cosmetic-settings:
force-permission-join: true # Checks a player permission if they can have a cosmetic when they join the server.
force-show-join: false # If the plugin should force show a player's cosmetics when they join the server.
# This determines what to process what areas to process placeholders when displaying the item to the user.
# This can be heavy on servers with a lot of players, so if experiencing lag issues relating to setting display/lores of items, disable this.
item-processing:
display-name: true
lore: true
# This is a list of worlds that cosmetics are hidden in. When a player enters one of these worlds, their cosmetics will be hidden.
disabled-worlds:
- "disabledworld"