This will allow you to create new enchanted books (even though you can get them in creative) but also ADD enchantments to your books, making super custom books
Requires Skript-Mirror
This is the actual command to create the books and/or add enchantments to books
This part is the tab completer for when you are creating a book, it'll auto fill in info for you
Requires Skript-Mirror
This is the actual command to create the books and/or add enchantments to books
code_language.skript:
import:
org.bukkit.enchantments.Enchantment
org.bukkit.event.server.TabCompleteEvent
java.util.Arrays
command /test <enchantment>:
trigger:
enchant player's tool with arg-1
command /bookench <text> <enchantment> [<integer=1>]:
usage: &a/BookEnch &7<&bnew&7/&badd&7> <&benchantment&7> [&6level&7]
permission: book.ench
permission message: You do not have permission to use this command
trigger:
if arg-1 is "new":
if arg-3 <= arg-2.getMaxLevel():
set {_book} to "enchanted book" parsed as item
set {_meta} to {_book}.getItemMeta()
set {_ench} to arg-2
{_meta}.addStoredEnchant({_ench}, arg-3, false)
{_book}.setItemMeta({_meta})
give player {_book}
if arg-3 >= 2:
send "&aNew enchanted book of &b%arg-2% %arg-3% &acreated!"
else:
send "&aNew enchanted book of &b%arg-2% &acreated!"
else:
send "&cENCHANTMENT LEVEL TOO HIGH"
else if arg-1 is "add":
if player's tool is enchanted book:
if arg-3 <= arg-2.getMaxLevel():
set {_book} to player's tool
set {_meta} to {_book}.getItemMeta()
set {_ench} to arg-2
{_meta}.addStoredEnchant({_ench}, arg-3, false)
{_book}.setItemMeta({_meta})
if arg-3 >= 2:
send "&b%arg-2% %arg-3% &ahas been added to your book"
else:
send "&b%arg-2% &ahas been added to your book"
else:
send "&cENCHANTMENT LEVEL TOO HIGH"
else:
send "&cYOU NEED AN ENCAHNTED BOOK TO USE THIS COMMAND"
This part is the tab completer for when you are creating a book, it'll auto fill in info for you
code_language.skript:
on TabCompleteEvent:
if event.getBuffer() contains "/bookench new " or "/bookench add ":
set {_buff} to event.getBuffer()
replace "/bookench new " and "/bookench add " with "" in {_buff}
set {_list} to "%Enchantment.values()%"
set {_list::*} to {_list} split at ", "
set {_num} to length of {_buff}
loop {_list::*}:
if first {_num} characters of loop-value is {_buff}:
add loop-value to {_newbuff::*}
if {_buff} contains " ":
if last character of {_buff} is " ":
set {_ench} to first (length of {_buff} - 1) characters of {_buff}
set {_ench} to {_ench} parsed as enchantment
set {_max} to {_ench}.getMaxLevel()
event.setCompletions(Arrays.asList("[<max-level=%{_max}%>]"))
else:
if size of {_newbuff::*} = 0:
event.setCompletions(Arrays.asList({_list::*}))
else if size of {_newbuff::*} >= 1:
event.setCompletions(Arrays.asList({_newbuff::*}))
else if event.getBuffer() = "/bookench ":
set {_list::*} to "new" and "add"
event.setCompletions(Arrays.asList({_list::*}))
else if event.getBuffer() = "/bookench a" or "/bookench ad":
event.setCompletions(Arrays.asList("add"))
else if event.getBuffer() = "/bookench n" or "/bookench ne":
event.setCompletions(Arrays.asList("new"))