Date: 2020/08/17 02:07:52 UTC-07: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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
#******************************************************#
# Warp Script with added Lodestone functionality #
# Allows users to create and set warps, as well as #
# introducing Lodestones as warp points #
#******************************************************#
# Original script by Seq: #
# https://one.denizenscript.com/denizen/repo/entry/67 #
# Adapted by Astrash #
#******************************************************#
#======================================================#
# - Permissions: (to be changed) #
# - warps.setwarp (Create new warps.) #
# - warps.delwarp (Delete existing warps.) #
# - warps.warp (Teleport to warps.) #
#======================================================#
#TODO
#--------------
#Redo permissions
#Add cost to teleport based on distance between warps
#Update GUI to include an interactive warp list
#Allow for chat messages to be modified using an external lang file
#Add logic to opening lodestone to check if a warp already exists there
#Ensures that the warps yaml file is always loaded, and saved upon server start, and script reload
warpdata_handler:
type: world
debug: true
events:
#Handling loading / unloading the warps.yml data file
on server start:
- if <server.has_file[/astdata/warps.yml]>:
- yaml "load:/astdata/warps.yml" id:warps
- else:
- yaml create id:warps
on shutdown:
#The below check is only necessary if id:warps is manually unloaded
- if <yaml.list.contains[warps]>:
- yaml id:warps "savefile:/astdata/warps.yml"
#Probs not necessary
- yaml unload id:warps
on pre script reload:
- if <yaml.list.contains[warps]>:
- yaml id:warps "savefile:/astdata/warps.yml"
#Probs not necessary
- yaml unload id:warps
on script reload:
- if <server.has_file[/astdata/warps.yml]>:
- yaml "load:/astdata/warps.yml" id:warps
- else:
- yaml create id:warps
#==============#
#---SETWARP----#
#==============#
setwarp_command:
type: command
debug: false
name: dsetwarp
aliases:
- dcreatewarp
usage: /dsetwarp <<>name<>>
description: Set new warp or set new location if it exists already.
permission: warps.setwarp
allowed help:
- determine <player.has_permission[warps.setwarp]||<player.is_op>>
script:
#Who can use the command
- if <context.server>:
- announce to_console "<&c>This command is for players only."
- queue clear
- if <player.has_permission[warps.setwarp].not||true>:
- narrate "<&c>Sorry, you don't have permission to use this command."
- queue clear
#Command usage
- define Args <context.args>
- if <def[Args].size> == 0:
- narrate "<&c>Please specify warp name!"
- queue clear
#Logic for successful setwarp
- yaml id:warps set "<context.raw_args>.location:<player.location.simple>"
- yaml id:warps set "<context.raw_args>.setby:<player.uuid>"
- yaml id:warps set "<context.raw_args>.type:generic"
- yaml id:warps "savefile:/astdata/warps.yml"
- narrate "<&2>Warp added!"
#==============#
#---DELWARP----#
#==============#
delwarp_command:
type: command
debug: false
name: ddelwarp
aliases:
- dremwarp
- drmwarp
usage: /ddelwarp <<>name<>>
description: Set new warp or set new location if it exists already.
permission: warps.delwarp
allowed help:
- determine <player.has_permission[warps.delwarp]||<player.is_op>>
script:
#Who can use the command
- if <context.server>:
- announce to_console "<&c>This command is for players only."
- queue clear
- if <player.has_permission[warps.delwarp].not||true>:
- narrate "<&c>Sorry, you don't have permission to use this command."
- queue clear
#Command usage
- define Args <context.args>
- if <def[Args].size> == 0:
- narrate "<&c>Please specify warp name!"
- queue clear
- if <yaml[warps].contains[<context.raw_args>]>:
- yaml id:warps set "<context.raw_args>:!"
- yaml id:warps "savefile:/astdata/warps.yml"
- narrate "<&2>Warp removed!"
- else:
- narrate "<&4>Could not find <&e><&l><context.raw_args><&4>!"
#==============#
#-----WARP-----#
#==============#
warp_command:
type: command
debug: false
name: dwarp
aliases:
- dwarps
usage: /dwarp (warp name)
description: Teleport to specific warp if it exists or list warps.
permission: warps.warp
allowed help:
- determine <player.has_permission[warps.warp]||<player.is_op>>
script:
#Who can use the command
- if <context.server>:
- announce to_console "<&c>This command is for players only."
- queue clear
- if <player.has_permission[warps.warp].not||<player.is_op.not>>:
- narrate "<&c>Sorry, you don't have permission to use this command."
- queue clear
#Command usage
- define Args <context.args>
- if <def[Args].size> == 0:
#If no arguments are given try list available warps
- narrate "<&6><&n>Warps"
- if <yaml[warps].list_keys[].is_empty>:
- narrate "<&c>Warps have not been set!"
- queue clear
- else:
#Might change to list warps on one line, rather than 1 warp per line
- define WarpsList <yaml[warps].list_keys[]>
- foreach <def[WarpsList]>:
- narrate "<[value]>"
- else:
#If an argument is given
- if <yaml[warps].contains[<context.raw_args>]>:
- define target_location <yaml[warps].read[<context.raw_args>.location].as_location>
#Checking if the warp requires a lodestone
- if <yaml[warps].read[<context.raw_args>.type]> == "lodestone":
- if <def[target_location].below.material.name> != lodestone:
- narrate "Failed to find warp, the lodestone must have been destroyed!"
- queue clear
#Successful warp!
- narrate "Teleporting to <context.raw_args>"
- title "title:<&chr[eff7]>" fade_in:4 stay:1 fade_out:0.5
- flag player teleporting:true
- wait 4
- teleport <player> <def[target_location].add[0.5,0,0.5]>
- flag player teleporting:false
- else:
- narrate "<&c>Sorry, <&e><&l><context.raw_args><&c> was not found!"
lodestone_handler:
type: world
debug: true
events:
on player right clicks lodestone:
- if <context.item.material.name> != compass:
- inventory open d:lodestone_menu
#Prevents players from initiating setting a warp then opening another lodestone and setting the warp there
- if <player.flag[lodestone_settingwarp]>:
- flag player lodestone_settingwarp:false
- narrate "Cancelled warp set: Lodestone menu opened!"
- flag player lodestone_open_location:<context.location>
on player closes lodestone_menu:
#If the player is not setting a warp, remove open location from player flags
- if <player.flag[lodestone_settingwarp]> != true:
- flag player lodestone_open_location:!
on player clicks in lodestone_menu:
#If the player clicks middle slot (setup with custom UI) to set a warp, set 'settingwarp' to true, and close the menu
- if <context.raw_slot> == 5:
- flag player lodestone_settingwarp:true
- inventory close
- narrate "<red>Type warp name:"
on player chats:
- if <player.flag[lodestone_settingwarp]>:
#Setting the warp in yaml file to the players lodestone open location, named after what they put in chat
- yaml id:warps set "<context.message>.location:<player.flag[lodestone_open_location].as_location.add[0,1,0].simple>
- yaml id:warps set "<context.message>.setby:<player.uuid>"
- yaml id:warps set "<context.message>.type:lodestone"
- yaml id:warps "savefile:/astdata/warps.yml"
- narrate "Warp <bold><yellow><context.message> <white>set."
#Reset lodestone flags
- flag player lodestone_settingwarp:false
- flag player lodestone_open_location:!
- determine cancelled
lodestone_menu:
type: inventory
inventory: chest
title: <white><&chr[f808]><&chr[eff8]>
size: 9
slots:
- [] [] [] [] [] [] [] [] []