Skip to content

Commit 3f220f5

Browse files
committed
Merge branch 'release/1.0.3.5'
2 parents 84f43ce + c23bbb9 commit 3f220f5

23 files changed

Lines changed: 941 additions & 102 deletions

changelog.md

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,10 @@
11
# ToDo
22

3-
- [x] Add anti dupe system with NMS Tag
4-
- [x] Add the BACK action, to return to the previous inventory when clicking
5-
- [x] Add the ability to perform actions when clicking
63
- [ ] Improve the firework system to put more buttonOption. Being able to put several effects, power etc.
74
- [ ] Add a system that allows you to cache an ItemStack, so instead of returning the ItemStack at each opening, there
85
can be several minutes without having to recreate a new ItemStack. For decorations, buttons without placeholders for
96
example.
107
- [ ] Add an order to display the list of official addons.
11-
- [ ] Add a ``/zm help`` command to send to documentation.
128
- [ ] Add a ``/zm command <command> <inventory>`` command to create an order file for an inventory.
139
- [ ] Add a system to translate plugin messages.
1410
- [ ] Update developer doc
@@ -29,27 +25,29 @@
2925
- [ ] Add a way to display the list of online players in a button list
3026
- [ ] Add Citizen and [ZNPCsPlus](https://www.spigotmc.org/resources/znpcsplus.109380/) support to open an inventory by
3127
clicking on an NPC
32-
- [x] Add a tool to transform ItemStack to base64 and vice versa. This tool can be used to all my plugins.
3328
- [ ] Fix the bug about the `clearInventory: true`. It does not restore inventory when the menu is closed.
3429
- [ ] Add the support for
3530
the `http://textures.minecraft.net/texture/e34969c2684e4f62d5f87875460441a9f849d296c01e4c621636bb6acda696f7` in the
3631
URL of a custom head.
37-
- [ ] Update pom.xml for add {projet.version} in plugin.yml
3832
- [ ] Add matrix support for slot (like
3933
this: https://abstractmenus.github.io/docs/general/item_format.html#way-4-matrix)
4034
- [ ] Adding more logs on the errors that can occur with custom items like ItemAdder, this will cause an error but the
4135
user will not have the information of why, for example when the item does not exist.
4236
- [ ] Create a new class for loading buttons to add more elements, like a boolean to check if the button needs an
4337
itemstack
4438
- [ ] Can split a file into several and thus avoid having too large files
45-
- [x] Add open link with a book
4639
- [ ] Add slot type for create pattern (Allows to fill slot areas as do the outline of the inventory)
47-
- [ ] Be able to set default values for player data
48-
- [x] Create a command `/zm download <link>` to download a configuration from a link (Allows to simply share its
49-
configurations, from discord for example)
5040

5141
# Unreleased
5242

43+
# 1.0.3.5
44+
45+
- Added support for DeluxeMenus configurations. You no longer need to convert your DeluxeMenu configurations to zMenu, they are now automatically compatible!
46+
- Added command ``/zm documentation [<word>]``
47+
- Added key `title` for inventory name, you can use `name` or `title` now
48+
- Fixed itemstack with 1.21, components was added when it should not be added by default.
49+
- Fixed the item backup system for potions and firework (use in `/zm save` command and in `zEssentials`)
50+
5351
# 1.0.3.4
5452

5553
- Add support for ``\n`` in item lore

dependency-reduced-pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<modelVersion>4.0.0</modelVersion>
44
<groupId>fr.maxlego08</groupId>
55
<artifactId>zmenu</artifactId>
6-
<version>1.0.3.4</version>
6+
<version>1.0.3.5</version>
77
<build>
88
<sourceDirectory>src</sourceDirectory>
99
<resources>

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<modelVersion>4.0.0</modelVersion>
44
<groupId>fr.maxlego08</groupId>
55
<artifactId>zmenu</artifactId>
6-
<version>1.0.3.4</version>
6+
<version>1.0.3.5</version>
77
<properties>
88
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
99
<maven.compiler.source>8</maven.compiler.source>

src/fr/maxlego08/menu/MenuItemStack.java

Lines changed: 67 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import org.bukkit.Bukkit;
2626
import org.bukkit.Color;
2727
import org.bukkit.DyeColor;
28+
import org.bukkit.FireworkEffect;
2829
import org.bukkit.Material;
2930
import org.bukkit.OfflinePlayer;
3031
import org.bukkit.block.banner.Pattern;
@@ -36,7 +37,10 @@
3637
import org.bukkit.inventory.meta.ArmorMeta;
3738
import org.bukkit.inventory.meta.Damageable;
3839
import org.bukkit.inventory.meta.EnchantmentStorageMeta;
40+
import org.bukkit.inventory.meta.FireworkEffectMeta;
41+
import org.bukkit.inventory.meta.FireworkMeta;
3942
import org.bukkit.inventory.meta.ItemMeta;
43+
import org.bukkit.inventory.meta.PotionMeta;
4044
import org.bukkit.inventory.meta.Repairable;
4145
import org.bukkit.inventory.meta.SkullMeta;
4246
import org.bukkit.inventory.meta.trim.ArmorTrim;
@@ -83,14 +87,14 @@ public class MenuItemStack extends ZUtils {
8387
private int maxDamage;
8488
private int damage;
8589
private int repairCost;
86-
private boolean unbreakableEnabled;
87-
private boolean unbreakableShowInTooltip;
88-
private boolean fireResistant;
89-
private boolean hideTooltip;
90-
private boolean hideAdditionalTooltip;
90+
private Boolean unbreakableEnabled;
91+
private Boolean unbreakableShowInTooltip;
92+
private Boolean fireResistant;
93+
private Boolean hideTooltip;
94+
private Boolean hideAdditionalTooltip;
9195
private Boolean enchantmentGlint;
92-
private boolean enchantmentShowInTooltip;
93-
private boolean attributeShowInTooltip;
96+
private Boolean enchantmentShowInTooltip;
97+
private Boolean attributeShowInTooltip;
9498
private MenuItemRarity itemRarity;
9599
private TrimConfiguration trimConfiguration;
96100

@@ -144,6 +148,43 @@ public static MenuItemStack fromItemStack(InventoryManager manager, ItemStack it
144148
menuItemStack.setEnchantments(enchantmentStorageMeta.getEnchants());
145149
}
146150
}
151+
152+
try {
153+
if (itemMeta instanceof PotionMeta) {
154+
PotionMeta potionMeta = (PotionMeta) itemMeta;
155+
PotionType type = potionMeta.getBasePotionType();
156+
if (type != null) {
157+
Potion menuPotion = new Potion(type, 0);
158+
menuItemStack.setPotion(menuPotion);
159+
}
160+
}
161+
} catch (Exception ignored) {
162+
}
163+
164+
try {
165+
// ToDo, upgrade for multiple effect
166+
if (itemMeta instanceof FireworkMeta) {
167+
FireworkMeta fireworkMeta = (FireworkMeta) itemMeta;
168+
List<FireworkEffect> fireworkEffects = fireworkMeta.getEffects();
169+
if (!fireworkEffects.isEmpty()) {
170+
FireworkEffect effect = fireworkEffects.get(0);
171+
Firework menuFirework = new Firework(false, effect);
172+
menuItemStack.setFirework(menuFirework);
173+
}
174+
}
175+
} catch (Exception ignored) {
176+
}
177+
178+
try {
179+
// ToDo, upgrade for multiple effect
180+
if (itemMeta instanceof FireworkEffectMeta) {
181+
FireworkEffectMeta fireworkMeta = (FireworkEffectMeta) itemMeta;
182+
FireworkEffect effect = fireworkMeta.getEffect();
183+
Firework menuFirework = new Firework(true, effect);
184+
menuItemStack.setFirework(menuFirework);
185+
}
186+
} catch (Exception ignored) {
187+
}
147188
}
148189

149190
return menuItemStack;
@@ -275,7 +316,7 @@ public ItemStack build(Player player, boolean useCache, Placeholders placeholder
275316
}
276317

277318
if (!this.lore.isEmpty()) {
278-
List<String> lore = placeholders.parse(locale == null ? this.lore : this.translatedLore.getOrDefault(locale, this.lore));
319+
List<String> lore = papi(placeholders.parse(locale == null ? this.lore : this.translatedLore.getOrDefault(locale, this.lore)), player, useCache);
279320
lore = lore.stream().flatMap(str -> Arrays.stream(str.split("\n"))).collect(Collectors.toList());
280321
Meta.meta.updateLore(itemMeta, lore, offlinePlayer == null ? player : offlinePlayer);
281322
}
@@ -336,37 +377,39 @@ private void buildNewItemStackAPI(ItemStack itemStack, ItemMeta itemMeta, Player
336377

337378
if (itemMeta instanceof Damageable) {
338379
Damageable damageable = (Damageable) itemMeta;
380+
339381
if (this.maxDamage > 0) damageable.setMaxDamage(this.maxDamage);
340-
damageable.setDamage(this.damage);
341-
damageable.setUnbreakable(this.unbreakableEnabled);
382+
if (this.damage != 0) damageable.setDamage(this.damage);
383+
384+
if (this.unbreakableEnabled != null) damageable.setUnbreakable(this.unbreakableEnabled);
342385

343-
if (!this.unbreakableShowInTooltip) {
386+
if (this.unbreakableShowInTooltip != null && !this.unbreakableShowInTooltip) {
344387
itemMeta.addItemFlags(ItemFlag.HIDE_UNBREAKABLE);
345388
}
346389
}
347390

348-
if (itemMeta instanceof Repairable) {
391+
if (itemMeta instanceof Repairable && this.repairCost > 0) {
349392
((Repairable) itemMeta).setRepairCost(this.repairCost);
350393
}
351394

352-
itemMeta.setHideTooltip(this.hideTooltip);
353-
if (this.hideAdditionalTooltip) {
395+
if (this.hideTooltip != null) itemMeta.setHideTooltip(this.hideTooltip);
396+
if (this.hideAdditionalTooltip != null && this.hideAdditionalTooltip) {
354397
for (ItemFlag value : ItemFlag.values()) {
355398
itemMeta.addItemFlags(value);
356399
}
357400
}
358401

359-
if (!this.enchantmentShowInTooltip) {
402+
if (this.enchantmentShowInTooltip != null && !this.enchantmentShowInTooltip) {
360403
itemMeta.addItemFlags(ItemFlag.HIDE_ENCHANTS);
361404
}
362405

363406
if (this.enchantmentGlint != null) {
364407
itemMeta.setEnchantmentGlintOverride(this.enchantmentGlint);
365408
}
366409

367-
itemMeta.setFireResistant(this.fireResistant);
410+
if (this.fireResistant != null) itemMeta.setFireResistant(this.fireResistant);
368411

369-
if (!this.attributeShowInTooltip) {
412+
if (this.attributeShowInTooltip != null && !this.attributeShowInTooltip) {
370413
itemMeta.addItemFlags(ItemFlag.HIDE_ATTRIBUTES);
371414
}
372415

@@ -897,39 +940,39 @@ public boolean isUnbreakableEnabled() {
897940
return unbreakableEnabled;
898941
}
899942

900-
public void setUnbreakableEnabled(boolean unbreakableEnabled) {
943+
public void setUnbreakableEnabled(Boolean unbreakableEnabled) {
901944
this.unbreakableEnabled = unbreakableEnabled;
902945
}
903946

904947
public boolean isUnbreakableShowInTooltip() {
905948
return unbreakableShowInTooltip;
906949
}
907950

908-
public void setUnbreakableShowInTooltip(boolean unbreakableShowInTooltip) {
951+
public void setUnbreakableShowInTooltip(Boolean unbreakableShowInTooltip) {
909952
this.unbreakableShowInTooltip = unbreakableShowInTooltip;
910953
}
911954

912955
public boolean isFireResistant() {
913956
return fireResistant;
914957
}
915958

916-
public void setFireResistant(boolean fireResistant) {
959+
public void setFireResistant(Boolean fireResistant) {
917960
this.fireResistant = fireResistant;
918961
}
919962

920963
public boolean isHideTooltip() {
921964
return hideTooltip;
922965
}
923966

924-
public void setHideTooltip(boolean hideTooltip) {
967+
public void setHideTooltip(Boolean hideTooltip) {
925968
this.hideTooltip = hideTooltip;
926969
}
927970

928971
public boolean isHideAdditionalTooltip() {
929972
return hideAdditionalTooltip;
930973
}
931974

932-
public void setHideAdditionalTooltip(boolean hideAdditionalTooltip) {
975+
public void setHideAdditionalTooltip(Boolean hideAdditionalTooltip) {
933976
this.hideAdditionalTooltip = hideAdditionalTooltip;
934977
}
935978

@@ -945,15 +988,15 @@ public boolean isEnchantmentShowInTooltip() {
945988
return enchantmentShowInTooltip;
946989
}
947990

948-
public void setEnchantmentShowInTooltip(boolean enchantmentShowInTooltip) {
991+
public void setEnchantmentShowInTooltip(Boolean enchantmentShowInTooltip) {
949992
this.enchantmentShowInTooltip = enchantmentShowInTooltip;
950993
}
951994

952995
public boolean isAttributeShowInTooltip() {
953996
return attributeShowInTooltip;
954997
}
955998

956-
public void setAttributeShowInTooltip(boolean attributeShowInTooltip) {
999+
public void setAttributeShowInTooltip(Boolean attributeShowInTooltip) {
9571000
this.attributeShowInTooltip = attributeShowInTooltip;
9581001
}
9591002

src/fr/maxlego08/menu/ZInventory.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import fr.maxlego08.menu.api.pattern.Pattern;
77
import fr.maxlego08.menu.api.players.inventory.InventoriesPlayer;
88
import fr.maxlego08.menu.api.requirement.Requirement;
9+
import fr.maxlego08.menu.api.utils.CompatibilityUtil;
910
import fr.maxlego08.menu.api.utils.OpenWithItem;
1011
import fr.maxlego08.menu.api.utils.Placeholders;
1112
import fr.maxlego08.menu.inventory.inventories.InventoryDefault;
@@ -34,7 +35,7 @@ public class ZInventory extends ZUtils implements Inventory {
3435
private final int size;
3536
private final List<Button> buttons;
3637
private Map<String, String> translatedNames = new HashMap<>();
37-
private List<Pattern> patterns;
38+
private List<Pattern> patterns = new ArrayList<>();
3839
private MenuItemStack fillItemStack;
3940
private int updateInterval;
4041
private File file;
@@ -158,7 +159,10 @@ public InventoryResult openInventory(Player player, InventoryDefault inventoryDe
158159

159160
@Override
160161
public void postOpenInventory(Player player, InventoryDefault inventoryDefault) {
161-
InventoryHolder holder = player.getOpenInventory().getTopInventory().getHolder();
162+
163+
org.bukkit.inventory.Inventory topInventory = CompatibilityUtil.getTopInventory(player);
164+
InventoryHolder holder = topInventory.getHolder();
165+
162166
if (holder != null) {
163167
if (holder instanceof InventoryDefault) {
164168
InventoryDefault inventoryHolder = (InventoryDefault) holder;
@@ -179,7 +183,7 @@ public void postOpenInventory(Player player, InventoryDefault inventoryDefault)
179183
public void closeInventory(Player player, InventoryDefault inventoryDefault) {
180184
if (this.clearInventory) {
181185
MenuPlugin.getInstance().getScheduler().runTaskLater(player.getLocation(), 1, () -> {
182-
InventoryHolder newHolder = player.getOpenInventory().getTopInventory().getHolder();
186+
InventoryHolder newHolder = CompatibilityUtil.getTopInventory(player).getHolder();
183187
if (newHolder != null && !(newHolder instanceof InventoryDefault)) {
184188
InventoriesPlayer inventoriesPlayer = inventoryDefault.getPlugin().getInventoriesPlayer();
185189
inventoriesPlayer.giveInventory(player);

src/fr/maxlego08/menu/ZInventoryManager.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import fr.maxlego08.menu.api.itemstack.ItemStackSimilar;
1313
import fr.maxlego08.menu.api.loader.MaterialLoader;
1414
import fr.maxlego08.menu.api.scheduler.ZScheduler;
15+
import fr.maxlego08.menu.api.utils.CompatibilityUtil;
1516
import fr.maxlego08.menu.api.utils.MetaUpdater;
1617
import fr.maxlego08.menu.api.utils.OpenWithItem;
1718
import fr.maxlego08.menu.button.buttons.ZNoneButton;
@@ -49,6 +50,7 @@
4950
import fr.maxlego08.menu.loader.actions.TitleLoader;
5051
import fr.maxlego08.menu.loader.actions.VaultDepositLoader;
5152
import fr.maxlego08.menu.loader.actions.VaultWithdrawLoader;
53+
import fr.maxlego08.menu.loader.deluxemenu.InventoryDeluxeMenuLoader;
5254
import fr.maxlego08.menu.loader.permissible.ItemPermissibleLoader;
5355
import fr.maxlego08.menu.loader.permissible.JobPermissibleLoader;
5456
import fr.maxlego08.menu.loader.permissible.LuckPermPermissibleLoader;
@@ -157,8 +159,10 @@ public Inventory loadInventory(Plugin plugin, String fileName, Class<? extends I
157159
@Override
158160
public Inventory loadInventory(Plugin plugin, File file, Class<? extends Inventory> classz) throws InventoryException {
159161

160-
Loader<Inventory> loader = new InventoryLoader(this.plugin);
161162
YamlConfiguration configuration = YamlConfiguration.loadConfiguration(file);
163+
boolean isDeluxeMenu = configuration.contains("menu_title");
164+
165+
Loader<Inventory> loader = isDeluxeMenu ? new InventoryDeluxeMenuLoader(this.plugin) : new InventoryLoader(this.plugin);
162166
Inventory inventory = loader.load(configuration, "", file, classz, plugin);
163167

164168
List<Inventory> inventories = this.inventories.getOrDefault(plugin.getName(), new ArrayList<>());
@@ -562,7 +566,7 @@ public void createNewInventory(CommandSender sender, String fileName, int invent
562566

563567
@Override
564568
public void updateInventory(Player player) {
565-
InventoryHolder holder = player.getOpenInventory().getTopInventory().getHolder();
569+
InventoryHolder holder = CompatibilityUtil.getTopInventory(player).getHolder();
566570
if (holder instanceof InventoryDefault) {
567571
InventoryDefault inventoryDefault = (InventoryDefault) holder;
568572
this.openInventory(player, inventoryDefault.getMenuInventory(), inventoryDefault.getPage(), inventoryDefault.getOldInventories());
@@ -571,7 +575,7 @@ public void updateInventory(Player player) {
571575

572576
@Override
573577
public void updateInventory(Player player, Plugin plugin) {
574-
InventoryHolder holder = player.getOpenInventory().getTopInventory().getHolder();
578+
InventoryHolder holder = CompatibilityUtil.getTopInventory(player).getHolder();
575579
if (holder instanceof InventoryDefault) {
576580
InventoryDefault inventoryDefault = (InventoryDefault) holder;
577581
if (inventoryDefault.getMenuInventory().getPlugin() == plugin) {

src/fr/maxlego08/menu/api/button/Button.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -330,4 +330,6 @@ public interface Button extends PermissibleButton, PlaceholderButton, SlotButton
330330
RefreshRequirement getRefreshRequirement();
331331

332332
boolean hasRefreshRequirement();
333+
334+
int getPriority();
333335
}

0 commit comments

Comments
 (0)