Skip to content

Commit

Permalink
Add custom item support to Chest Menus
Browse files Browse the repository at this point in the history
  • Loading branch information
Fabricio20 committed Jan 24, 2021
1 parent 9ece9b9 commit f004d5a
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,21 @@ public void onCommand(Player player) {
HubBasics.getInstance().getMessenger().send(player, Messages.get(player, "INVALID_MENU"));
else
menu.open(player);
} else if (operator.equalsIgnoreCase("item")) {
CustomItem item = HubBasics.getInstance().getItemManager().get(command);
if (item == null) {
HubBasics.getInstance().getMessenger().send(player, Messages.get(player, "ITEM_NOT_FOUND"));
return;
}
if (item.getPermission() != null && !player.hasPermission(item.getPermission())) {
HubBasics.getInstance().getMessenger().send(player, Messages.get(player, "NO_PERMISSION_ITEM"));
return;
}
if (item.getSlot() == null || item.getSlot() == -1) {
player.getInventory().addItem(item.toItemStack(player));
} else {
player.getInventory().setItem(item.getSlot(), item.toItemStack(player));
}
} else {
player.chat("/" + command);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ public void onWorldChange(PlayerChangedWorldEvent event) {
});
}

@SuppressWarnings("ConstantConditions")
private void removeItem(CustomItem item, Inventory inventory) {
for (ItemStack content : inventory.getContents()) {
if (content == null || (content.getType() != item.getMaterial())) {
Expand All @@ -113,4 +112,4 @@ private void removeItem(CustomItem item, Inventory inventory) {
}
}

}
}
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
allprojects {
group 'net.notfab.hubbasics'
version = '6.11.8'
version = '6.11.9'
wrapper {
gradleVersion = '6.3'
}
Expand Down

0 comments on commit f004d5a

Please sign in to comment.