Date: 2014/06/06 06:04:28 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
################################################################################
# #
# M o b S p a w n L i m i t M a n a g e r #
# #
# #
# A system for setting how many mobs are able to spawn per chunk in each world #
# #
# Features a dynamic command handler. Command arguments can be supplied in any #
# order. Syntax checking and error handeling included. #
# #
################################################################################
'MobSpawnManagerTasks':
type: task
debug: false
script:
- define worlds <server.list_worlds>
- if %world% != null {
- if !<def[worlds].contains[<def[world].as_world>]> {
- narrate "<&4><&l>ERROR<&co><&r> <&a><def[world]> <&b>does not exist"
- queue stop
}
- define worlds <def[world].as_world>
}
- define types 'ambient|animal|monster|water_animal'
- if %type% != null {
- if !<def[types].as_list.contains[<def[type]>]> {
- narrate "<&4><&l>ERROR<&co><&r> <&a><def[type]> <&b>is not a valid type"
- queue stop
}
- define types <def[type]>
}
set:
- define worlds <server.list_worlds>
- if %world% != null {
- if !<def[worlds].contains[<def[world].as_world>]> {
- narrate "<&4><&l>ERROR<&co><&r> <&a><def[world]> <&b>does not exist"
- queue stop
}
}
else {
- narrate "<&4><&l>ERROR<&co><&r> <&b>Must specify a world"
- narrate format:CmdSynFormat "/mslimit -w \<<\>world\<>\>"
- queue stop
}
- define types 'ambient|animal|monster|water_animal'
- if %type% != null {
- if !<def[types].as_list.contains[<def[type]>]> {
- narrate "<&4><&l>ERROR<&co><&r> <&a><def[type]> <&b>is not a valid type"
- queue stop
}
}
else {
- narrate "<&4><&l>ERROR<&co><&r> <&b>Must specify a type"
- narrate format:CmdSynFormat "/mslimit -t \<<\>type\<>\>"
- queue stop
}
- if %limit% != null {
- if !<def[limit].is[matches].to[integer]> {
- narrate "<&4><&l>ERROR<&co><&r> <&a><def[limit]> <&b>is not a valid number"
- queue stop
}
- define limit <def[limit].abs.as_int>
}
else {
- narrate "<&4><&l>ERROR<&co><&r> <&b>Must specify a limit"
- narrate format:CmdSynFormat "/mslimit -l \<<\>limit\<>\>"
- queue stop
}
- adjust <def[world].as_world> %type%_spawn_limit:<def[limit]>
list:
- inject s@MobSpawnManagerTasks
- foreach <def[worlds].as_list> {
- define world %value%
- narrate "<&6><&l><def[world].name> Spawn Limits"
- foreach <def[types].as_list> {
- narrate "<&sp><&sp><&sp><&b><def[value].to_titlecase><&co> <&a><def[world].<def[value]>_spawn_limit>"
}
- narrate ""
}
'MobSpawnManagerCommand':
# The command handler. Accepts the command and passes the info to the task scripts
type: world
debug: true
events:
on mslimit command:
- if !<player.has_permission[denizen.cmdtest]> queue stop
- determine passively fulfilled
- define list '<tern[<context.args.contains[-ls]>]:true||<tern[<context.args.contains[--list]>]:true||false>>'
- define set '<tern[<context.args.contains[-s]>]:true||<tern[<context.args.contains[--set]>]:true||false>>'
- define world '<tern[<c.args.find[-w].is[MORE].than[0]>]:<c.args.get[<c.args.find[-w].add[1].as_int>]> || null>'
- define type '<tern[<c.args.find[-t].is[MORE].than[0]>]:<c.args.get[<c.args.find[-t].add[1].as_int>]> || null>'
- define limit '<tern[<c.args.find[-l].is[MORE].than[0]>]:<c.args.get[<c.args.find[-l].add[1].as_int>]> || null>'
- if %list% == true {
- inject s@MobSpawnManagerTasks p:list
- queue stop
}
- if %set% == true {
- inject s@MobSpawnManagerTasks p:set
- queue stop
}