Date: 2017/01/30 12:24:20 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
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
WorldEvents:
type: world
debug: false
events:
on player enters cuboid1:
- adjust <player> send_to:server@shift1
on player enters cuboid2:
- adjust <player> send_to:server@shift2
on player enters cuboid3:
- adjust <player> send_to:server@shift3
on player enters cuboid4:
- adjust <player> send_to:server@shift4
on system time 05:00:
- run safe_shutdown
on system time 11:00:
- run safe_shutdown
on system time 17:00:
- run safe_shutdown
on system time 23:00:
- run safe_shutdown
# Isn't this a nicer and neater way to do announcements?
on system time minutely:
- if <context.minute.mod[4]> == 0 {
- announce '<&2>=<&6>=<&2>=<&6>=<&2>=<&6>=<&2>=<&6>=<&2>=<&6>=<&2>-<&6>-<&2>-<&6>-<&2>-<&6>-<&2>-<&6>-<&2>-<&6>-<&2>-<&6>-<&2>-<&6>-<&2>-<&6>-<&2>-<&6>-<&2>-<&6>-<&2>-<&6>-<&2>-<&6>-<&2>-<&6>-<&2>-<&6>-<&2>-<&6>-<&2>-<&6>-<&2>=<&6>=<&2>=<&6>=<&2>=<&6>=<&2>=<&6>=<&2>=<&6>='
- random {
- announce ' <&a><&l>Welcome to the XPCraft Server!'
- announce ' <&a>Type /vote for voting links!'
- announce ' <&a>Use the server selector or portals to play games!'
- announce ' <&a>Sign up on our forums at www.xpcraft.com!'
- announce ' <&a>Click the tutorial holograms to learn about our games!'
- announce '<&a>Use coupon code XPCRAFT for 50% off any store purchases!'
}
- announce '<&2>=<&6>=<&2>=<&6>=<&2>=<&6>=<&2>=<&6>=<&2>=<&6>=<&2>-<&6>-<&2>-<&6>-<&2>-<&6>-<&2>-<&6>-<&2>-<&6>-<&2>-<&6>-<&2>-<&6>-<&2>-<&6>-<&2>-<&6>-<&2>-<&6>-<&2>-<&6>-<&2>-<&6>-<&2>-<&6>-<&2>-<&6>-<&2>-<&6>-<&2>-<&6>-<&2>=<&6>=<&2>=<&6>=<&2>=<&6>=<&2>=<&6>=<&2>=<&6>='
}
on restart command:
- if <context.server> || !<player.is_op> {
- queue clear
}
- determine cancelled passively
- run safe_shutdown
on stop command:
- if <context.server> || !<player.is_op> {
- queue clear
}
- determine cancelled passively
- run safe_shutdown
on shutdown command:
- if <context.server> || !<player.is_op> {
- queue clear
}
- determine cancelled passively
- run safe_shutdown
on weather rains in MainLobby:
- determine cancelled
on player quit:
- flag player messager:!
- wait 1t
- adjust <player> 'location:l@-54.5,52.1,-94.5,0,90,MainLobby'
on server start:
- run Player_Count_Refresh
- run locally spawnloc
- run locally start
start:
# SQLManager expects you to have this subscript so it can restart things if needed.
# It's also not a bad idea for you to have a command to restart your own script systems.
# The command simply runs the start subscript. Or maybe on scripts reloaded event too.
- define yamlName 'XPCore'
- define scriptName '<script.name>'
- if !<server.has_file[%yamlName%/config.yml]> {
- run s@ConfigFileGeneratorHelper def:%yamlName%|Configurations instantly
}
- if <yaml.list.contains[%yamlName%_config]> {
- yaml unload 'id:%yamlName%_config'
}
- yaml 'load:%yamlName%/config.yml' 'id:%yamlName%_config'
- define db '<yaml[%yamlName%_config].read[config.MySQL.database]||false>'
- inject s@XPCoreSQL
# This checks the status as set by SQLManager to not duplicate restart
# processes. This is the only time this script needs to set the status. The
# SQLManager will handle every other situation.
- repeat 5:
- if <yaml.list.contains[SQLManager_Offline].not> {
- announce to_console "XPCore<&co> Waiting for SQLManager to come online..."
- wait 1s
}
- if <yaml.list.contains[SQLManager_Offline].not> {
- announce to_console "XPCore<&co> SQLManager FAILED!"
- announce to_console "XPCore<&co> Aborting startup!"
- queue clear
}
- define status '<yaml[SQLManager_Offline].read[Offline_Cache.databases.%db%.status]||null>'
- if <def[status].is[==].to[connecting]> {
- announce "<&b>SQLManager<&co><&c> Already attempting to reconnect to %db% database!" to_console
}
else {
- yaml set 'id:SQLManager_Offline' 'Offline_Cache.databases.%db%.status:connecting'
- yaml 'savefile:SQLManager/cache.yml' 'id:SQLManager_Offline'
- inject s@SQLManager
}
# A place to do whatever you need to do to fully unload XPCore
# SQLManager runs this in the event that the DB goes offline and can not be reconnected to.
unload:
- ^if <yaml.list.contains[XPCore_config]> {
- announce "<&b>XPCore<&co><&3> Unloading config.yml file..." to_console
- yaml unload 'id:XPCore_config'
}
spawnloc:
- foreach <server.list_players>
- adjust <def[value]> 'location:l@-54.5,52.1,-94.5,0,90,MainLobby'
cuboids:
# You really shouldn't have to recreate cuboids on every server start
- note cu@-19,51,-114,Mainlobby|-19,58,-104,Mainlobby as:cuboid1
- note cu@-19,51,-86,Mainlobby|-19,38,-76,Mainlobby as:cuboid2
- note cu@-46,51,-59,Mainlobby|-36,58,-59,Mainlobby as:cuboid3
- note cu@-64,51,-59,Mainlobby|-74,58,-59,Mainlobby as:cuboid4
#### Just keep this in the same file it's totally sane i swear ####
XPCoreSQL:
type: task
debug: true
script:
- define sqlScriptName '<script.name>'
- define sqlFile '<script.relative_filename>'
- if <yaml.list.contains[%sqlScriptName%]> {
- yaml unload 'id:%sqlScriptName%'
}
- yaml 'load:%sqlFile%' 'id:%sqlScriptName%'
- if !<yaml.list.contains[%sqlScriptName%]> {
- announce "<&c>XPCore<&co><&b> An error occurred while loading %sqlScriptname%!" to_console
- announce "<&b>XPCore<&co><&3> Aborting..." to_console
- inject s@%scriptName% p:unload
}
tables:
XPCoreValues:
columns:
ID: INT NOT NULL AUTO_INCREMENT PRIMARY KEY
PLAYERUUID: varchar(255) NOT NULL UNIQUE
XP: int
CLAIMEDCODES: tinyint
RANK: varchar(25)
NORMALPACKS: TINYINT NOT NULL DEFAULT '0'
SUPERPACKS: TINYINT NOT NULL DEFAULT '0'
MEDALLIONS: INT NOT NULL DEFAULT '0'
PLAYPOINTS: INT NOT NULL DEFAULT '0'
TOURNAMENTPOINTS: SMALLINT NOT NULL DEFAULT '0'
# Install CFG https://www.spigotmc.org/resources/denizen-confgfilegenerator.26837/ #
XPCore_Configurations:
type: yaml data
config:
MySQL:
connection:
retry: 3
retryDelay: 10s
keepAlive: 5m
host: localhost
port: 3306
username: root
password: goeatachode
database: Server
tables:
XPCoreValues: XPCore