Skip to content

Commit 240329f

Browse files
committed
Merge branch 'release/1.1.1.2'
2 parents 62179ec + 2963760 commit 240329f

22 files changed

Lines changed: 162 additions & 229 deletions

API/src/main/java/fr/maxlego08/menu/api/MenuPlugin.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,4 +263,6 @@ public interface MenuPlugin extends Plugin {
263263
ComponentsManager getComponentsManager();
264264

265265
VInvManager getVInventoryManager();
266+
267+
String[] getClickRequirementKeys();
266268
}

API/src/main/java/fr/maxlego08/menu/api/attribute/AttributeWrapper.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import org.bukkit.attribute.AttributeModifier;
88
import org.bukkit.inventory.EquipmentSlotGroup;
99
import org.jetbrains.annotations.NotNull;
10+
import org.jetbrains.annotations.Nullable;
1011

1112
import java.util.Locale;
1213
import java.util.Map;
@@ -17,7 +18,11 @@
1718
* Value object for encapsulating all data needed for an attribute modifier on an item: the attribute, operation, amount, and slot.
1819
* Provides deserialization and conversion to Bukkit AttributeModifier.
1920
*/
20-
public record AttributeWrapper(Attribute attribute, AttributeModifier.Operation operation, double amount, EquipmentSlotGroup slot) {
21+
public record AttributeWrapper(Attribute attribute, AttributeModifier.Operation operation, double amount, EquipmentSlotGroup slot, @Nullable NamespacedKey namespacedKey) {
22+
23+
AttributeWrapper(Attribute attribute, AttributeModifier.Operation operation, double amount, EquipmentSlotGroup slot) {
24+
this(attribute, operation, amount, slot, null);
25+
}
2126

2227
public static AttributeWrapper deserialize(@NotNull Map<String, Object> attributeMap) {
2328
var attribute = Registry.ATTRIBUTE.get(Objects.requireNonNull(NamespacedKey.fromString(((String) attributeMap.get("attribute")).toLowerCase(Locale.ROOT))));
@@ -30,6 +35,6 @@ public static AttributeWrapper deserialize(@NotNull Map<String, Object> attribut
3035
}
3136

3237
public AttributeModifier toAttributeModifier(MenuPlugin plugin) {
33-
return new AttributeModifier(new NamespacedKey(plugin, UUID.randomUUID().toString()), amount, operation, slot);
38+
return new AttributeModifier(Objects.requireNonNullElseGet(this.namespacedKey, () -> new NamespacedKey(plugin, UUID.randomUUID().toString())), amount, operation, slot);
3439
}
3540
}

Common/src/main/java/fr/maxlego08/menu/ZMenuItemStack.java

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
import fr.maxlego08.menu.api.utils.Placeholders;
2121
import fr.maxlego08.menu.common.context.ZBuildContext;
2222
import fr.maxlego08.menu.common.utils.ZUtils;
23-
import fr.maxlego08.menu.common.utils.itemstack.MenuItemStackFormMap;
2423
import fr.maxlego08.menu.common.utils.itemstack.MenuItemStackFromItemStack;
2524
import fr.maxlego08.menu.common.utils.nms.NmsVersion;
2625
import fr.maxlego08.menu.zcore.logger.Logger;
@@ -36,10 +35,9 @@
3635
import org.bukkit.inventory.meta.trim.ArmorTrim;
3736
import org.bukkit.potion.PotionType;
3837
import org.jetbrains.annotations.NotNull;
38+
import org.jetbrains.annotations.Nullable;
3939
import org.jspecify.annotations.NonNull;
4040

41-
import javax.annotation.Nullable;
42-
import java.io.File;
4341
import java.util.*;
4442

4543
public class ZMenuItemStack extends ZUtils implements MenuItemStack {
@@ -102,19 +100,6 @@ public static ZMenuItemStack fromItemStack(InventoryManager manager, ItemStack i
102100
return MenuItemStackFromItemStack.fromItemStack(manager, itemStack);
103101
}
104102

105-
/**
106-
* Build a MenuItemStack from a map.
107-
*
108-
* @param inventoryManager the inventoryManager of the item
109-
* @param file the file where the item is saved
110-
* @param path the path of the item in the file
111-
* @param map the map which contains the item data
112-
* @return the menuItemStack
113-
*/
114-
public static ZMenuItemStack fromMap(InventoryManager inventoryManager, File file, String path, Map<String, Object> map) {
115-
return MenuItemStackFormMap.fromMap(inventoryManager, file, path, map);
116-
}
117-
118103
/**
119104
* @return the inventoryManager
120105
*/
@@ -358,9 +343,7 @@ private void applyEnchantments(Material finalMaterial, ItemMeta itemMeta) {
358343

359344
private void applyFlags(ItemMeta itemMeta) {
360345
for (ItemFlag flag : this.flags) {
361-
if (flag != null) {
362-
itemMeta.addItemFlags(flag);
363-
}
346+
itemMeta.addItemFlags(flag);
364347
}
365348
}
366349

Common/src/main/java/fr/maxlego08/menu/common/enums/Permission.java

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,20 @@ public enum Permission {
1010
ZMENU_CONVERT,
1111
ZMENU_LIST,
1212
ZMENU_TEST_DUPE,
13-
ZMENU_OPEN_ITEM,
1413
ZMENU_CREATE,
15-
ZMENU_DOWNLOAD,
16-
ZMENU_LOGIN,
17-
ZMENU_MARKETPLACE,
18-
ZMENU_INVENTORIES,
19-
ZMENU_DESCRIPTION,
14+
ZMENU_DOWNLOAD,
15+
ZMENU_LOGIN,
16+
ZMENU_MARKETPLACE,
17+
ZMENU_INVENTORIES,
18+
ZMENU_DESCRIPTION,
2019
ZMENU_OPEN_DIALOG,
2120
ZMENU_RELOAD_DIALOG,
2221
ZMENU_DUMPLOG,
2322
ZMENU_CONTRIBUTORS,
2423
ZMENU_GIVE_ITEM,
24+
ZMENU_GIVE_OPEN_ITEM,
25+
ZMENU_EDITOR,
26+
ZMENU_VERSION,
2527

2628
ZMENU_ADDONS,
2729
ZMENU_DOCUMENTATION;

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ items:
7575
<dependency>
7676
<groupId>fr.maxlego08.menu</groupId>
7777
<artifactId>zmenu-api</artifactId>
78-
<version>1.1.1.1</version>
78+
<version>1.1.1.2</version>
7979
<scope>provided</scope>
8080
</dependency>
8181
```
@@ -87,7 +87,7 @@ repositories {
8787
}
8888

8989
dependencies {
90-
compileOnly("fr.maxlego08.menu:zmenu-api:1.1.1.1")
90+
compileOnly("fr.maxlego08.menu:zmenu-api:1.1.1.2")
9191
}
9292
```
9393

build.gradle.kts

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ plugins {
55
}
66

77
group = "fr.maxlego08.menu"
8-
version = "1.1.1.1"
8+
version = "1.1.1.2"
99

1010
extra.set("targetFolder", file("target/"))
1111
extra.set("apiFolder", file("target-api/"))
@@ -24,13 +24,24 @@ allprojects {
2424
mavenLocal()
2525
mavenCentral()
2626

27+
maven {
28+
name = "groupezReleases"
29+
url = uri("https://repo.groupez.dev/releases")
30+
}
2731
maven(url = "https://repo.tcoded.com/releases")
2832
maven(url = "https://repo.codemc.io/repository/maven-releases/")
2933
maven(url = "https://repo.codemc.io/repository/maven-snapshots/")
30-
maven(url = "https://jitpack.io")
3134
maven(url = "https://hub.spigotmc.org/nexus/content/repositories/snapshots/")
35+
maven(url = "https://hub.spigotmc.org/nexus/content/groups/public/")
3236
maven(url = "https://repo.extendedclip.com/content/repositories/placeholderapi/")
3337
maven(url = "https://libraries.minecraft.net/")
38+
maven(url = "https://repo.jsinco.dev/releases")
39+
maven {
40+
url = uri("https://jitpack.io")
41+
content {
42+
excludeGroup("org.spigotmc")
43+
}
44+
}
3445
}
3546

3647
java {
@@ -79,7 +90,7 @@ allprojects {
7990
options.encoding = "UTF-8"
8091
}
8192

82-
if (project.name == "API"){
93+
if (project.name == "API") {
8394
tasks.javadoc {
8495
options.encoding = "UTF-8"
8596
if (JavaVersion.current().isJava9Compatible)
@@ -95,11 +106,10 @@ allprojects {
95106
if (project.name != "Paper") {
96107
compileOnly("org.spigotmc:spigot-api:1.21.11-R0.1-SNAPSHOT")
97108
}
98-
compileOnly("com.mojang:authlib:1.5.26")
99109
compileOnly("me.clip:placeholderapi:2.11.6")
100110

101-
implementation("fr.maxlego08.sarah:sarah:1.20")
102-
implementation("fr.traqueur.currencies:currenciesapi:1.0.10")
111+
implementation("fr.maxlego08.sarah:sarah:1.22")
112+
implementation("fr.traqueur.currencies:currenciesapi:1.0.11")
103113
implementation("com.tcoded:FoliaLib:0.5.1")
104114

105115
implementation("com.github.cryptomorin:XSeries:13.3.0")

changelog.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,34 @@
4242

4343
# Unreleased
4444

45+
# 1.1.1.2
46+
47+
## Bug Fixes
48+
49+
- Fixed `openWithOldInventories` method crash on 1.20 by using `CompatibilityUtil.getTopInventory()` for safe inventory access.
50+
- Fixed trim pattern and material validation: now uses Bukkit `Registry` instead of the hardcoded `TrimHelper`, with proper error messages listing all available patterns/materials when a key is not found.
51+
- Fixed null `ItemFlag` entries causing errors when applying flags to item meta.
52+
- Fixed `EnchantmentGlintOverrideComponent` not handling `false` values correctly — previously only `true` was applied, now both `true` and `false` are respected.
53+
- Fixed click requirements defaulting to an empty click list when none are specified — now defaults to all click types.
54+
- Fixed `AttributeWrapper` to support an optional `NamespacedKey` instead of always generating a random UUID, preventing attribute duplication on item rebuild.
55+
- Fixed database connection logger initialization order in `ZStorageManager`.
56+
- Fixed item loading from map (`loadItemStack`) to use `MenuItemStackLoader` instead of the removed `MenuItemStackFormMap` class.
57+
58+
## Improvements
59+
60+
- **Command Permissions**: Added dedicated permissions for `CommandMenuEditor` (`ZMENU_EDITOR`), `CommandMenuVersion` (`ZMENU_VERSION`), and `CommandMenuGiveOpenItem` (`ZMENU_GIVE_OPEN_ITEM`).
61+
- **API**: Added `getClickRequirementKeys()` method to `MenuPlugin` interface, allowing addons to retrieve the supported click requirement configuration keys.
62+
- **Default Configs**: Updated default configuration files (`pro_inventory.yml`, `playtime_reward.yml`) to use kebab-case (`view-requirement`, `click-requirement`, `open-requirement`) matching current conventions.
63+
- **Dependencies**: Added `adventure-text-minimessage` as a library dependency in `plugin.yml`.
64+
65+
## Internal Changes
66+
67+
- Removed unused `PlayerSkin` class.
68+
- Removed unused `MenuItemStackFormMap` class and associated `fromMap` static method.
69+
- Cleaned up imports and formatting across multiple files.
70+
71+
---
72+
4573
# 1.1.1.1
4674

4775
## New Features

src/main/java/fr/maxlego08/menu/ZInventoryManager.java

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
import fr.maxlego08.menu.common.utils.ZUtils;
2828
import fr.maxlego08.menu.common.utils.cache.YamlFileCache;
2929
import fr.maxlego08.menu.common.utils.cache.YamlFileCacheEntry;
30-
import fr.maxlego08.menu.common.utils.itemstack.MenuItemStackFormMap;
3130
import fr.maxlego08.menu.common.utils.nms.ItemStackUtils;
3231
import fr.maxlego08.menu.common.utils.yaml.YamlParser;
3332
import fr.maxlego08.menu.hooks.dialogs.loader.body.ItemBodyLoader;
@@ -130,7 +129,9 @@ public MenuItemStack loadItemStack(YamlConfiguration configuration, String path,
130129

131130
@Override
132131
public MenuItemStack loadItemStack(File file, String path, Map<String, Object> map) {
133-
return MenuItemStackFormMap.fromMap(this, file, path, map);
132+
YamlConfiguration configuration = new YamlConfiguration();
133+
configuration.set("item", map);
134+
return new MenuItemStackLoader(this).load(configuration, "item", file);
134135
}
135136

136137
@Override
@@ -310,7 +311,9 @@ public void openInventoryWithOldInventories(Player player, Inventory inventory,
310311

311312
List<Inventory> oldInventories = new ArrayList<>();
312313

313-
if (player.getOpenInventory().getTopInventory().getHolder() instanceof InventoryDefault inventoryDefault) {
314+
315+
var topInventory = CompatibilityUtil.getTopInventory(player);
316+
if (topInventory != null && topInventory.getHolder() instanceof InventoryDefault inventoryDefault) {
314317
Inventory fromInventory = inventoryDefault.getMenuInventory();
315318
oldInventories = inventoryDefault.getOldInventories();
316319
oldInventories.add(fromInventory);
@@ -812,6 +815,11 @@ public List<ClickType> loadClicks(List<String> loadClicks) {
812815
}
813816
}
814817
});
818+
819+
if (clickTypes.isEmpty()) { // Use all clicks by default
820+
clickTypes.addAll(Configuration.allClicksType);
821+
}
822+
815823
return clickTypes;
816824
}
817825

src/main/java/fr/maxlego08/menu/ZMenuPlugin.java

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -189,14 +189,14 @@ public void onEnable() {
189189
servicesManager.register(Enchantments.class, this.enchantments, this, ServicePriority.Highest);
190190
servicesManager.register(TitleAnimationManager.class, this.titleAnimationManager, this, ServicePriority.Highest);
191191

192-
if (this.isPaperOrFolia() && NmsVersion.getCurrentVersion().isDialogsVersion()){
193-
if (Configuration.enableMiniMessageFormat){
192+
if (this.isPaperOrFolia() && NmsVersion.getCurrentVersion().isDialogsVersion()) {
193+
if (Configuration.enableMiniMessageFormat) {
194194
Logger.info("Paper server detected, loading Dialogs support");
195195
ConfigManager configManager = new ConfigManager(this);
196196
this.dialogManager = new ZDialogManager(this, configManager);
197197
servicesManager.register(DialogManager.class, this.dialogManager, this, ServicePriority.Highest);
198198
ConfigDialogBuilder configDialogBuilder = new ConfigDialogBuilder("zMenu Config", "zMenu Configuration");
199-
configManager.registerConfig(configDialogBuilder,Configuration.class, this);
199+
configManager.registerConfig(configDialogBuilder, Configuration.class, this);
200200
} else {
201201
Logger.info("Paper server detected but MiniMessage format is disabled, Dialogs support will not be loaded. Enable MiniMessage format in config.yml to use Dialogs.");
202202
}
@@ -366,7 +366,7 @@ private void registerHooks() {
366366
this.inventoryManager.registerMaterialLoader(new MMOItemsLoader());
367367
this.getLogger().info("Registered MMOItems material loader");
368368
}
369-
if (this.isActive(Plugins.PACKETEVENTS)){
369+
if (this.isActive(Plugins.PACKETEVENTS)) {
370370
this.titleAnimationManager.registerLoader("packet-events", new PacketEventTitleAnimationLoader());
371371
}
372372
}
@@ -415,7 +415,7 @@ public void onDisable() {
415415
if (this.vinventoryManager != null) this.vinventoryManager.close();
416416
this.inventoriesPlayer.restoreAllInventories();
417417

418-
Configuration.getInstance().save(getConfig(), this.configFile);
418+
Configuration.getInstance().save(getConfig(), this.configFile);
419419

420420
YamlFileCache.clearCache();
421421

@@ -496,6 +496,11 @@ public ComponentsManager getComponentsManager() {
496496
return this.componentsManager;
497497
}
498498

499+
@Override
500+
public String[] getClickRequirementKeys() {
501+
return new String[]{"click_requirement.", "click-requirement.", "click_requirements.", "click-requirements.", "clicks_requirement.", "clicks-requirement.", "clicks_requirements.", "clicks-requirements."};
502+
}
503+
499504
@Override
500505
public StorageManager getStorageManager() {
501506
return this.storageManager;

src/main/java/fr/maxlego08/menu/command/commands/CommandMenuEditor.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
package fr.maxlego08.menu.command.commands;
22

33
import fr.maxlego08.menu.ZMenuPlugin;
4-
import fr.maxlego08.menu.command.VCommand;
54
import fr.maxlego08.menu.api.utils.Message;
5+
import fr.maxlego08.menu.command.VCommand;
6+
import fr.maxlego08.menu.common.enums.Permission;
67
import fr.maxlego08.menu.zcore.utils.commands.CommandType;
78

89
public class CommandMenuEditor extends VCommand {
@@ -11,6 +12,7 @@ public CommandMenuEditor(ZMenuPlugin plugin) {
1112
super(plugin);
1213
this.addSubCommand("editor");
1314
this.setDescription(Message.DESCRIPTION_EDITOR);
15+
this.setPermission(Permission.ZMENU_EDITOR);
1416
}
1517

1618
@Override

0 commit comments

Comments
 (0)