Date: 2016/01/08 21:06:19 UTC-08:00
Type: Denizen Script
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
Bookshelves:
type: world
Whitelist:
- map
- empty_map
- book
- book_and_quill
- paper
- written_book
events:
on player right clicks bookshelf:
- determine passively CANCELLED
- define shelflocation <context.location.simple>
- define userlist <context.location.find.players.within[5].filter[open_inventory.is[==].to[in@shelf_<def[shelflocation]>]]>
- if <def[userlist].size> > 0 {
- narrate "<&4><def[userlist].get[1].name> is already using that!"
- queue clear
}
- if <server.list_notables[inventories].parse[notable_name].contains[shelf_<def[shelflocation]>].not> {
- note "in@generic[size=27;title=Book Shelf]" as:shelf_<def[shelflocation]>
}
- inventory open d:in@shelf_<def[shelflocation]>
on player breaks bookshelf:
- define brokenshelf shelf_<context.location.simple>
- if <server.list_notables[inventories].parse[notable_name].contains[<def[brokenshelf]>].not||true> {
- determine i@bookshelf
- queue clear
}
- if <def[brokenshelf].as_inventory.list_contents> > 0 {
- determine <def[brokenshelf].as_inventory.list_contents.full.include[i@bookshelf]>
} else {
- determine i@bookshelf
}
on player clicks in inventory:
- if <player.gamemode.is[==].to[CREATIVE]> queue clear
- if <context.inventory.notable_name.starts_with[shelf_].not||true> queue clear
- if <context.raw_slot.is[MORE].than[27]> queue clear
- if <script.yaml_key[Whitelist].contains[<c.item.material.name>].not> {
- narrate "<&4>You can't place that in a bookshelf!"
- determine CANCELLED
}