Guest User

Untitled

a guest
Dec 15th, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.64 KB | None | 0 0
  1. Player player = event.getPlayer();
  2.         Set<String> recipes = getConfig().getConfigurationSection("Recipes").getKeys(true);
  3.         if (player.getItemInHand().getTypeId() == 387 && player.getItemInHand().getDurability() <= 1) {
  4.             if (recipes != null) {
  5.                 for (String s : recipes) {
  6.                     Short bookdura = convertStringToShort(getConfig().getString("Recipes." + s + ".BookDurability"));
  7.                     if (bookdura == player.getItemInHand().getDurability()) {
  8.                         Material mat1 = Material.getMaterial(getConfig().getString("Recipes." + s + ".Output"));
  9.                         if (mat1 == Material.WRITTEN_BOOK) {
  10.                             String booktitle = getConfig().getString("Recipes." + s + ".BookTitle");
  11.                             String bookauthor = getConfig().getString("Recipes." + s + ".BookAuthor");
  12.                             if (bookdura != null && booktitle != null && bookauthor != null) {
  13.                                 int outnum = getConfig().getInt("Recipes." + s + ".Amount");
  14.                                 CustomBook custombook = new CustomBook(new ItemStack(387, outnum));
  15.                                 custombook.setTitle(booktitle);
  16.                                 custombook.setAuthor(bookauthor);
  17.                                 ItemStack writtenbook = custombook.getItemStack();
  18.                                 player.setItemInHand(writtenbook);
  19.                             }
  20.                         }
  21.                     } else {
  22.                         recipes.iterator().next();
  23.                     }
  24.                 }
  25.             }
  26.         }
Add Comment
Please, Sign In to add comment