mirror of
https://github.com/songoda/EpicEnchants.git
synced 2024-11-13 06:07:41 +01:00
Fix discover book message.
This commit is contained in:
parent
fc7ffefc2a
commit
d0fb435070
@ -17,6 +17,7 @@ import org.bukkit.inventory.ItemStack;
|
||||
import java.util.Optional;
|
||||
|
||||
import static com.songoda.epicenchants.enums.EnchantResult.*;
|
||||
import static java.util.concurrent.ThreadLocalRandom.current;
|
||||
|
||||
public class BookListener extends ItemListener {
|
||||
public BookListener(EpicEnchants instance) {
|
||||
@ -96,13 +97,16 @@ public class BookListener extends ItemListener {
|
||||
throw new IllegalStateException("The " + group.getName() + " group does not have any enchants.");
|
||||
}
|
||||
|
||||
int level = current().nextInt(enchant.get().getMaxLevel()) + 1;
|
||||
|
||||
useItem(event);
|
||||
event.getPlayer().getInventory().addItem(enchant.get().getBook().get(enchant.get()));
|
||||
event.getPlayer().getInventory().addItem(enchant.get().getBook().get(enchant.get(), level));
|
||||
|
||||
instance.getLocale().getMessage("book.discover")
|
||||
.processPlaceholder("group_name", group.getName())
|
||||
.processPlaceholder("group_color", group.getColor())
|
||||
.processPlaceholder("enchant_format", enchant.get().getFormat())
|
||||
.processPlaceholder("level", level)
|
||||
.sendPrefixedMessage(event.getPlayer());
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user