Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Player player = event.getPlayer();
- Set<String> recipes = getConfig().getConfigurationSection("Recipes").getKeys(true);
- if (player.getItemInHand().getTypeId() == 387 && player.getItemInHand().getDurability() <= 1) {
- if (recipes != null) {
- for (String s : recipes) {
- Short bookdura = convertStringToShort(getConfig().getString("Recipes." + s + ".BookDurability"));
- if (bookdura == player.getItemInHand().getDurability()) {
- Material mat1 = Material.getMaterial(getConfig().getString("Recipes." + s + ".Output"));
- if (mat1 == Material.WRITTEN_BOOK) {
- String booktitle = getConfig().getString("Recipes." + s + ".BookTitle");
- String bookauthor = getConfig().getString("Recipes." + s + ".BookAuthor");
- if (bookdura != null && booktitle != null && bookauthor != null) {
- int outnum = getConfig().getInt("Recipes." + s + ".Amount");
- CustomBook custombook = new CustomBook(new ItemStack(387, outnum));
- custombook.setTitle(booktitle);
- custombook.setAuthor(bookauthor);
- ItemStack writtenbook = custombook.getItemStack();
- player.setItemInHand(writtenbook);
- }
- }
- } else {
- recipes.iterator().next();
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment