Skip to content

Commit

Permalink
Fix not displaying drops without names
Browse files Browse the repository at this point in the history
  • Loading branch information
zrdzn committed Apr 29, 2022
1 parent 832e9f4 commit 08570eb
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 16 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ plugins {

allprojects {
group "io.github.zrdzn.minecraft"
version "1.3.0"
version "1.3.1"
}

subprojects {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,14 +101,17 @@ public void onSourceBreak(BlockBreakEvent event) {
amount = random.nextInt(item.getAmount().getKey(), item.getAmount().getValue());
}

String itemName = item.getDisplayName();
ItemStack droppedItem = new ItemStack(item.getType(), amount);

ItemMeta droppedItemMeta = droppedItem.getItemMeta();

String itemId = item.getId();

String[] placeholders = { "{DROP}", itemName, "{AMOUNT}", String.valueOf(amount) };
droppedItemMeta.setDisplayName(itemId);

String[] placeholders = { "{DROP}", itemId, "{AMOUNT}", String.valueOf(amount) };
this.messageService.send(player, "drop-successful", placeholders);

ItemStack droppedItem = new ItemStack(item.getType(), amount);
ItemMeta droppedItemMeta = droppedItem.getItemMeta();
droppedItemMeta.setDisplayName(itemName);
droppedItemMeta.setLore(item.getLore());
droppedItem.setItemMeta(droppedItemMeta);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ public boolean open(Player player) {
Entry<String, String> dropSwitch = this.menu.getDropSwitch();
Entry<String, String> inventoryDropSwitch = this.menu.getInventoryDropSwitch();

String dropName = dropItem.getDisplayName();
String dropId = dropItem.getId();

ItemBuilder menuItemBuilder = ItemBuilder.from(item.getType())
.setName(item.getDisplayName())
Expand Down Expand Up @@ -163,10 +163,10 @@ public boolean open(Player player) {
user.disableDrop(dropItem);
}

this.messageService.send(player, "drop-switched", "{DROP}", dropName);
this.messageService.send(player, "drop-switched", "{DROP}", dropId);
} else if (action == MenuAction.SWITCH_DROP_TO_INVENTORY) {
user.switchInventoryDrop(itemId, !user.hasSwitchedInventoryDrop(itemId));
this.messageService.send(player, "drop-switched-inventory", "{DROP}", dropName);
this.messageService.send(player, "drop-switched-inventory", "{DROP}", dropId);
}
}
} else {
Expand All @@ -181,10 +181,10 @@ public boolean open(Player player) {
user.disableDrop(dropItem);
}

this.messageService.send(player, "drop-switched", "{DROP}", dropName);
this.messageService.send(player, "drop-switched", "{DROP}", dropId);
} else if (action == MenuAction.SWITCH_DROP_TO_INVENTORY) {
user.switchInventoryDrop(itemId, !user.hasSwitchedInventoryDrop(itemId));
this.messageService.send(player, "drop-switched-inventory", "{DROP}", dropName);
this.messageService.send(player, "drop-switched-inventory", "{DROP}", dropId);
}
}

Expand All @@ -205,10 +205,7 @@ public boolean open(Player player) {
});

// Fill the rest inventory with the specified item if enabled.
ItemStack filler = this.menu.getFiller();
if (filler != null) {
menu.getFiller().fill(ItemBuilder.from(filler).asGuiItem());
}
this.menu.getFiller().ifPresent(filler -> menu.getFiller().fill(ItemBuilder.from(filler).asGuiItem()));

menu.open(player);

Expand Down
2 changes: 1 addition & 1 deletion plugin/src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: LovelyDrop
version: 1.3.0
version: 1.3.1
main: io.github.zrdzn.minecraft.lovelydrop.LovelyDropPlugin
api-version: 1.13
author: zrdzn
Expand Down

0 comments on commit 08570eb

Please sign in to comment.