-
-
Notifications
You must be signed in to change notification settings - Fork 635
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implemented books #3877
Implemented books #3877
Changes from all commits
c171b27
dd71e6d
b0dc890
d265e3a
e5758e8
e58dd78
92133f7
2126a17
16deb2b
2d2bfcd
0a77844
fd5eb01
1bc849c
28e4997
099e82d
a5bae9f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6936,14 +6936,19 @@ These ItemGrids are available in the API and can be manipulated by the plugins, | |
}, | ||
Variables = | ||
{ | ||
m_BookContent = | ||
{ | ||
Type = "cBookContent", | ||
Notes = "If it's a written or a writeable book, it contains the information of the book: Author, title and pages", | ||
}, | ||
m_CustomName = | ||
{ | ||
Type = "string", | ||
Notes = "The custom name for an item.", | ||
}, | ||
m_Enchantments = | ||
{ | ||
Type = "{{cEnchantments|cEnchantments}}}", | ||
Type = "cEnchantments", | ||
Notes = "The enchantments of the item.", | ||
}, | ||
m_ItemCount = | ||
|
@@ -7014,6 +7019,174 @@ local Item5 = cItem(E_ITEM_DIAMOND_CHESTPLATE, 1, 0, "thorns=1;unbreaking=3"); | |
}, | ||
}, | ||
}, | ||
cBookContent = | ||
{ | ||
Desc = [[ | ||
This class contains the information for a signed or writeable book: The author, title and the pages. A page of the writeable book is a simple string. For a signed book it can be a json string. Use {{cCompositeChat}} to create a more complex page with formatting. | ||
]], | ||
Functions = | ||
{ | ||
AddPage = | ||
{ | ||
{ | ||
Params = | ||
{ | ||
{ | ||
Name = "Page", | ||
Type = "string", | ||
}, | ||
}, | ||
Notes = "Add a page to the end of the book", | ||
}, | ||
{ | ||
Params = | ||
{ | ||
{ | ||
Name = "Page", | ||
Type = "cCompositeChat", | ||
}, | ||
}, | ||
Notes = "Add a page to the end of the book. For signed book saves it as json string, otherwise as simple string", | ||
} | ||
}, | ||
Clear = | ||
{ | ||
Notes = "Clears the whole book", | ||
}, | ||
constructor = | ||
{ | ||
Returns = | ||
{ | ||
{ | ||
Type = "cBookContent", | ||
}, | ||
}, | ||
Notes = "Creates a empty book", | ||
}, | ||
GetAuthor = | ||
{ | ||
Returns = | ||
{ | ||
{ | ||
Type = "string", | ||
}, | ||
}, | ||
Notes = "Returns the author of the book", | ||
}, | ||
GetTitle = | ||
{ | ||
Returns = | ||
{ | ||
{ | ||
Type = "string", | ||
}, | ||
}, | ||
Notes = "Returns the title of the book", | ||
}, | ||
GetPage = | ||
{ | ||
Params = | ||
{ | ||
{ | ||
Type = "number", | ||
}, | ||
}, | ||
Returns = | ||
{ | ||
{ | ||
Type = "string", | ||
}, | ||
}, | ||
Notes = "Returns the page at the given index, can be a json string or a simple string. Note: one-based", | ||
}, | ||
GetPages = | ||
{ | ||
Returns = | ||
{ | ||
{ | ||
Type = "table", | ||
}, | ||
}, | ||
Notes = "Returns the pages of the book as a table", | ||
}, | ||
IsEmpty = | ||
{ | ||
Returns = | ||
{ | ||
{ | ||
Type = "boolean", | ||
}, | ||
}, | ||
Notes = "Returns true if the book has no author, title and no pages", | ||
}, | ||
SetAuthor = | ||
{ | ||
Params = | ||
{ | ||
{ | ||
Name = "Author", | ||
Type = "string", | ||
}, | ||
}, | ||
Notes = "Set the author of the book", | ||
}, | ||
SetPage = | ||
{ | ||
{ | ||
Params = | ||
{ | ||
{ | ||
Name = "Index", | ||
Type = "number", | ||
}, | ||
{ | ||
Name = "Page", | ||
Type = "string", | ||
}, | ||
}, | ||
Notes = "Set's the page at the given index. Note: one-based", | ||
}, | ||
{ | ||
Params = | ||
{ | ||
{ | ||
Name = "Index", | ||
Type = "number", | ||
}, | ||
{ | ||
Name = "Page", | ||
Type = "cCompositeChat", | ||
}, | ||
}, | ||
Notes = "Set's the page at the given index. For signed book saves it as json string, otherwise as simple string. Note: one-based", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
}, | ||
}, | ||
SetPages = | ||
{ | ||
{ | ||
Params = | ||
{ | ||
{ | ||
Name = "Pages", | ||
Type = "table", | ||
}, | ||
}, | ||
Notes = "Sets all pages of the book. A entry can be a string or a {{cCompositeChat}}", | ||
}, | ||
}, | ||
SetTitle = | ||
{ | ||
Params = | ||
{ | ||
{ | ||
Name = "Title", | ||
Type = "string", | ||
}, | ||
}, | ||
Notes = "Set the title of the book", | ||
}, | ||
}, | ||
}, | ||
cItemFrame = | ||
{ | ||
Functions = | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
return | ||
{ | ||
HOOK_PLAYER_EDITED_BOOK = | ||
{ | ||
CalledWhen = "A player has edited a book.", | ||
DefaultFnName = "OnPlayerEditedBook", -- also used as pagename | ||
Desc = [[ | ||
This hook is called whenever a {{cPlayer|player}} has edited a book. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
See also the {{OnPlayerEditingBook|HOOK_PLAYER_EDITING_BOOK}} hook for a similar hook, is called when a | ||
player is editing a book. | ||
]], | ||
Params = | ||
{ | ||
{ Name = "Player", Type = "cPlayer", Notes = "The player that edited the book" }, | ||
{ Name = "NewContent", Type = "cBookContent", Notes = "Contains the new content of the book" }, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should have the |
||
{ Name = "IsSigned", Type = "boolean", Notes = "Player has signed the book" }, | ||
}, | ||
Returns = [[ | ||
If the function returns false or no value, Cuberite calls other plugins with this event. If the | ||
function returns true, no other plugin is called for this event.</p> | ||
]], | ||
}, -- HOOK_PLAYER_EDITED_BOOK | ||
} | ||
|
||
|
||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
return | ||
{ | ||
HOOK_PLAYER_EDITING_BOOK = | ||
{ | ||
CalledWhen = "A player is editing a book.", | ||
DefaultFnName = "OnPlayerEditingBook", -- also used as pagename | ||
Desc = [[ | ||
This hook is called whenever a {{cPlayer|player}} is editing a book. | ||
See also the {{OnPlayerEditingBook|HOOK_PLAYER_EDITED_BOOK}} hook for a similar hook, is called when a | ||
player has edited a book. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add the note that the plugin may override the player edits by changing the NewContent parameter |
||
]], | ||
Params = | ||
{ | ||
{ Name = "Player", Type = "cPlayer", Notes = "The player that is editing the book" }, | ||
{ Name = "OriginalContent", Type = "cBookContent", Notes = "Contains the original content of the book" }, | ||
{ Name = "NewContent", Type = "cBookContent", Notes = "Contains the new content of the book" }, | ||
{ Name = "IsSigned", Type = "boolean", Notes = "Player is signing the book" }, | ||
}, | ||
Returns = [[ | ||
If the function returns false or no value, Cuberite calls other plugins with this event. If the function returns true, | ||
no other plugin's callback is called and the editing of the book is denied. | ||
]], | ||
}, -- HOOK_PLAYER_EDITING_BOOK | ||
} | ||
|
||
|
||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sets