mirror of
https://github.com/GeorgH93/Minepacks.git
synced 2024-11-15 10:55:20 +01:00
Fix bug with the backpack item detection on Paper
This commit is contained in:
parent
0aee9bf302
commit
0cee4ba066
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2020 GeorgH93
|
||||
* Copyright (C) 2021 GeorgH93
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -50,7 +50,7 @@
|
||||
public class ItemShortcut extends MinepacksListener
|
||||
{
|
||||
private static final UUID MINEPACKS_UUID = UUID.nameUUIDFromBytes("Minepacks".getBytes());
|
||||
private final String itemName, value, openCommand;
|
||||
private final String itemName, itemNameNoReset, value, openCommand;
|
||||
private final Message messageDoNotRemoveItem;
|
||||
private final boolean improveDeathChestCompatibility, blockAsHat, allowRightClickOnContainers, blockItemFromMoving;
|
||||
private final int preferredSlotId;
|
||||
@ -60,6 +60,7 @@ public ItemShortcut(final @NotNull Minepacks plugin)
|
||||
{
|
||||
super(plugin);
|
||||
itemName = ChatColor.translateAlternateColorCodes('&', plugin.getConfiguration().getItemShortcutItemName());
|
||||
itemNameNoReset = itemName.replace(ChatColor.RESET.toString(), "");
|
||||
value = plugin.getConfiguration().getItemShortcutHeadValue();
|
||||
improveDeathChestCompatibility = plugin.getConfiguration().isItemShortcutImproveDeathChestCompatibilityEnabled();
|
||||
blockAsHat = plugin.getConfiguration().isItemShortcutBlockAsHatEnabled();
|
||||
@ -86,8 +87,9 @@ public ItemShortcut(final @NotNull Minepacks plugin)
|
||||
|
||||
public boolean isItemShortcut(final @Nullable ItemStack stack)
|
||||
{
|
||||
//noinspection ConstantConditions
|
||||
return stack != null && stack.getType() == HeadUtils.HEAD_MATERIAL && stack.hasItemMeta() && itemName.equals(stack.getItemMeta().getDisplayName());
|
||||
if(stack == null || stack.getType() != HeadUtils.HEAD_MATERIAL || !stack.hasItemMeta()) return false;
|
||||
String itemDisplayName = stack.getItemMeta().getDisplayName();
|
||||
return itemDisplayName != null && itemNameNoReset.equals(itemDisplayName.replace(ChatColor.RESET.toString(), ""));
|
||||
}
|
||||
|
||||
private void addItem(Player player)
|
||||
|
Loading…
Reference in New Issue
Block a user