@@ -55,6 +55,13 @@ object AgroNet : ModInitializer {
55
55
// Proceed with mild caution.
56
56
57
57
serverName = getEnvOrDefault(" SERVER_NAME" , InetAddress .getLocalHost().hostName)
58
+ if (serverName.contains(" dungeon-" )) {
59
+ // dungeon-1 -> d801
60
+ // dungeon-14 -> d814
61
+ val dungeonId = serverName.replace(" dungeon-" , " " )
62
+ serverName = " d8${dungeonId.padStart(2 , ' 0' )} "
63
+ }
64
+
58
65
val dungaAPIPath = getEnvOrDefault(" DUNGA_API" , " http://localhost:3000/v1" )
59
66
60
67
logger.info(" Agronet server name: $serverName (run ID: ${runContext.runId} )" )
@@ -106,84 +113,90 @@ object AgroNet : ModInitializer {
106
113
val removeDeckFromPlayerInventoryAction = RemoveDeckFromPlayerInventoryAction ()
107
114
108
115
CommandRegistrationCallback .EVENT .register { dispatcher, _, _ ->
109
- dispatcher.register(literal(" take-shulker" )
110
- .requires { it.hasPermissionLevel(2 ) } // Command Blocks have permission level of 2
111
- .executes { context ->
112
- val player = context.source.player
113
- if (player != null ) {
114
- removeDeckFromPlayerInventoryAction.execute(player)
115
- } else {
116
- logger.warn(" Attempting to take shulker but command is not run as a player, ignoring..." )
116
+ dispatcher.register(
117
+ literal(" take-shulker" )
118
+ .requires { it.hasPermissionLevel(2 ) } // Command Blocks have permission level of 2
119
+ .executes { context ->
120
+ val player = context.source.player
121
+ if (player != null ) {
122
+ removeDeckFromPlayerInventoryAction.execute(player)
123
+ } else {
124
+ logger.warn(" Attempting to take shulker but command is not run as a player, ignoring..." )
125
+ }
126
+
127
+ 1
117
128
}
118
-
119
- 1
120
- }
121
129
)
122
130
}
123
131
124
132
CommandRegistrationCallback .EVENT .register { dispatcher, _, _ ->
125
- dispatcher.register(literal(" gief-shulker" )
126
- .requires { it.hasPermissionLevel(2 ) } // Command Blocks have permission level of 2
127
- .executes { context ->
128
- val player = context.source.player
129
- if (player != null ) {
130
- addDeckToPlayerInventoryAction.execute(context.source, player)
131
- } else {
132
- logger.warn(" Attempting to give shulker but command is not run as a player, ignoring..." )
133
- }
134
-
135
- 1
136
- })
133
+ dispatcher.register(
134
+ literal(" gief-shulker" )
135
+ .requires { it.hasPermissionLevel(2 ) } // Command Blocks have permission level of 2
136
+ .executes { context ->
137
+ val player = context.source.player
138
+ if (player != null ) {
139
+ addDeckToPlayerInventoryAction.execute(context.source, player)
140
+ } else {
141
+ logger.warn(" Attempting to give shulker but command is not run as a player, ignoring..." )
142
+ }
143
+
144
+ 1
145
+ })
137
146
}
138
147
139
148
val logEventCommand = LogEventCommand (eventsApi)
140
149
141
150
CommandRegistrationCallback .EVENT .register { dispatcher, _, _ ->
142
- dispatcher.register(literal(" log-event" )
143
- .requires { it.hasPermissionLevel(2 ) } // Command Blocks have permission level of 2
144
- .then(
145
- argument(" event" , StringArgumentType .word()) // words_with_underscores
146
- .executes(logEventCommand::run)
147
- .then(
148
- argument(
149
- " count" , // Number of units for this event
150
- IntegerArgumentType .integer(1 )
151
+ dispatcher.register(
152
+ literal(" log-event" )
153
+ .requires { it.hasPermissionLevel(2 ) } // Command Blocks have permission level of 2
154
+ .then(
155
+ argument(" event" , StringArgumentType .word()) // words_with_underscores
156
+ .executes(logEventCommand::run)
157
+ .then(
158
+ argument(
159
+ " count" , // Number of units for this event
160
+ IntegerArgumentType .integer(1 )
161
+ )
162
+ .executes(logEventCommand::run)
151
163
)
152
- .executes(logEventCommand::run)
153
- )
154
- )
164
+ )
155
165
)
156
166
}
157
167
158
168
val cardInteractionCommand = CardInteractionCommand (inventoryApi, eventsApi, serverName)
159
169
160
170
listOf (" card-bought" , " card-played" , " card-available" ).forEach { action ->
161
171
CommandRegistrationCallback .EVENT .register { dispatcher, _, _ ->
162
- dispatcher.register(literal(action)
163
- .requires { it.hasPermissionLevel(2 ) } // Command Blocks have permission level of 2
164
- .then(
165
- argument(" card" , StringArgumentType .word()) // words_with_underscores
166
- .executes { context ->
167
- cardInteractionCommand.run (context, action)
168
- }
169
- )
172
+ dispatcher.register(
173
+ literal(action)
174
+ .requires { it.hasPermissionLevel(2 ) } // Command Blocks have permission level of 2
175
+ .then(
176
+ argument(" card" , StringArgumentType .word()) // words_with_underscores
177
+ .executes { context ->
178
+ cardInteractionCommand.run (context, action)
179
+ }
180
+ )
170
181
)
171
182
}
172
183
}
173
184
174
185
val itemInteractionCommand = CardInteractionCommand (inventoryApi, eventsApi, serverName)
175
186
listOf (" add-item" ).forEach { action ->
176
187
CommandRegistrationCallback .EVENT .register { dispatcher, _, _ ->
177
- dispatcher.register(literal(action)
178
- .requires { it.hasPermissionLevel(2 ) } // Command Blocks have permission level of 2
179
- .then(
180
- argument(" card" , StringArgumentType .word())
181
- .then(argument(" count" , IntegerArgumentType .integer(1 ))
182
- .executes { context ->
183
- itemInteractionCommand.run (context, action)
184
- }
185
- )
186
- )
188
+ dispatcher.register(
189
+ literal(action)
190
+ .requires { it.hasPermissionLevel(2 ) } // Command Blocks have permission level of 2
191
+ .then(
192
+ argument(" card" , StringArgumentType .word())
193
+ .then(
194
+ argument(" count" , IntegerArgumentType .integer(1 ))
195
+ .executes { context ->
196
+ itemInteractionCommand.run (context, action)
197
+ }
198
+ )
199
+ )
187
200
)
188
201
}
189
202
}
@@ -199,28 +212,31 @@ object AgroNet : ModInitializer {
199
212
// }
200
213
201
214
CommandRegistrationCallback .EVENT .register { dispatcher, _, _ ->
202
- dispatcher.register(literal(" update-workers" )
203
- .requires(Permissions .require(" trackedout.serveradmin.update-workers" , 4 ))
204
- .executes { context ->
205
- sendRedisMessage(context.source, " server-hosts" , " update-workers" )
206
- 1
207
- })
215
+ dispatcher.register(
216
+ literal(" update-workers" )
217
+ .requires(Permissions .require(" trackedout.serveradmin.update-workers" , 4 ))
218
+ .executes { context ->
219
+ sendRedisMessage(context.source, " server-hosts" , " update-workers" )
220
+ 1
221
+ })
208
222
}
209
223
210
224
CommandRegistrationCallback .EVENT .register { dispatcher, _, _ ->
211
- dispatcher.register(literal(" update-datapack" )
212
- .requires(Permissions .require(" trackedout.update-datapack" , 2 ))
213
- .executes { context ->
214
- sendRedisMessage(context.source, " datapack-updates" , " request-update" )
215
- 1
216
- })
225
+ dispatcher.register(
226
+ literal(" update-datapack" )
227
+ .requires(Permissions .require(" trackedout.update-datapack" , 2 ))
228
+ .executes { context ->
229
+ sendRedisMessage(context.source, " datapack-updates" , " request-update" )
230
+ 1
231
+ })
217
232
}
218
233
219
234
if (! serverName.equals(" builders" , ignoreCase = true )) {
220
235
CommandRegistrationCallback .EVENT .register { dispatcher, _, _ ->
221
- dispatcher.register(literal(" is-dungeon-instance" )
222
- .requires { it.hasPermissionLevel(2 ) } // Command Blocks have permission level of 2
223
- .executes { _ -> 1 })
236
+ dispatcher.register(
237
+ literal(" is-dungeon-instance" )
238
+ .requires { it.hasPermissionLevel(2 ) } // Command Blocks have permission level of 2
239
+ .executes { _ -> 1 })
224
240
}
225
241
}
226
242
@@ -237,7 +253,7 @@ object AgroNet : ModInitializer {
237
253
}
238
254
239
255
if (! serverName.equals(" builders" , ignoreCase = true )) {
240
- val scoreListener = AgroNetPlayerConnectionListener (scoreApi, claimApi, runContext, addDeckToPlayerInventoryAction)
256
+ val scoreListener = AgroNetPlayerConnectionListener (scoreApi, claimApi, addDeckToPlayerInventoryAction)
241
257
ServerPlayConnectionEvents .JOIN .register(scoreListener)
242
258
ServerPlayConnectionEvents .DISCONNECT .register(scoreListener)
243
259
ResourceManagerHelper .get(ResourceType .SERVER_DATA ).registerReloadListener(scoreListener)
0 commit comments