Date: 2016/04/04 19:04:27 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
################################################################################
#
# d W o r l d M a n a g e r
#
#
# Authors: |Anthony|
# Version: 0.1
# dScript Version: 0.9.8-DEV-b554
#
#
#
#--- About this script
#
# dWorldManager is a world management system written with the Denizen
# Scripting Engine. It is meant to take the place of existing world management
# plugins such as MultiVerse for those of us who want a pure Denizen Server.
#
# This is a very early ALPHA version of dWorldManager. Currently it will track
# new worlds as they are created and automatically make sure that they are
# loaded when the server starts. It provides no commands and no configurations
# at this time, though features will be added in the future.
#
#
#_______________________________________________________________________________
#
# Dependencies:
#
# - ConfigFileGenerator
# - Used to build default config files and data storage.
# - https://github.com/AnthonyAMC/Public-Denizen-Scripts/blob/master/ConfigFileGenerator.yml
#
# - MessageConstructorLibrary
# - Used for all message output
# - https://github.com/AnthonyAMC/Public-Denizen-Scripts/blob/master/MessageConstructors.yml
#
#
#_______________________________________________________________________________
#
# Command Permission Description
#
# /dwm help [arg/#] dwm.help Get help.
#
#
# TODO:
#
#
################################################################################
#
# dWorldManager Version
#
# Handles dWM Versioning Checks
#
dWM_Version:
type: version
author: Anthony
name: dWorldManager
version: 0.1
description: Denizen World Manager
id: 93
#
# END dWorldManager Version
#--------------------------------------
#
#
################################################################################
#
# dWorldManager Events
#
# This should cover all dWM related world events.
#
dWM_Events:
type: world
debug: false
events:
on server prestart:
- inject locally loadYaml
- foreach <server.list_worlds.parse[name]> {
- if !<yaml[dWM_Config].list_keys[worlds].contains[%value%]||false> {
- run s@msgPrefixed 'def:dWM|<&3>Adding %value% to the config file...'
- yaml set 'worlds.%value%.loaded:true' 'id:dWM_Config'
- yaml 'savefile:dWorldManager/config.yml' 'id:dWM_Config'
}
}
- foreach '<yaml[dWM_Config].list_keys[worlds]||li@>' {
- if <yaml[dWM_Config].read[worlds.%value%.loaded]||true> {
- createworld '%value%'
}
}
on server shutdown:
- yaml 'savefile:dWorldManager/config.yml' 'id:dWM_Config'
on world loads:
- if !<yaml[dWM_Config].list_keys[worlds].contains[<context.world.name>]||false> {
- run s@msgPrefixed 'def:dWM|<&3>Adding <context.world.name> to the config file...'
- yaml set 'worlds.<context.world.name>.loaded:true' 'id:dWM_Config'
- yaml 'savefile:dWorldManager/config.yml' 'id:dWM_Config'
}
on world initializes:
- if !<yaml[dWM_Config].list_keys[worlds].contains[<context.world.name>]||false> {
- run s@msgPrefixed 'def:dWM|<&3>Adding <context.world.name> to the config file...'
- yaml set 'worlds.<context.world.name>.loaded:true' 'id:dWM_Config'
- yaml 'savefile:dWorldManager/config.yml' 'id:dWM_Config'
}
loadYaml:
# Reloads the yaml files and generates default files if they don't exist.
# Rewrites config files that do not match internal version number!
- run s@msgPrefixed 'def:dWM|<&3>Loading system config files...'
- if !<server.has_file[dWorldManager/config.yml]> {
- inject locally createConfigFile
- run s@msgPrefixed 'def:dWM|<&7><&o>Created config file!'
}
- if <yaml.list.contains[dWM_Config]> {
- yaml unload 'id:dWM_Config'
}
- yaml 'load:dWorldManager/config.yml' 'id:dWM_Config'
- if <yaml[dWM_Config].read[config.version].is[!=].to[<s@dWM_Configurations.yaml_key[config.version]>]||false> {
- define isUpdate ''
- inject locally createConfigFile
- define isUpdate:!
- run s@msgPrefixed 'def:dWM|<&7><&o>Updated config file!'
}
- run s@msgPrefixed 'def:dWM|<&a>System config files Loaded!'
reloadYaml:
# A simpler reload
- run s@msgPrefixed 'def:dWM|<&7><&o>Reloading system config files...'
- if <yaml.list.contains[dWM_Config]> {
- yaml unload 'id:dWM_Config'
}
- yaml 'load:dWorldManager/config.yml' 'id:dWM_Config'
- run s@msgPrefixed 'def:dWM|<&7><&o>System config files Loaded!'
createConfigFile:
- define readID 'dWM_Configurations'
- define writeID 'dWM_Config'
- if !<yaml.list.contains[%readID%]> {
- yaml fix_formatting 'load:<script.relative_filename>' 'id:%readID%'
}
- if !<yaml.list.contains[%readID%]> {
- run s@msgPrefixed 'def:dWM|<&7><&o>Loaded <script.relative_filename>'
}
- yaml create 'id:%writeID%'
- define readPath '%readID%.config'
- define writePath 'config'
- if <def[isUpdate].exists||false> {
- run s@ConfigFileGenerator 'def:%readID%|%writeID%|%readPath%|%writePath%|false|false|true' instantly
}
else {
- run s@ConfigFileGenerator 'def:%readID%|%writeID%|%readPath%|%writePath%|false|false|false' instantly
}
- yaml unload 'id:%readID%'
- yaml 'savefile:dWorldManager/config.yml' 'id:%writeID%'
#
# END dWorldManager Events
#--------------------------------------
#
#
################################################################################
################################################################################
# #
# Configuration Files #
# #
# These are the default config files. They will be used to build the default #
# configuration and data storage files. #
# #
#______________________________________________________________________________#
# #
#______________________________DO_NOT_EDIT_THIS_DATA___________________________#
#______________________________________________________________________________#
dWM_Configurations:
type: yaml data
config:
version: 0.1
worlds: {}
#
# END dWorldManager Events
#--------------------------------------
#
#
################################################################################